u盘电脑cp系统安装步骤 ()

本次部署CP2K采用全离线方式安装(集群上安装居然没法自动下载工具链,太坑爹了。。我暂时没工夫调查原因,先pass了)。注意,安装CP2K-2022.2需要GCC 8以上的支持,老系统的小伙伴,需要额外安装新版gcc。


安装过程涉及到的软件包下载地址:

链接:https://pan.baidu.com/s/1fj9i-Wu1PVHAy8dCmQvJqA?pwd=1rjy

提取码:1rjy


参考博文:

1. GCC一键安装/升级脚本参考(白嫖)学术之友公众号的Tamas分享的脚本。

2. CP2K安装过程参考(照搬)《CP2K第一性原理程序在CentOS中的简易安装方法》:http://sobereva.com/586


一、安装GCC 9.3 (不需要的同学直接忽视掉这一部分的安装)

(1) 进入CP2K-2022.2/gcc_install目录,直接运行install_online_gcc_9.3.0.sh,这里安装gcc所需的4个工具包已经在同一目录下了,所以不需要再联网下载。

./install_online_gcc_9.3.0.sh

这个脚本特别傻瓜,全程不需要人为干涉,你只需要设置一下gcc的安装位置即可,在这里,我把gcc安装在/home/yjy/softwares/gcc9/目录下。


(2) 最后需要记住的是如何激活gcc,那就是

source ~/softwares/gcc9/env.sh

这里附上install_online_gcc_9.3.0.sh里的代码供大家参考:

