Документ взят из кэша поисковой машины. Адрес оригинального документа : http://crydee.sai.msu.ru/f90/c3.html
Дата изменения: Mon Dec 30 10:37:04 1996
Дата индексирования: Mon Oct 1 19:38:45 2012
Кодировка:

Поисковые слова: astronaut
The layout of a program

3. The layout of a program (free form and fix form)

Sometimes we require more than one line for a statement
   Print *, 'This is a long output line',&
            ' this is the second part',&
            ' and this is the third part!'
Nowadays, in the free form, we continue a line with the symbol "&" (called ampersand), i.e. with the sign & at the end of the old line instead of an almost arbitrary character in column 6 of the new line. With the compiler we are now using it is possible to include the Swedish characters in character strings and in comments.

Sometimes a certain identifier or a certain numerical number has not sufficient space on a line. We can then interrupt the identifier anywhere with the character "&" and then on the next line give a new "&" as the first non-blank character. You continue then directly from this "&" without any extra blank. The character "&" therefore works as a kind of delimiting or syllabification sign. You can write

     PI = 3.141592653589793
or you can write equivalently
     PI = 3.14159265&
            &3589793
Please note that comment lines can not be continued. The reason for this is that also in a comment line the sign "&" is treated as belonging to the comment. However, you can add comment lines also inside the continuation lines. Note that it is the final "&" of a line that informs of a continuation line, it is therefore possible to write a text string of characters including the character "&".

Sometimes you may wish to do it in the opposite way, to have several statements on the same line. This is being done with the use of semicolon and with the exclamation mark we can include a comment on the line.

     A = 0.0 ; B = 1.0 ; C = 2.0       !  Initialization
A line may include up to 132 characters, a statement may have up to 39 lines of continuation.

Note that on using the free form blanks are significant, as in my favourite example:

     DO 25 I = 1. 25
This gives a compilation error since the compiler does not find a comma between the lower and upper the limits, but the compressed version
     DO25I=1.25
gives the same result as the non-compressed form and as in Fortran 77 or using the old form (fix form) of Fortran 90, namely that the variable DO25I is being assigned the value 1.25.

Comments are started with "!" (exclamation mark) and ended with the end of line. The old types of comments introduced with C or * in column 1 are no longer permitted if you use free form, but of course if you use the fixed form. Upper case and lower case characters are equivalent except in character strings.

The above applies to the new free form. Also in the old, column -oriented or fixed form, we can use a semicolon or exclamation mark between columns 7 and 72 but you can not continue with "&" in columns 1 to 6 or 73 to 80 or write comments in columns 1 to 6. Exclamation mark in column 1 of course means a comment line also in the old fixed form. Some possibilities of longer lines do exist within the old fixed form (implementation dependent).

Exercises

(3.1) What does the following line mean?
  A = 0.0 ; B = 370 ! First variables ; C = 17.0 ; D = 33.0
Solution.

(3.2) Are the following lines correct according to Fortran 90?

  Y = SIN(MAX(X1,X2)) * EXP( - COS(X3)**I ) - TAN(AT&
             & AN(X4))
Solution.


Last modified: 5 December 1996
boein@nsc.liu.se