LF Fortran 95

MINVAL Function

Description

The MAXVAL function returns the minimum value of elements of an array, along a given dimension, for which a mask is true.

Syntax

MINVAL (array [, dim] [, mask] )

Required Arguments

array is an INTENT(IN) array of type INTEGER or REAL.

Optional Arguments

dim is an INTENT(IN) scalar INTEGER in the range 1 ≤ dimn, where n is the rank of array. The actual argument to MINVAL must not be an optional dummy argument.

mask is an INTENT(IN) scalar or array of type LOGICAL, and must be conformable with array.

Result

The result is the same type and kind as array.

If dim is present, the result is an array of rank n-1 and of shape (d1,d2, ...,ddim-1,ddim+1, ...,dn) where (d1,d2, ...,dn) is the shape of array. The results are the minimum values of all elements of array along dimension dim.

If dim is absent, or array is rank one, the result is a scalar with the value of the smallest element of array.

If mask is present, the elements of array for which mask is false are not considered.

Example

integer :: i6(6)=(/-14,3,0,-2,19,1/) integer :: i23(2,3)=reshape((/-14,3,0,-2,19,1/),shape(i23)) write(*,'(2i4)') i23 ! writes -14 3 ! 0 -2 ! 19 1 write(*,*) minloc(i6) ! writes 1 write(*,*) minloc(i23) ! writes 1 1 write(*,*) minloc(i23,1) ! writes 1 2 2 write(*,*) minloc(i23,2) ! writes 1 2 write(*,*) minloc(i23,1,(i23 < 10)) ! writes 1 2 2