Commits

BarryFSmith committed d1a7837

make sure no initialized data is sent via MPI to confuse valgrind

Comments (0)

Files changed (1)

src/tao/leastsquares/examples/tutorials/chwirut2.c

 #define __FUNCT__ "TaskWorker"
 PetscErrorCode TaskWorker(AppCtx *user)
 {
-  PetscReal      x[NPARAMETERS],f;
+  PetscReal      x[NPARAMETERS],f = 0.0;
   PetscMPIInt    tag=IDLE_TAG;
   PetscInt       index;
   MPI_Status     status;
   while(checkedin < user->size-1) {
     ierr = MPI_Recv(&f,1,MPIU_REAL,MPI_ANY_SOURCE,MPI_ANY_TAG,PETSC_COMM_WORLD,&status);CHKERRQ(ierr);
     checkedin++;
+    ierr = PetscMemzero(x,NPARAMETERS*sizeof(PetscReal));CHKERRQ(ierr);
     ierr = MPI_Send(x,NPARAMETERS,MPIU_REAL,status.MPI_SOURCE,DIE_TAG,PETSC_COMM_WORLD);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);