I need to run an existing model which includes multiple Fortran files and a Python file.
To run the Python file, I am trying to transform Fotran codes to Python modules using f2py. I got no issues on simpler Fortran files but in in a case where Fortran file uses another Fortran module(second.mod) it was unsuccessful. F2py is working fine on creating .so file but when importing it gives an error which is:
>>> import first
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: ./firstmod.so: undefined symbol: __second_MOD_secondr
To solve this I have used the command below which is also proposed in another topic(F2PY doesn't find a module):
f2py -c --fcompiler=gfortran -I"~/Documents" --fcompiler=gfortran -I"~/Documents" -lsecond -m first first.f90 -m first first.f90
But this time I get this error:
error: unknown file type '' (from '-m')
At this point I don't know what to do. Since the model is not written by me, I can't consider sharing it. I am using Ubuntu 16.04 LTS.
To clarify more, there are 4 fortran modules actually but now I got issues with connecting only two of them (first and second). In the first one these lines exist:
use second(...)
call secondr(...)
And I guess I need to find a proper way of including this second .mod file in creating my python module. Command that I provided includes duplicates but, since I am new to this I just copied it from the other topic with no questions asked.
Thank you for your help.