Next: Simple MPI example, Previous: FFTW MPI Installation, Up: Distributed-memory FFTW with MPI

### 6.2 Linking and Initializing MPI FFTW

Programs using the MPI FFTW routines should be linked with `-lfftw3_mpi -lfftw3 -lm` on Unix. You will also need to link with whatever library is responsible for MPI on your system; in most MPI implementations, there is a special compiler alias named `mpicc` to compile and link MPI code. Before calling any FFTW routines, but after calling `MPI_Init`, you should call the function:

         void fftw_mpi_init(void);

If, at the end of your program, you want to get rid of all memory and other resources allocated internally by FFTW, for both the serial and MPI routines, you can call:

         void fftw_mpi_cleanup(void);

which is much like the `fftw_cleanup()` function except that it also gets rid of FFTW's MPI-related data. You must not execute any previously created plans after calling this function.