FORTRAN Reference Manual

Intrinsic Functions
FORTRAN Reference Manual528615-001
8-23
MAX Function
MAX Function
The MAX function returns the largest value in its argument list.
The table below shows the argument and function type for the MAX generic function
and its associated specific functions.
Considerations
All arguments to the MAX function must be the same type.
The result type of the MAX function is the same as the type of its arguments.
You can specify up to 63 arguments to the MAX function. If you need to use more
than 63 arguments, you can distribute the arguments among several MAX
functions and take the MAX of those functions:
MAX (MAX (a, b, c, ... , x), MAX (a1, b1, c1, ... , x1))
Example of the MAX Function
READ *, x, y, z
greatest = MAX (x, y, z)
Syntax Argument Type Function Type
MAX (x1, ... , xn)
MAX0 (x1, ... , xn) Integer Integer
MAX04 (x1, ... , xn) Integer*4 Integer*4
MAX08 (x1, ... , xn) Integer*8 Integer*8
AMAX0 (x1, ... , xn) Integer Real
AMAX04 (x1, ... , xn) Integer*4 Real
AMAX08 (x1, ... , xn) Integer*8 Real
MAX1 (x1, ... , xn) Real Integer
MAX14 (x1, ... , xn) Real Integer*4
MAX18 (x1, ... , xn) Real Integer*8
AMAX1 (x1, ... , xn) Real Real
DMAX1 (x1, ... , xn) Double Precision Double Precision
Each xi is an arithmetic expression.