Re: [f2py] mixed f77/f90 code
Pearu Peterson <[email protected]> Wed, 24 Nov 2010 11:21:30 +0200
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
On 11/24/2010 11:14 AM, Jasper Werhahn wrote: > > > 2010/11/24 Pearu Peterson <[email protected] > <mailto:[email protected]>> > > > > On 11/24/2010 10:41 AM, Jasper Werhahn wrote: > > dear pearu, > > > > thanks a lot. i just don't understand one thing - i do of course only > > call fit_gm from python. but fit_gm itself continues to call the > > lmder-subroutines that actually do the fitting. how do i get this > passed > > on then? greetings, > > As I read the code, fit_gm uses gMorse as a callable argument to lmder > subroutines. Since Morse_mod.f90 is linked to the generated extension > module then all bits are there for fit_gm. May be I should clarify that > f2py builds wrappers to fortran subroutines, f2py does not convert > fortran codes to python. A wrapper is a lightweight C function that > converts Python objects to C objects that can be passed on to Fortran > subroutines. > > Regards, > Pearu > > > yes, you read the code right. this seems to make perfect sense. can i > find details of how to link the wrapped fit_gm subroutine to the actual > fitting then? sorry, I don't understand the question. > if i build the wrapper from only fit_gm and morse_mod > according to your instructions, making sure that only these functions > and subroutines are included in the pyf file, it builds the .so-file. > when i import that in python via from fit_gm import *, python gives me > the error message: > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > ImportError: dlopen(./fit_gm.so, 2): Symbol not found: _lmder1_ > Referenced from: /Users/umbra/Desktop/test/fit_gm.so > Expected in: dynamic lookup > > no reference to lmder1 is made in my pyf-file (i grepped it to make sure). While lmder1 should not be in the pyf file, you still need to specify lmder1.f in the f2py compile command line. HTH, Pearu