logical function to compare real values
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | r1 | |||
real(kind=wp), | intent(in) | :: | r2 |
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