function ESMF_MeshCreateFromDG(distgrid, nodalDistgrid, parametricDim, &
spatialDim, coordSys, name, rc)
!
!
! !RETURN VALUE:
type(ESMF_Mesh) :: ESMF_MeshCreateFromDG
! !ARGUMENTS:
type(ESMF_DistGrid), intent(in) :: distgrid
type(ESMF_DistGrid), intent(in), optional :: nodalDistgrid
integer, intent(in), optional :: parametricDim
integer, intent(in), optional :: spatialDim
type(ESMF_CoordSys_Flag), intent(in), optional :: coordSys
character(len=*), intent(in), optional :: name
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! Create a Mesh from an elemental distgrid. Such a mesh will have no coordinate or
! connectivity information stored.
!
! \begin{description}
! \item [distgrid]
! The elemental distgrid.
! \item [{[nodalDistgrid]}]
! The nodal distgrid, if not specified is set to distgrid (i.e. the elemental distgrid).
! \item [{[parametricDim]}]
! Dimension of the topology of the Mesh. (E.g. a mesh constructed of squares would
! have a parametric dimension of 2, whereas a Mesh constructed of cubes would have one
! of 3.)
! \item [{[spatialDim]}]
! The number of coordinate dimensions needed to describe the locations of the nodes
! making up the Mesh. For a manifold, the spatial dimension can be larger than the
! parametric dim (e.g. the 2D surface of a sphere in 3D space), but it can't be smaller.
! \item[{[coordSys]}]
! The coordinate system of the grid coordinate data.
! For a full list of options, please see Section~\ref{const:coordsys}.
! If not specified then defaults to ESMF\_COORDSYS\_SPH\_DEG.
! \item [{[name]}]
! The name of the Mesh.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOPI
!------------------------------------------------------------------------------
integer :: localrc
integer ::l_pdim, l_sdim
type(ESMF_CoordSys_Flag) :: coordSysLocal
l_pdim = 2
l_sdim = 3
if(present(parametricDim)) l_pdim = parametricDim
if(present(spatialDim)) l_sdim = spatialDim
! Set Default coordSys
if (present(coordSys)) then
coordSysLocal=coordSys
else
coordSysLocal=ESMF_COORDSYS_SPH_DEG
endif
ESMF_MeshCreateFromDG = ESMF_MeshCreate3part(l_pdim, l_sdim, &
coordSysLocal, name=name, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set information
call c_ESMC_MeshSetElemDistGrid(ESMF_MeshCreateFromDG, distgrid, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if (present(nodalDistgrid)) then
call c_ESMC_MeshSetNodeDistGrid(ESMF_MeshCreateFromDG, nodalDistgrid, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
else
call c_ESMC_MeshSetNodeDistGrid(ESMF_MeshCreateFromDG, distgrid, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
! Set Status
call C_ESMC_MeshSetStatus(ESMF_MeshCreateFromDG, ESMF_MESHSTATUS_COMPLETE)
! Set MeshCap::isfree
call C_ESMC_MeshSetIsFree(ESMF_MeshCreateFromDG)
ESMF_INIT_SET_CREATED(ESMF_MeshCreateFromDG)
if (present(rc)) rc=ESMF_SUCCESS
return
end function ESMF_MeshCreateFromDG