3 ! Test IEEE_MODES_TYPE, IEEE_GET_MODES and IEEE_SET_MODES
6 ! The symbols should be accessible from both IEEE_EXCEPTIONS
10 use ieee_exceptions
, only
: IEEE_GET_MODES
, IEEE_SET_MODES
14 use ieee_arithmetic
, only
: IEEE_GET_MODES
, IEEE_SET_MODES
18 use ieee_exceptions
, only
: IEEE_MODES_TYPE
22 use ieee_arithmetic
, only
: IEEE_MODES_TYPE
26 ! Check that the functions actually do the job
32 type(ieee_modes_type
) :: modes1
, modes2
33 type(ieee_round_type
) :: rmode
37 if (ieee_support_underflow_control()) then
38 call ieee_set_underflow_mode(gradual
=.false
.)
40 if (ieee_support_rounding(ieee_up
)) then
41 call ieee_set_rounding_mode(ieee_up
)
43 if (ieee_support_halting(ieee_overflow
)) then
44 call ieee_set_halting_mode(ieee_overflow
, .true
.)
47 call ieee_get_modes(modes1
)
50 if (ieee_support_underflow_control()) then
51 call ieee_set_underflow_mode(gradual
=.true
.)
53 if (ieee_support_rounding(ieee_down
)) then
54 call ieee_set_rounding_mode(ieee_down
)
56 if (ieee_support_halting(ieee_overflow
)) then
57 call ieee_set_halting_mode(ieee_overflow
, .false
.)
60 ! Save and restore the previous modes
61 call ieee_get_modes(modes2
)
62 call ieee_set_modes(modes1
)
65 if (ieee_support_underflow_control()) then
66 call ieee_get_underflow_mode(f
)
69 if (ieee_support_rounding(ieee_down
)) then
70 call ieee_get_rounding_mode(rmode
)
71 if (rmode
/= ieee_up
) stop 2
73 if (ieee_support_halting(ieee_overflow
)) then
74 call ieee_get_halting_mode(ieee_overflow
, f
)
78 ! Restore the second set of modes
79 call ieee_set_modes(modes2
)
82 if (ieee_support_underflow_control()) then
83 call ieee_get_underflow_mode(f
)
86 if (ieee_support_rounding(ieee_down
)) then
87 call ieee_get_rounding_mode(rmode
)
88 if (rmode
/= ieee_down
) stop 4
90 if (ieee_support_halting(ieee_overflow
)) then
91 call ieee_get_halting_mode(ieee_overflow
, f
)