Discussion:
[Numpy-discussion] F2PY subroutine referenced in another file
asbuzza
2016-07-09 18:57:23 UTC
Permalink
Hello everyone,

I am relatively new to f2py and have been trying to create a module of a
main fortran file that references a subroutine in another fortran file. I
f2py -c -m mainmodule mainmodule.f90 othermodule.f90
Any help would be greatly appreciated.

Thanks,
Andy



--
View this message in context: http://numpy-discussion.10968.n7.nabble.com/F2PY-subroutine-referenced-in-another-file-tp43261.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
Jonathan Stickel
2016-07-10 14:19:20 UTC
Permalink
Andy

First compile "othermodule" with fortran (not f2py):

$ gfortran -shared -o libothermodule.so othermodule.f90

Then link to it when compiling "mainmodule" with f2py:

$ f2py -c -L[path to libothermodule.so] -lothermodule -m mainmodule
mainmodule.f90

You can also make othermodule a static library and incorporate it into
mainmodule. The syntax is a little different, but I do not have an
example in front of me right now.

HTH,
Jonathan
Date: Sat, 9 Jul 2016 11:57:23 -0700 (MST)
Subject: [Numpy-discussion] F2PY subroutine referenced in another file
Content-Type: text/plain; charset=us-ascii
Hello everyone,
I am relatively new to f2py and have been trying to create a module of a
main fortran file that references a subroutine in another fortran file. I
f2py -c -m mainmodule mainmodule.f90 othermodule.f90
Any help would be greatly appreciated.
Thanks,
Andy
Loading...