Colvars / colvars

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

"trying to access an output file/channel from the wrong thread." when using writeHillsTrajectory #544

Closed HanatoK closed 1 year ago

HanatoK commented 1 year ago

I have tested the official NAMD 3.0b3 binary and also the latest Colvars master branch. When using writeHillsTrajectory on in metadynamics, I encounter the following error:

colvars: Error: trying to access an output file/channel from the wrong thread.
FATAL ERROR: Error in the collective variables module (see above for details)
FATAL ERROR: Error in the collective variables module (see above for details)

Please see the following attachment for a test case. apathCV_example_bug.tar.gz

ThaNikkitz commented 1 year ago

I had pretty much exactly the same issue in a couple runs yesterday and today. I was however using the colvars version bundled with the binary release of the NAMD3 beta 3 in the official website (released April). Thanks a lot for the fix, will be trying again with a fresh compilation of colvars once your pull request is accepted!

giacomofiorin commented 1 year ago

@HanatoK Thanks for catching this and the quick fix!

@ThaNikkitz It may take a while for the updated Colvars snapshot to make it into the NAMD distribution. A quick workaround for the error that you are experiencing would be to add this line:

smp off

at the top of the Colvars config file, which would force all Colvars objects to run on the first thread. If you have a very complex input (many CVs or components) this may lose some performance, but at least it would circumvent the bug without recompilation.