diff --git a/src/api.F90 b/src/api.F90 index 4f99066d27..50d702b311 100644 --- a/src/api.F90 +++ b/src/api.F90 @@ -424,7 +424,7 @@ contains if (.not. nuclide_dict % has_key(to_lower(name_))) then if (library_dict % has_key(to_lower(name_))) then ! allocate extra space in nuclides array - n = n_nuclides_total + n = n_nuclides allocate(new_nuclides(n + 1)) new_nuclides(1:n) = nuclides(:) call move_alloc(FROM=new_nuclides, TO=nuclides) @@ -446,7 +446,7 @@ contains ! Add entry to nuclide dictionary call nuclide_dict % add_key(to_lower(name_), n) - n_nuclides_total = n + n_nuclides = n ! Assign resonant scattering data if (res_scat_on) call assign_0K_elastic_scattering(nuclides(n)) @@ -585,7 +585,7 @@ contains err = E_UNASSIGNED if (index >= 1 .and. index <= size(materials)) then associate (m => materials(index)) - err = m % set_density(density, nuclides) + err = m % set_density(density) end associate else err = E_OUT_OF_BOUNDS @@ -636,10 +636,10 @@ contains m % p0(:) = .false. ! Set total density to the sum of the vector - err = m % set_density(sum(density), nuclides) + err = m % set_density(sum(density)) ! Assign S(a,b) tables - call m % assign_sab_tables(nuclides, sab_tables) + call m % assign_sab_tables() end associate else err = E_OUT_OF_BOUNDS diff --git a/src/geometry_header.F90 b/src/geometry_header.F90 index 0d3ae26401..b9eab0ad08 100644 --- a/src/geometry_header.F90 +++ b/src/geometry_header.F90 @@ -4,7 +4,9 @@ module geometry_header use constants, only: HALF, TWO, THREE, INFINITY, K_BOLTZMANN, & MATERIAL_VOID, NONE use dict_header, only: DictCharInt, DictIntInt + use nuclide_header use material_header, only: Material + use sab_header use stl_vector, only: VectorReal use string, only: to_lower @@ -330,16 +332,12 @@ contains ! temperatures to read (which may be different if interpolation is used) !=============================================================================== - subroutine get_temperatures(cells, materials, material_dict, nuclide_dict, & - n_nucs, nuc_temps, sab_dict, n_sabs, sab_temps) + subroutine get_temperatures(cells, materials, material_dict, & + nuc_temps, sab_temps) type(Cell), allocatable, intent(in) :: cells(:) type(Material), allocatable, intent(in) :: materials(:) type(DictIntInt), intent(in) :: material_dict - type(DictCharInt), intent(in) :: nuclide_dict - integer, intent(in) :: n_nucs type(VectorReal), allocatable, intent(out) :: nuc_temps(:) - type(DictCharInt), optional, intent(in) :: sab_dict - integer, optional, intent(in) :: n_sabs type(VectorReal), optional, allocatable, intent(out) :: sab_temps(:) integer :: i, j, k @@ -348,8 +346,8 @@ contains integer :: i_material real(8) :: temperature ! temperature in Kelvin - allocate(nuc_temps(n_nucs)) - if (present(n_sabs) .and. present(sab_temps)) allocate(sab_temps(n_sabs)) + allocate(nuc_temps(n_nuclides)) + if (present(sab_temps)) allocate(sab_temps(n_sab_tables)) do i = 1, size(cells) do j = 1, size(cells(i) % material) @@ -376,8 +374,7 @@ contains end if end do NUC_NAMES_LOOP - if (present(sab_temps) .and. present(sab_dict) .and. & - mat % n_sab > 0) then + if (present(sab_temps) .and. mat % n_sab > 0) then SAB_NAMES_LOOP: do k = 1, size(mat % sab_names) ! Get index in nuc_temps array i_sab = sab_dict % get_key(to_lower(mat % sab_names(k))) diff --git a/src/global.F90 b/src/global.F90 index 04e3eff899..9e2ca1c257 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -14,9 +14,7 @@ module global use material_header, only: Material use mesh_header, only: RegularMesh use mgxs_header, only: Mgxs, MgxsContainer - use nuclide_header 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 @@ -27,6 +25,10 @@ module global 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 + implicit none ! ============================================================================ @@ -70,39 +72,13 @@ module global ! ENERGY TREATMENT RELATED VARIABLES logical :: run_CE = .true. ! Run in CE mode? - ! ============================================================================ - ! CROSS SECTION RELATED VARIABLES NEEDED REGARDLESS OF CE OR MG - - ! Number of nuclide cross section tables - integer(C_INT), bind(C, name='n_nuclides') :: n_nuclides_total - ! Cross section caches type(NuclideMicroXS), allocatable :: micro_xs(:) ! Cache for each nuclide type(MaterialMacroXS) :: material_xs ! Cache for current material - ! Dictionaries to look up cross sections and listings - type(DictCharInt) :: nuclide_dict - type(DictCharInt) :: library_dict - - ! Cross section libraries - type(Library), allocatable :: libraries(:) - ! ============================================================================ ! CONTINUOUS-ENERGY CROSS SECTION RELATED VARIABLES - ! Cross section arrays - type(Nuclide), allocatable, target :: nuclides(:) ! Nuclide cross-sections - type(SAlphaBeta), allocatable, target :: sab_tables(:) ! S(a,b) tables - - integer :: n_sab_tables ! Number of S(a,b) thermal scattering tables - - ! Minimum/maximum energies - real(8) :: energy_min_neutron = ZERO - real(8) :: energy_max_neutron = INFINITY - - ! Dictionaries to look up cross sections and listings - type(DictCharInt) :: sab_dict - ! Unreoslved resonance probablity tables logical :: urr_ptables_on = .true. diff --git a/src/input_xml.F90 b/src/input_xml.F90 index efdc3e5230..cde7e21e00 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -2187,9 +2187,7 @@ contains call assign_temperatures(material_temps) ! Determine desired temperatures for each nuclide and S(a,b) table - call get_temperatures(cells, materials, material_dict, nuclide_dict, & - n_nuclides_total, nuc_temps, sab_dict, & - n_sab_tables, sab_temps) + call get_temperatures(cells, materials, material_dict, nuc_temps, sab_temps) ! Read continuous-energy cross sections if (run_CE .and. run_mode /= MODE_PLOTTING) then @@ -2617,8 +2615,8 @@ contains end do ! Set total number of nuclides and S(a,b) tables - n_nuclides_total = index_nuclide - n_sab_tables = index_sab + n_nuclides = index_nuclide + n_sab_tables = index_sab ! Close materials XML file call doc % clear() @@ -3464,15 +3462,15 @@ contains if (trim(sarray(1)) == 'all') then ! Handle special case all - allocate(t % nuclide_bins(n_nuclides_total + 1)) + allocate(t % nuclide_bins(n_nuclides + 1)) - ! Set bins to 1, 2, 3, ..., n_nuclides_total, -1 - t % nuclide_bins(1:n_nuclides_total) = & - (/ (j, j=1, n_nuclides_total) /) - t % nuclide_bins(n_nuclides_total + 1) = -1 + ! Set bins to 1, 2, 3, ..., n_nuclides, -1 + t % nuclide_bins(1:n_nuclides) = & + (/ (j, j=1, n_nuclides) /) + t % nuclide_bins(n_nuclides + 1) = -1 ! Set number of nuclide bins - t % n_nuclide_bins = n_nuclides_total + 1 + t % n_nuclide_bins = n_nuclides + 1 ! Set flag so we can treat this case specially t % all_nuclides = .true. @@ -5183,7 +5181,7 @@ contains character(MAX_WORD_LEN) :: name type(SetChar) :: already_read - allocate(nuclides(n_nuclides_total)) + allocate(nuclides(n_nuclides)) allocate(sab_tables(n_sab_tables)) ! Read cross sections @@ -5275,7 +5273,7 @@ contains end do ! Associate S(a,b) tables with specific nuclides - call materials(i) % assign_sab_tables(nuclides, sab_tables) + call materials(i) % assign_sab_tables() end do ! Show which nuclide results in lowest energy for neutron transport diff --git a/src/material_header.F90 b/src/material_header.F90 index b73f372bac..1308810e24 100644 --- a/src/material_header.F90 +++ b/src/material_header.F90 @@ -2,8 +2,8 @@ module material_header use constants use error - use nuclide_header, only: Nuclide - use sab_header, only: SAlphaBeta + use nuclide_header + use sab_header use stl_vector, only: VectorReal, VectorInt use string, only: to_str @@ -57,10 +57,9 @@ contains ! MATERIAL_SET_DENSITY sets the total density of a material in atom/b-cm. !=============================================================================== - function material_set_density(m, density, nuclides) result(err) + function material_set_density(m, density) result(err) class(Material), intent(inout) :: m real(8), intent(in) :: density - type(Nuclide), intent(in) :: nuclides(:) integer :: err integer :: i @@ -95,10 +94,8 @@ contains ! materials so the code knows when to apply bound thermal scattering data !=============================================================================== - subroutine material_assign_sab_tables(this, nuclides, sab_tables) + subroutine material_assign_sab_tables(this) class(Material), intent(inout) :: this - type(Nuclide), intent(in) :: nuclides(:) - type(SAlphaBeta), intent(in) :: sab_tables(:) integer :: j ! index over nuclides in material integer :: k ! index over S(a,b) tables in material diff --git a/src/mgxs_data.F90 b/src/mgxs_data.F90 index ad20aca83b..bbea3c4b32 100644 --- a/src/mgxs_data.F90 +++ b/src/mgxs_data.F90 @@ -51,8 +51,7 @@ contains call write_message("Loading cross section data...", 5) ! Get temperatures - call get_temperatures(cells, materials, material_dict, nuclide_dict, & - n_nuclides_total, temps) + call get_temperatures(cells, materials, material_dict, temps) ! Open file for reading file_id = file_open(path_cross_sections, 'r', parallel=.true.) @@ -72,7 +71,7 @@ contains end if ! allocate arrays for MGXS storage and cross section cache - allocate(nuclides_MG(n_nuclides_total)) + allocate(nuclides_MG(n_nuclides)) ! ========================================================================== ! READ ALL MGXS CROSS SECTION TABLES diff --git a/src/nuclide_header.F90 b/src/nuclide_header.F90 index bf1ea97b28..68759115be 100644 --- a/src/nuclide_header.F90 +++ b/src/nuclide_header.F90 @@ -7,7 +7,7 @@ module nuclide_header use algorithm, only: sort, find use constants - use dict_header, only: DictIntInt + use dict_header, only: DictIntInt, DictCharInt use endf, only: reaction_name, is_fission, is_disappearance use endf_header, only: Function1D, Polynomial, Tabulated1D use error, only: fatal_error, warning @@ -157,7 +157,20 @@ module nuclide_header character(MAX_FILE_LEN) :: path end type Library - contains + ! Cross section libraries + type(Library), allocatable :: libraries(:) + type(DictCharInt) :: library_dict + + ! Nuclear data for each nuclide + type(Nuclide), allocatable, target :: nuclides(:) + integer(C_INT), bind(C) :: n_nuclides + type(DictCharInt) :: nuclide_dict + + ! Minimum/maximum energies + real(8) :: energy_min_neutron = ZERO + real(8) :: energy_max_neutron = INFINITY + +contains !=============================================================================== ! NUCLIDE_CLEAR resets and deallocates data in Nuclide diff --git a/src/particle_restart.F90 b/src/particle_restart.F90 index 4438c48c00..35b16224d1 100644 --- a/src/particle_restart.F90 +++ b/src/particle_restart.F90 @@ -32,7 +32,7 @@ contains ! Set verbosity high verbosity = 10 - allocate(micro_xs(n_nuclides_total)) + allocate(micro_xs(n_nuclides)) ! Initialize the particle to be tracked call p % initialize() diff --git a/src/sab_header.F90 b/src/sab_header.F90 index e0b79f2485..8e783a741e 100644 --- a/src/sab_header.F90 +++ b/src/sab_header.F90 @@ -4,7 +4,7 @@ module sab_header use algorithm, only: find, sort use constants - use dict_header, only: DictIntInt + use dict_header, only: DictIntInt, DictCharInt use distribution_univariate, only: Tabular use error, only: warning, fatal_error use hdf5, only: HID_T, HSIZE_T, SIZE_T @@ -78,6 +78,11 @@ module sab_header procedure :: from_hdf5 => salphabeta_from_hdf5 end type SAlphaBeta + ! S(a,b) tables + type(SAlphaBeta), allocatable, target :: sab_tables(:) + integer :: n_sab_tables + type(DictCharInt) :: sab_dict + contains subroutine salphabeta_from_hdf5(this, group_id, temperature, method, & diff --git a/src/simulation.F90 b/src/simulation.F90 index 8da913b5ac..64632a3435 100644 --- a/src/simulation.F90 +++ b/src/simulation.F90 @@ -370,7 +370,7 @@ contains subroutine initialize_simulation() !$omp parallel - allocate(micro_xs(n_nuclides_total)) + allocate(micro_xs(n_nuclides)) ! Allocate array for matching filter bins allocate(filter_matches(n_filters)) diff --git a/src/summary.F90 b/src/summary.F90 index 9c952fe70a..e4263d8d0a 100644 --- a/src/summary.F90 +++ b/src/summary.F90 @@ -79,12 +79,12 @@ contains ! Write useful data from nuclide objects nuclide_group = create_group(file_id, "nuclides") - call write_attribute(nuclide_group, "n_nuclides", n_nuclides_total) + call write_attribute(nuclide_group, "n_nuclides", n_nuclides) ! Build array of nuclide names and awrs - allocate(nucnames(n_nuclides_total)) - allocate(awrs(n_nuclides_total)) - do i = 1, n_nuclides_total + allocate(nucnames(n_nuclides)) + allocate(awrs(n_nuclides)) + do i = 1, n_nuclides if (run_CE) then nucnames(i) = nuclides(i) % name awrs(i) = nuclides(i) % awr diff --git a/src/tally.F90 b/src/tally.F90 index fae7646027..338362c69f 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -2205,7 +2205,7 @@ contains atom_density = ZERO ! Determine score for each bin - call score_general(p, t, n_nuclides_total*t % n_score_bins, filter_index, & + call score_general(p, t, n_nuclides*t % n_score_bins, filter_index, & i_nuclide, atom_density, flux) end subroutine score_all_nuclides @@ -2300,7 +2300,7 @@ contains elseif (k == p % event_nuclide + 1) then ! After we've tallied the individual nuclide bin, we also need ! to contribute to the total material bin which is the last bin - k = n_nuclides_total + 1 + k = n_nuclides + 1 else ! After we've tallied in both the individual nuclide bin and the ! total material bin, we're done