aboutsummaryrefslogtreecommitdiff
path: root/src/gui_ambi.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_ambi.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_ambi.c')
-rw-r--r--src/gui_ambi.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/gui_ambi.c b/src/gui_ambi.c
index 0535dd99..8d07f436 100644
--- a/src/gui_ambi.c
+++ b/src/gui_ambi.c
@@ -509,8 +509,47 @@ int write_ambigator_script(const char *filename,
}
fprintf(fh, " --iterations=%i", params->niter);
- fprintf(fh, " --fg-graph=fg.dat\n");
+ fprintf(fh, " --fg-graph=fg.dat");
+ fprintf(fh, " >stdout.log 2>stderr.log\n");
fclose(fh);
return 0;
}
+
+
+double read_ambigator_progress(char *logfile_str, int niter)
+{
+ FILE *fh;
+ double iter_inc;
+ double frac_complete = 0.0;
+
+ iter_inc = 0.8/niter;
+
+ fh = fopen(logfile_str, "r");
+ if ( fh == NULL ) return 0.0;
+
+ do {
+ char line[1024];
+ int junk;
+
+ if ( fgets(line, 1024, fh) == NULL ) break;
+
+ if ( strncmp(line, "Mean number of correlations per crystal:", 40) == 0 ) {
+ frac_complete = 0.1;
+ }
+ if ( strncmp(line, "Mean f,g =", 10) == 0 ) {
+ frac_complete += iter_inc;
+ }
+ if ( sscanf(line, "%d assignments are different from "
+ "their starting values\n", &junk) == 1 )
+ {
+ frac_complete = 1.0;
+ }
+
+ } while ( 1 );
+
+ fclose(fh);
+
+ printf("got %f\n", frac_complete);
+ return frac_complete;
+}