后记

重新安装了Rocky Linux10,并安装了Slurm作业系统,尝试编译安装vasp,由于用的Rocky10,gcc等各种套件都比较新,折腾麻了,各种编译报错,干脆换到了较新的vasp.6.5.1版本,一遍过!

编译HDF5

编译HDF5部分内容参考了教程:https://zhuanlan.zhihu.com/p/617261007

编译安装HDF5之前需要先编译安装它的依赖zlib😂,首先去官网https://www.zlib.net/,目前最新的的版本是zlib 1.3.1,下载源代码source code,哪种格式的都行,我的工作站有网就直接用wget了:

1
wget https://www.zlib.net/zlib-1.3.1.tar.gz

没网的集群自己下载到本地计算机再上传到集群上。

解压、配置、编译、测试、安装:

1
tar -zxvf zlib-1.3.1.tar.gz
1
./configure --prefix=install_directory
1
make -jN
1
make test
1
make install

接下来安装szip,官网(https://docs.hdfgroup.org/archive/support/doc_resource/SZIP/index.html)同样只提供了源代码,需要编译安装,安装过程大差不差,类似的

接下来编译安装HDF5,官网打开比较慢、、、目前最新版本是1.14.6,使用1.14.5版本编译成功

1
wget https://support.hdfgroup.org/releases/hdf5/v1_14/v1_14_6/downloads/hdf5-1.14.6.tar.gz
1
tar -zxvf hdf5-1.14.6.tar.gz

接下来是配置,需要使用intel的编译器,所有首先需要安装intel的oneapi套件,安装下面这些:

intel的C++编译器,部分组件会捆绑其他组件
intel的fortran编译器

需要格外注意,我是用的是最新版的oneapi套件,已经删除了对iccifort的支持,所以需要注意CCFCCXX的写法

1
2
3
4
5
6
7
8
9
./configure --prefix=/opt/apps/vasp.6.5.1/hdf5/hdf5 \
--enable-fortran \
--with-zlib=/opt/apps/vasp.6.5.1/hdf5/dependences/zlib \
--with-szlib=/opt/apps/vasp.6.5.1/hdf5/dependencies/szip \
--enable-shared \
--enable-parallel \
CC=mpiicx \
FC=mpiifx \
CXX=mpiicpx

接着编译、测试、安装

1
make -jN
1
make check
1
make install

Wannier安装

接下来编译安装Wannier90,官网是https://wannier.org/download/,下载:

1
wget https://github.com/wannier-developers/wannier90/archive/v3.1.0.tar.gz

然后是解压,接着拷贝config文件夹中的模板:

1
cp config/make.inc.ifort make.inc

Wannier90的模板并没有调整,依然使用的ifort,然鹅Intel已经废弃了ifort,所以得手动修改一下模板了,把ifort改成ifx,依此类推,改完后的模板如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
root@cernet2:~/Wannier90/wannier90-3.1.0# cat make.inc 

#=====================================================
# For Linux with intel version 11/12 on 64bit machines
#=====================================================
F90 = ifx
COMMS=mpi
MPIF90=mpiifx
FCOPTS=-O2
LDOPTS=-O2

#========================================================
# Intel mkl libraries. Set LIBPATH if not in default path
#========================================================

LIBDIR = /opt/intel/mkl/lib/intel64
LIBS = -L$(LIBDIR) -lmkl_core -lmkl_intel_lp64 -lmkl_sequential -lpthread

#=======================
# ATLAS Blas and LAPACK
#=======================
#LIBDIR = /usr/local/lib
#LIBS = -L$(LIBDIR) -llapack -lf77blas -lcblas -latlas

接着编译吧:

1
make -jN

再编译库:

1
make lib -jN

最终,得到了两个重要的文件:wannier90.xlibwannier.a,记住这两个文件所在的目录,

VTST的安装

VTST,是一个”插件“,随着vasp的编译而安装,首先下载VTST

1
wget https://theory.cm.utexas.edu/code/vtstcode-209.tgz

参考官网的安装过程,需要修改源代码,谨慎且小麻烦,https://theory.cm.utexas.edu/vtsttools/installation.html

按照教程修改vasp的main.F源代码,源代码都在src目录内

修改main.F,记得备份源码
修改main.F,记得备份源码

接着将VTST文件夹下的所有源码文件复制到vasp的源码文件夹内,此时会覆盖掉chain.F

然后修改.object

修改.object,记得备份

接着修改源码目录内的makefile文件,将其中的某一行由:

1
LIB=lib parser

修改为:

1
LIB= lib parser pyamff_fortran

我编译vasp时为了加快编译速度,需要并行编译,因此也需要将:

1
dependencies: sources

修改为:

1
dependencies: sources libs

至此,VTST需要做的已经完成了,开始编译vasp吧~~

编译vasp

使用makefile.include.oneapi这个模板,这个模板已经适配了新版的intel套件,只需要修改hdf5wannier90这两个地方就行,本次编译使用了比较激进的方案,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxIFC\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Dtbdyn \
-Dfock_dblbuf

CPP = fpp -f_com=no -free -w0 $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)

