subroutine ESMF_XGridGeomBaseGet(gridbase, &
dimCount, localDECount, distgrid, &
distgridToGridMap, indexFlag, geomtype, &
grid, staggerloc, mesh, meshloc, rc)
!
! !ARGUMENTS:
type(ESMF_XGridGeomBase), intent(in) :: gridbase
integer, intent(out), optional :: dimCount
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_XGridGeomType_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
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! Gets various types of information about a grid.
!
!The arguments are:
!\begin{description}
!\item[{gridbase}]
! Gridbase to get the information from.
!\item[{[dimCount]}]
! DimCount of the GeomBase object (e.g. the number of dimensions in the Array
! it will be mapped to (e.g. Mesh=1)).
!\item[{[localDECount]}]
! The number of DEs in this grid on this PET.
!\item[{[distgrid]}]
! The structure describing the distribution of the grid.
!\item[{[distgridToGridMap]}]
! List that has as many elements as the distgrid dimCount. This array describes
! mapping between the grids dimensions and the distgrid.
! \item[{[indexflag]}]
! Flag that indicates how the DE-local indices are to be defined.
! \item[{[geomtype]}]
! Flag that indicates what type of object this gridbase holds.
! Can be {\tt ESMF_XGRIDGEOMTYPE_GRID}, {\tt ESMF_XGRIDGEOMTYPE_MESH},...
! \item[{[grid]}]
! The Grid object that this gridbase object holds.
! \item[{[staggerloc]}]
! The Grid stagger location.
! \item[{[mesh]}]
! The Mesh object that this gridbase object holds.
! \item[{[meshloc]}]
! The part of the mesh that the field is on
!\item[{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!\end{description}
!
!EOPI
type(ESMF_XGridGeomBaseClass),pointer :: gbcp
integer :: localrc
! 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_XGridGeomBaseGetInit, gridbase, rc)
! Get GeomBaseClass
gbcp=>gridbase%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_XGRIDGEOMTYPE_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_XGRIDGEOMTYPE_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 objects plus error checking
if (present(staggerloc)) then
if (gbcp%type==ESMF_XGRIDGEOMTYPE_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_XGRIDGEOMTYPE_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
! Get info depending on type
select case(gbcp%type%type)
case (ESMF_XGRIDGEOMTYPE_GRID%type) ! Grid
call ESMF_GridGet(grid=gbcp%grid, &
dimCount=dimCount, localDECount=localDECount, &
distgridToGridMap=distgridToGridMap, &
indexflag=indexFlag, 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_XGRIDGEOMTYPE_MESH%type) ! Mesh
if (present(dimCount)) dimCount = 1
if (present(localDECount)) localDECount = 1
if (present(distgridToGridMap)) distgridToGridMap = 1
! 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 default
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Bad type value", &
ESMF_CONTEXT, rcToReturn=rc)) return
end select
! Set return value
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_XGridGeomBaseGet