[GRASS-SVN] r71419 - in grass/trunk/raster/r.sim: r.sim.sediment r.sim.water simlib

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 19 13:54:53 PDT 2017


Author: annakrat
Date: 2017-08-19 13:54:53 -0700 (Sat, 19 Aug 2017)
New Revision: 71419

Modified:
   grass/trunk/raster/r.sim/r.sim.sediment/main.c
   grass/trunk/raster/r.sim/r.sim.water/main.c
   grass/trunk/raster/r.sim/simlib/hydro.c
Log:
r.sim: fix when openmp is not available

Modified: grass/trunk/raster/r.sim/r.sim.sediment/main.c
===================================================================
--- grass/trunk/raster/r.sim/r.sim.sediment/main.c	2017-08-19 20:46:08 UTC (rev 71418)
+++ grass/trunk/raster/r.sim/r.sim.sediment/main.c	2017-08-19 20:54:53 UTC (rev 71419)
@@ -375,7 +375,11 @@
       threads, abs(threads));
       threads = abs(threads);
     }
+#if defined(_OPENMP)
     omp_set_num_threads(threads);
+#else
+    threads = 1;
+#endif
     G_message(_("Number of threads: %d"), threads);
 
     /*      sscanf(parm.nwalk->answer, "%d", &wp.maxwa); */

Modified: grass/trunk/raster/r.sim/r.sim.water/main.c
===================================================================
--- grass/trunk/raster/r.sim/r.sim.water/main.c	2017-08-19 20:46:08 UTC (rev 71418)
+++ grass/trunk/raster/r.sim/r.sim.water/main.c	2017-08-19 20:54:53 UTC (rev 71419)
@@ -403,7 +403,11 @@
       threads, abs(threads));
       threads = abs(threads);
     }
+#if defined(_OPENMP)
     omp_set_num_threads(threads);
+#else
+    threads = 1;
+#endif
     G_message(_("Number of threads: %d"), threads);
 
     /* if no rain map input, then: */

Modified: grass/trunk/raster/r.sim/simlib/hydro.c
===================================================================
--- grass/trunk/raster/r.sim/simlib/hydro.c	2017-08-19 20:46:08 UTC (rev 71418)
+++ grass/trunk/raster/r.sim/simlib/hydro.c	2017-08-19 20:54:53 UTC (rev 71419)
@@ -25,7 +25,6 @@
 
 #include <grass/waterglobs.h>
 #include <grass/simlib.h>
-
 /*
  * Soeren 8. Mar 2011 TODO:
  * Put all these global variables into several meaningful structures and 
@@ -270,12 +269,16 @@
 
 #pragma omp parallel firstprivate(l,lw,k,decr,d1,hhc,velx,vely,eff,gaux,gauy)//nwalka
 {
+#if defined(_OPENMP)
         int steps = (int)((((double)nwalk) / ((double) omp_get_num_threads())) + 0.5);
         int tid = omp_get_thread_num();
         int min_loop = tid * steps;
         int max_loop = ((tid + 1) * steps) > nwalk ? nwalk : (tid + 1) * steps;
 
 	    for (lw = min_loop; lw < max_loop; lw++) {
+#else
+        for (lw = 0; lw < nwalk; lw++) {
+#endif
 		if (w[lw][2] > EPS) {	/* check the walker weight */
 		    ++nwalka;
 		    l = (int)((w[lw][0] + stxm) / stepx) - mx - 1;
@@ -312,7 +315,12 @@
 			gama[k][l] += (addac * w[lw][2]);	/* add walker weigh to water depth or conc. */
 
 			d1 = gama[k][l] * conn;
+#if defined(_OPENMP)
 			gasdev_for_paralel(&gaux, &gauy);
+#else
+			gaux = gasdev();
+			gauy = gasdev();
+#endif
 			hhc = pow(d1, 3. / 5.);
 
 			if (hhc > hhmax && wdepth == NULL) {	/* increased diffusion if w.depth > hhmax */



More information about the grass-commit mailing list