C     ********************************************************************

      program getvarnames

C     ********************************************************************

      implicit none
 
      include 'netcdf.inc'
 
      integer   ndims,nvars,ngatts,recdim,ierr
      integer   vartyp,ndim,nvatts,vardim(4)
      integer   cdfid,i
      character*80 cdfname
      character*80 vnam(100)
 
      integer   iargc
      character*(80) arg

c     check for sufficient requested arguments
      if (iargc().ne.1) then
         print*,'USAGE: getvars NetCDF-filename'
         call exit(1)
      endif
 
c     read and transform input
      call getarg(1,arg)
      cdfname=trim(arg)
 
      call cdfopn(cdfname,cdfid,ierr)

      call getvars(cdfid,nvars,vnam,ierr)

C     Write variable names to output

      do i=1,nvars
        write(*,*)vnam(i)
      enddo

C     Close the files

      call clscdf(cdfid,ierr)

      end 
