On Mon, Feb 14, 2011 at 11:01 AM, Gaurish Telang <gaurish108 at gmail.com>wrote:
> Hi, > > 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. > > 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. > > 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); *)?? > > e.g. > > The ASCII text file (BEFORE converting to binary) with standalone code > looks like > > 4 > 6 > > The output I get on -vec_view is > > 0 > 0 > 4 > 6 > > But with VecGetSize I get the vector length to be 2. !!! > Send the entire output and input files to petsc-maint at mcs.anl.gov. I guarantee you that this is just misunderstanding, but its impossible to see exactly what you are doing from this sample. For instance, in parallel -vec_view will print Process [k]. Matt > Thank you, > > Gaurish > > > %--------------------------------------------- > Code: > int main(int argc,char **args) > { > Mat A ; > Vec b ; > PetscTruth flg_A,flg_b ; > PetscErrorCode ierr ; > PetscInt m,n,length ; > char > file_A[PETSC_MAX_PATH_LEN],file_b[PETSC_MAX_PATH_LEN] ; > PetscViewer fd_A, fd_b ; > > PetscInitialize(&argc,&args,(char *)0,help); > > /* Get the option typed from the terminal */ > ierr = > PetscOptionsGetString(PETSC_NULL,"-matrix",file_A,PETSC_MAX_PATH_LEN-1,&flg_A);CHKERRQ(ierr); > if (!flg_A) SETERRQ(1,"Must indicate binary matrix matrix file with the > -matrix option"); > > ierr = > PetscOptionsGetString(PETSC_NULL,"-vector",file_b,PETSC_MAX_PATH_LEN-1,&flg_b);CHKERRQ(ierr); > if (!flg_b) SETERRQ(1,"Must indicate binary matrix matrix file with the > -vector option"); > > /* Load the matrix and vector */ > ierr = > PetscViewerBinaryOpen(PETSC_COMM_WORLD,file_A,FILE_MODE_READ,&fd_A);CHKERRQ(ierr); > ierr = MatLoad(fd_A,MATMPIAIJ,&A);CHKERRQ(ierr); > ierr = PetscViewerDestroy(fd_A);CHKERRQ(ierr); > > //ierr=MatView(A,PETSC_VIEWER_DRAW_WORLD);CHKERRQ(ierr); > > > ierr = > PetscViewerBinaryOpen(PETSC_COMM_WORLD,file_b,FILE_MODE_READ,&fd_b);CHKERRQ(ierr); > ierr = VecLoad(fd_b,VECMPI,&b);CHKERRQ(ierr); > ierr = PetscViewerDestroy(fd_b);CHKERRQ(ierr); > > /* Simple Cursory checks */ > ierr = MatGetSize(A,&m,&n);CHKERRQ(ierr); > ierr=PetscPrintf(PETSC_COMM_WORLD,"\n %i %i \n",m,n);CHKERRQ(ierr); > > ierr=VecGetSize(b,&length);CHKERRQ(ierr); > ierr=PetscPrintf(PETSC_COMM_WORLD,"%i \n",length);CHKERRQ(ierr); > //ierr=VecView(b,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); > > > > /* Destroy Objects. */ > MatDestroy(A); > VecDestroy(b); > > ierr = PetscFinalize();CHKERRQ(ierr); > > sleep(4); > > return 0; > } > > > > > > > > > > > > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110214/c1451f39/attachment.htm>