subroutine ESMF_AttributeGetCountGrid(target, count, keywordEnforcer, convention, purpose, attcountflag, attnestflag, rc)
! 39.11.15
type(ESMF_Grid), intent(in) :: target
integer, intent(out) :: count
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer ! must use keywords below
character(len=*), intent(in), optional :: convention
character(len=*), intent(in), optional :: purpose
type(ESMF_AttGetCountFlag), intent(in), optional :: attcountflag
type(ESMF_AttNest_Flag), intent(in), optional :: attnestflag
integer, intent(out), optional :: rc
type(ESMF_Info) :: info
type(ESMF_AttGetCountFlag) :: l_attcountflag
type(ESMF_AttNest_Flag) :: local_attnestflag
type(ESMF_InfoDescribe) :: eidesc
integer :: countSingle, countTotal, attPackCount, localrc, attPackCountTotal
character(:), allocatable :: key
localrc = ESMF_FAILURE
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Check object initialization
ESMF_INIT_CHECK_DEEP(ESMF_GridGetInit, target, rc)
if (present(attnestflag)) then
local_attnestflag = attnestflag
else
local_attnestflag = ESMF_ATTR_DEFAULT_ATTNEST
end if
if (present(attcountflag)) then
l_attcountflag = attcountflag
else
l_attcountflag = ESMF_ATTGETCOUNT_ATTRIBUTE
end if
if (present(convention)) then
call ESMF_InfoFormatKey(key, "", localrc, convention=convention, purpose=purpose)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
else
key = ""
end if
info = eidesc%GetInfo(target, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_InfoGet(info, key=key, attrCount=countSingle, attrCountTotal=countTotal, &
attPackCount=attPackCount, attnestflag=local_attnestflag, attrCompliance=.true., &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
if (present(attcountflag)) then
l_attcountflag = attcountflag
else
l_attcountflag = ESMF_ATTGETCOUNT_ATTRIBUTE
end if
if (l_attcountflag%value==ESMF_ATTGETCOUNT_ATTRIBUTE%value) then
if (local_attnestflag%value==ESMF_ATTNEST_ON%value) then
count = countTotal
else
count = countSingle
end if
else if (l_attcountflag%value==ESMF_ATTGETCOUNT_TOTAL%value) then
count = countTotal
else if (l_attcountflag%value==ESMF_ATTGETCOUNT_ATTPACK%value) then
count = attPackCount
else
if (ESMF_LogFoundError(ESMF_RC_ARG_BAD, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, rcToReturn=rc)) return
end if
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_AttributeGetCountGrid