MIN

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

Syntax

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

a1, a2, a3

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

Results

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.

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)

KMIN0

INTEGER(8)

INTEGER(8)

AKMIN0

INTEGER(8)

REAL(4)

IMIN1

REAL(4)

INTEGER(2)

MIN1 4, 5, 6

REAL(4)

INTEGER(4)

KMIN1

REAL(4)

INTEGER(8)

AMIN1 7

REAL(4)

REAL(4)

DMIN1

REAL(8)

REAL(8)

QMIN1

REAL(16)

REAL(16)

1These specific functions cannot be passed as actual arguments.

2Or JMIN0.

3Or AJMIN0.AMIN0 is the same as REAL (MIN).

4In Fortran 95/90, AMIN0 and MIN1 are specific functions with no generic name. For compatibility with older versions of Fortran, these functions can also be specified as generic functions.

5Or JMIN1.MIN1 is the same as INT (MIN).

6The setting of compiler options specifying integer size can affect MIN1.

7The setting of compiler options specifying real size can affect AMIN1.

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

See Also