Hi Kurt!

On Wed, Mar 24, 2010 at 11:52 PM, Dag Sverre Seljebotn
<[email protected]> wrote:
> Ondrej Certik wrote:
>> Hi Kurt!
>>
>> On Wed, Mar 24, 2010 at 1:40 PM, Kurt Smith <[email protected]> wrote:
>>> On Wed, Mar 24, 2010 at 2:08 PM, Ondrej Certik <[email protected]> wrote:
>>>> Hi,
>>>>
>>>> do you think that fwrap would be usable over the summer? I will be
>>>> working with some fortran codes (f95), so I am curious whether I
>>>> should stay with f2py, or invest some time into fwrap and use Cython,
>>>> that I use anyway for C/C++.
>>>>
>>> I'm working on the build system as we speak :-)
>>>
>>>> Is there some webpage for it? Bug tracker?
>>>>
>>> I've been putting my time in on coding lately, so fwrap's public face
>>> is sorely lacking.  I need to remedy this soon.  Thanks for the
>>> motivation -- you and others have made it clear that soon is 'now.'
>>>
>>>> I found this blog:
>>>>
>>>> http://fortrancython.wordpress.com/
>>>>
>>> To be updated soon, too (I know, long on promises -- I'm very short on
>>> time lately).  But the project is active.
>>>
>>>> and I found this:
>>>>
>>>> http://hg.cython.org/fwrap-dev/
>>>>
>>>> Is this the official source code?
>>>>
>>>> How do I compile it and use it? How do I run tests? I tried:
>>>>
>>>> $ python fwrap.py
>>>> Traceback (most recent call last):
>>>>  File "fwrap.py", line 4, in <module>
>>>>    main()
>>>>  File "/home/ondrej/repos/fwrap-dev/fwrap_src/main.py", line 12, in main
>>>>    wrap(options, args)
>>>>  File "/home/ondrej/repos/fwrap-dev/fwrap_src/main.py", line 18, in wrap
>>>>    funcs_templ = [(fc_wrap.generate_fortran, "%s_c.f90"),
>>>> AttributeError: 'module' object has no attribute 'generate_fortran'
>>>>
>>>> $ python runtests.py
>>>> Traceback (most recent call last):
>>>>  File "runtests.py", line 799, in <module>
>>>>    from fwrap_src.Main import wrap
>>>>
>>>>
>>>> And I didn't find any setup.py, or README (I found NOTES.txt, but no
>>>> build instructions). Sorry for the basic questions, I just want to
>>>> give it a shot.
>>>>
>>>>
>>>> Kurt and Dag seem to be working/interested in this, so if we can get
>>>> something usable (90%) to get started and then once I can use it for
>>>> my stuff (I just need simple wrappers for now), it'd be really cool.
>>> I'm *really* aiming for something like 90% by the end of April, as
>>> unlikely as the above makes it seem.  I'll put a post on the blog
>>> (fortrancython.wordpress.com/) about what 90% means.  It will include
>>> all the basic support stuff that you mention above (where hosted
>>> (likely bitbucket), a mailing-list, and the features supported).
>>>
>>> So by summer (end of May) fwrap should have a couple of releases out,
>>> and be usable.  It will certainly work for simple wrappers (no
>>> callback support).  Although that depends on just what you mean by
>>> 'simple.'
>>
>> That should be enough. I use cmake, so I'd appreciate if fwrap could
>> just spit the C (or fortran or both) files, that I compile and link
>> myself. Just like Cython does. (I read some issues with integrating
>
> Note that fwrap generates both C, Fortran and Cython code to make
> everything work together in a standard-compliant way...
>
> Also, unless things have changed, a configuration script must be run as
> part of the build process to detect which C types correspond to which
> Fortran types. f2py just makes blatant assumptions in this area and you
> could probably impose such blatant assumptions yourself too if you want
> to avoid complicating your build.

let me know if I can help somehow with frap --- in the meantime I
tried to figure out how to link gfortran with gcc, so that I can just
use Cython myself to wrap fortran things.

cd fwrap-dev/tests/compile/
gfortran -o int_args.o -c int_args.f95
cd intargs_stuff
gfortran -o wrap_int_args.o -c wrap_int_args.f95
gcc -o drive_int_args.o -c drive_int_args.c
gcc -o drive drive_int_args.o wrap_int_args.o ../int_args.o

And:

$ ./drive
before subr call in c
1 2 4 8
after subr call in c
1 2 4 7
before func call in c
1 2 4 7
after func call in c
1 2 4 7 result=10


So this is cool and works fine. Now I just wrap


void *int_args_subr(signed char *, short *, int *, long *);
long int_args_func(signed char *, short *, int *, long *);

using Cython.

Why is the file wrap_int_args.f95 needed at all? Is it not possible to
link with int_args.f95 directly? It contains the following code:

subroutine wrapsubr_int_args_subr(a,b,c,d) bind(c,name="int_args_subr")
      use iso_c_binding
      implicit none
      integer(kind=c_signed_char), intent(in) :: a
      integer(kind=c_short), intent(in) :: b
      integer(kind=c_int), intent(in) :: c
      integer(kind=c_long), intent(out) :: d

      interface
        subroutine int_args_subr(a,b,c,d)
          integer(kind=1), intent(in) :: a
          integer(kind=2), intent(in) :: b
          integer(kind=4), intent(in) :: c
          integer(kind=8), intent(out) :: d
        end subroutine int_args_subr
      end interface

      call int_args_subr(a,b,c,d)
end subroutine wrapsubr_int_args_subr


is it so that gfortran generates a C compatible .o file?

So the idea is that fwrap will generate the .f95 interface file, then
the C file (or possibly just a C header file) and a .pyx file with the
wrappers? Indeed, that'd be cool. But for my simple wrappers, it
should not be such a big deal to do this by hand, right? I have to try
an example with double arrays. If I can wrap that, then I am fine.

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

Reply via email to