Gromacs  2018.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
handlerestart.cpp File Reference
#include "gmxpre.h"
#include "handlerestart.h"
#include <string.h>
#include "gromacs/commandline/filenm.h"
#include "gromacs/fileio/checkpoint.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/mdlib/main.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
+ Include dependency graph for handlerestart.cpp:

Description

This file declares functions for mdrun to call to manage the details of doing a restart (ie. reading checkpoints, appending output files).

Todo:
Clean up the error-prone logic here. Add doxygen.
Author
Berk Hess hess@.nosp@m.kth..nosp@m.se
Erik Lindahl erik@.nosp@m.kth..nosp@m.se
Mark Abraham mark..nosp@m.j.ab.nosp@m.raham.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Functions

static gmx_bool exist_output_file (const char *fnm_cp, int nfile, const t_filenm fnm[])
 Search for fnm_cp in fnm and return true iff found. More...
 
static void read_checkpoint_data (const char *filename, int *simulation_part, t_commrec *cr, gmx_bool bTryToAppendFiles, int nfile, const t_filenm fnm[], const char *part_suffix, gmx_bool *bAddPart, bool *bDoAppendFiles)
 Support handling restarts. More...
 
void handleRestart (t_commrec *cr, gmx_bool bTryToAppendFiles, const int NFILE, t_filenm fnm[], bool *bDoAppendFiles, bool *bStartFromCpt)
 Handle startup of mdrun, particularly regarding -cpi and -append. More...
 

Function Documentation

static gmx_bool exist_output_file ( const char *  fnm_cp,
int  nfile,
const t_filenm  fnm[] 
)
static

Search for fnm_cp in fnm and return true iff found.

Todo:
This could be implemented sanely with a for loop.
void handleRestart ( t_commrec *  cr,
gmx_bool  bTryToAppendFiles,
const int  NFILE,
t_filenm  fnm[],
bool *  bDoAppendFiles,
bool *  bStartFromCpt 
)

Handle startup of mdrun, particularly regarding -cpi and -append.

If there is a checkpoint file, then prepare to start from that state. If restarting from a checkpoint file and appending is requested with tryToAppendFiles, we will set doAppendFiles to true on return if all files were found correctly. If some files are not found when appending should be done, we will instead issue a fatal error to avoid unintentional problems.

If there is no checkpoint file, we assume it is the first part of a new run, and in this case we silently set doAppendFiles to false on return.

On return, fnm is updated with suffix strings for part numbers if we are doing a restart from checkpoint and are not appending. The routine also does communication to coordinate behaviour between all ranks of a simulation, and/or simulations.

Parameters
[in]crCommunication structure
[in]bTryToAppendFilesWhether appending is requested (from mdrun)
[in]NFILESize of fnm struct
[in,out]fnmFilename parameters to mdrun
[out]bDoAppendFilesTrue on return if we will do appending. Note that the routine will generate a fatal error for some scenarios where appending is requested but the necessary files not found.
[out]bStartFromCptTrue on return if we found the checkpoint and will use it to restart.
static void read_checkpoint_data ( const char *  filename,
int *  simulation_part,
t_commrec *  cr,
gmx_bool  bTryToAppendFiles,
int  nfile,
const t_filenm  fnm[],
const char *  part_suffix,
gmx_bool bAddPart,
bool *  bDoAppendFiles 
)
static

Support handling restarts.

Todo:
Clean this up (next patch)

Read just the simulation 'generation' and with bTryToAppendFiles check files. This is is needed at the beginning of mdrun, to be able to rename the logfile correctly. When file appending is requested, checks which output files are present, and issue a fatal error if some are not. Upon return, bAddPart will tell whether the simulation part needs to be added to the output file name, i.e. when we are doing checkpoint continuation without appending.

This routine cannot print tons of data, since it is called before the log file is opened.