[petsc-users] Loading vector in parallel using PetscBinaryRead

khalid ashraf khalid_eee at yahoo.com
Mon Aug 29 22:43:43 CDT 2011


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.

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];

  }

  }
  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110829/83123661/attachment.htm>


More information about the petsc-users mailing list