Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Variables

A variable is a data object whose value can be changed (defined or redefined) at any point in a program. A variable can be any of the following:

  • A scalar

    A scalar is a single object that has a single value; it can be of any intrinsic or derived (user-defined) type.

  • An array

    An array is a collection of scalar elements of any intrinsic or derived type. All elements must have the same type and kind parameters.

  • A subobject designator

    A subobject is part of an object. The following are subobjects:

    An array element

    An array section

    A structure component

    A character substring

    For example, B(3) is a subobject (array element) designator for array B. A subobject cannot be a variable if its parent object is a constant.

  • A reference to a function that returns a data pointer

    A reference to a function that returns a data pointer is treated as a variable and is permitted in any variable-definition context .

The name of a variable is associated with a single storage location.

A designator is a name followed by zero or more component selectors, complex part selectors, array section selectors, array element selectors, image selectors, and substring selectors.

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

A variable is defined when you give it a value. A variable can be defined before program execution by a DATA statement or a type declaration statement. During program execution, variables can be defined or redefined in assignment statements and input statements, or undefined (for example, if an I/O error occurs). When a variable is undefined, its value is unpredictable.

When a variable becomes undefined, all variables associated by storage association also become undefined.

An object with subobjects, such as an array, can only be defined when all of its subobjects are defined. Conversely, when at least one of its subobjects are undefined, the object itself, such as an array or derived type, is undefined.