returning values from FORTRAN with f2py

Bengt Richter bokr at oz.net
Sat Sep 7 17:11:10 EDT 2002


On 7 Sep 2002 12:22:16 -0700, spam at fisher.forestry.uga.edu (Chris Fonnesbeck) wrote:

>I am wondering how to persuade some fortran code that I have compiled
>with f2py to return its calculated values to me in python.  I have
>some code that does gaussian elimination (mostly from Numerical
>Reciopes), and is supposed to return an inverted matrix so that I can
                                         ^^^^^^^^-[1]
>solve a system of linear equations.  However, when run in python, the
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-[2][3]
>function runs without error but returns no values:
>
>>>> a = [[2,1,3],[1,-1,1],[3,6,-1]]
>>>> b = [7,2,10]
>>>> import gauss
>>>> gauss.gauss(a,3,b,1)
>>>>
>
>Is there something that I have to change in my fortran code to make
>this work?
>
Have you looked at
http://www.pfdubois.com/numpy/html2/numpy.html
and
[1] http://www.pfdubois.com/numpy/html2/numpy-18.html#pgfId-303023
[2] http://www.pfdubois.com/numpy/html2/numpy-18.html#pgfId-303019
or maybe
[3] http://www.pfdubois.com/numpy/html2/numpy-18.html#pgfId-303085

Perhaps there is an easier route to your goal? (I haven't used the above,
but numpy seems to be recommended frequently).

Regards,
Bengt Richter



More information about the Python-list mailing list