HP Fortran Programmer's Reference (September 2007)

Intrinsic procedures
Intrinsic procedure specifications
Chapter 11626
SPREAD(SOURCE, DIM, NCOPIES)
Description
Replicates an array by adding a dimension. Broadcasts several copies of SOURCE along a
specified dimension (as in forming a book from copies of a single page) and thus forms an
array of rank one greater.
Class
Transformational function.
Arguments
SOURCE may be of any type. It may be scalar or array valued. The rank of SOURCE
must be less than 7.
DIM must be scalar and of type integer with value in the range 1 <= DIM <=
n
+1,
where
n
is the rank of SOURCE.
NCOPIES must be scalar and of type integer.
Result type,
type parameters,
and shape
The result is an array of the same type and type parameters as SOURCE and of rank
n
+ 1,
where
n
is the rank of SOURCE.
Case 1 If SOURCE is scalar, the shape of the result is (MAX(NCOPIES, 0)).
Case 2 If SOURCE is array valued with shape (
d
1
,
d
2
, ...,
d
n
), the shape of the result is
(
d
1
,
d
2
, ...,
d
DIM-1
, MAX(NCOPIES, 0),
d
DIM
, ...,
d
n
).
Result value
Case 1 If SOURCE is scalar, each element of the result has a value equal to SOURCE.
Case 2 If SOURCE is array valued, the element of the result with subscripts (
r
1
,
r
2
,
...,
r
n+1
) has the value SOURCE(
r
1
,
r
2
, ...,
r
DIM-1
,
r
DIM+1
, ...,
r
n+1
).