Stefan Behnel wrote:
> Dag Sverre Seljebotn wrote:
>   
>> Is it OK to have nice and convenient wrapping of Fortran libraries as an
>> additional feature of core Cython?
>>
>>  [ ] Yes, that would be grand
>>  [ ] No, that would bloat the language and/or the compiler/project too
>> much, I'd prefer to see this in a standalone tool/plugin
>>     
>
>   [X] It depends on how it's done.
>   
OK, some details then. This is a scetch only!

First of all, this is about calling into Fortran (i.e. calling 
conventions) only, not about writing Fortran code using Cython.

1) A "fortran" calling convention on external function declarations, and 
perhaps a "module"/"namespace" declaration (which one could reuse for C++):

cdef extern:
    module mymodule: # reusable for C++ wrapping, could say "namespace" 
instead
        cdef fortran sometype myfunc(sometype arg)

When "fortran" is in effect, one may accept some extra syntax for the 
arguments, i.e. "in" or "inout" (but "const" and no const could serve 
the same purpose).

2) Types -- I am thinking of a "cython.fortran" psuedomodule with 
Fortran types (i.e. cython.fortran.real(kind=8)); these would simply map 
down to C typedefs. But one could get by with a simple pxd with no 
compiler support as well.

3) Potentially parsing of Fortran files to autogenerate pxd files, but 
this could be a seperate tool and/or be pluggable using an API that 
could also be used for header files.

Implementation-wise, there would be a transform which would deal with 
calls to functions using the Fortran calling convention, and generates a 
mymodule.f90 wrapper to supplement mymodule.c -- however this is a very 
thin wrapper to retype the Fortran functions from Fortran-side to use 
some C conventions and some Cython-specific conventions, and most of the 
things would be C-side.

The argument for doing this in Cython is that both Cython/Python and 
Fortran support a higher-level construct which C doesn't 
(buffers/strided arrays).

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.

Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to