I have linked a C++ program with fortran dagmg.f90 routine from AGMG library. Initially the sparse matrix is built by Eigen library in CRS format and then i convert it to the required format for fortran routine. AGMG runs and calculates the number of non-zeros and displays the number of unknowns. But then it suddenly displays segmentation fault. I am unable to figure out what is the reasons behind it.
int jatest[NNZ];
int iatest[nodes+1];
double bftest[nodes];
double VXtest[nodes];
// code to convert Af into a, ja, ia vectors for AGMG
double *aptr; int* japtr; int* iaptr;
aptr = Af.valuePtr();
japtr = Af.innerIndexPtr();
iaptr = Af.outerIndexPtr();
for (i = 0; i < NNZ ; i++ ){
atest[i] = aptr[i];
jatest[i] = japtr[i] + 1;
// cout << atest[i] << "\t" << japtr[i] << endl;
}
for ( i = 0; i <= nodes; i++){
iatest[i] = iaptr[i] + 1;
}
dagmg_(nodes,atest,jatest,iatest,bftest,VXtest,ijob,iprint,nrest,iter,tol);
The output looks like this:
*ENTERING AGMG ************************************
Number of unknowns: 17
** Nonzeros : 51 (per row: 3.00)
Segmentation fault
Why am i getting this fault ???
Problem solved :
Actually the problem was with the LAPACK function being called by AGMG for direct solution to the coarsest level. After changing the lapack libraries linked to the AGMG, this problem of segmentation fault is solved.
Just for reference :