Installing PETSc and libMesh on CentOS 5

Prerequisites: boost-devel, openmpi-devel, valgrind-devel

I installed PETSc and libMesh in my user directory, since I have a single-user workstation.

Installing PETSc for use with libMesh

First, ensure that OpenMPI is installed and the system paths have been configured correctly.  You will need to add the directory containing OpenMPI binaries to your $PATH, and the directory containing OpenMPI libraries to $LD_LIBRARY_PATH.  CentOS does not do this automatically!  Type mpicc on the command line to make sure the shell can find the binary.  If mpicc and mpif77 run, then you should not need to use the comnand-line flags to the configure script for PETSc.

If you are going to use libMesh with PETSc, you need to enable C++ with a command-line option to the configure script.  Here is the process I used (it might be a good idea to set PETSC_ARCH and PETSC_DIR in your .bashrc so they are consistent for all builds).

tar xfz petsc-3.2-p6.tar.gz
cd petsc-3.2-p6
./configure --with-clanguage=c++
make PETSC_ARCH=arch-linux2-c-debug all
make PETSC_ARCH=arch-linux2-c-debug test

Installing libMesh

You must have compiled PETSc with C++ support, as detailed above, to install libMesh successfully.  Also, the environment variables PETSC_ARCH and PETSC_DIR in the libMesh build environment must have the same values used to build PETSc.  Once PETSc is built correctly, libMesh is easy to build:

 cd libmesh-0.7.2/libmesh
make run_examples

That’s it!  Please comment below if you have a different experience.

Leave a Reply