Skip to content

Particles between actual non-rectangular grid and rectangular envelope of grid search forever before failing #2428

@willirath

Description

@willirath

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:
LAB60 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triageIssue that has not been reviewed by a Parcels team member

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions