Format statements

Unlike many Fortran implementations, FTN95 preprocesses 'constant' formats at compile-time. These 'constant' formats are as follows:

  • A FORMAT statement.

  • A format expression that is a character constant or a character constant expression.

  • A format expression that is a parameter name.

All formats which include character arrays, array elements or variables are decoded at run-time. Such non-constant formats require more extensive decoding which leads to longer execution times.

For example, the following should be avoided wherever possible:

CHARACTER(LEN=10)::F
F = '(3F10.4)'
. . .
WRITE (2,F)X,Y,Z

It could be rewritten as follows:

CHARACTER(LEN=10)::F
PARAMETER (F='(3F10.4)')
. . .
WRITE (2,F)X,Y,Z

so that the format specifier would be decoded at compile-time.

Note also that the colon (:) edit descriptor and tab facilities can often be used instead of a run-time format.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited