Move openmc_tally_set_type to tally module

This commit is contained in:
Paul Romano 2017-08-18 06:57:46 -05:00
parent deacc5d5a5
commit 42c2a8739c
5 changed files with 46 additions and 54 deletions

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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