2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. index:: SIZE, array, size, array, number of elements, array, count elements
10 SIZE --- Determine the size of an array
11 ***************************************
13 .. function:: SIZE(ARRAY, DIM , KIND)
15 Determine the extent of :samp:`{ARRAY}` along a specified dimension :samp:`{DIM}`,
16 or the total number of elements in :samp:`{ARRAY}` if :samp:`{DIM}` is absent.
19 Shall be an array of any type. If :samp:`{ARRAY}` is
20 a pointer it must be associated and allocatable arrays must be allocated.
23 (Optional) shall be a scalar of type ``INTEGER``
24 and its value shall be in the range from 1 to n, where n equals the rank
28 (Optional) An ``INTEGER`` initialization
29 expression indicating the kind parameter of the result.
32 The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If
33 :samp:`{KIND}` is absent, the return value is of default integer kind.
36 Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later
42 .. code-block:: fortran
44 RESULT = SIZE(ARRAY[, DIM [, KIND]])
47 .. code-block:: fortran
50 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2