Gromacs Developer Setup

GROMACS version:
GROMACS modification: Yes/No

Hi,
I’m trying to build gromacs using cmake, as I wish to work on developing in Gromacs. I tried using Clion, and was able to successfully configure the cmake project, but due to its heavyweight nature, I switched to VSCode instead.

When I tried using the CMake:Tools extension, I was able to configure it so that the command that is run during build time is the following:

Executing command: /usr/bin/cmake --no-warn-unused-cli -DGMX_FFT_LIBRARY:STRING=fftw3 -DDREGRESSIONTESTS_DOWNLOAD:STRING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -S/home/sbadani/Work/MD/gromacs -B/home/sbadani/Work/MD/gromacs/build -G Ninja

But it fails, so I tried using the GMX_BUILD_OWN_FFTW3 option, to which it gave me the following error:

Cannot build FFTW3 automatically (GMX_BUILD_OWN_FFTW=ON) with ninja

I was just curious if the developers use an IDE or a standard build tool while doing bug fixes / feature implementation, or is the norm to stick with the time tested CLI cmake and debug tools?

Any help would be greatly appreciated. Thanks!

Hi,

why don’t you build FFTW yourself and then point to it using the CMAKE_PREFIX_PATH variable? Then it will also work with ninja.

Best,
Carsten

Hi!

As Carsten mentioned, there is always an option to build FFTW3 yourself separately.

Likely, it is also provided in your distribution package repository (e.g., sudo apt install libfftw3-dev libfftw3-single3 for Ubuntu). In this case, it should, hopefully, be detected automatically.

I have no experience with VSCode, but, if you really want to build FFTW3 bundled with GROMACS, it is possible to set cmake.generator to Makefile somewhere in project settings: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md#cmake-settings.

I was just curious if the developers use an IDE or a standard build tool while doing bug fixes / feature implementation, or is the norm to stick with the time tested CLI cmake and debug tools?

There is no single recommended tool. I know of people using CLion, VSCode, Visual Studio, and, of course, good old Vim with a bunch of plugins. Since building/testing is often done on remote machines, CLI tools are used directly too.


I also moved your post to “Developer Discussions” category.

I did try that. I already have the .so files in my /usr/lib :

[sbadani@sbadaniKDE ~]$ ls /usr/lib/libfftw3f.so
/usr/lib/libfftw3f.so

So I built it in vscode, and this is the command that was run :

[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_PREFIX_PATH:STRING=/usr/lib/ -DGMX_BUILD_OWN_FFTW:STRING=OFF -DDREGRESSIONTESTS_DOWNLOAD:STRING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -S/home/sbadani/Work/MD/gromacs -B/home/sbadani/Work/MD/gromacs/build -G Ninja

However, it gives the following error:

[cmake]   Could not find fftwf_plan_many_[r2c|c2r] in /usr/lib/libfftw3f.so, take a
[cmake]   look at the error message in

Does this have to do with fftw single precision?

Others have also reported a similar issue in this thread :

I’m working on archlinux, not windows, but still facing the same error :).
If you’ve faced this error before, any help would be appreciated.

Thank you for the response, al.
I did try manually installing libfftw3-single, using this deb

https://ubuntu.pkgs.org/18.04/ubuntu-main-amd64/libfftw3-single3_3.3.7-1_amd64.deb.html

it gave the same error as above.

Can you connect me to a few people who use CLion or VSCode for development, if possible? Thanks!

Update : I tried some other options using cmake, and I got this command on cmake :

/usr/bin/cmake --no-warn-unused-cli -DFFTWF_LIBRARY:STRING=/usr/lib/libfftw3f.so -DGMX_BUILD_OWN_FFTW:STRING=OFF -DDREGRESSIONTESTS_DOWNLOAD:STRING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=FALSE -DCMAKE_BUILD_TYPE:STRING=Debug -S/home/sbadani/Work/MD/gromacs -B/home/sbadani/Work/MD/gromacs/build -G "Unix Makefiles"

It failed with the same error message, could not find r2c|c2r
But when I executed the same on the terminal, it worked
That’s interesting, to say the least.

Apologies for the long reply thread, will stick to one long reply in the future.

If you’re using Arch, why are you trying to install the library from a 7-year-old Ubuntu? Anyway, can you try running ldd /usr/lib/libfftw3f.so to check that all the dependencies are present?

Presumably, it suggests looking at some other log file. Are there any details there?

Unless you are using -DGMX_DOUBLE=ON flag when configuring GROMACS, single-precision FFTW is expected. The fftwf_* functions are single-precision. So, that’s all fine.

I myself use CLion.

Since you have switched to using “Unix Makefiles” generator, you can just as well reenable -DGMX_BUILD_OWN_FFTW=ON.

  • Ninja: only external FFT libraries are supported (or fftpack, but that’s not recommended for general use)
  • Unix Makefiles: either external or built-in FFTW are supported.

Weird indeed. Did you use the exact same command in the exact same directory? If not, I would suspect CMake cache misbehaving. You can try removing the /home/sbadani/Work/MD/gromacs/build/CMakeCache.txt file and re-running CMake.

If you’re using Arch, why are you trying to install the library from a 7-year-old Ubuntu? Anyway, can you try running ldd /usr/lib/libfftw3f.so to check that all the dependencies are present?

I installed it correctly using the configure options I found online, using the --enable-single flag.
I was able to successfully compile it using CLI completely, had gmx running all dandy.
With VSCode CMake, it complained about not finding fftw files. Even after providing it with “CMAKE_PREFIX_PATH”, it complained about setting “CMAKE_PREFIX_PATH”.

I finally used your suggestion and just went ahead with “GMX_BUILD_OWN_FFTW=ON”, and it worked. I was able to completely setup, and debugged a minimization script too. Progress has been made!

You can try removing the /home/sbadani/Work/MD/gromacs/build/CMakeCache.txt file and re-running CMake.

For literally every one of my build, I have just yeeted the build folder and re-run the command. :(

I myself use CLion.
Would you be open to connecting on slack for further development-related discussions? Or if there is an existing slack group, I’d love to be a part of that.

Anyways, for the feature I wish to implement, I need MPI support, so I tried building it with “GMX_MPI=ON” in CMAKE, and it complains about the following :

[cmake] CMake Error at cmake/gmxManageMPI.cmake:81 (message):
[cmake]   MPI support requested, but no suitable MPI compiler found.  Either set the
[cmake]   MPI_CXX_COMPILER to the MPI compiler wrapper (often called mpicxx or

I even tried using -DMPI_CXX_COMPILER=“/usr/bin/mpic++”, but it didn’t work :(.
Trying to figure out a workaround for it.

If using a package manager for MPI, you will likely also need the header
files (dev package). Try both OpenMPI and MPICH.

🎉

Yeah, that’s the safest choice when dealing with CMake issues.

@bgrokm gave an excellent suggestion. If you still have troubles, looking at CMakeError.log file might offer additional clues as to why CMake does not like your MPI installation.

Hi! Sorry, I missed this part originally. We have a Slack workspace, you can join here.