Calling a fortran routine as a Scheme function

大憨熊 提交于 2019-12-12 21:17:13

问题


Is it possible to call a Fortran routine as a Scheme function? I could find nothing by searching the web.


回答1:


The answer depends on which implementation you use. Here is an example of writing bindings in Racket. The bindings are for CBLAS and LAPACK. The CBLAS library is C based and LAPACK is Fortran based. Therefore you can see both styles.

(Unfinished) Racket bindings for CBLAS and LAPACK




回答2:


Is it possible? Technically, yes. Most modern Fortran compilers (e.g. ifort, gfortran) support the ISO C Interoperability feature set defined by the Fortran 2003 standard. Thus, it should be possible to write a C compatible API for the fortran libraries you need using the Fortran language. Once you have the C API in place, you should be able to use the standard C FFI provided by your scheme implementation. Of course, all of the usual caveats of calling a C function will also apply here.




回答3:


It all depends on your scheme platform. There is nothing regarding FFI (foreign function interface) in the standard per se, but every actual implementation has its own FFI mechanism (if any).

If you're using racket scheme, it appears there is a solution to do so : see http://wmfarr.blogspot.fr/2007/04/linear-algebra-in-plt-scheme.html



来源:https://stackoverflow.com/questions/14609164/calling-a-fortran-routine-as-a-scheme-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!