exprep Function

private pure function exprep(x) result(f)

this function replaces exp() to avoid underflow and overflow.

note that the maximum and minimum values of exprep are such that they has no effect on the algorithm.

History

  • Jacob Williams, 8/30/2019 : new version of this routine that uses IEEE flags.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x

Return Value real(kind=wp)


Called by

proc~~exprep~~CalledByGraph proc~exprep exprep proc~sa simulated_annealing_type%sa proc~sa->proc~exprep proc~solve_simulated_annealing solve_simulated_annealing proc~solve_simulated_annealing->proc~sa

Source Code

   pure function exprep(x) result(f)

      logical,dimension(2) :: flags
      type(ieee_flag_type),parameter,dimension(2) :: out_of_range = &
         [ieee_overflow,ieee_underflow]

      real(wp), intent(in) :: x
      real(wp) :: f

      call ieee_set_halting_mode(out_of_range,.false.)

      f = exp(x)

      call ieee_get_flag(out_of_range,flags)
      if (any(flags)) then
         call ieee_set_flag(out_of_range,.false.)
         if (flags(1)) then
            f = huge(1.0_wp)
         else
            f = 0.0_wp
         end if
      end if

   end function exprep