The ALL function determines whether all values in a logical mask are true either for an entire mask or along a given dimension of the mask.

## Syntax

ALL (mask [,dim])

mask is an INTENT(IN) array of type LOGICAL. It cannot be scalar.

dim is an INTENT(IN) scalar INTEGER with a value within the range
*dim* ≤ n

The result is of type LOGICAL and the same kind as MASK. Its value and rank are determined as follows:

- The function will return a scalar logical value if
*mask*has rank one, or if*dim*is absent. The result has the value true if all elements of*mask*are true. - The function will return a logical array of rank n-1 if
*dim*is present and*mask*has rank two or greater. The resulting array is of shape (*d*where (_{1},d_{2}, ...,d_{dim-1},d_{dim+1}, ...,d_{n})*d*is the shape of_{1},d_{2}, ...,d_{n})*mask*and n is the rank of*mask*. The result has the value true for each corresponding vector in*mask*that evaluates to true for all elements in that vector.

## Example 1

real, dimension(4) :: o=0.,p=1.,q=(/1.,-2.,3.,4./) if (all(q /= 0.)) o=p/q write(*,*) o ! writes 1.000000 -.5000000 .3333333 .2500000## Example 2

integer, dimension (2,3) :: a, b a = reshape((/1,2,3,4,5,6/), (/2,3/)) write(*,'(2i3)') a ! writes 1 2 ! 3 4 ! 5 6 b = reshape((/1,2,3,5,6,4/), (/2,3/)) write(*,'(2i3)') b ! writes 1 2 ! 3 4 ! 5 6 write(*,*) all(a==b) ! writes F write(*,*) all(a==b, 1)! writes T F F write(*,*) all(a==b, 2)! writes F F