Purpose
Returns the lower bound of each
dimension in an array, or the lower bound of a specified dimension.
Argument type and attributes
- ARRAY
- The array whose lower bounds you want to determine. The bounds
of the array must be defined; that is, the corresponding
actual argument cannot be a disassociated pointer or an allocatable
array that is not allocated.
- DIM (optional)
- An INTEGER scalar. Its value must be in the range
1 ≤ DIM ≤ RANK(ARRAY).
The corresponding actual argument must not be an optional dummy argument. The DIM argument
cannot be present if ARRAY is an assumed-rank
object that is associated with a scalar.
- KIND (optional)
- An INTEGER scalar. The actual argument corresponding
to KIND must be a constant expression.
Result type and attributes
- The result is of type integer.
- If KIND is present,
the kind type parameter is that specified by the value of KIND;
otherwise, the kind type parameter is that of the default integer
type.
- If DIM is present, the result is a scalar.
If DIM is not present, the result is a one-dimensional
array with one element for each dimension in ARRAY.
- If ARRAY is
an assumed-rank object that is associated with a scalar, the result
is a zero-sized array.
Result value
Each element in the result
corresponds to a dimension of
array.
- If ARRAY is a whole array or array structure
component, LBOUND(ARRAY, DIM)
is equal to the lower bound for subscript DIM of ARRAY.
The only exception is for a dimension that is zero-sized and ARRAY is
not an assumed-size array of rank DIM, in
such a case, the corresponding element in the result is one regardless
of the value declared for the lower bound.
- If ARRAY is an array section or expression
that is not a whole array or array structure component, each element
has the value one.
Examples
REAL A(1:10, -4:5, 4:-5)
RES=LBOUND( A )
! The result is (/ 1, -4, 1 /).
RES=LBOUND( A(:,:,:) )
RES=LBOUND( A(4:10,-4:1,:) )
! The result in both cases is (/ 1, 1, 1 /)
! because the arguments are array sections.