OpenMPI, PETSc and petsc4py in a Mac Intel

Felipe Cruz refac at bristol.ac.uk
Mon Sep 10 10:59:47 CDT 2007


Hi all,

During the past weeks I was trying to install the Python bindings for  
PETSc (petsc4py) for
Mac Intel (a black Macbook and an Aluminium iMac, both with OS X  
10.4.10)

I succeeded and "how I did it"  might be helpful for some others  
Python-PETSc-Mac-Users.

Before to start the installation you'll need to have installed:

* XcodeTools:

It is IMPORTANT to get the latest version directly from Apple's  
website (http://connect.apple.com), the version
that comes with the installation CD have some issues (or not so nice  
"features".) I recommend to upgrade
your XcodeTools before trying to install anything.

* Python 2.5, Numpy, Scipy (optional - scientific lib) and Matplotlib  
(optional -matlab style graphics):

I followed the installation of this packages from: http:// 
www.scipy.org/Download
I installed MacPython2.5 and the SuperPack. For some reason  
Matplotlib didn't work after the installation
of the superpack, so I manually installed it again from: http:// 
matplotlib.sourceforge.net/


INSTALLATION

I'll describe the whole installation of OpenMPI, PETSc and petsc4py.

OpenMpi
-------------

Download OpenMPI source from:
http://www.open-mpi.org/software/ompi/v1.2/

Decompress the downloaded tar.gz file and from a terminal "cd" into  
the openMpi folder.
'$' indicates a terminal command, e.g;
$ tar -xzvf openmpi-1.2.3.tar.gz
$ cd openmpi-1.2.3

Now you can compile openmpi
$ ./configure --prefix=/usr/local/openmpi --with-fortran --enable- 
shared --disable-static --with-xgrid
$ sudo make
$ sudo make install

Add the next line at the END of /etc/profile, so the path will be  
available for all the users:
export PATH=$PATH:/usr/local/openmpi/bin



PETSc
-------------

First you need to make sure that OpenMPI is properly installed! check  
that
mpicc and mpif77 are in your $PATH before running the PETSc  
configure.py!
(if you added the export PATH to /etc/profile you can close your  
terminal and
open a new terminal, the PATH should be working now, otherwise, you  
can just type
in your terminal:
export PATH=$PATH:/usr/local/openmpi/bin


I installed PETSc on /opt/petsc
$ sudo mkdir /opt
$ sudo mkdir /opt/petsc

Set permissions for user and group.
$ sudo chown user:group /opt/petsc
In my case I added the user 'felipe' and the group 'admin' (sudo  
chown felipe:admin /opt/petsc)

Download PETSc from:
http://www-unix.mcs.anl.gov/petsc/petsc-as/download/index.html
Save the downloaded tar.gz on /opt/petsc

Decompress the file
$ cd /opt/petsc
$ tar -xzvf petsc-2.3.3-p5.tar.gz

I installed petscy for shared libraries and without X, beside this  
everything is normal:
$ cd petsc-2.3.3-p5
$ export PETSC_ARCH=darwin8.10.1-c-debug
$ export PETSC_DIR=/opt/petsc/petsc-2.3.3-p5
$ ./config/configure.py --with-mpi-dir=/usr/local/openmpi --with- 
shared=1 --with-x=0
$ make all test

At the end of /etc/profile add (so it will be available for all the  
users):
# variables for petsc
export PETSC_ARCH=darwin8.10.1-c-debug
export PETSC_DIR=/opt/petsc/petsc-2.3.3-p5



petsc4py
-------------
Open a new terminal so the variables PETSC_ARCH and PETSC_DIR will be  
available.

I installed petsc4py in /opt/petsc/petsc4py

In a terminal
$ cd /opt/petsc/petsc4py

Get a copy of petsc4py from: http://code.google.com/p/petsc4py/
and save it at /opt/petsc/petsc4py

$ tar -xvf petsc4py-0.7.5.tar
$ cd petsc4py-0.7.5
$ python setup.py install --home=/opt/petsc/petsc4py

# Add at the end of /etc/profile (it will be available for all the  
users)
export PYTHONPATH=/opt/petsc/petsc4py/lib/python/

Now is possible to open a new terminal and test petsc4py:
$python
 >>> from petsc4py import PETSc
 >>> A = PETSc.Mat()
 >>> A
 >>> A.createSeqAIJ(1000)




Hope that this info is helpful! I tested the installation in my  
MacBook (Dual-core), in an aluminium iMac (Dual-core),
and I hope to test the installation on a Mac pro (with two quad-core)  
some time this week!

I'm quite new to the list so I'm sorry if you have already discussed  
this topic.


Best regards,

Felipe Cruz






More information about the petsc-users mailing list