1 subroutine da_gauss_noise( z)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
10 real :: x, y, r, coeff
12 if (trace_use) call da_trace_entry("da_gauss_noise")
14 ! [2.1] Get two uniform variate random numbers in range 0 to 1:
17 call random_number( x)
18 call random_number( y)
20 ! [2.2] Transform to range -1 to 1 and calculate sum of squares:
26 if (r > 0.0 .and. r < 1.0) exit
29 ! [2.3] use Box-Muller transformation to get normal deviates:
31 coeff = sqrt( -2.0 * log(r) / r)
34 if (trace_use) call da_trace_exit("da_gauss_noise")
36 end subroutine da_gauss_noise