! { dg-do run }
|
! { dg-do run }
|
! Check real value edit descriptors
|
! Check real value edit descriptors
|
! Also checks that rounding is performed correctly
|
! Also checks that rounding is performed correctly
|
program edit_real_1
|
program edit_real_1
|
character(len=20) s
|
character(len=20) s
|
character(len=20) x
|
character(len=20) x
|
character(len=200) t
|
character(len=200) t
|
parameter (x = "xxxxxxxxxxxxxxxxxxxx")
|
parameter (x = "xxxxxxxxxxxxxxxxxxxx")
|
|
|
! W append a "z" onto each test to check the field is the correct width
|
! W append a "z" onto each test to check the field is the correct width
|
s = x
|
s = x
|
! G -> F format
|
! G -> F format
|
write (s, '(G10.3,A)') 12.36, "z"
|
write (s, '(G10.3,A)') 12.36, "z"
|
if (s .ne. " 12.4 z") call abort
|
if (s .ne. " 12.4 z") call abort
|
s = x
|
s = x
|
! G -> E format
|
! G -> E format
|
write (s, '(G10.3,A)') -0.0012346, "z"
|
write (s, '(G10.3,A)') -0.0012346, "z"
|
if (s .ne. "-0.123E-02z") call abort
|
if (s .ne. "-0.123E-02z") call abort
|
s = x
|
s = x
|
! Gw.eEe format
|
! Gw.eEe format
|
write (s, '(G10.3e1,a)') 12.34, "z"
|
write (s, '(G10.3e1,a)') 12.34, "z"
|
if (s .ne. " 12.3 z") call abort
|
if (s .ne. " 12.3 z") call abort
|
! E format with excessive precision
|
! E format with excessive precision
|
write (t, '(E199.192,A)') 1.5, "z"
|
write (t, '(E199.192,A)') 1.5, "z"
|
if ((t(1:7) .ne. " 0.1500") .or. (t(194:200) .ne. "00E+01z")) call abort
|
if ((t(1:7) .ne. " 0.1500") .or. (t(194:200) .ne. "00E+01z")) call abort
|
! EN format
|
! EN format
|
s = x
|
s = x
|
write (s, '(EN15.3,A)') 12873.6, "z"
|
write (s, '(EN15.3,A)') 12873.6, "z"
|
if (s .ne. " 12.874E+03z") call abort
|
if (s .ne. " 12.874E+03z") call abort
|
! EN format, negative exponent
|
! EN format, negative exponent
|
s = x
|
s = x
|
write (s, '(EN15.3,A)') 12.345e-6, "z"
|
write (s, '(EN15.3,A)') 12.345e-6, "z"
|
if (s .ne. " 12.345E-06z") call abort
|
if (s .ne. " 12.345E-06z") call abort
|
! ES format
|
! ES format
|
s = x
|
s = x
|
write (s, '(ES10.3,A)') 16.235, "z"
|
write (s, '(ES10.3,A)') 16.235, "z"
|
if (s .ne. " 1.624E+01z") call abort
|
if (s .ne. " 1.624E+01z") call abort
|
! F format, small number
|
! F format, small number
|
s = x
|
s = x
|
write (s, '(F10.8,A)') 1.0e-20, "z"
|
write (s, '(F10.8,A)') 1.0e-20, "z"
|
if (s .ne. "0.00000000z") call abort
|
if (s .ne. "0.00000000z") call abort
|
! E format, very large number.
|
! E format, very large number.
|
! Used to overflow with positive scale factor
|
! Used to overflow with positive scale factor
|
s = x
|
s = x
|
write (s, '(1PE10.3,A)') huge(0d0), "z"
|
write (s, '(1PE10.3,A)') huge(0d0), "z"
|
! The actual value is target specific, so just do a basic check
|
! The actual value is target specific, so just do a basic check
|
if ((s(1:1) .eq. "*") .or. (s(7:7) .ne. "+") .or. &
|
if ((s(1:1) .eq. "*") .or. (s(7:7) .ne. "+") .or. &
|
(s(11:11) .ne. "z")) call abort
|
(s(11:11) .ne. "z")) call abort
|
! F format, round up with carry to most significant digit.
|
! F format, round up with carry to most significant digit.
|
s = x
|
s = x
|
write (s, '(F10.3,A)') 0.9999, "z"
|
write (s, '(F10.3,A)') 0.9999, "z"
|
if (s .ne. " 1.000z") call abort
|
if (s .ne. " 1.000z") call abort
|
! F format, round up with carry to most significant digit < 0.1.
|
! F format, round up with carry to most significant digit < 0.1.
|
s = x
|
s = x
|
write (s, '(F10.3,A)') 0.0099, "z"
|
write (s, '(F10.3,A)') 0.0099, "z"
|
if (s .ne. " 0.010z") call abort
|
if (s .ne. " 0.010z") call abort
|
! E format, round up with carry to most significant digit.
|
! E format, round up with carry to most significant digit.
|
s = x
|
s = x
|
write (s, '(E10.3,A)') 0.9999, "z"
|
write (s, '(E10.3,A)') 0.9999, "z"
|
if (s .ne. " 0.100E+01z") call abort
|
if (s .ne. " 0.100E+01z") call abort
|
! EN format, round up with carry to most significant digit.
|
! EN format, round up with carry to most significant digit.
|
s = x
|
s = x
|
write (s, '(EN15.3,A)') 999.9999, "z"
|
write (s, '(EN15.3,A)') 999.9999, "z"
|
if (s .ne. " 1.000E+03z") call abort
|
if (s .ne. " 1.000E+03z") call abort
|
! E format, positive scale factor
|
! E format, positive scale factor
|
s = x
|
s = x
|
write (s, '(2PE10.4,A)') 1.2345, "z"
|
write (s, '(2PE10.4,A)') 1.2345, "z"
|
if (s .ne. '12.345E-01z') call abort
|
if (s .ne. '12.345E-01z') call abort
|
! E format, negative scale factor
|
! E format, negative scale factor
|
s = x
|
s = x
|
write (s, '(-2PE10.4,A)') 1.25, "z"
|
write (s, '(-2PE10.4,A)') 1.25, "z"
|
if (s .ne. '0.0013E+03z') call abort
|
if (s .ne. '0.0013E+03z') call abort
|
! E format, single digit precision
|
! E format, single digit precision
|
s = x
|
s = x
|
write (s, '(E10.1,A)') 1.1, "z"
|
write (s, '(E10.1,A)') 1.1, "z"
|
if (s .ne. ' 0.1E+01z') call abort
|
if (s .ne. ' 0.1E+01z') call abort
|
end
|
end
|
|
|
|
|