COUNT (mask [,dim] [,kind])
Class: Transformational function - Generic
Counts the number of true elements in an entire array or in a
specified dimension of an array.
The "mask" must be a logical array. The "dim" must be a scalar
integer with a value in the range 1 to n, where "n" is the rank of
"mask". The "kind" must be a scalar integer initialization
expression.
The result is integer. If "kind" is present, the kind parameter of
the result is that specified by "kind"; otherwise, the kind
parameter of the result is that of default integer. If the
processor cannot represent the result value in the kind of the
result, the result is undefined.
The result is a scalar if "dim" is absent or "mask" has rank one.
Otherwise, the result is an array with rank that is one less than
"mask", and shape (d1, d2,..., d"dim"-1, d"dim"+1,..., dn), where
(d1, d2,..., dn) is the shape of "mask".
The result of COUNT (mask) is a value equal to the number of true
elements of "mask". If mask has size zero, the result is zero.
If "mask" has rank one, COUNT (mask, dim) has the same value as
COUNT (mask). Otherwise, the value of element (s1, s2,...,
s"dim"-1, s"dim"+1,..., sn) of COUNT (mask, dim) is equal to COUNT
(mask (s1, s2,..., s"dim"-1, :, s"dim"+1, ...,sn).
Examples:
COUNT ((/.TRUE., .FALSE., .TRUE./)) has the value 2.
COUNT ((/.TRUE., .TRUE., .TRUE./)) has the value 3.
Consider the following arrays:
Array A Array B
|1 5 7| |0 5 7|
|3 6 8| |2 6 9|
COUNT (A .NE. B, DIM=1) has the value (2, 0, 1).
COUNT (A .NE. B, DIM=2) has the value (1, 2).