ESMF_TimeIntervalGetDurCalTyp Subroutine

private subroutine ESMF_TimeIntervalGetDurCalTyp(timeinterval, calkindflagIn, keywordEnforcer, yy, yy_i8, mm, mm_i8, d, d_i8, h, m, s, s_i8, ms, us, ns, d_r8, h_r8, m_r8, s_r8, ms_r8, us_r8, ns_r8, sN, sN_i8, sD, sD_i8, startTime, calendar, calkindflag, timeString, timeStringISOFrac, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_TimeInterval), intent(in) :: timeinterval
type(ESMF_CalKind_Flag), intent(in) :: calkindflagIn
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer(kind=ESMF_KIND_I4), intent(out), optional :: yy
integer(kind=ESMF_KIND_I8), intent(out), optional :: yy_i8
integer(kind=ESMF_KIND_I4), intent(out), optional :: mm
integer(kind=ESMF_KIND_I8), intent(out), optional :: mm_i8
integer(kind=ESMF_KIND_I4), intent(out), optional :: d
integer(kind=ESMF_KIND_I8), intent(out), optional :: d_i8
integer(kind=ESMF_KIND_I4), intent(out), optional :: h
integer(kind=ESMF_KIND_I4), intent(out), optional :: m
integer(kind=ESMF_KIND_I4), intent(out), optional :: s
integer(kind=ESMF_KIND_I8), intent(out), optional :: s_i8
integer(kind=ESMF_KIND_I4), intent(out), optional :: ms
integer(kind=ESMF_KIND_I4), intent(out), optional :: us
integer(kind=ESMF_KIND_I4), intent(out), optional :: ns
real(kind=ESMF_KIND_R8), intent(out), optional :: d_r8
real(kind=ESMF_KIND_R8), intent(out), optional :: h_r8
real(kind=ESMF_KIND_R8), intent(out), optional :: m_r8
real(kind=ESMF_KIND_R8), intent(out), optional :: s_r8
real(kind=ESMF_KIND_R8), intent(out), optional :: ms_r8
real(kind=ESMF_KIND_R8), intent(out), optional :: us_r8
real(kind=ESMF_KIND_R8), intent(out), optional :: ns_r8
integer(kind=ESMF_KIND_I4), intent(out), optional :: sN
integer(kind=ESMF_KIND_I8), intent(out), optional :: sN_i8
integer(kind=ESMF_KIND_I4), intent(out), optional :: sD
integer(kind=ESMF_KIND_I8), intent(out), optional :: sD_i8
type(ESMF_Time), intent(out), optional :: startTime
type(ESMF_Calendar), intent(out), optional :: calendar
type(ESMF_CalKind_Flag), intent(out), optional :: calkindflag
character(len=*), intent(out), optional :: timeString
character(len=*), intent(out), optional :: timeStringISOFrac
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_TimeIntervalGetDurCalTyp(timeinterval, calkindflagIn, &
        keywordEnforcer, &
        yy, yy_i8, &
        mm, mm_i8, &
        d, d_i8, &
        h, m, &
        s, s_i8, &
        ms, us, ns, &
        d_r8, h_r8, m_r8, s_r8, &
        ms_r8, us_r8, ns_r8, &
        sN, sN_i8, sD, sD_i8, &
        startTime, &
        calendar, calkindflag, &
        timeString, &
        timeStringISOFrac, rc)

