      Subroutine rhokff (nff)
c *** see RH Landau, Program lpott, 1981
      Implicit  Real*8   (a-h,o-z)
      Real*8 rpt(48),wtr(48)
      Real*8 kp,k
      Dimension rho(4,50), pl(50), ff(4)
      Common /sec5/ drho(4,50),rho,kp,k,imax
c
c     partl wave decpmp of ff by projection of single exspm
c     nff= = of form factors, needed and stored in comm/sec5/rho(nff,i).
c
c
      data nit/0/
      If (nit.ne.0) GoTo 10
c     1st Call to rhokff,stup
      nit = 1
      ncoss = imax
      If (imax.gt.40) ncoss = 40
      Call Gauss (ncoss,011,-1.d0,1.d0,rpt,wtr)
 10   rhl1 = kp*kp+k*k
      rhl2 = 2.*kp*k
      Do 30 i=1,imax
         Do 20 j=1,nff
            rho(j,i) = 0.
 20      Continue
 30   Continue
      Do 70 ncos=1,ncoss
         r = rpt(ncos)
         Call ffact ((rhl1-rhl2*r),ff,nff)
         pl(1) = wtr(ncos)
         pl(2) = r*wtr(ncos)
         Do 40 j=1,nff
            rho(j,1) = rho(j,1)+pl(1)*ff(j)
            rho(j,2) = rho(j,2)+pl(2)*ff(j)
 40      Continue
         ii = imax-1
         Do 60 i=2,ii
            g = r*pl(i)
            pl(i+1) = g-pl(i-1)+g-(g-pl(i-1))/i
            Do 50 j=1,nff
               rho(j,i+1) = rho(j,i+1)+pl(i+1)*ff(j)
 50         Continue
 60      Continue
 70   Continue
      Do 90 i=1,imax
         Do 80 j=1,nff
            rho(j,i) = rho(j,i)*(i-0.5)
 80      Continue
 90   Continue
      Return
      End
