subroutine copy_core_dets_to_spawnedparts(rep)
! This routine will copy all the core determinants *ON THIS PROCESS
! ONLY* to the SpawnedParts array.
use load_balance_calcnodes, only: DetermineDetNode
type(core_space_t), intent(in) :: rep
integer :: i, ncore, proc
integer :: nI(nel)
character(len=*), parameter :: t_r = "copy_core_dets_to_spawnedparts"
ncore = 0
SpawnedParts = 0_n_int
do i = 1, rep%determ_space_size
call decode_bit_det(nI, rep%core_space(:, i))
proc = DetermineDetNode(nel, nI, 0)
if (proc == iProcIndex) then
ncore = ncore + 1
SpawnedParts(0:NIfTot, ncore) = rep%core_space(:, i)
end if
end do
if (ncore /= rep%determ_sizes(iProcIndex)) call stop_all(t_r, "The number of &
&core determinants counted is less than was previously counted.")
end subroutine copy_core_dets_to_spawnedparts