Building MOAB
Note: If you are looking for building MOAB for E3SM, please refer to this link.
MOAB Pre-installed
MOAB comes pre-built in several different flavors and can be directly installed on several supported platforms.
Optional Dependencies
There are several option dependencies for MOAB. Features and tools get automatically built based on the enabled dependencies when configuring MOAB library.
- MPI: MOAB supports usage of MPICH and OpenMPI libraries configured externally in order to enable scalable mesh manipulation algorithms.
- HDF5: In order to manage the data dependencies and to natively support parallel I/O, MOAB uses a custom file format that can represent the entire MOAB data model in a native HDF5-based file format.
- NetCDF: MOAB library optionally depends on the NetCDF libraries (C and C++) to compile the ExodusII reader/writer.
- Metis/ParMetis: MOAB can use the Metis or ParMetis library for partitioning mesh files in serial and parallel respectively
- Zoltan: Support for online partitioning through Zoltan (and its dependencies on Scotch, ParMetis etc) can be utilized through the partitioner tool
- TempestRemap: Provide support for both offline and online remapping of Climate field data on unstructured spherical meshes
- Eigen3: A substitute for BLAS/LAPACK interfaces. However if TempestRemap tools are to be built, this becomes a required dependency
Configuration and building from source
First, clone the sources from the repository using the command
git clone https://bitbucket.org/fathomteam/moab.git
Currently, both CMake and Autotools are maintained simultaneously in order to support all platforms (including Windows). Please choose your build system according to your needs and follow instructions below. Both of these workflows follow the same pattern of commands to build and install in your platform. Note that the autotools workflow may get deprecated in the future.
Autotools based configuration workflow
- Please ensure that the autotools toolchain is pre-installed locally. We recommend a minimum autoconf version of v2.69.
- Run
autoreconf -fi
to generate the configure script - Run the
configure --help
script in the top source directory to see a list of available configure options.- Use
--prefix=INSTALL_DIR
to specify installation directory - Override default compilers with environment or user options:
CC, CXX, FC, F77
- If you have MPI installed, use
--with-mpi=$MPI_DIR
- If you have HDF5 and NetCDF installed, use
--with-hdf5=$HDF5_DIR
and--with-netcdf=$NETCDF_DIR
to specify external dependencies. - Similarly for Metis or ParMetis dependencies, use
--with-metis=$METIS_DIR
and--with-parmetis=$PARMETIS_DIR
respectively - If you have Zoltan installed, use
--with-zoltan=$ZOLTAN_DIR
- In order to enable Python bindings (PyMOAB), you need to use
--enable-shared --enable-pymoab
options - Auto-Download options: MOAB now supports automatic dependency download and configuration that has been tested on various platforms and architectures.
- HDF5: Use
--download-hdf5
OR--download-hdf5=TARBALL_PATH
- NetCDF: Use
--download-netcdf
OR--download-netcdf=TARBALL_PATH
- Metis: Use
--download-metis
OR--download-metis=TARBALL_PATH
- TempestRemap: Use
--download-tempestremap
OR--download-tempestremap=master
(to build from Git master)
- HDF5: Use
- Use
- Now run the
configure
script with desired configuration options either in-source or out-of-source (build) directory.
CMake based configuration workflow
- Please ensure you have CMake (>3.0) available locally.
- Run
ccmake
visual configuration editor orcmake
to get a bare configuration of MOAB - If you would like to override the compiler used by default, use the following variables to override
- C:
-DCMAKE_C_COMPILER=mpicc
- C++:
-DCMAKE_CXX_COMPILER=mpicxx
- Fortran:
-DCMAKE_Fortran_COMPILER=mpif90
- C:
- Specify your installation directory by using
-DCMAKE_INSTALL_PREFIX=$MOAB_INSTALL_PATH
- If you have MPI installed, use
-DENABLE_MPI=ON -DMPI_HOME=$MPI_DIR
- If you have Eigen3 installed, use
-DEIGEN3_DIR=$EIGEN3_INCLUDE_DIR
- If you have HDF5 installed, use
-DENABLE_HDF5=ON -DHDF5_ROOT=$HDF5_DIR
- If you have NetCDF installed, use
-DENABLE_NETCDF=ON -DNETCDF_ROOT=$NETCDF_DIR
. - Similarly for Metis or ParMetis dependencies, use
-DENABLE_METIS=ON -DMETIS_DIR=$METIS_DIR
and-DENABLE_PARMETIS=ON -DPARMETIS_DIR=$PARMETIS_DIR
respectively - In order to enable Python bindings (PyMOAB), you need to use
-DBUILD_SHARED_LIBS=ON -DENABLE_PYMOAB=ON
options - If you have Zoltan installed, use
-DENABLE_ZOLTAN=ON -DZOLTAN_DIR=$ZOLTAN_DIR
options - If you have TempestRemap installed, use
-DENABLE_TEMPESTREMAP=ON -DTEMPESTREMAP_DIR=$TEMPESTREMAP_DIR
options
Once configuration with either autotools or the CMake workflow is complete in the build directory, run the following to build the library:
- Compile MOAB and supported tools:
make -j4
- Verify configuration and build setup:
make check
Next to install the compiled libraries, headers and tools, run: make install
- You can now use the
makefile
generated under thebuild/examples
folder and modify it to compile downstream code with MOAB dependency