are_almost_equal Function

public elemental function are_almost_equal(x, y) result(almost_equal)

Arguments

Type IntentOptional Attributes Name
real(kind=ESMF_KIND_R8), intent(in) :: x
real(kind=ESMF_KIND_R4), intent(in) :: y

Return Value logical


Called by

proc~~are_almost_equal~~CalledByGraph proc~are_almost_equal are_almost_equal proc~test_almost_equal_array test_almost_equal_array proc~test_almost_equal_array->proc~are_almost_equal proc~test_almost_equal_scalar test_almost_equal_scalar proc~test_almost_equal_scalar->proc~are_almost_equal proc~test_fieldcopy_r8r4 test_FieldCOPY_R8R4 proc~test_fieldcopy_r8r4->proc~are_almost_equal

Source Code

   elemental function are_almost_equal(x, y) result(almost_equal)
      real(kind=ESMF_KIND_R4), parameter :: EPS = epsilon(real(1.0, kind=ESMF_KIND_R4))
      real(kind=ESMF_KIND_R8), intent(in) :: x
      real(kind=ESMF_KIND_R4), intent(in) :: y
      logical :: almost_equal

      if(y==0) then
         almost_equal = (x==0)
      else
         almost_equal = (abs(x-y)/abs(y) < EPS)
      end if

   end function are_almost_equal