! !ARGUMENTS:
      type(ESMF_TimeInterval), intent(in)            :: timeinterval
      type(ESMF_CalKind_Flag), intent(in)            :: calkindflagIn ! Input
      type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      integer(ESMF_KIND_I4),   intent(out), optional :: yy
      integer(ESMF_KIND_I8),   intent(out), optional :: yy_i8
      integer(ESMF_KIND_I4),   intent(out), optional :: mm
      integer(ESMF_KIND_I8),   intent(out), optional :: mm_i8
      integer(ESMF_KIND_I4),   intent(out), optional :: d
      integer(ESMF_KIND_I8),   intent(out), optional :: d_i8
      integer(ESMF_KIND_I4),   intent(out), optional :: h
      integer(ESMF_KIND_I4),   intent(out), optional :: m
      integer(ESMF_KIND_I4),   intent(out), optional :: s
      integer(ESMF_KIND_I8),   intent(out), optional :: s_i8
      integer(ESMF_KIND_I4),   intent(out), optional :: ms
      integer(ESMF_KIND_I4),   intent(out), optional :: us
      integer(ESMF_KIND_I4),   intent(out), optional :: ns
      real(ESMF_KIND_R8),      intent(out), optional :: d_r8
      real(ESMF_KIND_R8),      intent(out), optional :: h_r8
      real(ESMF_KIND_R8),      intent(out), optional :: m_r8
      real(ESMF_KIND_R8),      intent(out), optional :: s_r8
      real(ESMF_KIND_R8),      intent(out), optional :: ms_r8
      real(ESMF_KIND_R8),      intent(out), optional :: us_r8
      real(ESMF_KIND_R8),      intent(out), optional :: ns_r8
      integer(ESMF_KIND_I4),   intent(out), optional :: sN
      integer(ESMF_KIND_I8),   intent(out), optional :: sN_i8
      integer(ESMF_KIND_I4),   intent(out), optional :: sD
      integer(ESMF_KIND_I8),   intent(out), optional :: sD_i8
      type(ESMF_Time),         intent(out), optional :: startTime
      type(ESMF_Calendar),     intent(out), optional :: calendar
      type(ESMF_CalKind_Flag), intent(out), optional :: calkindflag
      character (len=*),       intent(out), optional :: timeString
      character (len=*),       intent(out), optional :: timeStringISOFrac
      integer,                 intent(out), optional :: rc

!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
!     Gets the value of {\tt timeinterval} in units specified by the
!     user via Fortran optional arguments.
!
!     The ESMF Time Manager represents and manipulates time internally with
!     integers to maintain precision.  Hence, user-specified floating point
!     values are converted internally from integers.
!
!     Units are bound (normalized) to the next larger unit specified.  For
!     example, if a time interval is defined to be one day, then
!     {\tt ESMF\_TimeIntervalGet(d = days, s = seconds)} would return
!       {\tt days = 1}, {\tt seconds = 0},
!     whereas {\tt ESMF\_TimeIntervalGet(s = seconds)} would return
!       {\tt seconds = 86400}.
!
!     For timeString, converts {\tt ESMF\_TimeInterval}'s value into
!     partial ISO 8601 format PyYmMdDThHmMs[:n/d]S.  See ~\cite{ISO} and
!     ~\cite{ISOnotes}.  See also method {\tt ESMF\_TimeIntervalPrint()}.
!
!     For timeStringISOFrac, converts {\tt ESMF\_TimeInterval}'s value into
!     full ISO 8601 format PyYmMdDThHmMs[.f]S.  See ~\cite{ISO} and
!     ~\cite{ISOnotes}.  See also method {\tt ESMF\_TimeIntervalPrint()}.
!
!     The arguments are:
!     \begin{description}
!     \item[timeinterval]
!          The object instance to query.
!     \item[calkindflagIn]
!          INPUT argument:  Alternate to, and mutually exclusive with,
!          calendarIn above.  More convenient way of specifying a built-in
!          calendar kind.
!     \item[{[yy]}]
!          Integer year (32-bit).
!     \item[{[yy\_i8]}]
!          Integer year (large, 64-bit).
!     \item[{[mm]}]
!          Integer month (32-bit).
!     \item[{[mm\_i8]}]
!          Integer month (large, 64-bit).
!     \item[{[d]}]
!          Integer Julian day, or Modified Julian day (32-bit).
!     \item[{[d\_i8]}]
!          Integer Julian day, or Modified Julian day (large, 64-bit).
!     \item[{[h]}]
!          Integer hour.
!     \item[{[m]}]
!          Integer minute.
!     \item[{[s]}]
!          Integer second (32-bit).
!     \item[{[s\_i8]}]
!          Integer second (large, 64-bit).
!     \item[{[ms]}]
!          Integer millisecond.
!     \item[{[us]}]
!          Integer microsecond.
!     \item[{[ns]}]
!          Integer nanosecond.
!     \item[{[d\_r8]}]
!          Double precision day.
!     \item[{[h\_r8]}]
!          Double precision hour.
!     \item[{[m\_r8]}]
!          Double precision minute.
!     \item[{[s\_r8]}]
!          Double precision second.
!     \item[{[ms\_r8]}]
!          Double precision millisecond.
!     \item[{[us\_r8]}]
!          Double precision microsecond.
!     \item[{[ns\_r8]}]
!          Double precision nanosecond.
!     \item[{[sN]}]
!          Integer numerator of fractional second (sN/sD).
!     \item[{[sN\_i8]}]
!          Integer numerator of fractional second (sN\_i8/sD\_i8)
!                                                           (large, 64-bit).
!     \item[{[sD]}]
!          Integer denominator of fractional second (sN/sD).
!     \item[{[sD\_i8]}]
!          Integer denominator of fractional second (sN\_i8/sD\_i8)
!                                                           (large, 64-bit).
!     \item[{[startTime]}]
!          Starting time, if set, of an absolute calendar interval
!          (yy, mm, and/or d).
!     \item[{[calendar]}]
!          Associated {\tt Calendar}, if any.
!     \item[{[calkindflag]}]
!          Associated {\tt CalKind\_Flag}, if any.
!     \item[[{timeString]}]
!          \begin{sloppypar}
!          Convert time interval value to format string PyYmMdDThHmMs[:n/d]S,
!          where n/d is numerator/denominator of any fractional seconds and
!          all other units are in ISO 8601 format.  See ~\cite{ISO} and
!          ~\cite{ISOnotes}.  See also method
!          {\tt ESMF\_TimeIntervalPrint()}.
!          \end{sloppypar}
!     \item[{[timeStringISOFrac]}]
!          Convert time interval value to strict ISO 8601 format string
!          PyYmMdDThHmMs[.f], where f is decimal form of any fractional
!          seconds.  See ~\cite{ISO} and ~\cite{ISOnotes}. See also method
!          {\tt ESMF\_TimeIntervalPrint()}.
!     \item[{[rc]}]
!          Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOP
! !REQUIREMENTS:
!     TMG1.1

      ! temp time string for C++ to fill
      character (len=ESMF_MAXSTR) :: tempTimeString, tempTimeStringISOFrac

      ! initialize time string lengths to zero for non-existent time string
      integer :: timeStringLen, timeStringLenISOFrac
      integer :: tempTimeStringLen, tempTimeStringLenISOFrac
      integer :: localrc                        ! local return code

      ! Assume failure until success
      if (present(rc)) rc = ESMF_RC_NOT_IMPL
      localrc = ESMF_RC_NOT_IMPL

      ! check inputs
      ESMF_INIT_CHECK_SHALLOW_SHORT(ESMF_TimeIntervalGetInit,timeinterval,rc)

      timeStringLen = 0
      timeStringLenISOFrac = 0
      tempTimeStringLen = 0
      tempTimeStringLenISOFrac = 0

      ! if used, get length of given timeString for C++ validation
      if (present(timeString)) then
        timeStringLen = len(timeString)
      end if
      if (present(timeStringISOFrac)) then
        timeStringLenISOFrac = len(timeStringISOFrac)
      end if

      ! use optional args for any subset
      call c_ESMC_TimeIntervalGetDurCalTyp(timeinterval, yy, yy_i8, mm, mm_i8, &
                                  d, d_i8, h, m, s, s_i8, ms, &
                                  us, ns, d_r8, h_r8, m_r8, s_r8, ms_r8, &
                                  us_r8, ns_r8, sN, sN_i8, sD, sD_i8, &
                                  startTime, calendar, calkindflag, &
                                  calkindflagIn, &
                                  timeStringLen, tempTimeStringLen, &
                                  tempTimeString, &
                                  timeStringLenISOFrac, &
                                  tempTimeStringLenISOFrac, &
                                  tempTimeStringISOFrac, localrc)
      if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

      ! copy temp time string back to given time string to restore
      !   native Fortran storage style
      if (present(timeString)) then
        timeString = tempTimeString(1:tempTimeStringLen)
      endif
      if (present(timeStringISOFrac)) then
        timeStringISOFrac = tempTimeStringISOFrac(1:tempTimeStringLenISOFrac)
      endif
    
      ! mark outputs as successfully initialized
      call ESMF_TimeInit(startTime)
      call ESMF_CalendarSetInitCreated(calendar)

      ! Return success
      if (present(rc)) rc = ESMF_SUCCESS
      end subroutine ESMF_TimeIntervalGetDurCalTyp