Previous: NF90_RENAME_ATT, Up: Attributes


5.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:

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)