[Numpy-discussion] Calling routines from a Fortran library using python

Matthieu Brucher matthieu.brucher@gmail....
Thu Feb 18 05:22:25 CST 2010


If Nils has no access to the Fortran interface (and I don't think he
has, unless there is some .mod file somewhere?), he shouldn't use
f2py. Even if you know that the Fortran routine is named XXX, you
don't know how the arguments must be given. Addressing the C interface
directly is much safer.

Matthieu

2010/2/18 George Nurser <gnurser@googlemail.com>:
> I'm suggesting writing a *new* Fortran interface, coupled with f2py.
> The original library just needs to be linked to the new .so generated
> by f2py. I am hoping (perhaps optimistically) that can be done in the
> Fortran compilation...
>
> --George.
>
> On 18 February 2010 10:56, Matthieu Brucher <matthieu.brucher@gmail.com> wrote:
>> If header files are provided, the work done by f2py is almost done.
>> But you don't know the real Fortran interface, so you still have to
>> use ctypes over f2py.
>>
>> Matthieu
>>
>> 2010/2/18 George Nurser <gnurser@googlemail.com>:
>>> Hi Nils,
>>> I've not tried it, but you might be able to interface with f2py your
>>> own fortran subroutine that calls the library.
>>> Then issue the f2py command with extra arguments -l<libname>
>>> -L<directory with lib>.
>>>
>>> See section 5 of
>>> http://cens.ioc.ee/projects/f2py2e/usersguide/index.html#command-f2py
>>>
>>> --George.
>>>
>>>
>>> On 18 February 2010 09:18, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
>>>> Hi all,
>>>>
>>>> I have a static  library (*.a) compiled by gfortran but no
>>>> source files.
>>>> How can I call routines from that library using python ?
>>>>
>>>> Any pointer would be appreciated.
>>>>
>>>> Thanks in advance.
>>>>
>>>>                                                  Nils
>>>> _______________________________________________
>>>> NumPy-Discussion mailing list
>>>> NumPy-Discussion@scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>>
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>
>>
>>
>> --
>> Information System Engineer, Ph.D.
>> Blog: http://matt.eifelle.com
>> LinkedIn: http://www.linkedin.com/in/matthieubrucher
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher


More information about the NumPy-Discussion mailing list