## Lbound

### Statement Type

Lbound is an inquiry function that operates on arrays of all types.

### Statement Purpose

Lbound is used to find the lower bound of an array. In other words it will tell you the
lowest index value permitted when referencing elements in an array.

### Required Arguments

lbound (**array**)

The argument **array** is any array for which you wish know the smallest element index.
Please note that any array that you pass to the function must be defined. This means that
disassociated pointers and non-allocated arrays can not be used as arguments to the
lbound function.

### Optional Arguments

lbound (array,**dim**)

**Dim **can be used with this function if you are curious about what the smallest element is
along a specific dimension of an array with rank greater than one. Take notice that when
**dim** is specified the result is a scalar. This result is radically different from the results
the function produces if dim is not present. When dim is not present, the result will be a
one dimensional array that contains the smallest element from each dimension of the
array.

### Results

To see the results of the lbound function, we first need to define an array.

real numbers(-9:10,1:12,37:40)

First, to find out what the lower bounds of all the three dimensions, the following would
be required.

Res1 = lbound(numbers)

This call to lbound requires that **res1** was previously declared as a rank one array,
containing at least three elements (e.g. "real res1(3)"). Here lbound will set the values of
the three elements will to -9, 1 and 37. Now, if you only needed to know the lower
bound of the second dimension of numbers, all that would need to be done is add the **dim**
argument to the call.

Res2 = lbound(numbers,dim=2)

This time res2 will be a scalar instead of an array. Naturally, the value of res2 will be
one.

### For more information and examples see

lecture thirty six

examples: pointers.f

## Up** one level / Home**

**
**

Written by Jason Wehr : jcw142@psu.edu and Maintained by John Mahaffy :
jhm@cac.psu.edu