[SciPy-user] f2py: Adding F_WRAPPEDFUNC to*module.c without actually wrapping a function

Pearu Peterson pearu@cens.ioc...
Mon Nov 17 06:57:32 CST 2008

On Mon, November 17, 2008 11:18 am, Berthold "Höllmann" wrote:
> I am wrapping some LAPACK routines currently not handled in
> scipy.linalg. some of them require workspace. In order to provide the
> optimal workspace i wrote some helper routines taking the FORTRAN code
> for calculating the optimal workspace and translating them C, e.g.::
> static int dsytrf_lwork(int n, char uplo) {
>   int one = 1;
>   int name_len = 6;
>   int opts_len = 1;
>   int none = -1;
>   int nb;
>   (*F_WRAPPEDFUNC(ilaenv,ILAENV))(&nb, &one, "DSYTRF", &uplo, &n, &none,
> &none, &none, name_len, opts_len);
>   return (n*nb);
> }
> and then in the wraper code for dsytrf::
>      integer intent(hide), depend(n, uplo) :: lwork = dsytrf_lwork(n,
> *uplo)
> This requires the function wrapper for the FORTRAN ilaenv function::
> extern void
> F_WRAPPEDFUNC(ilaenv,ILAENV)(int*,int*,string,string,int*,int*,int*,int*,size_t,size_t);
> Now my code only works when I also wrap the ilanev function (or, I
> guess, any other function), otherwise the F_WRAPPEDFUNC is missing in
> the generated code. Is there a way to get the F_WRAPPEDFUNC macro to the
> wrapper code without wrapping a function? the ilanev function should not
> become part of the interface, nor is there any other function that should.

The answer is No.

You either have to have a function wrapped or just copy the
F_WRAPPEDFUNC macro from numpy/f2py/cfuncs.py to your .pyf file
(look at the usercode statement in f2py manual).


More information about the SciPy-user mailing list