Intel® Fortran Compiler 16.0 User and Reference Guide
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. |
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.
When the run-time 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 run-time 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. It must not be a coarray. The polymorphic variable must be type compatible with the expression. Otherwise, the declared types of the variable and expression must conform.
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.
The following sections discuss numeric, logical, character, derived- type, and array intrinsic assignment.