E0.0E0 format valid F2018?

This 3-line program gives different results with two compilers, neither of them what I had hoped for. I suspect that the program is standard-conforming F2018 but the compilers are not, though both have implemented much of F2018, and one of them gave the output I had expected, 3.E0, with format either (ES0.0E0) or (EN0.0E0).

program teste0
  write(*,"(E0.0E0)") 3.14159
end program teste0

Have not looked it up in the standard(s) yet, but ifx (IFX) 2023.2.0 20230622 gives this warning,
which gives a specific reason to check.

remark #8577: The scale factor (k) and number of fractional digits (d) do not have the allowed combination of either -d < k <= 0 or 0 < k < d+2. Expect asterisks as output.
    write(*,"(E0.0E0)") 3.14159
-----------------^

I think the trouble is that E0.0E0 is a F2018 feature not yet implemented in some compilers. I have sent a bug report to gfortran.

Is this what is supposed to happen?

$ gfortran --version teste0.f90 && a.out
GNU Fortran (Homebrew GCC 13.1.0) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

0.314159012E+1

On the other hand…

$ nagfor teste0.f90 && a.out
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7114
Error: teste0.f90, line 2: Zero field width invalid for E edit descriptor
[NAG Fortran Compiler error termination, 1 error]

No. I think gfortran should have given 0.E+1 and I suspect that nagfor has
also not yet implemented E0.0E0, which is a possible f2018 output format
according to my reading of the f2018 (or f2023) standard 13.7.2.3.3.

It took me a while, but the Intel “remark” pointed me at the proper language (emphasis mine).

F2018 13.7.2.3.3p5 (E editing)

The scale factor k controls the decimal normalization (13.3.2, 13.8.5). If −d < k ≤ 0, the output field contains exactly |k| leading zeros and d−|k| significant digits after the decimal symbol. If 0 < k < d+2, the output field contains exactly k significant digits to the left of the decimal symbol and d − k + 1 significant digits to the right of the decimal symbol. Other values of k are not permitted.

In this example, k=0 and d=0. The first test (-d < k <= 0) is not satisfied because -0 is not less than 0. The second test (0 < k < d+2) is not satisfied because 0 is not less than 0. Therefore, this program is nonconforming.

Thank you @sblionel. I had not realised the importance of the scale factor k in E output in a program that did not mention it explicitly. That raises the question of EN and ES output. For both of them the standard says The scale factor has no effect on output. That suggests that EN0.0E0 and ES0.0E0 are both valid f2018 formats for a real value. If so, ifort is right, gfortran prints the correct value in the wrong format, and I don’t have any other compiler.

I agree - those formats are valid, and the Intel compiler does the right thing. I tried the NAG compiler, but it does not yet support zero widths for ES and EN.