Docs:  Installation

  1. (Windows only) Install the cygwin package and use bash as the working shell. Windows hints
  2. Locate BLAS and LAPACK on your machine or install them
  3. Locate MPI on your machine or install it. Don't want MPI
  4. Download the PETSc distribution, apply the patches, and cd to the PETSc directory
  5. Run bin/petscarch -suggest         (I got my PETSc from the Bitkeeper site)
  6. bash shell
    export PETSC_DIR=`pwd`        (note the backquote)
    export PETSC_ARCH=selectedvalue
    csh/tcsh shell
    setenv PETSC_DIR `pwd`
    setenv PETSC_ARCH selectedvalue
  7. - Automatic configuration, (experimental) run python config/configure.py 
    - Manual configuration, edit bmake/${PETSC_ARCH}/packages and specify the location of BLAS, LAPACK and MPI.
  8. Add optional packages to the bmake/${PETSC_ARCH}/packages
  9. make BOPT=g all
  10. make BOPT=g test
  11. Encounter problems? Check the bug-reporting section

Example Usages:

  • install PETSc with configure.py on linux, assuming BLAS, LAPACK, MPICH software are installed at the specified locations:
            export PETSC_DIR=/home/petsc/petsc-2.1.6
            cd $PETSC_DIR
            bin/petscarch -suggest
            export PETSC_ARCH=linux-gnu
            config/configure.py --with-blas=/usr/lib/libblas.a --with-lapack=/usr/lib/liblapack.a --with-mpi-dir=/usr/local/mpich
            make BOPT=g all
            make BOPT=g test
  • install PETSc on solaris  manually  by modifying the configuration files with Sun compilers
            export PETSC_DIR=/home/petsc/petsc-2.1.6
            cd $PETSC_DIR
            bin/petscarch -suggest
            export PETSC_ARCH=solaris

      edit bmake/solaris/packages - and update the location of BLAS, LAPACK, MPI
            cd $PETSC_DIR
            make BOPT=g all
            make BOPT=g test
  • install PETSc on windows, with MPICH-NT, Microsoft Compilers, Intel MKL
      install cygwin package and use 'bash' from cygwin to as the working shell
            export PETSC_DIR=/home/petsc/petsc-2.1.6
            cd $PETSC_DIR
            bin/petscarch -suggest
            export PETSC_ARCH=win32_ms_mpich

      edit bmake/win32_ms_mpich/packages and make sure the paths to MPICH-NT, Intel MKL (BLAS,LAPACK) are correct
            cd $PETSC_DIR
            make BOPT=g all
            make BOPT=g test

PETSC_DIR: - this environment/make variable should point to the location of the PETSc installation that is used. You can add export PETSC_DIR=value in your .profile or .sh file or setenv PETSC_DIR value in your .cshrc or .tcshrc file. Multiple PETSc versions of PETSc can coexist on the same file-system. By changing PETSC_DIR value one can switch between the versions

PETSC_ARCH: this environment/make variable is used to specify the configuration that should currently be used. It corresponds to the configuration files in bmake/${PETSC_ARCH}. Multiple variants of PETSc libraries can be installed - each variant corresponding to a different PETSC_ARCH. One can switch between using these variants - by changing the value of PETSC_ARCH

BOPT: this environment/make variable is used to distinguish debug/optimized or c/c++/complex versions of PETSc libraries. One can install, any/all variants of the libraries, and switch between them by changing the value of BOPT. The table below explains the most common BOPT values.

 g  debug version of PETSc libraries - useable from C, fortran
 g_c++  debug version of PETSc libraries - useable from C++, fortran
 g_complex  debug complex version of PETSc libraries - useable from C++, fortran
 O  Optimized version of PETSc libraries - useable from C, fortran
 O_c++  Optimized version of PETSc libraries - useable from C++, fortran
 O_complex  Optimized version of PETSc libraries - useable from C++, fortran

example usage - assuming ex1.c is user code, and a makefile with a target to compile ex1 exists: 
    make BOPT=g PETSC_ARCH=linux PETSC_DIR=/home/petsc/petsc-2.1.5 ex1

Return to Installation Instructions


bmake/${PETSC_ARCH}/packages:  this configuration file, corresponding to the PETSC_ARCH used, contains the configuration for all external software packages - PETSc is installed with. The specification is in the compiler notation for include paths, library paths, library names.

 Compiler flag   Example  Explanation
 -D  -DPETSC_HAVE_X11  define a macro
 -I  -I/home/petsc/mpich-1.2.5/include  specify include paths to the compiler
 -L  -L/home/petsc/mpich-1.2.5/lib  specify the library paths to the compiler
 -l  -lmpich  specify the name of the library to link to- if the library is libmpich.a
 filename  /home/petsc/foo.a  specify the library to link to (which cannot be specified using -l)

bmake/${PETSC_ARCH}/variables: this file contains the configuration for the C, C++, fortran compilers - that are associated with the PETSC_ARCH used.

Return to Installation Instructions


Cygwin:  it provides UNIX tools on windows - which enable PETSc install on windows. When installing cygwin make sure you install the patch utility (for some strange reason this is not installed by default). Cygwin also has GNU compilers - which can be used  if Microsoft compilers are not available

 Cygwin  http://www.cygwin.com

Return to Installation Instructions


