HP OpenVMS Systems Documentation
HP Fortran for OpenVMS
When a generic procedure reference is made, a specific procedure is invoked. If the following rules are used, the generic reference will be unambiguous:
When an interface block extends an intrinsic procedure, operator, or assignment, the rules apply as if the intrinsic consists of a collection of specific procedures, one for each allowed set of arguments.
When a generic procedure is accessed from a module, the rules apply to all the specific versions, even if some of them are inaccessible by their specific names.
The procedure name in a procedure reference is either established to be
generic or specific, or is not established. The rules for resolving a
procedure reference differ depending on whether the procedure is
established and how it is established.
15.4.1 References to Generic Names
Within a scoping unit, a procedure name is established to be generic if any of the following is true:
To resolve a reference to a procedure name established to be generic, the following rules are used in the order shown:
In a scoping unit, a procedure name is established to be specific if it is not established to be generic and any of the following is true:
To resolve a reference to a procedure name established to be specific, the following rules are used in the order shown:
In a scoping unit, a procedure name is not established if it is not determined to be generic or specific.
To resolve a reference to a procedure name that is not established, the following rules are used in the order shown:
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:
Example 15-1 shows name, pointer, and storage association between an external program unit and an external procedure.
|Example 15-1 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 ...
Name association allows an entity (such as the name of a variable,
constant, or procedure) to be accessed from different scoping units by
the same name or by different names. There are three types of name
association: argument, use, and host.
220.127.116.11 Argument Association
Execution of a procedure reference establishes argument association between an actual argument and its corresponding dummy argument. The name of a dummy argument can be different from the name of its associated actual argument (if any).
When the procedure completes execution, the argument association is terminated.
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.
Implicit declarations can cause problems for host association. It is recommended that you use IMPLICIT NONE in both the host and the contained procedure, and that you explicitly declare all entities.
When all entities are explicitly declared, local declarations override host declarations, and host declarations that are not overridden are available in the contained procedure.
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
A pointer can be associated with a target. At different times during the execution of a program, a pointer can be undefined, associated with different targets, or be disassociated. The initial association status of a pointer is undefined. A pointer can become associated by the following:
A pointer becomes disassociated if any of the following occur:
When a pointer is associated with a target, the definition status of the pointer is defined or undefined, depending on the definition status of the target. A target is undefined in the following cases:
If a pointer is associated with a definable target, the definition status of the pointer can be defined or undefined, according to the rules for a variable.
If the association status of a pointer is disassociated or undefined, the pointer must not be referenced or deallocated.
Whatever its association status, a pointer can always be nullified, allocated, or associated with a target. When a pointer is nullified, it is disassociated. When a pointer is allocated, it becomes associated, but is undefined. When a pointer is associated with a target, its association and definition status are determined by its target.
Storage association is the association of two or more
data objects. It occurs when two or more storage sequences share (or
are aligned with) one or more storage units. Storage
sequences are used to describe relationships among variables, common
blocks, and result variables.
18.104.22.168 Storage Units and Storage Sequence
A storage unit is a fixed unit of physical memory allocated to certain data. A storage sequence is a sequence of storage units. The size of a storage sequence is the number of storage units in the storage sequence. A storage unit can be numeric, character, or unspecified.
A nonpointer scalar of type default real, integer, or logical occupies one numeric storage unit. A nonpointer scalar of type double precision real or default complex occupies two contiguous numeric storage units. In HP Fortran, one numeric storage unit corresponds to 4 bytes of memory.
A nonpointer scalar of type default character with character length 1 occupies one character storage unit. A nonpointer scalar of type default character with character length len occupies len contiguous character storage units. In HP Fortran, one character storage unit corresponds to 1 byte of memory.
Table 15-2 lists the storage requirements (in bytes) for the intrinsic data types.
|Data Type||Storage Requirements (in bytes)|
|LOGICAL||2, 4, or 8 1|
|REAL||4, 8, or 16 2|
|COMPLEX||8, 16, or 32 2|
A nonpointer scalar of sequence derived type occupies a sequence of storage sequences corresponding to the components of the structure, in the order they occur in the derived-type definition. (A sequence derived type has a SEQUENCE statement.)
A pointer occupies a single unspecified storage unit that is different from that of any nonpointer object and is different for each combination of type, type parameters, and rank.
The definition status and value of a data object affects the definition status and value of any storage-associated entity.
When two objects occupy the same storage sequence, they are totally storage-associated. When two objects occupy parts of the same storage sequence, they are partially associated. An EQUIVALENCE statement, a COMMON statement, or an ENTRY statement can cause total or partial storage association of storage sequences.