By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 985 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

f2py and common blocks /Carl

P: n/a
I have been experimenting with f2py and some fortran code that I want to
port to Python.

I have the following fortran file (TEST_00.f):

C FILE: TEST_00.f
SUBROUTINE FOO(WORK)
IMPLICIT REAL*8 (A-H, O-Z)
COMMON /SIZES/ NINT
DIMENSION WORK(NINT)
DIMENSION USOL(NINT)
DO 10 I=1,NINT
WORK(I)=0.0
PRINT *, "In Fortran WORK(I)=", WORK(I)
10 CONTINUE
END
DO 10 I=1,NINT
USOL(I)=0.0
PRINT *, "In Fortran USOL(I)=", USOL(I)
10 CONTINUE
END
C END OF TEST_00.f

and the following signature file (generated by f2py TEST_00.f -m TEST_00 -h
TEST_00.pyf):

python module TEST_00 ! in
interface ! in :TEST_00
subroutine foo(work) ! in :TEST_00:TEST_00.f
real*8 dimension(nint) :: work
integer optional,check(len(work)>=nint),depend(work) ::
nint=len(work)
common /sizes/ nint
end subroutine foo
end interface
end python module TEST_00

When compiling (with f2py -c TEST_00.pyf TEST_00.f) I get the following
error message:

/tmp/tmpl75SQT/src/TEST_00module.c:149: error: `nint' undeclared (first use
in this function)

Question: How can one declare arrays passed as parameters via common block
variables?

Yours/ Carl


Jan 1 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.