SPREAD — Add a dimension to an array#
-
SPREAD(SOURCE, DIM, NCOPIES)#
Replicates a
SOURCE
arrayNCOPIES
times along a specified dimensionDIM
.- Parameters:
SOURCE – Shall be a scalar or an array of any type and a rank less than seven.
DIM – Shall be a scalar of type
INTEGER
with a value in the range from 1 to n+1, where n equals the rank ofSOURCE
.NCOPIES – Shall be a scalar of type
INTEGER
.
- Returns:
The result is an array of the same type as
SOURCE
and has rank n+1 where n equals the rank ofSOURCE
.
- Standard:
Fortran 90 and later
- Class:
Transformational function
- Syntax:
RESULT = SPREAD(SOURCE, DIM, NCOPIES)
- Example:
PROGRAM test_spread INTEGER :: a = 1, b(2) = (/ 1, 2 /) WRITE(*,*) SPREAD(A, 1, 2) ! "1 1" WRITE(*,*) SPREAD(B, 1, 2) ! "1 1 2 2" END PROGRAM
- See also: