On Mon, Feb 14, 2011 at 11:01 AM, Gaurish Telang <span dir="ltr"><<a href="mailto:gaurish108@gmail.com">gaurish108@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>I am having trouble understanding the -vec_view output of the simple code I have pasted underneath. In it, I am just reading two PetscBinary files created with a stand alone code. one containing a matrix and another containing a vector. <br>
<br>However on doing -vec_view during run-time, I get a sequence of zeros before the actual vector of the binary file is printed. But when I read the PetscBinary file in MATLAB I get the correct vector. <br><br>Why does this happen? Is it because I am using vector type VECMPI to load the binary file (* ierr = VecLoad(fd_b,VECMPI,&b);CHKERRQ(ierr); *)?? <br>
<br>e.g. <br><br>The ASCII text file (BEFORE converting to binary) with standalone code looks like<br><br>4<br>6<br><br>The output I get on -vec_view is <br><br>0<br>0<br>4<br>6<br><br>But with VecGetSize I get the vector length to be 2. !!!<br>
</blockquote><div><br></div><div>Send the entire output and input files to <a href="mailto:petsc-maint@mcs.anl.gov">petsc-maint@mcs.anl.gov</a>. I guarantee you that</div><div>this is just misunderstanding, but its impossible to see exactly what you are doing from</div>
<div>this sample. For instance, in parallel -vec_view will print Process [k].</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thank you,<br><br>Gaurish<br><br><br>%---------------------------------------------<br>Code:<br>int main(int argc,char **args)<br>{<br> Mat A ;<br> Vec b ;<br>
PetscTruth flg_A,flg_b ;<br> PetscErrorCode ierr ;<br> PetscInt m,n,length ;<br> char file_A[PETSC_MAX_PATH_LEN],file_b[PETSC_MAX_PATH_LEN] ; <br>
PetscViewer fd_A, fd_b ;<br><br> PetscInitialize(&argc,&args,(char *)0,help);<br><br> /* Get the option typed from the terminal */<br> ierr = PetscOptionsGetString(PETSC_NULL,"-matrix",file_A,PETSC_MAX_PATH_LEN-1,&flg_A);CHKERRQ(ierr);<br>
if (!flg_A) SETERRQ(1,"Must indicate binary matrix matrix file with the -matrix option");<br><br> ierr = PetscOptionsGetString(PETSC_NULL,"-vector",file_b,PETSC_MAX_PATH_LEN-1,&flg_b);CHKERRQ(ierr);<br>
if (!flg_b) SETERRQ(1,"Must indicate binary matrix matrix file with the -vector option");<br><br> /* Load the matrix and vector */<br> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,file_A,FILE_MODE_READ,&fd_A);CHKERRQ(ierr);<br>
ierr = MatLoad(fd_A,MATMPIAIJ,&A);CHKERRQ(ierr);<br> ierr = PetscViewerDestroy(fd_A);CHKERRQ(ierr);<br><br> //ierr=MatView(A,PETSC_VIEWER_DRAW_WORLD);CHKERRQ(ierr);<br> <br><br> ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,file_b,FILE_MODE_READ,&fd_b);CHKERRQ(ierr);<br>
ierr = VecLoad(fd_b,VECMPI,&b);CHKERRQ(ierr);<br> ierr = PetscViewerDestroy(fd_b);CHKERRQ(ierr);<br><br> /* Simple Cursory checks */<br> ierr = MatGetSize(A,&m,&n);CHKERRQ(ierr);<br> ierr=PetscPrintf(PETSC_COMM_WORLD,"\n %i %i \n",m,n);CHKERRQ(ierr);<br>
<br> ierr=VecGetSize(b,&length);CHKERRQ(ierr);<br> ierr=PetscPrintf(PETSC_COMM_WORLD,"%i \n",length);CHKERRQ(ierr);<br> //ierr=VecView(b,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<br><br><br><br> /* Destroy Objects. */<br>
MatDestroy(A);<br> VecDestroy(b);<br><br> ierr = PetscFinalize();CHKERRQ(ierr);<br><br> sleep(4);<br><br> return 0;<br>}<br><br><br><br><br><br><br><br><br><br><br> <br>
</blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>