createTestMesh3x3Cart_1 Subroutine

subroutine createTestMesh3x3Cart_1(mesh, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Mesh), intent(out) :: mesh
integer :: rc

Calls

proc~~createtestmesh3x3cart_1~~CallsGraph proc~createtestmesh3x3cart_1 createTestMesh3x3Cart_1 interface~esmf_meshcreate ESMF_MeshCreate proc~createtestmesh3x3cart_1->interface~esmf_meshcreate interface~esmf_vmget ESMF_VMGet proc~createtestmesh3x3cart_1->interface~esmf_vmget proc~esmf_vmgetglobal ESMF_VMGetGlobal proc~createtestmesh3x3cart_1->proc~esmf_vmgetglobal proc~esmf_meshcreate1part ESMF_MeshCreate1Part interface~esmf_meshcreate->proc~esmf_meshcreate1part proc~esmf_meshcreate3part ESMF_MeshCreate3Part interface~esmf_meshcreate->proc~esmf_meshcreate3part proc~esmf_meshcreateeasyelems1type ESMF_MeshCreateEasyElems1Type interface~esmf_meshcreate->proc~esmf_meshcreateeasyelems1type proc~esmf_meshcreateeasyelemsgen ESMF_MeshCreateEasyElemsGen interface~esmf_meshcreate->proc~esmf_meshcreateeasyelemsgen proc~esmf_meshcreatefromdg ESMF_MeshCreateFromDG interface~esmf_meshcreate->proc~esmf_meshcreatefromdg proc~esmf_meshcreatefromfile ESMF_MeshCreateFromFile interface~esmf_meshcreate->proc~esmf_meshcreatefromfile proc~esmf_meshcreatefromgrid ESMF_MeshCreateFromGrid interface~esmf_meshcreate->proc~esmf_meshcreatefromgrid proc~esmf_meshcreatefrommeshes ESMF_MeshCreateFromMeshes interface~esmf_meshcreate->proc~esmf_meshcreatefrommeshes proc~esmf_meshcreatefrompointer ESMF_MeshCreateFromPointer interface~esmf_meshcreate->proc~esmf_meshcreatefrompointer proc~esmf_meshcreateredist ESMF_MeshCreateRedist interface~esmf_meshcreate->proc~esmf_meshcreateredist proc~esmf_vmgetdefault ESMF_VMGetDefault interface~esmf_vmget->proc~esmf_vmgetdefault proc~esmf_vmgetpetspecific ESMF_VMGetPetSpecific interface~esmf_vmget->proc~esmf_vmgetpetspecific

Called by

proc~~createtestmesh3x3cart_1~~CalledByGraph proc~createtestmesh3x3cart_1 createTestMesh3x3Cart_1 proc~test_cartmeshtomesh_2nd test_CartMeshToMesh_2nd proc~test_cartmeshtomesh_2nd->proc~createtestmesh3x3cart_1 program~esmf_xgridutest ESMF_XGridUTest program~esmf_xgridutest->proc~test_cartmeshtomesh_2nd

Source Code

