help to use pdgesvx_

help to use pdgesvx_

Hi,

I need help to use pdgesvx. my code is below. I can use pdgesv_ and get correct results, but I have trouble with pdgesvx_. I couldn't understand how it work.it gives no result and no error, only program exits without anyexplanation.Please help ...

Regards

#include
#include
#include
#include "mpi.h"

#define AA(i,j) AA[(i)*M+(j)]
#define BB(i,j) BB[(i)*N+(j)]

int main(int argc, char **argv) {
int i, j, k;
/************ MPI ***************************/
int myrank_mpi, nprocs_mpi;
MPI_Init( &argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank_mpi);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs_mpi);
/********************************************************/
/************ BLACS ***************************/
int ictxt, nprow, npcol, myrow, mycol,nb;
int info,itemp;
int ZERO=0,ONE=1;
nprow = 2; npcol = 2; nb =2;
Cblacs_pinfo( &myrank_mpi, &nprocs_mpi ) ;
Cblacs_get( -1, 0, &ictxt );
Cblacs_gridinit( &ictxt, "R", nprow, npcol );
Cblacs_gridinfo( ictxt, &nprow, &npcol, &myrow, &mycol );
int M=5;
double *AA = (double*) malloc(M*M*sizeof(double));
for(i=0;i for(j=0;j<M;j++)
{
if(i==j)
AA[i*M+j]=i*M+j+5;
else
AA[i*M+j]=i*M+j+1;
}
int N=5;
double *BB = (double*) malloc(M*N*sizeof(double));
for(i=0;i for(j=0;j BB[i*N+j]=i*(M+1)+j*(N+1)+1;
int descA[9],descB[9],descC[9];
int mA = numroc_( &M, &nb, &myrow, &ZERO, &nprow );
int nA = numroc_( &M, &nb, &mycol, &ZERO, &npcol );
int mB = numroc_( &M, &nb, &myrow, &ZERO, &nprow );
int nB = numroc_( &N, &nb, &mycol, &ZERO, &npcol );

descinit_(descA, &M, &M, &nb, &nb, &ZERO, &ZERO, &ictxt, &mA, &info);
descinit_(descB, &M, &N, &nb, &nb, &ZERO, &ZERO, &ictxt, &mB, &info);
double *A = (double*) calloc(mA*nA,sizeof(double));
double *B = (double*) calloc(mB*nB,sizeof(double));

Cblacs_barrier(ictxt,"A");
printf("\\n");
int sat,sut;
for(i=0;i<mA;i++)
for(j=0;j<nA;j++){
sat= (myrow*nb)+i+(i/nb)*nb;
sut= (mycol*nb)+j+(j/nb)*nb;
A[j*mA+i]=AA(sat,sut);
}
for(i=0;i<mB;i++)
for(j=0;j<nB;j++){
sat= (myrow*nb)+i+(i/nb)*nb;
sut= (mycol*nb)+j+(j/nb)*nb;
B[j*mB+i]=BB(sat,sut);
}

Cblacs_barrier(ictxt,"A");
int *ippiv = (int *)calloc(M+nb,sizeof(int)) ;
if (ippiv==NULL){ printf("error of memory allocation IPIV on proc %dx%d\\n",myrow,mycol); exit(0); }

int descAf[9];
descinit_ (descAf, &M, &M, &nb, &nb, &ZERO, &ZERO, &ictxt, &mA, &info);
double *Af =(double *) calloc (mA * nA, sizeof (double));

double rcond;
double *ferr = (double *)calloc(nB,sizeof(double)) ;
double *berr = (double *)calloc(nB,sizeof(double)) ;
double *r = (double *)calloc(mA,sizeof(double)) ;
double *c = (double *)calloc(mA,sizeof(double)) ;

double *X = (double*) calloc(mB*nB,sizeof(double));
int descX[9];
descinit_ (descX, &M, &N, &nb, &nb, &ZERO, &ZERO, &ictxt, &mB, &info);

int lwork=M+N;
double *work=(double *)calloc(M+N,sizeof(double)) ;

int lrwork=M;
int *rwork = (int *)calloc(lrwork,sizeof(int)) ;

pdgesvx_('N','N',&M,&N,A,&ONE,&ONE,descA,Af,&ONE,&ONE,descAf,ippiv,'N',r,c,B,&ONE,&ONE,descB,X,&ONE,&ONE,descB,&rcond,ferr,berr,work,&lwork,rwork,&lrwork,&info);
Cblacs_barrier(ictxt,"A");
Cblacs_gridexit( 0 );
MPI_Finalize();
return 0;
}

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.