TABLE OF CONTENTS


ABINIT/ccfft [ Functions ]

[ Top ] [ Functions ]

NAME

 ccfft

FUNCTION

 Carry out complex-to-complex Fourier transforms between real
 and reciprocal (G) space. Library of such routines.
 Include machine-dependent F90 routines used with fftalg=200.

COPYRIGHT

 Copyright (C) 2000-2018 ABINIT group (PT, XG, FF)
 This file is distributed under the terms of the
 GNU General Public License, see ~abinit/COPYING
 or http://www.gnu.org/copyleft/gpl.txt .

INPUTS

  fftalga=govern the choice of the fft routine to be used
    if 1: SGoedecker routine
    if 2: Machine dependent routine, depending on the precompilation options
    if 3: FFTW library routine
    if 4: new SGoedecker routine, version 2002
          Warning : the second and third dimensions of the Fourier space
          array are switched, compared to the usual case
  fftcache=size of the cache (kB)
  isign= Integer specifying which sign to be used for the transformation.
         must be either +1 or -1.
  ngfft(18)=contain all needed information about 3D FFT, see ~abinit/doc/variables/vargs.htm#ngfft
  n1,n2,n3=Actual integer dimensions (see ngfft) for the 3D sequence.
           Physical dimension of the transform.
  n4,n5,n6=Leading dimensions. Generally, n6 is not different to n3.
  ndat=number of FFT to do in //
  option= 1 if call from fourwf, 2 if call from other routine
  work1(2,n4*n5*n6)=Array to be transformed.

OUTPUT

  inplace = 0 if result is in work2 ; =1 if result is in work1 (machine dependent)
  normalized=0 if the backward (isign=-1) FFT is not normalized, so has to be normalized outside of ccfft
            =1 otherwise
  work2(2,n4*n5*n6)=transformed array in case inplace=0.

SIDE EFFECTS

  work1(2,n4*n5*n6)=at input, array to be transformed
                    at output, transformed array (in case inplace=1)

NOTES

 precompilation definitions :
   -D(machine_list) :  (case fftalga=200)
      choice of machine-dependent FFT library, if permitted
   -DHAVE_FFT_FFTW2   : (case fftalga=300) activate the FFTW lib
   -Dnolib  : (case fftalga=200) call SGoedecker routine,
      instead of machine-dependent one

 More about fftalga=200
 Library routines for the following platforms have been implemented :
  Compaq/DEC
  HP          (in place FFT)
  SGI         (in place FFT)
  NEC         (in place FFT)
 For all the other platforms, or if the CPP directive nolib is
 activated, one uses the fft routine from S. Goedecker.

PARENTS

      fourdp,fourwf

CHILDREN

      sg2002_back,sg2002_forw,sg_fft_cc

SOURCE

 71 #if defined HAVE_CONFIG_H
 72 #include "config.h"
 73 #endif
 74 
 75 #include "abi_common.h"
 76 
 77 
 78 subroutine ccfft(ngfft,isign,n1,n2,n3,n4,n5,n6,ndat,option,work1,work2,comm_fft)
 79 
 80  use defs_basis
 81  use m_errors
 82  use m_profiling_abi
 83 
 84  use m_sgfft,     only : sg_fft_cc
 85  use m_sg2002,    only : sg2002_back, sg2002_forw
 86 
 87 !This section has been created automatically by the script Abilint (TD).
 88 !Do not modify the following lines by hand.
 89 #undef ABI_FUNC
 90 #define ABI_FUNC 'ccfft'
 91 !End of the abilint section
 92 
 93  implicit none
 94 
 95 !Arguments ------------------------------------
 96 !scalars
 97  integer,intent(in) :: isign,n1,n2,n3,n4,n5,n6,ndat,option,comm_fft
 98 !arrays
 99  integer,intent(in) :: ngfft(18)
100  real(dp),intent(inout) :: work1(2,n4*n5*n6*ndat)
101  real(dp),intent(inout) :: work2(2,n4*n5*n6*ndat) !vz_i
102 
103 !Local variables ------------------------------
104 !scalars
105  integer,parameter :: cplex2=2
106  integer :: fftalg,fftalga,fftalgb,fftalgc,fftcache
107  integer :: nd2proc,nd3proc,nproc_fft
108  character(len=500) :: message
109 
110 !*************************************************************************
111 
112  nproc_fft=ngfft(10)
113 
114  fftcache=ngfft(8)
115  fftalg  =ngfft(7)
116  fftalga =fftalg/100; fftalgb=mod(fftalg,100)/10; fftalgc=mod(fftalg,10)
117 
118  if(fftalga==2)then
119    MSG_ERROR("Machine dependent FFTs are not supported anymore")
120 
121  else if(fftalga==3)then
122    MSG_ERROR("Old interface with FFTW2 is not supported anymore")
123 
124  else if(fftalga<1 .or. fftalga>4)then
125    write(message, '(a,a,a,i5,a,a)' )&
126 &   'The allowed values of fftalg(A) are 1, 2, 3, and 4 .',ch10,&
127 &   'The actual value of fftalg(A) is',fftalga,ch10,&
128 &   'Action : check the value of fftalg in your input file.'
129    MSG_ERROR(message)
130  end if
131 
132  ! This routine will be removed ASAP.
133  ! Do not add new FFT libraries without previous discussion with Matteo Giantomassi
134  ! inplace==1 or normalize==2 are not supported anymore in the caller (fourwf, fourdp)
135  !inplace=0; normalized=0
136 
137  if (fftalga/=4) then
138    ! Call Stefan Goedecker FFT
139    call sg_fft_cc(fftcache,n1,n2,n3,n4,n5,n6,ndat,isign,work1,work2)
140 
141  else if (fftalga==4) then
142    ! Call new version of Stefan Goedecker FFT
143    nd2proc=((n2-1)/nproc_fft) +1
144    nd3proc=((n6-1)/nproc_fft) +1
145 
146    if (isign==1) then 
147      ! Fourier to real space (backward)
148      call sg2002_back(cplex2,ndat,n1,n2,n3,n4,n5,n6,n4,nd2proc,nd3proc,option,work1,work2,comm_fft)
149    else 
150      ! isign=-1, real space to Fourier (forward)
151      call sg2002_forw(cplex2,ndat,n1,n2,n3,n4,n5,n6,n4,nd2proc,nd3proc,option,work1,work2,comm_fft)
152    end if
153  end if
154 
155 end subroutine ccfft