MAXLOC — Location of the maximum value within an array#
-
MAXLOC(ARRAY, MASK, KIND, BACK)#
Determines the location of the element in the array with the maximum value, or, if the
DIMargument is supplied, determines the locations of the maximum element along each row of the array in theDIMdirection. IfMASKis present, only the elements for whichMASKis.TRUE.are considered. If more than one element in the array has the maximum value, the location returned is that of the first such element in array element order if theBACKis not present, or is false; ifBACKis true, the location returned is that of the last such element. If the array has zero size, or all of the elements ofMASKare.FALSE., then the result is an array of zeroes. Similarly, ifDIMis supplied and all of the elements ofMASKalong a given row are zero, the result value for that row is zero.- Parameters
ARRAY – Shall be an array of type
INTEGERorREAL.DIM – (Optional) Shall be a scalar of type
INTEGER, with a value between one and the rank ofARRAY, inclusive. It may not be an optional dummy argument.MASK – Shall be of type
LOGICAL, and conformable withARRAY.KIND – (Optional) An
INTEGERinitialization expression indicating the kind parameter of the result.BACK – (Optional) A scalar of type
LOGICAL.
- Returns
If
DIMis absent, the result is a rank-one array with a length equal to the rank ofARRAY. IfDIMis present, the result is an array with a rank one less than the rank ofARRAY, and a size corresponding to the size ofARRAYwith theDIMdimension removed. IfDIMis present andARRAYhas a rank of one, the result is a scalar. If the optional argumentKINDis present, the result is an integer of kindKIND, otherwise it is of default kind.
- Standard:
Fortran 95 and later;
ARRAYofCHARACTERand theKINDargument are available in Fortran 2003 and later. TheBACKargument is available in Fortran 2008 and later.- Class:
Transformational function
- Syntax:
RESULT = MAXLOC(ARRAY, DIM [, MASK] [,KIND] [,BACK]) RESULT = MAXLOC(ARRAY [, MASK] [,KIND] [,BACK])
- See also:
FINDLOC — Search an array for a value, MAX, MAXVAL — Maximum value of an array