From e81e335daf509166fc234c8835203a80d5b21e0d Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 19 Nov 2015 17:02:32 +0100 Subject: Maximum number of iterations for scaling --- src/scaling.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/scaling.c b/src/scaling.c index 05e741ca..77a64384 100644 --- a/src/scaling.c +++ b/src/scaling.c @@ -403,6 +403,7 @@ void scale_all(Crystal **crystals, int n_crystals, int nthreads, struct scale_args task_defaults; struct queue_args qargs; double old_res, new_res; + int niter = 0; task_defaults.crystal = NULL; task_defaults.pmodel = pmodel; @@ -447,6 +448,11 @@ void scale_all(Crystal **crystals, int n_crystals, int nthreads, STATUS("Mean B = %e\n", meanB); reflist_free(full); + niter++; - } while ( fabs(new_res-old_res) >= 0.01*old_res ); + } while ( (fabs(new_res-old_res) >= 0.01*old_res) && (niter < 10) ); + + if ( niter == 10 ) { + ERROR("Too many iterations - giving up!\n"); + } } -- cgit v1.2.3