Merge branch origin/release-5-0
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / grompp.c
index b63ce1020f3155bbc7d11f9c3754c3e81b792767..345822e4127be4639c7182f9d1086de23fc880cf 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 "grompp.h"
+#include "gmxpre.h"
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "grompp.h"
 
-#include <sys/types.h>
-#include <math.h>
-#include <string.h>
+#include <assert.h>
 #include <errno.h>
 #include <limits.h>
-#include <assert.h>
+#include <math.h>
+#include <string.h>
+
+#include <sys/types.h>
 
-#include "sysstuff.h"
-#include "gromacs/utility/smalloc.h"
-#include "macros.h"
-#include "readir.h"
-#include "toputil.h"
-#include "topio.h"
-#include "gromacs/fileio/confio.h"
-#include "readir.h"
-#include "symtab.h"
-#include "names.h"
-#include "grompp-impl.h"
-#include "gromacs/random/random.h"
-#include "gromacs/gmxpreprocess/gen_maxwell_velocities.h"
-#include "vec.h"
-#include "gromacs/fileio/futil.h"
 #include "gromacs/commandline/pargs.h"
-#include "splitter.h"
-#include "gromacs/gmxpreprocess/sortwater.h"
-#include "convparm.h"
-#include "gmx_fatal.h"
-#include "warninp.h"
-#include "index.h"
+#include "gromacs/fileio/confio.h"
+#include "gromacs/fileio/enxio.h"
 #include "gromacs/fileio/gmxfio.h"
-#include "gromacs/fileio/trnio.h"
 #include "gromacs/fileio/tpxio.h"
+#include "gromacs/fileio/trnio.h"
 #include "gromacs/fileio/trxio.h"
-#include "vsite_parm.h"
-#include "txtdump.h"
-#include "calcgrid.h"
-#include "add_par.h"
-#include "gromacs/fileio/enxio.h"
-#include "perf_est.h"
-#include "compute_io.h"
-#include "gpp_atomtype.h"
-#include "mtop_util.h"
-#include "genborn.h"
-#include "calc_verletbuf.h"
-#include "tomorse.h"
+#include "gromacs/gmxpreprocess/add_par.h"
+#include "gromacs/gmxpreprocess/convparm.h"
+#include "gromacs/gmxpreprocess/gen_maxwell_velocities.h"
+#include "gromacs/gmxpreprocess/gpp_atomtype.h"
+#include "gromacs/gmxpreprocess/grompp-impl.h"
+#include "gromacs/gmxpreprocess/readir.h"
+#include "gromacs/gmxpreprocess/sortwater.h"
+#include "gromacs/gmxpreprocess/tomorse.h"
+#include "gromacs/gmxpreprocess/topio.h"
+#include "gromacs/gmxpreprocess/toputil.h"
+#include "gromacs/gmxpreprocess/vsite_parm.h"
 #include "gromacs/imd/imd.h"
+#include "gromacs/legacyheaders/calcgrid.h"
+#include "gromacs/legacyheaders/genborn.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/legacyheaders/perf_est.h"
+#include "gromacs/legacyheaders/splitter.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/warninp.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/mdlib/calc_verletbuf.h"
+#include "gromacs/mdlib/compute_io.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/random/random.h"
+#include "gromacs/topology/mtop_util.h"
+#include "gromacs/topology/symtab.h"
+#include "gromacs/topology/topology.h"
 #include "gromacs/utility/cstringutil.h"
-
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/snprintf.h"
 
 static int rm_interactions(int ifunc, int nrmols, t_molinfo mols[])
 {
@@ -405,6 +403,8 @@ static void check_shells_inputrec(gmx_mtop_t *mtop,
     }
 }
 
+/* TODO Decide whether this function can be consolidated with
+ * gmx_mtop_ftype_count */
 static gmx_bool nint_ftype(gmx_mtop_t *mtop, t_molinfo *mi, int ftype)
 {
     int nint, mb;
@@ -627,11 +627,21 @@ new_status(const char *topfile, const char *topppfile, const char *confin,
                     nmismatch, (nmismatch == 1) ? "" : "s", topfile, confin);
             warning(wi, buf);
         }
+
+        /* Do more checks, mostly related to constraints */
         if (bVerbose)
         {
             fprintf(stderr, "double-checking input for internal consistency...\n");
         }
-        double_check(ir, state->box, nint_ftype(sys, molinfo, F_CONSTR), wi);
+        {
+            int bHasNormalConstraints = 0 < (nint_ftype(sys, molinfo, F_CONSTR) +
+                                             nint_ftype(sys, molinfo, F_CONSTRNC));
+            int bHasAnyConstraints = bHasNormalConstraints || 0 < nint_ftype(sys, molinfo, F_SETTLE);
+            double_check(ir, state->box,
+                         bHasNormalConstraints,
+                         bHasAnyConstraints,
+                         wi);
+        }
     }
 
     if (bGenVel)
