Skip to content

Commit

Permalink
bugfix: DIV_BY_ZERO in MatchingFunctionSpacePartitionerLonLatPolygon …
Browse files Browse the repository at this point in the history
…for small grids with OMP (#244)
  • Loading branch information
wdeconinck authored Nov 22, 2024
1 parent 893381f commit fc1cf50
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ void MatchingFunctionSpacePartitionerLonLatPolygon::partition(const Grid& grid,
ATLAS_TRACE("point-in-polygon check for entire grid (" + std::to_string(grid.size()) + " points)");
size_t num_threads = atlas_omp_get_max_threads();
size_t chunk_size = grid.size() / (1000 * num_threads);
if (chunk_size == 0) {
chunk_size = grid.size();
}
size_t chunks = num_threads == 1 ? 1 : std::max(size_t(1), size_t(grid.size()) / chunk_size);
atlas_omp_pragma(omp parallel for schedule(dynamic,1))
for( size_t chunk=0; chunk < chunks; ++chunk) {
Expand Down

0 comments on commit fc1cf50

Please sign in to comment.