7.8 NF90_DEL_ATT
The function NF90_DEL_ATT deletes a netCDF attribute from an open netCDF
dataset. The netCDF dataset must be in define mode.
Usage
function nf90_del_att(ncid, varid, name)
integer, intent( in) :: ncid, varid
character (len = *), intent( in) :: name
integer :: nf90_del_att
ncid- NetCDF ID, from a previous call to NF90_OPEN or NF90_CREATE.
varid- ID of the attribute's variable, or NF90_GLOBAL for a global attribute.
name- The name of the attribute to be deleted.
Errors
NF90_DEL_ATT returns the value NF90_NOERR if no errors
occurred. Otherwise, the returned status indicates an error. Possible
causes of errors include:
- The specified variable ID is not valid.
- The specified netCDF dataset is in data mode.
- The specified attribute does not exist.
- The specified netCDF ID does not refer to an open netCDF dataset.
Example
Here is an example using NF90_DEL_ATT to delete the variable attribute
Units for a variable rh in an existing netCDF dataset named foo.nc:
use netcdf
implicit none
integer :: ncid1, status
integer :: RHVarID ! Variable ID
...
status = nf90_open("foo.nc", nf90_nowrite, ncid)
if (status /= nf90_noerr) call handle_err(status)
...
! Find the IDs of the variables
status = nf90_inq_varid(ncid, "rh", RHVarID)
if (status /= nf90_noerr) call handle_err(status)
...
status = nf90_redef(ncid) ! Enter define mode
if (status /= nf90_noerr) call handle_err(status)
status = nf90_del_att(ncid, RHVarID, "Units")
if (status /= nf90_noerr) call handle_err(status)
status = nf90_enddef(ncid)
if (status /= nf90_noerr) call handle_err(status)