[f2py] f2py with commonblocks - problem
Jan.Sippli at dlr.de
Jan.Sippli at dlr.de
Tue Jul 22 10:43:49 EEST 2008
Hello,
I'm a student at the german aerospace-center in germany.
I have some problems with wrapping code from fortran to python by using common blocks. To show you my problem I paste you some example-fortran code. It isn't allowed (to me) to change the source code to solve the problem.
When I try to create the python-modul I build the .pyf-file first with the following command:
f2py main.f sub.f -m test -h test.pyf
Reading fortran codes...
Reading file 'main.f' (format:fix,strict)
Reading file 'sub.f' (format:fix,strict)
Post-processing...
Block: test
Block: test
Block: set
Block: compute
Block: output
Post-processing (stage 2)...
Saving signatures to file "./test.pyf"
Then I try to build the .so-file by doing this
f2py -c test.pyf main.f sub.f --f90exec=/usr/bin/gfortran
But then I get an ERROR when gcc tries to compile the testmodul.c
for example "n1,n2 is not defined"
Sorry for my bad english.... ;)
http://data.darkstoneathome.de/fortran/main.f
-------------------------------------------------------------------------
program test
c
integer n1, n2
common /sizes/ n1, n2
c
c dimension of array 'work' must be >= n1*n2 (set in subroutine 'set')
c
real work(1000)
c
call set
c
call compute(work)
c
call output(work)
c
end
c
---------------------------------------------------------------------------
http://data.darkstoneathome.de/fortran/sub.f
c---------------
c
subroutine set
c
integer n1, n2
common /sizes/ n1, n2
c
n1 = 5
n2 = 10
c
end
c---------------
c
subroutine compute (work)
c
integer n1, n2
common /sizes/ n1, n2
c
integer i,j
real work(n1,n2)
c
do 20 j=1,n2
do 10 i=1,n1
work(i,j) = real(i) * real(j)**2
10 continue
20 continue
c
end
c-------------------------
c
subroutine output(work)
c
integer nint
common /sizes/ n1, n2
c
integer i, j
real work(n1, n2)
c
do 20 j=1,n2
do 10 i=1,n1
print*, i, '*', j, '**2 = ', work(i,j)
10 continue
20 continue
c
end
c
----------------------------------------------------------------------------------
Deutsches Zentrum für Luft- und Raumfahrt e.V.
in der Helmholtz-Gemeinschaft
Ausbildung - Berufsakademie
Jan Sippli
More information about the f2py-users
mailing list