subroutine init_real_time_iteration(iter_data, iter_data2)
! routine to reinitialize all the necessary variables and pointers
! for a sucessful real-time fciqmc iteration
! RT_M_Merge: Added dummy argument for rezero_iter_stats_each_iter
use rdm_data, only: rdm_definitions_t
type(fcimc_iter_data), intent(inout) :: iter_data
type(fcimc_iter_data), intent(inout), optional :: iter_data2
type(rdm_definitions_t) :: dummy
character(*), parameter :: this_routine = "init_real_time_iteration"
! reuse parts of nicks routine and add additional real-time fciqmc
! specific quantities
! Reset positions to spawn into in the spawning array.
ValidSpawnedList = InitialSpawnedSlots
! Reset the array which holds empty slots in CurrentDets.
! hm, where is the iEndFreeSlot var. set?
! well i guess it uses the value from the last iteration and then
! gets reset..
FreeSlot(1:iEndFreeSlot) = 0
iStartFreeSlot = 1
iEndFreeSlot = 0
temp_freeslot = 0
temp_iendfreeslot = 0
! also reset the temporary variables
! this probably has not to be done, since at the end of the first
! spawn i set it to the freeslot array anyway..
! with changed temp_ var. usage i have to reset them!
! Index for counting deterministic states.
! n_determ_states = 1
! reset population snapshot
popSnapshot = 0
! Clear the hash table for the spawning array.
call clear_hash_table(spawn_ht)
call rezero_iter_stats_each_iter(iter_data, dummy)
if (present(iter_data2)) then
call rezero_iter_stats_each_iter(iter_data2, dummy)
end if
! additionaly i have to copy the CurrentDets array and all the
! associated pointers and hashtable related stuff to the
! temporary 2nd list
call save_current_dets()
call update_elapsed_time()
end subroutine init_real_time_iteration