From bda480005b278f82800d830d133d4cdba4ea5d97 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 4 May 2018 13:46:10 +0200 Subject: Put list of indexing methods into stream header Needed for when the methods are auto-determined. --- libcrystfel/src/stream.c | 20 +++++++++++++++++--- libcrystfel/src/stream.h | 3 +++ src/indexamajig.c | 20 ++++++++++---------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index db6c6199..47661946 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -1499,12 +1499,13 @@ static void write_cell_to_stream(Stream *st, UnitCell *cell) /** - * open_stream_for_write_3 + * open_stream_for_write_4 * @filename: Filename of new stream * @geom_filename: The geometry filename to copy * @cell: A %UnitCell to write into the stream * @argc: The number of arguments to the program * @argv: The arguments to the program + * @indm_str: The list of indexing methods * * Creates a new stream with name @filename, and adds the stream format * and version header, plus a verbatim copy of the geometry file and the unit @@ -1512,9 +1513,9 @@ static void write_cell_to_stream(Stream *st, UnitCell *cell) * * Returns: a %Stream, or NULL on failure. */ -Stream *open_stream_for_write_3(const char *filename, +Stream *open_stream_for_write_4(const char *filename, const char *geom_filename, UnitCell *cell, - int argc, char *argv[]) + int argc, char *argv[], const char *indm_str) { Stream *st; @@ -1542,6 +1543,10 @@ Stream *open_stream_for_write_3(const char *filename, if ( (argc > 0) && (argv != NULL) ) { write_command(st, argc, argv); } + + if ( indm_str != NULL ) { + fprintf(st->fh, "Indexing methods selected: %s\n", indm_str); + } if ( geom_filename != NULL ) { write_geometry_file(st, geom_filename); } @@ -1553,6 +1558,15 @@ Stream *open_stream_for_write_3(const char *filename, } +Stream *open_stream_for_write_3(const char *filename, + const char *geom_filename, UnitCell *cell, + int argc, char *argv[]) +{ + return open_stream_for_write_4(filename, geom_filename, cell, + argc, argv, NULL); +} + + /** * open_stream_for_write_2 * @filename: Filename of new stream diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h index b50da832..a8e3e2ee 100644 --- a/libcrystfel/src/stream.h +++ b/libcrystfel/src/stream.h @@ -99,6 +99,9 @@ extern Stream *open_stream_for_write_2(const char *filename, extern Stream *open_stream_for_write_3(const char *filename, const char* geom_filename, UnitCell *cell, int argc, char *argv[]); +extern Stream *open_stream_for_write_4(const char *filename, + const char *geom_filename, UnitCell *cell, + int argc, char *argv[], const char *indm_str); extern Stream *open_stream_fd_for_write(int fd); extern int get_stream_fd(Stream *st); extern void close_stream(Stream *st); diff --git a/src/indexamajig.c b/src/indexamajig.c index 3cfe2c6e..97ab2725 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -959,15 +959,6 @@ int main(int argc, char *argv[]) } - /* Open output stream */ - st = open_stream_for_write_3(outfile, geom_filename, iargs.cell, - argc, argv); - if ( st == NULL ) { - ERROR("Failed to open stream '%s'\n", outfile); - return 1; - } - free(outfile); - if ( indm_str == NULL ) { STATUS("No indexing methods specified. I will try to "); @@ -1039,10 +1030,19 @@ int main(int argc, char *argv[]) ERROR("Failed to set up indexing system\n"); return 1; } - free(indm_str); } + /* Open output stream */ + st = open_stream_for_write_4(outfile, geom_filename, iargs.cell, + argc, argv, indm_str); + if ( st == NULL ) { + ERROR("Failed to open stream '%s'\n", outfile); + return 1; + } + free(outfile); + free(indm_str); + gsl_set_error_handler_off(); create_sandbox(&iargs, n_proc, prefix, config_basename, fh, -- cgit v1.2.3