Compiling GULP with fftw3 + MPI - Can't open included file 'fftw3-mpi.f03'

I am encountering a persistent error when compiling Gulp with fftw3. Without the -f flag in the mkgulp command, it compiles without error. I have tried two different fftw3 modules that should work with my other loaded modules.

Modules used: gcc/9.3.0 openmpi/4.1.1 netlib-scalapack/2.1.0-openblas (I use this just for scalapack, despite the name) gsl/2.7 openblas/0.3.19 fftw/3.3.9

I’ve modified the mkgulp file successfully to account for non-standard locations of the other modules, and as I said above they work fine. However, when I try to compile with fftw, I get the following error:

…/m_fft3D.F90:14: Error: Can’t open included file ‘fftw3-mpi.f03’

I can confirm that fftw3-mpi.f03 is in the fftw/include directory, that fftw is in a nonstandard location, and as such I have included the following in the mkgulp script:

if [ "$fftw3" = "" ]
then
  echo 'FDEFS=' >> makefile
  echo 'FLIBS=' >> makefile
else
  echo 'FDEFS=-DFFTW3 ' >> makefile
  if [ "$parallel" = "" ]
#--USER--Start
    echo 'FLIBS=-I/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-9.3.0/fftw-3.3.9-ag7mcof5kg3ttvo3z2azdgx4jkrge2ly/include -L/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-9.3.0/fftw-3.3.9-ag7mcof5kg3ttvo3z2azdgx4jkrge2ly/lib -lfftw3.a' >> makefile
#--USER--End
  then
#--USER--Start
    echo 'FLIBS=-I/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-9.3.0/fftw-3.3.9-ag7mcof5kg3ttvo3z2azdgx4jkrge2ly/include -L/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-9.3.0/fftw-3.3.9-ag7mcof5kg3ttvo3z2azdgx4jkrge2ly/lib -lfftw3 -lfftw3_mpi' >> makefile
#  The following is for NCI
#    echo 'FLIBS=-mkl -lfftw3x_cdft_openmpi_lp64'
#--USER--End
  fi
fi

Any help would be greatly appreciated.

This has baffled me for a week, and yet I find the solution within an hour of asking the question. For those who were stuck at this point: the include statement (-I/…) cannot go into FLIBS. I had naively thought it would all go to the same place at compile time. Additionally, I had tried to put the include statement in a separate line as echo “FFLAGS=-I/…” but this didn’t work.

Only now did I realize that it absolutely should have worked, and upon looking into the Makefile I noticed FFLAGS gets used differently from the other FLAGS entities. As such, I modified the line in mkgulp to be echo “FFTFLAGS=-I/…”, which finally worked.

Hope this helps.

Sorry if this was a bit confusing - I’ll try to add more explicit guidance to the mkgulp file for the next release. Because FFTw only helps if using particle-mesh Ewald (usually for MD) then it’s not as widely used.
There is a specific environment variable for include files which is called INC that can be set in mkgulp. Hopefully if you set the directory in this flag then it will work.