static char help[] = "Test conversion of ScaLAPACK matrices.\n\n"; #include int main(int argc, char** argv) { Mat A,A_scalapack; PetscInt i,j,M=10,N=5,nloc,mloc,nrows,ncols; PetscMPIInt rank,size; IS isrows,iscols; const PetscInt *rows,*cols; PetscScalar *v; MatType type; PetscBool isDense,isAIJ,flg; PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-M",&M,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL)); /* Create a matrix */ PetscCall(MatCreate(PETSC_COMM_WORLD, &A)); mloc = PETSC_DECIDE; PetscCall(PetscSplitOwnershipEqual(PETSC_COMM_WORLD,&mloc,&M)); nloc = PETSC_DECIDE; PetscCall(PetscSplitOwnershipEqual(PETSC_COMM_WORLD,&nloc,&N)); PetscCall(MatSetSizes(A,mloc,nloc,M,N)); PetscCall(MatSetType(A,MATDENSE)); PetscCall(MatSetFromOptions(A)); PetscCall(MatSetUp(A)); /* Set local matrix entries */ PetscCall(MatGetOwnershipIS(A,&isrows,&iscols)); PetscCall(ISGetLocalSize(isrows,&nrows)); PetscCall(ISGetIndices(isrows,&rows)); PetscCall(ISGetLocalSize(iscols,&ncols)); PetscCall(ISGetIndices(iscols,&cols)); PetscCall(PetscMalloc1(nrows*ncols,&v)); for (i=0; i