pure subroutine clear_hash_table(hash_table)
! Take hash_table and clear it. This is done by nullifying all pointers
! in all the linked lists that form the hash table, and setting the
! first index to zero.
type(ll_node), pointer, intent(inout) :: hash_table(:)
type(ll_node), pointer :: curr, prev
integer :: i
! Loop over all entries corresponding to different hash values.
do i = 1, size(hash_table)
! Point to the second entry in this linked list.
curr => hash_table(i)%next
! Point to the first entry in this linked list.
prev => hash_table(i)
! Set the first index to zero.
prev%ind = 0
nullify (prev%next)
! Loop over the whole linked list and deallocate all pointers.
do while (associated(curr))
prev => curr
curr => curr%next
deallocate(prev)
end do
end do
nullify (curr)
nullify (prev)
end subroutine clear_hash_table