Blow is a main file
PROGRAM SPHEROID
USE nrtype
USE SUB_INFO
INCLUDE \"/usr/local/include/fftw3.f\"
INTEGER(I8B) :: plan_forward, plan_backward
INTEGER(I4B) ::
One issue may be that dfftw_execute_dft_c2r can destroy the content of the input array, as described in this page. The key excerpt is
FFTW_PRESERVE_INPUTspecifies that an out-of-place transform must not change its input array. This is ordinarily the default, except for c2r and hc2r (i.e. complex-to-real) transforms for whichFFTW_DESTROY_INPUTis the default...
We can verify this, for example, by modifying the sample code by @VladimirF such that it saves data_out to data_save right after the first FFT(r2c) call, and then calculating their difference after the second FFT (c2r) call. So, in the case of OP's code, it seems safer to save output1 and output2 to different arrays before entering the second FFT (c2r).