USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_LOC, C_PTR, C_ASSOCIATED 。该模块中定义的过程如下 功能 说明 C_LOC(X) 返回参数的 C 地址 C_ASSOCIATED(C_PTR_1 [, C_PTR_2]) 表示C_PTR_1的关联状态,或者表示C_PTR_1和C_PTR_2是否与同一个实体关联。
subroutinelua_createtable(L,narr,nrec)bind(c,name="lua_createtable")use,intrinsic::iso_c_bindingtype(c_ptr),value::Linteger(kind=c_int),value::narrinteger(kind=c_int),value::nrecend subroutinelua_createtable wrapper function in Fortran subroutineflu_createtable(L,narr,nrec)type(flu_State)...
program vectors use, intrinsic :: iso_c_binding implicit none type, bind(c) :: Vector integer(kind=c_int) :: size real(kind=c_double) :: data(3) end type Vector type, bind(c) :: VerticesVect integer(kind=c_int) :: size type(c_ptr) :: data end type VerticesVect interface fun...
! square.f90 module square_module use, intrinsic :: iso_c_binding implicit none contains function square(x) bind(c, name="square") real(c_float), intent(in) :: x real(c_float) :: square square = x * x end function square end module square_module bind(c, name="square") 使得可...
c. 在Fortran中,使用`ISO_C_BINDING`模块声明C函数,并调用`system_call`函数: “`fortran program main use, intrinsic :: iso_c_binding interface subroutine system_call(command) bind(c) import :: c_char, c_null_char character(kind=c_char), dimension(*), intent(in) :: command ...
2.2.2 C 绑定模块Fortran 2003 标准提供了一种引用 C 语言过程的方式。ISO_C_BINDING 模块按内模块函数形式定义了三个支持过程。访问这些函数需要在调用例程中使用 USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_LOC, C_PTR, C_ASSOCIATED。该模块中定义的过程如下...
programf_call_cuse,intrinsic::iso_c_bindingimplicitnone! define same struct in Ctype,bind(c)::my_structinteger(c_int)::nntype(c_ptr)::arrayendtypeinterfacetype(my_struct)functionmake_array() bind(c,name='make_array') import!! Make iso_c_binding and my_struct visible hereendfunctionend...
use,intrinsic :: iso_c_binding implicit none integer(c_int),value :: n !intent(in)可以加也可以不加 real(c_double) :: p(n) !intent(out)可以加也可以不加 integer(c_int) i do i=1,n p(i)=i*i end do return end 此处定义了一个C类型的函数,名字叫fun,并且其数据类型定义均采用c_*...
an intrinsic module (ISO_C_BINDING) that provides access to named constants and procedures relevant to C interoperability. Clearly, any interoperable entity must be such that equivalent declarations of it may be made in the two languages. This is enforced within the Fortran program by requiring al...
use,intrinsic::iso_c_binding!>三种接口interface!>接口1:(*)integerfunctionmax_1(two_int)bind(c,name="max")integer,intent(in)::two_int(*)endfunctionmax_1!>接口2(不推荐):(1)integerfunctionmax_2(two_int)bind(c,name="max")integer,intent(in)::two_int(1)endfunctionmax_2!>接口3:c_pt...