aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-06-03 17:10:31 +0200
committerThomas White <taw@physics.org>2010-06-03 17:10:31 +0200
commit3d9b5eaae4e4d5308c78f257297fc869ea634b4f (patch)
tree48ca40b18317cd17c573fcc79e4ad0c7452f0f84
parent7d0973929be8086954359f614a7da7dea6c549c7 (diff)
pattern_sim: Configurable output filename
-rw-r--r--src/pattern_sim.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index cdc918b6..6a8a9299 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -50,6 +50,12 @@ static void show_help(const char *s)
" --near-bragg Output h,k,l,I near Bragg conditions.\n"
" -n, --number=<N> Generate N images. Default 1.\n"
" --no-images Do not output any HDF5 files.\n"
+" -o, --output=<filename> Output HDF5 filename. Default: sim.h5.\n"
+" If you choose to simulate more than one pattern,\n"
+" the filename given will be postfixed with a\n"
+" hyphen, the image number and '.h5'. In this\n"
+" case, the default value is 'sim', such that the\n"
+" files produced are sim-1.h5, sim-2.h5 and so on.\n"
" -r, --random-orientation Use a randomly generated orientation\n"
" (a new orientation will be used for each image).\n"
" --powder Write a summed pattern of all images simulated by\n"
@@ -171,6 +177,7 @@ int main(int argc, char *argv[])
int config_powder = 0;
char *filename = NULL;
char *grad_str = NULL;
+ char *outfile = NULL;
GradientMethod grad;
int ndone = 0; /* Number of simulations done (images or not) */
int number = 1; /* Number used for filename of image */
@@ -194,11 +201,12 @@ int main(int argc, char *argv[])
{"powder", 0, &config_powder, 1},
{"gradients", 1, NULL, 'g'},
{"pdb", 1, NULL, 'p'},
+ {"output", 1, NULL, 'o'},
{0, 0, NULL, 0}
};
/* Short options */
- while ((c = getopt_long(argc, argv, "hrn:i:g:p:", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hrn:i:g:p:o:", longopts, NULL)) != -1) {
switch (c) {
case 'h' : {
@@ -231,6 +239,11 @@ int main(int argc, char *argv[])
break;
}
+ case 'o' : {
+ outfile = strdup(optarg);
+ break;
+ }
+
case 0 : {
break;
}
@@ -246,6 +259,14 @@ int main(int argc, char *argv[])
filename = strdup("molecule.pdb");
}
+ if ( outfile == NULL ) {
+ if ( n_images == 1 ) {
+ outfile = strdup("sim.h5");
+ } else {
+ outfile = strdup("sim");
+ }
+ }
+
if ( config_simdetails ) {
show_details();
return 0;
@@ -386,7 +407,13 @@ int main(int argc, char *argv[])
char filename[1024];
- snprintf(filename, 1023, "results/sim-%i.h5", number);
+ if ( n_images != 1 ) {
+ snprintf(filename, 1023, "%s-%i.h5",
+ outfile, number);
+ } else {
+ strncpy(filename, outfile, 1023);
+ }
+
number++;
/* Write the output file */