subroutine ESMF_TimeIntervalSetStrCal(timeinterval, calendar, &
timeIntervalString, rc)
! !ARGUMENTS:
type(ESMF_TimeInterval), intent(inout) :: timeinterval
type(ESMF_Calendar), intent(in) :: calendar
character(*), intent(in) :: timeIntervalString
integer, intent(out), optional :: rc
!
!
! !DESCRIPTION:
! Sets the value of an {\tt ESMF\_TimeInterval} using a
! string in ISO 8601 duration format P[y]Y[mm]M[d]DT[h]H[m]M[s]S. See ~\cite{ISO} and ~\cite{ISOnotes} for
! information about the format. Also, see the description for the method
! {\tt ESMF\_TimeIntervalSetStr()}~\ref{API:TimeIntervalSetStr}
! for the specific types supported by ESMF for the values in the duration string.
!
! The arguments are:
! \begin{description}
! \item[timeinterval]
! The object instance to initialize.
! \item[calendar]
! {\tt Calendar} used to give better definition to
! calendar interval (yy, mm, and/or d) for arithmetic, comparison,
! and conversion operations. Allows calendar interval to "float"
! across all times on a specific calendar. Default = NULL;
! if startTime also not specified, calendar interval "floats" across
! all calendars and times. Mutually exclusive with startTime since
! it contains a calendar. Alternate to, and mutually exclusive with,
! calkindflag below. Primarily for specifying a custom calendar kind.
! \item[timeIntervalString]
! ISO 8601 format duration string (e.g. P[y]Y[mm]M[d]DT[h]H[m]M[s]S).
! \item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOP
! !REQUIREMENTS:
! TMGn.n.n
integer :: localrc ! local return code
integer(ESMF_KIND_I8) :: yy_i8
integer(ESMF_KIND_I8) :: mm_i8
integer(ESMF_KIND_I8) :: d_i8
integer(ESMF_KIND_I8) :: s_i8
real(ESMF_KIND_R8) :: d_r8
real(ESMF_KIND_R8) :: h_r8
real(ESMF_KIND_R8) :: m_r8
real(ESMF_KIND_R8) :: s_r8
! Assume failure until success
if (present(rc)) rc = ESMF_RC_NOT_IMPL
localrc = ESMF_RC_NOT_IMPL
! Parse string into values for each time unit
call ESMF_ParseDurString(timeintervalString, &
yy_i8=yy_i8, mm_i8=mm_i8, d_i8=d_i8, d_r8=d_r8, &
h_r8=h_r8, m_r8=m_r8, s_i8=s_i8, s_r8=s_r8, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set time interval using time unit values parsed above
! NOTE: Just use I8 for integer values, since it looks like integer values
! are stored that way anyway. Also, for times (h,m,s), it looks like both R8
! and I8 are added together, so you can just
! use both and whichever isn't needed set to 0.
! An R8 can exactly represent an I4, so just use R8 for hours and minutes
! where an I4 is all that's available.
call ESMF_TimeIntervalSetDurCal(timeinterval, calendar, &
yy_i8=yy_i8, &
mm_i8=mm_i8, &
d_i8=d_i8, &
s_i8=s_i8, &
d_r8=d_r8, &
h_r8=h_r8, &
m_r8=m_r8, &
s_r8=s_r8, &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Return success
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_TimeIntervalSetStrCal