Intel® Fortran Compiler 18.0 Developer Guide and Reference
Statement: Marks the beginning of an ASSOCIATE construct. The ASSOCIATE construct creates a temporary association between a named entity and a variable or the value of an expression. The association lasts for the duration of the block.
[name:] ASSOCIATE (assoc-entity[, assoc-entity]...)
block
END ASSOCIATE [name]
name |
(Optional) Is the name of the ASSOCIATE construct. |
assoc-entity |
Is associate-name => selector
|
block |
Is a sequence of zero or more statements or constructs. |
If a construct name is specified at the beginning of an ASSOCIATE statement, the same name must appear in the corresponding END ASSOCIATE statement. The same construct name must not be used for different named constructs in the same scoping unit. If no name is specified at the beginning of an ASSOCIATE statement, you cannot specify one following the END ASSOCIATE statement.
During execution of the block within the construct, each associate-name identifies an entity, which is associated with the corresponding selector. The associating entity assumes the declared type and type parameters of the selector.
You can only branch to an END ASSOCIATE statement from within its ASSOCIATE construct.
Within an ASSOCIATE construct, each associating entity has the same rank as its associated selector. The lower bound of each dimension is the result of the intrinsic function LBOUND applied to the corresponding dimension of selector. The upper bound of each dimension is one less than the sum of the lower bound and the extent.
If the selector has the ALLOCATABLE attribute, it must be allocated. The associating entity is associated with the associated entity and does not have the ALLOCATABLE attribute. If the selector has the POINTER attribute, it must be associated. The associating entity is associated with the target of the pointer and does not have the POINTER attribute. If the selector has the TARGET, VOLATILE, or ASYNCHRONOUS attribute, an associating entity that is a variable has those attributes.
This construct is useful when you want to simplify multiple accesses to a variable that has a lengthy description; for example, if the variable contains multiple subscripts and component names.
The following shows an expression as a selector:
ASSOCIATE (O => (A-F)**2 + (B+G)**2)
PRINT *, SQRT (O)
END ASSOCIATE
The following shows association with an array section:
ASSOCIATE (ARRAY => AB % D (I, :) % X)
ARRAY (3) = ARRAY (1) + ARRAY (2)
END ASSOCIATE
Without the ASSOCIATE construct, this is what you would need to write:
AB % D (I, 3) % X = AB % D (I, 1) % X + AB % D (I, 2) % X