forked from UW-Hydro/VIC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added check to ensure mask variable in the input domain file is integ…
…er type (UW-Hydro#645) * Added check to ensure mask varible in domain file is integer type * Cleaned up some printing lines * Added get_nc_var_type.c * Minor update of comments and ReleaseNotes * Added domain file description in docs * Small fix of table in docs * Added ncdump -h results for domain file in docs * Minor docs update
- Loading branch information
Showing
9 changed files
with
125 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# VIC Domain file | ||
|
||
The Image Driver uses the [NetCDF](http://www.unidata.ucar.edu/software/netcdf/) file format to define model running domain. | ||
|
||
Below is a list of variables in the domain netCDF file. The dimensions of the netCDF file are `lat` and `lon`. Note that here only the type of variables (i.e., MASK, AREA, FRAC, LAT and LON) is listed; corresponding variable names in the input netCDF file are specified by user in the [Global Parameter File](GlobalParam.md). All the listed variables are required. | ||
|
||
| Variable | Dimension | Units | Type | Description | | ||
|------------|-------------|----------|--------|-------------| | ||
| 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. | | ||
| AREA | [lat, lon] | m2 | double | Area of grid cells. | | ||
| FRAC | [lat, lon] | N/A | double | Fraction of grid cells that is land. | | ||
|
||
# Example netCDF format VIC 5 image driver domain file | ||
|
||
```shell | ||
ncdump -h /ArkRed.domain.nc | ||
netcdf ArkRed.domain { | ||
dimensions: | ||
lat = 66 ; | ||
lon = 125 ; | ||
variables: | ||
int mask(lat, lon) ; | ||
mask:comment = "0 indicates grid cell is not active" ; | ||
mask:long_name = "domain mask" ; | ||
double lon(lon) ; | ||
lon:long_name = "longitude coordinate" ; | ||
lon:units = "degrees_east" ; | ||
double lat(lat) ; | ||
lat:long_name = "latitude coordinate" ; | ||
lat:units = "degrees_north" ; | ||
double frac(lat, lon) ; | ||
frac:long_name = "fraction of grid cell that is active" ; | ||
frac:units = "1" ; | ||
double area(lat, lon) ; | ||
area:standard_name = "area" ; | ||
area:long_name = "area of grid cell" ; | ||
area:units = "m2" ; | ||
|
||
// global attributes: | ||
:title = "VIC domain data" ; | ||
:Conventions = "CF-1.6" ; | ||
:history = "Wed Oct 12 15:48:42 2016: ncap2 -s mask=int(mask) ArkRed.domain.nc.float_mask ArkRed.domain.nc\n", | ||
"created by ymao, 2016-09-23 18:17:58.761256" ; | ||
:user_comment = "VIC domain data" ; | ||
:source = "generated from VIC CONUS 1.8 deg model parameters, see Maurer et al. (2002) for more information" ; | ||
:nco_openmp_thread_number = 1 ; | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/****************************************************************************** | ||
* @section DESCRIPTION | ||
* | ||
* Get netCDF variable type. | ||
* | ||
* @section LICENSE | ||
* | ||
* The Variable Infiltration Capacity (VIC) macroscale hydrological model | ||
* Copyright (C) 2016 The Computational 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 <vic_driver_shared_image.h> | ||
|
||
/****************************************************************************** | ||
* @brief Get netCDF variable type. | ||
*****************************************************************************/ | ||
int | ||
get_nc_var_type(char *nc_name, | ||
char *var_name) | ||
{ | ||
int nc_id; | ||
int var_id; | ||
int status; | ||
int xtypep; | ||
|
||
// open the netcdf file | ||
status = nc_open(nc_name, NC_NOWRITE, &nc_id); | ||
check_nc_status(status, "Error opening %s", nc_name); | ||
|
||
// get variable id | ||
status = nc_inq_varid(nc_id, var_name, &var_id); | ||
check_nc_status(status, "Error getting variable id %s in %s", var_name, | ||
nc_name); | ||
|
||
// get type ID | ||
status = nc_inq_var(nc_id, var_id, NULL, &xtypep, NULL, NULL, NULL); | ||
check_nc_status(status, "Error getting variable type %s in %s", var_name, | ||
nc_name); | ||
|
||
// close the netcdf file | ||
status = nc_close(nc_id); | ||
check_nc_status(status, "Error closing %s", nc_name); | ||
|
||
return(xtypep); | ||
} |