Lahey/Fujitsu Fortran

# ANY Function

### Description

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

```Syntax

```

### Required Arguments

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

### Optional Arguments

dim is an INTENT(IN) scalar INTEGER with a value within the range 1 ≤ dim ≤ n , where n is the rank of mask. The corresponding actual argument cannot be an optional dummy argument.

### Result

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

1. 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 any element of mask is true.
2. 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 (d1,d2, ...,ddim-1,ddim+1, ...,dn) where (d1,d2, ...,dn) is the shape of 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 any element in that vector.
```Example 1
real,dimension(4) :: q=(/1.,-2.,3.,4./)
write(*,*) any(q < 0.) ! writes T
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(*,*) any(a==b)    ! writes T
write(*,*) any(a==b, 1) ! writes T T F
write(*,*) any(a==b, 2) ! writes T T```