2 # This script automises installation of MoFEM user version with basic modules
4 # Full description of the installation process using spack can be found at:
5 # http://mofem.eng.gla.ac.uk/mofem/html/install_spack.html
6 # The script should work for both Ubuntu and macOS platforms
7 # The last known working platforms are Ubuntu (18.04) and macOS (10.13, 10.14)
8 # The installation may take two to three hours
11 # 1. Copy install_mofem_user.sh to the directory where MoFEM will be installed
12 # 2. Run install_mofem_user.sh from the command line
14 # Note: Installation script changes .bashrc on Ubuntu or .bash_profile on Mac.
15 # Please inspect the file after installation.
20 echo "Start time: $(date +"%T")"
22 ##############################
24 ##############################
26 # Setup installation directory
28 export MOFEM_INSTALL_DIR="$PWD/mofem_install"
29 mkdir -p $MOFEM_INSTALL_DIR
31 # Check operating system
32 unameOut="$(uname -s)"
34 Linux*) machine=Linux;;
35 Darwin*) machine=Mac;;
36 CYGWIN*) machine=Cygwin;;
37 MINGW*) machine=MinGw;;
38 *) machine="UNKNOWN:${unameOut}"
42 ##############################
44 ##############################
46 echo -e "\n****************************\nInstalling PREREQUISITES...\n****************************\n"
47 echo "User password can be asked at some point. Please wait..."
49 # Install appropriate prerequisite packages
50 if [ ${machine} = "Linux" ]
52 echo -e "\nRunning in Linux\n"
54 && sudo apt-get install -y --no-install-recommends \
71 elif [ ${machine} = "Mac" ]
73 echo -e "\nRunning in macOS\n"
76 if ! which 'brew' &>/dev/null
78 xcode-select --install
79 sudo xcodebuild -license accept
80 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
82 echo -e "\nHomebrew installed"
98 if ! which 'xquartz' &>/dev/null
100 echo -e "\nXQuartz is not installed yet. Installing XQuartz ...\n"
101 brew install --cask xquartz
103 echo -e "\nXQuartz is already installed.\n"
108 echo -e "\nFinished installing Prerequisites.\n"
109 echo "No user password will be asked from now on."
111 echo "Current directory: $PWD"
113 ##############################
115 ##############################
117 echo -e "\n****************************\nInstalling SPACK...\n****************************\n"
119 cd $MOFEM_INSTALL_DIR
122 SPACK_ROOT_DIR=$MOFEM_INSTALL_DIR/spack
124 # Retrieve Spack for MoFEM
125 if [ ! -d "$SPACK_ROOT_DIR" ]; then
127 # Remove .spack directory in $HOME from previous installation (if any)
128 if [ -d "$HOME/.spack" ]; then
129 mv $HOME/.spack $HOME/.spack_old
132 if [ ! -f "$PWD/spack.tgz" ]; then
133 echo "Downloading spack ..."
134 mkdir -p $SPACK_ROOT_DIR &&\
135 git clone -b Workshop23 https://bitbucket.org/mofem/mofem-spack.git spack
138 mkdir -p $SPACK_ROOT_DIR &&\
139 tar xzf $PWD/spack.tgz -C $SPACK_ROOT_DIR --strip 1
142 # Initialise Spack environment variables:
143 . $SPACK_ROOT_DIR/share/spack/setup-env.sh
144 # Add command to configuration file .bashrc on Ubuntu or .bash_profile on Mac
145 if [ ${machine} = "Linux" ]
147 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bashrc
148 elif [ ${machine} = "Mac" ]
150 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.bash_profile
151 echo ". $SPACK_ROOT_DIR/share/spack/setup-env.sh" >> ~/.zshrc
154 # Install packages required by Spack
160 echo -e "\nFinished installing Spack.\n"
162 echo "Current directory: $PWD"
164 ##############################
165 ### MoFEM USER MODULES
166 ##############################
168 echo -e "\n********************************************************\n"
169 echo -e "Installing USER MODULE ..."
170 echo -e "\n********************************************************\n"
172 # Locate MoFEM installation directory
173 cd $MOFEM_INSTALL_DIR
174 echo "Current directory: $PWD"
176 # Install MoFEM packages
177 spack install --only dependencies mofem-cephas ^petsc+X
178 spack install --test root mofem-users-modules build_type=Release ^petsc+X
180 # Activate fracture module
181 spack view --verbose symlink -i um_view mofem-users-modules
183 # Export view and make view visible from any directory
184 export PATH=$PWD/um_view/bin:$PATH
186 echo "End time: $(date +"%T")"