From 6b1c1af609c06db38e3fab5797c1da073609a4a7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 21 Feb 2018 08:55:33 +0100 Subject: [PATCH] no early return required here --- src/math.f90 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/math.f90 b/src/math.f90 index 3ede28beb..2eda31097 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -1902,19 +1902,18 @@ real(pReal) function math_sampleGaussVar(meanvalue, stddev, width) if (abs(stddev) < tol_math_check) then math_sampleGaussVar = meanvalue - return + else + myWidth = merge(width,3.0_pReal,present(width)) ! use +-3*sigma as default value for scatter if not given + + do + call halton(2_pInt, rnd) + scatter = myWidth * (2.0_pReal * rnd(1) - 1.0_pReal) + if (rnd(2) <= exp(-0.5_pReal * scatter ** 2.0_pReal)) exit ! test if scattered value is drawn + enddo + + math_sampleGaussVar = scatter * stddev endif - myWidth = merge(width,3.0_pReal,present(width)) ! use +-3*sigma as default value for scatter if not given - - do - call halton(2_pInt, rnd) - scatter = myWidth * (2.0_pReal * rnd(1) - 1.0_pReal) - if (rnd(2) <= exp(-0.5_pReal * scatter ** 2.0_pReal)) exit ! test if scattered value is drawn - enddo - - math_sampleGaussVar = scatter * stddev - end function math_sampleGaussVar