[f2py] Difficulties getting f90-files to work

innkeyp-ooo at yahoo.com innkeyp-ooo at yahoo.com
Fri Nov 4 19:03:28 EET 2005



--- pearu at cens.ioc.ee wrote:

> 
> On Thu, 3 Nov 2005 innkeyp-ooo at yahoo.com wrote:
> 
> > Hi,
> > 
> > I have been trying for quite some time now to get
> f2py
> > to work, but I can't seem to get it to work with
> with
> > anything except the GNU compiler, which seems only
> to
> > accept f77-files. I am new to Fortran and am more
> of a
> > Python programmer, but need some code to run
> faster
> > than it can with Python, so I needed to learn a
> new
> > language. I chose Fortran, because it doesn't seem
> as
> > mind-bending as C.
> > I write my files in f95-format and usully use
> gFortran
> > to compile. The files compile and run fine, but I
> > can't get f2py to do its magic on them, because
> f2py
> > doesn't seem to acknowledge gFortran as a viable
> > compiler. It this correct?
> > I have also downloaded and installed Intel's
> Fortran
> > compiler, and although it is recognized by f2py(it
> > shows up on the list of available compilers when I
> do
> > the f2py -c --help-fcompiler command), I get the
> LONG
> > error mesage seen below. It's quite difficult to
> > grasp, but I assume I need the executables called
> > 'efort' and 'efc', but I don't any files in my
> system
> > with those names, and googling for them does not
> > reveal anything..
> 
> You have ifort, that's enough.
> 
> > I really am clueless now, so any help is extremely
> > appreciated.
> > 
> > kind regards Terri P
> > 
> > output:
> >
> ***************************************************
> > numpy_info:
> >   FOUND:
> >     define_macros = [('NUMERIC_VERSION',
> > '"\\"23.8\\""')]
> >     include_dirs = ['/usr/include/python2.4']
> > 
> > running build
> > running config_fc
> > running build_src
> > building extension "untitled" sources
> > f2py:> /tmp/tmpd1lcgf/src/untitledmodule.c
> > creating /tmp/tmpd1lcgf
> > creating /tmp/tmpd1lcgf/src
> > Reading fortran codes...
> > 	Reading file 'int_sin.f90'
> > Line #33 in int_sin.f90:"real(DP), parameter ::
> > interval_end   = 2.0_DP * pi"
> > 	updatevars: no name pattern found for entity='*'.
> > Skipping.
> > Post-processing...
> > 	Block: untitled
> > 			Block: int_sin
> > {'interval_begin': '0.0_dp'}
> > In: :untitled:int_sin.f90:int_sin
> > get_parameters: got "unexpected EOF while parsing
> > (line 1)" on '0.0_dp'
> > {'interval_end': '2.0_dp', 'interval_begin':
> '0.0_dp'}
> > In: :untitled:int_sin.f90:int_sin
> > get_parameters: got "unexpected EOF while parsing
> > (line 1)" on '2.0_dp'
> > {'interval_end': '2.0_dp', 'interval_begin':
> '0.0_dp',
> > 'pi': '3.141592653589793238_dp'}
> > In: :untitled:int_sin.f90:int_sin
> > get_parameters: got "unexpected EOF while parsing
> > (line 1)" on '3.141592653589793238_dp'
> 
> Use f2py from CVS to get rid of these errors.
> 
> > 				Block: integ_func
> > Post-processing (stage 2)...
> > Building modules...
> > 	Building module "untitled"...
> > 	Wrote C/API module "untitled" to file
> > "/tmp/tmpd1lcgf/src/untitledmodule.c"
> >   adding '/tmp/tmpd1lcgf/src/fortranobject.c' to
> > sources.
> >   adding '/tmp/tmpd1lcgf/src' to include_dirs.
> > copying
> >
>
/usr/lib/python2.4/site-packages/f2py2e/src/fortranobject.c
> > -> /tmp/tmpd1lcgf/src
> > copying
> >
>
/usr/lib/python2.4/site-packages/f2py2e/src/fortranobject.h
> > -> /tmp/tmpd1lcgf/src
> > running build_ext
> > customize UnixCCompiler
> > customize UnixCCompiler using build_ext
> > Could not locate executable efort
> > Could not locate executable efc
> > customize IntelFCompiler
> > customize IntelFCompiler using build_ext
> > building 'untitled' extension
> > compiling C sources
> > gcc options: '-pthread -fno-strict-aliasing
> -DNDEBUG
> > -g -O3 -Wall -Wstrict-prototypes -fPIC'
> > creating /tmp/tmpd1lcgf/tmp
> > creating /tmp/tmpd1lcgf/tmp/tmpd1lcgf
> > creating /tmp/tmpd1lcgf/tmp/tmpd1lcgf/src
> > compile options: '-I/usr/include/python2.4
> > -I/tmp/tmpd1lcgf/src -I/usr/include/python2.4 -c'
> > gcc: /tmp/tmpd1lcgf/src/fortranobject.c
> > gcc: /tmp/tmpd1lcgf/src/untitledmodule.c
> > compiling Fortran sources
> > ifort(f77) options: '-72 -w90 -w95 -KPIC -cm -O3
> > -unroll'
> > ifort(f90) options: '-FR -KPIC -cm -O3 -unroll'
> > ifort(fix) options: '-FI -KPIC -cm -O3 -unroll'
> > compile options: '-I/usr/include/python2.4
> > -I/tmp/tmpd1lcgf/src -I/usr/include/python2.4 -c'
> > ifort:f90: int_sin.f90
> > /opt/intel/fc/9.0/bin/ifort -shared -nofor_main
> > /tmp/tmpd1lcgf/tmp/tmpd1lcgf/src/untitledmodule.o
> > /tmp/tmpd1lcgf/tmp/tmpd1lcgf/src/fortranobject.o
> > /tmp/tmpd1lcgf/int_sin.o -o ./untitled.so
> > IPO Error: unresolved : PyArg_ParseTuple
> >         Referenced in
> > /tmp/tmpd1lcgf/tmp/tmpd1lcgf/src/untitledmodule.o
> 
> Hmm, do you have python-dev package installed in
> your system? Try adding
> -lpython2.3 to the linking step.
> 
> Pearu

