Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

beta distribution and MKL

jaureus
Beginner
615 Views
Hello, I am attempting to work with the MKL library and in particular the beta function. The commands worked with an older version of mkl on a different system. I think that there may be a problem with my function

I am calling the following subroutine:

subroutine beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

use :: mkl_vsl_type

integer :: brng

integer, intent(in) :: seed_in, n_rand_obs_in, methodrng

real, pointer, intent(out) :: r_beta_list

type(VSL_STREAM_STATE) :: stream

integer :: status

external :: vslnewstream, vsrngbeta, vsldeletestream

methodrng = VSL_METHOD_SBETA_CJA

brng = vsl_brng_mcg31

status = vslnewstream(stream, brng, seed_in)

status = vsrngbeta( methodrng, stream, n_rand_obs_in, r_beta_list, shape1, shape2, 0.0, 1.0 )

status = vsldeletestream(stream)

end subroutine


and I get the following error message in my program:

jgold@clinic:~/smwcv/error_infect/data_augment/random_sim/sim1/o1newinfections75$ ifort -free -O2 -stand f03 -check bounds -traceback -warn all -fstack-protector -assume protect_parens -implicitnone -o mcmcobsgammanoepsilon.out mcmcobsgammanoepsilon.f90 -I/opt/intel/composer_xe_2011_sp1.6.233/mkl/include -L/opt/intel/composer_xe_2011_sp1.6.233/mkl/lib/intel64 -lmkl_rt

mcmcobsgammanoepsilon.f90(59): error #8000: There is a conflict between local interface block and external interface block. [R_BETA_LIST]

subroutine beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

---------------------------------------------------^

mcmcobsgammanoepsilon.f90(367): error #6634: The shape matching rules of actual arguments and dummy arguments have been violated. [R_BETA_LIST]

call beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)


below is the local interface:

include "mkl_vsl.f90"

module randvariables

real :: harvest, shape1, shape2

integer :: seed_in, n_rand_obs_in

real, dimension(:), pointer :: r_beta_list

integer :: r_beta_count, rejectflag

integer, dimension (:, :) , allocatable :: link

end module

program mcnet

! Tell the main program to use the randvariables module

use :: randvariables

0 Kudos
9 Replies
mecej4
Honored Contributor III
615 Views
Detection of perceived/actual mismatches of variable types is quite context dependent. We cannot ascertain what the compiler is complaining about from the snippets of code that you showed. For example, the error messages refer to source lines 59 and 367, and we do not know what those lines contain.

Please provide a complete example that reproduces the problem.
0 Kudos
Andrey_N_Intel
Employee
615 Views

Hello,
Please, provide a test casewhich reproduces the issue and would help toclarifyreasonsof thaterror.
Thanks,
Andrey

0 Kudos
jaureus
Beginner
615 Views

here is a test program

include 'mkl_vsl.f90'

module randvariables

real :: harvest, shape1, shape2

integer :: seed_in, n_rand_obs_in

real, dimension(:), pointer :: r_beta_list

integer :: r_beta_count

end module

program mcnet

! Tell the main program to use the randvariables module

use :: randvariables

implicit none

real :: theta

interface

subroutine beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

implicit none

integer, intent(in) :: seed_in, n_rand_obs_in

real, dimension(:), intent(out) :: r_beta_list

real, intent(in) :: shape1, shape2

end subroutine beta_rng_mkl

end interface

call random_number(harvest)

seed_in = aint(harvest * 2.0e0**31)

shape1 = 200

shape2 = 400

! print *, "shape1 ", " shape2"

! print *, shape1, shape2

n_rand_obs_in = 1

allocate (r_beta_list(n_rand_obs_in))

call beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

theta = r_beta_list(1)

print *, theta

end program

My routine is above and again here are the errors

betaworkedex.f90(20): error #8000: There is a conflict between local interface block and external interface block. [R_BETA_LIST]

subroutine beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

---------------------------------------------------^

betaworkedex.f90(40): error #6634: The shape matching rules of actual arguments and dummy arguments have been violated. [R_BETA_LIST]

call beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

0 Kudos
mecej4
Honored Contributor III
615 Views
The subroutine that you gave in the initial post is not quite correct. It declares intent for methodrng, which is not a subroutine argument.

