Re: [f2py] Problems with f2py callback example 64bit ubuntu

Pearu Peterson <[email protected]>
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
Hi,

Add the following line to the body of FOO in callback.f file:

REAL*8 FUN

HTH,
Pearu


On Mon, Nov 30, 2009 at 2:49 PM, Chris Strickland
<christophermarkstrickland-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> I am having trouble in getting f2py callback example to on my 64bit
> installation of ubuntu (both 9.04 and 9.10). I have had no trouble on my
> 32bit installation of ubuntu(9.04). The example I have been trying to get
> work is from the pdf and is as follows.
>
>  C FILE: CALLBACK.F
>       SUBROUTINE FOO(FUN,R)
>       EXTERNAL FUN
>       INTEGER I
>       REAL*8 R
> Cf2py intent(out) r
>       R = 0D0
>       DO I=-5,5
>          R = R + FUN(I)
>       ENDDO
>       END
> C END OF FILE CALLBACK.F
>
> I compiled this using :
> f2py$ f2py -c callback.f -m callback
>
> This is my build log
> 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 "callback" sources
> f2py options: []
> f2py:> /tmp/tmpi5QIEz/src.linux-x86_64-2.6/callbackmodule.c
> creating /tmp/tmpi5QIEz
> creating /tmp/tmpi5QIEz/src.linux-x86_64-2.6
> Reading fortran codes...
>     Reading file 'callback.f' (format:fix,strict)
> Post-processing...
>     Block: callback
>             Block: foo
>                     Block: fun
> Post-processing (stage 2)...
> Building modules...
>     Constructing call-back function "cb_fun_in_foo__user__routines"
>       def fun(i): return r
>     Building module "callback"...
>         Constructing wrapper function "foo"...
>           r = foo(fun,[fun_extra_args])
>     Wrote C/API module "callback" to file
> "/tmp/tmpi5QIEz/src.linux-x86_64-2.6/callbackmodule.c"
>   adding '/tmp/tmpi5QIEz/src.linux-x86_64-2.6/fortranobject.c' to sources.
>   adding '/tmp/tmpi5QIEz/src.linux-x86_64-2.6' to include_dirs.
> copying /usr/lib/python2.6/dist-packages/numpy/f2py/src/fortranobject.c ->
> /tmp/tmpi5QIEz/src.linux-x86_64-2.6
> copying /usr/lib/python2.6/dist-packages/numpy/f2py/src/fortranobject.h ->
> /tmp/tmpi5QIEz/src.linux-x86_64-2.6
> running build_ext
> customize UnixCCompiler
> customize UnixCCompiler using build_ext
> customize GnuFCompiler
> Could not locate executable g77
> Could not locate executable f77
> customize IntelFCompiler
> Could not locate executable ifort
> Could not locate executable ifc
> customize LaheyFCompiler
> Could not locate executable lf95
> customize PGroupFCompiler
> Could not locate executable pgf90
> Could not locate executable pgf77
> customize AbsoftFCompiler
> Could not locate executable f90
> customize NAGFCompiler
> Found executable /usr/bin/f95
> customize VastFCompiler
> customize GnuFCompiler
> customize CompaqFCompiler
> Could not locate executable fort
> customize IntelItaniumFCompiler
> Could not locate executable efort
> Could not locate executable efc
> customize IntelEM64TFCompiler
> customize Gnu95FCompiler
> Found executable /usr/bin/gfortran
> customize Gnu95FCompiler
> customize Gnu95FCompiler using build_ext
> building 'callback' extension
> compiling C sources
> C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
> -Wstrict-prototypes -fPIC
>
> creating /tmp/tmpi5QIEz/tmp
> creating /tmp/tmpi5QIEz/tmp/tmpi5QIEz
> creating /tmp/tmpi5QIEz/tmp/tmpi5QIEz/src.linux-x86_64-2.6
> compile options: '-I/tmp/tmpi5QIEz/src.linux-x86_64-2.6
> -I/usr/lib/python2.6/dist-packages/numpy/core/include
> -I/usr/include/python2.6 -c'
> gcc: /tmp/tmpi5QIEz/src.linux-x86_64-2.6/callbackmodule.c
> gcc: /tmp/tmpi5QIEz/src.linux-x86_64-2.6/fortranobject.c
> compiling Fortran sources
> Fortran f77 compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -fPIC -O3 -funroll-loops
> Fortran f90 compiler: /usr/bin/gfortran -Wall -fno-second-underscore -fPIC
> -O3 -funroll-loops
> Fortran fix compiler: /usr/bin/gfortran -Wall -ffixed-form
> -fno-second-underscore -Wall -fno-second-underscore -fPIC -O3 -funroll-loops
> compile options: '-I/tmp/tmpi5QIEz/src.linux-x86_64-2.6
> -I/usr/lib/python2.6/dist-packages/numpy/core/include
> -I/usr/include/python2.6 -c'
> gfortran:f77: callback.f
> /usr/bin/gfortran -Wall -Wall -shared
> /tmp/tmpi5QIEz/tmp/tmpi5QIEz/src.linux-x86_64-2.6/callbackmodule.o
> /tmp/tmpi5QIEz/tmp/tmpi5QIEz/src.linux-x86_64-2.6/fortranobject.o
> /tmp/tmpi5QIEz/callback.o -lgfortran -o ./callback.so
> running scons
> Removing build directory /tmp/tmpi5QIEz
>
> When I run in python my output is as follows
>
>>>> import callback
>>>> def f(i): return i*i
> ...
>>>> print callback.foo(f)
> 0.0
>>>>
>
> The routing callback.foo(f) should be returning 110.0
>
> Any help with this problem will be greatly appreciated.
>
> Regards,
> Chris.
>
>
>
>
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.