Open jacobwilliams opened 4 months ago
That's great. Yes, I was aware of this inefficiency; I know C and Python (among other languages) but I don't know enough Fortran to have undertaken that kind of surgery on the code. Will your fpm package build and install a shared library? If so then I should be able to wrap it with Python straightforwardly and replace the crap that I have here.
yeah I'm using my fork as an experiment to learn about f2py
and how to wrap modern fortran. work in progress.
@jacobwilliams, I think that I can wrap what you have. If I do it in a clean-room manner I can release a new Python wrapper under more favorable terms for third-party contribution. Are you planning to do a release of your fpm package in the near future?
Feel free to use it or get whatever inspiration you need from it. Sure, I'll probably release it as an FPM package at some point.
FYI
I've refactored the Fortran code to modern standards, and you can find it here if you are interested: https://github.com/jacobwilliams/radbelt
Your Python version is very inefficient, I believe because it is reading all the data files every time the
get_flux
function is called? Unless I'm reading it wrong or calling it incorrectly. See my test case.Compare to my refactored version:
The class version of mine will only read the files once, and store the data in the class so that subsequent calls don't have to read it again. That results in a huge speedup. Something like that could be implemented for the Python wrapper I believe.