subroutine test6(rc)
integer, intent(out) :: rc
integer :: localrc, i, npet
type(ESMF_XGrid) :: xgrid
!type(ESMF_Field) :: field
type(ESMF_VM) :: vm
real(ESMF_KIND_R8) :: xgrid_area(12), B_area(2,2)
rc = ESMF_SUCCESS
localrc = ESMF_SUCCESS
call ESMF_VMGetCurrent(vm=vm, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_VMGet(vm, petcount=npet, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Sew mesh
! right, left
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,2,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,2,0.5,1.,4.,0.,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,0.7,0.7,0.,0.,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_XGridDestroy(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! up, down
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,4,0.5,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,4,1.,1.,0.,-4.,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,1.,1.,0.,-4.,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_XGridDestroy(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! mix mesh and grid together
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,4,0.6,1.,3.5,3.5,rc=localrc)/), &
sideAGrid=(/make_grid_sph(4,4,1.,1.,-3.,0.,rc=localrc), &
make_grid_sph(4,4,1.,1.,-6.,0.,rc=localrc), &
make_grid_sph(4,4,1.,1.,-9.,0.,rc=localrc) /), &
sideBGrid=(/make_grid_sph(8,8,1.,1.,-7.,0.,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,1.,1.,0.,0.,rc=localrc)/), &
storeOverlay = .true., &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_XGridDestroy(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,4,0.6,1.,3.5,3.5,rc=localrc)/), &
sideAGrid=(/make_grid_sph(16,4,1.,1.,-3.,0.,rc=localrc), &
make_grid_sph(16,4,1.,1.,-6.,0.,rc=localrc), &
make_grid_sph(16,4,1.,1.,-9.,0.,rc=localrc) /), &
sideBGrid=(/make_grid_sph(8,8,1.,1.,-7.,0.,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,1.,1.,0.,0.,rc=localrc)/), &
sideAGridPriority=(/5,1,3/), &
sideAMeshPriority=(/4,2/), &
storeOverlay = .true., &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_XGridDestroy(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! partially overlap
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,4,0.6,1.,3.5,3.5,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,1.,1.,0.,0.,rc=localrc)/), &
storeOverlay = .true., &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
!field=ESMF_FieldCreate(xgrid%xgtypep%sideA(1)%gbcp%mesh, meshloc=ESMF_MESHLOC_ELEMENT, &
! typekind=ESMF_TYPEKIND_R8, rc=localrc)
!if (ESMF_LogFoundError(localrc, &
! ESMF_ERR_PASSTHRU, &
! ESMF_CONTEXT, rcToReturn=rc)) return
call flux_exchange_sph_mesh(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,4,0.6,1.,2.9,3.5,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,1.,1.,0.,0.,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call flux_exchange_sph_mesh(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,4,0.6,1.,2.9,2.5,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,1.,1.,0.,0.,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call flux_exchange_sph_mesh(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(8,4,0.6,1.,1.9,1.5,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,1.,1.,0.,0.,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! partially overlap subject bigger cell
xgrid = ESMF_XGridCreate(sideAMesh=(/ &
make_mesh_sph(4,4,0.5,1.,2.8,1.4,rc=localrc), &
make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc) &
/), &
sideBMesh=(/make_mesh_sph(30,30,0.3,0.3,0.,0.,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call flux_exchange_sph_mesh(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh= &
(/make_mesh_sph(30,30,0.3,0.3,0.,0.,rc=localrc)/), &
sideBMesh=(/ &
make_mesh_sph(4,4,0.5,1.,2.8,1.4,rc=localrc), &
make_mesh_sph(4,4,1.,1.,0.,0.,rc=localrc) &
/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call flux_exchange_sph_mesh(xgrid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
if(npet == 1) then
! complicated merging
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,2,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,2,0.5,1.,4.,0.,rc=localrc), &
make_mesh_sph(4,2,1.,1.,6.,0.,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,0.7,0.7,0.,0.,rc=localrc), &
make_mesh_sph(8,8,0.7,0.7,0.,5.6,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,2,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,2,0.5,1.,3.,0.3,rc=localrc), &
make_mesh_sph(4,4,1.,1.,-2.,-2.,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,0.7,0.7,0.,0.,rc=localrc), &
make_mesh_sph(8,8,0.7,0.7,0.,5.6,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh=&
(/make_mesh_sph(8,8,0.7,0.7,0.,0.,rc=localrc), &
make_mesh_sph(8,8,0.7,0.7,0.,5.6,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(4,2,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,2,0.5,1.,3.,0.3,rc=localrc), &
make_mesh_sph(4,4,1.,1.,-2.,-2.,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
xgrid = ESMF_XGridCreate(sideAMesh=(/make_mesh_sph(4,2,1.,1.,0.,0.,rc=localrc), &
make_mesh_sph(4,2,0.5,1.,3.,0.3,rc=localrc), &
make_mesh_sph(4,4,1.,1.,-2.,-2.,rc=localrc)/), &
sideBMesh=(/make_mesh_sph(8,8,0.7,0.7,0.,0.,rc=localrc), &
make_mesh_sph(8,8,0.5,0.7,0.9,3.6,rc=localrc)/), &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
endif
end subroutine test6