FFTW

Guidance last updated: 20 October 2026

FFTW is a C library for computing discrete Fourier transforms of real or complex data in one or more dimensions. It also supports discrete cosine and sine transforms.

Usage

After connecting to Stanage (see Establishing a SSH connection), start an interactive session:

salloc

For serial or shared-memory applications, load one of the following modules. This also loads the matching GCC compiler:

module load FFTW/3.3.10-GCC-15.2.0
module load FFTW/3.3.10-GCC-14.3.0
module load FFTW/3.3.10-GCC-14.2.0
module load FFTW/3.3.10-GCC-13.3.0
module load FFTW/3.3.10-GCC-13.2.0
module load FFTW/3.3.10-GCC-12.3.0
module load FFTW/3.3.10-GCC-12.2.0
module load FFTW/3.3.10-GCC-11.3.0

For distributed-memory applications, use FFTW.MPI instead. It loads its matching FFTW, GCC and OpenMPI dependencies. Use a build matching your application’s compiler and MPI toolchain.

For Intel’s FFTW-compatible interfaces, see imkl-fftw.

Serial C example

Download fftw-example.c into your working directory. Within a CPU allocation, compile and run it with:

module load FFTW/3.3.10-GCC-15.2.0
gcc fftw-example.c -o fftw-example -lfftw3 -lm
./fftw-example

The example transforms an impulse, checks that every Fourier coefficient is one, then checks the inverse transform after dividing by the transform size. FFTW does not normalise its inverse transforms automatically.

MPI C example

Download fftw-mpi-example.c. The following example batch submission script runs a distributed two-dimensional transform with two MPI processes on one CPU node:

#!/bin/bash
#SBATCH --partition=sheffield
#SBATCH --nodes=1
#SBATCH --ntasks=2
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=1000
#SBATCH --time=00:05:00

set -euo pipefail
cd "$SLURM_SUBMIT_DIR"
export SLURM_EXPORT_ENV=ALL
module load FFTW.MPI/3.3.10-gompi-2026.1
mpicc fftw-mpi-example.c -o fftw-mpi-example -lfftw3_mpi -lfftw3 -lm
srun ./fftw-mpi-example

Save the script as fftw.slurm and submit it with sbatch fftw.slurm. The program checks the Fourier coefficients and prints PASS: MPI transform with 2 processes on success.

Installation notes

FFTW was installed using Easybuild, build details can be found in $EBROOTFFTW/easybuild with a given module loaded.

Direct dependencies for latest version of FFTW