Skip to content

Commit 5a570f7

Browse files
committed
Moved SPATIAL_SNOW from compile-time to run-time options.
1 parent c4dcb66 commit 5a570f7

13 files changed

+141
-111
lines changed

samples/global.param.sample

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ STARTHOUR 00 # hour model simulation starts
1616
ENDYEAR 2000 # year model simulation ends
1717
ENDMONTH 12 # month model simulation ends
1818
ENDDAY 31 # day model simulation ends
19+
20+
#######################################################################
21+
# Energy Balance Parameters
22+
#######################################################################
1923
FULL_ENERGY TRUE # TRUE = calculate full energy balance; FALSE = compute water balance only
20-
FROZEN_SOIL TRUE # TRUE = calculate frozen soils
24+
#CLOSE_ENERGY FALSE # TRUE = all energy balance calculations (canopy air, canopy snow, ground snow,
25+
# and ground surface) are iterated to minimize the total column error
2126

2227
#######################################################################
2328
# Soil Temperature Parameters
2429
# VIC will choose appropriate values for QUICK_FLUX and IMPLICIT depending on values of FULL_ENERGY and FROZEN_SOIL; the user should only need to override VIC's choices in special cases.
2530
# The other options in this section are only applicable when FROZEN_SOIL is TRUE and their values depend on the application.
2631
#######################################################################
32+
FROZEN_SOIL TRUE # TRUE = calculate frozen soils
2733
#QUICK_FLUX FALSE # TRUE = use simplified ground heat flux method of Liang et al (1999); FALSE = use finite element method of Cherkauer et al (1999)
2834
#IMPLICIT TRUE # TRUE = use implicit solution for soil heat flux equation of Cherkauer et al (1999), otherwise uses original explicit solution.
2935
#QUICK_SOLVE FALSE # TRUE = Use Liang et al., 1999 formulation for iteration, but explicit finite difference method for final step.
@@ -60,8 +66,6 @@ FROZEN_SOIL TRUE # TRUE = calculate frozen soils
6066
# # AR_406_FULL = multiply by 10 for latent heat AND sensible heat and do NOT apply stability correction; additionally, always use overstory aero_resist for ET (as in 4.1.0).
6167
# # AR_410 = apply stability correction but do NOT multiply by 10 (as in VIC 4.1.0); additionally, always use overstory aero_resist for ET (as in 4.1.0).
6268
# # Default = AR_406_FULL
63-
#CLOSE_ENERGY FALSE # TRUE = all energy balance calculations (canopy air, canopy snow, ground snow,
64-
# and ground surface) are iterated to minimize the total column error
6569

6670
#######################################################################
6771
# Meteorological Forcing Disaggregation Parameters
@@ -94,6 +98,11 @@ FROZEN_SOIL TRUE # TRUE = calculate frozen soils
9498
#LOG_MATRIC FALSE # TRUE = use the linear interpolation of the logarithm of the matric potential
9599
# from the two surrounding layers to estimate the soil moisture drainage from each
96100
# layer (Boone and Wetzel, 1996).
101+
#SPATIAL_SNOW FALSE # TRUE = use a uniform distribution to simulate the partial coverage of the
102+
# surface by a thin snowpack. Coverage is assumed to be uniform after snowfall
103+
# until the pack begins to melt. If TRUE, VIC will expect an additional column
104+
# in the soil paramter file containing the snow distibution slope parameter
105+
# (= 2 * snow depth below which coverage < 1).
97106

98107
#######################################################################
99108
# State Files and Parameters

src/README.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,13 @@ Cleanup of compile-time options
619619
calc_atmos_energy_bal.c
620620
calc_forcing_stats.c (removed)
621621
calc_longwave.c
622+
calc_surf_energy_bal.c
622623
display_current_settings.c
623624
frozen_soil.c
624625
full_energy.c
625626
func_surf_energy_bal.c
626627
get_global_param.c
628+
ice_melt.c
627629
initialize_atmos.c
628630
initialize_global.c
629631
initialize_model_state.c
@@ -638,11 +640,13 @@ Cleanup of compile-time options
638640
runoff.c
639641
soil_conduction.c
640642
soil_thermal_eqn.c
643+
SnowPackEnergyBalance.c
644+
solve_snow.c
641645
surface_fluxes.c
642646
user_def.h
643647
vicNl_def.h
644648
vicNl.h
645-
write_model_state.h
649+
write_model_state.c
646650

647651
Description:
648652

@@ -662,6 +666,8 @@ Cleanup of compile-time options
662666

663667
* Moved CLOSE_ENERGY from compile-time to run-time options.
664668

669+
* Moved SPATIAL_SNOW from compile-time to run-time options.
670+
665671
* Moved max array dimensions such as MAX_VEG, MAX_LAYERS, etc. to
666672
vicNl_def.h.
667673

src/SnowPackEnergyBalance.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static char vcid[] = "$Id$";
8282
two elements (surface and overstory); added
8383
options.AERO_RESIST_CANSNOW. TJB
8484
2009-Sep-19 Added Added ground flux computation consistent with 4.0.6. TJB
85+
2013-Dec-27 Moved SPATIAL_SNOW from compile-time to run-time options. TJB
8586
8687
*****************************************************************************/
8788
double SnowPackEnergyBalance(double TSurf, va_list ap)
@@ -253,18 +254,19 @@ double SnowPackEnergyBalance(double TSurf, va_list ap)
253254

254255
*SensibleHeat = AirDens * Cp * (Tair - TMean) / Ra_used[0];
255256

