9 DATA STATEMENT

A DATA statement is used to provide initial values for variables, arrays, array elements, and substrings. A DATA statement is nonexecutable and may appear in a program unit anywhere after the specification statements, if any.

All initially defined entities are defined when an executable program begins execution. All entities not initially defined, or associated with an initially defined entity, are undefined at the beginning of execution of an executable program.

9.1 Form of a DATA Statement

The form of a DATA statement is:
DATA nlist /clist/ [ nlist /clist/]...

9.2 DATA Statement Restrictions

Names of dummy arguments, functions, and entities in blank common (including entities associated with an entity in blank common) must not appear in the list nlist . Names of entities in a named common block may appear in the list nlist only within a block data subprogram.

There must be the same number of items specified by each list nlist and its corresponding list clist . There is a one-to-one correspondence between the items specified by nlist and the constants specified by clist such that the first item of nlist corresponds to the first constant of clist , etc. By this correspondence, the initial value is established and the entity is initially defined. If an array name without a subscript is in the list, there must be one constant for each element of that array. The ordering of array elements is determined by the array element subscript value ( 5.2.4).

The type of the nlist entity and the type of the corresponding clist constant must agree when either is of type character or logical. When the nlist entity is of type integer, real, double precision, or complex, the 1corresponding clist constant must also be of type integer, real, double precision, or complex; if necessary, the clist constant is converted to the type of the nlist entity according to the rules for arithmetic conversion (Table 4). Note that if an nlist entity is of type double precision and the clist constant is of type real, the processor may supply more precision derived from the constant than can be contained in a real datum.

Any variable, array element, or substring may be initially defined except for:

  1. an entity that is a dummy argument,
  2. an entity in blank common, which includes an entity associated with an entity in blank common, or
  3. a variable in a function subprogram whose name is also the name of the function subprogram or an entry in the function subprogram.

A variable, array element, or substring must not be initially defined more than once in an executable program. If two entities are associated, only one may be initially defined in a DATA statement in the same executable program.

Each subscript expression in the list nlist must be an integer constant expression except for implied-DO-variables as noted in 9.3. Each substring expression in the list nlist must be an integer constant expression.

9.3 Implied-DO in a DATA Statement

The form of an implied-DO list in a DATA statement is:
( dlist, i = m ,  m  [,m  ] )
                             1    2    3

The range of an implied-DO list is the list dlist . An iteration count and the values of the implied-DO-variable are established from m 1 , m 2 , and m 3 exactly as for a DO-loop ( 11.10), except that the iteration count must be positive. When an implied-DO list appears in a DATA statement, the list items in dlist are specified once for each iteration of the implied-DO list with the appropriate substitution of values for any occurrence of the implied-DO-variable i . The appearance of an implied-DO-variable name in a DATA statement does not affect the definition status of a variable of the same name in the same program unit.

Each subscript expression in the list dlist must be an integer constant expression, except that the expression may contain implied-DO-variables of implied-DO lists that have the subscript expression within their ranges.

The following is an example of a DATA statement that contains implied-DO lists:

DATA (( X(J,I), I=1,J), J=1,5) / 15*0. /

9.4 Character Constant in a DATA Statement

An entity in the list nlist that corresponds to a character constant must be of type character.

If the length of the character entity in the list nlist is greater than the length of its corresponding character constant, the additional rightmost characters in the entity are initially defined with blank characters.

If the length of the character entity in the list nlist is less than the length of its corresponding character constant, the additional rightmost characters in the constant are ignored.

Note that initial definition of a character entity causes definition of all of the characters in the entity, and that each character constant initially defines exactly one variable, array element, or substring.

'




[Contents] [Previous] [Next]
This document was translated by troff2html v0.21 on August 16, 1995.