From b2b307e06cefe2a10db9331e8baa335fa53199d7 Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Mon, 16 Sep 2013 10:14:41 +0200 Subject: [PATCH] Added flush and some comment Without STORE_GRIDS it is necessary to flush the grid file, otherwise it might stay empty for the entire simulation --- src/bias/MetaD.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bias/MetaD.cpp b/src/bias/MetaD.cpp index 4fcdfc4ff..da9be43db 100644 --- a/src/bias/MetaD.cpp +++ b/src/bias/MetaD.cpp @@ -889,9 +889,20 @@ void MetaD::update(){ } // dump grid on file if(wgridstride_>0&&getStep()%wgridstride_==0){ +// in case old grids are stored, a sequence of grids should appear +// this call results in a repetition of the header: if(storeOldGrids_) gridfile_.clearFields(); +// in case only latest grid is stored, file should be rewound +// this will overwrite previously written grids else gridfile_.rewind(); BiasGrid_->writeToFile(gridfile_); +// if a single grid is stored, it is necessary to flush it, otherwise +// the file might stay empty forever (when a single grid is not large enough to +// trigger flushing from the operating system). +// on the other hand, if grids are stored one after the other this is +// no necessary, and we leave the flushing control to the user as usual +// (with FLUSH keyword) + if(!storeOldGrids_) gridfile_.flush(); } // if multiple walkers and time to read Gaussians -- GitLab