Remove .tpa, .tpb, .tpx, .trj files. Part of #1500.
[alexxy/gromacs.git] / src / programs / mdrun / mdrun.cpp
index d1ebcc102ea6b653c6db3417c8cae38dacbc6639..901cccfdcd073ff19874e4688346985471a8154c 100644 (file)
@@ -1,62 +1,78 @@
-/*  -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
  *
- *
- *                This source code is part of
- *
- *                 G   R   O   M   A   C   S
- *
- *          GROningen MAchine for Chemical Simulations
- *
- *                        VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2011,2012,2013,2014, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
  * of the License, or (at your option) any later version.
  *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
  *
- * For more info, check our website at http://www.gromacs.org
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
  *
- * And Hey:
- * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
+#include "gmxpre.h"
+
 #include "mdrun_main.h"
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <stdio.h>
+#include <string.h>
 
 #include "gromacs/legacyheaders/checkpoint.h"
 #include "gromacs/legacyheaders/copyrite.h"
-#include "gromacs/fileio/filenm.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
 #include "gromacs/legacyheaders/macros.h"
 #include "gromacs/legacyheaders/main.h"
 #include "gromacs/legacyheaders/mdrun.h"
 #include "gromacs/legacyheaders/network.h"
 #include "gromacs/legacyheaders/readinp.h"
-#include "gromacs/legacyheaders/statutil.h"
 #include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/filenm.h"
+#include "gromacs/utility/fatalerror.h"
+
+static bool is_multisim_option_set(int argc, const char *const argv[])
+{
+    for (int i = 0; i < argc; ++i)
+    {
+        if (strcmp(argv[i], "-multi") == 0 || strcmp(argv[i], "-multidir") == 0)
+        {
+            return true;
+        }
+    }
+    return false;
+}
 
 int gmx_mdrun(int argc, char *argv[])
 {
     const char   *desc[] = {
-        "The [TT]mdrun[tt] program is the main computational chemistry engine",
+        "[THISMODULE] is the main computational chemistry engine",
         "within GROMACS. Obviously, it performs Molecular Dynamics simulations,",
         "but it can also perform Stochastic Dynamics, Energy Minimization,",
         "test particle insertion or (re)calculation of energies.",
@@ -64,12 +80,11 @@ int gmx_mdrun(int argc, char *argv[])
         "builds a Hessian matrix from single conformation.",
         "For usual Normal Modes-like calculations, make sure that",
         "the structure provided is properly energy-minimized.",
-        "The generated matrix can be diagonalized by [TT]g_nmeig[tt].[PAR]",
+        "The generated matrix can be diagonalized by [gmx-nmeig].[PAR]",
         "The [TT]mdrun[tt] program reads the run input file ([TT]-s[tt])",
-        "and distributes the topology over nodes if needed.",
+        "and distributes the topology over ranks if needed.",
         "[TT]mdrun[tt] produces at least four output files.",
-        "A single log file ([TT]-g[tt]) is written, unless the option",
-        "[TT]-seppot[tt] is used, in which case each node writes a log file.",
+        "A single log file ([TT]-g[tt]) is written.",
         "The trajectory file ([TT]-o[tt]), contains coordinates, velocities and",
         "optionally forces.",
         "The structure file ([TT]-c[tt]) contains the coordinates and",
@@ -85,20 +100,26 @@ int gmx_mdrun(int argc, char *argv[])
         "The MPI parallelization uses multiple processes when [TT]mdrun[tt] is",
         "compiled with a normal MPI library or threads when [TT]mdrun[tt] is",
         "compiled with the GROMACS built-in thread-MPI library. OpenMP threads",
-        "are supported when mdrun is compiled with OpenMP. Full OpenMP support",
+        "are supported when [TT]mdrun[tt] is compiled with OpenMP. Full OpenMP support",
         "is only available with the Verlet cut-off scheme, with the (older)",
-        "group scheme only PME-only processes can use OpenMP parallelization.",
+        "group scheme only PME-only ranks can use OpenMP parallelization.",
         "In all cases [TT]mdrun[tt] will by default try to use all the available",
         "hardware resources. With a normal MPI library only the options",
         "[TT]-ntomp[tt] (with the Verlet cut-off scheme) and [TT]-ntomp_pme[tt],",
-        "for PME-only processes, can be used to control the number of threads.",
+        "for PME-only ranks, can be used to control the number of threads.",
         "With thread-MPI there are additional options [TT]-nt[tt], which sets",
         "the total number of threads, and [TT]-ntmpi[tt], which sets the number",
         "of thread-MPI threads.",
-        "Note that using combined MPI+OpenMP parallelization is almost always",
-        "slower than single parallelization, except at the scaling limit, where",
-        "especially OpenMP parallelization of PME reduces the communication cost.",
-        "OpenMP-only parallelization is much faster than MPI-only parallelization",
+        "The number of OpenMP threads used by [TT]mdrun[tt] can also be set with",
+        "the standard environment variable, [TT]OMP_NUM_THREADS[tt].",
+        "The [TT]GMX_PME_NUM_THREADS[tt] environment variable can be used to specify",
+        "the number of threads used by the PME-only ranks.[PAR]",
+        "Note that combined MPI+OpenMP parallelization is in many cases",
+        "slower than either on its own. However, at high parallelization, using the",
+        "combination is often beneficial as it reduces the number of domains and/or",
+        "the number of MPI ranks. (Less and larger domains can improve scaling,",
+        "with separate PME ranks, using fewer MPI ranks reduces communication costs.)",
+        "OpenMP-only parallelization is typically faster than MPI-only parallelization",
         "on a single CPU(-die). Since we currently don't have proper hardware",
         "topology detection, [TT]mdrun[tt] compiled with thread-MPI will only",
         "automatically use OpenMP-only parallelization when you use up to 4",
@@ -115,8 +136,8 @@ int gmx_mdrun(int argc, char *argv[])
         "to specify [TT]cutoff-scheme = Verlet[tt] in the [TT].mdp[tt] file.",
         "[PAR]",
         "With GPUs (only supported with the Verlet cut-off scheme), the number",
-        "of GPUs should match the number of MPI processes or MPI threads,",
-        "excluding PME-only processes/threads. With thread-MPI, unless set on the command line, the number",
+        "of GPUs should match the number of particle-particle ranks, i.e.",
+        "excluding PME-only ranks. With thread-MPI, unless set on the command line, the number",
         "of MPI threads will automatically be set to the number of GPUs detected.",
         "To use a subset of the available GPUs, or to manually provide a mapping of",
         "GPUs to PP ranks, you can use the [TT]-gpu_id[tt] option. The argument of [TT]-gpu_id[tt] is",
@@ -131,7 +152,18 @@ int gmx_mdrun(int argc, char *argv[])
         "multiple times, e.g. \"[TT]0011[tt]\" for four ranks sharing two GPUs in this node.",
         "This works within a single simulation, or a multi-simulation, with any form of MPI.",
         "[PAR]",
-        "When using PME with separate PME nodes or with a GPU, the two major",
+        "With the Verlet cut-off scheme and verlet-buffer-tolerance set,",
+        "the pair-list update interval nstlist can be chosen freely with",
+        "the option [TT]-nstlist[tt]. [TT]mdrun[tt] will then adjust",
+        "the pair-list cut-off to maintain accuracy, and not adjust nstlist.",
+        "Otherwise, by default, [TT]mdrun[tt] will try to increase the",
+        "value of nstlist set in the [TT].mdp[tt] file to improve the",
+        "performance. For CPU-only runs, nstlist might increase to 20, for",
+        "GPU runs up to 40. For medium to high parallelization or with",
+        "fast GPUs, a (user-supplied) larger nstlist value can give much",
+        "better performance.",
+        "[PAR]",
+        "When using PME with separate PME ranks or with a GPU, the two major",
         "compute tasks, the non-bonded force calculation and the PME calculation",
         "run on different compute resources. If this load is not balanced,",
         "some of the resources will be idle part of time. With the Verlet",
@@ -159,17 +191,15 @@ int gmx_mdrun(int argc, char *argv[])
         "With Intel Hyper-Threading 2 is best when using half or less of the",
         "logical cores, 1 otherwise. The default value of 0 do exactly that:",
         "it minimizes the threads per logical core, to optimize performance.",
-        "If you want to run multiple mdrun jobs on the same physical node,"
+        "If you want to run multiple [TT]mdrun[tt] jobs on the same physical node,"
         "you should set [TT]-pinstride[tt] to 1 when using all logical cores.",
-        "When running multiple mdrun (or other) simulations on the same physical",
+        "When running multiple [TT]mdrun[tt] (or other) simulations on the same physical",
         "node, some simulations need to start pinning from a non-zero core",
         "to avoid overloading cores; with [TT]-pinoffset[tt] you can specify",
         "the offset in logical cores for pinning.",
         "[PAR]",
-        "When [TT]mdrun[tt] is started using MPI with more than 1 process",
-        "or with thread-MPI with more than 1 thread, MPI parallelization is used.",
-        "By default domain decomposition is used, unless the [TT]-pd[tt]",
-        "option is set, which selects particle decomposition.",
+        "When [TT]mdrun[tt] is started with more than 1 rank,",
+        "parallelization with domain decomposition is used.",
         "[PAR]",
         "With domain decomposition, the spatial decomposition can be set",
         "with option [TT]-dd[tt]. By default [TT]mdrun[tt] selects a good decomposition.",
@@ -186,18 +216,21 @@ int gmx_mdrun(int argc, char *argv[])
         "At high parallelization the options in the next two sections",
         "could be important for increasing the performace.",
         "[PAR]",
-        "When PME is used with domain decomposition, separate nodes can",
+        "When PME is used with domain decomposition, separate ranks can",
         "be assigned to do only the PME mesh calculation;",
-        "this is computationally more efficient starting at about 12 nodes.",
-        "The number of PME nodes is set with option [TT]-npme[tt],",
-        "this can not be more than half of the nodes.",
+        "this is computationally more efficient starting at about 12 ranks,",
+        "or even fewer when OpenMP parallelization is used.",
+        "The number of PME ranks is set with option [TT]-npme[tt],",
+        "but this cannot be more than half of the ranks.",
         "By default [TT]mdrun[tt] makes a guess for the number of PME",
-        "nodes when the number of nodes is larger than 11 or performance wise",
-        "not compatible with the PME grid x dimension.",
-        "But the user should optimize npme. Performance statistics on this issue",
+        "ranks when the number of ranks is larger than 16. With GPUs,",
+        "using separate PME ranks is not selected automatically,",
+        "since the optimal setup depends very much on the details",
+        "of the hardware. In all cases, you might gain performance",
+        "by optimizing [TT]-npme[tt]. Performance statistics on this issue",
         "are written at the end of the log file.",
         "For good load balancing at high parallelization, the PME grid x and y",
-        "dimensions should be divisible by the number of PME nodes",
+        "dimensions should be divisible by the number of PME ranks",
         "(the simulation will run correctly also when this is not the case).",
         "[PAR]",
         "This section lists all options that affect the domain decomposition.",
@@ -286,7 +319,7 @@ int gmx_mdrun(int argc, char *argv[])
         "With [TT]-multi[tt], the system number is appended to the run input ",
         "and each output filename, for instance [TT]topol.tpr[tt] becomes",
         "[TT]topol0.tpr[tt], [TT]topol1.tpr[tt] etc.",
-        "The number of nodes per system is the total number of nodes",
+        "The number of ranks per system is the total number of ranks",
         "divided by the number of systems.",
         "One use of this option is for NMR refinement: when distance",
         "or orientation restraints are present these can be ensemble averaged",
@@ -348,7 +381,7 @@ int gmx_mdrun(int argc, char *argv[])
         "and no old output files are modified and no new output files are opened.",
         "The result with appending will be the same as from a single run.",
         "The contents will be binary identical, unless you use a different number",
-        "of nodes or dynamic load balancing or the FFT library uses optimizations",
+        "of ranks or dynamic load balancing or the FFT library uses optimizations",
         "through timing.",
         "[PAR]",
         "With option [TT]-maxh[tt] a simulation is terminated and a checkpoint",
@@ -360,17 +393,26 @@ int gmx_mdrun(int argc, char *argv[])
         "pressed), it will stop after the next neighbor search step ",
         "(with nstlist=0 at the next step).",
         "In both cases all the usual output will be written to file.",
-        "When running with MPI, a signal to one of the [TT]mdrun[tt] processes",
+        "When running with MPI, a signal to one of the [TT]mdrun[tt] ranks",
         "is sufficient, this signal should not be sent to mpirun or",
         "the [TT]mdrun[tt] process that is the parent of the others.",
         "[PAR]",
+        "Interactive molecular dynamics (IMD) can be activated by using at least one",
+        "of the three IMD switches: The [TT]-imdterm[tt] switch allows to terminate the",
+        "simulation from the molecular viewer (e.g. VMD). With [TT]-imdwait[tt],",
+        "[TT]mdrun[tt] pauses whenever no IMD client is connected. Pulling from the",
+        "IMD remote can be turned on by [TT]-imdpull[tt].",
+        "The port [TT]mdrun[tt] listens to can be altered by [TT]-imdport[tt].The",
+        "file pointed to by [TT]-if[tt] contains atom indices and forces if IMD",
+        "pulling is used."
+        "[PAR]",
         "When [TT]mdrun[tt] is started with MPI, it does not run niced by default."
     };
     t_commrec    *cr;
     t_filenm      fnm[] = {
-        { efTPX, NULL,      NULL,       ffREAD },
+        { efTPR, NULL,      NULL,       ffREAD },
         { efTRN, "-o",      NULL,       ffWRITE },
-        { efXTC, "-x",      NULL,       ffOPTWR },
+        { efCOMPRESSED, "-x", NULL,     ffOPTWR },
         { efCPT, "-cpi",    NULL,       ffOPTRD },
         { efCPT, "-cpo",    NULL,       ffOPTWR },
         { efSTO, "-c",      "confout",  ffWRITE },
@@ -400,24 +442,28 @@ int gmx_mdrun(int argc, char *argv[])
         { efRND, "-multidir", NULL,      ffOPTRDMULT},
         { efDAT, "-membed", "membed",   ffOPTRD },
         { efTOP, "-mp",     "membed",   ffOPTRD },
-        { efNDX, "-mn",     "membed",   ffOPTRD }
+        { efNDX, "-mn",     "membed",   ffOPTRD },
+        { efXVG, "-if",     "imdforces", ffOPTWR },
+        { efXVG, "-swap",   "swapions", ffOPTWR }
     };
 #define NFILE asize(fnm)
 
     /* Command line options ! */
