Community
cancel
Showing results for 
Search instead for 
Did you mean: 
diedro
Beginner
66 Views

random -- standard deviation - vsrnggaussian

Hi everyone,
I would like to usevsrnggaussian in my intel fortran compiler but I am not able to use it.
I tryed to use:
USE mkl_vsl
my test program is:
[bash]PROGRAM PROVA

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[/bash]
and I compile as:
[bash]ifort -r8 *.f90 -L$MKLPATH/lib/em64t  -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -warn all -check all -debug all[/bash]
I get the following error:
[bash]Check INCLUDE paths.   [MKL_VSL]
USE mkl_vsl
----^
gauss_normally.f90(10): error #6457: This derived type name has not been declared.   [VSL_STREAM_STATE]
TYPE (VSL_STREAM_STATE) stream   !Random stream
------^
gauss_normally.f90(20): error #6404: This name does not have a type, and must have an explicit type.   [VSL_METHOD_SGAUSSIAN_ICDF]
method = VSL_METHOD_SGAUSSIAN_ICDF    !NB - are different alternatives, but I found this worked well
---------^
gauss_normally.f90(21): error #6404: This name does not have a type, and must have an explicit type.   [VSL_BRNG_SOBOL]
brng = VSL_BRNG_SOBOL        
-------^
gauss_normally.f90(24): error #6404: This name does not have a type, and must have an explicit type.   [STREAM]
status = vslnewstream( stream, brng,  dimen )  !Create new stream (SOBOL in this case
-----------------------^
gauss_normally.f90(24): error #6404: This name does not have a type, and must have an explicit type.   [VSLNEWSTREAM]
status = vslnewstream( stream, brng,  dimen )  !Create new stream (SOBOL in this case
---------^
gauss_normally.f90(25): error #6404: This name does not have a type, and must have an explicit type.   [VSRNGGAUSSIAN]
status = vsrnggaussian( method, stream, nr, gauss, mean, sigma )   
---------^
gauss_normally.f90(26): error #6404: This name does not have a type, and must have an explicit type.   [VSLDELETESTREAM]
status = vsldeletestream( stream )   !Delete the stream
[/bash]
Could you please tel me what is wrong
thank you
0 Kudos
11 Replies
anthonyrichards
New Contributor III
66 Views

The file MKL_VSL.F90 contains the MODULE MKL_VSL_TYPE which contains all the definitions that you need.

So, you have to compile this file first, in order to create MKL_VSL_TYPE.MOD and then you must USE MKL_VSL_TYPE in files that are compiled later.
diedro
Beginner
66 Views

thank you for your replay,
however, How can I do it, is it not already compile in mkl libriries which I am calling when I compile?
anthonyrichards
New Contributor III
66 Views

Just add the MKL include file to your project.
diedro
Beginner
66 Views

Hi,
sorry but I am not able to understand.
In the source code I have put:
[bash]PROGRAM PROVA
USE mkl_vsl
...
..
.
...
...
...
END PROVA[/bash]
and then I compile, however it does not work
thanks
anthonyrichards
New Contributor III
66 Views

I repeat, the file MKL_VSL.F90 contains the MODULE MKL_VSL_TYPE which contains all the definitions that you need.

You must add the file 'MKL_VSL.F90' to your project, so that it shows up in the solution explorer pane as a file
You must compile that file in order to create the module MKL_VSL_TYPE.MOD, which you can then USE within your program file to make the VSL definitions available to the program.

So, you have to compile this file first, in order to create MKL_VSL_TYPE.MOD and then you must USE MKL_VSL_TYPE in files that are compiled later.

So change USE MKL_VSL to USE MKL_VSL_TYPE, after you have added MKL_VSL.F90 to your project.
You do understand what adding a file to a project involves I trust?
diedro
Beginner
66 Views

hi,
I got another problrm with mkl libraries
let's me check it before
diedro
Beginner
66 Views

HI,
I have cheked the file, now the lapack95 librarieswork.
However, I can not use theMKL_VSL_TYPE. How can I do, I have not understood.
Where can I find the .mod file andmkl_vsl.f90 file to include them in the project.
thank you
Andrey_N_Intel
Employee
66 Views

Hello,

To make sure thatyour test case can be built and run I did the following steps on Windows* based computer:

1. Created file testcase.f with your code and modified it as shown below:

include 'mkl_vsl.f90'
PROGRAM PROVA

USE mkl_vsl_type
USE mkl_vsl
...

That is, I additionally included Intel MKL VSL header file and started using mkl_vsl_type.

2. Configured environment by setting variables INCLUDE and LIB to point atinclude andlib folders in my MKL installation directory (I want to link against Intel 64 version of Intel MKL library and use ILP64 interface)

set MKLROOT=...
set INCLUDE=%MKLROOT%\include;%INCLUDE%
set LIB=%MKLROOT%\lib\intel64;%LIB%

I alsoconfigured the environment to use Intel Fortran compiler.

3.Built the testcase by using the build line below:

ifort testcase.f /4I8 mkl_intel_ilp64.lib mkl_sequential.lib mkl_core.lib

The result of the compilationare two mode files and the executable. Please, let me know if this helps.

Rich collection of Fortran VSL examples, available in examples\\vslf\\source directory of Intel MKL installation directory, demonstrates how to use Intel MKL in the applications.

MKLLink advisor, available at http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/,isanotherhelpful tool to configure your build environment.

Thanks,
Andrey

diedro
Beginner
66 Views

hi,
thank you la lot
now it seems to compile correctely.However, I have still some problems.
My simple test program is:
[bash]include 'mkl_vsl.f90'
PROGRAM PROVA
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.d0                      ! <== different values may be needed depending on application
gauss = 0.0d0
! 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

ENDPROGRAM[/bash]
when I compile with:
ifort -r8 *.f90 -lmkl_blas95_lp64 -lmkl_lapack95_lp64 -mkl=sequential
I get the folowing error:
[bash]prova_standanard.f90(25): error #6633: The type of the actual argument differs from the type of the dummy argument.   [GAUSS]
status = vsrnggaussian( method, stream, nr, gauss, mean, sigma )   
--------------------------------------------^
prova_standanard.f90(25): error #6633: The type of the actual argument differs from the type of the dummy argument.   [MEAN]
status = vsrnggaussian( method, stream, nr, gauss, mean, sigma )   
---------------------------------------------------^
prova_standanard.f90(25): error #6633: The type of the actual argument differs from the type of the dummy argument.   [SIGMA]
status = vsrnggaussian( method, stream, nr, gauss, mean, sigma )  [/bash]
Where am I wrong?
thank you again
Les_Neilson
Valued Contributor II
66 Views

You compiled with option -r8 which makes gauss, mean and sigma double precision but you are calling the *single* precision version of vsrnggaussian - note the "vs..." name.
Either change the call to the "vd..." version or remove the -r8 from the command line.

Les
Andrey_N_Intel
Employee
66 Views

Hi,
In addition to comment of Les: please, do not forget to use mkl_vsl_type asdescribed inmy previous post,and call service routines to create/delete VSL Random streambefore/aftergeneration of random numbers.
Thanks,
Andrey