Skip to content

Commit

Permalink
Merge pull request #182 from UW-Hydro/hotfix/4.2.1
Browse files Browse the repository at this point in the history
Hotfix/4.2.1
  • Loading branch information
bartnijssen committed Dec 21, 2014
2 parents f411198 + 7ab6196 commit 8efc149
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
34 changes: 5 additions & 29 deletions src/calc_surf_energy_bal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include <stdlib.h>
#include "vicNl.h"

static char vcid[] = "$Id$";

double calc_surf_energy_bal(double Le,
double LongUnderIn,
double NetLongSnow, // net LW at snow surface
Expand Down Expand Up @@ -180,8 +178,6 @@ double calc_surf_energy_bal(double Le,
extern option_struct options;

int FIRST_SOLN[2];
int NOFLUX;
int EXP_TRANS;
int VEG;
int i;
int nidx;
Expand Down Expand Up @@ -356,26 +352,9 @@ double calc_surf_energy_bal(double Le,
else tmpNnodes = 3;
}
else tmpNnodes += 4;
NOFLUX = FALSE;

/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
EXP_TRANS = FALSE; // Why would we do this???
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/

}
else {
tmpNnodes = Nnodes;
NOFLUX = options.NOFLUX;
EXP_TRANS = options.EXP_TRANS;
}

Tsurf = root_brent(T_lower, T_upper, ErrorString, func_surf_energy_bal,
Expand All @@ -402,7 +381,7 @@ double calc_surf_energy_bal(double Le,
alpha, beta, bubble_node, Zsum_node, expt_node, gamma,
ice_node, kappa_node, max_moist_node, moist_node,
soil_con, layer, veg_var,
INCLUDE_SNOW, NOFLUX, EXP_TRANS, snow->snow,
INCLUDE_SNOW, options.NOFLUX, options.EXP_TRANS, snow->snow,
FIRST_SOLN, &NetLongBare, &TmpNetLongSnow, &T1,
&energy->deltaH, &energy->fusion, &energy->grnd_flux,
&energy->latent, &energy->latent_sub,
Expand Down Expand Up @@ -450,7 +429,7 @@ double calc_surf_energy_bal(double Le,
soil_con->frost_fract,
layer, veg_var,
INCLUDE_SNOW, soil_con->FS_ACTIVE,
NOFLUX, EXP_TRANS,
options.NOFLUX, options.EXP_TRANS,
snow->snow, FIRST_SOLN, &NetLongBare,
&TmpNetLongSnow, &T1, &energy->deltaH,
&energy->fusion, &energy->grnd_flux,
Expand All @@ -468,7 +447,6 @@ double calc_surf_energy_bal(double Le,

if ( Ts_old * Tsurf < 0 && options.QUICK_SOLVE ) {
tmpNnodes = Nnodes;
NOFLUX = options.NOFLUX;
FIRST_SOLN[0] = TRUE;

Tsurf = root_brent(T_lower, T_upper, ErrorString, func_surf_energy_bal,
Expand All @@ -494,7 +472,7 @@ double calc_surf_energy_bal(double Le,
alpha, beta, bubble_node, Zsum_node, expt_node, gamma,
ice_node, kappa_node, max_moist_node, moist_node,
soil_con, layer, veg_var,
INCLUDE_SNOW, NOFLUX, EXP_TRANS, snow->snow,
INCLUDE_SNOW, options.NOFLUX, options.EXP_TRANS, snow->snow,
FIRST_SOLN, &NetLongBare, &TmpNetLongSnow, &T1,
&energy->deltaH, &energy->fusion, &energy->grnd_flux,
&energy->latent, &energy->latent_sub,
Expand Down Expand Up @@ -542,7 +520,7 @@ double calc_surf_energy_bal(double Le,
max_moist_node, moist_node,
soil_con->frost_fract,
layer, veg_var, INCLUDE_SNOW,
soil_con->FS_ACTIVE, NOFLUX, EXP_TRANS,
soil_con->FS_ACTIVE, options.NOFLUX, options.EXP_TRANS,
snow->snow, FIRST_SOLN, &NetLongBare,
&TmpNetLongSnow, &T1,
&energy->deltaH, &energy->fusion,
Expand All @@ -560,8 +538,6 @@ double calc_surf_energy_bal(double Le,

/** Frozen soil model run with no surface energy balance **/
Tsurf = Tair;
NOFLUX = options.NOFLUX;
EXP_TRANS = options.EXP_TRANS;

}

Expand Down Expand Up @@ -592,7 +568,7 @@ double calc_surf_energy_bal(double Le,
alpha, beta, bubble_node, Zsum_node, expt_node, gamma,
ice_node, kappa_node, max_moist_node, moist_node,
soil_con, layer, veg_var,
INCLUDE_SNOW, NOFLUX, EXP_TRANS, snow->snow,
INCLUDE_SNOW, options.NOFLUX, options.EXP_TRANS, snow->snow,
FIRST_SOLN, &NetLongBare, &TmpNetLongSnow, &T1,
&energy->deltaH, &energy->fusion, &energy->grnd_flux,
&energy->latent, &energy->latent_sub,
Expand Down
7 changes: 6 additions & 1 deletion src/full_energy.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,12 @@ int full_energy(int gridcell,
prepare_full_energy(iveg, Nveg, options.Nnode, all_vars, soil_con, moist0, ice0);

/** Compute Bare (free of snow) Albedo **/
bare_albedo = veg_var[iveg][0].albedo;
if (iveg!=Nveg){
bare_albedo = veg_var[iveg][0].albedo;
}
else {
bare_albedo = BARE_SOIL_ALBEDO;
}

/*************************************
Compute the aerodynamic resistance
Expand Down
11 changes: 11 additions & 0 deletions src/get_global_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,17 @@ global_param_struct get_global_param(filenames_struct *names,
nrerror(ErrStr);
}
}
if (options.QUICK_SOLVE && !options.QUICK_FLUX) {
if (options.NOFLUX) {
sprintf(ErrStr,"NOFLUX must be set to FALSE when QUICK_SOLVE=TRUE and QUICK_FLUX=FALSE");
nrerror(ErrStr);
}
if (options.EXP_TRANS) {
sprintf(ErrStr,"EXP_TRANS must be set to FALSE when QUICK_SOLVE=TRUE and QUICK_FLUX=FALSE");
nrerror(ErrStr);
}
}

if((options.FULL_ENERGY || options.FROZEN_SOIL) && options.Nlayer<3) {
sprintf(ErrStr,"You must define at least 3 soil moisture layers to run the model in FULL_ENERGY or FROZEN_SOIL modes. Currently Nlayers is set to %d.",options.Nlayer);
nrerror(ErrStr);
Expand Down

0 comments on commit 8efc149

Please sign in to comment.