- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi every one,
I would like to find the inverse and after that of a square matrix. The matrix it is n x n with n very small, max n = 20-30.I would like to use the mkl libraries in intel fortran 95\\2003.
what libraries could I use ?
How shall I do?
thanks
Link Copied
18 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Diedro,
Please see the MKL Manual Documentation - Lapack\Computations routines\Routines for Matrix Inversion.
also see the MKL Linker Adviser - to select what MKL'slibraries are recommended for linking ...
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
thank you very much but it seems very comlicate.
I found the functio that are:
[bash] call GETRF(CoeffMat,ipiv) call GETRI(CoeffMat,ipiv) [/bash]
and I try to compile as:
[bash]ifort -L$MKLPATH -lmkl_lapack -mkl -lpthread *.f90 [/bash]but I get the following error:
[bash]quadraturepoints.f90(86): error #6285: There is no matching specific subroutine for this generic subroutine call. [GETRF] call GETRF(CoeffMat,ipiv) ---------^ quadraturepoints.f90(87): error #6285: There is no matching specific subroutine for this generic subroutine call. [GETRI] [/bash]
could you please what it is wrong?
thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The combination of array data types and rank declarations must match one of the original BLAS functions. The source code for the lapack use modules is provided in your installation, in case that will help you see what are the supported specific subroutines. You could post a complete small example if you want further advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
thank you again very much.
the function defined in
[bash]/opt/intel/composerxe-2011.0.084/mkl/interfaces/lapack95/source/[/bash]
that I want to use to "computes an LU factorization of a nxm genelral matrix A" (first step to invert a matrix) is:
[bash]DGETRF[/bash]
and in dgetrf.f90 the subroutine is:
[bash]PURE SUBROUTINE DGETRF_F95(A,IPIV,INFO) USE F77_LAPACK, ONLY: F77_GETRF, F77_XERBLA ! <<< ENTRY point >>> ENTRY DGETRF_MKL95(A,IPIV,INFO) ! <<< Implicit statement >>> IMPLICIT NONE ... ... ... END SUBROUTINE DGETRF_F95[/bash]
[bash]As you can see it need only three arguments:
[/bash]
1) the matrix to invert A(nxn)
2) an array dim(n)
3) a flag
I compile as:
[bash]-L$MKLPATH -lmkl_lapack95 -mkl *.f90 [/bash]
It runs but I have the following error:
[bash]SIGSEGV, segmentation fault occurred Image PC Routine Line Source libmkl_intel_lp64 00007FBDAD0B37D3 Unknown Unknown Unknown [/bash]and here my code:
[bash]SUBROUTINE quadraturepoints USE precisionpc USE basic_funtions_modal_2D USE comuni IMPLICIT NONE .... .... REAL (DBL), DIMENSION(nGP1D,nGP1D) :: CoeffMat REAL (DBL), DIMENSION(nGP1D) :: IPIV ... ... CALL DGETRF(CoeffMat,ipiv,info) ... ... ... [/bash]
If I try to callDGETRF_F95 I have an errot
I don't know if the problem is in the link between my code and lapack95 or in the input in the subroutineDGETRF_F95
thank you very much you are my lifesaver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You must first resolve the compile time problem. The message you quoted before refers to the list of specific versions of getrf, dgetri, which you will see in lapack/interfaces.f90. Fortran looks at the list of alternatives there and gives you the error when none of the alternate specific subroutines match your data types.
IPIV is not a flag; it's an array of default integers to record interchanges. If you don't get that right, that would give rise to the error. If you supply it as an array of double precision, as you appear to have done, that also will give rise to the rejection. Likewise, INFO, which you may call a flag, must be typed integer (rank 0).
The integer types would be default integer, unless you choose the ilp libraries, in which case they would be integer(kind=8).
IPIV is not a flag; it's an array of default integers to record interchanges. If you don't get that right, that would give rise to the error. If you supply it as an array of double precision, as you appear to have done, that also will give rise to the rejection. Likewise, INFO, which you may call a flag, must be typed integer (rank 0).
The integer types would be default integer, unless you choose the ilp libraries, in which case they would be integer(kind=8).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi really really thank you,
A is amatrix andIPIV an array:
[bash]REAL (DBL), DIMENSION(nGP1D) :: IPIV[/bash]info is an integer, not standard I suppose, what do you mean forilp libraries.
AboutDGETRI_f95, it seems to be inDGETRI.f90 where it calls some F77 subroutine (ex.F77_GETRF)I suppose using lapack_interfaces.f90.
How can I use it? How shall compile with mkl?
I will use DGETRIeacuse it os double , is it right?
thank again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried also to set all the variables and mlk again:
[bash]./mklvars.sh intel64 [/bash]
and I have:
[bash]./mklvars.sh: 12: Bad substitution diego@diedro:/opt/intel/composerxe-2011/mkl/bin$ [/bash]
Is this the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess you're not using the ilp (64-bit integer) libraries, but you haven't given us that information. You don't need to change anything in the source code for the MKL .mod files; I just referred you to it to point out where the data type mismatch is (evidently, your wrong data type for IPIV, possibly others).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
now I can compile, I hope correctely:
[bash]ifort *.f90 -L$MKLPATH/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread [/bash]
But there is a problem:
If I use:
[bash]SUBROUTINE quadraturepoints USE precisionpc USE basic_funtions_modal_2D USE mkl95_LAPACK[/bash]
Fortran compile without any problem, it recognize also:
[bash]CALL DGETRF_F95 (Inv,IPIV,INFO)[/bash]however the program is non able to run to the end. I have check, the subroutine
[bash]DGETRF_F95[/bash]seems to not work.
If I choose also
[bash]USE LAPACK95[/bash]and I compile as
[bash] ifort *.f90 -L$MKLPATH/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -llapack95 [/bash]I have the following errors:
[bash]error #6633: The type of the actual argument differs from the type of the dummy argument. [INV] CALL DGETRF_F95 (Inv,IPIV,INFO) --------------------^ quadraturepoints.f90(91): error #6633: The type of the actual argument differs from the type of the dummy argument. [IPIV] CALL DGETRF_F95 (Inv,IPIV,INFO) ------------------------^ quadraturepoints.f90(91): error #6633: The type of the actual argument differs from the type of the dummy argument. [INFO] CALL DGETRF_F95 (Inv,IPIV,INFO) -----------------------------^ compilation aborted for quadraturepoints.f90 (code 1) diego@diedro:~/Desktop/dottorato/src/fortran_src/cgk2D_gauss_n$ [/bash]
why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
now I try ti summurized what is going on.
I am using composerxe2011.0.084
First of all I compile my program as:
[bash] ifort *.f90 -L$MKLPATH/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread [/bash]
After that I wrote a program to test the inversion of a matrix using mkl libraries:
[bash]program inversion use f95_precision use lapack95 implicit none integer(sp) :: I, N,info integer(sp) , dimension(:) , allocatable:: IPIV real (sp) , dimension(:,:) , allocatable:: A, AA N = 3 allocate( IPIV(N) ) allocate( A(N,N), AA(N,N) ) AA(1,1) = 1.0d0; AA(1,2) = 3.0d0; AA(1,3) = 1.0d0 AA(2,1) = 1.0d0; AA(2,2) = 1.0d0; AA(2,3) = 2.0d0 AA(3,1) = 2.0d0; AA(3,2) = 3.0d0; AA(3,3) = 4.0d0 A = AA write(*,*) 'The Matrix A is:' do I = 1,N write(*,*) AA(I,:) end do write(*,*) 'The First Step is to Factorise A' call GETRF( A, IPIV) write(*,*) 'The Inverted Matrix is:' do I = 1,N write(*,*) A(I,:) end do ! write(*,*) 'IPIV',IPIV write(*,*) 'The Second Step is to Invert A' call GETRI(A, IPIV ) ! write(*,*) 'The Inverted Matrix is:' do I = 1,N write(*,*) A(I,:) end do end program inversion[/bash]
and this are the results:
[bash]The Matrix A is: 1.000000 3.000000 1.000000 1.000000 1.000000 2.000000 2.000000 3.000000 4.000000 The First Step is to Factorise A The Inverted Matrix is: 2.000000 3.000000 4.000000 0.5000000 1.500000 -1.000000 0.5000000 -0.3333333 -0.3333333 info 0 IPIV 3 3 3 The Second Step is to Invert A forrtl: severe (174): SIGSEGV, segmentation fault occurred [/bash]
why Do I have a segmentation fault with the GETRI call?
I am not able to understand,GETRF seems to work correctely but notGETRI, and the belong to the same family functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
now I try ti summurized what is going on.
First of all I compile my program as:
[bash] ifort *.f90 -L$MKLPATH/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread [/bash]
After that I wrote a program to test the inversion of a matrix using mkl libraries:
[bash]program inversion use f95_precision use lapack95 implicit none integer(sp) :: I, N,info integer(sp) , dimension(:) , allocatable:: IPIV real (sp) , dimension(:,:) , allocatable:: A, AA N = 3 allocate( IPIV(N) ) allocate( A(N,N), AA(N,N) ) AA(1,1) = 1.0d0; AA(1,2) = 3.0d0; AA(1,3) = 1.0d0 AA(2,1) = 1.0d0; AA(2,2) = 1.0d0; AA(2,3) = 2.0d0 AA(3,1) = 2.0d0; AA(3,2) = 3.0d0; AA(3,3) = 4.0d0 A = AA write(*,*) 'The Matrix A is:' do I = 1,N write(*,*) AA(I,:) end do write(*,*) 'The First Step is to Factorise A' call GETRF( A, IPIV) write(*,*) 'The Inverted Matrix is:' do I = 1,N write(*,*) A(I,:) end do ! write(*,*) 'IPIV',IPIV write(*,*) 'The Second Step is to Invert A' call GETRI(A, IPIV ) ! write(*,*) 'The Inverted Matrix is:' do I = 1,N write(*,*) A(I,:) end do end program inversion[/bash]
and this are the results:
[bash]The Matrix A is: 1.000000 3.000000 1.000000 1.000000 1.000000 2.000000 2.000000 3.000000 4.000000 The First Step is to Factorise A The Inverted Matrix is: 2.000000 3.000000 4.000000 0.5000000 1.500000 -1.000000 0.5000000 -0.3333333 -0.3333333 info 0 IPIV 3 3 3 The Second Step is to Invert A forrtl: severe (174): SIGSEGV, segmentation fault occurred [/bash]
why Do I have a segmentation fault with the GETRI call?
I am not able to understand,GETRF seems to work correctely but notGETRI, and the belong to the same family functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You need to link with LP64 MKL libraries if yourprogram uses default INTEGERs.
Otherwise please try adding -i8 option for ifort to use INTEGER*8to correspond to ILP64 MKL libraries.
Intel MKL Link Line Advisorwill help you too.
You need to link with LP64 MKL libraries if yourprogram uses default INTEGERs.
Otherwise please try adding -i8 option for ifort to use INTEGER*8to correspond to ILP64 MKL libraries.
Intel MKL Link Line Advisorwill help you too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
it seems that does not work.
I'm using ubuntu 11.04 and this is my bash.bashrc (now I have include also the ilp64 to compile also the integer in 64 bit):
[bash]PATH="/opt/intel/compilerpro-12.0.0.084/bin/intel64$PATH" source /opt/intel/compilerpro-12.0.0.084/bin/ifortvars.sh intel64 export LD_LIBRARY_PATH=/opt/intel/compilerpro-12.0.0.084/debugger/lib/intel64:$LD_LIBRARY_PATH export PATH ################################################################################################### source /opt/intel/composerxe-2011.0.084/mkl/bin/mklvars.sh intel64 mod ilp64 export PATH[/bash]
I have use the Intel MKL Link Line Advisorand here is the result:
[bash]-L$(MKLROOT)/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread[/bash]so I compile as:
[bash]~/Desktop/prova/prova3$ ifort *.f90 -L$MKLPATH/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread[/bash]
after that I run the same program, all in single precision, so I use the:
[bash]call GETRF( A, IPIV,info) and call GETRI( A, IPIV,info)[/bash]
but I get the same problem:
[bash] The Matrix A is: 1.000000 3.000000 1.000000 1.000000 1.000000 2.000000 2.000000 3.000000 4.000000 The First Step is to Factorise A The Inverted Matrix is: 2.000000 3.000000 4.000000 0.5000000 1.500000 -1.000000 0.5000000 -0.3333333 -0.3333333 info 0 IPIV 3 3 3 The Second Step is to Invert A forrtl: severe (174): SIGSEGV, segmentation fault occured[/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
GETRF works but not GETRI
Have I done something wrong?
do I have to update my compiler? (compilerpro-12.0.0.084)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
now it seems to work
the code:
[bash]program inversion use f95_precision use lapack95 implicit none !ifort -i8 *.f90 -L$MKLPATH/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core integer(dp) :: I, N,info integer(dp) , dimension(:) , allocatable:: IPIV real (dp) , dimension(:,:) , allocatable:: A, AA N = 3 allocate( IPIV(N) ) allocate( A(N,N), AA(N,N) ) AA(1,1) = 1.0d0; AA(1,2) = 3.0d0; AA(1,3) = 1.0d0 AA(2,1) = 1.0d0; AA(2,2) = 1.0d0; AA(2,3) = 2.0d0 AA(3,1) = 2.0d0; AA(3,2) = 3.0d0; AA(3,3) = 4.0d0 A = AA write(*,*) 'The Matrix A is:' do I = 1,N write(*,*) AA(I,:) end do write(*,*) 'The First Step is to Factorise A' call GETRF( A, IPIV,info) write(*,*) 'The Inverted Matrix is:' do I = 1,N write(*,*) A(I,:) end do ! write(*,*) 'info',info write(*,*) 'IPIV',IPIV write(*,*) 'The Second Step is to Invert A' call GETRI(A, IPIV,info) ! write(*,*) 'The Inverted Matrix is:' do I = 1,N write(*,*) A(I,:) end do end program inversion[/bash]and I compile as:
[bash] ifort -i8 *.f90 -L$MKLPATH/lib/em64t -lmkl_blas95_ilp64 -lmkl_lapack95_ilp64 -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread[/bash]
now I have a new question:
If I want to compile inQuadruple precision?
what are the difference between GETRi e DGETRI, because when I compile with DGETRI?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There's no MKL support for quad precision, in part because quad precision (e.g. ifort REAL(KIND=16)) doesn't allow for the optimizations typical of MKL, including vectorization. You could build the netlib functions using ifort quad precision, if you chose.
The lapack95 getri is simply a way of letting the compiler choose among the f77 ?getri functions, supplying the additional arguments automatically.
The lapack95 getri is simply a way of letting the compiler choose among the f77 ?getri functions, supplying the additional arguments automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
ok, I get it.
However, DGETRI does not work, I have a segmetation fault error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
do you know why?
This is just to understand better.
Everything is working now:
[bash]CALL GETRF(Inv,IPIV,info) CALL GETRI(Inv,IPIV,info) Coeff1D = TRANSPOSE(Inv) DO i=1,nCP1D DO j=1,nCP1D Coeff1D(i,j) = REAL(Coeff1D(i,j),R16P) ENDDO ENDDO[/bash]
in this way I get also the quadruple precision

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page