Sun Studio 12 Update 1: Fortran User's Guide

4.1 Source Language Features

The f95 compiler provides the following source language features and extensions to the Fortran standard.

4.1.1 Continuation Line Limits

f95 allows 999 continuation lines (1 initial and 999 continuation lines). Standard Fortran 95 allows 19 for fixed-form and 39 for free-form.

4.1.2 Fixed-Form Source Lines

In fixed-form source, lines can be longer than 72 characters, but everything beyond column 73 is ignored. Standard Fortran 95 only allows 72-character lines.

4.1.3 Tab Form

The f95 fixed-format source text is defined as follows:

The f95 default maximum line length is 72 columns for fixed form and 132 for free form. Use the -e compiler option to extend the lines in fixed-format source to 132 columns.

Example: The tab form source on the left is treated as shown on the right.

!^IUses of tabs
^IREAL C = 3.0
^IWRITE(*,9) A, B, C
^I1 I3,
^I2 F9.1 )

!       Uses of tabs
        CHARACTER *3 A = ’A’
        INTEGER B = 2
        REAL C = 3.0
        WRITE(*,9) A, B, C
9       FORMAT(1X, A3,
       1 I3,
       2 F9.1 )

In the example above, ”^I” stands for the tab character, and the line starting with “1” and “2” are continuation lines. The coding is shown to illustrate various tab situations, and not to advocate any one style.

Tabs in f95 force the rest of the line to be padded out to column 72. This may cause unexpected results if the tab appears within a character string that is continued onto the next line:

Source file:

^Iprint *, "Tab on next line
^I1this  continuation line starts with a tab."

Running the code:

Tab on next line                                             this  continuation
 line starts with a tab.

Tab formatting is also permitted with the —f77 option.

4.1.4 Source Form Assumed

The source form assumed by f95 depends on options, directives, and suffixes.

Files with a .f or .F suffix are assumed to be in fixed format. Files with a .f90, .f95, .F90, or .F95 suffix are assumed to be in free format.

Table 4–1 F95 Source Form Command-line Options




Interpret all source files as Fortran fixed form


Interpret all source files as Fortran free form

If the -free or -fixed option is used, it overrides the file name suffix. If either a !DIR$ FREE or !DIR$ FIXED directive is used, it overrides the option and file name suffix. Mixing Forms

Some mixing of source forms is allowed. Case

Sun Fortran 95 is case insensitive by default. That means that a variable AbcDeF is treated as if it were spelled abcdef. Compile with the -U option to have the compiler treat upper and lower case as unique.

4.1.5 Limits and Defaults