LF Fortran 95

MAX Function


The MAX function returns the maximum value from a list of INTEGER or REAL arguments.


MAX (a1, a2 [, a3, ...])


The arguments are INTENT(IN) scalars or arrays of type INTEGER or REAL. They must all be of the same type and kind.

If more than one argument is an array, all arrays must have the same shape.


The result is of the same type and kind as the arguments.

If all the arguments are scalar, the result is the value of the largest argument.

If any of the arguments are arrays, the result is an array with the same shape. Each element of the result is as if the scalar MAX function was called for each corresponding element of the array argument(s).


integer :: i6(6)=(/-14,3,0,-2,19,1/) write(*,*) max(i6,0) ! writes 0 3 0 0 19 1 write(*,*) max(-14,3,0,-2,19,1) ! writes 19