Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

random draw from normal distribution

heini77
Beginner
136 Views
Hello,

I want to draw random number from a normal distribution but my FORTRAN code does not work. Ireceive the following error: "unresolved external symbol vsrnggaussian referenced in function main".It is the first time that I am using the Math Kernel Library and I hope someone van help me with it. My code is as follows:

PROGRAM drawnormal

USE mkl_vsl

IMPLICIT NONE

integer status !Error / status

integer brng !Index of generator to initialize stream

integer method !Method = 0 in case of uniform distribution

integer dimen !Initial condition of the stream

TYPE (VSL_STREAM_STATE) stream !Random stream

integer, PARAMETER :: nr = 1000 !Number of values required (whatever you want)

real gauss(nr)

real mean, sigma

mean = 0.0

sigma = 1.0

!SOBEL

method = VSL_METHOD_SGAUSSIAN_ICDF !NB - are different alternatives, but I found this worked well

brng = VSL_BRNG_SOBOL

dimen = 1 ! <== different values may be needed depending on application

gauss = 0.0

status = vslnewstream( stream, brng, dimen ) !Create new stream (SOBOL in this case

status = vsrnggaussian( method, stream, nr, gauss, mean, sigma )

status = vsldeletestream( stream ) !Delete the stream

end

0 Kudos
2 Replies
mecej4
Black Belt
136 Views
MKL is not used with every Fortran program. Therefore, you need to specify that you want the MKL linked in.

From the command line, use the -Qmkl (Windows) or -mkl (Linux/OSX) compiler option for a simple program such as the above.

In an IDE, do whatever is needed to link in the MKL as an additional library. See the MKL Link Line Advisor link at the top of this forum for further guidance.
Gennady_F_Intel
Moderator
136 Views
The similar problem has been discussed into this thread. Please see the reply #8 from Andrey Nikolaev. I hope it helps you.
--Gennady
Reply