#!/bin/bash#来自学术之友公众号的Tamas,我把7.1.0改成了9.3.0wget https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz wget http://mirrors.nju.edu.cn/gnu/mpc/mpc-1.2.0.tar.gz wget http://mirrors.nju.edu.cn/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz wget https://ftp.gnu.org/pub/gnu/gmp/gmp-6.2.0.tar.bz2 if [[ -f \"mpfr-4.1.0.tar.gz\" ]] && [[ -f \"mpc-1.2.0.tar.gz\" ]] && [[ -f \"gcc-9.3.0.tar.gz\" ]] && [[ -f \"gmp-6.2.0.tar.bz2\" ]] ;then trueelse echo \"One of mpfr-4.1.0.tar.gz,mpc-1.2.0.tar.gz,gmp-6.2.0.tar.bz2,gcc-9.3.0.tar.gz is missing.\" exit 1fi
gcc1=`gcc -dumpversion | awk '{split($0,a,\".\"); print a[1]}'`
if [ $gcc1 -gt 9 ];then echo \"GCC version is higher than 9, no need to install gcc-9\" exit 1fi read -p \"Input installation directory for 9.3.0--->\" gcc9dir# gcc9dir=/home/yjy/softwares/gcc9/if [ ! -n \"$gcc9dir\" ]; then echo \"Wrong: not a valid directory\"; exit 1fimkdir -p $gcc9dirif [ ! -d \"$gcc9dir\" ]; then echo \"Wrong: no permission or not a valid directory.\" exit 1电脑fi
read -p \"To use 9.3.0 after installation: source $gcc9dir/env.sh hit ENTER to continue!\" ok
function install_needed(){ echo \"installing gmp ...\" tar -jxvf gmp-6.2.0.tar.bz2 cd gmp-6.2.0
CC=gcc CXX=g++ ./configure --prefix=$gcc9dir/gmp-6.2.0 make make install export GMP_HOME=$gcc9dir/gmp-6.2.0 export PATH=$GMP_HOME/bin:$PATH export LD_LIBRARY_PATH=$GMP_HOME/lib:$LD_LIBRARY_PATH export INCLUDE=$GMP_HOME/include:$INCLUDE
cd ../ rm -rf gmp-6.2.0
echo \"installing mpfr ...\" tar -zxvf mpfr-4.1.0.tar.gz cd mpfr-4.1.0 CC=gcc CXX=g++ ./configure --prefix=电脑$gcc9dir/mpfr-4.1.0 --with-gmp=$GMP_HOME make make install
export MPFR_HOME=$gcc9dir/mpfr-4.1.0 export PATH=$MPFR_HOME/bin:$PATH export LD_LIBRARY_PATH=$MPFR_HOME/lib:$LD_LIBRARY_PATH export INCLUDE=$MPFR_HOME/include:$INCLUDE
cd ../ rm -rf mpfr-4.1.0
echo \"installing mpc ...\" tar -zxvf mpc-1.2.0.tar.gz cd mpc-1.2.0 CC=gcc CXX=g++ ./configure --prefix=$gcc9dir/mpc-1.2.0 --with-gmp=$GMP_HOME --with-mpfr=$MPFR_HOME make make install
export MPC_HOME=$gcc9dir/mpc-1.2.0 export PATH=$MPC_HOME/bin:$PATH export LD_LIBRARY_PATH=$MPC_HOME/lib:$LD_LIBRARY_PATH export INCLUDE=$MPC_HOME/include:$INCLUDE
cd ../ rm -rf mpc-1.2.0}
install_needed
#to prevent LIBRARY_PATH containing the current directoryunset LIBRARY_PATHecho \"installing gcc-9 ...\"tar -zxvf gcc-9.3.0.tar.gzcd gcc-9.3.0CC=gcc CXX=g++ ./configure --prefix=$gcc9dir/gcc-9.3.0 --with-gmp=$GMP_HOME --with-mpfr=$MPFR_HOME --with-mpc=$MPC_HOME --disable-multilib --enable-languages=c,c++,fortran
makemake installexport GCC_HOME=$gcc9dir/gcc-9.3.0export PATH=$GCC_HOME/bin:$PATHexport LD_LIBRARY_PATH=$GCC_HOME/lib:$GCC_HOME/lib64:$LD_LIBRARY_PATHexport INCLUDE=$GCC_HOME/include:$INCLUDEcd ../rm -rf gcc-9.3.0
echo \"export GMP_HOME=$gcc9dir/gmp-6.2.0\" >> $gcc9dir/env.shecho 'export PATH=$GMP_HOME/bin:$PATH' >> $gcc9dir/env.shecho 'export LD_LIBRARY_PATH=$GMP_HOME/lib:$LD_LIBRARY_PATH' >> $gcc9dir/env.shecho 'export INCLUDE=$GMP_HOME/include:$INCLUDE' >> $gcc9dir/env.shecho \"export MPFR_HOME=$gcc9dir/mpfr-4.1.0\" >> $gcc9dir/env.shecho 'export PATH=$MPFR_HOME/bin:$PATH' >> $gcc9dir/env.shecho 'export LD_LIBRARY_PATH=$MPFR_HOME/lib:$LD_LIBRARY_PATH' >> $gcc9dir/env.shecho 'export INCLUDE=$MPFR_HOME/include:$INCLUDE' >> $gcc9dir/env.shecho \"export MPC_HOME=$gcc9dir/mpc-1.2.0\" >> $gcc9dir/env.shecho 'export PATH=$MPC_HOME/bin:$PATH' >> $gcc9dir/env.shecho 'export LD_LIBRARY_PATH=$MPC_HOME/lib:$LD_LIBRARY_PATH' >> $gcc9dir/env.shecho 'export INCLUDE=$MPC_HOME/include:$INCLUDE' >> $gcc9dir/env.shecho \"export GCC_HOME=$gcc9dir/gcc-9.3.0/\" >> $gcc9dir/env.shecho 'export PATH=$GCC_HOME/bin:$PATH' >> $gcc9dir/env.shecho 'export LD_LIBRARY_PATH=$GCC_HOME/lib:$GCC_HOME/lib64:$LD_LIBRARY_PATH' >> $gcc9dir/env.shecho 'export INCLUDE=$GCC_HOME/include:$INCLUDE' >> $gcc9dir/env.sh
# gcc-9.3.0 in ~/.bashrc#source /home/yjy/softwares/gcc9/env.shechoecho \"###### Installation completed ! ######\"echo


二、编译安装CP2K-2022.2

(1) 软件本体位于网盘CP2K-2022.2/cp2k-2022.2.tar.bz2,利用如下命令进行解压:

tar -xvf cp2k-2022.2.tar.bz2


(2) 进入解压后的目录并且创建build文件夹:

cd /home/yjy/softwares/cp2k-2022.2/tools/toolchain/mkdir build

然后将网盘下载的CP2K-2022.2/toolchains中的所有工具包复制到 build文件夹里。


(3) 编译部署工具链:

./install_cp2k_toolchain.sh --with-sirius=no --with-openmpi=install --with-plumed=install

会看到如下编译信息:

