************************************************************************
C Open data files and read them into arrays.
C The dut files and the u files have different sizes; hence r1 and r2.
************************************************************************
      subroutine getdata(r1,rgrlat,rgroff,dutfix,ddutfix,u00,ugrlat,
     x     ugroff,nd,ngrlat,ngroff)

      include 'pimc_sqr3sc.dcl'
      dimension r1(nr1)
      dimension dutfix(lev,nr1),ddutfix(lev,nr1)
      dimension u00(nr1)
      dimension rgrlat(nr1),rgroff(nr1)
      dimension ugrlat(nr1),ugroff(nr1)

      open(10,file='data/dutfixt50.dat',status='old')
      open(11,file='data/ddutfixt50.dat',status='old')

      open(12,file='data/dutfixt100.dat',status='old')
      open(13,file='data/ddutfixt100.dat',status='old')

      open(16,file='data/dutfixt200.dat',status='old')
      open(17,file='data/ddutfixt200.dat',status='old')

      open(25,file='data/u00az2t200.dat',status='old')
      open(50,file='data/vgrlat.dat',status='old')
      open(51,file='data/vgroff.dat',status='old')

      i=1
 1    read(25,*,end=2) r1(i),u00(i)
         read(10,*) dum,dutfix(1,i)
         read(11,*) dum,ddutfix(1,i)
         read(12,*) dum,dutfix(2,i)
         read(13,*) dum,ddutfix(2,i)
         read(16,*) dum,dutfix(3,i)
         read(17,*) dum,ddutfix(3,i)
         arg=abs(dum-r1(i))
         if(arg.gt.1.e-5) print*, 'Error in getdata; redo dut files.'
         i=i+1
         goto 1
 2    continue
      nd=i-1

      i=1
 9    read(50,*,end=10) rgrlat(i),vgrlat
      ugrlat(i)=tau*vgrlat
      i=i+1
      goto 9
 10   continue
      ngrlat=i-1
      
      i=1
 11   read(51,*,end=12) rgroff(i),vgroff
      ugroff(i)=tau*vgroff
      i=i+1
      goto 11
 12   continue
      ngroff=i-1

      return
      end 


