I'm doing Fortran in a university lecture, but it's really annoying. I want to write modernly without doing this (Swift lover). The other day, a professor of our robot system answered the question "I'm doing Fortran in class. Do you want to use it?" .. Then, at least I won't use it in my future course ...
But for Fortran lecture assignments, you have to submit a .f90 file. Then, why not call your favorite language from Fortran? ?? ?? ??
So, let's try calling the Python code from the Fortran code.
It uses system (the one that can hit the shell from Fortran) to force Python in the same hierarchy.
callpython.f90
program callpython
call system("python called_python.py")
end program callpython
called_python.py
#!/usr/bin/env python
print "message from python code!!"
Execution method is the same as normal .f90
$ gfortran callpython.f90
$ ./a.out
This is the output result
$ message from python code!!
I wish I could pass the value
Recommended Posts