Next: nc_inq Family, Previous: nc__enddef, Up: Datasets
The function nc_close closes an open netCDF dataset. If the dataset is in define mode, nc_enddef will be called before closing. (In this case, if nc_enddef returns an error, nc_abort will automatically be called to restore the dataset to the consistent state before define mode was last entered.) After an open netCDF dataset is closed, its netCDF ID may be reassigned to the next netCDF dataset that is opened or created.
int nc_close(int ncid);
ncid
nc_close 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_close to finish the definitions of a new netCDF dataset named foo.nc and release its netCDF ID:
#include <netcdf.h> ... int status; int ncid; ... status = nc_create("foo.nc", NC_NOCLOBBER, &ncid); if (status != NC_NOERR) handle_error(status); ... /* create dimensions, variables, attributes */ status = nc_close(ncid); /* close netCDF dataset */ if (status != NC_NOERR) handle_error(status);