v0.15.0
Loading...
Searching...
No Matches
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# https://mofem.eng.gla.ac.uk/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
16echo "Start time: $(date +"%T")"
17
18##############################
19# INITIALISATION
20##############################
21
22# Setup installation directory
23pwd
24export MOFEM_INSTALL_DIR="$PWD/mofem_install"
25mkdir -p $MOFEM_INSTALL_DIR
26
27# Check operating system
28unameOut="$(uname -s)"
29case "${unameOut}" in
30 Linux*) machine=Linux;;
31 Darwin*) machine=Mac;;
32 CYGWIN*) machine=Cygwin;;
33 MINGW*) machine=MinGw;;
34 *) machine="UNKNOWN:${unameOut}"
35esac
36
37##############################
38### PREREQUISITES
39##############################
40
41echo -e "\n****************************\nInstalling PREREQUISITES...\n****************************\n"
42echo "User password can be asked at some point. Please wait..."
43
44# Install appropriate prerequisite packages
45if [ ${machine} = "Linux" ]
46then
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
67elif [ ${machine} = "Mac" ]
68then
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
103fi
104
105echo -e "\nFinished installing Prerequisites.\n"
106echo -e "\nNo user password will be asked from now on.\n"
107
108echo "Current directory: $PWD"
109
110##############################
111### SPACK
112##############################
113
114echo -e "\n****************************\nInstalling SPACK...\n****************************\n"
115
116# Locate home directory
117cd $MOFEM_INSTALL_DIR
118echo "$PWD"
119
120SPACK_ROOT_DIR=$MOFEM_INSTALL_DIR/spack
121
122# Retrieve Spack for MoFEM
123if [ ! -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
150else
151 . $SPACK_ROOT_DIR/share/spack/setup-env.sh
152 spack external find
153fi
154
155echo -e "\nFinished installing Spack.\n"
156
157echo "Current directory: $PWD"
158
159########################################
160### MoFEM CORE LIBRARY & USER MODULES
161########################################
162
163echo -e "\n********************************************************\n"
164echo -e "Installing CORE LIBRARY - Release version ..."
165echo -e "\n********************************************************\n"
166
167# Locate MoFEM installation directory
168cd $MOFEM_INSTALL_DIR
169echo "Current directory: $PWD"
170
171# Clone MoFEM core library
172if [ ! -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
175lse
176 echo -e "\nMoFEM source directory is found"
177fi
178
179# Installation of core library
180cd $MOFEM_INSTALL_DIR
181
182echo -e "\n----------------------------\n"
183echo -e "CORE LIBRARY - Install depenencies ..."
184echo -e "\n----------------------------\n"
185
186spack 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
190echo -e "\n----------------------------\n"
191echo -e "CORE LIBRARY - Release version ..."
192echo -e "\n----------------------------\n"
193
194spack 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
201echo -e "\n********************************************************\n"
202echo -e "Installing USER MODULES - Release version ..."
203echo -e "\n********************************************************\n"
204
205# Get mofem-cephas spack hash for release version
206TODAY=`date +%F`
207MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep RelWithDebInfo | awk '{print $1}'`
208echo "mofem-cephas id for release: $MOFEM_CEPHAS_HASH"
209
210hash=$(spack find -v mofem-cephas@develop build_type=RelWithDebInfo | grep mofem-cephas@develop)
211spack 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
217TODAY=`date +%F`
218MOFEM_UN_HASH=`spack find -lv --start-date $TODAY | grep mofem-users-modulesdevelop | grep RelWithDebInfo | awk '{print $1}'`
219echo "mofem-users-modules id for release: $MOFEM_UN_HASH"
220
221# ************************************************************************
222# DEBUG VERSION
223# ************************************************************************
224
225echo -e "\n********************************************************\n"
226echo -e "Installing MoFEM - DEBUG VERSION..."
227echo -e "\n********************************************************\n"
228
229
230########################################
231### MoFEM CORE LIBRARY & USER MODULES
232########################################
233
234echo -e "\n----------------------------\n"
235echo -e "CORE LIBRARY - Debug version ..."
236echo -e "\n----------------------------\n"
237
238spack 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
245echo -e "\n********************************************************\n"
246echo -e "Installing USER MODULES - Debug version ..."
247echo -e "\n********************************************************\n"
248
249# Get mofem-cephas spack hash for debug version
250TODAY=`date +%F`
251MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep Debug | awk '{print $1}'`
252echo "mofem-cephas id for debug: $MOFEM_CEPHAS_HASH"
253
254echo -e "\n----------------------------\n"
255echo -e "USER MODULE - Debug version ..."
256echo -e "\n----------------------------\n"
257
258hash=$(spack find -v mofem-cephas@develop build_type=Debug | grep mofem-cephas@develop)
259spack 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
265TODAY=`date +%F`
266MOFEM_UN_HASH=`spack find -lv --start-date $TODAY | grep mofem-users-modulesdevelop | grep Debug | awk '{print $1}'`
267echo "mofem-users-modules id for debug: $MOFEM_UN_HASH"
268
269echo -e "\nFinished installing and testing the User Module - Debug version.\n"
270cd $MOFEM_INSTALL_DIR
271
272echo "End time: $(date +"%T")"