I have downloaded the latest version from CVS(current
version number: 2.43.239_1844), and have now installed
python-dev, but still haven't resolved the issues and
the error message seems the same. Also, I tried
running f2py with lpython2.3 option:

f2py -c --fcompiler=Intel -lpython2.3 int_sin.f90

but there doesn't seem to be a package called
lpython2.3(I tried looking in synaptic too).

the output is now:'

*******************************************
numpy_info:
  FOUND:
    define_macros = [('NUMERIC_VERSION',
'"\\"23.8\\""')]
    include_dirs = ['/usr/include/python2.4']

running build
running config_fc
running build_src
building extension "untitled" sources
f2py:> /tmp/tmp27GfJo/src/untitledmodule.c
creating /tmp/tmp27GfJo
creating /tmp/tmp27GfJo/src
Reading fortran codes...
	Reading file 'int_sin.f90' (format:free)
Line #33 in int_sin.f90:"real(DP), parameter ::
interval_end   = 2.0_DP * pi"
	updatevars: no name pattern found for entity='*'.
Skipping.
Post-processing...
	Block: untitled
			Block: int_sin
In: :untitled:int_sin.f90:int_sin
get_parameters: got "unexpected EOF while parsing
(line 1)" on '0.0_dp'
In: :untitled:int_sin.f90:int_sin
get_parameters: got "unexpected EOF while parsing
(line 1)" on '2.0_dp'
In: :untitled:int_sin.f90:int_sin
get_parameters: got "unexpected EOF while parsing
(line 1)" on '3.141592653589793238_dp'
				Block: integ_func
Post-processing (stage 2)...
Building modules...
	Building module "untitled"...
	Wrote C/API module "untitled" to file
"/tmp/tmp27GfJo/src/untitledmodule.c"
  adding '/tmp/tmp27GfJo/src/fortranobject.c' to
sources.
  adding '/tmp/tmp27GfJo/src' to include_dirs.
