I'm using NMinimize with Mathematica 7 using an external Fortran program to get the target value to minimize. I'm doing it using
RunThrough with the variables as arguments in the command line.
This works, but I have to run the program for every possible candidate of NMinimize and is very slow (the program takes time to run and initialize).
I have made an interactive version of the program that will read the candidates from the standard input and write the resulting value to the standard output, but I cannot make it work in Mathematica. It seems that streams can be Input or Output only, so I cannot read and write to the stream at the same time, or get two different streams from a external execution command.
Documentation suggest using files for exchange but I'm not sure how to do that, not only in Mathematica but also in the Fortran code, to wait for a certain file to have new data instead of just returning EOF.
I've read the answer here: Is it possible to interact with an external program's command-line interface? but it doesn't address an interactive communication.
Any idea how to make Mathematica to open two In/Out streams to a external command?