Force Python from Fortran

What can Fortran do! !! !!

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.

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!!

next...

I wish I could pass the value

Recommended Posts

Force Python from Fortran
sql from python
MeCab from Python
Use thingsspeak from python
Operate Filemaker from Python
Use fluentd from python
Access bitcoind from python
Changes from Python 3.0 to Python 3.5
Python from or import
Use MySQL from Python
Install python from source
Execute command from Python
Operate neutron from Python!
Use MySQL from Python
Operate LXC from Python
Manipulate riak from python
Use BigQuery from python.
Execute command from python
[Python] Read From Stdin
Use mecab-ipadic-neologd from python
Flatten using Python yield from
Call CPLEX from Python (DO cplex)
Deep Python learned from DEAP
Post from Python to Slack
Grammar features added from Python3.6
Cheating from PHP to Python
Make MeCab available from Python3
Information obtained from tweet_id (Python)
OCR from PDF in Python
Run illustrator script from python
Use MySQL from Anaconda (python)
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Study from Python Hour4: Object-oriented ②
Query Athena from Lambda Python
Access Oracle DB from Python
Study from Python Hour3: Functions
Start / stop GCE from python
Stop Omxplayer from Python code
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
Install pyenv from Homebrew, install Python from pyenv
Study from Python Hour4: Object-oriented ①
Python naming convention (from PEP8)
With skype, notify with skype from python!
Use e-Stat API from Python
Read Fortran output in python
Register redmine issue from Python
Call Matlab from Python to optimize
Execute Python script from batch file
Call a Python function from p5.js.
Python: Exclude tags from html data
Try IAM Database Authentication from Python
Call C from Python with DragonFFI
Touch a Python object from Elixir
Python
Hit treasure data from Python Pandas
Using Rstan from Python with PypeR
Python, yield, return, and sometimes yield from
Install Python from source with Ansible
Create folders from '01' to '12' with python
Notes on using MeCab from Python