pure subroutine hash_table_lookup_int_32(orbs, targ, max_elem, hash_table, targ_array, ind, hash_val, found)
! Perform a search of targ_array for targ, by using hash_table.
! Only elements 0:max_elem will be used in comparing targ.
! If targ is found then found will be returned as .true. and ind will
! contain the index of targ in targ_array. Else, found will be
! returned as .false. and ind will be unset.
integer, intent(in) :: orbs(:)
integer(int32), intent(in) :: targ(0:)
integer, intent(in) :: max_elem
! Note that hash_table won't actually change, but we need the inout
! label to make this routine pure.
type(ll_node), pointer, intent(inout) :: hash_table(:)
integer(int32), intent(in) :: targ_array(0:, :)
integer, intent(out) :: ind
integer, intent(out) :: hash_val
logical, intent(out) :: found
type(ll_node), pointer :: temp_node
found = .false.
hash_val = FindWalkerHash(orbs, size(hash_table))
! Point to the first node in the linked list for this hash value.
temp_node => hash_table(hash_val)
! If temp_node%ind = 0 then there are no entries in targ_array
! with this hash, so the target is not in targ_array, so return.
if (temp_node%ind /= 0) then
do while (associated(temp_node))
! Check using the index stored in temp_node to see if we have
! found the searched-for determinant.
if (all(targ(0:max_elem) == targ_array(0:max_elem, temp_node%ind))) then
found = .true.
ind = temp_node%ind
exit
end if
! Move on to the next determinant with this hash value.
temp_node => temp_node%next
end do
end if
nullify (temp_node)
end subroutine hash_table_lookup_int_32