*-----------------------------------------------------------------------
      subroutine nxagtx(ncdfid,caname,values)

      include   '/usr/local/include/netcdf.inc'

      real      values(*)
      character caname*(*)


      lencan=lenc(caname)
      idxcol=indxcf(caname,lencan,1,':')

      if (idxcol.eq.1) then
        nvarid=NCGLOBAL
      else if (idxcol.gt.1) then
        nvarid=ncvid(ncdfid,caname(1:idxcol-1),ircode)
        if (ircode.ne.0) call msgdmp('e','nxagtx','error in ncvid.')
      else
        call msgdmp('e','nxagtx','error in attribute name.')
      end if

      call ncagt(ncdfid,nvarid,caname(idxcol+1:lencan),
     +     values,ircode)
      if (ircode.ne.0) call msgdmp('e','nxagtx','error in ncagt.')

      end
