gpt4 book ai didi

c - 如何使用 C 中的单元号参数调用 Fortran 例程

转载 作者:太空宇宙 更新时间:2023-11-03 23:24:17 24 4
gpt4 key购买 nike

如果我有一个 Fortran 子例程,它将 Fortran IO 单元作为其参数之一(用于打印调试信息),并且此函数被编译到共享库中,我如何从 C 中正确调用此函数?

! An example subroutine that I want to call from C:
subroutine hi(unit)
integer :: unit
write(unit,*) "hello"
end subroutine

! example call site in Fortran
program main
call hi(6)
end

我对这些单元号与文件描述符的关系很感兴趣。

最佳答案

这完全依赖于编译器,没有可移植的对应关系。如果编译器支持某种互操作性作为扩展,请参阅编译器手册。

关于c - 如何使用 C 中的单元号参数调用 Fortran 例程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30865467/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com