我想建立一个工作流程,在Windows机器上使用Cython从Python到达fortran例程
经过一番搜索,我找到了:http: //www.fortran90.org/src/best-practices.html#interfacing-with-c和https://stackoverflow.com/tags/fortran-iso-c-binding/info
和一些代码pices:
Fortran方面:
pygfunc.h:
void c_gfunc(double x, int n, int m, double *a, double *b, double *c);
Run Code Online (Sandbox Code Playgroud)
pygfunc.f90
module gfunc1_interface
use iso_c_binding
use gfunc_module
implicit none
contains
subroutine c_gfunc(x, n, m, a, b, c) bind(c)
real(C_FLOAT), intent(in), value :: x
integer(C_INT), intent(in), value :: n, m
type(C_PTR), intent(in), value :: a, b
type(C_PTR), value :: c
real(C_FLOAT), dimension(:), pointer :: fa, fb
real(C_FLOAT), dimension(:,:), pointer :: fc
call c_f_pointer(a, fa, (/ n /))
call …Run Code Online (Sandbox Code Playgroud)