      SUBROUTINE RHOKFF (NFF)
C *** SEE R H 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) GO TO 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
