function TestMCExit(Iter, RDMSamplingIter) result(ExitCriterion)
integer, intent(in) :: Iter, RDMSamplingIter
logical :: ExitCriterion
if ((Iter > NMCyc) .and. (NMCyc /= -1)) then
write(stdout, "(A)") "Total iteration number limit reached. Finishing FCIQMC loop..."
ExitCriterion = .true.
else if ((RDMSamplingIter > iSampleRDMIters) .and. (iSampleRDMIters /= -1)) then
write(stdout, "(A)") "RDM Sampling iteration number limit reached. Finishing FCIQMC loop..."
ExitCriterion = .true.
else if (Iter - maxval(VaryShiftIter) >= eq_cyc .and. eq_cyc > -1 &
.and. all(.not. tSinglePartPhase)) then
write(stdout, "(A)") "Equilibrated iteration number limit reached. Finishing FCIQMC loop..."
ExitCriterion = .true.
else
ExitCriterion = .false.
end if
end function TestMCExit