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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 27 17:41:37 EST 2010


Author: huhabla
Date: 2010-01-27 17:41:36 -0500 (Wed, 27 Jan 2010)
New Revision: 40702

Modified:
   grass/trunk/raster/simwe/r.sim.sediment/main.c
   grass/trunk/raster/simwe/r.sim.water/main.c
   grass/trunk/raster/simwe/simlib/input.c
   grass/trunk/raster/simwe/simlib/output.c
Log:
Simplified memory allocation. Changed variable naming for better code understanding. 
Fixed some gcc warnings.

Modified: grass/trunk/raster/simwe/r.sim.sediment/main.c
===================================================================
--- grass/trunk/raster/simwe/r.sim.sediment/main.c	2010-01-27 17:10:07 UTC (rev 40701)
+++ grass/trunk/raster/simwe/r.sim.sediment/main.c	2010-01-27 22:41:36 UTC (rev 40702)
@@ -75,6 +75,7 @@
 #include <grass/bitmap.h>
 /*#include <grass/site.h> */
 #include <grass/glocale.h>
+#include <grass/gmath.h>
 
 /********************************/
 /* Specific stuff               */
@@ -361,46 +362,15 @@
 
     /* mandatory for si,sigma */
 
-    si = (double **)G_malloc(sizeof(double *) * (my));
-    for (l = 0; l < my; l++) {
-	si[l] = (double *)G_malloc(sizeof(double) * (mx));
-    }
-    for (j = 0; j < my; j++) {
-	for (i = 0; i < mx; i++)
-	    si[j][i] = 0.;
-    }
+    si = G_alloc_matrix(my, mx);
+    sigma = G_alloc_matrix(my, mx);
 
-    sigma = (double **)G_malloc(sizeof(double *) * (my));
-    for (l = 0; l < my; l++) {
-	sigma[l] = (double *)G_malloc(sizeof(double) * (mx));
-    }
-    for (j = 0; j < my; j++) {
-	for (i = 0; i < mx; i++)
-	    sigma[j][i] = 0.;
-    }
-
     /* memory allocation for output grids */
 
-    dif = (float **)G_malloc(sizeof(float *) * (my));
-    for (l = 0; l < my; l++) {
-	dif[l] = (float *)G_malloc(sizeof(float) * (mx));
-    }
-    for (j = 0; j < my; j++) {
-	for (i = 0; i < mx; i++)
-	    dif[j][i] = 0.;
-    }
+    dif = G_alloc_fmatrix(my, mx);
+    if (erdep != NULL || et != NULL)
+	er = G_alloc_fmatrix(my, mx);
 
-    if (erdep != NULL || et != NULL) {
-	er = (float **)G_malloc(sizeof(float *) * (my));
-	for (l = 0; l < my; l++) {
-	    er[l] = (float *)G_malloc(sizeof(float) * (mx));
-	}
-	for (j = 0; j < my; j++) {
-	    for (i = 0; i < mx; i++)
-		er[j][i] = 0.;
-	}
-    }
-
     /*  if (maskmap != NULL)
        bitmask = BM_create (cols, rows);
        IL_create_bitmask (&params, bitmask);

Modified: grass/trunk/raster/simwe/r.sim.water/main.c
===================================================================
--- grass/trunk/raster/simwe/r.sim.water/main.c	2010-01-27 17:10:07 UTC (rev 40701)
+++ grass/trunk/raster/simwe/r.sim.water/main.c	2010-01-27 22:41:36 UTC (rev 40702)
@@ -82,6 +82,7 @@
 #include <grass/bitmap.h>
 /* #include <grass/site.h> */
 #include <grass/glocale.h>
+#include <grass/gmath.h>
 
 /********************************/
 /* Specific stuff               */
@@ -484,35 +485,11 @@
     /* memory allocation for output grids */
     G_debug(2, "beginning memory allocation for output grids");
 
