FORTRAN Concepts

FORTRAN-SO

2.1.2 The PROG RAM Statement

The PROGRAM statement is used to name a program. This statement is optional, but when present must be the first statement of a main program. It has the format

PROGRAM name

where 'name' is the symbolic name of the program. Only one PROGRAM statement is allowed per program. The main program can contain any other statement except FUNCTION, SUBROUTINE, BLOCK DATA, SAVE, or RETURN.

The scope of symbolic names is discussed later in this chapter (section 2.5.5). For the moment, suffice it to say that the program name is 'global' to the entire executable program. It cannot be the same as the name of an external procedure, BLOCK DATA subprogram, common block, or 'local' symbol name in the main program.

2.1.3 Statements and Lines

AFORTRAN-SO source program is made up of compiler controls and FORTRAN statements.

Compiler controls direct the operation of a particular FORTRAN compiler, telling it what kind of output to produce, the form of list output, etc. Controls are discuss- ed in detail in the compiler operator's manual, and a few will be mentioned in this manual where relevant. In general, controls can be embedded in FORTRAN source code and are identified by a '$' in the first character position ('column' 1).

All but two types of FORTRAN statement begin with a keyword and are identified by that keyword. For example, the PROGRAM statement just described begins with the keyword 'PROGRAM.' Only 'assignment' and 'statement function' statements do not begin with keywords. The 'AVG = HITS/AB' statement in Figure 1-1 is an example of an arithmetic assignment statement.

2.1.3.1Statement Labels. Any statement can be labeled; any statement to be referenced from elsewhere in the program must be labeled. The label is a 1-5 digit, unsigned, nonzero, integer constant written anywhere in columns 1-5 of a state- ment's initial line. No two statements may have the same label within the same pro- gram unit.

2.1.3.2Line Format. A FORTRAN statement consists of one or more lines. The first line of a statement is called the initial line; subsequent lines in the same state- ment are called continuation lines.

A FORTRAN line can have up to 72 characters. The first six character positions (referred to as 'columns' 1-6) contain information characterizing the line. The actual statement begins in column 7. A statement can extend over nine continuation lines (columns 7-72) for a total of 660 characters.

An integer anywhere in columns 1-5 is a statement label. If column 6 is blank or con- tains a '0,' the line is an initial line; if column 6 contains any other character, the line is a continuation line. Columns 1-5 of a continuation line must be blank.

Specific Intel FORTRAN compilers may allow exceptions to the standard line for- mat. See Section F.2.4 of Appendix F for details.

2-2

Page 14
Image 14
Intel fortran-80 manual Prog RAM Statement, Statements and Lines, Program name