Manual Reference Pages  - maxval (3fortran)

NAME

MAXVAL(3) - [ARRAY:REDUCTION] Determines the maximum value in an array or row

SYNOPSIS

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

         NUMERIC function maxval(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 designates any numeric type and kind.

DESCRIPTION

MAXVAL(3) determines the maximum value of the elements in an array value, or, if the DIM argument is supplied, determines the maximum value 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 the array has zero size, or all of the elements of MASK are .false., then the result is the most negative number of the type and kind of ARRAY if ARRAY is numeric, or a string of nulls if ARRAY is of character type.

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 : (Optional) Shall be an array of type logical, and conformable with ARRAY.

RESULT

If DIM is absent, or if ARRAY has a rank of one, the result is a scalar. 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. In all cases, the result is of the same type and kind as ARRAY.

EXAMPLES

sample program:

    program demo_maxval
    implicit none
    integer,save :: ints(3,5)= reshape([&
       1,  2,  3,  4,  5, &
      10, 20, 30, 40, 50, &
      11, 22, 33, 44, 55  &
    ],shape(ints),order=[2,1])

write(*,*) maxval(ints) write(*,*) maxval(ints,dim=1) write(*,*) maxval(ints,dim=2) ! find biggest number less than 30 with mask write(*,*) maxval(ints,mask=ints.lt.30) end program demo_maxval

Results:

     >  55
     >  11     22     33     44     55
     >   5     50     55
     >  22

STANDARD

Fortran 95

SEE ALSO

MAXLOC(3), MINLOC(3), MINVAL(3), MAX(3), MIN(3)

fortran-lang intrinsic descriptions


Nemo Release 3.1 maxval (3fortran) April 28, 2024
Generated by manServer 1.08 from cc3bedb2-32fb-43b9-9637-719f6b426ce4 using man macros.