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
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.
16 echo "Start time: $(date +"%T")"
18 ##############################
20 ##############################
22 # Setup installation directory
24 export MOFEM_INSTALL_DIR="$PWD/mofem_install"
25 mkdir -p $MOFEM_INSTALL_DIR
27 # Check operating system
28 unameOut="$(uname -s)"
30 Linux*) machine=Linux;;
31 Darwin*) machine=Mac;;
32 CYGWIN*) machine=Cygwin;;
33 MINGW*) machine=MinGw;;
34 *) machine="UNKNOWN:${unameOut}"
37 ##############################
39 ##############################
41 echo -e "\n****************************\nInstalling PREREQUISITES...\n****************************\n"
42 echo "User password can be asked at some point. Please wait..."
44 # Install appropriate prerequisite packages
45 if [ ${machine} = "Linux" ]
47 echo -e "\nRunning in Linux\n"
49 && sudo apt-get install -y --no-install-recommends \
67 elif [ ${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"
105 echo -e "\nFinished installing Prerequisites.\n"
106 echo -e "\nNo user password will be asked from now on.\n"
108 echo "Current directory: $PWD"
110 ##############################
112 ##############################
114 echo -e "\n****************************\nInstalling SPACK...\n****************************\n"
116 # Locate home directory
117 cd $MOFEM_INSTALL_DIR
120 SPACK_ROOT_DIR=$MOFEM_INSTALL_DIR/spack
122 # Retrieve Spack for MoFEM
123 if [ ! -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
155 echo -e "\nFinished installing Spack.\n"
157 echo "Current directory: $PWD"
159 ########################################
160 ### MoFEM CORE LIBRARY & USER MODULES
161 ########################################
163 echo -e "\n********************************************************\n"
164 echo -e "Installing CORE LIBRARY - Release version ..."
165 echo -e "\n********************************************************\n"
167 # Locate MoFEM installation directory
168 cd $MOFEM_INSTALL_DIR
169 echo "Current directory: $PWD"
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
176 echo -e "\nMoFEM source directory is found"
179 # Installation of core library
180 cd $MOFEM_INSTALL_DIR
182 echo -e "\n----------------------------\n"
183 echo -e "CORE LIBRARY - Install depenencies ..."
184 echo -e "\n----------------------------\n"
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
190 echo -e "\n----------------------------\n"
191 echo -e "CORE LIBRARY - Release version ..."
192 echo -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
201 echo -e "\n********************************************************\n"
202 echo -e "Installing USER MODULES - Release version ..."
203 echo -e "\n********************************************************\n"
205 # Get mofem-cephas spack hash for release version
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"
210 hash=$(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
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"
221 # ************************************************************************
223 # ************************************************************************
225 echo -e "\n********************************************************\n"
226 echo -e "Installing MoFEM - DEBUG VERSION..."
227 echo -e "\n********************************************************\n"
230 ########################################
231 ### MoFEM CORE LIBRARY & USER MODULES
232 ########################################
234 echo -e "\n----------------------------\n"
235 echo -e "CORE LIBRARY - Debug version ..."
236 echo -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
245 echo -e "\n********************************************************\n"
246 echo -e "Installing USER MODULES - Debug version ..."
247 echo -e "\n********************************************************\n"
249 # Get mofem-cephas spack hash for debug version
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"
254 echo -e "\n----------------------------\n"
255 echo -e "USER MODULE - Debug version ..."
256 echo -e "\n----------------------------\n"
258 hash=$(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
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"
269 echo -e "\nFinished installing and testing the User Module - Debug version.\n"
270 cd $MOFEM_INSTALL_DIR
272 echo "End time: $(date +"%T")"