]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
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:: SPREAD, array, increase dimension, array, duplicate elements, array, duplicate dimensions | |
7 | ||
8 | .. _spread: | |
9 | ||
10 | SPREAD --- Add a dimension to an array | |
11 | ************************************** | |
12 | ||
13 | .. function:: SPREAD(SOURCE, DIM, NCOPIES) | |
14 | ||
15 | Replicates a :samp:`{SOURCE}` array :samp:`{NCOPIES}` times along a specified | |
16 | dimension :samp:`{DIM}`. | |
17 | ||
18 | :param SOURCE: | |
19 | Shall be a scalar or an array of any type and | |
20 | a rank less than seven. | |
21 | ||
22 | :param DIM: | |
23 | Shall be a scalar of type ``INTEGER`` with a | |
24 | value in the range from 1 to n+1, where n equals the rank of :samp:`{SOURCE}`. | |
25 | ||
26 | :param NCOPIES: | |
27 | Shall be a scalar of type ``INTEGER``. | |
28 | ||
29 | :return: | |
30 | The result is an array of the same type as :samp:`{SOURCE}` and has rank n+1 | |
31 | where n equals the rank of :samp:`{SOURCE}`. | |
32 | ||
33 | Standard: | |
34 | Fortran 90 and later | |
35 | ||
36 | Class: | |
37 | Transformational function | |
38 | ||
39 | Syntax: | |
40 | .. code-block:: fortran | |
41 | ||
42 | RESULT = SPREAD(SOURCE, DIM, NCOPIES) | |
43 | ||
44 | Example: | |
45 | .. code-block:: fortran | |
46 | ||
47 | PROGRAM test_spread | |
48 | INTEGER :: a = 1, b(2) = (/ 1, 2 /) | |
49 | WRITE(*,*) SPREAD(A, 1, 2) ! "1 1" | |
50 | WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2" | |
51 | END PROGRAM | |
52 | ||
53 | See also: | |
3ed1b4ce | 54 | :ref:`UNPACK` |