<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Dear PETSC users,</div><div dir="ltr"><br></div><div dir="ltr">I try to verify a matrix by printing a PETSC matrix and comparing its elements with reference values. Below is my test code. </div><div dir="ltr"><br></div><div dir="ltr">It works well when a single process is used. The output file is created quickly. In contrast, when multiple processes (>2) are used, printing matrix is stuck (the parallel matrix is assembled very quickly owing to memory preallocation). The output file just prints two lines below. No element is printed. </div><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr">Mat Object: 2 MPI processes</div><div dir="ltr">  type: mpiaij</div><div><br></div></div><div>I assume that printing matrix is also designed for a parallel matrix. Does this suggest that my parallel matrix includes any errors? Otherwise, does this work only for a serial matrix?</div><div><br></div><div>Thanks for reading this question.</div><div><br></div><div>Regards,</div><div>Evan</div><div><br></div><div dir="ltr"><div><div>MatCreateAIJ(PETSC_COMM_WORLD, m, n, M, N, 0, d_nnz_A, 0, o_nnz_A, &Mat_A);</div><div>MatSetFromOptions(Mat_A);</div><div><br></div><div>for (int i=rstart_A[rank]; i<rend_A[rank]; i++) {</div><div><span style="white-space:pre">   </span>mat_value=val_A[i]+PETSC_i*0.0;</div><div><span style="white-space:pre">       </span>MatSetValue(Mat_A, i_A[i],j_A[i],mat_value,ADD_VALUES);</div><div>}</div><div><br></div><div>MatAssemblyBegin(Mat_A, MAT_FINAL_ASSEMBLY);</div><div>MatAssemblyEnd(Mat_A, MAT_FINAL_ASSEMBLY);</div><div><br></div><div>PetscViewer viewer;</div><div>PetscViewerASCIIOpen(PETSC_COMM_WORLD,"Mat_A",&viewer);</div><div>MatView(Mat_A,viewer);</div><div>PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);</div><div>PetscViewerPopFormat(viewer);</div><div>PetscViewerDestroy(&viewer);</div></div></div></div></div></div></div>