subroutine ESMF_DistGridGetIds(distgrid, Ids, rc)
type(ESMF_DistGrid), intent(in) :: distgrid
integer, intent(out) :: Ids(:)
integer, intent(out), optional :: rc
type(ESMF_DELayout) :: delayout
integer :: localDeCount,lDE,numDEIDs
integer :: startPos
integer :: localrc
! Get delayout from distgrid
call ESMF_DistGridGet(distgrid, delayout=delayout, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Get local number of DEs
call ESMF_DELayoutGet(delayout, localDECount=localDECount, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Iterate summing number of DEs
startPos=1
do lDE=0,localDECount-1
call ESMF_DistGridGet(distgrid,localDe=lDE, &
elementCount=numDEIds, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if (numDEIds >0) then
call ESMF_DistGridGet(distgrid,localDe=lDE, &
seqIndexList=Ids(startPos:startPos+numDEIds-1), rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
startPos=startPos+numDEIds
enddo
end subroutine ESMF_DistGridGetIds