Debian Codegraph @

gcc/testsuite/gfortran.dg/ieee/large_4.f90

raw
1 ! { dg-do run { xfail i?86-*-freebsd* } }
2
3 program test_underflow_control
4 use ieee_arithmetic
5 use iso_fortran_env
6
7 ! kx and ky will be large real kinds, if supported, and single/double
8 ! otherwise
9 integer, parameter :: kx = &
10 max(ieee_selected_real_kind(precision(0.d0) + 1), kind(0.))
11 integer, parameter :: ky = &
12 max(ieee_selected_real_kind(precision(0._kx) + 1), kind(0.d0))
13
14 logical l
15 real(kind=kx), volatile :: x
16 real(kind=ky), volatile :: y
17
18 if (ieee_support_underflow_control(x)) then
19
20 x = tiny(x)
21 call ieee_set_underflow_mode(.true.)
22 x = x / 2000._kx
23 if (x == 0) STOP 1
24 call ieee_get_underflow_mode(l)
25 if (.not. l) STOP 2
26
27 x = tiny(x)
28 call ieee_set_underflow_mode(.false.)
29 x = x / 2000._kx
30 if (x > 0) STOP 3
31 call ieee_get_underflow_mode(l)
32 if (l) STOP 4
33
34 end if
35
36 if (ieee_support_underflow_control(y)) then
37
38 y = tiny(y)
39 call ieee_set_underflow_mode(.true.)
40 y = y / 2000._ky
41 if (y == 0) STOP 5
42 call ieee_get_underflow_mode(l)
43 if (.not. l) STOP 6
44
45 y = tiny(y)
46 call ieee_set_underflow_mode(.false.)
47 y = y / 2000._ky
48 if (y > 0) STOP 7
49 call ieee_get_underflow_mode(l)
50 if (l) STOP 8
51
52 end if
53
54 end program