Visible to Intel only — GUID: GUID-4E4AA055-2036-4FEB-9105-70C0CC1CA3D6
Visible to Intel only — GUID: GUID-4E4AA055-2036-4FEB-9105-70C0CC1CA3D6
ASSOCIATE
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.
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