forked from dftfeDevelopers/dftfe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupUserPetsc.sh
executable file
·114 lines (92 loc) · 3.38 KB
/
setupUserPetsc.sh
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
# script to setup and build DFT-FE.
set -e
set -o pipefail
if [ -s CMakeLists.txt ]; then
echo "This script must be run from the build directory!"
exit 1
fi
# Path to project source
SRC=`dirname $0` # location of source directory
########################################################################
#Provide paths below for external libraries, compiler options and flags,
# and optimization flag
#Paths for required external libraries
dealiiPetscRealDir="/home/vikramg/DFT-FE-softwares/dealiiDevCustomized/install_gcc8.2.0_openmpi4.0.6_real_cpu"
dealiiPetscComplexDir="/home/vikramg/DFT-FE-softwares/dealiiDevCustomized/install_gcc8.2.0_openmpi4.0.6_complex_cpu"
alglibDir="/home/vikramg/DFT-FE-softwares/alglibGCC/cpp/src"
libxcDir="/home/vikramg/DFT-FE-softwares/libxc/install_libxc5.1.5"
spglibDir="/home/vikramg/DFT-FE-softwares/spglibGCC"
xmlIncludeDir="/usr/include/libxml2"
xmlLibDir="/usr/lib64"
ELPA_PATH="/home/vikramg/DFT-FE-softwares/elpa/elpa2021.05.002_gcc8.2.0_openmpi4.0.6_install"
#Paths for optional external libraries
NCCL_PATH=""
#Toggle GPU compilation
withGPU=OFF
#Option to link to NCCL library (Only for GPU compilation)
withNCCL=OFF
#Compiler options and flags
cxx_compiler=mpicxx
cxx_flagsRelease="-O2 -fPIC -fopenmp"
cuda_flags="" #only applicable for withGPU=ON
#ON is recommended for MD simulations with hard pseudopotentials
withHigherQuadPSP=OFF
#Optmization flag: Release for optimized mode and Debug for debug mode compilation
build_type=Release
testing=OFF
minimal_compile=ON
###########################################################################
#Usually, no changes are needed below this line
#
#if [[ x"$build_type" == x"Release" ]]; then
# c_flags="$c_flagsRelease"
# cxx_flags="$c_flagsRelease"
#else
#fi
out=`echo "$build_type" | tr '[:upper:]' '[:lower:]'`
function cmake_real() {
mkdir -p real && cd real
cmake -DCMAKE_CXX_COMPILER=$cxx_compiler \
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiPetscRealDir \
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
-DXML_INCLUDE_DIR=$xmlIncludeDir \
-DWITH_NCCL=$withNCCL -DCMAKE_PREFIX_PATH="$ELPA_PATH;$NCCL_PATH"\
-DWITH_COMPLEX=OFF -DWITH_GPU=$withGPU -DCMAKE_CUDA_FLAGS="$cuda_flags"\
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile \
-DHIGHERQUAD_PSP=$withHigherQuadPSP\
$1
}
function cmake_cplx() {
mkdir -p complex && cd complex
cmake -DCMAKE_CXX_COMPILER=$cxx_compiler \
-DCMAKE_CXX_FLAGS_RELEASE="$cxx_flagsRelease" \
-DCMAKE_BUILD_TYPE=$build_type -DDEAL_II_DIR=$dealiiPetscComplexDir \
-DALGLIB_DIR=$alglibDir -DLIBXC_DIR=$libxcDir \
-DSPGLIB_DIR=$spglibDir -DXML_LIB_DIR=$xmlLibDir \
-DXML_INCLUDE_DIR=$xmlIncludeDir \
-DCMAKE_PREFIX_PATH="$ELPA_PATH" \
-DWITH_COMPLEX=ON \
-DWITH_TESTING=$testing -DMINIMAL_COMPILE=$minimal_compile \
-DHIGHERQUAD_PSP=$withHigherQuadPSP\
$1
}
RCol='\e[0m'
Blu='\e[0;34m';
if [ -d "$out" ]; then # build directory exists
echo -e "${Blu}$out directory already present${RCol}"
else
rm -rf "$out"
echo -e "${Blu}Creating $out ${RCol}"
mkdir -p "$out"
fi
cd $out
echo -e "${Blu}Building Real executable in $build_type mode...${RCol}"
cmake_real "$SRC" && make -j4
cd ..
echo -e "${Blu}Building Complex executable in $build_type mode...${RCol}"
cmake_cplx "$SRC" && make -j4
cd ..
echo -e "${Blu}Build complete.${RCol}"