D3DEnergetic / FIDASIM

A Neutral Beam and Fast-ion Diagnostic Modeling Suite
http://d3denergetic.github.io/FIDASIM/
Other
29 stars 19 forks source link

Lam/jlib #226

Open lamorton opened 3 years ago

lamorton commented 3 years ago

This is my first pass at making Python & Julia interfaces to subroutines in fidasim.f90 module libfida. I modified the make instructions to produce a .so shared object for the Fortran wrappers in cx_helper.f90. This file uses C bindings to avoid Fortran name-mangling & standardize the numeric kinds. The wrappers also to manage hidden global variables (ex: atomic tables) to allow the subroutines to function autonomously. This approach does not require modifications to fidasim.f90. However, it might be more convenient in the future to bring the C bindings directly into fidasim.f90.

Julia uses ccall to easily call the shared library. I'm using the CFFI (C foreign function interface) library in Python. There's a lot of boilerplate involved.