subroutine update_hash_table_ind(hash_table, nI, ind_old, ind_new)
! Find and remove the entry in hash_table corresponding to nI, which
! must have index ind in the hash table. If not found then an error
! will be thrown.
type(ll_node), pointer, intent(inout) :: hash_table(:)
integer, intent(in) :: nI(:)
integer, intent(in) :: ind_old, ind_new
integer :: hash_val
type(ll_node), pointer :: prev, curr
logical :: found
#ifdef DEBUG_
character(len=*), parameter :: this_routine = "update_hash_table_ind"
#endif
ASSERT(all(nI <= nBasis))
ASSERT(all(nI > 0))
found = .false.
! Find the hash value corresponding to this determinant.
hash_val = FindWalkerHash(nI, size(hash_table))
! Point at the start of the linked list for this hash value.
curr => hash_table(hash_val)
prev => null()
! Loop over all entries in the linked list until we find the one equal
! to ind, the entry that we want to remove.
do while (associated(curr))
if (curr%ind == ind_old) then
! If this is the state to be removed.
found = .true.
curr%ind = ind_new
exit
end if
prev => curr
curr => curr%next
end do
ASSERT(found)
end subroutine update_hash_table_ind