aboutsummaryrefslogtreecommitdiff
path: root/src/gui_index.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-02-22 15:56:40 +0100
committerThomas White <taw@physics.org>2021-02-22 15:56:40 +0100
commitf7cef79ae1c8db2770f067735698850ef88da04e (patch)
treed4891f091ffb1051a917559f9d365d6e97023f0e /src/gui_index.c
parent32ee8110102b2c939c3fcc966a41587d1bb9d316 (diff)
Read job progress from written log files, even for local BE
This simplifies the backends somewhat, and makes them look more similar - e.g. there is now only one routine to find out how far along a merging job is. It has the added bonus of adding a log file for local jobs, which we would've had to add soon anyway.
Diffstat (limited to 'src/gui_index.c')
-rw-r--r--src/gui_index.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gui_index.c b/src/gui_index.c
index 68c89ca2..50b360f0 100644
--- a/src/gui_index.c
+++ b/src/gui_index.c
@@ -771,3 +771,29 @@ char **indexamajig_command_line(const char *geom_filename,
args[n_args] = NULL;
return args;
}
+
+
+int read_number_processed(const char *filename)
+{
+ FILE *fh = fopen(filename, "r");
+ int n_proc;
+
+ /* Normal situation if SLURM job hasn't started yet */
+ if ( fh == NULL ) return 0;
+
+ do {
+ char line[1024];
+ if ( fgets(line, 1024, fh) == NULL ) break;
+
+ if ( strncmp(line, "Final: ", 7) == 0 ) {
+ sscanf(line, "Final: %i images processed", &n_proc);
+ } else if ( strstr(line, " images processed, ") != NULL ) {
+ sscanf(line, "%i ", &n_proc);
+ }
+
+ } while ( 1 );
+
+ fclose(fh);
+
+ return n_proc;
+}