forked from opensbli/environment_and_run_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstallHDF5.sh
executable file
·110 lines (101 loc) · 3.04 KB
/
InstallHDF5.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
#!/bin/bash
##@brief Download, compile and install HDF5 library
##@author Jianping Meng
##@contributors
##@details
function usage {
echo "This script will download, compile and install the HDF library to a specified directory."
echo "./$(basename $0) -h -> showing usage"
echo "./$(basename $0) -v -> Specifying the HDF5 version (e.g., 1.10.1)"
echo "./$(basename $0) -d -> Specifying the directory where the HDF5 to be installed."
echo "./$(basename $0) -f -> Enabling the Fortran support."
echo "./$(basename $0) -s -> Compiling in the sequential mode (note OPS requires the parallel by default if using CMake)."
echo "./$(basename $0) -m -> Specifying the machine type"
echo "Machine type can be: Ubuntu ARCHER2 IRIDIS5 Fedora DAaaS"
echo "If without specifying the machine, the script will assume all dependencies prepared!"
}
optstring="v:d:m:fsh"
HDF5Ver="1.12.1"
Dir="$HOME/HDF5"
Parallel="ON"
Fortran="OFF"
Machine="None"
while getopts ${optstring} options; do
case ${options} in
h)
usage
exit 0
;;
v)
HDF5Ver=${OPTARG}
;;
s)
Parallel="OFF"
;;
f)
Fortran="ON"
;;
d)
Dir=${OPTARG}
;;
m)
Machine=${OPTARG}
;;
:)
echo "$0: Must supply an argument to -$OPTARG." >&2
exit 1
;;
?)
echo "Invalid option: -${OPTARG}."
exit 2
;;
esac
done
if [ $# -eq 0 ]
then
echo "We will install parallel hdf5-${HDF5Ver} to ${Dir} without Fortran support."
fi
if ! grep "CreateOpenSBLIEnv" /proc/$PPID/cmdline
then
if [[ "${Parallel}" == "ON" ]]
then
echo "Depending on the system, we might need to set CC=mpicc to compile in parallel mode."
echo "Typically in a desktop we need to run the script as CC=mpicc ./InstallHDF5.sh"
echo "However, in ARCHER2, we just need to run ./InstallHDF5.sh"
sleep 5
fi
fi
if [ $Machine == "CIRRUS" ]
then
module load nvidia/nvhpc
module load cmake/3.22.1
fi
if [ $Machine == "ARCHER2" ]
then
module purge PrgEnv-cray
module load load-epcc-module
module load cmake/3.21.3
module load PrgEnv-gnu
fi
if [ $Machine == "IRIDIS5" ]
then
module load gcc/6.4.0
module load cmake
fi
MainVer="${HDF5Ver:0:$((${#HDF5Ver}-2))}"
wget -c "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-$MainVer/hdf5-$HDF5Ver/src/CMake-hdf5-$HDF5Ver.tar.gz"
cpus=`lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l`
if [ ${cpus} -gt 12 ]
then
cpus=12
fi
tar -xf "CMake-hdf5-$HDF5Ver.tar.gz"
cd CMake-hdf5-$HDF5Ver/hdf5-${HDF5Ver}
mkdir build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=${Dir} -DCMAKE_BUILD_TYPE=Release -DHDF5_ENABLE_SZIP_SUPPORT=OFF -DHDF5_ENABLE_Z_LIB_SUPPORT=OFF -DHDF5_BUILD_CPP_LIB=OFF -DHDF5_ENABLE_PARALLEL=${Parallel} -DHDF5_BUILD_FORTRAN=${Fortran}
cmake --build . --config Release -j ${cpus}
cmake --install . --config Release
cd ../../../
rm -r -f "CMake-hdf5-$HDF5Ver"
rm -r -f "CMake-hdf5-$HDF5Ver.tar.gz"