W3cubDocs

/GNU Fortran 7

6.2.2 Variable FORMAT expressions

A variable FORMAT expression is format statement which includes angle brackets enclosing a Fortran expression: FORMAT(I<N>). GNU Fortran does not support this legacy extension. The effect of variable format expressions can be reproduced by using the more powerful (and standard) combination of internal output and string formats. For example, replace a code fragment like this:

WRITE(6,20) INT1
20   FORMAT(I<N+1>)

with the following:

c     Variable declaration
      CHARACTER(LEN=20) FMT
c     
c     Other code here...
c
      WRITE(FMT,'("(I", I0, ")")') N+1
      WRITE(6,FMT) INT1

or with:

c     Variable declaration
      CHARACTER(LEN=20) FMT
c     
c     Other code here...
c
      WRITE(FMT,*) N+1
      WRITE(6,"(I" // ADJUSTL(FMT) // ")") INT1

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gfortran/Variable-FORMAT-expressions.html