next up previous contents
Next: Character Set Up: Language Elements Previous: Source Form

Free Format Code

Fortran 90 supports the new free format source form:

Fortran 90 has two basically incompatible source forms, an old form compatible with that used in FORTRAN 77, fixed format, and a new form more suited to the modern computing environment, free format. The old form used a very strictly defined layout of program statements on lines. This was well suited to the expression of programs when the main method of entering programs into a computer was by the use of stacks of cards with holes punched in them to represent the characters of the program statements. Such punched card systems also worked with a very restricted set of characters; only upper-case letters, for example, were allowed. The new form is designed to be easier to prepare and to read using the sort of keyboard / display that is now ubiquitous. This new form uses a much wider character set and it allows much greater freedom in laying out statements on a line. It is this new form that we are going to describe here since this is the form we would expect any new programmer to employ. The old form will not be described in any great detail.

The old ``character in column 6'' method of line continuation is replaced by an & at the end of a line. Only one & is essential however if a string is to be split then there should also be an & at the beginning of the text on the next line in order to preserve the spacing. The continued line effectively begins from the character after the &.

PRINT*, 'This is a long constant continued from line to line&
        &by use of the continuation mark at both the end of the&
        &continued line and at the start of the continuation line'

& is ineffective within a comment and cannot be on a line on its own.

INTEGER SQUASHED, UP; REAL CLOSE  ! Two for the price of one

The `;' allows two statements (or more) to occupy the same line and ! signifies that the following text is a comment.

In free format blanks become significant. The rules are fairly straightforward: blanks cannot occur in the middle of names, keywords or literals and, in general, blanks must appear between keywords and between keywords and names. See Section 4.4 for more details.

Now try this question gif

Return to corresponding overview page gif


next up previous contents
Next: Character Set Up: Language Elements Previous: Source Form

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.