Move openmc_run to C++ side

This commit is contained in:
Paul Romano 2018-04-12 07:45:47 -05:00
parent 14455dc43e
commit faf35d21bc
4 changed files with 20 additions and 24 deletions

View file

@ -440,6 +440,7 @@ set(LIBOPENMC_CXX_SRC
src/hdf5_interface.h
src/random_lcg.cpp
src/random_lcg.h
src/simulation.cpp
src/surface.cpp
src/surface.h
src/xml_interface.h
@ -447,9 +448,7 @@ set(LIBOPENMC_CXX_SRC
src/pugixml/pugixml.hpp)
add_library(libopenmc SHARED ${LIBOPENMC_FORTRAN_SRC} ${LIBOPENMC_CXX_SRC})
set_target_properties(libopenmc PROPERTIES OUTPUT_NAME openmc)
add_executable(${program} src/main.cpp)
target_include_directories(${program} PUBLIC include)
#===============================================================================
# Add compiler/linker flags
@ -458,7 +457,7 @@ target_include_directories(${program} PUBLIC include)
set_property(TARGET ${program} libopenmc pugixml_fortran
PROPERTY LINKER_LANGUAGE Fortran)
target_include_directories(libopenmc PUBLIC ${HDF5_INCLUDE_DIRS})
target_include_directories(libopenmc PUBLIC include ${HDF5_INCLUDE_DIRS})
# The executable and the faddeeva package use only one language. They can be
# set via target_compile_options which accepts a list.

View file

@ -80,7 +80,6 @@ module openmc_api
public :: openmc_nuclide_name
public :: openmc_plot_geometry
public :: openmc_reset
public :: openmc_run
public :: openmc_set_seed
public :: openmc_simulation_finalize
public :: openmc_simulation_init

View file

@ -44,7 +44,6 @@ module simulation
implicit none
private
public :: openmc_next_batch
public :: openmc_run
public :: openmc_simulation_init
public :: openmc_simulation_finalize
@ -54,25 +53,6 @@ module simulation
contains
!===============================================================================
! OPENMC_RUN encompasses all the main logic where iterations are performed
! over the batches, generations, and histories in a fixed source or k-eigenvalue
! calculation.
!===============================================================================
function openmc_run() result(err) bind(C)
integer(C_INT) :: err
integer(C_INT) :: status
call openmc_simulation_init()
do
err = openmc_next_batch(status)
if (status /= 0 .or. err < 0) exit
end do
call openmc_simulation_finalize()
end function openmc_run
!===============================================================================
! OPENMC_NEXT_BATCH
!===============================================================================

18
src/simulation.cpp Normal file
View file

@ -0,0 +1,18 @@
#include "openmc.h"
// OPENMC_RUN encompasses all the main logic where iterations are performed
// over the batches, generations, and histories in a fixed source or k-eigenvalue
// calculation.
int openmc_run() {
openmc_simulation_init();
int err = 0;
int status = 0;
while (status == 0 && err == 0) {
err = openmc_next_batch(&status);
}
openmc_simulation_finalize();
return err;
}