Restructured handling of tally reduction to make it more clear.

This commit is contained in:
Paul Romano 2012-05-03 10:56:23 -04:00
parent a27f8f216e
commit 1aae776272
4 changed files with 46 additions and 49 deletions

View file

@ -180,7 +180,7 @@ module global
integer :: MPI_BANK ! MPI datatype for fission bank
! No reduction at end of batch
logical :: no_reduce = .false.
logical :: reduce_tallies = .true.
! ============================================================================
! TIMING VARIABLES

View file

@ -305,13 +305,13 @@ contains
! Check if the user has specified to not reduce tallies at the end of every
! batch
if (trim(no_reduce_) == 'on') no_reduce = .true.
if (trim(no_reduce_) == 'on') reduce_tallies = .false.
! Determine number of realizations
if (no_reduce) then
n_realizations = n_active * n_procs
else
if (reduce_tallies) then
n_realizations = n_active
else
n_realizations = n_active * n_procs
end if

View file

@ -390,7 +390,23 @@ contains
! =======================================================================
! ACTIVE BATCHES
if (no_reduce) then
if (reduce_tallies) then
! In this case, global_tallies has already been reduced, so we don't
! 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
if (n > 1) then
! Standard deviation of the sample mean of k
keff_std = sqrt((global_tallies(K_ANALOG) % sum_sq/n - &
keff*keff)/(n - 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
@ -418,22 +434,6 @@ contains
! Standard deviation of the sample mean of k
keff_std = sqrt((temp(2)/n - keff*keff)/(n - 1))
end if
else
! In this case, global_tallies has already been reduced, so we don't
! 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
if (n > 1) then
! Standard deviation of the sample mean of k
keff_std = sqrt((global_tallies(K_ANALOG) % sum_sq/n - &
keff*keff)/(n - 1))
end if
end if
else

View file

@ -1309,26 +1309,25 @@ contains
integer :: i ! index in tallies array
#ifdef MPI
if (.not. no_reduce) then
call reduce_tally_values()
if (.not. master) return
end if
if (reduce_tallies) call reduce_tally_values()
#endif
! Accumulate scores for each tally
do i = 1, n_tallies
call accumulate_score(tallies(i) % scores)
end do
if (master .or. (.not. reduce_tallies)) then
! Accumulate scores for each tally
do i = 1, n_tallies
call accumulate_score(tallies(i) % scores)
end do
! Before accumulating scores for global_tallies, we need to get the current
! batch estimate of k_analog for displaying to output
k_batch = global_tallies(K_ANALOG) % value
! Before accumulating scores for global_tallies, we need to get the
! current batch estimate of k_analog for displaying to output
k_batch = global_tallies(K_ANALOG) % value
! Accumulate scores for global tallies
call accumulate_score(global_tallies)
! Accumulate scores for global tallies
call accumulate_score(global_tallies)
end if
#ifdef MPI
if (no_reduce .and. current_batch == n_batches) &
if ((.not. reduce_tallies) .and. current_batch == n_batches) &
call reduce_tally_sums()
#endif
@ -1401,15 +1400,13 @@ contains
! We also need to determine the total starting weight of particles from the
! last realization
if (.not. no_reduce) then
if (master) then
call MPI_REDUCE(MPI_IN_PLACE, total_weight, 1, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
else
! Receive buffer not significant at other processors
call MPI_REDUCE(total_weight, dummy, 1, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
end if
if (master) then
call MPI_REDUCE(MPI_IN_PLACE, total_weight, 1, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
else
! Receive buffer not significant at other processors
call MPI_REDUCE(total_weight, dummy, 1, MPI_REAL8, MPI_SUM, &
0, MPI_COMM_WORLD, mpi_err)
end if
end subroutine reduce_tally_values
@ -1417,10 +1414,10 @@ contains
!===============================================================================
! REDUCE_TALLY_SUMS gathers data from the sum and sum_sq member variables of
! TallyScores rather than the data from values. This is used if no_reduce is
! turned on and scores are accumulated on every processor *before* being
! reduced.
!===============================================================================
! TallyScores rather than the data from values. This is used if the user
! specified that tallies should not be reduced and scores are accumulated on
! every processor *before* being reduced.
! ===============================================================================
#ifdef MPI
subroutine reduce_tally_sums()