f2py::Fortran 90 模块中的可分配数组
2012-03-21 13:39
344 查看
F2PY has basic support for Fortran 90 module allocatable arrays.
请看示例Fortran 90 文件:
在dos窗口编译一下:
下面演示在python中如何使用:
更详细的介绍见官方网站:
http://cens.ioc.ee/projects/f2py2e/
请看示例Fortran 90 文件:
module mod real, allocatable, dimension(:,:) :: b contains subroutine foo integer k if (allocated(b)) then print*, "b=[" do k = 1,size(b,1) print*, b(k,1:size(b,2)) enddo print*, "]" else print*, "b is not allocated" endif end subroutine foo end module mod
在dos窗口编译一下:
f2py -c -m allocarr allocarr.f90
下面演示在python中如何使用:
>>> allocarr.mod.foo() b=[ 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 ] >>> allocarr.mod.b # b is Fortran-contiguous array([[ 1., 2., 3.], [ 4., 5., 6.]],'f') >>> allocarr.mod.b = [[1,2,3],[4,5,6],[7,8,9]] # reallocate/initialize b >>> allocarr.mod.foo() b=[ 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000 ] >>> allocarr.mod.b = None # deallocate array >>> allocarr.mod.foo() b is not allocated
更详细的介绍见官方网站:
http://cens.ioc.ee/projects/f2py2e/
相关文章推荐
- f2py::演示Fortran模块功能
- Fortran把未分配的数组传入子过程,在子过程中分配空间
- Re: 用FORTRAN90最大可以开多大的数组?
- Fortran 动态分配数组
- C++动态分配二维/三维数组
- (转)Fortran、matlab 和 C语言中数组的存储方式
- 7.13 我该如何动态分配多维数组 ?
- 初始化动态分配的数组
- C++笔记之使用new动态分配多维数组
- 实现动态分配一维,二维,三维数组
- 使用f2py将C语言的函数转换为python模块
- Go语言的后缀数组模块尝鲜
- 数组及引用类型内存分配
- K3 工资模块进行费用分配 提示不能取得相应工资数据的解决方法
- 3. 动态分配数组
- 3. 动态分配数组
- 彻底了解指针数组,数组指针,以及函数指针,以及堆中的分配规则(转)
- 数组的动态分配(new)、初始化(memset)和撤销(delete)
- 【算法】C语言实现数组的动态分配
- 动态数组分配(C语言)