Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

BLOCK DATA

Statement: Identifies a block-data program unit, which provides initial values for variables in named common blocks. BLOCK DATA is an obsolescent language feature in Standard Fortran.

BLOCK DATA [name]

   [specification-part]

END [BLOCK DATA [name]]

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

RECORD1

USE 3

EQUIVALENCE

Record structure declaration1

IMPLICIT

SAVE

1 For more information, see RECORD statement and record structure declarations.

2 Can only contain attributes: DIMENSION, INTRINSIC, PARAMETER, POINTER, SAVE, STATIC, or TARGET.

3 Allows access to only named constants.

Description

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.

Example

The following shows 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

The following shows another example:

C      Main Program
       CHARACTER(LEN=10) family
       INTEGER a, b, c, d, e
       REAL X(10), Y(4)
       COMMON/Lakes/a,b,c,d,e,family/Blk2/x,y
       ...
C      The following block-data subprogram initializes
C      the named common block /Lakes/:
C
       BLOCK DATA InitLakes
       COMMON /Lakes/ erie, huron, michigan, ontario,
      +        superior, fname
       DATA erie, huron, michigan, ontario, superior /1, 2, 3, 4, 5/
       CHARACTER(LEN=10) fname/'GreatLakes'/
       INTEGER erie, huron, michigan, ontario, superior
       END