Refactor to wrap everything in main function into scope, to ensure DHT is freed before MPI_FInalize

This commit is contained in:
Max Luebke 2024-04-02 20:47:32 +00:00
parent b5dedb3422
commit 4784fc3e12

View File

@ -340,6 +340,7 @@ int main(int argc, char *argv[]) {
MPI_Init(&argc, &argv);
{
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &MY_RANK);
@ -386,16 +387,7 @@ int main(int argc, char *argv[]) {
if (MY_RANK > 0) {
chemistry.WorkerLoop();
MPI_Barrier(MPI_COMM_WORLD);
MSG("finished, cleanup of process " + std::to_string(MY_RANK));
MPI_Finalize();
return EXIT_SUCCESS;
}
} else {
// R.parseEvalQ("mysetup <- setup");
// // if (MY_RANK == 0) { // get timestep vector from
// // grid_init function ... //
@ -436,13 +428,15 @@ int main(int argc, char *argv[]) {
r_vis_code = "saveRDS(profiling, file=paste0(fileout,'/timings.rds'));";
R.parseEval(r_vis_code);
// MSG("Done! Results are stored as R objects into <" + run_params.getOutDir()
// MSG("Done! Results are stored as R objects into <" +
// run_params.getOutDir()
// +
// "/timings.rds>");
MPI_Barrier(MPI_COMM_WORLD);
}
}
MSG("finished, cleanup of process " + std::to_string(MY_RANK));
MPI_Finalize();
if (MY_RANK == 0) {