HP 3000 Manuals

Ch 5. Subprograms [ HP FORTRAN 77/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Programmer's Guide

Chapter 5  Subprograms 

A subprogram is an independent section of code called by a main program
or by another subprogram.  Subprograms make programs more readable and
easier to maintain, write, and debug.

Subprograms can be grouped into these three categories:

   *   Subroutines

   *   Functions

          *   Function subprograms

          *   Statement functions

          *   Intrinsic functions

   *   Block Data Subprograms

A program unit, such as a main program or a subprogram, is a sequence of
FORTRAN statements.  Table 5-1  summarizes the components of program
units.

          Table 5-1.  Components of Program Units 

----------------------------------------------------------------------------
|                |                            |                            |
|   Component    |        Description         |       How Identified       |
|                |                            |                            |
----------------------------------------------------------------------------
|                |                            |                            |
| Main program   | Defines the main entry     | Can begin with the PROGRAM |
|                | point.                     | statement.                 |
|                |                            |                            |
----------------------------------------------------------------------------
|                |                            |                            |
| Subroutine     | Returns values through     | Begins with the SUBROUTINE |
|                | argument lists or common   | statement.                 |
|                | blocks.                    |                            |
|                |                            |                            |
----------------------------------------------------------------------------
|                |                            |                            |
| Function       | Returns values through the | Begins with the FUNCTION   |
|                | function name, argument    | statement.                 |
|                | lists, or common blocks.   |                            |
|                |                            |                            |
----------------------------------------------------------------------------
|                |                            |                            |
| Statement      | Calculates a single        | Defined in a program unit. |
| function       | result; cannot be          |                            |
|                | referenced outside of the  |                            |
|                | program unit that defines  |                            |
|                | it.                        |                            |
|                |                            |                            |
----------------------------------------------------------------------------
|                |                            |                            |
| Block data     | Provides initial values    | Begins with the BLOCK DATA |
| subprogram     | for named and blank common | statement.                 |
|                | blocks.                    |                            |
|                |                            |                            |
----------------------------------------------------------------------------

This chapter describes subroutine, function, and block data subprogams.



MPE/iX 5.0 Documentation