[SciPy-dev] Two fortran/f2py questions

Pearu Peterson pearu at scipy.org
Mon Dec 13 14:37:16 EST 2004


On Mon, 13 Dec 2004, Tom Loredo wrote:

> Is there a way to use f2py directives to indicate that a few subprograms
> in a fortran77 source file need not be wrapped/exposed?  Right
> now I'm just using the "only:" keyword on the command line, but
> I would imagine there's a way to embed this info in the source.
> I just haven't been able to figure it out from the Users Guide.

No. But I think it would be a useful feature. So I'll add this request to 
my todo list. Btw, if you would use scipy_distutils-style setup.py file
then you can add the "only: .. :" part to f2py_options to avoid
using it on the command line.

> Is there documentation anywhere showing how one can have fortran
> source for a Python extension access a C or fortran function
> that is part of Scipy?  The specific example driving this is
> a module I'm working on that uses some special functions.  It
> seems there should be some way for me to call the cephes
> functions directly.  But I'm not sure how to make code that
> will automatically link to the appropriate library, and do it
> portably (so the module can be distributed).  If there's a good
> example of this within Scipy (as I suspect), just give me a pointer
> and I'll "go to the source."  I thought there might be some
> docs on this within scipy_distutils, but I haven't found it
> if it's there.

I am not sure if I follow you correctly here but when using f2py from
its CVS, all fortran objects have _cpointer attribute that is
a C pointer to the actual Fortran or C function. Using such a _cpointer
as an callback argument will speed up calling the Fortran or C function
because the f2py generated wrapper layer is avoided but at the risk
of crashing Python when using _cpointer feature incorrectly.
Is this what you are looking for?

Pearu




More information about the SciPy-Dev mailing list