From 0bf2d0c4a9559561fc63c458d779946f0d759cb1 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 9 Nov 2018 07:56:14 -0600 Subject: [PATCH] Make sure Tally % n_realizations is available on all ranks --- src/tallies/tally.F90 | 10 +++++----- src/tallies/tally_header.F90 | 36 +++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/tallies/tally.F90 b/src/tallies/tally.F90 index 475c6a60c7..b82837ea1e 100644 --- a/src/tallies/tally.F90 +++ b/src/tallies/tally.F90 @@ -3792,11 +3792,6 @@ contains ! Accumulate on master only unless run is not reduced then do it on all if (master .or. (.not. reduce_tallies)) then - ! Accumulate results for each tally - do i = 1, active_tallies % size() - call tallies(active_tallies % data(i)) % obj % accumulate() - end do - if (run_mode == MODE_EIGENVALUE) then if (current_batch > n_inactive) then ! Accumulate products of different estimators of k @@ -3820,6 +3815,11 @@ contains end do end if + ! Accumulate results for each tally + do i = 1, active_tallies % size() + call tallies(active_tallies % data(i)) % obj % accumulate() + end do + end subroutine accumulate_tallies !=============================================================================== diff --git a/src/tallies/tally_header.F90 b/src/tallies/tally_header.F90 index 08d3588a5a..f2339d85d5 100644 --- a/src/tallies/tally_header.F90 +++ b/src/tallies/tally_header.F90 @@ -6,7 +6,7 @@ module tally_header use error use dict_header, only: DictIntInt use hdf5_interface, only: HID_T, HSIZE_T - use message_passing, only: n_procs + use message_passing, only: n_procs, master use nuclide_header, only: nuclide_dict use settings, only: reduce_tallies, run_mode use stl_vector, only: VectorInt @@ -182,25 +182,27 @@ contains this % n_realizations = this % n_realizations + n_procs end if - ! Calculate total source strength for normalization - if (run_mode == MODE_FIXEDSOURCE) then - total_source = total_source_strength() - else - total_source = ONE - end if + if (master .or. (.not. reduce_tallies)) then + ! Calculate total source strength for normalization + if (run_mode == MODE_FIXEDSOURCE) then + total_source = total_source_strength() + else + total_source = ONE + end if - ! Accumulate each result - do j = 1, size(this % results, 3) - do i = 1, size(this % results, 2) - val = this % results(RESULT_VALUE, i, j)/total_weight * total_source - this % results(RESULT_VALUE, i, j) = ZERO + ! Accumulate each result + do j = 1, size(this % results, 3) + do i = 1, size(this % results, 2) + val = this % results(RESULT_VALUE, i, j)/total_weight * total_source + this % results(RESULT_VALUE, i, j) = ZERO - this % results(RESULT_SUM, i, j) = & - this % results(RESULT_SUM, i, j) + val - this % results(RESULT_SUM_SQ, i, j) = & - this % results(RESULT_SUM_SQ, i, j) + val*val + this % results(RESULT_SUM, i, j) = & + this % results(RESULT_SUM, i, j) + val + this % results(RESULT_SUM_SQ, i, j) = & + this % results(RESULT_SUM_SQ, i, j) + val*val + end do end do - end do + end if end subroutine tally_accumulate subroutine tally_write_results_hdf5(this, group_id)