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 ##############################
23 # Setup installation directory
25 export MOFEM_INSTALL_DIR="$PWD/mofem_install"
26 mkdir -p $MOFEM_INSTALL_DIR
28 # Check operating system
29 unameOut="$(uname -s)"
31 Linux*) machine=Linux;;
32 Darwin*) machine=Mac;;
33 CYGWIN*) machine=Cygwin;;
34 MINGW*) machine=MinGw;;
35 *) machine="UNKNOWN:${unameOut}"
38 ##############################
40 ##############################
42 echo -e "\n****************************\nInstalling PREREQUISITES...\n****************************\n"
43 echo "User password can be asked at some point. Please wait..."
45 # Install appropriate prerequisite packages
46 if [ ${machine} = "Linux" ]
48 echo -e "\nRunning in Linux\n"
50 && sudo apt-get install -y --no-install-recommends \
63 elif [ ${machine} = "Mac" ]
65 echo -e "\nRunning in macOS\n"
68 if ! which 'brew' &>/dev/null
70 xcode-select --install
71 sudo xcodebuild -license accept
72 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
74 echo -e "\nHomebrew is already installed."
76 brew install curl git gcc
79 if ! which 'xquartz' &>/dev/null
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
85 echo -e "\nXQuartz is already installed.\n"
90 echo -e "\nFinished installing Prerequisites.\n"
91 echo -e "\nNo user password will be asked from now on.\n"
93 echo "Current directory: $PWD"
96 ##############################
98 ##############################
100 echo -e "\n****************************\nInstalling SPACK...\n****************************\n"
102 # Locate home directory
103 cd $MOFEM_INSTALL_DIR
106 SPACK_ROOT_DIR=$MOFEM_INSTALL_DIR/spack
107 SPACK_MIRROR_DIR=$MOFEM_INSTALL_DIR/mofem_mirror
109 # Remove .spack directory in $HOME from previous installation (if any)
110 if [ -d "$HOME/.spack" ]; then
111 mv $HOME/.spack $HOME/.spack_old
114 # Retrieve Spack for MoFEM
115 if [ ! -d "$SPACK_ROOT_DIR" ]; then
117 echo "Cloning spack ..."
118 git clone -b develop_v0.12 https://bitbucket.org/mofem/mofem-spack.git spack
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" ]
126 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bashrc
127 elif [ ${machine} = "Mac" ]
129 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bash_profile
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
141 mkdir -p $SPACK_MIRROR_DIR && \
142 tar xzf $PWD/mirror.tgz -C $SPACK_MIRROR_DIR --strip 1
147 spack mirror remove mofem_mirror 2> /dev/null
148 spack mirror add mofem_mirror $SPACK_MIRROR_DIR
150 # Install packages required by Spack
154 echo -e "\nFinished installing Spack.\n"
156 echo "Current directory: $PWD"
158 ########################################
159 ### MoFEM CORE LIBRARY & USER MODULES
160 ########################################
162 echo -e "\n********************************************************\n"
163 echo -e "Installing CORE LIBRARY - Release version ..."
164 echo -e "\n********************************************************\n"
166 # Locate MoFEM installation directory
167 cd $MOFEM_INSTALL_DIR
168 echo "Current directory: $PWD"
170 # Clone MoFEM core library
171 if [ ! -d "$PWD/mofem-cephas" ]; then
172 git clone -b develop --recurse-submodules https://bitbucket.org/likask/mofem-cephas.git mofem-cephas
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
179 echo -e "\nMoFEM source directory is found"
182 # Clone MoFEM Fracture Module and Mortar Contact Module
183 cd $MOFEM_INSTALL_DIR/mofem-cephas/mofem/users_modules
184 git clone -b develop https://bitbucket.org/likask/mofem_um_fracture_mechanics.git
185 git clone -b develop https://bitbucket.org/mofem/mortar_contact.git
187 # Installation of core library
188 cd $MOFEM_INSTALL_DIR
192 spack install --only dependencies mofem-cephas+slepc ^petsc+X
193 spack setup mofem-cephas@develop+slepc copy_user_modules=False \
194 build_type=Release ^petsc+X
196 echo -e "\n----------------------------\n"
197 echo -e "CORE LIBRARY - Release version: spconfig ..."
198 echo -e "\n----------------------------\n"
200 ./spconfig.py -DMOFEM_BUILD_TESTS=ON $MOFEM_INSTALL_DIR/mofem-cephas/mofem
202 echo -e "\n----------------------------\n"
203 echo -e "CORE LIBRARY - Release version: make -j 2 ..."
204 echo -e "\n----------------------------\n"
208 # Run the tests on core library
209 echo -e "\n----------------------------\n"
210 echo -e "CORE LIBRARY - Release version: ctest ..."
211 echo -e "\n----------------------------\n"
214 ctest -D Experimental
216 # Install the library
217 echo -e "\n----------------------------\n"
218 echo -e "CORE LIBRARY - Release version: make install ..."
219 echo -e "\n----------------------------\n"
223 echo -e "\nFinished installing and testing the Core Library.\n"
225 echo -e "\n********************************************************\n"
226 echo -e "Installing USER MODULES - Release version ..."
227 echo -e "\n********************************************************\n"
229 # Get mofem-cephas spack hash for release version
231 MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep Release | awk '{print $1}'`
232 echo "mofem-cephas id for release: $MOFEM_CEPHAS_HASH"
234 # Installation of user modules
235 cd $MOFEM_INSTALL_DIR
239 spack view --verbose symlink -i um_view /$MOFEM_CEPHAS_HASH
240 export PATH=$PWD/um_view/bin:$PATH
241 # Add PATH to .bashrc on Ubuntu or .bash_profile on Mac
242 if [ ${machine} = "Linux" ]
244 echo "export PATH=$PWD/um_view/bin:\$PATH" >> ~/.bashrc
245 elif [ ${machine} = "Mac" ]
247 echo "export PATH=$PWD/um_view/bin:\$PATH" >> ~/.bash_profile
250 mkdir -p build_release
253 spack setup mofem-users-modules@develop \
254 copy_user_modules=False build_type=Release \
257 echo -e "\n----------------------------\n"
258 echo -e "USER MODULE - Release version: spconfig ..."
259 echo -e "\n----------------------------\n"
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
264 echo -e "\n----------------------------\n"
265 echo -e "USER MODULE - Release version: make -j 2 ..."
266 echo -e "\n----------------------------\n"
270 # Run the tests on user modules
271 echo -e "\n----------------------------\n"
272 echo -e "USER MODULE - Release version: ctest ..."
273 echo -e "\n----------------------------\n"
275 ctest -D Experimental
277 # Install the user module
278 echo -e "\n----------------------------\n"
279 echo -e "USER MODULE - Release version: make install ..."
280 echo -e "\n----------------------------\n"
284 echo -e "\nFinished installing and testing the User Module - Release version.\n"
287 # ************************************************************************
289 # ************************************************************************
291 echo -e "\n********************************************************\n"
292 echo -e "Installing MoFEM - DEBUG VERSION..."
293 echo -e "\n********************************************************\n"
296 ########################################
297 ### MoFEM CORE LIBRARY & USER MODULES
298 ########################################
300 # Locate MoFEM installation directory
301 cd $MOFEM_INSTALL_DIR
303 # Installation of core library
307 spack setup mofem-cephas@develop copy_user_modules=False \
308 build_type=Debug ^petsc+X
310 echo -e "\n----------------------------\n"
311 echo -e "CORE LIBRARY - Debug version: spconfig ..."
312 echo -e "\n----------------------------\n"
314 ./spconfig.py -DMOFEM_BUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 $MOFEM_INSTALL_DIR/mofem-cephas/mofem
317 echo -e "\n----------------------------\n"
318 echo -e "CORE LIBRARY - Debug version: make -j 2 ..."
319 echo -e "\n----------------------------\n"
323 # Run the tests on core library
324 echo -e "\n----------------------------\n"
325 echo -e "CORE LIBRARY - Debug version: ctest ..."
326 echo -e "\n----------------------------\n"
328 ctest -D Experimental
330 # Install the library
331 echo -e "\n----------------------------\n"
332 echo -e "CORE LIBRARY - Debug version: make install ..."
333 echo -e "\n----------------------------\n"
337 echo -e "\nFinished installing and testing the Core Library - Debug version.\n"
339 echo -e "\n********************************************************\n"
340 echo -e "Installing USER MODULES - Debug version ..."
341 echo -e "\n********************************************************\n"
343 # Get mofem-cephas spack hash for debug version
345 MOFEM_CEPHAS_HASH=`spack find -lv --start-date $TODAY | grep mofem-cephas@develop | grep Debug | awk '{print $1}'`
346 echo "mofem-cephas id for debug: $MOFEM_CEPHAS_HASH"
348 # Installation of user modules
349 cd $MOFEM_INSTALL_DIR
354 spack view --verbose symlink -i um_view_debug /$MOFEM_CEPHAS_HASH
360 spack setup mofem-users-modules@develop \
361 copy_user_modules=False build_type=Debug \
364 echo -e "\n----------------------------\n"
365 echo -e "USER MODULE: spconfig - Debug version ..."
366 echo -e "\n----------------------------\n"
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
371 echo -e "\n----------------------------\n"
372 echo -e "USER MODULE - Debug version: make -j 2 ..."
373 echo -e "\n----------------------------\n"
377 # Run the tests on user modules
378 echo -e "\n----------------------------\n"
379 echo -e "USER MODULE - Debug version: ctest ..."
380 echo -e "\n----------------------------\n"
382 ctest -D Experimental
384 # Install the user module
385 echo -e "\n----------------------------\n"
386 echo -e "USER MODULE - Debug version: make install ..."
387 echo -e "\n----------------------------\n"
391 echo -e "\nFinished installing and testing the User Module - Debug version.\n"
393 echo "End time: $(date +"%T")"