diff --git a/src/api.F90 b/src/api.F90 index 77b259fa4e..af00cdd837 100644 --- a/src/api.F90 +++ b/src/api.F90 @@ -20,6 +20,7 @@ module openmc_api 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 volume_calc, only: openmc_calculate_volumes diff --git a/src/cmfd_input.F90 b/src/cmfd_input.F90 index b809914746..f440486655 100644 --- a/src/cmfd_input.F90 +++ b/src/cmfd_input.F90 @@ -17,20 +17,9 @@ contains subroutine configure_cmfd() - use message_passing, only: master - - integer :: color ! color group of processor - ! Read in cmfd input file call read_cmfd_xml() - ! Assign color - if (master) then - color = 1 - else - color = 2 - end if - ! Initialize timers call time_cmfd % reset() call time_cmfdbuild % reset() @@ -251,7 +240,8 @@ contains use error, only: fatal_error, warning use mesh_header, only: RegularMesh, openmc_extend_meshes use string - use tally_header, only: openmc_extend_tallies, openmc_tally_set_type + use tally, only: openmc_tally_set_type + use tally_header, only: openmc_extend_tallies use tally_filter_header use tally_filter use xml_interface diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 08fad7202e..5f24c9c40f 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -33,7 +33,8 @@ module input_xml starts_with, ends_with, tokenize, split_string, & zero_padded use summary, only: write_summary - use tally_header, only: openmc_extend_tallies, openmc_tally_set_type + use tally, only: openmc_tally_set_type + use tally_header, only: openmc_extend_tallies use tally_filter_header, only: TallyFilterContainer use tally_filter use xml_interface @@ -62,10 +63,16 @@ contains ! Set up neighbor lists, convert user IDs -> indices, assign temperatures call finalize_geometry(material_temps, nuc_temps, sab_temps) - ! Read continuous-energy cross sections - if (run_CE .and. run_mode /= MODE_PLOTTING) then + if (run_mode /= MODE_PLOTTING) then call time_read_xs % start() - call read_ce_cross_sections(nuc_temps, sab_temps) + if (run_CE) then + ! Read continuous-energy cross sections + call read_ce_cross_sections(nuc_temps, sab_temps) + else + ! Create material macroscopic data for MGXS + call read_mgxs() + call create_macro_xs() + end if call time_read_xs % stop() end if @@ -76,14 +83,6 @@ contains if (cmfd_run) call configure_cmfd() - if (.not. run_CE) then - ! Create material macroscopic data for MGXS - call time_read_xs % start() - call read_mgxs() - call create_macro_xs() - call time_read_xs % stop() - end if - if (run_mode == MODE_PLOTTING) then ! Read plots.xml if it exists call read_plots_xml() diff --git a/src/tallies/tally.F90 b/src/tallies/tally.F90 index c97ff01e1b..0ed9b47e7c 100644 --- a/src/tallies/tally.F90 +++ b/src/tallies/tally.F90 @@ -4419,4 +4419,36 @@ contains end subroutine setup_active_tallies +!=============================================================================== +! C API FUNCTIONS +!=============================================================================== + + function openmc_tally_set_type(index, type) result(err) bind(C) + ! Set the type of the tally + integer(C_INT32_T), value, intent(in) :: index + character(kind=C_CHAR), intent(in) :: type(*) + integer(C_INT) :: err + + character(:), allocatable :: type_ + + ! Convert C string to Fortran string + type_ = to_f_string(type) + + err = 0 + if (index >= 1 .and. index <= n_tallies) then + if (allocated(tallies(index) % obj)) then + err = E_ALREADY_ALLOCATED + else + select case (type_) + case ('generic') + allocate(TallyObject :: tallies(index) % obj) + case default + err = E_UNASSIGNED + end select + end if + else + err = E_OUT_OF_BOUNDS + end if + end function openmc_tally_set_type + end module tally diff --git a/src/tallies/tally_header.F90 b/src/tallies/tally_header.F90 index f13768b360..596cf42c50 100644 --- a/src/tallies/tally_header.F90 +++ b/src/tallies/tally_header.F90 @@ -26,7 +26,6 @@ module tally_header public :: openmc_tally_set_filters public :: openmc_tally_set_nuclides public :: openmc_tally_set_scores - public :: openmc_tally_set_type !=============================================================================== ! TALLYDERIVATIVE describes a first-order derivative that can be applied to @@ -713,33 +712,4 @@ contains end if end function openmc_tally_set_scores - - function openmc_tally_set_type(index, type) result(err) bind(C) - ! Set the type of the tally - integer(C_INT32_T), value, intent(in) :: index - character(kind=C_CHAR), intent(in) :: type(*) - integer(C_INT) :: err - - character(:), allocatable :: type_ - - ! Convert C string to Fortran string - type_ = to_f_string(type) - - err = 0 - if (index >= 1 .and. index <= n_tallies) then - if (allocated(tallies(index) % obj)) then - err = E_ALREADY_ALLOCATED - else - select case (type_) - case ('generic') - allocate(TallyObject :: tallies(index) % obj) - case default - err = E_UNASSIGNED - end select - end if - else - err = E_OUT_OF_BOUNDS - end if - end function openmc_tally_set_type - end module tally_header