Returns the upper bounds of each dimension in an array, or the upper bound of a specified dimension.
Result Type and Attributes
If DIM is present, the result is a scalar. If it is not present, the result is a one-dimensional array with one element for each dimension in ARRAY.
Each element in the result corresponds to a dimension of ARRAY. If ARRAY is a whole array or array structure component, these values are equal to the upper bounds. If ARRAY is an array section or expression that is not a whole array or array structure component, the values represent the number of elements in each dimension, which may be different than the declared upper bounds of the original array. If a dimension is zero-sized, the corresponding element in the result is zero, regardless of the value of the upper bound.
! This array illustrates the way UBOUND works with ! different ranges for dimensions. REAL A(1:10, -4:5, 4:-5) RES=UBOUND( A ) ! The result is (/ 10, 5, 0 /). RES=UBOUND( A(:,:,:) ) ! The result is (/ 10, 10, 0 /) because the argument ! is an array section. RES=UBOUND( A(4:10,-4:1,:) ) ! The result is (/ 7, 6, 0 /), because for an array section, ! it is the number of elements that is significant.