[GRASS-SVN] r43584 - in grass/branches/releasebranch_6_4/raster: r.random.cells r.random.surface

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 21 09:08:34 EDT 2010


Author: neteler
Date: 2010-09-21 13:08:34 +0000 (Tue, 21 Sep 2010)
New Revision: 43584

Modified:
   grass/branches/releasebranch_6_4/raster/r.random.cells/description.html
   grass/branches/releasebranch_6_4/raster/r.random.cells/flag.c
   grass/branches/releasebranch_6_4/raster/r.random.cells/gasdev.c
   grass/branches/releasebranch_6_4/raster/r.random.cells/indep.c
   grass/branches/releasebranch_6_4/raster/r.random.cells/init.c
   grass/branches/releasebranch_6_4/raster/r.random.cells/main.c
   grass/branches/releasebranch_6_4/raster/r.random.cells/random.c
   grass/branches/releasebranch_6_4/raster/r.random.cells/ransurf.h
   grass/branches/releasebranch_6_4/raster/r.random.surface/calcsd.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/calcsurf.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/cpfilter.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/dd.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/decay.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/description.html
   grass/branches/releasebranch_6_4/raster/r.random.surface/digits.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/gasdev.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/gennorm.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/init.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/main.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/makebigf.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/makepp.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/random.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/ransurf.h
   grass/branches/releasebranch_6_4/raster/r.random.surface/save.c
   grass/branches/releasebranch_6_4/raster/r.random.surface/zero.c
Log:
backport: r.random.{suface,cells}: clean up

Modified: grass/branches/releasebranch_6_4/raster/r.random.cells/description.html
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/description.html	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/description.html	2010-09-21 13:08:34 UTC (rev 43584)
@@ -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/branches/releasebranch_6_4/raster/r.random.cells/flag.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/flag.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/flag.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,8 +1,9 @@
 #include <stdlib.h>
 #include <grass/gis.h>
+
+#undef MAIN
 #include "flag.h"
 
-
 void FlagClearAll(FLAG * flags)
 {
     register int r, c;

Modified: grass/branches/releasebranch_6_4/raster/r.random.cells/gasdev.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/gasdev.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/gasdev.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,14 +1,10 @@
 /* gasdev.c                                                             */
+#include <math.h>
 
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
-#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)
@@ -22,7 +18,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/branches/releasebranch_6_4/raster/r.random.cells/indep.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/indep.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/indep.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,13 +1,10 @@
 /* indep.c                                                              */
+#include <grass/gis.h>
+#include <grass/glocale.h>
 
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
-#include <grass/gis.h>
 #include "ransurf.h"
 
-
 void Indep(void)
 {
     int Count, DRow, DCol;
@@ -15,14 +12,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;
 
@@ -38,13 +36,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--;
 			    }
@@ -56,7 +54,7 @@
 		}
 	    }
 
-	    FUNCTION(it1);
+	    G_debug(2, "it1()");
 	    for (R = DRow - 1; R >= 0; R--) {
 		RowDist = NS * (DRow - R);
 		if (RowDist > MaxDistSq) {
@@ -68,7 +66,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--;
 			    }
@@ -80,7 +78,7 @@
 		}
 	    }
 
-	    FUNCTION(it2);
+	    G_debug(2, "it2()");
 	    for (R = DRow; R < Rs; R++) {
 		RowDist = NS * (R - DRow);
 		if (RowDist > MaxDistSq) {
@@ -92,7 +90,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--;
 			    }
@@ -104,7 +102,7 @@
 		}
 	    }
 
-	    FUNCTION(it3);
+	    G_debug(2, "it3()");
 	    for (R = DRow - 1; R >= 0; R--) {
 		RowDist = NS * (DRow - R);
 		if (RowDist > MaxDistSq) {
@@ -116,7 +114,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--;
 			    }
@@ -130,18 +128,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/branches/releasebranch_6_4/raster/r.random.cells/init.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/init.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/init.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,22 +1,18 @@
 /* init.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
-#undef MAIN
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
+
+#undef MAIN
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 /* function prototypes */
 static int comp_array(const void *p1, const void *p2);
 static void IsLegal(char *Name);
 
-
 void Init(int argc, char **argv)
 {
     struct Option *SeedStuff;
@@ -25,15 +21,9 @@
     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 independent cells map";
-    Output->gisprompt = "new,cell,raster";
+    Output = G_define_standard_option(G_OPT_R_OUTPUT);
 
     Distance = G_define_option();
     Distance->key = "distance";
@@ -41,14 +31,14 @@
     Distance->required = YES;
     Distance->multiple = NO;
     Distance->description =
-	"Input value: max. distance of spatial correlation (value(s) >= 0.0)";
+	_("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 =
-	"Input value: random seed (SEED_MIN >= value >= SEED_MAX), default [random]";
+	_("Random seed (SEED_MIN >= value >= SEED_MAX) (default [random])");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -75,7 +65,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,18 +89,13 @@
 	CellCount = Rs * Cs;
     }
 
-    if (!Output->answer) {
-	G_fatal_error("There should be an output map");
-    }
-    else {
-	IsLegal(Output->answer);
-    }
-
+    IsLegal(Output->answer);
+    
     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();
@@ -127,9 +112,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;
@@ -142,6 +131,8 @@
 	    }
 	}
     }
