[fortran]program dns2csr complex(8), allocatable :: Aall(:,:) integer, allocatable :: ia (:) integer, allocatable :: ja (:) complex(8), allocatable :: zval(:) real(8), allocatable :: dval(:) ! Variables needed by MKL integer :: job(1:8) integer :: info integer, parameter :: nrow = 3 integer, parameter :: ncol = 3 ! Allocate workspace allocate(Aall(1:3,1:3)) allocate(ia (1:nrow+1)) ! Initialize dns matrix Aall = cmplx(0.0d0,0.0d0) Aall(1,1) = cmplx(1.0d0,0.0d0) Aall(3,1) = cmplx(5.0d0,0.0d0) Aall(2,2) = cmplx(4.0d0,0.0d0) Aall(3,2) = cmplx(0.0d0,4.0d0) Aall(1,3) = cmplx(3.0d0,0.0d0) ! Set job job(1) = 0 ! Convert from dense to CSR format job(2) = 1 ! One-based indexing for dense job(3) = 1 ! One-based indexing for CSR job(4) = 2 ! Pass the whole dense matrix to MKL routines ! Compute ia only job(5) = 0 ! Max number of nnz job(6) = 0 ! Construct ia only allocate(ja(1),zval(1),dval(1)) call mkl_zdnscsr(job,nrow,ncol,Aall,nrow,zval,ja,ia,info) print *,ia print *,info call mkl_ddnscsr(job,nrow,ncol,real(Aall),nrow,dval,ja,ia,info) print *,ia print *,info deallocate(ia,ja,dval,zval) deallocate(Aall) end program dns2csr[/fortran]I compile this program with the command:
[bash]ifort -O0 -warn all dns2csr.f90 -lmkl_intel -lmkl_sequential -lmkl_core[/bash]Then running a.out I get the following output:
[bash]$ ./a.out 1 1 1 1 0 1 3 4 5 3 [/bash]While the correct one should have been:
[bash]$ ./a.out 1 3 4 6 3 1 3 4 5 3 [/bash]It seems that conversion from dense format to csr format works properly only with real(8) type. I wonder if the routine mkl_zdnscsr is somehow buggy or if I am doing some trivial error I am not able to spot. Is anyone able to reproduce the same behavior?
Convert a sparse matrix in dense representation to the CSR format and vice versa.
COMPLEX for mkl_cdnscsr
DOUBLE COMPLEX for mkl_zdnscsr
INTERFACE is as follows:
SUBROUTINE mkl_zdnscsr(job, m, n, adns, lda, acsr, ja, ia, info)
INTEGER m, n, lda, info
INTEGER ja(*), ia(m+1)
DOUBLE COMPLEX adns(*), acsr(*)
However, in your example complex(8) and real(8)are used for mkl_zdnscsr function.
HiMassimiliano, thanks for the problem you raised.This issue has been submitted to our internal development tracking database for further investigation, we will inform you once a new update becomes available.
Here is a bug tracking number for your reference: 200209064.
[bash]1 3 4 6 0 1 3 4 5 0 [/bash]which I think is fine. Many thanks for updating me on the issue!