Intel® Fortran Compiler 18.0 Developer Guide and Reference
Transformational Intrinsic Function (Generic): Determines if any value is true in an entire array or in a specified dimension of an array.
result = ANY (mask [, dim])
mask |
(Input) Must be a logical array. |
dim |
(Input; optional) Must be a scalar integer expression with a value in the range 1 to n, where n is the rank of mask. |
The result is an array or a scalar of type logical.
The result is a scalar if dim is omitted or mask has rank one. A scalar result is true if any elements of mask are true. The result has the value false if no element of mask is true, or mask has size zero.
An array result has the same type and kind parameters as mask, and a rank that is one less than mask. Its shape is (d1, d2, ..., ddim-1, ddim+1, ..., dn), where (d1, d2, ..., dn) is the shape of mask.
Each element in an array result is true if any elements in the one dimensional array defined by mask(s1, s2, ..., sdim-1, :, sdim+1, ..., sn) are true.
LOGICAL mask( 2, 3), AR1(3), AR2(2)
logical, parameter :: T = .true.
logical, parameter :: F = .false.
DATA mask /T, T, F, T, F, F/
! mask is true false false
! true true false
AR1 = ANY(mask,DIM = 1) ! evaluates the elements column by
! column yielding [true true false]
AR2 = ANY(mask,DIM = 2) ! evaluates the elements row by row
! yielding [true true]
ANY ((/.FALSE., .FALSE., .TRUE./)) has the value true because one element is true.
A is the array
[ 1 5 7 ] [ 3 6 8 ]
and B is the array
[ 0 5 7 ] [ 2 6 9 ].
ANY (A .EQ. B, DIM=1) tests to see if any elements in each column of A are equal to the elements in the corresponding column of B. The result has the value (false, true, true) because the second and third columns have at least one element that is equal.
ANY (A .EQ. B, DIM=2) tests to see if any elements in each row of A are equal to the elements in the corresponding row of B. The result has the value (true, true) because each row has at least one element that is equal.