rand_init Subroutine

private subroutine rand_init(seed1, seed2)

Initialize the intrinsic random number generator.

Author

  • Jacob Williams, 8/30/2019

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: seed1

the first seed for the random number generator.

integer, intent(in) :: seed2

the second seed for the random number generator.


Called by

proc~~rand_init~~CalledByGraph proc~rand_init simulated_annealing_module::rand_init proc~sa simulated_annealing_module::simulated_annealing_type%sa proc~sa->proc~rand_init

Source Code

    subroutine rand_init(seed1,seed2)

    implicit none

    integer,intent(in) :: seed1  !! the first seed for the random number generator.
    integer,intent(in) :: seed2  !! the second seed for the random number generator.

    integer,dimension(:),allocatable :: s
    integer :: n
    integer :: i

    if (seed1==0 .and. seed2==0) then
        call random_seed()
    else
        call random_seed(size = n)
        allocate(s(n))
        s(1) = seed1
        if (n>1) then
            s(2) = seed2
            do i = 3, n ! just in case
                s(i) = seed1 + seed2 + i
            end do
        end if
        call random_seed(put=s)
    end if

    end subroutine rand_init