Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / checkpoint.cpp
index 5cb9a23cdc827fc8abe7417e04b0969fb62f47ce..05edae309621284e92bdac2e981c4e7284c056b0 100644 (file)
@@ -1780,11 +1780,26 @@ static void check_match(FILE *fplog,
                         ivec dd_nc, ivec dd_nc_f)
 {
     int      npp;
-    gmx_bool mm;
-
-    mm = FALSE;
+    gmx_bool mm                 = FALSE;
+    gmx_bool patchlevel_differs = FALSE;
+    gmx_bool version_differs    = FALSE;
 
     check_string(fplog, "Version", gmx_version(), version, &mm);
+    patchlevel_differs = mm;
+
+    if (patchlevel_differs)
+    {
+        /* Gromacs should be able to continue from checkpoints between
+         * different patch level versions, but we do not guarantee
+         * compatibility between different major/minor versions - check this.
+         */
+        int   gmx_major, gmx_minor;
+        int   cpt_major, cpt_minor;
+        sscanf(gmx_version(), "VERSION %5d.%5d", &gmx_major, &gmx_minor);
+        sscanf(version, "VERSION %5d.%5d", &cpt_major, &cpt_minor);
+        version_differs = (gmx_major != cpt_major || gmx_minor != cpt_minor);
+    }
+
     check_string(fplog, "Build time", BUILD_TIME, btime, &mm);
     check_string(fplog, "Build user", BUILD_USER, buser, &mm);
     check_string(fplog, "Build host", BUILD_HOST, bhost, &mm);
@@ -1811,16 +1826,39 @@ static void check_match(FILE *fplog,
 
     if (mm)
     {
-        fprintf(stderr,
-                "Gromacs binary or parallel settings not identical to previous run.\n"
-                "Continuation is exact, but is not guaranteed to be binary identical%s.\n\n",
-                fplog ? ",\n see the log file for details" : "");
+        const char msg_version_difference[] =
+            "The current Gromacs major & minor version are not identical to those that\n"
+            "generated the checkpoint file. In principle Gromacs does not support\n"
+            "continuation from checkpoints between different versions, so we advise\n"
+            "against this. If you still want to try your luck we recommend that you use\n"
+            "the -noappend flag to keep your output files from the two versions separate.\n"
+            "This might also work around errors where the output fields in the energy\n"
+            "file have changed between the different major & minor versions.\n";
 
-        if (fplog)
+        const char msg_mismatch_notice[] =
+            "Gromacs patchlevel, binary or parallel settings differ from previous run.\n"
+            "Continuation is exact, but not guaranteed to be binary identical.\n";
+
+        const char msg_logdetails[] =
+            "See the log file for details.\n";
+
+        if (version_differs)
         {
-            fprintf(fplog,
-                    "Gromacs binary or parallel settings not identical to previous run.\n"
-                    "Continuation is exact, but is not guaranteed to be binary identical.\n\n");
+            fprintf(stderr, "%s%s\n", msg_version_difference, fplog ? msg_logdetails : "");
+
+            if (fplog)
+            {
+                fprintf(fplog, "%s\n", msg_version_difference);
+            }
+        }
+        else
+        {
+            /* Major & minor versions match at least, but something is different. */
+            fprintf(stderr, "%s%s\n", msg_mismatch_notice, fplog ? msg_logdetails : "");
+            if (fplog)
+            {
+                fprintf(fplog, "%s\n", msg_mismatch_notice);
+            }
         }
     }
 }
@@ -2579,7 +2617,7 @@ gmx_bool read_checkpoint_simulation_part(const char *filename, int *simulation_p
                     }
                     fprintf(stderr, "\n");
 
-                    gmx_fatal(FARGS, "File appending requested, but only %d of the %d output files are present", nexist, nfiles);
+                    gmx_fatal(FARGS, "File appending requested, but %d of the %d output files are not present or are named differently", nfiles-nexist, nfiles);
                 }
             }