Put replica exchange parameters in a struct
authorBerk Hess <hess@kth.se>
Fri, 9 Jun 2017 19:38:58 +0000 (21:38 +0200)
committerBerk Hess <hess@kth.se>
Sat, 10 Jun 2017 09:15:57 +0000 (11:15 +0200)
Change-Id: I56d3b19c3e3c83bf99ac622930fb20c1efdc129d

src/gromacs/mdlib/integrator.h
src/gromacs/mdlib/minimize.cpp
src/gromacs/mdlib/tpi.cpp
src/programs/mdrun/md.cpp
src/programs/mdrun/mdrun.cpp
src/programs/mdrun/repl_ex.cpp
src/programs/mdrun/repl_ex.h
src/programs/mdrun/runner.cpp
src/programs/mdrun/runner.h

index f48e6e910bcc973d6a47fa5fbaadd4408889fc55..e8fdaa42d40925143bf13f66cc0d7ee14ebf3452 100644 (file)
@@ -58,6 +58,7 @@ struct gmx_mtop_t;
 struct gmx_membed_t;
 struct gmx_output_env_t;
 struct ObservablesHistory;
+struct ReplicaExchangeParameters;
 struct t_commrec;
 struct t_filenm;
 struct t_inputrec;
@@ -92,9 +93,7 @@ class MDLogger;
  * \param[in] nrnb                Accounting for floating point operations
  * \param[in] wcycle              Wall cycle timing information
  * \param[in] fr                  Force record with cut-off information and more
- * \param[in] repl_ex_nst         How often we do replica exchange (in steps)
- * \param[in] repl_ex_nex         How many replicas we have
- * \param[in] repl_ex_seed        The seed for Monte Carlo swaps
+ * \param[in] replExParams        Parameters for the replica exchange algorithm
  * \param[in] membed              Membrane embedding data structure
  * \param[in] cpt_period          How often to checkpoint the simulation
  * \param[in] max_hours           Maximume length of the simulation (wall time)
@@ -116,7 +115,7 @@ typedef double integrator_t (FILE *fplog, t_commrec *cr, const gmx::MDLogger &md
                              t_mdatoms *mdatoms,
                              t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                              t_forcerec *fr,
-                             int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                             const ReplicaExchangeParameters &replExParams,
                              gmx_membed_t gmx_unused * membed,
                              real cpt_period, real max_hours,
                              int imdport,
index 10a5b19191318e4b9795910c3a4f64f059823e0b..0f9349c1f884c64b27b867944b04397d97762fd8 100644 (file)
@@ -978,7 +978,7 @@ namespace gmx
                            t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                            gmx_edsam_t ed,
                            t_forcerec *fr,
-                           int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                           const ReplicaExchangeParameters &replExParams,
                            gmx_membed_t gmx_unused *membed,
                            real cpt_period, real max_hours,
                            int imdport,
@@ -999,7 +999,7 @@ double do_cg(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
              t_mdatoms *mdatoms,
              t_nrnb *nrnb, gmx_wallcycle_t wcycle,
              t_forcerec *fr,
-             int gmx_unused repl_ex_nst, int gmx_unused repl_ex_nex, int gmx_unused repl_ex_seed,
+             const ReplicaExchangeParameters gmx_unused &replExParams,
              gmx_membed_t gmx_unused *membed,
              real gmx_unused cpt_period, real gmx_unused max_hours,
              int imdport,
@@ -1630,7 +1630,7 @@ double do_cg(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
                           t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                           gmx_edsam_t ed,
                           t_forcerec *fr,
-                          int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                          const ReplicaExchangeParameters &replExParams,
                           gmx_membed_t gmx_unused *membed,
                           real cpt_period, real max_hours,
                           int imdport,
@@ -1651,7 +1651,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlo
                 t_mdatoms *mdatoms,
                 t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                 t_forcerec *fr,
-                int gmx_unused repl_ex_nst, int gmx_unused repl_ex_nex, int gmx_unused repl_ex_seed,
+                const ReplicaExchangeParameters gmx_unused &replExParams,
                 gmx_membed_t gmx_unused *membed,
                 real gmx_unused cpt_period, real gmx_unused max_hours,
                 int imdport,
@@ -2403,7 +2403,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlo
                           t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                           gmx_edsam_t ed,
                           t_forcerec *fr,
-                          int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                          const ReplicaExchangeParameters &replExParams,
                           real cpt_period, real max_hours,
                           int imdport,
                           unsigned long Flags,
@@ -2423,7 +2423,7 @@ double do_steep(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlo
                 t_mdatoms *mdatoms,
                 t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                 t_forcerec *fr,
-                int gmx_unused repl_ex_nst, int gmx_unused repl_ex_nex, int gmx_unused repl_ex_seed,
+                const ReplicaExchangeParameters gmx_unused &replExParams,
                 gmx_membed_t gmx_unused *membed,
                 real gmx_unused cpt_period, real gmx_unused max_hours,
                 int imdport,
@@ -2673,7 +2673,7 @@ double do_steep(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlo
                           t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                           gmx_edsam_t ed,
                           t_forcerec *fr,
-                          int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                          const ReplicaExchangeParameters &replExParams,
                           real cpt_period, real max_hours,
                           int imdport,
                           unsigned long Flags,
@@ -2693,7 +2693,7 @@ double do_nm(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
              t_mdatoms *mdatoms,
              t_nrnb *nrnb, gmx_wallcycle_t wcycle,
              t_forcerec *fr,
-             int gmx_unused repl_ex_nst, int gmx_unused repl_ex_nex, int gmx_unused repl_ex_seed,
+             const ReplicaExchangeParameters gmx_unused &replExParams,
              gmx_membed_t gmx_unused *membed,
              real gmx_unused cpt_period, real gmx_unused max_hours,
              int imdport,
index 8ab7bb32210dca03f7b930f15ad0f2f834dfdf69..04c114d6bb136ab402b9bda30369cce6c3246c24 100644 (file)
@@ -141,7 +141,7 @@ namespace gmx
                            t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                            gmx_edsam_t ed,
                            t_forcerec *fr,
-                           int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                           const ReplicaExchangeParameters &replExParams,
                            real cpt_period, real max_hours,
                            int imdport,
                            unsigned long Flags,
@@ -161,7 +161,7 @@ double do_tpi(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
               t_mdatoms *mdatoms,
               t_nrnb *nrnb, gmx_wallcycle_t wcycle,
               t_forcerec *fr,
-              int gmx_unused repl_ex_nst, int gmx_unused repl_ex_nex, int gmx_unused repl_ex_seed,
+              const ReplicaExchangeParameters gmx_unused &replExParams,
               gmx_membed_t gmx_unused *membed,
               real gmx_unused cpt_period, real gmx_unused max_hours,
               int gmx_unused imdport,
index b73092eaf81aab9a123441b7f2e4b046205af1c7..d6046d5b7885cfa4087563e5077f19a4b737c65b 100644 (file)
@@ -226,7 +226,7 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
                   t_mdatoms *mdatoms,
                   t_nrnb *nrnb, gmx_wallcycle_t wcycle,
                   t_forcerec *fr,
-                  int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                  const ReplicaExchangeParameters &replExParams,
                   gmx_membed_t *membed,
                   real cpt_period, real max_hours,
                   int imdport,
@@ -505,10 +505,11 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
         set_constraints(constr, top, ir, mdatoms, cr);
     }
 
-    if (repl_ex_nst > 0 && MASTER(cr))
+    const bool useReplicaExchange = (replExParams.exchangeInterval > 0);
+    if (useReplicaExchange && MASTER(cr))
     {
         repl_ex = init_replica_exchange(fplog, cr->ms, state_global, ir,
-                                        repl_ex_nst, repl_ex_nex, repl_ex_seed);
+                                        replExParams);
     }
 
     /* PME tuning is only supported with PME for Coulomb. Is is not supported
@@ -572,9 +573,9 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
         {
             nstfep = gmx_greatest_common_divisor(ir->expandedvals->nstexpanded, nstfep);
         }
-        if (repl_ex_nst > 0)
+        if (useReplicaExchange)
         {
-            nstfep = gmx_greatest_common_divisor(repl_ex_nst, nstfep);
+            nstfep = gmx_greatest_common_divisor(replExParams.exchangeInterval, nstfep);
         }
     }
 
@@ -775,8 +776,8 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
         // checkpoints and stop conditions to act on the same step, so
         // the propagation of such signals must take place between
         // simulations, not just within simulations.
-        bool checkpointIsLocal    = (repl_ex_nst <= 0) && !bUsingEnsembleRestraints;
-        bool stopConditionIsLocal = (repl_ex_nst <= 0) && !bUsingEnsembleRestraints;
+        bool checkpointIsLocal    = !useReplicaExchange && !bUsingEnsembleRestraints;
+        bool stopConditionIsLocal = !useReplicaExchange && !bUsingEnsembleRestraints;
         bool resetCountersIsLocal = true;
         signals[eglsCHKPT]         = SimulationSignal(checkpointIsLocal);
         signals[eglsSTOPCOND]      = SimulationSignal(stopConditionIsLocal);
@@ -787,7 +788,7 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
     step_rel = 0;
 
     // TODO extract this to new multi-simulation module
-    if (MASTER(cr) && MULTISIM(cr) && (repl_ex_nst <= 0 ))
+    if (MASTER(cr) && MULTISIM(cr) && !useReplicaExchange)
     {
         if (!multisim_int_all_are_equal(cr->ms, ir->nsteps))
         {
@@ -860,8 +861,8 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
                             && (ir->bExpanded) && (step > 0) && (!startingFromCheckpoint));
         }
 
-        bDoReplEx = ((repl_ex_nst > 0) && (step > 0) && !bLastStep &&
-                     do_per_step(step, repl_ex_nst));
+        bDoReplEx = (useReplicaExchange && (step > 0) && !bLastStep &&
+                     do_per_step(step, replExParams.exchangeInterval));
 
         if (bSimAnn)
         {
@@ -1858,7 +1859,7 @@ double gmx::do_md(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
 
     done_shellfc(fplog, shellfc, step_rel);
 
-    if (repl_ex_nst > 0 && MASTER(cr))
+    if (useReplicaExchange && MASTER(cr))
     {
         print_replica_exchange_statistics(fplog, repl_ex);
     }
index 2855d79eca430c0b9728ca6075be18ee7d623581..e2b5dd1c51437abef887f1ec7bdb01f05af97f21 100644 (file)
@@ -69,6 +69,7 @@
 #include "gromacs/utility/smalloc.h"
 
 #include "mdrun_main.h"
+#include "repl_ex.h"
 #include "runner.h"
 
 /*! \brief Return whether either of the command-line parameters that
@@ -265,7 +266,7 @@ int gmx_mdrun(int argc, char *argv[])
     };
     const int     NFILE = asize(fnm);
 
-    /* Command line options ! */
+    /* Command line option parameters, with their default values */
     gmx_bool          bDDBondCheck  = TRUE;
     gmx_bool          bDDBondComm   = TRUE;
     gmx_bool          bTunePME      = TRUE;
@@ -281,14 +282,15 @@ int gmx_mdrun(int argc, char *argv[])
     int               nstlist       = 0;
     int               nmultisim     = 0;
     int               nstglobalcomm = -1;
-    int               repl_ex_nst   = 0;
-    int               repl_ex_seed  = -1;
-    int               repl_ex_nex   = 0;
     int               nstepout      = 100;
     int               resetstep     = -1;
     gmx_int64_t       nsteps        = -2;   /* the value -2 means that the mdp option will be used */
-    int               imdport       = 8888; /* can be almost anything, 8888 is easy to remember */
 
+    /* Special algorithms section */
+    ReplicaExchangeParameters replExParams;
+    int                       imdport       = 8888; /* can be almost anything, 8888 is easy to remember */
+
+    /* Command line options */
     rvec              realddxyz                   = {0, 0, 0};
     const char       *ddrank_opt[ddrankorderNR+1] =
     { nullptr, "interleave", "pp_pme", "cartesian", nullptr };
@@ -390,11 +392,11 @@ int gmx_mdrun(int argc, char *argv[])
           "Terminate after 0.99 times this time (hours)" },
         { "-multi",   FALSE, etINT, {&nmultisim},
           "Do multiple simulations in parallel" },
-        { "-replex",  FALSE, etINT, {&repl_ex_nst},
+        { "-replex",  FALSE, etINT, {&replExParams.exchangeInterval},
           "Attempt replica exchange periodically with this period (steps)" },
-        { "-nex",  FALSE, etINT, {&repl_ex_nex},
+        { "-nex",  FALSE, etINT, {&replExParams.numExchanges},
           "Number of random exchanges to carry out each exchange interval (N^3 is one suggestion).  -nex zero or not specified gives neighbor replica exchange." },
-        { "-reseed",  FALSE, etINT, {&repl_ex_seed},
+        { "-reseed",  FALSE, etINT, {&replExParams.randomSeed},
           "Seed for replica exchange, -1 is generate a seed" },
         { "-imdport",    FALSE, etINT, {&imdport},
           "HIDDENIMD listening port" },
@@ -470,12 +472,12 @@ int gmx_mdrun(int argc, char *argv[])
     }
 
 
-    if (repl_ex_nst != 0 && nmultisim < 2)
+    if (replExParams.exchangeInterval != 0 && nmultisim < 2)
     {
         gmx_fatal(FARGS, "Need at least two replicas for replica exchange (option -multi)");
     }
 
-    if (repl_ex_nex < 0)
+    if (replExParams.numExchanges < 0)
     {
         gmx_fatal(FARGS, "Replica exchange number of exchanges needs to be positive");
     }
@@ -547,7 +549,7 @@ int gmx_mdrun(int argc, char *argv[])
                        dddlb_opt[0], dlb_scale, ddcsx, ddcsy, ddcsz,
                        nbpu_opt[0], nstlist,
                        nsteps, nstepout, resetstep,
-                       nmultisim, repl_ex_nst, repl_ex_nex, repl_ex_seed,
+                       nmultisim, replExParams,
                        pforce, cpt_period, max_hours, imdport, Flags);
 
     /* Log file has to be closed in mdrunner if we are appending to it
index 1418ac92a1e7cc70d18d026f9d4c87bae9453e15..c886b180e4e8f5dfcaf8e2fa8e1ec54b42f59fb8 100644 (file)
@@ -149,11 +149,12 @@ static gmx_bool repl_quantity(const gmx_multisim_t *ms,
     return bDiff;
 }
 
-gmx_repl_ex_t init_replica_exchange(FILE *fplog,
-                                    const gmx_multisim_t *ms,
-                                    const t_state *state,
-                                    const t_inputrec *ir,
-                                    int nst, int nex, int init_seed)
+gmx_repl_ex_t
+init_replica_exchange(FILE                            *fplog,
+                      const gmx_multisim_t            *ms,
+                      const t_state                   *state,
+                      const t_inputrec                *ir,
+                      const ReplicaExchangeParameters &replExParams)
 {
     real                pres;
     int                 i, j, k;
@@ -192,6 +193,7 @@ gmx_repl_ex_t init_replica_exchange(FILE *fplog,
     check_multi_int(fplog, ms, state->natoms, "the number of atoms", FALSE);
     check_multi_int(fplog, ms, ir->eI, "the integrator", FALSE);
     check_multi_int64(fplog, ms, ir->init_step+ir->nsteps, "init_step+nsteps", FALSE);
+    const int nst = replExParams.exchangeInterval;
     check_multi_int64(fplog, ms, (ir->init_step+nst-1)/nst,
                       "first exchange step: init_step/-replex", FALSE);
     check_multi_int(fplog, ms, ir->etc, "the temperature coupling", FALSE);
@@ -372,7 +374,7 @@ gmx_repl_ex_t init_replica_exchange(FILE *fplog,
         }
     }
     re->nst = nst;
-    if (init_seed == -1)
+    if (replExParams.randomSeed == -1)
     {
         if (MASTERSIM(ms))
         {
@@ -386,7 +388,7 @@ gmx_repl_ex_t init_replica_exchange(FILE *fplog,
     }
     else
     {
-        re->seed = init_seed;
+        re->seed = replExParams.randomSeed;
     }
     fprintf(fplog, "\nReplica exchange interval: %d\n", re->nst);
     fprintf(fplog, "\nReplica random seed: %d\n", re->seed);
@@ -428,7 +430,7 @@ gmx_repl_ex_t init_replica_exchange(FILE *fplog,
     {
         snew(re->de[i], re->nrepl);
     }
-    re->nex = nex;
+    re->nex = replExParams.numExchanges;
     return re;
 }
 
index 2a0a517eb7af2b906beaa6db7b78d85078695635..d5064e176300c7ec6677d5efac05dff287ba1872 100644 (file)
@@ -49,15 +49,31 @@ struct t_commrec;
 struct t_inputrec;
 class t_state;
 
+/* The parameters for the replica exchange algorithm */
+struct ReplicaExchangeParameters
+{
+    ReplicaExchangeParameters() :
+        exchangeInterval(0),
+        numExchanges(0),
+        randomSeed(-1)
+    {
+    };
+
+    int exchangeInterval; /* Interval in steps at which to attempt exchanges, 0 means no replica exchange */
+    int numExchanges;     /* The number of exchanges to attempt at an exchange step */
+    int randomSeed;       /* The random seed, -1 means generate a seed */
+};
+
 /* Abstract type for replica exchange */
 typedef struct gmx_repl_ex *gmx_repl_ex_t;
 
-gmx_repl_ex_t init_replica_exchange(FILE *fplog,
-                                    const gmx_multisim_t *ms,
-                                    const t_state *state,
-                                    const t_inputrec *ir,
-                                    int nst, int nmultiex, int init_seed);
-/* Should only be called on the master nodes */
+gmx_repl_ex_t
+init_replica_exchange(FILE                            *fplog,
+                      const gmx_multisim_t            *ms,
+                      const t_state                   *state,
+                      const t_inputrec                *ir,
+                      const ReplicaExchangeParameters &replExParams);
+/* Should only be called on the master ranks */
 
 gmx_bool replica_exchange(FILE *fplog,
                           const t_commrec *cr,
@@ -65,15 +81,15 @@ gmx_bool replica_exchange(FILE *fplog,
                           t_state *state, gmx_enerdata_t *enerd,
                           t_state *state_local,
                           gmx_int64_t step, real time);
-/* Attempts replica exchange, should be called on all nodes.
+/* Attempts replica exchange, should be called on all ranks.
  * Returns TRUE if this state has been exchanged.
  * When running each replica in parallel,
- * this routine collects the state on the master node before exchange.
+ * this routine collects the state on the master rank before exchange.
  * With domain decomposition, the global state after exchange is stored
- * in state and still needs to be redistributed over the nodes.
+ * in state and still needs to be redistributed over the ranks.
  */
 
 void print_replica_exchange_statistics(FILE *fplog, gmx_repl_ex_t re);
-/* Should only be called on the master nodes */
+/* Should only be called on the master ranks */
 
 #endif  /* _repl_ex_h */
index ab159f87c029af434c6536ad912ceb213475a4a3..bc4f70ba2c3c1b5b760af05fc3a2b55cd7d76484 100644 (file)
@@ -141,38 +141,36 @@ tMPI_Thread_mutex_t deform_init_box_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
 
 struct mdrunner_arglist
 {
-    gmx_hw_opt_t            hw_opt;
-    FILE                   *fplog;
-    t_commrec              *cr;
-    int                     nfile;
-    const t_filenm         *fnm;
-    const gmx_output_env_t *oenv;
-    gmx_bool                bVerbose;
-    int                     nstglobalcomm;
-    ivec                    ddxyz;
-    int                     dd_rank_order;
-    int                     npme;
-    real                    rdd;
-    real                    rconstr;
-    const char             *dddlb_opt;
-    real                    dlb_scale;
-    const char             *ddcsx;
-    const char             *ddcsy;
-    const char             *ddcsz;
-    const char             *nbpu_opt;
-    int                     nstlist_cmdline;
-    gmx_int64_t             nsteps_cmdline;
-    int                     nstepout;
-    int                     resetstep;
-    int                     nmultisim;
-    int                     repl_ex_nst;
-    int                     repl_ex_nex;
-    int                     repl_ex_seed;
-    real                    pforce;
-    real                    cpt_period;
-    real                    max_hours;
-    int                     imdport;
-    unsigned long           Flags;
+    gmx_hw_opt_t                     hw_opt;
+    FILE                            *fplog;
+    t_commrec                       *cr;
+    int                              nfile;
+    const t_filenm                  *fnm;
+    const gmx_output_env_t          *oenv;
+    gmx_bool                         bVerbose;
+    int                              nstglobalcomm;
+    ivec                             ddxyz;
+    int                              dd_rank_order;
+    int                              npme;
+    real                             rdd;
+    real                             rconstr;
+    const char                      *dddlb_opt;
+    real                             dlb_scale;
+    const char                      *ddcsx;
+    const char                      *ddcsy;
+    const char                      *ddcsz;
+    const char                      *nbpu_opt;
+    int                              nstlist_cmdline;
+    gmx_int64_t                      nsteps_cmdline;
+    int                              nstepout;
+    int                              resetstep;
+    int                              nmultisim;
+    const ReplicaExchangeParameters *replExParams;
+    real                             pforce;
+    real                             cpt_period;
+    real                             max_hours;
+    int                              imdport;
+    unsigned long                    Flags;
 };
 
 
@@ -208,7 +206,7 @@ static void mdrunner_start_fn(void *arg)
                       mc.ddcsx, mc.ddcsy, mc.ddcsz,
                       mc.nbpu_opt, mc.nstlist_cmdline,
                       mc.nsteps_cmdline, mc.nstepout, mc.resetstep,
-                      mc.nmultisim, mc.repl_ex_nst, mc.repl_ex_nex, mc.repl_ex_seed, mc.pforce,
+                      mc.nmultisim, *mc.replExParams, mc.pforce,
                       mc.cpt_period, mc.max_hours, mc.imdport, mc.Flags);
     }
     GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
@@ -230,7 +228,8 @@ static t_commrec *mdrunner_start_threads(gmx_hw_opt_t *hw_opt,
                                          const char *nbpu_opt, int nstlist_cmdline,
                                          gmx_int64_t nsteps_cmdline,
                                          int nstepout, int resetstep,
-                                         int nmultisim, int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+                                         int nmultisim,
+                                         const ReplicaExchangeParameters &replExParams,
                                          real pforce, real cpt_period, real max_hours,
                                          unsigned long Flags)
 {
@@ -277,9 +276,7 @@ static t_commrec *mdrunner_start_threads(gmx_hw_opt_t *hw_opt,
     mda->nstepout        = nstepout;
     mda->resetstep       = resetstep;
     mda->nmultisim       = nmultisim;
-    mda->repl_ex_nst     = repl_ex_nst;
-    mda->repl_ex_nex     = repl_ex_nex;
-    mda->repl_ex_seed    = repl_ex_seed;
+    mda->replExParams    = &replExParams;
     mda->pforce          = pforce;
     mda->cpt_period      = cpt_period;
     mda->max_hours       = max_hours;
@@ -704,8 +701,9 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
              const char *ddcsx, const char *ddcsy, const char *ddcsz,
              const char *nbpu_opt, int nstlist_cmdline,
              gmx_int64_t nsteps_cmdline, int nstepout, int resetstep,
-             int gmx_unused nmultisim, int repl_ex_nst, int repl_ex_nex,
-             int repl_ex_seed, real pforce, real cpt_period, real max_hours,
+             int gmx_unused nmultisim,
+             const ReplicaExchangeParameters &replExParams,
+             real pforce, real cpt_period, real max_hours,
              int imdport, unsigned long Flags)
 {
     gmx_bool                  bForceUseGPU, bTryUseGPU, bRerunMD;
@@ -873,7 +871,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
                                         dddlb_opt, dlb_scale, ddcsx, ddcsy, ddcsz,
                                         nbpu_opt, nstlist_cmdline,
                                         nsteps_cmdline, nstepout, resetstep, nmultisim,
-                                        repl_ex_nst, repl_ex_nex, repl_ex_seed, pforce,
+                                        replExParams, pforce,
                                         cpt_period, max_hours,
                                         Flags);
             /* the main thread continues here with a new cr. We don't deallocate
@@ -977,7 +975,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
     snew(fcd, 1);
 
     /* This needs to be called before read_checkpoint to extend the state */
-    init_disres(fplog, mtop, inputrec, cr, fcd, state, repl_ex_nst > 0);
+    init_disres(fplog, mtop, inputrec, cr, fcd, state, replExParams.exchangeInterval > 0);
 
     init_orires(fplog, mtop, as_rvec_array(state->x.data()), inputrec, cr, &(fcd->orires),
                 state);
@@ -1383,7 +1381,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
                                      inputrec, mtop,
                                      fcd, state, &observablesHistory,
                                      mdatoms, nrnb, wcycle, fr,
-                                     repl_ex_nst, repl_ex_nex, repl_ex_seed,
+                                     replExParams,
                                      membed,
                                      cpt_period, max_hours,
                                      imdport,
index bfbaa315a193a03d3da68bc535f2be9caba51f2b..48e873b84c286c2282981ff5132dfe5984ffafdd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -50,6 +50,7 @@
 #include "gromacs/utility/real.h"
 
 struct gmx_output_env_t;
+struct ReplicaExchangeParameters;
 struct t_commrec;
 struct t_filenm;
 
@@ -83,9 +84,7 @@ namespace gmx
  * \param[in] nstepout     How often to write to the console
  * \param[in] resetstep    Reset the step counter
  * \param[in] nmultisim    Number of parallel simulations to run
- * \param[in] repl_ex_nst  Number steps between replica exchange attempts
- * \param[in] repl_ex_nex  Number of replicas in REMD
- * \param[in] repl_ex_seed The seed for Monte Carlo swaps
+ * \param[in] replExParams Parameters for the replica exchange algorithm
  * \param[in] pforce       Minimum force for printing (for debugging)
  * \param[in] cpt_period    How often to checkpoint the simulation
  * \param[in] max_hours     Maximume length of the simulation (wall time)
@@ -100,8 +99,9 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
              const char *ddcsx, const char *ddcsy, const char *ddcsz,
              const char *nbpu_opt, int nstlist_cmdline,
              gmx_int64_t nsteps_cmdline, int nstepout, int resetstep,
-             int nmultisim, int repl_ex_nst, int repl_ex_nex,
-             int repl_ex_seed, real pforce, real cpt_period, real max_hours,
+             int nmultisim,
+             const ReplicaExchangeParameters &replExParams,
+             real pforce, real cpt_period, real max_hours,
              int imdport, unsigned long Flags);