> However, the values that are supposed to be communicators show up as
> python integers. While these may be completely usable for passing to
> extension codes they are worthless for actually doing anything in
> python.
Alas, more underdocumented features of pyMPI come to light.
That functionality exists in the mpi module as the "communicator"
type object. This is the same object used to create and
expose the internal MPI communicators.
>>> h = myfortran.getHandle()
>>> print h
141259752
>>> c = mpi.communicator(h)
<communicator object at 0xb7532500>
>>> c.rank
14
Give it a bogus handle and you may segfault in LAM or
get an "Invalid communicator" exception in MPICH.
* * * * *
For a bit more info, see the help file [below]. The idea
of persistence of communicators is just to help Python
decide whether to delete the MPI communicator when the
Python communicator is freed. The default is to NOT
delete the communicator (that is, do NOT call MPI_Comm_free()
on it).
>>> import mpi
>>> help(mpi.communicator)
Help on class communicator in module __builtin__:
class communicator(object)
| Create communicator object from communicator or handle
|
| communicator(communicator=COMM_NULL, # Communicator to wrap
| persistent=1) # If false, release MPI comm
| --> <communicator instance>
|
| Build instance of a communicator interface. The persistent flag (by
| default on) means that Python WILL NOT release the MPI communicator on
| delete.
|
| >>> null = communicator() # returns a (not the) NULL communicator
| >>> c = communicator(WORLD) # a new interface to WORLD communicator
| >>> my_world = communicator(handle,0) # Python version of handle
| # MPI_Comm_free() will be called
...
--
Pat Miller | (925) 423-0309 | http://www.llnl.gov/CASC/people/pmiller
What hunger is in relation to food, zest is in relation to life. -- Bertrand
Russell, philosopher, mathematician, and author (1872-1970)
|