      program interpolate
      implicit none
      open(10,file='linint')
      open(11,file='cubeint')
      call linenrgy 
      call cubenrgy
      call plotit
      stop
      end
      subroutine linenrgy
      implicit none
      real Cv,u,T,w
      T=300.
      do 100 while (T.le.3000.)
        if(T.lt.1600.) then
           Cv=5000.
        else if (T.gt.2200.)  then
           Cv=7000.
        else
           w=(T-1600.)/(2200.-1600.)
           Cv= (1.-w)*5000.+w*7000.
        endif
        u=Cv*T
        write(10,*)T,Cv,u
        T=T+10.
  100 continue
      return
      end
      subroutine cubenrgy
      implicit none
      real Cv,u,T,ST,w
      T=300.
      do 200 while (T.le.3000.)
        if(T.lt.1600.) then
           Cv=5000.
        else if (T.gt.2200.) then
           Cv=7000.
        else
           ST=(T-1600.)/(2200.-1600.)
           w= ST**2*(3.-2.*ST)
           Cv= (1.-w)*5000.+w*7000.
        endif
        u=Cv*T
        write(11,2000)T,Cv,u
        T=T+10.
  200 continue
2000  format(1x,f7.1,1p,2e12.5)
      return
      end
      subroutine plotit
       logical fexist


      inquire (file='gp-int1',exist=fexist)
      if (.not.fexist) then
        call system('cp ~jhm/201/gp-int1 .')
         print *, ' Graphics input file copied'
      endif
      close ( 11 )
      close ( 10 )
c      call system ('gnuplot gp-int1')
      return
      end
