A block data program unit provides initial values for nonpointer variables in named common blocks. It takes the following form:
[prefix] BLOCK DATA [name] [specification-part] END [BLOCK DATA [name]]
COMMON | INTRINSIC | STATIC |
DATA | PARAMETER | TARGET |
Derived-type definition | POINTER | Type declaration[2] |
DIMENSION | RECORD[1] | USE[3] |
EQUIVALENCE | Record structure declaration[1] | |
IMPLICIT | SAVE | |
[1] For more information on the
RECORD statement and record structure declarations, see
Section B.11.
|
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