|||
好久没用cp2k了,以至于上次编译的版本还是2.5.x。最近突然想起,研究了一下6.1版本的编译。
编译系统: CentOS 7
编译环境:Intel parallel studio 2017*
*注:需要预先编译好intel mkl的fftw等库文件
**再注:吐槽一下这博客系统,竟然不支持Markdown。这博文将就着看吧,不过这排版对一个习惯用LaTex和Markdown的人简直是煎熬。
Step 1: 预装package
cp2k-6.1需要预装libxsmm,libxc,libint和libelpa四个package,笔者自己测试通过的兼容版本如下:
libxsmm: 1.16 libxc: 4.2.3 libint: 1.1.6 elpa: 2017.05.002
在这里(https://github.com/hfp/libxsmm/releases)下载libxsmm-1.16,然后安装:
# tar -vxf libxsmm-1.16.tar.gz # cd libxsmm-1.16 # mkdir /opt/cp2k/libs/libxsmm-1.16 -p # make -j 10 PREFIX=/opt/cp2k/libs/libxsmm-1.16 install CC=mpiicc FC=mpiifort
然后安装libxc-4.2.3,在这里(https://www.tddft.org/programs/libxc/down/4.0.3/libxc-4.0.3.tar.gz)下载源代码,安装方法如下:
# tar -vxf libxc-4.2.3.tar.gz # cd libxc-4.2.3 # ./configure --prefix="/opt/cp2k/libs/libxc-4.2.3" CC=mpiicc FC=mpiifort FCFLAGS="-mkl=cluster" # make -j 20 # make install
接下来安装libint-1.1.6稳定版:
# wget https://github.com/evaleev/libint/archive/release-1-1-6.tar.gz -O libint-1.1.6.tar.gz # tar -vxf libint-1.1.6.tar.gz # cd libint-release-1-1-6/ # wget --no-check-certificate https://github.com/hfp/xconfigure/raw/master/configure-get.sh # chmod +x configure-get.sh # ./configure-get.sh libint # ./configure-libint.sh "../../opt/cp2k/libs/libint-1.1.6/" CC=mpiicc FC=mpiifort FCFLAGS="-mkl=cluster" #注意这里的路径,默认是../libint,因此需要加上级../../opt,需要根据自己的实际情况来写安装路径 # make -j 20 # make install
最后安装elpa-2017.05.002:
# wget https://elpa.mpcdf.mpg.de/html/Releases/2017.05.002/elpa-2017.05.002.tar.gz # mkdir /opt/cp2k/libs/elpa-2017.05.002 # tar -vxf elpa-2017.05.002.tar.gz # cd elpa-2017.05.002 # ./configure --prefix="/opt/cp2k/libs/elpa-2017.05.002/" FCFLAGS="-mkl=cluster" CC=mpiicc FC=mpiifort # make -j 20 # make install
Step 2: 编译cp2k-6.1
下载cp2k-6.1并解压
# wget https://codeload.github.com/cp2k/cp2k/tar.gz/v6.1.0 -O cp2k-6.1.0.tar.gz # tar -vxf cp2k-6.1.0.tar.gz # cd cp2k-6.1.0
在arch目录下的Linux-x86-64-intel.popt内容修改如下(注意依赖packages库的位置,前面默认都是安装在/opt/cp2k/libs/目录下,根据自己实际情况修改路径):
# Author: Alfio Lazzaro (alfio.lazzaro@chem.uzh.ch), UZH, 2018 # Note: add optimization flags specific for your system (e.g. -xHost). LIBXSMM = /opt/cp2k/libs/libxsmm-1.16 LIBXC = /opt/cp2k/libs/libxc-4.2.3 LIBINT = /opt/cp2k/libs/libint-1.1.6 LIBELPA = /opt/cp2k/libs/elpa-2017.05.002 CC = cc CPP = FC = mpiifort LD = mpiifort AR = ar -r CPPFLAGS = DFLAGS = -D__MKL -D__FFTW3 -D__HAS_NO_SHARED_GLIBC -D__LIBXSMM \ -D__parallel -D__SCALAPACK \ -D__ELPA=201705 \ -D__LIBXC \ -D__LIBINT -D__LIBINT_MAX_AM=7 -D__LIBDERIV_MAX_AM1=6 \ -D__MAX_CONTR=4 CFLAGS = $(DFLAGS) -O2 FCFLAGS = $(DFLAGS) -O2 -funroll-loops -fpp -free -mkl=cluster FCFLAGS += -fp-model precise FCFLAGS += -g -traceback FCFLAGS += -I${MKLROOT}/include -I${MKLROOT}/include/fftw FCFLAGS += -I$(LIBXSMM)/include FCFLAGS += -I$(LIBXC)/include FCFLAGS += -I$(LIBELPA)/include/elpa-2017.05.002/modules -I$(LIBELPA)/include/elpa-2017.05.002/elpa -L$(LIBXC)/lib -lxcf03 -lxc LDFLAGS = $(FCFLAGS) -static-intel LDFLAGS_C = $(FCFLAGS) -static-intel -nofor_main LIBS = -L$(LIBELPA)/lib -lelpa MKL_LIB = ${MKLROOT}/lib/intel64 LIBS += $(MKL_LIB)/libmkl_scalapack_lp64.a -Wl,--start-group \ $(MKL_LIB)/libmkl_intel_lp64.a ${MKL_LIB}/libmkl_sequential.a \ $(MKL_LIB)/libmkl_core.a \ ${MKL_LIB}/libmkl_blacs_intelmpi_lp64.a -Wl,--end-group \ -lpthread -lm LIBS += -L$(LIBXSMM)/lib -lxsmmf -lxsmm -ldl LIBS += -L$(LIBXC)/lib -lxcf03 -lxc LIBS += -L$(LIBINT)/lib -lderiv -lint -lstdc++ #LIBS += -L$(LIBINT)/lib -lint2 -lstdc++ # Required due to memory leak that occurs if high optimisations are used mp2_optimize_ri_basis.o: mp2_optimize_ri_basis.F $(FC) -c $(subst O2,O0,$(FCFLAGS)) $<
回到cp2k的根目录下,并进入makefiles目录开始编译:
# cd makefiles # make -j 20 ARCH="Linux-x86-64-intel" VERSION="popt"
等待一段时间后,在cp2k-6.1.0/exe目录下即生成相关文件:
# ls exe/Linux-x86-64-intel/ cp2k.popt dbcsr_example_1.popt dbcsr_example_3.popt dbcsr_tensor_unittest.popt dbcsr_unittest.popt libcp2k_unittest.popt cp2k_shell.popt dbcsr_example_2.popt dbcsr_performance_driver.popt dbcsr_test_csr_conversions.popt graph.popt
Step 3(可选): cp2k的modulefile
笔者喜欢使用Environment modules来管理集群上的软件,刚才安装的cp2k的modulefile内容如下:
#%Module 1.0 conflictcp2k prepend-pathPATH /opt/cp2k/bin prepend-pathLD_LIBRARY_PATH /opt/cp2k/libs/elpa-2017.05.002/lib prepend-path LD_LIBRARY_PATH /opt/cp2k/libs/libint-1.1.6/lib prepend-path LD_LIBRARY_PATH /opt/cp2k/libs/libxc-4.2.3/lib prepend-path LD_LIBRARY_PATH /opt/cp2k/libs/libxsmm-1.16/lib
Step 4: 运行cp2k测试算例
在cp2k-6.1的根目录下有测试算例,这里以cp2k-6.1.0/tests/NEB/regtest-1/2gly_B-NEB.inp为例:
$ module load intel/2017 #这是笔者定义的Intel parallel studio 2017的module $ module load cp2k/6.1.0 #这是笔者定义的cp2k-6.1的module $ cd cp2k-6.1.0/tests/NEB/regtest-1 $ mpirun -np 4 cp2k.popt -i 2gly_B-NEB.inp
最后,在集群上需要使用脚本来提交算例。笔者自己搭建的是Slurm,在此就不再赘述。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2025-1-1 21:16
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社