Association

Association allows different program units to access the same value through different names. Entities are associated when each is associated with the same storage location.

There are three kinds of association:

The following example shows name, pointer, and storage association between an external program unit and an external procedure.

Example of Name, Pointer, and Storage Association

! Scoping Unit 1: An external program unit

 

REAL A, B(4)

REAL, POINTER :: M(:)

REAL, TARGET :: N(12)

COMMON /COM/...

EQUIVALENCE (A, B(1)) ! Storage association between A and B(1)

M => N ! Pointer association

CALL P (actual-arg,...)

...

 

! Scoping Unit 2: An external procedure

SUBROUTINE P (dummy-arg,...) ! Name and storage association between ! these arguments and the calling ! routine's arguments in scoping unit 1

 

COMMON /COM/... ! Storage association with common block COM

! in scoping unit 1

REAL Y

CALL Q (actual-arg,...)

CONTAINS

SUBROUTINE Q (dummy-arg,...) ! Name and storage association between ! these arguments and the calling

! routine's arguments in host procedure ! P (subprogram Q has host association ! with procedure P)

Y = 2.0*(Y-1.0) ! Name association with Y in host procedure P

...