aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/indexers
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-07-21 13:26:37 +0200
committerThomas White <taw@physics.org>2021-07-21 15:34:33 +0200
commit7e5536832b22036a634a74e16073b4762a416e29 (patch)
tree25799eb139d235f524a80c53fb25d0c9f64eb6f1 /libcrystfel/src/indexers
parent760f17f56b7f79f67a9029cbe7cc55a0acccd3b9 (diff)
Reduce variable scope where possible
Diffstat (limited to 'libcrystfel/src/indexers')
-rw-r--r--libcrystfel/src/indexers/asdf.c21
-rw-r--r--libcrystfel/src/indexers/felix.c2
-rw-r--r--libcrystfel/src/indexers/fromfile.c3
-rw-r--r--libcrystfel/src/indexers/mosflm.c5
-rw-r--r--libcrystfel/src/indexers/xds.c2
5 files changed, 22 insertions, 11 deletions
diff --git a/libcrystfel/src/indexers/asdf.c b/libcrystfel/src/indexers/asdf.c
index 7030a3e7..a1f8f50d 100644
--- a/libcrystfel/src/indexers/asdf.c
+++ b/libcrystfel/src/indexers/asdf.c
@@ -364,7 +364,7 @@ static float find_ds_fft(double *projections, int N_projections, double d_max,
memcpy(projections_sorted, projections, sizeof(double) * n);
qsort(projections_sorted, n, sizeof(double), compare_doubles);
- int i, k;
+ int i;
int N = fftw.N; // number of points in fft calculation
double *in = fftw.in;
@@ -376,6 +376,7 @@ static float find_ds_fft(double *projections, int N_projections, double d_max,
}
for ( i=0; i<n; i++ ) {
+ int k;
k = (int)((projections_sorted[i] - projections_sorted[0]) /
(projections_sorted[n - 1] - projections_sorted[0]) *
(N - 1));
@@ -394,8 +395,8 @@ static float find_ds_fft(double *projections, int N_projections, double d_max,
int d = 1;
double max = 0;
- double a;
for ( i=1; i<=i_max; i++ ) {
+ double a;
a = sqrt(out[i][0] * out[i][0] + out[i][1] * out[i][1]);
if (a > max) {
max = a;
@@ -581,8 +582,6 @@ static int refine_asdf_cell(struct asdf_cell *c, gsl_vector **reflections,
static int reduce_asdf_cell(struct asdf_cell *cl)
{
- double a, b, c, alpha, beta, gamma, ab, bc, ca, bb, cc;
-
gsl_vector *va = gsl_vector_alloc(3);
gsl_vector *vb = gsl_vector_alloc(3);
gsl_vector *vc = gsl_vector_alloc(3);
@@ -591,6 +590,9 @@ static int reduce_asdf_cell(struct asdf_cell *cl)
int n = 0;
while ( changed ) {
+
+ double a, b, c, alpha, beta, gamma, ab, bc, ca;
+
n += 1;
changed = 0;
@@ -612,6 +614,8 @@ static int reduce_asdf_cell(struct asdf_cell *cl)
if ( changed == 0 ) {
+ double bb;
+
if ( gamma < 90 ) {
gsl_vector_scale(vb, -1);
gamma = 180 - gamma;
@@ -634,6 +638,8 @@ static int reduce_asdf_cell(struct asdf_cell *cl)
if ( changed == 0 ) {
+ double cc;
+
if ( beta < 90 ) {
gsl_vector_scale(vc, -1);
beta = 180 - beta;
@@ -659,6 +665,9 @@ static int reduce_asdf_cell(struct asdf_cell *cl)
}
if ( changed == 0 ) {
+
+ double cc;
+
if ( alpha < 90 ) {
gsl_vector_scale(vc, -1);
beta = 180 - beta;
@@ -901,10 +910,12 @@ static int **generate_triplets(int N_reflections, int N_triplets_max, int *N)
return 0;
}
- int is_in_triplets;
n = 0;
while ( n < N_triplets ) {
+
+ int is_in_triplets;
+
/* Generate three different integer numbers < N_reflections */
i = rand() % N_reflections;
j = i;
diff --git a/libcrystfel/src/indexers/felix.c b/libcrystfel/src/indexers/felix.c
index b7d2a8a3..db7da8c4 100644
--- a/libcrystfel/src/indexers/felix.c
+++ b/libcrystfel/src/indexers/felix.c
@@ -131,7 +131,6 @@ static int read_felix(struct felix_private *gp, struct image *image,
float mean_ia;
int ngv;
char line[1024];
- int r;
int n_crystals = 0;
fh = fopen(filename, "r");
@@ -151,6 +150,7 @@ static int read_felix(struct felix_private *gp, struct image *image,
Crystal *cr;
UnitCell *cell;
+ int r;
/* One line per grain */
if ( fgets( line, 1024, fh ) == NULL ) {
diff --git a/libcrystfel/src/indexers/fromfile.c b/libcrystfel/src/indexers/fromfile.c
index d7dfbd09..1716dd66 100644
--- a/libcrystfel/src/indexers/fromfile.c
+++ b/libcrystfel/src/indexers/fromfile.c
@@ -228,7 +228,6 @@ void *fromfile_prepare(IndexingMethod *indm, struct fromfile_options *opts)
float vals[11];
struct fromfile_key key;
Crystal *cr;
- UnitCell *cell;
size_t len;
int n_sp;
struct fromfile_entry *item = NULL;
@@ -286,6 +285,8 @@ void *fromfile_prepare(IndexingMethod *indm, struct fromfile_options *opts)
} else {
+ UnitCell *cell;
+
cr = crystal_new();
/* mm -> m */
diff --git a/libcrystfel/src/indexers/mosflm.c b/libcrystfel/src/indexers/mosflm.c
index 129e6859..e77f6384 100644
--- a/libcrystfel/src/indexers/mosflm.c
+++ b/libcrystfel/src/indexers/mosflm.c
@@ -481,7 +481,6 @@ static char *mosflm_spacegroup_for_lattice(UnitCell *cell)
static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm)
{
char tmp[256];
- char cen;
double wavelength;
double a = 0, b = 0, c = 0, alpha = 0, beta = 0, gamma = 0;
@@ -548,6 +547,7 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm)
case 9 :
if ( mosflm->mp->indm & INDEXING_USE_CELL_PARAMETERS ) {
+ char cen;
cell_get_parameters(mosflm->mp->template,
&a, &b, &c, &alpha, &beta, &gamma);
cen = cell_get_centering(mosflm->mp->template);
@@ -886,9 +886,8 @@ const char *mosflm_probe(UnitCell *cell)
fh = fdopen(pty, "r");
for ( l=0; l<10; l++ ) {
- char *pos;
if ( fgets(line, 1024, fh) != NULL ) {
- pos = strstr(line, "Mosflm version ");
+ char *pos = strstr(line, "Mosflm version ");
if ( pos != NULL ) ok = 1;
}
}
diff --git a/libcrystfel/src/indexers/xds.c b/libcrystfel/src/indexers/xds.c
index 3936f791..8ef496cf 100644
--- a/libcrystfel/src/indexers/xds.c
+++ b/libcrystfel/src/indexers/xds.c
@@ -523,8 +523,8 @@ const char *xds_probe(UnitCell *cell)
fh = fdopen(pty, "r");
for ( l=0; l<10; l++ ) {
- char *pos;
if ( fgets(line, 1024, fh) != NULL ) {
+ char *pos;
pos = strstr(line, "** XDS **");
if ( pos != NULL ) {
ok = 1;