*dk lsthspl
      subroutine lsthspl(n,x,f,w,ij,y,tab)
      implicit real*8 (a-h,o-z)
      dimension x(n),f(n),w(n),tab(3)
      data r6 / .166666666666667d0 /
      if (y-x(1)) 10,10,20
   10 i=1
      go to 30
   20 if (y-x(n)) 15,40,40
   40 i=n-1
      go to 30
   15 i=0
      do 25 k=1,n
      if (x(k).gt.y) go to 30
   25 i=i+1
   30 mi =(i-1)*ij+1
      ki=mi+ij
      flk=x(i+1)-x(i)
      rflk = 1.0d0/flk
      a=(w(mi)*(x(i+1)-y)**3+w(ki)*(y-x(i))**3)*r6*rflk
      b=(f(ki)*rflk-w(ki)*flk*r6)*(y-x(i))
      c=(f(mi)*rflk-flk*w(mi)*r6)*(x(i+1)-y)
      tab(1)=a+b+c
      return
      end
