Reputation: 41
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)?
Upvotes: 4
Views: 4919
Reputation: 60123
Just count the non-zero elements
print *, count(value/=0)
Upvotes: 8