-    gama = (double **)G_malloc(sizeof(double *) * (my));
-    for (l = 0; l < my; l++) {
-	gama[l] = (double *)G_malloc(sizeof(double) * (mx));
-    }
-    for (j = 0; j < my; j++) {
-	for (i = 0; i < mx; i++)
-	    gama[j][i] = 0.;
-    }
+    gama = G_alloc_matrix(my, mx);
+    if (err != NULL)
+	gammas = G_alloc_matrix(my, mx);
+    dif = G_alloc_fmatrix(my, mx);
 
-    if (err != NULL) {
-	gammas = (double **)G_malloc(sizeof(double *) * (my));
-	for (l = 0; l < my; l++) {
-	    gammas[l] = (double *)G_malloc(sizeof(double) * (mx));
-	}
-	for (j = 0; j < my; j++) {
-	    for (i = 0; i < mx; i++)
-		gammas[j][i] = 0.;
-	}
-    }
-
-    dif = (float **)G_malloc(sizeof(float *) * (my));
-    for (l = 0; l < my; l++) {
-	dif[l] = (float *)G_malloc(sizeof(float) * (mx));
-    }
-    for (j = 0; j < my; j++) {
-	for (i = 0; i < mx; i++)
-	    dif[j][i] = 0.;
-    }
-
     /*  if (maskmap != NULL)
        bitmask = BM_create (cols, rows);
        IL_create_bitmask (&params, bitmask);

Modified: grass/trunk/raster/simwe/simlib/input.c
===================================================================
--- grass/trunk/raster/simwe/simlib/input.c	2010-01-27 17:10:07 UTC (rev 40701)
+++ grass/trunk/raster/simwe/simlib/input.c	2010-01-27 22:41:36 UTC (rev 40702)
@@ -27,15 +27,15 @@
 int input_data(void)
 {
 
-    FCELL *cell1, *cell4b, *cell5;
-    FCELL *cell9, *cell10, *cell11;
-    DCELL *cell2, *cell3, *cell4, *cell4a, *cell12;
-    int fd1, fd2, fd3, fd4, fd4a, fd4b, fd5, row, row_rev;
-    int fd9, fd10, fd11, fd12;
+    FCELL *elevin_cell, *traps_cell, *manin_cell;
+    FCELL *detin_cell, *trainin_cell, *tauin_cell;
+    DCELL *dxin_cell, *dyin_cell, *rain_cell, *infil_cell, *wdepth_cell;
+    int elevin_fd, dxin_fd, dyin_fd, rain_fd, infil_fd, traps_fd, manin_fd, row, row_rev;
+    int detin_fd, trainin_fd, tauin_fd, wdepth_fd;
     int l, j;
 /*    int nn, cc, ii, dd; */
     double unitconv = 0.0000002;	/* mm/hr to m/s */
-    char *mapset;
+    const char *mapset;
 /* output water depth and discharge at outlet points given in site file*/
 /*    Site *site; 
 
@@ -87,31 +87,33 @@
 */
 
     /* Allocate raster buffers */
-    cell1 = Rast_allocate_f_buf();
-    cell2 = Rast_allocate_d_buf();
-    cell3 = Rast_allocate_d_buf();
+    elevin_cell = Rast_allocate_f_buf();
+    dxin_cell = Rast_allocate_d_buf();
+    dyin_cell = Rast_allocate_d_buf();
 
+    if(manin != NULL)
+        manin_cell = Rast_allocate_f_buf();
+
     if (rain != NULL)
-	cell4 = Rast_allocate_d_buf();
+	rain_cell = Rast_allocate_d_buf();
 
     if (infil != NULL)
-	cell4a = Rast_allocate_d_buf();
+	infil_cell = Rast_allocate_d_buf();
 
     if (traps != NULL)
-	cell4b = Rast_allocate_f_buf();
-    cell5 = Rast_allocate_f_buf();
+	traps_cell = Rast_allocate_f_buf();
 
     if (detin != NULL)
-	cell9 = Rast_allocate_f_buf();
+	detin_cell = Rast_allocate_f_buf();
 
     if (tranin != NULL)
-	cell10 = Rast_allocate_f_buf();
+	trainin_cell = Rast_allocate_f_buf();
 
     if (tauin != NULL)
