Compiling with or without petsc

Satish Balay balay at
Mon Jun 19 10:18:50 CDT 2006

On Mon, 19 Jun 2006, Laslo Tibor Diosady wrote:

> Hi,
> I'm trying to create a distribution  which can be built both with and without
> petsc. The idea behind this is that when only running uni-processor cases
> typically petsc will not be needed so that users do not need a copy of petsc
> on their machine. 

I'm guesing this is the choice your code makes as PETSc+mpiuni or
petsc+mpi works in uniproc mode as well.

> I was wondering if  there is an easy way to detect the
> presence of petsc on your local machine and if petsc exists have a flag set
> which can be used in the makefile to comile with petsc. Also would it be
> possible to find the top petsc directory and specity the environment variables
> $PETSC_DIR and $PETSC_ARCH so that this does not need to be done manually by
> the user.

This is a general configure problem. Its not easy to detect any
package without a complicated detection system. [its easier for some
packages that reside in /usr or use a single config format such as

For PETSc, the detection code in 'BuildSystem'. This configure code
attempts to autodetect all possible external packages PETSc might
require [different types of mpi, blas etc..] - and if none exists - it
can download-install them.

The easiest way to detect PETSc is if PETSC_DIR/PETSC_ARCH are
provided. The alternative would be to do a 'global find for
petscconf.h' and then guess PETSC_DIR/PETSC_ARCH from this - and see
if the libs are built & operational with this combination.

But then, there could be multiple or non compliant installs of PETSc.
For ex: - you might be expecting a c/real install of PETSc but might
find a c++ or a complex install of PETSc.


> Any help in this area would be greatly appreciated.
> Thanks,
> Laslo

More information about the petsc-users mailing list