[Numpy-discussion] ANN: Numpy 1.6.0 release candidate 2

DJ Luscher djl at lanl.gov
Fri May 6 17:00:43 EDT 2011


Pearu Peterson <pearu.peterson <at> gmail.com> writes:
> 
> On Fri, May 6, 2011 at 10:18 PM, DJ Luscher <djl <at> lanl.gov> wrote:
> 
> I have encountered another minor hangup.  For assumed-shape array-valued
> functions defined within a fortran module there seems to be some trouble in
> the autogenerated subroutine wrapper interface.  I think it has to do with   >
the order in which variables are declared in the interface specification.
>
> in the subroutine interface specification the size(a) and size(b) are used to
> dimension outer above (before) the declaration of a and b themselves.  This
> halts my compiler.  The wrapper seems to compile OK if a and b are declared
> above outer in the interface.
> thanks again for your help,
> 
> DJ 
> 
> Your example works fine here:$ f2py  -m foo foo_out.f90 -c$ python -c 'import
> foo; print foo.foo.outer([1,2],[3,4])'[[ 3.  4.] [ 6.  8.]]with outer defined
> before a and b. I would presume that compiler would
> give a warning, at least, when this would be a problem. Anyway, try to apply >
the following patch:
> to see if changing the order will fix the hang.Pearu
> 
> 
indeed - it works fine as is when I compile with gfortran, but not ifort.  I
suppose there may be some compiler option for ifort to overcome that, but I
couldn't tell from a brief scan of the doc.  

the patch works when I add in two separate loops over args: (~line 138 in
func2subr.py):

    for a in args:
        if a in dumped_args: continue    
        if isscalar(vars[a]):
            add(var2fixfortran(vars,a,f90mode=f90mode))
            dumped_args.append(a)
    for a in args:
        if a in dumped_args: continue
	if isintent_in(vars[a]):
            add(var2fixfortran(vars,a,f90mode=f90mode))
            dumped_args.append(a)

not sure if that was your intention, but when I tried to use just "isintent_in"
or to include both conditions in same loop, the input arrays (a and b) were
declared ahead of the derived shape-array (outer), but also ahead of the
integers used to define a and b (e.g. f2py_a_d0).

this works. many thanks, DJ





More information about the NumPy-Discussion mailing list