diff --git a/src/Action.h b/src/Action.h index d4327af7eca533ccf3a054f385e972fc3f71a67d..84928723bfde17c452d9d4617cc315c2acbbd484 100644 --- a/src/Action.h +++ b/src/Action.h @@ -186,6 +186,11 @@ public: /// The set of all Actions is updated in forward order. virtual void update(){}; +/// RunFinalJobs +/// This method is called once at the very end of the calculation. +/// The set of all Actions in run for the final time in forward order. + virtual void runFinalJobs(){}; + /// Tell to the Action to flush open files void fflush(); diff --git a/src/CLToolDriver.cpp b/src/CLToolDriver.cpp index ecdbe0dc8c777ef2be6bca9c40574001a7fdb79c..a635c9f72d73f4f1322d615f404abe7216263803 100644 --- a/src/CLToolDriver.cpp +++ b/src/CLToolDriver.cpp @@ -487,6 +487,7 @@ int CLToolDriver<real>::main(FILE* in,FILE*out,PlumedCommunicator& pc){ step+=stride; } + p.cmd("runFinalJobs"); if(fp_forces) fclose(fp_forces); fclose(fp); diff --git a/src/PlumedMain.cpp b/src/PlumedMain.cpp index cab8a38466798135274469612f75f7b741f86ab0..b79a19b3c624d886cc523e13064f74528b35403a 100644 --- a/src/PlumedMain.cpp +++ b/src/PlumedMain.cpp @@ -293,6 +293,9 @@ void PlumedMain::cmd(const std::string & word,void*val){ CHECK_INIT(initialized,word); CHECK_NULL(val,word); exchangePatterns.getList((static_cast<int*>(val))); + } else if(word=="runFinalJobs"){ + CHECK_INIT(initialized,word); + runJobsAtEndOfCalculation(); } else { // multi word commands @@ -614,6 +617,12 @@ void PlumedMain::eraseFile(PlumedFileBase&f){ void PlumedMain::stop(){ stopNow=true; +} + +void PlumedMain::runJobsAtEndOfCalculation(){ + for(ActionSet::iterator p=actionSet.begin();p!=actionSet.end();++p){ + (*p)->runFinalJobs(); + } } diff --git a/src/PlumedMain.h b/src/PlumedMain.h index 6494a4f649de5403b8913dd1d53926293aaebb32..5afbd17a673979327985039315df583fe38d689b 100644 --- a/src/PlumedMain.h +++ b/src/PlumedMain.h @@ -209,6 +209,11 @@ public: Needed to apply the forces back. */ void justApply(); +/** + If there are calculations that need to be done at the very end of the calculations this + makes sures they are done +*/ + void runJobsAtEndOfCalculation(); /// Reference to atoms object Atoms& getAtoms(); /// Reference to the list of Action's