module subroutine ChangeRefDet(DetCurr)
INTEGER, intent(in) :: DetCurr(NEl)
integer :: i
FDet(1 : nEL) = DetCurr(1 : nEl)
write(stdout, "(A)") "*** Changing the reference determinant ***"
write(stdout, "(A)") "Switching reference and zeroing energy counters - restarting simulation"
!
!Initialise variables for calculation on each node
Iter = 1
CALL DeallocFCIMCMemPar()
IF (iProcIndex == Root) THEN
close(fcimcstats_unit)
if (inum_runs == 2) close(fcimcstats_unit2)
IF (tTruncInitiator) close(initiatorstats_unit)
IF (tLogComplexPops) close(complexstats_unit)
if (tLogEXLEVELStats) close(EXLEVELStats_unit)
end if
IF (TDebug) close(11)
CALL SetupParameters()
CALL InitFCIMCCalcPar()
end subroutine ChangeRefDet