ESMF_GridToMeshCell Function

public function ESMF_GridToMeshCell(grid, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Grid), intent(in) :: grid
integer, intent(out), optional :: rc

Return Value type(ESMF_Mesh)


Source Code

   function ESMF_GridToMeshCell(grid, rc)
!
!
! !RETURN VALUE:
    type(ESMF_Mesh)                               :: ESMF_GridToMeshCell
!
! !ARGUMENTS:
    type(ESMF_Grid), intent(in)                :: grid
    integer, intent(out) , optional               :: rc
!
! !DESCRIPTION:
!   Create a mesh object with the same topology as the grid.
!
!   \begin{description}
!   \item [grid]
!         The grid to copy.
!   \item [{[rc]}]
!         Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOPI
!------------------------------------------------------------------------------
    integer :: localrc
    type(ESMF_Pointer) :: theMesh
    type(ESMF_Index_Flag) :: indexflag
    type(ESMF_CoordSys_Flag) :: coordSys
    integer :: dimCount

    localrc = ESMF_SUCCESS

    ! Error check Grid
    call ESMF_GridGet(grid, indexflag=indexflag, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return

    call c_esmc_gridtomeshcell(grid, theMesh, localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

    ESMF_GridToMeshCell = ESMF_MeshCreate(theMesh)

    ! Set these here, eventually this will happen automatically internally inside ESMF_MeshCreate()
    call ESMF_GridGet(grid,              &
                      coordSys=coordSys, &
                      dimCount=dimCount, &
                      rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
            ESMF_CONTEXT, rcToReturn=rc)) return

    if (present(rc)) rc = ESMF_SUCCESS

    end function ESMF_GridToMeshCell