F2PY: Access Fortran module data from multiple python module

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Nov 20 23:22:23 EST 2008


En Wed, 19 Nov 2008 20:06:37 -0200, Yann Vonder  
<yann.vonderscher at gmail.com> escribió:

> 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

If you put tmod in both libraries, you'll have two copies of it, and two  
copies of the data. Can't you join both libraries onto a single one? Or  
make one load the other? Or avoid global variables, and pass the required  
data to the subroutines? Either way, this is a design problem that you'll  
have to solve on the Fortran side, not in Python.

-- 
Gabriel Genellina




More information about the Python-list mailing list