Gromacs
2025-dev-20240913-b871546
|
Classes | |
class | StartingBehaviorHandler |
Describes how mdrun will (re)start and provides supporting functionality based on that data. More... | |
Functions | |
gmx_bool | exist_output_file (const std::filesystem::path &fnm_cp, int nfile, const t_filenm fnm[]) |
Search for fnm_cp in fnm and return true iff found. More... | |
void | throwBecauseOfMissingOutputFiles (const std::filesystem::path &checkpointFilename, ArrayRef< const gmx_file_position_t > outputfiles, int nfile, const t_filenm fnm[], size_t numFilesMissing) |
Throw when mdrun -cpi fails because previous output files are missing. More... | |
const char * | precisionToString (bool isDoublePrecision) |
Return a string describing the precision of a build of GROMACS. | |
StartingBehaviorHandler | chooseStartingBehavior (const AppendingBehavior appendingBehavior, const int nfile, t_filenm fnm[]) |
Choose the starting behaviour for this simulation. More... | |
void | checkOutputFile (t_fileio *fileToCheck, const gmx_file_position_t &outputfile) |
Check whether chksum_file output file has a checksum that matches outputfile from the checkpoint. | |
void | lockLogFile (t_fileio *logfio, const std::filesystem::path &logFilename) |
If supported, obtain a write lock on the log file. More... | |
void | prepareForAppending (const ArrayRef< const gmx_file_position_t > outputFiles, t_fileio *logfio) |
Prepare to append to output files. More... | |
StartingBehaviorHandler gmx::anonymous_namespace{handlerestart.cpp}::chooseStartingBehavior | ( | const AppendingBehavior | appendingBehavior, |
const int | nfile, | ||
t_filenm | fnm[] | ||
) |
Choose the starting behaviour for this simulation.
This routine cannot print tons of data, since it is called before the log file is opened.
Note that different simulations in a multi-simulation can return values that depend on whether the respective checkpoint files are found (and other files found, when appending), and so can differ between multi-simulations. It is the caller's responsibility to detect this and react accordingly.
gmx_bool gmx::anonymous_namespace{handlerestart.cpp}::exist_output_file | ( | const std::filesystem::path & | fnm_cp, |
int | nfile, | ||
const t_filenm | fnm[] | ||
) |
Search for fnm_cp
in fnm and return true iff found.
void gmx::anonymous_namespace{handlerestart.cpp}::lockLogFile | ( | t_fileio * | logfio, |
const std::filesystem::path & | logFilename | ||
) |
If supported, obtain a write lock on the log file.
This wil prevent e.g. other mdrun instances from changing it while we attempt to restart with appending.
void gmx::anonymous_namespace{handlerestart.cpp}::prepareForAppending | ( | const ArrayRef< const gmx_file_position_t > | outputFiles, |
t_fileio * | logfio | ||
) |
Prepare to append to output files.
We use the file pointer positions of the output files stored in the checkpoint file and truncate the files such that any frames written after the checkpoint time are removed. All files are md5sum checked such that we can be sure that we do not truncate other (maybe important) files. The log file is locked so that we can avoid cases where another mdrun instance might still be writing to the file.
void gmx::anonymous_namespace{handlerestart.cpp}::throwBecauseOfMissingOutputFiles | ( | const std::filesystem::path & | checkpointFilename, |
ArrayRef< const gmx_file_position_t > | outputfiles, | ||
int | nfile, | ||
const t_filenm | fnm[], | ||
size_t | numFilesMissing | ||
) |
Throw when mdrun -cpi fails because previous output files are missing.
If we get here, the user requested restarting from a checkpoint file, that checkpoint file was found (so it is not the first part of a new run), but we are still missing some or all checkpoint files. In this case we issue a fatal error since there are so many special cases we cannot keep track of, and better safe than sorry.