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 asso-entity[, asso-entity]...
block
END ASSOCIATE [name]
name |
(Optional) Is the name of the ASSOCIATE construct. |
||||
asso-entity |
Is associate-name => selector associate-name Is an identifier that becomes associated with the selector. It becomes the associating entity. The identifier name must be unique within the construct. selector Is an expression or variable. It becomes the associated entity. |
||||
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, the associating entity does not have the ALLOCATABLE attribute. If the selector has the POINTER attribute, then the associating entity has the TARGET attribute. If the selector has the TARGET, VOLATILE, or ASYNCHRONOUS attribute, the 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
Copyright © 1996-2010, Intel Corporation. All rights reserved.