Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

Use and Host Association

Use association allows the entities in a module to be accessible to other scoping units. Host association allows the entities in a host scoping unit to be accessible to an internal subprogram, a module subprogram, or submodule program.

Use association and host association remain in effect throughout the execution of the executable program.

An interface body does not access named entities by host association, but it can access entities by use association.

Example

The following example shows host and use association:

 MODULE SHARE_DATA
   REAL Y, Z
 END MODULE

 PROGRAM DEMO
   USE SHARE_DATA         ! All entities in SHARE_DATA are available
   REAL B, Q              !   through use association.
   ...
   CALL CONS (Y)
 CONTAINS
   SUBROUTINE CONS (Y)    ! Y is a local entity (dummy argument).
     REAL C, Y
     ...
     Y = B + C + Q + Z    ! B and Q are available through host association.
     ...                  !   C is a local entity, explicitly declared.  
   END SUBROUTINE CONS    !   is available through use association.
 END PROGRAM DEMO

See Also