diff --git a/core/src/Xios.cpp b/core/src/Xios.cpp index 274640cfa..93b65a176 100644 --- a/core/src/Xios.cpp +++ b/core/src/Xios.cpp @@ -49,13 +49,16 @@ void enableXios() * * @param dt Timestep to use for the model * @param contextid ID for the XIOS context + * @param starttime Datetime string for the start of the simulation * @param calendartype Type of calendar to use */ -Xios::Xios(const std::string dt, const std::string contextid, const std::string calendartype) +Xios::Xios(const std::string dt, const std::string contextid, const std::string starttime, + const std::string calendartype) { - calendarType = calendartype; - contextId = contextid; timestep = Duration(dt); + startTime = TimePoint(starttime); + contextId = contextid; + calendarType = calendartype; configure(); } @@ -127,7 +130,7 @@ void Xios::configureServer() // Set default calendar origin and start setCalendarOrigin(TimePoint("1970-01-01T00:00:00Z")); // Unix epoch - setCalendarStart(TimePoint("2023-03-17T17:11:00Z")); // TODO: Read from config + setCalendarStart(TimePoint(startTime)); } /*! diff --git a/core/src/include/Xios.hpp b/core/src/include/Xios.hpp index 7b91e007c..cd846ded7 100644 --- a/core/src/include/Xios.hpp +++ b/core/src/include/Xios.hpp @@ -32,6 +32,7 @@ void enableXios(); class Xios : public Configured { public: Xios(const std::string dt = "P0-0T01:00:00", const std::string contextid = "nextSIM-DG", + const std::string starttime = "1970-01-01T00:00:00Z", const std::string calendartype = "Gregorian"); ~Xios(); @@ -150,6 +151,7 @@ class Xios : public Configured { std::string calendarType; std::string contextId; Duration timestep; + TimePoint startTime; MPI_Comm clientComm; MPI_Fint clientComm_F; MPI_Fint nullComm_F; diff --git a/core/test/XiosCalendar_test.cpp b/core/test/XiosCalendar_test.cpp index a77699789..6dcd0a7cc 100644 --- a/core/test/XiosCalendar_test.cpp +++ b/core/test/XiosCalendar_test.cpp @@ -42,8 +42,9 @@ MPI_TEST_CASE("TestXiosInitialization", 2) TimePoint origin("2020-01-23T00:08:15Z"); xios_handler.setCalendarOrigin(origin); REQUIRE(origin == xios_handler.getCalendarOrigin()); - REQUIRE(origin.format() == "1970-01-01T00:00:00Z"); + REQUIRE(origin.format() == "2020-01-23T00:08:15Z"); // Calendar start + REQUIRE(xios_handler.getCalendarStart().format() == "1970-01-01T00:00:00Z"); // Default TimePoint start("2023-03-17T17:11:00Z"); xios_handler.setCalendarStart(start); REQUIRE(start == xios_handler.getCalendarStart()); diff --git a/core/test/XiosReadWrite_test.cpp b/core/test/XiosReadWrite_test.cpp index ab497e10b..d746216a8 100644 --- a/core/test/XiosReadWrite_test.cpp +++ b/core/test/XiosReadWrite_test.cpp @@ -1,7 +1,7 @@ /*! * @file XiosReadWrite_test.cpp * @author Joe Wallwork - * @date 03 Dec 2024 + * @date 04 Dec 2024 * @brief Tests for XIOS write method * @details * This test is designed to test the read and write methods of the C++ @@ -61,7 +61,7 @@ Xios setupXiosHandler(int dim, bool read) } else { label = "write"; } - Xios xios_handler("P0-0T01:30:00", formatId(label, dim)); + Xios xios_handler("P0-0T01:30:00", formatId(label, dim), "2023-03-17T17:11:00Z"); REQUIRE(xios_handler.isInitialized()); const size_t size = xios_handler.getClientMPISize(); REQUIRE(size == 2);