Beginner Compile Issue

Post here if you have a question about linking your program with LAPACK or ScaLAPACK library

Beginner Compile Issue

Postby TAKAfoo » Thu Apr 14, 2011 12:52 am

I am having trouble compiling a .f90 program that I am trying to use zgesv in...

ifort 100.f90
/tmp/ifortN2Zshv.o: In function `MAIN__':
100.f90:(.text+0x25a2): undefined reference to `zgesv_'


If anyone could point me in the right direction on how to compile this properly it would be greatly appreciated.
TAKAfoo
 
Posts: 2
Joined: Thu Apr 14, 2011 12:48 am

Re: Beginner Compile Issue

Postby admin » Thu Apr 14, 2011 10:11 am

Hi,
You need the LAPACK and BLAS library in your link.
You can also use the Intel MKL library that contains both.
Julie
admin
Site Admin
 
Posts: 501
Joined: Wed Dec 08, 2004 7:07 pm

Re: Beginner Compile Issue

Postby TAKAfoo » Thu Apr 14, 2011 3:58 pm

Ok so I tried the below but I am still getting the same issue sorry

ifort 100.f90 -L/Lib/blas_LINUX -L/Lib/lapack_LINUX
/tmp/ifort4orRdn.o: In function `MAIN__':
100.f90.text+0x27d2): undefined reference to `zgesv_'
TAKAfoo
 
Posts: 2
Joined: Thu Apr 14, 2011 12:48 am

Re: Beginner Compile Issue

Postby jaureus76 » Fri Apr 22, 2011 3:54 pm

hello, I am experienceing a similar error,

I am attempting to use LAPACK include file to perform a Cholesky decomposition which is required for the GaussianMV random number generator. We have the MKL library installed on our server and by running the command mkl_vsl.f9, I am able to use other random numbers. U nfortunately, I am having trouble running a function that requires MKL_Lapack.f90. Does anyone have experience using the command potrf

My LAN administator copied the laplace.f90 file onto my local directory from the directory in which was found, and since all it is a series of subroutines I tried both attempting to run it as part of my compilation file and it seems to compile two mod files which I assume that the library requires.


mkl95_precision.mod and mkl95_lapack.mod, however, it give me an error, that it does not recognize the sepcific LAPACK command that I am using.

I rec eive the same error when I do not reference MKL_Lapack.f90 at all, which suggests to me that it is an error with t he command and not with the Lapack.f90 and yet the structure of the command follows that from the intel website. I am able to compile the program but obviously not run it when the command is commented out.
here is the error, I have tried using either the f77 version of the command dpotrf and the f95 version potrf to see if it was an issue of the program liking one or the other. I have also tried just using potrf but to no avail. when I comment out the command potrf, the program compiles

ifort -free -o testrandomMVnorm.out testrandomMVnorm.f90 mkl_lapack.f90 randmvnorm.f90 -L/opt/intel/mkl/8.1/lib/64/ -lmkl -lvml
/tmp/iforts98itX.o(.text+0x9d2): In function `MAIN__':
: undefined reference to `dpotrf_'
/tmp/iforts98itX.o(.text+0xa02): In function `MAIN__':
: undefined reference to `potrf_'


below is the relevant section of code within the file:


program mcnet

implicit none

integer :: i, j

real :: harvest1, harvest2, sd

integer :: dimen, seed_in1, seed_in2, n_rand_obs_in

real , dimension (:, :), allocatable :: newidentity, sigmanew, meanvectnorm, meanvectnormtrans, meanvect, meanvecttrans, &

meanvectold, meanvecttransold, Q, r_mvgaussian_list1, r_mvgaussian_list2, sigmanewchol

 

interface

subroutine gaussianmv_rng_mkl(seed_in, n_rand_obs_in, r_mvgaussian_list, dimen, mean, tcv)

implicit none

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

real, dimension(1:n_rand_obs_in, 1:dimen), intent(out) :: r_mvgaussian_list

real, dimension(1:dimen), intent(in) :: mean

real, dimension(1:dimen, 1:dimen), intent(in) :: tcv

end subroutine gaussianmv_rng_mkl

end interface

! allowing for easy changes in dimensionality

dimen = 3

n_rand_obs_in = 5
 

allocate(newidentity(1:dimen, 1:dimen))

allocate(meanvectnorm(1:dimen, 1:1))



newidentity = 0.0

!scaling factor as per algoritm

sd = (2.38)**2/dimen

meanvectnorm = 0.0



do j = 1, dimen

! identity matrix times scaling factor as per Roberts and Rosthenthal (2009) gives innitial value of covariance matrix



newidentity( j, j) = 1.0*(0.01)/dimen

end do

 

call random_number(harvest1)

seed_in1 = aint(harvest1 * 2.0e0**31)

 

meanvectnorm(1,1) = 0.2

meanvectnorm(2,1) = 0.3

meanvectnorm(3,1) = 0.001

call d potrf('U', dimen, newidentity)

call potrf( newidentity, 'U' )





call gaussianmv_rng_mkl(seed_in1, n_rand_obs_in, r_mvgaussian_list2, dimen, meanvectnorm, newidentity)



do i = 1, n_rand_obs_in

do j = 1, dimen

print *, r_mvgaussian_list2(i, j)

end do

end do

end program
jaureus76
 
Posts: 3
Joined: Fri Apr 22, 2011 3:47 pm

Re: Beginner Compile Issue

Postby admin » Mon Apr 25, 2011 6:12 am

Taka a look here :http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/
It should get you the correct linking sequence with MKL.
Julie
admin
Site Admin
 
Posts: 501
Joined: Wed Dec 08, 2004 7:07 pm

Re: Beginner Compile Issue

Postby jaureus76 » Tue Apr 26, 2011 4:17 pm

Hi Julie, thanks for the link. However, I am still having problems.


/opt/intel/Compiler/11.0/083/lib/ia64/libguide.so: undefined reference to `pthread_atfork'
Failed to exec command "mcmcobsinfwdaugmentinfprdvarrjeffbetanewu10Gibbs.out": No such file or directory


admin wrote:Taka a look here :http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/
It should get you the correct linking sequence with MKL.
Julie



Hi, i tried this using call potrf( newidentity2) and I got:

ifort -free -o testrandomMVnorm.out testrandomMVnorm.f90 randmvnorm.f90 -L/opt/intel/Compiler/11.1/064/mkl/lib/64 -lmkl_lapack95_ilp64 -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread
/tmp/ifortVr7Gud.o(.text+0x15b2): In function `MAIN__':

I also tried removing reference to potrf and just creating a upper triangular matrix, and my program runs, i.e. it creates random numbers from a multivariate normal. However, I get the following:

testrandomMVnor(30750): unaligned access to 0x60000fffffffa164, ip=0x20000000003c50d0
testrandomMVnor(30750): unaligned access to 0x60000fffffffa164, ip=0x20000000003c58f0
testrandomMVnor(30750): unaligned access to 0x60000fffffffa09c, ip=0x20000000003c5930
testrandomMVnor(30750): unaligned access to 0x60000fffffffa164, ip=0x20000000003c5311
testrandomMVnor(30750): unaligned access to 0x60000fffffffa09c, ip=0x20000000003c5340


However, when I xomment out some code to create a test upper traingler matrix and use call spotrf('U', dimen, newidentity2, dimen) I get a segmentation error

forrtl: severe (174): SIGSEGV, segmentation fault occurred. However, since I am using Fortran 77 code and compiling with f90 code, why am I not getting worse




here is the version of my code with spotrf('U', dimen, newidentity2, dimen)


program mcnet

implicit none

integer :: i, j

real :: harvest1, harvest2, sd
integer :: dimen, seed_in1, seed_in2, n_rand_obs_in
real , dimension (:, :), allocatable :: newidentity, sigmanew, meanvectnorm, meanvectnormtrans, meanvect, meanvecttrans, &
meanvectold, meanvecttransold, Q, r_mvgaussian_list1, r_mvgaussian_list2, sigmanewchol, newidentity2


interface

subroutine gaussianmv_rng_mkl(seed_in, n_rand_obs_in, r_mvgaussian_list, dimen, mean, tcv)
implicit none
integer, intent(in) :: seed_in, n_rand_obs_in, dimen
real, dimension(1:n_rand_obs_in, 1:dimen), intent(out) :: r_mvgaussian_list
real, dimension(1:1, 1:dimen), intent(in) :: mean
real, dimension(1:dimen, 1:dimen), intent(in) :: tcv
end subroutine gaussianmv_rng_mkl
end interface

! allowing for easy changes in dimensionality

dimen = 3
n_rand_obs_in = 3

call random_seed



allocate(newidentity(1:dimen, 1:dimen))
!allocate(sigmanew(1:dimen, 1:dimen))
allocate(meanvectnorm(1:dimen, 1:1))
allocate(meanvectnormtrans(1:1, 1:dimen))
allocate(newidentity2(1:dimen, 1:dimen))
allocate(r_mvgaussian_list2(1:n_rand_obs_in, 1:dimen) )
allocate(Q(1:dimen, 1:1))
!allocate(tcv(1:dimen, 1:dimen))

newidentity = 1.0

!scaling factor as per algoritm
sd = (2.38)**2/dimen

meanvect = 0.0
meanvectnorm = 0.0


do j = 1, dimen
! identity matrix times scaling factor as per Roberts and Rosthenthal (2009) gives innitial value of covariance matrix

newidentity( j, j) = 1.0*(0.01)/dimen

end do

!print *, newidentity

call random_number(harvest1)
seed_in1 = aint(harvest1 * 2.0e0**31)


meanvectnorm(1,1) = 0.2
meanvectnorm(2,1) = 0.3
meanvectnorm(3,1) = 0.001

newidentity2 = newidentity

!print *, meanvectnorm
meanvectnormtrans = transpose(meanvectnorm)

call spotrf('U', dimen, newidentity2, dimen)
!call potrf( newidentity2)
! note that since cholesky decomposition of newidentity does not change, since newidentity does not change one only needs to derive it once

newidentity2 = 0.0
!do i = 1, dimen
!do j = 1, dimen
!if (i .ge. j) then
! newidentity2(i,j) = newidentity(i,j)
!end if

!end do
!end do


print *, newidentity2
print *, "test"

call gaussianmv_rng_mkl(seed_in1, n_rand_obs_in, r_mvgaussian_list2, dimen, meanvectnormtrans, newidentity2)
!subroutine gaussianmv_rng_mkl(seed_in, n_rand_obs_in, r_mvgaussian_list, dimen, mean, tcv)
do i = 1, n_rand_obs_in
do j = 1, dimen
print *, r_mvgaussian_list2(i, j)

end do
end do

end program
jaureus76
 
Posts: 3
Joined: Fri Apr 22, 2011 3:47 pm

Re: Beginner Compile Issue

Postby admin » Wed Apr 27, 2011 12:08 pm

Your program seems fine.
I managed to compile and run it. The only modifications I did were
- to add the info parameter to spotrf (info being an integer)
call spotrf('U', dimen, newidentity2, dimen, info)
- to allocate space for meanvect
- to comment the call to gaussianmv_rng_mkl because I do not have that routine.

So my first try would be to add that info parameter.
And if you still have problem, try with the netlib LAPACK and reference BLAS. (They are both inside the LAPACK package at http://www.netlib.org/lapack)

Julie
admin
Site Admin
 
Posts: 501
Joined: Wed Dec 08, 2004 7:07 pm

Re: Beginner Compile Issue

Postby jaureus76 » Thu Apr 28, 2011 5:22 pm

admin wrote:Your program seems fine.
I managed to compile and run it. The only modifications I did were
- to add the info parameter to spotrf (info being an integer)
call spotrf('U', dimen, newidentity2, dimen, info)
- to allocate space for meanvect
- to comment the call to gaussianmv_rng_mkl because I do not have that routine.

So my first try would be to add that info parameter.
And if you still have problem, try with the netlib LAPACK and reference BLAS. (They are both inside the LAPACK package at http://www.netlib.org/lapack)

Julie



ok, I tried modifying the program as you suggested and I got rid of that one error, however, I get the following error which suggests to me that the version of LA_PACk that I have is missing a file. /opt/intel/mkl/8.1/lib/64/libmkl_i2p.so: undefined symbol: mkl_blas_spotrf_u_small

Also, I could not understand what I should be looking for at the link that you provided me with. i.e what do you mean reference BLAS do you mean include it in my statement


I also have copyied mkl_lapack.f90 into my working directory and attempted to compile it to see if that would work, however, I recieve the same error

ifort -free -o testrandomMVnorm.out testrandomMVnorm.f90 randmvnorm.f90 mkl_lapack.f90 -L/opt/intel/Compiler/11.1/064/mkl/lib/64 -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread


ifort -free -o testrandomMVnorm.out testrandomMVnorm.f90 randmvnorm.f90 -L/opt/intel/Compiler/11.1/064/mkl/lib/64 -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread

I have also tried using the reference creator and included BLAS but I get the same error

also here is the file which i use to call the multivariate normal:

subroutine gaussianmv_rng_mkl(seed_in, n_rand_obs_in, r_mvgaussian_list, dimen, mean, tcv)


!use :: mkl_vsl_type
USE MKL_VSL_TYPE
USE MKL_VSL


!subroutine gaussianmv_rng_mkl(seed_in, n_rand_obs_in, r_mvgaussian_list, dimen, mean, tcv)
! implicit none
integer, intent(in) :: seed_in, n_rand_obs_in, dimen
real, dimension(1:n_rand_obs_in, 1:dimen), intent(out) :: r_mvgaussian_list
real, dimension(1:1, 1:dimen), intent(in) :: mean
real, dimension(1:dimen, 1:dimen), intent(in) :: tcv
!end subroutine gaussianmv_rng_mkl



integer :: brng
!integer, intent(in) :: seed_in, n_rand_obs_in
!real, pointer, intent(out) :: r_mvgaussian_list
type(VSL_STREAM_STATE) :: stream
integer :: methodrng
integer :: status

!external :: vslnewstream, vsrnggausianmv, vsldeletestream
!!external :: vslnewstream, vsrnggaussianmv, vsldeletestream


do j = 1, dimen
print *, mean(1,j)
end do


methodrng = VSL_RNG_METHOD_GAUSSIANMV_BOXMULLER
mstorage = VSL_MATRIX_STORAGE_FULL
brng = vsl_brng_mcg31
status = vslnewstream(stream, brng, seed_in)
print *,''
print *, status
print *,''
status = 0
print *, status
print *,''
status = vsrnggaussianmv( methodrng, stream, n_rand_obs_in, r_mvgaussian_list, dimen, mstorage, mean, tcv)
print *,''
print *, status
print *,''

status = vsldeletestream(stream)

end subroutine
jaureus76
 
Posts: 3
Joined: Fri Apr 22, 2011 3:47 pm


Return to Linking Problem

Who is online

Users browsing this forum: No registered users and 1 guest

cron