From cc42a8ac8d210527411ce811eb960264d4d8ad1e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 8 Jul 2015 10:22:50 +0200 Subject: pattern_sim: Add check for HDF5 references This trips *everyone* up. --- src/pattern_sim.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/pattern_sim.c b/src/pattern_sim.c index f9d8126d..bd97ead7 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -223,6 +223,27 @@ static int random_ncells(double len, double min_m, double max_m) } +static void fixup_geom(struct detector *det) +{ + int i; + + for ( i=0; in_panels; i++ ) { + det->panels[i].clen += det->panels[i].coffset; + } +} + + +static int geom_contains_references(struct detector *det) +{ + int i; + + for ( i=0; in_panels; i++ ) { + if ( det->panels[i].clen_from != NULL ) return 1; + } + return 0; +} + + int main(int argc, char *argv[]) { int c; @@ -554,6 +575,13 @@ int main(int argc, char *argv[]) ERROR("The value given on the command line " "(with --photon-energy) will be used instead.\n"); } + if ( geom_contains_references(image.det) ) { + ERROR("Geometry file contains a reference to an HDF5 location" + " for the camera length. Change it to a numerical value " + " and try again.\n"); + return 1; + } + fixup_geom(image.det); if ( spectrum_str == NULL ) { STATUS("You didn't specify a spectrum type, so" -- cgit v1.2.3