<div>Thank you for the suggestion! Seems like a reasonable way to go. Not working for me, however, I suspect because I'm using homebrew installations of PETSc and SLEPc (I don't think all the makefiles are kept). Any other way to do the same thing by chance? Worst case I could use a non-homebrew installation but I'd prefer not to mess with that if I can help it...</div><div><br></div><div>Thanks,</div><div>Austin</div><div><br><div class="gmail_quote"><div>On Wed, Mar 22, 2017 at 11:20 AM Jose E. Roman <<a href="mailto:jroman@dsic.upv.es">jroman@dsic.upv.es</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Try the following:<br class="gmail_msg">
$ cd $SLEPC_DIR<br class="gmail_msg">
$ make getlinklibs_slepc<br class="gmail_msg">
Then copy the output and paste it at the end of your f2py command.<br class="gmail_msg">
<br class="gmail_msg">
Jose<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
> El 22 mar 2017, a las 16:38, Austin Herrema <<a href="mailto:aherrema@iastate.edu" class="gmail_msg" target="_blank">aherrema@iastate.edu</a>> escribió:<br class="gmail_msg">
><br class="gmail_msg">
> Hello all,<br class="gmail_msg">
><br class="gmail_msg">
> 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 class="gmail_msg">
><br class="gmail_msg">
> 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 class="gmail_msg">
><br class="gmail_msg">
> 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 class="gmail_msg">
><br class="gmail_msg">
> Using a python script, I set up and run the f2py command. Right now it has the form...<br class="gmail_msg">
> "f2py -c -m modname outer_driver.f90 file1.o file2.o file3.o..." etc.<br class="gmail_msg">
><br class="gmail_msg">
> This appears to work, but upon attempting to import, it cannot find the SLEPc (and, I presume, PETSc) objects/functions:<br class="gmail_msg">
><br class="gmail_msg">
> >>> import mod_name<br class="gmail_msg">
> Traceback (most recent call last):<br class="gmail_msg">
> File "<stdin>", line 1, in <module><br class="gmail_msg">
> ImportError: dlopen(./mod_name.so, 2): Symbol not found: _epscreate_<br class="gmail_msg">
> Referenced from: ./mod_name.so<br class="gmail_msg">
> Expected in: flat namespace<br class="gmail_msg">
> in ./mod_name.so<br class="gmail_msg">
><br class="gmail_msg">
> Based on this discussion, 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 class="gmail_msg">
><br class="gmail_msg">
> Thank you for any help or suggestions!<br class="gmail_msg">
> Austin<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> --<br class="gmail_msg">
> Austin Herrema<br class="gmail_msg">
> PhD Student | Graduate Research Assistant | Iowa State University<br class="gmail_msg">
> Wind Energy Science, Engineering, and Policy | Mechanical Engineering<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="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>