Block data program unit
A block data program unit provides initial values for objects in
named common blocks.
- BLOCK_DATA_statement
- See BLOCK DATA for syntax details
- specification_part
- is a sequence of statements from the statement groups numbered 2 , 4 , and 5 in Order of statements and execution sequence
- END_BLOCK_DATA_statement
- See END for syntax details
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 are: BIND, DIMENSION, INTRINSIC, PARAMETER, POINTER, SAVE, TARGET, and ASYNCHRONOUS.
A type declaration statement in a block data specification-part must 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:
- All items in a named common block must appear in the COMMON statement, even if they are not all initialized.
- The same named common block must not be referenced in two different block data program units.
- Only nonpointer objects in named common blocks can be initialized in block data program units.
- Objects in blank common blocks cannot be initialized.
Examples
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