Skip to content

Commit 312b6f4

Browse files
yixinmaoJoe Hamman
authored and
Joe Hamman
committed
Fix time precision issue for long VIC runs (#668)
* Fixed time precision issue for long VIC runs * Added release note for the time precision bug fix * Minor release note update
1 parent 1d5298b commit 312b6f4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/Development/ReleaseNotes.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,14 @@ To check which release of VIC you are running:
4646

4747
Before the fix, `dz_node` and `node_depth` in image driver output state file were not spatially distributed, which was wrong. Now these two variables are spatially distributed in the output state file.
4848

49-
6. Fixed a bug related to `run_cell` and `mask` variables in image driver inputs ([GH#662]((https://github.com/UW-Hydro/VIC/pull/662)))
49+
8. Fixed a bug related to `run_cell` and `mask` variables in image driver inputs ([GH#662](https://github.com/UW-Hydro/VIC/pull/662))
5050

5151
Before the fix, active cell was controlled by `mask` variable in the domain file in image driver, and `run_cell` variable in the parameter file was not actually used. Now `run_cell` variable in the parameter file controls active cells (`run_cell` must be within the mask defined by the domain file).
5252

53+
9. Fixed a time precision bug for long simulations ([GH#668](https://github.com/UW-Hydro/VIC/pull/668))
54+
55+
Before the fix, the timestamps of long VIC runs were incorrect in some cases due to precision issue in timestamp generation. This resulted in incorrect output timestamps after running for a long period of time, or output termination. Please refer to [GH#668](https://github.com/UW-Hydro/VIC/pull/668) for details on this bug fix.
56+
5357

5458
------------------------------
5559

vic/drivers/shared_all/src/make_dmy.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ make_dmy(global_param_struct *global)
4343
double dt_time_units, start_num, end_num, force_num,
4444
numdate;
4545

46-
dt_seconds_to_time_units(global->time_units, global->dt, &dt_time_units);
47-
4846
start_dmy.dayseconds = global->startsec;
4947
start_dmy.year = global->startyear;
5048
start_dmy.day = global->startday;
@@ -107,9 +105,10 @@ make_dmy(global_param_struct *global)
107105
temp = calloc(global->nrecs, sizeof(*temp));
108106

109107
/** Create Date Structure for each Model Time Step **/
110-
for (i = 0, numdate = start_num;
111-
i < global->nrecs;
112-
i++, numdate += dt_time_units) {
108+
for (i = 0; i < global->nrecs; i++) {
109+
dt_seconds_to_time_units(global->time_units, i * global->dt,
110+
&dt_time_units);
111+
numdate = start_num + dt_time_units;
113112
num2date(global->time_origin_num, numdate, 0., global->calendar,
114113
global->time_units, &temp[i]);
115114
}

0 commit comments

Comments
 (0)