2010-12-08 11:37:56 -02:00
|
|
|
!!******************************************************************************
|
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!! This file is part of the AMUN source code, a program to perform
|
|
|
|
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
|
|
|
!! adaptive mesh.
|
2010-12-08 11:37:56 -02:00
|
|
|
!!
|
2018-01-04 12:13:09 -02:00
|
|
|
!! Copyright (C) 2008-2018 Grzegorz Kowal <grzegorz@amuncode.org>
|
2010-12-08 11:37:56 -02:00
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
!! This program is free software: you can redistribute it and/or modify
|
|
|
|
!! it under the terms of the GNU General Public License as published by
|
|
|
|
!! the Free Software Foundation, either version 3 of the License, or
|
|
|
|
!! (at your option) any later version.
|
2010-12-08 11:37:56 -02:00
|
|
|
!!
|
2011-04-29 11:21:30 -03:00
|
|
|
!! This program is distributed in the hope that it will be useful,
|
2010-12-08 11:37:56 -02:00
|
|
|
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
!! GNU General Public License for more details.
|
|
|
|
!!
|
|
|
|
!! You should have received a copy of the GNU General Public License
|
2012-07-22 12:30:20 -03:00
|
|
|
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-08 11:37:56 -02:00
|
|
|
!!
|
|
|
|
!!******************************************************************************
|
|
|
|
!!
|
2012-07-22 19:37:58 -03:00
|
|
|
!! module: RANDOM
|
2012-07-22 12:30:20 -03:00
|
|
|
!!
|
2012-07-22 19:37:58 -03:00
|
|
|
!! This module provides subroutines to random number generators.
|
2012-07-22 12:30:20 -03:00
|
|
|
!!
|
2012-07-22 19:37:58 -03:00
|
|
|
!! References:
|
|
|
|
!!
|
|
|
|
!! [1] Marsaglia, G. & Tsang, W.W. (2000) `The ziggurat method for generating
|
|
|
|
!! random variables', J. Statist. Software, v5(8)
|
2012-07-22 12:30:20 -03:00
|
|
|
!!
|
|
|
|
!!******************************************************************************
|
|
|
|
!
|
2010-12-08 11:37:56 -02:00
|
|
|
module random
|
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! include external subroutines
|
|
|
|
!
|
|
|
|
use timers, only : set_timer, start_timer, stop_timer
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
! declare all module variables as implicit
|
|
|
|
!
|
2010-12-08 11:37:56 -02:00
|
|
|
implicit none
|
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! timer indices
|
|
|
|
!
|
|
|
|
integer , save :: iri, irc
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
! random generator type
|
|
|
|
!
|
|
|
|
character(len = 32), save :: gentype = "same"
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! variables to store seeds for random generator
|
|
|
|
!
|
|
|
|
integer , save :: kp = 0
|
|
|
|
integer , save :: nseeds, lseed
|
2010-12-08 11:37:56 -02:00
|
|
|
integer(kind=4), dimension(:), allocatable, save :: seeds
|
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! by default everything is private
|
|
|
|
!
|
|
|
|
private
|
|
|
|
|
|
|
|
! declare public subroutines
|
|
|
|
!
|
|
|
|
public :: initialize_random, finalize_random
|
|
|
|
public :: nseeds, set_seeds, get_seeds, randomu, randomz, randomn
|
2010-12-08 11:37:56 -02:00
|
|
|
|
|
|
|
contains
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! subroutine INITIALIZE_RANDOM:
|
|
|
|
! ----------------------------
|
|
|
|
!
|
|
|
|
! subroutine initializes random number generator;
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
subroutine initialize_random(nthreads, nthread)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! obtain required variables from other modules
|
|
|
|
!
|
|
|
|
use parameters, only : get_parameter_string
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! declare all variables as implicit
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
implicit none
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! subroutine arguments
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
integer, intent(in) :: nthreads, nthread
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! local variables
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2014-08-04 09:22:11 -03:00
|
|
|
integer :: i
|
|
|
|
real(kind=4) :: r
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! set timer descriptions
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2014-01-03 12:41:38 -02:00
|
|
|
call set_timer('random:: initialization' , iri)
|
|
|
|
call set_timer('random:: number generation', irc)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! start accounting time for the random number generator
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call start_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2018-02-09 16:44:19 -02:00
|
|
|
! set the thread number
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
kp = nthread
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! obtain the generator type
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call get_parameter_string("gentype", gentype)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! calculate the number of seeds
|
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
nseeds = nthreads
|
2012-07-22 19:37:58 -03:00
|
|
|
lseed = nseeds - 1
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! allocate seeds for random number generator
|
|
|
|
!
|
|
|
|
allocate(seeds(0:lseed))
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! prepare the seeds depending on the type of generator
|
|
|
|
!
|
|
|
|
select case(gentype)
|
|
|
|
case('random')
|
|
|
|
do i = 0, lseed
|
|
|
|
call random_number(r)
|
|
|
|
seeds(i) = 123456789 * r
|
|
|
|
end do
|
|
|
|
case default
|
2018-02-09 16:44:19 -02:00
|
|
|
r = 0.1234567890123456789
|
|
|
|
do i = 0, lseed
|
2012-07-22 19:37:58 -03:00
|
|
|
seeds(i) = 123456789 * r
|
|
|
|
end do
|
|
|
|
end select
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! stop accounting time for the random number generator
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call stop_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
2010-12-08 11:37:56 -02:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
end subroutine initialize_random
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! subroutine FINALIZE_RANDOM:
|
|
|
|
! --------------------------
|
|
|
|
!
|
|
|
|
! subroutine releases memory allocated by random number generator variables;
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
subroutine finalize_random()
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! declare all variables as implicit
|
2011-04-24 09:12:32 -03:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
implicit none
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! start accounting time for the random number generator
|
|
|
|
!
|
|
|
|
call start_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
! deallocate seeds if they are allocated
|
|
|
|
!
|
|
|
|
if (allocated(seeds)) deallocate(seeds)
|
|
|
|
|
|
|
|
#ifdef PROFILE
|
|
|
|
! stop accounting time for the random number generator
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call stop_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
2010-12-08 11:37:56 -02:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
end subroutine finalize_random
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! subroutine SET_SEEDS:
|
|
|
|
! --------------------
|
|
|
|
!
|
|
|
|
! subroutine sets the seeds from the given array;
|
2011-04-24 09:12:32 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
subroutine set_seeds(np, nseeds)
|
2011-04-24 09:12:32 -03:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! declare all variables as implicit
|
|
|
|
!
|
2011-04-24 09:12:32 -03:00
|
|
|
implicit none
|
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! input arguments
|
2011-04-24 09:12:32 -03:00
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
integer , intent(in) :: np
|
|
|
|
integer(kind=4), dimension(np), intent(in) :: nseeds
|
2014-04-23 14:56:23 -03:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
2014-08-04 09:22:11 -03:00
|
|
|
integer :: i, l
|
|
|
|
real(kind=4) :: r
|
2011-04-24 09:12:32 -03:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! start accounting time for the random number generator
|
|
|
|
!
|
|
|
|
call start_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
! set the seeds only if the input array and seeds have the same sizes
|
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
l = min(lseed, np - 1)
|
|
|
|
seeds(0:l) = seed(1:l+1)
|
|
|
|
select case(gentype)
|
|
|
|
case('random')
|
|
|
|
if (l < lseed) then
|
|
|
|
do i = l + 1, lseed
|
|
|
|
call random_number(r)
|
|
|
|
seeds(i) = 123456789 * r
|
2014-04-23 14:56:23 -03:00
|
|
|
end do
|
2018-02-09 16:44:19 -02:00
|
|
|
end if
|
|
|
|
case default
|
|
|
|
seeds(l+1:lseed) = seeds(0)
|
|
|
|
end select
|
2012-07-22 19:37:58 -03:00
|
|
|
|
|
|
|
#ifdef PROFILE
|
|
|
|
! stop accounting time for the random number generator
|
2011-04-24 09:12:32 -03:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call stop_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
2011-04-24 09:12:32 -03:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine set_seeds
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! subroutine GET_SEEDS:
|
|
|
|
! --------------------
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! subroutine returns the seeds through an array;
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
subroutine get_seeds(rseeds)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! declare all variables as implicit
|
|
|
|
!
|
2010-12-08 11:37:56 -02:00
|
|
|
implicit none
|
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! output arguments
|
|
|
|
!
|
2018-02-09 16:44:19 -02:00
|
|
|
integer(kind=4), dimension(nseeds), intent(out) :: rseeds
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! start accounting time for the random number generator
|
|
|
|
!
|
|
|
|
call start_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2018-02-09 16:44:19 -02:00
|
|
|
rseeds(1:nseeds) = seeds(0:lseed)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! stop accounting time for the random number generator
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call stop_timer(iri)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
2010-12-08 11:37:56 -02:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
end subroutine get_seeds
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! function RANDOMU:
|
|
|
|
! ----------------
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! function generates uniformly distributed random numbers in range 0.0..1.0;
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
function randomu() result(val)
|
|
|
|
|
|
|
|
! declare all variables as implicit
|
|
|
|
!
|
|
|
|
implicit none
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! output variables
|
|
|
|
!
|
2014-08-04 09:22:11 -03:00
|
|
|
real(kind=8) :: val
|
2012-07-22 19:37:58 -03:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer(kind=4) :: jz, jsr
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! start accounting time for the random number generation
|
|
|
|
!
|
|
|
|
call start_timer(irc)
|
|
|
|
#endif /* PROFILE */
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
jsr = seeds(kp)
|
|
|
|
jz = jsr
|
|
|
|
|
|
|
|
jsr = ieor( jsr, ishft( jsr, 13 ) )
|
|
|
|
jsr = ieor( jsr, ishft( jsr, -17 ) )
|
|
|
|
jsr = ieor( jsr, ishft( jsr, 5 ) )
|
|
|
|
|
|
|
|
seeds(kp) = jsr
|
|
|
|
|
2014-08-04 09:22:11 -03:00
|
|
|
val = 0.5d+00 + 0.23283064365d-09 * (jz + jsr)
|
2012-07-22 19:37:58 -03:00
|
|
|
|
|
|
|
#ifdef PROFILE
|
|
|
|
! stop accounting time for the random number generation
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call stop_timer(irc)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2010-12-08 11:37:56 -02:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end function randomu
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! function RANDOMZ:
|
|
|
|
! ----------------
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! function generates uniformly distributed random numbers in range -0.5..0.5;
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
function randomz() result(val)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! declare all variables as implicit
|
|
|
|
!
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! output variables
|
|
|
|
!
|
2014-08-04 09:22:11 -03:00
|
|
|
real(kind=8) :: val
|
2012-07-22 19:37:58 -03:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer(kind=4) :: jz, jsr
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! start accounting time for the random number generation
|
|
|
|
!
|
|
|
|
call start_timer(irc)
|
|
|
|
#endif /* PROFILE */
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
jsr = seeds(kp)
|
|
|
|
jz = jsr
|
|
|
|
|
|
|
|
jsr = ieor( jsr, ishft( jsr, 13 ) )
|
|
|
|
jsr = ieor( jsr, ishft( jsr, -17 ) )
|
|
|
|
jsr = ieor( jsr, ishft( jsr, 5 ) )
|
|
|
|
|
|
|
|
seeds(kp) = jsr
|
|
|
|
|
2014-08-04 09:22:11 -03:00
|
|
|
val = 0.23283064365d-09 * (jz + jsr)
|
2012-07-22 19:37:58 -03:00
|
|
|
|
|
|
|
#ifdef PROFILE
|
|
|
|
! stop accounting time for the random number generation
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call stop_timer(irc)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2010-12-08 11:37:56 -02:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end function randomz
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! function RANDOMN:
|
|
|
|
! ----------------
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
! function generates uniformly distributed random numbers in range -1.0..1.0;
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
function randomn() result(val)
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! declare all variables as implicit
|
|
|
|
!
|
2010-12-08 11:37:56 -02:00
|
|
|
implicit none
|
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
! output variables
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2014-08-04 09:22:11 -03:00
|
|
|
real(kind=8) :: val
|
2010-12-08 11:37:56 -02:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
integer(kind=4) :: jz, jsr
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
#ifdef PROFILE
|
|
|
|
! start accounting time for the random number generation
|
|
|
|
!
|
|
|
|
call start_timer(irc)
|
|
|
|
#endif /* PROFILE */
|
2010-12-08 11:37:56 -02:00
|
|
|
|
2012-07-22 19:37:58 -03:00
|
|
|
jsr = seeds(kp)
|
|
|
|
jz = jsr
|
|
|
|
|
|
|
|
jsr = ieor( jsr, ishft( jsr, 13 ) )
|
|
|
|
jsr = ieor( jsr, ishft( jsr, -17 ) )
|
|
|
|
jsr = ieor( jsr, ishft( jsr, 5 ) )
|
|
|
|
|
|
|
|
seeds(kp) = jsr
|
|
|
|
|
2014-08-04 09:22:11 -03:00
|
|
|
val = 0.46566128730d-09 * (jz + jsr)
|
2012-07-22 19:37:58 -03:00
|
|
|
|
|
|
|
#ifdef PROFILE
|
|
|
|
! stop accounting time for the random number generation
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
2012-07-22 19:37:58 -03:00
|
|
|
call stop_timer(irc)
|
|
|
|
#endif /* PROFILE */
|
|
|
|
|
|
|
|
return
|
|
|
|
|
2010-12-08 11:37:56 -02:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end function randomn
|
2012-07-22 19:37:58 -03:00
|
|
|
|
|
|
|
!===============================================================================
|
2010-12-08 11:37:56 -02:00
|
|
|
!
|
|
|
|
end module random
|