Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Source Forms

Within a program, source code can be in free, fixed, or tab form. Fixed or tab forms must not be mixed with free form in the same source program, but different source forms can be used in different source programs. Intel® Fortran supports compiler directives FREEFORM and NOFREEFORM, which let you toggle between fixed and free format in the same source file.

All source forms allow lowercase characters to be used as an alternative to uppercase characters.

Several characters are indicators in source code (unless they appear within a comment or a Hollerith or character constant). The following are rules for indicators in all source forms:

  • Comment indicator

    A comment indicator can precede the first statement of a program unit and appear anywhere within a program unit. If the comment indicator appears within a source line, the comment extends to the end of the line.

    An all blank line is also a comment line.

    Comments have no effect on the interpretation of the program unit.

    For more information, see comment indicators in free source form, or fixed and tab source forms.

  • Statement separator

    More than one statement (or partial statement) can appear on a single source line if a statement separator is placed between the statements. The statement separator is a semicolon character (;).

    Consecutive semicolons (with or without intervening blanks) are considered to be one semicolon.

    If a semicolon is the first character on a line, the last character on a line, or the last character before a comment, it is ignored.

  • Continuation indicator

    A statement can be continued for more than one line by placing a continuation indicator on the line.

    The Fortran Standard does not put a limit on the number of continuation lines, but limits the number of characters in a statement to 1,000,000.

    Comments can occur within a continued statement, but comment lines cannot be continued.

    For more information, see continuation indicators in free source form, or fixed and tab source forms.

The following table summarizes characters used as indicators in source forms.

Indicators in Source Forms

Source Item

Indicator 1

Source Form

Position

Comment

!

All forms

Anywhere in source code

Comment line

!

Free

At the beginning of the source line

!, C, or *

Fixed

In column 1

Tab

In column 1

Continuation line 2

&

Free

At the end of the source line

Any character except zero or blank

Fixed

In column 6

Any digit except zero

Tab

After the first tab

Statement separator

;

All forms

Between statements on the same line

Statement label

1 to 5 decimal digits

Free

Before a statement

Fixed

In columns 1 through 5

Tab

Before the first tab

A debugging statement3

D

Fixed

In column 1

Tab

In column 1

1 If the character appears in a Hollerith or character constant, it is not an indicator and is ignored.

2 The Fortran Standard does not limit the number of continuation lines, but limits the number of characters in a statement to 1,000,000.

3 Fixed and tab forms only.

Source form and line length can be changed at any time by using the FREEFORM, NOFREEFORM, or FIXEDFORMLINESIZE directives. The change remains in effect until the end of the file, or until changed again.

You can also select free source form by using compiler option free.

Source code can be written so that it is useable for all source forms.

Statement Labels

A statement label (or statement number) identifies a statement so that other statements can refer to it, either to get information or to transfer control. A label can precede any statement that is not part of another statement.

A statement label must be one to five decimal digits long; blanks and leading zeros are ignored. An all-zero statement label is invalid, and a blank statement cannot be labeled.

Labeled FORMAT and labeled executable statements are the only statements that can be referred to by other statement. FORMAT statements are referred to only in the format specifier of an I/O statement or in an ASSIGN statement. Two statements within a scoping unit cannot have the same label.