From fe1f6062a4a8fe8019f833f06afef2df990ba7d7 Mon Sep 17 00:00:00 2001 From: amandalund Date: Fri, 31 Mar 2017 17:37:09 -0500 Subject: [PATCH] Switched type of active_*tallies from SetInt to VectorInt to eliminate need for threadprivate --- src/cmfd_input.F90 | 2 -- src/global.F90 | 14 ++++++-------- src/simulation.F90 | 2 -- src/tally.F90 | 44 ++++++++++++++++++++++++++++---------------- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/cmfd_input.F90 b/src/cmfd_input.F90 index 8b67f7a8f4..91f2e03b6d 100644 --- a/src/cmfd_input.F90 +++ b/src/cmfd_input.F90 @@ -607,9 +607,7 @@ contains end do ! Put cmfd tallies into active tally array and turn tallies on -!$omp parallel call setup_active_cmfdtallies() -!$omp end parallel tallies_on = .true. end subroutine create_cmfd_tally diff --git a/src/global.F90 b/src/global.F90 index 815063344c..dd013b3a89 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -18,6 +18,7 @@ module global use plot_header, only: ObjectPlot use sab_header, only: SAlphaBeta use set_header, only: SetInt + use stl_vector, only: VectorInt use surface_header, only: SurfaceContainer use source_header, only: SourceDistribution use tally_header, only: TallyObject, TallyDerivative @@ -154,14 +155,11 @@ module global integer :: i_cmfd_tallies = -1 ! Active tally lists - type(SetInt) :: active_analog_tallies - type(SetInt) :: active_tracklength_tallies - type(SetInt) :: active_current_tallies - type(SetInt) :: active_collision_tallies - type(SetInt) :: active_tallies -!$omp threadprivate(active_analog_tallies, active_tracklength_tallies, & -!$omp& active_current_tallies, active_collision_tallies, & -!$omp& active_tallies) + type(VectorInt) :: active_analog_tallies + type(VectorInt) :: active_tracklength_tallies + type(VectorInt) :: active_current_tallies + type(VectorInt) :: active_collision_tallies + type(VectorInt) :: active_tallies ! Global tallies ! 1) collision estimate of k-eff diff --git a/src/simulation.F90 b/src/simulation.F90 index 13cc9b6695..0cdb4c66d0 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -186,9 +186,7 @@ contains tallies_on = .true. ! Add user tallies to active tallies list -!$omp parallel call setup_active_usertallies() -!$omp end parallel end if ! check CMFD initialize batch diff --git a/src/tally.F90 b/src/tally.F90 index f222fc55fc..02ab07339e 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -2219,7 +2219,7 @@ contains TALLY_LOOP: do i = 1, active_analog_tallies % size() ! Get index of tally and pointer to tally - i_tally = active_analog_tallies % get_item(i) + i_tally = active_analog_tallies % data(i) t => tallies(i_tally) ! Find the first bin in each filter. There may be more than one matching @@ -2356,7 +2356,7 @@ contains TALLY_LOOP: do i = 1, active_analog_tallies % size() ! Get index of tally and pointer to tally - i_tally = active_analog_tallies % get_item(i) + i_tally = active_analog_tallies % data(i) t => tallies(i_tally) ! Get pointer to current material. We need this in order to determine what @@ -2689,7 +2689,7 @@ contains TALLY_LOOP: do i = 1, active_tracklength_tallies % size() ! Get index of tally and pointer to tally - i_tally = active_tracklength_tallies % get_item(i) + i_tally = active_tracklength_tallies % data(i) t => tallies(i_tally) ! Find the first bin in each filter. There may be more than one matching @@ -2845,7 +2845,7 @@ contains TALLY_LOOP: do i = 1, active_collision_tallies % size() ! Get index of tally and pointer to tally - i_tally = active_collision_tallies % get_item(i) + i_tally = active_collision_tallies % data(i) t => tallies(i_tally) ! Find the first bin in each filter. There may be more than one matching @@ -3004,7 +3004,7 @@ contains xyz1 = p % coord(1) % xyz ! Get pointer to tally - i_tally = active_current_tallies % get_item(i) + i_tally = active_current_tallies % data(i) t => tallies(i_tally) ! Get index for mesh, surface, and energy filters @@ -4025,7 +4025,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 % get_item(i))) + call accumulate_tally(tallies(active_tallies % data(i))) end do if (run_mode == MODE_EIGENVALUE) then @@ -4070,7 +4070,7 @@ contains type(TallyObject), pointer :: t do i = 1, active_tallies % size() - t => tallies(active_tallies % get_item(i)) + t => tallies(active_tallies % data(i)) m = t % total_score_bins n = t % total_filter_bins @@ -4214,22 +4214,28 @@ contains do i = 1, n_user_tallies ! Add tally to active tallies - call active_tallies % add(i_user_tallies + i) + call active_tallies % push_back(i_user_tallies + i) ! Check what type of tally this is and add it to the appropriate list if (user_tallies(i) % type == TALLY_VOLUME) then if (user_tallies(i) % estimator == ESTIMATOR_ANALOG) then - call active_analog_tallies % add(i_user_tallies + i) + call active_analog_tallies % push_back(i_user_tallies + i) elseif (user_tallies(i) % estimator == ESTIMATOR_TRACKLENGTH) then - call active_tracklength_tallies % add(i_user_tallies + i) + call active_tracklength_tallies % push_back(i_user_tallies + i) elseif (user_tallies(i) % estimator == ESTIMATOR_COLLISION) then - call active_collision_tallies % add(i_user_tallies + i) + call active_collision_tallies % push_back(i_user_tallies + i) end if elseif (user_tallies(i) % type == TALLY_SURFACE_CURRENT) then - call active_current_tallies % add(i_user_tallies + i) + call active_current_tallies % push_back(i_user_tallies + i) end if end do + call active_tallies % shrink_to_fit() + call active_analog_tallies % shrink_to_fit() + call active_tracklength_tallies % shrink_to_fit() + call active_collision_tallies % shrink_to_fit() + call active_current_tallies % shrink_to_fit() + end subroutine setup_active_usertallies !=============================================================================== @@ -4256,20 +4262,26 @@ contains do i = 1, n_cmfd_tallies ! Add CMFD tally to active tallies - call active_tallies % add(i_cmfd_tallies + i) + call active_tallies % push_back(i_cmfd_tallies + i) ! Check what type of tally this is and add it to the appropriate list if (cmfd_tallies(i) % type == TALLY_VOLUME) then if (cmfd_tallies(i) % estimator == ESTIMATOR_ANALOG) then - call active_analog_tallies % add(i_cmfd_tallies + i) + call active_analog_tallies % push_back(i_cmfd_tallies + i) elseif (cmfd_tallies(i) % estimator == ESTIMATOR_TRACKLENGTH) then - call active_tracklength_tallies % add(i_cmfd_tallies + i) + call active_tracklength_tallies % push_back(i_cmfd_tallies + i) end if elseif (cmfd_tallies(i) % type == TALLY_SURFACE_CURRENT) then - call active_current_tallies % add(i_cmfd_tallies + i) + call active_current_tallies % push_back(i_cmfd_tallies + i) end if end do + call active_tallies % shrink_to_fit() + call active_analog_tallies % shrink_to_fit() + call active_tracklength_tallies % shrink_to_fit() + call active_collision_tallies % shrink_to_fit() + call active_current_tallies % shrink_to_fit() + end subroutine setup_active_cmfdtallies end module tally