In the beginning, there was only one source form for FORTRAN (as it was then known) programs. Each statement was exactly 72 characters long – no more, no less. (SeeĀ note below.) Columns 1-5 were for statement labels, whole line comments were indicated with a C in column 1, and column 6 was reserved for a continuation indicator. Blanks in the statement field, outside of character or Hollerith literals, were ignored. The standard didn’t (and still doesn’t) talk about how source programs are fed into a compiler, but on systems where there were “file types”, the types .for, .f and .ftn were usually recognized as being Fortran.

(Quiz: Which character in the Fortran character set other than blank, when it appears in column 6, doesn’t mean that the line is a continuation?  Answer below.)

Fortran 90 introduced a new source form called free-form; the older style was dubbed fixed-form. In free-form source there were no fixed column assignments – a statement could begin in any column and be of any length up to 132. More important, blanks were significant in free-form, so the classic error of:

      DO 10 I = 1.10

which, in fixed-form is an assignment to a (possibly implicitly declared) variable named DO10I, is a syntax error in free-form.  This is one of the major reasons that free-form is recommended for new development as it eliminates a whole class of errors that would otherwise go undetected during compilation.

The second source form posed a problem for compilers, though.  How could they tell whether a source file was fixed-form or free-form?  Remember that the standard was silent on the whole source file business; as far as the standard was concerned, source lines were delivered to the “processor” (compiler) by fairies in the night. Well, this new language was called Fortran 90, so the early compiler implementers decided that .f90 should be used for free-form source. Unfortunately, they did not anticipate what happened later when the Fortran standard was revised to become Fortran 95, and still later, Fortran 2003 and Fortran 2008. Programmers saw the “90” in .f90 and assumed that this meant that the source was Fortran 90.  But they were coding in Fortran 95, so the file type should now be .f95, right?  Or .f03?  .f08?  I shudder to think what programmers who wanted to code to F95 plus the features in TR15581 “Enhanced data type facilities” would want to use for a file type.

This second meaning attached to the file type raised a number of issues, not the least of which was its inappropriateness. After all, one can write Fortran 95 code in fixed-form source. Fixed-form is still part of Fortran 2008! Should the source file names change every time a new standard comes out?  Some compiler implementers added the user-created file types to the list of those recognized by their compiler, but not all, which created portability issues. In particular, DEC/Compaq/Intel did not take this route so that only .f90 is recognized as a free-form Fortran source file.

This topic comes up for discussion in comp.lang.fortran on occasion, with the general agreement of those past and present members of the standards committee and implementers that conflating the source form and the standards level is a bad idea. So please don’t do it. If you insist, though, you can make Intel Fortran recognize any file type you want. In Visual Studio on Windows, go to Tools > Options > Intel Compilers and Libraries > IFORT Intel Fortran Classic > General. (The exact path to this varies by version.) Add your desired file types to the Fixed Format Extensions and Free Format Extensions properties and click OK. From the command line on Linux or OS X, the -Tf option is used to indicate that the filename that follows is a Fortran file. You may also need to add -free to indicate free-form source. On the Windows command line you can use /extfor to name the additional file types you want recognized.

I am dreading the day when a customer sends me a .f15 source….

Footnote: Yes, I said 72 characters. What about 80-character punch cards? The standard does not say anything about the meaning of columns after 72. Compilers typically ignored additional characters which is what gave rise to the use of columns 73-80 for card deck sequence numbers. If you’ve ever dropped a large card deck, you appreciated having those and the use of a card sorter.

Quiz answer: The digit 0 is treated as if it were a blank when it appears in column 6 in fixed-form source. This often surprises programmers who number their continuation lines consecutively when they get to the 10th.

(Originally posted at Intel Developer Zone, copied with permission)


Fortran IV/Fortran 66 did not have the quote character in its character set, and literal character constants had to be written as Hollerith constants. The IBM 026 card punch did not have a quote character.

Thus, in the statement “Blanks in the statement field, outside of quoted literals, were ignored”, the qualifier “quoted”, may be replaced by a more appropriate word.


Write Your Comments

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Doctor Fortran

Subscribe to Doctor Fortran