@@ -35,7 +35,7 @@ Option interpretEnvString(const char* env,const char* str) {
35
35
if (!std::strcmp (str," no" ))return Option::no;
36
36
plumed_error ()<<" Cannot understand env var " <<env<<" \n Possible values: yes/no\n Actual value: " <<str;
37
37
}
38
-
38
+
39
39
// / Switch on/off chains of actions using PLUMED environment variable
40
40
// / export PLUMED_FORBID_CHAINS=yes # forbid the use of chains in this run
41
41
// / export PLUMED_FORBID_CHAINS=no # allow chains to be used in the run
@@ -44,7 +44,7 @@ Option getenvChainForbidden() {
44
44
static const char * name=" PLUMED_FORBID_CHAINS" ;
45
45
static const auto opt = interpretEnvString (name,std::getenv (name));
46
46
return opt;
47
- }
47
+ }
48
48
49
49
void ActionWithVector::registerKeywords ( Keywords& keys ) {
50
50
Action::registerKeywords ( keys );
@@ -60,6 +60,7 @@ ActionWithVector::ActionWithVector(const ActionOptions&ao):
60
60
ActionWithValue (ao),
61
61
ActionWithArguments (ao),
62
62
serial (false ),
63
+ forwardPass (false ),
63
64
action_to_do_before(NULL ),
64
65
action_to_do_after(NULL ),
65
66
never_reduce_tasks(false ),
@@ -451,6 +452,11 @@ std::vector<unsigned>& ActionWithVector::getListOfActiveTasks( ActionWithVector*
451
452
return active_tasks;
452
453
}
453
454
455
+ bool ActionWithVector::doNotCalculateDerivatives () const {
456
+ if ( forwardPass ) return true ;
457
+ return ActionWithValue::doNotCalculateDerivatives ();
458
+ }
459
+
454
460
void ActionWithVector::runAllTasks () {
455
461
// Skip this if this is done elsewhere
456
462
if ( action_to_do_before ) return ;
@@ -471,6 +477,12 @@ void ActionWithVector::runAllTasks() {
471
477
// Now do all preparations required to run all the tasks
472
478
// prepareForTaskLoop();
473
479
480
+ if ( !action_to_do_after ) {
481
+ forwardPass=true ;
482
+ for (unsigned i=0 ; i<getNumberOfComponents (); ++i) {
483
+ if ( getConstPntrToComponent (i)->getRank ()==0 ) { forwardPass=false ; break ; }
484
+ }
485
+ }
474
486
// Get the total number of streamed quantities that we need
475
487
unsigned nquants=0 , nmatrices=0 , maxcol=0 , nbooks=0 ;
476
488
getNumberOfStreamedQuantities ( getLabel (), nquants, nmatrices, maxcol, nbooks );
@@ -509,7 +521,7 @@ void ActionWithVector::runAllTasks() {
509
521
510
522
// MPI Gather everything
511
523
if ( !serial && buffer.size ()>0 ) gatherProcesses ( buffer );
512
- finishComputations ( buffer );
524
+ finishComputations ( buffer ); forwardPass= false ;
513
525
}
514
526
515
527
void ActionWithVector::gatherThreads ( const unsigned & nt, const unsigned & bufsize, const std::vector<double >& omp_buffer, std::vector<double >& buffer, MultiValue& myvals ) {
0 commit comments