[GRASS-SVN] r60792 - grass/branches/releasebranch_7_0/raster/r.topmodel

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 11 07:01:54 PDT 2014


Author: hcho
Date: 2014-06-11 07:01:54 -0700 (Wed, 11 Jun 2014)
New Revision: 60792

Modified:
   grass/branches/releasebranch_7_0/raster/r.topmodel/file_io.c
   grass/branches/releasebranch_7_0/raster/r.topmodel/global.h
   grass/branches/releasebranch_7_0/raster/r.topmodel/topmodel.c
Log:
r.topmodel: added tcsub for the time of concentration in the subcatchment (merge from r60791)

Modified: grass/branches/releasebranch_7_0/raster/r.topmodel/file_io.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.topmodel/file_io.c	2014-06-11 13:53:45 UTC (rev 60791)
+++ grass/branches/releasebranch_7_0/raster/r.topmodel/file_io.c	2014-06-11 14:01:54 UTC (rev 60792)
@@ -98,7 +98,6 @@
     if (params.qs0 == 0.0) {
 	fclose(fp);
 	G_fatal_error(_("%s cannot be 0"), "parameters.qs0");
-	exit(EXIT_FAILURE);
     }
     for (; !feof(fp);) {
 	get_line(fp, buf);
@@ -249,6 +248,7 @@
     fprintf(fp, "# nch:                     Number of channel segments\n");
     fprintf(fp, "# delay [timestep]:        Routing delay in the main channel\n");
     fprintf(fp, "# tc [timestep]:           Time of concentration\n");
+    fprintf(fp, "# tcsub [timestep]:        Time of concentration in the subcatchment\n");
     fprintf(fp, "#\n");
     fprintf(fp, "# tch [timestep]:          Routing time to the catchment outlet\n");
     fprintf(fp, "# Ad [m^2]:                Difference in the contribution area\n");
@@ -289,6 +289,7 @@
     fprintf(fp, "nch:            %10d\n", params.nch);
     fprintf(fp, "delay:          %10d\n", misc.delay);
     fprintf(fp, "tc:             %10d\n", misc.tc);
+    fprintf(fp, "tcsub:          %10d\n", misc.tcsub);
     fprintf(fp, "\n");
 
     fprintf(fp, "%10s\n", "tch");
@@ -297,7 +298,7 @@
     fprintf(fp, "\n");
 
     fprintf(fp, "%10s\n", "Ad");
-    for (i = 0; i < misc.tc; i++)
+    for (i = 0; i < misc.tcsub; i++)
 	fprintf(fp, "%10.3e\n", misc.Ad[i]);
     fprintf(fp, "\n");
 

Modified: grass/branches/releasebranch_7_0/raster/r.topmodel/global.h
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.topmodel/global.h	2014-06-11 13:53:45 UTC (rev 60791)
+++ grass/branches/releasebranch_7_0/raster/r.topmodel/global.h	2014-06-11 14:01:54 UTC (rev 60792)
@@ -91,6 +91,7 @@
     int ntopidxclasses;
     int delay;
     int tc;
+    int tcsub;
     double lnTe;
     double vch;
     double vr;
@@ -103,7 +104,7 @@
     int tt_peak;
     /* params.nch's */
     double *tch;
-    /* misc.tc's */
+    /* misc.tcsub's */
     double *Ad;
     /* input.ntimestep's */
     double *Qt;

Modified: grass/branches/releasebranch_7_0/raster/r.topmodel/topmodel.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.topmodel/topmodel.c	2014-06-11 13:53:45 UTC (rev 60791)
+++ grass/branches/releasebranch_7_0/raster/r.topmodel/topmodel.c	2014-06-11 14:01:54 UTC (rev 60792)
@@ -76,11 +76,11 @@
     misc.delay = (int)misc.tch[0];
 
     /* time of concentration in the subcatchment */
-    misc.tc -= misc.delay;
+    misc.tcsub = misc.tc - misc.delay;
 
     /* cumulative ratio of the contribution area for each time step */
-    misc.Ad = (double *)G_malloc(misc.tc * sizeof(double));
-    for (i = 0; i < misc.tc; i++) {
+    misc.Ad = (double *)G_malloc(misc.tcsub * sizeof(double));
+    for (i = 0; i < misc.tcsub; i++) {
 	t = misc.delay + i + 1;
 	if (t > misc.tch[params.nch - 1])
 	    misc.Ad[i] = 1.0;
@@ -100,7 +100,7 @@
     /* difference in the contribution area for each time step */
     A1 = misc.Ad[0];
     misc.Ad[0] *= params.A;
-    for (i = 1; i < misc.tc; i++) {
+    for (i = 1; i < misc.tcsub; i++) {
 	A2 = misc.Ad[i];
 	misc.Ad[i] = (A2 - A1) * params.A;
 	A1 = A2;
@@ -131,7 +131,7 @@
     for (i = 0; i < input.ntimesteps; i++) {
 	if (i < misc.delay)
 	    misc.Qt[i] = misc.qs0 * params.A;
-	else if (i < misc.delay + misc.tc) {
+	else if (i < misc.tc) {
 	    A1 += misc.Ad[i - misc.delay];
 	    misc.Qt[i] = misc.qs0 * (params.A - A1);
 	} else
@@ -287,7 +287,7 @@
 	    misc.S_mean[i + 1] = misc.S_mean[i];
 
 	/* total flow in m^3/timestep */
-	for (j = 0; j < misc.tc; j++) {
+	for (j = 0; j < misc.tcsub; j++) {
 	    k = i + j + misc.delay;
 	    if (k > input.ntimesteps - 1)
 		break;
@@ -305,9 +305,6 @@
 	}
     }
     misc.Qt_mean /= input.ntimesteps;
-
-    /* time of concentration */
-    misc.tc += misc.delay;
 }
 
 void run_topmodel(void)



More information about the grass-commit mailing list