5.3. Build from Source (for Developers)¶
5.3.1. Obtaining MFiX Source¶
This section describes how developers build MFiX packages for distribution. Most users will not need to do this.
Building from source requires the MFiX source tarball, which can be obtained on the MFiX download page. Extract the tarball and go into the top level source directory:
> tar xf mfix-20.3.1.tar.gz > cd mfix-20.3.1 > pwd /home/user/mfix-20.3.1
5.3.2. Building Solver from Source¶
You can build the Batch Solver from source, without the MFiX conda package installed. This is how MFiX was built in version 2016 and earlier.
cmake to configure MFiX and generate a Makefile, then run
make to build the MFiX solver.
cmake will generate a
CMakeCache.txt file in the directory it is
invoked from. Please include
CMakeCache.txt when posting a question about
build issues to the forum.
The default configuration for MFiX is serial with optimizations and debug symbols (standard optimization; for GFortran use flags
> pwd /home/user/mfix-20.3.1 # actual working directory will vary > mkdir release-build > cd release-build > cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo # .. is the relative path to the top-level MFiX source directory > cmake .. # same thing (RelWithDebInfo is the default CMAKE_BUILD_TYPE)
Using an “out of source” build is recommended. Create a new directory,
to that directory, and run
cmake <path> where
<path> is the top-level
MFiX source directory (containing
CMakeLists.txt). Out of source builds
are convenient for having different solvers built with different
configurations. The build directory can be whatever you want;
debug-build used here are just examples.
To configure the MFiX solver in serial with debug mode (no optimization; for GFortran use flags
> mkdir debug-build > cd debug-build > cmake .. -DCMAKE_BUILD_TYPE=Debug
mpifort is your MPI compiler wrapper command, then to configure the MFiX solver with DMP with optimizations and debug symbols:
> mkdir release-build > cd release-build > cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_MPI=1 > cmake .. # same thing (RelWithDebInfo is the default CMAKE_BUILD_TYPE)
mpifort is your MPI compiler wrapper command, then to configure the MFiX solver with DMP with debug mode:
> mkdir debug-build > cd debug-build > cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_MPI=1
To specify the Fortran compiler, define CMAKE_Fortran_COMPILER:
> cmake .. -DCMAKE_Fortran_COMPILER=ifort # for example
To add specific Fortran compiler flags, define CMAKE_Fortran_FLAGS:
> cmake .. -DCMAKE_Fortran_FLAGS="-O0 -g -Wall -fcheck=all" # for example
To configure with SMP support:
> cmake .. -ENABLE_OpenMP=1
Options can be combined in a single command:
> cmake .. -ENABLE_OpenMP=1 -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_Fortran_FLAGS="-O0 -g -Wall -fcheck=all"
Example with gfortran, serial optimized solver configuration:
> cmake .. -DENABLE_MPI=0 -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_Fortran_FLAGS="-O2 -g"
Example with gfortran, DMP optimized solver configuration:
> cmake .. -DENABLE_MPI=1 -DMPI_Fortran_COMPILER=mpifort -DCMAKE_Fortran_FLAGS="-O2 -g"
Example with gfortran, serial debug mode solver configuration:
> cmake .. -DENABLE_MPI=0 -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_Fortran_FLAGS="-O0 -fcheck=all -ffpe-trap=invalid,zero,overflow -g"
Example with gfortran, DMP debug mode solver configuration:
> cmake .. -DENABLE_MPI=1 -DMPI_Fortran_COMPILER=mpifort -DCMAKE_Fortran_FLAGS="-O0 -fcheck=all -ffpe-trap=invalid,zero,overflow -g"
For DMP support, defining
-DENABLE_MPI=1 is required. Defining
CMAKE_Fortran_COMPILER as your MPI wrapper (
mpifort) is recommended,
but not strictly required. CMake should automatically detect MPI include
files and libraries for your default compiler, but specifying
CMAKE_Fortran_COMPILER is better to ensure you are using the exact
compiler you intend to use.
CMake uses configurations values from both
CMakeCache.txt and from
command line arguments. Command line arguments take precedence over
CMakeCache.txt is used if nothing is specified on
the command line. For instance, if you run
-DCMAKE_Fortran_FLAGS="-fcheck=all", and then run
cmake .. again (in
the same build directory),
-fcheck=all will still be used (because it is
CMakeCache.txt). If this is not what you want, either edit
CMakeCache.txt, or just delete
CMakeCache.txt and run
with different options.
After configuring, build with make. For further details about the make utility,
man make at the prompt.
> make > make -j # for parallel build jobs > make VERBOSE=1 # to view the full command lines used for compiling and linking
At the end of a successful build, the MFiX solver will be located in the current directory.
The solver is called
mfixsolver on Linux.
5.3.3. Building Conda package¶
> conda install conda-build
The conda package recipes are under
conda/. Refer to the
conda-build documentation for