\chapter{Trilinos}
\label{app:trilinos}

In order to solve PDEs with complex coefficients, escript needs to be compiled with \texttt{Trilinos} support.
This requires that your version of Trilinos has certain features enabled.
Since some precompiled distributions of \texttt{Trilinos} are not built with these features, you may 
need to compile \texttt{Trilinos} yourself as well.

While we can't provide support for building \texttt{Trilinos}, we provide here two configuration files which seem to work for 
Debian 10 ``buster'. One of these cmake script builds \texttt{Trilinos} with MPI support and one builds \texttt{Trilinos} without MPI support.

\section{Debian ``buster'' configuration}


\subsection{Required packages}

The following packages should be installed to attempt this build:
\begin{itemize}
\item[] cmake
\item[] g++
\item[] libsuitesparse-dev
\item[] libmumps-dev
\item[] libboost-dev
\item[] libscotchparmetis-dev
\item[] libmetis-dev
\item[] libcppunit-dev
\end{itemize}

\subsection{Example configuration file (without MPI)}
\begin{verbatim}
#!/bin/bash

# Set this to the root of your Trilinos source directory.
TRILINOS_PATH=../trilinos_source

rm -f CMakeCache.txt

EXTRA_ARGS=$@

cmake \
      -D CMAKE_C_COMPILER=`which gcc` \
      -D CMAKE_CXX_COMPILER=`which g++` \
      -D CMAKE_Fortran_COMPILER=`which gfortran` \
      -D PYTHON_EXECUTABLE=/usr/bin/python3 \
      -D CMAKE_INSTALL_PREFIX=/usr/local/ \
      -D Trilinos_ENABLE_CXX11=ON \
      -D CMAKE_C_FLAGS=' -w -fopenmp' \
      -D CMAKE_CXX_FLAGS=' -w -fopenmp'\
      -D Trilinos_ENABLE_Fortran=ON \
      -D BUILD_SHARED_LIBS=ON \
      -D TPL_ENABLE_BLAS=ON \
      -D TPL_ENABLE_Boost=ON \
      -D TPL_ENABLE_Cholmod=ON \
      -D TPL_ENABLE_LAPACK=ON \
      -D TPL_ENABLE_METIS=ON \
      -D TPL_ENABLE_SuperLU=OFF \
      -D TPL_ENABLE_UMFPACK=ON \
      -D TPL_BLAS_INCLUDE_DIRS=/usr/include/suitesparse \
      -D TPL_Cholmod_INCLUDE_DIRS=/usr/include/suitesparse \
      -D TPL_Cholmod_LIBRARIES='libcholmod.so;libamd.so;libcolamd.so' \
      -D TPL_UMFPACK_INCLUDE_DIRS=/usr/include/suitesparse \
      -D TPL_Boost_INCLUDE_DIRS=/usr/local/boost/include \
      -D TPL_Boost_LIBRARY_DIRS=lib \
      -D Trilinos_ENABLE_Amesos=ON \
      -D Trilinos_ENABLE_Amesos2=ON \
      -D Trilinos_ENABLE_AztecOO=ON \
      -D Trilinos_ENABLE_Belos=ON \
      -D Trilinos_ENABLE_Ifpack=ON \
      -D Trilinos_ENABLE_Ifpack2=ON \
      -D Trilinos_ENABLE_Kokkos=ON \
      -D Trilinos_ENABLE_Komplex=ON \
      -D Trilinos_ENABLE_ML=ON \
      -D Trilinos_ENABLE_MueLu=ON \
      -D Trilinos_ENABLE_Teuchos=ON \
      -D Trilinos_ENABLE_Tpetra=ON \
      -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES=ON \
      -D Kokkos_ENABLE_AGGRESSIVE_VECTORIZATION=ON \
      -D Tpetra_INST_COMPLEX_DOUBLE=ON \
      -D Trilinos_ENABLE_COMPLEX_DOUBLE=ON \
      -D Teuchos_ENABLE_COMPLEX=ON \
      -D Tpetra_INST_INT_INT=ON \
      -D Tpetra_ENABLE_DEPRECATED_CODE=ON \
      -D Trilinos_ENABLE_OpenMP=ON \
      -D Trilinos_ENABLE_MPI=OFF \
      -D Trilinos_ENABLE_EXPLICIT_INSTANTIATION=ON \
      -D Kokkos_ENABLE_COMPILER_WARNINGS=ON \
      -D Amesos2_ENABLE_Basker=ON \
      -D Tpetra_INST_SERIAL:BOOL=ON \
      -D Trilinos_ENABLE_TESTS=OFF \
