You do not have to pass arrays to Fortran code using text files. If you create an entry point to the Fortran code as a subroutine, you can pass all the numpy
arrays using f2py
. You should be aware of that if you added the f2py
tag yourself. Just use any of the numerous tutorials, for example https://github.com/thehackerwithin/PyTrieste/wiki/F2Py or http://www.engr.ucsb.edu/~shell/che210d/f2py.pdf .
The way back is the same, the Fortran code just fills any of the intent(out)
or intent(inout)
arrays and variables with the results.