MPI is detected and it appears to be OpenMPICompiling with 32 processes.==================== Finding GCC from system paths ====================path to gcc is /home/yjy/softwares/gcc9//gcc-9.3.0//bin/gccpath to g++ is /home/yjy/softwares/gcc9//gcc-9.3.0//bin/g++path to gfortran is /home/yjy/softwares/gcc9//gcc-9.3.0//bin/gfortranFound include directory /usr/includeFound lib directory /home/yjy/softwares/gcc9/gcc-9.3.0/lib64Step gcc took 0.00 seconds.Step intel took 0.00 seconds.==================== Getting proc arch info using OpenBLAS tools ====================OpenBLAS-0.3.20.tar.gz is foundOpenBLAS detected LIBCORE = zenOpenBLAS detected ARCH = x86_64==================== Installing CMake ====================cmake-3.22.1-linux-x86_64.sh is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/cmake-3.22.1Step cmake took 1146.00 seconds.==================== Installing OpenMPI ====================openmpi-4.1.1.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1Found directory /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/binFound directory /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/libFound directory /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/includempirun is installed as /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/bin/mpirunmpicc is installed as /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/bin/mpiccmpicxx is installed as /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/bin/mpicxxmpif90 is installed as /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/bin/mpif90Step openmpi took 1490.00 seconds.==================== Installing OpenBLAS ====================OpenBLAS-0.3.20.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openblas-0.3.20Step openblas took 351.00 seconds.==================== Installing FFTW ====================fftw-3.3.10.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/fftw-3.3.10Step fftw took 202.00 seconds.==================== Installing LIBINT ====================libint-v2.6.0-cp2k-lmax-5.tgz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5Step libint took 1553.00 seconds.==================== Installing LIBXC ====================libxc-5.2.3.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxc-5.2.3Step libxc took 251.00 seconds.==================== Installing Libxsmm ====================libxsmm-1.17.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxsmm-1.17Step libxsmm took 81.00 seconds.==================== Installing ScaLAPACK ====================scalapack-2.1.0.tgz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/scalapack-2.1.0Step scalapack took 139.00 seconds.==================== Installing COSMA ====================COSMA-v2.5.1.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/COSMA-2.5.1Step cosma took 75.00 seconds.==================== Installing ELPA ====================elpa-2021.11.002.tar.gz is foundpatching file nvcc_wrapInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/elpa-2021.11.002/cpuStep elpa took 605.00 seconds.Step ptscotch took 0.00 seconds.Step superlu took 1.00 seconds.Step pexsi took 0.00 seconds.Step quip took 0.00 seconds.==================== Installing gsl ====================gsl-2.7.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/gsl-2.7Step gsl took 144.00 seconds.==================== Installing PLUMED ====================plumed-src-2.8.0.tgz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/plumed-2.8.0Step plumed took 225.00 seconds.Step hdf5 took 0.00 seconds.Step libvdwxc took 0.00 seconds.==================== Installing spglib ====================spglib-1.16.2.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/spglib-1.16.2Step spglib took 9.00 seconds.==================== Installing libvori ====================libvori-220621.tar.gz is foundInstalling from scratch into /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libvori-220621Step libvori took 62.00 seconds.Step spfft took 0.00 seconds.Step spla took 0.00 seconds.Step sirius took 0.00 seconds.==================== generating arch files ====================arch files can be found in the /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch subdirectoryWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local.ssmpWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local_static.ssmpWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local.sdbgWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local_coverage.sdbgWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local.psmpWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local.pdbgWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local_static.psmpWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local_warn.psmpWrote /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/local_coverage.pdbg========================== usage =========================Done!Now copy: cp /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/arch/* to the cp2k/arch/ directoryTo use the installed tools and libraries and cp2k versioncompiled with it you will first need to execute at the prompt: source /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/setupTo 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 to adapt them for other compilers.It is possible to use the provided CP2K arch files as guidance.


(4) 编译CP2K本体:

cp ./install/arch/* ../../arch/source ./install/setup && cd ../..make -j 32 ARCH=local VERSION=\"ssmp psmp\"

成功编译完后会有如下信息:

/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/bin/mpif90 -fno-omit-frame-pointer -fopenmp -g -march=native -mtune=native -O3 -funroll-loops -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/include' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openblas-0.3.20/include' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/fftw-3.3.10/include' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/include' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxc-5.2.3/include' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxsmm-1.17/include' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/COSMA-2.5.1/include' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/elpa-2021.11.002/cpu/include/elpa_openmp-2021.11.002/modules' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/elpa-2021.11.002/cpu/include/elpa_openmp-2021.11.002/elpa' -I'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/gsl-2.7/include' -I/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/spglib-1.16.2/include -fbacktrace -ffree-form -fimplicit-none -std=f2008 -Werror=aliasing -Werror=ampersand -Werror=c-binding-type -Werror=intrinsic-shadow -Werror=intrinsics-std -Werror=line-truncation -Werror=tabs -Werror=target-lifetime -Werror=underflow -Werror=unused-but-set-variable -Werror=unused-variable -Werror=unused-dummy-argument -Werror=conversion -Werror=zerotrip -Wno-maybe-uninitialized -Wuninitialized -Wuse-without-only -D__LIBXSMM -D__parallel -D__FFTW3 -D__LIBINT -D__LIBXC -D__SCALAPACK -D__COSMA -D__ELPA -D__GSL -D__PLUMED2 -D__SPGLIB -D__LIBVORI -D__COMPILE_ARCH=\"\"local\"\" -D__COMPILE_DATE=\"\"Fri Nov 11 10:45:51 CST 2022\"\" -D__COMPILE_HOST=\"\"master\"\" -D__COMPILE_REVISION=\"\"git:a95ec40\"\" -D__DATA_DIR=\"\"/home/yjy/softwares/cp2k-2022.2/data\"\" -Wl,--enable-new-dtags -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openmpi-4.1.1/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openblas-0.3.20/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/openblas-0.3.20/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/fftw-3.3.10/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/fftw-3.3.10/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libint-v2.6.0-cp2k-lmax-5/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxc-5.2.3/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxc-5.2.3/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxsmm-1.17/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libxsmm-1.17/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/scalapack-2.1.0/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/scalapack-2.1.0/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/COSMA-2.5.1/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/COSMA-2.5.1/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/elpa-2021.11.002/cpu/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/elpa-2021.11.002/cpu/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/gsl-2.7/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/gsl-2.7/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/plumed-2.8.0/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/plumed-2.8.0/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/spglib-1.16.2/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/spglib-1.16.2/lib' -L'/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libvori-220621/lib' -Wl,-rpath='/home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/libvori-220621/lib' -L/home/yjy/softwares/cp2k-2022.2/lib/local/psmp -o /home/yjy/softwares/cp2k-2022.2/exe/local/cp2k.psmp cp2k.o -lcp2kstart -lcp2kmc -lcp2kswarm -lcp2kmotion -lcp2kthermostat -lcp2kemd -lcp2ktmc -lcp2kmain -lcp2kdbt -lcp2ktas -lcp2kdbm -lcp2kgrid -lcp2kgridcpu -lcp2kgridref -lcp2kgridcommon -ldbcsrarnoldi -ldbcsrx -lcp2kshg_int -lcp2keri_mme -lcp2kminimax -lcp2khfxbase -lcp2ksubsys -lcp2kxc -lcp2kao -lcp2kpw_env -lcp2kinput -lcp2kpw -lcp2kgpu -lcp2kfft -lcp2kfpga -lcp2kfm -lcp2kcommon -lcp2koffload -lcp2kmpiwrap -lcp2kbase -L/home/yjy/softwares/cp2k-2022.2/lib/local/psmp/exts/dbcsr -ldbcsr -lsymspg -lplumed -ldl -lstdc++ -lz -ldl -lgsl -lelpa_openmp -lcosma_prefixed_pxgemm -lcosma -lcosta -lscalapack -lxsmmf -lxsmm -ldl -lpthread -lxcf03 -lxc -lint2 -lfftw3_mpi -lfftw3 -lfftw3_omp -lmpi -lopenblas -lvori -lstdc++ -lstdc++cd /home/yjy/softwares/cp2k-2022.2/exe/local; ln -sf cp2k.psmp cp2k_shell.psmpcd /home/yjy/softwares/cp2k-2022.2/exe/local; ln -sf cp2k.psmp cp2k.popt


(5) 把以下内容加入到~/.bashrc文件里:

#source /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/setupexport PATH=$PATH:/home/yjy/softwares/cp2k-2022.2/exe/local


(6) 利用网盘CP2K-2022.2/test目录下的测试文件进行测试:

source ~/softwares/gcc9/env.shsource /home/yjy/softwares/cp2k-2022.2/tools/toolchain/install/setupmpirun -np 4 cp2k.popt test.inp |tee test.out


(7) 网盘CP2K-2022.2/cp2kmonitor文件是本人编写的监控CP2K几何结构优化输出的脚本,感兴趣的童鞋可以给它加上可执行权限后丢到/home/yjy/softwares/cp2k-2022.2/exe/local目录里使用。具体使用方法参见:

《CP2K几何优化的监控/诊断小脚本-cp2kmonitor》

http://bbs.keinsci.com/thread-28109-1-1.html


电脑