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