Next: , Previous: NF__ENDDEF, Up: Datasets


2.12 NF_CLOSE

The function NF_CLOSE closes an open netCDF dataset. If the dataset is in define mode, NF_ENDDEF will be called before closing. (In this case, if NF_ENDDEF returns an error, NF_ABORT will automatically be called to restore the dataset to the consistent state before define mode was last entered.) After an open netCDF dataset is closed, its netCDF ID may be reassigned to the next netCDF dataset that is opened or created.

Usage

     INTEGER FUNCTION NF_CLOSE(INTEGER NCID)
NCID
NetCDF ID, from a previous call to NF_OPEN or NF_CREATE.

Errors

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

Example

Here is an example using NF_CLOSE to finish the definitions of a new netCDF dataset named foo.nc and release its netCDF ID:

     INCLUDE 'netcdf.inc'
        ...
     INTEGER NCID, STATUS
        ...
     STATUS = NF_CREATE('foo.nc', NF_NOCLOBBER, NCID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)
     
        ...   ! create dimensions, variables, attributes
     
     STATUS = NF_CLOSE(NCID)
     IF (STATUS .NE. NF_NOERR) CALL HANDLE_ERR(STATUS)