Next: CPU_TIME, Previous: COSH, Up: Intrinsic Procedures
COUNT
— Count functionCOUNT(MASK [, DIM])
counts the number of .TRUE.
elements of
MASK along the dimension of DIM. If DIM is omitted it is
taken to be 1
. DIM is a scaler of type INTEGER
in the
range of 1 /leq DIM /leq n) where n is the rank of MASK.
RESULT = COUNT(MASK [, DIM])
MASK | The type shall be LOGICAL .
|
DIM | The type shall be INTEGER .
|
INTEGER
with rank equal to that of
MASK.
program test_count integer, dimension(2,3) :: a, b logical, dimension(2,3) :: mask a = reshape( (/ 1, 2, 3, 4, 5, 6 /), (/ 2, 3 /)) b = reshape( (/ 0, 7, 3, 4, 5, 8 /), (/ 2, 3 /)) print '(3i3)', a(1,:) print '(3i3)', a(2,:) print * print '(3i3)', b(1,:) print '(3i3)', b(2,:) print * mask = a.ne.b print '(3l3)', mask(1,:) print '(3l3)', mask(2,:) print * print '(3i3)', count(mask) print * print '(3i3)', count(mask, 1) print * print '(3i3)', count(mask, 2) end program test_count