-	cell11 = Rast_allocate_f_buf();
+	tauin_cell = Rast_allocate_f_buf();
 
     if (wdepth != NULL)
-	cell12 = Rast_allocate_d_buf();
+	wdepth_cell = Rast_allocate_d_buf();
 
     /* Allocate some double dimension arrays for each input */
     /* with length of matrix Y */
@@ -141,93 +143,93 @@
     if (wdepth != NULL)
 	gama = G_alloc_matrix(my, mx);
 
-    G_debug(3, "Running MAY 10 version, started modifications on 20080211");
+    G_debug(3, "Running JAN 2010 version, started modifications on 20080211");
 
     /* Check if data available in mapsets
      * if found, then open the files */
-    fd1 = Rast_open_old(elevin, "");
+    elevin_fd = Rast_open_old(elevin, "");
 
     /* TO REPLACE BY INTERNAL PROCESSING of dx, dy from Elevin */
     if ((mapset = G_find_raster(dxin, "")) == NULL)
 	G_fatal_error(_("Raster map <%s> not found"), dxin);
 
-    fd2 = Rast_open_old(dxin, "");
+    dxin_fd = Rast_open_old(dxin, "");
 
-    fd3 = Rast_open_old(dyin, "");
+    dyin_fd = Rast_open_old(dyin, "");
     /* END OF REPLACEMENT */
 
     /* Rendered Mannings n input map optional to run! */
     /* Careful!                     (Yann, 20080212) */
     if (manin)
-	fd5 = Rast_open_old(manin, "");
+	manin_fd = Rast_open_old(manin, "");
 
     /* Rendered Rainfall input map optional to run! */
     /* Careful!                     (Yann, 20080212) */
     if (rain)
-	fd4 = Rast_open_old(rain, "");
+	rain_fd = Rast_open_old(rain, "");
 
     if (infil)
-	fd4a = Rast_open_old(infil, "");
+	infil_fd = Rast_open_old(infil, "");
 
     if (traps)
-	fd4b = Rast_open_old(traps, "");
+	traps_fd = Rast_open_old(traps, "");
 
     if (detin)
-	fd9 = Rast_open_old(detin, "");
+	detin_fd = Rast_open_old(detin, "");
 
     if (tranin)
-	fd10 = Rast_open_old(tranin, "");
+	trainin_fd = Rast_open_old(tranin, "");
 
     if (tauin)
-	fd11 = Rast_open_old(tauin, "");
+	tauin_fd = Rast_open_old(tauin, "");
 
     if (wdepth)
