QM/MM with new CP2K 2026.1

GROMACS version:2026
GROMACS modification: CP2k interface
Good evening,

I am attempting to compile CP2K 2026.1 on an HPC cluster. While I am familiar with compiling older versions of the code, the newer versions now require CMake. I managed to compile CP2K 2026.1 using the ./make_cp2k.sh script.

Nevertheless, I have not been able to replicate the behavior of the old make -j 128 ARCH=local VERSION=“psmp” libcp2k command, which was necessary for the GROMACS/CP2K interface. Moreover, the libcp2k.a file is not produced by the current CP2K compilation—only libcp2k.so is generated.

Maybe the guide on how to compile the GROMACS/CP2K interface might be updated?

@dmorozov Could you look into this?

Hi, have you been able to build GROMACS with CP2K in that case?

I checked, it actually works completely fine for GROMACS, you should just change CP2K_DIR in GROMACS CMake command to: -DCP2K_DIR=”<your CP2K installation directory>/lib"

P.S. will update installation instructions for CP2K>=2026.1

Actually, since you are using make_cp2k.sh, which builds CP2K using spack. Then I suggest you to try installing everything with spack install gromacs+cp2k it should build the whole toolchain for the latest GROMACS and CP2K versions

Thanks for the kind reply. I actually attempted to compile GROMACS, but it didn’t work; the build process complained that it couldn’t find libcp2k.h.

Could you please share your compilation procedure for both CP2K and GROMACS so that I can try to replicate it? I’m especially interested in how you compiled CP2K (using the toolchain or make_cp2k.sh) and your cmake flags for GROMACS. I will try the suggestion to use -DCP2K_DIR=“/lib”.

I used toolchain script, but it depends on your system (which libraries are available and which not).

CMake command for GROMACS:

cmake .. -DGMX_MPI=ON -DGMX_FFT_LIBRARY=fftw3 -DCMAKE_INSTALL_PREFIX=“/scratch/project_2001312/gromacs_cp2k/install” -DGMX_CP2K=ON -DCP2K_DIR=“/scratch/project_2001312/gromacs_cp2k/cp2k-v2026.1/install/lib” -DGMX_EXTERNAL_BLAS=ON -DGMX_EXTERNAL_LAPACK=ON

After toolchain script, you compiled CP2K with cmake (as suggested by cp2k website)?
In case I’ll try a “custom” version to fit my setup of already installed packages

cd <CP2K_REPOSITORY>

mkdir build/

cmake -S . -B build
-GNinja
-DCP2K_USE_LIBXC=ON
-DCP2K_USE_LIBINT2=ON
-DCP2K_USE_SPGLIB=ON
-DCP2K_USE_ELPA=ON
-DCP2K_USE_SPLA=ON
-DCP2K_USE_SIRIUS=ON
-DCP2K_USE_COSMA=ON

cmake --build build -j 32

Yes but also added -DCMAKE_INSTALL_PREFIX=./install and MPI -DCP2K_USE_MPI=ON -DCP2K_USE_MPI_F08=ON

I also combined build and install commands:

cmake --build build --target install -j 32

Thanks a lot for the help!
Few days I managed to compile it.
It seems I had some problems with the toolchain compilation of cp2k.
Then it worked correctly amd it automatically gave me the correct cmak command (for my config):
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=./install -DCP2K_DATA_DIR=/cluster/…/cp2k/cp2k/data -DCP2K_USE_MPI=ON -DCP2K_USE_MPI_F08=ON -DCP2K_USE_FFTW3=ON -DCP2K_USE_LIBINT2=ON -DCP2K_USE_LIBXC=ON -DCP2K_USE_LIBXSMM=ON -DCP2K_USE_COSMA=ON -DCP2K_USE_ELPA=ON -DCP2K_USE_SpFFT=ON -DCP2K_USE_SPLA=ON -DCP2K_USE_SPGLIB=ON -DCP2K_USE_HDF5=ON -DCP2K_USE_LIBVDWXC=ON -DCP2K_USE_SIRIUS=ON -DCP2K_USE_VORI=ON.
Then, as you suggested, I modified the cmake for Gromacs (this trial version uses its own FFTW, then I’ll link the same as cp2k):
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_DOUBLE=ON -DGMX_MPI=ON -DGMX_CP2K=ON -DCP2K_DIR=/cluster/…/cp2k/cp2k/install/lib/ -DGMX_BLAS_USER=/cluster/…/cp2k/cp2k/tools/toolchain/build/OpenBLAS-0.3.31/libopenblas.so -DGMX_LAPACK_USER=/cluster/…/cp2k/cp2k/tools/toolchain/build/OpenBLAS-0.3.31/libopenblas.so
And it seems it is working properly.

Good! The only thing you should always check before GROMACS launch is that all shared libraries are visible in $LD_LIBRARY_PATH. I also contacted CP2K developers, they will check how to enable possibility of static linking (like it was before CP2K 2026)

Actually I solved the issue by sourcing: source /cluster/…/cp2k/cp2k/tools/toolchain/install/setup before launching the .exe in the slurm file (or from terminal). But of course having a static link would be easier.