aboutsummaryrefslogtreecommitdiff
path: root/src/indexamajig.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-10-01 12:20:11 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:00 +0100
commitce045961f4d1cee94b98cbb8580141b20bb0a00f (patch)
tree9310c120031ad2e924dda45e5f33e5cd9fe4990d /src/indexamajig.c
parentc5dc4b204fab4dfd4a33ff4e2e299f407e9561f9 (diff)
indexamajig: Take output stream as a command line parameter
Diffstat (limited to 'src/indexamajig.c')
-rw-r--r--src/indexamajig.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 0fa1e8a1..2f25d58a 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -44,7 +44,6 @@ struct process_args
/* Input */
char *filename;
int id;
- pthread_mutex_t *output_mutex; /* Protects stdout */
pthread_mutex_t *gpu_mutex; /* Protects "gctx" */
UnitCell *cell;
int config_cmfilter;
@@ -76,6 +75,10 @@ struct process_args
int done;
int indexable;
int sane;
+
+ /* Output stream */
+ pthread_mutex_t *output_mutex; /* Protects the output stream */
+ FILE *ofh;
};
@@ -365,7 +368,7 @@ static void process_image(struct process_args *pargs)
output_intensities(&image, image.indexed_cell,
pargs->output_mutex, config_polar,
pargs->config_sa, pargs->config_closer,
- 0, 0.1);
+ pargs->ofh, 0, 0.1);
}
simage = get_simage(&image, config_alternate);
@@ -439,7 +442,9 @@ int main(int argc, char *argv[])
int c;
struct gpu_context *gctx = NULL;
char *filename = NULL;
+ char *outfile = NULL;
FILE *fh;
+ FILE *ofh;
char *rval = NULL;
int n_images;
int n_indexable;
@@ -486,6 +491,7 @@ int main(int argc, char *argv[])
const struct option longopts[] = {
{"help", 0, NULL, 'h'},
{"input", 1, NULL, 'i'},
+ {"output", 1, NULL, 'o'},
{"gpu", 0, &config_gpu, 1},
{"no-index", 0, &config_noindex, 1},
{"dump-peaks", 0, &config_dumpfound, 1},
@@ -514,7 +520,7 @@ int main(int argc, char *argv[])
};
/* Short options */
- while ((c = getopt_long(argc, argv, "hi:wp:j:x:g:t:",
+ while ((c = getopt_long(argc, argv, "hi:wp:j:x:g:t:o:",
longopts, NULL)) != -1) {
switch (c) {
@@ -526,6 +532,10 @@ int main(int argc, char *argv[])
filename = strdup(optarg);
break;
+ case 'o' :
+ outfile = strdup(optarg);
+ break;
+
case 'z' :
indm_str = strdup(optarg);
break;
@@ -584,6 +594,20 @@ int main(int argc, char *argv[])
}
free(filename);
+ if ( outfile == NULL ) {
+ outfile = strdup("-");
+ }
+ if ( strcmp(outfile, "-") == 0 ) {
+ ofh = stdout;
+ } else {
+ ofh = fopen(outfile, "w");
+ }
+ if ( ofh == NULL ) {
+ ERROR("Failed to open output file '%s'\n", outfile);
+ return 1;
+ }
+ free(outfile);
+
if ( intfile != NULL ) {
ReflItemList *items;
items = read_reflections(intfile, intensities,
@@ -674,6 +698,7 @@ int main(int argc, char *argv[])
for ( i=0; i<nthreads; i++ ) {
worker_args[i] = malloc(sizeof(struct process_args));
worker_args[i]->filename = malloc(1024);
+ worker_args[i]->ofh = ofh;
worker_active[i] = 0;
}