From 47e381b0521347684a759af20685bc4a44c5b79f Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sun, 20 Sep 2015 16:02:22 -0700 Subject: [PATCH 01/14] Removal of MTCLIM code from VIC classic driver. --- vic/drivers/classic/src/get_global_param.c | 77 +++++- vic/drivers/classic/src/vic_force.c | 233 +++++++++++++++++- vic/drivers/image/include/vic_driver_image.h | 5 - vic/drivers/image/src/vic_force.c | 95 +------ .../shared/include/vic_driver_shared.h | 5 + vic/drivers/shared/src/forcing_utils.c | 123 +++++++++ 6 files changed, 432 insertions(+), 106 deletions(-) create mode 100644 vic/drivers/shared/src/forcing_utils.c diff --git a/vic/drivers/classic/src/get_global_param.c b/vic/drivers/classic/src/get_global_param.c index 8c124fcf1..6f5c220d8 100644 --- a/vic/drivers/classic/src/get_global_param.c +++ b/vic/drivers/classic/src/get_global_param.c @@ -1252,12 +1252,87 @@ get_global_param(FILE *gp) "tile in EACH grid cell, and you MUST specify " "\"VEGPARAM_LAI\" as \"TRUE\" in the global parameter " "file. Alternatively, if you want VIC to read LAI values " - "from the veg library file, set \"LAI_SRC\" ro " + "from the veg library file, set \"LAI_SRC\" to " "\"LAI_FROM_VEGLIB\" in the global parameter file. In " "either case, the setting of \"VEGPARAM_LAI\" must be " "consistent with the contents of the veg param file (i.e. " "whether or not it contains LAI values)."); } + if (options.LAI_SRC == FROM_VEGPARAM && !options.VEGPARAM_LAI) { + log_err("\"LAI_SRC\" was specified as \"FROM_VEGPARAM\", but " + "\"VEGPARAM_LAI\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read LAI values from " + "the vegparam file, you MUST make sure the veg param file " + "contains 1 line of 12 monthly LAI values for EACH veg " + "tile in EACH grid cell, and you MUST specify " + "\"VEGPARAM_LAI\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read LAI values " + "from the veg library file, set \"LAI_SRC\" to " + "\"FROM_VEGLIB\" in the global parameter file. In " + "either case, the setting of \"VEGPARAM_LAI\" must be " + "consistent with the contents of the veg param file (i.e. " + "whether or not it contains LAI values)."); + } + if (options.ALB_SRC == FROM_VEGPARAM && !options.VEGPARAM_ALB) { + log_err("\"ALB_SRC\" was specified as \"FROM_VEGPARAM\", but " + "\"VEGPARAM_ALB\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read albedo values from " + "the vegparam file, you MUST make sure the veg param file " + "contains 1 line of 12 monthly albedo values for EACH veg " + "tile in EACH grid cell, and you MUST specify " + "\"VEGPARAM_ALB\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read albedo values " + "from the veg library file, set \"ALB_SRC\" to " + "\"FROM_VEGLIB\" in the global parameter file. In " + "either case, the setting of \"VEGPARAM_ALB\" must be " + "consistent with the contents of the veg param file (i.e. " + "whether or not it contains albedo values)."); + } + if (options.VEGCOVER_SRC == FROM_VEGPARAM && !options.VEGPARAM_VEGCOVER) { + log_err("\"VEGCOVER_SRC\" was specified as \"FROM_VEGPARAM\", but " + "\"VEGPARAM_VEGCOVER\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read vegcover values from " + "the vegparam file, you MUST make sure the veg param file " + "contains 1 line of 12 monthly vegcover values for EACH veg " + "tile in EACH grid cell, and you MUST specify " + "\"VEGPARAM_VEGCOVER\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read vegcover values " + "from the veg library file, set \"VEGCOVER_SRC\" to " + "\"FROM_VEGLIB\" in the global parameter file. In " + "either case, the setting of \"VEGPARAM_VEGCOVER\" must be " + "consistent with the contents of the veg param file (i.e. " + "whether or not it contains vegcover values)."); + } + if (options.ALB_SRC == FROM_VEGLIB && !options.VEGLIB_ALB) { + log_err("\"ALB_SRC\" was specified as \"FROM_VEGLIB\", but " + "\"VEGLIB_ALB\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read albedo values from " + "the veglib file, you MUST make sure the veg lib file " + "contains 1 line of 12 monthly albedo values for EACH veg " + "class, and you MUST specify " + "\"VEGLIB_ALB\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read albedo values " + "from the veg param file, set \"ALB_SRC\" to " + "\"FROM_VEGPARAM\" in the global parameter file. In " + "either case, the setting of \"VEGLIB_ALB\" must be " + "consistent with the contents of the veg lib file (i.e. " + "whether or not it contains albedo values)."); + } + if (options.VEGCOVER_SRC == FROM_VEGLIB && !options.VEGLIB_VEGCOVER) { + log_err("\"VEGCOVER_SRC\" was specified as \"FROM_VEGLIB\", but " + "\"VEGLIB_VEGCOVER\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read vegcover values from " + "the veglib file, you MUST make sure the veg lib file " + "contains 1 line of 12 monthly vegcover values for EACH veg " + "class, and you MUST specify " + "\"VEGLIB_VEGCOVER\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read vegcover values " + "from the veg param file, set \"VEGCOVER_SRC\" to " + "\"FROM_VEGPARAM\" in the global parameter file. In " + "either case, the setting of \"VEGLIB_VEGCOVER\" must be " + "consistent with the contents of the veg lib file (i.e. " + "whether or not it contains vegcover values)."); + } // Validate SPATIAL_FROST information if (options.SPATIAL_FROST) { diff --git a/vic/drivers/classic/src/vic_force.c b/vic/drivers/classic/src/vic_force.c index aa2e86dbc..83f6342e5 100644 --- a/vic/drivers/classic/src/vic_force.c +++ b/vic/drivers/classic/src/vic_force.c @@ -2,10 +2,7 @@ * @section DESCRIPTION * * This routine initializes atmospheric variables for both the model time step, - * and the time step used by the snow algorithm (if different). Air temperature - * is estimated using MTCLIM (see routine for reference), atmospheric moisture - * is estimated using Kimball's algorithm (see routine for reference), and - * radiation is estimated using Bras's algorithms (see routines for reference). + * and the time step used by the snow algorithm (if different). * * @section LICENSE * @@ -33,7 +30,7 @@ #include /****************************************************************************** - * @brief Initialize atmospheric variables for both the model time step. + * @brief Initialize atmospheric variables for the model and snow time steps. *****************************************************************************/ void vic_force(atmos_data_struct *atmos, @@ -46,5 +43,229 @@ vic_force(atmos_data_struct *atmos, out_data_file_struct *out_data_files, out_data_struct *out_data) { - ; + + extern option_struct options; + extern param_set_struct param_set; + extern global_param_struct global_param; + extern parameters_struct param; + extern size_t NR, NF; + + size_t i; + size_t j; + size_t v; + size_t rec; + size_t uidx; + double **forcing_data; + double ***veg_hist_data; + double avgJulyAirTemp; + double *Tfactor; + bool *AboveTreeLine; + + /******************************* + Check that required inputs were supplied + *******************************/ + + if (!param_set.TYPE[AIR_TEMP].SUPPLIED) { + log_err("Air temperature must be supplied as a forcing"); + } + if (!param_set.TYPE[PREC].SUPPLIED) { + log_err("Precipitation must be supplied as a forcing"); + } + if (!param_set.TYPE[SHORTWAVE].SUPPLIED) { + log_err("Downward shortwave radiation must be supplied as a forcing"); + } + if (!param_set.TYPE[LONGWAVE].SUPPLIED) { + log_err("Downward longwave radiation must be supplied as a forcing"); + } + if (!param_set.TYPE[PRESSURE].SUPPLIED) { + log_err("Atmospheric pressure must be supplied as a forcing"); + } + if (!param_set.TYPE[QAIR].SUPPLIED) { + log_err("Specific humidity must be supplied as a forcing"); + } + if (!param_set.TYPE[WIND].SUPPLIED) { + log_err("Wind speed must be supplied as a forcing"); + } + + /******************************* + Miscellaneous initialization + *******************************/ + + /* Assign local copies of some variables */ + avgJulyAirTemp = soil_con->avgJulyAirTemp; + Tfactor = soil_con->Tfactor; + AboveTreeLine = soil_con->AboveTreeLine; + + /* Assign N_ELEM for veg-dependent forcings */ + if (param_set.TYPE[ALBEDO].SUPPLIED) { + param_set.TYPE[ALBEDO].N_ELEM = veg_con[0].vegetat_type_num; + } + if (param_set.TYPE[LAI_IN].SUPPLIED) { + param_set.TYPE[LAI_IN].N_ELEM = veg_con[0].vegetat_type_num; + } + if (param_set.TYPE[VEGCOVER].SUPPLIED) { + param_set.TYPE[VEGCOVER].N_ELEM = veg_con[0].vegetat_type_num; + } + + /******************************* + read in meteorological data + *******************************/ + + forcing_data = read_forcing_data(infile, global_param, &veg_hist_data); + + log_info("Read meteorological forcing file"); + + /**************************************************** + Variables in the atmos_data structure + ****************************************************/ + + for (rec = 0; rec < global_param.nrecs; rec++) { + for (i = 0; i < NF; i++) { + uidx = rec * NF + i; + // temperature in Celsius + atmos[rec].air_temp[i] = forcing_data[AIR_TEMP][uidx]; + // precipitation in mm/period + atmos[rec].prec[i] = forcing_data[PREC][uidx]; + // downward shortwave in W/m2 + atmos[rec].shortwave[i] = forcing_data[SHORTWAVE][uidx]; + // downward longwave in W/m2 + atmos[rec].longwave[i] = forcing_data[LONGWAVE][uidx]; + // pressure in kPa + atmos[rec].pressure[i] = forcing_data[PRESSURE][uidx]; + // vapor pressure in kPa (we read specific humidity in kg/kg) + atmos[rec].vp[i] = q_to_vp(forcing_data[QAIR][uidx], + atmos[rec].pressure[i]); + // vapor pressure deficit in kPa + atmos[rec].vpd[i] = svp(atmos[rec].air_temp[i]) - atmos[rec].vp[i]; + // air density + atmos[rec].density[i] = air_density(atmos[rec].air_temp[i], + atmos[rec].pressure[i]); + // wind speed in m/s + atmos[rec].wind[i] = forcing_data[WIND][uidx]; + // Optional inputs + // Channel inflow from upstream (into lake) + if (param_set.TYPE[CHANNEL_IN].SUPPLIED) { + atmos[rec].channel_in[i] = forcing_data[CHANNEL_IN][uidx]; + } + else { + atmos[rec].channel_in[i] = 0; + } + // Atmospheric CO2 concentration + if (param_set.TYPE[CATM].SUPPLIED) { + atmos[rec].Catm[i] = forcing_data[CATM][uidx]; + } + // Fraction of shortwave that is direct + if (param_set.TYPE[FDIR].SUPPLIED) { + atmos[rec].fdir[i] = forcing_data[FDIR][uidx]; + } + // photosynthetically active radiation + if (param_set.TYPE[PAR].SUPPLIED) { + atmos[rec].par[i] = forcing_data[PAR][uidx]; + } + else { + atmos[rec].par[i] = param.CARBON_SW2PAR * atmos[rec].shortwave[i]; + } + } + if (NF > 1) { + atmos[rec].air_temp[NR] = average(atmos[rec].air_temp, NF); + // For precipitation put total + atmos[rec].prec[NR] = average(atmos[rec].prec, NF) * NF; + atmos[rec].shortwave[NR] = average(atmos[rec].shortwave, NF); + atmos[rec].longwave[NR] = average(atmos[rec].longwave, NF); + atmos[rec].pressure[NR] = average(atmos[rec].pressure, NF); + atmos[rec].vp[NR] = average(atmos[rec].vp, NF); + atmos[rec].vpd[NR] = average(atmos[rec].vpd, NF); + atmos[rec].density[NR] = average(atmos[rec].density, NF); + atmos[rec].wind[NR] = average(atmos[rec].wind, NF); + atmos[rec].channel_in[NR] = average(atmos[rec].channel_in, NF); + atmos[rec].Catm[NR] = average(atmos[rec].Catm, NF); + atmos[rec].fdir[NR] = average(atmos[rec].fdir, NF); + atmos[rec].par[NR] = average(atmos[rec].par, NF); + } + } + + /**************************************************** + Variables in the veg_hist structure + ****************************************************/ + + /* First, assign default climatology */ + for (rec = 0; rec < global_param.nrecs; rec++) { + for (v = 0; v < veg_con[0].vegetat_type_num; v++) { + for (i = 0; i < NF; i++) { + veg_hist[rec][v].albedo[i] = + veg_lib[veg_con[v].veg_class].albedo[dmy[rec].month - + 1]; + } + } + } + + /* Next, overwrite with timeseries */ + for (rec = 0; rec < global_param.nrecs; rec++) { + for (v = 0; v < veg_con[0].vegetat_type_num; v++) { + for (i = 0; i < NF; i++) { + uidx = rec * NF + i; + if (param_set.TYPE[ALBEDO].SUPPLIED) { + if (veg_hist_data[ALBEDO][v][uidx] != NODATA_VH) { + veg_hist[rec][v].albedo[i] = + veg_hist_data[ALBEDO][v][uidx]; + } + } + if (param_set.TYPE[LAI_IN].SUPPLIED) { + if (veg_hist_data[LAI_IN][v][uidx] != NODATA_VH) { + veg_hist[rec][v].LAI[i] = + veg_hist_data[LAI_IN][v][uidx]; + } + } + if (param_set.TYPE[VEGCOVER].SUPPLIED) { + if (veg_hist_data[VEGCOVER][v][uidx] != NODATA_VH) { + veg_hist[rec][v].vegcover[i] = + veg_hist_data[VEGCOVER][v][uidx]; + } + if (veg_hist[rec][v].vegcover[i] > MAX_VEGCOVER) { + veg_hist[rec][v].vegcover[i] = MAX_VEGCOVER; + } + if (veg_hist[rec][v].vegcover[i] < MIN_VEGCOVER) { + veg_hist[rec][v].vegcover[i] = MIN_VEGCOVER; + } + } + } + if (NF > 1) { + veg_hist[rec][v].albedo[NR] = average(veg_hist[rec][v].albedo, NF); + veg_hist[rec][v].LAI[NR] = average(veg_hist[rec][v].LAI, NF); + veg_hist[rec][v].vegcover[NR] = average(veg_hist[rec][v].vegcover, NF); + } + } + } + + /**************************************************** + Free forcing_data and veg_hist_data structures + ****************************************************/ + + for (i = 0; i < N_FORCING_TYPES; i++) { + if (param_set.TYPE[i].SUPPLIED) { + if (i != ALBEDO && i != LAI_IN && i != VEGCOVER) { + free(forcing_data[i]); + } + else { + for (j = 0; j < param_set.TYPE[i].N_ELEM; j++) { + free(veg_hist_data[i][j]); + } + free(veg_hist_data[i]); + } + } + } + free(forcing_data); + free(veg_hist_data); + + /**************************************************** + Compute treeline based on July average temperature + ****************************************************/ + + if (options.COMPUTE_TREELINE) { + if (!(options.JULY_TAVG_SUPPLIED && avgJulyAirTemp == -999)) { + compute_treeline(atmos, dmy, avgJulyAirTemp, Tfactor, + AboveTreeLine); + } + } + } diff --git a/vic/drivers/image/include/vic_driver_image.h b/vic/drivers/image/include/vic_driver_image.h index 716596bbd..282421b00 100644 --- a/vic/drivers/image/include/vic_driver_image.h +++ b/vic/drivers/image/include/vic_driver_image.h @@ -131,8 +131,6 @@ typedef struct { void add_nveg_to_global_domain(char *nc_name, domain_struct *global_domain); void alloc_atmos(atmos_data_struct *atmos); void alloc_veg_hist(veg_hist_struct *veg_hist); -double air_density(double t, double p); -double average(double *ar, size_t n); out_data_struct *create_output_list(void); void free_atmos(atmos_data_struct *atmos); void free_out_data(out_data_struct **out_data); @@ -172,7 +170,6 @@ int put_nc_field_double(char *nc_name, bool *open, int *nc_id, double fillval, int put_nc_field_int(char *nc_name, bool *open, int *nc_id, int fillval, int *dimids, int ndims, char *var_name, size_t *start, size_t *count, int *var); -double q_to_vp(double q, double p); void sprint_location(char *str, location_struct *loc); void vic_alloc(void); void vic_nc_info(nc_file_struct *nc_hist_file, out_data_struct **out_data, @@ -186,7 +183,5 @@ void vic_restore(void); void vic_start(void); void vic_store(void); void vic_write(void); -char will_it_snow(double *t, double t_offset, double max_snow_temp, - double *prcp, size_t n); #endif diff --git a/vic/drivers/image/src/vic_force.c b/vic/drivers/image/src/vic_force.c index 87778a994..e05613374 100644 --- a/vic/drivers/image/src/vic_force.c +++ b/vic/drivers/image/src/vic_force.c @@ -163,7 +163,7 @@ vic_force(void) // Convert forcings into what we need and calculate missing ones for (i = 0; i < local_domain.ncells; i++) { for (j = 0; j < NF; j++) { - // temperature in CONST_TKFRZ + // temperature in Celsius atmos[i].air_temp[j] -= CONST_TKFRZ; // precipitation in mm/period atmos[i].prec[j] *= global_param.snow_dt; @@ -238,96 +238,3 @@ vic_force(void) free(fvar); } -/****************************************************************************** - * @brief calculate 1d average - *****************************************************************************/ -double -average(double *ar, - size_t n) -{ - size_t i; - double sum = 0.; - - if (n <= 0) { - log_err("Error in calc_average: divide by zero or negative"); - } - else if (n == 1) { - return ar[0]; - } - else { - for (i = 0; i < n; i++) { - sum += ar[i]; - } - } - - return sum / n; -} - -/****************************************************************************** - * @brief convert specific humidity (q) to vapor pressure (vp) based on - * pressure (p) - * - * @param q specific humidity - * @param p pressure - * - * @return vp vapor pressure (units are the same as p) - *****************************************************************************/ -double -q_to_vp(double q, - double p) -{ - double vp; - - // full equation - // vp = q/(q+CONST_EPS*(1-q))*p; - - // approximation used in VIC - vp = q * p / CONST_EPS; - - return vp; -} - -/****************************************************************************** - * @brief convert surface pressure (kPa) to density (kg/m3) based on - * pressure (p), vapor pressure (vp), and temperature - * - * @param t temperature - * @param p pressure - * - * @return rho surface pressure - *****************************************************************************/ -double -air_density(double t, - double p) -{ - double rho; - - // full equation - // rho = (p*1000)/(Rd * *t+CONST_TKFRZ) + (pv*1000)/(Rv * *t+CONST_TKFRZ); - - // approximation used in VIC - rho = 0.003486 * p / (275.0 + t); - - return rho; -} - -/****************************************************************************** - * @brief return 1 if it will snow, otherwise return 0 - *****************************************************************************/ -char -will_it_snow(double *t, - double t_offset, - double max_snow_temp, - double *prcp, - size_t n) -{ - size_t i; - - for (i = 0; i < n; i++) { - if ((t[i] + t_offset) < max_snow_temp && prcp[i] > 0.) { - return 1; - } - } - - return 0; -} diff --git a/vic/drivers/shared/include/vic_driver_shared.h b/vic/drivers/shared/include/vic_driver_shared.h index 6658c2d27..93ef928df 100644 --- a/vic/drivers/shared/include/vic_driver_shared.h +++ b/vic/drivers/shared/include/vic_driver_shared.h @@ -455,8 +455,10 @@ typedef struct { veg_var_struct *veg_var; } Error_struct; +double air_density(double t, double p); double all_30_day_from_dmy(dmy_struct *dmy); double all_leap_from_dmy(dmy_struct *dmy); +double average(double *ar, size_t n); double calc_energy_balance_error(int, double, double, double, double, double); void calc_root_fractions(veg_con_struct *veg_con, soil_con_struct *soil_con); double calc_water_balance_error(int, double, double, double); @@ -544,9 +546,12 @@ void print_veg_lib(veg_lib_struct *vlib, char carbon); void print_veg_var(veg_var_struct *vvar, size_t ncanopy); void print_version(char *); void print_usage(char *); +double q_to_vp(double q, double p); void soil_moisture_from_water_table(soil_con_struct *soil_con, size_t nlayers); int valid_date(unsigned short int calendar, dmy_struct *dmy); void validate_parameters(void); +char will_it_snow(double *t, double t_offset, double max_snow_temp, + double *prcp, size_t n); void zero_output_list(out_data_struct *); #endif diff --git a/vic/drivers/shared/src/forcing_utils.c b/vic/drivers/shared/src/forcing_utils.c new file mode 100644 index 000000000..cde65e52b --- /dev/null +++ b/vic/drivers/shared/src/forcing_utils.c @@ -0,0 +1,123 @@ +/****************************************************************************** + * @section DESCRIPTION + * + * Library of utilities for processing meteorological forcings. + * + * @section LICENSE + * + * The Variable Infiltration Capacity (VIC) macroscale hydrological model + * Copyright (C) 2014 The Land Surface Hydrology Group, Department of Civil + * and Environmental Engineering, University of Washington. + * + * The VIC model is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + *****************************************************************************/ + +#include +#include +#include + +/****************************************************************************** + * @brief calculate 1d average + *****************************************************************************/ +double +average(double *ar, + size_t n) +{ + size_t i; + double sum = 0.; + + if (n <= 0) { + log_err("Error in calc_average: divide by zero or negative"); + } + else if (n == 1) { + return ar[0]; + } + else { + for (i = 0; i < n; i++) { + sum += ar[i]; + } + } + + return sum / n; +} + +/****************************************************************************** + * @brief convert specific humidity (q) to vapor pressure (vp) based on + * pressure (p) + * + * @param q specific humidity + * @param p pressure + * + * @return vp vapor pressure (units are the same as p) + *****************************************************************************/ +double +q_to_vp(double q, + double p) +{ + double vp; + + // full equation + // vp = q/(q+CONST_EPS*(1-q))*p; + + // approximation used in VIC + vp = q * p / CONST_EPS; + + return vp; +} + +/****************************************************************************** + * @brief convert surface pressure (kPa) to density (kg/m3) based on + * pressure (p), vapor pressure (vp), and temperature + * + * @param t temperature + * @param p pressure + * + * @return rho surface pressure + *****************************************************************************/ +double +air_density(double t, + double p) +{ + double rho; + + // full equation + // rho = (p*1000)/(Rd * *t+CONST_TKFRZ) + (pv*1000)/(Rv * *t+CONST_TKFRZ); + + // approximation used in VIC + rho = 0.003486 * p / (275.0 + t); + + return rho; +} + +/****************************************************************************** + * @brief return 1 if it will snow, otherwise return 0 + *****************************************************************************/ +char +will_it_snow(double *t, + double t_offset, + double max_snow_temp, + double *prcp, + size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + if ((t[i] + t_offset) < max_snow_temp && prcp[i] > 0.) { + return 1; + } + } + + return 0; +} From 04401a3718bc693d6d25da8a8d40ee84afece994 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Thu, 24 Sep 2015 15:47:24 -0700 Subject: [PATCH 02/14] Finished removing MTCLIM code and options from code. Removed other disaggregation logic from vic_force(). Moved air_density(), average(), q_to_vp(), and will_it_snow() from drivers/image to drivers/shared/. Removed ALMA_INPUT option. Removed TSKC forcing variable. --- samples/global.param.sample | 24 ----- samples/vic_parameters.txt | 26 ------ vic/drivers/classic/src/alloc_atmos.c | 5 - .../classic/src/display_current_settings.c | 6 -- vic/drivers/classic/src/get_force_type.c | 74 +++------------ vic/drivers/classic/src/get_global_param.c | 7 +- vic/drivers/classic/src/output_list_utils.c | 1 - .../classic/src/print_library_classic.c | 5 - vic/drivers/classic/src/vic_force.c | 21 +++++ vic/drivers/classic/src/write_forcing_file.c | 1 - vic/drivers/image/src/alloc_atmos.c | 5 - .../image/src/display_current_settings.c | 6 -- vic/drivers/image/src/get_global_param.c | 93 ++++++++++++++++--- vic/drivers/image/src/output_list_utils.c | 1 - vic/drivers/image/src/print_library_image.c | 1 - vic/drivers/image/src/vic_nc_info.c | 1 - .../python/src/display_current_settings.c | 6 -- .../shared/include/vic_driver_shared.h | 21 +---- vic/drivers/shared/src/print_library_shared.c | 8 +- vic/drivers/shared/src/put_data.c | 1 - vic/vic_run/include/vic_def.h | 13 --- 21 files changed, 125 insertions(+), 201 deletions(-) diff --git a/samples/global.param.sample b/samples/global.param.sample index 4550b793b..d4919c9e6 100644 --- a/samples/global.param.sample +++ b/samples/global.param.sample @@ -79,29 +79,6 @@ FROZEN_SOIL FALSE # TRUE = calculate frozen soils. Default = FALSE. # # AR_410 = apply stability correction but do NOT multiply by 10 (as in VIC 4.1.0); additionally, always use overstory aero_resist for ET (as in 4.1.0). # # Default = AR_406_FULL -####################################################################### -# Meteorological Forcing Disaggregation Parameters -# Generally these default values do not need to be overridden -####################################################################### -#OUTPUT_FORCE FALSE # TRUE = perform disaggregation of forcings, skip the simulation, and output the disaggregated forcings. -#PLAPSE TRUE # This controls how VIC computes air pressure when air pressure is not supplied as an input forcing: TRUE = set air pressure to sea level pressure, lapsed to grid cell average elevation; FALSE = set air pressure to constant 95.5 kPa (as in all versions of VIC pre-4.1.1) -#MTCLIM_SWE_CORR TRUE # This controls VIC's estimates of incoming shortwave in the presence of snow; TRUE = adjust incoming shortwave for snow albedo effect; FALSE = do not adjust shortwave; default = TRUE -#VP_ITER VP_ITER_ANNUAL # This controls VIC's iteration between estimates of shortwave and vapor pressure: -# # VP_ITER_NEVER = never iterate; make estimates separately -# # VP_ITER_ALWAYS = always iterate once -# # VP_ITER_ANNUAL = iterate once for arid climates based on annual Precip/PET ratio -# # VP_ITER_CONVERGE = iterate until shortwave and vp stabilize -# # default = VP_ITER_ALWAYS -#VP_INTERP TRUE # This controls sub-daily humidity estimates; TRUE = interpolate daily VP estimates linearly between sunrise of one day to the next; FALSE = hold VP constant for entire day -#LW_TYPE LW_PRATA # This controls the algorithm used to estimate clear-sky longwave radiation: -# # LW_TVA = Tennessee Valley Authority algorithm (1972) (this was traditional VIC algorithm) -# # other options listed in vicNl_def.h -# # default = LW_PRATA -#LW_CLOUD LW_CLOUD_DEARDORFF # This controls the algorithm used to estimate the influence of clouds on total longwave: -# # LW_CLOUD_BRAS = method from Bras textbook (this was the traditional VIC algorithm) -# # LW_CLOUD_DEARDORFF = method of Deardorff (1978) -# # default = LW_CLOUD_DEARDORFF - ####################################################################### # Carbon Cycle Parameters ####################################################################### @@ -158,7 +135,6 @@ FORCEHOUR 00 # Hour of first forcing record GRID_DECIMAL 4 # Number of digits after decimal point in forcing file names WIND_H 10.0 # height of wind speed measurement (m) MEASURE_H 2.0 # height of humidity measurement (m) -ALMA_INPUT FALSE # TRUE = ALMA-compliant input variable units; FALSE = standard VIC units ####################################################################### # Land Surface Files and Parameters diff --git a/samples/vic_parameters.txt b/samples/vic_parameters.txt index 980f036e1..61dc75ada 100644 --- a/samples/vic_parameters.txt +++ b/samples/vic_parameters.txt @@ -73,32 +73,6 @@ CANOPY_RSMAX 5000.0 # Maximum allowable resistance (s/m) CANOPY_VPDMINFACTOR 0.1 # Minimum allowable vapor pressure deficit factor ############################################################################### -############################################################################### - # MTCLIM Parameters -MTCLIM_SOLAR_CONSTANT 1368.0 - -# parameters for the Tair algorithm -MTCLIM_TDAYCOEF 0.45 # (dim) daylight air temperature coefficient (dim) - -# parameters for the snowpack algorithm -MTCLIM_SNOW_TCRIT -6.0 # (deg C) critical temperature for snowmelt -MTCLIM_SNOW_TRATE 0.042 # (cm/degC/day) snowmelt rate - -# parameters for the radiation algorithm -MTCLIM_TBASE 0.870 # (dim) max inst. trans., 0m, nadir, dry atm -MTCLIM_ABASE -6.1e-5 # (1/Pa) vapor pressure effect on transmittance -MTCLIM_C 1.5 # (dim) radiation parameter -MTCLIM_B0 0.031 # (dim) radiation parameter -MTCLIM_B1 0.201 # (dim) radiation parameter -MTCLIM_B2 0.185 # (dim) radiation parameter -MTCLIM_RAIN_SCALAR 0.75 # (dim) correction to trans. for rain day -MTCLIM_DIF_ALB 0.6 # (dim) diffuse albedo for horizon correction -MTCLIM_SC_INT 1.32 # (MJ/m2/day) snow correction intercept -MTCLIM_SC_SLOPE 0.096 # (MJ/m2/day/cm) snow correction slope -MTCLIM_SRADDT 30.0 # timestep for radiation routine (seconds) - # Note: Make sure that 3600 % SRADDT == 0 -############################################################################### - ############################################################################### # Lake Model Parameters diff --git a/vic/drivers/classic/src/alloc_atmos.c b/vic/drivers/classic/src/alloc_atmos.c index 697793bcb..94c9de4ad 100644 --- a/vic/drivers/classic/src/alloc_atmos.c +++ b/vic/drivers/classic/src/alloc_atmos.c @@ -91,10 +91,6 @@ alloc_atmos(int nrecs, if ((*atmos)[i].snowflag == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - (*atmos)[i].tskc = (double *) calloc(NR + 1, sizeof(double)); - if ((*atmos)[i].tskc == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } (*atmos)[i].vp = (double *) calloc(NR + 1, sizeof(double)); if ((*atmos)[i].vp == NULL) { log_err("Memory allocation error in alloc_atmos()."); @@ -136,7 +132,6 @@ free_atmos(int nrecs, free((*atmos)[i].pressure); free((*atmos)[i].shortwave); free((*atmos)[i].snowflag); - free((*atmos)[i].tskc); free((*atmos)[i].vp); free((*atmos)[i].vpd); free((*atmos)[i].wind); diff --git a/vic/drivers/classic/src/display_current_settings.c b/vic/drivers/classic/src/display_current_settings.c index 74ed284ea..962d5b1fb 100644 --- a/vic/drivers/classic/src/display_current_settings.c +++ b/vic/drivers/classic/src/display_current_settings.c @@ -278,12 +278,6 @@ display_current_settings(int mode) } } fprintf(LOG_DEST, "GRID_DECIMAL\t\t%d\n", options.GRID_DECIMAL); - if (options.ALMA_INPUT) { - fprintf(LOG_DEST, "ALMA_INPUT\t\tTRUE\n"); - } - else { - fprintf(LOG_DEST, "ALMA_INPUT\t\tFALSE\n"); - } fprintf(LOG_DEST, "\n"); fprintf(LOG_DEST, "Constants File\t\t%s\n", filenames.constants); diff --git a/vic/drivers/classic/src/get_force_type.c b/vic/drivers/classic/src/get_force_type.c index 962769cb9..5b6bebee5 100644 --- a/vic/drivers/classic/src/get_force_type.c +++ b/vic/drivers/classic/src/get_force_type.c @@ -59,7 +59,7 @@ get_force_type(char *cmdstr, Get meteorological data forcing info ***************************************/ - /* type 0: air temperature [C] (ALMA_INPUT: [K]) */ + /* type 0: air temperature [C] */ if (strcasecmp("AIR_TEMP", optstr) == 0) { type = AIR_TEMP; } @@ -71,101 +71,53 @@ get_force_type(char *cmdstr, else if (strcasecmp("CATM", optstr) == 0) { type = CATM; } - /* type 3: incoming channel flow [m3] (ALMA_INPUT: [m3/s]) */ + /* type 3: incoming channel flow [m3] */ else if (strcasecmp("CHANNEL_IN", optstr) == 0) { type = CHANNEL_IN; } - /* type 4: convective rainfall [mm] (ALMA_INPUT: [mm/s]) */ - else if (strcasecmp("CRAINF", optstr) == 0) { - type = CRAINF; - } - /* type 5: convective snowfall [mm] (ALMA_INPUT: [mm/s]) */ - else if (strcasecmp("CSNOWF", optstr) == 0) { - type = CSNOWF; - } - /* type 6: air density [kg/m3] */ - else if (strcasecmp("DENSITY", optstr) == 0) { - type = DENSITY; - } - /* type 7: direct fraction of shortwave [fraction] */ + /* type 4: direct fraction of shortwave [fraction] */ else if (strcasecmp("FDIR", optstr) == 0) { type = FDIR; } - /* type 8: LAI [m2/m2] */ + /* type 5: LAI [m2/m2] */ else if (strcasecmp("LAI_IN", optstr) == 0) { type = LAI_IN; } - /* type 9: incoming longwave radiation [W/m2] */ + /* type 6: incoming longwave radiation [W/m2] */ else if (strcasecmp("LONGWAVE", optstr) == 0 || strcasecmp("LWDOWN", optstr) == 0) { type = LONGWAVE; } - /* type 10: large-scale rainfall [mm] (ALMA_INPUT: [mm/s]) */ - else if (strcasecmp("LSRAINF", optstr) == 0) { - type = LSRAINF; - } - /* type 11: large-scale snowfall [mm] (ALMA_INPUT: [mm/s]) */ - else if (strcasecmp("LSSNOWF", optstr) == 0) { - type = LSSNOWF; - } - /* type 12: photosynthetically active radiation [uE/m2s] */ + /* type 7: photosynthetically active radiation [uE/m2s] */ else if (strcasecmp("PAR", optstr) == 0) { type = PAR; } - /* type 13: precipitation [mm] (ALMA_INPUT: [mm/s]) */ + /* type 8: precipitation [mm] */ else if (strcasecmp("PREC", optstr) == 0) { type = PREC; } - /* type 14: air pressure [kPa] (ALMA_INPUT: [Pa]) */ + /* type 9: air pressure [kPa] */ else if (strcasecmp("PRESSURE", optstr) == 0) { type = PRESSURE; } - /* type 15: specific humidity [kg/kg] */ + /* type 10: specific humidity [kg/kg] */ else if (strcasecmp("QAIR", optstr) == 0) { type = QAIR; } - /* type 16: rainfall [mm] (ALMA_INPUT: [mm/s]) */ - else if (strcasecmp("RAINF", optstr) == 0) { - type = RAINF; - } - /* type 17: relative humidity [fraction] */ - else if (strcasecmp("REL_HUMID", optstr) == 0) { - type = REL_HUMID; - } - /* type 18: shortwave radiation [W/m2] */ + /* type 11: rainfall [mm] */ else if (strcasecmp("SHORTWAVE", optstr) == 0 || strcasecmp("SWDOWN", optstr) == 0) { type = SHORTWAVE; } - /* type 19: snowfall [mm] (ALMA_INPUT: [mm/s]) */ - else if (strcasecmp("SNOWF", optstr) == 0) { - type = SNOWF; - } - /* type 22: cloud cover fraction */ - else if (strcasecmp("TSKC", optstr) == 0) { - type = TSKC; - } - /* type 23: vegetation cover fraction */ + /* type 12: vegetation cover fraction */ else if (strcasecmp("VEGCOVER", optstr) == 0) { type = VEGCOVER; } - /* type 24: vapor pressure [kPa] (ALMA_INPUT: [Pa]) */ - else if (strcasecmp("VP", optstr) == 0) { - type = VP; - } - /* type 25: wind speed [m/s] */ + /* type 13: wind speed [m/s] */ else if (strcasecmp("WIND", optstr) == 0) { type = WIND; } - /* type 26: zonal component of wind speed [m/s] */ - else if (strcasecmp("WIND_E", optstr) == 0) { - type = WIND_E; - } - /* type 27: meridional component of wind speed [m/s] */ - else if (strcasecmp("WIND_N", optstr) == 0) { - type = WIND_N; - } - /* type 28: unused (blank) data */ + /* type 14: unused (blank) data */ else if (strcasecmp("SKIP", optstr) == 0) { type = SKIP; } diff --git a/vic/drivers/classic/src/get_global_param.c b/vic/drivers/classic/src/get_global_param.c index 6f5c220d8..0ea819b07 100644 --- a/vic/drivers/classic/src/get_global_param.c +++ b/vic/drivers/classic/src/get_global_param.c @@ -547,12 +547,7 @@ get_global_param(FILE *gp) else if (strcasecmp("MEASURE_H", optstr) == 0) { sscanf(cmdstr, "%*s %lf", &global_param.measure_h); } - else if (strcasecmp("ALMA_INPUT", optstr) == 0) { - sscanf(cmdstr, "%*s %s", flgstr); - if (strcasecmp("TRUE", flgstr) == 0) { - options.ALMA_INPUT = true; - } - } + /************************************* Define parameter files *************************************/ diff --git a/vic/drivers/classic/src/output_list_utils.c b/vic/drivers/classic/src/output_list_utils.c index 9b174edc3..52b35ff41 100644 --- a/vic/drivers/classic/src/output_list_utils.c +++ b/vic/drivers/classic/src/output_list_utils.c @@ -183,7 +183,6 @@ create_output_list() strcpy(out_data[OUT_REL_HUMID].varname, "OUT_REL_HUMID"); /* relative humidity [fraction]*/ strcpy(out_data[OUT_SHORTWAVE].varname, "OUT_SHORTWAVE"); /* incoming shortwave [W/m2] */ strcpy(out_data[OUT_SURF_COND].varname, "OUT_SURF_COND"); /* surface conductance [m/s] */ - strcpy(out_data[OUT_TSKC].varname, "OUT_TSKC"); /* cloud cover fraction [fraction] */ strcpy(out_data[OUT_VEGCOVER].varname, "OUT_VEGCOVER"); /* fractional area of plants within veg tile [fraction] */ strcpy(out_data[OUT_VP].varname, "OUT_VP"); /* near surface vapor pressure [kPa] */ strcpy(out_data[OUT_VPD].varname, "OUT_VPD"); /* near surface vapor pressure deficit [kPa] */ diff --git a/vic/drivers/classic/src/print_library_classic.c b/vic/drivers/classic/src/print_library_classic.c index 41c53e92b..970b3d4b0 100644 --- a/vic/drivers/classic/src/print_library_classic.c +++ b/vic/drivers/classic/src/print_library_classic.c @@ -113,11 +113,6 @@ print_atmos_data(atmos_data_struct *atmos, fprintf(LOG_DEST, "\t%d\n", atmos->snowflag[i]); } fprintf(LOG_DEST, "\n"); - fprintf(LOG_DEST, "\ttskc :"); - for (i = 0; i <= nr; i++) { - fprintf(LOG_DEST, "\t%.4f", atmos->tskc[i]); - } - fprintf(LOG_DEST, "\n"); fprintf(LOG_DEST, "\tvp :"); for (i = 0; i <= nr; i++) { fprintf(LOG_DEST, "\t%.4f", atmos->vp[i]); diff --git a/vic/drivers/classic/src/vic_force.c b/vic/drivers/classic/src/vic_force.c index 83f6342e5..657a3f982 100644 --- a/vic/drivers/classic/src/vic_force.c +++ b/vic/drivers/classic/src/vic_force.c @@ -55,6 +55,7 @@ vic_force(atmos_data_struct *atmos, size_t v; size_t rec; size_t uidx; + double t_offset; double **forcing_data; double ***veg_hist_data; double avgJulyAirTemp; @@ -119,6 +120,12 @@ vic_force(atmos_data_struct *atmos, Variables in the atmos_data structure ****************************************************/ + t_offset = Tfactor[0]; + for (band = 1; band < options.SNOW_BAND; band++) { + if (Tfactor[band] < t_offset) + t_offset = Tfactor[band]; + } + for (rec = 0; rec < global_param.nrecs; rec++) { for (i = 0; i < NF; i++) { uidx = rec * NF + i; @@ -142,6 +149,11 @@ vic_force(atmos_data_struct *atmos, atmos[rec].pressure[i]); // wind speed in m/s atmos[rec].wind[i] = forcing_data[WIND][uidx]; + // snow flag + atmos[i].snowflag[j] = will_it_snow(&(atmos[i].air_temp[j]), + t_offset, + param.SNOW_MAX_SNOW_TEMP, + &(atmos[i].prec[j]), 1); // Optional inputs // Channel inflow from upstream (into lake) if (param_set.TYPE[CHANNEL_IN].SUPPLIED) { @@ -154,6 +166,9 @@ vic_force(atmos_data_struct *atmos, if (param_set.TYPE[CATM].SUPPLIED) { atmos[rec].Catm[i] = forcing_data[CATM][uidx]; } + else { + atmos[rec].Catm[i] = param.CARBON_CATMCURRENT * PPM_to_MIXRATIO; + } // Fraction of shortwave that is direct if (param_set.TYPE[FDIR].SUPPLIED) { atmos[rec].fdir[i] = forcing_data[FDIR][uidx]; @@ -177,6 +192,12 @@ vic_force(atmos_data_struct *atmos, atmos[rec].vpd[NR] = average(atmos[rec].vpd, NF); atmos[rec].density[NR] = average(atmos[rec].density, NF); atmos[rec].wind[NR] = average(atmos[rec].wind, NF); + atmos[rec].snowflag[NR] = FALSE; + for (i=0; isnowflag == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - atmos->tskc = (double *) calloc(NR + 1, sizeof(double)); - if (atmos->tskc == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } atmos->vp = (double *) calloc(NR + 1, sizeof(double)); if (atmos->vp == NULL) { log_err("Memory allocation error in alloc_atmos()."); @@ -122,7 +118,6 @@ free_atmos(atmos_data_struct *atmos) free(atmos->pressure); free(atmos->shortwave); free(atmos->snowflag); - free(atmos->tskc); free(atmos->vp); free(atmos->vpd); free(atmos->wind); diff --git a/vic/drivers/image/src/display_current_settings.c b/vic/drivers/image/src/display_current_settings.c index 2ea13d094..367da32eb 100644 --- a/vic/drivers/image/src/display_current_settings.c +++ b/vic/drivers/image/src/display_current_settings.c @@ -278,12 +278,6 @@ display_current_settings(int mode) } } fprintf(LOG_DEST, "GRID_DECIMAL\t\t%hu\n", options.GRID_DECIMAL); - if (options.ALMA_INPUT) { - fprintf(LOG_DEST, "ALMA_INPUT\t\tTRUE\n"); - } - else { - fprintf(LOG_DEST, "ALMA_INPUT\t\tFALSE\n"); - } fprintf(LOG_DEST, "\n"); fprintf(LOG_DEST, "Input Domain Data:\n"); diff --git a/vic/drivers/image/src/get_global_param.c b/vic/drivers/image/src/get_global_param.c index 99be92202..1593d9d3f 100644 --- a/vic/drivers/image/src/get_global_param.c +++ b/vic/drivers/image/src/get_global_param.c @@ -537,12 +537,6 @@ get_global_param(FILE *gp) else if (strcasecmp("MEASURE_H", optstr) == 0) { sscanf(cmdstr, "%*s %lf", &global_param.measure_h); } - else if (strcasecmp("ALMA_INPUT", optstr) == 0) { - sscanf(cmdstr, "%*s %s", flgstr); - if (strcasecmp("TRUE", flgstr) == 0) { - options.ALMA_INPUT = true; - } - } /************************************* Define parameter files @@ -1150,8 +1144,8 @@ get_global_param(FILE *gp) "than 0, in the global control file."); } if (options.LAI_SRC == LAI_FROM_VEGPARAM && !options.VEGPARAM_LAI) { - log_err("\"LAI_SRC\" was specified as \"LAI_FROM_VEGPARAM\", " - "but \"VEGPARAM_LAI\" was set to \"FALSE\" in the global " + log_err("\"LAI_SRC\" was specified as \"LAI_FROM_VEGPARAM\", but " + "\"VEGPARAM_LAI\" was set to \"FALSE\" in the global " "parameter file. If you want VIC to read LAI values from " "the vegparam file, you MUST make sure the veg param file " "contains 1 line of 12 monthly LAI values for EACH veg " @@ -1159,10 +1153,85 @@ get_global_param(FILE *gp) "\"VEGPARAM_LAI\" as \"TRUE\" in the global parameter " "file. Alternatively, if you want VIC to read LAI values " "from the veg library file, set \"LAI_SRC\" to " - "\"LAI_FROM_VEGLIB\" in the global parameter file. " - "In either case, the setting of \"VEGPARAM_LAI\" must be " - "consistent with the contents of the veg param file " - "(i.e. whether or not it contains LAI values)."); + "\"LAI_FROM_VEGLIB\" in the global parameter file. In " + "either case, the setting of \"VEGPARAM_LAI\" must be " + "consistent with the contents of the veg param file (i.e. " + "whether or not it contains LAI values)."); + } + if (options.LAI_SRC == FROM_VEGPARAM && !options.VEGPARAM_LAI) { + log_err("\"LAI_SRC\" was specified as \"FROM_VEGPARAM\", but " + "\"VEGPARAM_LAI\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read LAI values from " + "the vegparam file, you MUST make sure the veg param file " + "contains 1 line of 12 monthly LAI values for EACH veg " + "tile in EACH grid cell, and you MUST specify " + "\"VEGPARAM_LAI\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read LAI values " + "from the veg library file, set \"LAI_SRC\" to " + "\"FROM_VEGLIB\" in the global parameter file. In " + "either case, the setting of \"VEGPARAM_LAI\" must be " + "consistent with the contents of the veg param file (i.e. " + "whether or not it contains LAI values)."); + } + if (options.ALB_SRC == FROM_VEGPARAM && !options.VEGPARAM_ALB) { + log_err("\"ALB_SRC\" was specified as \"FROM_VEGPARAM\", but " + "\"VEGPARAM_ALB\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read albedo values from " + "the vegparam file, you MUST make sure the veg param file " + "contains 1 line of 12 monthly albedo values for EACH veg " + "tile in EACH grid cell, and you MUST specify " + "\"VEGPARAM_ALB\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read albedo values " + "from the veg library file, set \"ALB_SRC\" to " + "\"FROM_VEGLIB\" in the global parameter file. In " + "either case, the setting of \"VEGPARAM_ALB\" must be " + "consistent with the contents of the veg param file (i.e. " + "whether or not it contains albedo values)."); + } + if (options.VEGCOVER_SRC == FROM_VEGPARAM && !options.VEGPARAM_VEGCOVER) { + log_err("\"VEGCOVER_SRC\" was specified as \"FROM_VEGPARAM\", but " + "\"VEGPARAM_VEGCOVER\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read vegcover values from " + "the vegparam file, you MUST make sure the veg param file " + "contains 1 line of 12 monthly vegcover values for EACH veg " + "tile in EACH grid cell, and you MUST specify " + "\"VEGPARAM_VEGCOVER\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read vegcover values " + "from the veg library file, set \"VEGCOVER_SRC\" to " + "\"FROM_VEGLIB\" in the global parameter file. In " + "either case, the setting of \"VEGPARAM_VEGCOVER\" must be " + "consistent with the contents of the veg param file (i.e. " + "whether or not it contains vegcover values)."); + } + if (options.ALB_SRC == FROM_VEGLIB && !options.VEGLIB_ALB) { + log_err("\"ALB_SRC\" was specified as \"FROM_VEGLIB\", but " + "\"VEGLIB_ALB\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read albedo values from " + "the veglib file, you MUST make sure the veg lib file " + "contains 1 line of 12 monthly albedo values for EACH veg " + "class, and you MUST specify " + "\"VEGLIB_ALB\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read albedo values " + "from the veg param file, set \"ALB_SRC\" to " + "\"FROM_VEGPARAM\" in the global parameter file. In " + "either case, the setting of \"VEGLIB_ALB\" must be " + "consistent with the contents of the veg lib file (i.e. " + "whether or not it contains albedo values)."); + } + if (options.VEGCOVER_SRC == FROM_VEGLIB && !options.VEGLIB_VEGCOVER) { + log_err("\"VEGCOVER_SRC\" was specified as \"FROM_VEGLIB\", but " + "\"VEGLIB_VEGCOVER\" was set to \"FALSE\" in the global " + "parameter file. If you want VIC to read vegcover values from " + "the veglib file, you MUST make sure the veg lib file " + "contains 1 line of 12 monthly vegcover values for EACH veg " + "class, and you MUST specify " + "\"VEGLIB_VEGCOVER\" as \"TRUE\" in the global parameter " + "file. Alternatively, if you want VIC to read vegcover values " + "from the veg param file, set \"VEGCOVER_SRC\" to " + "\"FROM_VEGPARAM\" in the global parameter file. In " + "either case, the setting of \"VEGLIB_VEGCOVER\" must be " + "consistent with the contents of the veg lib file (i.e. " + "whether or not it contains vegcover values)."); } // Validate SPATIAL_FROST information diff --git a/vic/drivers/image/src/output_list_utils.c b/vic/drivers/image/src/output_list_utils.c index 1e16be750..896ffd297 100644 --- a/vic/drivers/image/src/output_list_utils.c +++ b/vic/drivers/image/src/output_list_utils.c @@ -182,7 +182,6 @@ create_output_list() strcpy(out_data[OUT_REL_HUMID].varname, "OUT_REL_HUMID"); /* relative humidity [fraction]*/ strcpy(out_data[OUT_SHORTWAVE].varname, "OUT_SHORTWAVE"); /* incoming shortwave [W/m2] */ strcpy(out_data[OUT_SURF_COND].varname, "OUT_SURF_COND"); /* surface conductance [m/s] */ - strcpy(out_data[OUT_TSKC].varname, "OUT_TSKC"); /* cloud cover fraction [fraction] */ strcpy(out_data[OUT_VP].varname, "OUT_VP"); /* near surface vapor pressure [kPa] */ strcpy(out_data[OUT_VPD].varname, "OUT_VPD"); /* near surface vapor pressure deficit [kPa] */ strcpy(out_data[OUT_WIND].varname, "OUT_WIND"); /* near surface wind speed [m/s] */ diff --git a/vic/drivers/image/src/print_library_image.c b/vic/drivers/image/src/print_library_image.c index 2b1d873bb..bb579083c 100644 --- a/vic/drivers/image/src/print_library_image.c +++ b/vic/drivers/image/src/print_library_image.c @@ -50,7 +50,6 @@ print_atmos_data(atmos_data_struct *atmos) fprintf(LOG_DEST, "\tpressure : %.4f\n", atmos->pressure[0]); fprintf(LOG_DEST, "\tshortwave : %.4f\n", atmos->shortwave[0]); fprintf(LOG_DEST, "\tsnowflag : %d\n", atmos->snowflag[0]); - fprintf(LOG_DEST, "\ttskc : %.4f\n", atmos->tskc[0]); fprintf(LOG_DEST, "\tvp : %.4f\n", atmos->vp[0]); fprintf(LOG_DEST, "\tvpd : %.4f\n", atmos->vpd[0]); fprintf(LOG_DEST, "\twind : %.4f\n", atmos->wind[0]); diff --git a/vic/drivers/image/src/vic_nc_info.c b/vic/drivers/image/src/vic_nc_info.c index b3bf01b14..4ce98ee0f 100644 --- a/vic/drivers/image/src/vic_nc_info.c +++ b/vic/drivers/image/src/vic_nc_info.c @@ -159,7 +159,6 @@ vic_nc_info(nc_file_struct *nc_hist_file, case OUT_COSZEN: case OUT_FDIR: case OUT_REL_HUMID: - case OUT_TSKC: case OUT_ALBEDO_BAND: case OUT_SNOW_COVER_BAND: strncpy(nc_vars[i].nc_units, "-", MAXSTRING); diff --git a/vic/drivers/python/src/display_current_settings.c b/vic/drivers/python/src/display_current_settings.c index e6ee136fa..aba04fe4e 100644 --- a/vic/drivers/python/src/display_current_settings.c +++ b/vic/drivers/python/src/display_current_settings.c @@ -283,12 +283,6 @@ display_current_settings(int mode) } } fprintf(LOG_DEST, "GRID_DECIMAL\t\t%hu\n", options.GRID_DECIMAL); - if (options.ALMA_INPUT) { - fprintf(LOG_DEST, "ALMA_INPUT\t\tTRUE\n"); - } - else { - fprintf(LOG_DEST, "ALMA_INPUT\t\tFALSE\n"); - } fprintf(LOG_DEST, "\n"); fprintf(LOG_DEST, "Input Domain Data:\n"); diff --git a/vic/drivers/shared/include/vic_driver_shared.h b/vic/drivers/shared/include/vic_driver_shared.h index 93ef928df..7d436bcf5 100644 --- a/vic/drivers/shared/include/vic_driver_shared.h +++ b/vic/drivers/shared/include/vic_driver_shared.h @@ -76,32 +76,20 @@ enum *****************************************************************************/ enum { - AIR_TEMP, /**< air temperature per time step [C] (ALMA_INPUT: [K]) */ + AIR_TEMP, /**< air temperature per time step [C] */ ALBEDO, /**< surface albedo [fraction] */ CATM, /**< atmospheric CO2 concentration [ppm] */ - CHANNEL_IN, /**< incoming channel flow [m3] (ALMA_INPUT: [m3/s]) */ - CRAINF, /**< convective rainfall [mm] (ALMA_INPUT: [mm/s]) */ - CSNOWF, /**< convective snowfall [mm] (ALMA_INPUT: [mm/s]) */ - DENSITY, /**< atmospheric density [kg/m3] */ + CHANNEL_IN, /**< incoming channel flow [m3] */ FDIR, /**< fraction of incoming shortwave that is direct [fraction] */ LAI_IN, /**< leaf area index [m2/m2] */ LONGWAVE, /**< incoming longwave radiation [W/m2] */ - LSRAINF, /**< large-scale rainfall [mm] (ALMA_INPUT: [mm/s]) */ - LSSNOWF, /**< large-scale snowfall [mm] (ALMA_INPUT: [mm/s]) */ PAR, /**< incoming photosynthetically active radiation [W/m2] */ - PREC, /**< total precipitation (rain and snow) [mm] (ALMA_INPUT: [mm/s]) */ - PRESSURE, /**< atmospheric pressure [kPa] (ALMA_INPUT: [Pa]) */ + PREC, /**< total precipitation (rain and snow) [mm] */ + PRESSURE, /**< atmospheric pressure [kPa] */ QAIR, /**< specific humidity [kg/kg] */ - RAINF, /**< rainfall (convective and large-scale) [mm] (ALMA_INPUT: [mm/s]) */ - REL_HUMID, /**< relative humidity [%] */ SHORTWAVE, /**< incoming shortwave [W/m2] */ - SNOWF, /**< snowfall (convective and large-scale) [mm] (ALMA_INPUT: [mm/s]) */ - TSKC, /**< cloud cover fraction [fraction] */ VEGCOVER, /**< fraction of each veg tile covered by plants [fraction] */ - VP, /**< vapor pressure [kPa] (ALMA_INPUT: [Pa]) */ WIND, /**< wind speed [m/s] */ - WIND_E, /**< zonal component of wind speed [m/s] */ - WIND_N, /**< meridional component of wind speed [m/s] */ SKIP, /**< place holder for unused data columns */ // Last value of enum - DO NOT ADD ANYTHING BELOW THIS LINE!! // used as a loop counter and must be >= the largest value in this enum @@ -250,7 +238,6 @@ enum OUT_REL_HUMID, /**< relative humidity [%]*/ OUT_SHORTWAVE, /**< incoming shortwave [W/m2] */ OUT_SURF_COND, /**< surface conductance [m/s] */ - OUT_TSKC, /**< cloud cover fraction [fraction] */ OUT_VEGCOVER, /**< fractional area of plants [fraction] */ OUT_VP, /**< near surface vapor pressure [kPa] (ALMA_OUTPUT: [Pa]) */ OUT_VPD, /**< near surface vapor pressure deficit [kPa] (ALMA_OUTPUT: [Pa]) */ diff --git a/vic/drivers/shared/src/print_library_shared.c b/vic/drivers/shared/src/print_library_shared.c index 64d100c37..8f2be6b25 100644 --- a/vic/drivers/shared/src/print_library_shared.c +++ b/vic/drivers/shared/src/print_library_shared.c @@ -497,14 +497,16 @@ print_option(option_struct *option) fprintf(LOG_DEST, "\tSPATIAL_FROST : %d\n", option->SPATIAL_FROST); fprintf(LOG_DEST, "\tSPATIAL_SNOW : %d\n", option->SPATIAL_SNOW); fprintf(LOG_DEST, "\tTFALLBACK : %d\n", option->TFALLBACK); - fprintf(LOG_DEST, "\tVP_INTERP : %d\n", option->VP_INTERP); - fprintf(LOG_DEST, "\tVP_ITER : %d\n", option->VP_ITER); - fprintf(LOG_DEST, "\tALMA_INPUT : %d\n", option->ALMA_INPUT); fprintf(LOG_DEST, "\tBASEFLOW : %d\n", option->BASEFLOW); fprintf(LOG_DEST, "\tGRID_DECIMAL : %d\n", option->GRID_DECIMAL); fprintf(LOG_DEST, "\tVEGLIB_PHOTO : %d\n", option->VEGLIB_PHOTO); + fprintf(LOG_DEST, "\tVEGLIB_VEGCOVER : %d\n", option->VEGLIB_VEGCOVER); + fprintf(LOG_DEST, "\tVEGPARAM_ALB : %d\n", option->VEGPARAM_ALB); fprintf(LOG_DEST, "\tVEGPARAM_LAI : %d\n", option->VEGPARAM_LAI); + fprintf(LOG_DEST, "\tVEGPARAM_VEGCOVER : %d\n", option->VEGPARAM_VEGCOVER); + fprintf(LOG_DEST, "\tALB_SRC : %d\n", option->ALB_SRC); fprintf(LOG_DEST, "\tLAI_SRC : %d\n", option->LAI_SRC); + fprintf(LOG_DEST, "\tVEGCOVER_SRC : %d\n", option->VEGCOVER_SRC); fprintf(LOG_DEST, "\tLAKE_PROFILE : %d\n", option->LAKE_PROFILE); fprintf(LOG_DEST, "\tORGANIC_FRACT : %d\n", option->ORGANIC_FRACT); fprintf(LOG_DEST, "\tBINARY_STATE_FILE : %d\n", diff --git a/vic/drivers/shared/src/put_data.c b/vic/drivers/shared/src/put_data.c index ae880f790..24d1f09c1 100644 --- a/vic/drivers/shared/src/put_data.c +++ b/vic/drivers/shared/src/put_data.c @@ -174,7 +174,6 @@ put_data(all_vars_struct *all_vars, } out_data[OUT_SHORTWAVE].data[0] = atmos->shortwave[NR]; out_data[OUT_SNOWF].data[0] = atmos->out_snow; // mm over grid cell - out_data[OUT_TSKC].data[0] = atmos->tskc[NR]; out_data[OUT_VP].data[0] = atmos->vp[NR] / PA_PER_KPA; out_data[OUT_VPD].data[0] = atmos->vpd[NR] / PA_PER_KPA; out_data[OUT_WIND].data[0] = atmos->wind[NR]; diff --git a/vic/vic_run/include/vic_def.h b/vic/vic_run/include/vic_def.h index f02b3ff2a..1c27208f2 100644 --- a/vic/vic_run/include/vic_def.h +++ b/vic/vic_run/include/vic_def.h @@ -286,10 +286,6 @@ typedef struct { bool NOFLUX; /**< TRUE = Use no flux lower bondary when computing soil thermal fluxes */ size_t NVEGTYPES; /**< number of vegetation types (used by image driver) */ - bool PLAPSE; /**< TRUE = If air pressure not supplied as an - input forcing, compute it by lapsing sea-level - pressure by grid cell average elevation; - FALSE = air pressure set to constant 95.5 kPa */ unsigned short int RC_MODE; /**< RC_JARVIS = compute canopy resistance via Jarvis formulation (default) RC_PHOTO = compute canopy resistance based on photosynthetic activity */ size_t ROOT_ZONES; /**< Number of root zones used in simulation */ @@ -317,16 +313,8 @@ typedef struct { FALSE = when iterations fail to converge, report an error and abort simulation for current grid cell Default = TRUE */ - bool VP_INTERP; /**< How to disaggregate VP from daily to sub-daily; - TRUE = linearly interpolate between daily VP values, assuming they occur at the times of Tmin; - FALSE = hold VP constant at the daily value */ - unsigned short VP_ITER; /**< VP_ITER_NONE = never iterate with SW - VP_ITER_ALWAYS = always iterate with SW - VP_ITER_ANNUAL = use annual Epot/PRCP criterion - VP_ITER_CONVERGE = always iterate until convergence */ // input options - bool ALMA_INPUT; /**< TRUE = input variables are in ALMA-compliant units; FALSE = standard VIC units */ bool BASEFLOW; /**< ARNO: read Ds, Dm, Ws, c; NIJSSEN2001: read d1, d2, d3, d4 */ unsigned short int GRID_DECIMAL; /**< Number of decimal places in grid file extensions */ bool VEGLIB_PHOTO; /**< TRUE = veg library contains photosynthesis parameters */ @@ -774,7 +762,6 @@ typedef struct { double *shortwave; /**< incoming shortwave radiation (W/m^2) */ bool *snowflag; /**< TRUE if there is snowfall in any of the snow bands during the timestep, FALSE otherwise*/ - double *tskc; /**< cloud cover fraction (fraction) */ double *vp; /**< atmospheric vapor pressure (kPa) */ double *vpd; /**< atmospheric vapor pressure deficit (kPa) */ double *wind; /**< wind speed (m/s) */ From e30f03b477af18325550d0001da7c5f8feaeccc7 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Thu, 24 Sep 2015 16:23:48 -0700 Subject: [PATCH 03/14] Fixed some bugs. --- .../classic/include/vic_driver_classic.h | 3 +-- vic/drivers/classic/src/get_global_param.c | 15 ------------- vic/drivers/classic/src/vic_force.c | 22 ++++++------------- vic/drivers/image/src/get_global_param.c | 15 ------------- 4 files changed, 8 insertions(+), 47 deletions(-) diff --git a/vic/drivers/classic/include/vic_driver_classic.h b/vic/drivers/classic/include/vic_driver_classic.h index fe47746b3..6a723233b 100644 --- a/vic/drivers/classic/include/vic_driver_classic.h +++ b/vic/drivers/classic/include/vic_driver_classic.h @@ -75,8 +75,7 @@ out_data_file_struct *set_output_defaults(out_data_struct *); int set_output_var(out_data_file_struct *, int, int, out_data_struct *, char *, int, char *, int, double); void vic_force(atmos_data_struct *, dmy_struct *, FILE **, veg_lib_struct *, - veg_con_struct *, veg_hist_struct **, soil_con_struct *, - out_data_file_struct *, out_data_struct *); + veg_con_struct *, veg_hist_struct **, soil_con_struct *); void write_data(out_data_file_struct *, out_data_struct *, dmy_struct *, double); void write_forcing_file(atmos_data_struct *, int, out_data_file_struct *, diff --git a/vic/drivers/classic/src/get_global_param.c b/vic/drivers/classic/src/get_global_param.c index 0ea819b07..21f3e8219 100644 --- a/vic/drivers/classic/src/get_global_param.c +++ b/vic/drivers/classic/src/get_global_param.c @@ -1298,21 +1298,6 @@ get_global_param(FILE *gp) "consistent with the contents of the veg param file (i.e. " "whether or not it contains vegcover values)."); } - if (options.ALB_SRC == FROM_VEGLIB && !options.VEGLIB_ALB) { - log_err("\"ALB_SRC\" was specified as \"FROM_VEGLIB\", but " - "\"VEGLIB_ALB\" was set to \"FALSE\" in the global " - "parameter file. If you want VIC to read albedo values from " - "the veglib file, you MUST make sure the veg lib file " - "contains 1 line of 12 monthly albedo values for EACH veg " - "class, and you MUST specify " - "\"VEGLIB_ALB\" as \"TRUE\" in the global parameter " - "file. Alternatively, if you want VIC to read albedo values " - "from the veg param file, set \"ALB_SRC\" to " - "\"FROM_VEGPARAM\" in the global parameter file. In " - "either case, the setting of \"VEGLIB_ALB\" must be " - "consistent with the contents of the veg lib file (i.e. " - "whether or not it contains albedo values)."); - } if (options.VEGCOVER_SRC == FROM_VEGLIB && !options.VEGLIB_VEGCOVER) { log_err("\"VEGCOVER_SRC\" was specified as \"FROM_VEGLIB\", but " "\"VEGLIB_VEGCOVER\" was set to \"FALSE\" in the global " diff --git a/vic/drivers/classic/src/vic_force.c b/vic/drivers/classic/src/vic_force.c index 657a3f982..4c263906e 100644 --- a/vic/drivers/classic/src/vic_force.c +++ b/vic/drivers/classic/src/vic_force.c @@ -39,9 +39,7 @@ vic_force(atmos_data_struct *atmos, veg_lib_struct *veg_lib, veg_con_struct *veg_con, veg_hist_struct **veg_hist, - soil_con_struct *soil_con, - out_data_file_struct *out_data_files, - out_data_struct *out_data) + soil_con_struct *soil_con) { extern option_struct options; @@ -121,9 +119,9 @@ vic_force(atmos_data_struct *atmos, ****************************************************/ t_offset = Tfactor[0]; - for (band = 1; band < options.SNOW_BAND; band++) { - if (Tfactor[band] < t_offset) - t_offset = Tfactor[band]; + for (i = 1; i < options.SNOW_BAND; i++) { + if (Tfactor[i] < t_offset) + t_offset = Tfactor[i]; } for (rec = 0; rec < global_param.nrecs; rec++) { @@ -192,10 +190,10 @@ vic_force(atmos_data_struct *atmos, atmos[rec].vpd[NR] = average(atmos[rec].vpd, NF); atmos[rec].density[NR] = average(atmos[rec].density, NF); atmos[rec].wind[NR] = average(atmos[rec].wind, NF); - atmos[rec].snowflag[NR] = FALSE; + atmos[rec].snowflag[NR] = false; for (i=0; i MAX_VEGCOVER) { - veg_hist[rec][v].vegcover[i] = MAX_VEGCOVER; - } - if (veg_hist[rec][v].vegcover[i] < MIN_VEGCOVER) { - veg_hist[rec][v].vegcover[i] = MIN_VEGCOVER; - } } } if (NF > 1) { diff --git a/vic/drivers/image/src/get_global_param.c b/vic/drivers/image/src/get_global_param.c index 1593d9d3f..58e7d4b8d 100644 --- a/vic/drivers/image/src/get_global_param.c +++ b/vic/drivers/image/src/get_global_param.c @@ -1203,21 +1203,6 @@ get_global_param(FILE *gp) "consistent with the contents of the veg param file (i.e. " "whether or not it contains vegcover values)."); } - if (options.ALB_SRC == FROM_VEGLIB && !options.VEGLIB_ALB) { - log_err("\"ALB_SRC\" was specified as \"FROM_VEGLIB\", but " - "\"VEGLIB_ALB\" was set to \"FALSE\" in the global " - "parameter file. If you want VIC to read albedo values from " - "the veglib file, you MUST make sure the veg lib file " - "contains 1 line of 12 monthly albedo values for EACH veg " - "class, and you MUST specify " - "\"VEGLIB_ALB\" as \"TRUE\" in the global parameter " - "file. Alternatively, if you want VIC to read albedo values " - "from the veg param file, set \"ALB_SRC\" to " - "\"FROM_VEGPARAM\" in the global parameter file. In " - "either case, the setting of \"VEGLIB_ALB\" must be " - "consistent with the contents of the veg lib file (i.e. " - "whether or not it contains albedo values)."); - } if (options.VEGCOVER_SRC == FROM_VEGLIB && !options.VEGLIB_VEGCOVER) { log_err("\"VEGCOVER_SRC\" was specified as \"FROM_VEGLIB\", but " "\"VEGLIB_VEGCOVER\" was set to \"FALSE\" in the global " From 055c9335fa369951eaa7b61a9f771181118b57fc Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Thu, 24 Sep 2015 16:35:24 -0700 Subject: [PATCH 04/14] Fixed a couple more bugs. --- vic/drivers/classic/src/vic_classic.c | 2 +- vic/drivers/classic/src/vic_force.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vic/drivers/classic/src/vic_classic.c b/vic/drivers/classic/src/vic_classic.c index 882649954..86812e1fc 100644 --- a/vic/drivers/classic/src/vic_classic.c +++ b/vic/drivers/classic/src/vic_classic.c @@ -193,7 +193,7 @@ main(int argc, **************************************************/ vic_force(atmos, dmy, filep.forcing, veg_lib, veg_con, veg_hist, - &soil_con, out_data_files, out_data); + &soil_con); /************************************************** Initialize Energy Balance and Snow Variables diff --git a/vic/drivers/classic/src/vic_force.c b/vic/drivers/classic/src/vic_force.c index 4c263906e..6ce37019e 100644 --- a/vic/drivers/classic/src/vic_force.c +++ b/vic/drivers/classic/src/vic_force.c @@ -148,10 +148,10 @@ vic_force(atmos_data_struct *atmos, // wind speed in m/s atmos[rec].wind[i] = forcing_data[WIND][uidx]; // snow flag - atmos[i].snowflag[j] = will_it_snow(&(atmos[i].air_temp[j]), + atmos[rec].snowflag[i] = will_it_snow(&(atmos[rec].air_temp[i]), t_offset, param.SNOW_MAX_SNOW_TEMP, - &(atmos[i].prec[j]), 1); + &(atmos[rec].prec[i]), 1); // Optional inputs // Channel inflow from upstream (into lake) if (param_set.TYPE[CHANNEL_IN].SUPPLIED) { From 8e928521bd211e34e9898ff5d7bbe1e035c43e33 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Thu, 24 Sep 2015 17:12:13 -0700 Subject: [PATCH 05/14] Fixed another bug. --- vic/drivers/image/src/vic_mpi_support.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/vic/drivers/image/src/vic_mpi_support.c b/vic/drivers/image/src/vic_mpi_support.c index 2d4bd68d8..d26568e17 100644 --- a/vic/drivers/image/src/vic_mpi_support.c +++ b/vic/drivers/image/src/vic_mpi_support.c @@ -869,18 +869,6 @@ create_MPI_option_struct_type(MPI_Datatype *mpi_type) offsets[i] = offsetof(option_struct, TFALLBACK); mpi_types[i++] = MPI_C_BOOL; - // bool VP_INTERP; - offsets[i] = offsetof(option_struct, VP_INTERP); - mpi_types[i++] = MPI_C_BOOL; - - // unsigned short VP_ITER; - offsets[i] = offsetof(option_struct, VP_ITER); - mpi_types[i++] = MPI_UNSIGNED_SHORT; - - // bool ALMA_INPUT; - offsets[i] = offsetof(option_struct, ALMA_INPUT); - mpi_types[i++] = MPI_C_BOOL; - // bool BASEFLOW; offsets[i] = offsetof(option_struct, BASEFLOW); mpi_types[i++] = MPI_C_BOOL; From eb9fa64cf302749c4d957c40de95f596656fcb44 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Thu, 24 Sep 2015 17:13:59 -0700 Subject: [PATCH 06/14] Fixed another bug. --- vic/drivers/python/src/display_current_settings.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vic/drivers/python/src/display_current_settings.c b/vic/drivers/python/src/display_current_settings.c index aba04fe4e..b66a3b707 100644 --- a/vic/drivers/python/src/display_current_settings.c +++ b/vic/drivers/python/src/display_current_settings.c @@ -228,12 +228,6 @@ display_current_settings(int mode) else { fprintf(LOG_DEST, "TFALLBACK\t\tFALSE\n"); } - if (options.VP_INTERP) { - fprintf(LOG_DEST, "VP_INTERP\t\tTRUE\n"); - } - else { - fprintf(LOG_DEST, "VP_INTERP\t\tFALSE\n"); - } fprintf(LOG_DEST, "WIND_H\t\t\t%f\n", global_param.wind_h); fprintf(LOG_DEST, "MEASURE_H\t\t%f\n", global_param.measure_h); fprintf(LOG_DEST, "NODES\t\t\t%zu\n", options.Nnode); From a49f01d64dc93b42ba810d4ba7438e8eb0858b7a Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Fri, 25 Sep 2015 08:27:02 -0700 Subject: [PATCH 07/14] Fixed nitems to match number of items in option_struct. --- vic/drivers/image/src/vic_mpi_support.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vic/drivers/image/src/vic_mpi_support.c b/vic/drivers/image/src/vic_mpi_support.c index d26568e17..12f9561d0 100644 --- a/vic/drivers/image/src/vic_mpi_support.c +++ b/vic/drivers/image/src/vic_mpi_support.c @@ -693,7 +693,7 @@ create_MPI_option_struct_type(MPI_Datatype *mpi_type) MPI_Datatype *mpi_types; // nitems has to equal the number of elements in option_struct - nitems = 64; + nitems = 60; blocklengths = (int *) malloc(nitems * sizeof(int)); if (blocklengths == NULL) { log_err("Memory allocation error in create_MPI_option_struct_type().") From 8a83e628c522cdfab334a573bb4b1daa9a3f94c4 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sat, 26 Sep 2015 10:09:07 -0700 Subject: [PATCH 08/14] Removed generation of carbon forcings. Removed constants CARBON_CATMCURRENT and CARBON_SW2PAR. Carbon terms in atmos struct (Catm, fdir, par) are now only allocated and accessed by the code if options.CARBON is true. If carbon forcing terms are not allocated, their OUT_* values are set to MISSING in put_data(). --- vic/drivers/classic/src/alloc_atmos.c | 53 +++++++++--------- .../classic/src/print_library_classic.c | 49 ++++++++--------- vic/drivers/classic/src/vic_force.c | 44 +++++++-------- vic/drivers/classic/src/write_forcing_file.c | 14 +++-- vic/drivers/image/src/alloc_atmos.c | 55 ++++++++++--------- vic/drivers/image/src/output_list_utils.c | 1 - vic/drivers/image/src/print_library_image.c | 13 +++-- vic/drivers/image/src/vic_force.c | 53 ++++++++++++++++-- vic/drivers/image/src/vic_mpi_support.c | 10 +--- vic/drivers/image/src/vic_nc_info.c | 1 - .../shared/include/vic_driver_shared.h | 1 - vic/drivers/shared/src/get_parameters.c | 15 ----- .../shared/src/initialize_parameters.c | 4 -- vic/drivers/shared/src/print_library_shared.c | 3 - vic/drivers/shared/src/put_data.c | 14 +++-- vic/vic_run/include/vic_def.h | 5 -- vic/vic_run/src/surface_fluxes.c | 6 +- 17 files changed, 182 insertions(+), 159 deletions(-) diff --git a/vic/drivers/classic/src/alloc_atmos.c b/vic/drivers/classic/src/alloc_atmos.c index 94c9de4ad..f4eba7fa2 100644 --- a/vic/drivers/classic/src/alloc_atmos.c +++ b/vic/drivers/classic/src/alloc_atmos.c @@ -47,34 +47,14 @@ alloc_atmos(int nrecs, if ((*atmos)[i].air_temp == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - (*atmos)[i].Catm = (double *) calloc(NR + 1, sizeof(double)); - if ((*atmos)[i].Catm == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } - (*atmos)[i].channel_in = (double *) calloc(NR + 1, sizeof(double)); - if ((*atmos)[i].channel_in == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } - (*atmos)[i].coszen = (double *) calloc(NR + 1, sizeof(double)); - if ((*atmos)[i].coszen == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } (*atmos)[i].density = (double *) calloc(NR + 1, sizeof(double)); if ((*atmos)[i].density == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - (*atmos)[i].fdir = (double *) calloc(NR + 1, sizeof(double)); - if ((*atmos)[i].fdir == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } (*atmos)[i].longwave = (double *) calloc(NR + 1, sizeof(double)); if ((*atmos)[i].longwave == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - (*atmos)[i].par = (double *) calloc(NR + 1, sizeof(double)); - if ((*atmos)[i].par == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } (*atmos)[i].prec = (double *) calloc(NR + 1, sizeof(double)); if ((*atmos)[i].prec == NULL) { log_err("Memory allocation error in alloc_atmos()."); @@ -103,6 +83,26 @@ alloc_atmos(int nrecs, if ((*atmos)[i].wind == NULL) { log_err("Memory allocation error in alloc_atmos()."); } + if (options.LAKES) { + (*atmos)[i].channel_in = (double *) calloc(NR + 1, sizeof(double)); + if ((*atmos)[i].channel_in == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + } + if (options.CARBON) { + (*atmos)[i].Catm = (double *) calloc(NR + 1, sizeof(double)); + if ((*atmos)[i].Catm == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + (*atmos)[i].fdir = (double *) calloc(NR + 1, sizeof(double)); + if ((*atmos)[i].fdir == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + (*atmos)[i].par = (double *) calloc(NR + 1, sizeof(double)); + if ((*atmos)[i].par == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + } } } @@ -121,13 +121,8 @@ free_atmos(int nrecs, for (i = 0; i < nrecs; i++) { free((*atmos)[i].air_temp); - free((*atmos)[i].Catm); - free((*atmos)[i].channel_in); - free((*atmos)[i].coszen); free((*atmos)[i].density); - free((*atmos)[i].fdir); free((*atmos)[i].longwave); - free((*atmos)[i].par); free((*atmos)[i].prec); free((*atmos)[i].pressure); free((*atmos)[i].shortwave); @@ -135,6 +130,14 @@ free_atmos(int nrecs, free((*atmos)[i].vp); free((*atmos)[i].vpd); free((*atmos)[i].wind); + if (options.LAKES) { + free((*atmos)[i].channel_in); + } + if (options.CARBON) { + free((*atmos)[i].Catm); + free((*atmos)[i].fdir); + free((*atmos)[i].par); + } } free(*atmos); diff --git a/vic/drivers/classic/src/print_library_classic.c b/vic/drivers/classic/src/print_library_classic.c index 970b3d4b0..e162ca611 100644 --- a/vic/drivers/classic/src/print_library_classic.c +++ b/vic/drivers/classic/src/print_library_classic.c @@ -43,31 +43,11 @@ print_atmos_data(atmos_data_struct *atmos, fprintf(LOG_DEST, "\t%.4f", atmos->air_temp[i]); } fprintf(LOG_DEST, "\n"); - fprintf(LOG_DEST, "\tCatm :"); - for (i = 0; i <= nr; i++) { - fprintf(LOG_DEST, "\t%.4f", atmos->Catm[i]); - } - fprintf(LOG_DEST, "\n"); - fprintf(LOG_DEST, "\tchannel_in:"); - for (i = 0; i <= nr; i++) { - fprintf(LOG_DEST, "\t%.4f", atmos->channel_in[i]); - } - fprintf(LOG_DEST, "\n"); - fprintf(LOG_DEST, "\tcoszen :"); - for (i = 0; i <= nr; i++) { - fprintf(LOG_DEST, "\t%.4f", atmos->coszen[i]); - } - fprintf(LOG_DEST, "\n"); fprintf(LOG_DEST, "\tdensity :"); for (i = 0; i <= nr; i++) { fprintf(LOG_DEST, "\t%.4f", atmos->density[i]); } fprintf(LOG_DEST, "\n"); - fprintf(LOG_DEST, "\tfdir :"); - for (i = 0; i <= nr; i++) { - fprintf(LOG_DEST, "\t%.4f", atmos->fdir[i]); - } - fprintf(LOG_DEST, "\n"); fprintf(LOG_DEST, "\tlongwave :"); for (i = 0; i <= nr; i++) { fprintf(LOG_DEST, "\t%.4f", atmos->longwave[i]); @@ -88,11 +68,6 @@ print_atmos_data(atmos_data_struct *atmos, fprintf(LOG_DEST, "\t%.4f", atmos->out_snow); } fprintf(LOG_DEST, "\n"); - fprintf(LOG_DEST, "\tpar :"); - for (i = 0; i <= nr; i++) { - fprintf(LOG_DEST, "\t%.4f", atmos->par[i]); - } - fprintf(LOG_DEST, "\n"); fprintf(LOG_DEST, "\tprec :"); for (i = 0; i <= nr; i++) { fprintf(LOG_DEST, "\t%.4f", atmos->prec[i]); @@ -128,4 +103,28 @@ print_atmos_data(atmos_data_struct *atmos, fprintf(LOG_DEST, "\t%.4f", atmos->wind[i]); } fprintf(LOG_DEST, "\n"); + if (options.LAKES) { + fprintf(LOG_DEST, "\tchannel_in:"); + for (i = 0; i <= nr; i++) { + fprintf(LOG_DEST, "\t%.4f", atmos->channel_in[i]); + } + fprintf(LOG_DEST, "\n"); + } + if (options.CARBON) { + fprintf(LOG_DEST, "\tCatm :"); + for (i = 0; i <= nr; i++) { + fprintf(LOG_DEST, "\t%.4f", atmos->Catm[i]); + } + fprintf(LOG_DEST, "\n"); + fprintf(LOG_DEST, "\tfdir :"); + for (i = 0; i <= nr; i++) { + fprintf(LOG_DEST, "\t%.4f", atmos->fdir[i]); + } + fprintf(LOG_DEST, "\n"); + fprintf(LOG_DEST, "\tpar :"); + for (i = 0; i <= nr; i++) { + fprintf(LOG_DEST, "\t%.4f", atmos->par[i]); + } + fprintf(LOG_DEST, "\n"); + } } diff --git a/vic/drivers/classic/src/vic_force.c b/vic/drivers/classic/src/vic_force.c index 6ce37019e..07e79e34e 100644 --- a/vic/drivers/classic/src/vic_force.c +++ b/vic/drivers/classic/src/vic_force.c @@ -153,31 +153,23 @@ vic_force(atmos_data_struct *atmos, param.SNOW_MAX_SNOW_TEMP, &(atmos[rec].prec[i]), 1); // Optional inputs - // Channel inflow from upstream (into lake) - if (param_set.TYPE[CHANNEL_IN].SUPPLIED) { - atmos[rec].channel_in[i] = forcing_data[CHANNEL_IN][uidx]; - } - else { - atmos[rec].channel_in[i] = 0; + if (options.LAKES) { + // Channel inflow from upstream (into lake) + if (param_set.TYPE[CHANNEL_IN].SUPPLIED) { + atmos[rec].channel_in[i] = forcing_data[CHANNEL_IN][uidx]; + } + else { + atmos[rec].channel_in[i] = 0; + } } - // Atmospheric CO2 concentration - if (param_set.TYPE[CATM].SUPPLIED) { + if (options.CARBON) { + // Atmospheric CO2 concentration atmos[rec].Catm[i] = forcing_data[CATM][uidx]; - } - else { - atmos[rec].Catm[i] = param.CARBON_CATMCURRENT * PPM_to_MIXRATIO; - } - // Fraction of shortwave that is direct - if (param_set.TYPE[FDIR].SUPPLIED) { + // Fraction of shortwave that is direct atmos[rec].fdir[i] = forcing_data[FDIR][uidx]; - } - // photosynthetically active radiation - if (param_set.TYPE[PAR].SUPPLIED) { + // photosynthetically active radiation atmos[rec].par[i] = forcing_data[PAR][uidx]; } - else { - atmos[rec].par[i] = param.CARBON_SW2PAR * atmos[rec].shortwave[i]; - } } if (NF > 1) { atmos[rec].air_temp[NR] = average(atmos[rec].air_temp, NF); @@ -196,10 +188,14 @@ vic_force(atmos_data_struct *atmos, atmos[rec].snowflag[NR] = true; } } - atmos[rec].channel_in[NR] = average(atmos[rec].channel_in, NF); - atmos[rec].Catm[NR] = average(atmos[rec].Catm, NF); - atmos[rec].fdir[NR] = average(atmos[rec].fdir, NF); - atmos[rec].par[NR] = average(atmos[rec].par, NF); + if (options.LAKES) { + atmos[rec].channel_in[NR] = average(atmos[rec].channel_in, NF) * NF; + } + if (options.CARBON) { + atmos[rec].Catm[NR] = average(atmos[rec].Catm, NF); + atmos[rec].fdir[NR] = average(atmos[rec].fdir, NF); + atmos[rec].par[NR] = average(atmos[rec].par, NF); + } } } diff --git a/vic/drivers/classic/src/write_forcing_file.c b/vic/drivers/classic/src/write_forcing_file.c index 2d3802556..fd205b784 100644 --- a/vic/drivers/classic/src/write_forcing_file.c +++ b/vic/drivers/classic/src/write_forcing_file.c @@ -53,12 +53,8 @@ write_forcing_file(atmos_data_struct *atmos, for (rec = 0; rec < nrecs; rec++) { for (j = 0; j < NF; j++) { out_data[OUT_AIR_TEMP].data[0] = atmos[rec].air_temp[j]; - out_data[OUT_CATM].data[0] = atmos[rec].Catm[j] * 1e6; - out_data[OUT_COSZEN].data[0] = atmos[rec].coszen[j]; out_data[OUT_DENSITY].data[0] = atmos[rec].density[j]; - out_data[OUT_FDIR].data[0] = atmos[rec].fdir[j]; out_data[OUT_LONGWAVE].data[0] = atmos[rec].longwave[j]; - out_data[OUT_PAR].data[0] = atmos[rec].par[j]; out_data[OUT_PREC].data[0] = atmos[rec].prec[j]; out_data[OUT_PRESSURE].data[0] = atmos[rec].pressure[j] / PA_PER_KPA; @@ -90,6 +86,16 @@ write_forcing_file(atmos_data_struct *atmos, out_data[OUT_SNOWF].data[0] = out_data[OUT_PREC].data[0] - out_data[OUT_RAINF].data[0]; } + if (options.CARBON) { + out_data[OUT_CATM].data[0] = atmos[rec].Catm[j] * 1e6; + out_data[OUT_FDIR].data[0] = atmos[rec].fdir[j]; + out_data[OUT_PAR].data[0] = atmos[rec].par[j]; + } + else { + out_data[OUT_CATM].data[0] = MISSING; + out_data[OUT_FDIR].data[0] = MISSING; + out_data[OUT_PAR].data[0] = MISSING; + } for (v = 0; v < N_OUTVAR_TYPES; v++) { for (i = 0; i < out_data[v].nelem; i++) { diff --git a/vic/drivers/image/src/alloc_atmos.c b/vic/drivers/image/src/alloc_atmos.c index 76ef2f3d0..7dad0f328 100644 --- a/vic/drivers/image/src/alloc_atmos.c +++ b/vic/drivers/image/src/alloc_atmos.c @@ -38,34 +38,14 @@ alloc_atmos(atmos_data_struct *atmos) if (atmos->air_temp == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - atmos->Catm = (double *) calloc(NR + 1, sizeof(double)); - if (atmos->Catm == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } - atmos->channel_in = (double *) calloc(NR + 1, sizeof(double)); - if (atmos->channel_in == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } - atmos->coszen = (double *) calloc(NR + 1, sizeof(double)); - if (atmos->coszen == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } atmos->density = (double *) calloc(NR + 1, sizeof(double)); if (atmos->density == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - atmos->fdir = (double *) calloc(NR + 1, sizeof(double)); - if (atmos->fdir == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } atmos->longwave = (double *) calloc(NR + 1, sizeof(double)); if (atmos->longwave == NULL) { log_err("Memory allocation error in alloc_atmos()."); } - atmos->par = (double *) calloc(NR + 1, sizeof(double)); - if (atmos->par == NULL) { - log_err("Memory allocation error in alloc_atmos()."); - } atmos->prec = (double *) calloc(NR + 1, sizeof(double)); if (atmos->prec == NULL) { log_err("Memory allocation error in alloc_atmos()."); @@ -94,6 +74,26 @@ alloc_atmos(atmos_data_struct *atmos) if (atmos->wind == NULL) { log_err("Memory allocation error in alloc_atmos()."); } + if (options.LAKES) { + atmos->channel_in = (double *) calloc(NR + 1, sizeof(double)); + if (atmos->channel_in == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + } + if (options.CARBON) { + atmos->Catm = (double *) calloc(NR + 1, sizeof(double)); + if (atmos->Catm == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + atmos->fdir = (double *) calloc(NR + 1, sizeof(double)); + if (atmos->fdir == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + atmos->par = (double *) calloc(NR + 1, sizeof(double)); + if (atmos->par == NULL) { + log_err("Memory allocation error in alloc_atmos()."); + } + } } /****************************************************************************** @@ -107,13 +107,6 @@ free_atmos(atmos_data_struct *atmos) } free(atmos->air_temp); - free(atmos->Catm); - free(atmos->channel_in); - free(atmos->coszen); - free(atmos->density); - free(atmos->fdir); - free(atmos->longwave); - free(atmos->par); free(atmos->prec); free(atmos->pressure); free(atmos->shortwave); @@ -121,4 +114,12 @@ free_atmos(atmos_data_struct *atmos) free(atmos->vp); free(atmos->vpd); free(atmos->wind); + if (options.LAKES) { + free(atmos->channel_in); + } + if (options.CARBON) { + free(atmos->Catm); + free(atmos->fdir); + free(atmos->par); + } } diff --git a/vic/drivers/image/src/output_list_utils.c b/vic/drivers/image/src/output_list_utils.c index 896ffd297..7584beec1 100644 --- a/vic/drivers/image/src/output_list_utils.c +++ b/vic/drivers/image/src/output_list_utils.c @@ -172,7 +172,6 @@ create_output_list() strcpy(out_data[OUT_AERO_RESIST2].varname, "OUT_AERO_RESIST2"); /* overstory aerodynamic resistance [m/s] */ strcpy(out_data[OUT_AIR_TEMP].varname, "OUT_AIR_TEMP"); /* air temperature [C] */ strcpy(out_data[OUT_CATM].varname, "OUT_CATM"); /* atmospheric CO2 concentration [ppm] */ - strcpy(out_data[OUT_COSZEN].varname, "OUT_COSZEN"); /* cosine of solar zenith angle [fraction] */ strcpy(out_data[OUT_DENSITY].varname, "OUT_DENSITY"); /* near-surface atmospheric density [kg/m3] */ strcpy(out_data[OUT_FDIR].varname, "OUT_FDIR"); /* fraction of incoming shortwave that is direct [fraction] */ strcpy(out_data[OUT_LONGWAVE].varname, "OUT_LONGWAVE"); /* incoming longwave [W/m2] */ diff --git a/vic/drivers/image/src/print_library_image.c b/vic/drivers/image/src/print_library_image.c index bb579083c..8c2f079b4 100644 --- a/vic/drivers/image/src/print_library_image.c +++ b/vic/drivers/image/src/print_library_image.c @@ -36,16 +36,11 @@ print_atmos_data(atmos_data_struct *atmos) { fprintf(LOG_DEST, "atmos_data :\n"); fprintf(LOG_DEST, "\tair_temp : %.4f\n", atmos->air_temp[0]); - fprintf(LOG_DEST, "\tCatm : %.4f\n", atmos->Catm[0]); - fprintf(LOG_DEST, "\tchannel_in: %.4f\n", atmos->channel_in[0]); - fprintf(LOG_DEST, "\tcoszen : %.4f\n", atmos->coszen[0]); fprintf(LOG_DEST, "\tdensity : %.4f\n", atmos->density[0]); - fprintf(LOG_DEST, "\tfdir : %.4f\n", atmos->fdir[0]); fprintf(LOG_DEST, "\tlongwave : %.4f\n", atmos->longwave[0]); fprintf(LOG_DEST, "\tout_prec : %.4f\n", atmos->out_prec); fprintf(LOG_DEST, "\tout_rain : %.4f\n", atmos->out_rain); fprintf(LOG_DEST, "\tout_snow : %.4f\n", atmos->out_snow); - fprintf(LOG_DEST, "\tpar : %.4f\n", atmos->par[0]); fprintf(LOG_DEST, "\tprec : %.4f\n", atmos->prec[0]); fprintf(LOG_DEST, "\tpressure : %.4f\n", atmos->pressure[0]); fprintf(LOG_DEST, "\tshortwave : %.4f\n", atmos->shortwave[0]); @@ -53,6 +48,14 @@ print_atmos_data(atmos_data_struct *atmos) fprintf(LOG_DEST, "\tvp : %.4f\n", atmos->vp[0]); fprintf(LOG_DEST, "\tvpd : %.4f\n", atmos->vpd[0]); fprintf(LOG_DEST, "\twind : %.4f\n", atmos->wind[0]); + if (options.LAKES) { + fprintf(LOG_DEST, "\tchannel_in: %.4f\n", atmos->channel_in[0]); + } + if (options.CARBON) { + fprintf(LOG_DEST, "\tCatm : %.4f\n", atmos->Catm[0]); + fprintf(LOG_DEST, "\tfdir : %.4f\n", atmos->fdir[0]); + fprintf(LOG_DEST, "\tpar : %.4f\n", atmos->par[0]); + } } /****************************************************************************** diff --git a/vic/drivers/image/src/vic_force.c b/vic/drivers/image/src/vic_force.c index e05613374..739d618f0 100644 --- a/vic/drivers/image/src/vic_force.c +++ b/vic/drivers/image/src/vic_force.c @@ -150,6 +150,45 @@ vic_force(void) atmos[i].pressure[j] = (double) fvar[i]; } } + // Optional inputs + if (options.LAKES) { + // Channel inflow to lake + // set to 0 for image mode + for (j = 0; j < NF; j++) { + for (i = 0; i < local_domain.ncells; i++) { + atmos[i].channel_in[j] = 0; + } + } + } + if (options.CARBON) { + // Atmospheric CO2 mixing ratio + for (j = 0; j < NF; j++) { + d3start[0] = global_param.forceoffset[0] + j; + get_scatter_nc_field_float(filenames.forcing[0], "catm", + d3start, d3count, fvar); + for (i = 0; i < local_domain.ncells; i++) { + atmos[i].Catm[j] = (double) fvar[i]; + } + } + // Fraction of shortwave that is direct + for (j = 0; j < NF; j++) { + d3start[0] = global_param.forceoffset[0] + j; + get_scatter_nc_field_float(filenames.forcing[0], "fdir", + d3start, d3count, fvar); + for (i = 0; i < local_domain.ncells; i++) { + atmos[i].fdir[j] = (double) fvar[i]; + } + } + // Photosynthetically active radiation + for (j = 0; j < NF; j++) { + d3start[0] = global_param.forceoffset[0] + j; + get_scatter_nc_field_float(filenames.forcing[0], "par", + d3start, d3count, fvar); + for (i = 0; i < local_domain.ncells; i++) { + atmos[i].par[j] = (double) fvar[i]; + } + } + } // Update the offset counter global_param.forceoffset[0] += NF; @@ -173,8 +212,6 @@ vic_force(void) atmos[i].vp[j] = q_to_vp(atmos[i].vp[j], atmos[i].pressure[j]); // vapor pressure deficit atmos[i].vpd[j] = svp(atmos[i].air_temp[j]) - atmos[i].vp[j]; - // photosynthetically active radiation - atmos[i].par[j] = param.CARBON_SW2PAR * atmos[i].shortwave[j]; // air density atmos[i].density[j] = air_density(atmos[i].air_temp[j], atmos[i].pressure[j]); @@ -203,11 +240,17 @@ vic_force(void) atmos[i].snowflag[NR] = will_it_snow(atmos[i].air_temp, t_offset, param.SNOW_MAX_SNOW_TEMP, atmos[i].prec, NF); + // Optional inputs + if (options.LAKES) { + atmos[i].channel_in[NR] = average(atmos[i].channel_in, NF) * NF; + } + if (options.CARBON) { + atmos[i].Catm[NR] = average(atmos[i].Catm, NF); + atmos[i].fdir[NR] = average(atmos[i].fdir, NF); + atmos[i].par[NR] = average(atmos[i].par, NF); + } } - // TBD: coszen (used for some of the carbon functions), fdir (if needed) - // Catm, fdir (not used as far as I can tell) - // Update the veg_hist structure with the current vegetation parameters. // Currently only implemented for climatological values in image mode for (i = 0; i < local_domain.ncells; i++) { diff --git a/vic/drivers/image/src/vic_mpi_support.c b/vic/drivers/image/src/vic_mpi_support.c index 12f9561d0..6698950e0 100644 --- a/vic/drivers/image/src/vic_mpi_support.c +++ b/vic/drivers/image/src/vic_mpi_support.c @@ -998,7 +998,7 @@ create_MPI_param_struct_type(MPI_Datatype *mpi_type) MPI_Datatype *mpi_types; // nitems has to equal the number of elements in parameters_struct - nitems = 143; + nitems = 141; blocklengths = (int *) malloc(nitems * sizeof(int)); if (blocklengths == NULL) { log_err("Memory allocation error in create_MPI_param_struct_type().") @@ -1202,14 +1202,6 @@ create_MPI_param_struct_type(MPI_Datatype *mpi_type) offsets[i] = offsetof(parameters_struct, SVP_C); mpi_types[i++] = MPI_DOUBLE; - // double CARBON_CATMCURRENT - offsets[i] = offsetof(parameters_struct, CARBON_CATMCURRENT); - mpi_types[i++] = MPI_DOUBLE; - - // double CARBON_SW2PAR - offsets[i] = offsetof(parameters_struct, CARBON_SW2PAR); - mpi_types[i++] = MPI_DOUBLE; - // double PHOTO_OMEGA offsets[i] = offsetof(parameters_struct, PHOTO_OMEGA); mpi_types[i++] = MPI_DOUBLE; diff --git a/vic/drivers/image/src/vic_nc_info.c b/vic/drivers/image/src/vic_nc_info.c index 4ce98ee0f..66600a56c 100644 --- a/vic/drivers/image/src/vic_nc_info.c +++ b/vic/drivers/image/src/vic_nc_info.c @@ -156,7 +156,6 @@ vic_nc_info(nc_file_struct *nc_hist_file, case OUT_SURFT_FBFLAG: case OUT_TCAN_FBFLAG: case OUT_TFOL_FBFLAG: - case OUT_COSZEN: case OUT_FDIR: case OUT_REL_HUMID: case OUT_ALBEDO_BAND: diff --git a/vic/drivers/shared/include/vic_driver_shared.h b/vic/drivers/shared/include/vic_driver_shared.h index 7d436bcf5..1a4bd7c41 100644 --- a/vic/drivers/shared/include/vic_driver_shared.h +++ b/vic/drivers/shared/include/vic_driver_shared.h @@ -227,7 +227,6 @@ enum OUT_AERO_RESIST2, /**< overstory aerodynamic resistance [s/m] */ OUT_AIR_TEMP, /**< air temperature [C] (ALMA_OUTPUT: [K])*/ OUT_CATM, /**< atmospheric CO2 concentrtaion [ppm]*/ - OUT_COSZEN, /**< cosine of solar zenith angle [fraction]*/ OUT_DENSITY, /**< near-surface atmospheric density [kg/m3]*/ OUT_FDIR, /**< fraction of incoming shortwave that is direct [fraction]*/ OUT_LAI, /**< leaf area index [m2/m2] */ diff --git a/vic/drivers/shared/src/get_parameters.c b/vic/drivers/shared/src/get_parameters.c index 73dc067c2..5c5ee6edb 100644 --- a/vic/drivers/shared/src/get_parameters.c +++ b/vic/drivers/shared/src/get_parameters.c @@ -201,13 +201,6 @@ get_parameters(FILE *paramfile) else if (strcasecmp("SVP_C", optstr) == 0) { sscanf(cmdstr, "%*s %lf", ¶m.SVP_C); } - // Carbon Parameters - else if (strcasecmp("CARBON_CATMCURRENT", optstr) == 0) { - sscanf(cmdstr, "%*s %lf", ¶m.CARBON_CATMCURRENT); - } - else if (strcasecmp("CARBON_SW2PAR", optstr) == 0) { - sscanf(cmdstr, "%*s %lf", ¶m.CARBON_SW2PAR); - } // Photosynthesis Parameters else if (strcasecmp("PHOTO_OMEGA", optstr) == 0) { sscanf(cmdstr, "%*s %lf", ¶m.PHOTO_OMEGA); @@ -643,14 +636,6 @@ validate_parameters() if (!(param.SVP_C >= 0.)) { log_err("SVP_C must be defined on the interval [0, inf) (kPa)"); } - // Carbon Parameters - if (!(param.CARBON_CATMCURRENT >= 0.)) { - log_err( - "CARBON_CATMCURRENT must be defined on the interval [0, inf) (ppm)"); - } - if (!(param.CARBON_SW2PAR >= 0.)) { - log_err("CARBON_SW2PAR must be defined on the interval [0, inf) (W/m2)"); - } // Photosynthesis Parameters // PHOTO_OMEGA - Currently, no constraints if (!(param.PHOTO_LAIMAX >= 0.)) { diff --git a/vic/drivers/shared/src/initialize_parameters.c b/vic/drivers/shared/src/initialize_parameters.c index 94a210e69..d22774532 100644 --- a/vic/drivers/shared/src/initialize_parameters.c +++ b/vic/drivers/shared/src/initialize_parameters.c @@ -102,10 +102,6 @@ initialize_parameters() param.SVP_B = 17.269; param.SVP_C = 237.3; - // Carbon Parameters - param.CARBON_CATMCURRENT = 383; - param.CARBON_SW2PAR = 0.45; - // Photosynthesis Parameters param.PHOTO_OMEGA = 0.12; param.PHOTO_LAIMAX = 8.0; diff --git a/vic/drivers/shared/src/print_library_shared.c b/vic/drivers/shared/src/print_library_shared.c index 8f2be6b25..a78a5fb85 100644 --- a/vic/drivers/shared/src/print_library_shared.c +++ b/vic/drivers/shared/src/print_library_shared.c @@ -648,9 +648,6 @@ print_parameters(parameters_struct *param) fprintf(LOG_DEST, "\tSVP_A: %.4f\n", param->SVP_A); fprintf(LOG_DEST, "\tSVP_B: %.4f\n", param->SVP_B); fprintf(LOG_DEST, "\tSVP_C: %.4f\n", param->SVP_C); - fprintf(LOG_DEST, "\tCARBON_CATMCURRENT: %.4f\n", - param->CARBON_CATMCURRENT); - fprintf(LOG_DEST, "\tCARBON_SW2PAR: %.4f\n", param->CARBON_SW2PAR); fprintf(LOG_DEST, "\tPHOTO_OMEGA: %.4f\n", param->PHOTO_OMEGA); fprintf(LOG_DEST, "\tPHOTO_LAIMAX: %.4f\n", param->PHOTO_LAIMAX); fprintf(LOG_DEST, "\tPHOTO_LAILIMIT: %.4f\n", param->PHOTO_LAILIMIT); diff --git a/vic/drivers/shared/src/put_data.c b/vic/drivers/shared/src/put_data.c index 24d1f09c1..8f993cc58 100644 --- a/vic/drivers/shared/src/put_data.c +++ b/vic/drivers/shared/src/put_data.c @@ -153,12 +153,8 @@ put_data(all_vars_struct *all_vars, // Set output versions of input forcings out_data[OUT_AIR_TEMP].data[0] = atmos->air_temp[NR]; - out_data[OUT_CATM].data[0] = atmos->Catm[NR] * 1e6; - out_data[OUT_COSZEN].data[0] = atmos->coszen[NR]; out_data[OUT_DENSITY].data[0] = atmos->density[NR]; - out_data[OUT_FDIR].data[0] = atmos->fdir[NR]; out_data[OUT_LONGWAVE].data[0] = atmos->longwave[NR]; - out_data[OUT_PAR].data[0] = atmos->par[NR]; out_data[OUT_PREC].data[0] = atmos->out_prec; // mm over grid cell out_data[OUT_PRESSURE].data[0] = atmos->pressure[NR] / PA_PER_KPA; out_data[OUT_QAIR].data[0] = CONST_EPS * atmos->vp[NR] / @@ -177,6 +173,16 @@ put_data(all_vars_struct *all_vars, out_data[OUT_VP].data[0] = atmos->vp[NR] / PA_PER_KPA; out_data[OUT_VPD].data[0] = atmos->vpd[NR] / PA_PER_KPA; out_data[OUT_WIND].data[0] = atmos->wind[NR]; + if (options.CARBON) { + out_data[OUT_CATM].data[0] = atmos->Catm[NR] * 1e6; + out_data[OUT_FDIR].data[0] = atmos->fdir[NR]; + out_data[OUT_PAR].data[0] = atmos->par[NR]; + } + else { + out_data[OUT_CATM].data[0] = MISSING; + out_data[OUT_FDIR].data[0] = MISSING; + out_data[OUT_PAR].data[0] = MISSING; + } /**************************************** Store Output for all Vegetation Types (except lakes) diff --git a/vic/vic_run/include/vic_def.h b/vic/vic_run/include/vic_def.h index 1c27208f2..3d0b3f0d1 100644 --- a/vic/vic_run/include/vic_def.h +++ b/vic/vic_run/include/vic_def.h @@ -468,10 +468,6 @@ typedef struct { double SVP_B; /**< constant for saturated vapor pressure curve (kPa) */ double SVP_C; /**< constant for saturated vapor pressure curve (kPa) */ - // Carbon Parameters - double CARBON_CATMCURRENT; /**< Current global atmospheric CO2 mixing ratio (ppm) */ - double CARBON_SW2PAR; /**< Empirical ratio of PAR (W/m2) to SHORTWAVE (W/m2) from Lopez et al., 2001 */ - // Photosynthesis Parameters double PHOTO_OMEGA; /**< single leaf scattering albedo */ double PHOTO_LAIMAX; /**< Maximum LAI in nitrogen scaling */ @@ -747,7 +743,6 @@ typedef struct { double *air_temp; /**< air temperature (C) */ double *Catm; /**< atmospheric CO2 mixing ratio (mol CO2/ mol air) */ double *channel_in; /**< incoming channel inflow for time step (mm) */ - double *coszen; /**< cosine of solar zenith angle (fraction) */ double *density; /**< atmospheric density (kg/m^3) */ double *fdir; /**< fraction of incoming shortwave that is direct (fraction) */ double *longwave; /**< incoming longwave radiation (W/m^2) (net incoming diff --git a/vic/vic_run/src/surface_fluxes.c b/vic/vic_run/src/surface_fluxes.c index 7f5d44cbc..e7b96b264 100644 --- a/vic/vic_run/src/surface_fluxes.c +++ b/vic/vic_run/src/surface_fluxes.c @@ -115,6 +115,7 @@ surface_fluxes(bool overstory, double snowfall; // snowfall double snow_flux; // heat flux through snowpack double snow_grnd_flux; // ground heat flux into snowpack + double coszen; // cosine of solar zenith angle double tol_under; double tol_over; double *aero_resist_used; @@ -411,6 +412,9 @@ surface_fluxes(bool overstory, if (options.CARBON && iveg < Nveg) { LAIlayer = (double *) calloc(options.Ncanopy, sizeof(double)); faPAR = (double *) calloc(options.Ncanopy, sizeof(double)); + coszen = compute_coszen(soil_con->lat, soil_con->lng, + soil_con->time_zone_lng, + dmy->day_in_year, (hidx+0.5)*step_dt); /* Compute absorbed PAR per ground area per canopy layer (W/m2) normalized to PAR = 1 W, i.e. the canopy albedo in the PAR @@ -418,7 +422,7 @@ surface_fluxes(bool overstory, faparl(CanopLayerBnd, veg_var->LAI, soil_con->AlbedoPar, - atmos->coszen[hidx], + coszen, atmos->fdir[hidx], LAIlayer, faPAR); From f04030415515ca88e2dbd637515593fead39b462 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sat, 26 Sep 2015 10:14:58 -0700 Subject: [PATCH 09/14] Added options_struct as extern to alloc_atmos.c. --- vic/drivers/classic/src/alloc_atmos.c | 2 ++ vic/drivers/image/src/alloc_atmos.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/vic/drivers/classic/src/alloc_atmos.c b/vic/drivers/classic/src/alloc_atmos.c index f4eba7fa2..a5ebf186a 100644 --- a/vic/drivers/classic/src/alloc_atmos.c +++ b/vic/drivers/classic/src/alloc_atmos.c @@ -35,6 +35,7 @@ void alloc_atmos(int nrecs, atmos_data_struct **atmos) { + extern option_struct options; int i; *atmos = (atmos_data_struct *) calloc(nrecs, sizeof(atmos_data_struct)); @@ -113,6 +114,7 @@ void free_atmos(int nrecs, atmos_data_struct **atmos) { + extern option_struct options; int i; if (*atmos == NULL) { diff --git a/vic/drivers/image/src/alloc_atmos.c b/vic/drivers/image/src/alloc_atmos.c index 7dad0f328..6c85ba840 100644 --- a/vic/drivers/image/src/alloc_atmos.c +++ b/vic/drivers/image/src/alloc_atmos.c @@ -34,6 +34,8 @@ void alloc_atmos(atmos_data_struct *atmos) { + extern option_struct options; + atmos->air_temp = (double *) calloc(NR + 1, sizeof(double)); if (atmos->air_temp == NULL) { log_err("Memory allocation error in alloc_atmos()."); @@ -102,6 +104,8 @@ alloc_atmos(atmos_data_struct *atmos) void free_atmos(atmos_data_struct *atmos) { + extern option_struct options; + if (atmos == NULL) { return; } From a6e1951433dbfda9d08c76e4600b4f11370aa8cc Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sat, 26 Sep 2015 10:18:09 -0700 Subject: [PATCH 10/14] Fixed a few bugs. --- vic/drivers/classic/src/output_list_utils.c | 1 - vic/drivers/classic/src/print_library_classic.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/vic/drivers/classic/src/output_list_utils.c b/vic/drivers/classic/src/output_list_utils.c index 52b35ff41..4384f655a 100644 --- a/vic/drivers/classic/src/output_list_utils.c +++ b/vic/drivers/classic/src/output_list_utils.c @@ -172,7 +172,6 @@ create_output_list() strcpy(out_data[OUT_AERO_RESIST2].varname, "OUT_AERO_RESIST2"); /* overstory aerodynamic resistance [m/s] */ strcpy(out_data[OUT_AIR_TEMP].varname, "OUT_AIR_TEMP"); /* air temperature [C] */ strcpy(out_data[OUT_CATM].varname, "OUT_CATM"); /* atmospheric CO2 concentration [ppm] */ - strcpy(out_data[OUT_COSZEN].varname, "OUT_COSZEN"); /* cosine of solar zenith angle [fraction] */ strcpy(out_data[OUT_DENSITY].varname, "OUT_DENSITY"); /* near-surface atmospheric density [kg/m3] */ strcpy(out_data[OUT_FDIR].varname, "OUT_FDIR"); /* fraction of incoming shortwave that is direct [fraction] */ strcpy(out_data[OUT_LAI].varname, "OUT_LAI"); /* leaf area index [m2/m2] */ diff --git a/vic/drivers/classic/src/print_library_classic.c b/vic/drivers/classic/src/print_library_classic.c index e162ca611..cca769b8d 100644 --- a/vic/drivers/classic/src/print_library_classic.c +++ b/vic/drivers/classic/src/print_library_classic.c @@ -35,6 +35,7 @@ void print_atmos_data(atmos_data_struct *atmos, size_t nr) { + extern option_struct options; size_t i; fprintf(LOG_DEST, "atmos_data :\n"); From a9e5d0676f62d2f428fc28b82311291d5abff4e1 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sat, 26 Sep 2015 10:48:47 -0700 Subject: [PATCH 11/14] Removed ALMA_INPUT from global files. --- tests/examples/global_param.STEHE.3hewb.txt | 1 - tests/examples/global_param.STEHE.init_state.txt | 1 - tests/examples/global_param.STEHE.save_state.txt | 1 - tests/examples/global_param.STEHE.txt | 1 - tests/examples/global_param.STEHE.wb_output.txt | 1 - tests/release/global_0.5deg-eb.txt | 1 - tests/release/global_0.5deg-wb.txt | 1 - 7 files changed, 7 deletions(-) diff --git a/tests/examples/global_param.STEHE.3hewb.txt b/tests/examples/global_param.STEHE.3hewb.txt index 26e444e83..48f8e1c05 100644 --- a/tests/examples/global_param.STEHE.3hewb.txt +++ b/tests/examples/global_param.STEHE.3hewb.txt @@ -27,7 +27,6 @@ FORCEHOUR 00 GRID_DECIMAL 4 WIND_H 10.0 MEASURE_H 2.0 -ALMA_INPUT FALSE SOIL $test_data_dir/Stehekin/parameters/soil_param.STEHE BASEFLOW ARNO JULY_TAVG_SUPPLIED FALSE diff --git a/tests/examples/global_param.STEHE.init_state.txt b/tests/examples/global_param.STEHE.init_state.txt index 41e39d0db..69a3aaf15 100644 --- a/tests/examples/global_param.STEHE.init_state.txt +++ b/tests/examples/global_param.STEHE.init_state.txt @@ -28,7 +28,6 @@ FORCEHOUR 00 GRID_DECIMAL 4 WIND_H 10.0 MEASURE_H 2.0 -ALMA_INPUT FALSE FORCE_FORMAT BINARY FORCE_ENDIAN LITTLE SOIL $test_data_dir/Stehekin/parameters/soil_param.STEHE diff --git a/tests/examples/global_param.STEHE.save_state.txt b/tests/examples/global_param.STEHE.save_state.txt index a7a279e30..f8c4574b1 100644 --- a/tests/examples/global_param.STEHE.save_state.txt +++ b/tests/examples/global_param.STEHE.save_state.txt @@ -32,7 +32,6 @@ FORCEHOUR 00 GRID_DECIMAL 4 WIND_H 10.0 MEASURE_H 2.0 -ALMA_INPUT FALSE FORCE_FORMAT BINARY FORCE_ENDIAN LITTLE SOIL $test_data_dir/Stehekin/parameters/soil_param.STEHE diff --git a/tests/examples/global_param.STEHE.txt b/tests/examples/global_param.STEHE.txt index b81621234..ae1adfaff 100644 --- a/tests/examples/global_param.STEHE.txt +++ b/tests/examples/global_param.STEHE.txt @@ -27,7 +27,6 @@ FORCEHOUR 00 GRID_DECIMAL 4 WIND_H 10.0 MEASURE_H 2.0 -ALMA_INPUT FALSE FORCE_FORMAT BINARY FORCE_ENDIAN LITTLE SOIL $test_data_dir/Stehekin/parameters/soil_param.STEHE diff --git a/tests/examples/global_param.STEHE.wb_output.txt b/tests/examples/global_param.STEHE.wb_output.txt index b7f94da2e..8168f0326 100644 --- a/tests/examples/global_param.STEHE.wb_output.txt +++ b/tests/examples/global_param.STEHE.wb_output.txt @@ -27,7 +27,6 @@ FORCEHOUR 00 GRID_DECIMAL 4 WIND_H 10.0 MEASURE_H 2.0 -ALMA_INPUT FALSE FORCE_FORMAT BINARY FORCE_ENDIAN LITTLE SOIL $test_data_dir/Stehekin/parameters/soil_param.STEHE diff --git a/tests/release/global_0.5deg-eb.txt b/tests/release/global_0.5deg-eb.txt index b1f2cab02..9458cb880 100644 --- a/tests/release/global_0.5deg-eb.txt +++ b/tests/release/global_0.5deg-eb.txt @@ -27,7 +27,6 @@ FORCEHOUR 00 GRID_DECIMAL 4 WIND_H 10.0 MEASURE_H 2.0 -ALMA_INPUT FALSE SOIL {test_data_dir}/global_0.5deg/parameters/soil_param.txt ARC_SOIL FALSE BASEFLOW ARNO diff --git a/tests/release/global_0.5deg-wb.txt b/tests/release/global_0.5deg-wb.txt index 87e293093..548b8d9d7 100644 --- a/tests/release/global_0.5deg-wb.txt +++ b/tests/release/global_0.5deg-wb.txt @@ -27,7 +27,6 @@ FORCEHOUR 00 GRID_DECIMAL 4 WIND_H 10.0 MEASURE_H 2.0 -ALMA_INPUT FALSE SOIL {test_data_dir}/global_0.5deg/parameters/soil_param.txt ARC_SOIL FALSE BASEFLOW ARNO From d92c6b837e5d855d81c8f640545f02b2488bbe99 Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sat, 26 Sep 2015 10:55:05 -0700 Subject: [PATCH 12/14] More bug fixes. --- vic/drivers/image/src/print_library_image.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vic/drivers/image/src/print_library_image.c b/vic/drivers/image/src/print_library_image.c index 8c2f079b4..25d1cf480 100644 --- a/vic/drivers/image/src/print_library_image.c +++ b/vic/drivers/image/src/print_library_image.c @@ -34,6 +34,8 @@ void print_atmos_data(atmos_data_struct *atmos) { + extern option_struct options; + fprintf(LOG_DEST, "atmos_data :\n"); fprintf(LOG_DEST, "\tair_temp : %.4f\n", atmos->air_temp[0]); fprintf(LOG_DEST, "\tdensity : %.4f\n", atmos->density[0]); From 8aee46b925ad02ab3b5606dddc04a80a9c47885d Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sat, 26 Sep 2015 11:50:50 -0700 Subject: [PATCH 13/14] Updated to reflect changes in .h files. --- vic/drivers/python/vic_headers.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/vic/drivers/python/vic_headers.py b/vic/drivers/python/vic_headers.py index 2e8456bd1..c58fb13aa 100644 --- a/vic/drivers/python/vic_headers.py +++ b/vic/drivers/python/vic_headers.py @@ -84,28 +84,19 @@ ALBEDO, CATM, CHANNEL_IN, - CRAINF, - CSNOWF, DENSITY, FDIR, LAI_IN, LONGWAVE, - LSRAINF, - LSSNOWF, PAR, PREC, PRESSURE, QAIR, - RAINF, REL_HUMID, SHORTWAVE, - SNOWF, - TSKC, VEGCOVER, VP, WIND, - WIND_E, - WIND_N, SKIP, N_FORCING_TYPES }; @@ -393,9 +384,6 @@ _Bool SPATIAL_FROST; _Bool SPATIAL_SNOW; _Bool TFALLBACK; - _Bool VP_INTERP; - unsigned short VP_ITER; - _Bool ALMA_INPUT; _Bool BASEFLOW; unsigned short int GRID_DECIMAL; _Bool VEGLIB_PHOTO; @@ -501,8 +489,6 @@ double SVP_A; double SVP_B; double SVP_C; - double CARBON_CATMCURRENT; - double CARBON_SW2PAR; double PHOTO_OMEGA; double PHOTO_LAIMAX; double PHOTO_LAILIMIT; @@ -713,7 +699,6 @@ double *air_temp; double *Catm; double *channel_in; - double *coszen; double *density; double *fdir; double *longwave; @@ -725,7 +710,6 @@ double *pressure; double *shortwave; _Bool *snowflag; - double *tskc; double *vp; double *vpd; double *wind; From dda590ef0b80b568e7dbb616f9c58c7d696c114e Mon Sep 17 00:00:00 2001 From: Ted Bohn Date: Sat, 26 Sep 2015 13:12:51 -0700 Subject: [PATCH 14/14] Replaced hard-coded unit conversion with constant. Removed extraneous comment statement. --- vic/drivers/classic/src/write_forcing_file.c | 2 +- vic/drivers/image/src/vic_force.c | 1 - vic/drivers/shared/src/put_data.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/vic/drivers/classic/src/write_forcing_file.c b/vic/drivers/classic/src/write_forcing_file.c index fd205b784..d21bad029 100644 --- a/vic/drivers/classic/src/write_forcing_file.c +++ b/vic/drivers/classic/src/write_forcing_file.c @@ -87,7 +87,7 @@ write_forcing_file(atmos_data_struct *atmos, out_data[OUT_RAINF].data[0]; } if (options.CARBON) { - out_data[OUT_CATM].data[0] = atmos[rec].Catm[j] * 1e6; + out_data[OUT_CATM].data[0] = atmos[rec].Catm[j] / PPM_to_MIXRATIO; out_data[OUT_FDIR].data[0] = atmos[rec].fdir[j]; out_data[OUT_PAR].data[0] = atmos[rec].par[j]; } diff --git a/vic/drivers/image/src/vic_force.c b/vic/drivers/image/src/vic_force.c index 739d618f0..a5cc43810 100644 --- a/vic/drivers/image/src/vic_force.c +++ b/vic/drivers/image/src/vic_force.c @@ -153,7 +153,6 @@ vic_force(void) // Optional inputs if (options.LAKES) { // Channel inflow to lake - // set to 0 for image mode for (j = 0; j < NF; j++) { for (i = 0; i < local_domain.ncells; i++) { atmos[i].channel_in[j] = 0; diff --git a/vic/drivers/shared/src/put_data.c b/vic/drivers/shared/src/put_data.c index 8f993cc58..0b9f205e3 100644 --- a/vic/drivers/shared/src/put_data.c +++ b/vic/drivers/shared/src/put_data.c @@ -174,7 +174,7 @@ put_data(all_vars_struct *all_vars, out_data[OUT_VPD].data[0] = atmos->vpd[NR] / PA_PER_KPA; out_data[OUT_WIND].data[0] = atmos->wind[NR]; if (options.CARBON) { - out_data[OUT_CATM].data[0] = atmos->Catm[NR] * 1e6; + out_data[OUT_CATM].data[0] = atmos->Catm[NR] / PPM_to_MIXRATIO; out_data[OUT_FDIR].data[0] = atmos->fdir[NR]; out_data[OUT_PAR].data[0] = atmos->par[NR]; }