Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a fortran routine as a Scheme function

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


2 Answers

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.

like image 197
Benjamin Silbaugh Avatar answered Dec 03 '25 06:12

Benjamin Silbaugh


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

like image 43
soegaard Avatar answered Dec 03 '25 05:12

soegaard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!