| 1 | It is sometimes convenient to submit jobs and let them run in the background. This easiest way to do this is to run the same step twice, with a variable `loadonly` that indicates whether we want to submit the job (when it is 0) or load results once the job is completed (1). |
| 2 | {{{ |
| 3 | #!m |
| 4 | %Do we need to submit the job or download the results? |
| 5 | loadonly = 0; |
| 6 | |
| 7 | if perform(org,'Stepname') |
| 8 | loadmodel(org,'PreviousStepName'); |
| 9 | |
| 10 | %Make sure jobs are submitted without MATLAB waiting for the results, and job name is unique |
| 11 | md.settings.waitonlock = 0; |
| 12 | md.cluster.interactive = 0; %only needed if you are using the generic cluster |
| 13 | md.miscellaneous.name = 'YourJobName'; |
| 14 | |
| 15 | %Submit job or download results, make sure that there is no runtime name (that includes the date) |
| 16 | md=solve(md,'Transient','runtimename',false,'loadonly',loadonly); |
| 17 | |
| 18 | %Save model if necessary |
| 19 | if loadonly |
| 20 | savemodel(org,md); |
| 21 | end |
| 22 | end |
| 23 | }}} |
| 24 | |
| 25 | Now, to submit jobs, set `loadonly = 0` and launch your simulation. Once it is fully completed, you can set `loadonly = 1` and run the same script, all the results will be downloaded and the model will be saved with a unique name. Good luck! |