Go to the previous, next section.
The function ncclose (or NCCLOS for FORTRAN) closes an
open netCDF file. If the file is in define mode, ncendef (or
NCENDF) will be called before closing. (In this case, if
ncendef [or NCENDF] returns an error, ncabort [or
NCABOR] will automatically be called to restore the file to the
consistent state before define mode was last entered.) After an open
netCDF file is closed, its netCDF ID will be reassigned to the next
netCDF file that is opened or created.
In case of an error, ncclose returns -1; NCCLOS returns a
nonzero value in rcode. Possible causes of errors include:
ncendef (or NCENDF) failed.
int ncclose(int ncid);
ncid
ncopen or nccreate.
Here is an example using ncclose to finish the definitions of a
new netCDF file named `foo.nc' and release its netCDF ID:
#include "netcdf.h"
...
int ncid;
...
ncid = nccreate("foo.nc", NC_NOCLOBBER);
... /* create dimensions, variables, attributes */
ncclose(ncid); /* close netCDF file */
SUBROUTINE NCCLOS(INTEGER NCID, INTEGER RCODE)
NCID
NCOPN or NCCRE.
RCODE
Here is an example using NCCLOS to finish the definitions of a
new netCDF file named `foo.nc' and release its netCDF ID:
INCLUDE 'netcdf.inc'
...
INTEGER NCID, RCODE
...
NCID = NCCRE('foo.nc', NCNOCLOB, RCODE)
... ! create dimensions, variables, attributes
CALL NCCLOS(NCID, RCODE)
Go to the previous, next section.