+    G_percent(1, 1, 1);
+    
     qsort(DoNext, CellCount, sizeof(CELLSORTER), comp_array);
 }
 
@@ -162,6 +153,6 @@
 static void IsLegal(char *Name)
 {
     if (G_legal_filename(Name) == -1)
-	G_fatal_error("%s: map name [%s] not legal for GRASS",
-		      G_program_name(), Name);
+	G_fatal_error(_("<%s> is an illegal name"),
+		      Name);
 }

Modified: grass/branches/releasebranch_6_4/raster/r.random.cells/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/main.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/main.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -9,20 +9,18 @@
  *               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
-
-#define MAIN
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
+
+#define MAIN
 #include "ransurf.h"
 #include "local_proto.h"
 #undef MAIN
@@ -31,16 +29,17 @@
 {
     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);
     Indep();
+    
+    G_done_msg(" ");
+    
     exit(EXIT_SUCCESS);
 }

Modified: grass/branches/releasebranch_6_4/raster/r.random.cells/random.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/random.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/random.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,10 +1,8 @@
 /* random.c                                                             */
+#include <grass/gis.h>
+#include <grass/glocale.h>
 
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
-#include <grass/gis.h>
 #include "ransurf.h"
 
 #define M1 259200
@@ -19,7 +17,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 +26,7 @@
     static int iff = 0;
     int j;
 
