Visible to Intel only — GUID: GUID-57F68FBB-B689-4EE6-9456-B8257D5C84B8
Visible to Intel only — GUID: GUID-57F68FBB-B689-4EE6-9456-B8257D5C84B8
Derived-Type Assignment Statements
In derived-type assignment statements, the variable and expression must be of the same derived type. There must be no accessible interface block with defined assignment for objects of this derived type.
The derived-type assignment is performed as if each component of the expression is assigned to the corresponding component of the variable. Pointer assignment is performed for pointer components, defined assignment for each nonallocatable, nonpointer component of a type that has a type-bound component, and intrinsic assignment is performed for other nonpointer, nonallocatable components and for allocated coarray components.
For a noncoarray allocatable component, if the component of the variable (LHS of assignment statement) is allocated, it is deallocated. If the component of the expression (RHS of assignment statement) is allocated, the corresponding component of the variable is allocated with the same dynamic type and type parameters as the component of the expression.
The value of the component of the expression is assigned to the component of the variable using defined assignment if the component has a type-bound defined assignment consistent with the component; otherwise, intrinsic assignment is used for the dynamic type of that component.
The order of component assignment can happen in any order.
Examples
The following example shows derived-type assignment:
TYPE DATE
LOGICAL(1) DAY, MONTH
INTEGER(2) YEAR
END TYPE DATE
TYPE(DATE) TODAY, THIS_WEEK(7)
TYPE APPOINTMENT
...
TYPE(DATE) APP_DATE
END TYPE
TYPE(APPOINTMENT) MEETING
DO I = 1,7
CALL GET_DATE(TODAY)
THIS_WEEK(I) = TODAY
END DO
MEETING%APP_DATE = TODAY