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

ID 767251
Date 11/07/2023
Public

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

Document Table of Contents

Intrinsic Assignment Statements

Intrinsic assignment is used to assign a value to a nonpointer variable. In the case of pointers, intrinsic assignment is used to assign a value to the target associated with the pointer variable. The value assigned to the variable (or target) is determined by evaluation of the expression to the right of the equal sign.

An intrinsic assignment statement takes the following form:

variable = expression

variable

Is the name of a scalar or array of intrinsic or derived type (with no defined assignment). The array cannot be an assumed-size array, and neither the scalar nor the array can be declared with the PARAMETER or INTENT(IN) attribute.

expression

Is of intrinsic type or the same derived type as variable. Its shape must conform with variable. If necessary, it is converted to the same type and kind as variable.

Description

Before a value is assigned to the variable, the expression part of the assignment statement and any expressions within the variable are evaluated. No definition of expressions in the variable can affect or be affected by the evaluation of the expression part of the assignment statement.

NOTE:

When the runtime system assigns a value to a scalar integer or character variable and the variable is shorter than the value being assigned, the assigned value may be truncated and significant bits (or characters) lost. This truncation can occur without warning, and can cause the runtime system to pass incorrect information back to the program.

The following rules apply to intrinsic assignment statements:

  • The variable and expression must be conformable unless the variable is an allocatable array that has the same rank as the expression, and is neither a coarray nor a coindexed object.

  • If the expression is an array, then the variable must also be an array.

  • If the variable is polymorphic, it must be allocatable and it must not be a coarray. The polymorphic variable must be type compatible with the expression and of the same rank. If it is allocated but the dynamic type differs from that of the expression, it is deallocated. If it is not allocated or becomes deallocated, it is allocated with the dynamic type of the expression.

  • If the variable is a pointer, it must be associated with a definable target. The shape of the target and expression must conform and their type and kind parameters must match.

  • If the variable is of type character, the expression must have the same kind type parameter.

  • If the variable is of derived type:

    • Each kind type parameter of the variable must have the same value as the corresponding kind type parameter of the expression.

    • Each length type parameter of the variable must have the same value as the corresponding type parameter of the expression unless the variable is an allocatable array and its corresponding type parameter is deferred.

  • If the variable is a coindexed object, each deferred-length type parameter must have the same value as the corresponding type parameter of the expression. Also, the variable must not be polymorphic, and it must not have an allocatable ultimate component.

  • If the type of the assignment is C_PTR, C_FUNPTR, or TEAM_TYPE, the variable becomes undefined if variable and expression are not on the same image.