Arrays
Array Reduce
Count With a Mask
Whole-array comparisons return a logical mask. count returns how many positions are .true..
Program
Play the program to count scores at or above 80.
array_reduce.f90
program array_reduce
implicit none
integer :: scores(5)
integer :: above
scores = [65, 82, 91, 74, 88]
above = count(scores >= 80)
print '(I0)', above
end program array_reduce
logical mask
`scores >= 80` produces a logical array.
count
`count(mask)` returns the number of `.true.` positions.
whole array op
Comparisons apply to every element at once.