2.2. Running PETSc Programs

Up: Contents Next: Writing PETSc Programs Previous: Suggested Reading

Before using PETSc, the user must first set the environmental variable PETSC_DIR, indicating the full path of the PETSc home directory. For example, under the UNIX C shell a command of the form

   setenv PETSC_DIR $HOME/petsc 
can be placed in the user's .cshrc file. In addition, the user must set the environmental variable PETSC_ARCH to specify the architecture (e.g., rs6000, sun4, solaris, etc.) on which PETSc is being used. The utility ${}PETSC_DIR/bin/petscarch can be used for this purpose. For example,
   setenv PETSC_ARCH `$PETSC_DIR/bin/petscarch` 
can be placed in a .cshrc file. Thus, even if several machines of different types share the same filesystem, PETSC_ARCH will be set correctly when logging into any of them.

All PETSc programs use the MPI (Message Passing Interface) standard for message-passing communication [16]. Thus, to execute PETSc programs, users must know the procedure for beginning MPI jobs on their selected computer system(s). For instance, when using the MPICH implementation of MPI [9] and many others, the following command initiates a program that uses eight processors:

   mpirun -np 8 petsc_program_name petsc_options 
All PETSc 2.0-compliant programs support the use of the -h or -help option as well as the -v or -version option.

Certain options are supported by all PETSc programs. We list a few particularly useful ones below; a complete list can be obtained by running any PETSc program with the option -help.


See Section Debugging for more information on debugging PETSc programs.


Up: Contents Next: Writing PETSc Programs Previous: Suggested Reading