## 2.2.2 Variables

A variable is represented by a symbolic name associated with a single storage location. The value of the variable is the value currently stored in that location; you can change its value at any point in a program by assigning a new value to it.

Variables are classified by data type, as constants are. The data type of a variable indicates the type of data it contains, its precision, and its storage requirements. When data of any type is assigned to a variable, it is converted, if necessary, to the data type of the variable.

The data type of a variable can be established by any of the following:

- A type declaration statement

- An IMPLICIT statement

- Predefined typing rules

All variables are scalar references because they resolve into single data items having a data type.

Associating Variables

Two or more variables are associated with each other when each is associated with the same storage location. They are partially associated when part (but not all) of the storage associated with one variable is the same as part or all of the storage associated with another variable.

Association and partial association occur when you use COMMON or EQUIVALENCE statements, map declarations (within structure declarations), or actual arguments and dummy arguments in subprogram references.

If variables of different data types are associated (or partially associated) with the same storage location, and the value of one variable is defined (for example, by assignment), the value of the other variable becomes undefined. This occurs because a variable is defined only if the storage associated with it contains data of the same type as the name.

A variable can be defined before program execution by a DATA statement or during execution by an assignment or input statement.

For More Information:

- On the form of a symbolic name, see Section 1.3.3.

- On scalar references, see Section 2.2.6.

- On the COMMON statement, see Section 4.3.

- On the EQUIVALENCE statement, see Section 4.7.

- On map declarations, see Section 4.17.3.

- On the DATA statement, see Section 4.4.

Previous Page Next Page Table of Contents