diff --git a/src/math.f90 b/src/math.f90 index 5b2cedacb..191791ee2 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -646,9 +646,8 @@ pure function math_33to9(m33) integer :: i - do i = 1, 9 - math_33to9(i) = m33(MAPPLAIN(1,i),MAPPLAIN(2,i)) - enddo + + math_33to9 = [(m33(MAPPLAIN(1,i),MAPPLAIN(2,i)),i=1,9)] end function math_33to9 @@ -663,6 +662,7 @@ pure function math_9to33(v9) integer :: i + do i = 1, 9 math_9to33(MAPPLAIN(1,i),MAPPLAIN(2,i)) = v9(i) enddo @@ -685,15 +685,14 @@ pure function math_sym33to6(m33,weighted) real(pReal), dimension(6) :: w integer :: i + if(present(weighted)) then w = merge(NRMMANDEL,1.0_pReal,weighted) else w = NRMMANDEL endif - do i = 1, 6 - math_sym33to6(i) = w(i)*m33(MAPNYE(1,i),MAPNYE(2,i)) - enddo + math_sym33to6 = [(w(i)*m33(MAPNYE(1,i),MAPNYE(2,i)),i=1,6)] end function math_sym33to6 @@ -842,18 +841,18 @@ end function math_Voigt66to3333 !-------------------------------------------------------------------------------------------------- !> @brief draw a random sample from Gauss variable !-------------------------------------------------------------------------------------------------- -real(pReal) function math_sampleGaussVar(meanvalue, stddev, width) +real(pReal) function math_sampleGaussVar(mu, sigma, width) - real(pReal), intent(in) :: meanvalue, & !< meanvalue of gauss distribution - stddev !< standard deviation of gauss distribution - real(pReal), intent(in), optional :: width !< width of considered values as multiples of standard deviation + real(pReal), intent(in) :: mu, & !< mean + sigma !< standard deviation + real(pReal), intent(in), optional :: width !< cut off as multiples of standard deviation real(pReal), dimension(2) :: rnd ! random numbers - real(pReal) :: scatter, & ! normalized scatter around meanvalue + real(pReal) :: scatter, & ! normalized scatter around mean width_ - if (abs(stddev) < tol_math_check) then - math_sampleGaussVar = meanvalue + if (abs(sigma) < tol_math_check) then + math_sampleGaussVar = mu else if (present(width)) then width_ = width @@ -867,7 +866,7 @@ real(pReal) function math_sampleGaussVar(meanvalue, stddev, width) if (rnd(2) <= exp(-0.5_pReal * scatter ** 2.0_pReal)) exit ! test if scattered value is drawn enddo - math_sampleGaussVar = scatter * stddev + math_sampleGaussVar = scatter * sigma endif end function math_sampleGaussVar