LCOV - code coverage report
Current view: top level - math - fft_interface.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 18 18 100.0 %
Date: 2019-09-08 04:53:50 Functions: 1 1 100.0 %

          Line data    Source code
       1             : MODULE m_fft_interface
       2             : 
       3             :  use m_cfft
       4             :  use m_juDFT
       5             : #ifdef CPP_FFT_MKL        
       6             :  use mkl_dfti
       7             : #endif
       8             : 
       9             : IMPLICIT NONE
      10             : CONTAINS
      11             : 
      12       20674 :     subroutine fft_interface(dimen,length,dat,forw)
      13             :     ! provides interfaces to ftt subroutines
      14             : 
      15             :     integer, intent(in)    :: dimen         !dimension of fft transformation
      16             :     integer, intent(in)    :: length(dimen) !length of data in each direction
      17             :     complex, intent(inout) :: dat(:)        !data to be transformed, size(dat) should be sum(length)
      18             :     logical, intent(in)    :: forw          !.true. for the forward transformation, .false. for the backward one
      19             : 
      20             : #ifdef CPP_FFT_MKL        
      21             :     type(dfti_descriptor),pointer :: dfti_handle
      22             :     integer :: dfti_status
      23             : #else
      24       20674 :     real,allocatable :: afft(:),bfft(:)
      25             :     integer :: isn
      26             : #endif
      27             :     integer :: size_dat,i
      28             :     
      29       20674 :        size_dat = 1
      30       82696 :        do i = 1,dimen
      31       82696 :           size_dat = size_dat * length(i)
      32             :        enddo
      33       20674 :        if (size(dat) .ne. size_dat) call juDFT_error('array bounds are inconsistent',calledby ='fft_interface')
      34       20674 :        if (dimen .ne. 3 )  call juDFT_error('sorry, not implemented yet for this value of dimen',calledby ='fft_interface')
      35             :  
      36             : #ifdef CPP_FFT_MKL        
      37             :        !using MKL library
      38             :        dfti_status = DftiCreateDescriptor(dfti_handle,dfti_double,dfti_complex,3,length)
      39             :        dfti_status = DftiCommitDescriptor(dfti_handle)
      40             :        if (forw) then
      41             :            dfti_status = DftiComputeForward(dfti_handle,dat)
      42             :        else
      43             :            dfti_status = DftiComputeBackward(dfti_handle,dat)
      44             :        end if
      45             :        dfti_status = DftiFreeDescriptor(dfti_handle)
      46             : 
      47             : #else
      48       20674 :        allocate(afft(size_dat),bfft(size_dat))
      49       20674 :        afft = real(dat)
      50       20674 :        bfft = aimag(dat)
      51       20674 :        if (forw) then 
      52        7165 :           isn = -1
      53             :        else
      54       13509 :           isn = 1
      55             :        end if
      56       20674 :        CALL cfft(afft,bfft,size_dat,length(1),length(1),isn)
      57       20674 :        CALL cfft(afft,bfft,size_dat,length(2),length(1)*length(2),isn)
      58       20674 :        CALL cfft(afft,bfft,size_dat,length(3),size_dat,isn)
      59             : 
      60   251078119 :        dat = cmplx(afft,bfft)
      61             : #endif
      62             : 
      63       20674 :     end subroutine fft_interface
      64             : 
      65             : END MODULE m_fft_interface

Generated by: LCOV version 1.13