Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran 90 Programmer's Reference: HP Fortran 90 Programmer's Reference > Chapter 7 Program units and procedures

Terminology and concepts

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

The following sections define the terms and explain the concepts that are mentioned throughout this chapter.

Program units

A program consists of the following program units:

  • Main program unit

  • External procedure, which can be either a subroutine or a function

  • Module program unit

  • Block data program unit

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:

  • The module program unit, which contains data declarations, user-defined type definitions, procedure interfaces, common block declarations, namelist group declarations, and subprogram definitions used by other program units. Modules are described in “Modules”.

  • The block data program unit, which specifies initial values for variables in named common blocks. Block data program units are described in “Block data program unit”.

Procedures

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:

  • Intrinsic procedures are defined by the language and are available for use without any declaration or definition. Intrinsic procedures implement common computations that are important to scientific and engineering applications. Intrinsic procedures are described in detail in Chapter 11 “Intrinsic procedures”.

  • An external procedure is a separately compilable program unit whose name and any additional entry points have global scope. External procedures are described in “External procedures”.

  • An internal procedure has more limited accessibility than an external procedure. It can appear only within a main program unit or an external procedure and cannot be accessed outside of its hosting program unit. Internal procedures are described in “Internal procedures”.

  • A module procedure can be defined only within a module program unit and can be accessed only by use association. Module procedures are described in “Modules”.

Scope

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.

Association

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:

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.