-	fd12 = Rast_open_old(wdepth, "");
+	wdepth_fd = Rast_open_old(wdepth, "");
 
     for (row = 0; row < my; row++) {
-	Rast_get_f_row(fd1, cell1, row);
-	Rast_get_d_row(fd2, cell2, row);
-	Rast_get_d_row(fd3, cell3, row);
+	Rast_get_f_row(elevin_fd, elevin_cell, row);
+	Rast_get_d_row(dxin_fd, dxin_cell, row);
+	Rast_get_d_row(dyin_fd, dyin_cell, row);
 
 	if (manin)
-	    Rast_get_f_row(fd5, cell5, row);
+	    Rast_get_f_row(manin_fd, manin_cell, row);
 
 	if (rain)
-	    Rast_get_d_row(fd4, cell4, row);
+	    Rast_get_d_row(rain_fd, rain_cell, row);
 
 	if (infil)
-	    Rast_get_d_row(fd4a, cell4a, row);
+	    Rast_get_d_row(infil_fd, infil_cell, row);
 
 	if (traps)
-	    Rast_get_f_row(fd4b, cell4b, row);
+	    Rast_get_f_row(traps_fd, traps_cell, row);
 
 	if (detin)
-	    Rast_get_f_row(fd9, cell9, row);
+	    Rast_get_f_row(detin_fd, detin_cell, row);
 
 	if (tranin)
-	    Rast_get_f_row(fd10, cell10, row);
+	    Rast_get_f_row(trainin_fd, trainin_cell, row);
 
 	if (tauin)
-	    Rast_get_f_row(fd11, cell11, row);
+	    Rast_get_f_row(tauin_fd, tauin_cell, row);
 
 	if (wdepth)
-	    Rast_get_d_row(fd12, cell12, row);
+	    Rast_get_d_row(wdepth_fd, wdepth_cell, row);
 
 	for (j = 0; j < mx; j++) {
 	    row_rev = my - row - 1;
 	    /*if elevation data exists store in zz[][] */
-	    if (!Rast_is_f_null_value(cell1 + j))
-		zz[row_rev][j] = (float)(conv * cell1[j]);
+	    if (!Rast_is_f_null_value(elevin_cell + j))
+		zz[row_rev][j] = (float)(conv * elevin_cell[j]);
 	    else
 		zz[row_rev][j] = UNDEF;
 
-	    if (!Rast_is_d_null_value(cell2 + j))
-		v1[row_rev][j] = (double)cell2[j];
+	    if (!Rast_is_d_null_value(dxin_cell + j))
+		v1[row_rev][j] = (double)dxin_cell[j];
 	    else
 		v1[row_rev][j] = UNDEF;
 
-	    if (!Rast_is_d_null_value(cell3 + j))
-		v2[row_rev][j] = (double)cell3[j];
+	    if (!Rast_is_d_null_value(dyin_cell + j))
+		v2[row_rev][j] = (double)dyin_cell[j];
 	    else
 		v2[row_rev][j] = UNDEF;
 
@@ -246,8 +248,8 @@
 
 	    /* If Rain Exists, then load data */
 	    if (rain) {
-		if (!Rast_is_d_null_value(cell4 + j))
-		    si[row_rev][j] = ((double)cell4[j]) * unitconv;
+		if (!Rast_is_d_null_value(rain_cell + j))
+		    si[row_rev][j] = ((double)rain_cell[j]) * unitconv;
 		/*conv mm/hr to m/s */
 		/*printf("\n INPUTrain, convert %f %f",si[row_rev][j],unitconv); */
 
@@ -258,8 +260,8 @@
 
 		/* Load infiltration map too if it exists */
 		if (infil) {
-		    if (!Rast_is_d_null_value(cell4a + j))
-			inf[row_rev][j] = (double)cell4a[j] * unitconv;
+		    if (!Rast_is_d_null_value(infil_cell + j))
+			inf[row_rev][j] = (double)infil_cell[j] * unitconv;
 		    /*conv mm/hr to m/s */
 		    /*printf("\nINPUT infilt,convert %f %f",inf[row_rev][j],unitconv); */
 		    else {
@@ -280,8 +282,8 @@
 		}
 
 		if (traps) {
-		    if (!Rast_is_f_null_value(cell4b + j))
-			trap[row_rev][j] = (float)cell4b[j];	/* no conv, unitless */
+		    if (!Rast_is_f_null_value(traps_cell + j))
+			trap[row_rev][j] = (float)traps_cell[j];	/* no conv, unitless */
 		    else {
 			trap[row_rev][j] = UNDEF;
 			zz[row_rev][j] = UNDEF;
@@ -300,8 +302,8 @@
 		}
 
 		if (infil) {
-		    if (!Rast_is_d_null_value(cell4a + j))
-			inf[row_rev][j] = (double)cell4a[j] * unitconv;	/*conv mm/hr to m/s */
+		    if (!Rast_is_d_null_value(infil_cell + j))
+			inf[row_rev][j] = (double)infil_cell[j] * unitconv;	/*conv mm/hr to m/s */
 		    /*printf("\nINPUT infilt,convert %f %f",inf[row_rev][j],unitconv); */
 		    else {
 			inf[row_rev][j] = UNDEF;
@@ -321,8 +323,8 @@
 		}
 
 		if (traps) {
-		    if (!Rast_is_f_null_value(cell4b + j))
-			trap[row_rev][j] = (float)cell4b[j];	/* no conv, unitless */
+		    if (!Rast_is_f_null_value(traps_cell + j))
+			trap[row_rev][j] = (float)traps_cell[j];	/* no conv, unitless */
 		    else {
 			trap[row_rev][j] = UNDEF;
 			zz[row_rev][j] = UNDEF;
@@ -330,8 +332,8 @@
 		}
 	    }			/* End of added by Yann 20080213 */
 	    if (manin) {
-		if (!Rast_is_f_null_value(cell5 + j)) {
-		    cchez[row_rev][j] = (float)cell5[j];	/* units in manual */
+		if (!Rast_is_f_null_value(manin_cell + j)) {
+		    cchez[row_rev][j] = (float)manin_cell[j];	/* units in manual */
 		}
 		else {
 		    cchez[row_rev][j] = UNDEF;
@@ -346,8 +348,8 @@
 			      manin);
 	    }
 	    if (detin) {
-		if (!Rast_is_f_null_value(cell9 + j))
-		    dc[row_rev][j] = (float)cell9[j];	/*units in manual */
+		if (!Rast_is_f_null_value(detin_cell + j))
+		    dc[row_rev][j] = (float)detin_cell[j];	/*units in manual */
 		else {
 		    dc[row_rev][j] = UNDEF;
 		    zz[row_rev][j] = UNDEF;
@@ -355,8 +357,8 @@
 	    }
 
 	    if (tranin) {
-		if (!Rast_is_f_null_value(cell10 + j))
-		    ct[row_rev][j] = (float)cell10[j];	/*units in manual */
+		if (!Rast_is_f_null_value(trainin_cell + j))
+		    ct[row_rev][j] = (float)trainin_cell[j];	/*units in manual */
 		else {
 		    ct[row_rev][j] = UNDEF;
 		    zz[row_rev][j] = UNDEF;
@@ -364,8 +366,8 @@
 	    }
 
 	    if (tauin) {
-		if (!Rast_is_f_null_value(cell11 + j))
-		    tau[row_rev][j] = (float)cell11[j];	/*units in manual */
+		if (!Rast_is_f_null_value(tauin_cell + j))
+		    tau[row_rev][j] = (float)tauin_cell[j];	/*units in manual */
 		else {
 		    tau[row_rev][j] = UNDEF;
 		    zz[row_rev][j] = UNDEF;
@@ -373,8 +375,8 @@
 	    }
 
 	    if (wdepth) {
-		if (!Rast_is_d_null_value(cell12 + j))
-		    gama[row_rev][j] = (double)cell12[j];	/*units in manual */
+		if (!Rast_is_d_null_value(wdepth_cell + j))
+		    gama[row_rev][j] = (double)wdepth_cell[j];	/*units in manual */
 		else {
 		    gama[row_rev][j] = UNDEF;
 		    zz[row_rev][j] = UNDEF;
@@ -382,34 +384,34 @@
 	    }
 	}
     }
-    Rast_close(fd1);
-    Rast_close(fd2);
-    Rast_close(fd3);
+    Rast_close(elevin_fd);
+    Rast_close(dxin_fd);
+    Rast_close(dyin_fd);
 
     if (rain)
-	Rast_close(fd4);
+	Rast_close(rain_fd);
 
     if (infil)
-	Rast_close(fd4a);
+	Rast_close(infil_fd);
 
     if (traps)
-	Rast_close(fd4b);
+	Rast_close(traps_fd);
     /* Maybe a conditional to manin!=NULL here ! */
-    Rast_close(fd5);
+    Rast_close(manin_fd);
 
 	/****************/
 
     if (detin)
-	Rast_close(fd9);
+	Rast_close(detin_fd);
 
     if (tranin)
-	Rast_close(fd10);
+	Rast_close(trainin_fd);
 
     if (tauin)
-	Rast_close(fd11);
+	Rast_close(tauin_fd);
 
     if (wdepth)
-	Rast_close(fd12);
+	Rast_close(wdepth_fd);
 
     return 1;
 }

Modified: grass/trunk/raster/simwe/simlib/output.c
===================================================================
--- grass/trunk/raster/simwe/simlib/output.c	2010-01-27 17:10:07 UTC (rev 40701)
+++ grass/trunk/raster/simwe/simlib/output.c	2010-01-27 22:41:36 UTC (rev 40702)
@@ -15,10 +15,10 @@
 int output_data(int tt, double ft)
 {
 
-    FCELL *cell6, *cell7, *cell8;
-    FCELL *cell14, *cell15, *cell16;
-    int fd6, fd7, fd8;
-    int fd14, fd15, fd16;
+    FCELL *depth_cell, *disch_cell, *err_cell;
+    FCELL *conc_cell, *flux_cell, *erdep_cell;
+    int depth_fd, disch_fd, err_fd;
+    int conc_fd, flux_fd, erdep_fd;
     int i, iarc, j;
     float gsmax = 0, dismax = 0., gmax = 0., ermax = -1.e+12, ermin = 1.e+12;
     struct Colors colors;
@@ -27,7 +27,7 @@
     char *conc0 = NULL, *flux0 = NULL;
 /*    char *erdep0 = NULL, *outwalk0 = NULL; */
     char *erdep0 = NULL;
-    char *mapst = NULL;
+    const char *mapst = NULL;
     char *type;
     char buf[256];
     int ndigit;
@@ -37,7 +37,6 @@
     Site *sd;
 */
 
-
     ndigit = 2;
     if (timesec >= 10)
 	ndigit = 3;
@@ -90,73 +89,71 @@
     }
 */
     if (depth) {
-	cell6 = Rast_allocate_f_buf();
+	depth_cell = Rast_allocate_f_buf();
 	if (ts == 1) {
 	    sprintf(buf, "%s.%.*d", depth, ndigit, tt);
 	    depth0 = G_store(buf);
-	    fd6 = Rast_open_fp_new(depth0);
+	    depth_fd = Rast_open_fp_new(depth0);
 	}
 	else
-	    fd6 = Rast_open_fp_new(depth);
+	    depth_fd = Rast_open_fp_new(depth);
     }
 
     if (disch) {
-	cell7 = Rast_allocate_f_buf();
+	disch_cell = Rast_allocate_f_buf();
 	if (ts == 1) {
 	    sprintf(buf, "%s.%.*d", disch, ndigit, tt);
 	    disch0 = G_store(buf);
-	    fd7 = Rast_open_fp_new(disch0);
+	    disch_fd = Rast_open_fp_new(disch0);
 	}
 	else
-	    fd7 = Rast_open_fp_new(disch);
+	    disch_fd = Rast_open_fp_new(disch);
     }
 
     if (err) {
-	cell8 = Rast_allocate_f_buf();
+	err_cell = Rast_allocate_f_buf();
 	if (ts == 1) {
 	    sprintf(buf, "%s.%.*d", err, ndigit, tt);
 	    err0 = G_store(buf);
-	    fd8 = Rast_open_fp_new(err0);
+	    err_fd = Rast_open_fp_new(err0);
 	}
 	else
-	    fd8 = Rast_open_fp_new(err);
+	    err_fd = Rast_open_fp_new(err);
     }
 
-
     if (conc) {
-	cell14 = Rast_allocate_f_buf();
+	conc_cell = Rast_allocate_f_buf();
 	if (ts == 1) {
 	    sprintf(buf, "%s.%.*d", conc, ndigit, tt);
 	    conc0 = G_store(buf);
-	    fd14 = Rast_open_fp_new(conc0);
+	    conc_fd = Rast_open_fp_new(conc0);
 	}
 	else
-	    fd14 = Rast_open_fp_new(conc);
+	    conc_fd = Rast_open_fp_new(conc);
     }
 
     if (flux) {
-	cell15 = Rast_allocate_f_buf();
+	flux_cell = Rast_allocate_f_buf();
 	if (ts == 1) {
 	    sprintf(buf, "%s.%.*d", flux, ndigit, tt);
 	    flux0 = G_store(buf);
-	    fd15 = Rast_open_fp_new(flux0);
+	    flux_fd = Rast_open_fp_new(flux0);
 	}
 	else
-	    fd15 = Rast_open_fp_new(flux);
+	    flux_fd = Rast_open_fp_new(flux);
     }
 
     if (erdep) {
-	cell16 = Rast_allocate_f_buf();
+	erdep_cell = Rast_allocate_f_buf();
 	if (ts == 1) {
 	    sprintf(buf, "%s.%.*d", erdep, ndigit, tt);
 	    erdep0 = G_store(buf);
-	    fd16 = Rast_open_fp_new(erdep0);
+	    erdep_fd = Rast_open_fp_new(erdep0);
 	}
 	else
-	    fd16 = Rast_open_fp_new(erdep);
+	    erdep_fd = Rast_open_fp_new(erdep);
     }
 
-
     Rast_set_window(&cellhd);
 
     if (my != G_window_rows())
@@ -171,98 +168,94 @@
 	if (depth) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || gama[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell6 + j, 1);
+		    Rast_set_f_null_value(depth_cell + j, 1);
 		else {
 		    a1 = pow(gama[i][j], 3. / 5.);
-		    cell6[j] = (FCELL) a1;	/* add conv? */
+		    depth_cell[j] = (FCELL) a1;	/* add conv? */
 		    gmax = amax1(gmax, a1);
 		}
 	    }
-	    Rast_put_f_row(fd6, cell6);
+	    Rast_put_f_row(depth_fd, depth_cell);
 	}
 
 	if (disch) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || gama[i][j] == UNDEF ||
 		    cchez[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell7 + j, 1);
+		    Rast_set_f_null_value(disch_cell + j, 1);
 		else {
 		    a2 = step * gama[i][j] * cchez[i][j];	/* cchez incl. sqrt(sinsl) */
-		    cell7[j] = (FCELL) a2;	/* add conv? */
+		    disch_cell[j] = (FCELL) a2;	/* add conv? */
 		    dismax = amax1(dismax, a2);
 		}
 	    }
-	    Rast_put_f_row(fd7, cell7);
+	    Rast_put_f_row(disch_fd, disch_cell);
 	}
 
 	if (err) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || gammas[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell8 + j, 1);
+		    Rast_set_f_null_value(err_cell + j, 1);
 		else {
-		    cell8[j] = (FCELL) gammas[i][j];
+		    err_cell[j] = (FCELL) gammas[i][j];
 		    gsmax = amax1(gsmax, gammas[i][j]);	/* add conv? */
 		}
 	    }
-	    Rast_put_f_row(fd8, cell8);
+	    Rast_put_f_row(err_fd, err_cell);
 	}
 
-
 	if (conc) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || gama[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell14 + j, 1);
+		    Rast_set_f_null_value(conc_cell + j, 1);
 		else {
-		    cell14[j] = (FCELL) gama[i][j];
+		    conc_cell[j] = (FCELL) gama[i][j];
 		    /*      gsmax = amax1(gsmax, gama[i][j]); */
 		}
 	    }
-	    Rast_put_f_row(fd14, cell14);
+	    Rast_put_f_row(conc_fd, conc_cell);
 	}
 
