Restart Loops in C++

I have a simple question in "theory"
I have the following code, that is running for few thousands iterations, I am trying to add some restart loop or condition. Where I ask the code to restart from a very specific iteration that has been saved on my computer (data of the iteration is saved) instead of running the code from scratch every single time.

For example, if I want to restart the code from the following iteration, but add few changes to my code:

Iteration = 2874 t = 287.50000000 phi_iter = 9
Is this possible? Thanks!

Link for full code, if interested:
https://www.zipshare.com/download/eyJhcmNoaXZlSWQiOiJhOTkxMzRmZi1mN2JlLTRhNDQtYjFhNS05NjkwZTNjOTJhMWIiLCJlbWFpbCI6ImFzdHJvbHVqeUBnbWFpbC5jb20ifQ==
Last edited on
The link doesn't seem to work.
sure, its possible. You need to save everything that matters to the file, though, every single variable's state. The more complex the program the harder it will be to ensure everything is in a resume state, but its always possible, computers are still finite and linear. Parallel processing of any sort could be a headache to unravel correctly.

@dutch

yeah sorry this link should be working:
https://www.zipshare.com/download/eyJhcmNoaXZlSWQiOiIzYjQwMmMxMy0yNzg3LTRiYmUtODViYy1hM2QyNjUyZjU1MjYiLCJlbWFpbCI6ImFzdHJvbHVqeUBnbWFpbC5jb20ifQ==

@jonnin
I have everything saved on my computer, just not sure how to write such loop
if file exists:
?? you read the values in and kick off from where you were.
file >> iteration;
file >> other variables...;

for(iteration; iteration < stop_value; iteration ++)
{
computation;
}

else ... (as before, initial values set and loop from 0 or 1 etc)


note that it would be, if not impossible, not worth doing to try to restart a recursive routine this way.
Last edited on
Topic archived. No new replies allowed.