How to compile Python scripts for use in FORTRAN?

后端 未结 2 1616
小鲜肉
小鲜肉 2021-01-05 09:43

Although I found many answers and discussions about this question, I am unable to find a solution particular to my situation. Here it is:

I have a main program writt

相关标签:
2条回答
  • 2021-01-05 09:55

    You don't want any of those. What you should do is use FORTRAN's FFI to talk with libpython and frob its API.

    0 讨论(0)
  • 2021-01-05 09:58

    One way or another, you'll need to get the Python runtime on your server, otherwise it won't be possible to execute Python bytecode. Ignacio is on the right track with suggesting invoking libpython directly, but due to Fortran's parameter-passing conventions, it will be a lot easier for you to write a C wrapper to handle the interface between Fortran and the CPython embedding API.

    Unfortunately, you're doing this the hard way -- it's a lot easier to write a Python program that can call Fortran subroutines than the other way around.

    0 讨论(0)
提交回复
热议问题