Visible to Intel only — GUID: GUID-B4CF205F-A0E6-4853-9C24-2DC78969C7BF
Visible to Intel only — GUID: GUID-B4CF205F-A0E6-4853-9C24-2DC78969C7BF
SIZE Function
Inquiry Intrinsic Function (Generic): Returns the total number of elements in an array, or the extent of an array along a specified dimension.
result = SIZE (array [, dim] [, kind])
array |
(Input) Must be an array; it can be assumed-rank. It can be of any data type. It must not be a disassociated pointer or an allocatable array that is not allocated. It can be an assumed-size array if dim is present with a value less than the rank of array. |
dim |
(Input; optional) Must be a scalar integer with a value in the range 1 to n, where n is the rank of array. |
kind |
(Input; optional) Must be a scalar integer constant expression. |
Results
The result is a scalar of type 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.
In general, if dim is present, the result is the extent of dimension dim in array; otherwise, the result is the total number of elements in array. However, the following exceptions apply:
If array is assumed-rank and associated with an assumed-size array and dim is present with a value equal to the rank of ARRAY, the result has a value of -1.
If dim is absent and array is assumed-rank, the result has a value equal to PRODUCT(SHAPE(ARRAY, KIND)).
The setting of compiler options specifying integer size can affect this function.
Example
If B is declared as B(2:4, -3:1), then SIZE (B, DIM=2) has the value 5 and SIZE (B) has the value 15.
The following shows another example:
REAL(8) array (3:10, -1:3)
INTEGER i
i = SIZE(array, DIM = 2) ! returns 5
i = SIZE(array) ! returns 40