TABLE OF CONTENTS


ABINIT/m_OurRng [ Modules ]

[ Top ] [ Modules ]

NAME

  m_OurRng

FUNCTION

  Random number generator module
  Should be modify and merge with uniformrandom and zbq

COPYRIGHT

  Copyright (C) 2013-2018 ABINIT group (J. Bieder)
  This file is distributed under the terms of the
  GNU General Public License, see ~abinit/COPYING
  or http://www.gnu.org/copyleft/gpl.txt .

NOTES

PARENTS

  Will be filled automatically by the parent script

CHILDREN

  Will be filled automatically by the parent script

SOURCE

29 #include "defs.h"
30 
31 MODULE m_OurRng
32 !! Implementation of various RNG with a small footprint
33 
34  !use m_numeric_tools,  only : uniformrandom
35 
36 IMPLICIT NONE
37 
38 PRIVATE
39 
40 PUBLIC :: OurRng
41 
42 CONTAINS

ABINIT/m_OurRng/OurRng [ Functions ]

[ Top ] [ Functions ]

NAME

  OurRng

FUNCTION

  Generator given by G. Colin de Verdiere
  Efficient on GPU and MIC

COPYRIGHT

  Copyright (C) 2013-2018 ABINIT group (J. Bieder)
  This file is distributed under the terms of the
  GNU General Public License, see ~abinit/COPYING
  or http://www.gnu.org/copyleft/gpl.txt .

INPUTS

  xn=seed
  rng=random number

OUTPUT

SIDE EFFECTS

NOTES

PARENTS

  Will be filled automatically by the parent script

CHILDREN

  Will be filled automatically by the parent script

SOURCE

 77 SUBROUTINE OurRng(xn,rng)
 78   ! returns a value between 0. and 1. with a period of 2**31
 79   ! implements the Marsaglia serie:
 80   !   xn+1 = (69069 * xn) mod 2^31
 81 
 82 !This section has been created automatically by the script Abilint (TD).
 83 !Do not modify the following lines by hand.
 84 #undef ABI_FUNC
 85 #define ABI_FUNC 'OurRng'
 86 !End of the abilint section
 87 
 88   implicit none
 89 !Arguments ------------------------------------
 90   DOUBLE PRECISION, INTENT(  OUT) :: rng
 91   INTEGER(8), INTENT(INOUT) :: xn
 92   !
 93   INTEGER(8) :: two31  ! 2 ** 31
 94   INTEGER(8) :: two31m ! 2 ** 31 -1
 95   INTEGER(8), PARAMETER :: mars   = 69069
 96   INTEGER(8) :: xn8
 97   INTRINSIC MOD, REAL, IAND
 98 
 99   two31 = 1
100   two31 = two31 * 65536   ! **16
101   two31 = two31 * 32768   ! **31
102   two31m = two31 - 1
103 
104 !!$  two31  = z'80000000'
105 !!$  two31m = z'7FFFFFFF'
106 
107   IF (xn == 0) xn = 1
108   xn8 = (mars * xn)
109   xn8 = IAND(xn8, two31m)
110   xn = xn8
111 
112   rng = REAL(xn, 8) / REAL(two31m, 8)
113   ! guard to avoid pick up one since that sould never happen (otherwise ctqmc
114   ! may generate an error and exit the code)
115   if ( rng == 1.d0 ) rng = 0.d0
116 END SUBROUTINE OurRng