string_to_integer_time Function

public function string_to_integer_time(time_string, unusable, rc) result(time)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: time_string
class(KeywordEnforcer), intent(in), optional :: unusable
integer, intent(out), optional :: rc

Return Value integer


Calls

proc~~string_to_integer_time~~CallsGraph proc~string_to_integer_time string_to_integer_time proc~mapl_return MAPL_Return proc~string_to_integer_time->proc~mapl_return at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception

Called by

proc~~string_to_integer_time~~CalledByGraph proc~string_to_integer_time string_to_integer_time none~create_from_parameters ExtDataPointerUpdate%create_from_parameters none~create_from_parameters->proc~string_to_integer_time proc~string_to_esmf_time string_to_esmf_time proc~string_to_esmf_time->proc~string_to_integer_time proc~test_string_to_integer_time_delimiters test_string_to_integer_time_delimiters proc~test_string_to_integer_time_delimiters->proc~string_to_integer_time none~new_extdataconfig_from_yaml ExtDataConfig%new_ExtDataConfig_from_yaml none~new_extdataconfig_from_yaml->proc~string_to_esmf_time proc~fillin_derived ExtDataOldTypesCreator%fillin_derived proc~fillin_derived->none~create_from_parameters proc~fillin_primary ExtDataOldTypesCreator%fillin_primary proc~fillin_primary->none~create_from_parameters proc~new_extdataoldtypescreator new_ExtDataOldTypesCreator proc~new_extdataoldtypescreator->none~new_extdataconfig_from_yaml

Source Code

   function string_to_integer_time(time_string,unusable,rc) result(time)
      character(len=*), intent(in) :: time_string
      class(KeywordEnforcer), optional, intent(in) :: unusable
      integer, optional, intent(out) :: rc

      integer :: time
      integer mpos(2), hpos(2), spos(2)
      integer strlen
      integer firstcolon, lastcolon
      integer lastspace
      integer hour,min,sec

      _UNUSED_DUMMY(unusable)

      strlen = LEN_TRIM (time_string)

      firstcolon = index(time_string, ':')
      if (firstcolon .LE. 0) then

        ! If no colons, check for hour.

        ! Logic below assumes a null character or something else is after the hour
        ! if we do not find a null character add one so that it correctly parses time
        !if (time_string(strlen:strlen) /= char(0)) then
           !time_string = trim(time_string)//char(0)
           !strlen=len_trim(time_string)
        !endif
        lastspace = index(TRIM(time_string), ' ', BACK=.TRUE.)
        if ((strlen-lastspace).eq.2 .or. (strlen-lastspace).eq.3) then
          hpos(1) = lastspace+1
          hpos(2) = strlen-1
          read (time_string(hpos(1):hpos(2)), * ) hour
          min  = 0
          sec  = 0
        else
          hour = 0
          min  = 0
          sec  = 0
        endif

      else
        hpos(1) = firstcolon - 2
        hpos(2) = firstcolon - 1
        lastcolon =  index(time_string, ':', BACK=.TRUE.)
        if ( lastcolon .EQ. firstcolon ) then
          mpos(1) = firstcolon + 1
          mpos(2) = firstcolon + 2
          read (time_string(hpos(1):hpos(2)), * ) hour
          read (time_string(mpos(1):mpos(2)), * ) min
          sec = 0
        else
          mpos(1) = firstcolon + 1
          mpos(2) = lastcolon - 1
          spos(1) = lastcolon + 1
          spos(2) = lastcolon + 2
          read (time_string(hpos(1):hpos(2)), * ) hour
          read (time_string(mpos(1):mpos(2)), * ) min
          read (time_string(spos(1):spos(2)), * ) sec
        endif
      endif

      time = hour*10000+min*100+sec 
      _RETURN(_SUCCESS)

   end function string_to_integer_time