[f2py] netlib spline source compilation
Jean-Michel Philippe
jean-michel.philippe at arcelor.com
Thu Feb 24 10:29:38 EET 2005
pearu at cens.ioc.ee a écrit :
> I suggest using 'The smart way' for wrapping fitpack.percur, i.e. generate
> a signature file, specify all output arguments as intent(out) and all
> input-output arguments as intent(in,out). See f2py users guide for more
> information.
>
> Pearu
Unfortunately I could not get a better result for this subroutine. I now
feel that the Fortran code does not work as expected. I explain what I
did below.
I tried the smart way for the whole library ('f2py -c fitpack.pyf -m
fitpack') but this did not produce a compilable *.pyf file and I did not
find any modification of this file making it compilable (maybe the smart
way is not intended for entire libraries? I didn't want to have a
separate *.so file just for this subroutine indeed).
Anyway I finally used the quick and smart way by adding the following
lines to 'percur.f':
==============
Cf2py intent(in) iopt
Cf2py intent(in) m
Cf2py intent(in) x
Cf2py intent(in) y
Cf2py intent(in) w
Cf2py intent(in) k
Cf2py intent(in) s
Cf2py intent(in) nest
Cf2py intent(in) n
Cf2py intent(in,out) t
Cf2py intent(out) c
Cf2py intent(out) fp
Cf2py intent(in) wrk
Cf2py intent(in) lwrk
Cf2py intent(in) iwrk
Cf2py intent(out) ier
===============
Then I modified this line of the 'sample.py' script :
fitpack.percur(-1, x, y, w, k, 2.0, knotslen, knots, coeffs, fp, wrk,
iwrk, ier)
which became:
knots, coeffs, fp, ier = fitpack.percur(-1, x, y, w, k, 2.0, knotslen,
knots, wrk, iwrk)
As it was still producing no output coefficients (ie. all zeros), I
decided to add some Fortran code in 'percur.f' to fill coefficients with
ones:
=============
do 1 i=1,nest
c(i) = 1.0
1 continue
=============
I now get all output coeffs equals to 1.0 in Python showing that f2py
correctly wraps arrays. So to me the Fortran code does not work properly
for an unknown reason. Let me know if you find something wrong.
JM. Philippe
More information about the f2py-users
mailing list