fortran - 带参数的 f2py 转换子例程具有 inout 的意图
问题描述
通过f2py -c sorting.f90 -m sortF
,我得到sortF.cpython-37m-x86_64-linux-gnu.so
了很棒的东西。
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
在这个子程序中,输入array
被改变了,因此,我希望在我执行之后sorting.bubblesort(x)
,我希望x
变成[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]
解决方案
推荐阅读
- multithreading - 从 spark 启动器线程中获取异常
- entity-framework-core - Entity Framework Core 看不到所有子类型字段
- discord.js - 嵌入不和谐机器人的问题
- mongodb - MongoClient insert_one 工作,而 mongoengine 连接不工作(未经授权)
- matplotlib - 如何为科学论文一致且轻松地更改 matplotlib 图中的字体、字体粗细、颜色图……?
- reactjs - 如何在反应js的侧边栏中使所选项目处于活动状态
- r - 在没有 Janitor 包的情况下将列的总和附加到数据框中
- django-rest-framework - 验证 json 字段
- reactjs - PWA 中的随机行为安装为 WebAPK
- sql - SQL - 在另一个表的查询中查找值并返回 YES/NO