subroutine createTestMesh3x3Cart_1(mesh, rc)
  type(ESMF_Mesh), intent(out) :: mesh
  integer :: rc

  integer, pointer :: nodeIds(:),nodeOwners(:)
  real(ESMF_KIND_R8), pointer :: nodeCoords(:)
  real(ESMF_KIND_R8), pointer :: ownedNodeCoords(:)
  integer :: numNodes, numOwnedNodes, numOwnedNodesTst
   integer :: numElems,numOwnedElemsTst
  integer :: numElemConns, numTriElems, numQuadElems
  real(ESMF_KIND_R8), pointer :: elemCoords(:)
  integer, pointer :: elemIds(:),elemTypes(:),elemConn(:)
  integer, pointer :: elemMask(:)
  integer :: petCount, localPet
  type(ESMF_VM) :: vm


  ! get global VM
  call ESMF_VMGetGlobal(vm, rc=rc)
  if (rc /= ESMF_SUCCESS) return
  call ESMF_VMGet(vm, localPet=localPet, petCount=petCount, rc=rc)
  if (rc /= ESMF_SUCCESS) return

   ! return with an error if not 1 or 2 PETs
  if ((petCount /= 1) .and. (petCount /=2)) then
     rc=ESMF_FAILURE
     return
   endif


  ! Setup mesh info depending on the 
  ! number of PETs
  if (petCount .eq. 1) then

     ! Fill in node data
     numNodes=16

     !! node ids
     allocate(nodeIds(numNodes))
     nodeIds=(/1,2,3,4,5,6,7,8, &
                9,10,11,12,13,14,&
               15,16/) 
     
     !! node Coords
     allocate(nodeCoords(numNodes*2))
     nodeCoords=(/0.0,0.0, & ! 1
                 1.0,0.0, &  ! 2
                 2.0,0.0, &  ! 3
                 3.0,0.0, &  ! 4
                 0.0,1.0, &  ! 5
                 1.0,1.0, &  ! 6
                 2.0,1.0, &  ! 7
                 3.0,1.0, &  ! 8
                  0.0,2.0, &  ! 9
                 1.0,2.0, &  ! 10
                 2.0,2.0, &  ! 11
                 3.0,2.0, &  ! 12
                 0.0,3.0, &  ! 13
                  1.0,3.0, &  ! 14
                 2.0,3.0, &  ! 15
                 3.0,3.0 /)  ! 16
 

      !! node owners
      allocate(nodeOwners(numNodes))
      nodeOwners=0 ! everything on proc 0


      ! Fill in elem data
      numTriElems=2
      numQuadElems=8
       numElems=numTriElems+numQuadElems
      numElemConns=3*numTriElems+4*numQuadElems

      !! elem ids
      allocate(elemIds(numElems))
      elemIds=(/1,2,3,4,5,6,7,8,9,10/) 


      !! elem types
      allocate(elemTypes(numElems))
      elemTypes=(/ESMF_MESHELEMTYPE_QUAD, & ! 1
                  ESMF_MESHELEMTYPE_QUAD, & ! 2
                  ESMF_MESHELEMTYPE_QUAD, & ! 3
                  ESMF_MESHELEMTYPE_QUAD, & ! 4
                  ESMF_MESHELEMTYPE_QUAD, & ! 5
                  ESMF_MESHELEMTYPE_QUAD, & ! 6
                  ESMF_MESHELEMTYPE_QUAD, & ! 7
                  ESMF_MESHELEMTYPE_QUAD, & ! 8
                  ESMF_MESHELEMTYPE_TRI,  & ! 9
                  ESMF_MESHELEMTYPE_TRI/)   ! 10

      !! elem coords
      allocate(elemCoords(2*numElems))
      elemCoords=(/0.5,0.5, & ! 1
                   1.5,0.5, & ! 2
                   2.5,0.5, & ! 3
                   0.5,1.5, & ! 4
                   1.5,1.5, & ! 5
                   2.5,1.5, & ! 6
                   0.5,2.5, & ! 7
                   1.5,2.5, & ! 8
                   2.75,2.25,& ! 9
                    2.25,2.75/)  ! 10

      !! elem conn
      allocate(elemConn(numElemConns))
      elemConn=(/1,2,6,5,   & ! 1
                 2,3,7,6,   & ! 2
                 3,4,8,7,   & ! 3
                 5,6,10,9,  & ! 4
                 6,7,11,10, & ! 5
                 7,8,12,11, & ! 6
                 9,10,14,13, & ! 7
                 10,11,15,14, & ! 8
                 11,12,16, & ! 9
                  11,16,15/) ! 10

   else if (petCount .eq. 2) then
     ! Setup mesh data depending on PET
     if (localPet .eq. 0) then
 
     ! Fill in node data
     numNodes=8

     !! node ids
     allocate(nodeIds(numNodes))
     nodeIds=(/1,2,3,4,5,6,7,8/)
     
     !! node Coords
     allocate(nodeCoords(numNodes*2))
     nodeCoords=(/0.0,0.0, &  ! 1
                  1.0,0.0, &  ! 2
                  2.0,0.0, &  ! 3
                  3.0,0.0, &  ! 4
                  0.0,1.0, &  ! 5
                  1.0,1.0, &  ! 6
                  2.0,1.0, &  ! 7
                  3.0,1.0/)   ! 8 

      !! node owners
      allocate(nodeOwners(numNodes))
      nodeOwners=0 ! everything on proc 0

      ! Fill in elem data
      numTriElems=0
      numQuadElems=3
      numElems=numTriElems+numQuadElems
      numElemConns=3*numTriElems+4*numQuadElems

      !! elem ids
       allocate(elemIds(numElems))
      elemIds=(/1,2,3/) 


      !! elem types
      allocate(elemTypes(numElems))
      elemTypes=(/ESMF_MESHELEMTYPE_QUAD, & ! 1
                  ESMF_MESHELEMTYPE_QUAD, & ! 2
                  ESMF_MESHELEMTYPE_QUAD/)  ! 3

      !! elem coords
      allocate(elemCoords(2*numElems))
      elemCoords=(/0.5,0.5, & ! 1
                   1.5,0.5, & ! 2
                   2.5,0.5/)  ! 3

      !! elem conn
      allocate(elemConn(numElemConns))
      elemConn=(/1,2,6,5, & ! 1
                 2,3,7,6, & ! 2
                 3,4,8,7/)  ! 2
           

     else if (localPet .eq. 1) then

     ! Fill in node data
      numNodes=12

     !! node ids
     allocate(nodeIds(numNodes))
     nodeIds=(/5,6,7,8,9,10,11,12,13,14,15,16/)
     
     !! node Coords
     allocate(nodeCoords(numNodes*2))
     nodeCoords=(/0.0,1.0, &  ! 5
                 1.0,1.0, &  ! 6
                 2.0,1.0, &  ! 7
                 3.0 ,1.0, &  ! 8
                 0.0,2.0, &  ! 9
                 1.0,2.0, &  ! 10
                 2.0,2.0, &  ! 11
                 3.0,2.0, &  ! 12
                 0.0,3.0, &  ! 13
                 1.0,3.0, &  ! 14
                 2.0,3.0, &  ! 15
                 3.0,3.0 /)  ! 16


 

      !! node owners
       allocate(nodeOwners(numNodes))
      nodeOwners=(/0, & ! 5
                   0, & ! 6
                   0, & ! 7
                   0, & ! 8
                   1, & ! 9
                   1, & ! 10
                   1, & ! 11                  
                   1, & ! 12
                   1, & ! 13
                   1, & ! 14
                   1, & ! 15
                   1/)  ! 16 

      ! Fill in elem data
      numTriElems=2
      numQuadElems=5
      numElems=numTriElems+numQuadElems
      numElemConns=3*numTriElems+4*numQuadElems
 
      !! elem ids
      allocate(elemIds(numElems))
      elemIds=(/4,5,6,7,8,9,10/)

      !! elem types
      allocate(elemTypes(numElems))
      elemTypes=(/ESMF_MESHELEMTYPE_QUAD, & ! 4
                  ESMF_MESHELEMTYPE_QUAD, & ! 5
                  ESMF_MESHELEMTYPE_QUAD, & ! 6
                  ESMF_MESHELEMTYPE_QUAD, & ! 7 
                  ESMF_MESHELEMTYPE_QUAD, & ! 8
                  ESMF_MESHELEMTYPE_TRI, & ! 9
                  ESMF_MESHELEMTYPE_TRI/)  ! 10

      !! elem coords
      allocate(elemCoords(2*numElems))
      elemCoords=(/0.5,1.5, & ! 4
                  1.5,1.5, & ! 5
                  2.5,1.5, & ! 6
                  0.5,2.5, & ! 7
                  1.5,2.5, & ! 8
                  2.75,2.25,& ! 9
                  2.25,2.75/)  ! 10


      !! elem conn
      allocate(elemConn(numElemConns))
      elemConn=(/1,2,6,5,  & ! 4
                 2,3,7,6,  & ! 5
                 3,4,8,7,  & ! 6
                 5,6,10,9, & ! 7
                 6,7,11,10, & ! 8
                 7,8,12,    & ! 9
                 7,12,11/)    ! 10
      endif
   endif

   ! Create Mesh structure in 1 step
   mesh=ESMF_MeshCreate(parametricDim=2,spatialDim=2, &
        coordSys=ESMF_COORDSYS_CART, &
        nodeIds=nodeIds, nodeCoords=nodeCoords, &
        nodeOwners=nodeOwners, elementIds=elemIds, &
        elementTypes=elemTypes, elementConn=elemConn, &
         elementCoords=elemCoords, rc=rc)
   if (rc /= ESMF_SUCCESS) return

   ! deallocate node data
   deallocate(nodeIds)
   deallocate(nodeCoords)
   deallocate(nodeOwners)
   
   ! deallocate elem data
   deallocate(elemIds)
   deallocate(elemTypes)
   deallocate(elemCoords)
   deallocate(elemConn)

end subroutine createTestMesh3x3Cart_1