I am relatively new to making different programing languages communicate with each other and would appreciate some help. Basically I have a Fortran code and a Matlab code. Both codes are first initialized and then have to run sequentially. Each code requires input from the other one. When this process has repeated often enough some convergence criteria is reached and the iteration is terminated. To make things more complicated the Fortran code not only requires input from Matlab but also from its own previous iteration. The same holds true for Matlab. So as far as I can see it is best to keep both programs open throughout the iteration process as I have a lot of variables and therefore can’t just write them in a text file to hand them over to the other programme and preserve them for the next iteration.
So essentially I’m trying to do something like this:
Initialise variable sets A,B,C and D
Fortran:
Input: A and B
Calculations …
Output: A (variables have now new values) and D
Matlab:
Input: C and D
Calculations …
Output: C (variables have now new values) and B
Repeat Fortran and Matlab until convergence criteria is reached.
So my questions are: How to make Matlab and Fortran communicate with each other and pass variables to one and another? And how can each code trigger the other one but then wait for the other code to finish its calculation first before continuing?