subroutine test_mesh_create_ee_1type(correct, rc)
type(ESMF_Mesh) :: mesh
logical :: correct
integer :: rc
integer :: numElems
real(ESMF_KIND_R8), pointer :: elemCoords(:,:)
real(ESMF_KIND_R8), pointer :: elemCornerCoords(:,:,:)
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 4 PETs
if ((petCount /= 1) .and. (petCount /=4)) then
rc=ESMF_FAILURE
return
endif
! Setup mesh info depending on the
! number of PETs
if (petCount .eq. 1) then
! Fill in elem data
numElems=4
!! elem ids
allocate(elemIds(numElems))
elemIds=(/1,3,7,9/)
!! elem coords
allocate(elemCoords(2,numElems))
elemCoords(:,1)=(/0.5,0.5/) ! 1
elemCoords(:,2)=(/2.5,0.5/) ! 3
elemCoords(:,3)=(/0.5,2.5/) ! 7
elemCoords(:,4)=(/2.5,2.5/) ! 9
!! elem corner Coords
allocate(elemCornerCoords(2,4,numElems))
elemCornerCoords(:,1,1)=(/0.0,0.0/) ! 1
elemCornerCoords(:,2,1)=(/1.0,0.0/) ! 1
elemCornerCoords(:,3,1)=(/1.0,1.0/) ! 1
elemCornerCoords(:,4,1)=(/0.0,1.0/) ! 1
elemCornerCoords(:,1,2)=(/2.0,0.0/) ! 3
elemCornerCoords(:,2,2)=(/3.0,0.0/) ! 3
elemCornerCoords(:,3,2)=(/3.0,1.0/) ! 3
elemCornerCoords(:,4,2)=(/2.0,1.0/) ! 3
elemCornerCoords(:,1,3)=(/0.0,2.0/) ! 7
elemCornerCoords(:,2,3)=(/1.0,2.0/) ! 7
elemCornerCoords(:,3,3)=(/1.0,3.0/) ! 7
elemCornerCoords(:,4,3)=(/0.0,3.0/) ! 7
elemCornerCoords(:,1,4)=(/2.0,2.0/) ! 9
elemCornerCoords(:,2,4)=(/3.0,2.0/) ! 9
elemCornerCoords(:,3,4)=(/3.0,3.0/) ! 9
elemCornerCoords(:,4,4)=(/2.0,3.0/) ! 9
else if (petCount .eq. 4) then
! Setup mesh data depending on PET
if (localPet .eq. 0) then
! Fill in elem data
numElems=1
!! elem ids
allocate(elemIds(numElems))
elemIds=(/1/)
!! elem coords
allocate(elemCoords(2,numElems))
elemCoords(:,1)=(/0.5,0.5/) ! 1
!! elem corner Coords
allocate(elemCornerCoords(2,4,numElems))
elemCornerCoords(:,1,1)=(/0.0,0.0/) ! 1
elemCornerCoords(:,2,1)=(/1.0,0.0/) ! 1
elemCornerCoords(:,3,1)=(/1.0,1.0/) ! 1
elemCornerCoords(:,4,1)=(/0.0,1.0/) ! 1
else if (localPet .eq. 1) then
! Fill in elem data
numElems=1
!! elem ids
allocate(elemIds(numElems))
elemIds=(/3/)
!! elem coords
allocate(elemCoords(2,numElems))
elemCoords(:,1)=(/2.5,0.5/) ! 3
!! elem corner Coords
allocate(elemCornerCoords(2,4,numElems))
elemCornerCoords(:,1,1)=(/2.0,0.0/) ! 3
elemCornerCoords(:,2,1)=(/3.0,0.0/) ! 3
elemCornerCoords(:,3,1)=(/3.0,1.0/) ! 3
elemCornerCoords(:,4,1)=(/2.0,1.0/) ! 3
else if (localPet .eq. 2) then
! Fill in elem data
numElems=2
!! elem ids
allocate(elemIds(numElems))
elemIds=(/7,9/)
!! elem coords
allocate(elemCoords(2,numElems))
elemCoords(:,1)=(/0.5,2.5/) ! 7
elemCoords(:,2)=(/2.5,2.5/) ! 9
!! elem corner Coords
allocate(elemCornerCoords(2,4,numElems))
elemCornerCoords(:,1,1)=(/0.0,2.0/) ! 7
elemCornerCoords(:,2,1)=(/1.0,2.0/) ! 7
elemCornerCoords(:,3,1)=(/1.0,3.0/) ! 7
elemCornerCoords(:,4,1)=(/0.0,3.0/) ! 7
elemCornerCoords(:,1,2)=(/2.0,2.0/) ! 9
elemCornerCoords(:,2,2)=(/3.0,2.0/) ! 9
elemCornerCoords(:,3,2)=(/3.0,3.0/) ! 9
elemCornerCoords(:,4,2)=(/2.0,3.0/) ! 9
else if (localPet .eq. 3) then
! Fill in elem data
numElems=0
!! elem ids
allocate(elemIds(numElems))
!! elem coords
allocate(elemCoords(2,numElems))
!! elem corner Coords
allocate(elemCornerCoords(2,4,numElems))
endif
endif
! Create Mesh structure in 1 step
mesh=ESMF_MeshCreate(parametricDim=2, &
coordSys=ESMF_COORDSYS_CART, &
elementIds=elemIds,&
elementType=ESMF_MESHELEMTYPE_QUAD,&
elementCoords=elemCoords,&
elementCornerCoords=elemCornerCoords, &
rc=rc)
if (rc /= ESMF_SUCCESS) return
! deallocate elem data
deallocate(elemIds)
deallocate(elemCoords)
deallocate(elemCornerCoords)
! Output Mesh for debugging
!call ESMF_MeshWrite(mesh,"meshee1t",rc=localrc)
!if (localrc .ne. ESMF_SUCCESS) rc=ESMF_FAILURE
! Return success
rc=ESMF_SUCCESS
end subroutine test_mesh_create_ee_1type