-
 	if (flux) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || gama[i][j] == UNDEF ||
 		    slope[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell15 + j, 1);
+		    Rast_set_f_null_value(flux_cell + j, 1);
 		else {
 		    a2 = gama[i][j] * slope[i][j];
-		    cell15[j] = (FCELL) a2;
+		    flux_cell[j] = (FCELL) a2;
 		    dismax = amax1(dismax, a2);
 		}
 	    }
-	    Rast_put_f_row(fd15, cell15);
+	    Rast_put_f_row(flux_fd, flux_cell);
 	}
 
-
 	if (erdep) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || er[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell16 + j, 1);
+		    Rast_set_f_null_value(erdep_cell + j, 1);
 		else {
-		    cell16[j] = (FCELL) er[i][j];
+		    erdep_cell[j] = (FCELL) er[i][j];
 		    ermax = amax1(ermax, er[i][j]);
 		    ermin = amin1(ermin, er[i][j]);
 		}
 	    }
-	    Rast_put_f_row(fd16, cell16);
+	    Rast_put_f_row(erdep_fd, erdep_cell);
 	}
-
     }
 
     if (depth)
-	Rast_close(fd6);
+	Rast_close(depth_fd);
     if (disch)
-	Rast_close(fd7);
+	Rast_close(disch_fd);
     if (err)
