c utest.f  17 Nov 1994  Glenn Bateman
c
c      Program to test routines that read ASCII U-files
c
c---:----1----:----2----:----3----:----4----:----5----:----6----:----7-c
      program utest
c
      real u1d(1000), u2d(30,1000), x(30), t(1000)
c
      integer nx, nxdim, nt, ntdim, nuout, nufile, nerr, jx, jt
c
      character cudir*36, cu1file*36, cu2file*36
c
c  u1d(jx) = 1-D array
c  u2d(jx,jt) = 2-D array
c  x(jx)   = radial array
c  t(jt)   = time array
c
c  nx      = number of elements found in x-array
c  nxdim   = dimension of x-array
c  nt      = number of elements found in t-array
c  ntdim   = dimension of time array
c  nuout   = output unit number
c  nufile  = unit number to be used for reading U-file
c  nerr    = error condition
c
c  cudir   = name of directory where U-file is located
c  cu1file = name of 1-D U-file
c  cu2file = name of 2-D U-file
c
c..namelist input
c
      namelist /uin/ time, nufile, cudir, cu1file, cu2file, nerr
c
c..defaults
c
      nxdim  = 30
      ntdim  = 1000
      nuout  = 6
      nufile = 10
      nerr   = 0
      time   = 4.5
c
c..open files
c
      open (unit=5,file='utest.dat',status='old')
      open (unit=nuout,file='utest.out')
c
      read (5,uin)
c
c
c..read 2-D ufile
c
      ierr = nerr
c
      call u2read ( cudir, cu2file, nufile, nxdim, ntdim
     &  , x, nx, t, nt, u2d, ierr )
c
c
c..write 2-D array slice
c
      itime = 1
      do jt=1,nt
        if ( t(j) .gt. time ) go to 21
        itime = jt
      enddo
  21  continue
c
      write ( nuout, *)
      write ( nuout, *) 'cudir   = ',cudir
      write ( nuout, *) 'cu1file = ',cu1file
      write ( nuout, *) 'nx = ',nx
      write ( nuout, *) 'nt = ',nt
      write ( nuout, *) 'itime = ',itime
      write ( nuout, *) 't(itime) = ',t(itime)
c
      write ( nuout, 110 ) time
 110  format (//'radial slice of 2-D array just befor time ',1pe13.4
     &  //,t4,'x',t17,'u2d')
c
      do jx=1,nx
        write ( nuout, 101 ) x(jx), u2d(jx,itime)
      enddo
c
c
c..read 1-D ufile
c
      ierr = nerr
c
      call u1read ( cudir, cu1file, nufile, ntdim, t, nt, u1d, ierr )
c
c..write 1-D array
c
      write ( nuout, *)
      write ( nuout, *)
      write ( nuout, *) 'cudir   = ',cudir
      write ( nuout, *) 'cu1file = ',cu1file
      write ( nuout, *) 'nt = ',nt
c
      write ( nuout, 100 )
 100  format (//t4,'time',t17,'u1d')
c
      do jt=1,nt
        write ( nuout, 101 ) t(jt), u1d(jt)
 101  format (1p5e13.6)
      enddo
c
c
      stop
      end
