[UP]


Manual Reference Pages  - maxval (3)

NAME

maxval(3f) - [FORTRAN:INTRINSIC:ARRAY REDUCTION] determines the maximum value in an array or row

CONTENTS

Syntax
Description
Arguments
Return Value
Example
Standard
Class
See Also
Category

SYNTAX

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

result = maxval(array [, mask])

DESCRIPTION

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.

ARGUMENTS

ARRAY - Shall be an array of type INTEGER, REAL, or CHARACTER.
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.
MASK - Shall be an array of type LOGICAL, and conformable with ARRAY.

RETURN VALUE

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.

EXAMPLE

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]] and later

CLASS

Transformational function

SEE ALSO

[[max]], [[maxloc]]

CATEGORY

intrinsics


maxval (3) March 18, 2019
Generated by manServer 1.08 from 15451103-76ad-4a37-9a10-27b8f5d4c299 using man macros.