C Library Functions - init_random_seed (3)
NAME
init_random_seed(3f) - [M_random] seed random_number(3f) with single value like srand(3c) usage
(LICENSE:MIT)
CONTENTS
Synopsis
Description
Examples
Author
License
SYNOPSIS
subroutine init_random_seed(mine)
integer,intent(in) :: mine
DESCRIPTION
A simple wrapper around random_seed(3f) that uses the single given
integer to initialize the seed so you can easily call random_number(3f)
with varying pseudo-random real number sequences simply, much like
srand(3c) and rand(3c).
EXAMPLES
Sample program:
program demo_init_random_seed
use M_random, only : init_random_seed
integer :: iseed
integer :: i
real :: x
iseed=218595421
call init_random_seed(iseed)
do i=1,10
! generate real pseudo-random numbers from 0 to <1.0
call random_number(x)
write(*,*)i,x
enddo
end program demo_init_random_seed
Results
> 1 0.989341617
> 2 0.296594143
> 3 0.805420995
> 4 4.00894880E-03
> 5 5.73359132E-02
> 6 0.805290103
> 7 0.944527864
> 8 0.789443851
> 9 0.327288270
> 10 0.710926533
AUTHOR
John S. Urban
LICENSE
MIT License
| Nemo Release 3.1 | init_random_seed (3) | June 29, 2025 |
Generated by manServer 1.08 from 07cbed97-da73-408c-bc8e-4640f2f5714a using man macros.