mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Move accumulate tally into type-bound procedure
This commit is contained in:
parent
ce1a342976
commit
1740d9fb8d
2 changed files with 38 additions and 37 deletions
|
|
@ -4256,7 +4256,7 @@ contains
|
|||
if (master .or. (.not. reduce_tallies)) then
|
||||
! Accumulate results for each tally
|
||||
do i = 1, active_tallies % size()
|
||||
call accumulate_tally(tallies(active_tallies % data(i)) % obj)
|
||||
call tallies(active_tallies % data(i)) % obj % accumulate()
|
||||
end do
|
||||
|
||||
if (run_mode == MODE_EIGENVALUE) then
|
||||
|
|
@ -4345,39 +4345,6 @@ contains
|
|||
end subroutine reduce_tally_results
|
||||
#endif
|
||||
|
||||
!===============================================================================
|
||||
! ACCUMULATE_TALLY
|
||||
!===============================================================================
|
||||
|
||||
subroutine accumulate_tally(t)
|
||||
|
||||
type(TallyObject), intent(inout) :: t
|
||||
|
||||
integer :: i, j
|
||||
real(C_DOUBLE) :: val
|
||||
|
||||
! Increment number of realizations
|
||||
if (reduce_tallies) then
|
||||
t % n_realizations = t % n_realizations + 1
|
||||
else
|
||||
t % n_realizations = t % n_realizations + n_procs
|
||||
end if
|
||||
|
||||
! Accumulate each result
|
||||
do j = 1, size(t % results, 3)
|
||||
do i = 1, size(t % results, 2)
|
||||
val = t % results(RESULT_VALUE, i, j)/total_weight
|
||||
t % results(RESULT_VALUE, i, j) = ZERO
|
||||
|
||||
t % results(RESULT_SUM, i, j) = &
|
||||
t % results(RESULT_SUM, i, j) + val
|
||||
t % results(RESULT_SUM_SQ, i, j) = &
|
||||
t % results(RESULT_SUM_SQ, i, j) + val*val
|
||||
end do
|
||||
end do
|
||||
|
||||
end subroutine accumulate_tally
|
||||
|
||||
!===============================================================================
|
||||
! SETUP_ACTIVE_TALLIES
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ module tally_header
|
|||
use constants
|
||||
use error
|
||||
use dict_header, only: DictIntInt
|
||||
use message_passing, only: n_procs
|
||||
use nuclide_header, only: nuclide_dict
|
||||
use settings, only: reduce_tallies
|
||||
use stl_vector, only: VectorInt
|
||||
use string, only: to_lower, to_f_string, str_to_int
|
||||
use tally_filter_header, only: TallyFilterContainer, filters, n_filters
|
||||
|
|
@ -108,9 +110,10 @@ module tally_header
|
|||
integer :: deriv = NONE
|
||||
|
||||
contains
|
||||
procedure :: accumulate => tally_accumulate
|
||||
procedure :: allocate_results => tally_allocate_results
|
||||
procedure :: read_results_hdf5 => tally_read_results_hdf5
|
||||
procedure :: write_results_hdf5 => tally_write_results_hdf5
|
||||
procedure :: allocate_results => tally_allocate_results
|
||||
procedure :: set_filters => tally_set_filters
|
||||
end type TallyObject
|
||||
|
||||
|
|
@ -161,6 +164,37 @@ module tally_header
|
|||
|
||||
contains
|
||||
|
||||
!===============================================================================
|
||||
! ACCUMULATE_TALLY
|
||||
!===============================================================================
|
||||
|
||||
subroutine tally_accumulate(this)
|
||||
class(TallyObject), intent(inout) :: this
|
||||
|
||||
integer :: i, j
|
||||
real(C_DOUBLE) :: val
|
||||
|
||||
! Increment number of realizations
|
||||
if (reduce_tallies) then
|
||||
this % n_realizations = this % n_realizations + 1
|
||||
else
|
||||
this % n_realizations = this % n_realizations + n_procs
|
||||
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
|
||||
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
|
||||
end do
|
||||
end do
|
||||
end subroutine tally_accumulate
|
||||
|
||||
subroutine tally_write_results_hdf5(this, group_id)
|
||||
class(TallyObject), intent(in) :: this
|
||||
integer(HID_T), intent(in) :: group_id
|
||||
|
|
@ -268,8 +302,8 @@ contains
|
|||
integer(C_INT32_T), intent(in) :: filter_indices(:)
|
||||
integer(C_INT) :: err
|
||||
|
||||
integer :: i ! index in t % filter/stride
|
||||
integer :: j ! index in t % find_filter
|
||||
integer :: i ! index in this % filter/stride
|
||||
integer :: j ! index in this % find_filter
|
||||
integer :: k ! index in global filters array
|
||||
integer :: n ! number of filters
|
||||
integer :: stride ! filter stride
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue