2 ! { dg-require-effective-target fortran_large_real }
4 ! This tests that the default formats for formatted I/O of reals are
5 ! wide enough and have enough precision, by checking that values can
6 ! be written and read back.
8 module test_default_format
10 module procedure test_rl
13 integer, parameter :: kl = selected_real_kind (precision (0.0_8) + 1)
14 integer, parameter :: count = 200
18 function test_rl (start, towards) result (res)
19 integer, parameter :: k = kl
20 integer, intent(in) :: towards
21 real(k), intent(in) :: start
25 character(len=100) :: s
29 if (towards >= 0) then
34 if (y /= x) res = res + 1
35 x = nearest(x,huge(x))
39 if (towards <= 0) then
44 if (y /= x) res = res + 1
45 x = nearest(x,-huge(x))
50 end module test_default_format
53 use test_default_format
55 if (test (1.0_kl, 0) /= 0) call abort
56 if (test (0.0_kl, 0) /= 0) call abort
57 if (test (tiny(0.0_kl), 0) /= 0) call abort
58 if (test (-tiny(0.0_kl), 0) /= 0) call abort
59 if (test (huge(0.0_kl), -1) /= 0) call abort
60 if (test (-huge(0.0_kl), 1) /= 0) call abort
64 ! { dg-final { cleanup-modules "test_default_format" } }