Fixed minor issue with replica exchange
authorMark Abraham <Mark.J.Abraham@gmail.com>
Wed, 2 Feb 2011 04:48:20 +0000 (15:48 +1100)
committerMark Abraham <Mark.J.Abraham@gmail.com>
Wed, 2 Feb 2011 04:48:20 +0000 (15:48 +1100)
If the user chose mdrun -replex that was not a multiple of
nstcalcenergy, then replica exchange could occur when energies were
not current. Fixed by requiring repl_ex_nst to be a multiple of
nstcalcenergy, as with similar mechanisms for global
intra-simulation communication.

IssueID #695

src/kernel/md.c

index dde06c1b46aac184ab06afdc31149a6d51eff6d1..b476249a207907c063a24854b4893ff308d553bb 100644 (file)
@@ -1380,6 +1380,15 @@ double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
         }
     }
 
+    if (repl_ex_nst > 0)
+    {
+        /* We need to be sure replica exchange can only occur
+         * when the energies are current */
+        check_nst_param(fplog,cr,"nstcalcenergy",ir->nstcalcenergy,
+                        "repl_ex_nst",&repl_ex_nst);
+        /* This check needs to happen before inter-simulation
+         * signals are initialized, too */
+    }
     if (repl_ex_nst > 0 && MASTER(cr))
         repl_ex = init_replica_exchange(fplog,cr->ms,state_global,ir,
                                         repl_ex_nst,repl_ex_seed);