!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
!

      SUBROUTINE SUFFT(KULOUT) 1,1
#if defined (DOC) 
C
C**** *SUFFT * - Initialisation and preparation for the
C                FFT
C
C     INPUT : comdim.cdk  (dimensions of the model)
C
C     Modifications.
C     --------------
C        Original : 92-05-28  P. Gauthier *ARMA/AES*
C
C        Revisions: JM Belanger CMDA/SMC  Aug 2000
C          . 32 bits conversion
C            (- Use real*8 interface setfft8 which manages memory space 
C             for internal variables TRIGS,WKFFT,NIFAX.
C             - comfft.cdk becomes obsolete.
C             - call to ngfft to test grid length factorization)
C----------------------------------------------------------------------
C
#endif
      IMPLICIT NONE
#include "comdim.cdk"
#include "comct0.cdk"

      integer jk
      INTEGER IERR, KULOUT, i
*----------------------------------------------------------------------
C
C*    1. Allocate memory for the constant arrays required by the FFT
C
      WRITE(KULOUT,FMT='(//,'' SUFFT- Memory allocation and''
     S    ,'' initialisation for the fast Fourier transform'')')
 100  CONTINUE
C
      IF(NLFFT.GT.1024)THEN
         NLFFT = 1024
         WRITE(KULOUT,FMT='(/,'' *** The FFT cannot handle more than''
     S        ,'' 1024 transforms at the time. NLFFT reset to ''
     S        ,I4)')NLFFT
      END IF
C
C
C*    2. Initialisation of the constants of the FFT
C
 200  CONTINUE

      i = ni
      call ngfft( i )
      if ( i.ne.ni ) then
         write(kulout,*) 'SUFFT: NI = ',ni,' I = ',i
         stop
      else
         write(kulout,*) 'SUFFT: NI = ',ni
      endif

      call setfft8(ni)

      RETURN
      END