[Numpy-discussion] f2py problem with complex inout in subroutine

Pearu Peterson pearu.peterson@gmail....
Sat Jul 24 07:02:50 CDT 2010


Hi Mark,

On Mon, Jul 19, 2010 at 11:49 AM, Mark Bakker <markbak@gmail.com> wrote:
> Thanks for fixing this, Pearu.
> Complex arrays with intent(inout) don't seem to work either.
> They compile, but a problem occurs when calling the routine.

What problem?

> Did you fix that as well?

I guess so, see below.

> Here's an example that doesn't work (sorry, I cannot update to svn 8478 on
> my machine right now):
>
>     subroutine test3(nlab,omega)
>         implicit none
>         integer, intent(in) :: nlab
>         complex(kind=8), dimension(nlab), intent(inout) :: omega
>         integer :: n
>         do n = 1,nlab
>             omega(n) = cmplx(1,1,kind=8)
>         end do
>     end subroutine test3

The example works fine here:

$ f2py -c -m foo test3.f90
>>> import foo
>>> from numpy import *
>>> omega=array([1,2,3,4],dtype='D')
>>> foo.test3(omega)
>>> print omega
--> print(omega)
[ 1.+1.j  1.+1.j  1.+1.j  1.+1.j]

If you cannot update numpy to required revision, you can also modify
the broken file directly. It only involves replacing four lines with
one line in numpy/f2py/cfuncs.py file.
See

  http://projects.scipy.org/numpy/changeset/8478

for details.

HTH,
Pearu


More information about the NumPy-Discussion mailing list