问题
I am attempting to build a python wrap for some fortran code I have using f2py and am experiencing a very odd problem.
I am using Python 3.4.3 32 bit, gfortran 4.8.1, and numpy 1.9.2 on Windows 8.
f2py compiles the fortran code so I can call it from python. The code has multiple subroutines. Some of them work, but two do not. The important difference seems to be subroutine declaration spanning multiple lines. The working subroutines are declared on a single line. The ones that fail span multiple lines.
Example:
The Python call
# import QC1_LIB ("library" of fortran code).
import QC1_LIB
TSDs = []
message += "Duplicate and TSD Check have started...\n"
QC1_LIB.dupandtsdchck(ts[0:##], data[0:##], ##, ##, ##, file, TSDs[0:##], ##)
where ##
are some integers that are determined and assigned elsewhere.
The Fortran subroutine declaration
1234567
SUBROUTINE DUPANDTSDCHCK(ts,data,nlines,nchar,frd,flnm,
$ TSDs,counter)
The python does not recognize TSDs
from the fortran code, i.e. it thinks there are only 7 arguments when in fact there are 8. It returns the error IndexError: QC1_LIB.dupandtsdchck() 7th argument (counter) can't be converted to int
I have not found this kind of problem mentioned anywhere. What is happening and how can I fix it?
Note: I realize I need to make some changes to the fortran code to actually get my desired output into the python workspace as f2py makes the subroutine into a function, but I'll worry about that later.
来源:https://stackoverflow.com/questions/31123427/why-does-f2py-not-include-all-arguments