Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
7e23e02a
Commit
7e23e02a
authored
7 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Patches
Plain Diff
Make saving previous collection of restart files an option
parent
a436e781
No related branches found
No related tags found
1 merge request
!501
Backup of restart files
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/parameter_example.yml
+1
-0
1 addition, 0 deletions
examples/parameter_example.yml
src/engine.c
+3
-0
3 additions, 0 deletions
src/engine.c
src/engine.h
+3
-0
3 additions, 0 deletions
src/engine.h
src/restart.c
+3
-3
3 additions, 3 deletions
src/restart.c
with
10 additions
and
3 deletions
examples/parameter_example.yml
+
1
−
0
View file @
7e23e02a
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
src/engine.c
+
3
−
0
View file @
7e23e02a
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/engine.h
+
3
−
0
View file @
7e23e02a
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
src/restart.c
+
3
−
3
View file @
7e23e02a
...
@@ -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
)
{
/*
B
ackup the existing restart file
. XXX configure this
. */
/*
Save a b
ackup 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.
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment