Use of Variable Format Expressions

Variable format expressions (a Compaq Fortran extension) is a numeric expression enclosed in angle brackets (< >) that can be used in a FORMAT statement. Variable format expressions (VFEs) are almost as flexible as run-time formatting, but they are more efficient because the compiler can eliminate run-time parsing of the I/O format. Only a small amount of processing and the actual data transfer are required during run time.

On the other hand, run-time formatting can impair performance significantly. For example, in the following statements, S1 is more efficient than S2 because the formatting is done once at compile time, not at run time:

  S1        WRITE (6,400) (A(I), I=1,N)
      400   FORMAT (1X, <N> F5.2)
                         .
                         .
                         .
  S2        WRITE (CHFMT,500) '(1X,',N,'F5.2)'
      500   FORMAT (A,I3,A)
            WRITE (6,FMT=CHFMT) (A(I), I=1,N)