[NumPy-Tickets] [NumPy] #1532: f2py does not respect assumed size arrays of fortran 90
NumPy Trac
numpy-tickets@scipy....
Thu Jul 1 00:51:26 CDT 2010
#1532: f2py does not respect assumed size arrays of fortran 90
-------------------------+--------------------------------------------------
Reporter: ozn | Owner: pearu
Type: enhancement | Status: new
Priority: normal | Milestone: 2.0.0
Component: numpy.f2py | Version: 1.3.0
Keywords: |
-------------------------+--------------------------------------------------
consider the following fortran 90 file:
$ cat dsum.f90
subroutine dsum(b, a, n)
integer, intent(in) :: n
real,intent(in) :: a(n)
real,intent(out) :: b
b=0.0d0
do i=1,n
b=b+a(i)
end do
end
subroutine locpt(x0,y0,x,y,xd,yd,n,l,m)
IMPLICIT NONE
INTEGER, INTENT(IN) :: xd,yd,n
REAL, INTENT(IN) :: x0, y0, x(:), y(:)
INTEGER, INTENT(OUT) :: l, m
print *, x0
print *, y0
print *, x
print *, y
print *, 'n', n
call dsum(x0,x,n)
print *, 'sum', x0
END SUBROUTINE locpt
I compiled the filed with:
f2py -c -m dsum dsum.f90
and it crashes with:
oz@safira2:~/test$ python
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dsum
>>> dsum.locpt(2.0,2.0,(2.0,1.0,3.0),(5.0,6.0,8.0),7,7,3)
2.0000000
2.0000000
Segmentation fault
if I replace the line declaring the array with:
REAL, INTENT(IN) :: x0, y0, x(xd), y(yd)
no problems occur.
It would be nice to be able to pass assumed size arrays too.
on the other hand, f2py is smart enough to conclude the follwoing:
print dsum2.__doc__
This module 'dsum2' is auto-generated with f2py (version:2_5237).
Functions:
b = dsum(a,n=len(a))
l,m = locpt(x0,y0,x,y,n,xd=len(x),yd=len(y))
so, it figures automatically, that xd and yd, should be optional.
I don't know whether I'd classify it as a bug/feature wish.
But I hope it would at least be considered.
Cheers,
Oz N
(P.S)
I'm using numpy 1.3 on debian lenny.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1532>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list