[Numpy-discussion] [f2py] mailing lists, bug, and .f2py_f2cmap, Oh My!
Peter Schmitt
pschmittml@gmail....
Wed Nov 7 12:55:54 CST 2007
Hi,
I have one short question, a possible bug report, and one longer question:
1. (short question)
Which mailing list is appropriate for f2py discussion:
numpy-discussion or f2py-users?
2. (bug report?)
I'm using numpy from svn (revision 4410). When using f2py to compile,
I got an error:
File "/home/pschmitt/usr/local/lib/python2.5/site-packages/numpy/f2py/rules.py",
line 1228, in buildmodule
for l in '\n\n'.join(funcwrappers2)+'\n'.split('\n'):
TypeError: cannot concatenate 'str' and 'list' objects
I made what I think should be a fix:
$ svn diff numpy/numpy/f2py/rules.py
Index: numpy/numpy/f2py/rules.py
===================================================================
--- numpy/numpy/f2py/rules.py (revision 4410)
+++ numpy/numpy/f2py/rules.py (working copy)
@@ -1219,7 +1219,7 @@
f.write('! This file is autogenerated with f2py
(version:%s)\n'%(f2py_version))
f.write('! It contains Fortran 90 wrappers to fortran
functions.\n')
lines = []
- for l in '\n\n'.join(funcwrappers2)+'\n'.split('\n'):
+ for l in ('\n\n'.join(funcwrappers2)+'\n').split('\n'):
if len(l)>72 and l[0]==' ':
lines.append(l[:72]+'&\n &')
l = l[72:]
but I'm not sure if this is what Pearu wanted with that block of
code.... Should I submit a bug report???
3. (Longer question)
I have 3 source files:
a) types_QG.f90, which specifies the "types_QG" module: "integer,
parameter :: WP=4, intdim=selected_int_kind(8)"
b) fftpack.f which is a f77 program to perform fourier transforms in 1D
c) fft_lib.f90 which is a f90 program (a f90 module, actually)
that uses fftpack.f to do 1,2 or 3D fourier transforms. I want access
to access the functions in fft_lib.f90 via Python... So I use f2py!
:)
I just learned about ".f2py_f2cmap" to handle fortran90 <type spec>
(kind=KIND(..)) statements and I'm trying to implement it into my code
[http://cens.ioc.ee/projects/f2py2e/FAQ.html#q-what-if-fortran-90-code-uses-type-spec-kind-kind].
f2py successfully applies the f2py_f2cmap:
make fft
gfortran -fPIC -c types_QG.f90
gfortran -fPIC -c fftpack.f
f2py2.5 --fcompiler=gfortran -m fft_lib -c types_QG.o fftpack.o fft_lib.f90
Reading .f2py_f2cmap ...
Mapping "real(kind=wp)" to "float"
Mapping "real(kind=WP)" to "float"
Mapping "integer(kind=intdim)" to "int"
Succesfully applied user defined changes from .f2py_f2cmap
...
However, f2py complains about the "kind=" syntax in every single
function I have defined in the module within fft_lib.f90. The errors
look something like this:
> /tmp/tmpeP_IaX/src.linux-i686-2.5/fft_lib-f2pywrappers2.f90:9.16:
>
> real(kind=wp) a(2,2,2)
> 1
> Error: Parameter 'wp' at (1) has not been declared or is a variable, which does not reduce to a constant expression
If I remove every function from the fft_lib.f90 source code, f2py
succesfully compiles the Python module, and I can call all the
subroutines in fft_lib.
Any ideas on what's going on with f2py, the "kind" statement,
.f2py_f2cmap, and functions within a f90 module?
Thanks,
Pete
More information about the Numpy-discussion
mailing list