x_comp_hconfig_logical Function

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

Arguments

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

Return Value logical


Source Code

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

    rc = ESMF_SUCCESS
    x_comp_hconfig_logical = .false.

    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_logical = ESMF_HConfigAsLogical(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 Logical - "//trim(key), &
          line=__LINE__, file=__FILE__, rcToReturn=rc)
        return
      endif
    elseif (present(defaultValue)) then
      x_comp_hconfig_logical = 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_logical