Returns the maximum value of the elements in the array along a dimension corresponding to the true elements of MASK.
Transformational function
The result is an array of rank rank(ARRAY)-1, with the same data type as ARRAY. If DIM is missing or if ARRAY is of rank one, the result is a scalar. If ARRAY is of type character, the length of the result is the same as that of ARRAY.
If DIM is specified, each element of the result value contains the maximum value of all the elements that satisfy the condition specified by MASK along each vector of the dimension DIM. The array element subscripts in the result are (s1, s2, …, s(DIM-1), s(DIM+1), …, sn), where n is the rank of ARRAY and DIM is the dimension specified by DIM.
If DIM is not specified, the function returns the maximum value of all applicable elements.
If ARRAY is of type character, all comparisons are done using the ASCII collating sequence.
If ARRAY is zero-sized or the mask array has all .FALSE. values, then:
! A is the array | -41 33 25 |
! | 12 -61 11 |
! What is the largest value in the entire array?
RES = MAXVAL(A)
! The result is 33
! What is the largest value in each column?
RES = MAXVAL(A, DIM=1)
! The result is | 12 33 25 |
! What is the largest value in each row?
RES = MAXVAL(A, DIM=2)
! The result is | 33 12 |
! What is the largest value in each row, considering only
! elements that are less than 30?
RES = MAXVAL(A, DIM=2, MASK = A .LT. 30)
! The result is | 25 12 |