From ec6c4d53f5e5c0ede6b75b82c56682f813f7a546 Mon Sep 17 00:00:00 2001 From: dschlaep Date: Tue, 23 Jan 2018 15:15:08 -0500 Subject: [PATCH] Correctly initialize new array variables - this commit exactly reproduces output as current master (plus new fix for forbs #47) --- SW_Flow.c | 10 +++++----- SW_Site.c | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/SW_Flow.c b/SW_Flow.c index 1cf882ebc..ccf4a041a 100644 --- a/SW_Flow.c +++ b/SW_Flow.c @@ -132,6 +132,7 @@ extern SW_SKY SW_Sky; extern unsigned int soil_temp_init; // simply keeps track of whether or not the values for the soil_temperature function have been initialized. 0 for no, 1 for yes. extern unsigned int fusion_pool_init; +extern char const *key2veg[]; /* *************************************************** */ /* Module-Level Variables */ @@ -148,7 +149,6 @@ RealD lyrSWCBulk[MAX_LAYERS], lyrDrain[MAX_LAYERS], lyrTransp[NVEGTYPES][MAX_LAYERS], lyrTranspCo[NVEGTYPES][MAX_LAYERS], lyrEvap[NVEGTYPES][MAX_LAYERS], lyrEvap_BareGround[MAX_LAYERS], lyrSWCBulk_atSWPcrit[NVEGTYPES][MAX_LAYERS], lyrHydRed[NVEGTYPES][MAX_LAYERS], - lyrHydRed[NVEGTYPES][MAX_LAYERS], lyrbDensity[MAX_LAYERS], lyrWidths[MAX_LAYERS], lyrEvapCo[MAX_LAYERS], lyrSumTrCo[MAX_TRANSP_REGIONS + 1], @@ -248,14 +248,14 @@ void SW_Water_Flow(void) { SW_SOILWAT *sw = &SW_Soilwat; RealD swpot_avg[NVEGTYPES], - transp_veg[NVEGTYPES], transp_rate[NVEGTYPES] = {1.}, - soil_evap[NVEGTYPES], soil_evap_rate[NVEGTYPES] = {1.}, soil_evap_rate_bs = 1., - surface_evap_veg_rate[NVEGTYPES] = {1.}, + transp_veg[NVEGTYPES], transp_rate[NVEGTYPES], + soil_evap[NVEGTYPES], soil_evap_rate[NVEGTYPES], soil_evap_rate_bs = 1., + surface_evap_veg_rate[NVEGTYPES], surface_evap_litter_rate = 1., surface_evap_standingWater_rate = 1., snow_evap_rate = 1., veg_h2o[NVEGTYPES], litter_h2o, litter_h2o_help, h2o_for_soil = 0., ppt_toUse, snowmelt, - snowdepth_scale_veg[NVEGTYPES] = {1.}, + snowdepth_scale_veg[NVEGTYPES], rate_help, x; int doy, k; diff --git a/SW_Site.c b/SW_Site.c index 4b4277390..a3406dd59 100644 --- a/SW_Site.c +++ b/SW_Site.c @@ -433,7 +433,7 @@ static void _read_layers(void) { SW_SITE *v = &SW_Site; FILE *f; Bool evap_ok = swTRUE, /* mitigate gaps in layers' evap coeffs */ - transp_ok_veg[NVEGTYPES] = {swTRUE}, /* same for transpiration coefficients */ + transp_ok_veg[NVEGTYPES], /* same for transpiration coefficients */ fail = swFALSE; LyrIndex lyrno; int x, k; @@ -441,6 +441,11 @@ static void _read_layers(void) { RealF dmin = 0.0, dmax, evco, trco_veg[NVEGTYPES], psand, pclay, matricd, imperm, soiltemp, fval = 0, f_gravel; + // Initialize + ForEachVegType(k) { + transp_ok_veg[k] = swTRUE; + } + /* note that Files.read() must be called prior to this. */ MyFileName = SW_F_name(eLayers);