subroutine init_kp_fciqmc_iter(iter_data, determ_index)
use FciMCData, only: FreeSlot, iStartFreeSlot, iEndFreeSlot, fcimc_iter_data, InitialSpawnedSlots
use FciMCData, only: ValidSpawnedList, spawn_ht
use hash, only: clear_hash_table
use rdm_data, only: rdm_definitions
type(fcimc_iter_data), intent(inout) :: iter_data
integer, intent(out) :: determ_index
! Reset positions to spawn into in the spawning array.
ValidSpawnedList = InitialSpawnedSlots
! Reset the array which holds empty slots in CurrentDets.
FreeSlot(1:iEndFreeSlot) = 0
iStartFreeSlot = 1
iEndFreeSlot = 0
! Index for counting deterministic states.
determ_index = 1
! Clear the hash table for the spawning array.
call clear_hash_table(spawn_ht)
call rezero_iter_stats_each_iter(iter_data, rdm_definitions)
end subroutine init_kp_fciqmc_iter