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.
This is for 64-bit Xubuntu 13.04 on a x86-64 system. You will need Python, valgrind, gdb, gfortran, 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: 1, 2, 3.
./configure --with-cc=clang --with-fc=gfortran
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:
Scalar type: real
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:
Finally we are ready to build PETSc and test it:
Hopefully everything compiles successfully and passes the tests.