disjoint_integer_int32 Function

private pure function disjoint_integer_int32(A, B) result(res)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: A(:)
integer(kind=int32), intent(in) :: B(:)

Return Value logical


Contents


Source Code

    pure function disjoint_integer_int32 (A, B) result(res)
        integer (int32), intent(in) :: A(:), B(:)
        logical :: res
        character(*), parameter :: this_routine = "disjoint_integer_int32"

        integer :: i, j

#ifdef DEBUG_
    block
        use util_mod, only: stop_all
        if (.not. (is_sorted(A))) then
            call stop_all (this_routine, "Assert fail: is_sorted(A)")
        end if
    end block
#endif
#ifdef DEBUG_
    block
        use util_mod, only: stop_all
        if (.not. (is_sorted(B))) then
            call stop_all (this_routine, "Assert fail: is_sorted(B)")
        end if
    end block
#endif

        res = .true.
        i = 1; j = 1
        do while (i <= size(A) .and. j <= size(B))
            if (A(i) < B(j)) then
                i = i + 1
            else if (A(i) > B(j)) then
                j = j + 1
            else
                res = .false.
                return
            end if
        end do
    end function disjoint_integer_int32