rand_int64 Subroutine

private subroutine rand_int64(irand)

Arguments

Type IntentOptional AttributesName
integer(kind=8), intent(out), optional :: irand

Contents

Source Code


Source Code

subroutine rand_int64(irand)
	INTEGER(8), OPTIONAL, INTENT(OUT)  :: irand
	INTEGER(8)                         :: x


	urand_vars%u = urand_vars%u*d + e !u=u* 2862933555777941757LL + 7046029254386353087LL;

	urand_vars%v = IEOR(urand_vars%v,ISHFT(urand_vars%v,-17)) ! v^=v>>17;
	urand_vars%v = IEOR(urand_vars%v,ISHFT(urand_vars%v,31)) ! v^=v<<31;
	urand_vars%v = IEOR(urand_vars%v,ISHFT(urand_vars%v,-8)) ! v^=v>>8;

	urand_vars%w = a*IAND(urand_vars%w,b) + ISHFT(urand_vars%w,-32) ! w = 4294957665U*(w & 0xffffffff) + (w >> 32);

	x = IEOR(urand_vars%u,ISHFT(urand_vars%u,21)) ! Ullong x=u^(u<< 21);
	x = IEOR(x,ISHFT(x,-35)) ! x ^= x >> 35;
	x = IEOR(x,ISHFT(x,4)) ! x ^= x << 4;

	if (PRESENT(irand)) then
		irand = IEOR(x + urand_vars%v,urand_vars%w)
	end if
end subroutine rand_int64