Skip to content
Snippets Groups Projects
Commit 9b6098d9 authored by Carlo Camilloni's avatar Carlo Camilloni
Browse files

MetaD,PBMetaD: fix for writing GRIDS when using multiple walkers with mpi

parent 5b50438e
No related branches found
No related tags found
No related merge requests found
......@@ -1351,7 +1351,14 @@ void MetaD::update(){
if(storeOldGrids_) gridfile_.clearFields();
// in case only latest grid is stored, file should be rewound
// this will overwrite previously written grids
else gridfile_.rewind();
else {
int r = 0;
if(walkers_mpi) {
if(comm.Get_rank()==0) r=multi_sim_comm.Get_rank();
comm.Bcast(r,0);
}
if(r==0) 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
......
......@@ -843,10 +843,17 @@ void PBMetaD::update()
// write grid files
if(wgridstride_>0 && getStep()%wgridstride_==0) {
for(unsigned i=0; i<gridfiles_.size(); ++i) {
gridfiles_[i]->rewind();
BiasGrids_[i]->writeToFile(*gridfiles_[i]);
gridfiles_[i]->flush();
int r = 0;
if(multiple_w) {
if(comm.Get_rank()==0) r=multi_sim_comm.Get_rank();
comm.Bcast(r,0);
}
if(r==0) {
for(unsigned i=0; i<gridfiles_.size(); ++i) {
gridfiles_[i]->rewind();
BiasGrids_[i]->writeToFile(*gridfiles_[i]);
gridfiles_[i]->flush();
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment