UW-Hydro / VIC

The Variable Infiltration Capacity (VIC) Macroscale Hydrologic Model
http://vic.readthedocs.io
MIT License
260 stars 383 forks source link

NetCDF: Invalid dimension ID or name: Error getting dimension id MISSING #927

Open ednisle opened 1 year ago

ednisle commented 1 year ago

I am trying to run VIC.5.1.0.rc2/vic/drivers/image and it gives me the following error: ../shared_image/src/get_nc_dimension.c:42: errno: NetCDF: Invalid dimension ID or name: Error getting dimension id MISSING in /home/edna/Desktop/datosedna/domain_file.nc

I have already checked my domain_file.nc several times and has the correct dimensions ands names:

<class 'netCDF4._netCDF4.Dataset'> root group (NETCDF3_64BIT_OFFSET data model, file format NETCDF3): history: Thu Aug 25 12:05:31 2022: ncks -6 domain_file.nc netCDF3_64bit_offset.nc NCO: netCDF Operators version 4.9.1 (Homepage = http://nco.sf.net/, Code = http://github.com/nco/nco) dimensions(sizes): lat(107), lon(99), month(12) variables(dimensions): float64 AREA(lat, lon), float64 FRAC(lat, lon), int32 MASK(lat, lon), float64 dur(month, lat, lon), float64 lat(lat), float64 lon(lon) , int32 month(month), float64 t_pk(month, lat, lon) groups:

Try running the program using the sample data from FindleyLake and the error is the same.

Does anyone know how I can correct the error or what is the cause?

ednisle commented 1 year ago

I fixed the error by assigning the domain file variable names in the get_domain_type function (in get_global_domain.c):

get_domain_type(char *cmdstr) { extern domain_struct global_domain;

char                 optstr[MAXSTRING];
char                 ncvarname[MAXSTRING];

strcpy(ncvarname, "MISSING");

sscanf(cmdstr, "%*s %s %s", optstr, ncvarname);

// Lattitude variable name
if (strcasecmp("LAT", optstr) == 0) {
    strcpy(global_domain.info.lat_var, "lat");
}
// Longitude variable name
else if (strcasecmp("LON", optstr) == 0) {
    strcpy(global_domain.info.lon_var, "lon");
}
// Mask variable name
else if (strcasecmp("MASK", optstr) == 0) {
    strcpy(global_domain.info.mask_var, "mask");
}
// Area variable name
else if (strcasecmp("AREA", optstr) == 0) {
    strcpy(global_domain.info.area_var, "area");
}
// Fraction variable name
else if (strcasecmp("FRAC", optstr) == 0) {
    strcpy(global_domain.info.frac_var, "frac");
}
// y dimension name
else if (strcasecmp("YDIM", optstr) == 0) {
    strcpy(global_domain.info.y_dim, "lat");
}
// x dimension name
else if (strcasecmp("XDIM", optstr) == 0) {
    strcpy(global_domain.info.x_dim, "lon");
}
else {