!********************************************************************
!*                   SUBROUTINE SCFFT1D
!********************************************************************
!*
!* Objet      : routine d'interface pour les fft R/C 1D de la lib SGI
!*
!*
!* Methode    :
!*
!* Langage    : Fortran90
!*
!* Auteur     : Guy Moebs
!*
!*
!* $Date$
!*
!********************************************************************
!*
!* $Source$
!*
!* $Log$
!*
!********************************************************************
!*
!* APPELES    :
!*
!********************************************************************
!*
!*
!* ENTREES         :  itrans, ndim
!*
!* ENTREES/SORTIES :  R, C
!*
!* SORTIES         :
!*
!* CODE ERREUR     :
!*
!*
!********************************************************************
!*
      SUBROUTINE scfft1d (itrans, ndim, R, C)
!      
!--------------------
! modules necessaires
!--------------------
      use numerics
      use modfft
!
      IMPLICIT NONE
!
!--------------------------
! description des arguments
!--------------------------
!     * itrans (E ,I ) Entier definissant la transformation
!     * ndim   (E ,I ) Nombre de points de la transformantion
!     * R      (ES,CX) Tableau des valeurs reelles
!     * C      (ES,CX) Tableau des valeurs complexes
!
!--------------------------
! declaration des arguments
!--------------------------
      INTEGER,  INTENT(IN)  ::  itrans
      INTEGER,  INTENT(IN)  ::  ndim
!
      REAL(rp),     DIMENSION(0:ndim-1),  INTENT(INOUT)  ::  R
      COMPLEX(rp),  DIMENSION(0:ndim/2),  INTENT(INOUT)  ::  C
!
!----------------------------------
! declaration des variables locales
!----------------------------------
      REAL(rp)  ::  usn
!
      INTEGER   ::  i
!
!-----------------------
! debut de la subroutine
!-----------------------
!
      SELECT CASE (itrans)
!
!----------------------------------------------------
! Passage de l'espace spectral dans l'espace physique
!----------------------------------------------------
!
      CASE (-1)
           usn = un / REAL(ndim, rp)
           CALL ZDFFT( -1, ndim, usn, C, R, CTRIGS, CWK, 0 )
!
!----------------------------------------------------
! Passage de l'espace physique dans l'espace spectral
!----------------------------------------------------
!
      CASE (1)
           CALL DZFFT(  1, ndim, un,  R, C, CTRIGS, CWK, 0 )
!
!--------------------------
! Initialisations des TRIGS
!--------------------------
!
      CASE (0)
           ALLOCATE( CTRIGS(ndim), CWK(0:2*ndim-1), STAT = ierr )
           IF( ierr /= 0 ) THEN
              WRITE (6,*) ' Probleme allocation CTRIGS, CWK'
              STOP
           END IF
!
           CALL DZFFT(  0, ndim, un,  R, C, CTRIGS, CWK, 0 )
!
!-----------------------
! Finalisation des TRIGS
!-----------------------
!
      CASE (-2)
           DEALLOCATE( CTRIGS, CWK )
!
!-------
! Erreur
!-------
!
      CASE DEFAULT
           WRITE (6,'(A)') 'ERREUR : PARAMETRE itrans INCONNU'
           STOP
!
      END SELECT
!
!---------------------
! Fin de la subroutine
!---------------------
!
      RETURN
      END SUBROUTINE scfft1d
