sync_rdm_sampling_iter Subroutine

public subroutine sync_rdm_sampling_iter()

Arguments

None

Contents


Source Code

    subroutine sync_rdm_sampling_iter()
        use LoggingData, only: RDMEnergyIter, IterRDMOnfly
        use CalcData, only: coreSpaceUpdateCycle, semistoch_shift_iter
        implicit none
        integer :: frac
        ! first, adjust the offset to make the rdm sampling start right when a semistochastic
        ! update cycle ends
        IterRDMOnFly = IterRDMOnFly - &
                       mod(IterRDMOnFly - semistoch_shift_iter, coreSpaceUpdateCycle) - 1
        ! The -1 is just because the sampling starts one iteration after IterRDMOnFly
        ! If we subtracted too much, jump one cycle backwards
        if (IterRDMOnFly < semistoch_shift_iter) IterRDMOnFly = IterRDMOnFly + coreSpaceUpdateCycle
        write(stdout, *) "Adjusted starting iteration of RDM sampling to ", IterRDMOnFly

        ! Now sync the update cycles
        if (RDMEnergyIter > coreSpaceUpdateCycle) then
            RDMEnergyIter = coreSpaceUpdateCycle
            write(stdout, *) "The RDM sampling interval cannot be larger than the update " &
                //"interval of the semi-stochastic space. Reducing it to ", RDMEnergyIter
        end if
        if (mod(coreSpaceUpdateCycle, RDMEnergyIter) /= 0) then
            ! first, try to ramp up the RDMEnergyIter to meet the coreSpaceUpdateCycle
            frac = coreSpaceUpdateCycle / RDMEnergyIter
            RDMEnergyIter = coreSpaceUpdateCycle / frac
            write(stdout, *) "Update cycle of semi-stochastic space and RDM sampling interval" &
                //" out of sync. "
            write(stdout, *) "Readjusting RDM sampling interval to ", RDMEnergyIter

            ! now, if this did not succeed, adjust the coreSpaceUpdateCycle
            if (mod(coreSpaceUpdateCycle, RDMEnergyIter) /= 0) then
                coreSpaceUpdateCycle = coreSpaceUpdateCycle - &
                                       mod(coreSpaceUpdateCycle, RDMEnergyIter)
                write(stdout, *) "Adjusted update cycle of semi-stochastic space to ", &
                    coreSpaceUpdateCycle
            end if
        end if
    end subroutine sync_rdm_sampling_iter