copying
/usr/lib/python2.4/site-packages/f2py2e/src/fortranobject.c
-> /tmp/tmp27GfJo/src
copying
/usr/lib/python2.4/site-packages/f2py2e/src/fortranobject.h
-> /tmp/tmp27GfJo/src
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
Could not locate executable efort
Could not locate executable efc
customize IntelFCompiler
customize IntelFCompiler using build_ext
building 'untitled' extension
compiling C sources
gcc options: '-pthread -fno-strict-aliasing -DNDEBUG
-g -O3 -Wall -Wstrict-prototypes -fPIC'
creating /tmp/tmp27GfJo/tmp
creating /tmp/tmp27GfJo/tmp/tmp27GfJo
creating /tmp/tmp27GfJo/tmp/tmp27GfJo/src
compile options: '-I/usr/include/python2.4
-I/tmp/tmp27GfJo/src -I/usr/include/python2.4 -c'
gcc: /tmp/tmp27GfJo/src/untitledmodule.c
gcc: /tmp/tmp27GfJo/src/fortranobject.c
compiling Fortran sources
ifort(f77) options: '-72 -w90 -w95 -KPIC -cm -O3
-unroll'
ifort(f90) options: '-FR -KPIC -cm -O3 -unroll'
ifort(fix) options: '-FI -KPIC -cm -O3 -unroll'
compile options: '-I/usr/include/python2.4
-I/tmp/tmp27GfJo/src -I/usr/include/python2.4 -c'
ifort:f90: int_sin.f90
/opt/intel/fc/9.0/bin/ifort -shared -nofor_main
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
/tmp/tmp27GfJo/int_sin.o -lpython2.3 -o ./untitled.so
IPO link: can not find -lpython2.3
IPO Error: unresolved : PyArg_ParseTuple
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : Py_BuildValue
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyErr_SetString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyErr_Occurred
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : Py_InitModule4
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyType_Type
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyImport_ImportModule
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyModule_GetDict
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyDict_GetItemString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyCObject_Type
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : Py_FatalError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyString_FromString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyDict_SetItemString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyErr_NewException
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyErr_Print
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyCObject_AsVoidPtr
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : _PyObject_New
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyDict_New
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyObject_Free
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : _Py_NoneStruct
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : Py_FindMethod
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyString_ConcatAndDel
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyCObject_FromVoidPtr
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyExc_TypeError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyErr_Format
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyExc_RuntimeError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyDict_DelItemString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyExc_AttributeError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
ld: cannot find -lpython2.3
IPO link: can not find -lpython2.3
IPO Error: unresolved : PyArg_ParseTuple
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : Py_BuildValue
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyErr_SetString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyErr_Occurred
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : Py_InitModule4
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyType_Type
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyImport_ImportModule
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyModule_GetDict
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyDict_GetItemString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyCObject_Type
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : Py_FatalError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyString_FromString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyDict_SetItemString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyErr_NewException
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyErr_Print
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : PyCObject_AsVoidPtr
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/untitledmodule.o
IPO Error: unresolved : _PyObject_New
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyDict_New
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyObject_Free
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : _Py_NoneStruct
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : Py_FindMethod
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyString_ConcatAndDel
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyCObject_FromVoidPtr
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyExc_TypeError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyErr_Format
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyExc_RuntimeError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyDict_DelItemString
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
IPO Error: unresolved : PyExc_AttributeError
        Referenced in
/tmp/tmp27GfJo/tmp/tmp27GfJo/src/fortranobject.o
ld: cannot find -lpython2.3



Also, I get a new stderr message :
***********************************************'
error: Command "/opt/intel/fc/9.0/bin/ifort -shared
-nofor_main
/tmp/tmpXrVlzo/tmp/tmpXrVlzo/src/untitledmodule.o
/tmp/tmpXrVlzo/tmp/tmpXrVlzo/src/fortranobject.o
/tmp/tmpXrVlzo/int_sin.o -lpython2.3 -o ./untitled.so"
failed with exit status 1


Again, I'm clueless....



More information about the f2py-users mailing list