PETSc
FORTRAN77 Examples


This directory includes examples of the use of PETSc with a calling program written in FORTRAN77.

PETSc is a library of high level mathematical routines that can be executed in a parallel environment, making it easier for a user to gain the advantages of MPI.

PETSc stands for the Portable Extensible Toolkit for Scientific Computations.

PETSc is particularly suitable for the numerical solution of systems of partial differential equations on high performance computers. PETSc includes parallel linear and nonlinear equation solvers and time integrators that may be used by application programs written in C, C++, FORTRAN77 or FORTRAN90.

PETSc consists of a number of libraries which work with a particular family of objects, such as vectors. Some of the PETSc modules deal with

PETSc includes parts of the following software libraries:

PETSc runs in parallel by relying on:

A FORTRAN77 program that uses PETSc must specify many include files, from the basis level up to the level corresponding to the highest level PETSc objects needed within that program. That means that the user source code will include statements like

#include "include/finclude/petsc.h" #include "include/finclude/petscvec.h" #include "include/finclude/petscmat.h" #include "include/finclude/petscksp.h" #include "include/finclude/petscpc.h"
Moreover, the user source code must be passed through the C preprocessor in order for the text of the include files to be accessed. This means that the source code extension must be ".F", that is CAPITAL "F".

Usage:

Before using PETSc, the user must set the environment variable PETSC_DIR, indicating the full path of the PETSc home directory. On Phoenix, for instance, this might be done with the command

setenv PETSC_DIR /usr/local/petsc
This command might best be placed in the user's .cshrc file.

Before using PETSc, the user must set the environment variable PETSC_ARCH, indicating the architecture of the machine on which PETSc is to be run. On Phoenix, for instance, this might be done with the command

setenv PETSC_ARCH linux-gnu
This command might best be placed in the user's .cshrc file.

The commands required to compile, link and load a program with PETSc are complicated. It is best to use a makefile for this purpose, in which case most of the complications can be hidden. A bare bones makefile for the example ex1.F, which is going to use PETSc's Krylov Subspace Package (KSP), would look like this:

include ${PETSC_DIR}/bmake/common/base

ex1: ex1.o
	-${FLINKER} -o ex1 ex1.o ${PETSC_FORTRAN_LIB} ${PETSC_LIB}
      
To use this makefile, one simply types
make ex1
and the executable will be created.

The mpirun command may be used for SMALL jobs that run for a SHORT time on FEW processors. Repeated use of the mpirun command for large long jobs is an abuse of the system and will not be allowed.

To run a program that uses PETSc, the user may invoke the mpirun command, specifying the number of processors.

mpirun -np 4 ex1
The mpirun command will automatically log the user into 3 more nodes of Phoenix, (requiring the user to type in a password each time!).

To run a program that uses PETSc, the CONDOR system is preferable. This is a batch system which tries to be fair and efficient in the allocation of computing resources. To use CONDOR, the user should create an executable program, then prepare a "CONDOR submit script" that describes how the executable is to be run, and on how many processors, and submit the script. Details and examples of how to do this are given on the CONDOR examples page.

Related Data and Programs:

BLAS1, a vector-vector library, is included in PETSC.

BLAS2, a matrix-vector library, is included in PETSC.

BLAS3, a matrix-matrix library, is included in PETSC.

CONDOR, is a queueing system used locally to submit jobs to our parallel clusters.

LAPACK, an extensive linear algebra library, is included in PETSC.

LINPACK, an extensive linear algebra library, is included in PETSC.

MINPACK, a library for minimization and least squares, is included in PETSC.

MPI is used as part of the PETSC library. You may be interested in seeing examples of that parallel programming system.

PESSL is a parallel mathematics library developed exclusively for IBM systems.

PETSc examples are also available in a C version, and a C++ version, and a FORTRAN90 version.

SPARSEKIT2, Yousef Saad's library for sparse matrices, is included in PETSC.

SPARSEPAK, a library of sparse matrix reordering routines, is included in PETSC.

Reference:

  1. Satish Balay, Kris Buschelman, Victor Eijkhout, William Gropp, Dinesh Kaushik, Matt Knepley, Lois Curfman McInnes, Barry Smith, Hong Zhang,
    The PETSc Users Manual,
    ANL-95/11, Revision 2.3.0,
    Argonne National Laboratory;
    A copy is available in a PDF version.
  2. Jeff Borggaard,
    A PETSc Tutorial (in C);
    A copy is available in a PDF version.
  3. The PETSc website
    http://www.mcs.anl.gov

Examples and Tests:

MAKEFILE contains the information necessary to properly compile, link and load the various user examples. If you use PETSc, you will have to have a similar makefile. The makefile is used by typing commands like

make ex1
which compiles, links and loads the program ex1.F, creating the executable ex1, which may then be run by submitting a Condor job.

HELLO is the "Hello, world!" example. This example may be run on any number of processors. Note that the file extension if ".F" (that is, CAPITAL "F"). This is a signal that indicates that the code should be preprocessed by the C preprocessor. This is how the include files are taken care of.

EX1 is an example program from the PETSc website. It demonstrates the use of the Krylov Subspace Package. This example may be run on a SINGLE processor. Note that the file extension if ".F" (that is, CAPITAL "F"). This is a signal that indicates that the code should be preprocessed by the C preprocessor. This is how the include files are taken care of.

EX22 is an example program from the PETSc website. It demonstrates the use of the Krylov Subspace Package. This example may be run on MULTIPLE processors.

You can go up one level to the FORTRAN77 source codes.


Last revised on 17 January 2006.