      program dviscf
      implicit none
      real t,viscf
      integer ierr
      character tinput*32
c
c     Program to read a temperature and test the output of viscf
c
      print *, 'Test program.  Hit a Return (Enter) with no data',
     &         ' to exit'
      ierr=0
      do while (ierr.eq.0)
         write (*,'(a)',advance='no') 'Temperature: '
         read (*,'(a)') tinput
         if (tinput.eq.' ') stop
         read (tinput,*,iostat=ierr) t
         if (ierr.ne.0) cycle
         print *, 'Freon 11 viscosity is ', viscf(t)
      enddo
      stop
      end
c===============================================================
      function viscf(t)
c
c     Given a value of t return a value of viscosity based on interpolation
c     within a table of  values (vtab) corresponding to the t values
c     contained in the array ttab.  The function   assumes that the
c     values in ttab increase monotonically.  Efficiency is increased
c     by remembering the table points used in the last call (ilast).
c
c    John Mahaffy 2/12/95
c
      implicit none
      real ttab(19),vtab(19), t, viscf,wx
      integer ilast, i1
      save ilast
      data ilast/1/
      data ttab/ 199.8267, 210.9378, 222.0489, 233.16,
     &           244.2711, 255.3822, 266.4933, 277.6044,
     &           288.7156, 299.8267, 310.9378, 322.0489,
     &           333.16, 344.2711, 355.3822, 366.4933,
     &           377.6044, 388.7156, 399.8267 /
      data vtab /0.001678 , 0.001348, 0.001104, 0.000922,
     &          0.000781, 0.000674, 0.000587, 0.000517,
     &          0.00046, 0.000413, 0.000374, 0.000341,
     &          0.000312, 0.000288, 0.000266, 0.000249,
     &          0.000236, 0.000219, 0.000202 /
      if (t.le.ttab(ilast+1)) then
          do 20 i1=ilast,1,-1
              if(t.ge.ttab(i1)) go to 60
  20          continue
          write(6,*) 't = ', t, '  is below the table range'
          stop
      else
          do 40 i1=ilast+1,10
              if(t.le.ttab(i1+1)) go to 60
  40          continue
          write(6,*) 't = ', t, '  is above the table range'
          stop
      endif
  60  wx=(t-ttab(i1))/(ttab(i1+1)-ttab(i1))
      viscf=(1-wx)*vtab(i1)+wx*vtab(i1+1)
      ilast=i1
      return
      end
