Through f2py -c sorting.f90 -m sortF
, I get sortF.cpython-37m-x86_64-linux-gnu.so
which is great.
sorting.f90
module sorting
use iso_fortran_env, only: i4 => int32, i8 => int64
implicit none
contains
subroutine bubbleSort(array)
implicit none
integer, dimension(:):: array
integer :: i, j, tem
i = size(array)
do while (i > 1)
do j = 1, i - 1
if (array(j) > array(j + 1)) then
tem = array(j)
array(j) = array(j + 1)
array(j + 1) = tem
end if
end do
i = i - 1
end do
end subroutine bubbleSort
end module sorting
In this subroutine, the input array
is changed, therefore, I expect after I execute sorting.bubblesort(x)
, I hope x
becomes [1, 2, 3, 5]
In [1]: from sortF import sorting
In [2]: x = [1, 2, 5, 3]
In [3]: print(sorting.bubblesort(x))
None
In [4]: x
Out[4]: [1, 2, 5, 3]