      SUBROUTINE FRMTAU(SCR,MAXCOR,IUHF,RLECYC,MAXORD,NEWT,IBOT,
     &                  SINGLE,RLETYP)
C
C FORMS THE TAU VECTOR USED TO EXTRAPOLATE THE AMPLITUDES.
C
CEND
      IMPLICIT INTEGER (A-Z)
      DOUBLE PRECISION R,ECORR,DET,TOL,ERLE,SCR,ERLET2,FACT
      LOGICAL NEWT,SINGLE
      DIMENSION SCR(MAXCOR/2)
      COMMON /RMAT/ R(400)
cAP - 500 is the maximum number of CC iterations (not basis functions)
      COMMON /ENERGY/ ECORR(500,2),IXTRLE(500)
      COMMON /MACHSP/ IINTLN,IFLTLN,IINTFP,IALONE,IBITWD
      COMMON /FLAGS/ IFLAGS(100)
C
C FORM AUGMENTED R MATRIX NOW
C
      IF(MOD(RLETYP,2).EQ.0)THEN
C
C RLE
C
       TOL=0.0
       IORDER=MIN(RLECYC-1,MAXORD)
       ISTART=MAXORD*IORDER+1
       LENGTH=MAXORD*IORDER+IORDER
       I000=1
       I010=I000+LENGTH
c YAU : old
c      CALL ICOPY(LENGTH*IINTFP,R,1,SCR,1)
c YAU : new
       CALL DCOPY(LENGTH,R,1,SCR,1)
c YAU : end
       IX=0
       DO 10 I=IORDER,1,-1
        IX=IX+1
        SCR(ISTART+I-1)=ECORR(IBOT+RLECYC-IORDER+IX-1,2)
10     CONTINUE
       CALL MINV(SCR,IORDER,MAXORD,SCR(I010),DET,TOL,1,0)
      ELSE
C
C RLE-1
C
       TOL=0.0
       NROWPHYR=MAXORD
       NROWPHYS=MAXORD+1
       NCOLPHYR=NROWPHYR
       NCOLPHYS=NROWPHYS
       NROWLOGR=MIN(RLECYC-1,MAXORD)
       NROWLOGS=MIN(RLECYC-1,MAXORD)+1
       IORDER=NROWLOGR
       ISTART=NROWPHYS*NROWLOGS+1
       CALL ZERO(SCR,NROWPHYS*NCOLPHYS)
       I010=1+2*NROWPHYS*NCOLPHYS
       IOFFR=1
       IOFFS=1
       DO 6 ICOL=1,NROWLOGR
c YAU : old
c       CALL ICOPY(IINTFP*NROWLOGR,R(IOFFR),1,SCR(IOFFS),1)
c YAU : new
        CALL DCOPY(NROWLOGR,R(IOFFR),1,SCR(IOFFS),1)
c YAU : end
        SCR(IOFFS+NROWLOGR)=-1.0
        IOFFR=IOFFR+NROWPHYR
        IOFFS=IOFFS+NROWPHYS
        SCR(NROWPHYS*NROWLOGR+ICOL)=-1.0
6      CONTINUE
       SCR(NROWPHYS*NCOLPHYS)=0.0
       DO 7 I=NROWLOGS,1,-1
        FACT=0.
        IF(I.EQ.NROWLOGS)FACT=-1.
        SCR(ISTART+I-1)=FACT
7      CONTINUE
       ISCR=NROWPHYS*(NCOLPHYS+1)
       CALL MINV(SCR,NROWLOGS,NROWPHYS,SCR(I010),DET,TOL,1,0)
      ENDIF
      IF(IFLAGS(1).GT.10)THEN
       WRITE(6,2000)(SCR(ISTART+J),J=0,IORDER-1)
2000   FORMAT(T3,'@FRMTAU-I, RLE expansion coefficients: ',/,
     &        ((5F12.8)))
      ENDIF
C
C SOLUTION VECTOR NOW RESIDES IN R(ISTART..ISTART+IORDER-1).
C
C
C FORM RLE ENERGY ESTIMATE.
C
      IEOFF=IBOT+RLECYC-IORDER+1
      IF(RLETYP.NE.2.AND.RLETYP.NE.3)THEN
        CALL FRMTAU_EXTRAP(ECORR(1,2),ECORR(IEOFF,1),ECORR(IEOFF,2),
     &              SCR(ISTART),ERLE,IORDER,SINGLE,RLETYP)
      ENDIF
      IF(NEWT.OR.RLETYP.EQ.2.OR.RLETYP.EQ.3)THEN
       WRITE(6,200)IORDER
200    FORMAT(T3,'@FRMTAU-I, Generating new solution vector from ',
     &           'previous ',I3,' iterates.')
       CALL RLEVEC(SCR(I010),MAXCOR-I010,IUHF,
     &             SCR(ISTART),IORDER,SINGLE,ERLE,RLETYP,MAXORD)
       ECORR(IBOT+RLECYC,2)=ERLE
       IXTRLE(IBOT+RLECYC)=1
       IF(RLETYP.NE.2.AND.RLETYP.NE.3)CALL ZERO(R,400)
      ENDIF 
      WRITE(6,100)ERLE
100   FORMAT(T3,'RLE <0|H (T2+T1)|0> energy estimator : ',F14.10,
     &          ' a.u.')
      RETURN
      END 
