      SUBROUTINE CXFFT3N(C,MX,MY,MZ,ISIGN)
C Parameters:
      INTEGER MXTRIG
      PARAMETER(MXTRIG=1000)
C Arguments:
      INTEGER ISIGN,MX,MY,MZ
      REAL C(*)
C
C Local scalars:
      INTEGER INC,IND,JUMP,K,LOT,MXOLD,MYOLD,MZOLD
C Local arrays:
      REAL TRIG1(MXTRIG),TRIG2(MXTRIG),TRIG3(MXTRIG)
      SAVE TRIG1,TRIG2,TRIG3,MXOLD,MYOLD,MZOLD
C***********************************************************************
C Interface routine for "Generalized Prime Factor Algorithm" FFT code
C of Temperton.
C Interface written by P.J.Flatau
C
C History:
C
C***********************************************************************
      data mxold, myold, mzold/0,0,0/
      if(mx.ne.mxold .or. my.ne.myold .or. mz.ne.mzold) then
        mxold=mx
        myold=my
        mzold=mz
        CALL SETGPFA(trig1,mX)
        CALL SETGPFA(trig2,mY)
        CALL SETGPFA(trig3,mZ)
      endif
C --- first dimension
      INC=2
      JUMP=2*MX
      LOT=MY*MZ
      CALL GPFA(C(1),c(2),TRIG1,INC,JUMP,MX,LOT,ISIGN)
C --- second dimension
      INC=MX*2
      JUMP=2
      LOT=MX
C --- one plane at a time
      DO 10 K=1,MZ
      ind=1+2*MX*MY*(K-1)
         CALL GPFA(C(IND),C(IND+1),TRIG2,INC,JUMP,
     &               MY,LOT,ISIGN)
   10 CONTINUE
C --- third dimension
      INC=MX*MY*2
      JUMP=2
      LOT=MX*MY
      CALL GPFA(C(1),C(2),TRIG3,INC,JUMP,MZ,LOT,
     &          ISIGN)
      RETURN
      END
