Read forcings only when necessary#1055
Conversation
timspainNERSC
left a comment
There was a problem hiding this comment.
This will be fine. There is an assumption that the time step length will either evenly divide an hour or be a multiple number of hours that evenly divide the day. But this seems to be a reasonable assumption.
I'd recommend not printing the time string every time you want to check for fresh data, though.
| if (tst.start.format(TimePoint::msFormat) == "T00:00Z") { | ||
| forcingState = ParaGridIO::readForcingTimeStatic(forcings, tst.start, filePath); |
There was a problem hiding this comment.
To avoid string parsing every time, I suggest getting the duration since the epoch in seconds and seeing whether it is the top of the hour:
(tst.start - TimePoint()).seconds() % 3600. == 0.
(This should work: if it doesn't that's a bug in the Time classes).
379bb4b to
c314139
Compare
|
[Rebased on top of |
cf6d362 to
b450e26
Compare
TomMelt
left a comment
There was a problem hiding this comment.
Thanks @joewallwork . It looks good to me
b450e26 to
ef53708
Compare
timspainNERSC
left a comment
There was a problem hiding this comment.
Looking good, now
Read forcings only when necessary
Fixes #1054
Task List
Change Description
Currently, if the ERA5 and TOPAZ modules are included then they are read every timestep. This is unnecessary given that ERA5 data are only available once per hour and TOPAZ once per day.
This PR makes it so that ERA5 forcings are only read at the top of the hour and TOPAZ forcings are only read at midnight.
Caveats
Are we happy with these assumptions? If so, I can add config checks to ensure that they are satisfied. If not then I will have to modify how the XIOS calendar is handled.
(This change is also required to enable ERA5 and TOPAZ forcings with XIOS.)
Test Description
XIOS tests are updated accordingly.
Documentation Impact
A note on the assumptions has been added to the XIOS doc page.