i was wondering if it is possible to call python from fortran.
In particular, my goal is to call some python functions (in which i use tensorflow) by passing a fortran array to the functions directly from fortran.
I know that i can do the opposite: in particular, i have used f2py for binding some subroutines from fortran to python and they work well.
If someone has some ideas, i really will appreciate that. P.S. If there is the possibility to pass from C using iso_bind_c, someone has some guides/references? Thank you in advance!
I have tried to look at third party libraries but i have not found something easy to manage, also, i think that doing the binding with c could be great, but i have not found reference/tutorial online. Also, i have not found online if it is possible to use f2py for calling a python function from fortran.
So yes, you can call Python through the C API, but it is complicated enough that you probably don't want to. You'd then probably have to write your own library around the C API for python to use it from Fortran to do the data massaging you need. This is documented here:
https://docs.python.org/3/c-api/intro.html
If you are trying to use TensorFlow, a better approach would probably be the C interface to TensorFlow:
https://www.tensorflow.org/install/lang_c
Good luck!