Skip to content

Fix run_cell bug in image driver #662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/Development/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ To check which release of VIC you are running:
6. Fixed a bug related to `dz_node` and `node_depth` variables in image driver output state file ([GH#657](https://github.com/UW-Hydro/VIC/pull/657))

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

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

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


------------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/Documentation/Drivers/Image/Domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Below is a list of variables in the domain netCDF file. The dimensions of the ne
|------------|-------------|----------|--------|-------------|
| LAT | [lat] | degree | double | Latitudes |
| LON | [lon] | degree | double | Longitues |
| MASK | [lat, lon] | N/A | integer | Mask of VIC run. 1 for active cells for VIC run; 0 indicates inactive grid cells. VIC will not run at grid cells with MASK = 0 or missing value. |
| MASK | [lat, lon] | N/A | integer | Mask of domain. 1 for grid cells inside considered domain; 0 for grid cells outside of domain. Cells outside of domain will not be run. Use run_cell variable in the parameter file to turn on/off active cells inside domain. |
| AREA | [lat, lon] | m2 | double | Area of grid cells. |
| FRAC | [lat, lon] | N/A | double | Fraction of grid cells that is land. |

Expand All @@ -22,7 +22,7 @@ dimensions:
lon = 125 ;
variables:
int mask(lat, lon) ;
mask:comment = "0 indicates grid cell is not active" ;
mask:comment = "0 indicates grid cell outside of domain" ;
mask:long_name = "domain mask" ;
double lon(lon) ;
lon:long_name = "longitude coordinate" ;
Expand Down
5 changes: 0 additions & 5 deletions docs/Documentation/Drivers/Image/ForcingData.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ variables:
lat:long_name = "latitude of grid cell center" ;
lat:units = "degrees_north" ;
lat:axis = "Y" ;
double mask(lat, lon) ;
mask:_FillValue = 0. ;
mask:comment = "0 value indicates cell is not active" ;
mask:long_name = "fraction of grid cell that is activedomain mask" ;
mask:note = "unitlessunitless" ;
float prcp(time, lat, lon) ;
prcp:_FillValue = 9.96921e+36f ;
prcp:long_name = "PREC" ;
Expand Down
9 changes: 1 addition & 8 deletions docs/Documentation/Drivers/Image/Params.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Below is a list of soil parameters.

| Variable Name | Dimension | Units | Type | Number of Values | Description |
|--------------------------|--------------------|----------|--------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| run_cell | [lat, lon] | N/A | int | 1 | 1 = Run Grid Cell, 0 = Do Not Run |
| run_cell | [lat, lon] | N/A | int | 1 | 1 = Run Grid Cell, 0 = Do Not Run. Must be zero for all grid cells outside of the mask defined in the domain netCDF file. |
| gridcel | [lat, lon] | N/A | int | 1 | Grid cell number |
| lat | [lat, lon] | degrees | double | 1 | Latitude of grid cell |
| lon | [lat, lon] | degrees | double | 1 | Longitude of grid cell |
Expand Down Expand Up @@ -173,13 +173,6 @@ variables:
double lon(lon) ;
lon:units = "degrees_east" ;
lon:long_name = "longitude of grid cell center" ;
int mask(lat, lon) ;
mask:long_name = "area of grid cell" ;
mask:comment = "0 value indicates cell is not active" ;
mask:note = "unitless" ;
mask:standard_name = "area" ;
mask:units = "m2" ;
mask:axis = "Y" ;
int layer(nlayer) ;
layer:long_name = "soil layer" ;
int run_cell(lat, lon) ;
Expand Down
6 changes: 4 additions & 2 deletions vic/drivers/shared_image/include/vic_driver_shared_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ void compare_ncdomain_with_global_domain(char *ncfile);
void free_force(force_data_struct *force);
void free_veg_hist(veg_hist_struct *veg_hist);
void get_domain_type(char *cmdstr);
size_t get_global_domain(char *fname, domain_struct *global_domain,
bool coords_only);
size_t get_global_domain(char *domain_nc_name, char *param_nc_name,
domain_struct *global_domain);
void get_nc_latlon(char *nc_name, domain_struct *global_domain,
domain_struct *nc_domain);
size_t get_nc_dimension(char *nc_name, char *dim_name);
void get_nc_var_attr(char *nc_name, char *var_name, char *attr_name,
char **attr);
Expand Down
18 changes: 9 additions & 9 deletions vic/drivers/shared_image/src/check_domain_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include <vic_driver_shared_image.h>

/******************************************************************************
* @brief Check that the cooridnates, dimensions, and mask variables in a
netcdf file matches the global domain.
* @brief Check that the cooridnates and dimensions in a netcdf file matches
the global domain.
*****************************************************************************/
void
compare_ncdomain_with_global_domain(char *ncfile)
Expand All @@ -42,8 +42,13 @@ compare_ncdomain_with_global_domain(char *ncfile)

ncfile_domain.info = global_domain.info;

// read the domain info from ncfile (e.g. parameters file or state file)
get_global_domain(ncfile, &ncfile_domain, true);
// read the lat lon coordinates info from ncfile
// (e.g. parameters file or state file)
ncfile_domain.locations =
malloc(global_domain.ncells_total *
sizeof(*(ncfile_domain.locations)));
check_alloc_status(ncfile_domain.locations, "Memory allocation error.");
get_nc_latlon(ncfile, &global_domain, &ncfile_domain);

// using the ncfile_domain, we can compare the values to the global domain.

Expand All @@ -57,11 +62,6 @@ compare_ncdomain_with_global_domain(char *ncfile)

// loop over all grid cells and check that the two domains are identical
for (i = 0; i < global_domain.ncells_total; i++) {
// mask matches
if (ncfile_domain.locations[i].run < global_domain.locations[i].run) {
log_err("parameter file mask for gridcell %zu is zero and the "
"domain file specifies that this cell should be run", i);
}
// latitude matches
if (!assert_close_double(ncfile_domain.locations[i].latitude,
global_domain.locations[i].latitude,
Expand Down
Loading