Visible to Intel only — GUID: GUID-EC99CA8A-CFD5-45AF-83C1-42B2EAB552BA
Visible to Intel only — GUID: GUID-EC99CA8A-CFD5-45AF-83C1-42B2EAB552BA
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. If it has the OPTIONAL attribute, it must be PRESENT if the assignment statement is executed. |
expression |
Is of a compatible intrinsic type if variable is of intrinsic type or of the same derived type as variable, if variable is not polymorphic; otherwise, it must be of a type that is type compatible with variable. Its shape must conform with variable. Unless the variable is unlimited polymorphic, an intrinsic typed expression is converted to the same type and kind as variable when possible. |
Description
Before a value is assigned to variable, expression and any expressions within variable are evaluated. No definition of expressions in variable can affect or be affected by the evaluation of expression.
variable must be allocatable if it is polymorphic. The value of expression is assigned to the target of variable if variable is a pointer.
If variable is an allocatable array, expression must have the same rank. If variable is an allocated allocatable variable, it is deallocated under these conditions:
If expression is an array of with a different shape
If any corresponding length parameter values of variable and expression differ
If variable is polymorphic and the dynamic type or any corresponding kind type parameter values of variable and expression differ
If variable is unallocated, or becomes unallocated during the assignment statement, it becomes allocated with the following:
The same bounds as before if variable is an array and expression is a scalar
The same shape as expression with each lower bound set to the corresponding element of LBOUND(expression) if expression is an array
The same dynamic type and kind type parameter values if expression is polymorphic
The deferred type parameter values that are the same as the corresponding type parameter values of expression
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 not a coarray, or of a type that has a coarray potential subobject component.
If expression is an array, then variable must also be an array.
If variable is polymorphic, it must be allocatable and it must not be a coarray or a data object with a coarray potential subobject component. A 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 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 variable is of type character, the expression must have the same kind type parameter.
If the variable is of derived type, the following rules apply:
Each kind type parameter of variable must have the same value as the corresponding kind type parameter of expression.
Each length type parameter of variable must have the same value as the corresponding type parameter of expression unless the variable is an allocatable array and its corresponding type parameter is deferred.
If 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 variable is a coarray or a coindexed object and is allocatable, it must be allocated.
If variable is a pointer, it must be associated with a definable target such that the type, type parameters, and shape of the target and the expression conform.
If the type of the assignment is C_PTR, C_FUNPTR, or TEAM_TYPE, variable becomes undefined if variable and expression are not on the same image.
If variable is of enum type type-name, and expression is of integer type, the behavior is as if the statement was written as:
variable = type-name (expression)
where type-name (expression) is an enum constructor.
- Numeric Assignment Statements
- Logical Assignment Statements
- Character Assignment Statements
- Derived-Type Assignment Statements
- Array Assignment Statements
- Examples of Intrinsic Assignment to Polymorphic Variables