From 129d9a1cae60cdab99f5af28128f840f137949e4 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 9 Dec 2011 13:56:06 -0500 Subject: [PATCH] Reduced unnecessary calls to mesh_indices_to_bin. --- src/mesh.F90 | 10 +++++++--- src/tally.F90 | 26 ++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/mesh.F90 b/src/mesh.F90 index f88c5f1af0..40354a72ad 100644 --- a/src/mesh.F90 +++ b/src/mesh.F90 @@ -12,15 +12,15 @@ contains ! GET_MESH_BIN determines the tally bin for a particle in a structured mesh !=============================================================================== - subroutine get_mesh_bin(m, xyz, bin, in_mesh) + subroutine get_mesh_bin(m, xyz, bin) type(StructuredMesh), pointer :: m real(8), intent(in) :: xyz(:) integer, intent(out) :: bin - logical, intent(out) :: in_mesh integer :: n integer, allocatable :: ijk(:) + logical :: in_mesh ! Get number of dimensions n = m % n_dimension @@ -32,7 +32,11 @@ contains call get_mesh_indices(m, xyz(1:n), ijk, in_mesh) ! Convert indices to bin - bin = mesh_indices_to_bin(m, ijk) + if (in_mesh) then + bin = mesh_indices_to_bin(m, ijk) + else + bin = NO_BIN_FOUND + end if ! Release memory for ijk deallocate(ijk) diff --git a/src/tally.F90 b/src/tally.F90 index b31dd24ce5..547f212690 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -333,7 +333,6 @@ contains real(8) :: wgt real(8) :: mu real(8) :: E_out - logical :: in_mesh logical :: has_energyout_bin logical :: analog type(TallyObject), pointer :: t @@ -356,6 +355,18 @@ contains ! ======================================================================= ! DETERMINE SCORING BIN COMBINATION + ! determine mesh bin + if (t % n_bins(T_MESH) > 0) then + m => meshes(t % mesh) + + ! Determine if we're in the mesh first + call get_mesh_bin(m, p % coord0 % xyz, mesh_bin) + if (mesh_bin == NO_BIN_FOUND) cycle + bins(T_MESH) = mesh_bin + else + bins(T_MESH) = 1 + end if + ! determine next universe bin if (t % n_bins(T_UNIVERSE) > 0) then bins(T_UNIVERSE) = get_next_bin(T_UNIVERSE, p % coord % universe, i) @@ -396,19 +407,6 @@ contains bins(T_SURFACE) = 1 end if - ! determine mesh bin - if (t % n_bins(T_MESH) > 0) then - m => meshes(t % mesh) - - ! Determine if we're in the mesh first - call get_mesh_bin(m, p % coord0 % xyz, mesh_bin, in_mesh) - if (.not. in_mesh) cycle - - bins(T_MESH) = mesh_bin - else - bins(T_MESH) = 1 - end if - ! determine incoming energy bin n = t % n_bins(T_ENERGYIN) if (n > 0) then