From 78103849f86e68e55c1de95f9c9e6de27587ca5b Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sun, 12 Feb 2012 20:40:15 -0500 Subject: [PATCH] Added pointer lists for analog, track-length, and surface current tallies. --- src/global.F90 | 12 ++++++++-- src/input_xml.F90 | 57 +++++++++++++++++++++++++++++++++++++------- src/tally.F90 | 31 +++++++----------------- src/tally_header.F90 | 5 ++-- 4 files changed, 70 insertions(+), 35 deletions(-) diff --git a/src/global.F90 b/src/global.F90 index 5c09afe46f..19cc3fe885 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -86,11 +86,19 @@ module global type(StructuredMesh), allocatable, target :: meshes(:) type(TallyObject), allocatable, target :: tallies(:) + ! Pointers for analog, track-length, and surface-current tallies + integer, allocatable :: analog_tallies(:) + integer, allocatable :: tracklength_tallies(:) + integer, allocatable :: current_tallies(:) + ! Tally map structure type(TallyMap), allocatable :: tally_maps(:) - integer :: n_meshes ! # of structured meshes - integer :: n_tallies ! # of tallies + integer :: n_meshes ! # of structured meshes + integer :: n_tallies ! # of tallies + integer :: n_analog_tallies = 0 ! # of analog tallies + integer :: n_tracklength_tallies = 0 ! # of track-length tallies + integer :: n_current_tallies = 0 ! # of surface current tallies ! Flag for turning tallies on logical :: tallies_on diff --git a/src/input_xml.F90 b/src/input_xml.F90 index ad2f3d60ac..267c23026d 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -636,15 +636,18 @@ contains use xml_data_tallies_t - integer :: i ! loop over user-specified tallies - integer :: j ! loop over words - integer :: id ! user-specified identifier - integer :: i_mesh ! index in meshes array - integer :: n ! size of arrays in mesh specification - integer :: n_words ! number of words read - integer :: n_filters ! number of filters + integer :: i ! loop over user-specified tallies + integer :: j ! loop over words + integer :: i_analog ! index in analog_tallies array + integer :: i_tracklength ! index in tracklength_tallies array + integer :: i_current ! index in current_tallies array + integer :: id ! user-specified identifier + integer :: i_mesh ! index in meshes array + integer :: n ! size of arrays in mesh specification + integer :: n_words ! number of words read + integer :: n_filters ! number of filters integer :: filters(N_FILTER_TYPES) ! temporary list of filters - logical :: file_exists ! does tallies.xml file exist? + logical :: file_exists ! does tallies.xml file exist? character(MAX_LINE_LEN) :: filename character(MAX_WORD_LEN) :: word character(MAX_WORD_LEN) :: words(MAX_WORDS) @@ -1031,6 +1034,44 @@ contains t % n_score_bins = n_words end if + ! Count number of tallies by type + if (t % type == TALLY_VOLUME) then + if (t % estimator == ESTIMATOR_ANALOG) then + n_analog_tallies = n_analog_tallies + 1 + elseif (t % estimator == ESTIMATOR_TRACKLENGTH) then + n_tracklength_tallies = n_tracklength_tallies + 1 + end if + elseif (t % type == TALLY_SURFACE_CURRENT) then + n_current_tallies = n_current_tallies + 1 + end if + end do + + ! Allocate list of pointers for tallies by type + allocate(analog_tallies(n_analog_tallies)) + allocate(tracklength_tallies(n_tracklength_tallies)) + allocate(current_tallies(n_current_tallies)) + + ! Set indices for tally pointer lists to zero + i_analog = 0 + i_tracklength = 0 + i_current = 0 + + do i = 1, n_tallies + t => tallies(i) + + ! Increment the appropriate index and set pointer + if (t % type == TALLY_VOLUME) then + if (t % estimator == ESTIMATOR_ANALOG) then + i_analog = i_analog + 1 + analog_tallies(i_analog) = i + elseif (t % estimator == ESTIMATOR_TRACKLENGTH) then + i_tracklength = i_tracklength + 1 + tracklength_tallies(i_tracklength) = i + end if + elseif (t % type == TALLY_SURFACE_CURRENT) then + i_current = i_current + 1 + current_tallies(i_current) = i + end if end do end subroutine read_tallies_xml diff --git a/src/tally.F90 b/src/tally.F90 index eda14464e1..8a8eb0daac 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -261,19 +261,13 @@ contains ! A loop over all tallies is necessary because we need to simultaneously ! determine different filter bins for the same tally in order to score to it - do i = 1, n_tallies - t => tallies(i) - - ! Surface current tallies are treated separately - if (t % type == TALLY_SURFACE_CURRENT) cycle - - ! Skip tallies that are handled by track-length estimators - if (t % estimator == ESTIMATOR_TRACKLENGTH) cycle + do i = 1, n_analog_tallies + t => tallies(analog_tallies(i)) ! ======================================================================= ! DETERMINE SCORING BIN COMBINATION - call get_scoring_bins(p, i, bins, found_bin) + call get_scoring_bins(p, analog_tallies(i), bins, found_bin) if (.not. found_bin) cycle ! ======================================================================= @@ -541,19 +535,13 @@ contains ! A loop over all tallies is necessary because we need to simultaneously ! determine different filter bins for the same tally in order to score to it - do i = 1, n_tallies - t => tallies(i) - - ! Surface current tallies are treated separately - if (t % type == TALLY_SURFACE_CURRENT) cycle - - ! Skip tallies that are handled by track-length estimators - if (t % estimator == ESTIMATOR_ANALOG) cycle + do i = 1, n_tracklength_tallies + t => tallies(tracklength_tallies(i)) ! ======================================================================= ! DETERMINE SCORING BIN COMBINATION - call get_scoring_bins(p, i, bins, found_bin) + call get_scoring_bins(p, tracklength_tallies(i), bins, found_bin) if (.not. found_bin) cycle ! ======================================================================= @@ -757,16 +745,13 @@ contains bins = 1 - do i = 1, n_tallies + do i = 1, n_current_tallies ! Copy starting and ending location of particle xyz0 = p % last_xyz xyz1 = p % coord0 % xyz ! Get pointer to tally - t => tallies(i) - - ! Skip non-surface-current tallies - if (t % type /= TALLY_SURFACE_CURRENT) cycle + t => tallies(current_tallies(i)) ! Determine indices for starting and ending location m => meshes(t % mesh) diff --git a/src/tally_header.F90 b/src/tally_header.F90 index b722c2730c..8e04a334d4 100644 --- a/src/tally_header.F90 +++ b/src/tally_header.F90 @@ -51,8 +51,9 @@ module tally_header end type TallyFilter !=============================================================================== -! TALLY describes a user-specified tally. The region of phase space to tally in -! is given by the TallyBins and the scores are stored in a TallyScore array. +! TALLYOBJECT describes a user-specified tally. The region of phase space to +! tally in is given by the TallyBins and the scores are stored in a TallyScore +! array. !=============================================================================== type TallyObject