Skip to content

Commit 69ed683

Browse files
author
Joe Hamman
authored
Merge pull request #677 from yixinmao/develop
Merge VIC5.0.1 release into develop branch
2 parents ebd2ba3 + cbfad8e commit 69ed683

File tree

11 files changed

+106
-28
lines changed

11 files changed

+106
-28
lines changed

docs/Development/ReleaseNotes.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@ To check which release of VIC you are running:
1414
- For VIC 5 and later, type `vic_{classic,image}.exe -v`
1515

1616
------------------------------
17+
18+
## VIC 5.1.0
19+
20+
**Release date: (Unreleased)**
21+
22+
#### Model enhancement:
23+
24+
1. Improved calculation of drainage between soil layers ([GH#656](https://github.com/UW-Hydro/VIC/pull/656))
25+
26+
Drainage from upper layer to adjacent lower layer is calculated according to Brook & Corey curve (where drainage rate is a function of upper-layer soil moisture). In previous versions, a simple numerical solution is applied which uses the timestep-beginning upper-layer soil moisture to calculate drainage rate, and assume this constant rate over the entire timestep. This can cause unreasonably large drainage if the curve has a steep shape and when soil moisture is high. Now, the current version uses exact integral (instead of numerical solution) for layer drainage calculation.
27+
28+
2. Fixes for the CESM driver ([GH#642](https://github.com/UW-Hydro/VIC/pull/642))
29+
30+
1. Using correct fill value datatypes in MPI Gather steps
31+
2. Updated state file name time step to be period-ending rather than period-beginning
32+
3. Set the state file name to the RASM case ID
33+
4. Removed decimal point for missing values for unsigned integers
34+
5. Create dummy forcings when initializing the model (so that there is forcing data for the first time step)
35+
6. Changed pressure units from kPa to Pa
36+
7. Fixed bug that prevented using the correct local domain grid cells in `cesm_put_data.c`
37+
8. Changed reference temperature units from Celsius to Kelvin in `cesm_put_data.c`
38+
39+
------------------------------
40+
1741
## VIC 5.0.1
1842

1943
**Release date: (February 1, 2017)**
@@ -61,7 +85,7 @@ To check which release of VIC you are running:
6185

6286
------------------------------
6387

64-
## VIC 5.0.0 [![DOI](https://zenodo.org/badge/7766/UW-Hydro/VIC.svg)](https://zenodo.org/badge/latestdoi/7766/UW-Hydro/VIC)
88+
## VIC 5.0.0 [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.61422.svg)](http://dx.doi.org/10.5281/zenodo.61422)
6589

6690
**Release date: (September 2, 2016)**
6791

@@ -236,6 +260,7 @@ This is a major update from VIC 4. The VIC 5.0.0 release aims to have nearly ide
236260

237261
Fixed a bug where volumetric heat capacity of water should be used in `func_canopy_energy_bal` (previously specific heat capacity was used).
238262

263+
239264
------------------------------
240265

241266
## VIC 4.2.d [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.56058.svg)](http://dx.doi.org/10.5281/zenodo.56058)

vic/drivers/cesm/src/cesm_interface_c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ vic_cesm_init(vic_clock *vclock,
9696
// populate model state, either using a cold start or from a restart file
9797
vic_populate_model_state(trim(cmeta->starttype));
9898

99+
// initialize forcings
100+
vic_force();
101+
99102
// initialize output structures
100103
vic_init_output(&dmy_current);
101104

@@ -137,6 +140,7 @@ vic_cesm_run(vic_clock *vclock)
137140

138141
// if save:
139142
if (vclock->state_flag) {
143+
// write state file
140144
vic_store(&dmy_current, state_filename);
141145
write_rpointer_file(state_filename);
142146
}

vic/drivers/cesm/src/cesm_put_data.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ vic_cesm_put_data()
140140

141141
// 2m reference temperature
142142
// CESM units: K
143-
l2x_vic[i].l2x_Sl_tref += AreaFactor * force->air_temp[NR];
143+
l2x_vic[i].l2x_Sl_tref += AreaFactor * (force[i].air_temp[NR] + CONST_TKFRZ);
144144

145145
// 2m reference specific humidity
146146
// CESM units: g/g
147147
l2x_vic[i].l2x_Sl_qref += AreaFactor * CONST_EPS *
148-
force->vp[NR] / force->pressure[NR];
148+
force[i].vp[NR] / force[i].pressure[NR];
149149

150150
// Albedo Note: VIC does not partition its albedo, all returned
151151
// values will be the same
@@ -156,10 +156,10 @@ vic_cesm_put_data()
156156
// force->NetShortAtmos net shortwave flux (+ down)
157157
// SWup = force->shortwave[NR] - energy.NetShortAtmos
158158
// Set the albedo to zero for the case where there is no shortwave down
159-
if (force->shortwave[NR] > 0.) {
159+
if (force[i].shortwave[NR] > 0.) {
160160
albedo = AreaFactor *
161-
(force->shortwave[NR] - energy.NetShortAtmos) /
162-
force->shortwave[NR];
161+
(force[i].shortwave[NR] - energy.NetShortAtmos) /
162+
force[i].shortwave[NR];
163163
}
164164
else {
165165
albedo = 0.;
@@ -184,7 +184,7 @@ vic_cesm_put_data()
184184

185185
// 10m wind
186186
// CESM units: m/s
187-
l2x_vic[i].l2x_Sl_u10 += AreaFactor * force->wind[NR];
187+
l2x_vic[i].l2x_Sl_u10 += AreaFactor * force[i].wind[NR];
188188

189189
// dry deposition velocities (optional)
190190
// CESM units: ?
@@ -259,7 +259,7 @@ vic_cesm_put_data()
259259
// upward longwave heat flux
260260
// CESM units: W m-2
261261
l2x_vic[i].l2x_Fall_lwup += AreaFactor *
262-
(force->longwave[NR] -
262+
(force[i].longwave[NR] -
263263
energy.NetLongAtmos);
264264

265265
// evaporation water flux
@@ -278,7 +278,7 @@ vic_cesm_put_data()
278278

279279
// heat flux shortwave net
280280
l2x_vic[i].l2x_Fall_swnet += AreaFactor *
281-
(force->shortwave[NR] -
281+
(force[i].shortwave[NR] -
282282
energy.NetShortAtmos);
283283

284284
// co2 flux **For testing set to 0

vic/drivers/cesm/src/get_global_param.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ get_global_param(FILE *gp)
385385
"control file.");
386386
}
387387
}
388+
else if (strcasecmp("SNOW_BAND", optstr) == 0) {
389+
sscanf(cmdstr, "%*s %s", flgstr);
390+
if (str_to_bool(flgstr)) {
391+
options.SNOW_BAND = SNOW_BAND_TRUE_BUT_UNSET;
392+
}
393+
}
388394
else if (strcasecmp("LAKES", optstr) == 0) {
389395
sscanf(cmdstr, "%*s %s", flgstr);
390396
if (strcasecmp("FALSE", flgstr) == 0) {
@@ -415,6 +421,9 @@ get_global_param(FILE *gp)
415421
else if (strcasecmp("OUTVAR", optstr) == 0) {
416422
; // do nothing
417423
}
424+
else if (strcasecmp("AGGFREQ", optstr) == 0) {
425+
; // do nothing
426+
}
418427
else if (strcasecmp("OUTPUT_STEPS_PER_DAY", optstr) == 0) {
419428
; // do nothing
420429
}

vic/drivers/cesm/src/vic_cesm_start.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ vic_cesm_start(vic_clock *vclock,
4646
// Driver specific settings
4747
if (mpi_rank == VIC_MPI_ROOT) {
4848
strcpy(filenames.global, GLOBALPARAM);
49+
50+
// assign case name to state file name
51+
strncpy(filenames.statefile, trim(cmeta->caseid),
52+
sizeof(filenames.statefile));
53+
4954
// read global settings
5055
filep.globalparam = open_file(filenames.global, "r");
5156
get_global_param(filep.globalparam);

vic/drivers/cesm/src/vic_force.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ vic_force(void)
127127
for (j = 0; j < NF; j++) {
128128
for (i = 0; i < local_domain.ncells_active; i++) {
129129
// CESM units: Pa
130-
// VIC units: kPa
131-
force[i].pressure[j] = x2l_vic[i].x2l_Sa_pbot / PA_PER_KPA;
130+
// VIC units: Pa
131+
force[i].pressure[j] = x2l_vic[i].x2l_Sa_pbot;
132132
}
133133
}
134134

vic/drivers/shared_image/src/vic_store.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,44 @@ vic_store(dmy_struct *dmy_current,
4848
size_t k;
4949
size_t m;
5050
size_t p;
51+
double offset;
52+
double time_num;
53+
double end_time_num;
5154
int *ivar = NULL;
5255
double *dvar = NULL;
5356
size_t d2start[2];
5457
size_t d3start[3];
5558
size_t d4start[4];
5659
size_t d5start[5];
5760
size_t d6start[6];
61+
dmy_struct end_time_date;
5862
nc_file_struct nc_state_file;
5963
nc_var_struct *nc_var;
6064

6165
set_nc_state_file_info(&nc_state_file);
6266

63-
// only open and initialize the netcdf file on the first thread
67+
// advance dmy_current by one timestep since dmy_current is the
68+
// timestep-beginning timestamp, and state file date should be
69+
// the end of the current time step
70+
dt_seconds_to_time_units(global_param.time_units, global_param.dt,
71+
&offset);
72+
time_num = date2num(global_param.time_origin_num, dmy_current, 0,
73+
global_param.calendar, global_param.time_units);
74+
end_time_num = time_num + offset;
75+
76+
// allocate dmy struct for end of current time step
77+
num2date(global_param.time_origin_num, end_time_num, 0.,
78+
global_param.calendar, global_param.time_units,
79+
&end_time_date);
80+
6481
// create netcdf file for storing model state
6582
sprintf(filename, "%s.%04i%02i%02i_%05u.nc",
66-
filenames.statefile, global_param.stateyear,
67-
global_param.statemonth, global_param.stateday,
68-
global_param.statesec);
83+
filenames.statefile, end_time_date.year,
84+
end_time_date.month, end_time_date.day,
85+
end_time_date.dayseconds);
86+
6987
initialize_state_file(filename, &nc_state_file, dmy_current);
88+
7089
if (mpi_rank == VIC_MPI_ROOT) {
7190
debug("writing state file: %s", filename);
7291
}
@@ -348,7 +367,7 @@ vic_store(dmy_struct *dmy_current,
348367
}
349368
gather_put_nc_field_int(nc_state_file.nc_id,
350369
nc_var->nc_varid,
351-
nc_state_file.d_fillvalue,
370+
nc_state_file.i_fillvalue,
352371
d4start, nc_var->nc_counts, ivar);
353372
for (i = 0; i < local_domain.ncells_active; i++) {
354373
ivar[i] = nc_state_file.i_fillvalue;
@@ -374,7 +393,7 @@ vic_store(dmy_struct *dmy_current,
374393
}
375394
gather_put_nc_field_int(nc_state_file.nc_id,
376395
nc_var->nc_varid,
377-
nc_state_file.d_fillvalue,
396+
nc_state_file.i_fillvalue,
378397
d4start, nc_var->nc_counts, ivar);
379398
for (i = 0; i < local_domain.ncells_active; i++) {
380399
ivar[i] = nc_state_file.i_fillvalue;
@@ -811,7 +830,7 @@ vic_store(dmy_struct *dmy_current,
811830
}
812831
gather_put_nc_field_int(nc_state_file.nc_id,
813832
nc_var->nc_varid,
814-
nc_state_file.d_fillvalue,
833+
nc_state_file.i_fillvalue,
815834
d2start, nc_var->nc_counts, ivar);
816835
for (i = 0; i < local_domain.ncells_active; i++) {
817836
ivar[i] = nc_state_file.i_fillvalue;
@@ -824,7 +843,7 @@ vic_store(dmy_struct *dmy_current,
824843
}
825844
gather_put_nc_field_int(nc_state_file.nc_id,
826845
nc_var->nc_varid,
827-
nc_state_file.d_fillvalue,
846+
nc_state_file.i_fillvalue,
828847
d2start, nc_var->nc_counts, ivar);
829848
for (i = 0; i < local_domain.ncells_active; i++) {
830849
ivar[i] = nc_state_file.i_fillvalue;
@@ -970,7 +989,7 @@ vic_store(dmy_struct *dmy_current,
970989
}
971990
gather_put_nc_field_int(nc_state_file.nc_id,
972991
nc_var->nc_varid,
973-
nc_state_file.d_fillvalue,
992+
nc_state_file.i_fillvalue,
974993
d2start, nc_var->nc_counts, ivar);
975994
for (i = 0; i < local_domain.ncells_active; i++) {
976995
ivar[i] = nc_state_file.i_fillvalue;

vic/drivers/shared_image/src/vic_write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ vic_write(stream_struct *stream,
194194
}
195195
gather_put_nc_field_schar(nc_hist_file->nc_id,
196196
nc_hist_file->nc_vars[k].nc_varid,
197-
nc_hist_file->d_fillvalue,
197+
nc_hist_file->c_fillvalue,
198198
dstart, dcount, cvar);
199199
}
200200
else {

vic/vic_run/include/vic_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
/***** Model Constants *****/
5353
#define MAXSTRING 2048
5454
#define MISSING -99999. /**< missing value */
55-
#define MISSING_USI 99999. /**< missing value for unsigned ints */
55+
#define MISSING_USI 99999 /**< missing value for unsigned ints */
5656
#define MISSING_S "MISSING" /**< missing value for strings */
5757
#define NODATA_VH -1 /**< missing value for veg_hist inputs */
5858
#define NODATA_VEG -1 /**< flag for veg types not in grid cell */

vic/vic_run/include/vic_run.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ void compute_pot_evap(size_t, double, double, double, double, double, double,
113113
double, double *);
114114
void compute_runoff_and_asat(soil_con_struct *, double *, double, double *,
115115
double *);
116+
double calc_Q12(double, double, double, double, double);
116117
void compute_soil_resp(int, double *, double, double, double *, double *,
117118
double, double, double, double *, double *, double *);
118119
void compute_soil_layer_thermal_properties(layer_data_struct *, double *,

0 commit comments

Comments
 (0)