Go to the previous, next section.

Put Open NetCDF File into Define Mode

The function ncredef (or NCREDF for FORTRAN) puts an open netCDF file into define mode, so dimensions, variables, and attributes can be added or renamed and attributes can be deleted.

In case of an error, ncredef returns -1; NCREDF returns a nonzero value in rcode. Possible causes of errors include::

ncredef: C Interface

int ncredef(int ncid);

ncid
netCDF ID, returned from a previous call to ncopen or nccreate.

Here is an example using ncredef to open an existing NetCDF file named `foo.nc' and put it into define mode:

#include "netcdf.h"
   ...
int ncid;
   ...
ncid = ncopen("foo.nc", NC_WRITE);    /* open file */
   ...
ncredef(ncid);                        /* put in define mode */

NCREDF: FORTRAN Interface

SUBROUTINE NCREDF(INTEGER NCID, INTEGER RCODE)

NCID
NetCDF ID, returned from a previous call to NCOPN or NCCRE.

RCODE
Returned error code. If no errors occurred, 0 is returned.

Here is an example of using NCREDF to open an existing netCDF file named `foo.nc' and put it into define mode:

      INCLUDE 'netcdf.inc'
         ...
      INTEGER NCID
         ...
      NCID = NCOPN('foo.nc', NCWRITE, RCODE)
         ...
      CALL NCREDF(NCID, RCODE)

Go to the previous, next section.