gmx tcaf only reads one frame
## Summary `gmx tcaf` reads only one frame from an input trajectory, even when there are several. Then we get [a division by 0 when computing `dt`](https://gitlab.com/gromacs/gromacs/-/blob/fb76912b5687bef1831b9a6d82329fd77f6991e4/src/gromacs/gmxana/gmx_tcaf.cpp#L507), and a crash when trying to allocate the negative amount of memory. ## Exact steps to reproduce ```console $ ~/gromacs-2024/build/clang-debug/bin/gmx tcaf -f ./traj.trr -s ./topol.tpr -oc tcaf_cub.xvg <<< 0 :-) GROMACS - gmx tcaf, 2024.5-dev-20241101-acfe7911ab (-: Executable: /home/aland/gromacs-2024/build/clang-debug/bin/gmx Data prefix: /home/aland/gromacs-2024 (source tree) Working dir: /home/aland/issue-abcd Command line: gmx tcaf -f ./traj.trr -s ./topol.tpr -oc tcaf_cub.xvg Reading file ./topol.tpr, VERSION 2024.5-dev-20241101-acfe7911ab (single precision) Reading file ./topol.tpr, VERSION 2024.5-dev-20241101-acfe7911ab (single precision) Group 0 ( System) has 5832 elements Group 1 ( Other) has 5832 elements Group 2 ( AR) has 5832 elements Select a group: Selected 0: 'System' trr version: GMX_trn_file (single precision) Last frame -1 time 0.000 Last frame -1 time 2.000 Density = 1743.2 (kg/m^3) ------------------------------------------------------- Program: gmx tcaf, version 2024.5-dev-20241101-acfe7911ab Source file: src/gromacs/utility/smalloc.cpp (line 131) Fatal error: Not enough memory. Failed to calloc -2147483647 elements of size 4 for tcaf[k] (called from file /home/aland/gromacs-2024/src/gromacs/gmxana/gmx_tcaf.cpp, line 137) For more information and tips for troubleshooting, please check the GROMACS website at https://manual.gromacs.org/current/user-guide/run-time-errors.html ------------------------------------------------------- ``` ## For developers: Why is this important? Users are complaining: https://gromacs.bioexcel.eu/t/fatal-error-not-enough-memory/10542 ## If this is a bug, (1) what happens, and (2) what did you expect to happen? 1. `gmx tcaf` crashes after reading one frame of the trajectory 2. `gmx tcaf` reads all the frames in the trajectory, not the first one. Additionally, would be nice to have proper diagnostics when the trajectory actually has only one input frame. ## Relevant input files, logs and/or screenshots Based on `ar-5.8k` system, but I guess anything should work: - [traj.trr](/uploads/4020231e19d312211ae7748502d6cb17/traj.trr) - [topol.tpr](/uploads/521c95f5c1360d47cf0d85c0458fe3cd/topol.tpr) ## Possible fixes :shrug:
issue