Skip to content

Commit 3f43fa5

Browse files
committed
Allow seconds to be either real or integer in string.
1 parent c65e62f commit 3f43fa5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Infrastructure/TimeMgr/interface/ESMF_TimeInterval.F90

+8-3
Original file line numberDiff line numberDiff line change
@@ -2865,8 +2865,12 @@ subroutine ESMF_ParseDurTimeString(timeintervalString, &
28652865
return
28662866
endif
28672867

2868-
! Read year value
2869-
read(timeIntervalString(beg_loc:end_loc), *, ioStat=ioStatus) s_i8
2868+
! Read second value depending on if it looks like an integer or a real
2869+
if (VERIFY(timeIntervalString(beg_loc:end_loc),"+-0123456789") == 0) then
2870+
read(timeIntervalString(beg_loc:end_loc), *, ioStat=ioStatus) s_i8
2871+
else
2872+
read(timeIntervalString(beg_loc:end_loc), *, ioStat=ioStatus) s_r8
2873+
endif
28702874
if (ioStatus /=0) then
28712875
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_VALUE, &
28722876
msg=" An error occurred while reading S value in ISO duration string.", &
@@ -2910,7 +2914,8 @@ subroutine ESMF_ParseDurDateString(timeintervalString, &
29102914
integer :: localrc
29112915
integer :: beg_loc, end_loc
29122916
integer :: t_loc
2913-
2917+
integer :: ioStatus
2918+
29142919
! Init output to 0
29152920
yy_i8=0
29162921
mm_i8=0

src/Infrastructure/TimeMgr/tests/ESMF_TimeIntervalUTest.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -3899,7 +3899,7 @@ program ESMF_TimeIntervalUTest
38993899
! Testing ESMF_TimeIntervalSet from an ISO duration string
39003900
write(name, *) "Set an ESMF_TimeInterval using an ISO duration string."
39013901
write(failMsg, *) "Output did not match duration set in string."
3902-
call ESMF_TimeIntervalSet(timeInterval1, timeIntervalString="P1Y2M3DT4H5M6S", rc=rc)
3902+
call ESMF_TimeIntervalSet(timeInterval1, timeIntervalString="P1Y2M3DT4H5M6.1S", rc=rc)
39033903
!call ESMF_TimeIntervalGet(timeInterval1, s=S, sN=sN, sD=sD, rc=rc)
39043904
call ESMF_Test((rc .eq. ESMF_SUCCESS), &
39053905
name, failMsg, result, ESMF_SRCLINE)

0 commit comments

Comments
 (0)