From 7a1e9a3bace1a882fc846cde90216343eddca66d Mon Sep 17 00:00:00 2001 From: Rossen Apostolov Date: Thu, 19 Jun 2014 12:26:27 +0200 Subject: [PATCH] Extend version checking/warnings for checkpoint continuation 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 | 62 +++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/src/gmxlib/checkpoint.c b/src/gmxlib/checkpoint.c index 142c46c8de..5e47db8786 100644 --- a/src/gmxlib/checkpoint.c +++ b/src/gmxlib/checkpoint.c @@ -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); + } } } } -- 2.22.0