256-
#if SPATIAL_SNOW
257-
/* Add in Sensible heat flux turbulent exchange from surrounding
258-
snow free patches - if present */
259-
if ( SnowCoverFract > 0 ) {
260-
*(AdvectedSensibleHeat) = advected_sensible_heat(SnowCoverFract,
261-
AirDens, Tair, TGrnd,
262-
Ra_used[0]);
257+
if (options.SPATIAL_SNOW) {
258+
/* Add in Sensible heat flux turbulent exchange from surrounding
259+
snow free patches - if present */
260+
if ( SnowCoverFract > 0 ) {
261+
*(AdvectedSensibleHeat) = advected_sensible_heat(SnowCoverFract,
262+
AirDens, Tair, TGrnd,
263+
Ra_used[0]);
264+
}
265+
else (*AdvectedSensibleHeat) = 0;
266+
}
267+
else {
268+
(*AdvectedSensibleHeat) = 0;
263269
}
264-
else (*AdvectedSensibleHeat) = 0;
265-
#else
266-
(*AdvectedSensibleHeat) = 0;
267-
#endif // SPATIAL_SNOW
268270

269271
/* Convert sublimation terms from m/timestep to kg/m2s */
270272
VaporMassFlux = *vapor_flux * Density / Dt;

src/calc_surf_energy_bal.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ double calc_surf_energy_bal(double Le,
172172
and clarified the descriptions of the SPATIAL_SNOW
173173
option. TJB
174174
2013-Jul-25 Added photosynthesis. TJB
175+
2013-Dec-27 Moved SPATIAL_SNOW to options_struct. TJB
175176
***************************************************************/
176177
{
177178
extern veg_lib_struct *veg_lib;
@@ -745,21 +746,21 @@ double calc_surf_energy_bal(double Le,
745746

746747
/** Check for Thin Snowpack which only Partially Covers Grid Cell
747748
exists only if not snowing and snowpack has started to melt **/
748-
#if SPATIAL_SNOW
749-
snow->coverage = calc_snow_coverage(&snow->store_snow,
750-
soil_con->max_snow_distrib_slope,
751-
snow_coverage, snow->swq,
752-
old_swq, snow->depth, old_depth,
753-
(*melt) - snow->vapor_flux,
754-
&snow->max_snow_depth, snowfall,
755-
&snow->store_swq,
756-
&snow->snow_distrib_slope,
757-
&snow->store_coverage);
758-
759-
#else
760-
if ( snow->swq > 0 ) snow->coverage = 1.;
761-
else snow->coverage = 0.;
762-
#endif // SPATIAL_SNOW
749+
if (options.SPATIAL_SNOW) {
750+
snow->coverage = calc_snow_coverage(&snow->store_snow,
751+
soil_con->max_snow_distrib_slope,
752+
snow_coverage, snow->swq,
753+
old_swq, snow->depth, old_depth,
754+
(*melt) - snow->vapor_flux,
755+
&snow->max_snow_depth, snowfall,
756+
&snow->store_swq,
757+
&snow->snow_distrib_slope,
758+
&snow->store_coverage);
759+
}
760+
else {
761+
if ( snow->swq > 0 ) snow->coverage = 1.;
762+
else snow->coverage = 0.;
763+
}
763764

764765
if ( snow->surf_temp > 0 )
765766
energy->snow_flux = ( energy->grnd_flux + energy->deltaH
@@ -775,9 +776,8 @@ double calc_surf_energy_bal(double Le,
775776
snow->surf_temp = 0;
776777
snow->pack_temp = 0;
777778
snow->coverage = 0;
778-
#if SPATIAL_SNOW
779-
snow->store_swq = 0.;
780-
#endif // SPATIAL_SNOW
779+
if (options.SPATIAL_SNOW)
780+
snow->store_swq = 0.;
781781
}
782782
snow->vapor_flux *= -1;
783783
}

src/display_current_settings.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void display_current_settings(int mode,
5757
run-time option. TJB
5858
2013-Dec-26 Moved CLOSE_ENERGY from compile-time to run-time options. TJB
5959
2013-Dec-26 Removed EXCESS_ICE option. TJB
60+
2013-Dec-27 Moved SPATIAL_SNOW from compile-time to run-time options. TJB
6061
**********************************************************************/
6162
{
6263

@@ -116,11 +117,6 @@ void display_current_settings(int mode,
116117
#else
117118
fprintf(stderr,"SPATIAL_FROST\t\tFALSE\n");
118119
#endif
119-
#if SPATIAL_SNOW
120-
fprintf(stderr,"SPATIAL_SNOW\t\tTRUE\n");
121-
#else
122-
fprintf(stderr,"SPATIAL_SNOW\t\tFALSE\n");
123-
#endif
124120

125121
fprintf(stderr,"\n");
126122
fprintf(stderr,"Maximum Array Sizes:\n");
@@ -268,6 +264,10 @@ void display_current_settings(int mode,
268264
fprintf(stderr,"QUICK_SOLVE\t\tTRUE\n");
269265
else
270266
fprintf(stderr,"QUICK_SOLVE\t\tFALSE\n");
267+
if (options.SPATIAL_SNOW == TRUE)
268+
fprintf(stderr,"SPATIAL_SNOW\t\tTRUE\n");
269+
else
270+
fprintf(stderr,"SPATIAL_SNOW\t\tFALSE\n");
271271
if (options.SNOW_ALBEDO == USACE)
272272
fprintf(stderr,"SNOW_ALBEDO\t\tUSACE\n");
273273
else if (options.SNOW_ALBEDO == SUN1999)

src/get_global_param.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ global_param_struct get_global_param(filenames_struct *names,
107107
2013-Dec-26 Added LOG_MATRIC option. TJB
108108
2013-Dec-26 Moved CLOSE_ENERGY from compile-time to run-time options. TJB
109109
2013-Dec-26 Removed EXCESS_ICE option. TJB
110+
2013-Dec-27 Moved SPATIAL_SNOW from compile-time to run-time options. TJB
110111
**********************************************************************/
111112
{
112113
extern option_struct options;
@@ -380,6 +381,11 @@ global_param_struct get_global_param(filenames_struct *names,
380381
options.PLAPSE = TRUE;
381382
}
382383
}
384+
else if(strcasecmp("SPATIAL_SNOW",optstr)==0) {
385+
sscanf(cmdstr,"%*s %s",flgstr);
386+
if(strcasecmp("TRUE",flgstr)==0) options.SPATIAL_SNOW=TRUE;
387+
else options.SPATIAL_SNOW = FALSE;
388+
}
383389
else if(strcasecmp("SW_PREC_THRESH",optstr)==0) {
384390
sscanf(cmdstr,"%*s %s",flgstr);
385391
options.SW_PREC_THRESH = atof(flgstr);

src/ice_melt.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static char vcid[] = "$Id$";
115115
2012-Feb-08 Renamed depth_full_snow_cover to max_snow_distrib_slope
116116
and clarified the descriptions of the SPATIAL_SNOW
117117
option. TJB
118+
2013-Dec-27 Moved SPATIAL_SNOW from compile-time to run-time options. TJB
118119
*****************************************************************************/
119120
int ice_melt(double z2,
120121
double aero_resist,
@@ -623,21 +624,22 @@ int ice_melt(double z2,
623624
if (lake->ice_water_eq <= 0.0) {
624625
lake->ice_water_eq = 0.0;
625626
}
626-
#if SPATIAL_SNOW
627+
if (options.SPATIAL_SNOW) {
627628
/* snow->coverage = calc_snow_coverage(&snow->store_snow,
628-
soil_con->max_snow_distrib_slope,
629-
old_coverage, snow->swq,
630-
old_swq, snow->depth, old_depth,
631-
melt + snow->vapor_flux,
632-
&snow->max_snow_depth, snowfall,
633-
&snow->store_swq,
634-
&snow->snow_distrib_slope,
635-
&snow->store_coverage);
636-
*/
637-
#else
638-
if ( snow->swq > 0 ) snow->coverage = 1.;
639-
else snow->coverage = 0.;
640-
#endif
629+
soil_con->max_snow_distrib_slope,
630+
old_coverage, snow->swq,
631+
old_swq, snow->depth, old_depth,
632+
melt + snow->vapor_flux,
633+
&snow->max_snow_depth, snowfall,
634+
&snow->store_swq,
635+
&snow->snow_distrib_slope,
636+
&snow->store_coverage);
637+
*/
638+
}
639+
else {
640+
if ( snow->swq > 0 ) snow->coverage = 1.;
641+
else snow->coverage = 0.;
642+
}
641643

642644
/* Mass balance test */
643645
MassBalanceError = (InitialSwq - snow->swq) + (InitialIce - LakeIce)

src/initialize_global.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ void initialize_global() {
125125
2013-Jul-25 Added CARBON, SHARE_LAYER_MOIST, and VEGLIB_PHOTO. TJB
126126
2013-Dec-26 Added LOG_MATRIC option. TJB
127127
2013-Dec-26 Moved CLOSE_ENERGY from compile-time to run-time options. TJB
128+
2013-Dec-27 Moved SPATIAL_SNOW from compile-time to run-time options. TJB
128129
*********************************************************************/
129130

130131
extern option_struct options;
@@ -172,6 +173,7 @@ void initialize_global() {
172173
options.SNOW_BAND = 1;
173174
options.SNOW_DENSITY = DENS_BRAS;
174175
options.SNOW_STEP = 1;
176+
options.SPATIAL_SNOW = FALSE;
175177
options.SW_PREC_THRESH = 0;
176178
options.TFALLBACK = TRUE;
177179
options.VP_INTERP = TRUE;

src/read_soilparam.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ soil_con_struct read_soilparam(FILE *soilparam,
122122
option. TJB
123123
2013-Jul-25 Added calculation of soil albedo in PAR range. TJB
124124
2013-Dec-26 Removed EXCESS_ICE option. TJB
125+
2013-Dec-27 Moved SPATIAL_SNOW from compile-time to run-time options. TJB
125126
**********************************************************************/
126127
{
127128
void ttrim( char *string );
@@ -598,16 +599,19 @@ soil_con_struct read_soilparam(FILE *soilparam,
598599
temp.FS_ACTIVE = (char)tempint;
599600

600601
/* read minimum snow depth for full coverage */
601-
#if SPATIAL_SNOW
602-
token = strtok (NULL, delimiters);
603-
while (token != NULL && (length=strlen(token))==0) token = strtok (NULL, delimiters);
604-
if( token == NULL ) {
605-
sprintf(ErrStr,"ERROR: Can't find values for SPATIAL SNOW in soil file\n");
606-
nrerror(ErrStr);
602+
if (options.SPATIAL_SNOW) {
603+
token = strtok (NULL, delimiters);
604+
while (token != NULL && (length=strlen(token))==0) token = strtok (NULL, delimiters);
605+
if( token == NULL ) {
606+
sprintf(ErrStr,"ERROR: Can't find values for SPATIAL SNOW in soil file\n");
607+
nrerror(ErrStr);
608+
}
609+
sscanf(token, "%lf", &tempdbl);
610+
temp.max_snow_distrib_slope = tempdbl;
611+
}
612+
else {
613+
temp.max_snow_distrib_slope = 0;
607614
}
608-
sscanf(token, "%lf", &tempdbl);
609-
temp.max_snow_distrib_slope = tempdbl;
610-
#endif // SPATIAL_SNOW
611615

612616
/* read slope of frozen soil distribution */
613617
#if SPATIAL_FROST
@@ -716,12 +720,12 @@ soil_con_struct read_soilparam(FILE *soilparam,
716720
/**********************************************
717721
Validate Spatial Snow/Frost Params
718722
**********************************************/
719-
#if SPATIAL_SNOW
720-
if (temp.max_snow_distrib_slope < 0.0) {
721-
sprintf(ErrStr,"max_snow_distrib_slope (%f) must be positive.\n", temp.max_snow_distrib_slope);
722-
nrerror(ErrStr);
723+
if (options.SPATIAL_SNOW) {
724+
if (temp.max_snow_distrib_slope < 0.0) {
725+
sprintf(ErrStr,"max_snow_distrib_slope (%f) must be positive.\n", temp.max_snow_distrib_slope);
726+
nrerror(ErrStr);
727+
}
723728
}
724-
#endif // SPATIAL_SNOW
725729

726730
#if SPATIAL_FROST
727731
if (temp.frost_slope < 0.0) {

src/read_soilparam_arc.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ soil_con_struct read_soilparam_arc(FILE *soilparam,
131131
and clarified the descriptions of the SPATIAL_SNOW
132132
option. TJB
133133
2013-Dec-26 Removed EXCESS_ICE option. TJB
134+
2013-Dec-27 Moved SPATIAL_SNOW from compile-time to run-time options. TJB
134135
**********************************************************************/
135136
{
136137
extern option_struct options;
@@ -406,12 +407,15 @@ soil_con_struct read_soilparam_arc(FILE *soilparam,
406407

407408
/** Minimum Snow Depth of Full Coverage **/
408409
fscanf(soilparam,"%s",tmpstr);
409-
#if SPATIAL_SNOW
410-
strcpy(namestr,soilparamdir);
411-
strcat(namestr,"/");
412-
strcat(namestr,tmpstr);
413-
temp.max_snow_distrib_slope = read_arcinfo_value(namestr,temp.lat,temp.lng);
414-
#endif // SPATIAL_SNOW
410+
if (options.SPATIAL_SNOW) {
411+
strcpy(namestr,soilparamdir);
412+
strcat(namestr,"/");
413+
strcat(namestr,tmpstr);
414+
temp.max_snow_distrib_slope = read_arcinfo_value(namestr,temp.lat,temp.lng);
415+
}
416+
else {
417+
temp.max_snow_distrib_slope = 0;
418+
}
415419

416420
/** Slope of Frozen Soil Distribution **/
417421
fscanf(soilparam,"%s",tmpstr);

0 commit comments

Comments
 (0)