Manual Reference Pages  - iany (3fortran)

NAME

IANY(3) - [BIT:LOGICAL] Bitwise OR of array elements

SYNOPSIS

result = iany(array [,mask]) | iany(array ,dim [,mask])

         integer(kind=KIND) function iany(array,dim,mask)

integer(kind=KIND),intent(in) :: array(..) integer(kind=**),intent(in),optional :: dim logical(kind=**),intent(in),optional :: mask(..)

CHARACTERISTICS

o ARRAY is an integer array
o DIM may be of any integer kind.
o MASK is a logical array that conforms to ARRAY
o The result will by of the same type and kind as ARRAY. It is scalar if DIM does not appear or is 1. Otherwise, it is the shape and rank of array reduced by the dimension DIM.
note a kind designated as ** may be any supported kind for the type

DESCRIPTION

IANY(3) reduces with bitwise OR (inclusive OR) the elements of ARRAY along dimension DIM if the corresponding element in MASK is .true..

OPTIONS

o ARRAY : an array of elements to selectively OR based on the mask.
o DIM : a value in the range from 1 TO N, where N equals the rank of ARRAY.
o MASK : a logical scalar; or an array of the same shape as ARRAY.

RESULT

The result is of the same type as ARRAY.

If DIM is absent, a scalar with the bitwise or of all elements in ARRAY is returned. Otherwise, an array of rank N-1, where N equals the rank of ARRAY, and a shape similar to that of ARRAY with dimension DIM dropped is returned.

EXAMPLES

Sample program:

    program demo_iany
    use, intrinsic :: iso_fortran_env, only : integer_kinds, &
     & int8, int16, int32, int64
    implicit none
    logical,parameter :: T=.true., F=.false.
    integer(kind=int8) :: a(3)
       a(1) = int(b’00100100’,int8)
       a(2) = int(b’01101010’,int8)
       a(3) = int(b’10101010’,int8)
       write(*,*)’A=’
       print ’(1x,b8.8)’, a
       print *
       write(*,*)’IANY(A)=’
       print ’(1x,b8.8)’, iany(a)
       print *
       write(*,*)’IANY(A) with a mask’
       print ’(1x,b8.8)’, iany(a,mask=[T,F,T])
       print *
       write(*,*)’should match ’
       print ’(1x,b8.8)’, iany([a(1),a(3)])
       print *
       write(*,*)’does it?’
       write(*,*)iany(a,[T,F,T]) == iany([a(1),a(3)])
    end program demo_iany

Results:

        A=
        00100100
        01101010
        10101010

IANY(A)= 11101110

IANY(A) with a mask 10101110

should match 10101110

does it?

    T

STANDARD

Fortran 2008

SEE ALSO

IPARITY(3), IALL(3), IOR(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 iany (3fortran) April 28, 2024
Generated by manServer 1.08 from 30ad7746-6dc8-4068-8e3a-d70f2af0371d using man macros.