jadconnolly / Perple_X

GNU General Public License v3.0
25 stars 5 forks source link

Perplex wrapper functions #5

Closed sc-dyer closed 4 months ago

sc-dyer commented 5 months ago

I've developed a handful of wrapper functions in a new file called perplexwrapper.f So far all I've implemented is a limited version of meemum and pssect that can be called from external programs. Example implementations can be found in an experimental julia package I'm working on: JPerplex.jl. These wrappers seem to work and can be effectively called from Julia, I havent tested calling from other languages but they should work too.

The changes are mostly limited to the new file but there are some additional common variables added to use as flags in some of the main functions. As far as I can tell this has not impacted other programs and tests are still passing, but I have not done rigorous testing.

There is a lot more that can be added to this. I have been working on implementing a function call of vertex that will return the full data output of vertex without needing to mess around with werami but this has been quite challenging.

boriskaus commented 5 months ago

I think this would be a useful addition but leave it up to Jamie to see if he is happy to keep the changes inro account in future versions of Perple_X. If you compile this function on the BinaryBuilder version of Perple_X it will be included in Perple_X_jll so will be easier to embed on your julia interface

jadconnolly commented 4 months ago

Sorry for taking so long to respond and thank you very much for the contribution. As Boris can attest, I know nothing about programming and/or repositories. One consequence of that is that my working copy of Perple_X is in a different repository and someone else has recently made changes there. I'll clean that up in the next few days and push it to a branch here, then merge your branch into that (if I understand how these things work), and then merge the whole thing back to main. Your changes look safe to me, however, my preference is to place all the commons I can in perplex_parameters.h, your LibVars common could go there. There's also another main program (MC_fit.f, same dependencies as MEEMUM) that does thermodynamic parameter and thermobarometric inversion present, i think, in src for which there's currently no target in the makefile(s).

MEEMUM does bypass WERAMI to return all anticipated properties, an issue there is that, as also the case for WERAMI, it calls getloc/calpr0 to do so and those routines would generate a fair amount of overhead in VERTEX when, say, only one property is of interest. That mess could be cleaned up by creating a list of the desired properties and only calculating those.

sc-dyer commented 4 months ago

Thanks for the feedback! I Just pushed some commits that should address these issues. Let me know if there's anything else that needs to be changed.