<div dir="ltr">Hi,<div><br></div><div>I am trying to load a matrix and a right hand side into Petsc from a file. The matrix and rhs are preprocessed from matrix market format using the following python script:</div><div><br></div><div><div>import <a href="http://scipy.io">scipy.io</a>, PetscBinaryIO</div><div><br></div><div>A = scipy.io.mmread('sherman2.mtx')</div><div>PetscBinaryIO.PetscBinaryIO().writeMatSciPy(open('sherman2','w'), A)</div><div><br></div><div>B = scipy.io.mmread('sherman2_rhs1.mtx')</div><div>PetscBinaryIO.PetscBinaryIO().writeVec(open('sherman2_rhs','w'), B)</div><div><br></div><div>The binary matrix sherman2 and rhs sherman2_rhs are then being loaded into Petsc using the following code:</div><div><br></div><div><div> PetscErrorCode ierr;</div><div> PetscViewer fd; /* viewer */</div><div> Mat A; /* linear system matrix */</div><div> Vec b; /* RHS */</div><div> char file[2][PETSC_MAX_PATH_LEN];</div><div> PetscBool flg, PetscPreLoad = PETSC_FALSE;</div><div> PetscDraw dc;</div><div> PetscInt size;</div><div> PetscReal value;</div><div><br></div><div> PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;</div><div> //PetscPrintf(MPI_COMM</div><div> ierr = PetscOptionsGetString(PETSC_NULL,PETSC_NULL,"-f",file[0],PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr);</div><div> if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate binary file with the -f option");</div><div> // Load Matrix A</div><div> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,file[0],FILE_MODE_READ,&fd);CHKERRQ(ierr);</div><div><br></div><div> ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);</div><div> ierr = MatSetFromOptions(A);CHKERRQ(ierr);</div><div> ierr = MatLoad(A,fd);CHKERRQ(ierr);</div><div> ierr = MatView(A, PETSC_VIEWER_STDOUT_WORLD);</div><div><br></div><div><br></div><div> // Load RHS</div><div> flg = PETSC_FALSE;</div><div> ierr = PetscOptionsGetString(PETSC_NULL,PETSC_NULL,"-rhs",file[1],PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr);</div><div> if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate rhs file with the -rhs option");</div><div><br></div><div> ierr = VecCreate(PETSC_COMM_WORLD, &b);CHKERRQ(ierr);</div><div> ierr = PetscViewerDestroy(&fd);CHKERRQ(ierr);</div><div> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,file[1],FILE_MODE_READ,&fd);CHKERRQ(ierr);</div><div> ierr = VecSetFromOptions(b);CHKERRQ(ierr);</div><div><br></div><div> ierr = VecLoad(b,fd);CHKERRQ(ierr);</div></div><div><br></div><div><br></div><div>While the matrix loads correctly, when I try to load the vector b, the behavior of the program becomes unexpected afterwards. For instance, if I try to view the vector, sometimes it prints and sometimes not and even when it prints, it only shows some entries in process 0 and then stops.</div><div><br></div><div>AM I DOING SOMETHING WRONG IN PREPROCESSING? Or am I missing something?</div><div><br></div><div>Thank you</div><div><br></div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div></div><font size="2"><b><span style="color:rgb(7,55,99)"><i>Najeeb Ahmad</i></span></b></font></div><div><font size="2"><b><font color="#073763"><i><br></i></font></b></font><div dir="ltr" style="font-size:small"><div><font size="2"><b><span style="color:rgb(120,63,4)">Research and Teaching Assistant</span><br></b></font></div><div><font size="2"><b><font color="#000000">PARallel and MultiCORE Computing Laboratory (ParCoreLab)</font><span style="color:rgb(120,63,4)"> </span></b></font></div><font size="2"><b>Computer Science and Engineering<br></b></font></div><div style="font-size:small"><font size="2"><b>Koç University, Istanbul, Turkey</b></font></div></div></div></div><div><font size="2"><b><br></b></font></div></div></div></div></div></div></div></div>
</div></div>