exprep Function

private pure function exprep(x) result(f)

Uses

  • proc~~exprep~~UsesGraph proc~exprep simulated_annealing_module::exprep ieee_exceptions ieee_exceptions proc~exprep->ieee_exceptions

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 simulated_annealing_module::exprep proc~sa simulated_annealing_module::simulated_annealing_type%sa proc~sa->proc~exprep

Source Code

    pure function exprep(x) result(f)

    use, intrinsic :: ieee_exceptions

    implicit none

    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