# Installation of GROMACS 2022.5 with CP2K 2023.1 using Intel compilers, mpi and mkl fails

**URL:** <https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238>\
**Category:** QM/MM for Biomolecular Simulation\
**Created:** [March 31, 2023, 11:14am UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238 "2023-03-31T11:14:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajib](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajib](https://ask.bioexcel.eu/u/rajib)\
**Post date:** [March 31, 2023, 11:14am UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/1 "2023-03-31T11:14:06Z")

</div>

**GROMACS version:** 2022.5  
**CP2K Version:** 2023.1  
**Compiler and library used:** Intel compilers, mpi and mkl library

Dear Community Members,  
I have followed the following website to install CP2K first:  
[https://docs.bioexcel.eu/qmmm\_bpg/en/main/running\_cp2k/building\_cp2k.html#building-the-interface](https://docs.bioexcel.eu/qmmm_bpg/en/main/running_cp2k/building_cp2k.html#building-the-interface)

**CP2K Installation:**  
./install\_cp2k\_toolchain.sh --math-mode=mkl --mpi-mode=intelmpi --with-hdf5=no --with-sirius=no --with-libvori=no --with-gsl=no --with-spfft=no --with-spglib=no

The local.psmp file has the following contents:

> CC = /home/Packages/intel/oneapi/mpi/2021.5.1/bin/mpiicc  
> CXX = /home/Packages/intel/oneapi/mpi/2021.5.1/bin/mpiicpc  
> AR = ar -r  
> FC = /home/Packages/intel/oneapi/mpi/2021.5.1/bin/mpiifort  
> LD = /home/Packages/intel/oneapi/mpi/2021.5.1/bin/mpiifort
> 
> # 
> 
> DFLAGS = -D\_\_LIBXSMM -D\_\_parallel -D\_\_MKL -D\_\_FFTW3 -D\_\_SCALAPACK -D\_\_LIBINT -D\_\_LIBXC -D\_\_COSMA -D\_\_ELPA
> 
> # 
> 
> WFLAGS =
> 
> # 
> 
> FCDEBFLAGS =  
> CFLAGS = -fopenmp -fp-model precise -g -nofor-main -qopenmp-simd -traceback -wd279 -xHost $(PROFOPT) -m64 -I/home/Packages/intel/oneapi/mkl/2022.0.2/include -I/home/Packages/intel/oneapi/mkl/2022.0.2/include/fftw -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/libxc-6.0.0/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/libxsmm-1.17/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/COSMA-2.6.2/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/elpa-2022.11.001/cpu/include/elpa\_openmp-2022.11.001/modules’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/elpa-2022.11.001/cpu/include/elpa\_openmp-2022.11.001/elpa’ -std=c11 -Wall -Wextra -Werror -Wno-vla-parameter -Wno-deprecated-declarations $(DFLAGS)  
> FCFLAGS = -fopenmp -fp-model precise -g -nofor-main -qopenmp-simd -traceback -wd279 -xHost $(PROFOPT) -m64 -I/home/Packages/intel/oneapi/mkl/2022.0.2/include -I/home/Packages/intel/oneapi/mkl/2022.0.2/include/fftw -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/libxc-6.0.0/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/libxsmm-1.17/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/COSMA-2.6.2/include’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/elpa-2022.11.001/cpu/include/elpa\_openmp-2022.11.001/modules’ -I’/home/Packages/cp2k/2023.1/tools/toolchain/install/elpa-2022.11.001/cpu/include/elpa\_openmp-2022.11.001/elpa’ $(FCDEBFLAGS) $(WFLAGS) $(DFLAGS)  
> CXXFLAGS = -O2 -fPIC -fno-omit-frame-pointer -fopenmp -g -march=native -mtune=native --std=c++14 $(DFLAGS) -Wno-deprecated-declarations
> 
> # 
> 
> LDFLAGS = $(FCFLAGS) -Wl,–enable-new-dtags -L’/home/Packages/intel/oneapi/mpi/2021.5.1/lib/release’ -Wl,-rpath,‘/home/Packages/intel/oneapi/mpi/2021.5.1/lib/release’ -L’/home/Packages/cp2k/2023.1/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/lib’ -L’/home/Packages/cp2k/2023.1/tools/toolchain/install/libxc-6.0.0/lib’ -Wl,-rpath,‘/home/Packages/cp2k/2023.1/tools/toolchain/install/libxc-6.0.0/lib’ -L’/home/Packages/cp2k/2023.1/tools/toolchain/install/libxsmm-1.17/lib’ -Wl,-rpath,‘/home/Packages/cp2k/2023.1/tools/toolchain/install/libxsmm-1.17/lib’ -L’/home/Packages/cp2k/2023.1/tools/toolchain/install/COSMA-2.6.2/lib’ -Wl,-rpath,‘/home/Packages/cp2k/2023.1/tools/toolchain/install/COSMA-2.6.2/lib’ -L’/home/Packages/cp2k/2023.1/tools/toolchain/install/elpa-2022.11.001/cpu/lib’ -Wl,-rpath,‘/home/Packages/cp2k/2023.1/tools/toolchain/install/elpa-2022.11.001/cpu/lib’  
> LIBS = -lelpa\_openmp -lcosma\_prefixed\_pxgemm -lcosma -lcosta -lxsmmf -lxsmm -ldl -lpthread -lxcf03 -lxc -lint2 -lmpi -lmpicxx -L/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64 -Wl,-rpath,/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64 -lmkl\_scalapack\_lp64 -Wl,–start-group -lmkl\_gf\_lp64 -lmkl\_sequential -lmkl\_core -lmkl\_blacs\_intelmpi\_lp64 -Wl,–end-group -lpthread -lm -ldl -lstdc++

After that, I executed the following commands:

> source install/setup  
> cp /home/Packages/cp2k\_2023.1/tools/toolchain/install/arch/\* …/…/arch/  
> cd …/…/arch  
> make -j 24 ARCH=local VERSION=“psmp”  
> make -j 24 ARCH=local VERSION=“psmp” libcp2k

It was successful. I could see the executables and the library files in the respective folders.

**GROMACS Installation:**  
Patched with plumed 2.8.2 compiled using Intel mpi and compilers

> FLAGS=“-xCORE-AVX512 -g -static-intel”; CFLAGS=$FLAGS CXXFLAGS=$FLAGS CC=mpiicc CXX=mpiicpc /home/Packages/cp2k/2023.1/tools/toolchain/install/cmake-3.25.1/bin/cmake … -DCMAKE\_INSTALL\_PREFIX=/home/Packages/gromacs/2022.5\_cp2k\_2023.1 -DGMX\_MPI=ON -DBUILD\_SHARED\_LIBS=OFF -DGMX\_PREFER\_STATIC\_LIBS=ON -DGMX\_FFT\_LIBRARY=mkl -DMKL\_LIBRARIES=“/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_scalapack\_lp64.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_gf\_lp64.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_sequential.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_core.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_blacs\_intelmpi\_lp64.so” -DMKL\_INCLUDE\_DIR=“/home/Packages/intel/oneapi/mkl/2022.0.2/include” -DGMX\_GPU=OFF -DGMX\_BUILD\_HELP=OFF -DGMX\_HWLOC=OFF -DGMX\_SIMD=AVX\_512 -DGMX\_CP2K=ON -DCP2K\_DIR=“/home/Packages/cp2k/2023.1/lib/local/psmp” -DGMX\_LIBS\_SUFFIX=\_cp2k -DGMX\_DEFAULT\_SUFFIX=off -DGMX\_BINARY\_SUFFIX=\_cp2k -DGMXAPI=OFF -DGMX\_INSTALL\_NBLIB\_API=OFF -DGMX\_DOUBLE=ON

The process is through up to 100%.

> 100%] Linking CXX static library …/…/lib/libgromacs\_cp2k.a  
> [100%] Built target libgromacs  
> [100%] Linking CXX executable …/…/bin/gmx\_cp2k  
> icpc: warning #10237: -lcilkrts linked in dynamically, static library not available

Thereafter I get a myriad of ‘undefined reference to’ statements. Below I am pasting a few of them.

> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86\_64-redhat-linux/9/ld: /home/Packages/cp2k/2023.1/lib/local/psmp/libcp2k.a(libcp2k.o): in function `cp2k_get_version': /home/Packages/cp2k/2023.1/src/start/libcp2k.F:73: undefined reference to `for\_len\_trim’  
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86\_64-redhat-linux/9/ld: /home/Packages/cp2k/2023.1/lib/local/psmp/libcp2k.a(libcp2k.o): in function `cp2k\_create\_force\_env’  
> …  
> …

> …  
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86\_64-redhat-linux/9/ld: libxcf03.f90:(.text+0x2755): undefined reference to `c_f_pointer_set_desc4' /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: libxcf03.f90:(.text+0x2818): undefined reference to `for\_cpystr’  
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86\_64-redhat-linux/9/ld: libxcf03.f90:(.text+0x283e): undefined reference to `for\_cpystr’  
> make[2]: \*\*\* [src/programs/CMakeFiles/gmx.dir/build.make:110: bin/gmx\_cp2k] Error 1  
> make[1]: \*\*\* [CMakeFiles/Makefile2:5966: src/programs/CMakeFiles/gmx.dir/all] Error 2  
> make: \*\*\* [Makefile:166: all] Error 2

Any help will be appreciated.  
Thanks and regards,  
Rajib

---

<div class="post-metadata">

**Author:** ![rajib](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajib](https://ask.bioexcel.eu/u/rajib)\
**Post date:** [April 3, 2023, 6:28am UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/2 "2023-04-03T06:28:07Z")

</div>

I still could not figure out the solution to this problem. I have even tried using local\_static.psmp version of cp2k as well. I would appreciate it if anyone could help me with some guidance here. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dmorozov](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@dmorozov](https://ask.bioexcel.eu/u/dmorozov)\
**Post date:** [April 5, 2023, 6:04pm UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/3 "2023-04-05T18:04:27Z")

</div>

Hi, you are using different linkers for GROMACS: “/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86\_64-redhat-linux/9/ld” for CP2K: “LD = /home/Packages/intel/oneapi/mpi/2021.5.1/bin/mpiifort” this could cause problems try to use the same for both.

Also check if CP2K works well by itself (without GROMACS).

---

<div class="post-metadata">

**Author:** ![rajib](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajib](https://ask.bioexcel.eu/u/rajib)\
**Post date:** [April 6, 2023, 6:40am UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/4 "2023-04-06T06:40:11Z")

</div>

Thanks Dmitry for the suggestion.

> Also check if CP2K works well by itself (without GROMACS).

I have checked with some test run of only cp2k, and it is working fine. Even I could compile the GROMACS without CP2K as well. The problem is arising only when I am coupling them together.

Regarding the linker issue, I have tried to pass the following linker option to CMAKE while compiling gromacs using

> -DCMAKE\_LINKER=/home/Packages/intel/oneapi/mpi/2021.5.1/bin/mpiifort

however, it is still using the same linker option, which is

> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86\_64-redhat-linux/9/ld”

I do not know how else I could force the linker option here.

---

<div class="post-metadata">

**Author:** ![dmorozov](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@dmorozov](https://ask.bioexcel.eu/u/dmorozov)\
**Post date:** [April 6, 2023, 7:57am UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/5 "2023-04-06T07:57:07Z")

</div>

Try this one:

> -DCMAKE\_CXX\_LINK\_EXECUTABLE=/home/Packages/intel/oneapi/mpi/2021.5.1/bin/mpiifort

---

<div class="post-metadata">

**Author:** ![rajib](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajib](https://ask.bioexcel.eu/u/rajib)\
**Post date:** [April 7, 2023, 7:32am UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/6 "2023-04-07T07:32:52Z")

</div>

Thanks! I have tried this one and I am now getting the following error.

> Error: Command line argument is needed!  
> Simple script to compile and/or link MPI programs.  
> Usage: mpiifort [options]   
> The following options are supported:  
> -fc= | -f90=  
> specify a FORTRAN compiler name: i.e. -fc=ifort  
> -echo print the scripts during their execution  
> -show show command lines without real calling  
> -show\_env show environment variables  
> -config= specify a configuration file: i.e. -config=ifort for mpif90-ifort.conf file  
> -v print version info of mpiifort and its native compiler  
> -profile= specify a profile configuration file (an MPI profiling  
> library): i.e. -profile=myprofile for the myprofile.cfg file.  
> As a special case, lib.so or lib.a may be used  
> if the library is found  
> -check\_mpi link against the Intel(R) Trace Collector (-profile=vtmc).  
> -static\_mpi link the Intel(R) MPI Library statically  
> -mt\_mpi link the thread safe version of the Intel(R) MPI Library  
> -ilp64 link the ILP64 support of the Intel(R) MPI Library  
> -no\_ilp64 disable ILP64 support explicitly  
> -fast the same as -static\_mpi + pass -fast option to a compiler.  
> -t or -trace  
> link against the Intel(R) Trace Collector  
> -trace-imbalance  
> link against the Intel(R) Trace Collector imbalance library  
> (-profile=vtim)  
> -dynamic\_log link against the Intel(R) Trace Collector dynamically  
> -static use static linkage method  
> -nostrip turn off the debug information stripping during static linking  
> -O enable optimization  
> -link\_mpi=  
> link against the specified version of the Intel(R) MPI Library  
> i.e -link\_mpi=opt|opt\_mt|dbg|dbg\_mt  
> -norpath disable rpath for compiler wrapper of the Intel(R) MPI Library  
> All other options will be passed to the compiler without changing.  
> The following environment variables are used:  
> I\_MPI\_ROOT the Intel(R) MPI Library installation directory path  
> I\_MPI\_F90 or MPICH\_F90  
> the path/name of the underlying compiler to be used  
> I\_MPI\_FC\_PROFILE or I\_MPI\_F90\_PROFILE or MPIF90\_PROFILE  
> the name of profile file (without extension)  
> I\_MPI\_COMPILER\_CONFIG\_DIR  
> the folder which contains configuration files \*.conf  
> I\_MPI\_TRACE\_PROFILE  
> specify a default profile for the -trace option  
> I\_MPI\_CHECK\_PROFILE  
> specify a default profile for the -check\_mpi option  
> I\_MPI\_LINK specify the version of the Intel(R) MPI Library  
> I\_MPI\_DEBUG\_INFO\_STRIP  
> turn on/off the debug information stripping during static linking  
> make[2]: \*\*\* [src/programs/CMakeFiles/gmx.dir/build.make:110: bin/gmx\_cp2k] Error 1  
> make[1]: \*\*\* [CMakeFiles/Makefile2:5966: src/programs/CMakeFiles/gmx.dir/all] Error 2  
> make: \*\*\* [Makefile:166: all] Error 2

---

<div class="post-metadata">

**Author:** ![mabraham](https://dub1.discourse-cdn.com/flex013/user_avatar/ask.bioexcel.eu/mabraham/32/20_2.png) [@mabraham](https://ask.bioexcel.eu/u/mabraham)\
**Post date:** [April 20, 2023, 1:51pm UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/7 "2023-04-20T13:51:42Z")

</div>

The change of linker sounds to me like it should have worked. But per [Static linking of an FORTRAN code with MPI - Stack Overflow](https://stackoverflow.com/questions/32043520/static-linking-of-an-fortran-code-with-mpi) there’s another approach that might work, which is to add -lifcore to the gmx linking command line, like the MPI linker might have done automatically. Try adding `-DCMAKE_EXE_LINKER_FLAGS=-lifcore` to your cmake command line and build again!

---

<div class="post-metadata">

**Author:** ![rajib](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajib](https://ask.bioexcel.eu/u/rajib)\
**Post date:** [April 20, 2023, 8:19pm UTC](https://ask.bioexcel.eu/t/installation-of-gromacs-2022-5-with-cp2k-2023-1-using-intel-compilers-mpi-and-mkl-fails/4238/8 "2023-04-20T20:19:47Z")

</div>

Thanks a lot, Mark. It works. This is the CMake command I used to compile the GROMACS.

> FLAGS=“-xCORE-AVX512 -g -static-intel”; CFLAGS=$FLAGS CXXFLAGS=$FLAGS CC=mpiicc CXX=mpiicpc /home/Packages/cp2k/2023.1/tools/toolchain/install/cmake-3.25.1/bin/cmake … -DCMAKE\_INSTALL\_PREFIX=/home/Packages/gromacs/2022.5\_cp2k\_2023.1 -DGMX\_MPI=ON -DBUILD\_SHARED\_LIBS=OFF -DGMX\_PREFER\_STATIC\_LIBS=ON -DGMX\_FFT\_LIBRARY=mkl -DMKL\_LIBRARIES=“/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_scalapack\_lp64.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_gf\_lp64.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_sequential.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_core.so;/home/Packages/intel/oneapi/mkl/2022.0.2/lib/intel64/libmkl\_blacs\_intelmpi\_lp64.so” -DMKL\_INCLUDE\_DIR=“/home/Packages/intel/oneapi/mkl/2022.0.2/include” -DGMX\_GPU=OFF -DGMX\_BUILD\_HELP=OFF -DGMX\_HWLOC=OFF -DGMX\_SIMD=AVX\_512 -DGMX\_CP2K=ON -DCP2K\_DIR=“/home/Packages/cp2k/2023.1/lib/local/psmp” -DGMX\_LIBS\_SUFFIX=\_cp2k -DGMX\_DEFAULT\_SUFFIX=off -DGMX\_BINARY\_SUFFIX=\_cp2k -DGMXAPI=OFF -DGMX\_INSTALL\_NBLIB\_API=OFF -DGMX\_DOUBLE=ON -DCMAKE\_EXE\_LINKER\_FLAGS=“-lifcore”

I will run the simulation and keep you posted.
