Advertisements
I am new in fortran. I want to know, for example if I have an 1d array,
indices=(/1, 1, 1, 2 , 2 ,10, 11 /) and I want to know how many times 1 occur (answer should be 3), number 2 should be 2 times, num 10 should be 1 also number 11, . I already tried to find out if there is intrinsic function but ‘count’ function works differently.
>Solution :
You can use the count
intrinsic with a comparison operator, e.g.
integer :: indices(5)
indices = [1, 1, 1, 2, 2, 10, 11]
write(*,*) count(indices==1)