I am interested in calculating higher order spectral derivatives using CUFFT in Fortran. While the first derivative is correctly calculated, higher derivatives are producing oscillations at the edges of my domain.
You can see that a couple of points are off at 0 and 6.28 and that behavior is even worse for higher derivatives.
The relevant part of my code is the following where I am trying to calculate the second derivative of the 1D array a_d
! Execute FFTs istat=cufftExecD2Z(plan,a_d,b_d,CUFFT_FORWARD) if(istat.ne.0) write(*,*) 'problem with forward fft' !second derivative !$cuf kernel do <<<ceiling(real(nz)/1024)),1024,0,stream>>> do k=1,nz if(k.ge.1.and.k.le.nz/2) then kz=dble(k-1) else kz=dble(-nz+k-1) endif if(k.eq.nz/2+1) kz=0.d0 b_d(i)=b_d(i)*cmplx(0.d0,kz)*cmplx(0.d0,kz) enddo istat=cufftExecZ2D(plan2,b_d,a_d,CUFFT_INVERSE) if(istat.ne.0) write(*,*) 'problem with inverse fft'
a_d is expected to have the second derivative after the inverse fft and after normalization. The core of the result is good but as you can see on the plot above there are issues at the edges.
I would like to ask if you have seen that behavior before using the cufft library and if you have any ideas what may cause that problem.
Thank you in advance