FC = mpiifort -fc=ifx
FCL = mpiifort -fc=ifx

FREE = -free -names lowercase

FFLAGS = -assume byterecl -w

OFLAG = -O3 -xHost -unroll-aggressive #激进的方案
OFLAG_IN = $(OFLAG)
DEBUG = -O0

# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = icx
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)

OBJECTS_LIB = linpack_double.o

# For the parser library
CXX_PARS = icpx
LLIBS = -lstdc++

##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##

# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -xHOST
FFLAGS += $(VASP_TARGET_CPU)

# Intel MKL (FFTW, BLAS, LAPACK, and scaLAPACK)
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL += -qmkl=parallel
MKLROOT ?= /path/to/your/mkl/installation
LLIBS += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS =-I$(MKLROOT)/include/fftw

MKL_THREADING_LAYER=INTEL
OMP_NUM_THREADS=1 # MPI+MKL 并行时必须绑 1,否则容易 oversubscribe

# HDF5-support (optional but strongly recommended, and mandatory for some features)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /opt/apps/vasp.6.5.1/hdf5/hdf5
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include

# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /opt/apps/vasp.6.5.1/wannier90-3.1.0
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier

# For machine learning library vaspml (experimental)
#CPP_OPTIONS += -Dlibvaspml
#CPP_OPTIONS += -DVASPML_USE_CBLAS
#CPP_OPTIONS += -DVASPML_USE_MKL
#CPP_OPTIONS += -DVASPML_DEBUG_LEVEL=3
#CXX_ML = mpiicpc -cxx=icpx
#CXXFLAGS_ML = -O3 -std=c++17 -Wall
#INCLUDE_ML =
1
make DEPS=1 -jN

笔者用的双路2676 v3的落后的工作站,因为调用了24个核心并行编译所以比较快,编译时间大概是四五分钟

接着是测试,make test默认调用4个核心,可以编辑runtest文件手动修改核心数目加快测试速度,关于测试的说明在官网:https://www.vasp.at/wiki/Validation_tests

我自己测试时需要手动加上hdf5库的环境变量,否则一个测试也跑不了:

1
export LD_LIBRARY_PATH=/opt/apps/vasp.6.5.1/hdf5/hdf5/lib:$LD_LIBRARY_PATH

对了,为了避免任何关于内存栈的错误,也请执行下面四行命令(从集群slurm脚本抄的)

1
2
3
4
ulimit -d unlimited
ulimit -s unlimited
ulimit -t unlimited
ulimit -v unlimited

./install_cp2k_toolchain.sh –with-sirius=no –with-intelmpi=system –with-mkl=system –with-openmpi=no –with-plumed=install –with-cmake=system –with-ninja=install –with-dftd4=install

cp2k的dftd4库和ninja库参考公社上的文件,http://bbs.keinsci.com/forum.php?mod=viewthread&tid=55624&highlight=dftd4