pause a running executable and continue other calculations in Matlab

5 views (last 30 days)
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
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?
ASauca
ASauca on 23 Dec 2015
I can read the message "Fortran Pause - Enter CR or CR to continue" in command window. By this time, I want to write some data from Matlab in some files which will be used by Fortran and then to continue the calculation. The only problem is that when the Fortran stops, I can go further on to continue my calculations. Thank you for your kind help!

Sign in to comment.

Accepted Answer

dpb
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
ASauca
ASauca on 23 Dec 2015
Thank you for your answer. The change in Fortran code is possible but it would take some time (it has been designed by someone else, therefore it should be asked). And then I started to question if is not possible to force the Fortran executable to release the CPU from Matlab and also from Matlab to decide when to restart the execution?
dpb
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).

Sign in to comment.

More Answers (0)

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!