Say I have a module to be compiled via f2py
:
test.f90
module test
implicit none
integer, parameter :: q = 2
real(8), parameter, dimension(-q:q) :: vec = (/ 1, 2, 3, 4, 5 /)
contains
subroutine writevec()
write(*,*) vec
end subroutine
end module
Upon running f2py -c -m test test.f90
, I get the error
/tmp/tmp6X6gsD/src.linux-x86_64-2.7/testmodule.c:176:17: error: expected expression before ‘)’ token
{"vec",1,{{-(-)+1}},NPY_DOUBLE},
On the other hand, if I declare vec
with dimension(2*q+1)
, it works. Sort of. When I import into python:
>>> from test import test
>>> test.writevec()
>>> 1.0000000000000000 2.0000000000000000 3.0000000000000000 4.0000000000000000 5.0000000000000000
>>> test.vec
>>> array([ 1., 2.]) # ???
What is going on here??