[GRASS-SVN] r35039 - in grass/trunk/raster: r.random.cells r.random.surface

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 26 11:31:46 EST 2008


Author: martinl
Date: 2008-12-26 11:31:45 -0500 (Fri, 26 Dec 2008)
New Revision: 35039

Modified:
   grass/trunk/raster/r.random.cells/flag.c
   grass/trunk/raster/r.random.cells/gasdev.c
   grass/trunk/raster/r.random.cells/indep.c
   grass/trunk/raster/r.random.cells/init.c
   grass/trunk/raster/r.random.cells/local_proto.h
   grass/trunk/raster/r.random.cells/main.c
   grass/trunk/raster/r.random.cells/r.random.cells.html
   grass/trunk/raster/r.random.cells/random.c
   grass/trunk/raster/r.random.cells/ransurf.h
   grass/trunk/raster/r.random.surface/calcsd.c
   grass/trunk/raster/r.random.surface/calcsurf.c
   grass/trunk/raster/r.random.surface/cpfilter.c
   grass/trunk/raster/r.random.surface/dd.c
   grass/trunk/raster/r.random.surface/decay.c
   grass/trunk/raster/r.random.surface/digits.c
   grass/trunk/raster/r.random.surface/gasdev.c
   grass/trunk/raster/r.random.surface/gennorm.c
   grass/trunk/raster/r.random.surface/init.c
   grass/trunk/raster/r.random.surface/main.c
   grass/trunk/raster/r.random.surface/makebigf.c
   grass/trunk/raster/r.random.surface/makepp.c
   grass/trunk/raster/r.random.surface/r.random.surface.html
   grass/trunk/raster/r.random.surface/random.c
   grass/trunk/raster/r.random.surface/ransurf.h
   grass/trunk/raster/r.random.surface/save.c
   grass/trunk/raster/r.random.surface/zero.c
Log:
r.random.{surface|cells}: clean up


Modified: grass/trunk/raster/r.random.cells/flag.c
===================================================================
--- grass/trunk/raster/r.random.cells/flag.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/flag.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,8 +1,8 @@
 #include <stdlib.h>
 #include <grass/gis.h>
+
 #include "flag.h"
 
-
 void FlagClearAll(FLAG * flags)
 {
     register int r, c;

Modified: grass/trunk/raster/r.random.cells/gasdev.c
===================================================================
--- grass/trunk/raster/r.random.cells/gasdev.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/gasdev.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,13 +1,9 @@
 /* gasdev.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
+
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 /* GasDev() returns a random double with a mean of 0.0 and a standard   */
 /*      deviation of 1.0.                                               */
 double GasDev(void)
@@ -21,7 +17,7 @@
     } while (r >= 1.0);
 
     fac = sqrt(-2.0 * log(r) / r);
-    DOUBLE(v2 * fac);
+    G_debug(3, "(v2 * fac):%.12lf", v2 * fac);
 
     return (v2 * fac);
 }

Modified: grass/trunk/raster/r.random.cells/indep.c
===================================================================
--- grass/trunk/raster/r.random.cells/indep.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/indep.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,12 +1,9 @@
 /* indep.c                                                              */
+#include <grass/gis.h>
+#include <grass/glocale.h>
 
-#undef TRACE
-#undef DEBUG
-
-#include <grass/gis.h>
 #include "ransurf.h"
 
-
 void Indep(void)
 {
     int Count, DRow, DCol;
@@ -14,14 +11,15 @@
     double RowDist, RowDistSq, ColDist;
     struct History history;
 
-    FUNCTION(indep);
+    G_debug(2, "indep()");
+
     Count = 0;
     Found = 0;
 
     while (CellCount > 0) {
-	INT(CellCount);
-	INT(Count);
-	RETURN;
+	G_debug(3, "(CellCount):%d", CellCount);
+	G_debug(3, "(Count):%d", Count);
+
 	DRow = DoNext[Count].R;
 	DCol = DoNext[Count++].C;
 
@@ -37,13 +35,13 @@
 		    RowDistSq = RowDist * RowDist;
 		    for (C = DCol; C < Cs; C++) {
 			ColDist = EW * (C - DCol);
-			DOUBLE(RowDistSq);
-			DOUBLE(ColDist);
-			DOUBLE(MaxDistSq);
-			RETURN;
+			G_debug(3, "(RowDistSq):%.12lf", RowDistSq);
+			G_debug(3, "(ColDist):%.12lf", ColDist);
+			G_debug(3, "(MaxDistSq):%.12lf", MaxDistSq);
+			
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 			    }
@@ -55,7 +53,7 @@
 		}
 	    }
 
-	    FUNCTION(it1);
+	    G_debug(2, "it1()");
 	    for (R = DRow - 1; R >= 0; R--) {
 		RowDist = NS * (DRow - R);
 		if (RowDist > MaxDistSq) {
@@ -67,7 +65,7 @@
 			ColDist = EW * (C - DCol);
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 			    }
@@ -79,7 +77,7 @@
 		}
 	    }
 
-	    FUNCTION(it2);
+	    G_debug(2, "it2()");
 	    for (R = DRow; R < Rs; R++) {
 		RowDist = NS * (R - DRow);
 		if (RowDist > MaxDistSq) {
@@ -91,7 +89,7 @@
 			ColDist = EW * (DCol - C);
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 			    }
@@ -103,7 +101,7 @@
 		}
 	    }
 
