x_comp_hconfig_r8 Function

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

Arguments

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

Return Value real(kind=ESMF_KIND_R8)


Source Code

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

    rc = ESMF_SUCCESS
    x_comp_hconfig_r8 = 0.0_ESMF_KIND_R8

    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_r8 = ESMF_HConfigAsR8(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 R8 - "//trim(key), &
          line=__LINE__, file=__FILE__, rcToReturn=rc)
        return
      endif
    elseif (present(defaultValue)) then
      x_comp_hconfig_r8 = 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_r8