-    gmx_bool        bPartDec      = FALSE;
     gmx_bool        bDDBondCheck  = TRUE;
     gmx_bool        bDDBondComm   = TRUE;
     gmx_bool        bTunePME      = TRUE;
     gmx_bool        bTestVerlet   = FALSE;
     gmx_bool        bVerbose      = FALSE;
     gmx_bool        bCompact      = TRUE;
-    gmx_bool        bSepPot       = FALSE;
     gmx_bool        bRerunVSite   = FALSE;
     gmx_bool        bConfout      = TRUE;
     gmx_bool        bReproducible = FALSE;
+    gmx_bool        bIMDwait      = FALSE;
+    gmx_bool        bIMDterm      = FALSE;
+    gmx_bool        bIMDpull      = FALSE;
 
     int             npme          = -1;
+    int             nstlist       = 0;
     int             nmultisim     = 0;
     int             nstglobalcomm = -1;
     int             repl_ex_nst   = 0;
@@ -425,7 +471,8 @@ int gmx_mdrun(int argc, char *argv[])
     int             repl_ex_nex   = 0;
     int             nstepout      = 100;
     int             resetstep     = -1;
-    gmx_large_int_t nsteps        = -2; /* the value -2 means that the mdp option will be used */
+    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 */
 
     rvec            realddxyz          = {0, 0, 0};
     const char     *ddno_opt[ddnoNR+1] =
@@ -449,29 +496,29 @@ int gmx_mdrun(int argc, char *argv[])
      * But unfortunately we are not allowed to call a function here,
      * since declarations follow below.
      */
-    gmx_hw_opt_t    hw_opt = { 0, 0, 0, 0, threadaffSEL, 0, 0,
-                               { NULL, FALSE, 0, NULL } };
+    gmx_hw_opt_t    hw_opt = {
+        0, 0, 0, 0, threadaffSEL, 0, 0,
+        { NULL, FALSE, 0, NULL }
+    };
 
     t_pargs         pa[] = {
 
-        { "-pd",      FALSE, etBOOL, {&bPartDec},
-          "Use particle decompostion" },
         { "-dd",      FALSE, etRVEC, {&realddxyz},
           "Domain decomposition grid, 0 is optimize" },
         { "-ddorder", FALSE, etENUM, {ddno_opt},
-          "DD node order" },
+          "DD rank order" },
         { "-npme",    FALSE, etINT, {&npme},
-          "Number of separate nodes to be used for PME, -1 is guess" },
+          "Number of separate ranks to be used for PME, -1 is guess" },
         { "-nt",      FALSE, etINT, {&hw_opt.nthreads_tot},
           "Total number of threads to start (0 is guess)" },
         { "-ntmpi",   FALSE, etINT, {&hw_opt.nthreads_tmpi},
           "Number of thread-MPI threads to start (0 is guess)" },
         { "-ntomp",   FALSE, etINT, {&hw_opt.nthreads_omp},
-          "Number of OpenMP threads per MPI process/thread to start (0 is guess)" },
+          "Number of OpenMP threads per MPI rank to start (0 is guess)" },
         { "-ntomp_pme", FALSE, etINT, {&hw_opt.nthreads_omp_pme},
-          "Number of OpenMP threads per MPI process/thread to start (0 is -ntomp)" },
+          "Number of OpenMP threads per MPI rank to start (0 is -ntomp)" },
         { "-pin",     FALSE, etENUM, {thread_aff_opt},
-          "Fix threads (or processes) to specific cores" },
+          "Set thread affinities" },
         { "-pinoffset", FALSE, etINT, {&hw_opt.core_pinning_offset},
           "The starting logical core number for pinning to cores; used to avoid pinning threads from different mdrun instances to the same core" },
         { "-pinstride", FALSE, etINT, {&hw_opt.core_pinning_stride},
@@ -489,27 +536,34 @@ int gmx_mdrun(int argc, char *argv[])
         { "-dlb",     FALSE, etENUM, {dddlb_opt},
           "Dynamic load balancing (with DD)" },
         { "-dds",     FALSE, etREAL, {&dlb_scale},
-          "Minimum allowed dlb scaling of the DD cell size" },
+          "Fraction in (0,1) by whose reciprocal the initial DD cell size will be increased in order to "
+          "provide a margin in which dynamic load balancing can act while preserving the minimum cell size." },
         { "-ddcsx",   FALSE, etSTR, {&ddcsx},
-          "HIDDENThe DD cell sizes in x" },
+          "HIDDENA string containing a vector of the relative sizes in the x "
+          "direction of the corresponding DD cells. Only effective with static "
+          "load balancing." },
         { "-ddcsy",   FALSE, etSTR, {&ddcsy},
-          "HIDDENThe DD cell sizes in y" },
+          "HIDDENA string containing a vector of the relative sizes in the y "
+          "direction of the corresponding DD cells. Only effective with static "
+          "load balancing." },
         { "-ddcsz",   FALSE, etSTR, {&ddcsz},
-          "HIDDENThe DD cell sizes in z" },
+          "HIDDENA string containing a vector of the relative sizes in the z "
+          "direction of the corresponding DD cells. Only effective with static "
+          "load balancing." },
         { "-gcom",    FALSE, etINT, {&nstglobalcomm},
           "Global communication frequency" },
         { "-nb",      FALSE, etENUM, {&nbpu_opt},
           "Calculate non-bonded interactions on" },
