size

Date:

02-06-2023

NAME

SIZE - Returns the total number of elements in an array

SYNOPSIS

SIZE ([ARRAY=]array [, [DIM=]dim, [KIND=]kind])

STANDARDS

Fortran

DESCRIPTION

The SIZE intrinsic function returns the extent of an array along a specified dimension or the total number of elements in the array. It accepts the following arguments:

array

May be of any type. It must not be scalar. It must not be a pointer that is disassociated or an allocatable array that is not allocated. If array is an assumed-size array, dim must be present with a value less than the rank of array.

dim

Must be scalar and of type integer with a value in the range 1 <= dim <= n, where n is the rank of array.

kind

The kind argument determines the kind type of the return result. If this argument is not specified, the return result is of type default integer.

  • This argument must be a scalar integer initialization expression.

SIZE is an inquiry function. The name of this intrinsic cannot be passed as an argument.

RETURN VALUES

The result is integer scalar. The result has a value equal to the extent of dimension dim of array or, if dim is absent, the total number of elements of array.

EXAMPLES

SIZE(A(2:5,-1:1),DIM=2) yields 3.

SIZE(A(2:5,-1:1)) yields 12.