forked from adfriend45/RINGS_v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GAUSS.f90
27 lines (27 loc) · 1.14 KB
/
GAUSS.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
!======================================================================!
SUBROUTINE GAUSS (Z, sigma)
!----------------------------------------------------------------------!
USE DOUBLE
!----------------------------------------------------------------------!
IMPLICIT NONE
!----------------------------------------------------------------------!
! https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/
! 294465
!----------------------------------------------------------------------!
REAL(DP) :: Z, sigma, w, x1, x2, ran
!----------------------------------------------------------------------!
w = 0.0_DP
DO WHILE ((w >= 1.0_DP) .OR. (w == 0.0_DP))
!---------------------------------------------------------------------!
CALL RANDOM_NUMBER (ran)
x1 = 2.0_DP * ran - 1.0_DP
CALL RANDOM_NUMBER (ran)
x2 = 2.0_DP * ran - 1.0_DP
w = x1 * x1 + x2 * x2
!---------------------------------------------------------------------!
END DO
w = sigma * SQRT ((-2.0_DP * LOG (w)) / w)
Z = x1 * w
!----------------------------------------------------------------------!
END SUBROUTINE GAUSS
!======================================================================!