subroutine ESMF_AttributeSetObjLocStreamI4(target, name, value, convention, purpose, itemcount, attnestflag, rc)
type(ESMF_LocStream), intent(inout) :: target
character(len=*), intent(in) :: name
integer(ESMF_KIND_I4), intent(in) :: value
character(len=*), intent(in), optional :: convention
character(len=*), intent(in), optional :: purpose
integer, intent(in), optional :: itemcount
type(ESMF_AttNest_Flag), intent(in), optional :: attnestflag
integer, intent(out), optional :: rc
integer :: len_key, localrc
character(:), allocatable :: key, pkey
type(ESMF_Info) :: info
type(ESMF_InfoDescribe) :: eidesc
type(ESMF_AttNest_Flag) :: local_attnestflag
logical :: is_present
localrc = ESMF_FAILURE
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Check object initialization
ESMF_INIT_CHECK_DEEP(ESMF_LocStreamGetInit, target, rc)
if (present(attnestflag)) then
local_attnestflag = attnestflag
else
local_attnestflag = ESMF_ATTR_DEFAULT_ATTNEST
end if
info = eidesc%GetInfo(target, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (local_attnestflag%value == ESMF_ATTNEST_ON%value) then
call ESMF_InfoFormatKey(pkey, "", localrc, convention=convention, purpose=purpose)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
! is_present = ESMF_InfoIsPresent(info, TRIM(pkey)//"/"//TRIM(name), attnestflag=local_attnestflag, isPointer=.true., rc=localrc)
! if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
is_present = .true.
if (is_present) then
call ESMF_InfoSet(info, name, value, force=ESMF_ATTR_DEFAULT_FORCE, pkey=pkey, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
else
if (ESMF_LogFoundError(ESMF_RC_ATTR_ITEMSOFF, msg="Attribute must be added before it is set", ESMF_CONTEXT, rcToReturn=rc)) return
endif
else
call ESMF_InfoFormatKey(key, name, localrc, convention=convention, purpose=purpose)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
! is_present = ESMF_InfoIsPresent(info, key, attnestflag=local_attnestflag, isPointer=.true., rc=localrc)
! if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
is_present = .true.
if (is_present) then
call ESMF_InfoSet(info, key, value, force=ESMF_ATTR_DEFAULT_FORCE, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
else
if (ESMF_LogFoundError(ESMF_RC_ATTR_ITEMSOFF, msg="Attribute must be added before it is set", ESMF_CONTEXT, rcToReturn=rc)) return
endif
end if
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_AttributeSetObjLocStreamI4