A block data program unit provides initial values for nonpointer variables in named common blocks. It takes the following form:
|Derived-type definition||POINTER||Type declaration 2|
|DIMENSION||RECORD 1||USE 3|
|EQUIVALENCE||Record structure declaration 1|
1 For more information on the
RECORD statement and record structure declarations, see
2 Can only contain attributes: DIMENSION, INTRINSIC, PARAMETER, POINTER, SAVE, STATIC, or TARGET.
3 Allows access to only named constants.
Rules and Behavior
A block data program unit need not be named, but there can only be one unnamed block data program unit in an executable program.
If a name follows the END statement, it must be the same as the name specified in the BLOCK DATA statement.
An interface block must not appear in a block data program unit and a block data program unit must not contain any executable statements.
If a DATA statement initializes any variable in a named common block, the block data program unit must have a complete set of specification statements establishing the common block. However, all of the variables in the block do not have to be initialized.
A block data program unit can establish and define initial values for more than one common block, but a given common block can appear in only one block data program unit in an executable program.
The name of a block data program unit can appear in the EXTERNAL statement of a different program unit to force a search of object libraries for the block data program unit at link time.
The following is an example of a block data program unit:
BLOCK DATA BLKDAT INTEGER S,X LOGICAL T,W DOUBLE PRECISION U DIMENSION R(3) COMMON /AREA1/R,S,U,T /AREA2/W,X,Y DATA R/1.0,2*2.0/, T/.FALSE./, U/0.214537D-7/, W/.TRUE./, Y/3.5/ END
For More Information: