Possible explaination why large_real_kind_form_io_2.f90 is failing on PPC/OSX

Dominique Dhumieres dominiq@lps.ens.fr
Sun Jan 14 15:51:00 GMT 2007


Trying to understand why large_real_kind_form_io_2.f90 is failing on PPC/OSX,
I ended up with the following code:

! { dg-do run }
! { dg-require-effective-target fortran_large_real }
! PR libfortran/24685
program large_real_kind_form_io_2
  ! This should be 10 or 16 on systems that support kind=10 or kind=16
  integer, parameter :: k = selected_real_kind (precision (0.0_8) + 1)

  print *, k
  print *, nearest(1.0_8,1.0_8)
  print *, nearest(1.0_8,-1.0_8)
  print '(1pg50.40))', nearest(1.0_8,1.0_8)
  print '(1pg50.40)', nearest(1.0_8,-1.0_8)
  print *, nearest(1.0_k,1.0_k), nearest(1.0_k,1.0_k)-1.0_k
  print *, nearest(1.0_k,-1.0_k), nearest(1.0_k,-1.0_k)-1.0_k
  print '(2(1pg60.50))', nearest(1.0_k,1.0_k), nearest(1.0_k,1.0_k)-1.0_k
  print '(2(1pg60.50))', nearest(1.0_k,-1.0_k), nearest(1.0_k,-1.0_k)-1.0_k
  
end program large_real_kind_form_io_2

which gives:

          16
   1.00000000000000     
     1.000000000000000222044604925031308084726    
    0.9999999999999998889776975374843459576368    
  1.0000000000000000000000000000000000        2.4651903288156618919116517665087070E-0032
  1.0000000000000000000000000000000000       -1.2325951644078309459558258832543535E-0032
    1.00000000000000000000000000000000000000000000000000        2.46519032881566189191165176650870696772900000000000E-32
    1.00000000000000000000000000000000000000000000000000       -1.23259516440783094595582588325435348386400000000000E-32

with two results that might explain the failure:

(1) the default format is too short to distinguish close values, 
so codes such that:

  write (tmp, *) b
  read (tmp, *) a, c

may fail to read a and c as b(1) and b(2) if the default format gives
ambiguous output.

(2) The general format for real(16) seems to stop the decoding too
soon (without reaching the last significant digits).

If I am right, should I fill one or two PR?

TIA

Dominique



More information about the Fortran mailing list