Opened 7 years ago
Closed 7 years ago
#6942 closed defect (fixed)
Using H5S_MAX_RANK rather than hard coded 32?
Reported by: | Kurt Schwehr | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | svn-trunk |
Severity: | normal | Keywords: | netcdf hdf5 |
Cc: |
Description
In r39202, there is mention of 32 and H5S_MAX_RANK. Is it too hard to actually use the H5S_MAX_RANK from H5Spublic.h? e.g.
int nDims = CSLCount(papszTokens) - 2; if( nDims >= 32 ) { // The number of dimensions in a netCDFv4 file is // limited by #define H5S_MAX_RANK 32 // but libnetcdf doesn't check that... CPLDebug("netCDF", "nc_def_var(%s) failed: too many dimensions", pszVarName); CSLDestroy(papszTokens); continue; }
Should be something like:
int nDims = CSLCount(papszTokens) - 2; if( nDims >= H5S_MAX_RANK ) { // The number of dimensions in a netCDFv4 file is // limited by H5S_MAX_RANK, // but libnetcdf doesn't check that... CPLDebug("netCDF", "nc_def_var(%s) failed: too many dimensions", pszVarName); CSLDestroy(papszTokens); continue; }
e.g. (UNTESTED!)
-
netcdfdataset.cpp
60 60 #include "gdal.h" 61 61 #include "gdal_frmts.h" 62 62 #include "gdal_version.h" 63 #include "hdf5.h" 63 64 #include "ogr_core.h" 64 65 #include "ogr_srs_api.h" 65 66 … … 5841 5842 #endif 5842 5843 5843 5844 int nDims = CSLCount(papszTokens) - 2; 5844 if( nDims >= 32)5845 if( nDims >= H5S_MAX_RANK ) 5845 5846 { 5846 5847 // The number of dimensions in a netCDFv4 file is 5847 // limited by #define H5S_MAX_RANK 325848 // but libnetcdf doesn't check that. ..5848 // limited by H5S_MAX_RANK to 32, 5849 // but libnetcdf doesn't check that. 5849 5850 CPLDebug("netCDF", 5850 5851 "nc_def_var(%s) failed: too many dimensions", 5851 5852 pszVarName);
Change History (2)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Upstream issue reported as https://github.com/Unidata/netcdf-c/issues/433
Note:
See TracTickets
for help on using tickets.
Actually, I wanted to make a bug report to libnetcdf. They should validate that and refuse to create variables with more than 32 dimensions for a netCDF v4 file.