4

I am trying to wrap FORTRAN90 code using f2py by writing the following commands

gfortran -c nrt.f90
gfortran -c lu.f90
gfortran -c sqn.f90
gfortran -c csm.f90 -llapack -lblas
gfortran -c pa.f90

f2py -c nrt.f90 lu.f90 sqn.f90 csm.f90 pa.f90 -m p_avg

I call the LAPACK function zhegv() inside csm.f90. Everything compiles, but when I call ipython from the terminal

ipython --pylab

And then in ipython type

from p_avg import pa

I see

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-8181d9e1b27d> in <module>()
----> 1 from p_avg import pa

ImportError: ./p_avg.so: undefined symbol: zhegv_

Is there something else I need to do to make sure f2py can understand this LAPACK function call? I see other people have asked about using f2py directly with LAPACK modules, but here I am using a LAPACK function from within another piece of FORTRAN code.

Thank you.

Update: When I try the command suggested in the comments by typing the following at the terminal,

f2py -L/usr/lib/lapack -llapack -c nrt.f90 lu.f90 sqn.f90 csm.f90 pa.f90 -m p_avg 

or

f2py -L/usr/lib/ -llapack -c nrt.f90 lu.f90 sqn.f90 csm.f90 pa.f90 -m p_avg

And then typing the following in ipython,

from p_avg import pa

I get

----------------------------------------------------------------    -----------
ImportError                               Traceback (most recent    call last)
<ipython-input-1-8181d9e1b27d> in <module>()
----> 1 from p_avg import pa

ImportError: No module named p_avg
  • Have you seen this [question](http://stackoverflow.com/questions/10766969/f2py-wrapping-fortran-module-which-makes-use-of-subrouines-distributed-in-diffe) and its answer ? Could you try something like `f2py -L/path/to/lapack -llapack -c nrt.f90 lu.f90 sqn.f90 csm.f90 pa.f90 -m p_avg` ? – francis Oct 09 '14 at 16:52
  • I am in Ubuntu and hopefully put in the correct path to lapack. Unfortunately, another problem seems to result from that command. – Impossibear Oct 09 '14 at 18:21

1 Answers1

2

In this case, you can indeed write

f2py -L/usr/lib/ -llapack -c nrt.f90 lu.f90 sqn.f90 csm.f90 pa.f90 -m p_avg

but you need to make sure the lapack development library is installed. When I only had liblapack3 installed, the above command didn't work.