2.12 NF90_ABORT
You no longer need to call this function, since it is called
automatically by NF90_CLOSE in case the dataset is in define mode and
something goes wrong with committing the changes. The function
NF90_ABORT just closes the netCDF dataset, if not in define mode. If the
dataset is being created and is still in define mode, the dataset is
deleted. If define mode was entered by a call to NF90_REDEF, the netCDF
dataset is restored to its state before definition mode was entered
and the dataset is closed.
Usage
function nf90_abort(ncid)
integer, intent( in) :: ncid
integer :: nf90_abort
ncid- NetCDF ID, from a previous call to NF90_OPEN or NF90_CREATE.
Errors
NF90_ABORT returns the value NF90_NOERR if no errors occurred. Otherwise,
the returned status indicates an error. Possible causes of errors
include:
- When called from define mode while creating a netCDF dataset, deletion
of the dataset failed.
- The specified netCDF ID does not refer to an open netCDF dataset.
Example
Here is an example using NF90_ABORT to back out of redefinitions of a
dataset named foo.nc:
use netcdf
implicit none
integer :: ncid, status, LatDimID
...
status = nf90_open("foo.nc", nf90_write, ncid)
if (status /= nf90_noerr) call handle_err(status)
...
status = nf90_redef(ncid)
if (status /= nf90_noerr) call handle_err(status)
...
status = nf90_def_dim(ncid, "Lat", 18, LatDimID)
if (status /= nf90_noerr) then ! Dimension definition failed
call handle_err(status)
status = nf90_abort(ncid) ! Abort redefinitions
if (status /= nf90_noerr) call handle_err(status)
end if
...