Go to the previous, next section.

Leave Define Mode

The function ncendef (or NCENDF for FORTRAN) takes an open netCDF file out of define mode. The changes made to the netCDF file while it was in define mode are checked and committed to disk if no problems occurred. The netCDF file is then placed in data mode, so variable data can be read or written.

This call can be expensive, since it involves initializing non-record variables and copying data under some circumstances. See section NetCDF File Structure and Performance, for a more extensive discussion.

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

ncendef: C Interface

int ncendef(int ncid);

ncid
NetCDF ID, returned from a previous call to ncopen or nccreate.
Here is an example using ncendef to finish the definitions of a new netCDF file named `foo.nc' and put it into data mode:
#include "netcdf.h"
   ...
int ncid;
   ...
ncid = nccreate("foo.nc", NC_NOCLOBBER);

   ...      /* create dimensions, variables, attributes */

ncendef(ncid);  /*leave define mode*/

NCENDF: FORTRAN Interface

SUBROUTINE NCENDF(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 using NCENDF to finish the definitions of a new netCDF file named `foo.nc' and put it into data mode:

      INCLUDE 'netcdf.inc'
         ...
      INTEGER NCID
         ...
      NCID = NCCRE('foo.nc', NCNOCLOB, RCODE)

         ...  !  create dimensions, variables, attributes

      CALL NCENDF(NCID, RCODE)

Go to the previous, next section.