+        { "-nstlist", FALSE, etINT, {&nstlist},
+          "Set nstlist when using a Verlet buffer tolerance (0 is guess)" },
         { "-tunepme", FALSE, etBOOL, {&bTunePME},
-          "Optimize PME load between PP/PME nodes or GPU/CPU" },
+          "Optimize PME load between PP/PME ranks or GPU/CPU" },
         { "-testverlet", FALSE, etBOOL, {&bTestVerlet},
           "Test the Verlet non-bonded scheme" },
         { "-v",       FALSE, etBOOL, {&bVerbose},
           "Be loud and noisy" },
         { "-compact", FALSE, etBOOL, {&bCompact},
           "Write a compact log file" },
-        { "-seppot",  FALSE, etBOOL, {&bSepPot},
-          "Write separate V and dVdl terms for each interaction type and node to the log file(s)" },
         { "-pforce",  FALSE, etREAL, {&pforce},
           "Print all forces larger than this (kJ/mol nm)" },
         { "-reprod",  FALSE, etBOOL, {&bReproducible},
@@ -520,7 +574,7 @@ int gmx_mdrun(int argc, char *argv[])
           "Keep and number checkpoint files" },
         { "-append",  FALSE, etBOOL, {&bAppendFiles},
           "Append to previous output files when continuing from checkpoint instead of adding the simulation part number to all file names" },
-        { "-nsteps",  FALSE, etGMX_LARGE_INT, {&nsteps},
+        { "-nsteps",  FALSE, etINT64, {&nsteps},
           "Run this number of steps, overrides .mdp file option" },
         { "-maxh",   FALSE, etREAL, {&max_hours},
           "Terminate after 0.99 times this time (hours)" },
@@ -532,6 +586,14 @@ int gmx_mdrun(int argc, char *argv[])
           "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},
           "Seed for replica exchange, -1 is generate a seed" },
+        { "-imdport",    FALSE, etINT, {&imdport},
+          "HIDDENIMD listening port" },
+        { "-imdwait",  FALSE, etBOOL, {&bIMDwait},
+          "HIDDENPause the simulation while no IMD client is connected" },
+        { "-imdterm",  FALSE, etBOOL, {&bIMDterm},
+          "HIDDENAllow termination of the simulation from IMD client" },
+        { "-imdpull",  FALSE, etBOOL, {&bIMDpull},
+          "HIDDENAllow pulling in the simulation from IMD client" },
         { "-rerunvsite", FALSE, etBOOL, {&bRerunVSite},
           "HIDDENRecalculate virtual site coordinates with [TT]-rerun[tt]" },
         { "-confout", FALSE, etBOOL, {&bConfout},
@@ -543,7 +605,7 @@ int gmx_mdrun(int argc, char *argv[])
         { "-resethway", FALSE, etBOOL, {&bResetCountersHalfWay},
           "HIDDENReset the cycle counters after half the number of steps or halfway [TT]-maxh[tt]" }
     };
