Make sure cpp_driver test works with MPI

This commit is contained in:
Paul Romano 2021-04-21 10:40:01 -05:00
parent dea0a0e21f
commit e5715946c2

View file

@ -1,6 +1,10 @@
#ifdef OPENMC_MPI
#include <mpi.h>
#endif
#include "openmc/capi.h"
#include "openmc/cell.h"
#include "openmc/error.h"
#include "openmc/geometry.h"
#include "openmc/message_passing.h"
#include "openmc/summary.h"
@ -11,7 +15,13 @@
using namespace openmc;
int main(int argc, char** argv) {
openmc_init(argc, argv, nullptr);
#ifdef OPENMC_MPI
MPI_Comm world {MPI_COMM_WORLD};
int err = openmc_init(argc, argv, &world);
#else
int err = openmc_init(argc, argv, nullptr);
#endif
if (err) fatal_error(openmc_err_msg);
// create a new cell filter
auto cell_filter = Filter::create<CellFilter>();
@ -57,5 +67,10 @@ int main(int argc, char** argv) {
openmc_run();
openmc_finalize();
#ifdef OPENMC_MPI
MPI_Finalize();
#endif
return 0;
}