Problem with read_dump command

Dear all,
I am using LAMMPS version 2 June 2022 on widows.
I wish to run a 5 years old LAMMPS script which read in a loop a dump file with read_dump. It succefully worked at this time.
I wish to inject every 40000 timestep 10 atoms with x y z vx vy vz.
the called inputdata.lammpstrj file with read_dump is read but when reading timestep it causes the error message below. I add also the calling script and and the read_dump file.
I do not understand what I have to do for solving the issue.
Thanks for the help
Pascal

I got the following error message when calling the first time the read_dump file :

read_dump inputdata.lammpstrj $x x y z vx vy vz box yes replace no add yes
read_dump inputdata.lammpstrj 40000 x y z vx vy vz box yes replace no add yes
Scanning dump file …
ERROR: Cannot reset timestep with active dump - must undump first (src/output.cpp:637)
Last command: read_dump inputdata.lammpstrj $x x y z vx vy vz box yes replace no add yes

the run script part with the read_dump command

run 40000
variable i loop 2
label loopa
variable x equal 40000*$i
print “i = $i”
print “x = $x”
read_dump inputdata.lammpstrj $x x y z vx vy vz box yes replace no add yes
run 40000
next i
jump SELF loopa

The called dump file.

ITEM: TIMESTEP
40000
ITEM: NUMBER OF ATOMS
10
ITEM: BOX BOUNDS pp pp pp
0.0 54.308
0.0 54.308
-50.0 50.0
ITEM: ATOMS id type x y z vx vy vz
4003 2 22.835783 0.8583603 80. 1.1035043 1.4167222 -1.2925347
4004 2 42.30523 8.980942 80. -1.3417536 0.057432473 -2.1200328
4005 2 10.225216 50.538414 80. 6.9438434 2.686896 -0.7516653
4006 2 2.3181605 42.114346 80. -3.0544128 4.0598774 -2.735853
4007 2 27.584095 10.428562 80. -1.1441863 -1.4464989 -5.552846
4008 2 24.529537 33.613873 80. -4.6492987 -2.6672466 -2.6431813
4009 2 14.137962 7.180363 80. -4.361336 -0.40602574 -0.9889284
4010 2 44.329464 43.71828 80. -1.1946876 1.8862572 -0.828331
4011 2 16.191877 21.573439 80. -0.9770629 -1.93134 -0.0044369013
4012 2 49.05994 53.35912 80. -0.7366441 -5.6772575 -1.3975966
ITEM: TIMESTEP
80000
ITEM: NUMBER OF ATOMS
10
ITEM: BOX BOUNDS pp pp pp
0.0 54.308
0.0 54.308
-50.0 50.0
ITEM: ATOMS id type x y z vx vy vz
4013 2 31.817413 35.1767 80. 2.8501549 -0.23212712 -2.0210931
4014 2 38.746002 19.610298 80. 2.546568 0.03248285 -0.34521067
4015 2 21.962831 49.603275 80. 0.023324206 1.6832926 -0.8532388
4016 2 52.45205 21.977224 80. 2.1697412 0.851192 -5.047345
4017 2 49.96703 50.652637 80. 2.8668077 -1.3900887 -2.3385847
4018 2 9.487449 43.387627 80. -0.64800346 -2.9146833 -1.6317519
4019 2 21.048777 34.550377 80. 3.0670655 -1.0718929 -0.49690315
4020 2 3.268927 4.7386293 80. 4.567323 2.516106 -0.90702564
4021 2 50.634235 0.08142315 80. -2.4640586 0.8867847 -0.7044423
4022 2 2.2719877 35.67405 80. -0.15131328 3.1233056 -1.1750917

This is likely (another) ripple from the refactoring of the handling of dump output some time ago.
I have to look at the relevant code to see if there is a proper solution, but the obvious workaround can be inferred from the error message. Undump your current dump instance before the read_dump command and continue it afterwards.

I checked the read_dump documentation and what happens is actually what should happen. We just didn’t have a test for it before.

The problem is that read_dump will reset the timestep number and that conflicts with several LAMMPS features like active dumps or time averaging fixes.

Thus a clean solution will be to add an option to the read_dump command to tell it to not reset the time step number.

Thanks a lot Axel.
I will try for a workaround as you suggest;
The current dump is outside the loop. So if I undump it in the loop the dump file will not be filled, I guess ?
Or may be I shall include the dump command in the loop before the read_dump and I hope the new data will be appended to the desired output file.
Kind regards
Pascal

That way, if you tell it to append to the file, you should get a continuous trajectory. But note that every read_dump command will reset the timestep number, so you need to save and restore that, too if you want a consistent trajectory and timestep numbers in your output.

FWIW, I have just submitted a pull request (Add option to read_dump that prevents resetting the timestep by akohlmey · Pull Request #3344 · lammps/lammps · GitHub) that adds a “timestep” keyword to the read_dump command. After the change is merged you can use “timestep no” as argument to read_dump to prevent it from resetting the timestep and also the need to stop and restart any open dump stream will no longer apply.

1 Like

Thanks a lot Axel
This will be very helpful.
Since I am not familar at all with github, What I should do for including the solution. Should I install a last windows version ? And for linux version on my workstation ?
Sorry again for such basics questions
Kind regards
Pascal

Right now you would need to download a sourcecode snapshot of my branch (https://github.com/akohlmey/lammps/archive/refs/heads/read_dump_no_timestep.tar.gz)
since I only today submitted it and it has not been reviewed or merged to the development branch.

For that you will have to wait until a new release is made. Or learn how to build LAMMPS from source on Windows (using Microsoft Visual Studio 2022), or use WSL and run Linux on Windows.

You will have to build from the snapshot source code. But since this is based on development code you run a higher risk of having a version of LAMMPS with known (or unknown) bugs.

Thanks a lot Axel
Best
Pascal

Dear Axel
Thanks a lot again
I will install the last LAMMPS version 3Aug2022 and use the timestep no new keyword.
Best regards
Pascal

It seems the patch don’t backport to the stable version, whose link is https://download.lammps.org/tars/lammps-stable.tar.gz ? or does there a more new stable version

This is a new feature and not a bugfix and thus it is not backported to the stable release. The stable LAMMPS version does behave as documented. It just happens that the documented behavior is not always convenient. :wink:

You have to use a more recent feature release (the most recent was on 28 March 2023) to have this feature included.

Thansk for your quick reply!

ERROR: Cannot reset timestep with active dump - must undump first (../output.cpp:637)
Last command: reset_timestep 0
  • these is the snippets of the input file around the reset_timestep 0, I tried it works fine if I deleted the description begin with the reset_timestep 0.
dump           1           all      atom     100000    initial.lammpstrj
dump_modify    1           format   line     "%7d %3d %8.5f %8.5f %8.5f" scale yes

# Equilibrium

fix            1           carbon   nve
fix            2           salt     nve/limit 0.1
fix            3           salt     temp/rescale 10 298 298 0.05 1.0
fix            4           carbon   setforce 0.0 0.0 0.0
fix            5           salt     wall/reflect zlo -0.98 zhi 159

velocity       carbon      set      0.0  0.0   0.0   units box

run            300

reset_timestep 0

unfix           2
unfix           3

fix            2           water    shake    0.0001 20 0 b 1 a 1
fix            3           salt     nvt      temp   298   298   0.1  drag  0.5


run            2000

All commands that have timestep selections (e.g. dump, fix ave/*) must be closed (undump, unfix) before using reset_timestep.

1 Like

Thanks again, it works after I add undump 1 before reset_timestep 0.