How to install/update MARS on a MAC. [last update: 20180125]
Posted: Thu Jan 25, 2018 6:48 pm
Prerequisite 1: Install the command line tool component of Xcode.
If you don't want to install the full Xcode software (the size is usually several Gigabytes), you can only install the command line tool component (which provides necessary header files and libraries to compile a c/c++ program) in Terminal App:
When you do a major macOS upgrade, e.g. from macOS 10.10 to macOS 10.11, you need to redo this step because a major macOS upgrade will erase the Xcode components installed before. In case of a minor upgrade, e.g. from 10.12.0 to 10.12.2, you don't need to redo this part.
Prerequisite 2: Install HomeBrew.
HomeBrew (https://brew.sh/) is a very popular package management system for macOS. It can be used to install many useful tools (e.g. GCC 7) which Apple does not provide. To install HomeBrew, open Terminal App and run
Part 1: Install a recent C++ commpiler (e.g. GNU g++) using HomeBrew
Install GNU GCC by running
The installed c++ compiler is /usr/local/bin/g++-N, where N is the version number of the latest stable release. Note: make sure to replace N with the actual number.
Part 2: Build or update MARS
Part 3: Install MPI compiler using HomeBrew (optional)
Install Open MPI by running
The executables (e.g. mpic++, mpirun) are installed under /usr/local/bin by default.
The MPI c++ compiler (actually a wrapper) is mpic++. To invoke the c++ compiler installed in Part 1, in the Makefile we can use:
If you don't want to install the full Xcode software (the size is usually several Gigabytes), you can only install the command line tool component (which provides necessary header files and libraries to compile a c/c++ program) in Terminal App:
- Code: Select all
xcode-select --install
When you do a major macOS upgrade, e.g. from macOS 10.10 to macOS 10.11, you need to redo this step because a major macOS upgrade will erase the Xcode components installed before. In case of a minor upgrade, e.g. from 10.12.0 to 10.12.2, you don't need to redo this part.
Prerequisite 2: Install HomeBrew.
HomeBrew (https://brew.sh/) is a very popular package management system for macOS. It can be used to install many useful tools (e.g. GCC 7) which Apple does not provide. To install HomeBrew, open Terminal App and run
- Code: Select all
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Part 1: Install a recent C++ commpiler (e.g. GNU g++) using HomeBrew
Install GNU GCC by running
- Code: Select all
brew install gcc
The installed c++ compiler is /usr/local/bin/g++-N, where N is the version number of the latest stable release. Note: make sure to replace N with the actual number.
Part 2: Build or update MARS
- Download the latest package from http://mars.es3inc.com/protected/MARS/ (e.g. mars2018.01.00.MacOSX.zip) to a local folder where you want to build the MARS executables.
- Unzip the package, among other files, you will find two files: user.cpp and Makefile.
- If you are developing user-defined features with your own user.cpp, replace the one within our package with your copy.
- Open Makefile, make necessary changes to specify CXX to the c++ compiler we have install in Part 1.
- Compile debug version of MARS (marsD) using
- Code: Select all
make V=D
- Code: Select all
make V=O
- Code: Select all
make V=M
- Add
- Code: Select all
export PATH=[path_to_mars_folder]:$PATH
- Add
- Code: Select all
export MARS_LICENSE_PATH=[file_name]
- Run
- Code: Select all
source ~/.bash_profile
Part 3: Install MPI compiler using HomeBrew (optional)
Install Open MPI by running
- Code: Select all
brew install open-mpi
The executables (e.g. mpic++, mpirun) are installed under /usr/local/bin by default.
The MPI c++ compiler (actually a wrapper) is mpic++. To invoke the c++ compiler installed in Part 1, in the Makefile we can use:
- Code: Select all
OMPI_CXX=/usr/local/bin/g++-N mpic++
- Code: Select all
mpic++