      SUBROUTINE FFTidim (A, B, work,al,trigs,idim,idimp2,
     &                    mwave2,lot,isign)
      SAVE
      DIMENSION A( idim ,LOT)
      DIMENSION B( idim ,LOT)
C
      DIMENSION IFAX(20), TRIGS( idim ,2)
C
      DIMENSION WORK( idim ,lot,4), AL( idimp2 ,lot)
C                                                                       
       DATA ITEST/0/                                                    
        IF (ITEST.ne.idim)  THEN                                           
            ITEST=idim                                                     
            JUMP = idim +2                                              
            CALL fftfax(idim,ifax,trigs)
            IF (IFAX(1) .EQ. -99)  PRINT 120                            
            IF (IFAX(1) .EQ. -99)  STOP                                 
120         FORMAT (' ERROR IN FFT idim .   idim  NOT FACTORABLE. ')    
            PRINT 140                                                   
140         FORMAT (' FFTFAX CALLED IN FFT idim .  LONF =  idim  ')     
      ENDIF                                                             
C                                                                       
C                                                                       
      IF (ISIGN .EQ.  1)  THEN                                          
C                                                                       
C  MULTIPLE FAST FOURIER TRANSFORM - SYNTHESIS.  ISIGN=1                
C  GOOD FOR ZONAL WAVE NUMBER  62 .                                     
C                                                                       
C     DIMENSION A( idim ,LOT)                                           
C                                                                       
C   INPUT - LOT SETS OF COMPLEX COEFFICIENTS IN                         
C           A(1,J), A(2,J), ..., A( mwavep *2,J), J=1,...,LOT.          
C           A( mwavep *2+1,J), ..., A( idim ,J), J=1,...,LOT ARE NOT SET
C           BEFORE CALL FFT idim .                                      
C                                                                       
C  OUTPUT - LOT SETS OF GRID VALUES IN                                  
C           A(1,J), A(2,J), ..., A( idim ,J), J=1,...,LOT.              
C                                                                       
      DO 360 J=1, lot
      DO 320 L=1, mwave2                                                
             AL(L,J) = A(L,J)                                       
320   CONTINUE                                                          
      DO 340 L= mwave2+1, jump                                         
             AL(L,J) = 0.0                                          
340   CONTINUE                                                          
360   CONTINUE                                                          
C                                                                       
C     CALL CRAY FFT FOR SYNTHESIS.                                      
      CALL RFFTMLT (AL,WORK,TRIGS,IFAX,1,JUMP, idim ,LOT,1)             
C                                                                       
      DO 440 J=1,lot
      DO 420 L=1, idim                                                  
             A(L,J) = AL(L,J)                                       
420   CONTINUE                                                          
440   CONTINUE                                                          
460   CONTINUE                                                          
C                                                                       
      ENDIF                                                             
C                                                                       
C                                                                       
      IF (ISIGN .EQ. -1)  THEN                                          
C                                                                       
C  MULTIPLE FAST FOURIER TRANSFORM - ANALYSIS.  ISIGN=-1                
C  GOOD FOR ZONAL WAVE NUMBER  62 .                                     
C                                                                       
C     DIMENSION A( idim ,LOT), B( idim ,LOT)                            
C                                                                       
C   INPUT - LOT SETS OF GRID VALUES IN                                  
C           A(1,J), A(2,J), ..., A( idim ,J), J=1,...,LOT.              
C           A ARRAY IS NOT CHANGED BY SUBROUTINE FFT idim .             
C                                                                       
C  OUTPUT - LOT SETS OF COMPLEX COEFFICIENTS IN                         
C           B(1,J), B(2,J), ..., B( mwavep *2,J), J=1,...,LOT.          
C           B( mwavep *2+1,J), ..., B( idim ,J), J=1,...,LOT ARE NOT SET
C                                                                       
      DO 560 J=1, lot
      DO 520 L=1, idim                                                  
             AL(L,J) = A(L,J)                                       
520   CONTINUE                                                          
      DO 540 L= idim+1 , jump                                          
             AL(L,J) = 0.0                                          
540   CONTINUE                                                          
560   CONTINUE                                                          
C                                                                       
C     CALL CRAY FFT FOR ANALYSIS.                                       
      CALL RFFTMLT (AL,WORK,TRIGS,IFAX,1,JUMP, idim ,LOT,-1)            
C                                                                       
      DO 640 J=1, lot
      DO 620 L=1, mwave2                                                
             B(L,J) = AL(L,J)                                       
620   CONTINUE                                                          
640   CONTINUE                                                          
660   CONTINUE                                                          
C                                                                       
      ENDIF                                                             
C                                                                       
      RETURN                                                            
      END                                                               
