UBOUND intrinsic function

Standard: F77 F90 F95 F2003 F2008 Example program



ARRAY : array of any type and rank N;
DIM : scalar Integer in the range 1 to N;
KIND : scalar Integer constant expression;

Result : Integer or Integer(Kind=KIND).


If DIM appears, the result is scalar, being the value of the upper bound of that dimension of ARRAY. If DIM does not, the result is a vector of length N containing all the upper bounds of ARRAY. The actual argument for DIM must not itself be an optional dummy argument.

If the array is not a data object, or is an array section, the upper bounds are considered to be equal to the extent of the array in each dimension. Also, the upper bound of any dimension with zero extent is considered to be zero.

It is prohibited to ask for the upper bound of the last dimension of an assumed-size array; an assumed-size array is a dummy array whose last dimension is declared as “*”. In any case, assumed-size arrays are error-prone and not recommended for normal use.

In Fortran 2003, the KIND argument should be used when the upper bound might not be representable in the default Integer kind.


DIMENSION attribute, LBOUND intrinsic function, SHAPE intrinsic function, SIZE intrinsic function