# 4.2 BLOCK DATA Statement

A BLOCK DATA statement initiates a series of specification statements that establish common blocks and assign initial values to the entities in named common blocks.

The BLOCK DATA statement takes the following form:

    BLOCK DATA [nam]

nam
  Is a symbolic name.

Rules and Behavior

A BLOCK DATA statement and its associated specification statements are a special kind of program unit, called a block data subprogram.

Any of the following specification statements can appear in a block data subprogram:

COMMON | RECORD
DATA | SAVE
DIMENSION | STATIC
EQUIVALENCE | Structure declaration
IMPLICIT | Type declaration statement
PARAMETER |

A block data subprogram must not contain any executable statements.

As with other types of program units, the last statement in a block data subprogram must be an END statement.

Within a block data subprogram, if a DATA statement initializes any entity in a named common block, the subprogram must have a complete set of specification statements that establishes the common block. However, all of the entities in the block do not have to be assigned initial values in a DATA statement.

One block data subprogram can establish and define initial values for more than one common block.

The name of a block data subprogram 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.

Example

The following example shows a valid block data subprogram:

    BLOCK DATA BLKDAT

    INTEGER S,X

    LOGICAL T,W

    DOUBLE PRECISION U

    DIMENSION R(3)

    COMMON /AREA1/R,S,T,U /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 the DATA statement, see Section 4.4.

- On the EXTERNAL statement, see Section 4.8.

- On the END statement, see Section 5.5.

Previous Page Next Page Table of Contents