I'm using mkl_dcsrmultcsr to find a product of sparse matrices, "A" and "B". "A" has many zeros in the array of nonzero elements (because I need so). Result (matrix "C" in csr format) is incorrect. In particular, half of the array jC consists of correct numbers, an there are zeros with some random numbers (pretty big, some of them are negative) in other half. It results in segmentation fault in the following code. How can zeros be in jC? It seems to be malfunctioning of procedure. Most arrays in my program are allocatable, many allocate-deallocate operators, so maybe there is a clue.
Also, I noted some "intresting" thing. If I print two integer variables in the beginning of the code (write(*,*) m,n), there are 0's and some 1's in second half of jC, no big random numbers. And following code works properly, on some stage second half of jC somehow isn't referenced, and products of other matrix are correct. So do happen in the first case (without printing m,n), when biggest positive random number in jC is 10^4, not 10^10.
I'm not an experienced programmer (how you may've seen), so I understand, that I could miss some simple and well-known things, but in that case you will not spend much time to correct me, I suppose :)
Version of MKL:
Processor optimization:Intel Core 2 Duo Processor
Program is running on cluster with Xeon's 8-core nodes.
I'd assume that the root cause of the behavior described by you is that it is not enough memory for storing the result matrix. I'd recommend you to allocate the integer array ic of the size n+1 where n is the number of rows in the the result matrix. Then please call the routine with job=1
call mkl_dcsrmultcsr(trans, job, sort, n, n, n, a,ja,ia, a, ja,ia, ddum, idum, ic, idum, idum)
After that thevalue of ic(n+1)-1 is the exact size of jC and C. After allocation of jC and C, the routine should be called again with job=2 to fill Jc and C.
Another possible reason of the failures is that the column indices of the matrix A or the matrix B are not arranged in the increasing order for each row. I'd recommend to set the parameter sort to 3.
Please provide a test case for reproducing the issue if above suggestions dont workfor you.
All the best