Cufftmp 2d fft R2C

I have wrote a code for performing 2d FFT using cufftmp .

i used a sin function to test it as ::

4 * ((sin(1.0 * l * dx) * sin(3.0 * k * dz)) + (sin(4.0 * l * dx) * sin(6.0 * k * dz)))

with dx = 2 *pi /Nx and dz = 2*pi/Nz

so the output must be ::

1+0i -- at (1,3), also at (4,6). same inverted output for negatives also.

But i’m getting some random numbers .
Can someone tell the error in cufftmp implemntation.
code.cu.txt (8.5 KB)