Extend version checking/warnings for checkpoint continuation
authorRossen Apostolov <rossen@kth.se>
Thu, 19 Jun 2014 10:26:27 +0000 (12:26 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 24 Jun 2014 08:15:59 +0000 (10:15 +0200)
Detect if the major/minor versions differ, and write a more
explicit warning that both explains this type of continuation
is unsupported, and recommend to use the -noappend option.
In contrast, for cases where only the patch level differs,
we now only issue a note that the binary has changed, since
this is fully supported.

Fixes #1230.

Change-Id: Ifec509de0e5a05d170ada89fd000c961e311c9ca

src/gmxlib/checkpoint.c

index 142c46c8dea408405fb090cce0058303ac6ab88e..5e47db878656dcd1ad3d194187e9ad7da0cc9f24 100644 (file)
@@ -1010,7 +1010,7 @@ static int do_cpt_state(XDR *xd, gmx_bool bRead,
 
     if (bRead) /* we need to allocate space for dfhist if we are reading */
     {
-        init_df_history(&state->dfhist,state->dfhist.nlambda);
+        init_df_history(&state->dfhist, state->dfhist.nlambda);
     }
 
     /* We want the MC_RNG the same across all the notes for now -- lambda MC is global */
@@ -1699,11 +1699,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", 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(VERSION, "%d.%d", &gmx_major, &gmx_minor);
+        sscanf(version, "%d.%d", &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);
@@ -1736,16 +1751,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);
+            }
         }
     }
 }