-    unsigned long   Flags, PCA_Flags;
+    unsigned long   Flags;
     ivec            ddxyz;
     int             dd_node_order;
     gmx_bool        bAddPart;
@@ -554,10 +616,17 @@ int gmx_mdrun(int argc, char *argv[])
     int             rc;
     char          **multidir = NULL;
 
-
     cr = init_commrec();
 
-    PCA_Flags = (PCA_CAN_SET_DEFFNM | (MASTER(cr) ? 0 : PCA_QUIET));
+    unsigned long PCA_Flags = PCA_CAN_SET_DEFFNM;
+    // With -multi or -multidir, the file names are going to get processed
+    // further (or the working directory changed), so we can't check for their
+    // existence during parsing.  It isn't useful to do any completion based on
+    // file system contents, either.
+    if (is_multisim_option_set(argc, argv))
+    {
+        PCA_Flags |= PCA_DISABLE_INPUT_FILE_CHECKING;
+    }
 
     /* Comment this in to do fexist calls only on master
      * works not with rerun or tables at the moment
@@ -614,7 +683,8 @@ int gmx_mdrun(int argc, char *argv[])
         gmx_bool bParFn = (multidir == NULL);
         init_multisystem(cr, nmultisim, multidir, NFILE, fnm, bParFn);
 #else
-        gmx_fatal(FARGS, "mdrun -multi is not supported with the thread library.Please compile GROMACS with MPI support");
+        gmx_fatal(FARGS, "mdrun -multi is not supported with the thread library. "
+                  "Please compile GROMACS with MPI support");
 #endif
     }
 
@@ -625,11 +695,6 @@ int gmx_mdrun(int argc, char *argv[])
     sim_part_fn = sim_part;
     if (opt2bSet("-cpi", NFILE, fnm))
     {
-        if (bSepPot && bAppendFiles)
-        {
-            gmx_fatal(FARGS, "Output file appending is not supported with -seppot");
-        }
-
         bAppendFiles =
             read_checkpoint_simulation_part(opt2fn_master("-cpi", NFILE,
                                                           fnm, cr),
@@ -684,8 +749,6 @@ int gmx_mdrun(int argc, char *argv[])
     }
 
     Flags = opt2bSet("-rerun", NFILE, fnm) ? MD_RERUN : 0;
-    Flags = Flags | (bSepPot       ? MD_SEPPOT       : 0);
-    Flags = Flags | (bPartDec      ? MD_PARTDEC      : 0);
     Flags = Flags | (bDDBondCheck  ? MD_DDBONDCHECK  : 0);
     Flags = Flags | (bDDBondComm   ? MD_DDBONDCOMM   : 0);
     Flags = Flags | (bTunePME      ? MD_TUNEPME      : 0);
@@ -698,24 +761,22 @@ int gmx_mdrun(int argc, char *argv[])
     Flags = Flags | (bKeepAndNumCPT ? MD_KEEPANDNUMCPT : 0);
     Flags = Flags | (sim_part > 1    ? MD_STARTFROMCPT : 0);
     Flags = Flags | (bResetCountersHalfWay ? MD_RESETCOUNTERSHALFWAY : 0);
-
+    Flags = Flags | (bIMDwait      ? MD_IMDWAIT      : 0);
+    Flags = Flags | (bIMDterm      ? MD_IMDTERM      : 0);
+    Flags = Flags | (bIMDpull      ? MD_IMDPULL      : 0);
 
     /* We postpone opening the log file if we are appending, so we can
        first truncate the old log file and append to the correct position
        there instead.  */
