Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
17 Views

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.

0 Kudos
2 Replies
Highlighted
Moderator
17 Views

please look at this thread, it might help you..
--Gennady
0 Kudos
Highlighted
Beginner
17 Views

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