[GRASS-SVN] r73312 - grass-addons/grass7/raster/r.spread.sod

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 10 19:36:57 PDT 2018


Author: wenzeslaus
Date: 2018-09-10 19:36:57 -0700 (Mon, 10 Sep 2018)
New Revision: 73312

Modified:
   grass-addons/grass7/raster/r.spread.sod/CHANGELOG.md
   grass-addons/grass7/raster/r.spread.sod/main.cpp
Log:
r.spread.sod: use GRASS lib function for random seed value, not C++ lib one

The C++ function/class has deterministic results with MinGW on MS Windows.

Sync to commit 33fff3c, lanternfly branch of
https://github.com/ncsu-landscape-dynamics/r.spread.pest/


Modified: grass-addons/grass7/raster/r.spread.sod/CHANGELOG.md
===================================================================
--- grass-addons/grass7/raster/r.spread.sod/CHANGELOG.md	2018-09-11 01:53:16 UTC (rev 73311)
+++ grass-addons/grass7/raster/r.spread.sod/CHANGELOG.md	2018-09-11 02:36:57 UTC (rev 73312)
@@ -20,6 +20,11 @@
 ### Fixed
 
 - Current month is now checked if it is in the season (Vaclav Petras)
+ - Fixes #1 (Metadata - missing full command used).
+- GRASS GIS library function now used to generate random seed (Vaclav Petras)
+ - Previous implementation didn't give non-deterministic outputs with
+   the -s flag on MS Windows.
+ - Fixes #2 (Stochastic runs with -s are always the same on Windows).
 
 ## 2018-06-21 - Critical Temperature
 

Modified: grass-addons/grass7/raster/r.spread.sod/main.cpp
===================================================================
--- grass-addons/grass7/raster/r.spread.sod/main.cpp	2018-09-11 01:53:16 UTC (rev 73311)
+++ grass-addons/grass7/raster/r.spread.sod/main.cpp	2018-09-11 02:36:57 UTC (rev 73312)
@@ -708,9 +708,10 @@
         G_verbose_message(_("Read random seed from %s option: %ud"),
                           opt.seed->key, seed_value);
     } else {
-        // flag of option is required
-        std::random_device rd;
-        seed_value = rd();
+        // flag or option is required, so no check needed
+        // getting random seed using GRASS library
+        // std::random_device is deterministic in MinGW (#338)
+        seed_value = G_srand48_auto();
         G_verbose_message(_("Generated random seed (-%c): %ud"),
                           flg.generate_seed->key, seed_value);
     }



More information about the grass-commit mailing list