Skip to content

Commit

Permalink
Stash Xios handler on ParaGridIO instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Nov 1, 2024
1 parent 28f269a commit fae39fc
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 30 deletions.
3 changes: 2 additions & 1 deletion core/src/include/ParaGridIO_Xios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class ParaGridIO : public ParametricGrid::IParaGridIO {
static ModelState readForcingTimeStatic(
const std::set<std::string>& forcings, const TimePoint& time, const std::string& filePath);

// Xios xiosHandler;
// XIOS handler object
Xios xiosHandler;
};
} /* namespace Nextsim */

Expand Down
15 changes: 11 additions & 4 deletions core/test/XiosAxis_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file XiosAxis_test.cpp
* @author Joe Wallwork <[email protected]>
* @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
Expand All @@ -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 <iostream>

Expand All @@ -38,8 +39,14 @@ MPI_TEST_CASE("TestXiosAxis", 2)
std::unique_ptr<std::istream> 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<IStructure>("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);

Expand Down
16 changes: 12 additions & 4 deletions core/test/XiosCalendar_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file XiosCalendar_test.cpp
* @author Joe Wallwork <[email protected]>
* @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
Expand All @@ -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 <iostream>

Expand All @@ -38,8 +39,15 @@ MPI_TEST_CASE("TestXiosInitialization", 2)
std::unique_ptr<std::istream> 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<IStructure>("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);

Expand Down
15 changes: 11 additions & 4 deletions core/test/XiosDomain_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file XiosDomain_test.cpp
* @author Joe Wallwork <[email protected]>
* @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
Expand All @@ -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 <iostream>

Expand All @@ -38,8 +39,14 @@ MPI_TEST_CASE("TestXiosDomain", 2)
std::unique_ptr<std::istream> 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<IStructure>("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);
Expand Down
15 changes: 11 additions & 4 deletions core/test/XiosField_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file XiosField_test.cpp
* @author Joe Wallwork <[email protected]>
* @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
Expand All @@ -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 <iostream>

Expand All @@ -38,8 +39,14 @@ MPI_TEST_CASE("TestXiosField", 2)
std::unique_ptr<std::istream> 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<IStructure>("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);
Expand Down
15 changes: 11 additions & 4 deletions core/test/XiosFile_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file XiosFile_test.cpp
* @author Joe Wallwork <[email protected]>
* @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
Expand All @@ -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 <iostream>

Expand All @@ -40,8 +41,14 @@ MPI_TEST_CASE("TestXiosFile", 2)
std::unique_ptr<std::istream> 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<IStructure>("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);
Expand Down
14 changes: 11 additions & 3 deletions core/test/XiosGrid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#include <doctest/extensions/doctest_mpi.h>
#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 <iostream>

Expand All @@ -37,8 +39,14 @@ MPI_TEST_CASE("TestXiosGrid", 2)
std::unique_ptr<std::istream> 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<IStructure>("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);
Expand Down
5 changes: 2 additions & 3 deletions core/test/XiosRead_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions core/test/XiosWrite_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fae39fc

Please sign in to comment.