How to quit lammps after a certain period of time

Dear all,

I am running Lammps on a HPC cluster. The files are copied from a global directory to a local one (from a share disk to the node’s disk) and then Lammps runs. Once the job is successfully finished, everything is moved back to the share disk. However, submitted jobs have a time limit. After 7 days, jobs are killed and files are stuck in the local disks.

How can I quit lammps properly, just before jobs are killed ?

I would need something like

submission script:

lmp -in input_file

within the input_file

if time > 6.99 days then
  write_restart
  quit
end if

In this way, my submission script could end properly and copy the files on my global directory.

It would be even greater if I have something like:

submission script:

lmp -in input_file

within the input_file

if time > 6.99 days then
  write_restart
  quit
end if

back in the submission script:

launch a new job : lmp -in restart_input_file

within the restart_ input_file

read_restart 

cheers,

Yann
Post-doc at IPR, Rennes, France

The use of the “if” statement the way you outlined it cannot work, because when the if statement is processed, the time has not yet passed. Usually you will be within a “run” or “minimize” command when you need to check if the time has expired.

There are two ways to address this:

  • you use the restart command to regularly write out restart files during a run. Then if the job gets killed because the time has run out, you can continue with a new input using a read_restart command to read the latest restart and then use the run command with the “upto” option to continue the interrupted run
  • you can use the timer command with the timeout option to stop a run/minimize after a predetermined time and then write your script so that it properly acts if the run/minimize ends prematurely with a timed out timer

Axel.

Thanks, For now, I was using your first solution, but it is not convenient as I have to copy back all the files on the global disk.

Your second solution seems to be the one I was looking for. Thank you very much !

Yann