Compiling a PETSc Program

 

Make sure that the environmental variables  PETSC_ARCH and PETSC_DIR are set in your shell.

Copy the two files ${PETSC_DIR}/src/sys/examples/tutorials/makefile and ex2.c to your working directory (use the right mouse button and select Save Target as ... to directly save the file)

Type make ex2 (sample output)

Type mpiexec -np 2 ex2 (sample output)

If you have problems, STOP, either MPI or PETSc are not installed properly or one of your environmental variables is not correct. See the troubleshooting guide

Detailed discussion of PETSc makefiles in the users manual