Ich hab mich aus Neugier mal an ein bisschen Fortran versucht, bin über f2py gestolpert, und fand die Idee das ganze nach Python zu wrappen sehr reizvoll.
alle Beispiele hab ich hierher:
http://cens.ioc.ee/projects/f2py2e/
erste Versuche:
1.
Create a Fortran file hello.f that contains:
Code: Alles auswählen
C File hello.f
subroutine foo (a)
integer a
print*, "Hello from Fortran!"
print*, "a=",a
end
Code: Alles auswählen
flo@AKB-34:~/Desktop/FORTRAN$ f2py -c -m hello hello.f
numpy_info:
FOUND:
define_macros = [('NUMERIC_VERSION', '"\\"24.2\\""'), ('NUMERIC', None)]
include_dirs = ['/usr/include/python2.5']
running build
running config_fc
running build_src
applying backend (numeric) info to extensions
building extension "hello" sources
f2py:> /tmp/tmp4Sc3Nd/src/hellomodule.c
creating /tmp/tmp4Sc3Nd
creating /tmp/tmp4Sc3Nd/src
Reading fortran codes...
Reading file 'hello.f'
Post-processing...
Block: hello
Block: foo
Post-processing (stage 2)...
Building modules...
Building module "hello"...
Constructing wrapper function "foo"...
foo(a)
Wrote C/API module "hello" to file "/tmp/tmp4Sc3Nd/src/hellomodule.c"
adding '/tmp/tmp4Sc3Nd/src/fortranobject.c' to sources.
adding '/tmp/tmp4Sc3Nd/src' to include_dirs.
copying /usr/lib/python2.5/site-packages/f2py2e/src/fortranobject.c -> /tmp/tmp4Sc3Nd/src
copying /usr/lib/python2.5/site-packages/f2py2e/src/fortranobject.h -> /tmp/tmp4Sc3Nd/src
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
Could not locate executable g77
customize GnuFCompiler
Could not locate executable ifort
Could not locate executable ifc
Could not locate executable efort
Could not locate executable efc
Could not locate executable ifort
customize IntelFCompiler
customize LaheyFCompiler
customize PGroupFCompiler
customize AbsoftFCompiler
customize NAGFCompiler
customize VastFCompiler
customize GnuFCompiler
customize CompaqFCompiler
customize IntelItaniumFCompiler
customize G95FCompiler
customize GnuFCompiler
customize GnuFCompiler
customize GnuFCompiler using build_ext
building 'hello' extension
compiling C sources
gcc options: '-pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC'
creating /tmp/tmp4Sc3Nd/tmp
creating /tmp/tmp4Sc3Nd/tmp/tmp4Sc3Nd
creating /tmp/tmp4Sc3Nd/tmp/tmp4Sc3Nd/src
compile options: '-DNUMERIC_VERSION="\"24.2\"" -DNUMERIC -I/usr/include/python2.5 -I/tmp/tmp4Sc3Nd/src -I/usr/include/python2.5 -c'
gcc: /tmp/tmp4Sc3Nd/src/fortranobject.c
gcc: /tmp/tmp4Sc3Nd/src/hellomodule.c
compiling Fortran sources
f77(f77) options: '-Wall -fno-second-underscore -fPIC -O2 -funroll-loops -march=i686 -malign-double -fomit-frame-pointer'
compile options: '-I/usr/include/python2.5 -I/tmp/tmp4Sc3Nd/src -I/usr/include/python2.5 -c'
f77:f77: hello.f
foo:
cc1: Warnung: Kommandozeilenoption "-fno-second-underscore" ist g�ltig f�r Fortran, aber nicht f�r C
/usr/bin/f77 -shared /tmp/tmp4Sc3Nd/tmp/tmp4Sc3Nd/src/hellomodule.o /tmp/tmp4Sc3Nd/tmp/tmp4Sc3Nd/src/fortranobject.o /tmp/tmp4Sc3Nd/hello.o -lg2c -o ./hello.so
/usr/bin/ld: cannot find -lg2c
collect2: ld gab 1 als Ende-Status zur�ck
Removing build directory /tmp/tmp4Sc3Nd
ich hab das -lg2c gegoogelt und hab daraufhin libg2c0 installiert. Hat leider nichts gebracht.
Hat Jemand von Euch eine Idee??
Vielen Dank & Gru�,
flo
ach ja -- os ist ubuntu 8.10 intrepid