FINDLOC — Search an array for a value#
-
FINDLOC(ARRAY, VALUE, MASK, KIND, BACK)#
Determines the location of the element in the array with the value given in the
VALUE
argument, or, if theDIM
argument is supplied, determines the locations of the elements equal to theVALUE
argument element along each row of the array in theDIM
direction. IfMASK
is present, only the elements for whichMASK
is.TRUE.
are considered. If more than one element in the array has the valueVALUE
, the location returned is that of the first such element in array element order if theBACK
is not present or if it is.FALSE.
. IfBACK
is true, the location returned is that of the last such element. If the array has zero size, or all of the elements ofMASK
are.FALSE.
, then the result is an array of zeroes. Similarly, ifDIM
is supplied and all of the elements ofMASK
along a given row are zero, the result value for that row is zero.- Parameters
ARRAY – Shall be an array of intrinsic type.
VALUE – A scalar of intrinsic type which is in type conformance with
ARRAY
.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 – (Optional) Shall be of type
LOGICAL
, and conformable withARRAY
.KIND – (Optional) An
INTEGER
initialization expression indicating the kind parameter of the result.BACK – (Optional) A scalar of type
LOGICAL
.
- Returns
If
DIM
is absent, the result is a rank-one array with a length equal to the rank ofARRAY
. IfDIM
is present, the result is an array with a rank one less than the rank ofARRAY
, and a size corresponding to the size ofARRAY
with theDIM
dimension removed. IfDIM
is present andARRAY
has a rank of one, the result is a scalar. If the optional argumentKIND
is present, the result is an integer of kindKIND
, otherwise it is of default kind.
- Standard:
Fortran 2008 and later.
- Class:
Transformational function
- Syntax:
RESULT = FINDLOC(ARRAY, VALUE, DIM [, MASK] [,KIND] [,BACK]) RESULT = FINDLOC(ARRAY, VALUE, [, MASK] [,KIND] [,BACK])
- See also:
MAXLOC — Location of the maximum value within an array, MINLOC — Location of the minimum value within an array