<div dir="ltr">Hello all,<br><br>I am trying to do as the subject line describes--use f2py to run a large PETSc/SLEPc fortran finite element code through python. I really only need to wrap the outermost function of the fortran code--don't need any access to subroutines. I'll describe what I'm doing, some of which I'm not 100% confident is correct (not much experience with f2py)--feel free to correct/redirect any of it.<br><br>First, I'm editing the fortran code so that the top-level function is a subroutine rather than a main program (it's my understanding that this is required for f2py?).<br><br>I use my regular makefile (modeled after a standard SLEPc makefile from the user guide) to compile all of the .f90/.F90 files (many of them) to .o files using SLEPc/PETSc rules. The final linking phase fails since there isn't a main program, but I'm just ignoring that for now since that's not what I ultimately need...<br><br>Using a python script, I set up and run the f2py command. Right now it has the form...<br>"f2py -c -m modname outer_driver.f90 file1.o file2.o file3.o..." etc.<br><br>This appears to work, but upon attempting to import, it cannot find the SLEPc (and, I presume, PETSc) objects/functions:<br><br><div><font color="#666666">>>> import mod_name</font></div><div><font color="#666666">Traceback (most recent call last):</font></div><div><font color="#666666">  File "<stdin>", line 1, in <module></font></div><div><font color="#666666">ImportError: dlopen(./mod_name.so, 2): Symbol not found: _epscreate_</font></div><div><font color="#666666">  Referenced from: ./mod_name.so</font></div><div><font color="#666666">  Expected in: flat namespace</font></div><div><font color="#666666"> in ./mod_name.so</font></div><div><br></div><div>Based on <a href="http://stackoverflow.com/questions/40144031/using-f2py-on-a-fortran-code-linked-to-petsc">this discussion</a>, I believe I need to somehow include PETSc/SLEPc info when linking with f2py. Is that correct? Any direction on how to do that? I don't quite understand what the OP of that question ultimately ended up doing to get it to work. I tried using the -I flag pointing to the slepc_common file (like the SLEPc makefile does). The problem is that that is a file, not a directory, which contains a number of other makefile-style variables--so it works to include it in a makefile, but doesn't work in python. Maybe there are only a few directories I really need to include? Or is it possible to somehow run f2py through a makefile? I'm a bit ignorant in that realm as well.<br><br>Thank you for any help or suggestions!<br>Austin</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><b style="font-size:12.8px"><font color="#666666">Austin Herrema</font></b><br></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><div><font color="#999999">PhD Student | Graduate Research Assistant | Iowa State University</font></div><div><font color="#999999">Wind Energy Science, Engineering, and Policy | Mechanical Engineering</font></div></div></div></div></div>