Setting Up PETSc on Xubuntu 13.04

For the purposes of documenting this for myself (and perhaps others) here are the various pieces of what I’ve done to set up PETSc (Portable, Extensible Toolkit for Scientific Computation)  for Xubuntu.

Preliminary Steps
This is for 64-bit Xubuntu 13.04 on a x86-64 system. You will need Pythonvalgrind, gdbgfortran, and C/C++ compilers. In my case I choseClang for both. Clang uses the LLVM backend for compilation. It is more feature complete than gcc and was C++11 compliant first and even is C++1y compliant. It generates superior errors and I think is going to be the future accepted standard when it comes to compilation. I found the following pages invaluable in setting up Clang: 123.

PETSc Setup
The PETSc website has a good tutorial for installation. This is what I modified for my setup for PETSc 3.4.3.
./configure --with-cc=clang --with-fc=gfortran --with-cxx=clang++ --download-f-blas-lapack --download-mpich
You may be tempted to add “–with-clanguage=cxx” if you plan to use PETSc in a C++ program, however as of PETSc 3.4 :
“The configure options –with-c-support and –with-c++-support have been removed. A PETSc library built using C or C++ can be called from either C or C++. The primary functional reason to use –with-clanguage=C++ is to usestd::complex data types. Other users will likely prefer –with-clanguage=C (the default) because it compiles somewhat faster. The –with-c-support option is no longer needed because it is now the default behavior when using –with-clanguage=c++.”
If you persist with using the cxx option, Clang will generate warnings because it is deprecated behavior to compile C code with Clang++.
PETSc will download MPICH and blas/lapack as needed. It is important that MPI and PETSc are compiled with the same compiler. It will install these dependencies and then setup itself. At the end it will give some output including:
  PETSC_ARCH: arch-linux2-c-debug
  PETSC_DIR: /home/userjjb/PETSc/petsc-3.4.3A
  Clanguage: C
  Scalar type: real
  Precision: double
  Memory alignment: 16
  shared libraries: enabled
  dynamic loading: disabled
Next you should set up your PETSc environment variables (this isn’t strictly necessary, you can specify these variables at the command line, but I plan to primarily use one PETSc install so it saves me some typing). In a bash shell you should use export, for my variables I did:
export PETSC_DIR=/home/userjjb/PETSc/petsc-3.4.3A
export PETSC_ARCH=arch-linux2-c-debug
Finally we are ready to build PETSc and test it:
make all
make test
Hopefully everything compiles successfully and passes the tests.