Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

LBOUND

Inquiry Intrinsic Function (Generic): Returns the lower bounds for all dimensions of an array, or the lower bound for a specified dimension.

result = LBOUND (array [, dim] [, kind])

array

(Input) Must be an array; it can be assumed-rank. It may be of any data type. It must not be an allocatable array that is not allocated, or a disassociated pointer.

dim

(Input; optional) Must be a scalar integer with a value in the range 1 to n, where n is the rank array.

kind

(Input; optional) Must be a scalar integer constant expression.

Results

The result type is integer. If kind is present, the kind parameter of the result is that specified by kind; otherwise, the kind parameter of the result is that of default integer. If the processor cannot represent the result value in the kind of the result, the result is undefined.

If dim is present, the result is a scalar. Otherwise, the result is a rank-one array with one element for each dimension of array. Each element in the result corresponds to a dimension of array.

If array is an array section or an array expression that is not a whole array or array structure component, each element of the result has the value 1.

If array is a whole array or array structure component, LBOUND ( array, dim) has a value equal to the lower bound for subscript dim of array(if dim is nonzero or array is an assumed-size array of rank dim). Otherwise, the corresponding element of the result has the value 1.

If LBOUND is invoked for an assumed-rank object that is associated with a scalar and dim is absent, the result is a zero-sized array. LBOUND cannot be invoked for an assumed-rank object that is associated with a scalar if dim is present because the rank of a scalar is zero and dim must be >= 1.

The setting of compiler options specifying integer size can affect this function.

Example

Consider the following:

  REAL ARRAY_A (1:3, 5:8)
  REAL ARRAY_B (2:8, -3:20)

LBOUND(ARRAY_A) is (1, 5). LBOUND(ARRAY_A, DIM=2) is 5.

LBOUND(ARRAY_B) is (2, -3). LBOUND(ARRAY_B (5:8, :)) is (1,1) because the arguments are array sections.

The following shows another example:

  REAL ar1(2:3, 4:5, -1:14), vec1(35)
  INTEGER res1(3), res2, res3(1)
  res1 = LBOUND (ar1)          ! returns [2, 4, -1]
  res2 = LBOUND (ar1, DIM= 3)  ! returns -1
  res3 = LBOUND (vec1)         ! returns [1]
  END

See Also