LF Fortran 95

UBOUND Function


The UBOUND function retrieves the upper bounds of an array or a dimension of an array.


UBOUND (array [, dim] )

Required Arguments

array is an INTENT(IN) array of any type. It must not be a pointer that is disassociated or an allocatable array that is not allocated.

Optional Arguments

dim is an INTENT(IN) scalar of type INTEGER and must be a dimension of array.


The result is of type default INTEGER.

If dim is present, the result is a scalar with the value of the upper bound of array.

If dim is absent, the result is an array of rank one with values corresponding to the upper bounds of each dimension of array.

The result is zero for zero-sized dimensions.


integer,dimension (3,-4:0) :: i integer :: k,j(2) write(*,*) ubound(j) ! writes 2 write(*,*) ubound(i) ! writes 3 0 write(*,*) ubound(i,2) ! writes 0 write(*,*) ubound(i,1) ! writes 3

See Also

LBOUND Function