Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to calculation of OUT_PREC for output files when LAKES=TRUE. #316

Merged
merged 3 commits into from
Dec 7, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/full_energy.c
Original file line number Diff line number Diff line change
@@ -543,9 +543,11 @@ int full_energy(int gridcell,
oldsnow = lake_var->snow.swq;
snowprec = gauge_correction[SNOW] * (atmos->prec[NR] - rainonly);
rainprec = gauge_correction[SNOW] * rainonly;
atmos->out_prec += (snowprec + rainprec) * lake_con->Cl[0] * lakefrac;
atmos->out_rain += rainprec * lake_con->Cl[0] * lakefrac;
atmos->out_snow += snowprec * lake_con->Cl[0] * lakefrac;
Cv = veg_con[iveg].Cv;
Cv *= lakefrac;
atmos->out_prec += (snowprec + rainprec) * Cv;
atmos->out_rain += rainprec * Cv;
atmos->out_snow += snowprec * Cv;

ErrorFlag = solve_lake(snowprec, rainprec, atmos->air_temp[NR],
atmos->wind[NR], atmos->vp[NR] / 1000.,
18 changes: 16 additions & 2 deletions src/read_lakeparam.c
Original file line number Diff line number Diff line change
@@ -167,6 +167,13 @@ lake_con_struct read_lakeparam(FILE *lakeparam,
sprintf(tmpstr, "Lake area fraction (%f) for cell (%d) specified in the lake parameter file must be a fraction between 0 and 1.", temp.Cl[0], soil_con.gridcel);
nrerror(tmpstr);
}
if(fabs(1-temp.Cl[0]/veg_con[temp.lake_idx].Cv) > 0.01) {
sprintf(tmpstr, "Lake area fraction at top of lake basin (%f) for cell (%d) specified in the lake parameter file must equal the area fraction of the veg tile containing it (%f).", temp.Cl[0], soil_con.gridcel,veg_con[temp.lake_idx].Cv);
nrerror(tmpstr);
}
else {
temp.Cl[0] = veg_con[temp.lake_idx].Cv;
}

fgets(tmpstr, MAXSTRING, lakeparam);

@@ -204,10 +211,17 @@ lake_con_struct read_lakeparam(FILE *lakeparam,
if(i==0) {
temp.maxdepth = temp.z[i];
tempdz = (temp.maxdepth) / ((float) temp.numnod);
if(fabs(1-temp.Cl[0]/veg_con[temp.lake_idx].Cv) > 0.01) {
sprintf(tmpstr, "Lake area fraction at top of lake basin (%f) for cell (%d) specified in the lake parameter file must equal the area fraction of the veg tile containing it (%f).", temp.Cl[0], soil_con.gridcel,veg_con[temp.lake_idx].Cv);
nrerror(tmpstr);
}
else {
temp.Cl[0] = veg_con[temp.lake_idx].Cv;
}
}

if(temp.Cl[0] < 0.0 || temp.Cl[0] > 1.0) {
sprintf(tmpstr, "Lake area fraction (%f) for cell (%d) specified in the lake parameter file must be a fraction between 0 and 1.", temp.Cl[0], soil_con.gridcel);
if(temp.Cl[i] < 0.0 || temp.Cl[i] > 1.0) {
sprintf(tmpstr, "Lake layer %d area fraction (%f) for cell (%d) specified in the lake parameter file must be a fraction between 0 and 1.", i, temp.Cl[i], soil_con.gridcel);
nrerror(tmpstr);
}
}