Next: , Previous: nc_redef, Up: Datasets


2.9 Leave Define Mode: nc_enddef

The function nc_enddef takes an open netCDF dataset out of define mode. The changes made to the netCDF dataset while it was in define mode are checked and committed to disk if no problems occurred. Non-record variables may be initialized to a "fill value" as well. See nc_set_fill. The netCDF dataset is then placed in data mode, so variable data can be read or written.

This call may involve copying data under some circumstances. For a more extensive discussion see File Structure and Performance.

Usage

     int nc_enddef(int ncid);
ncid
NetCDF ID, from a previous call to nc_open or nc_create.

Errors

nc_enddef returns the value NC_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:

Example

Here is an example using nc_enddef to finish the definitions of a new netCDF dataset named foo.nc and put it into data mode:

     #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_enddef(ncid);  /*leave define mode*/
     if (status != NC_NOERR) handle_error(status);