ASSOCIATE construct

Standard: F77 F90 F95 F2003 F2008 F2018 Example program


<Syntax>

associate-stmt
      block
end-associate-stmt

The syntax of the ASSOCIATE statement (associate-stmt) is as follows.

[ construct-name : ] ASSOCIATE ( association-list )

where:
association-list ::= association [ , association ]...
association ::= associate-name => selector
selector ::= variable | expr

If the ASSOCIATE statement has a construct name (construct-name), the END ASSOCIATE statement needs to have the same construct name.

<Semantics>

The ASSOCIATE construct associates one or more names with a variable(s) and/or value(s) throughout execution of the construct. Each associate-name of an ASSOCIATE construct is local to the construct; its type and rank are determined by the construct and are unaffected by any declaration outside the construct.

Throughout the construct, the associate name is a variable if and only if the selector is a variable; any changes to the associate name affect the variable with which it is associated. If the selector is an expression (expr), the associate name is not permitted to appear in any context that requires a variable.

The associate name is polymorphic if and only if its selector is polymorphic. If the selector is a pointer or allocatable, it must be associated or allocated on execution of the ASSOCIATE statement; the associate name does not have the POINTER or ALLOCATABLE attribute (but will have the TARGET attribute if the selector has either the POINTER or TARGET attribute).

<Related>

END ASSOCIATE statement, SELECT TYPE construct