From 329d314ac94b4307e2c621181904b8d003a57f64 Mon Sep 17 00:00:00 2001 From: program-- Date: Mon, 12 Feb 2024 10:47:02 -0800 Subject: [PATCH] feat: allow forcings engine provider to set MPI communicator [no ci] --- .../forcing/ForcingsEngineDataProvider.hpp | 23 +++++++++++++++++++ src/forcing/ForcingsEngineDataProvider.cpp | 6 +++++ 2 files changed, 29 insertions(+) diff --git a/include/forcing/ForcingsEngineDataProvider.hpp b/include/forcing/ForcingsEngineDataProvider.hpp index 89f725b640..932130ad5b 100644 --- a/include/forcing/ForcingsEngineDataProvider.hpp +++ b/include/forcing/ForcingsEngineDataProvider.hpp @@ -15,11 +15,34 @@ namespace data_access { struct ForcingsEngineDataProvider : public GenericDataProvider { + /** + * @brief Construct a new Forcings Engine Data Provider instance + * + * @param init Path to initialization config + * @param time_start start time for module as a unix epoch + * @param time_end end time for module as a unix epoch + */ explicit ForcingsEngineDataProvider(const std::string& init, std::size_t time_start, std::size_t time_end); + + /** + * @brief Construct a new Forcings Engine Data Provider instance + * + * @param init Path to initialization config + * @param time_start start time for module as a string timestamp + * @param time_end end time for module as a string timestamp + * @param fmt format of timestamps + */ explicit ForcingsEngineDataProvider(const std::string& init, const std::string& time_start, const std::string& time_end, const std::string& fmt = "%Y-%m-%d %H:%M:%S"); ~ForcingsEngineDataProvider() override; + /** + * @brief Set the MPI communicator that the Forcings Engine should use. + * + * @param handle int representing a communicator handle. + */ + void set_communicator(int handle); + auto get_available_variable_names() -> boost::span override; diff --git a/src/forcing/ForcingsEngineDataProvider.cpp b/src/forcing/ForcingsEngineDataProvider.cpp index 8317054255..12078792db 100644 --- a/src/forcing/ForcingsEngineDataProvider.cpp +++ b/src/forcing/ForcingsEngineDataProvider.cpp @@ -37,6 +37,12 @@ ForcingsEngineDataProvider::ForcingsEngineDataProvider(const std::string& init, ForcingsEngineDataProvider::~ForcingsEngineDataProvider() = default; +void ForcingsEngineDataProvider::set_communicator(int handle) +{ + int idx = 0; + instance_.set_value_at_indices("bmi_mpi_comm_handle", &idx, 1, &handle, "int"); +} + auto ForcingsEngineDataProvider::get_available_variable_names() -> boost::span {