# Fortran Wiki size

## Description

Determine the extent of array along a specified dimension dim, or the total number of elements in array if dim is absent.

## Standard

Fortran 95 and later, with kind argument Fortran 2003 and later

Inquiry function

## Syntax

result = size(array[, dim [, kind]])

## Arguments

• array - Shall be an array of any type. If array is a pointer it must be associated and allocatable arrays must be allocated.
• dim - (Optional) shall be a scalar of type integer and its value shall be in the range from 1 to n, where n equals the rank of array.
• kind - (Optional) An integer initialization expression indicating the kind parameter of the result.

## Return value

The return value is of type integer and of kind kind. If kind is absent, the return value is of default integer kind.

## Example

program test_size
write(*,*) size((/ 1, 2 /))    ! 2
end program