Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2011-2019 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #include "core/ActionRegister.h" 23 : #include "core/ActionPilot.h" 24 : #include "core/PlumedMain.h" 25 : #include "core/ActionSet.h" 26 : 27 : namespace PLMD { 28 : namespace generic { 29 : 30 : using namespace std; 31 : 32 : //+PLUMEDOC GENERIC FLUSH 33 : /* 34 : This command instructs plumed to flush all the open files with a user specified frequency. 35 : Notice that all files are flushed anyway every 10000 steps. 36 : 37 : This 38 : is useful for preventing data loss that would otherwise arise as a consequence of the code 39 : storing data for printing in the buffers. Notice that wherever it is written in the 40 : plumed input file, it will flush all the open files. 41 : 42 : \par Examples 43 : 44 : A command like this in the input will instruct plumed to flush all the output files every 100 steps 45 : \plumedfile 46 : d1: DISTANCE ATOMS=1,10 47 : PRINT ARG=d1 STRIDE=5 FILE=colvar1 48 : 49 : FLUSH STRIDE=100 50 : 51 : d2: DISTANCE ATOMS=2,11 52 : # also this print is flushed every 100 steps: 53 : PRINT ARG=d2 STRIDE=10 FILE=colvar2 54 : \endplumedfile 55 : (see also \ref DISTANCE and \ref PRINT). 56 : */ 57 : //+ENDPLUMEDOC 58 : 59 34 : class Flush: 60 : public ActionPilot 61 : { 62 : public: 63 17 : explicit Flush(const ActionOptions&ao): 64 : Action(ao), 65 17 : ActionPilot(ao) 66 : { 67 17 : checkRead(); 68 17 : } 69 : static void registerKeywords( Keywords& keys ); 70 561 : void calculate() override {} 71 561 : void apply() override {} 72 561 : void update() override { 73 561 : plumed.fflush(); 74 561 : log.flush(); 75 561 : const ActionSet & actionSet(plumed.getActionSet()); 76 4501 : for(const auto & p : actionSet) 77 3379 : p->fflush(); 78 561 : } 79 : }; 80 : 81 7866 : PLUMED_REGISTER_ACTION(Flush,"FLUSH") 82 : 83 18 : void Flush::registerKeywords( Keywords& keys ) { 84 18 : Action::registerKeywords( keys ); 85 18 : ActionPilot::registerKeywords( keys ); 86 72 : keys.add("compulsory","STRIDE","the frequency with which all the open files should be flushed"); 87 36 : keys.remove("LABEL"); 88 18 : } 89 : 90 : } 91 5874 : } 92 : 93 :