After declaring methodrng as a local integer variable, I obtained the following output:

[bash]T:> ifort /Qmkl mklvsl.f90 Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.1.3.300 Build 20120130 Copyright (C) 1985-2012 Intel Corporation. All rights reserved. Microsoft Incremental Linker Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. -out:mklvsl.exe -subsystem:console -libpath:c:LANGIntelCOMPOS~2mkllibia32 mklvsl.obj T:>mklvsl 0.2999528

However, this may be a bogus result, since I did not check whether the VSL subroutine/function calls are being made with the proper argument types.[/bash]
0 Kudos
jaureus
Beginner
615 Views

Hi, ok so I modified the variable definition and I get the same error. Clearly, I am doing somethng very wrong. could it have to do with the fact that I am defining variables in a module and also reading them in with an intent statement. Usually, I would not do this but it seems that this is what mkl modules want.


subroutine beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

use :: mkl_vsl_type

integer :: brng

integer, intent(in) :: seed_in, n_rand_obs_in

!integer, intent(in) :: methodrng

real, pointer, intent(out) :: r_beta_list

type(VSL_STREAM_STATE) :: stream

integer :: status, methodrng

external :: vslnewstream, vsrngbeta, vsldeletestream

methodrng = VSL_METHOD_SBETA_CJA

brng = vsl_brng_mcg31

status = vslnewstream(stream, brng, seed_in)

status = vsrngbeta( methodrng, stream, n_rand_obs_in, r_beta_list, shape1, shape2, 0.0, 1.0 )

status = vsldeletestream(stream)

end subroutine

0 Kudos
mecej4
Honored Contributor III
615 Views
You have to add

use MKL_VSL

to provide the compiler with the information needed to check that you are making proper calls to the VSL routine(s).

There are example source codes provided with MKL, and many of these are also described in the documentation. I suggest that you pick one that is suitable, verify that it works correctly when compiled and run, and then modify the example for your purposes.
0 Kudos
Naveen_G_Intel
Employee
615 Views

Hi jaureus,

I used test case which you provided not able to reproduce it for above mentioned error, did you verified MKL_VSL option?

Thanks,

Naveen Gv

0 Kudos
jaureus
Beginner
615 Views
Hi Naveen,
I am really sorry to say that even with all of your help I am unble to get it to work. I have tried out the example within the example set and it works so there is clearly a coding issue, however, I just can't see it.

subroutine beta_rng_mkl(seed_in, r_beta_list, shape1, shape2)

use mkl_vsl_type

use mkl_vsl

integer :: brng

integer, intent(in) :: seed_in

!integer, intent(in) :: methodrng

real, intent(out) :: r_beta_list(1)

type(VSL_STREAM_STATE) :: stream

integer :: status, methodrng, n_rand_obs_in

!external :: vslnewstream, vsrngbeta, vsldeletestream

methodrng = VSL_METHOD_SBETA_CJA

n_rand_obs_in = 1

brng = vsl_brng_mcg31

status = vslnewstream(stream, brng, seed_in)

status = vsrngbeta( methodrng, stream, n_rand_obs_in, r_beta_list, shape1, shape2, 0.0, 1.0 )

status = vsldeletestream(stream)

end subroutine

I have modified the code to include the mkl_vsl option as suggested. However, alas still no joy. i.e. I still get the following errors with my test code:

betaworkedexold.f90(20): error #8000: There is a conflict between local interface block and external interface block. [R_BETA_LIST]

subroutine beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

---------------------------------------------------^

betaworkedexold.f90(41): error #6634: The shape matching rules of actual arguments and dummy arguments have been violated. [R_BETA_LIST]

call beta_rng_mkl(seed_in, n_rand_obs_in, r_beta_list, shape1, shape2)

0 Kudos
Naveen_G_Intel
Employee
615 Views

Hi,

Test code which you provided may not be enough to reproduce the problem.

This particular error usually means that the declaration of the named routine R_BETA_LIST is different between the actual procedure and a definition that came from a module. It may be that a Build > Rebuild of the VS solution will take care of it, as sometimes, with /warn:interface enabled, a generated interface module from a previous compilation is out of date.

Regards,

Naveen Gv

0 Kudos
Reply