Page 1 of 1

linking Vensim and Fortran, possible ? How ?

Posted: Thu May 24, 2012 11:29 am
by Christian.Chaboud
Dear colleagues,

I want to establish a 2 ways link between a Fortran porgram and a Vensim program in the following way :
at every time step Vensim receives inputs from Fortran, computes new values for variables, and send some outputs to Fortran ...
1-do you think it is possible ?
2-if possible, how to do that ?...

Thanks for your help

Re: linking Vensim and Fortran, possible ? How ?

Posted: Thu May 24, 2012 12:49 pm
by Administrator
There are three ways you might do this. None of them are trivial and will involve some programming. It can be done though (I've linked Excel/Vensim and MapInfo/Vensim in the past).

1. External functions.The function would be executed each time step, and you could read from an output file or write to one. If your Fortran program is DDE enabled (or can use memory files), you can use that method to swap information.
2. DDE. If the Fortran program has a way of connecting to another application via DDE, you could control Vensim this way.
3. Visual Basic/other. If the Fortran program has an API (like the Vensim DLL), you could control both the model and the Fortran program this way).

Re: linking Vensim and Fortran, possible ? How ?

Posted: Fri May 25, 2012 3:36 pm
by mike
Fortan code can be run via the 'C' language.
Don't recall the details though.
Did it back in the early 1990s.

Re: linking Vensim and Fortran, possible ? How ?

Posted: Sat May 26, 2012 3:13 am
by tomfid
@mike - Right. This is probably the way to go, because Vensim external functions are normally native C, and the DLL is easy to call from C. I haven't used Fortran since the mid-80s, on computers with tape drives, so unfortunately I don't have any further insights on this.