[patch, libfortran] Implement KIND specific floating point formatted output
Jerry DeLisle
jvdelisle@verizon.net
Wed Aug 29 08:29:00 GMT 2007
Dominique Dhumieres wrote:
> This patch breaks gfortran.dg/fmt_p_1.f90, gfortran.dg/output_exponents_1.f90,
> and gfortran.dg/large_real_kind_form_io_1.f90 on PPC Darwin. For the first two tests
> the failure comes from a truncated exponent:
>
> 0.100E-99 0.200E-99
> 1.000-10 2.000-10
>
> instead of
>
> 0.100E-99 0.200E-99
> 1.000-100 2.000-100
>
> For the last test, the bug is less obvious: the last output is:
>
> .1000E+0000 .2000E+0000
>
> giving the runtime error:
>
> At line 28 of file large_real_kind_form_io_1_db.f90
> Fortran runtime error: Bad value during floating point read
>
> See http://gcc.gnu.org/ml/gcc-testresults/2007-08/msg01010.html for
> results on Darwin.
>
> Dominique
>
> PS Note that gfortran.dg/edit_real_1.f90 now pass, but if I print the
>
> 9 1.798+30z
>
> instead of
>
> 9 1.798+308z
>
> Also the code
>
> print *, huge(1.0), -huge(1.0), huge(1.0d0), -huge(1.0d0)
> print *, nearest(huge(1.0),-1.0), nearest(-huge(1.0),1.0), nearest(huge(1.0d0),-1.0d0), nearest(-huge(1.0d0),1.0d0)
> print *, nearest(huge(1.0),1.0), nearest(-huge(1.0),-1.0), nearest(huge(1.0d0),1.0d0), nearest(-huge(1.0d0),-1.0d0)
> end
>
> gives
>
> edit_real_1_red_3.f90:3.18:
>
> print *, nearest(huge(1.0),1.0), nearest(-huge(1.0),-1.0), nearest(huge(1.0d0)
> 1
> Error: Result of NEAREST overflows its kind at (1)
> edit_real_1_red_3.f90:3.42:
>
> print *, nearest(huge(1.0),1.0), nearest(-huge(1.0),-1.0), nearest(huge(1.0d0)
> 1
> Error: Result of NEAREST overflows its kind at (1)
> edit_real_1_red_3.f90:3.68:
>
> print *, nearest(huge(1.0),1.0), nearest(-huge(1.0),-1.0), nearest(huge(1.0d0)
> 1
> Error: Result of NEAREST overflows its kind at (1)
> edit_real_1_red_3.f90:3.96:
>
> e(1.0),1.0), nearest(-huge(1.0),-1.0), nearest(huge(1.0d0),1.0d0), nearest(-hug
> 1
> Error: Result of NEAREST overflows its kind at (1)
>
> I was expecting no errors and
>
> 3.4028235E+38 -3.4028235E+38 1.7976931348623157E+308 -1.7976931348623157E+308
> 3.4028233E+38 -3.4028233E+38 1.7976931348623155E+308 -1.7976931348623155E+308
> +Inf -Inf +Inf -Inf
>
> If I remove the offending line, the output is:
>
> 3.4028235E+38 -3.4028235E+38 1.797693134862316E+30 -1.797693134862316E+30
> 3.4028233E+38 -3.4028233E+38 1.797693134862316E+30 -1.797693134862316E+30
>
Would you please file a PR for this. I have seen something similar to this
before, but will have to think about it a bit. I think this is target specific.
Please try touching all files in libgfortran/io and rebuild and see what happens.
Jerry
More information about the Fortran
mailing list