ALL(3) - [ARRAY:REDUCTION] Determines if all the values are true
result = all(mask [,dim])
function all(mask ,dim)logical(kind=KIND),intent(in) :: mask(..) integer,intent(in),optional :: dim logical(kind=KIND) :: all(..)
o MASK is a logical array o DIM is an integer o the result is a logical array if DIM is supplied, otherwise it is a logical scalar. It has the same characteristics as MASK
ALL(3) determines if all the values are true in MASK in the array along dimension DIM if DIM is specified; otherwise all elements are tested together.
This testing type is called a logical conjunction of elements of MASK along dimension DIM.
The mask is generally a logical expression, allowing for comparing arrays and many other common operations.
o MASK : the logical array to be tested for all elements being .true. o DIM : DIM indicates the direction through the elements of MASK to group elements for testing. : DIM has a value that lies between one and the rank of MASK. The corresponding actual argument shall not be an optional dummy argument. : If DIM is not present all elements are tested and a single scalar value is returned.
1. If DIM is not present ALL(MASK) is .true. if all elements of MASK are .true.. It also is .true. if MASK has zero size; otherwise, it is .false. . 2. If the rank of MASK is one, then ALL(MASK, DIM) is equivalent to ALL(MASK). 3. If the rank of MASK is greater than one and DIM is present then ALL(MASK,DIM) returns an array with the rank (number of dimensions) of MASK minus 1. The shape is determined from the shape of MASK where the DIM dimension is elided. A value is returned for each set of elements along the DIM dimension.
Sample program:
program demo_all implicit none logical,parameter :: T=.true., F=.false. logical boolResults:! basic usage ! is everything true? bool = all([ T,T,T ]) print *, are all values true?, bool bool = all([ T,F,T ]) print *, are all values true now?, bool
! compare matrices, even by a dimension ARRAYS: block integer :: a(2,3), b(2,3) ! set everything to one except one value in b a = 1 b = 1 b(2,2) = 2 ! now compare those two arrays print *,entire array :, all(a == b ) print *,compare columns:, all(a == b, dim=1) print *,compare rows:, all(a == b, dim=2) end block ARRAYS
end program demo_all
> T > F > entire array : F > compare columns: T F T > compare rows: T F
Fortran 95
ANY(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | all (3fortran) | November 02, 2024 |