travellhyne / f2py

Automatically exported from code.google.com/p/f2py
Other
0 stars 0 forks source link

power operator in array dimension #38

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I don't know whether this is actually an f2py issue, but:

if you try to compile the following code with:

$> f2py -c -m test test.f90

subroutine array(n, A, B)
    implicit none
    integer n
    double precision A(n,n)
    double precision B(n*n) !B(n**2)
    !f2py intent(in) n
    !f2py intent(out) A
    !f2py intent(out) B
    A(:,:) = 1.0
    B(:) = 2.0
    print *, n
end subroutine

This code works with a multiplication in the dimension of B (i.e. B(n*n)) but 
it does not work with the power operator (i.e. B(n**2)). As far as I know using 
the power works in common Fortran.

The error msg that I get is:

"
In function ‘f2py_rout_test_array’:
error: invalid type argument of unary ‘*’ (have ‘int’)
"

=================
What version of the product are you using? On what operating system?

I am using f2py Version: 2, numpy Version 1.6.1 Python 2.7.3 on Ubuntu 12.04

Original issue reported on code.google.com by Matthias...@gmail.com on 12 Jun 2013 at 12:45

GoogleCodeExporter commented 9 years ago
This is actually expected behavior. Namely, f2py interprets expressions in array
dimension specifications as C expressions, not Fortran expressions.
It is a simplification that can be worked around using signature files.

Original comment by pearu.peterson on 12 Jun 2013 at 8:24