subroutine set_initial_global_data(ndets, ilut_list)
use bit_rep_data, only: NIfTot, nifd, extract_sign
use Parallel_neci, only: iProcIndex, MPISumAll
! Take in a list of determinants and calculate and set all of the
! global data needed for the start of a FCIQMC calculation.
integer(int64), intent(in) :: ndets
integer(n_int), intent(inout) :: ilut_list(0:NIfTot, ndets)
integer :: run
integer(int64) :: i
real(dp) :: real_sign(lenof_sign)
character(*), parameter :: t_r = 'set_initial_global_data'
TotParts = 0.0_dp
NoAtHF = 0.0_dp
iHighestPop = 0
! First, find the population of the walkers in walker_list.
do i = 1, ndets
call extract_sign(ilut_list(:, i), real_sign)
TotParts = TotParts + abs(real_sign)
if (all(ilut_list(0:nifd, i) == iLutRef(0:nifd, 1))) NoAtHF = real_sign
do run = 1, inum_runs
if (abs_sign(real_sign(min_part_type(run):max_part_type(run))) > iHighestPop(run)) then
iHighestPop(run) = int(abs_sign(real_sign(min_part_type(run):max_part_type(run))))
HighestPopDet(:, run) = ilut_list(:, i)
end if
end do
end do
TotWalkers = ndets
TotWalkersOld = TotWalkers
call MPISumAll(TotWalkers, AllTotWalkers)
AllTotWalkersOld = AllTotWalkers
TotPartsOld = TotParts
call MPISumAll(TotParts, AllTotParts)
AllTotPartsOld = AllTotParts
call MPISumAll(NoatHF, AllNoatHF)
OldAllNoatHF = AllNoatHF
#ifdef PROG_NUMRUNS_
do run = 1, inum_runs
OldAllAvWalkersCyc(run) = sum(AllTotParts(min_part_type(run):max_part_type(run)))
end do
#else
#ifdef CMPLX_
OldAllAvWalkersCyc = sum(AllTotParts)
#else
OldAllAvWalkersCyc = AllTotParts
#endif
#endif
do run = 1, inum_runs
OldAllHFCyc(run) = ARR_RE_OR_CPLX(AllNoatHF, run)
end do
AllNoAbortedOld(:) = 0.0_dp
iter_data_fciqmc%tot_parts_old = AllTotParts
do run = 1, inum_runs
! Calculate the projected energy for this iteration.
if (.not. near_zero(ARR_RE_OR_CPLX(AllSumNoAtHF, run))) &
ProjectionE(run) = AllSumENum(run) / ARR_RE_OR_CPLX(AllSumNoatHF, run)
if (iProcIndex == iRefProc(run)) then
do i = min_part_type(run), max_part_type(run)
SumNoatHF(i) = AllSumNoatHF(i)
InstNoatHF(i) = NoatHF(i)
end do
SumENum(run) = AllSumENum(run)
end if
end do
end subroutine set_initial_global_data