How to know the number of non-zero elements of a Fortran array?

arrays, fortran, size

Solution

Just count the non-zero elements

print *, count(value/=0)

Problem

So I have something like this: ``` INTEGER i REAL value(10) DO i = 1,5 value(i) = 1 ENDDO ``` So now my value = (1,1,1,1,1,0,0,0,0,0). What would be the function that gives size = 5 (the size of the array without the zeros)?

Original source