next up previous contents
Next: Main Program Example Up: Program Units Previous: Program Units

 

Main Program Syntax

This is the only compulsory program unit, every program must have one:

 
[ PROGRAM [ < main program name > ] ]

...

< declaration of local objects >

...

< executable stmts >

...

[ CONTAINS

< internal procedure definitions > ]

END [ PROGRAM [ < main program name > ] ]

The PROGRAM statement and < main program name > are optional, however, it is good policy to always use them. < main program name > can be any valid Fortran 90 name.

The main program contains declarations and executable statements and may also contain internal procedures. These internal procedures are separated from the surrounding program unit, the host (in this case the main program), by a CONTAINS statement. Internal procedures may only be called from within the surrounding program unit and automatically have access to all the host program unit's declarations but may also override them. Please note that some implementation of HPF may not yet support internal procedures.

 

  figure8481
Figure 22: Schematic Diagram of a Main Program

Internal procedures may not contain further internal procedures, in other words the nesting level is a maximum of 1. The diagram shows two internal procedures, Sub1 and Funkyn however, there may be any number of internal procedures (subroutines or functions) which are wholly contained within the main program.

The main program may also contain calls to external procedures. This will be discussed later (see Section 14).

The main program must contain an END statement as its last (non-blank) line. For neatness sake this should really be suffixed by PROGRAM (so it reads END PROGRAM) and should also have the name of the program attached too. Using as descriptive as possible END statements helps to reduce confusion.

Return to corresponding overview page gif




next up previous contents
Next: Main Program Example Up: Program Units Previous: Program Units

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.