subroutine add_semistoch_spawns(population, populationSize, hashTable, maxSize, &
sourcePopulation)
integer(n_int), intent(inout) :: population(:, :)
integer, intent(inout) :: populationSize
type(ll_node), pointer, intent(inout) :: hashTable(:)
integer, intent(in) :: maxSize
integer(n_int), intent(in) :: sourcePopulation(:, :)
integer :: i, hashValue, ilutindex, nI(nel)
real(dp) :: sign(lenof_sign)
logical :: tSuccess
character(*), parameter :: this_routine = "add_semistoch_spawns"
associate(rep => cs_replicas(core_run))
do i = 1, rep%determ_sizes(iProcIndex)
! check if the core-space determinant was already spawned upon
call decode_bit_det(nI, sourcePopulation(:, rep%indices_of_determ_states(i)))
call hash_table_lookup(nI, sourcePopulation(:, rep%indices_of_determ_states(i)), nifd, &
hashTable, population, ilutindex, hashValue, tSuccess)
if (tSuccess) then
! if it is found, add the signs
call extract_sign(population(:, ilutIndex), sign)
call encode_sign(population(:, ilutIndex), sign + rep%partial_determ_vecs(:, i))
else
! the spawn is new, add it to population
populationSize = populationSize + 1
if (populationSize > maxSize) call stop_all(this_routine, &
"Out of memory for adding semistochastic spawns")
population(:, populationSize) = sourcePopulation(:, rep%indices_of_determ_states(i))
call encode_sign(population(:, populationSize), rep%partial_determ_vecs(:, i))
! add the hash table entry for the new determinant
call add_hash_table_entry(hashTable, populationSize, hashValue)
end if
end do
end associate
end subroutine add_semistoch_spawns