-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align update of nextSIM-DG and XIOS calendars #757
base: develop
Are you sure you want to change the base?
Changes from all commits
105568d
6ff28af
3d15fae
ee75b9d
752b24f
a5b639b
57bb749
8238fb6
4868f88
260e050
326d519
9cf905a
fe2118d
955c5c2
0ca57ad
fe1c9b2
350702e
00f1a5e
28b2453
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* @file ModelMetadata.cpp | ||
* | ||
* @date 21 August 2024 | ||
* @date 10 Dec 2024 | ||
* @author Tim Spain <[email protected]> | ||
*/ | ||
|
||
|
@@ -103,4 +103,28 @@ ModelState& ModelMetadata::affixCoordinates(ModelState& state) const | |
} | ||
return state; | ||
} | ||
|
||
void ModelMetadata::setTime(const TimePoint& time) | ||
{ | ||
m_time = time; | ||
#ifdef USE_XIOS | ||
if (!xiosHandler->isInitialized()) { | ||
throw std::runtime_error("ModelMetadata: Xios handler has not been initialized"); | ||
} | ||
xiosHandler->setCalendarStep(0); | ||
xiosHandler->setCalendarStart(time); | ||
#endif | ||
} | ||
|
||
void ModelMetadata::incrementTime(const Duration& step) | ||
{ | ||
m_time += step; | ||
#ifdef USE_XIOS | ||
if (!xiosHandler->isInitialized()) { | ||
throw std::runtime_error("ModelMetadata: Xios handler has not been initialized"); | ||
} | ||
xiosHandler->incrementCalendar(); | ||
#endif | ||
} | ||
|
||
} /* namespace Nextsim */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* @file ParaGridIO.cpp | ||
* | ||
* @date Oct 24, 2022 | ||
* @date 09 Dec 2024 | ||
* @author Tim Spain <[email protected]> | ||
*/ | ||
|
||
|
@@ -227,7 +227,7 @@ ModelState ParaGridIO::readForcingTimeStatic( | |
std::vector<double> timeVec(timeDim.getSize()); | ||
timeVar.getVar(timeVec.data()); | ||
// Get the index of the largest TimePoint less than the target. | ||
targetTIndex = std::find_if(begin(timeVec), end(timeVec), [time](double t) { | ||
targetTIndex = std::find_if(std::begin(timeVec), std::end(timeVec), [time](double t) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required to avoid compile errors about |
||
return (TimePoint() + Duration(t)) > time; | ||
}) - timeVec.begin(); | ||
// Rather than the first that is greater than, get the last that is less | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @file Xios.cpp | ||
* @author Tom Meltzer <[email protected]> | ||
* @author Joe Wallwork <[email protected]> | ||
* @date 09 Dec 2024 | ||
* @date 10 Dec 2024 | ||
* @brief XIOS interface implementation | ||
* @details | ||
* | ||
|
@@ -37,7 +37,6 @@ static const std::map<int, std::string> keyMap = { { Xios::ENABLED_KEY, "xios.en | |
//! Enable XIOS in the 'config' | ||
void enableXios() | ||
{ | ||
Configurator::clearStreams(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is important when you set up XIOS after you've already configured other parts of nextSIM-DG. |
||
std::stringstream config; | ||
config << "[xios]" << std::endl << "enable = true" << std::endl; | ||
std::unique_ptr<std::istream> pcstream(new std::stringstream(config.str())); | ||
|
@@ -271,6 +270,18 @@ void Xios::setCalendarTimestep(const Duration timestep) | |
cxios_update_calendar_timestep(clientCalendar); | ||
} | ||
|
||
/*! | ||
* Update XIOS calendar iteration/step number to some value | ||
* | ||
* @param Step number to update to | ||
*/ | ||
void Xios::setCalendarStep(const int stepNumber) { cxios_update_calendar(stepNumber); } | ||
|
||
/*! | ||
* Increment XIOS' calendar iteration/step number by one. | ||
*/ | ||
void Xios::incrementCalendar() { setCalendarStep(getCalendarStep() + 1); } | ||
|
||
/*! | ||
* Get calendar type | ||
* | ||
|
@@ -347,13 +358,6 @@ std::string Xios::getCurrentDate(const bool isoFormat) | |
return convertXiosDatetimeToString(xiosDate, isoFormat); | ||
} | ||
|
||
/*! | ||
* Update XIOS calendar iteration/step number | ||
* | ||
* @param current step number | ||
*/ | ||
void Xios::updateCalendar(const int stepNumber) { cxios_update_calendar(stepNumber); } | ||
|
||
/*! | ||
* Get the axis_definition group | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* @file ModelMetadata.hpp | ||
* | ||
* @date Jun 29, 2022 | ||
* @date 09 Dec 2024 | ||
* @author Tim Spain <[email protected]> | ||
*/ | ||
|
||
|
@@ -12,6 +12,9 @@ | |
#include "include/ModelArray.hpp" | ||
#include "include/ModelState.hpp" | ||
#include "include/Time.hpp" | ||
#ifdef USE_XIOS | ||
#include "include/Xios.hpp" | ||
#endif | ||
|
||
#include <string> | ||
|
||
|
@@ -47,13 +50,13 @@ class ModelMetadata { | |
* | ||
* @param time TimePoint instance encoding the current time. | ||
*/ | ||
inline void setTime(const TimePoint& time) { m_time = time; } | ||
void setTime(const TimePoint& time); | ||
/*! | ||
* @brief Increments the model time metadata value. | ||
* | ||
* @param step Duration of the time increment to add. | ||
*/ | ||
inline void incrementTime(const Duration& step) { m_time += step; } | ||
void incrementTime(const Duration& step); | ||
//! Returns the current model time. | ||
inline const TimePoint& time() const { return m_time; } | ||
|
||
|
@@ -99,6 +102,15 @@ class ModelMetadata { | |
int localCornerX, localCornerY, localExtentX, localExtentY, globalExtentX, globalExtentY; | ||
#endif | ||
|
||
#ifdef USE_XIOS | ||
/* | ||
* @brief Set pointer to Xios handler instance. | ||
* | ||
* @param xiosPtr Pointer to set | ||
*/ | ||
inline void setXiosHandler(Xios* xiosPtr) { xiosHandler = xiosPtr; } | ||
#endif | ||
|
||
private: | ||
TimePoint m_time; | ||
ConfigMap m_config; | ||
|
@@ -117,6 +129,9 @@ class ModelMetadata { | |
#ifdef USE_MPI | ||
const std::string bboxName = "bounding_boxes"; | ||
#endif | ||
#ifdef USE_XIOS | ||
Xios* xiosHandler = nullptr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is Also, wherever it ends up, might a smarter pointer be better than a raw pointer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way I currently have it set up in #751 is that multiple classes ( |
||
#endif | ||
}; | ||
|
||
} /* namespace Nextsim */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @file Xios.hpp | ||
* @author Tom Meltzer <[email protected]> | ||
* @author Joe Wallwork <[email protected]> | ||
* @date 04 Dec 2024 | ||
* @date 10 Dec 2024 | ||
* @brief XIOS interface header | ||
* @details | ||
* | ||
|
@@ -55,13 +55,14 @@ class Xios : public Configured<Xios> { | |
void setCalendarOrigin(const TimePoint origin); | ||
void setCalendarStart(const TimePoint start); | ||
void setCalendarTimestep(const Duration timestep); | ||
void setCalendarStep(const int stepNumber); | ||
void incrementCalendar(); | ||
std::string getCalendarType(); | ||
TimePoint getCalendarOrigin(); | ||
TimePoint getCalendarStart(); | ||
Duration getCalendarTimestep(); | ||
int getCalendarStep(); | ||
std::string getCurrentDate(const bool isoFormat = true); | ||
void updateCalendar(const int stepNumber); | ||
|
||
/* Axis */ | ||
void createAxis(const std::string axisId); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this change is the same as the one in #758.