https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111022

--- Comment #25 from john.harper at vuw dot ac.nz ---
With that program Intel's two compilers (ifort and ifx) both print

  >.30D+01<
  >.30E+01<

If your program removes the d0.2 stuff and changes e0.2 to es0.2e0, i.e.

   character(20) :: fmt
   character(9) :: buffer
   fmt = "(1a1,es0.2e0,1a1)"
   write(buffer,fmt) ">", 3.0, "<"
   print *, buffer
   end

then both Intel compilers print what you seem to have hoped for:

  >3.00E+0<

but my gfortran, gcc version 13.1.0 (Ubuntu 13.1.0-8ubuntu1~22.04), prints

  >3.00<

I won't argue about the difference between gfortran's >0.30D+1< 
and Intel's >.30D+01< because I have been caught before by whether the 
zero before the decimal point and the zero after the D are optional. 
The f2018 standard is not easy to read on this.

I tried aocc-flang on your original program, and I ought to send them a 
bug report because it printed

  ><
  ><

I don't have access to the NAG compiler or anyone else's flang.

John


On Thu, 25 Jan 2024, jvdelisle at gcc dot gnu.org wrote:

> Date: Thu, 25 Jan 2024 22:21:01 +0000
> From: jvdelisle at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org>
> To: John Harper <john.har...@vuw.ac.nz>
> Subject: [Bug libfortran/111022] ES0.0E0 format gave ES0.dE0 output with d too
>      high.
> Resent-Date: Fri, 26 Jan 2024 11:21:15 +1300 (NZDT)
> Resent-From: <john.har...@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111022
>
> --- Comment #24 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> Currently gfortran does the following:
>
> character(20) :: fmt
> character(9) :: buffer
> fmt = "(1a1,d0.2,1a1)"
> write(buffer,fmt) ">", 3.0, "<"
> print *, buffer
> fmt = "(1a1,e0.2,1a1)"
> write(buffer,fmt) ">", 3.0, "<"
> print *, buffer
> end
>
>
> $ gfc question.f90
> $ ./a.out
> >0.30D+1<
> >0.30E+1<
>
> Why not:
>
> $ ./a.out
> >3.00D+0<
> >3.00E+0<
>
> What does Intel do?
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.har...@vuw.ac.nz

Reply via email to