From af25e7932e5e50d3a5516c695997fa59110106db Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 31 Jul 2012 10:25:29 -0400 Subject: [PATCH] Increase n_realizations every time accumulate_score is called. --- src/global.F90 | 4 ++-- src/input_xml.F90 | 8 -------- src/intercycle.F90 | 22 ++++++++-------------- src/tally.F90 | 7 +++++++ 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/global.F90 b/src/global.F90 index a94548f5e5..dea0db4570 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -121,8 +121,8 @@ module global integer :: n_current_tallies = 0 ! # of surface current tallies ! Normalization for statistics - integer :: n_realizations ! # of independent realizations - real(8) :: total_weight ! total starting particle weight in realization + integer :: n_realizations = 0 ! # of independent realizations + real(8) :: total_weight ! total starting particle weight in realization ! Flag for turning tallies on logical :: tallies_on diff --git a/src/input_xml.F90 b/src/input_xml.F90 index ec192e74f8..72a64a7758 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -461,14 +461,6 @@ contains ! batch if (trim(no_reduce_) == 'on') reduce_tallies = .false. - ! Determine number of realizations - if (reduce_tallies) then - n_realizations = n_active - else - n_realizations = n_active * n_procs - end if - - end subroutine read_settings_xml !=============================================================================== diff --git a/src/intercycle.F90 b/src/intercycle.F90 index 3a155df508..0118bf5104 100644 --- a/src/intercycle.F90 +++ b/src/intercycle.F90 @@ -360,7 +360,6 @@ contains subroutine calculate_keff() - integer :: n ! active batch number real(8) :: temp(2) ! used to reduce sum and sum_sq message = "Calculate batch keff..." @@ -395,25 +394,19 @@ contains ! need to perform any more reductions and just take the values from ! global_tallies directly - ! Define number of realizations - n = current_batch - n_inactive - ! Sample mean of keff - keff = global_tallies(K_ANALOG) % sum / n + keff = global_tallies(K_ANALOG) % sum / n_realizations - if (n > 1) then + if (n_realizations > 1) then ! Standard deviation of the sample mean of k - keff_std = sqrt((global_tallies(K_ANALOG) % sum_sq/n - & - keff*keff)/(n - 1)) + keff_std = sqrt((global_tallies(K_ANALOG) % sum_sq / & + n_realizations - keff * keff) / (n_realizations - 1)) end if else ! In this case, no reduce was ever done on global_tallies. Thus, we ! need to reduce the values in sum and sum^2 to get the sample mean ! and its standard deviation - ! Define number of realizations - n = (current_batch - n_inactive) * n_procs - #ifdef MPI if (current_batch /= n_batches) then call MPI_REDUCE(global_tallies(K_ANALOG) % sum, temp, 2, & @@ -428,11 +421,12 @@ contains #endif ! Sample mean of k - keff = temp(1) / n + keff = temp(1) / n_realizations - if (n > 1) then + if (n_realizations > 1) then ! Standard deviation of the sample mean of k - keff_std = sqrt((temp(2)/n - keff*keff)/(n - 1)) + keff_std = sqrt((temp(2)/n_realizations - keff*keff) / & + (n_realizations - 1)) end if end if diff --git a/src/tally.F90 b/src/tally.F90 index fa49364be1..955daf8380 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -1622,6 +1622,13 @@ contains #endif if (master .or. (.not. reduce_tallies)) then + ! Increase number of realizations + if (reduce_tallies) then + n_realizations = n_realizations + 1 + else + n_realizations = n_realizations + n_procs + end if + ! Accumulate scores for each tally do i = 1, n_tallies call accumulate_score(tallies(i) % scores)