Skip to content

Conversation

mgduda
Copy link
Contributor

@mgduda mgduda commented May 2, 2019

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.,

     xtime =
      "2010-10-23_23:59:59                                             " ;

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.

@mgduda mgduda changed the base branch from develop to hotfix-v6.3 May 2, 2019 21:16
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.,

 xtime =
  "2010-10-23_23:59:59                                             " ;

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.
@mgduda mgduda force-pushed the atmosphere/fix_xtime_fractional_seconds branch from 3d1e8ba to fa6ef1f Compare May 6, 2019 20:42
@mgduda mgduda requested a review from davegill May 6, 2019 20:43
Copy link

@davegill davegill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy to understand
Approved

@mgduda mgduda merged commit fa6ef1f into MPAS-Dev:hotfix-v6.3 May 9, 2019
mgduda added a commit that referenced this pull request May 9, 2019
….3 (PR #225)

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.,

     xtime =
      "2010-10-23_23:59:59                                             " ;

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.

* atmosphere/fix_xtime_fractional_seconds:
  Fix incorrect 'xtime' variable for fractional dt
@mgduda mgduda deleted the atmosphere/fix_xtime_fractional_seconds branch May 9, 2019 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants