+void preparePrevStepPullCom(const t_inputrec *ir, const t_mdatoms *md, t_state *state, const t_state *state_global, const t_commrec *cr, bool startingFromCheckpoint)
+{
+ if (!ir->pull || !ir->pull->bSetPbcRefToPrevStepCOM)
+ {
+ return;
+ }
+ allocStatePrevStepPullCom(state, ir->pull_work);
+ if (startingFromCheckpoint)
+ {
+ if (MASTER(cr))
+ {
+ state->pull_com_prev_step = state_global->pull_com_prev_step;
+ }
+ if (PAR(cr))
+ {
+ /* Only the master rank has the checkpointed COM from the previous step */
+ gmx_bcast(sizeof(double) * state->pull_com_prev_step.size(), &state->pull_com_prev_step[0], cr);
+ }
+ setPrevStepPullComFromState(ir->pull_work, state);
+ }
+ else
+ {
+ t_pbc pbc;
+ set_pbc(&pbc, ir->ePBC, state->box);
+ initPullComFromPrevStep(cr, ir->pull_work, md, &pbc, state->x.rvec_array());
+ updatePrevStepPullCom(ir->pull_work, state);
+ }
+}
+