Skip to content

Commit d5590db

Browse files
committed
Merge branch 'atmosphere/fix_xtime_fractional_seconds' into hotfix-v6.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
2 parents 70afa9f + fa6ef1f commit d5590db

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/core_atmosphere/dynamics/mpas_atm_time_integration.F

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module atm_time_integration
6262
contains
6363

6464

65-
subroutine atm_timestep(domain, dt, timeStamp, itimestep)
65+
subroutine atm_timestep(domain, dt, nowTime, itimestep)
6666
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6767
! Advance model state forward in time by the specified time step
6868
!
@@ -76,7 +76,7 @@ subroutine atm_timestep(domain, dt, timeStamp, itimestep)
7676

7777
type (domain_type), intent(inout) :: domain
7878
real (kind=RKIND), intent(in) :: dt
79-
character(len=*), intent(in) :: timeStamp
79+
type (MPAS_Time_type), intent(in) :: nowTime
8080
integer, intent(in) :: itimestep
8181

8282

@@ -98,9 +98,8 @@ subroutine atm_timestep(domain, dt, timeStamp, itimestep)
9898
call mpas_log_write('Currently, only ''SRK3'' is supported.', messageType=MPAS_LOG_CRIT)
9999
end if
100100

101-
call mpas_set_time(currTime, dateTimeString=timeStamp)
102101
call mpas_set_timeInterval(dtInterval, dt=dt)
103-
currTime = currTime + dtInterval
102+
currTime = nowTime + dtInterval
104103
call mpas_get_time(currTime, dateTimeString=xtime_new)
105104

106105
block => domain % blocklist

src/core_atmosphere/mpas_atm_core.F

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function atm_core_init(domain, startTimeStamp) result(ierr)
3636
real (kind=RKIND), pointer :: dt
3737
type (block_type), pointer :: block
3838

39-
character(len=StrKIND) :: timeStamp
4039
integer :: i
4140
logical, pointer :: config_do_restart
4241

@@ -846,7 +845,6 @@ subroutine atm_do_timestep(domain, dt, itimestep)
846845

847846
type (MPAS_Time_Type) :: startTime, currTime
848847
type (MPAS_TimeInterval_Type) :: xtimeTime
849-
character(len=StrKIND) :: timeStamp
850848
integer :: s, s_n, s_d
851849
real (kind=RKIND) :: xtime_s
852850
integer :: ierr
@@ -858,8 +856,6 @@ subroutine atm_do_timestep(domain, dt, itimestep)
858856
call mpas_get_timeInterval(interval=xtimeTime, S=s, S_n=s_n, S_d=s_d, ierr=ierr)
859857
xtime_s = (s + s_n / s_d)
860858

861-
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
862-
863859

864860
#ifdef DO_PHYSICS
865861
!proceed with physics if moist_physics is set to true:
@@ -869,7 +865,7 @@ subroutine atm_do_timestep(domain, dt, itimestep)
869865
endif
870866
#endif
871867

872-
call atm_timestep(domain, dt, timeStamp, itimestep)
868+
call atm_timestep(domain, dt, currTime, itimestep)
873869

874870
end subroutine atm_do_timestep
875871

0 commit comments

Comments
 (0)