create_command_line_snippets(bAppendFiles, bKeepAndNumCPT, bResetCountersHalfWay, presteps,
NFILE, fnm, &cmd_args_bench, &cmd_args_launch, ExtraArgs);
- /* Read in checkpoint file if requested */
+ /* Prepare to use checkpoint file if requested */
sim_part = 1;
if (opt2bSet("-cpi", NFILE, fnm))
{
- snew(cr, 1);
- cr->duty = DUTY_PP; /* makes the following routine happy */
- read_checkpoint_simulation_part(opt2fn("-cpi", NFILE, fnm),
- &sim_part, &cpt_steps, cr,
- FALSE, NFILE, fnm, NULL, NULL);
- sfree(cr);
- sim_part++;
- /* sim_part will now be 1 if no checkpoint file was found */
- if (sim_part <= 1)
+ const char *filename = opt2fn("-cpi", NFILE, fnm);
+ int cpt_sim_part;
+ read_checkpoint_part_and_step(filename,
+ &cpt_sim_part, &cpt_steps);
+ if (cpt_sim_part == 0)
{
- gmx_fatal(FARGS, "Checkpoint file %s not found!", opt2fn("-cpi", NFILE, fnm));
+ gmx_fatal(FARGS, "Checkpoint file %s could not be read!", filename);
}
+ /* tune_pme will run the next part of the simulation */
+ sim_part = cpt_sim_part + 1;
}
/* Open performance output file and write header info */
ir->simulation_part += 1;
}
+void read_checkpoint_part_and_step(const char *filename,
+ int *simulation_part,
+ gmx_int64_t *step)
+{
+ int file_version;
+ char *version, *btime, *buser, *bhost, *fprog, *ftime;
+ int double_prec;
+ int eIntegrator;
+ int nppnodes, npme;
+ ivec dd_nc;
+ int flags_eks, flags_enh, flags_dfh;
+ double t;
+ t_state state;
+ t_fileio *fp;
+
+ if (filename == NULL ||
+ !gmx_fexist(filename) ||
+ (!(fp = gmx_fio_open(filename, "r"))))
+ {
+ *simulation_part = 0;
+ *step = 0;
+ return;
+ }
+
+ /* Not calling initializing state before use is nasty, but all we
+ do is read into its member variables and throw the struct away
+ again immediately. */
+
+ do_cpt_header(gmx_fio_getxdr(fp), TRUE, &file_version,
+ &version, &btime, &buser, &bhost, &double_prec, &fprog, &ftime,
+ &eIntegrator, simulation_part, step, &t, &nppnodes, dd_nc, &npme,
+ &state.natoms, &state.ngtc, &state.nnhpres, &state.nhchainlength,
+ &(state.dfhist.nlambda), &state.flags, &flags_eks, &flags_enh, &flags_dfh,
+ &state.edsamstate.nED, &state.swapstate.eSwapCoords, NULL);
+
+ gmx_fio_close(fp);
+}
+
static void read_checkpoint_data(t_fileio *fp, int *simulation_part,
gmx_int64_t *step, double *t, t_state *state,
int *nfiles, gmx_file_position_t **outputfiles)
/* This routine cannot print tons of data, since it is called before the log file is opened. */
gmx_bool read_checkpoint_simulation_part(const char *filename, int *simulation_part,
- gmx_int64_t *cpt_step, t_commrec *cr,
+ t_commrec *cr,
gmx_bool bAppendReq,
int nfile, const t_filenm fnm[],
const char *part_suffix, gmx_bool *bAddPart)
gmx_bcast(sizeof(*bAddPart), bAddPart, cr);
}
}
- if (NULL != cpt_step)
- {
- *cpt_step = step;
- }
return bAppend;
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
/* Print the complete contents of checkpoint file fn to out */
void list_checkpoint(const char *fn, FILE *out);
+/* ! \brief Read simulation step and part from a checkpoint file
+ *
+ * Used by tune_pme to handle tuning with a checkpoint file as part of the input.
+ *
+ * \param[in] filename Name of checkpoint file
+ * \param[out] simulation_part The part of the simulation that wrote the checkpoint
+ * \param[out] step The final step number of the simulation that wrote the checkpoint
+ *
+ * The output variables will both contain 0 if filename is NULL, the file
+ * does not exist, or is not readable. */
+void read_checkpoint_part_and_step(const char *filename,
+ int *simulation_part,
+ gmx_int64_t *step);
+
/* Read just the simulation 'generation' and with bAppendReq check files.
* This is necessary already at the beginning of mdrun,
* to be able to rename the logfile correctly.
* needs to be added to the output file name.
*/
gmx_bool read_checkpoint_simulation_part(const char *filename, int *simulation_part,
- gmx_int64_t *step, t_commrec *cr,
+ t_commrec *cr,
gmx_bool bAppendReq,
int nfile, const t_filenm fnm[],
const char *part_suffix, gmx_bool *bAddPart);
bAppendFiles =
read_checkpoint_simulation_part(opt2fn_master("-cpi", NFILE,
fnm, cr),
- &sim_part_fn, NULL, cr,
+ &sim_part_fn, cr,
bAppendFiles, NFILE, fnm,
part_suffix, &bAddPart);
if (sim_part_fn == 0 && MULTIMASTER(cr))