pause a running executable and continue other calculations in Matlab
5 views (last 30 days)
Show older comments
Hello,
I am running a Fortran executable inside a Matlab code (whith some other calculations). This executable will pause at one moment specified by me. When the executable is in pause, no other calculation will be performed in Matlab. How can I continue the rest of calculations from Matlab (the execution of other Matlab lines) and to restart the running of the executable afterwards?
Thanks in advance! A.S.
5 Comments
Walter Roberson
on 23 Dec 2015
How can you determine whether the program has reached its suspension point? For example does it output a particular line? What does the program need in order to know it should resume?
Accepted Answer
dpb
on 22 Dec 2015
You'll have to implement some sort of nonblocking semaphore into the Fortran code to allow it to release the CPU and then have another mex function that sends the signal when you're ready to release the execution.
2 Comments
dpb
on 23 Dec 2015
It sounds much more complicated than it is to actually implement altho I've not done the mex file route from Matlab as the cooperating process but see no real issue there since you have access to both you can create a semaphore and when ready to release from Matlab execute the function in the mex file that is the signal the Fortran is waiting for. I've a whole collection of Fortran apps I maintain for power plant online (slow) real time monitoring that operate cooperatively this way. It's a few lines of code on startup to create/connect to the object, and a set of helper function wrappers for the progammer to make the creation and access simple in use. Or, for a wone-place, one-time deal such is this, a single call to the system APIs buried in line isn't that big a deal. With the newer Fortran Standard supporting C interface, one doesn't even have to resort to much if anything non-Standard to be able to access the APIs (although unfortunately, TMW hasn't gotten out of the F77 era in their mex support).
More Answers (0)
See Also
Categories
Find more on Fortran with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!