From f216ee3fb43da3a18062d90e00eb315f5c135416 Mon Sep 17 00:00:00 2001 From: Shikhar Kumar Date: Tue, 2 Oct 2018 22:02:54 -0400 Subject: [PATCH] First pass at removing replay_batch_history --- src/simulation.F90 | 71 ++------------------------------------------- src/state_point.F90 | 16 +++++++++- 2 files changed, 17 insertions(+), 70 deletions(-) diff --git a/src/simulation.F90 b/src/simulation.F90 index f9fcc62bd5..b51962a17e 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -87,13 +87,6 @@ contains call initialize_batch() - ! Handle restart runs - if (restart_run .and. current_batch <= restart_batch) then - call replay_batch_history() - status = STATUS_EXIT_NORMAL - return - end if - ! ======================================================================= ! LOOP OVER GENERATIONS GENERATION_LOOP: do current_gen = 1, gen_per_batch @@ -205,7 +198,7 @@ contains total_weight = ZERO if ((n_inactive > 0 .and. current_batch == 1) .or. & - (restart_run .and. restart_batch <= n_inactive .and. current_batch == restart_batch)) then + (restart_run .and. restart_batch < n_inactive .and. current_batch == restart_batch + 1)) then ! Turn on inactive timer call time_inactive % start() elseif (current_batch == n_inactive + 1) then @@ -387,48 +380,6 @@ contains end subroutine finalize_batch -!=============================================================================== -! REPLAY_BATCH_HISTORY displays keff and entropy for each generation within a -! batch using data read from a state point file -!=============================================================================== - - subroutine replay_batch_history - - ! Write message at beginning - if (n_realizations == 0) then - call write_message("Replaying history from state point...", 6) - end if - - if (run_mode == MODE_EIGENVALUE) then - do current_gen = 1, gen_per_batch - call calculate_average_keff() - - ! print out batch keff - if (verbosity >= 7) then - if (current_gen < gen_per_batch) then - if (master) call print_generation() - else - if (master) call print_batch_keff() - end if - end if - end do - end if - - ! Increment n_realizations if in active batches as would ordinarily be done in finalize_batch - if (current_batch > n_inactive) then - if (reduce_tallies) then - n_realizations = n_realizations + 1 - else - n_realizations = n_realizations + n_procs - end if - end if - - ! Write message at end - if (current_batch == restart_batch) then - call write_message("Resuming simulation...", 6) - end if - - end subroutine replay_batch_history !=============================================================================== ! INITIALIZE_SIMULATION @@ -492,29 +443,11 @@ contains ! file if (restart_run) then call load_state_point() + call write_message("Resuming simulation...", 6) else call initialize_source() end if - ! In restart, set the batch to begin from in order to reproduce the correct - ! average keff (used in sampling the fission bank). Use n_realizations from - ! the statepoint rather than n_inactive in case openmc_reset was called in - ! the previous run. - if (restart_run) then - if (reduce_tallies) then - current_batch = restart_batch - n_realizations - else - current_batch = restart_batch - n_realizations*n_procs - end if - ! If simulation restarted from inactive batch, decrement current_batch - ! by one to replay an additional batch so that keff is set before resuming - ! simulation - if (restart_batch <= n_inactive) then - current_batch = current_batch - 1 - end if - n_realizations = 0 - end if - ! Display header if (master) then if (run_mode == MODE_FIXEDSOURCE) then diff --git a/src/state_point.F90 b/src/state_point.F90 index 526066c529..91d0f10908 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -16,7 +16,7 @@ module state_point use bank_header, only: Bank use cmfd_header use constants - use eigenvalue, only: openmc_get_keff + use eigenvalue, only: openmc_get_keff, k_sum use endf, only: reaction_name use error, only: fatal_error, warning, write_message use hdf5_interface @@ -749,6 +749,20 @@ contains ! Read number of realizations for global tallies call read_dataset(n_realizations, file_id, "n_realizations", indep=.true.) + ! Set k_sum, keff, and current_batch based on whether restart file is part + ! of active cycle or inactive cycle + if (restart_batch > n_inactive) then + do i = n_inactive + 1, restart_batch + k_sum(1) = k_sum(1) + k_generation % data(i) + k_sum(2) = k_sum(2) + k_generation % data(i)**2 + end do + n = gen_per_batch*n_realizations + keff = k_sum(1) / n + else + keff = k_generation % data(n) + end if + current_batch = restart_batch + ! Check to make sure source bank is present if (path_source_point == path_state_point .and. .not. source_present) then call fatal_error("Source bank must be contained in statepoint restart &