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

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. Did you fix that as well? 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 Thanks, Mark On 07/09/2010 02:03 PM, Mark Bakker wrote:
Hello list. The following subroutine fails to compile with f2py. I use a complex variable with intent(inout). It works fine with two real variables, so I have a workaround, but it would be nicer with a complex variable. Any thoughts on what I am doing wrong?
compilation failed because of typos in the generated code. This is fixed in svn revision 8478.
Pearu

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
participants (2)
-
Mark Bakker
-
Pearu Peterson