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.
function nf90_close(ncid) integer, intent( in) :: ncid integer :: nf90_close
ncid
NF90_CLOSE returns the value NF90_NOERR if no errors occurred. Otherwise, the returned status indicates an error. Possible causes of errors include:
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)