ASSOCIATE Construct (Fortran 2003)
The ASSOCIATE construct creates an association between an identifier and a variable, or the value of an expression, during the execution of that construct. The identifier you specify in an ASSOCIATE construct becomes an associating entity. You can create multiple associating entities inside a single ASSOCIATE construct.
Syntax
- ASSOCIATE_statement
- See ASSOCIATE (Fortran 2003) for syntax details
- END_ASSOCIATE_statement
- See END (Construct) for syntax details
Execution of an ASSOCIATE construct causes execution of an ASSOCIATE_statement followed by the ASSOCIATE_statement_block. During execution of that block, the construct creates an association with an identifier and the corresponding selector. The associating entity assumes the declared type and type parameters of the selector. The name of the associating entity is an associate name. For further information on associate names, see Associate names.
Examples
PROGRAM ASSOCIATE_EXAMPLE
REAL :: MYREAL, X, Y, THETA, A
X = 0.42
Y = 0.35
MYREAL = 9.1
THETA = 1.5
A = 0.4
ASSOCIATE ( Z => EXP(-(X**2+Y**2)) * COS(THETA), V => MYREAL)
PRINT *, A+Z, A-Z, V
V = V * 4.6
END ASSOCIATE
PRINT *, MYREAL
END PROGRAM ASSOCIATE_EXAMPLE
0.4524610937 0.3475389183 9.100000381
41.86000061