x_comp_hconfig_i4 Function

private function x_comp_hconfig_i4(hconfig, key, defaultValue, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_HConfig), intent(in) :: hconfig
character(len=*), intent(in) :: key
integer(kind=ESMF_KIND_I4), intent(in), optional :: defaultValue
integer, intent(out) :: rc

Return Value integer(kind=ESMF_KIND_I4)


Source Code

  function x_comp_hconfig_i4(hconfig, key, defaultValue, rc)
    ! return value
    integer(ESMF_KIND_I4) :: x_comp_hconfig_i4
    ! arguments
    type(ESMF_HConfig), intent(in)              :: hconfig
    character(*), intent(in)                    :: key
    integer(ESMF_KIND_I4), intent(in), optional :: defaultValue
    integer, intent(out)                        :: rc
    ! local variables
    logical :: isPresent
    logical :: check

    rc = ESMF_SUCCESS
    x_comp_hconfig_i4 = 0

    isPresent = ESMF_HConfigIsDefined(hconfig, keyString=key, rc=rc)
    if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
      line=__LINE__, file=__FILE__)) return

    if (isPresent) then
      x_comp_hconfig_i4 = ESMF_HConfigAsI4(hconfig, keyString=key, &
        asOkay=check, rc=rc)
      if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
        line=__LINE__, file=__FILE__)) return
      if (.not.check) then
        call ESMF_LogSetError(ESMF_RC_NOT_VALID, &
          msg="XDATA: Value cannot be converted to I4 - "//trim(key), &
          line=__LINE__, file=__FILE__, rcToReturn=rc)
        return
      endif
    elseif (present(defaultValue)) then
      x_comp_hconfig_i4 = defaultValue
    else
      call ESMF_LogSetError(ESMF_RC_NOT_FOUND, &
        msg="XDATA: Key not found - "//trim(key), &
        line=__LINE__, file=__FILE__, rcToReturn=rc)
      return
    endif
  endfunction x_comp_hconfig_i4