next up previous contents
Next: Include files Up: The Building Blocks of Previous: F77 Global Storage. Storage   Contents

BLOCK DATA statements

To initialize the variables in a COMMON BLOCK we can use the BLOCK DATA construct. For example,

 
block data coeff_init 
  integer :: n
  real, dimension(0:10) :: b
  common /coeff/ n, b
  data n /10/ 
  data b /1.0000000000e+00, 1.0000000000e+00, 0.5000000000e+00, &
          0.1666666667e+00, 4.1666666667e-02, 8.3333333333e-03, &
	  1.3888888889e-03, 1.9841269841e-04, 2.4801587302e-05, &
	  2.7557319224e-06, 2.7557319224e-07/ 
end block data coeff_init

initializes the elements of the (coeff) COMMON block variables to n=1, x(1) = 3.0, x(2) = 5.0. Note that a BLOCK DATA construct includes the COMMON block statement, and the definitions of the COMMON block variables; also, it contains the DATA statements, which initialize the variables with the prescribed values (i.e. at compile time the allocated memory slots for the specified variables are written with the given initial values).

The statement

 
save /coeff/
makes the common block static storage; it will be kept in memory for the whole duration of the current execution (in practice most Fortran systems will automatically make all common blocks static, but we should not rely on this!).



Adrian Sandu 2001-08-26