



DATA Statement DATA statement is used to specify initial values for variables and array
elements. The DATA statement is non-executable, but in a main program
unit it has the same effect as a set of assignment statements at the very
beginning of the program. Thus in a main program a DATA statement like this:
DATA LINES/625/, FREQ/50.0/, NAME/'PAL'/ |
LINES = 625 FREQ = 50.0 NAME = 'PAL' |
In a procedure, however, these two methods are not equivalent, especially in the
case of items which are modified as the procedure executes. A DATA statement only
sets the values once at the start of execution, whereas assignment statements will do
so every time the procedure is called.
It is important to distinguish between the DATA and PARAMETER statements. The
DATA statement merely specifies an initial value for a variable (or array) which
may be altered during the course of execution. The PARAMETER statement
specifies values for constants which cannot be changed without recompiling the
program. If, however, you need an array of constants, for which there is no
direct support in Fortran, you should use an ordinary array with a DATA
statement to initialise its elements (and take care not to corrupt the contents
afterwards).
11.1 Defined and Undefined Values
11.2 Initialising Variables
11.3 Initialising Arrays
11.4 DATA Statements in Procedures
11.5 General Rules