Skip to content

Commit

Permalink
refactor: added MPI capabilities to all roughpaper programs
Browse files Browse the repository at this point in the history
  • Loading branch information
yoctoyotta1024 committed Nov 17, 2024
1 parent 3535c1a commit 1306324
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
16 changes: 14 additions & 2 deletions roughpaper/scratch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <iostream>

#include "./cleotypes_sizes.hpp"
#include "zarr/dataset.hpp"
#include "cartesiandomain/cartesianmaps.hpp"
#include "cartesiandomain/createcartesianmaps.hpp"
#include "cartesiandomain/null_boundary_conditions.hpp"
Expand Down Expand Up @@ -54,7 +55,6 @@
#include "runcleo/sdmmethods.hpp"
#include "superdrops/microphysicalprocess.hpp"
#include "superdrops/motion.hpp"
#include "zarr/dataset.hpp"
#include "zarr/fsstore.hpp"

template <typename Store>
Expand Down Expand Up @@ -172,7 +172,17 @@ inline auto create_sdm(const Config &config, const Timesteps &tsteps, Dataset<St
}

int main(int argc, char *argv[]) {
print_type_sizes(argc, argv);
// print_type_sizes(argc, argv);

MPI_Init(&argc, &argv);

int comm_size;
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
if (comm_size > 1) {
std::cout << "ERROR: The current example is not prepared"
<< " to be run with more than one MPI process" << std::endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}

Kokkos::Timer kokkostimer;

Expand Down Expand Up @@ -210,6 +220,8 @@ int main(int argc, char *argv[]) {
"Total Program Duration: "
<< ttot << "s \n-------------------------------\n";

MPI_Finalize();

return 0;
}
/* ----------------------------------------------------------------------------------------------*/
Expand Down
15 changes: 14 additions & 1 deletion roughpaper/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ int main(int argc, char *argv[]) {
throw std::invalid_argument("configuration file(s) not specified");
}

MPI_Init(&argc, &argv);

int comm_size;
MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
if (comm_size > 1) {
std::cout << "ERROR: The current example is not prepared"
<< " to be run with more than one MPI process" << std::endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}

Kokkos::Timer kokkostimer;

/* Read input parameters from configuration file(s) */
Expand All @@ -40,14 +50,15 @@ int main(int argc, char *argv[]) {
auto dataset = Dataset(store);

/* Initial conditions for CLEO run */
const InitialConditions auto initconds = create_initconds(config);

/* Initialise Kokkos parallel environment */
Kokkos::initialize(argc, argv);
{
/* CLEO Super-Droplet Model (excluding coupled dynamics solver) */
const SDMMethods sdm(create_sdm(config, tsteps, dataset));

const InitialConditions auto initconds = create_initconds(config, sdm.gbxmaps);

/* Solver of dynamics coupled to CLEO SDM */
CoupledDynamics auto coupldyn(
create_coupldyn(config, sdm.gbxmaps, tsteps.get_couplstep(), tsteps.get_t_end()));
Expand All @@ -66,5 +77,7 @@ int main(int argc, char *argv[]) {
"Total Program Duration: "
<< ttot << "s \n-------------------------------\n";

MPI_Finalize();

return 0;
}
6 changes: 3 additions & 3 deletions roughpaper/src/main_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <stdexcept>
#include <string_view>

#include "zarr/dataset.hpp"
#include "cartesiandomain/add_supers_at_domain_top.hpp"
#include "cartesiandomain/cartesianmaps.hpp"
#include "cartesiandomain/cartesianmotion.hpp"
Expand Down Expand Up @@ -74,7 +75,6 @@
#include "superdrops/microphysicalprocess.hpp"
#include "superdrops/motion.hpp"
#include "superdrops/terminalvelocity.hpp"
#include "zarr/dataset.hpp"
#include "zarr/fsstore.hpp"

inline CoupledDynamics auto create_coupldyn(const Config &config, const CartesianMaps &gbxmaps,
Expand All @@ -88,9 +88,9 @@ inline CoupledDynamics auto create_coupldyn(const Config &config, const Cartesia
return FromFileDynamics(config.get_fromfiledynamics(), couplstep, ndims, nsteps);
}

inline InitialConditions auto create_initconds(const Config &config) {
inline InitialConditions auto create_initconds(const Config &config, const CartesianMaps &gbxmaps) {
// const InitAllSupersFromBinary initsupers(config.get_initsupersfrombinary());
const InitSupersFromBinary initsupers(config.get_initsupersfrombinary());
const InitSupersFromBinary initsupers(config.get_initsupersfrombinary(), gbxmaps);
const InitGbxsNull initgbxs(config.get_ngbxs());

return InitConds(initsupers, initgbxs);
Expand Down

0 comments on commit 1306324

Please sign in to comment.