diff options
author | Thomas White <taw@physics.org> | 2021-07-15 15:13:03 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-07-15 17:05:05 +0200 |
commit | c5a89386f273473954ec5f9e460052c175236c16 (patch) | |
tree | 897babdf9e14812de44260bc5305e55ea4823b7a /src/gui_merge.c | |
parent | 81071755af6d46edd21735ecd749b72695629f11 (diff) |
GUI: Run all jobs with same CWD as GUI itself
This requires changing all the paths to relative ones.
Previously, the jobs ran with their CWDs set to the corresponding
"result" folder. The trouble is, this breaks everything that uses a
relative location: image filenames, mask/satmap files referenced by the
geometry, etc.
Note that this change also means that the temporary folders
("indexamajig.XXX") are now produced in the top-level working directory.
Eventually, a GUI option should be added to allow these folders to be
put somewhere better (i.e. somewhere fast).
Closes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/44
Diffstat (limited to 'src/gui_merge.c')
-rw-r--r-- | src/gui_merge.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src/gui_merge.c b/src/gui_merge.c index bef6d7b7..b911fa5a 100644 --- a/src/gui_merge.c +++ b/src/gui_merge.c @@ -349,7 +349,10 @@ static int write_partialator_script(const char *filename, struct gui_indexing_result *input, const char *n_thread_str, struct merging_params *params, - const char *out_hkl) + const char *out_hkl, + const char *stdout_filename, + const char *stderr_filename, + const char *harvest_filename) { FILE *fh; char *exe_path; @@ -365,7 +368,7 @@ static int write_partialator_script(const char *filename, fprintf(fh, "%s \\\n", exe_path); for ( i=0; i<input->n_streams; i++ ) { - fprintf(fh, "\"../%s\" \\\n", input->streams[i]); + fprintf(fh, "\"%s\" \\\n", input->streams[i]); } fprintf(fh, " --model=%s", params->model); @@ -405,9 +408,9 @@ static int write_partialator_script(const char *filename, } fprintf(fh, " --iterations=%i", params->niter); - fprintf(fh, " --harvest-file=parameters.json"); + fprintf(fh, " --harvest-file=%s", harvest_filename); - fprintf(fh, " >stdout.log 2>stderr.log\n"); + fprintf(fh, " >%s 2>%s\n", stdout_filename, stderr_filename); fclose(fh); return 0; @@ -419,6 +422,8 @@ static void add_process_hkl(FILE *fh, struct gui_indexing_result *input, struct merging_params *params, const char *out_hkl, + const char *stdout_filename, + const char *stderr_filename, const char *extra_arg, const char *out_suffix) { @@ -427,7 +432,7 @@ static void add_process_hkl(FILE *fh, fprintf(fh, "%s \\\n", exe_path); for ( i=0; i<input->n_streams; i++ ) { - fprintf(fh, " \"../%s\" \\\n", input->streams[i]); + fprintf(fh, " \"%s\" \\\n", input->streams[i]); } fprintf(fh, " -o \"%s%s\"", out_hkl, out_suffix); @@ -442,14 +447,17 @@ 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 >>stdout.log 2>>stderr.log\n", extra_arg); + fprintf(fh, " %s >>%s 2>>%s\n", + extra_arg, stdout_filename, stderr_filename); } static int write_process_hkl_script(const char *filename, struct gui_indexing_result *input, struct merging_params *params, - const char *out_hkl) + const char *out_hkl, + const char *stdout_filename, + const char *stderr_filename) { FILE *fh; char *exe_path; @@ -462,9 +470,12 @@ static int write_process_hkl_script(const char *filename, exe_path = get_crystfel_exe("process_hkl"); if ( exe_path == NULL ) return 1; - add_process_hkl(fh, exe_path, input, params, out_hkl, "", ""); - add_process_hkl(fh, exe_path, input, params, out_hkl, "--even-only", "1"); - add_process_hkl(fh, exe_path, input, params, out_hkl, "--odd-only", "2"); + add_process_hkl(fh, exe_path, input, params, out_hkl, + stdout_filename, stderr_filename, "", ""); + add_process_hkl(fh, exe_path, input, params, out_hkl, + stdout_filename, stderr_filename, "--even-only", "1"); + add_process_hkl(fh, exe_path, input, params, out_hkl, + stdout_filename, stderr_filename, "--odd-only", "2"); fclose(fh); return 0; @@ -475,14 +486,22 @@ int write_merge_script(const char *filename, struct gui_indexing_result *input, const char *n_thread_str, struct merging_params *params, - const char *out_hkl) + const char *out_hkl, + const char *stdout_filename, + const char *stderr_filename, + const char *harvest_filename) { if ( strcmp(params->model, "process_hkl") == 0 ) { return write_process_hkl_script(filename, input, - params, out_hkl); + params, out_hkl, + stdout_filename, + stderr_filename); } else { return write_partialator_script(filename, input, n_thread_str, - params, out_hkl); + params, out_hkl, + stdout_filename, + stderr_filename, + harvest_filename); } } |