Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

MIN

Elemental Intrinsic Function (Generic): Returns the minimum value of the arguments.

result = MIN (a1,a2[,a3...])

a1, a2, a3

(Input) All must have the same type (integer, real, or character) and kind parameters.

Results

For arguments of character type, the result type is character, and the length of the result is the length of the longest argument. For MIN0, AMIN1, DMIN1, QMIN1, IMIN0, JMIN0, and KMIN0, the result type is the same as the arguments. For MIN1, IMIN1, JMIN1, and KMIN1, the result type is integer. For AMIN0, AIMIN0, AJMIN0, and AKMIN0, the result type is real. The value of the result is that of the smallest argument. For character arguments, the comparison is done using the ASCII collating sequence. If the selected argument is shorter than the longest argument, the result is extended to the length of the longest argument by inserting blank characters on the right.

The Fortran standard does not define the behavior if one or more real arguments is a NaN and at least one argument is not a NaN. Depending on the order of the arguments, the result may be either the minimum non-NaN value or a NaN.

Specific Name 1

Argument Type

Result Type

INTEGER(1)

INTEGER(1)

IMIN0

INTEGER(2)

INTEGER(2)

AIMIN0

INTEGER(2)

REAL(4)

MIN0 2

INTEGER(4)

INTEGER(4)

AMIN0 3, 4

INTEGER(4)

REAL(4)

Example

MIN (2.0, -8.0, 6.0) has the value -8.0.

MIN (14, 32, -50) has the value -50.

The following shows another example:

INTEGER m1, m2 REAL r1, r2 m1 = MIN (5, 6, 7) ! returns 5 m2 = MIN1 (-5.7, 1.23, -3.8) ! returns -5 r1 = AMIN0 (-5, -6, -7) ! returns -7.0 r2 = AMIN1(-5.7, 1.23, -3.8) ! returns -5.7