Block Data Subprograms [ HP FORTRAN 77/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP FORTRAN 77/iX Programmer's Guide
Block Data Subprograms
Block data subprograms define the size and reserve storage space for
common blocks. Block data subprograms can also initialize the variables
and arrays declared in the common block. A block data subprogram begins
with a BLOCK DATA statement and ends with an END statement.
For example, consider this block data subprogram:
BLOCK DATA datablock1
INTEGER i, n, t
REAL x, y, z
COMMON /block1/ n, t
COMMON /block2/ i, x(10)
DATA n, t /5, 25/
DATA x /10*1.0/
END
This block data subprogram specifies that n and t are in named common
block block1 and these are to be initialized to 5 and 25, respectively.
The block block2 contains i and the ten elements in array x. The
variable i is undefined and each element in array x is initialized to
1.0.
The block data subprogram is a nonexecutable program module that can be
placed anywhere after the main program. The name of the subprogram can
be omitted, but a program cannot have more than one unnamed block data
subprogram.
The BLOCK DATA statement must be the first noncomment statement in a
block data subprogram. Each common block referenced in an executable
FORTRAN program can be defined in a block data subprogram.
Specification statements, data initialization, and blank common
statements are allowed in the body of a block data subprogram. Block
data statements cannot contain executable statements. Acceptable
statements include: COMMON, DATA, DIMENSION, IMPLICIT, PARAMETER, SAVE,
and type specification (INTEGER*4, REAL*8, and so on), statements.
EXTERNAL and INTRINSIC statements are not allowed.
Here is another example of a BLOCK DATA subprogram:
BLOCK DATA null
COMMON /xxx/ x(5), b(10), c
COMMON /set1/ iy(10)
DATA iy/1,2,4,8,16,32,64,128,256,512/
DATA b/10*1.0/
END
The name null is the optional name of a BLOCK DATA subprogram used to
reserve storage locations for the named common blocks xxx and set1.
Arrays iy and b are initialized in the DATA statements. The remaining
elements in the common block can optionally be initialized or typed in
the block data subprogram.
MPE/iX 5.0 Documentation