Use savefiles in uk

This commit is contained in:
2025-02-10 15:34:03 -05:00
parent 8a1f3987f4
commit 08ded444b8
3 changed files with 25 additions and 6 deletions

View File

@@ -48,7 +48,13 @@ int uk(
double print_freq,
double starting_time,
unsigned int nthreads,
FILE* savefile
FILE* savefile,
FILE* utfile,
// for interrupt recovery
const char* cmd_string,
const char* params_string,
const char* savefile_string,
const char* utfile_string
){
_Complex double* u;
_Complex double* tmp1;
@@ -95,7 +101,6 @@ int uk(
ns_step(algorithm, u, K1, K2, N1, N2, nu, &step, &next_step, adaptive_tolerance, adaptive_factor, max_delta, adaptive_cost, L, g, time, starting_time, fft1, fft2, ifft, &tmp1, &tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, irreversible, keep_en_cst, target_en);
time+=step;
step=next_step;
if(time>(n+1)*print_freq){
n++;
@@ -115,11 +120,25 @@ int uk(
fprintf(stderr,"\n");
printf("\n");
}
// get ready for next step
step=next_step;
// catch abort signal
if (g_abort){
break;
}
}
// TODO: update handling of savefile
// save final entry to savefile
write_vec_bin(u, K1, K2, savefile);
if(savefile!=NULL){
save_state(u, savefile, K1, K2, cmd_string, params_string, savefile_string, utfile_string, utfile, COMMAND_UK, algorithm, step, time, nthreads);
}
// save final u to utfile in txt format
if(utfile!=NULL){
write_vec(u, K1, K2, utfile);
}
ns_free_tmps(u, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, fft1, fft2, ifft, algorithm);
return(0);