From fae39fce27c60bcd95aa8878f7e4440543d976cd Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Fri, 1 Nov 2024 14:53:10 +0000 Subject: [PATCH] Stash Xios handler on ParaGridIO instance --- core/src/include/ParaGridIO_Xios.hpp | 3 ++- core/test/XiosAxis_test.cpp | 15 +++++++++++---- core/test/XiosCalendar_test.cpp | 16 ++++++++++++---- core/test/XiosDomain_test.cpp | 15 +++++++++++---- core/test/XiosField_test.cpp | 15 +++++++++++---- core/test/XiosFile_test.cpp | 15 +++++++++++---- core/test/XiosGrid_test.cpp | 14 +++++++++++--- core/test/XiosRead_test.cpp | 5 ++--- core/test/XiosWrite_test.cpp | 5 ++--- 9 files changed, 73 insertions(+), 30 deletions(-) diff --git a/core/src/include/ParaGridIO_Xios.hpp b/core/src/include/ParaGridIO_Xios.hpp index e2e9ea275..be4e21ea4 100644 --- a/core/src/include/ParaGridIO_Xios.hpp +++ b/core/src/include/ParaGridIO_Xios.hpp @@ -77,7 +77,8 @@ class ParaGridIO : public ParametricGrid::IParaGridIO { static ModelState readForcingTimeStatic( const std::set& forcings, const TimePoint& time, const std::string& filePath); - // Xios xiosHandler; + // XIOS handler object + Xios xiosHandler; }; } /* namespace Nextsim */ diff --git a/core/test/XiosAxis_test.cpp b/core/test/XiosAxis_test.cpp index 681685696..88f06f15e 100644 --- a/core/test/XiosAxis_test.cpp +++ b/core/test/XiosAxis_test.cpp @@ -1,7 +1,7 @@ /*! * @file XiosAxis_test.cpp * @author Joe Wallwork - * @date 12 August 2024 + * @date 01 Nov 2024 * @brief Tests for XIOS axes * @details * This test is designed to test axis functionality of the C++ interface @@ -13,7 +13,8 @@ #include "StructureModule/include/ParametricGrid.hpp" #include "include/Configurator.hpp" -#include "include/Xios.hpp" +#include "include/NextsimModule.hpp" +#include "include/ParaGridIO_Xios.hpp" #include @@ -38,8 +39,14 @@ MPI_TEST_CASE("TestXiosAxis", 2) std::unique_ptr pcstream(new std::stringstream(config.str())); Configurator::addStream(std::move(pcstream)); - // Initialize an Xios instance called xios_handler - Xios xios_handler; + // Create ParametricGrid and ParaGridIO instances + Module::setImplementation("Nextsim::ParametricGrid"); + ParametricGrid grid; + ParaGridIO* pio = new ParaGridIO(grid); + grid.setIO(pio); + + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; REQUIRE(xios_handler.isInitialized()); REQUIRE(xios_handler.getClientMPISize() == 2); diff --git a/core/test/XiosCalendar_test.cpp b/core/test/XiosCalendar_test.cpp index 0d00145a1..87e9ef9ae 100644 --- a/core/test/XiosCalendar_test.cpp +++ b/core/test/XiosCalendar_test.cpp @@ -1,7 +1,7 @@ /*! * @file XiosCalendar_test.cpp * @author Joe Wallwork - * @date 5 August 2024 + * @date 01 Nov 2024 * @brief Tests for XIOS calandars * @details * This test is designed to test calendar functionality of the C++ interface @@ -13,7 +13,8 @@ #include "StructureModule/include/ParametricGrid.hpp" #include "include/Configurator.hpp" -#include "include/Xios.hpp" +#include "include/NextsimModule.hpp" +#include "include/ParaGridIO_Xios.hpp" #include @@ -38,8 +39,15 @@ MPI_TEST_CASE("TestXiosInitialization", 2) std::unique_ptr pcstream(new std::stringstream(config.str())); Configurator::addStream(std::move(pcstream)); - // Initialize an Xios instance called xios_handler - Xios xios_handler; + // Create ParametricGrid and ParaGridIO instances + Module::setImplementation("Nextsim::ParametricGrid"); + ParametricGrid grid; + ParaGridIO* pio = new ParaGridIO(grid); + grid.setIO(pio); + + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; + REQUIRE(xios_handler.isInitialized()); REQUIRE(xios_handler.isInitialized()); REQUIRE(xios_handler.getClientMPISize() == 2); diff --git a/core/test/XiosDomain_test.cpp b/core/test/XiosDomain_test.cpp index e0c76d1c1..9ba4dcdcd 100644 --- a/core/test/XiosDomain_test.cpp +++ b/core/test/XiosDomain_test.cpp @@ -1,7 +1,7 @@ /*! * @file XiosDomain_test.cpp * @author Joe Wallwork - * @date 21 August 2024 + * @date 01 Nov 2024 * @brief Tests for XIOS domains * @details * This test is designed to test domain functionality of the C++ interface @@ -13,7 +13,8 @@ #include "StructureModule/include/ParametricGrid.hpp" #include "include/Configurator.hpp" -#include "include/Xios.hpp" +#include "include/NextsimModule.hpp" +#include "include/ParaGridIO_Xios.hpp" #include @@ -38,8 +39,14 @@ MPI_TEST_CASE("TestXiosDomain", 2) std::unique_ptr pcstream(new std::stringstream(config.str())); Configurator::addStream(std::move(pcstream)); - // Initialize an Xios instance called xios_handler - Xios xios_handler; + // Create ParametricGrid and ParaGridIO instances + Module::setImplementation("Nextsim::ParametricGrid"); + ParametricGrid grid; + ParaGridIO* pio = new ParaGridIO(grid); + grid.setIO(pio); + + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; REQUIRE(xios_handler.isInitialized()); const size_t size = xios_handler.getClientMPISize(); REQUIRE(size == 2); diff --git a/core/test/XiosField_test.cpp b/core/test/XiosField_test.cpp index d71e374cd..b973364a7 100644 --- a/core/test/XiosField_test.cpp +++ b/core/test/XiosField_test.cpp @@ -1,7 +1,7 @@ /*! * @file XiosField_test.cpp * @author Joe Wallwork - * @date 21 August 2024 + * @date 01 Nov 2024 * @brief Tests for XIOS axes * @details * This test is designed to test axis functionality of the C++ interface @@ -13,7 +13,8 @@ #include "StructureModule/include/ParametricGrid.hpp" #include "include/Configurator.hpp" -#include "include/Xios.hpp" +#include "include/NextsimModule.hpp" +#include "include/ParaGridIO_Xios.hpp" #include @@ -38,8 +39,14 @@ MPI_TEST_CASE("TestXiosField", 2) std::unique_ptr pcstream(new std::stringstream(config.str())); Configurator::addStream(std::move(pcstream)); - // Initialize an Xios instance called xios_handler - Xios xios_handler; + // Create ParametricGrid and ParaGridIO instances + Module::setImplementation("Nextsim::ParametricGrid"); + ParametricGrid grid; + ParaGridIO* pio = new ParaGridIO(grid); + grid.setIO(pio); + + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; REQUIRE(xios_handler.isInitialized()); const size_t size = xios_handler.getClientMPISize(); REQUIRE(size == 2); diff --git a/core/test/XiosFile_test.cpp b/core/test/XiosFile_test.cpp index 77c19116d..e35ecb8ca 100644 --- a/core/test/XiosFile_test.cpp +++ b/core/test/XiosFile_test.cpp @@ -1,7 +1,7 @@ /*! * @file XiosFile_test.cpp * @author Joe Wallwork - * @date 12 August 2024 + * @date 01 Nov 2024 * @brief Tests for XIOS axes * @details * This test is designed to test axis functionality of the C++ interface @@ -13,7 +13,8 @@ #include "StructureModule/include/ParametricGrid.hpp" #include "include/Configurator.hpp" -#include "include/Xios.hpp" +#include "include/NextsimModule.hpp" +#include "include/ParaGridIO_Xios.hpp" #include @@ -40,8 +41,14 @@ MPI_TEST_CASE("TestXiosFile", 2) std::unique_ptr pcstream(new std::stringstream(config.str())); Configurator::addStream(std::move(pcstream)); - // Initialize an Xios instance called xios_handler - Xios xios_handler; + // Create ParametricGrid and ParaGridIO instances + Module::setImplementation("Nextsim::ParametricGrid"); + ParametricGrid grid; + ParaGridIO* pio = new ParaGridIO(grid); + grid.setIO(pio); + + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; REQUIRE(xios_handler.isInitialized()); const size_t size = xios_handler.getClientMPISize(); REQUIRE(size == 2); diff --git a/core/test/XiosGrid_test.cpp b/core/test/XiosGrid_test.cpp index f595690af..a56fea95f 100644 --- a/core/test/XiosGrid_test.cpp +++ b/core/test/XiosGrid_test.cpp @@ -11,8 +11,10 @@ #include #undef INFO +#include "StructureModule/include/ParametricGrid.hpp" #include "include/Configurator.hpp" -#include "include/Xios.hpp" +#include "include/NextsimModule.hpp" +#include "include/ParaGridIO_Xios.hpp" #include @@ -37,8 +39,14 @@ MPI_TEST_CASE("TestXiosGrid", 2) std::unique_ptr pcstream(new std::stringstream(config.str())); Configurator::addStream(std::move(pcstream)); - // Initialize an Xios instance called xios_handler - Xios xios_handler; + // Create ParametricGrid and ParaGridIO instances + Module::setImplementation("Nextsim::ParametricGrid"); + ParametricGrid grid; + ParaGridIO* pio = new ParaGridIO(grid); + grid.setIO(pio); + + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; REQUIRE(xios_handler.isInitialized()); const size_t size = xios_handler.getClientMPISize(); REQUIRE(size == 2); diff --git a/core/test/XiosRead_test.cpp b/core/test/XiosRead_test.cpp index 2e92fa5c9..012e65a49 100644 --- a/core/test/XiosRead_test.cpp +++ b/core/test/XiosRead_test.cpp @@ -46,9 +46,8 @@ MPI_TEST_CASE("TestXiosRead", 2) ParaGridIO* pio = new ParaGridIO(grid); grid.setIO(pio); - // Initialize an Xios instance called xios_handler - // TODO: Create XIOS handler along with ParaGridIO instance - Xios xios_handler; + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; REQUIRE(xios_handler.isInitialized()); const size_t size = xios_handler.getClientMPISize(); REQUIRE(size == 2); diff --git a/core/test/XiosWrite_test.cpp b/core/test/XiosWrite_test.cpp index 3503392f5..c8238c221 100644 --- a/core/test/XiosWrite_test.cpp +++ b/core/test/XiosWrite_test.cpp @@ -46,9 +46,8 @@ MPI_TEST_CASE("TestXiosWrite", 2) ParaGridIO* pio = new ParaGridIO(grid); grid.setIO(pio); - // Initialize an Xios instance called xios_handler - // TODO: Create XIOS handler along with ParaGridIO instance - Xios xios_handler; + // Create a reference for the Xios handler object associated with the ParaGridIO instance + Xios& xios_handler = pio->xiosHandler; REQUIRE(xios_handler.isInitialized()); const size_t size = xios_handler.getClientMPISize(); REQUIRE(size == 2);