@@ -779,7 +789,7 @@ static void cont_status(const char *slog, const char *ener,
 
     /* Set the relative box lengths for preserving the box shape.
      * Note that this call can lead to differences in the last bit
-     * with respect to using gmx convert-tpr to create a [TT].tpx[tt] file.
+     * with respect to using gmx convert-tpr to create a [REF].tpx[ref] file.
      */
     set_box_rel(ir, state);
 
@@ -1426,30 +1436,27 @@ int gmx_grompp(int argc, char *argv[])
         "only the atom types are used for generating interaction parameters.[PAR]",
 
         "[THISMODULE] uses a built-in preprocessor to resolve includes, macros, ",
-        "etc. The preprocessor supports the following keywords:[PAR]",
-        "#ifdef VARIABLE[BR]",
-        "#ifndef VARIABLE[BR]",
-        "#else[BR]",
-        "#endif[BR]",
-        "#define VARIABLE[BR]",
-        "#undef VARIABLE[BR]"
-        "#include \"filename\"[BR]",
-        "#include <filename>[PAR]",
+        "etc. The preprocessor supports the following keywords::",
+        "",
+        "    #ifdef VARIABLE",
+        "    #ifndef VARIABLE",
+        "    #else",
+        "    #endif",
+        "    #define VARIABLE",
+        "    #undef VARIABLE",
+        "    #include \"filename\"",
+        "    #include <filename>",
+        "",
         "The functioning of these statements in your topology may be modulated by",
-        "using the following two flags in your [TT].mdp[tt] file:[PAR]",
-        "[TT]define = -DVARIABLE1 -DVARIABLE2[BR]",
-        "include = -I/home/john/doe[tt][BR]",
+        "using the following two flags in your [REF].mdp[ref] file::",
+        "",
+        "    define = -DVARIABLE1 -DVARIABLE2",
+        "    include = -I/home/john/doe",
+        "",
         "For further information a C-programming textbook may help you out.",
         "Specifying the [TT]-pp[tt] flag will get the pre-processed",
         "topology file written out so that you can verify its contents.[PAR]",
 
-        /* cpp has been unnecessary for some time, hasn't it?
-            "If your system does not have a C-preprocessor, you can still",
-            "use [TT]grompp[tt], but you do not have access to the features ",
-            "from the cpp. Command line options to the C-preprocessor can be given",
-            "in the [TT].mdp[tt] file. See your local manual (man cpp).[PAR]",
-         */
-
         "When using position restraints a file with restraint coordinates",
         "can be supplied with [TT]-r[tt], otherwise restraining will be done",
         "with respect to the conformation from the [TT]-c[tt] option.",
@@ -1462,7 +1469,7 @@ int gmx_grompp(int argc, char *argv[])
         "unless the [TT]-time[tt] option is used. Only if this information",
         "is absent will the coordinates in the [TT]-c[tt] file be used.",
         "Note that these velocities will not be used when [TT]gen_vel = yes[tt]",
-        "in your [TT].mdp[tt] file. An energy file can be supplied with",
+        "in your [REF].mdp[ref] file. An energy file can be supplied with",
         "[TT]-e[tt] to read Nose-Hoover and/or Parrinello-Rahman coupling",
         "variables.[PAR]",
 
@@ -1473,7 +1480,7 @@ int gmx_grompp(int argc, char *argv[])
         "You then supply the old checkpoint file directly to [gmx-mdrun]",
         "with [TT]-cpi[tt]. If you wish to change the ensemble or things",
         "like output frequency, then supplying the checkpoint file to",
-        "[THISMODULE] with [TT]-t[tt] along with a new [TT].mdp[tt] file",
+        "[THISMODULE] with [TT]-t[tt] along with a new [REF].mdp[ref] file",
         "with [TT]-f[tt] is the recommended procedure.[PAR]",
 
         "By default, all bonded interactions which have constant energy due to",
@@ -1536,7 +1543,7 @@ int gmx_grompp(int argc, char *argv[])
         { efNDX, NULL,  NULL,        ffOPTRD },
         { efTOP, NULL,  NULL,        ffREAD  },
         { efTOP, "-pp", "processed", ffOPTWR },
-        { efTPX, "-o",  NULL,        ffWRITE },
+        { efTPR, "-o",  NULL,        ffWRITE },
         { efTRN, "-t",  NULL,        ffOPTRD },
         { efEDR, "-e",  NULL,        ffOPTRD },
         /* This group is needed by the VMD viewer as the start configuration for IMD sessions: */
@@ -2028,9 +2035,9 @@ int gmx_grompp(int argc, char *argv[])
         }
     }
 
-    if (ir->ePull != epullNO)
+    if (ir->bPull)
     {
-        set_pull_init(ir, sys, state->x, state->box, state->lambda[efptMASS], oenv, opts->pull_start);
+        set_pull_init(ir, sys, state->x, state->box, state->lambda[efptMASS], oenv);
     }
 
     if (ir->bRot)
@@ -2086,7 +2093,7 @@ int gmx_grompp(int argc, char *argv[])
     }
 
     done_warning(wi, FARGS);
-    write_tpx_state(ftp2fn(efTPX, NFILE, fnm), ir, state, sys);
+    write_tpx_state(ftp2fn(efTPR, NFILE, fnm), ir, state, sys);
 
     /* Output IMD group, if bIMD is TRUE */
     write_IMDgroup_to_file(ir->bIMD, ir, state, sys, NFILE, fnm);