LF Fortran 95

SIZE Function

Description

The SIZE function returns the size of an array or a dimension of an array.

Syntax

SIZE (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. If array is assumed-size, dim must be present and less than the rank of array

Result

The result is a scalar default INTEGER.

If dim is present, the result is the extent of dimension dim of array.

If dim is absent, the result is the total number of elements in array.

Example

integer,dimension(3,-4:0) :: i integer :: k,j write(*,*) size (i) ! writes 15 write(*,*) size (i,2) ! writes 5