A random distribution ?

A random distribution ?

Hi,

I am trying to use the routine vdrnggaussian to obtain a random vector. Here is the code I am using:

include 'mkl_vsl.fi'

include 'ERRCHECK.INC'

SUBROUTINE RandomNumber(ranval)

USE MKL_VSL_TYPE

USE MKL_VSL

!DEC$ ATTRIBUTES DLLEXPORT :: RandomNumber

!DEC$ ATTRIBUTES STDCALL :: RandomNumber

INTEGER METHOD,i, brng, seed

integer(kind=4) errcode

integer n

parameter(n=1000)

real(kind=8) ranval(n)

real(kind=8) r(n), sigma

real(kind=8) a

TYPE (VSL_STREAM_STATE) :: stream

do 20 i=1,n

r(i)=0

20 continue

brng=VSL_BRNG_MCG31

method=0

seed=777

a=0.5

sigma=0.166D+0

errcode=vslnewstream(stream,brng,seed)

call CheckVslError(errcode)

errcode = vdrnggaussian(method,stream,n,r,a,sigma)

do 10 i=1,n

ranval(i)=r(i)

10 continue

errcode=vslDeleteStream( stream );

call CheckVslError(errcode)

end

The problem is the following, I am always receivingfrom my fortran DLL the same random vector "r" ... I read the Intel MKL VSL notes pdf but could not figure out whatwas the problem.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

please look at this thread, it might help you..--Gennady

Thank you, I am now using the function DCLOCK() to obtain a random seed and it is working like I wanted!

Leave a Comment

Please sign in to add a comment. Not a member? Join today