Skip to content
Snippets Groups Projects
Commit 7e23e02a authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Make saving previous collection of restart files an option

parent a436e781
No related branches found
No related tags found
1 merge request!501Backup of restart files
...@@ -78,6 +78,7 @@ InitialConditions: ...@@ -78,6 +78,7 @@ InitialConditions:
# Parameters controlling restarts # Parameters controlling restarts
Restarts: Restarts:
enable: 1 # (Optional) whether to enable dumping restarts at fixed intervals. enable: 1 # (Optional) whether to enable dumping restarts at fixed intervals.
save: 1 # (Optional) whether to save copies of the previous set of restart files (named .prev)
onexit: 0 # (Optional) whether to dump restarts on exit (*needs enable*) onexit: 0 # (Optional) whether to dump restarts on exit (*needs enable*)
subdir: restart # (Optional) name of subdirectory for restart files. subdir: restart # (Optional) name of subdirectory for restart files.
basename: swift # (Optional) prefix used in naming restart files. basename: swift # (Optional) prefix used in naming restart files.
......
...@@ -5569,6 +5569,9 @@ void engine_config(int restart, struct engine *e, ...@@ -5569,6 +5569,9 @@ void engine_config(int restart, struct engine *e,
/* Whether restarts are enabled. Yes by default. Can be changed on restart. */ /* Whether restarts are enabled. Yes by default. Can be changed on restart. */
e->restart_dump = parser_get_opt_param_int(params, "Restarts:enable", 1); e->restart_dump = parser_get_opt_param_int(params, "Restarts:enable", 1);
/* Whether to save backup copies of the previous restart files. */
e->restart_save = parser_get_opt_param_int(params, "Restarts:save", 1);
/* Whether restarts should be dumped on exit. Not by default. Can be changed /* Whether restarts should be dumped on exit. Not by default. Can be changed
* on restart. */ * on restart. */
e->restart_onexit = parser_get_opt_param_int(params, "Restarts:onexit", 0); e->restart_onexit = parser_get_opt_param_int(params, "Restarts:onexit", 0);
......
...@@ -296,6 +296,9 @@ struct engine { ...@@ -296,6 +296,9 @@ struct engine {
/* Whether to dump restart files. */ /* Whether to dump restart files. */
int restart_dump; int restart_dump;
/* Whether to save previous generation of restart files. */
int restart_save;
/* Whether to dump restart files after the last step. */ /* Whether to dump restart files after the last step. */
int restart_onexit; int restart_onexit;
......
...@@ -128,8 +128,8 @@ void restart_locate_free(int nfiles, char **files) { ...@@ -128,8 +128,8 @@ void restart_locate_free(int nfiles, char **files) {
*/ */
void restart_write(struct engine *e, const char *filename) { void restart_write(struct engine *e, const char *filename) {
/* Backup the existing restart file. XXX configure this. */ /* Save a backup the existing restart file, if requested. */
restart_save_previous(filename); if (e->restart_save) restart_save_previous(filename);
FILE *stream = fopen(filename, "w"); FILE *stream = fopen(filename, "w");
if (stream == NULL) if (stream == NULL)
...@@ -289,7 +289,7 @@ int restart_stop_now(const char *dir, int cleanup) { ...@@ -289,7 +289,7 @@ int restart_stop_now(const char *dir, int cleanup) {
/** /**
* @brief check if a file with the given name exists and rename to * @brief check if a file with the given name exists and rename to
* <filename>.prev. Used to move old restart files before overwriting. * {filename}.prev. Used to move old restart files before overwriting.
* *
* Does nothing if the file does not exist. * Does nothing if the file does not exist.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment