Colvars / colvars

Collective variables library for molecular simulation and analysis programs
http://colvars.github.io/
GNU Lesser General Public License v3.0
196 stars 56 forks source link

Don't strip input state file in GROMACS (pre-2024) #642

Closed HubLot closed 7 months ago

HubLot commented 7 months ago

This follows the bug report in GROMACS forum here.

The bug lied in the name of the colvars restart file or (colvars input state file) which was abf_dihedral_state.dat so the line input_prefix_str.erase(input_prefix_str.rfind(".colvars.state")); crashed. Furthermore, the function colvarmodule::setup_input(): https://github.com/Colvars/colvars/blob/351bfd2677186f2e0f1ad21050098c08d6db60c6/src/colvarmodule.cpp#L1346-L1351 doesn't handle the case when the suffix is .dat. (suffix .dat was introduced due to a limitation in file extension in mdrun).

So the most forward bugfix is to not strip the extension and let setup_input() takes the whole string as a filename. The downside is the variable input_prefix_str is also called in colvarmodule::print_total_forces_errning() but according to @jhenin it's only called for code older than 2016 https://github.com/Colvars/colvars/blob/351bfd2677186f2e0f1ad21050098c08d6db60c6/src/colvarmodule.cpp#L1535

(it's basically a revert of commit efac865ce0ce1cd070)