Compiling MARE2DEM on OS X

Here are instructions for installing MARE2DEM on an OS X computer.  I run MARE2DEM on my 4-core Macbook Pro and also have it setup on a Mac Pro Desktop.   Leave a comment below if you have any trouble with these instructions.

  1. Install Apple's Xcode.  You can download Xcode from  the App Store on OS X. After you install Xcode, you need to also install the Xcode command line tools using one of the methods described here.
  2. Install the Intel C and Fortran compilers, including the Math Kernel Library.  After you install them, make sure you add the line "source /opt/intel/bin/compilervars.sh intel64" to your .profile or .bash_profile file in your home directory so that the terminal will know where the compilers are located at.  See the Intel help for more details on that.
  3. Download and install Open-MPI.  You can obtain Open-MPI source code here.  Unpack or unzip the files. Open Terminal.app and cd to the open-mpi folder. Run the configure script by pasting the following into the terminal (this should be one line of text):

    ./configure --prefix=/opt/openmpi CC=icc F77=ifort FC=ifort CFLAGS=-m64 CXXFLAGS=-m64 FFLAGS=-m64 FCFLAGS=-m64 CXX=icpc

    That will take a few minutes. Then run this command to make and install the MPI routines into /opt/openmpi :

    sudo make all install
  4. Make MARE2DEM.    Open Terminal.app and cd to the MARE2DEM /Source folder. Type the following:
    make CLUSTER=macpro

    That will make MARE2DEM using the variable defined in the macpro section of the Makefile.  It should take a few minutes to compile all the libraries and MARE2DEM source codes. In case you have any trouble, here are the Makefile settings for macpro:

    FC = /opt/openmpi/bin/mpif90 
    FFLAGS = -O2 -m64 -fpp # optimized code
    CC = /opt/openmpi/bin/mpicc 
    CFLAGS = -O2 -m64 
    ARCH = /opt/intel/composerxe/bin/xiar
    ARCHFLAGS = ruv
    RANLIB    = ranlib
    BLASDEF   = -DUSE_VENDOR_BLAS
    MKLPATH=$(MKLROOT)/lib
    MKLINCLUDE=$(MKLROOT)/include
    BLASLIB = -L$(MKLPATH) -I$(MKLINCLUDE) -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
    SUPERLU_CDEFS = -DAdd_
  5. Now you can run MARE2DEM.   For example, to run one of the Demo examples, cd to the folder and run this command as a single line of text (substituting in the correct path to the compiled MARE2DEM executable on your system):
    /opt/openmpi/bin/mpirun -n 9 /<pathToMARE2DEM>/Source/MARE2DEM Demo.0.resistivity

    The "-n 9" argument after mpirun tells MPI to run using 9 processors. I use this on my laptop since it can run 8 threads efficiently. Since MARE2DEM uses a manager-worker model, the extra thread is for the manager, who like most managers, just sits around idle while the real work is being done by others 🙂

3 thoughts on “Compiling MARE2DEM on OS X

  1. I just ran through the installation on a new Mac today and have a tip. The open-mpi .configure step failed when "checking whether the C compiler works". The fix is to open up the Xcode app (it was newly installed) and agree to the Xcode/iOS license.

Leave a Reply