ESMF_ParseDurString Subroutine

private subroutine ESMF_ParseDurString(timeIntervalString, yy_i8, mm_i8, d_i8, d_r8, h_r8, m_r8, s_i8, s_r8, rc)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: timeIntervalString
integer(kind=ESMF_KIND_I8), intent(out) :: yy_i8
integer(kind=ESMF_KIND_I8), intent(out) :: mm_i8
integer(kind=ESMF_KIND_I8), intent(out) :: d_i8
real(kind=ESMF_KIND_R8), intent(out) :: d_r8
real(kind=ESMF_KIND_R8), intent(out) :: h_r8
real(kind=ESMF_KIND_R8), intent(out) :: m_r8
integer(kind=ESMF_KIND_I8), intent(out) :: s_i8
real(kind=ESMF_KIND_R8), intent(out) :: s_r8
integer, intent(out), optional :: rc

Calls

proc~~esmf_parsedurstring~~CallsGraph proc~esmf_parsedurstring ESMF_ParseDurString proc~esmf_logfounderror ESMF_LogFoundError proc~esmf_parsedurstring->proc~esmf_logfounderror proc~esmf_logseterror ESMF_LogSetError proc~esmf_parsedurstring->proc~esmf_logseterror proc~esmf_parsedurdatestring ESMF_ParseDurDateString proc~esmf_parsedurstring->proc~esmf_parsedurdatestring proc~esmf_parsedurtimestring ESMF_ParseDurTimeString proc~esmf_parsedurstring->proc~esmf_parsedurtimestring esmf_breakpoint esmf_breakpoint proc~esmf_logfounderror->esmf_breakpoint proc~esmf_logrc2msg ESMF_LogRc2Msg proc~esmf_logfounderror->proc~esmf_logrc2msg proc~esmf_logwrite ESMF_LogWrite proc~esmf_logfounderror->proc~esmf_logwrite proc~esmf_logseterror->esmf_breakpoint proc~esmf_logseterror->proc~esmf_logrc2msg proc~esmf_logseterror->proc~esmf_logwrite proc~esmf_parsedurdatestring->proc~esmf_logseterror proc~esmf_parsedurtimestring->proc~esmf_logseterror c_esmc_loggeterrormsg c_esmc_loggeterrormsg proc~esmf_logrc2msg->c_esmc_loggeterrormsg c_esmc_vmwtime c_esmc_vmwtime proc~esmf_logwrite->c_esmc_vmwtime proc~esmf_logclose ESMF_LogClose proc~esmf_logwrite->proc~esmf_logclose proc~esmf_logflush ESMF_LogFlush proc~esmf_logwrite->proc~esmf_logflush proc~esmf_logopenfile ESMF_LogOpenFile proc~esmf_logwrite->proc~esmf_logopenfile proc~esmf_utiliounitflush ESMF_UtilIOUnitFlush proc~esmf_logwrite->proc~esmf_utiliounitflush proc~esmf_utilstring2array ESMF_UtilString2Array proc~esmf_logwrite->proc~esmf_utilstring2array proc~esmf_logclose->proc~esmf_logflush proc~esmf_logflush->proc~esmf_utiliounitflush proc~esmf_utilarray2string ESMF_UtilArray2String proc~esmf_logflush->proc~esmf_utilarray2string proc~esmf_logopenfile->proc~esmf_utiliounitflush proc~esmf_utiliounitget ESMF_UtilIOUnitGet proc~esmf_logopenfile->proc~esmf_utiliounitget

Called by

proc~~esmf_parsedurstring~~CalledByGraph proc~esmf_parsedurstring ESMF_ParseDurString proc~esmf_timeintervalsetstr ESMF_TimeIntervalSetStr proc~esmf_timeintervalsetstr->proc~esmf_parsedurstring proc~esmf_timeintervalsetstrcal ESMF_TimeIntervalSetStrCal proc~esmf_timeintervalsetstrcal->proc~esmf_parsedurstring proc~esmf_timeintervalsetstrcaltyp ESMF_TimeIntervalSetStrCalTyp proc~esmf_timeintervalsetstrcaltyp->proc~esmf_parsedurstring proc~esmf_timeintervalsetstrstart ESMF_TimeIntervalSetStrStart proc~esmf_timeintervalsetstrstart->proc~esmf_parsedurstring interface~esmf_timeintervalset ESMF_TimeIntervalSet interface~esmf_timeintervalset->proc~esmf_timeintervalsetstr interface~esmf_timeintervalset->proc~esmf_timeintervalsetstrcal interface~esmf_timeintervalset->proc~esmf_timeintervalsetstrcaltyp interface~esmf_timeintervalset->proc~esmf_timeintervalsetstrstart

Source Code

subroutine ESMF_ParseDurString(timeintervalString, &
        yy_i8, mm_i8, d_i8, d_r8, &
        h_r8, m_r8, s_i8, s_r8, rc)

        character(*),            intent(in)  :: timeIntervalString  
        integer(ESMF_KIND_I8),   intent(out)  :: yy_i8
        integer(ESMF_KIND_I8),   intent(out)  :: mm_i8
        integer(ESMF_KIND_I8),   intent(out)  :: d_i8
        real(ESMF_KIND_R8),      intent(out)  :: d_r8
        real(ESMF_KIND_R8),      intent(out)  :: h_r8
        real(ESMF_KIND_R8),      intent(out)  :: m_r8
        integer(ESMF_KIND_I8),   intent(out)  :: s_i8        
        real(ESMF_KIND_R8),      intent(out)  :: s_r8
        integer,                 intent(out), optional :: rc

        integer :: localrc
        integer :: beg_loc, end_loc
        integer :: t_loc

        ! Init output to 0
        ! NOTE: Need to do all of these here in case date or time parsing isn't done below
        yy_i8=0
        mm_i8=0
        d_i8=0
        d_r8=0.0
        h_r8=0.0
        m_r8=0.0
        s_r8=0.0
        s_i8=0
        
      ! Make sure P is there and find beginning of string
      beg_loc=INDEX(timeIntervalString,"P")

      ! Complain if it doesn't start with P
      if (beg_loc < 1) then
          call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_VALUE, &
               msg=" ISO 8601 duration strings need to begin with: P", &
               ESMF_CONTEXT, rcToReturn=rc)
           return           
      endif

      ! Advance to slot after P
      beg_loc=beg_loc+1

      ! See if T is there and if so where
      t_loc=0
      t_loc=INDEX(timeIntervalString,"T")

      ! Figure out end_loc
      if (t_loc == 0) then
         ! No times, so end is the end of the string
         end_loc=LEN(timeIntervalString)
      else
         ! There are times so end is right before t
         end_loc=t_loc-1
      endif

      
      ! If not empty, parse just the date part of the string
      if (beg_loc <= end_loc) then
         call ESMF_ParseDurDateString(timeintervalString(beg_loc:end_loc), &
              yy_i8, mm_i8, d_i8, d_r8, rc=localrc)
         if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
              ESMF_CONTEXT, rcToReturn=rc)) return      
      endif

      
      ! If there are times, then parse those
      if (t_loc > 0) then

         ! Begin is after t
         beg_loc=t_loc+1

         ! End is end of string
         end_loc=LEN(timeIntervalString)
         
         ! If not empty, parse just the time part of the string
         if (beg_loc <= end_loc) then
            call ESMF_ParseDurTimeString(timeintervalString(beg_loc:end_loc), &
                 h_r8, m_r8, s_i8, s_r8, rc=localrc)
            if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
                 ESMF_CONTEXT, rcToReturn=rc)) return      
         endif         
      endif
      

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