I am working in Python calling a Fortran function bound by f2py. When I explicitly dimension the array my sum call returns the desired result, but when I use assumed-shape it returns 0
! foo.f95
function sum_test(arr)
IMPLICIT NONE
integer(8), dimension(:), intent(in) :: arr
integer(8) :: sum_test
sum_test = sum(arr)
end function sum_test
Python side:
import foo
foo.sum_test([1,2,3])
0L
if I dimension explicitly in Fortran:
! foo.f95
function sum_test(arr)
IMPLICIT NONE
integer(8), dimension(3), intent(in) :: arr
integer(8) :: sum_test
sum_test = sum(arr)
end function sum_test
Python side:
import foo
foo.sum_test([1,2,3])
6L
Note that if I print out my values on the assumed-shape version like so:
write(*,*) arr
I can see the values in the array.
I'm clearly missing some key piece here!