static char help[] = "Tests various routines in MatKAIJ format.\n"; #include #define IMAX 15 int main(int argc,char **args) { Mat A,B,TA; PetscScalar *S,*T; PetscViewer fd; char file[PETSC_MAX_PATH_LEN]; PetscInt m,n,M,N,p=1,q=1,i,j; PetscMPIInt rank,size; PetscBool flg; PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); /* Load AIJ matrix A */ PetscCall(PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&flg)); PetscCheck(flg,PETSC_COMM_WORLD,PETSC_ERR_USER,"Must indicate binary file with the -f option"); PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd)); PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatLoad(A,fd)); PetscCall(PetscViewerDestroy(&fd)); /* Get dof, then create S and T */ PetscCall(PetscOptionsGetInt(NULL,NULL,"-p",&p,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-q",&q,NULL)); PetscCall(PetscMalloc2(p*q,&S,p*q,&T)); for (i=0; i