Parcels version
< 4
Description
(This is a bug in older parcels versions but as we're still running some v3 for production, I'm finding myself patching index search .h files. So I still want to report here.)
A colleague (@elenagebauer) is running Parcels experiments in nested fields on these grids:

(from https://doi.org/10.5194/gmd-13-4959-2020) and finds particles from just outside the western boundary of the finest nested grid searching all the way up to int maxIterSearch = 1e6 until they finally realize they're supposed look in the next coarser grid.
This is due to the fact that
|
if (zonal_periodic == 0){ |
|
if ((x < xy_minmax[0]) || (x > xy_minmax[1])){ |
|
if (xgrid[0][0] < xgrid[0][xdim-1]) {return ERROROUTOFBOUNDS;} |
|
else if (x < xgrid[0][0] && x > xgrid[0][xdim-1]) {return ERROROUTOFBOUNDS;} |
|
} |
|
} |
|
if ((y < xy_minmax[2]) || (y > xy_minmax[3])) |
|
return ERROROUTOFBOUNDS; |
only checks if a particle is out of the rectanugular envelope of the grid (as defined by
xy_minmax) and then goes on to look for its grid point forever.
A possible fix is to really check if a particle is outside the tight envelope of the grid before searching. @elenagebauer and I are currently working on a point-in-polygon check for failing fast on non-global grids. We'll feed this back once we got it right.
Parcels version
< 4
Description
(This is a bug in older parcels versions but as we're still running some v3 for production, I'm finding myself patching index search .h files. So I still want to report here.)
A colleague (@elenagebauer) is running Parcels experiments in nested fields on these grids:

(from https://doi.org/10.5194/gmd-13-4959-2020) and finds particles from just outside the western boundary of the finest nested grid searching all the way up to
int maxIterSearch = 1e6until they finally realize they're supposed look in the next coarser grid.This is due to the fact that
Parcels/parcels/include/index_search.h
Lines 351 to 358 in 1ce5908
only checks if a particle is out of the rectanugular envelope of the grid (as defined by
xy_minmax) and then goes on to look for its grid point forever.A possible fix is to really check if a particle is outside the tight envelope of the grid before searching. @elenagebauer and I are currently working on a point-in-polygon check for failing fast on non-global grids. We'll feed this back once we got it right.