function ESMF_MeshCreateDual(mesh, rc)
!
!
! !RETURN VALUE:
type(ESMF_Mesh) :: ESMF_MeshCreateDual
! !ARGUMENTS:
type(ESMF_Mesh), intent(in) :: mesh
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! Create the dual of an existing mesh.
!
! \begin{description}
! \item [mesh]
! The source Mesh.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOPI
!------------------------------------------------------------------------------
integer :: localrc
type(ESMF_MeshStatus_Flag) :: status
integer :: numNode, numElem
! Init localrc
localrc = ESMF_SUCCESS
! Check input classes
ESMF_INIT_CHECK_DEEP(ESMF_MeshGetInit, mesh, rc)
! If mesh has not been fully created
call C_ESMC_MeshGetStatus(mesh, status)
if (status .ne. ESMF_MESHSTATUS_COMPLETE) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_OBJ_WRONG, &
msg="- the mesh has not been fully created", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
! Call into C
call C_ESMC_MeshCreateDual(mesh, ESMF_MeshCreateDual, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! these should be set inside MeshCap
! Create node distgrid and get number of nodes
call C_ESMC_MeshCreateNodeDistGrid(ESMF_MeshCreateDual, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call C_ESMC_MeshCreateElemDistGrid(ESMF_MeshCreateDual, localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Set as created
ESMF_INIT_SET_CREATED(ESMF_MeshCreateDual)
if (present(rc)) rc=ESMF_SUCCESS
return
end function ESMF_MeshCreateDual