加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

CP2K编译的整理记录

(2017-07-15 18:40:31)
标签:

cp2k

编译

分类: 学习科研
         印象中老早之前应该编译过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          = gfortran
LD          = gfortran
#
DFLAGS      = -D__LIBXSMM   -D__FFTW3  -D__LIBINT -D__LIBINT_MAX_AM=6 -D__LIBDERIV_MAX_AM1=5 -D__LIBXC
#
WFLAGS      = -Werror=aliasing -Werror=ampersand -Werror=c-binding-type -Werror=intrinsic-shadow -Werror=intrinsics-std -Werror=line-truncation -Werror=tabs -Werror=realloc-lhs-all -Werror=target-lifetime -Werror=underflow -Werror=unused-but-set-variable -Werror=unused-variable -Werror=unused-dummy-argument -Werror=conversion -Werror=zerotrip -Werror=uninitialized -Wno-maybe-uninitialized -Wuse-without-only
#
FCDEBFLAGS  = -ffree-form -std=f2003 -fimplicit-none
CFLAGS      = -march=native -fno-omit-frame-pointer -g  -O3 -funroll-loops -ffast-math $(PROFOPT) -fopenmp   -m64 -I/opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/include -I'/usr/include' -I'/usr/include' -I'/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxc-3.0.0/include' -I'/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxsmm-1.7.1/include' $(DFLAGS)
FCFLAGS     = -march=native -fno-omit-frame-pointer -g  -O3 -funroll-loops -ffast-math $(PROFOPT) -fopenmp   -m64 -I/opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/include -I'/usr/include' -I'/usr/include' -I'/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxc-3.0.0/include' -I'/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxsmm-1.7.1/include' $(FCDEBFLAGS) $(WFLAGS) $(DFLAGS)
#
LDFLAGS     = $(FCFLAGS) -Wl,--enable-new-dtags    -L'/usr/lib' -Wl,-rpath='/usr/lib' -L'/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxc-3.0.0/lib' -Wl,-rpath='/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxc-3.0.0/lib' -L'/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxsmm-1.7.1/lib' -Wl,-rpath='/home/yingjin/Chem_Soft/cp2k/cp2k/tools/toolchain/install/libxsmm-1.7.1/lib'
LIBS        -lxsmmf -lxsmm -ldl -lpthread -lxcf90 -lxc -lderiv -lint -lfftw3 -lfftw3_omp    -Wl,--start-group /opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/lib/intel64/libmkl_gf_lp64.a /opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/lib/intel64/libmkl_core.a /opt/intel/compilers_and_libraries_2017.4.196/linux/mkl/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm -ldl -lstdc++


========================================================================
附1,根据arch/Linux-x86-64-gfortran.ssmp改写后的配置文件
(编译可以,但是最后的链接有问题,后续修正)
========================================================================
# Tested with: GFortran 5.4.1
CC         = gcc
CPP        =
FC         = gfortran
LD         = gfortran
AR         = ar -r
ACML_INC   = /opt/acml5.3.1/gfortran64/include
ACML_LIB   = /opt/acml5.3.1/gfortran64/lib
FFTW_INC   = /usr/include
FFTW_LIB   = /usr/lib/x86_64-linux-gnu
LIBINT_INC = /usr/include
LIBINT_LIB = /usr/lib
LIBXC_INC  = /opt/etsf/include
LIBXC_LIB  = /opt/etsf/lib
DFLAGS     = -D__FFTW3 -D__LIBINT -D__LIBXC\
             -D__LIBINT_MAX_AM=7 -D__LIBDERIV_MAX_AM1=6 -D__MAX_CONTR=4
CPPFLAGS   =
FCFLAGS    = $(DFLAGS) -O2 -ffast-math -ffree-form -ffree-line-length-none\
             -fopenmp -ftree-vectorize -funroll-loops\
             -mtune=native\
             -I$(ACML_INC) -I$(FFTW_INC) -I$(LIBINT_INC) -I$(LIBXC_INC)

LDFLAGS    = $(FCFLAGS) -static
LIBS       = $(ACML_LIB)/libacml.a\
             $(FFTW_LIB)/libfftw3.a\
             $(FFTW_LIB)/libfftw3_threads.a\
             $(LIBXC_LIB)/libxcf90.a\
             $(LIBXC_LIB)/libxc.a\
             $(LIBXC_LIB)/libxcf03.a\
             $(LIBINT_LIB)/libderiv.a\
             $(LIBINT_LIB)/libint.a

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有