-    if ((MASTER(cr) || bSepPot) && !bAppendFiles)
+    if (MASTER(cr) && !bAppendFiles)
     {
         gmx_log_open(ftp2fn(efLOG, NFILE, fnm), cr,
-                     !bSepPot, Flags & MD_APPENDFILES, &fplog);
+                     Flags & MD_APPENDFILES, &fplog);
         please_cite(fplog, "Hess2008b");
         please_cite(fplog, "Spoel2005a");
         please_cite(fplog, "Lindahl2001a");
         please_cite(fplog, "Berendsen95a");
     }
-    else if (!MASTER(cr) && bSepPot)
-    {
-        gmx_log_open(ftp2fn(efLOG, NFILE, fnm), cr, !bSepPot, Flags, &fplog);
-    }
     else
     {
         fplog = NULL;
@@ -728,10 +789,10 @@ int gmx_mdrun(int argc, char *argv[])
     rc = mdrunner(&hw_opt, fplog, cr, NFILE, fnm, oenv, bVerbose, bCompact,
                   nstglobalcomm, ddxyz, dd_node_order, rdd, rconstr,
                   dddlb_opt[0], dlb_scale, ddcsx, ddcsy, ddcsz,
-                  nbpu_opt[0],
+                  nbpu_opt[0], nstlist,
                   nsteps, nstepout, resetstep,
                   nmultisim, repl_ex_nst, repl_ex_nex, repl_ex_seed,
-                  pforce, cpt_period, max_hours, deviceOptions, Flags);
+                  pforce, cpt_period, max_hours, deviceOptions, imdport, Flags);
 
     /* Log file has to be closed in mdrunner if we are appending to it
        (fplog not set here) */