v0.14.0
install_mofem_developer.sh
Go to the documentation of this file.
1 #!/bin/bash
2 # This script automises installation of MoFEM developer version: Release & Debug
3 # Full description of the installation process using spack can be found at:
4 # http://mofem.eng.gla.ac.uk/mofem/html/install_spack.html
5 # The script should work for both Ubuntu and macOS platforms
6 # The last known working platforms are Ubuntu (18.04) and macOS (10.13, 10.14)
7 # The installation may take two to three hours
8 #
9 # Usage:
10 # 1. Copy install_mofem_developer.sh to the directory where MoFEM will be installed
11 # 2. Run install_mofem_developer.sh from the command line
12 #
13 # Note: Installation script changes .bashrc on Ubuntu or .bash_profile on Mac.
14 # Please inspect the file after installation.
15 
16 echo "Start time: $(date +"%T")"
17 
18 ##############################
19 # INITIALISATION
20 ##############################
21 
22 # Setup installation directory
23 pwd
24 export MOFEM_INSTALL_DIR="$PWD/mofem_install"
25 mkdir -p $MOFEM_INSTALL_DIR
26 
27 # Check operating system
28 unameOut="$(uname -s)"
29 case "${unameOut}" in
30  Linux*) machine=Linux;;
31  Darwin*) machine=Mac;;
32  CYGWIN*) machine=Cygwin;;
33  MINGW*) machine=MinGw;;
34  *) machine="UNKNOWN:${unameOut}"
35 esac
36 
37 ##############################
38 ### PREREQUISITES
39 ##############################
40 
41 echo -e "\n****************************\nInstalling PREREQUISITES...\n****************************\n"
42 echo "User password can be asked at some point. Please wait..."
43 
44 # Install appropriate prerequisite packages
45 if [ ${machine} = "Linux" ]
46 then
47  echo -e "\nRunning in Linux\n"
48  sudo apt-get update \
49  && sudo apt-get install -y --no-install-recommends \
50  autoconf \
51  build-essential \
52  ca-certificates \
53  coreutils \
54  curl \
55  environment-modules \
56  pkgconf \
57  cmake \
58  git \
59  python3 \
60  python3-dev \
61  python3-distutils \
62  unzip \
63  ssh \
64  vim \
65  gfortran
66 
67 elif [ ${machine} = "Mac" ]
68 then
69  echo -e "\nRunning in macOS\n"
70 
71  # Install Xcode
72  if ! which 'brew' &>/dev/null
73  then
74  xcode-select --install
75  sudo xcodebuild -license accept
76  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
77  else
78  echo -e "\nHomebrew is already installed."
79  fi
80 
81  brew install \
82  curl \
83  git \
84  python \
85  gcc@9 \
86  cmake \
87  autoconf \
88  automake \
89  libtool \
90  doxygen \
91  pkg-config
92 
93  # Install XQuartz
94  if ! which 'xquartz' &>/dev/null
95  then
96  xcode-select --install
97  sudo xcodebuild -license accept
98  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebreinstall/HEAD/install.sh)"
99  else
100  echo -e "\nXQuartz is already installed.\n"
101  fi
102 
103 fi
104 
105 echo -e "\nFinished installing Prerequisites.\n"
106 echo -e "\nNo user password will be asked from now on.\n"
107 
108 echo "Current directory: $PWD"
109 
110 ##############################
111 ### SPACK
112 ##############################
113 
114 echo -e "\n****************************\nInstalling SPACK...\n****************************\n"
115 
116 # Locate home directory
117 cd $MOFEM_INSTALL_DIR
118 echo "$PWD"
119 
120 SPACK_ROOT_DIR=$MOFEM_INSTALL_DIR/spack
121 
122 # Retrieve Spack for MoFEM
123 if [ ! -d "$SPACK_ROOT_DIR" ]; then
124 
125  # Remove .spack directory in $HOME from previous installation (if any)
126  if [ -d "$HOME/.spack" ]; then
127  mv $HOME/.spack $HOME/.spack_old
128  fi
129 
130  echo "Cloning spack ..."
131  git clone -b Workshop23 https://bitbucket.org/mofem/mofem-spack.git spack
132  echo -e "Done.\n"
133 
134  # Initialise Spack environment variables:
135  . $SPACK_ROOT_DIR/share/spack/setup-env.sh
136  # Add command to configuration file .bashrc on Ubuntu or .bash_profile on Mac
137  if [ ${machine} = "Linux" ]
138  then
139  echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bashrc
140  elif [ ${machine} = "Mac" ]
141  then
142  echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bash_profile
143  echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.zshrc
144  fi
145 
146  # Install packages required by Spack
147  spack compiler find
148  spack external find
149 
150 else
151  . $SPACK_ROOT_DIR/share/spack/setup-env.sh
152  spack external find
153 fi
154 
155 echo -e "\nFinished installing Spack.\n"
156 
157 echo "Current directory: $PWD"
158 
159 ########################################
160 ### MoFEM CORE LIBRARY & USER MODULES
161 ########################################
162 
163 echo -e "\n********************************************************\n"
164 echo -e "Installing CORE LIBRARY - Release version ..."
165 echo -e "\n********************************************************\n"
166 
167 # Locate MoFEM installation directory
168 cd $MOFEM_INSTALL_DIR
169 echo "Current directory: $PWD"
170 
171 # Clone MoFEM core library
172 if [ ! -d "$PWD/mofem-cephas" ]; then
173  git clone -b develop https://bitbucket.org/likask/mofem-cephas.git mofem-cephas
174  git clone -b develop https://likask@bitbucket.org/mofem/users-modules-cephas.git mofem-cephas/mofem/users_modules
175 lse
176  echo -e "\nMoFEM source directory is found"
177 fi
178 
179 # Installation of core library
180 cd $MOFEM_INSTALL_DIR
181 
182 echo -e "\n----------------------------\n"
183 echo -e "CORE LIBRARY - Install depenencies ..."
184 echo -e "\n----------------------------\n"
185 
186 spack install --only dependencies \
187  mofem-cephas@develop+adol-c~copy_user_modules+docker~ipo+med+mgis~shared+slepc+tetgen \
188  build_type=RelWithDebInfo install_id=0 ^petsc+X ^boost+python+numpy
189 
190 echo -e "\n----------------------------\n"
191 echo -e "CORE LIBRARY - Release version ..."
192 echo -e "\n----------------------------\n"
193 
194 spack dev-build \
195  --source-path $MOFEM_INSTALL_DIR/mofem-cephas \
196  --keep-prefix \
197  --test root \
198  mofem-cephas@develop+adol-c~copy_user_modules+docker~ipo+med+mgis~shared+slepc+tewtgen \
199  build_type=RelWithDebInfo install_id=0 ^petsc+X ^boost+python+numpy
200 
201 echo -e "\n********************************************************\n"
202 echo -e "Installing USER MODULES - Release version ..."
203 echo -e "\n********************************************************\n"
204 
205 # Get mofem-cephas spack hash for release version
206 TODAY=`date +%F`
207 MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep RelWithDebInfo | awk '{print $1}'`
208 echo "mofem-cephas id for release: $MOFEM_CEPHAS_HASH"
209 
210 hash=$(spack find -v mofem-cephas@develop build_type=RelWithDebInfo | grep mofem-cephas@develop)
211 spack dev-build \
212  --test root \
213  --source-path $MOFEM_INSTALL_DIR/mofem-cephas/mofem/users_modules \
214  mofem-users-modules@develop build_type=RelWithDebInfo \
215  ^$hash ^petsc+X ^boost+python+numpy
216 
217 TODAY=`date +%F`
218 MOFEM_UN_HASH=`spack find -lv --start-date $TODAY | grep mofem-users-modulesdevelop | grep RelWithDebInfo | awk '{print $1}'`
219 echo "mofem-users-modules id for release: $MOFEM_UN_HASH"
220 
221 # ************************************************************************
222 # DEBUG VERSION
223 # ************************************************************************
224 
225 echo -e "\n********************************************************\n"
226 echo -e "Installing MoFEM - DEBUG VERSION..."
227 echo -e "\n********************************************************\n"
228 
229 
230 ########################################
231 ### MoFEM CORE LIBRARY & USER MODULES
232 ########################################
233 
234 echo -e "\n----------------------------\n"
235 echo -e "CORE LIBRARY - Debug version ..."
236 echo -e "\n----------------------------\n"
237 
238 spack dev-build \
239  --source-path $MOFEM_INSTALL_DIR/mofem-cephas \
240  --keep-prefix \
241  --test root \
242  mofem-cephas@develop+adol-c~copy_user_modules+docker~ipo+med+mgis~shared+slepc+tetgen \
243  build_type=Debug install_id=0 ^petsc+X ^boost+python+numpy
244 
245 echo -e "\n********************************************************\n"
246 echo -e "Installing USER MODULES - Debug version ..."
247 echo -e "\n********************************************************\n"
248 
249 # Get mofem-cephas spack hash for debug version
250 TODAY=`date +%F`
251 MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep Debug | awk '{print $1}'`
252 echo "mofem-cephas id for debug: $MOFEM_CEPHAS_HASH"
253 
254 echo -e "\n----------------------------\n"
255 echo -e "USER MODULE - Debug version ..."
256 echo -e "\n----------------------------\n"
257 
258 hash=$(spack find -v mofem-cephas@develop build_type=Debug | grep mofem-cephas@develop)
259 spack dev-build \
260  --test root \
261  --source-path $MOFEM_INSTALL_DIR/mofem-cephas/mofem/users_modules \
262  mofem-users-modules@develop build_type=Debug \
263  ^$hash ^petsc+X ^boost+python+numpy
264 
265 TODAY=`date +%F`
266 MOFEM_UN_HASH=`spack find -lv --start-date $TODAY | grep mofem-users-modulesdevelop | grep Debug | awk '{print $1}'`
267 echo "mofem-users-modules id for debug: $MOFEM_UN_HASH"
268 
269 echo -e "\nFinished installing and testing the User Module - Debug version.\n"
270 cd $MOFEM_INSTALL_DIR
271 
272 echo "End time: $(date +"%T")"