Robert Bradshaw wrote: > On Mar 24, 2009, at 7:32 AM, Dag Sverre Seljebotn wrote: >> How does that make you feel? Alternatives: >> - Plug it in through a plugin framework >> - Do it through a preprocessing step which generates the >> necesarry .pyx >> and .f90 files. > > I think it makes the most sense to have a .f90 file correspond to the > library .pxd file (either generated from the .pxd, or along side > the .pxd), but I don't have much experience with fortran. If two > separate .pyx files use the same library, how (if at all) would > their .f90 wrappers differ? > > Also, what would the compilation process then be like?
Here's the current plan which should answer these questions. I've already posted on the SciPy list about this, so I just paste that: 1) Add a Cython syntax and API for passing acquired PEP-3118 buffers/NumPy arrays to external C functions (i.e. as a struct with the necesarry information (pointer, shape, strides)). This simply means defining a syntax for passing information that Cython already has to an external C function. 2) Create a new tool which uses the parser part of f2py (with any necesarry improvements) but adds a different backend which generates a C interface to the given Fortran module, along with a Cython pxd file for it. (Adding a C .h file target, to get "f2c" functionality, would be trivial.) This will be done using the Fortran 2003 C bindings. So a .f90 file is generated which compiles to a C interface to the library. Array parameters will be passed as the PEP-3118-like structs we define in 1), and so the functions will be callable directly with e.g. NumPy arrays from Cython. Copy-in/out might be necesarry for Fortran to be able to work with the arrays, if so this will happen in the Fortran wrapper generated by this new tool. 3) One could then add a feature to Cython to automatically export external functions as Python functions so that one doesn't have to write wrapper stubs. This should bring the functionality to a level comparable to current f2py. -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
