This is how you do it in FFTW 2.1.5 MPI for an array
with real-space dimensions
,
where nx is the ``fast'' index for a ``row-major'' array
as described in Sec. 1.4.3 (we'll
also assume n_fields=1).
fplan = fftw3d_mpi_create_plan(mpi_comm,nx,ny,nz,
FFTW_FORWARD,flags);
if (output_order == FFTW_NORMAL_ORDER) {
iplan = fftw3d_mpi_create_plan(mpi_comm,nx,ny,nz,
FFTW_INVERSE,flags);
} else {
iplan = fftw3d_mpi_create_plan(mpi_comm,ny,nz,nx,
FFTW_INVERSE,flags);
}
fftwnd_mpi_local_sizes(fplan,&local_nz,&local_z_start, &local_ny_after_transpose,&local_y_start_after_transpose, &total_local_size);to get information on the part of the data that you will be working with. You must then use malloc() to create total_local_size pixels of complex data (we'll call this sub-array local_data), and an equal amount of workspace array data (we'll call this sub-array workspace).
for (iz=0; iz<local_nz; iz++)
for (iy=0; iy<ny; iy++)
for (ix=0; ix<nx; ix++)
i = ix+iy*nx+(iz+local_z_start)*nx*ny;
c_re(local_data,i) = f(i);
fftwnd_mpi(plan,n_fields,local_data,workspace,output_order);You can then refer to Fourier space data in the output as
if (output_order == FFTW_NORMAL_ORDER) {
for (iz=0; iz<local_nz; iz++)
for (iy=0; iy<ny; iy++)
for (ix=0; ix<nx; ix++)
i = ix+iy*nx+(iz+local_z_start)*nx*ny;
this_real = c_re(local_data,i);
} else {
for (iy=0; iy<local_ny_after_transpose; iy++)
for (iz=0; iz<nz; iz++)
for (ix=0; ix<nx; ix++)
i = ix+iz*nx+(iy+local_y_start_after_transpose)*nx*nz;
this_real = c_re(local_data,i);
}
Microscope User 2008-04-30