本帖最后由 DavyHou 于 2024-7-31 09:08 编辑
安装GCC需要依赖三个库:GMP, MPFR 和 MPC三个库。 如果可以在联网的情况下,我们直接运行如下命令即可以安装这三个库。运行以下命令即可:./contrib/download_prerequisites
然后分别执行以下命令(这个过程可能有点久):
mkdir objdir
cd objdir
../configure --disable-checking --enable-languages=c,c++,fortran --disable-multilib --prefix=/path/to/install/gcc-14.1 --enable-threads=posix
make -j && make install
/path/to/install/gcc-14.1这个是自己想要给gcc安装的目录,需要自己创建好。
gcc 安装速度非常慢,需要一个多小时,要耐心等待
2. gcc安装结束后,解压cp2k-2024.1.tar.bz2文件 tar -xvf cp2k-2024.1.tar.bz2
之后进入./cp2k-2024.1/tools/toolchain/文件夹,运行以下命令
./install_cp2k_toolchain.sh --with-sirius=no --with-openmpi=install--with-plumed=install --with-gcc=system --with-intel=no > out.log2>&1 &
出现以下内容且无报错则为安装顺利完成。之后根据黑体提示即可编译CP2K。
------------------------------------------------------------------------------------------------------------------------------------------------
Done!
Now copy:
cp /home/xxx/software/cp2k-2024.1/tools/toolchain/install/arch/* tothe cp2k/arch/ directory
To use the installed tools and libraries and cp2k version
compiled with it you will first need to execute at the prompt:
source/home/xxx/software/cp2k-2024.1/tools/toolchain/install/setup
To build CP2K you should change directory:
cd cp2k/
make -j 32 ARCH=local VERSION="ssmp sdbg psmp pdbg"
arch files for GPU enabled CUDA versions are named "local_cuda.*"
arch files for GPU enabled HIP versions are named "local_hip.*"
arch files for OpenCL (GPU) versions are named "local_opencl.*"
arch files for coverage versions are named "local_coverage.*"
Note that these pre-built arch files are for the GNU compiler, users have toadapt them for other compilers.
It is possible to use the provided CP2K arch files as guidance.
--------------------------------------------------------------------------------------------------------------------------------------------------
安装结束后可以在./cp2k-2024.1/exe/local/文件夹下看到cp2k.pdbg,cp2k.popt,cp2k.psmp,cp2k.sdbg,cp2k.sopt,cp2k.ssmp几个文件。对于计算主要使用cp2k.popt和cp2k.psmp。
另外在.bashrc中写入以下内容
source /home/xxx/software/cp2k-2024.1/tools/toolchain/install/setup
export PATH=$PATH:/home/xxx/software/cp2k-2024.1/exe/local
3. 开始吐槽,心情不好的请绕道
3.1 F**king gcc-10.2
由于之前安装PACE的时候已经安装了gcc-10.2,并且该版本gcc已经相对较新了,所以没有再考虑安装其它版本gcc。但是该版本gcc在安装libint-v2.6.0-cp2k-lmax-5.tgz时有以下错误
python c_to_f.py ../include/libint2.h.i libint2_types_f.h Libint_t
grep '^#' ../include/libint2_types.h | grep -v '#include' >fortran_incldefs.h
FC libint_f.o
../include/libint2/util/generated/libint2_params.h:29:0:
29 | # if __has_include(<libint2_params.h>)
|
Error: missing '(' before "__has_include" operand
../include/libint2/util/generated/libint2_params.h:29:0: Error: operator"__has_include" requires a header-name
make[1]: *** [libint_f.o] Error 1
make[1]: Leaving directory`/home/xxx/software/t/cp2k-2024.1/tools/toolchain/build/libint-v2.6.0-cp2k-lmax-5/fortran'
make: *** [fortran] Error 1
但是更换为gcc14.1后一切都顺利了起来。所以有理由怀疑是编译器兼容问题。
3.2 F**king oneapi-2021
如果使用intel编译器来编译CP2K2024.1时,./install_cp2k_toolchain.sh可以顺利运行,无报错。但是make -j 32 ARCH=localVERSION="ssmp sdbg psmp pdbg"运行时只能编译出cp2k.sopt,cp2k.ssmp。之后报错,无法编译出cp2k.popt和cp2k.psmp。cp2k.ssmp虽然能够正常运行,但是遇到大体系结构,计算过程会有内存问题。
|