msbas v10 compilation on macOS

The Multidimensional Small Baseline Subset (MSBAS) is used for time series analysis of InSAR and speckle range/azimuth offset data. The latest version 10 is out and uses MPICH (a high performance implementation of the Message Passing Interface (MPI) ) along with OpenMP and gdal.
More info on msbas at github:
https://github.com/insar-info/msbas

Here’s a quick instruction on how to compile the latest msbas v10 for macOS with MacPorts.
A Homebrew version is a also available in the Makefile.

Requirements

XCode command line:
xcode-select --install

and Macports or Homebrew already installed.

Always do a selfupdate and a reclaim first:
#sudo port selfupdate
#sudo port reclaim

Install OpenMP

(note the name:libomp on macOS, instead of openmp on Linux, also in the Makefile we don’t use -fopenmp but -lomp instead).

#sudo port install libomp

Install gdal

#sudo port install gdal

Install mpich

(Can take some time to compile with Macports):
#sudo port install mpich

Clone the msbas repo on your Mac

git clone https://github.com/insar-info/msbas

Copy the original Makefile

cd msbas/src
cp Makefile Makefile.ORI

Replace content of Makefile

Open the Makefile in src/ and just copy/paste the following lines:


## Note: on macOS install these dependencies (mpich, gdal and openmp = libomp on macOS)
## Macports - when using Macports
# sudo port selfupdate
# sudo port reclaim
# sudo port install mpich
# sudo port install libomp
# sudo port install gdal
## Homebrew - install these dependencies (mpich, gdal and openmp = libomp on macOS)
#
# brew install mpich
# brew install libomp
# brew install gdal
# Macports - if you use: mpich
# sudo port install mpich
CC = /opt/local/bin/mpicxx-mpich-mp
CXX = /opt/local/bin/mpicxx-mpich-mp
# Homebrew: brew install mpi
#CXX = /usr/local/bin/mpic++
# Macports - use this:
OMP_INCLUDE = -I/opt/local/include/libomp/
GDAL_INCLUDE = -I/opt/local/include/
# Homebrew - use this
#GDAL_INCLUDE = -I/usr/local/include/
#OMP_INCLUDE = -I/usr/local/opt/libomp/include/
# Using -mtune=native produces code optimized for the local machine under the constraints of the selected instruction set.
#CXXFLAGS = -O3 -std=c++11 $(GDAL_INCLUDE) $(OMP_INCLUDE)
CXXFLAGS = -std=c++11 -mtune=native $(GDAL_INCLUDE) $(OMP_INCLUDE)
# Macports
LDFLAGS = -L/opt/local/lib/ -L/opt/local/lib/libomp/
# Homebrew
#LDFLAGS = -L/usr/local/lib/ -L/usr/local/opt/libomp/lib/ -L/usr/local/opt/llvm/lib
# On macOS the Lapack lib is integrated into the Accelerate framework
# On macOS: Don't use -fopenmp but use "-lomp" instead !!
LDLIBS = -lomp -lgdal -framework Accelerate
all: carea.o Image.o Interferogram.o Param.o Set.o Buffer.o main.o
$(CC) $(CXXFLAGS) -o msbas carea.o Image.o Interferogram.o Param.o Set.o Buffer.o main.o $(LDFLAGS) $(LDLIBS)
$(RM) *.o
clean:
$(RM) *.o msbas

Finally compile msbas with command

#make

Comments are closed.