det_int_arr_eq Function

private pure function det_int_arr_eq(a, b, len)

Arguments

Type IntentOptional Attributes Name
integer(kind=n_int), intent(in), dimension(:) :: a
integer(kind=n_int), intent(in), dimension(:) :: b
integer, intent(in), optional :: len

Return Value logical


Contents

Source Code


Source Code

    logical pure function det_int_arr_eq(a, b, len)

        ! If two specified integer arrays are equal, return true. Otherwise
        ! return false.
        !
        ! In:  a, b - The arrays to consider
        !      len  - The maximum length to consider. Otherwise will use whole
        !             length of array
        !NOTE: These will sort by the bit-string integer length, n_int.
        !Therefore, these may be 32 or 64 bit integers and should
        !only be used as such.

        integer(kind=n_int), intent(in), dimension(:) :: a, b
        integer, intent(in), optional :: len

        integer llen, i

        ! Obtain the lengths of the arrays if a bound is not specified.
        ! Return false if mismatched sizes and not specified.
        if(present(len)) then
            llen = len
        else
            if(size(a) /= size(b)) then
                det_int_arr_eq = .false.
                return
            endif
            llen = size(a)
        endif

        ! Run through the arrays. Return if they differ at any point.
        do i = 1, llen
            if(a(i) /= b(i)) then
                det_int_arr_eq = .false.
                return
            endif
        enddo

        ! If we get this far, they are equal
        det_int_arr_eq = .true.
    end function det_int_arr_eq