Manual Reference Pages  - minloc (3fortran)

NAME

MINLOC(3) - [ARRAY:LOCATION] Location of the minimum value within an array

SYNOPSIS

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

         NUMERIC function minloc(array, dim, mask)

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

CHARACTERISTICS

o a kind designated as ** may be any supported kind for the type
o NUMERIC is any numeric type and kind.

DESCRIPTION

MINLOC(3) determines the location of the element in the array with the minimum value, or, if the DIM argument is supplied, determines the locations of the minimum element along each row of the array in the DIM direction.

If MASK is present, only the elements for which MASK is true. are considered.

If more than one element in the array has the minimum value, the location returned is that of the first such element in array element order.

If the array has zero size, or all of the elements of MASK are .false., then the result is an array of zeroes. Similarly, if DIM is supplied and all of the elements of MASK along a given row are zero, the result value for that row is zero.

OPTIONS

o ARRAY : Shall be an array of type integer, real, or character.
o DIM : (Optional) Shall be a scalar of type integer, with a value between one and the rank of ARRAY, inclusive. It may not be an optional dummy argument.
o MASK : Shall be an array of type logical, and conformable with ARRAY.

RESULT

If DIM is absent, the result is a rank-one array with a length equal to the rank of ARRAY. If DIM is present, the result is an array with a rank one less than the rank of ARRAY, and a size corresponding to the size of ARRAY with the DIM dimension removed. If DIM is present and ARRAY has a rank of one, the result is a scalar. In all cases, the result is of default integer type.

EXAMPLES

sample program:

    program demo_minloc
    implicit none
    integer,save :: ints(3,5)= reshape([&
       4, 10,  1,  7, 13, &
       9, 15,  6, 12,  3, &
      14,  5, 11,  2,  8  &
    ],shape(ints),order=[2,1])
       write(*,*) minloc(ints)
       write(*,*) minloc(ints,dim=1)
       write(*,*) minloc(ints,dim=2)
       ! where in each column is the smallest number .gt. 10 ?
       write(*,*) minloc(ints,dim=2,mask=ints.gt.10)
       ! a one-dimensional array with dim=1 explicitly listed returns a scalar
       write(*,*) minloc(pack(ints,.true.),dim=1) ! scalar
    end program demo_minloc

Results:

     >        1       3
     >        1       3       1       3       2
     >        3       5       4
     >        5       4       3
     >        7

STANDARD

Fortran 95

SEE ALSO

o FINDLOC(3) - Location of first element of ARRAY identified by MASK along dimension DIM matching a target
o MAXLOC(3) - Location of the maximum value within an array
o MINLOC(3) - Location of the minimum value within an array
o MIN(3)
o MINVAL(3)
o MAXVAL(3)
o MAX(3)
fortran-lang intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 minloc (3fortran) April 28, 2024
Generated by manServer 1.08 from 72a46f47-1e4e-40d4-a1a8-2ea498721be7 using man macros.