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 arrise 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 32 : class Flush:
60 : public ActionPilot
61 : {
62 : public:
63 16 : explicit Flush(const ActionOptions&ao):
64 : Action(ao),
65 16 : ActionPilot(ao)
66 : {
67 16 : checkRead();
68 16 : }
69 : static void registerKeywords( Keywords& keys );
70 453 : void calculate() {}
71 453 : void apply() {}
72 453 : void update() {
73 453 : plumed.fflush();
74 453 : log.flush();
75 453 : const ActionSet & actionSet(plumed.getActionSet());
76 1888 : for(const auto & p : actionSet)
77 1435 : p->fflush();
78 453 : }
79 : };
80 :
81 6468 : PLUMED_REGISTER_ACTION(Flush,"FLUSH")
82 :
83 17 : void Flush::registerKeywords( Keywords& keys ) {
84 17 : Action::registerKeywords( keys );
85 17 : ActionPilot::registerKeywords( keys );
86 68 : keys.add("compulsory","STRIDE","the frequency with which all the open files should be flushed");
87 34 : keys.remove("LABEL");
88 17 : }
89 :
90 : }
91 4839 : }
92 :
93 :
|