1 !===-- module/ieee_exceptions.f90 ------------------------------------------===!
3 ! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 ! See https://llvm.org/LICENSE.txt for license information.
5 ! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 !===------------------------------------------------------------------------===!
9 ! See Fortran 2018, clause 17
10 module ieee_exceptions
12 type :: ieee_flag_type
! Fortran 2018, 17.2 & 17.3
14 integer(kind
=1) :: flag
= 0
15 end type ieee_flag_type
17 type(ieee_flag_type
), parameter :: &
18 ieee_invalid
= ieee_flag_type(1), &
19 ieee_overflow
= ieee_flag_type(2), &
20 ieee_divide_by_zero
= ieee_flag_type(4), &
21 ieee_underflow
= ieee_flag_type(8), &
22 ieee_inexact
= ieee_flag_type(16), &
23 ieee_denorm
= ieee_flag_type(32) ! PGI extension
25 type(ieee_flag_type
), parameter :: &
27 ieee_overflow
, ieee_divide_by_zero
, ieee_invalid
], &
29 ieee_usual
, ieee_underflow
, ieee_inexact
, ieee_denorm
]
31 type :: ieee_modes_type
! Fortran 2018, 17.7
33 end type ieee_modes_type
35 type :: ieee_status_type
! Fortran 2018, 17.7
37 end type ieee_status_type
39 private
:: ieee_support_flag_2
, ieee_support_flag_3
, &
40 ieee_support_flag_4
, ieee_support_flag_8
, ieee_support_flag_10
, &
42 interface ieee_support_flag
43 module procedure
:: ieee_support_flag
, &
44 ieee_support_flag_2
, ieee_support_flag_3
, &
45 ieee_support_flag_4
, ieee_support_flag_8
, ieee_support_flag_10
, &
50 elemental
subroutine ieee_get_flag(flag
, flag_value
)
51 type(ieee_flag_type
), intent(in
) :: flag
52 logical, intent(out
) :: flag_value
53 end subroutine ieee_get_flag
55 elemental
subroutine ieee_get_halting_mode(flag
, halting
)
56 type(ieee_flag_type
), intent(in
) :: flag
57 logical, intent(out
) :: halting
58 end subroutine ieee_get_halting_mode
60 subroutine ieee_get_modes(modes
)
61 type(ieee_modes_type
), intent(out
) :: modes
62 end subroutine ieee_get_modes
64 subroutine ieee_get_status(status
)
65 type(ieee_status_type
), intent(out
) :: status
66 end subroutine ieee_get_status
68 pure
subroutine ieee_set_flag(flag
, flag_value
)
69 type(ieee_flag_type
), intent(in
) :: flag
70 logical, intent(in
) :: flag_value
71 end subroutine ieee_set_flag
73 pure
subroutine ieee_set_halting_mode(flag
, halting
)
74 type(ieee_flag_type
), intent(in
) :: flag
75 logical, intent(in
) :: halting
76 end subroutine ieee_set_halting_mode
78 subroutine ieee_set_modes(modes
)
79 type(ieee_modes_type
), intent(in
) :: modes
80 end subroutine ieee_set_modes
82 subroutine ieee_set_status(status
)
83 type(ieee_status_type
), intent(in
) :: status
84 end subroutine ieee_set_status
86 pure
logical function ieee_support_flag(flag
)
87 type(ieee_flag_type
), intent(in
) :: flag
88 ieee_support_flag
= .true
.
90 pure
logical function ieee_support_flag_2(flag
, x
)
91 type(ieee_flag_type
), intent(in
) :: flag
92 real(kind
=2), intent(in
) :: x(..)
93 ieee_support_flag_2
= .true
.
95 pure
logical function ieee_support_flag_3(flag
, x
)
96 type(ieee_flag_type
), intent(in
) :: flag
97 real(kind
=3), intent(in
) :: x(..)
98 ieee_support_flag_3
= .true
.
100 pure
logical function ieee_support_flag_4(flag
, x
)
101 type(ieee_flag_type
), intent(in
) :: flag
102 real(kind
=4), intent(in
) :: x(..)
103 ieee_support_flag_4
= .true
.
105 pure
logical function ieee_support_flag_8(flag
, x
)
106 type(ieee_flag_type
), intent(in
) :: flag
107 real(kind
=8), intent(in
) :: x(..)
108 ieee_support_flag_8
= .true
.
110 pure
logical function ieee_support_flag_10(flag
, x
)
111 type(ieee_flag_type
), intent(in
) :: flag
112 real(kind
=10), intent(in
) :: x(..)
113 ieee_support_flag_10
= .true
.
115 pure
logical function ieee_support_flag_16(flag
, x
)
116 type(ieee_flag_type
), intent(in
) :: flag
117 real(kind
=16), intent(in
) :: x(..)
118 ieee_support_flag_16
= .true
.
121 pure
logical function ieee_support_halting(flag
)
122 type(ieee_flag_type
), intent(in
) :: flag
123 end function ieee_support_halting
125 end module ieee_exceptions