Skip to content

Commit 29e72b3

Browse files
committed
Fixed the use of uninitialized soil moisture array on first time step.
1 parent 07db13e commit 29e72b3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/README.txt

+17
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ Usage:
3333
Bug Fixes:
3434
----------
3535

36+
Fixed use of uninitialized soil moisture values on first time step.
37+
38+
Files Affected:
39+
40+
initialize_model_state.c
41+
42+
Description:
43+
44+
The tmp_moist array, used in initialize_model_state() as an input to
45+
compute_runoff_and_asat(), was initialized within an if statement that
46+
caused it to be sent to compute_runoff_and_asat() without initialization
47+
in some cases. This has been fixed by moving the initialization of
48+
tmp_moist outside the if statement.
49+
50+
51+
52+
3653
Fixed errors in forcing disaggregation under certain input cases.
3754

3855
Files Affected:

src/initialize_model_state.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ int initialize_model_state(dist_prcp_struct *prcp,
115115
2012-Jan-16 Removed LINK_DEBUG code BN
116116
2012-Jan-28 Added stability check for case of (FROZEN_SOIL=TRUE &&
117117
IMPLICIT=FALSE). TJB
118+
2013-Jul-30 Moved computation of tmp_moist argument of
119+
compute_runoff_and_asat() so that it would always be
120+
initialized. TJB
118121
**********************************************************************/
119122
{
120123
extern option_struct options;
@@ -377,7 +380,6 @@ int initialize_model_state(dist_prcp_struct *prcp,
377380
cell[dist][veg][band].layer[lidx].ice *= soil_con->max_moist[lidx]/cell[dist][veg][band].layer[lidx].moist;
378381
#endif
379382
cell[dist][veg][band].layer[lidx].moist = soil_con->max_moist[lidx];
380-
tmp_moist[lidx] = cell[dist][veg][band].layer[lidx].moist;
381383
}
382384

383385
#if SPATIAL_FROST
@@ -389,6 +391,7 @@ int initialize_model_state(dist_prcp_struct *prcp,
389391
if (cell[dist][veg][band].layer[lidx].ice > cell[dist][veg][band].layer[lidx].moist)
390392
cell[dist][veg][band].layer[lidx].ice = cell[dist][veg][band].layer[lidx].moist;
391393
#endif
394+
tmp_moist[lidx] = cell[dist][veg][band].layer[lidx].moist;
392395

393396
}
394397
compute_runoff_and_asat(soil_con, tmp_moist, 0, &(cell[dist][veg][band].asat), &tmp_runoff);

0 commit comments

Comments
 (0)