# 8.4 Block Data Program Units

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]]
  prefix
  Is one of the High Performance Fortran (HPF) keywords (see Section 8.2).
  name
  Is the name of the block data program unit.
  specification-part
  Is one or more of the following statements:

  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.12. 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.

Examples

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:

- On common blocks, see Section 5.4.
- On the DATA statement, see Section 5.5.
- On the EXTERNAL statement, see Section 5.8.

Previous Page Next Page Table of Contents