4 ms·
Hi, guys. This is my first post on HN, so I'll tread lightly. I wrote this article about how to execute external binaries such as a Fortran program from inside
by escribapetrus 4y ago
Hi, guys. This is my first post on HN, so I'll tread lightly.
I wrote this article about how to execute external binaries such as a Fortran program from inside the Erlang runtime, using Ports. I hope you like it. Here's an excerpt:
We are going to write a Fortran program that receives input and does some calculations with the values provided by the user. Because our problem here is not how to write Fortran, but rather how to run the program from inside the Erlang runtime, a simple program will do just fine. For this exercise, we will write a program that calculates the force according to Newton's 2nd law.
In order to interface with the Fortran program, we use a genserver process that manages an Erlang port. Ports are Erlang processes that allow running external programs and interact with them in the same way we interact with processes in the Erlang machine, by sending and receiving messages.
Our objective is to call the genserver API in Erlang, have the function transparently execute in the Fortran program (that is, as if it had been called locally), and return the correct result.