有人会报怨,Fortran的库太少了
没关系,借助iso_c_binding,可以拥抱粗大腿Python
Forpy: A library for Fortran-Python interoperability
网址:https://github.com/ylikx/forpy
Python造的轮子:list, dict, tuple, numpy可以统统拿来直接用
以下是一个例子:
[Fortran] 纯文本查看 复制代码 program intro_to_forpy
use forpy_mod
implicit none
integer :: ierror
type(list) :: my_list
ierror = forpy_initialize()
ierror = list_create(my_list)
ierror = my_list%append(19)
ierror = my_list%append("Hello world!")
ierror = my_list%append(3.14d0)
ierror = print_py(my_list)
call my_list%destroy
call forpy_finalize
end program
|