Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Sort Problem

JohnNichols
Valued Contributor III
343 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
Honored Contributor III
322 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

 

0 Kudos
Reply