CP2K编译的整理记录
(2017-07-15 18:40:31)
印象中老早之前应该编译过CP2K,应该也写过博文。不过想想那个应该是出国前的时候,大概12年13年,现在都17年了,重新来写个吧
顺便也重新感受一下CP2K的编译方式
首先,官方的文档可以找到的,如下,可供参考
https://www.cp2k.org/howto:compile
1)获取cp2k的源码,推荐使用git或者svn
笔者用的git,如下
git clone https://github.com/cp2k/cp2k.git
2)笔者这次需要侧重dft部分,所以libxc库(http://octopus-code.org/wiki/Libxc)是肯定要下载下来的。
也可以通过sudo apt-get install
libxc-dev 来安装
3)还有一些需要的其他库/基本库,也可以apt-get安装上去 如Blas或者lapack库
sudo apt-get install libblas-dev
liblapack-dev
更暴力的,直接
apt-get install libxc1 libxc-dev libint-dev libint1 libelpa-dev
libopenblas-base libopenblas-dev libfftw3-3 libfftw3-bin
libfftw3-dev libfftw3-mpi3 openmpi-bin gcc gfortran g++
这样的话无论有没有都直接可以装上的
4-a)cp2k/cp2k/tools/toolchain目录下面有自动配置的脚本,配置完以后执行
make -j4 ARCH=local VERSION="sopt sdbg ssmp popt pdbg psmp"
简单粗暴,就可以了
4-b)
如果自行书写配置环境的话,需要修改arch里面对应的配置文件,比如笔者修改的为Linux-x86-64-gfortran.ssmp,
即支持openMP并行的版本
如果libxc(http://octopus-code.org/wiki/Libxc)版本过新的话(i.e. >
3),cp2k的部分源码需要修改一下(如有错误请指出) ====》
src/xc/xc_libxc_wrap.F 文件
! YMA
modified
!大概在228行,添加以下
TYPE(xc_f90_pointer_t)
:: str ! this will hold a (char **)
pointer ! 定义str
#if (XC_MAJOR_VERSION ==
2)
!稍候一点
CALL xc_f90_info_refs(xc_info, i_ref, str, ref_string)
#else
!CALL xc_f90_info_refs(xc_info, i_ref, ref_string)
CALL xc_f90_info_refs(xc_info, i_ref, str,
ref_string) ! 采用跟2.x一样的调用方式 (注意修改的地方有两处)
#endif
PS:cp2k依赖的前置库巨多,有以下必需的数学或者相关的库
fftw
:
FFTW is
a C subroutine library for computing the discrete Fourier transform
(DFT).
libint
: Libint is
a software stack for computing integrals used in molecular quantum
mechanics.
libxc
: Libxc is a
library of exchange-correlation functionals for density-functional
theory.
libxsmm :
Library for small matrix-matrix multiplications targeting Intel
Architecture (x86)
mkl
: Math Kernel Library
lapack
: Routines for solving systems
of simultaneous linear equations, least-squares solutions of linear
systems of equations, eigenvalue problems, and singular value
problems.
scalapack :
Scalable LAPACK
如果以上有缺失的话,有时候也会报比较奇怪的错误,比如
Can't write to /data/sublist
make[2]: Circular Please <- Please dependency dropped.
make[2]: Circular wait <- Please dependency dropped.
等等错误提示
编译完以后就会在exe对应的目录里面找到如下的可执行文件:(此为采用脚本自动生成的配置文件编译)
yingjin@yingjin-lenovo:~/Chem_Soft/cp2k/cp2k/exe/local$ ls
cp2k_shell.ssmp
dbcsr_example_2.ssmp
dbcsr_tensor_unittest.ssmp
graph.ssmp
cp2k.ssmp
dbcsr_example_3.ssmp
dbcsr_test_csr_conversions.ssmp
libcp2k_unittest.ssmp
dbcsr_example_1.ssmp
dbcsr_performance_driver.ssmp
dbcsr_unittest.ssmp
也可参考:
http://yafanzhao.blog.163.com/blog/static/193196267201410147464255/
http://www.cndba.cn/shuye100/article/1723
http://octopus-code.org/wiki/Libxc
https://www.cp2k.org/howto:compile
========================================================================
附1,toolchain自动生成的arch/local.ssmp配置文件
========================================================================
CC
= gcc
CXX
= g++
CPP
=
AR
= ar -r
FC