[f2py] f2py + F90 problems

Bruno Fletcher brunofletcher at gmail.com
Tue Jun 24 04:17:26 EEST 2008


Hi there,
I was finally able to get the allocarr.f90 example to work. I removed
numpy 1.0.4 from my machine (which was installed via the official
Ubuntu *.deb package), and built numpy 1.1.0 from source.  Everything
seems to be working perfectly now...

Thanks for your help.

Cheers,
Bruno Fletcher


On Mon, Jun 23, 2008 at 5:38 PM, Bruno Fletcher <brunofletcher at gmail.com> wrote:
> Hi there Pearu,
>
> Thanks for the tip. I tried running the command that you suggested,
> but I still get an error when I import the module in Python:
>
>
> fletcher at fletcher-laptop:~/Desktop/OLD_DESKTOP$ sudo f2py -c
> --fcompiler=gnu95 -m allocarr allocarr.f90
> running build
> running config_cc
> unifing config_cc, config, build_clib, build_ext, build commands
> --compiler options
> running config_fc
> unifing config_fc, config, build_clib, build_ext, build commands
> --fcompiler options
> running build_src
> building extension "allocarr" sources
> f2py options: []
> f2py:> /tmp/tmpdrrVAE/src.linux-i686-2.5/allocarrmodule.c
> creating /tmp/tmpdrrVAE
> creating /tmp/tmpdrrVAE/src.linux-i686-2.5
> Reading fortran codes...
>        Reading file 'allocarr.f90' (format:free)
> Post-processing...
>        Block: allocarr
>                        Block: mod
>                                Block: foo
> Post-processing (stage 2)...
>        Block: allocarr
>                Block: unknown_interface
>                        Block: mod
>                                Block: foo
> Building modules...
>        Building module "allocarr"...
>                Constructing F90 module support for "mod"...
>                  Variables: b
> getarrdims:warning: assumed shape array, using 0 instead of ':'
> getarrdims:warning: assumed shape array, using 0 instead of ':'
>                        Constructing wrapper function "mod.foo"...
>                          foo()
>        Wrote C/API module "allocarr" to file
> "/tmp/tmpdrrVAE/src.linux-i686-2.5/allocarrmodule.c"
>        Fortran 90 wrappers are saved to
> "/tmp/tmpdrrVAE/src.linux-i686-2.5/allocarr-f2pywrappers2.f90"
>  adding '/tmp/tmpdrrVAE/src.linux-i686-2.5/fortranobject.c' to sources.
>  adding '/tmp/tmpdrrVAE/src.linux-i686-2.5' to include_dirs.
> copying /usr/lib/python2.5/site-packages/numpy/f2py/src/fortranobject.c
> -> /tmp/tmpdrrVAE/src.linux-i686-2.5
> copying /usr/lib/python2.5/site-packages/numpy/f2py/src/fortranobject.h
> -> /tmp/tmpdrrVAE/src.linux-i686-2.5
>  adding '/tmp/tmpdrrVAE/src.linux-i686-2.5/allocarr-f2pywrappers2.f90'
> to sources.
> running build_ext
> customize UnixCCompiler
> customize UnixCCompiler using build_ext
> customize Gnu95FCompiler
> Found executable /usr/bin/gfortran
> customize Gnu95FCompiler using build_ext
> building 'allocarr' extension
> compiling C sources
> C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2
> -Wall -Wstrict-prototypes -fPIC
>
> creating /tmp/tmpdrrVAE/tmp
> creating /tmp/tmpdrrVAE/tmp/tmpdrrVAE
> creating /tmp/tmpdrrVAE/tmp/tmpdrrVAE/src.linux-i686-2.5
> compile options: '-I/tmp/tmpdrrVAE/src.linux-i686-2.5
> -I/usr/lib/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> gcc: /tmp/tmpdrrVAE/src.linux-i686-2.5/allocarrmodule.c
> gcc: /tmp/tmpdrrVAE/src.linux-i686-2.5/fortranobject.c
> compiling Fortran 90 module sources
> Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -fPIC -O3 -funroll-loops -mmmx -m3dnow -msse2
> -msse
> Fortran f90 compiler: /usr/bin/gfortran -Wall -fno-second-underscore
> -fPIC -O3 -funroll-loops -mmmx -m3dnow -msse2 -msse
> Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -Wall -fno-second-underscore -fPIC -O3
> -funroll-loops -mmmx -m3dnow -msse2 -msse
> compile options: '-I/tmp/tmpdrrVAE/src.linux-i686-2.5
> -I/usr/lib/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> extra options: '-J/tmp/tmpdrrVAE/ -I/tmp/tmpdrrVAE/'
> gfortran:f90: allocarr.f90
> compiling Fortran sources
> Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -fPIC -O3 -funroll-loops -mmmx -m3dnow -msse2
> -msse
> Fortran f90 compiler: /usr/bin/gfortran -Wall -fno-second-underscore
> -fPIC -O3 -funroll-loops -mmmx -m3dnow -msse2 -msse
> Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -Wall -fno-second-underscore -fPIC -O3
> -funroll-loops -mmmx -m3dnow -msse2 -msse
> compile options: '-I/tmp/tmpdrrVAE/src.linux-i686-2.5
> -I/usr/lib/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> extra options: '-J/tmp/tmpdrrVAE/ -I/tmp/tmpdrrVAE/'
> gfortran:f90: /tmp/tmpdrrVAE/src.linux-i686-2.5/allocarr-f2pywrappers2.f90
> /usr/bin/gfortran -Wall -Wall -shared
> /tmp/tmpdrrVAE/tmp/tmpdrrVAE/src.linux-i686-2.5/allocarrmodule.o
> /tmp/tmpdrrVAE/tmp/tmpdrrVAE/src.linux-i686-2.5/fortranobject.o
> /tmp/tmpdrrVAE/allocarr.o
> /tmp/tmpdrrVAE/tmp/tmpdrrVAE/src.linux-i686-2.5/allocarr-f2pywrappers2.o
> -lgfortran -o ./allocarr.so
> Removing build directory /tmp/tmpdrrVAE
> fletcher at fletcher-laptop:~/Desktop/OLD_DESKTOP$ python
> Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import allocarr
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ImportError: ./allocarr.so: undefined symbol: f2pyinitmod_
>
> I tried using the ifort compiler (intel compiler) but I still get the
> same message. Any ideas?
>
> I appreciate your help...
>
> Cheers,
> Bruno F.
>
>
> On Mon, Jun 23, 2008 at 1:41 AM, Pearu Peterson <pearu at cens.ioc.ee> wrote:
>> On Mon, June 23, 2008 3:51 am, Bruno Fletcher wrote:
>>> Hi there,
>>>
>>> I am having issues when I try to compile a module based F90 sample
>>> code with f2py;  in my case, I'm just trying to run the "allocarr"
>>> example from the f2py documentation. I downloaded the code from the
>>> documentation's website
>>> (http://cens.ioc.ee/projects/f2py2e/usersguide/allocarr.f90), and then
>>> I invoke f2py to compile module:
>>>
>>> fletcher at fletcher-laptop:~/Desktop$ f2py -c
>>> --f90exec=/usr/bin/gfortran -m allocarr allocarr.f90
>> ..
>>
>>> Traceback (most recent call last):
>>>   File "<stdin>", line 1, in <module>
>>> ImportError: ./allocarr.so: undefined symbol: _gfortran_st_write_done
>>>
>>> Does anyone have an idea of what might be causing this error?
>>
>> Yes, you should invoke f2py using --fcompiler=gnu95 switch
>> in order to use gfortran:
>>
>>  f2py -c --fcompiler=gnu95 -m allocarr allocarr.f90
>>
>> Otherwise, although with --f90exec the Fortran code is compiled with
>> gfortran but the module is still linked with the g77, and hence
>> the gfortran undefined symbol.
>>
>> HTH,
>> Pearu
>>
>>
>> _______________________________________________
>> f2py-users mailing list
>> f2py-users at cens.ioc.ee
>> http://cens.ioc.ee/mailman/listinfo/f2py-users
>>
>



More information about the f2py-users mailing list