-    FUNCTION(ran1);
+    G_debug(2, "ran1()");
 
     if (Seed < 0 || iff == 0) {
 	iff = 1;
@@ -51,22 +48,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/branches/releasebranch_6_4/raster/r.random.cells/ransurf.h
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.cells/ransurf.h	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.cells/ransurf.h	2010-09-21 13:08:34 UTC (rev 43584)
@@ -33,23 +33,3 @@
 GLOBAL struct Flag *Verbose;
 GLOBAL struct Option *Distance;
 GLOBAL 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

Modified: grass/branches/releasebranch_6_4/raster/r.random.surface/calcsd.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/calcsd.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/calcsd.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,19 +1,14 @@
 /* calcsd.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #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++) {
@@ -30,8 +25,9 @@
 	}
     }
 
-    DOUBLE(FilterSD);
+    G_debug(3, "(FilterSD):%.12lf", FilterSD);
     FilterSD = sqrt(FilterSD);
-    DOUBLE(FilterSD);
-    RETURN;
+    G_debug(3, "(FilterSD):%.12lf", FilterSD);
+
+    return;
 }

Modified: grass/branches/releasebranch_6_4/raster/r.random.surface/calcsurf.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/calcsurf.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/calcsurf.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,15 +1,10 @@
 /* calcsurf.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #include <stdlib.h>
 #include <grass/gis.h>
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 void CalcSurface(void)
 {
     int Count, OutRows, OutCols;
@@ -17,7 +12,7 @@
     int owC, oeC, onR, osR, wC, eC, nR, sR;
     double **Randoms;
 
-    FUNCTION(CalcSurface);
+    G_debug(2, "CalcSurface()");
 
     OutRows = BigF.RowPlus;
     OutCols = BigF.ColPlus;
@@ -97,21 +92,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);
-		    if (!Verbose->answer)
-			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);
-		    if (!Verbose->answer)
-			G_percent(++Count, MapCount, 1);
 		}
 	    }
 	}
+	G_percent(1, 1, 1);
     }
     else {
 	for (Row = 0; Row < Rs; Row++) {
@@ -121,11 +115,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);
-
-			if (!Verbose->answer)
-			    G_percent(++Count, MapCount, 1);
 		    }
 		}
 	    }
@@ -134,17 +126,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);
-
-			if (!Verbose->answer)
-			    G_percent(++Count, MapCount, 1);
 		    }
 		}
 	    }
 	}
+	G_percent(1, 1, 1);
     }
 
     G_free(Randoms);
-    FUNCTION(end calcsurf);
 }

Modified: grass/branches/releasebranch_6_4/raster/r.random.surface/cpfilter.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/cpfilter.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/cpfilter.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,15 +1,10 @@
 /* cpfilter.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #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/branches/releasebranch_6_4/raster/r.random.surface/dd.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/dd.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/dd.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,13 +1,8 @@
 /* dd.c                                                         */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #include <math.h>
 #include "ransurf.h"
 
-
 double DD(double Dist)
 {
     double SmallD, SmallDist;

Modified: grass/branches/releasebranch_6_4/raster/r.random.surface/decay.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/decay.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/decay.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,17 +1,13 @@
 /* decay.c                                                              */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #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/branches/releasebranch_6_4/raster/r.random.surface/description.html
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/description.html	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/description.html	2010-09-21 13:08:34 UTC (rev 43584)
@@ -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/branches/releasebranch_6_4/raster/r.random.surface/digits.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/digits.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/digits.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,19 +1,14 @@
 /* digits.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #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/branches/releasebranch_6_4/raster/r.random.surface/gasdev.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/gasdev.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/gasdev.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,14 +1,9 @@
 /* gasdev.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #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)
@@ -22,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/branches/releasebranch_6_4/raster/r.random.surface/gennorm.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/gennorm.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/gennorm.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,20 +1,15 @@
 /* gennorm.c                                                    */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #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);
@@ -23,8 +18,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/branches/releasebranch_6_4/raster/r.random.surface/init.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/init.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/init.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,8 +1,4 @@
 /* init.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -15,7 +11,6 @@
 #include "ransurf.h"
 #include "local_proto.h"
 
-
 /* function prototypes */
 static void IsLegal(char *Name);
 
@@ -33,15 +28,16 @@
     char msg[128], msg2[64];
     double MinRes;
 
-    FUNCTION(Init);
+    G_debug(2, "Init");
 
     Output = G_define_option();
     Output->key = "output";
     Output->type = TYPE_STRING;
+    Output->key_desc = "name";
     Output->required = YES;
     Output->multiple = YES;
-    Output->description = "Names of the resulting maps";
     Output->gisprompt = "new,cell,raster";
+    Output->description = _("Name for output raster map(s)");
 
     /*
        TheoryS              = G_define_option() ;
@@ -59,7 +55,8 @@
     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";
@@ -67,7 +64,8 @@
     Exponent->multiple = NO;
     Exponent->required = NO;
     Exponent->description =
-	"Input value: distance decay exponent (value > 0.0), default [1.0])";
+	_("Distance decay exponent (value > 0.0)");
+    Exponent->answer = "1.0";
 
     Weight = G_define_option();
     Weight->key = "flat";
@@ -75,30 +73,32 @@
     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]";
+	_("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");
 
     /* please, remove before GRASS 7 released */
     Verbose = G_define_flag();
     Verbose->key = 'q';
-    Verbose->description = "No (quiet) description during run";
+    Verbose->description = _("No (quiet) description during run");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -109,8 +109,7 @@
 	G_warning(_("The '-q' flag is superseded and will be removed "
 		    "in future. Please use '--quiet' instead."));
     }
-
-
+    
     Rs = G_window_rows();
     Cs = G_window_cols();
     Surface = (double **)G_malloc(Rs * sizeof(double *));
@@ -132,7 +131,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;
@@ -161,7 +160,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;
@@ -171,8 +170,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 *));
@@ -181,7 +180,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;
     /*
@@ -203,7 +202,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]);
@@ -211,7 +210,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;
@@ -254,8 +253,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,
+	    G_fatal_error(_("Distance value (%d): %lf must be >= 0.0"),
+			  NumDist,
 			  AllFilters[NumDist].MaxDist);
 
 	NumDist++;
@@ -283,8 +282,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++;
     }
@@ -307,10 +306,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++;
     }
@@ -329,9 +327,8 @@
     }
 
     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;
     }
@@ -362,8 +359,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=");
@@ -372,7 +368,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);
@@ -380,9 +376,8 @@
     }
 
     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++)
 	    AllFilters[NumExp].Exp = AllFilters[0].Exp;
@@ -397,20 +392,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;
+	AllFilters[i].MaxSq = AllFilters[i].MaxDist * AllFilters[i].MaxDist;	
+	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;
@@ -430,6 +422,6 @@
 static void IsLegal(char *Name)
 {
     if (G_legal_filename(Name) == -1)
-	G_fatal_error("%s: map name [%s] not legal for GRASS",
-		      G_program_name(), Name);
+	G_fatal_error(_("<%s> is an ilegal name"),
+		      Name);
 }

Modified: grass/branches/releasebranch_6_4/raster/r.random.surface/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/main.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/main.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -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,27 +26,21 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
-#undef TRACE
-#undef DEBUG
-
 #define MAIN
 #include "ransurf.h"
 #include "local_proto.h"
 #undef MAIN
 
-
 int main(int argc, char **argv)
 {
     struct GModule *module;
     int DoMap, DoFilter, MapSeed;
     double ran1();
 
-    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.");
 
@@ -57,10 +51,11 @@
     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);
@@ -70,13 +65,11 @@
 
 	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),
+	    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();
 	}
@@ -84,5 +77,7 @@
 	SaveMap(DoMap, MapSeed);
     }
 
-    return 0;
+    G_done_msg(" ");
+    
+    exit(EXIT_SUCCESS);
 }

Modified: grass/branches/releasebranch_6_4/raster/r.random.surface/makebigf.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/makebigf.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/makebigf.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,8 +1,4 @@
 /* makebigf.c                                                           */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #include "ransurf.h"
 #include "local_proto.h"
