Skip to content

Instantly share code, notes, and snippets.

@zbeekman
Created June 16, 2017 20:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbeekman/56ef0c3ca4e98831d31839e8524bec9b to your computer and use it in GitHub Desktop.
Save zbeekman/56ef0c3ca4e98831d31839e8524bec9b to your computer and use it in GitHub Desktop.
A script that will automatically install OpenCoarrays using Homebrew. MPICH and OpenCoarrays will be compiled and installed with GCC-7
#!/usr/bin/env bash
set -o nounset
set -o pipefail
set -o errexit
set -o errtrace
msg="Press Ctrl-C to abort, or enter to continue"
echo "Tapping homebrew-bundle"
read -rp "${msg}"
brew tap homebrew/bundle
echo "Writing Brewfile for use with \`brew bundle\`"
read -rp "${msg}"
cat <<-EOF > Brewfile
brew 'cmake'
brew 'gcc'
brew 'mpich', args: ['cc=gcc-7']
brew 'opencoarrays', args: ['cc=gcc-7']
EOF
echo "Uninstalling OpenCoarrays and MPICH if installed with Homebrew, unlinking openmpi if installed"
read -rp "${msg}"
brew uninstall opencoarrays || true
brew uninstall mpich || true
brew unlink openmpi || true
echo "Using \`brew bundle\` and previously written Brewfile to install OpenCoarrays and"
echo "MPICH using the latest GCC-7.x. GCC and CMake will also be installed or upgraded."
read -rp "${msg}"
brew bundle --verbose --file=./Brewfile
while true; do
read -rp "Update your global Brewfile, \`${HOME}/.Brewfile\`? (Recommended)" yn
case $yn in
[Yy]* ) cat ./Brewfile >> "${HOME}/.Brewfile"; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
@zbeekman
Copy link
Author

This script will install MPICH built with GCC 7.x and the OpenCoarrays linked against MPICH and also built with GCC 7.x. OpenMPI will be unlinked, and previous installations of OpenCoarrays and MPICH will be removed. Here is a one liner you can use on MacOS to download and execute the script:

/usr/bin/env bash <(curl -fsSL https://gist.githubusercontent.com/zbeekman/56ef0c3ca4e98831d31839e8524bec9b/raw/f9256cecc20044ceaae163abb7bb4672cc431e49/brew-install-opencoarrays.sh)

I'll try to remember to update the SHA if I edit the script, but no guarantees; you should make sure you check it against the link to the raw version of this gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment