-
Notifications
You must be signed in to change notification settings - Fork 3
/
persiansph_install.sh
149 lines (136 loc) · 5.28 KB
/
persiansph_install.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#####################################################################################
# PersianSPH - A C++ library to simulate Mechanical Systems #
# Copyright (C) 2016 Maziar Gholami Korzani and Sergio Galindo-Torres #
# #
# This file is part of PersianSPH #
# #
# PersianSPH is free software; you can redistribute it and/or modify it under the #
# terms of the GNU General Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your option) any later #
# version. #
# #
# PersianSPH is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A #
# PARTICULAR PURPOSE. See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with #
# PersianSPH; if not, write to the Free Software Foundation, Inc., #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #
#####################################################################################
#!/bin/bash
echo ""
#checking git, gfortran, g++ and cmake
for Compulsory_Software in g++ cmake git gfortran
do
command -v $Compulsory_Software >/dev/null &&
echo "$Compulsory_Software has been found." ||
{
echo "$Compulsory_Software is not installed.";
while true; do
read -p "Do you wish to install this program (sudo access required)?(y/n)" yn;
case $yn in
[Yy]* ) sudo apt-get install $Compulsory_Software;
command -v $Compulsory_Software >/dev/null || { echo "You do not have sudo access."; exit; }
break;;
[Nn]* ) echo "$Compulsory_Software is compulsory to install PersianSPH code."; exit;;
* ) echo "Please answer yes or no.";;
esac
done
}
done
echo ""
#using the current directory as the main installation directory
Current_Address=$(pwd)
#copying the code on this pc
if [ -d "$Current_Address/persiansph" ]; then
echo "PersianSPH code directory already exists at $Current_Address/persiansph"
while true; do
read -p "Do you wish to remove it?(y/n)" yn;
case $yn in
[Yy]* ) rm -rf $Current_Address/persiansph;
echo "... Downloading PersianSPH code ..."
git clone https://github.com/mghkorzani/persiansph.git
break;;
[Nn]* ) echo "It is probably an older copy of PersianSPH code on this PC!!!"; break;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "... Downloading PersianSPH code ..."
git clone https://github.com/mghkorzani/persiansph.git
fi
#setting a permanent environmental variable for the main code
if [ $SPH!="$Current_Address/persiansph" ]; then
SPH_Address=""
else
SPH_Address=$SPH
fi
if [ -z "${SPH_Address}" ]; then
echo "Creating an environment variable for the path of the SPH code as \$SPH"
echo "export SPH=$Current_Address/persiansph" >> $HOME/.bashrc
SPH_Address="$Current_Address/persiansph"
source $HOME/.bashrc
fi
echo ""
#copying packages on this pc
if [ -d "$Current_Address/persiansph-lib" ]; then
echo "Libraries' directory already exists at $Current_Address/persiansph-lib"
while true; do
read -p "Do you wish to remove it?(y/n)" yn;
case $yn in
[Yy]* ) rm -rf $Current_Address/persiansph-lib;
echo "... Downloading required libraries ..."
git clone https://github.com/mghkorzani/persiansph-lib.git
break;;
[Nn]* ) echo "These are probably older copies of required libraries on this PC!!!"; break;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "... Downloading required libraries ..."
git clone https://github.com/mghkorzani/persiansph-lib.git
fi
#setting a permanent environmental variable for the packages
if [ $PKG!="$Current_Address/persiansph-lib" ]; then
PKG_Address=""
else
PKG_Address=$PKG
fi
if [ -z "${PKG_Address}" ]; then
echo "Creating an environment variable for the path of required packages as \$PKG"
echo "export PKG=$Current_Address/persiansph-lib" >> $HOME/.bashrc
PKG_Address="$Current_Address/persiansph-lib"
source $HOME/.bashrc
fi
echo ""
#installing libraries
echo "... Installing libraries ..."
cd $PKG_Address
tar -xzf blitz-0.9.tar.gz
tar -xzf hdf5-1.8.16.tar.gz;
tar -xzf gsl-2.1.tar.gz;
tar -xzf lapack-3.5.0.tgz;
rm -f blitz-0.9.tar.gz
rm -f hdf5-1.8.16.tar.gz;
rm -f gsl-2.1.tar.gz;
rm -f lapack-3.5.0.tgz;
echo "... Compiling libraries ...";
read -p "It takes a few minutes, press any key to continue ..."
cd $PKG_Address/hdf5-1.8.16;
./configure;
make;
cd $PKG_Address/gsl-2.1;
./configure;
make;
cd $PKG_Address/lapack-3.5.0;
cmake .;
make;
sudo apt-get install liblapack-dev
sudo apt-get install libblas-dev
echo ""
echo ""
echo "Installation is completed."
echo "Close all terminal windows and open a new one to take effect the defined environment variables"
echo "Please refer to the tutorial to run a simulation."
echo ""
echo ""