Using F2Py
to compile Fortran
routines being suitable to be used within Python
, the following piece of code is successfully compiled configured gfortran as the compiler while using F2Py
, however, at the time of invoking in Python
it raises a runtime error!
Any comments and solutions?
function select(x) result(y)
implicit none
integer,intent(in):: x(:)
integer:: i,j,temp(size(x))
integer,allocatable:: y(:)
j = 0
do i=1,size(x)
if (x(i)/=0) then
j = j+1
temp(j) = x(i)
endif
enddo
allocate(y(j))
y = temp(:j)
end function select
A similar StackOverflow post can be found here.