Previous: nc_inq_dim Family, Up: Dimensions
The function nc_rename_dim renames an existing dimension in a netCDF dataset open for writing. If the new name is longer than the old name, the netCDF dataset must be in define mode. You cannot rename a dimension to have the same name as another dimension.
int nc_rename_dim(int ncid, int dimid, const char* name);
ncid
dimid
name
nc_rename_dim returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
Here is an example using nc_rename_dim to rename the dimension lat to latitude in an existing netCDF dataset named foo.nc:
#include <netcdf.h> ... int status, ncid, latid; ... status = nc_open("foo.nc", NC_WRITE, &ncid); /* open for writing */ if (status != NC_NOERR) handle_error(status); ... status = nc_redef(ncid); /* put in define mode to rename dimension */ if (status != NC_NOERR) handle_error(status); status = nc_inq_dimid(ncid, "lat", &latid); if (status != NC_NOERR) handle_error(status); status = nc_rename_dim(ncid, latid, "latitude"); if (status != NC_NOERR) handle_error(status); status = nc_enddef(ncid); /* leave define mode */ if (status != NC_NOERR) handle_error(status);