You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int ndims;
nc_inq( ncid, &ndims, 0,0,0);
for( int i=0; i<ndims; i++)
{
char dimname[256];
size_t len;
err = nc_inq_dim( ncid, i, dimname, &len);
}
can have unexpected behaviour in NetCDF-4 if dimensions are defined in groups, e.g.
int ncid;
int err;
err = nc_create( "test.nc", NC_NETCDF4|NC_CLOBBER, &ncid);
int dimID;
int grpid;
err = nc_def_dim( ncid, "x", 10, &dimID);
err = nc_def_grp(ncid,"group",&grpid);
err = nc_def_dim( grpid, "gdim", 10, &dimID);
err = nc_def_dim( ncid, "y", 10, &dimID);
Because the dimIDs will not be sequential, the first code thinks "x" and "gdim" are the dimensions in ncid instead of "x" and "y".
The code in ncdump.c shows how to do it correctly using nc_inq_dimids.
I think the documentation at the above place should show and explain how to do it correctly as well
The text was updated successfully, but these errors were encountered:
The documentation
https://docs.unidata.ucar.edu/netcdf-c/current/reading_unknown.html
recommends using nc_inq to get the number of dimension and then using nc_inq_dim to get the name and length of each of the dimensions. However code like this
can have unexpected behaviour in NetCDF-4 if dimensions are defined in groups, e.g.
Because the dimIDs will not be sequential, the first code thinks "x" and "gdim" are the dimensions in ncid instead of "x" and "y".
The code in ncdump.c shows how to do it correctly using nc_inq_dimids.
I think the documentation at the above place should show and explain how to do it correctly as well
The text was updated successfully, but these errors were encountered: