Go to the previous, next section.
The function nccreate (or NCCRE for FORTRAN) creates a
new netCDF file, returning a netCDF ID that can subsequently be used to
refer to the netCDF file. The new netCDF file is placed in define mode.
In case of an error, nccreate returns -1; NCCRE returns a
nonzero value in rcode. Possible causes of errors include::
NC_NOCLOBBER (or NCNOCLOB).
int nccreate (const char* path, int cmode);
path
cmode
NC_CLOBBER or NC_NOCLOBBER. These
constants are defined in the include file named `netcdf.h'.
NC_CLOBBER means that even if the file already exists, you want to
create a new file with the same name, erasing the old file's contents.
NC_NOCLOBBER means you want to create a new netCDF file only if the
given file name does not refer to a file that already exists.
In this example we create a netCDF file named `foo.nc'; we want the file to be created in the current directory only if a file with that name does not already exist:
#include "netcdf.h"
...
int ncid;
...
ncid = nccreate("foo.nc", NC_NOCLOBBER);
INTEGER FUNCTION NCCRE (CHARACTER*(*) PATH, INTEGER CMODE,
INTEGER RCODE)
PATH
CMODE
NCCLOB or NCNOCLOB. These
constants are defined in the include file `netcdf.inc'.
NCCLOB means that even if the file already exists, you want to
create a new file with the same name, erasing the old file's contents.
NCNOCLOB means you want to create a new netCDF file only if the
given file name does not refer to a file that already exists.
RCODE
In this example we create a netCDF file named `foo.nc', assuming we want the file to be created in the current directory only if a file with that name does not already exist:
INCLUDE 'netcdf.inc'
...
INTEGER NCID
...
NCID = NCCRE('foo.nc', NCNOCLOB, RCODE)
Go to the previous, next section.