public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: bug report : gfortran E edit descriptor
@ 2016-03-10 10:09 Dominique d'Humières
  0 siblings, 0 replies; 4+ messages in thread
From: Dominique d'Humières @ 2016-03-10 10:09 UTC (permalink / raw)
  To: sudo.michio; +Cc: GCC Development, fortran

> I have an trouble in E edit descriptor of gfortran.
> This is a example.
> (source file: test.f95)
>        program test
>        implicit none
>        real a,b
>        a=135.0
>        b=1737.5
>        write(*,*)a,b
>        write(*,'(e9.3,a,f7.1)')a,' ',b
>        write(*,'(1pe9.3,a,f7.1)')a,' ',b
>        end
> (compile)
> gfortran test.f95
> (execute)
> a.exe
> (result)
>    135.000000       1737.50000    
> 0.135E+03  1737.5
> 1.350E+02 17375.0  ( <--- wrong value )
>
> I suppose there are some bugs in the E edit descriptor.
IIRC 
(1) the P ‘modifier’ applies to all the subsequent numeric descriptors,
(2) when rP is applied to an F descriptor, the value is ‘multiplied’ by 10**r.
write(*,'(e9.3,a,1pf7.1)')a,' ‘,b
gives
0.135E+03 17375.0
and
write(*,'(1pe9.3,a,e9.3)')a,' ‘,b
gives
1.350E+02 1.738E+03
So I think gfortran is right.

> I like Fortran and I wish gfortran of GCC to be better compiler.
> best regards.
If you want to contribute, discussion about gfortran should go to fortran@gcc.gnu.org and bug should be filed in bugzilla.

Cheers,

Dominique

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bug report : gfortran E edit descriptor
@ 2016-03-10 23:32 sudo.michio
  0 siblings, 0 replies; 4+ messages in thread
From: sudo.michio @ 2016-03-10 23:32 UTC (permalink / raw)
  To: Tobias Burnus, Dominique d'Humières; +Cc: GCC Development, fortran

to:Dr.Dominique d'Humières and Dr.Tobias Burnus 
from:Mr.Michio Sudo

Thankyou for your prompt responses.
My research was not enough.
I will use the p edit scriptor as it is.
Best regards.

----- Original Message -----
>> From: Dominique d'Humières <dominiq@lps.ens.fr>
>> To: sudo.michio@jaea.go.jp
>> Cc: GCC Development <gcc@gcc.gnu.org>,fortran@gcc.gnu.org
>> Date: 2016-03-10 19:09:33
>> Subject: Re: bug report : gfortran E edit descriptor
>> 
>> > I have an trouble in E edit descriptor of gfortran.
>> > This is a example.
>> > (source file: test.f95)
>> >        program test
>> >        implicit none
>> >        real a,b
>> >        a=135.0
>> >        b=1737.5
>> >        write(*,*)a,b
>> >        write(*,'(e9.3,a,f7.1)')a,' ',b
>> >        write(*,'(1pe9.3,a,f7.1)')a,' ',b
>> >        end
>> > (compile)
>> > gfortran test.f95
>> > (execute)
>> > a.exe
>> > (result)
>> >    135.000000       1737.50000    
>> > 0.135E+03  1737.5
>> > 1.350E+02 17375.0  ( <--- wrong value )
>> >
>> > I suppose there are some bugs in the E edit descriptor.
>> IIRC 
>> (1) the P ‘modifier’ applies to all the subsequent numeric descriptors,
>> (2) when rP is applied to an F descriptor, the value is ‘multiplied’ by 10**r.
>> write(*,'(e9.3,a,1pf7.1)')a,' ‘,b
>> gives
>> 0.135E+03 17375.0
>> and
>> write(*,'(1pe9.3,a,e9.3)')a,' ‘,b
>> gives
>> 1.350E+02 1.738E+03
>> So I think gfortran is right.
>> 
>> > I like Fortran and I wish gfortran of GCC to be better compiler.
>> > best regards.
>> If you want to contribute, discussion about gfortran should go to fortran@gcc.gnu.org and bug should be filed in bugzilla.
>> 
>> Cheers,
>> 
>> Dominique
>> 
>> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bug report : gfortran E edit descriptor
  2016-03-10  8:40 sudo.michio
@ 2016-03-10 10:14 ` Tobias Burnus
  0 siblings, 0 replies; 4+ messages in thread
From: Tobias Burnus @ 2016-03-10 10:14 UTC (permalink / raw)
  To: sudo.michio, gcc


I think gfortran's result *is* *correct* according to the
Fortran standard.

(I concur that the result is not what one would expect but
it is now decades to late to change that.)


sudo.michio wrote:
> I have an trouble in E edit descriptor of gfortran.
> This is a example.
...
>       write(*,'(e9.3,a,f7.1)')a,' ',b
>       write(*,'(1pe9.3,a,f7.1)')a,' ',b
...
> (execute)
> a.exe
> (result)
>   135.000000       1737.50000    
> 0.135E+03  1737.5
> 1.350E+02 17375.0  ( <--- wrong value )

Looking at the Fortran standard [1], the result looks
correct:

"The k P edit descriptor temporarily changes (9.5.2) the scale
 factor for the connection to k. The scale factor affects the
 editing done by the F, E, EN, ES, D, and G edit descriptors
 for numeric quantities.
[...]

 * On output, with F output editing, the effect is that the
   externally represented number equals the internally represented
   number multiplied by 10**k; the internal value is converted using
   the I/O rounding mode and then the scale factor is applied to
   the converted decimal value.

 * On output, with E and D editing, the effect is that the
   significand (R414) part of the quantity to be produced is
   multiplied by 10**k and the exponent is reduced by k."


The referenced 9.5.2 contains the following, which implies
that the "1p" not only affects the immediately following "e9.3"
but also the later "f7.1":

"Edit descriptors take effect when they are encountered in
 format processing.  When a data transfer statement terminates,
 the values for the modes are reset to the values in effect
 immediately before the data transfer statement was executed."


Cheers,

Tobias

[1] http://j3-fortran.org/doc/year/10/10-007r1.pdf
Section "10.8.5 P editing"
Page 279 of the document, page number labelled as "261"

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug report : gfortran E edit descriptor
@ 2016-03-10  8:40 sudo.michio
  2016-03-10 10:14 ` Tobias Burnus
  0 siblings, 1 reply; 4+ messages in thread
From: sudo.michio @ 2016-03-10  8:40 UTC (permalink / raw)
  To: gcc

to:gcc@gcc.gnu.org
from:Mr.Michio Sudo

I have an trouble in E edit descriptor of gfortran.
This is a example.
(source file: test.f95)
       program test
       implicit none
       real a,b
       a=135.0
       b=1737.5
       write(*,*)a,b
       write(*,'(e9.3,a,f7.1)')a,' ',b
       write(*,'(1pe9.3,a,f7.1)')a,' ',b
       end
(compile)
gfortran test.f95
(execute)
a.exe
(result)
   135.000000       1737.50000    
0.135E+03  1737.5
1.350E+02 17375.0  ( <--- wrong value )

I suppose there are some bugs in the E edit descriptor.
I like Fortran and I wish gfortran of GCC to be better compiler.
best regards.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-10 23:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-10 10:09 bug report : gfortran E edit descriptor Dominique d'Humières
  -- strict thread matches above, loose matches on Subject: below --
2016-03-10 23:32 sudo.michio
2016-03-10  8:40 sudo.michio
2016-03-10 10:14 ` Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).