Dear LAMMPS Community,
I have encountered that LAMMPS requires initialization of the variable even if the -skiprun
option is used. Let me first give you an MWE: (I didn’t care about the physical component, just to reproduce the error)
# Initialization
lattice fcc 0.001
region allbox block 0 100 0 100 0 100 side in units box
create_box 1 allbox
create_atoms 1 box
mass 1 1
pair_style lj/cut 2.5
pair_coeff 1 1 1 1
# Main part
compute neighs all coord/atom cutoff 1.5
variable is_monomer atom c_neighs==0
write_restart restart.a
group monomers variable is_monomer
If I run it the normal way lmp -in in.file
, everything works. But if I add the -skiprun
option: lmp -skiprun -in in.file
, I get the error:
ERROR: Variable is_monomer: Variable formula compute cannot be invoked before initialization by a run (src/variable.cpp:1674)
Last command: group monomers variable is_monomer
In principle, it is clear that it is incorrect to use a variable defined as a result of a calculation that did not occur because the -skiprun
option was used. But this is exactly what the -skiprun
option is used for. Uncertainty.
What is interesting about it is that if we add the write_restart
command before the needed variable is used, for example:
variable is_monomer atom c_neighs==0
write_restart restart.a
group monomers variable is_monomer
and run it with the -skiprun
option, there will be no error.
Is adding the write_restart
command the correct solution to the error?
LAMMPS: 2 Aug 2023 development, platform: SLES 12.3 and Linux Mint 21.2