4.6 Find All Unlimited Dimension IDs: nc_inq_unlimdims
In netCDF-4 files, it's possible to have multiple unlimited
dimensions. This function returns a list of the unlimited dimension
ids visible in a group.
Dimensions are visible in a group if they have been defined in that
group, or any ancestor group.
Usage
int nc_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp);
ncid
- NetCDF group ID, from a previous call to nc_open, nc_create,
nc_def_grp, etc.
nunlimdimsp
- A pointer to an int which will get the number of visible unlimited
dimensions. Ignored if NULL.
unlimdimidsp
- A pointer to an already allocated array of int which will get the ids
of all visible unlimited dimensions. Ignored if NULL. To allocate the
correct length for this array, call nc_inq_unlimdims with a NULL for
this parameter and use the nunlimdimsp parameter to get the number of
visible unlimited dimensions.
Errors
NC_NOERR
- No error.
NC_EBADID
- Bad group id.
NC_ENOTNC4
- Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4
operations can only be performed on files defined with a create mode
which includes flag HDF5. (see nc_open).
NC_ESTRICTNC3
- This file was created with the strict netcdf-3 flag, therefore
netcdf-4 operations are not allowed. (see nc_open).
NC_EHDFERR
- An error was reported by the HDF5 layer.
Example
int root_ncid, num_unlimdims, unlimdims[NC_MAX_DIMS];
char file[] = "nc4_test.nc";
int res;
/* Open the file. */
if ((res = nc_open(file, NC_NOWRITE, &root_ncid)))
return res;
/* Find out if there are any unlimited dimensions in the root
group. */
if ((res = nc_inq_unlimdims(root_ncid, &num_unlimdims, unlimdims)))
return res;
printf("nc_inq_unlimdims reports %d unlimited dimensions\n", num_unlimdims);