# How to continue a simulation when suddenly stopped?

**URL:** <https://gromacs.bioexcel.eu/t/how-to-continue-a-simulation-when-suddenly-stopped/7370>\
**Category:** User discussions\
**Created:** [October 11, 2023, 4:56pm UTC](https://gromacs.bioexcel.eu/t/how-to-continue-a-simulation-when-suddenly-stopped/7370 "2023-10-11T16:56:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nhina](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nhina](https://gromacs.bioexcel.eu/u/nhina)\
**Post date:** [October 11, 2023, 4:56pm UTC](https://gromacs.bioexcel.eu/t/how-to-continue-a-simulation-when-suddenly-stopped/7370/1 "2023-10-11T16:56:20Z")

</div>

GROMACS version:2019  
GROMACS modification: Yes/No  
Hi everyone,  
I’m running .sh file like below and the simulation is stopped at step 100300. How should I change the command to restore simulation from step 100300 without having to rerun from step 1?

"for ((i=0;i\<=1;i=i+1))  
do  
gmx grompp -f nvt.mdp -r em.gro -c em.gro -p top.top -o nvt\_${i}.tpr

```
gmx mdrun -nt 40 -deffnm nvt_${i} -v	

gmx grompp -f npt.mdp -r nvt_${i}.gro -c nvt_${i}.gro -t nvt_${i}.cpt -p top.top -o npt_${i}.tpr

gmx mdrun -nt 40 -deffnm npt_${i} -v

gmx grompp -f md.mdp -r npt_${i}.gro -c npt_${i}.gro -t npt_${i}.cpt -p top.top -o md_${i}.tpr

gmx mdrun -nt 40 -deffnm md_${i} -v

```

done"

---

<div class="post-metadata">

**Author:** ![MagnusL](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/magnusl/32/2380_2.png) [@MagnusL](https://gromacs.bioexcel.eu/u/MagnusL)\
**Post date:** [October 12, 2023, 6:44am UTC](https://gromacs.bioexcel.eu/t/how-to-continue-a-simulation-when-suddenly-stopped/7370/2 "2023-10-12T06:44:04Z")

</div>

You can restart from the latest checkpoint if you add `-cpt` as option, e.g.  
`gmx mdrun -nt 40 -deffnm md_${i} -v -cpt`  
Since you are running with the `-deffnm` option I would suggest that you first check the name of the checkpoint file (called `.cpt`) and specify that as name to the `-cpt` option. Because, if the checkpoint file cannot be found it will start over from the beginning. Even if the files from the previous run are copied beforehand your current checkpoint file might get overwritten, it’s nice not complicate things further and possibly have to restart things from the beginning.

If you really want to be on the safe side you could make a copy of your previous files first.

---

<div class="post-metadata">

**Author:** ![nhina](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nhina](https://gromacs.bioexcel.eu/u/nhina)\
**Post date:** [October 12, 2023, 8:29am UTC](https://gromacs.bioexcel.eu/t/how-to-continue-a-simulation-when-suddenly-stopped/7370/3 "2023-10-12T08:29:03Z")

</div>

Thanks for you reply

I tried as suggested. When I tried, it still started over from the beginning, although I specify name for -cpt option.

I realize that the cpt file is only created when a command is completed. If the simulation suddenly stops, I can not find cpt file created. Is there any way to write the cpt file for each 1000 steps or solve this problem?

Please suggest.  
Regards,  
Nhina

---

<div class="post-metadata">

**Author:** ![MagnusL](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/magnusl/32/2380_2.png) [@MagnusL](https://gromacs.bioexcel.eu/u/MagnusL)\
**Post date:** [October 12, 2023, 8:53am UTC](https://gromacs.bioexcel.eu/t/how-to-continue-a-simulation-when-suddenly-stopped/7370/4 "2023-10-12T08:53:13Z")

</div>

I see that I made a typo in my previous instructions. I meant that the `-cpi` should be used and can also specify the checkpoint file name. I’m sorry about that.

By default a checkpoint file is written every 15 minutes. This can be changed with the `cpt` option (the option use suggested by mistake in my previous post).

I hope it works better with the correct options.
