Silverfrost Logo About Us | Contact Us
 

UBOUND

Platform

x64, Win32, .NET

Purpose

To get the upper bound or upper bounds for the indexes of an array.

Class

Inquiry function.

Syntax

INTEGER FUNCTION UBOUND (ARRAY [, DIM [, KIND]])
INTEGER DIM, KIND

Description

ARRAY is an array of any type. If it is a pointer it must be associated. If it is an allocatable array, it must be allocated. If it is an assumed-size array, DIM must be present with a value less than the rank of ARRAY.

DIM is a scalar with a value in the range 1 < DIM < n, where n is the rank of ARRAY.

The result is a scalar integer or a one-dimensional integer array (of default type). It is scalar if DIM is present, otherwise, the result is an array of size n. If KIND is present it provides the INTEGER kind value of the result.

Return value

Case (i): 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; otherwise, it has a value equal to the upper bound for subscript DIM of ARRAY. If dimension DIM has zero size the result is zero.

Case (ii): UBOUND(ARRAY) has a value whose ith component is equal to UBOUND(ARRAY, i), for i = 1, 2, ..., n .

Example

If A is declared by the statement REAL A(2:3, 7:10) then UBOUND(A) is [3, 10] and UBOUND(A, DIM = 2) is 10.

 

 

Copyright © 1999-2018 Silverfrost Limited