$EXTRA_ARGS \
$TRILINOS_PATH
\end{verbatim}


\subsection{Example configuration file (with MPI)}
\begin{verbatim}
#!/bin/bash

# Set this to the root of your Trilinos source directory.
TRILINOS_PATH=../trilinos_source

#
# You can invoke this shell script with additional command-line
# arguments.  They will be passed directly to CMake.
#
EXTRA_ARGS=$@

rm -f CMakeCache.txt

cmake \
      -D MPI_C_COMPILER=`which mpicc` \
      -D MPI_CXX_COMPILER=`which mpic++` \
      -D MPI_Fortran_COMPILER=`which mpif90` \
      -D PYTHON_EXECUTABLE=/usr/bin/python3 \
      -D CMAKE_INSTALL_PREFIX=/usr/local/ \
      -D Trilinos_ENABLE_CXX11=ON \
      -D CMAKE_C_FLAGS=' -w -fopenmp' \
      -D CMAKE_CXX_FLAGS=' -w -fopenmp'\
      -D Trilinos_ENABLE_Fortran=ON \
      -D BUILD_SHARED_LIBS=ON \
      -D TPL_ENABLE_BLAS=ON \
      -D TPL_ENABLE_Boost=ON \
      -D TPL_ENABLE_Cholmod=ON \
      -D TPL_ENABLE_LAPACK=ON \
      -D TPL_ENABLE_METIS=ON \
      -D TPL_ENABLE_SuperLU=OFF \
      -D TPL_ENABLE_UMFPACK=ON \
      -D TPL_ENABLE_PARMETIS=ON \
      -D TPL_ENABLE_SCALAPACK=ON \
      -D TPL_ENABLE_MUMPS=OFF \
      -D TPL_BLAS_INCLUDE_DIRS=/usr/include/suitesparse \
      -D TPL_Cholmod_INCLUDE_DIRS=/usr/include/suitesparse \
      -D TPL_Cholmod_LIBRARIES='libcholmod.so;libamd.so;libcolamd.so' \
      -D TPL_UMFPACK_INCLUDE_DIRS=/usr/include/suitesparse \
      -D TPL_Boost_INCLUDE_DIRS=/usr/local/boost/include \
      -D TPL_Boost_LIBRARY_DIRS=lib \
      -D TPL_MUMPS_INCLUDE_DIRS='/usr/include/mumps-seq-shared/' \
      -D Trilinos_ENABLE_Amesos=ON \
      -D Trilinos_ENABLE_Amesos2=ON \
      -D Trilinos_ENABLE_AztecOO=ON \
      -D Trilinos_ENABLE_Belos=ON \
      -D Trilinos_ENABLE_Ifpack=ON \
      -D Trilinos_ENABLE_Ifpack2=ON \
      -D Trilinos_ENABLE_Kokkos=ON \
      -D Trilinos_ENABLE_Komplex=ON \
      -D Trilinos_ENABLE_ML=ON \
      -D Trilinos_ENABLE_MueLu=ON \
      -D Trilinos_ENABLE_Teuchos=ON \
      -D Trilinos_ENABLE_Tpetra=ON \
      -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES=ON \
      -D KOKKOS_ENABLE_AGGRESSIVE_VECTORIZATION=ON \
      -D Tpetra_INST_COMPLEX_DOUBLE=ON \
      -D Teuchos_ENABLE_COMPLEX=ON \
      -D Tpetra_INST_INT_INT=ON \
      -D Tpetra_ENABLE_DEPRECATED_CODE=ON \
      -D Trilinos_ENABLE_OpenMP=ON \
      -D Trilinos_ENABLE_MPI=ON \
      -D Trilinos_ENABLE_EXPLICIT_INSTANTIATION=ON \
      -D KOKKOS_ENABLE_COMPILER_WARNINGS=ON \
      -D Amesos2_ENABLE_Basker=ON \
      -D Tpetra_INST_SERIAL:BOOL=ON \
      -D Trilinos_ENABLE_TESTS=OFF \
$EXTRA_ARGS \
$TRILINOS_PATH
\end{verbatim}
