Re: [f2py] Errors with size 0 arrays
Pearu Peterson <[email protected]> Thu, 11 Jul 2013 16:10:08 +0300
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <CAPpwKcwX7w995cCjZ3Wuv_PLyH6NKfNjHy-VFK7ygm7JQbci-g@mail.gmail.com> |
Hi, f2py generated wrapper code does not support creating 0-size arrays as, in general, passing such arrays to Fortran code is a potential source of trouble. If you still think that it would be worthwhile to have such behavior, please create the corresponding ticket (in numpy trac) and mark it as a feature request. As a workaround, you can create a small Python wrapper around f2py generated wrapper function that checks the u==0 condition and does what you would expect without calling the f2py generated function. HTH, Pearu On Tue, Jul 9, 2013 at 6:23 PM, Ed <[email protected]> wrote: > I have the following subroutine: > > SUBROUTINE test(u,outarr) > implicit none > INTEGER, INTENT(in) :: u > DOUBLE PRECISION, INTENT(out), DIMENSION(u) :: outarr > END SUBROUTINE > > f2py compiles it fine, and I can import it without problem. For all positive > integers, the subroutine runes fine, giving me an array of size u with all > values zero. However, upon trying to run the above with u=0, I get the > following error: > > ValueError: failed to create intent(cache|hide)|optional array-- must have > defined dimensions but got (0,) > > How do I go about fixing this, so I get an array of size 0? > > > _______________________________________________ > f2py-users mailing list > f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > http://cens.ioc.ee/mailman/listinfo/f2py-users