2019-12-21 04:52:07 +08:00
|
|
|
!===-- module/ieee_exceptions.f90 ------------------------------------------===!
|
2019-06-01 07:35:52 +08:00
|
|
|
!
|
2019-12-21 04:52:07 +08:00
|
|
|
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
! See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2019-06-01 07:35:52 +08:00
|
|
|
!
|
2020-01-11 04:12:03 +08:00
|
|
|
!===------------------------------------------------------------------------===!
|
2019-06-01 07:35:52 +08:00
|
|
|
|
|
|
|
! See Fortran 2018, clause 17
|
|
|
|
module ieee_exceptions
|
|
|
|
|
|
|
|
type :: ieee_flag_type ! Fortran 2018, 17.2 & 17.3
|
|
|
|
private
|
|
|
|
integer(kind=1) :: flag = 0
|
|
|
|
end type ieee_flag_type
|
|
|
|
|
|
|
|
type(ieee_flag_type), parameter :: &
|
|
|
|
ieee_invalid = ieee_flag_type(1), &
|
|
|
|
ieee_overflow = ieee_flag_type(2), &
|
|
|
|
ieee_divide_by_zero = ieee_flag_type(4), &
|
|
|
|
ieee_underflow = ieee_flag_type(8), &
|
2019-09-17 07:58:13 +08:00
|
|
|
ieee_inexact = ieee_flag_type(16), &
|
|
|
|
ieee_denorm = ieee_flag_type(32) ! PGI extension
|
2019-06-01 07:35:52 +08:00
|
|
|
|
|
|
|
type(ieee_flag_type), parameter :: &
|
2019-08-07 05:14:33 +08:00
|
|
|
ieee_usual(*) = [ &
|
2019-06-01 07:35:52 +08:00
|
|
|
ieee_overflow, ieee_divide_by_zero, ieee_invalid ], &
|
2019-08-07 05:14:33 +08:00
|
|
|
ieee_all(*) = [ &
|
2019-09-17 07:58:13 +08:00
|
|
|
ieee_usual, ieee_underflow, ieee_inexact, ieee_denorm ]
|
2019-06-01 07:35:52 +08:00
|
|
|
|
|
|
|
type :: ieee_modes_type ! Fortran 2018, 17.7
|
|
|
|
private
|
|
|
|
end type ieee_modes_type
|
|
|
|
|
|
|
|
type :: ieee_status_type ! Fortran 2018, 17.7
|
|
|
|
private
|
|
|
|
end type ieee_status_type
|
|
|
|
|
2019-09-17 07:58:13 +08:00
|
|
|
private :: ieee_support_flag_2, ieee_support_flag_3, &
|
|
|
|
ieee_support_flag_4, ieee_support_flag_8, ieee_support_flag_10, &
|
|
|
|
ieee_support_flag_16
|
|
|
|
interface ieee_support_flag
|
2019-10-17 01:35:34 +08:00
|
|
|
module procedure :: ieee_support_flag, &
|
|
|
|
ieee_support_flag_2, ieee_support_flag_3, &
|
2019-09-17 07:58:13 +08:00
|
|
|
ieee_support_flag_4, ieee_support_flag_8, ieee_support_flag_10, &
|
|
|
|
ieee_support_flag_16
|
|
|
|
end interface
|
|
|
|
|
2019-06-01 07:35:52 +08:00
|
|
|
contains
|
2019-12-21 04:28:18 +08:00
|
|
|
elemental subroutine ieee_get_flag(flag, flag_value)
|
2019-08-10 02:34:31 +08:00
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
logical, intent(out) :: flag_value
|
|
|
|
end subroutine ieee_get_flag
|
|
|
|
|
2019-12-21 04:28:18 +08:00
|
|
|
elemental subroutine ieee_get_halting_mode(flag, halting)
|
2019-08-10 02:34:31 +08:00
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
logical, intent(out) :: halting
|
|
|
|
end subroutine ieee_get_halting_mode
|
|
|
|
|
2019-06-01 07:35:52 +08:00
|
|
|
subroutine ieee_get_modes(modes)
|
|
|
|
type(ieee_modes_type), intent(out) :: modes
|
|
|
|
end subroutine ieee_get_modes
|
|
|
|
|
|
|
|
subroutine ieee_get_status(status)
|
|
|
|
type(ieee_status_type), intent(out) :: status
|
|
|
|
end subroutine ieee_get_status
|
|
|
|
|
2019-08-10 02:34:31 +08:00
|
|
|
pure subroutine ieee_set_flag(flag, flag_value)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
logical, intent(in) :: flag_value
|
|
|
|
end subroutine ieee_set_flag
|
|
|
|
|
|
|
|
pure subroutine ieee_set_halting_mode(flag, halting)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
logical, intent(in) :: halting
|
|
|
|
end subroutine ieee_set_halting_mode
|
|
|
|
|
|
|
|
subroutine ieee_set_modes(modes)
|
|
|
|
type(ieee_modes_type), intent(in) :: modes
|
|
|
|
end subroutine ieee_set_modes
|
|
|
|
|
2019-06-01 07:35:52 +08:00
|
|
|
subroutine ieee_set_status(status)
|
|
|
|
type(ieee_status_type), intent(in) :: status
|
|
|
|
end subroutine ieee_set_status
|
|
|
|
|
2019-10-17 01:35:34 +08:00
|
|
|
pure logical function ieee_support_flag(flag)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
ieee_support_flag = .true.
|
|
|
|
end function
|
2019-09-17 07:58:13 +08:00
|
|
|
pure logical function ieee_support_flag_2(flag, x)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
real(kind=2), intent(in) :: x(..)
|
|
|
|
ieee_support_flag_2 = .true.
|
|
|
|
end function
|
|
|
|
pure logical function ieee_support_flag_3(flag, x)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
real(kind=3), intent(in) :: x(..)
|
|
|
|
ieee_support_flag_3 = .true.
|
|
|
|
end function
|
|
|
|
pure logical function ieee_support_flag_4(flag, x)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
real(kind=4), intent(in) :: x(..)
|
|
|
|
ieee_support_flag_4 = .true.
|
|
|
|
end function
|
|
|
|
pure logical function ieee_support_flag_8(flag, x)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
real(kind=8), intent(in) :: x(..)
|
|
|
|
ieee_support_flag_8 = .true.
|
|
|
|
end function
|
|
|
|
pure logical function ieee_support_flag_10(flag, x)
|
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
|
|
|
real(kind=10), intent(in) :: x(..)
|
|
|
|
ieee_support_flag_10 = .true.
|
|
|
|
end function
|
|
|
|
pure logical function ieee_support_flag_16(flag, x)
|
2019-08-10 02:34:31 +08:00
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
2019-09-17 07:58:13 +08:00
|
|
|
real(kind=16), intent(in) :: x(..)
|
|
|
|
ieee_support_flag_16 = .true.
|
|
|
|
end function
|
2019-08-10 02:34:31 +08:00
|
|
|
|
2019-09-11 03:43:16 +08:00
|
|
|
pure logical function ieee_support_halting(flag)
|
2019-08-10 02:34:31 +08:00
|
|
|
type(ieee_flag_type), intent(in) :: flag
|
2019-09-11 03:43:16 +08:00
|
|
|
end function ieee_support_halting
|
2019-06-01 07:35:52 +08:00
|
|
|
|
|
|
|
end module ieee_exceptions
|