Prevent log file energy average printing dividing by zero
authorMark Abraham <mark.j.abraham@gmail.com>
Wed, 31 Jan 2018 07:48:16 +0000 (08:48 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 6 Feb 2018 15:27:57 +0000 (16:27 +0100)
commitfb33d1ced794c511839d21ed3444325d2db9b728
treefcb1fd859327f69e16539bc52631b3a8eeb7f843
parentd3d2ea008158d3a2f2a9d3355587db3bd3d55951
Prevent log file energy average printing dividing by zero

If there's not enough data for averages, skip the average printing
entirely. In principle, pr_ebin could be called from elsewhere than
print_ebin, so now we print "N/A" rather than "nan" or segfaulting.

Added some const correctness. Added some tests. Unfortunately they
currently have to write a file to disk, but we should have the test
before refactoring it to run in memory. The tests needed to be able
to clean up their memory, so runner can now also call done_ebin
but for stability we'll leave that off for now.

TODO When merging to master branch enable the call to done_ebin
in runner().

Fixes #2394

Change-Id: Id2e151664dd4553e49880f96bdd90aacc945f992
12 files changed:
src/gromacs/mdlib/ebin.cpp
src/gromacs/mdlib/ebin.h
src/gromacs/mdlib/mdebin.cpp
src/gromacs/mdlib/tests/CMakeLists.txt
src/gromacs/mdlib/tests/mdebin.cpp [new file with mode: 0644]
src/gromacs/mdlib/tests/refdata/PrintEbin_pr_ebin_HandlesAverages.xml [new file with mode: 0644]
src/gromacs/mdlib/tests/refdata/PrintEbin_pr_ebin_HandlesEmptyAverages.xml [new file with mode: 0644]
src/gromacs/mdlib/tests/refdata/PrintEbin_print_ebin_HandlesEmptyAverages.xml [new file with mode: 0644]
src/programs/mdrun/md.cpp
src/programs/mdrun/tests/termination.cpp
src/programs/mdrun/tests/terminationhelper.cpp
src/programs/mdrun/tests/terminationhelper.h