The global module is finally gone

This commit is contained in:
Paul Romano 2017-09-16 14:46:13 -05:00
parent 2cae2cecf8
commit b867d640da
13 changed files with 175 additions and 163 deletions

View file

@ -322,7 +322,6 @@ set(LIBOPENMC_FORTRAN_SRC
src/error.F90
src/geometry.F90
src/geometry_header.F90
src/global.F90
src/hdf5_interface.F90
src/initialize.F90
src/input_xml.F90

View file

@ -8,21 +8,26 @@ module openmc_api
use eigenvalue, only: k_sum, openmc_get_keff
use error
use geometry, only: find_cell
use geometry_header, only: root_universe
use global
use geometry_header
use hdf5_interface
use material_header
use mesh_header
use message_passing
use nuclide_header
use initialize, only: openmc_init
use input_xml, only: assign_0K_elastic_scattering, check_data_version
use particle_header, only: Particle
use plot, only: openmc_plot_geometry
use random_lcg, only: seed, initialize_prng
use settings
use simulation_header
use tally_header
use tally_filter_header
use tally_filter
use tally, only: openmc_tally_set_type
use simulation, only: openmc_run
use string, only: to_f_string
use timer_header
use volume_calc, only: openmc_calculate_volumes
implicit none
@ -719,4 +724,121 @@ contains
end subroutine openmc_reset
!===============================================================================
! FREE_MEMORY deallocates and clears all global allocatable arrays in the
! program
!===============================================================================
subroutine free_memory()
use cmfd_header
use mgxs_header
use plot_header
use sab_header
use settings
use source_header
use surface_header
use tally_derivative_header
use trigger_header
use volume_header
integer :: i ! Loop Index
! Deallocate cells, surfaces, materials
if (allocated(cells)) deallocate(cells)
if (allocated(universes)) deallocate(universes)
if (allocated(lattices)) deallocate(lattices)
if (allocated(surfaces)) deallocate(surfaces)
if (allocated(materials)) deallocate(materials)
if (allocated(plots)) deallocate(plots)
if (allocated(volume_calcs)) deallocate(volume_calcs)
! Deallocate geometry debugging information
if (allocated(overlap_check_cnt)) deallocate(overlap_check_cnt)
! Deallocate cross section data, listings, and cache
if (allocated(nuclides)) then
! First call the clear routines
do i = 1, size(nuclides)
call nuclides(i) % clear()
end do
deallocate(nuclides)
end if
if (allocated(libraries)) deallocate(libraries)
if (allocated(res_scat_nuclides)) deallocate(res_scat_nuclides)
if (allocated(nuclides_MG)) deallocate(nuclides_MG)
if (allocated(macro_xs)) deallocate(macro_xs)
if (allocated(sab_tables)) deallocate(sab_tables)
! Deallocate external source
if (allocated(external_source)) deallocate(external_source)
! Deallocate k and entropy
if (allocated(k_generation)) deallocate(k_generation)
if (allocated(entropy)) deallocate(entropy)
if (allocated(entropy_p)) deallocate(entropy_p)
! Deallocate tally-related arrays
if (allocated(global_tallies)) deallocate(global_tallies)
if (allocated(meshes)) deallocate(meshes)
if (allocated(filters)) deallocate(filters)
if (allocated(tallies)) deallocate(tallies)
! Deallocate fission and source bank and entropy
!$omp parallel
if (allocated(fission_bank)) deallocate(fission_bank)
if (allocated(tally_derivs)) deallocate(tally_derivs)
!$omp end parallel
#ifdef _OPENMP
if (allocated(master_fission_bank)) deallocate(master_fission_bank)
#endif
if (allocated(source_bank)) deallocate(source_bank)
! Deallocate array of work indices
if (allocated(work_index)) deallocate(work_index)
if (allocated(energy_bins)) deallocate(energy_bins)
if (allocated(energy_bin_avg)) deallocate(energy_bin_avg)
! Deallocate CMFD
call deallocate_cmfd(cmfd)
! Deallocate tally node lists
call active_analog_tallies % clear()
call active_tracklength_tallies % clear()
call active_current_tallies % clear()
call active_collision_tallies % clear()
call active_surface_tallies % clear()
call active_tallies % clear()
! Deallocate track_identifiers
if (allocated(track_identifiers)) deallocate(track_identifiers)
! Deallocate dictionaries
call cell_dict % clear()
call universe_dict % clear()
call lattice_dict % clear()
call surface_dict % clear()
call material_dict % clear()
call mesh_dict % clear()
call filter_dict % clear()
call tally_dict % clear()
call plot_dict % clear()
call nuclide_dict % clear()
call sab_dict % clear()
call library_dict % clear()
! Clear statepoint and sourcepoint batch set
call statepoint_batch % clear()
call sourcepoint_batch % clear()
! Deallocate ufs
if (allocated(source_frac)) deallocate(source_frac)
end subroutine free_memory
end module openmc_api

View file

@ -394,7 +394,7 @@ contains
subroutine neutron_balance()
use constants, only: ONE, ZERO, CMFD_NOACCEL, CMFD_NORES
use global, only: keff, current_batch
use simulation_header, only: keff, current_batch
integer :: nx ! number of mesh cells in x direction
integer :: ny ! number of mesh cells in y direction

View file

@ -5,9 +5,9 @@ module cmfd_execute
! cross section generation, diffusion calculation, and source re-weighting
!==============================================================================
use cmfd_header, only: cmfd_begin, cmfd_on, cmfd_reset, cmfd, cmfd_coremap, &
cmfd_mesh
use global
use cmfd_header
use settings
use simulation_header
implicit none
private
@ -65,8 +65,6 @@ contains
subroutine cmfd_init_batch()
use global, only: cmfd_run, current_batch
! Check to activate CMFD diffusion and possible feedback
! this guarantees that when cmfd begins at least one batch of tallies are
! accumulated
@ -91,7 +89,6 @@ contains
subroutine calc_fission_source()
use constants, only: CMFD_NOACCEL, ZERO, TWO
use global, only: entropy_on, current_batch
use message_passing
use string, only: to_str
@ -214,9 +211,9 @@ contains
subroutine cmfd_reweight(new_weights)
use algorithm, only: binary_search
use bank_header, only: source_bank
use constants, only: ZERO, ONE
use error, only: warning, fatal_error
use global, only: source_bank, work
use mesh_header, only: RegularMesh
use mesh, only: count_bank_sites
use message_passing

View file

@ -3,7 +3,11 @@ module cmfd_input
use, intrinsic :: ISO_C_BINDING
use cmfd_header
use global
use mesh_header, only: mesh_dict
use mgxs_header, only: energy_bins
use tally
use tally_header
use timer_header
implicit none
private

View file

@ -101,7 +101,7 @@ contains
use constants, only: ONE, ZERO
use cmfd_header, only: cmfd_shift, cmfd_ktol, cmfd_stol, cmfd_write_matrices
use global, only: keff
use simulation_header, only: keff
logical, intent(in) :: adjoint
@ -694,7 +694,7 @@ contains
subroutine extract_results()
use cmfd_header, only: cmfd, cmfd_write_matrices
use global, only: current_batch
use simulation_header, only: current_batch
character(len=25) :: filename ! name of file to write data
integer :: n ! problem size

View file

@ -1,135 +0,0 @@
module global
use, intrinsic :: ISO_C_BINDING
! Inherit module variables from other modules
use cmfd_header
use geometry_header
use material_header
use mesh_header
use mgxs_header
use nuclide_header
use plot_header
use sab_header
use settings
use simulation_header
use source_header
use surface_header
use tally_filter_header
use tally_header
use tally_derivative_header
use timer_header
use trigger_header
use volume_header
implicit none
contains
!===============================================================================
! FREE_MEMORY deallocates and clears all global allocatable arrays in the
! program
!===============================================================================
subroutine free_memory()
integer :: i ! Loop Index
! Deallocate cells, surfaces, materials
if (allocated(cells)) deallocate(cells)
if (allocated(universes)) deallocate(universes)
if (allocated(lattices)) deallocate(lattices)
if (allocated(surfaces)) deallocate(surfaces)
if (allocated(materials)) deallocate(materials)
if (allocated(plots)) deallocate(plots)
if (allocated(volume_calcs)) deallocate(volume_calcs)
! Deallocate geometry debugging information
if (allocated(overlap_check_cnt)) deallocate(overlap_check_cnt)
! Deallocate cross section data, listings, and cache
if (allocated(nuclides)) then
! First call the clear routines
do i = 1, size(nuclides)
call nuclides(i) % clear()
end do
deallocate(nuclides)
end if
if (allocated(libraries)) deallocate(libraries)
if (allocated(res_scat_nuclides)) deallocate(res_scat_nuclides)
if (allocated(nuclides_MG)) deallocate(nuclides_MG)
if (allocated(macro_xs)) deallocate(macro_xs)
if (allocated(sab_tables)) deallocate(sab_tables)
! Deallocate external source
if (allocated(external_source)) deallocate(external_source)
! Deallocate k and entropy
if (allocated(k_generation)) deallocate(k_generation)
if (allocated(entropy)) deallocate(entropy)
if (allocated(entropy_p)) deallocate(entropy_p)
! Deallocate tally-related arrays
if (allocated(global_tallies)) deallocate(global_tallies)
if (allocated(meshes)) deallocate(meshes)
if (allocated(filters)) deallocate(filters)
if (allocated(tallies)) deallocate(tallies)
! Deallocate fission and source bank and entropy
!$omp parallel
if (allocated(fission_bank)) deallocate(fission_bank)
if (allocated(tally_derivs)) deallocate(tally_derivs)
!$omp end parallel
#ifdef _OPENMP
if (allocated(master_fission_bank)) deallocate(master_fission_bank)
#endif
if (allocated(source_bank)) deallocate(source_bank)
! Deallocate array of work indices
if (allocated(work_index)) deallocate(work_index)
if (allocated(energy_bins)) deallocate(energy_bins)
if (allocated(energy_bin_avg)) deallocate(energy_bin_avg)
! Deallocate CMFD
call deallocate_cmfd(cmfd)
! Deallocate tally node lists
call active_analog_tallies % clear()
call active_tracklength_tallies % clear()
call active_current_tallies % clear()
call active_collision_tallies % clear()
call active_surface_tallies % clear()
call active_tallies % clear()
! Deallocate track_identifiers
if (allocated(track_identifiers)) deallocate(track_identifiers)
! Deallocate dictionaries
call cell_dict % clear()
call universe_dict % clear()
call lattice_dict % clear()
call surface_dict % clear()
call material_dict % clear()
call mesh_dict % clear()
call filter_dict % clear()
call tally_dict % clear()
call plot_dict % clear()
call nuclide_dict % clear()
call sab_dict % clear()
call library_dict % clear()
! Clear statepoint and sourcepoint batch set
call statepoint_batch % clear()
call sourcepoint_batch % clear()
! Deallocate ufs
if (allocated(source_frac)) deallocate(source_frac)
end subroutine free_memory
end module global

View file

@ -7,13 +7,14 @@ module plot
use constants
use error, only: fatal_error
use geometry, only: find_cell, check_cell_overlap
use geometry_header, only: Cell, root_universe
use global
use geometry_header, only: Cell, root_universe, cells
use hdf5_interface
use output, only: write_message, time_stamp
use material_header, only: materials
use particle_header, only: LocalCoord, Particle
use plot_header
use progress_header, only: ProgressBar
use settings, only: check_overlaps
use string, only: to_str
implicit none

View file

@ -6,7 +6,9 @@ module simulation
use omp_lib
#endif
use bank_header, only: source_bank
use cmfd_execute, only: cmfd_init_batch, execute_cmfd
use cmfd_header, only: cmfd_on
use constants, only: ZERO
use eigenvalue, only: count_source_for_ufs, calculate_average_keff, &
calculate_generation_keff, shannon_entropy, &
@ -14,19 +16,26 @@ module simulation
#ifdef _OPENMP
use eigenvalue, only: join_bank_from_threads
#endif
use global
use error, only: fatal_error
use message_passing
use mgxs_header, only: energy_bins, energy_bin_avg
use nuclide_header, only: micro_xs, n_nuclides
use output, only: write_message, header, print_columns, &
print_batch_keff, print_generation, print_runtime, &
print_results, print_overlap_check, write_tallies
use particle_header, only: Particle
use random_lcg, only: set_particle_seed
use settings
use simulation_header
use source, only: initialize_source, sample_external_source
use state_point, only: write_state_point, write_source_point, load_state_point
use string, only: to_str
use tally, only: accumulate_tallies, setup_active_tallies, &
init_tally_routines
use tally_header, only: configure_tallies
use tally_header
use tally_filter_header, only: filter_matches, n_filters
use tally_derivative_header, only: tally_derivs
use timer_header
use trigger, only: check_triggers
use tracking, only: transport

View file

@ -15,17 +15,25 @@ module state_point
use hdf5
use cmfd_header
use constants
use eigenvalue, only: openmc_get_keff
use endf, only: reaction_name
use error, only: fatal_error, warning
use global
use hdf5_interface
use mesh_header, only: RegularMesh
use mesh_header, only: RegularMesh, meshes, n_meshes
use message_passing
use mgxs_header, only: nuclides_MG
use nuclide_header, only: nuclides
use output, only: write_message, time_stamp
use random_lcg, only: seed
use settings
use simulation_header
use string, only: to_str, count_digits, zero_padded
use tally_header
use tally_filter_header
use tally_derivative_header, only: tally_derivs
use timer_header
implicit none

View file

@ -4,15 +4,15 @@ module summary
use constants
use endf, only: reaction_name
use geometry_header, only: root_universe, Cell, Universe, Lattice, &
RectLattice, HexLattice
use global
use geometry_header
use hdf5_interface
use material_header, only: Material
use material_header, only: Material, n_materials
use mesh_header, only: RegularMesh
use message_passing
use mgxs_header, only: nuclides_MG
use nuclide_header
use output, only: time_stamp
use settings, only: run_CE
use surface_header
use string, only: to_str
use tally_header, only: TallyObject

View file

@ -8,14 +8,17 @@ module trigger
use constants
use eigenvalue, only: openmc_get_keff
use global
use string, only: to_str
use output, only: warning, write_message
use mesh_header, only: RegularMesh
use mesh_header, only: RegularMesh, meshes
use message_passing, only: master
use trigger_header, only: TriggerObject
use settings
use simulation_header
use trigger_header
use tally, only: TallyObject
use tally_filter_mesh, only: MeshFilter
use tally_filter_header, only: filter_matches, filters
use tally_header, only: tallies, n_tallies
implicit none

View file

@ -9,14 +9,18 @@ module volume_calc
use constants
use geometry, only: find_cell
use global
use geometry_header, only: universes, cells
use hdf5_interface, only: file_create, file_close, write_attribute, &
create_group, close_group, write_dataset
use output, only: write_message, header, time_stamp
use material_header, only: materials
use message_passing
use nuclide_header, only: nuclides
use particle_header, only: Particle
use random_lcg, only: prn, prn_set_stream, set_particle_seed
use settings, only: path_output
use stl_vector, only: VectorInt, VectorReal
use string, only: to_str
use timer_header, only: Timer
use volume_header