Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Next: , Previous: nc_open_par, Up: Datasets



2.11 Put Open NetCDF Dataset into Define Mode: nc_redef

The function nc_redef puts an open netCDF dataset into define mode, so dimensions, variables, and attributes can be added or renamed and attributes can be deleted.

Usage

For netCDF-4 files (i.e. files created with NC_NETCDF4 in the cmode, see nc_create), it is not necessary to call nc_redef unless the file was also created with NC_STRICT_NC3. For straight-up netCDF-4 files, nc_redef is called automatically, as needed.

For all netCDF-4 files, the root ncid must be used. This is the ncid returned by nc_open and nc_create, and points to the root of the hierarchy tree for netCDF-4 files.

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

Errors

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

Errors

NC_NOERR
No error.
NC_EBADID
Bad ncid.
NC_EBADGRPID
The ncid must refer to the root group of the file, that is, the group returned by nc_open or nc_create. (see nc_open see nc_create).
NC_EINDEFINE
Already in define mode.
NC_EPERM
File is read-only.

Example

Here is an example using nc_redef to open an existing netCDF dataset named foo.nc and put it into define mode:

     #include <netcdf.h>
        ...
     int status;
     int ncid;
        ...
     status = nc_open("foo.nc", NC_WRITE, &ncid);  /* open dataset */
     if (status != NC_NOERR) handle_error(status);
        ...
     status = nc_redef(ncid);                      /* put in define mode */
     if (status != NC_NOERR) handle_error(status);
 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Office of Programs University Corporation for Atmospheric Research (UCAR)   Unidata is a member of the UCAR Office of Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690