The function nc_del_att deletes a netCDF attribute from an open netCDF dataset. The netCDF dataset must be in define mode.
int nc_del_att (int ncid, int varid, const char* name);
ncid
varid
name
nc_del_att 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_del_att to delete the variable attribute Units for a variable rh in an existing netCDF dataset named foo.nc:
#include <netcdf.h> ... int status; /* error status */ int ncid; /* netCDF ID */ int rh_id; /* variable ID */ ... status = nc_open("foo.nc", NC_WRITE, &ncid); if (status != NC_NOERR) handle_error(status); ... status = nc_inq_varid (ncid, "rh", &rh_id); if (status != NC_NOERR) handle_error(status); ... /* delete attribute */ status = nc_redef(ncid); /* enter define mode */ if (status != NC_NOERR) handle_error(status); status = nc_del_att(ncid, rh_id, "Units"); if (status != NC_NOERR) handle_error(status); status = nc_enddef(ncid); /* leave define mode */ if (status != NC_NOERR) handle_error(status);