-1

Good afternoon everyone, So I'm learning to use the FFTW and I was testing a 1D DFT from real to complex and everything was working fine. Then now I try doing the same with a 2D transformation and I find that my program fails.

The thing is that I get a Segmentation Fault (core dumped) when I try to execute my plan. It didn't happen with the 1D plan and I've read through all the documentation and other questions here in Stack Overflow but I can't find where my program fails.

You can see that in the code there are a couple of prints to find where my program crashes and it's just when executing, it prints the executing but never reached the executed so I think the error should come from the plan declaration but I don't know why.

// Declaring variables
const int   Nx=88; 
const int   Ny=44;  
const int   DataFiles=512;
fftw_complex *out2;
double *in2= (double *) fftw_malloc(sizeof(double) * Ny*Nx );
out2  = (fftw_complex*) fftw_malloc( Nx*(Ny/2+1) * sizeof(fftw_complex));
fftw_plan p2 = fftw_plan_dft_r2c_2d (Ny,Nx, in2, out2, FFTW_ESTIMATE);

printf("done \n");
for (n=0; n<DataFiles;n++){
// Filling input with the data
for(kjj=0;kjj<Ny;kjj++){
for(kii=0;kii<Nx;kii++){
    index = kjj*Nx + kii;
    in[index]=data[n][kii][kjj];
}}
printf("executing \n");
fftw_execute(p2);
printf("executed \n");
// DO THINGS WITH OUT[][]
}

I've tried changing the order of Nx Ny in the plan because I'm not sure if it's the smallest which should go first but anyway I get the error.

Any kind of help or pointing to which could be the problem would be an enormous relief. Thank you very much.

fdzglln
  • 39
  • 4
  • For your own and our sake, please add correct indentations in code in future posts (always a tab or four spaces in each nested block). Also, how can you declare for (kjj = 0; etc.) without declaring the type, e.g. for (int kjj = 0; etc..)? – L. van Agtmaal Dec 13 '19 at 09:02

1 Answers1

-1

Okay i had an errata and was giving an empty array in2 because I've put the data inside in.

Sorry for the trouble.

fdzglln
  • 39
  • 4