Checkpoint

class Checkpoint

Checkpoint after user defined number of hours. Note that for OMP or parallel simulations, the number of hours is multiplied by the number of cores.

Public Functions

Checkpoint(argtype args = argtype())

args:

  • num_hours: Number of hours between printing of checkpoint file (default: 1).

  • num_hours_terminate: Terminate after this many hours. If -1, do not terminate (default: -1). Termination may be detected in Bash shell using “$? != 0”.

  • file_name: The default is one space (e.g., ” “). Do not checkpoint if file_name is empty or is one space.

  • writes_per_backup: Create a unique checkpoint file name every this many times that a checkpoint is written (default: -1). If -1, only backup the previous file by appending its name with “.bak”. Otherwise, if > 0, append each backup with an integer count beginning 0.

double num_hours() const

Return number of hours between writing file.

template<typename T>
void write(const T &obj, const std::string append_backup = ".bak") const

Write the checkpoint to file. If the file exists, create backup.

template<typename T>
void check(const T &obj)

Write object to file_name if num_hours has passed since previous.

template<typename T>
void read(T *obj)

Initialize object by reading from file.

void serialize(std::ostream &ostr) const

Serialize object.

Checkpoint(std::istream &istr)

Deserialize object.