<div dir="ltr"><div>We have the subroutine below that scatters three vectors.  We have used this code on many machines and it works fine but on one machine data does not get scattered correctly. The first scatter looks OK, but it looks like the other two are missing data.</div><div><br></div><div>Am I using this correctly?  Should we use VecGetArray in here instead of just using the pointer used for construction? Is there a race condition here that I'm missing?</div><div><br></div><div>Thanks,</div><div>Mark</div><div><br></div><div>subroutine scatter_to_xgc(a_ts,a_XX,a_n1,a_apar,a_phi,ierr)</div><div>  use petscts</div><div>  use sml_module,only:sml_mype</div><div>  use xgc_ts_module</div><div>  implicit none</div><div>  type(xgc_ts),intent(in)::a_ts</div><div>  Vec,intent(in)::a_XX</div><div>  real (kind=8),dimension(a_ts%nnode)::a_n1,a_apar,a_phi</div><div>  PetscErrorCode,intent(out)::ierr</div><div>  ! locals</div><div>  PetscInt,parameter::ione=1</div><div>  PetscScalar,dimension(a_ts%nnode)::n1,apar,phi</div><div>  Vec::xxvec(0:2)</div><div><br></div><div>  ! scatter solution back - n1</div><div>  n1 = a_n1</div><div>  call VecCreateSeqWithArray(PETSC_COMM_SELF,ione,a_ts%nnode,n1,xxvec(0),ierr);CHKERRQ(ierr)</div><div>  call VecScatterBegin(a_ts%from_petsc(0),a_XX,xxvec(0),INSERT_VALUES,SCATTER_FORWARD,ierr)</div><div><br></div><div>  ! scatter solution back - apar</div><div>  apar = a_apar</div><div>  call VecCreateSeqWithArray(PETSC_COMM_SELF,ione,a_ts%nnode,apar,xxvec(1),ierr);CHKERRQ(ierr)</div><div>  call VecScatterBegin(a_ts%from_petsc(1),a_XX,xxvec(1),INSERT_VALUES,SCATTER_FORWARD,ierr)</div><div><br></div><div>  ! scatter solution back - phi</div><div>  phi = a_phi</div><div>  call VecCreateSeqWithArray(PETSC_COMM_SELF,ione,a_ts%nnode,phi,xxvec(2),ierr);CHKERRQ(ierr)</div><div>  call VecScatterBegin(a_ts%from_petsc(2),a_XX,xxvec(2),INSERT_VALUES,SCATTER_FORWARD,ierr)</div><div><br></div><div>  ! end</div><div>  call VecScatterEnd(  a_ts%from_petsc(0),a_XX,xxvec(0),INSERT_VALUES,SCATTER_FORWARD,ierr)</div><div>  a_n1 = n1</div><div>  call VecDestroy(xxvec(0),ierr)</div><div><br></div><div>  call VecScatterEnd(  a_ts%from_petsc(1),a_XX,xxvec(1),INSERT_VALUES,SCATTER_FORWARD,ierr)</div><div>  a_apar = apar</div><div>  call VecDestroy(xxvec(1),ierr)</div><div><br></div><div>  call VecScatterEnd(  a_ts%from_petsc(2),a_XX,xxvec(2),INSERT_VALUES,SCATTER_FORWARD,ierr)</div><div>  a_phi = phi</div><div>  call VecDestroy(xxvec(2),ierr)</div><div><br></div><div>  return</div><div>end subroutine scatter_to_xgc</div></div>