180. ALLOCATE with SOURCE or MOLD to set values or SHAPE.#

topic: Allocation

Note

This tip is a draft1.

Some forms of ALLOCATE are

allocate (y(2)) ! y undefined allocate (y(2),source=0.0) ! fill with zeros allocate (y(2),source=[3.0,4.0]) ! fill with [3.0,4.0] allocate (y,mold=x) ! get shape from x allocate (y,source=x) ! get shape and values from x



1

From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.