Printing format control

In this FORTRAN 77 program:

      program test
      write(6,*) '- - - - - - - - - - - - - - - - - - - - - - - - - - ',
     &           '- - - - - - - - - - - - - - - - - - - - - - - - - -'
      write(6,'(2G15.5)') 0.1,0.0
      end

I get the following output with pgf77:

 - - - - - - - - - - - - - - - - - - - - - - - - - - 
 - - - - - - - - - - - - - - - - - - - - - - - - - -
    0.10000        0.00000E+00

I would like all the hyphens in a single line, and the zero printed as “0.00000” (or “0.0000”). I know I can do that by modifying the source, but that is quite cumbersome with a long program.

Can I add some flag or option to the compiler to get the desired output?

Hi Ignacio Fdez. Galvan,

With list-directed output, different compiler implementations may break up lines. You must use formatted output to force the desired behavior:

      write(6,9) '---- ...
     &         '---- ...
     9 format(a,a)

Per the F77 Specification, ‘E’ must be used to get “0.0”. The F90 Specification changed the behavior of ‘G’. You may wish to compile this code using “pgf90” or “pgfortran”.

Hope this helps,
Mat