aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2014-03-31 14:42:13 +0200
committerThomas White <taw@physics.org>2014-09-05 18:03:30 +0200
commitf5513fcb51d0d027bb7d5e1e2db95fae480c3a86 (patch)
tree4fa2da0a733ac7491258f1f62acd609b494681d8
parent6b889daf0d737c7c921ba80818b0b008e4de86af (diff)
Changed code to use the hdf5_write_image instead of the deprecated hd5_write
-rw-r--r--src/pattern_sim.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index 8568dc5f..2cbb616e 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -221,7 +221,8 @@ int main(int argc, char *argv[])
int c;
struct image image;
struct gpu_context *gctx = NULL;
- double *powder;
+ struct image *powder;
+ float *powder_data;
char *intfile = NULL;
double *intensities;
char *rval;
@@ -586,7 +587,12 @@ int main(int argc, char *argv[])
gsl_rng_set(rng, seed);
}
- powder = calloc(image.width*image.height, sizeof(*powder));
+ powder = calloc(1, sizeof(struct image));
+ powder->width = image.width;
+ powder->height = image.height;
+ powder->det = image.det;
+ powder_data = calloc(image.width*image.height, sizeof(float));
+ powder->data = powder_data;
/* Splurge a few useful numbers */
STATUS("Wavelength is %f nm\n", image.lambda/1.0e-9);
@@ -725,14 +731,12 @@ int main(int argc, char *argv[])
for ( x=0; x<image.width; x++ ) {
for ( y=0; y<image.height; y++ ) {
- powder[x+w*y] += (double)image.data[x+w*y];
+ powder->data[x+w*y] += (double)image.data[x+w*y];
}
}
if ( !(ndone % 10) ) {
- hdf5_write(powder_fn, powder,
- image.width, image.height,
- H5T_NATIVE_DOUBLE);
+ hdf5_write_image(powder_fn, powder, NULL);
}
}
@@ -749,7 +753,7 @@ int main(int argc, char *argv[])
number++;
- /* Write the output file */
+ /* Write the output file */
hdf5_write_image(filename, &image, NULL);
}
@@ -768,9 +772,7 @@ skip:
} while ( !done );
if ( powder_fn != NULL ) {
- hdf5_write(powder_fn, powder,
- image.width, image.height,
- H5T_NATIVE_DOUBLE);
+ hdf5_write_image(powder_fn, powder, NULL);
}
if ( gctx != NULL ) {
@@ -780,6 +782,7 @@ skip:
free(image.det->panels);
free(image.det);
free(image.beam);
+ free(powder->data);
free(powder);
cell_free(input_cell);
free(intensities);