-	    FUNCTION(it3);
+	    G_debug(2, "it3()");
 	    for (R = DRow - 1; R >= 0; R--) {
 		RowDist = NS * (DRow - R);
 		if (RowDist > MaxDistSq) {
@@ -115,7 +113,7 @@
 			ColDist = EW * (DCol - C);
 			if (MaxDistSq >= RowDistSq + ColDist * ColDist) {
 			    if (0 != FlagGet(Cells, R, C)) {
-				FUNCTION(unset);
+				G_debug(2, "unset()");
 				FLAG_UNSET(Cells, R, C);
 				CellCount--;
 			    }
@@ -129,18 +127,23 @@
 	}
     }
 
-    FUNCTION(outputting);
+    G_debug(2, "outputting()");
     OutFD = G_open_cell_new(Output->answer);
     if (OutFD < 0)
-	G_fatal_error("%s: unable to open new raster map [%s]",
-		      G_program_name(), Output->answer);
+	G_fatal_error(_("Unable to open raster map <%s>"),
+		      Output->answer);
 
+    G_message(_("Writing raster map <%s>..."),
+	      Output->answer);
     for (R = 0; R < Rs; R++) {
+	G_percent(R, Rs, 2);
 	for (C = 0; C < Cs; C++) {
 	    CellBuffer[C] = Out[R][C];
 	}
 	G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
     }
+    G_percent(1, 1, 1);
+    
     G_close_cell(OutFD);
     G_short_history(Output->answer, "raster", &history);
     G_command_history(&history);

Modified: grass/trunk/raster/r.random.cells/init.c
===================================================================
--- grass/trunk/raster/r.random.cells/init.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/init.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,56 +1,25 @@
 /* init.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
+
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 /* function prototypes */
 static int comp_array(const void *p1, const void *p2);
 
-
-void Init(int argc, char **argv)
+void Init()
 {
-    struct Option *SeedStuff;
     struct Cell_head Region;
     int Count;
     int FD, row, col;
     double MinRes;
 
-    FUNCTION(Init);
+    G_debug(2, "Init()");
 
-    Output = G_define_option();
-    Output->key = "output";
-    Output->type = TYPE_STRING;
-    Output->required = YES;
-    Output->multiple = NO;
-    Output->description = "Name of indepent cells map";
-    Output->gisprompt = "new,cell,raster";
-
-    Distance = G_define_option();
-    Distance->key = "distance";
-    Distance->type = TYPE_DOUBLE;
-    Distance->required = YES;
-    Distance->multiple = NO;
-    Distance->description =
-	"Input value: max. distance of spatial correlation (value(s) >= 0.0)";
-
-    SeedStuff = G_define_option();
-    SeedStuff->key = "seed";
-    SeedStuff->type = TYPE_INTEGER;
-    SeedStuff->required = NO;
-    SeedStuff->description =
-	"Input value: random seed (SEED_MIN >= value >= SEED_MAX), default [random]";
-
-    if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
-
     Rs = G_window_rows();
     Cs = G_window_cols();
     G_get_set_window(&Region);
@@ -73,7 +42,7 @@
     CellCount = 0;
     if (NULL != G_find_file("cell", "MASK", G_mapset())) {
 	if ((FD = G_open_cell_old("MASK", G_mapset())) < 0) {
-	    G_fatal_error(" unable to open MASK");
+	    G_fatal_error(_("Unable to open raster map <%s>"), "MASK");
 	}
 	else {
 	    for (row = 0; row < Rs; row++) {
@@ -99,9 +68,9 @@
 
     sscanf(Distance->answer, "%lf", &MaxDist);
     if (MaxDist < 0.0)
-	G_fatal_error("distance must be >= 0.0");
-
-    DOUBLE(MaxDist);
+	G_fatal_error(_("Distance must be >= 0.0"));
+    
+    G_debug(3, "(MaxDist):%.12lf", MaxDist);
     MaxDistSq = MaxDist * MaxDist;
     if (!SeedStuff->answer) {
 	Seed = (int)getpid();
@@ -118,9 +87,13 @@
 	    Seed += SEED_MAX - SEED_MIN;
     }
 
+    G_message(_("Generating raster map <%s>..."),
+	      Output->answer);
+
     DoNext = (CELLSORTER *) G_malloc(CellCount * sizeof(CELLSORTER));
     Count = 0;
     for (row = 0; row < Rs; row++) {
+	G_percent(row, Rs, 2);
 	for (col = 0; col < Cs; col++) {
 	    if (0 != FlagGet(Cells, row, col)) {
 		DoNext[Count].R = row;
@@ -133,6 +106,8 @@
 	    }
 	}
     }
+    G_percent(1, 1, 1);
+    
     qsort(DoNext, CellCount, sizeof(CELLSORTER), comp_array);
 }
 

Modified: grass/trunk/raster/r.random.cells/local_proto.h
===================================================================
--- grass/trunk/raster/r.random.cells/local_proto.h	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/local_proto.h	2008-12-26 16:31:45 UTC (rev 35039)
@@ -8,7 +8,7 @@
 void Indep(void);
 
 /* init.c */
-void Init(int argc, char **argv);
+void Init();
 
 /* random.c */
 double ran1(void);

Modified: grass/trunk/raster/r.random.cells/main.c
===================================================================
--- grass/trunk/raster/r.random.cells/main.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/main.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -9,19 +9,17 @@
  *               Brad Douglas <rez touchofmadness.com>, Glynn Clements <glynn gclements.plus.com>
  * PURPOSE:      generates a random sets of cells that are at least
  *               some distance apart
- * COPYRIGHT:    (C) 1999-2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 1999-2008 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
  *               for details.
  *
  *****************************************************************************/
-#undef TRACE
-#undef DEBUG
-
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+
 #include "ransurf.h"
 #include "local_proto.h"
 
@@ -35,21 +33,43 @@
 struct Flag *Verbose;
 struct Option *Distance;
 struct Option *Output;
+struct Option *SeedStuff;
 
 int main(int argc, char *argv[])
 {
     struct GModule *module;
 
-    FUNCTION(main);
-
     G_gisinit(argv[0]);
     /* Set description */
     module = G_define_module();
-    module->keywords = _("raster");
+    module->keywords = _("raster, random, cell");
     module->description =
 	_("Generates random cell values with spatial dependence.");
 
-    Init(argc, argv);
+    Output = G_define_standard_option(G_OPT_R_OUTPUT);
+
+    Distance = G_define_option();
+    Distance->key = "distance";
+    Distance->type = TYPE_DOUBLE;
+    Distance->required = YES;
+    Distance->multiple = NO;
+    Distance->description =
+	_("Maximum distance of spatial correlation (value(s) >= 0.0)");
+
+    SeedStuff = G_define_option();
+    SeedStuff->key = "seed";
+    SeedStuff->type = TYPE_INTEGER;
+    SeedStuff->required = NO;
+    SeedStuff->description =
+	_("Random seed (SEED_MIN >= value >= SEED_MAX) (default [random])");
+
+    if (G_parser(argc, argv))
+	exit(EXIT_FAILURE);
+
+    Init();
     Indep();
+    
+    G_done_msg(" ");
+    
     exit(EXIT_SUCCESS);
 }

Modified: grass/trunk/raster/r.random.cells/r.random.cells.html
===================================================================
--- grass/trunk/raster/r.random.cells/r.random.cells.html	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/r.random.cells.html	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,79 +1,93 @@
 <h2>DESCRIPTION</h2>
 
 <em>r.random.cells</em> generates a random sets of cells that are at
-least <var>distance</var> apart. The cells are numbered from 1 to the
-numbers of cells generated. Random cells will not be generated in areas
-masked off.
+least <b>distance</b> apart. The cells are numbered from 1 to the
+numbers of cells generated. Random cells will not be generated in
+areas masked off.
 
-<h2>PARAMETERS</h2>
+<h3>Parameters</h3>
 
-<b>output </b> Output map: Random cells. Each random cell has a unique
-non-zero cell value ranging from 1 to the number of cells generated. The
-heuristic for this algorithm is to randomly pick cells until there are no
-cells outside of the chosen cell's buffer of radius <b>distance</b>.
-<p>
+<dl>
+<dt><b>output</b></dt>
+<dd>Random cells. Each random cell has a unique non-zero cell value
+ranging from 1 to the number of cells generated. The heuristic for
+this algorithm is to randomly pick cells until there are no cells
+outside of the chosen cell's buffer of radius <b>distance</b>.</dd>
 
-<b>distance</b> Input value(s) [default 0.0]: <b>distance</b> determines the
-minimum distance the centers of the random cells will be apart.
-<p>
-<b>seed</b> Input value [default: random]: Specifies the random seed that
+<dt><b>distance</b></dt>
+<dd>Determines the minimum distance the centers of the random cells
+will be apart.</dd>
+
+<dt><b>seed</b></dt>
+<dd>Specifies the random seed that
 <em>r.random.cells</em> will use to generate the cells. If the random seed
 is not given,<em> r.random.cells</em> will get a seed from the process ID
-number.
+number.</dd>
 
+</dl>
+
 <h2>NOTES</h2>
 
-The original purpose for this program was to generate independent random
-samples of cells in a study area. The <b>distance</b> value is the amount of
-spatial autocorrelation for the map being studied. The amount of spatial
-autocorrelation can be determined by using <em>r.2Dcorrelogram</em> with
+The original purpose for this program was to generate independent
+random samples of cells in a study area. The <b>distance</b> value is
+the amount of spatial autocorrelation for the map being studied. 
+
+<!-- The amount of spatial autocorrelation can be determined by
+using <em>r.2Dcorrelogram</em> with
 <em>r.2Dto1D</em>, or <em>r.1Dcorrelogram</em>. With <b>distance</b> set to
 zero, the <b>output</b> map will number each non-masked cell from 1 to the
-number of non-masked cells in the study region.
+number of non-masked cells in the study region. -->
 
 <h2>REFERENCES</h2>
-Random Field Software for GRASS by Chuck Ehlschlaeger<p>
+Random Field Software for GRASS by Chuck Ehlschlaeger
 
-<p>As part of my dissertation, I put together several programs that help
+<p>
+  As part of my dissertation, I put together several programs that help
 GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope
 you find it useful and dependable. The following papers might clarify their
-use: </p>
+use:
 
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/CGFinal/paper.htm">Visualizing Spatial Data
-Uncertainty Using Animation (final draft)</a>,&quot; by Charles R.
+<ul>
+<li><a href="../../CGFinal/paper.htm">Visualizing Spatial Data
+Uncertainty Using Animation (final draft)</a>, by Charles R.
 Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to
 Computers in GeoSciences in September, 1996, accepted October, 1996 for
-publication in June, 1997. </p>
+publication in June, 1997.</li>
 
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/SDH96/paper.html">Modeling Uncertainty in Elevation Data for
-Geographical Analysis</a>&quot;, by Charles R. Ehlschlaeger, and Ashton M.
-Shortridge. Proceedings of the 7th International Symposium on Spatial Data
-Handling, Delft, Netherlands, August 1996. </p>
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/paper.html">Modeling
+Uncertainty in Elevation Data for Geographical Analysis</a>, by
+Charles R. Ehlschlaeger, and Ashton M.  Shortridge. Proceedings of the
+7th International Symposium on Spatial Data Handling, Delft,
+Netherlands, August 1996.</li>
 
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/acm/paper.html">Dealing with Uncertainty in
-Categorical Coverage Maps: Defining, Visualizing, and Managing Data
-Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild.
-Proceedings, Workshop on Geographic Information Systems at the Conference on
-Information and Knowledge Management, Gaithersburg MD, 1994. </p>
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing
+with Uncertainty in Categorical Coverage Maps: Defining, Visualizing,
+and Managing Data Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild.  Proceedings, Workshop on Geographic Information Systems at
+the Conference on Information and Knowledge Management, Gaithersburg
+MD, 1994.</li>
 
-<p>&quot;<a href="http://www.wiu.edu/users/cre111/older/gislis/gislis.html">Uncertainty in Spatial Data:
-Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles
-Ehlschlaeger and Michael Goodchild. Proceedings, GIS/LIS'94, pp. 246-253,
-Phoenix AZ, 1994. </p>
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty
+in Spatial Data: Defining, Visualizing, and Managing Data
+Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ,
+1994.</li>
+</ul>
 
 <h2>SEE ALSO</h2>
 
 <em>
-r.1Dcorrelogram, 
+<!--r.1Dcorrelogram, 
 r.2Dcorrelogram, 
-r.2Dto1D, 
+r.2Dto1D, -->
 <a href="r.random.surface.html">r.random.surface</a>,
-r.random.model, 
 <a href="r.random.html">r.random</a>
 </em> 
 
 <h2>AUTHOR</h2>
-<p>Charles Ehlschlaeger; National Center for Geographic Information and
+
+Charles Ehlschlaeger; National Center for Geographic Information and
 Analysis, University of California, Santa Barbara.
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

Modified: grass/trunk/raster/r.random.cells/random.c
===================================================================
--- grass/trunk/raster/r.random.cells/random.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/random.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,9 +1,7 @@
 /* random.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <grass/gis.h>
+#include <grass/glocale.h>
+
 #include "ransurf.h"
 
 #define M1 259200
@@ -18,7 +16,6 @@
 #define IA3 4561
 #define IC3 51349
 
-
 /* ran1() returns a double with a value between 0.0 and 1.0             */
 double ran1(void)
 {
@@ -28,7 +25,7 @@
     static int iff = 0;
     int j;
 
-    FUNCTION(ran1);
+    G_debug(2, "ran1()");
 
     if (Seed < 0 || iff == 0) {
 	iff = 1;
@@ -50,22 +47,10 @@
     ix3 = (IA3 * ix3 + IC3) % M3;
     j = 1 + ((97 * ix3) / M3);
     if (j > 97 || j < 1)
-	G_fatal_error("RAN1: j==%d shouldn't happen", j);
+	G_fatal_error(_("RAN1: j == %d shouldn't happen"), j);
 
     temp = r[j];
     r[j] = (ix1 + ix2 * RM2) * RM1;
 
     return temp;
 }
-
-#undef M1
-#undef IA1
-#undef IC1
-#undef RM1
-#undef M2
-#undef IA2
-#undef IC2
-#undef RM2
-#undef M3
-#undef IA3
-#undef IC3

Modified: grass/trunk/raster/r.random.cells/ransurf.h
===================================================================
--- grass/trunk/raster/r.random.cells/ransurf.h	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.cells/ransurf.h	2008-12-26 16:31:45 UTC (rev 35039)
@@ -27,23 +27,4 @@
 extern struct Flag *Verbose;
 extern struct Option *Distance;
 extern struct Option *Output;
-
-#ifdef DEBUG
-#define INDX(a,b) (printf("(a)[%d]:%lf ",(b),(a)[(b)]))
-#define CHARS(a) (printf("(a):%s ",(a)))
-#define DOUBLE(a) (printf("(a):%.12lf ",(a)))
-#define INT(a) (printf("(a):%d ",(a)))
-#define RETURN (printf("\n"))
-#else
-#define INDX(a,b)
-#define CHARS(a)
-#define DOUBLE(a)
-#define INT(a)
-#define RETURN
-#endif
-
-#ifdef TRACE
-#define FUNCTION(a) (printf("Function:(a)\n"))
-#else
-#define FUNCTION(a)
-#endif
+extern struct Option *SeedStuff;

Modified: grass/trunk/raster/r.random.surface/calcsd.c
===================================================================
--- grass/trunk/raster/r.random.surface/calcsd.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/calcsd.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,18 +1,13 @@
 /* calcsd.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 void CalcSD(void)
 {
     int Row, Col, DoFilter;
     double Effect;
 
-    FUNCTION(CalcSD);
+    G_debug(2, "CalcSD()");
 
     FilterSD = 0.0;
     for (DoFilter = 0; DoFilter < NumFilters; DoFilter++) {
@@ -29,8 +24,9 @@
 	}
     }
 
-    DOUBLE(FilterSD);
+    G_debug(3, "(FilterSD):%.12lf", FilterSD);
     FilterSD = sqrt(FilterSD);
-    DOUBLE(FilterSD);
-    RETURN;
+    G_debug(3, "(FilterSD):%.12lf", FilterSD);
+
+    return;
 }

Modified: grass/trunk/raster/r.random.surface/calcsurf.c
===================================================================
--- grass/trunk/raster/r.random.surface/calcsurf.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/calcsurf.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,14 +1,9 @@
 /* calcsurf.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #include <stdlib.h>
 #include <grass/gis.h>
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 void CalcSurface(void)
 {
     int Count, OutRows, OutCols;
@@ -16,7 +11,7 @@
     int owC, oeC, onR, osR, wC, eC, nR, sR;
     double **Randoms;
 
-    FUNCTION(CalcSurface);
+    G_debug(2, "CalcSurface()");
 
     OutRows = BigF.RowPlus;
     OutCols = BigF.ColPlus;
@@ -96,19 +91,20 @@
 	for (Row = 0; Row < Rs; Row++) {
 	    if (ODD(Row)) {
 		for (Col = Cs - 1; Col >= 0; Col--) {
+		    G_percent(Count++, MapCount, 1);
 		    Surface[Row][Col] =
 			MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			G_percent(++Count, MapCount, 1);
 		}
 	    }
 	    else {
 		for (Col = 0; Col < Cs; Col++) {
+		    G_percent(Count++, MapCount, 1);
 		    Surface[Row][Col] =
 			MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			G_percent(++Count, MapCount, 1);
 		}
 	    }
 	}
+	G_percent(1, 1, 1);
     }
     else {
 	for (Row = 0; Row < Rs; Row++) {
@@ -118,9 +114,9 @@
 		    if (CellBuffer[Col] == 0)
 			Surface[Row][Col] = 0.0;
 		    else {
+			G_percent(Count++, MapCount, 1);
 			Surface[Row][Col] =
 			    MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			    G_percent(++Count, MapCount, 1);
 		    }
 		}
 	    }
@@ -129,15 +125,15 @@
 		    if (CellBuffer[Col] == 0)
 			Surface[Row][Col] = 0.0;
 		    else {
+			G_percent(Count++, MapCount, 1);
 			Surface[Row][Col] =
 			    MakePP(Row, Col, OutRows, OutCols, Randoms, BigF);
-			    G_percent(++Count, MapCount, 1);
 		    }
 		}
 	    }
 	}
+	G_percent(1, 1, 1);
     }
 
     G_free(Randoms);
-    FUNCTION(end calcsurf);
 }

Modified: grass/trunk/raster/r.random.surface/cpfilter.c
===================================================================
--- grass/trunk/raster/r.random.surface/cpfilter.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/cpfilter.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,14 +1,9 @@
 /* cpfilter.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 
-
 void CopyFilter(FILTER * FPtr, FILTER Filter)
 {
-    FUNCTION(CopyFilter);
+    G_debug(2, "CopyFilter()");
 
     FPtr->Mult = Filter.Mult;
     FPtr->MaxDist = Filter.MaxDist;

Modified: grass/trunk/raster/r.random.surface/dd.c
===================================================================
--- grass/trunk/raster/r.random.surface/dd.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/dd.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,12 +1,7 @@
 /* dd.c                                                         */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include "ransurf.h"
 
-
 double DD(double Dist)
 {
     double SmallD, SmallDist;

Modified: grass/trunk/raster/r.random.surface/decay.c
===================================================================
--- grass/trunk/raster/r.random.surface/decay.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/decay.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,16 +1,12 @@
 /* decay.c                                                              */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 
 void DistDecay(double *Effect, int R, int C)
 {
-    FUNCTION(DistDecay);
-    INT(R);
-    INT(C);
+    G_debug(2, "DistDecay");
+    G_debug(3, "(R):%d", R);
+    G_debug(3, "(C):%d", C);
 
     *Effect = BigF.F[R + BigF.RowPlus][C + BigF.ColPlus];
-    FUNCTION(end DistDecay);
+
 }

Modified: grass/trunk/raster/r.random.surface/digits.c
===================================================================
--- grass/trunk/raster/r.random.surface/digits.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/digits.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,18 +1,13 @@
 /* digits.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include "ransurf.h"
 
-
 int Digits(double Double, int MaxSig)
 {
     int I, Round;
     double Check, RD, Right;
 
-    FUNCTION(SigDigits);
+    G_debug(2, "SigDigits");
 
     I = 0;
     Double += 1.0;

Modified: grass/trunk/raster/r.random.surface/gasdev.c
===================================================================
--- grass/trunk/raster/r.random.surface/gasdev.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/gasdev.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,13 +1,8 @@
 /* gasdev.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 /* GasDev() returns a random double with a mean of 0.0 and a standard   */
 /*      deviation of 1.0.                                               */
 double GasDev(void)
@@ -21,7 +16,7 @@
     } while (r >= 1.0);
 
     fac = sqrt(-2.0 * log(r) / r);
-    DOUBLE(v2 * fac);
+    G_debug(3, "(v2 * fac):%.12lf", v2 * fac);
 
     return (v2 * fac);
 }

Modified: grass/trunk/raster/r.random.surface/gennorm.c
===================================================================
--- grass/trunk/raster/r.random.surface/gennorm.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/gennorm.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,19 +1,14 @@
 /* gennorm.c                                                    */
-
-#undef TRACE
-#undef DEBUG
-
 #include <math.h>
 #include <grass/gis.h>
 #include "ransurf.h"
 
-
 void GenNorm(void)
 {
     double t, b, c, sqr;
     int i;
 
-    FUNCTION(GenNorm);
+    G_debug(2, "GenNorm()");
 
     Norm = (double *)G_malloc(SIZE_OF_DISTRIBUTION * sizeof(double));
     sqr = 1 / sqrt(2 * PI);
@@ -22,8 +17,9 @@
 	t = ((double)(i - SIZE_OF_DISTRIBUTION / 2)) * DELTA_T;
 	b = exp(-t * t / 2.0) * sqr * DELTA_T;
 	c = c + b;
-	DOUBLE(c);
+	G_debug(3, "(c):%.12lf", c);
 	Norm[i] = c;
     }
-    RETURN;
+
+    return;
 }

Modified: grass/trunk/raster/r.random.surface/init.c
===================================================================
--- grass/trunk/raster/r.random.surface/init.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/init.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,8 +1,4 @@
 /* init.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -15,7 +11,6 @@
 #include "local_proto.h"
 
 
-
 void Init(void)
 {
     struct Cell_head Region;
@@ -24,7 +19,7 @@
     char msg[128], msg2[64];
     double MinRes;
 
-    FUNCTION(Init);
+    G_debug(2, "Init");
 
     Rs = G_window_rows();
     Cs = G_window_cols();
@@ -47,7 +42,7 @@
     }
     else {
 	if ((FDM = G_open_cell_old("MASK", G_mapset())) < 0) {
-	    G_fatal_error(" unable to open MASK");
+	    G_fatal_error(_("Unable to open raster map <%s>"), "MASK");
 	}
 	else {
 	    MapCount = 0;
@@ -76,7 +71,7 @@
     }
 
     if (1 >= High)
-	G_fatal_error("high [%d] must be greater than 1", High);
+	G_fatal_error(_("High (%d) must be greater than 1"), High);
 
     CatInfo.NumCat = High;
     NumMaps = 0;
@@ -85,8 +80,8 @@
 	for (j = i - 1; j >= 0; j--) {
 	    if (strcmp(OutNames[j], Name) == 0)
 		G_fatal_error
-		    ("%s: Random map [%s] repeated, maps must be unique",
-		     G_program_name(), Name);
+		    (_("Rastar map <%s> repeated, maps must be unique"),
+		     Name);
 	}
 
 	OutNames = (char **)G_realloc(OutNames, (i + 1) * sizeof(char *));
@@ -95,7 +90,7 @@
 	NumMaps++;
     }
     if (NumMaps == 0)
-	G_fatal_error("%s: requires an output map", G_program_name());
+	G_fatal_error(_("Output raster map required"));
 
     Theory = 0;
     NumSeeds = 0;
@@ -111,7 +106,7 @@
 	    sscanf(Number, "%d", &(Seeds[i]));
 	    if (Seeds[i] > SEED_MAX) {
 
-		sprintf(msg, _("Seed [%d] larger than maximum [%d]"),
+		sprintf(msg, _("Seed (%d) larger than maximum (%d)"),
 			Seeds[i], SEED_MAX);
 		Seeds[i] = Seeds[i] % SEED_MAX;
 		sprintf(msg2, _(" seed is set to %d"), Seeds[i]);
@@ -119,7 +114,7 @@
 		G_warning(msg);
 	    }
 	    else if (Seeds[i] < SEED_MIN) {
-		sprintf(msg, _("Seed [%d] smaller than minimum [%d]"),
+		sprintf(msg, _("Seed (%d) smaller than minimum (%d)"),
 			Seeds[i], SEED_MIN);
 		while (Seeds[i] < SEED_MIN)
 		    Seeds[i] += SEED_MAX - SEED_MIN;
@@ -162,9 +157,8 @@
     if (Distance->answer) {
 	sscanf(Distance->answer, "%lf", &(AllFilters[NumDist].MaxDist));
 	if (AllFilters[NumDist].MaxDist < 0.0)
-	    G_fatal_error("%s: distance value[%d]: [%lf] must be >= 0.0",
-			  G_program_name(), NumDist,
-			  AllFilters[NumDist].MaxDist);
+	    G_fatal_error(_("Distance value (%d): %lf must be >= 0.0"),
+			  NumDist, AllFilters[NumDist].MaxDist);
 
 	NumDist++;
     }
@@ -191,8 +185,8 @@
     if (Exponent->answer) {
 	sscanf(Exponent->answer, "%lf", &(AllFilters[NumExp].Exp));
 	if (AllFilters[NumExp].Exp <= 0.0)
-	    G_fatal_error("%s: exponent value [%lf] must be > 0.0",
-			  G_program_name(), AllFilters[NumExp].Exp);
+	    G_fatal_error(_("Exponent value (%lf) must be > 0.0"),
+			  AllFilters[NumExp].Exp);
 
 	NumExp++;
     }
@@ -215,10 +209,9 @@
     if (Weight->answer) {
 	sscanf(Weight->answer, "%lf", &(AllFilters[NumWeight].Mult));
 	if (AllFilters[NumWeight].Mult > AllFilters[NumWeight].MaxDist)
-	    G_fatal_error
-		("%s: flat value [%lf] must be less than distance value [%lf]",
-		 G_program_name(), AllFilters[NumWeight].Mult,
-		 AllFilters[NumWeight].MaxDist);
+	    G_fatal_error(_("Flat value (%lf) must be less than distance value (%lf)"),
+			  AllFilters[NumWeight].Mult,
+			  AllFilters[NumWeight].MaxDist);
 
 	NumWeight++;
     }
@@ -237,8 +230,7 @@
     }
 
     if (NumDist > 1 && NumDist < NumFilters)
-	G_fatal_error("%s: must have a distance value for each filter",
-		      G_program_name());
+	G_fatal_error(_("Must have a distance value for each filter"));
 
     if (NumDist == 0) {
 	AllFilters[0].MaxDist = MinRes / 4.0;
@@ -270,8 +262,7 @@
     }
 
     if (NumExp > 1 && NumExp < NumFilters)
-	G_fatal_error("%s: must have a exponent value for each filter",
-		      G_program_name());
+	G_fatal_error(_("Must have a exponent value for each filter"));
 
     if (NumWeight > 0) {
 	sprintf(String, " flat=");
@@ -280,7 +271,7 @@
 	    sprintf(String, "%.*lf,",
 		    Digits(AllFilters[i].Mult, 6), AllFilters[i].Mult);
 	    strcat(Buf, String);
-	    DOUBLE(AllFilters[i].Mult);
+	    G_debug(3, "(AllFilters[i].Mult):%.12lf", AllFilters[i].Mult);
 	}
 	sprintf(String, "%.*lf",
 		Digits(AllFilters[i].Mult, 6), AllFilters[i].Mult);
@@ -288,8 +279,7 @@
     }
 
     if (NumWeight > 1 && NumWeight < NumFilters)
-	G_fatal_error("%s: must have a weight value for each filter",
-		      G_program_name());
+	G_fatal_error(_("Must have a weight value for each filter"));
 
     if (NumExp == 1) {
 	for (NumExp = 1; NumExp < NumFilters; NumExp++)
@@ -305,20 +295,17 @@
 	for (NumWeight = 0; NumWeight < NumFilters; NumWeight++)
 	    AllFilters[NumWeight].Mult = 0.0;
     }
-    RETURN;
 
     AllMaxDist = 0.0;
     for (i = 0; i < NumFilters; i++) {
 	if (AllMaxDist < AllFilters[i].MaxDist)
 	    AllMaxDist = AllFilters[i].MaxDist;
 	AllFilters[i].MaxSq = AllFilters[i].MaxDist * AllFilters[i].MaxDist;
-	INT(i);
-	DOUBLE(AllFilters[i].Mult);
-	DOUBLE(AllFilters[i].MaxDist);
-	RETURN;
-	DOUBLE(AllFilters[i].MaxSq);
-	DOUBLE(AllFilters[i].Exp);
-	RETURN;
+	G_debug(3, "(i):%d", i);
+	G_debug(3, "(AllFilters[i].Mult):%.12lf", AllFilters[i].Mult);
+	G_debug(3, "(AllFilters[i].MaxDist):%.12lf", AllFilters[i].MaxDist);
+	G_debug(3, "(AllFilters[i].MaxSq):%.12lf", AllFilters[i].MaxSq);
+	G_debug(3, "(AllFilters[i].Exp):%.12lf", AllFilters[i].Exp);
     }
 
     BigF.RowPlus = AllMaxDist / NS;
@@ -333,4 +320,3 @@
 
     AllMaxDist *= 2.0;
 }
-

Modified: grass/trunk/raster/r.random.surface/main.c
===================================================================
--- grass/trunk/raster/r.random.surface/main.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/main.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -13,7 +13,7 @@
  *               Jachym Cepicky <jachym les-ejk.cz>, 
  *               Jan-Oliver Wagner <jan intevation.de>
  * PURPOSE:      generates a spatially dependent random surface
- * COPYRIGHT:    (C) 2000-2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2000-2008 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -26,9 +26,6 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "local_proto.h"
 
@@ -40,8 +37,8 @@
 CATINFO CatInfo;
 int *Seeds, Seed, NumSeeds, Low, High, NumMaps, NumFilters, OutFD;
 char Buf[240], **OutNames, *TheoryName, *Mapset;
+
 struct Flag *Uniform;
-
 struct Option *Distance, *Exponent, *Weight;
 struct Option *Output;
 struct Option *range_high_stuff;
@@ -50,14 +47,13 @@
 int main(int argc, char **argv)
 {
     struct GModule *module;
+
     int DoMap, DoFilter, MapSeed;
 
-    FUNCTION(main);
-
     G_gisinit(argv[0]);
 
     module = G_define_module();
-    module->keywords = _("raster");
+    module->keywords = _("raster, random, surface");
     module->description =
 	_("Generates random surface(s) with spatial dependence.");
 
@@ -66,7 +62,7 @@
     Output->type = TYPE_STRING;
     Output->required = YES;
     Output->multiple = YES;
-    Output->description = "Names of the resulting maps";
+    Output->description = _("Name for output raster map(s)");
     Output->gisprompt = "new,cell,raster";
 
     Distance = G_define_option();
@@ -75,15 +71,16 @@
     Distance->required = NO;
     Distance->multiple = NO;
     Distance->description =
-	"Input value: max. distance of spatial correlation (value >= 0.0, default [0.0])";
+	_("Maximum distance of spatial correlation (value >= 0.0)");
+    Distance->answer = "0.0";
 
     Exponent = G_define_option();
     Exponent->key = "exponent";
     Exponent->type = TYPE_DOUBLE;
     Exponent->multiple = NO;
     Exponent->required = NO;
-    Exponent->description =
-	"Input value: distance decay exponent (value > 0.0), default [1.0])";
+    Exponent->description = _("Distance decay exponent (value > 0.0)");
+    Exponent->answer = "1.0";
 
     Weight = G_define_option();
     Weight->key = "flat";
@@ -91,39 +88,44 @@
     Weight->multiple = NO;
     Weight->required = NO;
     Weight->description =
-	"Input value: distance filter remains flat before beginning exponent, default [0.0]";
+	_("Distance filter remains flat before beginning exponent");
+    Weight->answer = "0.0";
 
     SeedStuff = G_define_option();
     SeedStuff->key = "seed";
     SeedStuff->type = TYPE_INTEGER;
     SeedStuff->required = NO;
     SeedStuff->description =
-	"Input value: random seed (SEED_MIN >= value >= SEED_MAX), default [random]";
+	_("Random seed (SEED_MIN >= value >= SEED_MAX), default [random]");
 
     range_high_stuff = G_define_option();
     range_high_stuff->key = "high";
     range_high_stuff->type = TYPE_INTEGER;
     range_high_stuff->required = NO;
-    range_high_stuff->description =
-	"Input value: maximum cell value of distribution, default [255]";
+    range_high_stuff->description = _("Maximum cell value of distribution");
+    range_high_stuff->answer = "255";
 
     Uniform = G_define_flag();
     Uniform->key = 'u';
-    Uniform->description = "Uniformly distributed cell values";
+    Uniform->description = _("Uniformly distributed cell values");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    Init();
+
     if (Uniform->answer)
 	GenNorm();
+
     CalcSD();
+
     for (DoMap = 0; DoMap < NumMaps; DoMap++) {
 	OutFD = G_open_cell_new(OutNames[DoMap]);
 	if (OutFD < 0)
-	    G_fatal_error("%s: unable to open [%s] random raster map",
-			  G_program_name(), OutNames[DoMap]);
+	    G_fatal_error(_("Unable to open raster map <%s>"),
+			  OutNames[DoMap]);
 
-	G_message(_("Starting map [%s]"), OutNames[DoMap]);
+	G_message(_("Generating raster map <%s>..."), OutNames[DoMap]);
 
 	if (Seeds[DoMap] == SEED_MIN - 1)
 	    Seeds[DoMap] = (int)(ran1() * SEED_MAX);
@@ -133,13 +135,12 @@
 
 	for (DoFilter = 0; DoFilter < NumFilters; DoFilter++) {
 	    CopyFilter(&Filter, AllFilters[DoFilter]);
-	    G_message(_("Starting filter #%d, distance: %.*lf, exponent: %.*lf, flat: %.*lf"),
-		      DoFilter, Digits(2.0 * Filter.MaxDist, 6),
-		      2.0 * Filter.MaxDist, Digits(1.0 / Filter.Exp, 6),
-		      1.0 / Filter.Exp, Digits(Filter.Mult, 6), Filter.Mult);
+	    G_debug(1,
+		    "Starting filter #%d, distance: %.*lf, exponent: %.*lf, flat: %.*lf",
+		    DoFilter, Digits(2.0 * Filter.MaxDist, 6),
+		    2.0 * Filter.MaxDist, Digits(1.0 / Filter.Exp, 6),
+		    1.0 / Filter.Exp, Digits(Filter.Mult, 6), Filter.Mult);
 
-	    G_message(_("Percent done:"));
-
 	    MakeBigF();
 	    CalcSurface();
 	}
@@ -147,5 +148,7 @@
 	SaveMap(DoMap, MapSeed);
     }
 
-    return 0;
+    G_done_msg(" ");
+
+    exit(EXIT_SUCCESS);
 }

Modified: grass/trunk/raster/r.random.surface/makebigf.c
===================================================================
--- grass/trunk/raster/r.random.surface/makebigf.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/makebigf.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,8 +1,4 @@
 /* makebigf.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "local_proto.h"
 
@@ -12,15 +8,16 @@
     int R, C;
     double Dist, RDist, CDist;
 
-    FUNCTION(MakeBigF);
+    G_debug(2, "MakeBigF");
+
     for (R = 0; R < BigF.NumR; R++) {
 	BigF.LowBF[R] = BigF.HihBF[R] = -1;
 	RDist = (R - BigF.RowPlus) * NS;
 	RDist *= RDist;
 
 	for (C = 0; C < BigF.NumC; C++) {
-	    INT(R);
-	    INT(C);
+	    G_debug(3, "(R):%d", R);
+	    G_debug(3, "(C):%d", C);
 	    CDist = (C - BigF.ColPlus) * EW;
 	    CDist *= CDist;
 	    Dist = sqrt(CDist + RDist);
@@ -35,13 +32,10 @@
 		BigF.HihBF[R] = C;
 	    }
 
-	    DOUBLE(BigF.F[R][C]);
-	    RETURN;
+	    G_debug(3, "(BigF.F[R][C]):%.12lf", BigF.F[R][C]);
 	}
 
 	BigF.LowBF[R] -= BigF.ColPlus;
 	BigF.HihBF[R] -= BigF.ColPlus;
     }
-
-    FUNCTION(end MakeBigF);
 }

Modified: grass/trunk/raster/r.random.surface/makepp.c
===================================================================
--- grass/trunk/raster/r.random.surface/makepp.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/makepp.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,8 +1,4 @@
 /* makepp.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include "ransurf.h"
 #include "local_proto.h"
 
@@ -14,7 +10,7 @@
     int RRow, RCol;
     double Effect, Value;
 
-    FUNCTION(MakePP);
+    G_debug(2, "MakePP()");
 
     Value = 0.0;
     RRow = Row + BigF.RowPlus;
@@ -25,14 +21,13 @@
 
 	for (DCol = RCol - BigF.ColPlus; DCol <= RCol + BigF.ColPlus; DCol++) {
 	    DistDecay(&Effect, RRow - DRow, RCol - DCol);
-	    INT(RRow - DRow);
-	    INT(RCol - DCol);
-	    DOUBLE(Effect);
-	    RETURN;
+	    G_debug(3, "(RRow - DRow):%d", RRow - DRow);
+	    G_debug(3, "(RCol - DCol):%d", RCol - DCol);
+	    G_debug(3, "(Effect):%.12lf", Effect);
+
 	    Value += Effect * Randoms[DRow][DCol];
 	}
     }
 
     return (Value);
-    FUNCTION(end MakePP);
 }

Modified: grass/trunk/raster/r.random.surface/r.random.surface.html
===================================================================
--- grass/trunk/raster/r.random.surface/r.random.surface.html	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/r.random.surface.html	2008-12-26 16:31:45 UTC (rev 35039)
@@ -9,7 +9,7 @@
 nearby cells is determined by a distance decay function based on exponent.
 If multiple filters are passed over the output maps, each filter is given a
 weight based on the weight inputs.  The resulting random surface can have
-&quot;any&quot; mean and variance, but the theoretical mean of an infinitely
+<em>any</em> mean and variance, but the theoretical mean of an infinitely
 large map is 0.0 and a variance of 1.0. Description of the algorithm is in
 the <b>NOTES</b> section.
 
@@ -17,7 +17,7 @@
 The random surface generated are composed of floating point numbers, and
 saved in the category description files of the output map(s).  Cell values
 are uniformly or normally distributed between 1 and high values inclusive
-(determined by whether the <em>-u</em> flag is used). The category names
+(determined by whether the <b>-u</b> flag is used). The category names
 indicate the average floating point value and the range of floating point
 values that each cell value represents.
 
@@ -26,68 +26,68 @@
 spatial error modeling. A procedure to use <em>r.random.surface</em> in
 spatial error modeling is given in the <b>NOTES</b> section.
 
-<h3>Parameters:</h3>
+<h3>Parameters</h3>
 <dl>
-<dt><b>output</b>
-<dd>Output map(s): Random surface(s). The cell values are a random
-distribution between the low and high values inclusive.  The category values
-of the output map(s) are in the form &quot;#.# #.# to #.#&quot; where each
-#.# is a floating point number. The first number is the average of the
-random values the cell value represents. The other two numbers are the range
-of random values for that cell value. The &quot;average&quot; mean value of
-generated <tt>output</tt> map(s) is 0. The &quot;average&quot;
-variance of map(s) generated is 1. The random values represent the standard
-deviation from the mean of that random surface.
+<dt><b>output</b></dt>
+<dd>Random surface(s). The cell values are a random distribution
+between the low and high values inclusive.  The category values of the
+output map(s) are in the form <em>#.# #.# to #.#</em> where each #.#
+is a floating point number. The first number is the average of the
+random values the cell value represents. The other two numbers are the
+range of random values for that cell value. The <em>average</em> mean
+value of generated <tt>output</tt> map(s) is 0. The <em>average</em>
+variance of map(s) generated is 1. The random values represent the
+standard deviation from the mean of that random surface.</dd>
 
-<dt><b>distance</b>
-<dd>Input value(s) [default 0.0]: distance determines the spatial dependence
-of the output map(s). The distance value indicates the minimum distance at
-which two map cells have no relationship to each other. A distance value of
-0.0 indicates that there is no spatial dependence (i.e., adjacent cell
-values have no relationship to each other). As the distance value increases,
-adjacent cell values will have values closer to each other. But the range
-and distribution of cell values over the output map(s) will remain the same.
-Visually, the clumps of lower and higher values gets larger as distance
-increases. If multiple values are given, each output map will have multiple
-filters, one for each set of distance, exponent, and weight values.
+<dt><b>distance</b></dt>
+<dd>Distance determines the spatial dependence of the output
+map(s). The distance value indicates the minimum distance at which two
+map cells have no relationship to each other. A distance value of 0.0
+indicates that there is no spatial dependence (i.e., adjacent cell
+values have no relationship to each other). As the distance value
+increases, adjacent cell values will have values closer to each
+other. But the range and distribution of cell values over the output
+map(s) will remain the same.  Visually, the clumps of lower and higher
+values gets larger as distance increases. If multiple values are
+given, each output map will have multiple filters, one for each set of
+distance, exponent, and weight values.</dd>
 
-<dt><b>exponent</b>
-<dd>Input value(s) [default 1.0]: exponent determines the distance decay
-exponent for a particular filter. The exponent value(s) have the property of
-determining the &quot;texture&quot; of the random surface. Texture will
-decrease as the exponent value(s) get closer to 1.0. Normally, exponent will
-be 1.0 or less. If there are no exponent values given, each filter will be
-given an exponent value of 1.0. If there is at least one exponent value
-given, there must be one exponent value for each distance value.
+<dt><b>exponent</b></dt>
+<dd>Exponent determines the distance decay exponent for a particular
+filter. The exponent value(s) have the property of determining
+the <em>texture</em> of the random surface. Texture will decrease as
+the exponent value(s) get closer to 1.0. Normally, exponent will be
+1.0 or less. If there are no exponent values given, each filter will
+be given an exponent value of 1.0. If there is at least one exponent
+value given, there must be one exponent value for each distance value.</dd>
 
-<dt><b>flat</b>
-<dd>Input value(s) [default 0.0]: flat determines the distance at which the
-filter
+<dt><b>flat</b></dt>
+<dd>Flat determines the distance at which the filter.</dd>
 
-<dt><b>weight</b>
-<dd>Input value(s) [default 1.0]: weight determines the relative importance
-of each filter. For example, if there were two filters driving the algorithm
-and weight=1.0, 2.0 was given in the command line: The second filter would
-be twice as important as the first filter. If no weight values are given,
-each filter will be just as important as the other filters defining the
-random field. If weight values exist, there must be a weight value for each
-filter of the random field.
+<dt><b>weight</b></dt>
+<dd>Weight determines the relative importance of each filter. For
+example, if there were two filters driving the algorithm and
+weight=1.0, 2.0 was given in the command line: The second filter would
+be twice as important as the first filter. If no weight values are
+given, each filter will be just as important as the other filters
+defining the random field. If weight values exist, there must be a
+weight value for each filter of the random field.</dd>
 
-<dt><b>high</b>
-<dd>Input value [default 255]: Specifies the high end of the range of cell
-values in the output map(s). Specifying a very large high value will
-minimize the &quot;errors&quot; caused by the random surface's
-discretization. The word errors is in quotes because errors in
-discretization are often going to cancel each other out and the spatial
-statistics are far more sensitive to the initial independent random deviates
-than any potential discretization errors.
+<dt><b>high</b></dt>
+<dd>Specifies the high end of the range of cell values in the output
+map(s). Specifying a very large high value will minimize
+the <em>errors</em> caused by the random surface's discretization. The
+word errors is in quotes because errors in discretization are often
+going to cancel each other out and the spatial statistics are far more
+sensitive to the initial independent random deviates than any
+potential discretization errors.</dd>
 
-<dt><b>seed</b>
-<dd>Input value(s) [default random]: Specifies the random seed(s), one for
-each map, that <em>r.random.surface</em> will use to generate the initial
-set of random values that the resulting map is based on. If the random seed
-is not given, <em>r.random.surface</em> will get a seed from the process ID
-number.
+<dt><b>seed</b></dt>
+<dd>Specifies the random seed(s), one for each map,
+that <em>r.random.surface</em> will use to generate the initial set of
+random values that the resulting map is based on. If the random seed
+is not given, <em>r.random.surface</em> will get a seed from the
+process ID number.</dd>
 
 </dl>
 
@@ -110,65 +110,56 @@
 <p>
 One of the most important uses for <em>r.random.surface</em> is to determine
 how the error inherent in raster maps might effect the analyses done with
-those maps. If you wanted to check to see how sensitive your analysis is to
-the errors in the DEMs in your study area, see:
+those maps.
 
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/CGFinal/paper.htm">Visualizing Spatial Data Uncertainty Using Animation (final draft)</a>,&quot; by Charles R. Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to Computers in GeoSciences in September, 1996, accepted October, 1996 for publication in June, 1997.
-
-<p>
-&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/SDH96/paper.html">Modeling Uncertainty in Elevation Data for Geographical Analysis</a>&quot;, by Charles R. Ehlschlaeger, and Ashton M. Shortridge. Proceedings of the 7th International Symposium on Spatial Data Handling, Delft, Netherlands, August 1996. </p>
-
-<p>
-&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing with Uncertainty in Categorical Coverage Maps: Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild. Proceedings, Workshop on Geographic Information Systems at the Conference on Information and Knowledge Management, Gaithersburg MD, 1994.
-
-<p>
-&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty in Spatial Data: Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ,
-1994.
-
-<p>
-If you are interested in creating potential realizations of categorical
-coverage maps, see <em>r.random.model</em>.
-
-<h2>SEE ALSO</h2>
-
-<em><a href="r.random.html">r.random</a>, 
-<a href="r.mapcalc.html">r.mapcalc</a>
-</em>
-
 <h2>REFERENCES</h2>
-Random Field Software for GRASS by Chuck Ehlschlaeger<p>
+Random Field Software for GRASS by Chuck Ehlschlaeger
 
-<p>As part of my dissertation, I put together several programs that help
+<p>
+  As part of my dissertation, I put together several programs that help
 GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope
 you find it useful and dependable. The following papers might clarify their
-use: </p>
+use:
 
-<p>&quot;<a href="../../CGFinal/paper.htm">Visualizing Spatial Data
-Uncertainty Using Animation (final draft)</a>,&quot; by Charles R.
+<ul>
+<li><a href="../../CGFinal/paper.htm">Visualizing Spatial Data
+Uncertainty Using Animation (final draft)</a>, by Charles R.
 Ehlschlaeger, Ashton M. Shortridge, and Michael F. Goodchild. Submitted to
 Computers in GeoSciences in September, 1996, accepted October, 1996 for
-publication in June, 1997. </p>
+publication in June, 1997.</li>
 
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/paper.html">Modeling Uncertainty in Elevation Data for
-Geographical Analysis</a>&quot;, by Charles R. Ehlschlaeger, and Ashton M.
-Shortridge. Proceedings of the 7th International Symposium on Spatial Data
-Handling, Delft, Netherlands, August 1996. </p>
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/paper.html">Modeling
+Uncertainty in Elevation Data for Geographical Analysis</a>, by
+Charles R. Ehlschlaeger, and Ashton M.  Shortridge. Proceedings of the
+7th International Symposium on Spatial Data Handling, Delft,
+Netherlands, August 1996.</li>
 
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing with Uncertainty in
-Categorical Coverage Maps: Defining, Visualizing, and Managing Data
-Errors</a>&quot;, by Charles Ehlschlaeger and Michael Goodchild.
-Proceedings, Workshop on Geographic Information Systems at the Conference on
-Information and Knowledge Management, Gaithersburg MD, 1994. </p>
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/acm/paper.html">Dealing
+with Uncertainty in Categorical Coverage Maps: Defining, Visualizing,
+and Managing Data Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild.  Proceedings, Workshop on Geographic Information Systems at
+the Conference on Information and Knowledge Management, Gaithersburg
+MD, 1994.</li>
 
-<p>&quot;<a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty in Spatial Data:
-Defining, Visualizing, and Managing Data Errors</a>&quot;, by Charles
-Ehlschlaeger and Michael Goodchild. Proceedings, GIS/LIS'94, pp. 246-253,
-Phoenix AZ, 1994. </p>
+<li><a href="http://www.geo.hunter.cuny.edu/~chuck/gislis/gislis.html">Uncertainty
+in Spatial Data: Defining, Visualizing, and Managing Data
+Errors</a>, by Charles Ehlschlaeger and Michael
+Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ,
+1994.</li>
+</ul>
 
+<h2>SEE ALSO</h2>
 
+<em>
+  <a href="r.random.html">r.random</a>, 
+  <a href="r.random.cell.html">r.random.cell</a>, 
+  <a href="r.mapcalc.html">r.mapcalc</a>
+</em>
+
 <h2>AUTHORS</h2>
 Charles Ehlschlaeger, Michael Goodchild, and Chih-chang Lin; National Center
 for Geographic Information and Analysis, University of California, Santa
 Barbara.
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

Modified: grass/trunk/raster/r.random.surface/random.c
===================================================================
--- grass/trunk/raster/r.random.surface/random.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/random.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,12 +1,7 @@
 /* random.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #include <grass/gis.h>
 #include "ransurf.h"
 
-
 #define M1 259200
 #define IA1 7141
 #define IC1 54773
@@ -19,7 +14,6 @@
 #define IA3 4561
 #define IC3 51349
 
-
 /* ran1() returns a double with a value between 0.0 and 1.0             */
 double ran1(void)
 {
@@ -29,7 +23,7 @@
     static int iff = 0;
     int j;
 
-    FUNCTION(ran1);
+    G_debug(2, "ran1()");
 
     if (Seed < 0 || iff == 0) {
 	iff = 1;
@@ -59,15 +53,3 @@
 
     return temp;
 }
-
-#undef M1
-#undef IA1
-#undef IC1
-#undef RM1
-#undef M2
-#undef IA2
-#undef IC2
-#undef RM2
-#undef M3
-#undef IA3
-#undef IC3

Modified: grass/trunk/raster/r.random.surface/ransurf.h
===================================================================
--- grass/trunk/raster/r.random.surface/ransurf.h	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/ransurf.h	2008-12-26 16:31:45 UTC (rev 35039)
@@ -53,25 +53,4 @@
 extern struct Option *Output;
 extern struct Option *range_high_stuff;
 extern struct Option *SeedStuff;
-
-#ifdef DEBUG
-#define INDX(a,b) (printf("(a)[%d]:%lf ",(b),(a)[(b)]))
-#define CHARS(a) (printf("(a):%s ",(a)))
-#define DOUBLE(a) (printf("(a):%.12lf ",(a)))
-#define INT(a) (printf("(a):%d ",(a)))
-#define RETURN (printf("\n"))
-#else
-#define INDX(a,b)
-#define CHARS(a)
-#define DOUBLE(a)
-#define INT(a)
-#define RETURN
 #endif
-
-#ifdef TRACE
-#define FUNCTION(a) (printf("Function:(a)\n"))
-#else
-#define FUNCTION(a)
-#endif
-
-#endif

Modified: grass/trunk/raster/r.random.surface/save.c
===================================================================
--- grass/trunk/raster/r.random.surface/save.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/save.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -1,8 +1,4 @@
 /* save.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
@@ -19,15 +15,15 @@
     char String[80], Label[240];
     struct History history;
 
-    FUNCTION(SaveMap);
+    G_debug(2, "SaveMap()");
 
     OutFD = G_open_cell_new(OutNames[NumMap]);
     if (OutFD < 0)
-	G_fatal_error("%s: unable to open new raster map [%s]",
-		      G_program_name(), OutNames[NumMap]);
+	G_fatal_error(_("Unable to create raster map <%s>"),
+		      OutNames[NumMap]);
 
     MeanMod = 0.0;
-    INT(FDM);
+    G_debug(3, "(FDM):%d", FDM);
     if (FDM == -1) {
 	for (Row = 0; Row < Rs; Row++) {
 	    for (Col = 0; Col < Cs; Col++) {
@@ -70,12 +66,12 @@
 	}
 
 	MeanMod /= MapCount;
-	DOUBLE(MeanMod);
-	DOUBLE(FilterSD);
+	G_debug(3, "(MeanMod):%.12lf", MeanMod);
+	G_debug(3, "(FilterSD):%.12lf", FilterSD);
 	/* Value = (Value - MeanMod) / FilterSD + MeanMod / FilterSD; */
 	Value /= FilterSD;
-	DOUBLE(Value);
-	RETURN;
+	G_debug(3, "(Value):%.12lf", Value);
+
 	DownInterval = UpInterval = Value;
 
 	for (Row = 0; Row < Rs; Row++) {
@@ -100,8 +96,7 @@
 	}
     }
 
-    G_message(_("%s: saving [%s] raster map layer.\nPercent complete:"),
-	      G_program_name(), OutNames[NumMap]);
+    G_message(_("Writing raster map <%s>..."), OutNames[NumMap]);
 
     for (Index = 0; Index < CatInfo.NumCat; Index++) {
 	CatInfo.Max[Index] = DownInterval;
@@ -114,7 +109,6 @@
 	UpInterval += .1;
 
     if (!Uniform->answer) {
-	FUNCTION(NOT_UNIFORM);
 	/* normal distribution */
 	for (Row = 0; Row < Rs; Row++) {
 	    for (Col = 0; Col < Cs; Col++) {
@@ -170,12 +164,13 @@
     }
 
     for (Row = 0; Row < Rs; Row++) {
+	G_percent(Row, Rs, 2);
 	for (Col = 0; Col < Cs; Col++) {
 	    CellBuffer[Col] = (CELL) Surface[Row][Col];
 	}
 	G_put_raster_row(OutFD, CellBuffer, CELL_TYPE);
-	G_percent(Row + 1, Rs, 1);
     }
+    G_percent(1, 1, 1);
 
     G_close_cell(OutFD);
     G_short_history(OutNames[NumMap], "raster", &history);
@@ -212,13 +207,13 @@
 	LowColor = 0;
     if (Uniform->answer || HighColor > 255)
 	HighColor = 255;
-    INT(LowColor);
-    INT(HighColor);
+    G_debug(3, "(LowColor):%d", LowColor);
+    G_debug(3, "(HighColor):%d", HighColor);
 
     G_add_color_rule(1, LowColor, LowColor, LowColor,
 		     High, HighColor, HighColor, HighColor, &Colr);
 
     if (G_write_colors(OutNames[NumMap], G_mapset(), &Colr) == -1)
-	G_warning("%s: unable to write colr file for %s\n",
-		  G_program_name(), OutNames[NumMap]);
+	G_warning(_("Unable to write color table for raster map <%s>"),
+		  OutNames[NumMap]);
 }

Modified: grass/trunk/raster/r.random.surface/zero.c
===================================================================
--- grass/trunk/raster/r.random.surface/zero.c	2008-12-26 16:30:34 UTC (rev 35038)
+++ grass/trunk/raster/r.random.surface/zero.c	2008-12-26 16:31:45 UTC (rev 35039)
@@ -10,7 +10,7 @@
 {
     int Row, Col;
 
-    FUNCTION(ZeroMapCells);
+    G_debug(2, "ZeroMapCells()");
 
     for (Row = 0; Row < Rs; Row++) {
 	for (Col = 0; Col < Cs; Col++)



More information about the grass-commit mailing list