[f2py] f2py and lapack DLARUV

Paul Anton Letnes paul.anton.letnes at gmail.com
Fri May 20 17:36:29 EEST 2011


Just a thought, maybe I'm missing something, but: can't you simply use scipy? It contains thin wrappers for alot of LAPACK calls in:
from scipy.linalg.lapack import flapack as lapack
Now, I think this will give you a list of routine names that are wrapped:
for routine in dir(lapack):
	print routine

There is probably some "bloat" by using all of scipy, but it will save you a lot of compiling. Also, you could look at how scipy wraps lapack, and learn from that.

YMMV
Paul

On 20. mai 2011, at 05.02, Stephane Raynaud wrote:

> Since the only subroutine used from lapack is DLARUV with no
> dependencies, I folowed your excellent idea :
> ----
> f2py  -m testmod testfile.f90 -h testfile.pyf
> f2py testfile.pyf dlaruv.f
> ---
> 
> It failed on the second phase :
> ---
> |...]
>        Block: DLARUV
> Post-processing (stage 2)...
> Tip: If your original code is Fortran source then you must use -m option.
> [...]
> TypeError: All blocks must be python module blocks but got 'subroutine'
> ---
> 
> However, it work using the same idea with :
> ----
> f2py  -m testmod testfile.f90 -h testfile.pyf # setup interface only
> for testfunc
> f2py -c -m testmod testfile.f90 testfile.pyf dlaruv.f # build
> ---
> 
> 
> Thus, this solution is sufficient for me, thanks alot !!!
> 
> However, it would be great to have a solution for the when using the
> lapack/blas library itself.
> 
> On Fri, May 20, 2011 at 11:35 AM, Pearu Peterson
> <pearu.peterson at gmail.com> wrote:
>> 
>> 
>> On 05/20/2011 10:39 AM, Stephane Raynaud wrote:
>>> Hi,
>>> 
>>> trying to build a fortran extension linked to lapack (f77), I faced a
>>> problem that I reduced to the following example.
>>> 
>>> ------------ testfile.f90 ------------
>>> subroutine testfunc
>>>     integer,parameter :: n=2
>>>     integer :: iseed(4)
>>>     real(kind=8) :: x(n)
>>>     iseed = (/0,1,3,4/)
>>>     call DLARUV(iseed, n, x)
>>> end subroutine testfunc
>>> --------------------------------------
>>> 
>>> Then :  f2py -c -m testmod -llapack -lblas
>>> -L/home/raynaud/soft/lapack_gfortran/lib testfile.f90
>>> 
>>> It rises the following error (using gfortran) :
>>> 
>>>    /usr/bin/gfortran -Wall -Wall -shared
>>> /tmp/tmpzBIKPf/tmp/tmpzBIKPf/src.linux-x86_64-2.6/testmodule.o
>>> /tmp/tmpzBIKPf/tmp/tmpzBIKPf/src.linux-x86_64-2.6/fortranobject.o
>>> /tmp/tmpzBIKPf/test.o -L/home/raynaud/soft/lapack_gfortran/lib
>>> -L/soft/cdat/5.2.0/lib -llapack -lblas -lpython2.6 -lgfortran -o
>>> ./test.so
>>>    /usr/bin/ld:
>>> /home/raynaud/soft/lapack_gfortran/lib/liblapack.a(dlaruv.o):
>>> relocation R_X86_64_32S against `.data' can not be used when making a
>>> shared object; recompile with -fPIC
>>>    /home/raynaud/soft/lapack_gfortran/lib/liblapack.a: could not read
>>> symbols: Bad value
>>> 
>>> 
>>> BLAS and LAPACK where compilated with gfortran and options '-fPIC -O3'.
>> 
>> Are you absolutely sure?
>> 
>> Can you try creating the testmod without using lapack and blas libraries
>> but their sources? For example:
>> 
>> f2py  -m testmod testfile.f90 -h testfile.pyf
>> f2py testfile.pyf /path/to/lapack/src/*.f /path/to/blas/src/*.f
>> 
>> Pearu
>> 
>>> I tried to use the DATA statement directly in a subroutine that I
>>> converted to a python module, and it worked.
>>> 
>>> 
>>> Any idea ?
>>> 
>>> Thanks.
>>> 
>> 
>> _______________________________________________
>> f2py-users mailing list
>> f2py-users at cens.ioc.ee
>> http://cens.ioc.ee/mailman/listinfo/f2py-users
>> 
> 
> 
> 
> -- 
> Stephane Raynaud
> 
> _______________________________________________
> f2py-users mailing list
> f2py-users at cens.ioc.ee
> http://cens.ioc.ee/mailman/listinfo/f2py-users




More information about the f2py-users mailing list