Counts the number of true array elements in an entire logical array, or in each vector along a single dimension. Typically, the logical array is one that is used as a mask in another intrinsic.

**MASK**- is a logical array.
**DIM (optional)**- is an integer scalar in the range 1 <= DIM <= rank(MASK). The corresponding actual argument must not be an optional dummy argument.

**Class**

Transformational function

**Result Value**

If DIM is present, the result is an integer array of rank rank(MASK)-1. If DIM is missing, or if MASK has a rank of one, the result is a scalar of type integer.

Each element of the resulting array (R(s_{1}, s_{2},
..., s_{(DIM-1)}, s_{(DIM+1)}, ..., s_{n}))
equals the number of elements that are true in MASK along the corresponding
dimension (s_{1}, s_{2}, ..., s_{(DIM-1)},
:, s_{(DIM+1)}, ..., s_{n}).

If MASK is a zero-sized array, the result equals zero.

**Examples**

```
! A is the array | T F F |, and B is the array | F F T |
! | F T T | | T T T |
! How many corresponding elements in A and B
! are equivalent?
RES = COUNT(A .EQV. B) ! result RES is 3
! How many corresponding elements are equivalent
! in each column?
RES = COUNT(A .EQV. B, DIM=1) ! result RES is (0,2,1)
! Same question, but for each row.
RES = COUNT(A .EQV. B, DIM=2) ! result RES is (1,2)
```