A block data program unit provides initial values for objects in named common blocks.
>>-BLOCK_DATA_statement---------------------------------------->< >>-+--------------------+-------------------------------------->< '-specification_part-' >>-END_BLOCK_DATA_statement------------------------------------>< |
In specification_part, you can specify type declaration, USE, IMPLICIT, COMMON, DATA, EQUIVALENCE, and integer POINTER statements, derived-type definitions, and the allowable attribute specification statements. The only attributes that can be specified include PARAMETER, DIMENSION, INTRINSIC, POINTER, SAVE, and TARGET.
A type declaration statement in a block data specification-part shall not contain ALLOCATABLE or EXTERNAL attribute specifiers.
You can have more than one block data program unit in an executable program, but only one can be unnamed. You can also initialize multiple named common blocks in a block data program unit.
Restrictions on common blocks in block data program units are:
PROGRAM MAIN COMMON /L3/ C, X(10) COMMON /L4/ Y(5) END PROGRAM BLOCK DATA BDATA COMMON /L3/ C, X(10) DATA C, X /1.0, 10*2.0/ ! Initializing common block L3 END BLOCK DATA BLOCK DATA ! An unnamed block data program unit PARAMETER (Z=10) DIMENSION Y(5) COMMON /L4/ Y DATA Y /5*Z/ END BLOCK DATA