Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian.jauslin@rutgers.edu>2023-04-26 17:20:38 -0400
committerIan Jauslin <ian.jauslin@rutgers.edu>2023-04-26 17:20:38 -0400
commit4436866d2f9b2a3b12e1ebf81df22e5e03cebd6c (patch)
treeeb968ff368c60b5e7df696f95109dc369ed4d349
parenta94c066014fe460e2823dee83debf71d6a8a8f24 (diff)
Write resume command even when computation concludes
-rw-r--r--src/navier-stokes.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/navier-stokes.c b/src/navier-stokes.c
index f0c31ed..bab2710 100644
--- a/src/navier-stokes.c
+++ b/src/navier-stokes.c
@@ -159,36 +159,35 @@ int eea(
if (savefile==NULL){
savefile=stderr;
}
-
- fprintf(savefile,"# Interrupted computation. Resume with\n");
- // command to resume
- fprintf(savefile,"#! ");
-
- fprintf(savefile, cmd_string);
-
- // params
- // allocate buffer for params
- if(params_string!=NULL) {
- char* params=calloc(sizeof(char), strlen(params_string)+1);
- strcpy(params, params_string);
- remove_entry(params, "starting_time");
- remove_entry(params, "init");
- remove_entry(params, "nsteps");
- fprintf(savefile," -p \"%s;starting_time=%lu;nsteps=%lu;init=file:%s\"", params, t+1, (nsteps == 0 ? 0 : nsteps-t-1), savefile_string);
- free(params);
- }
-
- fprintf(savefile," energy\n");
-
break;
}
}
- // save final entry to savefile
- if(savefile==stderr || savefile==stdout){
- write_vec(u, K1, K2, savefile);
- } else {
- write_vec_bin(u, K1, K2, savefile);
+ if(savefile!=NULL){
+ fprintf(savefile,"# Continue computation with\n");
+
+ // command to resume
+ fprintf(savefile,"#! ");
+ fprintf(savefile, cmd_string);
+ // params
+ // allocate buffer for params
+ if(params_string!=NULL) {
+ char* params=calloc(sizeof(char), strlen(params_string)+1);
+ strcpy(params, params_string);
+ remove_entry(params, "starting_time");
+ remove_entry(params, "init");
+ remove_entry(params, "nsteps");
+ fprintf(savefile," -p \"%s;starting_time=%lu;nsteps=%lu;init=file:%s\"", params, t+1, (nsteps < t+1 ? 0 : nsteps-t-1), savefile_string);
+ free(params);
+ }
+ fprintf(savefile," energy\n");
+
+ // save final u to savefile
+ if(savefile==stderr || savefile==stdout){
+ write_vec(u, K1, K2, savefile);
+ } else {
+ write_vec_bin(u, K1, K2, savefile);
+ }
}
ns_free_tmps(u, tmp1, tmp2, tmp3, fft1, fft2, ifft);