Sort includes outside src/gromacs
[alexxy/gromacs.git] / src / programs / mdrun / mdrun.cpp
index 6bac3f08e7e6709a81be1606711027302cc034f8..b3df7ca4a826700b949550dada55fa7f3a213f51 100644 (file)
  * 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 "mdrun_main.h"
+#include "gmxpre.h"
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <stdio.h>
+#include <string.h>
 
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/filenm.h"
 #include "gromacs/legacyheaders/checkpoint.h"
 #include "gromacs/legacyheaders/copyrite.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/readinp.h"
 #include "gromacs/legacyheaders/typedefs.h"
 #include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/utility/fatalerror.h"
 
-#include "gromacs/commandline/pargs.h"
-#include "gromacs/fileio/filenm.h"
+#include "mdrun_main.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[])
 {
@@ -71,8 +83,7 @@ int gmx_mdrun(int argc, char *argv[])
         "The [TT]mdrun[tt] program reads the run input file ([TT]-s[tt])",
         "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 rank 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",
@@ -398,7 +409,7 @@ int gmx_mdrun(int argc, char *argv[])
     };
     t_commrec    *cr;
     t_filenm      fnm[] = {
-        { efTPX, NULL,      NULL,       ffREAD },
+        { efTPR, NULL,      NULL,       ffREAD },
         { efTRN, "-o",      NULL,       ffWRITE },
         { efCOMPRESSED, "-x", NULL,     ffOPTWR },
         { efCPT, "-cpi",    NULL,       ffOPTRD },
@@ -443,7 +454,6 @@ int gmx_mdrun(int argc, char *argv[])
     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;
@@ -553,8 +563,6 @@ int gmx_mdrun(int argc, char *argv[])
           "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 rank to the log file(s)" },
         { "-pforce",  FALSE, etREAL, {&pforce},
           "Print all forces larger than this (kJ/mol nm)" },
         { "-reprod",  FALSE, etBOOL, {&bReproducible},
@@ -596,7 +604,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;
@@ -607,10 +615,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
@@ -679,11 +694,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),
@@ -738,7 +748,6 @@ int gmx_mdrun(int argc, char *argv[])
     }
 
     Flags = opt2bSet("-rerun", NFILE, fnm) ? MD_RERUN : 0;
-    Flags = Flags | (bSepPot       ? MD_SEPPOT       : 0);
     Flags = Flags | (bDDBondCheck  ? MD_DDBONDCHECK  : 0);
     Flags = Flags | (bDDBondComm   ? MD_DDBONDCOMM   : 0);
     Flags = Flags | (bTunePME      ? MD_TUNEPME      : 0);
@@ -758,19 +767,15 @@ int gmx_mdrun(int argc, char *argv[])
     /* 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;