Hello! I posted this question on the f2py list but since I haven't got any answers (yet), I thought I'd try my luck here.
I'm having a hard time wrapping a fortran subroutine into a python module. The problem seems to be related to having a subroutine argument to the fortran subroutine. A simple version of my problem is the following. Consider a subroutine (sub), which takes as argument a real array (x), the dimension (n) of that array and another subroutine (other_sub) that is to be called by sub : file sub.f95 ---------------------------------------------- subroutine sub(x,other_sub,n) integer::n real, dimension(n)::x external other_sub call other_sub(x) end subroutine sub ---------------------------------------------- The gnu fortran compiler compiles this snippet without any warnings or errors. However, when I run it through f2py, all I get is a bunch of errors (see below the error output). I'm not sure if this has any relevance but if I change argument x to a real scalar (instead of an array), then f2py executes fine and the python module is generated. I just don't get it! Can anybody explain me what I am doing wrong, please? Thanks in advance. Jose Amoreira Part of the output of f2py -m sub -c sub.f95: ---------------------------------------------- creating /tmp/tmpyHp76U/tmp creating /tmp/tmpyHp76U/tmp/tmpyHp76U creating /tmp/tmpyHp76U/tmp/tmpyHp76U/src.linux-x86_64-2.6 compile options: '-I/tmp/tmpyHp76U/src.linux-x86_64-2.6 - I/usr/lib64/python2.6/site-packages/numpy/core/include - I/usr/include/python2.6 -c' gcc: /tmp/tmpyHp76U/src.linux-x86_64-2.6/fortranobject.c gcc: /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c: In function ‘cb_other_sub_in_sub__user__routines’: /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c:306: error: ‘n’ undeclared (first use in this function) /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c:306: error: (Each undeclared identifier is reported only once /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c:306: error: for each function it appears in.) /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c: In function ‘cb_other_sub_in_sub__user__routines’: /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c:306: error: ‘n’ undeclared (first use in this function) /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c:306: error: (Each undeclared identifier is reported only once /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c:306: error: for each function it appears in.) error: Command "gcc -pthread -fno-strict-aliasing -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables - fasynchronous-unwind-tables -g -fwrapv -fPIC -I/tmp/tmpyHp76U/src.linux- x86_64-2.6 -I/usr/lib64/python2.6/site-packages/numpy/core/include - I/usr/include/python2.6 -c /tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.c -o /tmp/tmpyHp76U/tmp/tmpyHp76U/src.linux-x86_64-2.6/submodule.o" failed with exit status 1 ------------------------------------- _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor