Description

Replicates a source array ncopies times along a specified dimension dim.

Standard

Fortran 95 and later

Class

Transformational function

Syntax

result = spread(source, dim, ncopies)

Arguments

• 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.

Return value

The result is an array of the same type as source and has rank n+1 where n equals the rank of source.

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