*-----------------------------------------------------------------------
*     FILE HANDLING
*-----------------------------------------------------------------------
      subroutine nxopen(ncdfid,cfname,cfmode)

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

      character cfname*(*),cfmode*(*)

      logical   lchreq


      call ncpopt(NCVERBOS)

      if (lchreq(cfmode(1:1),'c')) then
        ncdfid=nccre(cfname,NCCLOB,ircode)
      else if (lchreq(cfmode(1:1),'r')) then
        ncdfid=ncopn(cfname,NCNOWRIT,ircode)
      else if (lchreq(cfmode(1:1),'m')) then
        ncdfid=ncopn(cfname,NCWRITE,ircode)
      else
        call msgdmp('e','nxopen',
     +       'access mode should be "c"reate, "r"ead or "m"odify.')
      end if

      if (ircode.ne.0)
     +     call msgdmp('e','nxopen','error in nccre/ncopn.')

      end