-	Rast_close(fd8);
+	Rast_close(err_fd);
     if (conc)
-	Rast_close(fd14);
+	Rast_close(conc_fd);
     if (flux)
-	Rast_close(fd15);
+	Rast_close(flux_fd);
     if (erdep)
-	Rast_close(fd16);
+	Rast_close(erdep_fd);
 
     if (depth) {
 
@@ -305,7 +298,6 @@
 				    (CELL) gmax);
 	    Rast_free_colors(&colors);
 	}
-
     }
 
     if (disch) {
@@ -391,7 +383,6 @@
 	}
     }
 
-
     if (erdep) {
 
 	Rast_init_colors(&colors);
@@ -587,8 +578,8 @@
 int output_et()
 {
 
-    FCELL *cell13, *cell17;
-    int fd13, fd17;
+    FCELL *tc_cell, *et_cell;
+    int tc_fd, et_fd;
     int i, iarc, j;
     float etmax = -1.e+12, etmin = 1.e+12;
     float trc;
@@ -600,31 +591,28 @@
 
     /*   float a1,a2; */
 
-
-
     if (et) {
-	cell17 = Rast_allocate_f_buf();
+	et_cell = Rast_allocate_f_buf();
 	/*      if (ts == 1) {
 	   sprintf(buf,"%s.%.*d",et,ndigit,tt);
 	   et0 = G_store(buf);
-	   fd17 = Rast_open_fp_new (et0);
+	   et_fd = Rast_open_fp_new (et0);
 	   }
 	   else */
-	fd17 = Rast_open_fp_new(et);
+	et_fd = Rast_open_fp_new(et);
     }
 
     if (tc) {
-	cell13 = Rast_allocate_f_buf();
+	tc_cell = Rast_allocate_f_buf();
 	/*   if (ts == 1) {
 	   sprintf(buf,"%s.%.*d",tc,ndigit,tt);
 	   tc0 = G_store(buf);
-	   fd13 = Rast_open_fp_new (tc0);
+	   tc_fd = Rast_open_fp_new (tc0);
 	   }
 	   else */
-	fd13 = Rast_open_fp_new(tc);
+	tc_fd = Rast_open_fp_new(tc);
     }
 
-
     Rast_set_window(&cellhd);
 
     if (my != G_window_rows())
@@ -639,40 +627,39 @@
 	if (et) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || er[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell17 + j, 1);
+		    Rast_set_f_null_value(et_cell + j, 1);
 		else {
-		    cell17[j] = (FCELL) er[i][j];	/* add conv? */
+		    et_cell[j] = (FCELL) er[i][j];	/* add conv? */
 		    etmax = amax1(etmax, er[i][j]);
 		    etmin = amin1(etmin, er[i][j]);
 		}
 	    }
-	    Rast_put_f_row(fd17, cell17);
+	    Rast_put_f_row(et_fd, et_cell);
 	}
 
 	if (tc) {
 	    for (j = 0; j < mx; j++) {
 		if (zz[i][j] == UNDEF || sigma[i][j] == UNDEF ||
 		    si[i][j] == UNDEF)
-		    Rast_set_f_null_value(cell13 + j, 1);
+		    Rast_set_f_null_value(tc_cell + j, 1);
 		else {
 		    if (sigma[i][j] == 0.)
 			trc = 0.;
 		    else
 			trc = si[i][j] / sigma[i][j];
-		    cell13[j] = (FCELL) trc;
+		    tc_cell[j] = (FCELL) trc;
 		    /*  gsmax = amax1(gsmax, trc); */
 		}
 	    }
-	    Rast_put_f_row(fd13, cell13);
+	    Rast_put_f_row(tc_fd, tc_cell);
 	}
     }
 
-
     if (tc)
-	Rast_close(fd13);
+	Rast_close(tc_fd);
 
     if (et)
-	Rast_close(fd17);
+	Rast_close(et_fd);
 
     if (et) {
 



More information about the grass-commit mailing list