From 7fe6325a02cb86dfbc513e93fa8ee8165deb509a Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Fri, 26 Jan 2018 17:28:01 +0100 Subject: [PATCH] Quiet checkpoint reading If reading succeeds, it should write anything of interest to the log file. If it does not, it should make a fatal error. Code here might be run as part of mdrun (possibly in a multi-simulation), or grompp, or compare, or dump, or eventually from an API caller, so we can't make assumptions about what should be reported to a terminal. Removed support for issuing a warning about restarting from very old checkpoint formats, instead issuing a fatal error. Elsewhere, we anyway observe that checkpoint restarts across major version differences are not supported. Change-Id: Id2b084bf0792a6992931609fb78d4a38a5f255fe --- src/gromacs/fileio/checkpoint.cpp | 63 ++++++++++++++------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/src/gromacs/fileio/checkpoint.cpp b/src/gromacs/fileio/checkpoint.cpp index fc7c7c4c1a..20a100e645 100644 --- a/src/gromacs/fileio/checkpoint.cpp +++ b/src/gromacs/fileio/checkpoint.cpp @@ -596,7 +596,6 @@ static int doVectorLow(XDR *xd, StatePart part, int ecpt, int sflags, { gmx_fatal(FARGS, "Type %s: incompatible checkpoint formats or corrupted checkpoint file.", buf); } - fprintf(stderr, "Precision %s\n", buf); } T *vp; @@ -2025,30 +2024,36 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep, static void check_int(FILE *fplog, const char *type, int p, int f, gmx_bool *mm) { - FILE *fp = fplog ? fplog : stderr; - - if (p != f) + bool foundMismatch = (p != f); + if (!foundMismatch) + { + return; + } + *mm = TRUE; + if (fplog) { - fprintf(fp, " %s mismatch,\n", type); - fprintf(fp, " current program: %d\n", p); - fprintf(fp, " checkpoint file: %d\n", f); - fprintf(fp, "\n"); - *mm = TRUE; + fprintf(fplog, " %s mismatch,\n", type); + fprintf(fplog, " current program: %d\n", p); + fprintf(fplog, " checkpoint file: %d\n", f); + fprintf(fplog, "\n"); } } static void check_string(FILE *fplog, const char *type, const char *p, const char *f, gmx_bool *mm) { - FILE *fp = fplog ? fplog : stderr; - - if (std::strcmp(p, f) != 0) + bool foundMismatch = (std::strcmp(p, f) != 0); + if (!foundMismatch) { - fprintf(fp, " %s mismatch,\n", type); - fprintf(fp, " current program: %s\n", p); - fprintf(fp, " checkpoint file: %s\n", f); - fprintf(fp, "\n"); - *mm = TRUE; + return; + } + *mm = TRUE; + if (fplog) + { + fprintf(fplog, " %s mismatch,\n", type); + fprintf(fplog, " current program: %s\n", p); + fprintf(fplog, " checkpoint file: %s\n", f); + fprintf(fplog, "\n"); } } @@ -2070,7 +2075,6 @@ static void check_match(FILE *fplog, const t_commrec *cr, const ivec dd_nc, const char msg_precision_difference[] = "You are continuing a simulation with a different precision. Not matching\n" "single/double precision will lead to precision or performance loss.\n"; - fprintf(stderr, "%s\n", msg_precision_difference); if (fplog) { fprintf(fplog, "%s\n", msg_precision_difference); @@ -2136,13 +2140,8 @@ static void check_match(FILE *fplog, const t_commrec *cr, const ivec dd_nc, "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 (majorVersionDiffers) { - fprintf(stderr, "%s%s\n", msg_major_version_difference, fplog ? msg_logdetails : ""); - if (fplog) { fprintf(fplog, "%s\n", msg_major_version_difference); @@ -2151,7 +2150,6 @@ static void check_match(FILE *fplog, const t_commrec *cr, const ivec dd_nc, else if (reproducibilityRequested) { /* 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); @@ -2200,12 +2198,6 @@ static void read_checkpoint(const char *fn, FILE **pfplog, gmx_fatal(FARGS, "Output file appending requested, but the code and checkpoint file precision (single/double) don't match"); } - if (cr == nullptr || MASTER(cr)) - { - fprintf(stderr, "\nReading checkpoint file %s generated: %s\n\n", - fn, headerContents->ftime); - } - /* This will not be written if we do appending, since fplog is still NULL then */ if (fplog) { @@ -2293,15 +2285,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog, if (headerContents->file_version < 6) { - const char *warn = "Reading checkpoint file in old format, assuming that the run that generated this file started at step 0, if this is not the case the averages stored in the energy file will be incorrect."; - - fprintf(stderr, "\nWARNING: %s\n\n", warn); - if (fplog) - { - fprintf(fplog, "\nWARNING: %s\n\n", warn); - } - observablesHistory->energyHistory->nsum = headerContents->step; - observablesHistory->energyHistory->nsum_sim = headerContents->step; + gmx_fatal(FARGS, "Continuing from checkpoint files written before GROMACS 4.5 is not supported"); } ret = do_cpt_df_hist(gmx_fio_getxdr(fp), headerContents->flags_dfh, headerContents->nlambda, &state->dfhist, nullptr); @@ -2420,7 +2404,6 @@ static void read_checkpoint(const char *fn, FILE **pfplog, } else { - fprintf(stderr, "\nNOTE: File locking is not supported on this system, will not lock %s\n\n", outputfile.filename); if (fplog) { fprintf(fplog, "\nNOTE: File locking not supported on this system, will not lock %s\n\n", outputfile.filename); -- 2.11.4.GIT