Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Sort Problem

JohnNichols
Valued Contributor II
156 Views

In Fortran - the input data files has five million entries

each entry is a integer from 0 to about 8000

I want to do a count of each of the 8000 elements in the five million entries

The vast majority will be zero so it there a way to do this is a sparse vector or array?

 

0 Kudos
1 Reply
mecej4
Black Belt
135 Views

There is no need to sort, at least not explicitly. Using an array provides the means to impose order.

Suppose the data file has been opened with unit number iu.

 

IMAX = 8000
allocate (icount(0:IMAX))
icount = 0
do
   read(iu,*,end=10)iv
   icount(iv)=icount(iv)+1
end do
10 continue

 

Reply