InstallGuides/MatlabUbuntu

How to install Chaste on Ubuntu in preparation for using the MATLAB interface to cell-based Chaste

This guide is only for set up. The files for operating the MATLAB interface for cell-based Chaste have not yet been released.

This guide is the result of the project undertaken by Tom Dunton at the MathWorks. It is known to work with Chaste (revision 15715) and MATLAB R2012a - stray from these versions at your own risk. These instructions have been followed successfully on 64bit versions of Ubuntu 11.10 and 12.04. To avoid conflicting with any existing versions of Chaste, it is advisable to install Ubuntu as a virtual machine on your current system - at least that is what I did while working on the Windows computers at the MathWorks.

MATLAB is distributed with its own versions of BLAS, LAPACK, Boost, CVODE, HDF5, Xerces (almost all of the libraries that Chaste uses!). To circumvent the issues this raises, we have to rebuild some of Chaste's dependencies, so that they use MATLAB's versions of some libraries.

Throughout this guide, you should be able to copy the entire text within each command box and past it into a terminal window to complete the installation.

Prerequisites

Chaste

Install the Chaste dependencies with the following commands. These are taken from the installation instructions for the chaste-dependencies.deb package.

sudo bash -c 'echo "deb http://www.cs.ox.ac.uk/chaste/ubuntu /" >> /etc/apt/sources.list.d/chaste.list'
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 422C4D99
sudo apt-get update
sudo apt-get install --install-recommends chaste-dependencies
sudo apt-get install `dpkg -s chaste-dependencies | egrep "^Suggests" | \
cut -d "," -f 1-111 --output-delimiter " " | cut -d ":" -f 2`

Matlab

You must then install MATLAB (version R2012a) before proceeding.

Environmental variables

In order for Chaste's hostconfig system to work successfully, the following environmental variables need to be set in your $HOME/.profile file. These environment variables are read by the Chaste host configuration script attached to this guide (local.py). The examples given below should be correct if you installed Chaste's dependencies using the instructions above and used the default installation options for MATLAB. If you used different options, you will need to change these locations to match your configuration, both in these instructions and within local.py.

CHASTE
Directory where you will install Chaste and any re-compiled dependencies (default is $HOME/Chaste).
MATLABROOT
Root directory of your MATLAB installation (default is /usr/local/MATLAB/R2012a).
DOWNLOAD_DIR
Download location of the files attached to this guide (default is $HOME/Downloads ).
echo "export CHASTE=$HOME/Chaste" >> $HOME/.profile
echo "export MATLABROOT=/usr/local/MATLAB/R2012a" >> $HOME/.profile
echo "export DOWNLOAD_DIR=$HOME/Downloads" >> $HOME/.profile
 

Before performing the steps outlined below, you need to download all of the attached files to $DOWNLOAD_DIR - click on each attachment, then at the bottom of the page there is a link to download in original format. You will also need to log out and back in again, so that your modified .profile file is loaded.

PETSc

The BLAS and LAPACK libraries used by MATLAB do not use int, but instead use ptrdiff_t, so we have to recompile PETSc after applying the attached petsc.patch file. We also have to stop PETSc from catching the signal SIGSEGV, since MATLAB uses this for internal communication. To compile PETSc with the necessary changes, execute these commands in a terminal window.

mkdir -p $CHASTE
cd $CHASTE
wget ftp://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.1-p4.tar.gz
tar xvzf petsc-3.1-p4.tar.gz
rm -f petsc-3.1-p4.tar.gz
mv petsc-3.1-p4 petsc
cd petsc
patch -p0 <$DOWNLOAD_DIR/petsc.patch
export PETSC_DIR=$(pwd)
export PETSC_ARCH=openmpi-debug 
./config/configure.py --LDFLAGS="-Wl,-rpath,$MATLABROOT/bin/glnxa64,-rpath,$MATLABROOT/sys/os/glnxa64" \
--with-blas-lib=$MATLABROOT/bin/glnxa64/libmwblas.so --with-lapack-lib=$MATLABROOT/bin/glnxa64/libmwlapack.so \
--download-openmpi=1 --download-hypre=1 --with-x=0 --with-clanguage=cxx --with-shared=1 --CXXFLAGS="-DPETSC_MISSING_SIGSEGV"
make all
 

For any PETSc test to pass, you will need to force it to load the newer versions of the gfortran and stdc++ libraries, which are shipped with Ubuntu, eg. for running the post-install tests of PETSc, you would issue the following command instead of that issued by the builder.

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.3:/usr/lib/x86_64-linux-gnu/libstdc++.so.6 make test
 

Boost

MATLAB ships with Boost 1.44, but this version is known to have some bugs with the serialization (see [ here] for details). We will therefore need to install a patched Boost, keeping to the same version as that used by MATLAB to avoid conflicts.

mkdir -p $CHASTE
cd $CHASTE
wget http://downloads.sourceforge.net/project/boost/boost/1.44.0/boost_1_44_0.tar.gz
tar xvzf boost_1_44_0.tar.gz
rm -f boost_1_44_0.tar.gz
mv boost_1_44_0 boost
cd boost
patch -p0 <$DOWNLOAD_DIR/boost.patch
./bootstrap.sh --prefix=. --with-libraries=serialization,system,filesystem
./bjam install
 

HDF5

We also need to install the correct version of HDF5 for MATLAB (v1.8.6).

cd $CHASTE
wget http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.6/src/hdf5-1.8.6.tar.gz
tar xvzf hdf5-1.8.6.tar.gz
rm -f hdf5-1.8.6.tar.gz
cd hdf5-1.8.6
export CC=$CHASTE/petsc/openmpi-debug/bin/mpicc
CFLAGS=-O1 ./configure --enable-parallel --prefix=$CHASTE/hdf5 --enable-shared
make
cd test
make check
cd ../testpar
make check
cd ..
make install
cd ..
rm -rf hdf5-1.8.6
unset CC
 

Chaste

Firstly we need to get the Chaste source from the SVN repository.

cd $CHASTE
svn --username anonymous --revision 15715 checkout https://chaste.cs.ox.ac.uk/svn/chaste/trunk/ src

When prompted for your password enter your email address.

cd $CHASTE/src
cp $DOWNLOAD_DIR/local.py python/hostconfig/
 

We should now be able to build Chaste. We must, however, ensure that we preload the gfrotran and stdc++ libraries as described above, otherwise the incorrect versions included in the MATLAB directory will be used. We also need to preload the HDF5 library, to avoid using the version distributed with MATLAB.

cd $CHASTE/src
LD_PRELOAD=$CHASTE/hdf5/lib/libhdf5.so:/usr/lib/x86_64-linux-gnu/libgfortran.so.3:/usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
scons cl=1 build=GccOpt
 

When you have confirmed that all the tests have passed, you must then install the Chaste libraries and headers to a single location.

cd $CHASTE/src
LD_PRELOAD=$CHASTE/hdf5/lib/libhdf5.so:/usr/lib/x86_64-linux-gnu/libgfortran.so.3:/usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
scons co=1 cl=1 build=GccOpt install_prefix=$CHASTE install
 

Finished

Your system is now ready to run the MATLAB interface for cell-based Chaste.

Attachments