| United States-English |
|
|
|
![]() |
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 7 Program
units and proceduresTerminology and concepts |
|
The following sections define the terms and explain the concepts that are mentioned throughout this chapter. A program consists of the following program units:
A complete executable program contains one (and only one) main program unit and zero or more other program units, each of which is separately compilable. A program unit is an ordered set of constructs, statements, comments, and INCLUDE lines. The heading statement identifies the kind of program unit; it is optional in a main program unit only. An END statement marks the end of a program unit. The only executable program units are the main program and external procedures. Program execution begins with the first executable statement in the main program and ends (typically) with the last. During execution, if the main program references an external procedure, control passes to the procedure, which executes and returns control to the main program. An executing procedure can also reference other procedures or even reference itself recursively. The main program unit is described in “Main program”, and external procedures are described in “External procedures”. The nonexecutable program units are:
A procedure is a subroutine or function that contains a sequence of statements and that may be invoked during program execution. Depending on where and how it is used, a procedure can be one of the following:
All defined Fortran entities have a scope within which their properties are known. For example, a label used within a subprogram cannot be referenced directly from outside the subprogram; the subprogram is the scoping unit of the label. A variable declared within a subprogram has a scope that is the subprogram. A common block name can be used in any program unit, and it refers to the same entity—that is, the name has global scope. At the other extreme, the index variable used within an implied-DO loop in a DATA statement or array constructor has a scope consisting only of the implied-DO loop construct itself. If the concept of scope limits the accessibility of entities, then the concept of association permits different entities to become accessible to each other in the same or different scope. The different types of association are:
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||