*-----------------------------------------------------------------------
      subroutine nxdefm(ncdfid,ldmode)

      logical   ldmode


      if (ldmode) then
        call ncredf(ncdfid,ircode)
      else
        call ncendf(ncdfid,ircode)
      end if

      if (ircode.ne.0)
     +     call msgdmp('e','nxdefm','error in ncredf/ncendf.')

      end
