PGI Fortran ES and EN formats errors

Since upgrading from PGI Community 17.4 to 18.4 my I/O formatting isn’t working properly any more. The ES format I used to define 3 decimal places in the exponent to avoid postprocessing problems associated with a missing e sign doesn’t work right.

In ESw.dEe I can control the total width w and the number of decimal places d, but the number of digits in the exponent e will be 2 regardless of the value of e. Oddly, e can still be controlled in the G format, but which unfortunately comes with its own problems (zeroes are rendered as 0.0). I would really appreciate any help/workarounds on this.

Update: I tried using the E format instead and it does let me define the number of digits in the exponent which solves my trouble.

Hi atruk,

Sounds like a bug. Can you post or send to PGI Customer Service ( a reproducing example?

I tried but was unable to reproduce the issue with a simple program so there’s something specific about your program that’s causing it to fail.


% cat test.F90
program testES

   real :: rvar
   real(8) :: dvar

   rvar = 0.000123456
   dvar = 0.000123456

   write(*,'(ES20.6E1)'), rvar
   write(*,'(ES20.6E1)'), dvar
   write(*,'(E20.6E1)'), rvar
   write(*,'(E20.6E1)'), dvar

end program testES
% pgf90 test.F90 -V17.4 ; a.out
% pgf90 test.F90 -V18.4  ; a.out

Hi mkcolg,

your example runs fine but does not have exponents exceeding three digits. If I run the following code:

program testES
   implicit none

   integer, parameter :: dp = 8
   real(dp) :: rvar

   rvar = 0.123e120_dp

   write(*,'(ES20.6E3)'), rvar
   write(*,'(ES20.6E4)'), rvar
   write(*,'(E20.6E3)'), rvar
   write(*,'(E20.6E4)'), rvar

end program testES

The output is


If I understand the ES format right, the first and second outputs should have 3 and 4 places after E+, much like the E format. Instead, it seems to be limited to 4 places in total.