Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions raster/r.sim/r.sim.water/testsuite/test_r_sim_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TestRSimWater(TestCase):
dx = "tmp_dx"
dy = "tmp_dy"
depth = "tmp_depth"
depth2 = "tmp_depth2"
discharge = "tmp_discharge"
diff_depth = "tmp_diff_depth"
diff_discharge = "tmp_diff_discharge"
Expand Down Expand Up @@ -132,6 +133,7 @@ def test_nodxdy(self):
depth=self.depth,
discharge=self.discharge,
random_seed=1,
nprocs=1,
)

# Assert that the output rasters exist
Expand All @@ -158,6 +160,21 @@ def test_nodxdy(self):
stats = tools.r_univar(map=self.diff_discharge, format="json")
self.assertAlmostEqual(stats["sum"], 0, delta=1e-3)

# test parallelized dxdy
# lower precision because parallelization affects random number generator
self.assertModule(
"r.sim.water",
elevation=self.elevation,
depth=self.depth2,
random_seed=1,
nprocs=2,
)
self.assertRastersEqual(
self.depth2,
reference=self.reference_depth_default,
precision="0.02",
)

def test_complex(self):
"""Test r.sim.water execution with more complex inputs"""
# Run the r.sim.water simulation
Expand Down
5 changes: 5 additions & 0 deletions raster/r.sim/simlib/derivatives.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ void derivatives(const Geometry *geometry, float **elevation, double **dx,
H = (geometry->stepx / geometry->conv) * 8.0;
V = (geometry->stepy / geometry->conv) * 8.0;

#if defined(_OPENMP)
#pragma omp parallel for default(none) schedule(static) \
shared(geometry, elevation, dx, dy, H, V) \
private(col, c1, c2, c3, c4, c5, c6, c7, c8, c9)
#endif
for (row = 0; row < geometry->my; row++) {
for (col = 0; col < geometry->mx; col++) {

Expand Down
Loading