Compilation of Fortan code with f2py creates empty Python module

44 Views Asked by At

I have a large Fortran 90 code that I would like to compile with f2py so I can run it from within a Python code. I do get the compilation to run without any errors, like this:

f2py -c -lgomp -lcfitsio.10 -L/usr/local/opt/cfitsio/lib/ -m code_name code_name.f90

Importing of code_name into Python works, but the subroutines are not included. It seems to have created an empty Python module.

I think it might be related to how I had set up the Fortran code, which has the following structure:

program code_name

implicit none

"many defined variables"

call run

contains

subroutine run

end subroutine run

"many more subroutines"

end program code_name

From a terminal, the code would execute the run subroutine. I would like to run it in a same way with Python, so calling code_name.run().

Any suggestions on how I could make this work?

Thanks a lot for any help !

0

There are 0 best solutions below