Hi there,
I'm running into issues with unmapped points when using ESMF (8.3.0) regridding with bilinear and patch interpolation, weirdly this is only issue for certain resolutions of the source field. The source field uses a regular lat-long grid at centre stagger locations, and the destination field uses the 'gx1v6_090205_ESMFmesh.nc' mesh at element locations.
For example a lat-long grid at 24x24 resolution works fine, but 16x16 and 32x32 have a series of unmapped points at particular latitudes. At 16x16 resolution destination points in the rough latitude range '(5.679, 5.72)' are unmapped, and at 32x32 resolution points in the latitude range `(2.818, 2.819)` are unmapped. These latitudes seems suspiciously close to the first latitude north of the equator in the source fields (5.625 and 2.8125 respectively) but this might be a coincidence.
Here's the code that I'm using to construct the lat-long grid, does anyone know what’s going on here? I can also share the rest of the code, 60ish extra lines that just create the source and destination field, set source field to 1 and dest field to 0, and then regrid.
I'm running into issues with unmapped points when using ESMF (8.3.0) regridding with bilinear and patch interpolation, weirdly this is only issue for certain resolutions of the source field. The source field uses a regular lat-long grid at centre stagger locations, and the destination field uses the 'gx1v6_090205_ESMFmesh.nc' mesh at element locations.
For example a lat-long grid at 24x24 resolution works fine, but 16x16 and 32x32 have a series of unmapped points at particular latitudes. At 16x16 resolution destination points in the rough latitude range '(5.679, 5.72)' are unmapped, and at 32x32 resolution points in the latitude range `(2.818, 2.819)` are unmapped. These latitudes seems suspiciously close to the first latitude north of the equator in the source fields (5.625 and 2.8125 respectively) but this might be a coincidence.
Here's the code that I'm using to construct the lat-long grid, does anyone know what’s going on here? I can also share the rest of the code, 60ish extra lines that just create the source and destination field, set source field to 1 and dest field to 0, and then regrid.
Code:
subroutine create_lat_lon_grid(grid, nlon, nlat, nproc_x, nproc_y, rc)
use ESMF
type(ESMF_Grid) :: grid
integer :: nlon, lat, nproc_x, nproc_y, rc
! local variables
integer :: i1, i2, clbnd(2), cubnd(2)
real :: dx, dy
real(ESMF_KIND_R8), pointer :: long_coords(:,:), lat_coords(:,:)
character(len=200) :: msgString, tmpString
dx = 360.0 / nlon
dy = 180.0 / nlat
grid = ESMF_GridCreate1PeriDim( &
! Define a regular distribution
maxIndex=(/nlon, nlat/), & ! define index space
regDecomp=(/nproc_x, nproc_y/), & ! define how to divide among DEs
! polekindflag=(/ESMF_POLEKIND_BIPOLE, ESMF_POLEKIND_BIPOLE/), &
coordDep1=(/1,2/), & ! 1st coord is 1D and depends on 1st Grid dim
coordDep2=(/1,2/), & ! 2nd coord is 1D and depends on 2nd Grid dim
indexflag=ESMF_INDEX_GLOBAL, &
coordSys=ESMF_COORDSYS_SPH_DEG, &
rc=rc)
call ESMF_GridAddCoord(grid, staggerloc=ESMF_STAGGERLOC_CENTER, rc=rc)
! dim 1 - longitude
call ESMF_GridGetCoord(grid, localDE=0, staggerLoc=ESMF_STAGGERLOC_CENTER, coordDim=1, &
computationalLBound=clbnd, computationalUBound=cubnd, farrayPtr=long_coords, rc=rc)
call ESMF_GridGetCoord(grid, localDE=0, staggerLoc=ESMF_STAGGERLOC_CENTER, coordDim=2, &
computationalLBound=clbnd, computationalUBound=cubnd, farrayPtr=lat_coords, rc=rc)
do i1=clbnd(1),cubnd(1)
do i2=clbnd(2),cubnd(2)
! Set source coordinates as 0 to 360
long_coords(i1, i2) = REAL(i1 - 1) * dx
lat_coords(i1, i2) = REAL(i2 - 0.5) * dy - 90.0
end do
end do
end subroutine create_lat_lon_grid