v0.15.0
Loading...
Searching...
No Matches
install_mofem_developer_spack_v0.12.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
23# Setup installation directory
24pwd
25export MOFEM_INSTALL_DIR="$PWD/mofem_install"
26mkdir -p $MOFEM_INSTALL_DIR
27
28# Check operating system
29unameOut="$(uname -s)"
30case "${unameOut}" in
31 Linux*) machine=Linux;;
32 Darwin*) machine=Mac;;
33 CYGWIN*) machine=Cygwin;;
34 MINGW*) machine=MinGw;;
35 *) machine="UNKNOWN:${unameOut}"
36esac
37
38##############################
39### PREREQUISITES
40##############################
41
42echo -e "\n****************************\nInstalling PREREQUISITES...\n****************************\n"
43echo "User password can be asked at some point. Please wait..."
44
45# Install appropriate prerequisite packages
46if [ ${machine} = "Linux" ]
47then
48 echo -e "\nRunning in Linux\n"
49 sudo apt-get update \
50 && sudo apt-get install -y --no-install-recommends \
51 autoconf \
52 build-essential \
53 ca-certificates \
54 coreutils \
55 curl \
56 environment-modules \
57 git \
58 python \
59 unzip \
60 vim \
61 gfortran
62
63elif [ ${machine} = "Mac" ]
64then
65 echo -e "\nRunning in macOS\n"
66
67 # Install Xcode
68 if ! which 'brew' &>/dev/null
69 then
70 xcode-select --install
71 sudo xcodebuild -license accept
72 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
73 else
74 echo -e "\nHomebrew is already installed."
75 fi
76 brew install curl git gcc
77
78 # Install XQuartz
79 if ! which 'xquartz' &>/dev/null
80 then
81 echo -e "\nXQuartz is not installed yet. Installing XQuartz ...\n"
82 brew install caskroom/cask/brew-cask 2> /dev/null
83 brew cask install xquartz
84 else
85 echo -e "\nXQuartz is already installed.\n"
86 fi
87
88fi
89
90echo -e "\nFinished installing Prerequisites.\n"
91echo -e "\nNo user password will be asked from now on.\n"
92
93echo "Current directory: $PWD"
94
95
96##############################
97### SPACK
98##############################
99
100echo -e "\n****************************\nInstalling SPACK...\n****************************\n"
101
102# Locate home directory
103cd $MOFEM_INSTALL_DIR
104echo "$PWD"
105
106SPACK_ROOT_DIR=$MOFEM_INSTALL_DIR/spack
107SPACK_MIRROR_DIR=$MOFEM_INSTALL_DIR/mofem_mirror
108
109# Remove .spack directory in $HOME from previous installation (if any)
110if [ -d "$HOME/.spack" ]; then
111 mv $HOME/.spack $HOME/.spack_old
112fi
113
114# Retrieve Spack for MoFEM
115if [ ! -d "$SPACK_ROOT_DIR" ]; then
116
117 echo "Cloning spack ..."
118 git clone -b develop_v0.12 https://bitbucket.org/mofem/mofem-spack.git spack
119 echo -e "Done.\n"
120
121 # Initialise Spack environment variables:
122 . $SPACK_ROOT_DIR/share/spack/setup-env.sh
123 # Add command to configuration file .bashrc on Ubuntu or .bash_profile on Mac
124 if [ ${machine} = "Linux" ]
125 then
126 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bashrc
127 elif [ ${machine} = "Mac" ]
128 then
129 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bash_profile
130 fi
131
132 # Download mirror
133 if [ ! -d "$SPACK_MIRROR_DIR" ]; then
134 if [ ! -f "$PWD/mirror.tgz" ]; then
135 echo "Downloading mirror of spack packages for MoFEM..."
136 mkdir -p $SPACK_MIRROR_DIR && \
137 curl -s -L http://mofem.eng.gla.ac.uk/downloads/mirror_v0.9.2.tar.gz \
138 | tar xzC $SPACK_MIRROR_DIR --strip 1
139 echo -e "Done.\n"
140 else
141 mkdir -p $SPACK_MIRROR_DIR && \
142 tar xzf $PWD/mirror.tgz -C $SPACK_MIRROR_DIR --strip 1
143 fi
144 fi
145
146 # Add mirror
147 spack mirror remove mofem_mirror 2> /dev/null
148 spack mirror add mofem_mirror $SPACK_MIRROR_DIR
149
150 # Install packages required by Spack
151 spack bootstrap
152fi
153
154echo -e "\nFinished installing Spack.\n"
155
156echo "Current directory: $PWD"
157
158########################################
159### MoFEM CORE LIBRARY & USER MODULES
160########################################
161
162echo -e "\n********************************************************\n"
163echo -e "Installing CORE LIBRARY - Release version ..."
164echo -e "\n********************************************************\n"
165
166# Locate MoFEM installation directory
167cd $MOFEM_INSTALL_DIR
168echo "Current directory: $PWD"
169
170# Clone MoFEM core library
171if [ ! -d "$PWD/mofem-cephas" ]; then
172 git clone -b develop --recurse-submodules https://bitbucket.org/likask/mofem-cephas.git mofem-cephas
173
174 # Checkout develop branch in user modules repo (sub-module)
175 cd mofem-cephas/mofem/users_modules
176 git fetch && git checkout develop && git pull
177
178else
179 echo -e "\nMoFEM source directory is found"
180fi
181
182# Clone MoFEM Fracture Module and Mortar Contact Module
183cd $MOFEM_INSTALL_DIR/mofem-cephas/mofem/users_modules
184git clone -b develop https://bitbucket.org/likask/mofem_um_fracture_mechanics.git
185git clone -b develop https://bitbucket.org/mofem/mortar_contact.git
186
187# Installation of core library
188cd $MOFEM_INSTALL_DIR
189mkdir -p lib_release
190cd lib_release
191
192spack install --only dependencies mofem-cephas+slepc ^petsc+X
193spack setup mofem-cephas@develop+slepc copy_user_modules=False \
194 build_type=Release ^petsc+X
195
196echo -e "\n----------------------------\n"
197echo -e "CORE LIBRARY - Release version: spconfig ..."
198echo -e "\n----------------------------\n"
199
200./spconfig.py -DMOFEM_BUILD_TESTS=ON $MOFEM_INSTALL_DIR/mofem-cephas/mofem
201
202echo -e "\n----------------------------\n"
203echo -e "CORE LIBRARY - Release version: make -j 2 ..."
204echo -e "\n----------------------------\n"
205
206make -j 2
207
208# Run the tests on core library
209echo -e "\n----------------------------\n"
210echo -e "CORE LIBRARY - Release version: ctest ..."
211echo -e "\n----------------------------\n"
212
213spack load cmake
214ctest -D Experimental
215
216# Install the library
217echo -e "\n----------------------------\n"
218echo -e "CORE LIBRARY - Release version: make install ..."
219echo -e "\n----------------------------\n"
220
221make install
222
223echo -e "\nFinished installing and testing the Core Library.\n"
224
225echo -e "\n********************************************************\n"
226echo -e "Installing USER MODULES - Release version ..."
227echo -e "\n********************************************************\n"
228
229# Get mofem-cephas spack hash for release version
230TODAY=`date +%F`
231MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep Release | awk '{print $1}'`
232echo "mofem-cephas id for release: $MOFEM_CEPHAS_HASH"
233
234# Installation of user modules
235cd $MOFEM_INSTALL_DIR
236
237mkdir -p um
238cd um/
239spack view --verbose symlink -i um_view /$MOFEM_CEPHAS_HASH
240export PATH=$PWD/um_view/bin:$PATH
241# Add PATH to .bashrc on Ubuntu or .bash_profile on Mac
242if [ ${machine} = "Linux" ]
243then
244 echo "export PATH=$PWD/um_view/bin:\$PATH" >> ~/.bashrc
245elif [ ${machine} = "Mac" ]
246then
247 echo "export PATH=$PWD/um_view/bin:\$PATH" >> ~/.bash_profile
248fi
249
250mkdir -p build_release
251cd build_release/
252
253spack setup mofem-users-modules@develop \
254 copy_user_modules=False build_type=Release \
255 ^/$MOFEM_CEPHAS_HASH
256
257echo -e "\n----------------------------\n"
258echo -e "USER MODULE - Release version: spconfig ..."
259echo -e "\n----------------------------\n"
260
261./spconfig.py -DMOFEM_UM_BUILD_TESTS=ON -DFM_VERSION_MAJOR=0 -DFM_VERSION_MINOR=0 -DFM_VERSION_BUILD=0 -DMOFEM_DIR=../um_view \
262 $MOFEM_INSTALL_DIR/mofem-cephas/mofem/users_modules
263
264echo -e "\n----------------------------\n"
265echo -e "USER MODULE - Release version: make -j 2 ..."
266echo -e "\n----------------------------\n"
267
268make -j 2
269
270# Run the tests on user modules
271echo -e "\n----------------------------\n"
272echo -e "USER MODULE - Release version: ctest ..."
273echo -e "\n----------------------------\n"
274
275ctest -D Experimental
276
277# Install the user module
278echo -e "\n----------------------------\n"
279echo -e "USER MODULE - Release version: make install ..."
280echo -e "\n----------------------------\n"
281
282make install
283
284echo -e "\nFinished installing and testing the User Module - Release version.\n"
285
286
287# ************************************************************************
288# DEBUG VERSION
289# ************************************************************************
290
291echo -e "\n********************************************************\n"
292echo -e "Installing MoFEM - DEBUG VERSION..."
293echo -e "\n********************************************************\n"
294
295
296########################################
297### MoFEM CORE LIBRARY & USER MODULES
298########################################
299
300# Locate MoFEM installation directory
301cd $MOFEM_INSTALL_DIR
302
303# Installation of core library
304mkdir -p lib_debug
305cd lib_debug
306
307spack setup mofem-cephas@develop copy_user_modules=False \
308build_type=Debug ^petsc+X
309
310echo -e "\n----------------------------\n"
311echo -e "CORE LIBRARY - Debug version: spconfig ..."
312echo -e "\n----------------------------\n"
313
314./spconfig.py -DMOFEM_BUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 $MOFEM_INSTALL_DIR/mofem-cephas/mofem
315
316
317echo -e "\n----------------------------\n"
318echo -e "CORE LIBRARY - Debug version: make -j 2 ..."
319echo -e "\n----------------------------\n"
320
321make -j 2
322
323# Run the tests on core library
324echo -e "\n----------------------------\n"
325echo -e "CORE LIBRARY - Debug version: ctest ..."
326echo -e "\n----------------------------\n"
327
328ctest -D Experimental
329
330# Install the library
331echo -e "\n----------------------------\n"
332echo -e "CORE LIBRARY - Debug version: make install ..."
333echo -e "\n----------------------------\n"
334
335make install
336
337echo -e "\nFinished installing and testing the Core Library - Debug version.\n"
338
339echo -e "\n********************************************************\n"
340echo -e "Installing USER MODULES - Debug version ..."
341echo -e "\n********************************************************\n"
342
343# Get mofem-cephas spack hash for debug version
344TODAY=`date +%F`
345MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep Debug | awk '{print $1}'`
346echo "mofem-cephas id for debug: $MOFEM_CEPHAS_HASH"
347
348# Installation of user modules
349cd $MOFEM_INSTALL_DIR
350
351# mkdir um
352cd um/
353
354spack view --verbose symlink -i um_view_debug /$MOFEM_CEPHAS_HASH
355
356mkdir -p build_debug
357cd build_debug/
358
359
360spack setup mofem-users-modules@develop \
361 copy_user_modules=False build_type=Debug \
362 ^/$MOFEM_CEPHAS_HASH
363
364echo -e "\n----------------------------\n"
365echo -e "USER MODULE: spconfig - Debug version ..."
366echo -e "\n----------------------------\n"
367
368./spconfig.py -DMOFEM_UM_BUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DFM_VERSION_MAJOR=0 -DFM_VERSION_MINOR=0 -DFM_VERSION_BUILD=0 -DMOFEM_DIR=../um_view_debug \
369 $MOFEM_INSTALL_DIR/mofem-cephas/mofem/users_modules
370
371echo -e "\n----------------------------\n"
372echo -e "USER MODULE - Debug version: make -j 2 ..."
373echo -e "\n----------------------------\n"
374
375make -j 2
376
377# Run the tests on user modules
378echo -e "\n----------------------------\n"
379echo -e "USER MODULE - Debug version: ctest ..."
380echo -e "\n----------------------------\n"
381
382ctest -D Experimental
383
384# Install the user module
385echo -e "\n----------------------------\n"
386echo -e "USER MODULE - Debug version: make install ..."
387echo -e "\n----------------------------\n"
388
389make install
390
391echo -e "\nFinished installing and testing the User Module - Debug version.\n"
392
393echo "End time: $(date +"%T")"