From df26c722cdcc68f4b3dcc09976ad0075b8e65537 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 27 Feb 2018 16:48:23 +0100 Subject: partialator: Tidy up old log files, and add --no-logs --- src/partialator.c | 70 +++++++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 41 deletions(-) (limited to 'src/partialator.c') diff --git a/src/partialator.c b/src/partialator.c index 760af036..d548e956 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -325,7 +326,8 @@ static void show_help(const char *s) " -j Run analyses in parallel.\n" " --no-free Disable cross-validation (testing only).\n" " --custom-split List of files for custom dataset splitting.\n" -" --max-rel-B Maximum allowable relative |B| factor.\n"); +" --max-rel-B Maximum allowable relative |B| factor.\n" +" --no-logs Do not write extensive log files.\n"); } @@ -738,35 +740,6 @@ static void show_all_residuals(Crystal **crystals, int n_crystals, } -static void dump_parameters(const char *filename, Crystal **crystals, - int n_crystals) -{ - FILE *fh; - fh = fopen(filename, "w"); - if ( fh == NULL ) { - ERROR("Couldn't open partialator.params!\n"); - } else { - fprintf(fh, " cr OSF relB div" - " flag filename event\n"); - int i; - for ( i=0; ievent); - fprintf(fh, "%4i %10.5f %10.2f %8.5e %-25s %s %s\n", - i, crystal_get_osf(crystals[i]), - crystal_get_Bfac(crystals[i])*1e20, - crystal_get_image(crystals[i])->div, - str_prflag(crystal_get_user_flag(crystals[i])), - img->filename, evt_str); - free(evt_str); - } - fclose(fh); - } -} - - struct log_qargs { int iter; @@ -878,6 +851,7 @@ int main(int argc, char *argv[]) double max_B = 1e-18; char *rfile = NULL; RefList *reference = NULL; + int no_logs = 0; /* Long options */ const struct option longopts[] = { @@ -910,6 +884,7 @@ int main(int argc, char *argv[]) {"polarization", 0, &polarisation, 1}, /* compat */ {"no-free", 0, &no_free, 1}, {"output-every-cycle", 0, &output_everycycle, 1}, + {"no-logs", 0, &no_logs, 1}, {0, 0, NULL, 0} }; @@ -1084,7 +1059,22 @@ int main(int argc, char *argv[]) if ( (pmodel == PMODEL_UNITY) && !no_pr ) { no_pr = 1; - STATUS("Setting --no-pr because we are not modelling partialities (--model=unity).\n"); + STATUS("Setting --no-pr because we are not modelling " + "partialities (--model=unity).\n"); + } + + if ( !no_logs ) { + int r = mkdir("pr-logs", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + if ( r ) { + if ( errno == EEXIST ) { + ERROR("A folder called 'pr-logs' exists in the " + "working directory.\n"); + ERROR("Please delete or move it first.\n"); + } else { + ERROR("Failed to create pr-logs folder.\n"); + } + return 1; + } } /* Read the custom split list (if applicable) */ @@ -1263,7 +1253,9 @@ int main(int argc, char *argv[]) check_rejection(crystals, n_crystals, full, max_B); show_all_residuals(crystals, n_crystals, full); write_pgraph(full, crystals, n_crystals, 0, ""); - if ( !no_pr ) write_logs_parallel(crystals, n_crystals, full, 0, nthreads); + if ( !no_pr && !no_logs ) { + write_logs_parallel(crystals, n_crystals, full, 0, nthreads); + } /* Iterate */ for ( i=0; i