# Suggestions for how to suspend a programme, while preserving the computations, which takes several days to finish?

I have a programme that needs to run for some time (2 days more or less). I only have access to a laptop, which I must turn off at the end of the day.

I thought of making my programme to export the computed data at the end of the day to a .txt file, and then on the next day to import it from the same file, and begin the computations from the last of the previous day.

For that, I thought of creating a main while cycle where we would define the variable 'stop', with a DialogInput box, so that the user could stop the programme at their desired time, without ruining the possible current computations.

For example:

stop=0;

While[stop==0 && numbComp<=UpBound,

DialogNotebook[{TextCell["Click to stop computations"],
Button["Stop", DialogReturn[1]]}]];

(*Heavy Computations Here*)

numbComp++;

];


However, this method seems not to work since Mathematica will not proceed until the user has clicked a button in the dialogue box...

Well, after searching the wolfram documentation I wrote this:

stop = 0;
counter = 0;
CreateDialog[
Column[{TextCell["Click to stop computations"],
Button["Stop", DialogReturn[stop = 1; Beep[] ]]}]];
While[stop == 0 && counter <= 5000000,

data = RandomVariate[NormalDistribution[0, 10], counter];(*This is just an example*)

counter++;

];


This seems to work fine. If someone has a better idea, please share.

• If you use Windows, you might hibernate it and resume the next day. This used to work many years ago. I no longer use windows so I do not know if it still does, and if problems would be expected. For safety, you can also interrupt the computation first: mathematica.stackexchange.com/q/58446/12 – Szabolcs Jan 7 at 15:48
• @Szabolcs I've added some new information. I would like to know if you agree with it. Thanks for your comment. ;) – An old man in the sea. Jan 7 at 17:29