set_larnv_seed Subroutine

public subroutine set_larnv_seed(irow, nrow, icol, ncol, ival, iseed)

generate a seed respecting the lapack constraints, - values between 0..4095 (2**12-1) - iseed(4) odd also try to avoid iseed that are zero. Have but with a unique 2D mapping (irow,icol), and a 'mini-seed' ival

Arguments

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

1..nrow nrow 1..ncol ncol mini-seed

integer, intent(in) :: nrow

1..nrow nrow 1..ncol ncol mini-seed

integer, intent(in) :: icol

1..nrow nrow 1..ncol ncol mini-seed

integer, intent(in) :: ncol

1..nrow nrow 1..ncol ncol mini-seed

integer, intent(in) :: ival

1..nrow nrow 1..ncol ncol mini-seed

integer, intent(out) :: iseed(4)

a lapack compatible seed


Source Code

   SUBROUTINE set_larnv_seed(irow, nrow, icol, ncol, ival, iseed)
      !! generate a seed respecting the lapack constraints,
      !! - values between 0..4095 (2**12-1)
      !! - iseed(4) odd
      !! also try to avoid iseed that are zero.
      !! Have but with a unique 2D mapping (irow,icol), and a 'mini-seed' ival

      INTEGER, INTENT(IN)                                :: irow, nrow, icol, ncol, ival
         !! 1..nrow
         !! nrow
         !! 1..ncol
         !! ncol
         !! mini-seed
      INTEGER, INTENT(OUT)                               :: iseed(4)
         !! a lapack compatible seed

      INTEGER(KIND=int_8)                                :: map

      map = ((irow - 1 + icol*INT(nrow, int_8))*(1 + MODULO(ival, 2**16)))*2 + 1 + 0*ncol ! ncol used
      iseed(4) = INT(MODULO(map, 2_int_8**12)); map = map/2_int_8**12; ! keep odd
      iseed(3) = INT(MODULO(IEOR(map, 3541_int_8), 2_int_8**12)); map = map/2_int_8**12
      iseed(2) = INT(MODULO(IEOR(map, 1153_int_8), 2_int_8**12)); map = map/2_int_8**12
      iseed(1) = INT(MODULO(IEOR(map, 2029_int_8), 2_int_8**12)); map = map/2_int_8**12
   END SUBROUTINE set_larnv_seed