subroutine ESMF_GeomGet(geom, &
dimCount, rank, localDECount, distgrid, &
distgridToGridMap, indexFlag, geomtype, &
grid, staggerloc, mesh, meshloc, locstream, &
xgrid, xgridside, gridIndex,rc)
!
! !ARGUMENTS:
type(ESMF_Geom), intent(in) :: geom
integer, intent(out), optional :: dimCount
integer, intent(out), optional :: rank
integer, intent(out), optional :: localDECount
type(ESMF_DistGrid), intent(out), optional :: distgrid
integer, intent(out), optional :: distgridToGridMap(:)
type(ESMF_Index_Flag), intent(out), optional :: indexflag
type(ESMF_GeomType_Flag), intent(out), optional :: geomtype
type(ESMF_Grid), intent(out), optional :: grid
type(ESMF_StaggerLoc), intent(out), optional :: staggerloc
type(ESMF_Mesh), intent(out), optional :: mesh
type(ESMF_MeshLoc), intent(out), optional :: meshloc
type(ESMF_LocStream), intent(out), optional :: locstream
type(ESMF_XGrid), intent(out), optional :: xgrid
type(ESMF_XGridSide_Flag), intent(out), optional :: xgridside
integer, intent(out), optional :: gridIndex
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! Get various types of information about a Geom.
!
!The arguments are:
!\begin{description}
!\item[{geom}]
! Geom to get the information from.
!\item[{[dimCount]}]
! The full number of dimensions of the Distgrid object underneath the Geom object.
! \item[{[rank]}]
! The count of the memory dimensions in this Geom object.
! Typically it's the same as dimCount.
! However, in some cases (e.g. arbitrarily distributed grids) it can be different.
!\item[{[localDECount]}]
! The number of DEs in this Geom object on this PET.
!\item[{[distgrid]}]
! The structure describing the distribution of the Geom object.
!\item[{[distgridToGridMap]}]
! List that has as many elements as the distgrid dimCount. This array describes
! mapping between the Geom object's dimensions and its Distgrid.
! \item[{[indexflag]}]
! Flag that indicates how the DE-local indices are to be defined.
! \item [{[geomtype]}]
! The type of geometry on which the Field is built. See
! section~\ref{const:geomtype} for the range of values.
! \item[{[grid]}]
! If the Geom object holds a Grid, then this will pass out that Grid object.
! \item[{[staggerloc]}]
! If the Geom object holds a Grid, then this will pass out the staggerloc.
! \item[{[mesh]}]
! If the Geom object holds a Mesh, then this will pass out that Mesh object.
! \item[{[meshloc]}]
! If the Geom object holds a Mesh, then this will pass out the meshloc.
! \item[{[locstream]}]
! If the Geom object holds a LocStream, then this will pass out that LocStream object.
! \item[{[xgrid]}]
! If the Geom object holds an XGrid, then this will pass out that XGrid object.
! \item[{[xgridSide]}]
! If the Geom object holds an XGrid, then this will pass out the XGrid side.
! \item[{[gridIndex]}]
! If the Geom object holds an XGrid, then this will pass out the gridIndex.
!\item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!\end{description}
!
!EOP
type(ESMF_GeomClass),pointer :: gbcp
type(ESMF_XGridGeomBase) :: xgrid_geom
type(ESMF_Distgrid) :: localDistgrid
type(ESMF_DELayout) :: localDelayout
integer :: localrc
integer :: i
! Initialize return code; assume failure until success is certain
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Check init status of arguments
ESMF_INIT_CHECK_DEEP_SHORT(ESMF_GeomGetInit, geom, rc)
! Get GeomClass
gbcp=>geom%gbcp
! get type
if (present(geomtype)) then
geomtype=gbcp%type
endif
! Get grid object plus error checking
if (present(grid)) then
if (gbcp%type==ESMF_GEOMTYPE_GRID) then
grid=gbcp%grid
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Grid not geometry type", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
! Get mesh object plus error checking
if (present(mesh)) then
if (gbcp%type==ESMF_GEOMTYPE_Mesh) then
mesh=gbcp%mesh
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Mesh not geometry type", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
! Get locstream object plus error checking
if (present(locstream)) then
if (gbcp%type==ESMF_GEOMTYPE_LOCSTREAM) then
locstream=gbcp%locstream
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" LocStream not geometry type", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
! Get xgrid object plus error checking
if (present(xgrid)) then
if (gbcp%type==ESMF_GEOMTYPE_XGRID) then
xgrid=gbcp%xgrid
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" XGrid not geometry type", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
! Get objects plus error checking
if (present(staggerloc)) then
if (gbcp%type==ESMF_GEOMTYPE_GRID) then
staggerloc=gbcp%staggerloc
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Grid not geometry type", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
! Get objects plus error checking
if (present(meshloc)) then
if (gbcp%type==ESMF_GEOMTYPE_MESH) then
meshloc=gbcp%meshloc
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Grid not geometry type", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
if (present(dimCount).or. present(rank).or. &
present(localDECount).or.present(distgrid).or. &
present(distgridToGridMap).or.present(indexflag)) then
! Get info depending on type
select case(gbcp%type%type)
case (ESMF_GEOMTYPE_GRID%type) ! Grid
call ESMF_GridGet(grid=gbcp%grid, &
dimCount=dimCount, localDECount=localDECount, &
distgridToGridMap=distgridToGridMap, &
indexflag=indexFlag, rank=rank, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_GridGet(grid=gbcp%grid, staggerloc=gbcp%staggerloc, &
distgrid=distgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_MESH%type) ! Mesh
! Get distgrid
if (gbcp%meshloc == ESMF_MESHLOC_NODE) then
call ESMF_MeshGet(mesh=gbcp%mesh, &
nodalDistgrid=localDistgrid, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
else if (gbcp%meshloc == ESMF_MESHLOC_ELEMENT) then
call ESMF_MeshGet(mesh=gbcp%mesh, &
elementDistgrid=localDistgrid, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Bad Mesh Location value", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(dimCount)) then
call ESMF_DistGridGet(localDistgrid, &
dimCount=dimCount, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(rank)) then
call ESMF_DistGridGet(localDistgrid, &
dimCount=rank, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(localDECount)) then
call ESMF_DistGridGet(localDistgrid, &
delayout=localDeLayout, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_DELayoutGet(localDelayout, &
localDECount=localDECount, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(distgridToGridMap)) then
do i=1,size(distgridToGridMap)
distgridToGridMap(i)=i
enddo
endif
! Distgrid
if (present(distgrid)) then
if (gbcp%meshloc == ESMF_MESHLOC_NODE) then
call ESMF_MeshGet(mesh=gbcp%mesh, &
nodalDistgrid=distgrid, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
else if (gbcp%meshloc == ESMF_MESHLOC_ELEMENT) then
call ESMF_MeshGet(mesh=gbcp%mesh, &
elementDistgrid=distgrid, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
else
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Bad Mesh Location value", &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
if (present(indexFlag)) indexFlag = ESMF_INDEX_DELOCAL
case (ESMF_GEOMTYPE_LOCSTREAM%type) ! LocStream
if (present(dimCount)) dimCount = 1
if (present(rank)) rank = 1
if (present(distgridToGridMap)) distgridToGridMap = 1
call ESMF_LocStreamGet(gbcp%locstream, distgrid=distgrid, &
localDECount=localDECount, indexflag=indexflag, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_XGRID%type) ! XGrid
if(gbcp%xgridside == ESMF_XGRIDSIDE_BALANCED) then
if (present(dimCount)) dimCount = 1
if (present(rank)) rank = 1
if (present(distgridToGridMap)) distgridToGridMap = 1
if (present(localDECount)) then
call ESMF_DistGridGet(gbcp%xgrid%xgtypep%distgridM, delayout=localdelayout, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_DelayoutGet(localdelayout, localDECount=localDECount, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
else
call ESMF_XGridGet(gbcp%xgrid, xgrid_geom, xgridSide=gbcp%xgridSide, &
gridindex=gbcp%xgridindex, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_XGridGeomBaseGet(xgrid_geom, &
dimCount=dimCount, localDeCount=localDECount, distgrid=distgrid, &
distgridToGridMap=distgridToGridMap, indexFlag=indexFlag, &
grid=grid, staggerloc=staggerloc, mesh=mesh, meshloc=meshloc, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! For XGrid rank=dimCount, but we need to call in separately because
! dimCount keyword is used above
if (present(rank)) then
call ESMF_XGridGeomBaseGet(xgrid_geom, dimCount=rank, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
endif
! Get distgrid
if (present(distgrid)) then
call ESMF_XGridGet(gbcp%xgrid, gridIndex=gbcp%xgridindex, &
xgridSide=gbcp%xgridSide, &
distgrid=distgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
if (present(indexFlag)) indexFlag = ESMF_INDEX_DELOCAL
if (present(xgridside)) xgridside=gbcp%xgridside
if (present(gridIndex)) gridIndex=gbcp%xgridIndex
case default
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Bad type value", &
ESMF_CONTEXT, rcToReturn=rc)) return
end select
endif
! Set return value
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_GeomGet