HP MLIB User's Guide Vol. 2 7th Ed.
Chapter 11 Introduction to Distributed SuperLU 751
Sample programs
* initializes the SuperLU_DIST 2D process grid.
*
* MPI_COMM_WORLD is the base communicator upon which the new
* grid is formed.
* nprow is the number of process rows.
* npcol is the number of process columns.
* grid points to the storage of the SuperLU_DIST
* 2D process grid.
*/
superlu_gridinit(MPI_COMM_WORLD, nprow, npcol, &grid);
/* Bail out if I do not belong in the grid. */
iam = grid.iam;
if ( iam >= nprow * npcol )
goto out;
/* ------------------------------------------------------------
Set up the input matrix and the right-hand side.
------------------------------------------------------------*/
/* Set up data of Harwell-Boeing formatted sparse matrix.
* The data can also be read from a Harwell-Boeing formatted
* data set.
*/
m=5; n=5; nnz=14; ldb = m;
if (!(a = (double *) malloc(nnz * sizeof(double)))) {
printf(“malloc fails for a[]”);
exit (-1);
}
if (!(rowind = (int_t *) malloc(nnz * sizeof(int_t)))) {
printf(“malloc fails for rowind[]”);
exit (-1);
}
if (!(colptr = (int_t *) malloc((n+1) * sizeof(int_t)))) {
printf(“malloc fails for colptr[]”);
exit (-1);
}
if (!(b=(double *) malloc(m*nrhs*sizeof(double)))) {
printf(“malloc fails for b[]”);
exit (-1);
}
a[0]=1.1; a[1]=3.1; a[2]=5.1; a[3]=3.2; a[4]=4.2; a[5]=5.2;
a[6]=1.3;
a[7]=2.3; a[8]=3.3; a[9]=1.4; a[10]=2.4; a[11]=3.4; a[12]=4.4;
a[13]=5.5;
rowind[0]=0; rowind[1]=2; rowind[2]=4; rowind[3]=2; rowind[4]=3;
rowind[5]=4; rowind[6]=0; rowind[7]=1; rowind[8]=2; rowind[9]=0;