[f2py] One dimensional array with unbounded dimension
pearu at cens.ioc.ee
pearu at cens.ioc.ee
Thu Oct 13 19:54:35 EEST 2005
On Thu, 13 Oct 2005, olusegun ogunbade wrote:
>
> Dear All,
>
> I'm a newbie to f2py. I need someone to help me out with this trivial
> problem. I created a signature file for a fortran code. The subroutine
> interface is given as:
>
> subroutine wclbes(zz,eta1,zlmin,nl,fc,gc,fcp,gcp,sig,kfn,mode1,ifail,ipr).
>
> fc, gc, fcp, gcp and sig are arrays dimensioned (0 : *). On exit, each of
> these one-dimensional arrays with dimension (0:d) where d is >= nl + 1 may
> contain the value of a function of order zlmin + n (n = 0,1,...,nl).
>
> The modified signature file I generated looks like this:
> ! -*- f90 -*-
> ! Note: the context of this file is case sensitive.
>
> python module wclbes ! in
> interface ! in :wclbes
> subroutine
> wclbes(zz,eta1,zlmin,nl,fc,gc,fcp,gcp,sig,kfn,mode1,ifail,ipr) ! in
> :wclbes:wclbes.f
> complex*16 intent(in) :: zz
> complex*16 intent(in) :: eta1
> complex*16 intent(in) :: zlmin
> integer intent(in) :: nl
> complex*16 dimension(*), intent(out) :: fc
> complex*16 dimension(*), intent(out) :: gc
> complex*16 dimension(*), intent(out) :: fcp
> complex*16 dimension(*), intent(out) :: gcp
> complex*16 dimension(*), intent(out) :: sig
> integer intent(in) :: kfn
> integer intent(in) :: mode1
> integer intent(out) :: ifail
> integer intent(hide) :: ipr = 1
> integer :: nfp
> integer :: n11
> integer :: npq1
> integer :: npq2
> integer :: n20
> integer :: kas1
> integer :: kas2
> common /coulc2/ nfp,n11,npq1,npq2,n20,kas1,kas2
> end subroutine wclbes
> end interface
> end python module wclbes
>
> ! This file was auto-generated with f2py (version:2.45.241_1926).
> ! See http://cens.ioc.ee/projects/f2py2e/
>
> Afterwards, I created the .so library using f2py -c wclbes.pyf wclbes.f
> without any problem. When I tried to access this from python I got the
> following:
>
> Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
> [GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
> Type "copyright", "credits" or "license()" for more information.
>
> ****************************************************************
> Personal firewall software may warn about the connection IDLE
> makes to its subprocess using this computer's internal loopback
> interface. This connection is not visible on any external
> interface and no data is sent to or received from the Internet.
> ****************************************************************
>
> IDLE 1.0.3
> >>>import Numeric
> >>>import wclbes
> >>>print wclbes.wclbes.__doc__
> wclbes - Function signature:
> fc,gc,fcp,gcp,sig,ifail = wclbes(zz,eta1,zlmin,nl,kfn,mode1)
> Required arguments:
> zz : input complex
> eta1 : input complex
> zlmin : input complex
> nl : input int
> kfn : input int
> mode1 : input int
> Return objects:
> fc : rank-1 array('D') with bounds (*)
> gc : rank-1 array('D') with bounds (*)
> fcp : rank-1 array('D') with bounds (*)
> gcp : rank-1 array('D') with bounds (*)
> sig : rank-1 array('D') with bounds (*)
> ifail : int
>
> >>>a, b, c, d, e, f = wclbes.wclbes(19.2j, 0., 0.728, 11, 3, -2)
>
> Traceback (most recent call last):
> File "<pyshell#5>", line 1, in -toplevel-
> a, b, c, d, e, f = wclbes.wclbes(19.2j, 0., 0.728, 11, 3, -2)
> error: failed in converting hidden `fcp' of wclbes.wclbes to C/Fortran array
>
> What is it that I'm doing wrong? Any suggestion is welcome and will be
> highly valued.
Output arrays should have defined dimensions (f2py should give a warning
on that). So, try
complex*16 dimension(0:nl+1), intent(out) :: fc,gc,fco,gcp,sig
HTH,
Pearu
More information about the f2py-users
mailing list