SOURCE= specifier

Standard: F77 F90 F95 F2003 F2008 Example program


SOURCE = expression

The SOURCE= specifier may occur only in an ALLOCATE statement. If SOURCE= appears, Fortran 2003 permitted only one item to be allocated; Fortran 2008 permits multiple items to be allocated. Each item to be allocated must be type-compatible with the SOURCE= expression.


With SOURCE=, the item is allocated to have the same dynamic type and value as the SOURCE= expression. This operation is sometimes known as “cloning”.

If an item is an array but the SOURCE= expression is scalar, the scalar value is broadcast to every element of the item.

If the SOURCE= expression is an array, Fortran 2003 requires the item being allocated to have that same shape specified. Fortran 2008 permits the array shape to be omitted in this case; the bounds of the allocation are taken from the bounds of the SOURCE= expression.


ALLOCATE statement, CLASS specifier, MOLD= specifier