BLAS/LAPACK: these packages provide basic numeric kernels used by PETSc. This is available from the following sources

  • on Windows, one can use Intel MKL
  • On AIX boxes, ESSL, on OSF (alpha) DXML, on Solaris Sunperf libraries provide this functionality
  • On some linux boxes, regular blas/lapack is installed [/usr/lib/liblapack.a /usr/lib/libblas.a ]
  • Alternatively download the source distribution fblaslapack or cblaslapack from PETSc download page
 BLAS  http://www.netlib.org/blas
 LAPACK     http://www.netlib.org/lapack
 Intel MKL  http://www.intel.com/software/products/mkl
 fblaslapack  http://www.mcs.anl.gov/petsc/petsc-2/download
 cblaslapack  http://www.mcs.anl.gov/petsc/petsc-2/download
 ESSL  http://www-1.ibm.com/servers/eserver/pseries/library/sp_books/essl.html

Return to Installation Instructions


MPI: This software provides the parallel functionality for PETSc. This is available from the following sources

  • On parallel machines, Vendor provided MPI might already be installed.  IBM, SGI, Cray etc provide their own. 
  • If vendor provided MPI is not available, it can be installed from sources. We recommend MPICH
 MPI     http://www.mpi-forum.org
 MPICH  http://www.mcs.anl.gov/mpi/mpich
 LAM  http://www.lam-mpi.org
 MPICH-NT (windows)  http://www-unix.mcs.anl.gov/~ashton/mpich.nt
 MPI/Pro (windows)  http://www.mpi-softtech.com/products/mpi_pro
 HPVM (windows)  http://www-csag.ucsd.edu/projects/hpvm.html
 WMPI (windows)  http://www.criticalsoftware.com/hpc

Return to Installation Instructions


I don't want to use MPI: You can build (sequential) PETSc without an MPI.

  • If building PETSc with configure run config/configure.py --with-mpi=0 ....
  • Otherwise edit bmake/${PETSC_ARCH}/packages and use
    # Location of MPI (Message Passing Interface) software
    #
    MPI_LIB        = ${PETSC_DIR}/lib/lib${BOPT}/${PETSC_ARCH}/libmpiuni.a
    MPI_INCLUDE    = -I${PETSC_DIR}/src/sys/src/mpiuni
    MPIRUN         = ${PETSC_DIR}/src/sys/src/mpiuni/mpirun
    

Return to Installation Instructions


Downloading PETSc and applying Patches: 

  • download the distribution and the latest patches file from PETSc download section
  • extract the distribution file
            gnuzip -c petsc.tar.gz | tar -xof -
  • apply the patches (using GNU patch utility)
            cd petsc-2.1.6
            patch -Np1 < petsc_patches_all_2.1.6

Return to Installation Instructions


Configure:

Instead of manually editing bmake/${PETSC_ARCH}/* files one can use config/configure.py to create these files - for the specified PETSC_ARCH

Configure is implemented in python and requires python version 2.2 or newer.

With configure build, the PETSC_ARCH should be chosen from the suggested value by 'bin/petscarch -suggest'. For example, on a linux box, to use configure one should use linux-gnu, or linux-gnu-foobar etc.  

examples:

  • config/configure.py --help
  • config/configure.py --with-mpi-dir=/usr/local/mpich --with-blas=/usr/lib/libblas.a --with-lapack=/usr/lib/liblapack.a

We provide some default configure examples in ${PETSC_DIR}/config, for example: on Mac OS X, a sample configure file is ${PETSC_ARCH}/config/configure_darwin6.6.py

Currently configure cannot handle most of the optional packages so after running configure you should manually add them to the bmake/${PETSC_ARCH}/packages file

Return to Installation Instructions


Optional Packages:  PETSc can be installed with various optional packages - including SuperLU, Spooles, Matlab etc.. 

The optional package information is specified in bmake/${PETSC_ARCH/packages file. An example specification is as follows:

PARMETIS_INCLUDE    = -I/home/petsc/soft/solaris-9/ParMetis-3.0
PARMETIS_LIB        = -L/home/petsc/soft/solaris-9/ParMetis-3.0 -lparmetis -lmetis
PETSC_HAVE_PARMETIS = -DPETSC_HAVE_PARMETIS

Notice that the include, library paths, library files are specified, and a flag is set - to enable the package within PETSc. For more example usage for any other package, check out the default bmake/*/packages files in the distribution

Return to Installation Instructions


Aditional Windows Notes:

Compilers: Support Microsoft (win32_ms*), Intel (win32_intel), Borland (win32_borland), Gnu compilers (win32_gnu)

Project Files: We provide default project files that work with PETSC_ARCH=win32_ms_mpich. They are located at ${PETSC_DIR}/projects. Be sure to build the libraries that correspond to the project configuration you are using. To use a C++ project with Debug configuration, BOPT=g_c++ libraries are required.

Debugger:  Running PETSc probrams with -start_in_debugger is not supported on this platform, so debuggers will need to be initiated manually. Make sure your environment is properly configured to use the appropriate debugger for your compiler. The debuggers can be initiated using Microsoft Visual Studio 6: msdev ex1.exe, Microsoft Visual Studio .NET: devenv ex1.exe, Intel Enhanced Debugger: edb ex1.exe, or GNU Debugger gdb ex1.exe.

PETSc Win32 front end - win32fe:  This tool is used as a wrapper to Microsoft/ Borland/ Intel compilers and associated tools - to enable building PETSc libraries using make and other UNIX tools. For additional info, run ${PETSC_DIR}/bin/win32/win32fe without any options.

Return to Installation Instructions


I got PETSc from the BitKeeper site: If manually editing the bmake/${PETSC_ARCH}/packages file we recommend creating a new PETSC_ARCH - for example:  linux_local(i.e copy files from bmake/linux over to bmake/linux_local) and make edits suitable for your configuration in this copy - this way  you don't have to edit sources in BitKeeer.

  • cd bmake
  • mkdir linux_local 
  • cp linux/* linux_local 
  • chmod u+w linux_local/*
Note: do not use 'bk cp' or 'cp -r' as these would be messing with the version control files in the BitKeeper repository

Return to Installation Instructions