spread(3f) - [FORTRAN:INTRINSIC:ARRAY CONSTRUCTION] Add a dimension to an array
Syntax
Description
Arguments
Return Value
Example
Standard
Class
See Also
result = spread(source, dim, ncopies)
Replicates a SOURCE array NCOPIES times along a specified dimension DIM.
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.
Sample program:
program demo_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 demo_spread
[[Fortran 95]] and later
Transformational function
[[unpack]]
spread (3) | March 19, 2019 |