Elemental Intrinsic Function (Generic): Returns the maximum value of the arguments.
Syntax
Results:
For MAX0, AMAX1, DMAX1, QMAX1, IMAX0, JMAX0, and KMAX0, the result type is the same as the arguments. For MAX1, IMAX1, JMAX1, and KMAX1, the result type is integer. For AMAX0, AIMAX0, AJMAX0, and AKMAX0, the result type is real. The value of the result is that of the largest argument.
Specific Name 1 | Argument Type | Result Type |
---|---|---|
INTEGER(1) | INTEGER(1) | |
INTEGER(1) | REAL(4) | |
IMAX0 | INTEGER(2) | INTEGER(2) |
AIMAX0 | INTEGER(2) | REAL(4) |
MAX0 2 | INTEGER(4) | INTEGER(4) |
AMAX0 3, 4 | INTEGER(4) | REAL(4) |
KMAX0 | INTEGER(8) | INTEGER(8) |
AKMAX0 | INTEGER(8) | REAL(4) |
IMAX1 | REAL(4) | INTEGER(2) |
MAX1 4, 5, 6 | REAL(4) | INTEGER(4) |
KMAX1 | REAL(4) | INTEGER(8) |
AMAX1 7 | REAL(4) | REAL(4) |
DMAX1 | REAL(8) | REAL(8) |
QMAX1 8 | REAL(16) | REAL(16) |
1 These specific functions cannot be passed as actual
arguments.
2 Or JMAX0. 3 Or AJMAX0. AMAX0 is the same as REAL (MAX). 4 In Fortran 90, AMAX0 and MAX1 are specific functions with no generic name. For compatibility with older versions of Fortran, these functions can also be specified as generic functions. 5 Or JMAX1. MAX1 is the same as INT (MAX). 6 The setting of compiler option /integer_size can affect MAX1. 7 The setting of compiler option /real_size can affect AMAX1. 8 VMS and U*X |
Compatibility
CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB
See Also: MIN
Examples
MAX (2.0, -8.0, 6.0) has the value 6.0.
MAX (14, 32, -50) has the value 32.
The following shows another example:
INTEGER m1, m2
REAL r1, r2
m1 = MAX(5, 6, 7) ! returns 7
m2 = MAX1(5.7, 3.2, -8.3) ! returns 5
r1 = AMAX0(5, 6, 7) ! returns 7.0
r2 = AMAX1(6.4, -12.2, 4.9) ! returns 6.4