diff options
-rw-r--r-- | doc/man/partialator.1 | 5 | ||||
-rw-r--r-- | src/partialator.c | 58 | ||||
-rw-r--r-- | src/post-refinement.c | 52 | ||||
-rw-r--r-- | src/post-refinement.h | 12 |
4 files changed, 84 insertions, 43 deletions
diff --git a/doc/man/partialator.1 b/doc/man/partialator.1 index 9808c64b..7cd8df03 100644 --- a/doc/man/partialator.1 +++ b/doc/man/partialator.1 @@ -162,6 +162,11 @@ Write out the per-crystal parameters and reflection lists after every cycle of r Do not write the extensive log files needed for plotting contour maps and spectrum graphs. This makes the process a lot faster, but you probably do want these logs to check that post-refinement is working reasonably. .PD 0 +.IP \fB--log-folder=\fIfolder\fR +.PD +Specify the location of the log folder (see \fB--no-logs\fR). The default is \fB--log-folder=pr-logs\fR. + +.PD 0 .IP "\fB-w\fR \fIpg\fR" .PD Set the apparent symmetry of the crystals. The ambiguity operator will be determined by comparing this to the actual symmetry. diff --git a/src/partialator.c b/src/partialator.c index ca0249ce..35d1ff95 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -334,6 +334,7 @@ static void show_help(const char *s) " --custom-split List of files for custom dataset splitting.\n" " --max-rel-B Maximum allowable relative |B| factor.\n" " --no-logs Do not write extensive log files.\n" +" --log-folder=<fn> Location for log folder.\n" " -w <pg> Apparent point group for resolving ambiguities.\n" " --operator=<op> Indexing ambiguity operator for resolving.\n" " --force-bandwidth=<n> Set all bandwidths to <n> (fraction).\n" @@ -686,13 +687,14 @@ static void write_to_pgraph(FILE *fh, RefList *list, RefList *full, Crystal *cr, static void write_pgraph(RefList *full, Crystal **crystals, int n_crystals, - signed int iter, const char *suff) + signed int iter, const char *suff, + const char *log_folder) { FILE *fh; char tmp[256]; int i; - snprintf(tmp, 256, "pr-logs/pgraph%s.dat", suff); + snprintf(tmp, 256, "%s/pgraph%s.dat", log_folder, suff); if ( iter == 0 ) { fh = fopen(tmp, "w"); @@ -850,6 +852,7 @@ struct log_qargs int scaleflags; PartialityModel pmodel; int n_done; + const char *log_folder; }; @@ -861,6 +864,7 @@ struct log_args PartialityModel pmodel; int iter; int cnum; + const char *log_folder; }; @@ -880,6 +884,7 @@ static void *get_log_task(void *vp) task->cnum = qargs->next; task->scaleflags = qargs->scaleflags; task->pmodel = qargs->pmodel; + task->log_folder = qargs->log_folder; qargs->next += 20; return task; @@ -889,10 +894,12 @@ static void *get_log_task(void *vp) static void write_logs(void *vp, int cookie) { struct log_args *args = vp; - write_specgraph(args->cr, args->full, args->iter, args->cnum); + write_specgraph(args->cr, args->full, args->iter, args->cnum, + args->log_folder); write_gridscan(args->cr, args->full, args->iter, args->cnum, - args->scaleflags, args->pmodel); - write_test_logs(args->cr, args->full, args->iter, args->cnum); + args->scaleflags, args->pmodel, args->log_folder); + write_test_logs(args->cr, args->full, args->iter, args->cnum, + args->log_folder); } @@ -908,7 +915,8 @@ static void done_log(void *vqargs, void *vp) static void write_logs_parallel(Crystal **crystals, int n_crystals, RefList *full, int iter, int n_threads, - int scaleflags, PartialityModel pmodel) + int scaleflags, PartialityModel pmodel, + const char *log_folder) { struct log_qargs qargs; @@ -920,6 +928,7 @@ static void write_logs_parallel(Crystal **crystals, int n_crystals, qargs.n_crystals = n_crystals; qargs.scaleflags = scaleflags; qargs.pmodel = pmodel; + qargs.log_folder = log_folder; run_threads(n_threads, write_logs, get_log_task, done_log, &qargs, n_crystals/20, 0, 0, 0); @@ -1058,6 +1067,7 @@ int main(int argc, char *argv[]) int do_write_logs = 0; int no_deltacchalf = 0; char *harvest_file = NULL; + char *log_folder = "pr-logs"; /* Long options */ const struct option longopts[] = { @@ -1091,6 +1101,7 @@ int main(int argc, char *argv[]) {"no-polarisation", 0, NULL, 15}, {"no-polarization", 0, NULL, 15}, /* compat */ {"harvest-file", 1, NULL, 16}, + {"log-folder", 1, NULL, 17}, {"no-scale", 0, &no_scale, 1}, {"no-Bscale", 0, &no_Bscale, 1}, @@ -1280,6 +1291,10 @@ int main(int argc, char *argv[]) harvest_file = strdup(optarg); break; + case 17 : + log_folder = strdup(optarg); + break; + case 0 : break; @@ -1391,21 +1406,24 @@ int main(int argc, char *argv[]) } if ( do_write_logs ) { - int r = mkdir("pr-logs", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + int r = mkdir(log_folder, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if ( r ) { if ( errno == EEXIST ) { - ERROR("WARNING: pr-logs folder already exists. " - "Beware of mixing old and new log files!\n"); + ERROR("WARNING: Log folder (%s) already exists. " + "Beware of mixing old and new log files!\n", + log_folder); } else { - ERROR("Failed to create pr-logs folder.\n"); + ERROR("Failed to create log folder (%s).\n", + log_folder); return 1; } } } else { struct stat s; - if ( stat("pr-logs", &s) != -1 ) { - ERROR("WARNING: pr-logs folder exists, but I will not " - "write anything in it with these settings.\n"); + if ( stat(log_folder, &s) != -1 ) { + ERROR("WARNING: Log folder (%s) exists, but I will not " + "write anything in it with these settings.\n", + log_folder); } } @@ -1641,9 +1659,9 @@ int main(int argc, char *argv[]) show_all_residuals(crystals, n_crystals, full, no_free); if ( do_write_logs ) { - write_pgraph(full, crystals, n_crystals, 0, ""); + write_pgraph(full, crystals, n_crystals, 0, "", log_folder); write_logs_parallel(crystals, n_crystals, full, 0, nthreads, - scaleflags, pmodel); + scaleflags, pmodel, log_folder); } /* Iterate */ @@ -1653,7 +1671,8 @@ int main(int argc, char *argv[]) if ( !no_pr ) { refine_all(crystals, n_crystals, full, nthreads, pmodel, - itn+1, no_logs, sym, amb, scaleflags); + itn+1, no_logs, sym, amb, scaleflags, + log_folder); } /* Create new reference if needed */ @@ -1674,7 +1693,8 @@ int main(int argc, char *argv[]) show_all_residuals(crystals, n_crystals, full, no_free); if ( do_write_logs ) { - write_pgraph(full, crystals, n_crystals, itn+1, ""); + write_pgraph(full, crystals, n_crystals, itn+1, "", + log_folder); } if ( output_everycycle ) { @@ -1724,9 +1744,9 @@ int main(int argc, char *argv[]) /* Write final figures of merit (no rejection any more) */ show_all_residuals(crystals, n_crystals, full, no_free); if ( do_write_logs ) { - write_pgraph(full, crystals, n_crystals, -1, ""); + write_pgraph(full, crystals, n_crystals, -1, "", log_folder); write_logs_parallel(crystals, n_crystals, full, -1, nthreads, - scaleflags, pmodel); + scaleflags, pmodel, log_folder); } /* Output results */ diff --git a/src/post-refinement.c b/src/post-refinement.c index e5218094..70b14a0f 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -317,14 +317,15 @@ static void try_reindex(Crystal *crin, const RefList *full, void write_test_logs(Crystal *crystal, const RefList *full, - signed int cycle, int serial) + signed int cycle, int serial, + const char *log_folder) { FILE *fh; struct image *image = crystal_get_image(crystal); char tmp[256]; char ins[16]; - snprintf(tmp, 256, "pr-logs/parameters-crystal%i.dat", serial); + snprintf(tmp, 256, "%s/parameters-crystal%i.dat", log_folder, serial); if ( cycle == 0 ) { fh = fopen(tmp, "w"); @@ -367,7 +368,8 @@ void write_test_logs(Crystal *crystal, const RefList *full, void write_specgraph(Crystal *crystal, const RefList *full, - signed int cycle, int serial) + signed int cycle, int serial, + const char *log_folder) { FILE *fh; char tmp[256]; @@ -379,7 +381,7 @@ void write_specgraph(Crystal *crystal, const RefList *full, struct image *image = crystal_get_image(crystal); char ins[16]; - snprintf(tmp, 256, "pr-logs/specgraph-crystal%i.dat", serial); + snprintf(tmp, 256, "%s/specgraph-crystal%i.dat", log_folder, serial); if ( cycle == 0 ) { fh = fopen(tmp, "w"); @@ -443,7 +445,8 @@ void write_specgraph(Crystal *crystal, const RefList *full, static void write_angle_grid(Crystal *cr, const RefList *full, signed int cycle, int serial, int scaleflags, - PartialityModel pmodel) + PartialityModel pmodel, + const char *log_folder) { FILE *fh; char fn[64]; @@ -475,8 +478,8 @@ static void write_angle_grid(Crystal *cr, const RefList *full, ins[1] = '\0'; } - snprintf(fn, 64, "pr-logs/grid-crystal%i-cycle%s-ang1-ang2.dat", - serial, ins); + snprintf(fn, 64, "%s/grid-crystal%i-cycle%s-ang1-ang2.dat", + log_folder, serial, ins); fh = fopen(fn, "w"); if ( fh != NULL ) { double v1, v2; @@ -509,7 +512,8 @@ static void write_angle_grid(Crystal *cr, const RefList *full, static void write_radius_grid(Crystal *cr, const RefList *full, signed int cycle, int serial, int scaleflags, - PartialityModel pmodel) + PartialityModel pmodel, + const char *log_folder) { FILE *fh; char fn[64]; @@ -541,8 +545,8 @@ static void write_radius_grid(Crystal *cr, const RefList *full, ins[1] = '\0'; } - snprintf(fn, 64, "pr-logs/grid-crystal%i-cycle%s-R-wave.dat", - serial, ins); + snprintf(fn, 64, "%s/grid-crystal%i-cycle%s-R-wave.dat", + log_folder, serial, ins); fh = fopen(fn, "w"); if ( fh != NULL ) { double v1, v2; @@ -575,10 +579,11 @@ static void write_radius_grid(Crystal *cr, const RefList *full, void write_gridscan(Crystal *cr, const RefList *full, signed int cycle, int serial, int scaleflags, - PartialityModel pmodel) + PartialityModel pmodel, + const char *log_folder) { - write_angle_grid(cr, full, cycle, serial, scaleflags, pmodel); - write_radius_grid(cr, full, cycle, serial, scaleflags, pmodel); + write_angle_grid(cr, full, cycle, serial, scaleflags, pmodel, log_folder); + write_radius_grid(cr, full, cycle, serial, scaleflags, pmodel, log_folder); } @@ -647,7 +652,8 @@ static void zero_alter(struct rf_alteration *alter) static void do_pr_refine(Crystal *cr, const RefList *full, PartialityModel pmodel, int serial, int cycle, int write_logs, - SymOpList *sym, SymOpList *amb, int scaleflags) + SymOpList *sym, SymOpList *amb, int scaleflags, + const char *log_folder) { struct rf_priv priv; struct rf_alteration alter; @@ -684,7 +690,8 @@ static void do_pr_refine(Crystal *cr, const RefList *full, char fn[64]; - snprintf(fn, 63, "pr-logs/crystal%i-cycle%i.log", serial, cycle); + snprintf(fn, 63, "%s/crystal%i-cycle%i.log", + log_folder, serial, cycle); fh = fopen(fn, "w"); if ( fh != NULL ) { fprintf(fh, "iter FoM FreeFoM rotx/rad " @@ -722,9 +729,10 @@ static void do_pr_refine(Crystal *cr, const RefList *full, calculate_partialities(cr, pmodel); if ( write_logs ) { - write_gridscan(cr, full, cycle, serial, scaleflags, pmodel); - write_specgraph(cr, full, cycle, serial); - write_test_logs(cr, full, cycle, serial); + write_gridscan(cr, full, cycle, serial, scaleflags, + pmodel, log_folder); + write_specgraph(cr, full, cycle, serial, log_folder); + write_test_logs(cr, full, cycle, serial, log_folder); } if ( crystal_get_profile_radius(cr) > 5e9 ) { @@ -752,6 +760,7 @@ struct refine_args SymOpList *sym; SymOpList *amb; int scaleflags; + const char *log_folder; }; @@ -775,7 +784,8 @@ static void refine_image(void *task, int id) do_pr_refine(cr, pargs->full, pargs->pmodel, pargs->serial, pargs->cycle, write_logs, - pargs->sym, pargs->amb, pargs->scaleflags); + pargs->sym, pargs->amb, pargs->scaleflags, + pargs->log_folder); } @@ -810,7 +820,8 @@ static void done_image(void *vqargs, void *task) void refine_all(Crystal **crystals, int n_crystals, RefList *full, int nthreads, PartialityModel pmodel, int cycle, int no_logs, - SymOpList *sym, SymOpList *amb, int scaleflags) + SymOpList *sym, SymOpList *amb, int scaleflags, + const char *log_folder) { struct refine_args task_defaults; struct pr_queue_args qargs; @@ -824,6 +835,7 @@ void refine_all(Crystal **crystals, int n_crystals, task_defaults.amb = amb; task_defaults.scaleflags = scaleflags; task_defaults.serial = 0; + task_defaults.log_folder = log_folder; qargs.task_defaults = task_defaults; qargs.n_started = 0; diff --git a/src/post-refinement.h b/src/post-refinement.h index a15d0396..546050a4 100644 --- a/src/post-refinement.h +++ b/src/post-refinement.h @@ -61,20 +61,24 @@ extern const char *str_prflag(enum prflag flag); extern void refine_all(Crystal **crystals, int n_crystals, RefList *full, int nthreads, PartialityModel pmodel, int cycle, int no_logs, - SymOpList *sym, SymOpList *amb, int scaleflags); + SymOpList *sym, SymOpList *amb, int scaleflags, + const char *log_folder); extern void write_gridscan(Crystal *cr, const RefList *full, int cycle, int serial, int scaleflags, - PartialityModel model); + PartialityModel model, + const char *log_folder); extern void write_specgraph(Crystal *crystal, const RefList *full, - signed int cycle, int serial); + signed int cycle, int serial, + const char *log_folder); /* Exported so it can be poked by tests/pr_p_gradient_check */ extern double gradient(Crystal *cr, int k, Reflection *refl, PartialityModel pmodel); extern void write_test_logs(Crystal *crystal, const RefList *full, - signed int cycle, int serial); + signed int cycle, int serial, + const char *log_folder); #endif /* POST_REFINEMENT_H */ |