string_to_integer_date Function

public function string_to_integer_date(time_string, unusable, rc) result(date)

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_date~~CallsGraph proc~string_to_integer_date string_to_integer_date proc~mapl_return MAPL_Return proc~string_to_integer_date->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_date~~CalledByGraph proc~string_to_integer_date string_to_integer_date proc~string_to_esmf_time string_to_esmf_time proc~string_to_esmf_time->proc~string_to_integer_date proc~test_string_to_integer_date_delimiters test_string_to_integer_date_delimiters proc~test_string_to_integer_date_delimiters->proc~string_to_integer_date none~new_extdataconfig_from_yaml ExtDataConfig%new_ExtDataConfig_from_yaml none~new_extdataconfig_from_yaml->proc~string_to_esmf_time proc~new_extdataoldtypescreator new_ExtDataOldTypesCreator proc~new_extdataoldtypescreator->none~new_extdataconfig_from_yaml

Source Code

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

      integer :: date
      integer ypos(2), mpos(2), dpos(2)
      integer strlen
      integer firstdash, lastdash
      integer year,month,day

      _UNUSED_DUMMY(unusable)

      strlen = LEN_TRIM (time_string)

      firstdash = index(time_string, '-')
      lastdash  = index(time_string, '-', BACK=.TRUE.)

      if (firstdash .LE. 0 .OR. lastdash .LE. 0) then
        _RETURN(_FAILURE)
      endif

      ypos(2) = firstdash - 1
      mpos(1) = firstdash + 1
      ypos(1) = ypos(2) - 3

      mpos(2) = lastdash - 1
      dpos(1) = lastdash + 1
      dpos(2) = dpos(1) + 1

      read ( time_string(ypos(1):ypos(2)), * ) year
      read ( time_string(mpos(1):mpos(2)), * ) month
      read ( time_string(dpos(1):dpos(2)), * ) day

      date = year*10000+month*100+day
      _RETURN(_SUCCESS)

   end function string_to_integer_date