]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/fortran/doc/gfortran/intrinsic-procedures/size.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / fortran / doc / gfortran / intrinsic-procedures / size.rst
1 ..
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.
5
6 .. index:: SIZE, array, size, array, number of elements, array, count elements
7
8 .. _size:
9
10 SIZE --- Determine the size of an array
11 ***************************************
12
13 .. function:: SIZE(ARRAY, DIM , KIND)
14
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.
17
18 :param ARRAY:
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.
21
22 :param DIM:
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
25 of :samp:`{ARRAY}`.
26
27 :param KIND:
28 (Optional) An ``INTEGER`` initialization
29 expression indicating the kind parameter of the result.
30
31 :return:
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.
34
35 Standard:
36 Fortran 90 and later, with :samp:`{KIND}` argument Fortran 2003 and later
37
38 Class:
39 Inquiry function
40
41 Syntax:
42 .. code-block:: fortran
43
44 RESULT = SIZE(ARRAY[, DIM [, KIND]])
45
46 Example:
47 .. code-block:: fortran
48
49 PROGRAM test_size
50 WRITE(*,*) SIZE((/ 1, 2 /)) ! 2
51 END PROGRAM
52
53 See also:
54 :ref:`SHAPE`,
55 :ref:`RESHAPE`