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

Feature/debug cesm driver #642

Merged
merged 36 commits into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
99629f6
update command line usage docs
Sep 6, 2016
698dd0a
Merge pull request #634 from jhamman/fix/doc_command_line_usage
Sep 9, 2016
96e3177
update release notes
Sep 11, 2016
8d64e34
Fixed image driver history file name (#635)
yixinmao Sep 12, 2016
8181420
Committing a fix to vic_restore.c
Sep 29, 2016
ed98825
Use multiple processors for image restart tests
Sep 30, 2016
bd3db2f
Merge pull request #1 from yixinmao/multiproc_init_state_fix
hhelgason Sep 30, 2016
9a71edd
Merge pull request #638 from hhelgason/multiproc_init_state_fix
bartnijssen Oct 3, 2016
35cfb0b
dummy forcings are now created while initializing the model prior to …
dgergel Oct 4, 2016
cb87c5e
removed decimal point for missing value for unsigned ints
dgergel Oct 5, 2016
1b4ff79
initial fix for getting state file date/time info
dgergel Oct 5, 2016
d2b6643
updated fix for getting statefile time info from dmy_current (period-…
dgergel Oct 5, 2016
6d911d6
Fixed a bug when calculating steps of forcing to skip (#639)
yixinmao Oct 5, 2016
d85e37e
fixed bug that passed fillvalue as double when it was supposed to be …
dgergel Oct 6, 2016
644f2aa
Added release notes about PR #638. (#640)
hhelgason Oct 6, 2016
95d6983
use appropriate fillvalue datatypes in gather_put_nc_field fctns
dgergel Oct 7, 2016
7e28f13
add caseid to statefile name by passing case metadata in to vic_cesm_…
dgergel Oct 9, 2016
78dd563
Revert "add caseid to statefile name by passing case metadata in to v…
dgergel Oct 10, 2016
013d4c5
assign caseid to statefile name in vic_cesm_init
dgergel Oct 10, 2016
53a9535
fix warnings for SNOW_BAND and AGGFREQ
dgergel Oct 11, 2016
bbf7d9a
fixed typo in comment
dgergel Oct 16, 2016
c81c518
Added check to ensure mask variable in the input domain file is integ…
yixinmao Oct 17, 2016
8a6d19b
fix typo in primary reference (#646)
Oct 17, 2016
ef269dd
Fix bug make lastday (#647)
yixinmao Oct 17, 2016
16f74dd
Merge branch 'hotfix/5.0.1' of github.com:UW-Hydro/VIC into feature/d…
dgergel Oct 21, 2016
a9a202b
Merge branch 'hotfix/5.0.1' of github.com:UW-Hydro/VIC into hotfix/5.0.1
dgergel Oct 27, 2016
e2ca076
Merge branch 'hotfix/5.0.1' into feature/debug_CESM_driver
dgergel Nov 9, 2016
2aa1eb0
Revert "Merge branch 'hotfix/5.0.1' of github.com:UW-Hydro/VIC into h…
dgergel Nov 11, 2016
72a56a5
pressure was being converted to kPa, should be in Pa
dgergel Nov 17, 2016
8bbca06
Revert "pressure was being converted to kPa, should be in Pa"
dgergel Nov 17, 2016
1c13e93
pressure was being converted to kPa, should be in Pa
dgergel Nov 17, 2016
e7192c5
convert pressure to kPa when reading it in rather than Pa since this …
dgergel Dec 30, 2016
034bf33
Revert "convert pressure to kPa when reading it in rather than Pa sin…
dgergel Dec 30, 2016
da96d91
fixed bug with using the correct local domain grid cells and units is…
dgergel Jan 4, 2017
60b754a
address PR review comments
dgergel Jan 5, 2017
e598652
add change log entry
dgergel Jan 5, 2017
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
10 changes: 10 additions & 0 deletions docs/Development/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ This is a major update from VIC 4. The VIC 5.0.0 release aims to have nearly ide

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

6. Fixes for the CESM driver ([GH#642](https://github.com/UW-Hydro/VIC/pull/642))

1. Using correct fill value datatypes in MPI Gather steps
2. Updated state file name time step to be period-ending rather than period-beginning
3. Set the state file name to the RASM case ID
4. Removed decimal point for missing values for unsigned integers
5. Create dummy forcings when initializing the model (so that there is forcing data for the first time step)
6. Changed pressure units from kPa to Pa
7. Fixed bug that prevented using the correct local domain grid cells in `cesm_put_data.c`
8. Changed reference temperature units from Celsius to Kelvin in `cesm_put_data.c`
------------------------------

## VIC 4.2.d [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.56058.svg)](http://dx.doi.org/10.5281/zenodo.56058)
Expand Down
4 changes: 4 additions & 0 deletions vic/drivers/cesm/src/cesm_interface_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ vic_cesm_init(vic_clock *vclock,
// populate model state, either using a cold start or from a restart file
vic_populate_model_state(trim(cmeta->starttype));

// initialize forcings
vic_force();

// initialize output structures
vic_init_output(&dmy_current);

Expand Down Expand Up @@ -137,6 +140,7 @@ vic_cesm_run(vic_clock *vclock)

// if save:
if (vclock->state_flag) {
// write state file
vic_store(&dmy_current, state_filename);
write_rpointer_file(state_filename);
}
Expand Down
16 changes: 8 additions & 8 deletions vic/drivers/cesm/src/cesm_put_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ vic_cesm_put_data()

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

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

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

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

// dry deposition velocities (optional)
// CESM units: ?
Expand Down Expand Up @@ -259,7 +259,7 @@ vic_cesm_put_data()
// upward longwave heat flux
// CESM units: W m-2
l2x_vic[i].l2x_Fall_lwup += AreaFactor *
(force->longwave[NR] -
(force[i].longwave[NR] -
energy.NetLongAtmos);

// evaporation water flux
Expand All @@ -278,7 +278,7 @@ vic_cesm_put_data()

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

// co2 flux **For testing set to 0
Expand Down
9 changes: 9 additions & 0 deletions vic/drivers/cesm/src/get_global_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ get_global_param(FILE *gp)
"control file.");
}
}
else if (strcasecmp("SNOW_BAND", optstr) == 0) {
sscanf(cmdstr, "%*s %s", flgstr);
if (str_to_bool(flgstr)) {
options.SNOW_BAND = SNOW_BAND_TRUE_BUT_UNSET;
}
}
else if (strcasecmp("LAKES", optstr) == 0) {
sscanf(cmdstr, "%*s %s", flgstr);
if (strcasecmp("FALSE", flgstr) == 0) {
Expand Down Expand Up @@ -415,6 +421,9 @@ get_global_param(FILE *gp)
else if (strcasecmp("OUTVAR", optstr) == 0) {
; // do nothing
}
else if (strcasecmp("AGGFREQ", optstr) == 0) {
; // do nothing
}
else if (strcasecmp("OUTPUT_STEPS_PER_DAY", optstr) == 0) {
; // do nothing
}
Expand Down
5 changes: 5 additions & 0 deletions vic/drivers/cesm/src/vic_cesm_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ vic_cesm_start(vic_clock *vclock,
// Driver specific settings
if (mpi_rank == VIC_MPI_ROOT) {
strcpy(filenames.global, GLOBALPARAM);

// assign case name to state file name
strncpy(filenames.statefile, trim(cmeta->caseid),
sizeof(filenames.statefile));

// read global settings
filep.globalparam = open_file(filenames.global, "r");
get_global_param(filep.globalparam);
Expand Down
4 changes: 2 additions & 2 deletions vic/drivers/cesm/src/vic_force.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ vic_force(void)
for (j = 0; j < NF; j++) {
for (i = 0; i < local_domain.ncells_active; i++) {
// CESM units: Pa
// VIC units: kPa
force[i].pressure[j] = x2l_vic[i].x2l_Sa_pbot / PA_PER_KPA;
// VIC units: Pa
force[i].pressure[j] = x2l_vic[i].x2l_Sa_pbot;
}
}

Expand Down
4 changes: 2 additions & 2 deletions vic/drivers/shared_image/src/vic_init_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ initialize_history_file(nc_file_struct *nc,
double *dvar;


// This could be further refined but for now, I've choosen a file naming
// Convention that goes like this:
// This could be further refined but for now, I've chosen a file naming
// convention that goes like this:
switch (stream->agg_alarm.freq) {
// If FREQ_NDAYS -- filename = result_dir/prefix.YYYY-MM-DD.nc
case FREQ_NDAYS:
Expand Down
36 changes: 28 additions & 8 deletions vic/drivers/shared_image/src/vic_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,45 @@ vic_store(dmy_struct *dmy_current,
size_t k;
size_t m;
size_t p;
double offset;
double time_num;
double end_time_num;
int *ivar = NULL;
double *dvar = NULL;
size_t d2start[2];
size_t d3start[3];
size_t d4start[4];
size_t d5start[5];
size_t d6start[6];
dmy_struct end_time_date;
nc_file_struct nc_state_file;
nc_var_struct *nc_var;

set_nc_state_file_info(&nc_state_file);

// only open and initialize the netcdf file on the first thread
if (mpi_rank == VIC_MPI_ROOT) {

// advance dmy_current by one timestep since dmy_current is the
// timestep-beginning timestamp, and state file date should be
// the end of the current time step
dt_seconds_to_time_units(global_param.time_units, global_param.dt,
&offset);
time_num = date2num(global_param.time_origin_num, dmy_current, 0,
global_param.calendar, global_param.time_units);
end_time_num = time_num + offset;

// allocate dmy struct for end of current time step
num2date(global_param.time_origin_num, end_time_num, 0.,
global_param.calendar, global_param.time_units,
&end_time_date);


// create netcdf file for storing model state
sprintf(filename, "%s.%04i%02i%02i_%05u.nc",
filenames.statefile, global_param.stateyear,
global_param.statemonth, global_param.stateday,
global_param.statesec);
filenames.statefile, end_time_date.year,
end_time_date.month, end_time_date.day,
end_time_date.dayseconds);

initialize_state_file(filename, &nc_state_file, dmy_current);

Expand Down Expand Up @@ -350,7 +370,7 @@ vic_store(dmy_struct *dmy_current,
}
gather_put_nc_field_int(nc_state_file.nc_id,
nc_var->nc_varid,
nc_state_file.d_fillvalue,
nc_state_file.i_fillvalue,
d4start, nc_var->nc_counts, ivar);
for (i = 0; i < local_domain.ncells_active; i++) {
ivar[i] = nc_state_file.i_fillvalue;
Expand All @@ -376,7 +396,7 @@ vic_store(dmy_struct *dmy_current,
}
gather_put_nc_field_int(nc_state_file.nc_id,
nc_var->nc_varid,
nc_state_file.d_fillvalue,
nc_state_file.i_fillvalue,
d4start, nc_var->nc_counts, ivar);
for (i = 0; i < local_domain.ncells_active; i++) {
ivar[i] = nc_state_file.i_fillvalue;
Expand Down Expand Up @@ -813,7 +833,7 @@ vic_store(dmy_struct *dmy_current,
}
gather_put_nc_field_int(nc_state_file.nc_id,
nc_var->nc_varid,
nc_state_file.d_fillvalue,
nc_state_file.i_fillvalue,
d2start, nc_var->nc_counts, ivar);
for (i = 0; i < local_domain.ncells_active; i++) {
ivar[i] = nc_state_file.i_fillvalue;
Expand All @@ -826,7 +846,7 @@ vic_store(dmy_struct *dmy_current,
}
gather_put_nc_field_int(nc_state_file.nc_id,
nc_var->nc_varid,
nc_state_file.d_fillvalue,
nc_state_file.i_fillvalue,
d2start, nc_var->nc_counts, ivar);
for (i = 0; i < local_domain.ncells_active; i++) {
ivar[i] = nc_state_file.i_fillvalue;
Expand Down Expand Up @@ -972,7 +992,7 @@ vic_store(dmy_struct *dmy_current,
}
gather_put_nc_field_int(nc_state_file.nc_id,
nc_var->nc_varid,
nc_state_file.d_fillvalue,
nc_state_file.i_fillvalue,
d2start, nc_var->nc_counts, ivar);
for (i = 0; i < local_domain.ncells_active; i++) {
ivar[i] = nc_state_file.i_fillvalue;
Expand Down
2 changes: 1 addition & 1 deletion vic/drivers/shared_image/src/vic_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ vic_write(stream_struct *stream,
}
gather_put_nc_field_schar(nc_hist_file->nc_id,
nc_hist_file->nc_vars[k].nc_varid,
nc_hist_file->d_fillvalue,
nc_hist_file->c_fillvalue,
dstart, dcount, cvar);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion vic/vic_run/include/vic_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/***** Model Constants *****/
#define MAXSTRING 2048
#define MISSING -99999. /**< missing value */
#define MISSING_USI 99999. /**< missing value for unsigned ints */
#define MISSING_USI 99999 /**< missing value for unsigned ints */
#define MISSING_S "MISSING" /**< missing value for strings */
#define NODATA_VH -1 /**< missing value for veg_hist inputs */
#define NODATA_VEG -1 /**< flag for veg types not in grid cell */
Expand Down