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
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
13# Note: Installation script changes .bashrc on Ubuntu or .bash_profile on Mac.
14# Please inspect the file after installation.
16echo "Start time: $(date +"%T")"
18##############################
20##############################
22# Setup installation directory
24export MOFEM_INSTALL_DIR="$PWD/mofem_install"
25mkdir -p $MOFEM_INSTALL_DIR
27# Check operating system
30 Linux*) machine=Linux;;
31 Darwin*) machine=Mac;;
32 CYGWIN*) machine=Cygwin;;
33 MINGW*) machine=MinGw;;
34 *) machine="UNKNOWN:${unameOut}"
37##############################
39##############################
41echo -e "\n****************************\nInstalling PREREQUISITES...\n****************************\n"
42echo "User password can be asked at some point. Please wait..."
44# Install appropriate prerequisite packages
45if [ ${machine} = "Linux" ]
47 echo -e "\nRunning in Linux\n"
49 && sudo apt-get install -y --no-install-recommends \
67elif [ ${machine} = "Mac" ]
69 echo -e "\nRunning in macOS\n"
72 if ! which 'brew' &>/dev/null
74 xcode-select --install
75 sudo xcodebuild -license accept
76 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
78 echo -e "\nHomebrew is already installed."
94 if ! which 'xquartz' &>/dev/null
96 xcode-select --install
97 sudo xcodebuild -license accept
98 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebreinstall/HEAD/install.sh)"
100 echo -e "\nXQuartz is already installed.\n"
105echo -e "\nFinished installing Prerequisites.\n"
106echo -e "\nNo user password will be asked from now on.\n"
108echo "Current directory: $PWD"
110##############################
112##############################
114echo -e "\n****************************\nInstalling SPACK...\n****************************\n"
116# Locate home directory
120SPACK_ROOT_DIR=$MOFEM_INSTALL_DIR/spack
122# Retrieve Spack for MoFEM
123if [ ! -d "$SPACK_ROOT_DIR" ]; then
125 # Remove .spack directory in $HOME from previous installation (if any)
126 if [ -d "$HOME/.spack" ]; then
127 mv $HOME/.spack $HOME/.spack_old
130 echo "Cloning spack ..."
131 git clone -b Workshop23 https://bitbucket.org/mofem/mofem-spack.git spack
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" ]
139 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bashrc
140 elif [ ${machine} = "Mac" ]
142 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bash_profile
143 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.zshrc
146 # Install packages required by Spack
151 . $SPACK_ROOT_DIR/share/spack/setup-env.sh
155echo -e "\nFinished installing Spack.\n"
157echo "Current directory: $PWD"
159########################################
160### MoFEM CORE LIBRARY & USER MODULES
161########################################
163echo -e "\n********************************************************\n"
164echo -e "Installing CORE LIBRARY - Release version ..."
165echo -e "\n********************************************************\n"
167# Locate MoFEM installation directory
169echo "Current directory: $PWD"
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
176 echo -e "\nMoFEM source directory is found"
179# Installation of core library
182echo -e "\n----------------------------\n"
183echo -e "CORE LIBRARY - Install depenencies ..."
184echo -e "\n----------------------------\n"
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
190echo -e "\n----------------------------\n"
191echo -e "CORE LIBRARY - Release version ..."
192echo -e "\n----------------------------\n"
195 --source-path $MOFEM_INSTALL_DIR/mofem-cephas \
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
201echo -e "\n********************************************************\n"
202echo -e "Installing USER MODULES - Release version ..."
203echo -e "\n********************************************************\n"
205# Get mofem-cephas spack hash for release version
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"
210hash=$(spack find -v mofem-cephas@develop build_type=RelWithDebInfo | grep mofem-cephas@develop)
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
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"
221# ************************************************************************
223# ************************************************************************
225echo -e "\n********************************************************\n"
226echo -e "Installing MoFEM - DEBUG VERSION..."
227echo -e "\n********************************************************\n"
230########################################
231### MoFEM CORE LIBRARY & USER MODULES
232########################################
234echo -e "\n----------------------------\n"
235echo -e "CORE LIBRARY - Debug version ..."
236echo -e "\n----------------------------\n"
239 --source-path $MOFEM_INSTALL_DIR/mofem-cephas \
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
245echo -e "\n********************************************************\n"
246echo -e "Installing USER MODULES - Debug version ..."
247echo -e "\n********************************************************\n"
249# Get mofem-cephas spack hash for debug version
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"
254echo -e "\n----------------------------\n"
255echo -e "USER MODULE - Debug version ..."
256echo -e "\n----------------------------\n"
258hash=$(spack find -v mofem-cephas@develop build_type=Debug | grep mofem-cephas@develop)
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
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"
269echo -e "\nFinished installing and testing the User Module - Debug version.\n"
272echo "End time: $(date +"%T")"