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/fix initialization of coupler fields #716

Merged
4 changes: 4 additions & 0 deletions docs/Development/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ To check which release of VIC you are running:

Refactor the cesm_put_data.c routine in the CESM driver to use values from out_data directly, rather than computing them separately in cesm_put_data.c.

[GH#716] (https://github.com/UW-Hydro/VIC/pull/716)

Fixes initialization of coupler fields and calculates temperature and upwelling longwave to pass to WRF during initialization.

3. Speed up NetCDF operations in the image/CESM drivers ([GH#684](https://github.com/UW-Hydro/VIC/pull/684))

These changes speed up image driver initialization, forcing reads, and history writes by only opening and closing each input netCDF file once.
Expand Down
4 changes: 3 additions & 1 deletion vic/drivers/cesm/include/vic_driver_cesm.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ void vic_force(void);
void vic_cesm_put_data(void);
void vic_cesm_run_model(void);
void vic_cesm_start(vic_clock *vclock, case_metadata *cmeta);
void vic_initialize_albedo(void);
void vic_initialize_lwup(void);
void vic_initialize_temperature(void);
void vic_populate_model_state(char *runtype_str);
void write_rpointer_file(char *fname);
void vic_initialize_albedo(void);

#endif
6 changes: 6 additions & 0 deletions vic/drivers/cesm/src/cesm_interface_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ vic_cesm_init(vic_clock *vclock,
// initialize albedo
vic_initialize_albedo();

// initialize temperature
vic_initialize_temperature();

// initialize upwelling longwave
vic_initialize_lwup();

// initialization is complete, print settings
log_info(
"Initialization is complete, print global param and options structures");
Expand Down
42 changes: 41 additions & 1 deletion vic/drivers/cesm/src/vic_cesm_init_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ initialize_l2x_data(void)

size_t i;

log_info("Setting all l2x fields to %f", SHR_CONST_SPVAL);
log_info("Initializing l2x_data_struct");

for (i = 0; i < local_domain.ncells_active; i++) {
l2x_vic[i].l2x_Sl_t = SHR_CONST_SPVAL;
Expand Down Expand Up @@ -144,3 +144,43 @@ vic_initialize_albedo(void)
l2x_vic[i].l2x_Sl_anidf = all_vars[i].gridcell_avg.avg_albedo;
}
}

/*****************************************************************************
* @brief Initialize temperature in l2x_data_struct.
****************************************************************************/
void
vic_initialize_temperature(void)
{
extern l2x_data_struct *l2x_vic;
extern domain_struct local_domain;
extern soil_con_struct *soil_con;

size_t i;

log_info("Initializing temperature");

for (i = 0; i < local_domain.ncells_active; i++) {
l2x_vic[i].l2x_Sl_t = soil_con[i].avg_temp + CONST_TKFRZ;
}
}

/*****************************************************************************
* @brief Initialize upwelling longwave in l2x_data_struct.
****************************************************************************/
void
vic_initialize_lwup(void)
{
extern l2x_data_struct *l2x_vic;
extern domain_struct local_domain;
extern parameters_struct param;

size_t i;

log_info("Initializing upwelling longwave");

for (i = 0; i < local_domain.ncells_active; i++) {
// adjust sign for CESM sign convention
l2x_vic[i].l2x_Fall_lwup = -1 * param.EMISS_GRND * CONST_STEBOL * pow(
l2x_vic[i].l2x_Sl_t, 4);
}
}