-
Notifications
You must be signed in to change notification settings - Fork 0
/
prereq.sh
executable file
·79 lines (61 loc) · 4.19 KB
/
prereq.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
#!/bin/bash
set -e
# install required ubuntu packages using apt
sudo apt update
sudo apt install -y python curl unzip
sudo apt install -y hwloc sysstat
sudo apt install -y build-essential g++ gfortran libreadline-dev m4 xsltproc
sudo apt install -y mpich libmpich-dev
box_out "Ubuntu package installation OK"
# create installation directories
if [[ ! -d $BASE_DIR ]]; then
sudo mkdir -p $BASE_DIR
fi
sudo mkdir -p $SIESTA_DIR $OPENBLAS_DIR $SCALAPACK_DIR
sudo chmod -R 777 $SIESTA_DIR $OPENBLAS_DIR $SCALAPACK_DIR
box_out "Created target directories..."
# download and extract requried source files
# download and extract OpenBLAS source files
cd $OPENBLAS_DIR
curl -kLo OpenBLAS.tar.gz --progress-bar https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.3/OpenBLAS-0.3.3.tar.gz
tar xzf OpenBLAS.tar.gz && rm OpenBLAS.tar.gz
# download and extract Siesta source
cd $SIESTA_DIR
curl -kLo "siesta-$SIESTA_FULL_VERSION.tar.gz" --progress-bar "https://launchpad.net/siesta/$SIESTA_PART_VERSION/$SIESTA_FULL_VERSION/+download/siesta-$SIESTA_FULL_VERSION.tar.gz"
tar xzf "siesta-$SIESTA_FULL_VERSION.tar.gz" && rm "siesta-$SIESTA_FULL_VERSION.tar.gz"
box_out "Downloaded dependent packages..."
# read versions of flook, zlib, hdf5, netcdf-c and netcdf-fortran
FLOOK_VERSION=$(cat "$SIESTA_DIR/siesta-$SIESTA_FULL_VERSION/Docs/install_flook.bash" | grep f_v= | cut -d'=' -f 2)
ZLIB_VERSION=$(cat "$SIESTA_DIR/siesta-$SIESTA_FULL_VERSION/Docs/install_netcdf4.bash" | grep z_v= | cut -d'=' -f 2)
HDF_FULL_VERSION=$(cat "$SIESTA_DIR/siesta-$SIESTA_FULL_VERSION/Docs/install_netcdf4.bash" | grep h_v= | cut -d'=' -f 2)
HDF_PART_VERSION=$(echo $HDF_FULL_VERSION | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')
NC_VERSION=$(cat "$SIESTA_DIR/siesta-$SIESTA_FULL_VERSION/Docs/install_netcdf4.bash" | grep nc_v= | cut -d'=' -f 2)
NF_VERSION=$(cat "$SIESTA_DIR/siesta-$SIESTA_FULL_VERSION/Docs/install_netcdf4.bash" | grep nf_v= | cut -d'=' -f 2)
box_out "Going to install the following libraries:" "+FLOOK v$FLOOK_VERSION" "+ZLIB v$ZLIB_VERSION" "+HDF5 v$HDF_FULL_VERSION" "+NETCDF_C v$NC_VERSION" "+NETCDF_FORTRAN v$NF_VERSION"
# download Siesta dependencies
cd "$SIESTA_DIR/siesta-$SIESTA_FULL_VERSION/Docs"
curl -kLo "flook-$FLOOK_VERSION.tar.gz" --progress-bar "https://github.com/ElectronicStructureLibrary/flook/releases/download/v$FLOOK_VERSION/flook-$FLOOK_VERSION.tar.gz"
curl -kLo "zlib-$ZLIB_VERSION.tar.gz" --progress-bar "https://github.com/madler/zlib/archive/refs/tags/v$ZLIB_VERSION.tar.gz"
curl -kLo "hdf5-$HDF_FULL_VERSION.tar.bz2" --progress-bar "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-$HDF_PART_VERSION/hdf5-$HDF_FULL_VERSION/src/hdf5-$HDF_FULL_VERSION.tar.bz2"
curl -kLo "netcdf-c-$NC_VERSION.tar.gz" --progress-bar "https://github.com/Unidata/netcdf-c/archive/v$NC_VERSION.tar.gz"
curl -kLo "netcdf-fortran-$NF_VERSION.tar.gz" --progress-bar "https://github.com/Unidata/netcdf-fortran/archive/v$NF_VERSION.tar.gz"
box_out "Downloaded package files..."
# install OpenBLAS
cd $OPENBLAS_DIR/OpenBLAS-0.3.3
make DYNAMIC_ARCH=0 CC=gcc FC=gfortran HOSTCC=gcc BINARY=64 INTERFACE=64 NO_AFFINITY=1 NO_WARMUP=1 USE_OPENMP=0 USE_THREAD=0 LIBNAMESUFFIX=nonthreaded > blas1.log 2>&1
make PREFIX=$OPENBLAS_DIR LIBNAMESUFFIX=nonthreaded install > ../blas2.log 2>&1
#cd $OPENBLAS_DIR && rm -rf "$(find $OPENBLAS_DIR -maxdepth 1 -type d -name xianyi-OpenBLAS*)"
box_out "Installed OpenBLAS..."
# install ScaLAPACK
cd $SCALAPACK_DIR
cp $CURRENT_DIR/scalapack_installer.zip ./
unzip scalapack_installer.zip
cd scalapack_installer
./setup.py --prefix $SCALAPACK_DIR --blaslib=$OPENBLAS_DIR/lib/libopenblas_nonthreaded.a --lapacklib=$OPENBLAS_DIR/lib/libopenblas_nonthreaded.a --mpibindir=/usr/bin --mpiincdir=/usr/lib/mpich/include > scalapack.log 2>&1
box_out "Installed ScaLapack..."
# install Siesta dependencies
cd "$SIESTA_DIR/siesta-$SIESTA_FULL_VERSION/Docs"
./install_flook.bash > install_flook.log 2>&1
./install_netcdf4.bash > install_netcdf4.log 2>&1
box_out "Prerequisite Installation OK" "" "Installed the following libraries:" "+OpenBLAS v0.3.3" "+ScaLAPACK v$SCALAPACK_VERSION" "+FLOOK v$FLOOK_VERSION" "+ZLIB v$ZLIB_VERSION" "+HDF5 v$HDF_FULL_VERSION" "+NETCDF_C v$NC_VERSION" "+NETCDF_FORTRAN v$NF_VERSION"
read -p "Press Enter to continue..."