@@ -13,15 +9,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);
@@ -36,13 +33,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/branches/releasebranch_6_4/raster/r.random.surface/makepp.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/makepp.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/makepp.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,8 +1,4 @@
 /* makepp.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #include "ransurf.h"
 #include "local_proto.h"
@@ -15,7 +11,7 @@
     int RRow, RCol;
     double Effect, Value;
 
-    FUNCTION(MakePP);
+    G_debug(2, "MakePP()");
 
     Value = 0.0;
     RRow = Row + BigF.RowPlus;
@@ -26,14 +22,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/branches/releasebranch_6_4/raster/r.random.surface/random.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/random.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/random.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,13 +1,8 @@
 /* random.c                                                             */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #include <grass/gis.h>
 #include "ransurf.h"
 
-
 #define M1 259200
 #define IA1 7141
 #define IC1 54773
@@ -20,7 +15,6 @@
 #define IA3 4561
 #define IC3 51349
 
-
 /* ran1() returns a double with a value between 0.0 and 1.0             */
 double ran1(void)
 {
@@ -30,7 +24,7 @@
     static int iff = 0;
     int j;
 
-    FUNCTION(ran1);
+    G_debug(2, "ran1()");
 
     if (Seed < 0 || iff == 0) {
 	iff = 1;
@@ -61,14 +55,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/branches/releasebranch_6_4/raster/r.random.surface/ransurf.h
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/ransurf.h	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/ransurf.h	2010-09-21 13:08:34 UTC (rev 43584)
@@ -56,25 +56,4 @@
     /* please, remove before GRASS 7 released */
 GLOBAL struct Flag *Verbose;
 GLOBAL struct Option *Distance, *Exponent, *Weight;
-
-#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/branches/releasebranch_6_4/raster/r.random.surface/save.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/save.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/save.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -1,8 +1,4 @@
 /* save.c                                                               */
-
-#undef TRACE
-#undef DEBUG
-
 #undef MAIN
 #include <string.h>
 #include <grass/gis.h>
@@ -20,15 +16,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++) {
@@ -71,12 +67,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++) {
@@ -101,8 +97,8 @@
 	}
     }
 
-    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;
@@ -115,7 +111,6 @@
 	UpInterval += .1;
 
     if (!Uniform->answer) {
-	FUNCTION(NOT_UNIFORM);
 	/* normal distribution */
 	for (Row = 0; Row < Rs; Row++) {
 	    for (Col = 0; Col < Cs; Col++) {
@@ -171,13 +166,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);
-	if (!Verbose->answer)
-	    G_percent(Row + 1, Rs, 1);
     }
+    G_percent(1, 1, 1);
 
     G_close_cell(OutFD);
     G_short_history(OutNames[NumMap], "raster", &history);
@@ -214,13 +209,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/branches/releasebranch_6_4/raster/r.random.surface/zero.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.random.surface/zero.c	2010-09-21 13:06:44 UTC (rev 43583)
+++ grass/branches/releasebranch_6_4/raster/r.random.surface/zero.c	2010-09-21 13:08:34 UTC (rev 43584)
@@ -11,7 +11,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