F2PY: Access Fortran module data from multiple python module

Yann Vonder yann.vonderscher at gmail.com
Wed Nov 19 17:06:37 EST 2008


Hi all,
Here is a description of what I am trying to implement using F2PY:
I have created two python extension modules using F2PY. The first extension
module (say fsubr1.so) contains a Fortran module (say "tmod") and a
subroutine (say "subr1") that modifies the data contained in "tmod". The
second extension module (fsubr2.so) contains the same Fortran module as
fsubr1.so (tmod), and a different subroutine ("subr2") that also modifies
the data contained in "tmod". I am hoping to be able to have fsubr1.so and
fsubr2.so share the content of "tmod," in a way that if a call is made, from
python, to "subr1", followed by a call to "subr2", both subroutine access
the same data contained in "tmod". Unfortunately, if I run the Python
script:

from fsubr1 import *
from fsubr2 import *

subr1()
print tmod.data
subr2()
print tmod.data

the data in "tmod" will be modified only by the subroutine contained in the
python module imported last, i.e. subr2 in this case.

Does anyone know how to go about this problem?
Any help/insight will be greatly appreciated.

Thanks,

YAV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081119/b5c60e06/attachment.html>


More information about the Python-list mailing list