Fix incorrect 'xtime' variable in MPAS-A when dt is non-integral #225
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This merge addresses a issue that caused incorrect 'xtime' strings when the model
timestep was non-integral.
When the model timestep is not an integer number of seconds, the xtime variable
computed in the atm_timestep(...) routine could be short by 1.9999... seconds.
The timestamp string valid at the beginning of the time step is computed from
the exact simulation clock time, and the conversion to a string truncates
the fractional part (i.e., up to 0.99999... seconds). Then, in the atm_timestep
routine, the model timestep, dt, is added to this truncated timestamp.
In the conversion of the resulting time back to a timestamp string, fractional
seconds (i.e., up to 0.99999... seconds) are again lost.
One practical impact of this is that model output and restart files would have
an incorrect 'xtime' field, preventing the model from restarting from the correct
time, e.g.,
To address this problem, we now pass an MPAS_Time_type in place of the timeStamp
character string to the atm_timestep(...) routine. This preserves any fractional
seconds in the beginning time, allowing the computed time at the end of
the dynamics step (i.e., xtime) to be correct when the result has no fractional
part.
Note: There are still other potential problems with fractional seconds.
For example, if the output interval is not evenly divided by the fractional
timestep, the 'xtime' field in the output file will contain only
the integer part of the seconds, and will therefore be up to 0.99999...
seconds short.