2.9 NF90_CLOSE
The function NF90_CLOSE closes an open netCDF dataset. If the dataset is
in define mode, NF90_ENDDEF will be called before closing. (In this
case, if NF90_ENDDEF returns an error, NF90_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
function nf90_close(ncid)
integer, intent( in) :: ncid
integer :: nf90_close
ncid- NetCDF ID, from a previous call to NF90_OPEN or NF90_CREATE.
Errors
NF90_CLOSE returns the value NF90_NOERR if no errors occurred. Otherwise,
the returned status indicates an error. Possible causes of errors
include:
- Define mode was entered and the automatic call made to NF90_ENDDEF
failed.
- The specified netCDF ID does not refer to an open netCDF dataset.
Example
Here is an example using NF90_CLOSE to finish the definitions of a new
netCDF dataset named foo.nc and release its netCDF ID:
use netcdf
implicit none
integer :: ncid, status
...
status = nf90_create("foo.nc", nf90_noclobber, ncid)
if (status /= nf90_noerr) call handle_err(status)
... ! create dimensions, variables, attributes
status = nf90_close(ncid)
if (status /= nf90_noerr) call handle_err(status)