ubound

Date:

06-19-2023

NAME

UBOUND - Returns all the upper bounds of an array or a specified upper bound

SYNOPSIS

UBOUND ([ARRAY=] array [,[DIM=]dim] [,[KIND=]kind])

STANDARDS

Fortran

DESCRIPTION

The UBOUND intrinsic function returns all the upper bounds of an array or returns a specified upper bound. It accepts the following arguments:

array

Can be of any type. It must not be scalar. It must not be a pointer that is disassociated or an allocatable array that is not allocated. If array is an assumed-size array, dim must be present with a value less than the rank of array.

dim

Must be scalar and of type integer with a value in the range 1 <= dim <= n, where n is the rank of array. The corresponding actual argument must not be an optional dummy argument.

kind

The kind argument determines the kind type of the return result. If this argument is not specified, the return result is of type default integer.

  • This argument must be a scalar integer initialization expression.

UBOUND is an inquiry function. The name of this intrinsic cannot be passed as an argument.

RETURN VALUES

The result type is integer. It is scalar if dim is present; otherwise, the result is an array of rank one and size n, where n is the rank of array.

For an array section or for an array expression, other than a whole array or array structure component, UBOUND(array,dim) has a value equal to the number of elements in the given dimension. It has a value equal to the upper bound for subscript dim of array if dimension dim of array does not have size zero; it has the value zero if dimension dim has size zero.

UBOUND(array) has a value whose ith component is equal to UBOUND(array,i), for i= 1, 2, …,n, where n is the rank of array.

EXAMPLES

Assume that A is declared by the statement REAL A(2:3, 7:10). In this case, the following are true:

  • UBOUND(A) yields (/3,10/).

  • UBOUND(A,DIM=2) yields 10.