is_equal Function

private elemental function is_equal(lhs, rhs)

Arguments

Type IntentOptional AttributesName
class(container), intent(in) :: lhs
class(container), intent(in) :: rhs

Return Value logical

Description

Checks whether two containers are of the same type and are storing the same contents.


Source Code

  elemental logical function is_equal(lhs, rhs)
    !! Author: Chris MacMackin
    !! Date: December 2015
    !!
    !! Checks whether two containers are of the same type and are
    !! storing the same contents.
    class(container), intent(in) :: lhs, rhs
    if (.not.same_type_as(lhs, rhs)) then
      is_equal = .false.
      return
    end if
    if ((.not.lhs%filled).and.(.not.rhs%filled)) then
      is_equal = .true.
      return
    end if
    if (lhs%filled.neqv.rhs%filled) then
      is_equal = .false.
      return
    end if
    is_equal = (size(lhs%storage) == size(rhs%storage) .and. &
                all(lhs%storage == rhs%storage))
  end function is_equal