A statement takes one or more lines; the first line is called the initial line; the subsequent lines are called the continuation lines.
You can format a source line in either of two ways:
Standard fixed format
Tab format @
The standard fixed format source lines are defined as follows:
The first 72 columns of each line are scanned. See "Extended Lines".
The first five columns must be blank or contain a numeric label.
Continuation lines are identified by a nonblank, nonzero in column 6.
Short lines are padded to 72 characters.
Long lines are truncated. See "Extended Lines".
The tab-format source lines are defined as follows: @
A tab in any of columns 1 through 6, or an ampersand in column 1, establishes the line as a tab-format source line.
If the tab is the first nonblank character, the text following the tab is scanned as if it started in column 7.
A comment indicator or a statement number can precede the tab.
Continuation lines are identified by an ampersand (&) in column 1, or a nonzero digit after the first tab.
You can format lines both ways in one program unit, but not in the same line.
The default maximum number of continuation lines is 99 @ (1 initial and 99 continuation). To change this number of lines, use the -Nln option. @
To extend the source line length to 132 characters, use the -e option.@ Otherwise, by default, f77 ignores any characters after column 72.
Example: Compile to allow extended lines:
demo% f77 -e prog.f
Padding is significant in lines such as the two in the following DATA statement:
C 1 2 3 4 5 6 7 C23456789012345678901234567890123456789012345678901234567890123456789012 DATA SIXTYH/60H 1 /
A line with a c, C, *, d, D, or! in column one is a comment line, except that if the -xld option is set, then the lines starting with D or d are compiled as debug lines. The d, D, and! are nonstandard. @
If you put an exclamation mark (!) in any column of the statement field, except within character literals, then everything after the ! on that line is a comment. @
A totally blank line is a comment line.
Example: c, C, d, D, *,!, and blank comments:
c Start expression analyzer CHARACTER S, STACK*80 COMMON /PRMS/ N, S, STACK ... * Crack the expression: IF ( S .GE. '0' .AND. S .LE. '9' ) THEN ! EoL comment CALL PUSH ! Save on stack. EoL comment d PRINT *, S ! Debug comment & EoL comment ELSE CALL TOLOWER ! To lowercase EoL comment END IF D PRINT *, N! Debug comment & EoL comment ... C Finished ! expression analyzer
A directive passes information to a compiler in a special form of comment. @ Directives are also called compiler pragmas. There are two kinds of directives:
General directives
Parallel directives
See the Sun Fortran User's Guide and the Fortran Programming Guide for details on the specific directives available with f77.
The form of a general directive is one of the following:@
C$PRAGMA id
C$PRAGMA id ( a [ , a ] ) [ , id ( a [ , a ] ... ) ] ,...
C$PRAGMA SUN id[=options]
The variable id identifies the directive keyword; a is an argument.
A directive has the following syntax:
In column one, any of the comment-indicator characters c, C, !, or *
In any column, the ! comment-indicator character
The next 7 characters are $PRAGMA, no blanks, any uppercase or lowercase
After the first eight characters, blanks are ignored, and uppercase and lowercase are equivalent, as in FORTRAN text.
Because it is a comment, a directive cannot be continued, but you can have many C$PRAGMA lines, one after the other, as needed.
If a comment satisfies the above syntax, it is expected to contain one or more directives recognized by the compiler; if it does not, a warning is issued.
Parallelization directives explicitly request the compiler attempt to parallelize the DO loop that follows the directive. The syntax differs from general directives. Parallelization directives are only recognized when compilation options --parallel or --explicitpar are used. (f77 parallelization options are described in the Fortran User's Guide.)
Parallelization directives have the following syntax:
The first character must be in column one.
The first character can be any one of c, C, *, or !.
The next four characters are $PAR, no blanks, either upper or lower case.
Next follows the directive keyword and options, separated by blanks.
The explicit parallelization directive keywords are:
TASKCOMMON, DOALL, DOSERIAL, and DOSERIAL*
Each parallelization directive has its own set of optional qualifiers that follow the keyword.
Example: Specifying a loop with a shared variable:
C$PAR DOALL SHARED(yvalue)
See the Fortran Programming Guide for details about parallelization and these directives.