diff --git a/developer-doc/mdTemplate.txt b/developer-doc/mdTemplate.txt index 709bd417134a761e9dd953923c30e5799ffb8a5a..747cc3eb9c10f53fc9d29414f8a4f5f236662f14 100644 --- a/developer-doc/mdTemplate.txt +++ b/developer-doc/mdTemplate.txt @@ -199,7 +199,11 @@ plumed_cmd(plumedmain,"setLog",fplog); // Pass the file plumed_cmd(plumedmain,"setLogFile",fplog); // Pass the file on which to write out the plumed log (to be created) plumed_cmd(plumedmain,"setTimestep",&delta_t); // Pass a pointer to the molecular dynamics timestep to plumed -plumed_cmd(plumedmain,"setKbT",&kbT); // Tell to PLUMED the value of kbT - ONLY VALID IF API VERSION > 1 +// This is valid only if API VERSION > 1 +plumed_cmd(plumedmain,"setKbT",&kbT); // Pointer to a real containing the value of kbT + +// This is valid only if API VERSION > 2 +plumed_cmd(plumedmain,"setRestart",&res); // Pointer to an integer saying if we are restarting (zero means no, one means yes) // Calls to do the actual initialization (all the above commands must appear before this call) plumed_cmd(plumedmain,"init",NULL); // Do all the initialization of plumed diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp index 18ebee0b25ad28097742ba77e4c683470ef58ec1..e93e704013b44ba5547c2eeda42bf3a0248831d3 100644 --- a/src/core/PlumedMain.cpp +++ b/src/core/PlumedMain.cpp @@ -47,7 +47,7 @@ using namespace std; -enum { SETBOX, SETPOSITIONS, SETMASSES, SETCHARGES, SETPOSITIONSX, SETPOSITIONSY, SETPOSITIONSZ, SETVIRIAL, SETENERGY, SETFORCES, SETFORCESX, SETFORCESY, SETFORCESZ, CALC, PREPAREDEPENDENCIES, SHAREDATA, PREPARECALC, PERFORMCALC, SETSTEP, SETSTEPLONG, SETATOMSNLOCAL, SETATOMSGATINDEX, SETATOMSFGATINDEX, SETATOMSCONTIGUOUS, CREATEFULLLIST, GETFULLLIST, CLEARFULLLIST, READ, CLEAR, GETAPIVERSION, INIT, SETREALPRECISION, SETMDLENGTHUNITS, SETMDENERGYUNITS, SETMDTIMEUNITS, SETNATURALUNITS, SETNOVIRIAL, SETPLUMEDDAT, SETMPICOMM, SETMPIFCOMM, SETMPIMULTISIMCOMM, SETNATOMS, SETTIMESTEP, SETMDENGINE, SETLOG, SETLOGFILE, SETSTOPFLAG, GETEXCHANGESFLAG, SETEXCHANGESSEED, SETNUMBEROFREPLICAS, GETEXCHANGESLIST, RUNFINALJOBS, ISENERGYNEEDED, GETBIAS, SETKBT }; +enum { SETBOX, SETPOSITIONS, SETMASSES, SETCHARGES, SETPOSITIONSX, SETPOSITIONSY, SETPOSITIONSZ, SETVIRIAL, SETENERGY, SETFORCES, SETFORCESX, SETFORCESY, SETFORCESZ, CALC, PREPAREDEPENDENCIES, SHAREDATA, PREPARECALC, PERFORMCALC, SETSTEP, SETSTEPLONG, SETATOMSNLOCAL, SETATOMSGATINDEX, SETATOMSFGATINDEX, SETATOMSCONTIGUOUS, CREATEFULLLIST, GETFULLLIST, CLEARFULLLIST, READ, CLEAR, GETAPIVERSION, INIT, SETREALPRECISION, SETMDLENGTHUNITS, SETMDENERGYUNITS, SETMDTIMEUNITS, SETNATURALUNITS, SETNOVIRIAL, SETPLUMEDDAT, SETMPICOMM, SETMPIFCOMM, SETMPIMULTISIMCOMM, SETNATOMS, SETTIMESTEP, SETMDENGINE, SETLOG, SETLOGFILE, SETSTOPFLAG, GETEXCHANGESFLAG, SETEXCHANGESSEED, SETNUMBEROFREPLICAS, GETEXCHANGESLIST, RUNFINALJOBS, ISENERGYNEEDED, GETBIAS, SETKBT, SETRESTART }; namespace PLMD{ @@ -134,6 +134,7 @@ PlumedMain::PlumedMain(): word_map["isEnergyNeeded"]=ISENERGYNEEDED; word_map["getBias"]=GETBIAS; word_map["setKbT"]=SETKBT; + word_map["setRestart"]=SETRESTART; } PlumedMain::~PlumedMain(){ @@ -300,7 +301,7 @@ void PlumedMain::cmd(const std::string & word,void*val){ break; case GETAPIVERSION: CHECK_NULL(val,word); - *(static_cast<int*>(val))=2; + *(static_cast<int*>(val))=3; break; // commands which can be used only before initialization: case INIT: @@ -375,6 +376,11 @@ void PlumedMain::cmd(const std::string & word,void*val){ CHECK_NULL(val,word); atoms.setKbT(val); break; + case SETRESTART: /* ADDED WITH API==3 */ + CHECK_NOTINIT(initialized,word); + CHECK_NULL(val,word); + if(*static_cast<int*>(val)!=0) restart=true; + break; case SETMDENGINE: CHECK_NOTINIT(initialized,word); CHECK_NULL(val,word); diff --git a/src/setup/Restart.cpp b/src/setup/Restart.cpp index f640627de479b3326aaa52755c12a163ac735c56..a8efa8d1fe4f80b68bb0c72a833e06530f8f2665 100644 --- a/src/setup/Restart.cpp +++ b/src/setup/Restart.cpp @@ -95,14 +95,26 @@ PLUMED_REGISTER_ACTION(Restart,"RESTART") void Restart::registerKeywords( Keywords& keys ){ ActionSetup::registerKeywords(keys); + keys.addFlag("NO",false,"switch off restart - can be used to override the behavior of the MD engine"); } Restart::Restart(const ActionOptions&ao): Action(ao), ActionSetup(ao) { - plumed.setRestart(true); - log<<"Restarting simulation: files will be appended\n"; + bool no=false; + parseFlag("NO",no); + bool md=plumed.getRestart(); + log<<" MD code "<<(md?"did":"didn't")<<" require restart\n"; + if(no){ + if(md) log<<" Switching off restart\n"; + plumed.setRestart(false); + log<<" Not restarting simulation: files will be backed up\n"; + } else { + if(!md) log<<" Switching on restart\n"; + plumed.setRestart(true); + log<<" Restarting simulation: files will be appended\n"; + } } }