Use association allows the entities in a module to be accessible to other scoping units. The mechanism for use association is the USE statement. The USE statement provides access to all public entities in the module, unless ONLY is specified. In this case, only the entities named in the ONLY list can be accessed.
Host association allows the entities in a host scoping unit to be accessible to an internal procedure, derived-type definition, or module procedure contained within the host. The accessed entities are known by the same name and have the same attributes as in the host. Entities that are local to a procedure are not accessible to its host.
Use or host association remains in effect throughout the execution of the executable program.
If an entity that is accessed by use association has the same nongeneric name as a host entity, the host entity is inaccessible. A name that appears in the scoping unit as an external name in an EXTERNAL statement is a global name, and any entity of the host that has this as its nongeneric name is inaccessible.
An interface body does not access named entities by host association, but it can access entities by use association.
If a procedure gains access to a pointer by host association, the association of the pointer with a target that is current at the time the procedure is invoked remains current within the procedure. This pointer association can be changed within the procedure. After execution of the procedure, the pointer association remains current, unless the execution caused the target to become undefined. If this occurs, the host associated pointer becomes undefined.
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. Z END SUBROUTINE CONS ! is available through use association. END PROGRAM DEMO
For More Information: