real_equal Function

public pure elemental function real_equal(r1, r2)

logical function to compare real values

Arguments

Type IntentOptional AttributesName
real(kind=wp), intent(in) :: r1
real(kind=wp), intent(in) :: r2

Return Value logical


Called by

proc~~real_equal~~CalledByGraph proc~real_equal real_equal interface~operator(.iseq.) operator(.iseq.) interface~operator(.iseq.)->proc~real_equal

Contents

Source Code


Source Code

    pure elemental logical function real_equal(r1,r2)
        real(wp), intent(in) :: r1
        real(wp), intent(in) :: r2
        real(wp), parameter :: eps_wp  = epsilon(eps_wp)
        real(wp), parameter :: eps_wp3 = 3.0_wp * epsilon(eps_wp)

        !real_equal = abs(r1-r2) < eps
        real_equal = abs(r1-r2) <= max( abs(r1), abs(r2) ) * eps_wp3

    end function real_equal