aboutsummaryrefslogtreecommitdiff
path: root/src/gui_merge.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_merge.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_merge.c')
-rw-r--r--src/gui_merge.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/gui_merge.c b/src/gui_merge.c
index 762c7e95..cb00b330 100644
--- a/src/gui_merge.c
+++ b/src/gui_merge.c
@@ -402,7 +402,7 @@ static int write_partialator_script(const char *filename,
fprintf(fh, " --iterations=%i", params->niter);
- fprintf(fh, "\n");
+ fprintf(fh, " >stdout.log 2>stderr.log\n");
fclose(fh);
return 0;
@@ -437,7 +437,7 @@ static void add_process_hkl(FILE *fh,
fprintf(fh, " --max-adu=%f", params->max_adu);
fprintf(fh, " --min-res=%f", params->min_res);
fprintf(fh, " --push-res=%f", params->push_res);
- fprintf(fh, " %s\n", extra_arg);
+ fprintf(fh, " %s >>stdout.log 2>>stderr.log\n", extra_arg);
}
@@ -480,3 +480,47 @@ int write_merge_script(const char *filename,
params, out_hkl);
}
}
+
+
+double read_merge_progress(char *logfile_str, enum gui_job_type type)
+{
+ FILE *fh;
+ double frac_complete = 0.0;
+
+ fh = fopen(logfile_str, "r");
+ if ( fh == NULL ) return 0.0;
+
+ do {
+ char line[1024];
+
+ if ( fgets(line, 1024, fh) == NULL ) break;
+
+ if ( type == GUI_JOB_PROCESS_HKL ) {
+ frac_complete += 1.0/3.0;
+ } else if ( type == GUI_JOB_PROCESS_HKL_SCALE ) {
+ frac_complete += 1.0/6.0;
+ } else {
+ int cycle, max_cycles;
+ assert(type == GUI_JOB_PARTIALATOR);
+ if ( strcmp(line, "Initial partiality calculation...\n") == 0 ) {
+ frac_complete = 0.1;
+ }
+ if ( sscanf(line, "Scaling and refinement cycle %d of %d\n",
+ &cycle, &max_cycles) == 2 )
+ {
+ frac_complete = 0.1 + 0.8*(double)cycle/max_cycles;
+ }
+ if ( strcmp(line, "Final merge...\n") == 0 ) {
+ frac_complete = 0.9;
+ }
+ if ( strncmp(line, "Writing two-way split", 20) == 0 ) {
+ frac_complete = 1.0;
+ }
+
+ }
+ } while ( 1 );
+
+ fclose(fh);
+
+ return frac_complete;
+}