From c063b8d9dbcf8cebae3307564291eb331acd6b4b Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Thu, 10 Aug 2017 11:42:55 -0500 Subject: [PATCH] Move most important arrays out of global module and into their respective headers --- src/geometry_header.F90 | 15 ++++++ src/global.F90 | 72 +++++------------------------ src/material_header.F90 | 10 ++++ src/mesh_header.F90 | 13 ++++-- src/nuclide_header.F90 | 4 ++ src/plot_header.F90 | 12 ++++- src/surface_header.F90 | 10 ++++ src/tallies/tally_filter_header.F90 | 12 +++++ src/tallies/tally_header.F90 | 11 +++++ src/volume_header.F90 | 2 + 10 files changed, 97 insertions(+), 64 deletions(-) diff --git a/src/geometry_header.F90 b/src/geometry_header.F90 index b9eab0ad08..f4eb9b6628 100644 --- a/src/geometry_header.F90 +++ b/src/geometry_header.F90 @@ -1,5 +1,7 @@ module geometry_header + use, intrinsic :: ISO_C_BINDING + use algorithm, only: find use constants, only: HALF, TWO, THREE, INFINITY, K_BOLTZMANN, & MATERIAL_VOID, NONE @@ -157,6 +159,19 @@ module geometry_header ! array index of the root universe integer :: root_universe = -1 + integer(C_INT32_T), bind(C) :: n_cells ! # of cells + integer(C_INT32_T), bind(C) :: n_universes ! # of universes + integer(C_INT32_T), bind(C) :: n_lattices ! # of lattices + + type(Cell), allocatable, target :: cells(:) + type(Universe), allocatable, target :: universes(:) + type(LatticeContainer), allocatable, target :: lattices(:) + + ! Dictionaries which map user IDs to indices in the global arrays + type(DictIntInt) :: cell_dict + type(DictIntInt) :: universe_dict + type(DictIntInt) :: lattice_dict + contains !=============================================================================== diff --git a/src/global.F90 b/src/global.F90 index 27c28b0404..0f1ca48c7c 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -9,64 +9,30 @@ module global use bank_header, only: Bank use cmfd_header use constants - use dict_header, only: DictCharInt, DictIntInt - use geometry_header, only: Cell, Universe, Lattice, LatticeContainer - use material_header, only: Material - use mgxs_header - use plot_header, only: ObjectPlot 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 - use tally_filter_header, only: TallyFilterContainer, TallyFilterMatch use trigger_header, only: KTrigger use timer_header, only: Timer - use volume_header, only: VolumeCalculation - ! Inherit module variables from nuclide/S(a,b) modules - use nuclide_header - use sab_header - - ! Inherit meshes array + ! Inherit module variables from other modules + use geometry_header + use material_header use mesh_header + use mgxs_header + use nuclide_header + use plot_header + use sab_header + use surface_header + use tally_filter_header + use tally_header + use volume_header implicit none ! ============================================================================ ! GEOMETRY-RELATED VARIABLES - ! Main arrays - type(Cell), allocatable, target :: cells(:) - type(Universe), allocatable, target :: universes(:) - type(LatticeContainer), allocatable, target :: lattices(:) - type(SurfaceContainer), allocatable, target :: surfaces(:) - type(Material), allocatable, target :: materials(:) - type(ObjectPlot), allocatable, target :: plots(:) - - type(VolumeCalculation), allocatable :: volume_calcs(:) - - ! Size of main arrays - integer(C_INT32_T), bind(C) :: n_cells ! # of cells - integer :: n_universes ! # of universes - integer :: n_lattices ! # of lattices - integer :: n_surfaces ! # of surfaces - integer(C_INT32_T), bind(C) :: n_materials ! # of materials - integer :: n_plots ! # of plots - - ! These dictionaries provide a fast lookup mechanism -- the key is the - ! user-specified identifier and the value is the index in the corresponding - ! array - type(DictIntInt) :: cell_dict - type(DictIntInt) :: universe_dict - type(DictIntInt) :: lattice_dict - type(DictIntInt) :: surface_dict - type(DictIntInt) :: material_dict - type(DictIntInt) :: mesh_dict - type(DictIntInt) :: filter_dict - type(DictIntInt) :: tally_dict - type(DictIntInt) :: plot_dict - ! Number of lost particles integer :: n_lost_particles @@ -74,10 +40,6 @@ module global ! ENERGY TREATMENT RELATED VARIABLES logical :: run_CE = .true. ! Run in CE mode? - ! Cross section caches - type(NuclideMicroXS), allocatable :: micro_xs(:) ! Cache for each nuclide - type(MaterialMacroXS) :: material_xs ! Cache for current material - ! ============================================================================ ! CONTINUOUS-ENERGY CROSS SECTION RELATED VARIABLES @@ -109,9 +71,6 @@ module global ! ============================================================================ ! TALLY-RELATED VARIABLES - type(TallyObject), allocatable, target :: tallies(:) - type(TallyFilterContainer), allocatable, target :: filters(:) - type(TallyFilterMatch), allocatable :: filter_matches(:) ! Pointers for different tallies type(TallyObject), pointer :: user_tallies(:) => null() @@ -149,17 +108,10 @@ module global !$omp threadprivate(global_tally_collision, global_tally_absorption, & !$omp& global_tally_tracklength, global_tally_leakage) - integer :: n_meshes = 0 ! # of structured meshes integer :: n_user_meshes = 0 ! # of structured user meshes - integer :: n_filters = 0 ! # of filters integer :: n_user_filters = 0 ! # of user filters - integer(C_INT32_T), bind(C) :: n_tallies = 0 ! # of tallies integer :: n_user_tallies = 0 ! # of user tallies - ! Tally derivatives - type(TallyDerivative), allocatable :: tally_derivs(:) -!$omp threadprivate(tally_derivs) - ! Normalization for statistics integer :: n_realizations = 0 ! # of independent realizations real(8) :: total_weight ! total starting particle weight in realization @@ -407,7 +359,7 @@ module global character(10), allocatable :: res_scat_nuclides(:) !$omp threadprivate(micro_xs, material_xs, fission_bank, n_bank, & -!$omp& trace, thread_id, current_work, filter_matches) +!$omp& trace, thread_id, current_work) contains diff --git a/src/material_header.F90 b/src/material_header.F90 index 1308810e24..f80c36b5cc 100644 --- a/src/material_header.F90 +++ b/src/material_header.F90 @@ -1,6 +1,9 @@ module material_header + use, intrinsic :: ISO_C_BINDING + use constants + use dict_header, only: DictIntInt use error use nuclide_header use sab_header @@ -51,6 +54,13 @@ module material_header procedure :: assign_sab_tables => material_assign_sab_tables end type Material + integer(C_INT32_T), bind(C) :: n_materials ! # of materials + + type(Material), allocatable, target :: materials(:) + + ! Dictionary that maps user IDs to indices in 'materials' + type(DictIntInt) :: material_dict + contains !=============================================================================== diff --git a/src/mesh_header.F90 b/src/mesh_header.F90 index f112eb23ff..d941891616 100644 --- a/src/mesh_header.F90 +++ b/src/mesh_header.F90 @@ -1,22 +1,24 @@ module mesh_header + use, intrinsic :: ISO_C_BINDING + use hdf5 use constants, only: NO_BIN_FOUND + use dict_header, only: DictIntInt use hdf5_interface use string, only: to_str implicit none - private - public :: RegularMesh, meshes + public :: RegularMesh, meshes, n_meshes, mesh_dict !=============================================================================== ! STRUCTUREDMESH represents a tessellation of n-dimensional Euclidean space by ! congruent squares or cubes !=============================================================================== - type RegularMesh + type, public :: RegularMesh integer :: id ! user-specified id integer :: type ! rectangular, hexagonal integer :: n_dimension ! rank of mesh @@ -34,8 +36,13 @@ module mesh_header procedure :: to_hdf5 => regular_to_hdf5 end type RegularMesh + integer(C_INT32_T), bind(C) :: n_meshes = 0 ! # of structured meshes + type(RegularMesh), allocatable, target :: meshes(:) + ! Dictionary that maps user IDs to indices in 'meshes' + type(DictIntInt) :: mesh_dict + contains !=============================================================================== diff --git a/src/nuclide_header.F90 b/src/nuclide_header.F90 index 68759115be..7848881724 100644 --- a/src/nuclide_header.F90 +++ b/src/nuclide_header.F90 @@ -166,6 +166,10 @@ module nuclide_header integer(C_INT), bind(C) :: n_nuclides type(DictCharInt) :: nuclide_dict + ! Cross section caches + type(NuclideMicroXS), allocatable :: micro_xs(:) ! Cache for each nuclide + type(MaterialMacroXS) :: material_xs ! Cache for current material + ! Minimum/maximum energies real(8) :: energy_min_neutron = ZERO real(8) :: energy_max_neutron = INFINITY diff --git a/src/plot_header.F90 b/src/plot_header.F90 index a6ea9a580d..06b4919ad5 100644 --- a/src/plot_header.F90 +++ b/src/plot_header.F90 @@ -1,7 +1,10 @@ module plot_header + use, intrinsic :: ISO_C_BINDING + use constants - use mesh_header, only: RegularMesh + use dict_header, only: DictIntInt + use mesh_header, only: RegularMesh implicit none @@ -50,4 +53,11 @@ module plot_header integer, parameter :: PLOT_COLOR_CELLS = 1 integer, parameter :: PLOT_COLOR_MATS = 2 + integer(C_INT32_T), bind(C) :: n_plots ! # of plots + + type(ObjectPlot), allocatable, target :: plots(:) + + ! Dictionary that maps user IDs to indices in 'plots' + type(DictIntInt) :: plot_dict + end module plot_header diff --git a/src/surface_header.F90 b/src/surface_header.F90 index 68e5144b7c..d1c0452335 100644 --- a/src/surface_header.F90 +++ b/src/surface_header.F90 @@ -1,6 +1,9 @@ module surface_header + use, intrinsic :: ISO_C_BINDING + use constants, only: NONE, ONE, TWO, ZERO, HALF, INFINITY, FP_COINCIDENT + use dict_header, only: DictIntInt implicit none @@ -193,6 +196,13 @@ module surface_header procedure :: normal => quadric_normal end type SurfaceQuadric + integer(C_INT32_T), bind(C) :: n_surfaces ! # of surfaces + + type(SurfaceContainer), allocatable, target :: surfaces(:) + + ! Dictionary that maps user IDs to indices in 'surfaces' + type(DictIntInt) :: surface_dict + contains !=============================================================================== diff --git a/src/tallies/tally_filter_header.F90 b/src/tallies/tally_filter_header.F90 index d69dd299d1..1553576958 100644 --- a/src/tallies/tally_filter_header.F90 +++ b/src/tallies/tally_filter_header.F90 @@ -1,6 +1,9 @@ module tally_filter_header + use, intrinsic :: ISO_C_BINDING + use constants, only: MAX_LINE_LEN + use dict_header, only: DictIntInt use particle_header, only: Particle use stl_vector, only: VectorInt, VectorReal @@ -94,6 +97,15 @@ module tally_filter_header class(TallyFilter), allocatable :: obj end type TallyFilterContainer + integer :: n_filters = 0 ! # of filters + + type(TallyFilterContainer), allocatable, target :: filters(:) + type(TallyFilterMatch), allocatable :: filter_matches(:) +!$omp threadprivate(filter_matches) + + ! Dictionary that maps user IDs to indices in 'filters' + type(DictIntInt) :: filter_dict + contains !=============================================================================== diff --git a/src/tallies/tally_header.F90 b/src/tallies/tally_header.F90 index 76e3d143f9..2f712c5f85 100644 --- a/src/tallies/tally_header.F90 +++ b/src/tallies/tally_header.F90 @@ -5,6 +5,7 @@ module tally_header use hdf5 use constants, only: NONE, N_FILTER_TYPES + use dict_header, only: DictIntInt use tally_filter_header, only: TallyFilterContainer use trigger_header, only: TriggerObject @@ -93,6 +94,16 @@ module tally_header procedure :: read_results_hdf5 end type TallyObject + integer(C_INT32_T), bind(C) :: n_tallies = 0 ! # of tallies + + type(TallyObject), allocatable, target :: tallies(:) + type(TallyDerivative), allocatable :: tally_derivs(:) +!$omp threadprivate(tally_derivs) + + ! Dictionary that maps user IDs to indices in 'tallies' + type(DictIntInt) :: tally_dict + + contains subroutine write_results_hdf5(this, group_id) diff --git a/src/volume_header.F90 b/src/volume_header.F90 index a01b664dfe..13c3299bb6 100644 --- a/src/volume_header.F90 +++ b/src/volume_header.F90 @@ -16,6 +16,8 @@ module volume_header procedure :: from_xml => volume_from_xml end type VolumeCalculation + type(VolumeCalculation), allocatable :: volume_calcs(:) + contains subroutine volume_from_xml(this, node_vol)