      PROGRAM TSTFFT
C Parameters:
      INTEGER MX,MY,MZ
        PARAMETER (MX=100, MY=100, MZ=100)
C Local variables:
      INTEGER IN,N,NX,NY,NZ
      INTEGER NF235(45)
      COMPLEX C(MX,MY,MZ),CW(MX,MY,MZ)
C***********************************************************************
C Purpose:
C Tests different 3D FFT implementations (CPU time).
C Required routines:
C cfft99f.o  cxfft3.o  cxfft3n.o  
C errmsg.o  fourx.o 
C gpfa.o  timeit_sgi.o  tst.o  wrimsg.o gen.o
C
C History:
C 94.06.20 (PJF): Original version
C 94.12.18 (BTD): Minor changes in output formatting.
C                 Explicit declaration of all variables.
C 95.07.12 (BTD): Minor changes in formatting.
C 96.11.14 (PJF)  getset not needed
C Copyright (C) 1994,1995 B.T. Draine and P.J. Flatau
C This code is covered by the GNU General Public License.
C
C***********************************************************************
C Elements of NF235 are numbers.le.4096  which can be factored by 2,3,5:
       DATA NF235/2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,
     &    45,48,50,54,60,64,72,75,80,81,90,96,100,108,120,125,128,135,
     &    144,150,160,162,180,192,200/
       PRINT *,"Calculation time for different 3-D FFT's methods"
       PRINT *,"================================================ " 
       PRINT *," "
       open(unit=20,file='err.dat',status='unknown')
       open(unit=21,file='res.dat',status='unknown')
       WRITE(21,6021)
 6021 FORMAT(' CPU time (sec) for different 3-D FFT methods',/,
     &   ' Machine=_______',/,
     &   ' parameter LVR =_____',/,
     &   ' LVR="length of vector registers" in gpfa2f,gpfa3f,gpfa5f',/,
     &   '==========================================================',/,
     &   '                     Brenner      Temperton    ',
     &   '  Temperton',/,
     &   '   NX  NY  NZ        (FOURX)        (Old)      ',
     &   '    (GPFA)')
      rewind(20)
      DO 10 IN=1,31
         N=NF235(IN)
         NX=N
         NY=N
         NZ=N
         CALL CASE(C,CW,NX,NY,NZ)
10    CONTINUE
      STOP
      END
      SUBROUTINE CASE(C,CW,NX,NY,NZ)
C Arguments:
      INTEGER NX,NY,NZ
      COMPLEX C(NX,NY,NZ),CW(NX,NY,NZ)
C Local variables:
      INTEGER NN(3)
      REAL T0,T1,T2,T3
      COMPLEX C1, C2, C3, C4, C5, C6
C***********************************************************************
C Purpose: interface to 3D FFT codes (for use in FFT tests)
C History:
C 94.06.20 (PJF): Original version
C 94.12.19 (BTD): Explicit declaration of all variables.
C
C Copyright (C) 1994, B.T. Draine and P.J. Flatau
C This code is covered by the GNU General Public License.
***********************************************************************C
C--------- BRENNR
         NN(1)=NX
         NN(2)=NY
         NN(3)=NZ
         call  gen(c,nx,ny,nz)
         CALL TIMEIT('BREN',T0)         
         CALL FOURX(C,NN,3,1)
         CALL TIMEIT('BREN',T1)
         c1=c(1,1,1)
         c2=c(2,1,1)

C--------- TEMP-OLD
         call  gen(c,nx,ny,nz)
         CALL TIMEIT('OLD',T0)
         CALL CXFFT3(C,NX,NY,NZ,1,CW)
         CALL TIMEIT('OLD',T2)
         c3=c(1,1,1)
         c4=c(2,1,1)

C--------- TEMP-NEW
         call  gen(c,nx,ny,nz)
         CALL TIMEIT('NEW',T0)
         CALL CXFFT3n (C,NX,NY,NZ,1)
         CALL TIMEIT('NEW',T3)
         c5=c(1,1,1)
         c6=c(2,1,1)
C--------- Print
         WRITE(21, '(1x,3i4,3F15.6)') NX,NY,NZ,T1,T2,T3 
         write(20,100) nx, c1,c2
         write(20,100) nx, c3,c4
         write(20,100) nx, c5,c6
 100     format(1x,i5,4g15.4)
         RETURN
         END
      subroutine gen(c,nx,ny,nz)
C Arguments:
      INTEGER NX,NY,NZ
      complex c(nx,ny,nz)
C Local variables:
      INTEGER I1,I2,I3
      REAL F
C Purpose:
C generates a 3D matrix for use in 3D FFT CPU timmings
      do 103 i1=1, nx
         do 102 i2=1, ny
            do 101 i3=1, nz
c              f=i1*i2*i3
               f=sin(float(i1))+sin(float(i2))+sin(float(i3))
               c(i1,i2,i3)=cmplx(f*1.,f*0.5)
 101        CONTINUE
 102     CONTINUE
 103  continue
      return
      end
