ismall Function

public pure function ismall(x, ref)

Evaluates the smallness of a variable compared to a reference value.

.true. if x is small compared to ref according to eps_wp, and .false. otherwise.

Arguments

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

Reference value, default=1.0

Return Value logical


Source Code

  pure logical function ismall(x, ref)
    !* Evaluates the smallness of a variable compared to a reference value.
    !
    ! `.true.` if `x` is small compared to `ref` according to `eps_wp`, and
    !* `.false.` otherwise.

    real(wp), intent(in) :: x
    real(wp), intent(in), optional :: ref  !! Reference value, default=`1.0`
    real(wp) :: ref_

    ref_ = 1.0_wp

    if (present(ref)) then
      ref_ = ref
    end if

    ismall = abs(x) < eps_wp * abs(ref_)
  end function ismall