"timer timeout" and "clear"

Hi,

I have wall time limitations and thus I use a “timer timeout” command.
This time I need to perform two simulations within one input script;
this can be done with “clear” command. The “clear” command destroys
everything except “the working directory, log file status, echo status,
and input script variables except for atomfile style variables”.
Timer is not in this list, thus “clear” should destroy it. But this behavior
seems strange. The question is: does “clear” indeed destroy timer?

Best regards,
Anders

Yes, it “has to”. The Timer class is a member of the LAMMPS class and thus is created and destroyed with all of LAMMPS. Only the few settings that are set outside the LAMMPS class (e.g. from the command line) are retained on a clear command.

Here is proof. When I run this input:

timer
timer timeout 0
timer

clear
timer

I get this output:

LAMMPS (2 Aug 2023 - Development - patch_2Aug2023-405-gaa1cde3665-modified)
  using 1 OpenMP thread(s) per MPI task
New timer settings: style=normal  mode=nosync  timeout=off
New timer settings: style=normal  mode=nosync  timeout=00:00:00
New timer settings: style=normal  mode=nosync  timeout=00:00:00
  using 1 OpenMP thread(s) per MPI task
New timer settings: style=normal  mode=nosync  timeout=off
Total wall time: 0:00:00

Dear Axel, thank you for the clarification.
And what would you advise to restrict the computation time of such input script?

Best regards,
Anders

You could take advantage of the fact that variables are retained. Here is a modified version of my previous demo script:

variable tstart timer
variable maxtime index 100

timer timeout ${maxtime}
timer
shell sleep 10

variable tstop timer
variable timeleft equal ${maxtime}-${tstop}+${tstart}
print "${timeleft} of ${maxtime}"

clear
print "${timeleft} of ${maxtime}"
timer timeout $(v_timeleft:%.0f)
timer

Nice solution )
Thanks a lot!

Best regards,
Anders