Skip to content

Commit

Permalink
r.sim: fix previously ignored infil_value (backport) (OSGeo#3119)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa authored Aug 14, 2023
1 parent 5007c30 commit 3b6cb1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion raster/r.sim/simlib/hydro.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void main_loop(void)
}

if (zz[k][l] != UNDEF) {
if (infil != NULL) { /* infiltration part */
if (inf[k][l] != UNDEF) { /* infiltration part */
if (inf[k][l] - si[k][l] > 0.) {

decr = pow(addac * w[lw].m, 3. / 5.); /* decreasing factor in m */
Expand Down
29 changes: 11 additions & 18 deletions raster/r.sim/simlib/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ int input_data(void)
int rows = my, cols = mx; /* my and mx are global variables */
int max_walkers;
double unitconv = 0.000000278; /* mm/hr to m/s */
int if_rain = 0;

G_debug(1, "Running MAR 2011 version, started modifications on 20080211");
G_debug(1, "Reading input data");
Expand All @@ -321,35 +320,29 @@ int input_data(void)
/* Rain: read rain map or use a single value for all cells */
if (rain != NULL) {
si = read_double_raster_map(rows, cols, rain, unitconv);
if_rain = 1;
} else if(rain_val >= 0.0) { /* If no value set its set to -999.99 */
si = create_double_matrix(rows, cols, rain_val * unitconv);
if_rain = 1;
} else{
si = create_double_matrix(rows, cols, (double)UNDEF);
if_rain = 0;
}

/* Update elevation map */
copy_matrix_undef_double_to_float_values(rows, cols, si, zz);

/* Load infiltration and traps if rain is present */
if(if_rain == 1) {
/* Infiltration: read map or use a single value */
if (infil != NULL) {
inf = read_double_raster_map(rows, cols, infil, unitconv);
} else if(infil_val >= 0.0) { /* If no value set its set to -999.99 */
inf = create_double_matrix(rows, cols, infil_val * unitconv);
} else{
inf = create_double_matrix(rows, cols, (double)UNDEF);
}
if (infil != NULL) {
inf = read_double_raster_map(rows, cols, infil, unitconv);
} else if(infil_val >= 0.0) { /* If no value set its set to -999.99 */
inf = create_double_matrix(rows, cols, infil_val * unitconv);
} else{
inf = create_double_matrix(rows, cols, (double)UNDEF);
}

/* Traps */
if (traps != NULL)
trap = read_float_raster_map(rows, cols, traps, 1.0);
else
trap = create_float_matrix(rows, cols, (double)UNDEF);
}
if (traps != NULL)
trap = read_float_raster_map(rows, cols, traps, 1.0);
else
trap = create_float_matrix(rows, cols, (double)UNDEF);

if (detin != NULL) {
dc = read_float_raster_map(rows, cols, detin, 1.0);
Expand Down

0 comments on commit 3b6cb1c

Please sign in to comment.