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?
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