Replicates a source
array ncopies
times along a specified dimension dim
.
Fortran 95 and later
Transformational function
result = spread(source, dim, ncopies)
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 of source
.ncopies
- Shall be a scalar of type integer
.The result is an array of the same type as source
and has rank n+1 where n equals the rank of source
.
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