Block Data

Statement Purpose

The Block Data statement is the first line that appears in a block data program unit. The block data construct is then used to provide initial values to variables that appear in named common blocks within the program. Please note that the block data statement can either be named or unnamed.

Rules on the Use of the Block Data Construct

The discussion of the block data statement would not be complete without an overall description of the block data program unit and the rules that govern its use. The important things to remember are listed below


First, a block data unit can be either named or unnamed. A unnamed block data unit would start out with only the block data statement like so:
		block data
On the other hand, a named block data unit would have the block data statement and then a name following the block data statement. This would simply look like the following:
		block data first
The actual declaration and initialization of variables inside the block data unit is not unlike what might be done for other variables in the main program. Although, make sure that the names of the common blocks that are going to be initialized appear after the block data statement. Then, at the end of the block would be an end statement. Therefore, an entire block data unit might appear like the following.
		Block data first
		common/global/ x(15),g,n
		real x(15),g,n
		integer ldata,lmax,lmin
		data g,n,x/9.81,6.02e23,15*3.0/
		data lmin,lmax/1,100/
		end block data first

For additional examples and information see

lecture thirty eight

example: fall.f

Up one level / Home

Written by Jason Wehr : and Maintained by John Mahaffy :