      SUBROUTINE GOERT(DATA,NPREV,IPROD,IFACT,IREM,WORK,WMINR,WMINI,
     X ROOTR,ROOTI) 
C     * APR 21/83 - R.LAPRISE.
C     PHASE-SHIFTED FOURIER TRANSFORM OF LENGTH IFACT BY THE GOERTZEL 
C     ALGORITHM (4).  IFACT MUST BE ODD AND AT LEAST 5.  FURTHER SPEED
C     IS GAINED BY COMPUTING TWO TRANSFORM VALUES AT THE SAME TIME. 
C     DIMENSION DATA(NPREV,IPROD,IFACT,IREM)
C     DATA(I1,1,J3,I5) = SUM(DATA(I1,1,I3,I5) * W**(I3-1)), SUMMED
C     OVER I3 = 1 TO IFACT FOR ALL I1 FROM 1 TO NPREV, J3 FROM 1 TO 
C     IFACT AND I5 FROM 1 TO IREM.
C     W = WMIN * EXP(ISIGN*2*PI*I*(J3-1)/IFACT).
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      DIMENSION DATA(1), WORK(2)
      IP0=2 
      IP1=IP0*NPREV 
      IP2=IP1*IPROD 
      IP3=IP2*IFACT 
      IP5=IP3*IREM
      IF (WMINI) 10,40,10 
C     APPLY THE PHASE SHIFT FACTORS 
 10   WR=WMINR
      WI=WMINI
      I3MIN=1+IP2 
      DO 30 I3=I3MIN,IP3,IP2
      I1MAX=I3+IP1-IP0
      DO 20 I1=I3,I1MAX,IP0 
      DO 20 I5=I1,IP5,IP3 
      TEMPR=DATA(I5)
      DATA(I5)=WR*TEMPR-WI*DATA(I5+1) 
 20   DATA(I5+1)=WR*DATA(I5+1)+WI*TEMPR 
      TEMPR=WR
      WR=WMINR*TEMPR-WMINI*WI 
 30   WI=WMINR*WI+WMINI*TEMPR 
 40   DO 90 I1=1,IP1,IP0
      DO 90 I5=I1,IP5,IP3 
C     STRAIGHT SUMMATION FOR THE FIRST TERM 
      SUMR=0.E0 
      SUMI=0.E0 
      I3MAX=I5+IP3-IP2
      DO 50 I3=I5,I3MAX,IP2 
      SUMR=SUMR+DATA(I3)
 50   SUMI=SUMI+DATA(I3+1)
      WORK(1)=SUMR
      WORK(2)=SUMI
      WR=ROOTR+1.E0 
      WI=ROOTI
      IWMIN=1+IP0 
      IWMAX=IP0*((IFACT+1)/2)-1 
      DO 80 IWORK=IWMIN,IWMAX,IP0 
      TWOWR=WR+WR 
      I3=I3MAX
      OLDSR=0.E0
      OLDSI=0.E0
      SUMR=DATA(I3) 
      SUMI=DATA(I3+1) 
      I3=I3-IP2 
 60   TEMPR=SUMR
      TEMPI=SUMI
      SUMR=TWOWR*SUMR-OLDSR+DATA(I3)
      SUMI=TWOWR*SUMI-OLDSI+DATA(I3+1)
      OLDSR=TEMPR 
      OLDSI=TEMPI 
      I3=I3-IP2 
      IF (I3-I5) 70,70,60 
C     IN A FOURIER TRANSFORM THE W CORRESPONDING TO THE POINT AT K
C     IS THE CONJUGATE OF THAT AT IFACT-K (THAT IS, EXP(TWOPI*I*
C     K/IFACT) = CONJ(EXP(TWOPI*I*(IFACT-K)/IFACT))).  SINCE THE
C     MAIN LOOP OF GOERTZELS ALGORITHM IS INDIFFERENT TO THE IMAGINARY
C     PART OF W, IT NEED BE SUPPLIED ONLY AT THE END. 
 70   TEMPR=-WI*SUMI
      TEMPI=WI*SUMR 
      SUMR=WR*SUMR-OLDSR+DATA(I3) 
      SUMI=WR*SUMI-OLDSI+DATA(I3+1) 
      WORK(IWORK)=SUMR+TEMPR
      WORK(IWORK+1)=SUMI+TEMPI
      IWCNJ=IP0*(IFACT+1)-IWORK 
      WORK(IWCNJ)=SUMR-TEMPR
      WORK(IWCNJ+1)=SUMI-TEMPI
C     SINGLETON'S RECURSION, FOR ACCURACY AND SPEED (5).
      TEMPR=WR
      WR=WR*ROOTR-WI*ROOTI+WR 
 80   WI=TEMPR*ROOTI+WI*ROOTR+WI
      IWORK=1 
      DO 90 I3=I5,I3MAX,IP2 
      DATA(I3)=WORK(IWORK)
      DATA(I3+1)=WORK(IWORK+1)
 90   IWORK=IWORK+IP0 
      RETURN
      END 
