On Tue, Aug 30, 2011 at 3:43 AM, khalid ashraf <khalid_eee at yahoo.com> wrote:
> Hi, > I am trying to load a vector that I saved as PetscBinary file. > On a single processor, I have to put an initial PetscBinaryRead command & > put the subsequent reads in the loop. Then I get the correct answer. I don't > understand why an initial PetscBinaryRead is required. Anyway, with this, > the code works fine on single processor. > > However, on multiple processors, the input file and the vector after > reading are not in the same order. I think that somehow I have to pass the > information to each processor as to which part of the binary file to read. > Please tell me how to do this. > Is there a reason you are not using VecLoad, http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Vec/VecLoadIntoVector.html? Matt > Thanks. > > Khalid > > > Here is the code: > > PetscViewerBinaryOpen(appctx->comm,"Pxbin_10.out",FILE_MODE_READ,&viewer); > PetscViewerBinaryGetDescriptor(viewer,&fd); > PetscBinaryRead(fd,header,1,PETSC_SCALAR); > > for (k=zs; k<zs+zm; k++) { > for (j=ys; j<ys+ym; j++) { > for (i=xs; i<xs+xm; i++) { > PetscBinaryRead(fd,header,1,PETSC_SCALAR); > u_localptr[k][j][i] = header[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/20110830/3215489d/attachment.htm>
