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 Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 7 Program units and procedures

Main program

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

A main program is a program unit. There must be exactly one main program in an executable program. Execution always begins with the main program.

The main program can determine the overall design and structure of the complete program and often performs various computations by referencing procedures. A program may consist of the main program alone, in which case all the program logic is contained within it.

A main program has the form:

[PROGRAM program-name]
[specification-part]
[execution-part]
[internal-procedure-part]
END [PROGRAM [program-name]]
program-name

i s the name of the program. program-name can appear on the END PROGRAM statement only if it also appears on the PROGRAM statement; the name must be the same in both places.

specification-part

is zero or more of the statements listed in Table 7-1 “Specification statements” as well as any of the following:

  • Type declaration statement

  • Derived-type definition

  • Interface block

  • Statement function

  • Cray-style pointer statement (HP extension)

  • Structure definition (HP extension)

  • Record declaration (HP extension)

execution-part

is zero or more of the statements or constructs listed in Table 7-2 “Executable statements” as well as any of the following:

  • Assignment statement

  • Pointer assignment statement

internal-procedure-part

takes the form:

CONTAINS
[
internal-procedure]...

where internal-procedure is one or more internal procedures; see “Internal procedures”.

Table 7-1 Specification statements

ALLOCATABLEFORMATPOINTER
COMMONIMPLICITSAVE
DATAINTRINSICSTATIC
DIMENSIONNAMELISTUSE
EQUIVALENCEOPTIONALVIRTUAL
EXTERNALPARAMETERVOLATILE

 

Table 7-2 Executable statements

ACCEPTELSEON
ALLOCATEELSE IFOPEN
ASSIGNELSEWHEREPAUSE
BACKSPACEENCODEPRINT
CALLENDREAD

CASE construct

ENDFILEREWIND
CLOSEEXITSTOP
CONTINUEFORMAT

TYPE (I/O)

CYCLEGO TOWHERE
DEALLOCATEIF

WHERE construct

DECODE

IF construct

WRITE
DOINQUIRE

DO construct

NULLIFY

 

The only required component of a main program unit is the END statement. The following is therefore a valid, compilable program:

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