SCALE-RM
Data Types | Functions/Subroutines
scale_random Module Reference

module RANDOM More...

Functions/Subroutines

subroutine, public random_setup
 Setup. More...
 
subroutine random_uniform_1d (var)
 Get uniform random number ( 1D ) More...
 
subroutine, public random_finalize
 finalize More...
 
subroutine, public random_knuth_shuffle (num, a)
 

Detailed Description

module RANDOM

Description
random number generation module
Author
Team SCALE
NAMELIST
  • PARAM_RANDOM
    nametypedefault valuecomment
    RANDOM_FIX logical .false.

History Output
No history output

Function/Subroutine Documentation

◆ random_setup()

subroutine, public scale_random::random_setup

Setup.

Definition at line 69 of file scale_random.F90.

69  use scale_prc, only: &
70  prc_abort
71  implicit none
72 
73  namelist / param_random / &
74  random_fix
75 
76  integer :: nseeds, ierr
77  !---------------------------------------------------------------------------
78 
79  log_newline
80  log_info("RANDOM_setup",*) 'Setup'
81 
82  !--- read namelist
83  rewind(io_fid_conf)
84  read(io_fid_conf,nml=param_random,iostat=ierr)
85  if( ierr < 0 ) then !--- missing
86  log_info("RANDOM_setup",*) 'Not found namelist. Default used.'
87  elseif( ierr > 0 ) then !--- fatal error
88  log_error("RANDOM_setup",*) 'Not appropriate names in namelist PARAM_RANDOM. Check!'
89  call prc_abort
90  endif
91  log_nml(param_random)
92 
93  call random_seed
94  call random_seed(size=nseeds)
95 
96  allocate( random_seedvar(nseeds))
97 
98  log_newline
99  log_info("RANDOM_setup",*) 'Array size for random seed:', nseeds
100  if ( random_fix ) then
101  log_info("RANDOM_setup",*) 'random seed is fixed.'
102  endif
103 
104  call random_reset
105 
106  return

References scale_io::io_fid_conf, scale_prc::prc_abort(), and scale_prc::prc_universal_myrank.

Referenced by mod_rm_driver::rm_driver(), and mod_rm_prep::rm_prep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_uniform_1d()

subroutine scale_random::random_uniform_1d ( real(rp), dimension(:), intent(out)  var)

Get uniform random number ( 1D )

Definition at line 154 of file scale_random.F90.

154  implicit none
155  real(RP), intent(out) :: var(:)
156  !---------------------------------------------------------------------------
157 
158  call random_number(var)
159  !$acc update device(var) if(acc_is_present(var))
160 
161  return

◆ random_finalize()

subroutine, public scale_random::random_finalize

finalize

Definition at line 229 of file scale_random.F90.

229  implicit none
230  !---------------------------------------------------------------------------
231 
232  random_fix = .false.
233 
234  deallocate( random_seedvar )
235 
236  return

Referenced by mod_rm_driver::rm_driver(), and mod_rm_prep::rm_prep().

Here is the caller graph for this function:

◆ random_knuth_shuffle()

subroutine, public scale_random::random_knuth_shuffle ( integer, intent(in)  num,
integer, dimension(num), intent(out)  a 
)

Definition at line 240 of file scale_random.F90.

240  implicit none
241  integer, intent(in) :: num
242  integer, intent(out) :: a(num)
243  integer :: i, randpos, tmp
244  real(DP) :: r
245 
246  do i = 1, num
247  a(i) = i
248  end do
249 
250  do i = num, 2, -1
251  call random_number(r)
252  randpos = int(r * i) + 1
253  tmp = a(randpos)
254  a(randpos) = a(i)
255  a(i) = tmp
256  end do
257 
258  return

References scale_const::const_pi.

Referenced by scale_letkf::letkf_system().

Here is the caller graph for this function:
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_prc
module PROCESS
Definition: scale_prc.F90:11