Frames skipped in log during minimization on GPU
**Summary**
During L-BFGS minimization on the GPU, some frames are skipped in the LOG and EDR files. In the example below, the length of the TRR trajectory is 2712 frames, whereas the LOG and EDR files contain only 2708 frames. Notably, 5 frames are missing in the LOG and EDR files (1777th, 1880th, 1886th, 2102nd and 2558th), indicating that 1 frame is potentially missing in the TRR file as well.
<details><summary>Part of the LOG file near the 1777th frame (1777th is skipped)</summary>
```
Step Time
1775 1775.00000
Energies (kJ/mol)
Bond Angle Ryckaert-Bell. Per. Imp. Dih. LJ-14
3.72086e+03 2.05143e+03 -2.09458e+01 2.41717e-01 1.72923e+02
Coulomb-14 LJ (SR) Disper. corr. Coulomb (SR) Coul. recip.
-5.41198e+01 2.23244e+04 -2.91719e+02 -1.41841e+05 1.23624e+02
Potential Pres. DC (bar) Pressure (bar)
-1.14106e+05 -7.56881e+01 -4.31093e+03
Step Time
1776 1776.00000
Energies (kJ/mol)
Bond Angle Ryckaert-Bell. Per. Imp. Dih. LJ-14
3.72106e+03 2.05114e+03 -2.09335e+01 2.33791e-01 1.72920e+02
Coulomb-14 LJ (SR) Disper. corr. Coulomb (SR) Coul. recip.
-5.41250e+01 2.23246e+04 -2.91719e+02 -1.41841e+05 1.23624e+02
Potential Pres. DC (bar) Pressure (bar)
-1.14106e+05 -7.56881e+01 -4.31205e+03
Step Time
1778 1778.00000
Energies (kJ/mol)
Bond Angle Ryckaert-Bell. Per. Imp. Dih. LJ-14
3.72056e+03 2.05115e+03 -2.09335e+01 2.34095e-01 1.73425e+02
Coulomb-14 LJ (SR) Disper. corr. Coulomb (SR) Coul. recip.
-5.41243e+01 2.23246e+04 -2.91719e+02 -1.41842e+05 1.23640e+02
Potential Pres. DC (bar) Pressure (bar)
-1.14106e+05 -7.56881e+01 -4.31129e+03
Step Time
1779 1779.00000
Energies (kJ/mol)
Bond Angle Ryckaert-Bell. Per. Imp. Dih. LJ-14
3.72056e+03 2.05121e+03 -2.09363e+01 2.34158e-01 1.73380e+02
Coulomb-14 LJ (SR) Disper. corr. Coulomb (SR) Coul. recip.
-5.41146e+01 2.23246e+04 -2.91719e+02 -1.41842e+05 1.23645e+02
Potential Pres. DC (bar) Pressure (bar)
-1.14106e+05 -7.56881e+01 -4.31095e+03
```
</details>
**GROMACS version**
```
GROMACS version: 2022.4
Precision: mixed
```
**Steps to reproduce**
```
gmx grompp -f min.mdp -c box.gro -p topol.top -o min.tpr -maxwarn 3
mpirun -np 1 gmx_mpi mdrun -nb gpu -gpu_id 0 -deffnm min ; run minimization (about 2300 steps for convergence)
gmx energy -f min.edr -o min ; 11 0 to get potential energy log
```
```
from MDAnalysis import Universe
import numpy as np
# get length of trr trajectory
u = Universe('min.tpr', 'min.trr')
print(len(u.trajectory)) # output: 2712
# get length of edr log
log = np.loadtxt('./min.xvg', comments=['#', '@'])
print(energy_log.shape) # output: (2708, 2)
# get missed frames:
print(set(np.arange(2712)) - set(energy_log[:, 0].astype(int)) # output: {1777, 1880, 1886, 2102, 2558}
```
All files except min.trr (its size 400MB+ since every frame is dumped): [files.zip](/uploads/63c179b00efe8a858f9726300f9a387b/files.zip)
**What is the current bug behavior?**
The number of frames in the TRR file differs from the number of frames in the LOG and EDR files. Specifically, some frames are skipped in the LOG and EDR files.
**What did you expect the correct behavior to be?**
It matches or number of skipped frames equals to length of TRR minus length of EDR/LOG.
issue