LCOV - code coverage report
Current view: top level - setup - Restart.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 18 21 85.7 %
Date: 2018-12-19 07:49:13 Functions: 9 10 90.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2018 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/ActionSetup.h"
      23             : #include "core/ActionRegister.h"
      24             : #include "core/PlumedMain.h"
      25             : #include "core/Atoms.h"
      26             : #include "tools/Exception.h"
      27             : 
      28             : using namespace std;
      29             : 
      30             : namespace PLMD {
      31             : namespace setup {
      32             : 
      33             : //+PLUMEDOC GENERIC RESTART
      34             : /*
      35             : Activate restart.
      36             : 
      37             : This is a Setup directive and, as such, should appear
      38             : at the beginning of the input file. It influences the way
      39             : PLUMED treat files open for writing (see also \ref Files).
      40             : 
      41             : Notice that it is also possible to enable or disable restart on a per-action
      42             : basis using the RESTART keyword on a single action. In this case,
      43             : the keyword should be assigned a value. RESTART=AUTO means that global
      44             : settings are used, RESTART=YES or RESTART=NO respectively enable
      45             : and disable restart for that single action.
      46             : 
      47             : \attention
      48             : This directive can have also other side effects, e.g. on \ref METAD
      49             : and \ref PBMETAD and on some analysis action.
      50             : 
      51             : \par Examples
      52             : 
      53             : Using the following input:
      54             : \verbatim
      55             : d: DISTANCE ATOMS=1,2
      56             : PRINT ARG=d FILE=out
      57             : \endverbatim
      58             : (See also \ref DISTANCE and \ref PRINT).
      59             : a new 'out' file will be created. If an old one is on the way, it will be automatically backed up.
      60             : 
      61             : On the other hand, using the following input:
      62             : \verbatim
      63             : RESTART
      64             : d: DISTANCE ATOMS=1,2
      65             : PRINT ARG=d FILE=out
      66             : \endverbatim
      67             : the file 'out' will be appended.
      68             : (See also \ref DISTANCE and \ref PRINT).
      69             : 
      70             : In the following case, file out1 will be backed up and file out2 will be concatenated
      71             : \verbatim
      72             : RESTART
      73             : d1: DISTANCE ATOMS=1,2
      74             : d2: DISTANCE ATOMS=1,2
      75             : PRINT ARG=d1 FILE=out1 RESTART=NO
      76             : PRINT ARG=d2 FILE=out2
      77             : \endverbatim
      78             : (See also \ref DISTANCE and \ref PRINT).
      79             : 
      80             : 
      81             : 
      82             : 
      83             : */
      84             : //+ENDPLUMEDOC
      85             : 
      86          26 : class Restart :
      87             :   public virtual ActionSetup
      88             : {
      89             : public:
      90             :   static void registerKeywords( Keywords& keys );
      91             :   explicit Restart(const ActionOptions&ao);
      92             : };
      93             : 
      94        2536 : PLUMED_REGISTER_ACTION(Restart,"RESTART")
      95             : 
      96          14 : void Restart::registerKeywords( Keywords& keys ) {
      97          14 :   ActionSetup::registerKeywords(keys);
      98          14 :   keys.addFlag("NO",false,"switch off restart - can be used to override the behavior of the MD engine");
      99          14 : }
     100             : 
     101          13 : Restart::Restart(const ActionOptions&ao):
     102             :   Action(ao),
     103          13 :   ActionSetup(ao)
     104             : {
     105          13 :   bool no=false;
     106          13 :   parseFlag("NO",no);
     107          13 :   bool md=plumed.getRestart();
     108          13 :   log<<"  MD code "<<(md?"did":"didn't")<<" require restart\n";
     109          13 :   if(no) {
     110           0 :     if(md) log<<"  Switching off restart\n";
     111           0 :     plumed.setRestart(false);
     112           0 :     log<<"  Not restarting simulation: files will be backed up\n";
     113             :   } else {
     114          13 :     if(!md) log<<"  Switching on restart\n";
     115          13 :     plumed.setRestart(true);
     116          13 :     log<<"  Restarting simulation: files will be appended\n";
     117             :   }
     118          13 : }
     119             : 
     120             : }
     121        2523 : }

Generated by: LCOV version 1.13