<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Not sure if this is a bug or not, but, for the following code:<div class=""><br class=""></div><div class=""><div class="">#include <petscvec.h></div><div class="">#include <petscdm.h></div><div class="">#include <petscdmda.h></div><div class=""><br class=""></div><div class="">typedef struct{</div><div class="">  PetscScalar u;</div><div class="">  PetscScalar v;</div><div class="">}b_node;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">int main(int argc, char **args)</div><div class="">{</div><div class="">  char dataname[PETSC_MAX_PATH_LEN] = "testvec.bin";</div><div class="">  PetscInt N = 8;</div><div class="">  DM dm;</div><div class="">  Vec b;</div><div class="">  PetscScalar mass, eng;</div><div class="">  PetscViewer viewer;</div><div class="">  DMDALocalInfo info;</div><div class="">  b_node * b_array;</div><div class="">  Vec b_local;</div><div class="">  PetscInt local_index, local_width, i;</div><div class="">  PetscScalar u, v;</div><div class=""><br class=""></div><div class="">  </div><div class="">  PetscInitialize(&argc,&args,NULL,NULL);</div><div class=""><br class=""></div><div class="">  PetscOptionsGetInt(NULL,NULL,"-N",&N,NULL);</div><div class="">  </div><div class="">  DMDACreate1d(PETSC_COMM_WORLD, DM_BOUNDARY_GHOSTED, N, 2 , 1 , NULL, &dm);</div><div class="">  DMCreateGlobalVector(dm ,&b);</div><div class=""><br class=""></div><div class="">  /* Load vector from disk */</div><div class="">  PetscViewerBinaryOpen(PETSC_COMM_WORLD,dataname, FILE_MODE_READ, &viewer);</div><div class="">  VecLoad(b, viewer);</div><div class="">  PetscViewerDestroy(&viewer);</div><div class=""><br class=""></div><div class="">  /* Inspect with viewer */</div><div class="">  VecView(b, PETSC_VIEWER_STDOUT_WORLD);</div><div class=""><br class=""></div><div class="">  DMGetLocalVector(dm,&b_local);</div><div class="">  DMGlobalToLocalBegin(dm,b,INSERT_VALUES,b_local);</div><div class="">  DMGlobalToLocalEnd(dm,b,INSERT_VALUES,b_local);</div><div class=""><br class=""></div><div class="">  DMDAVecGetArray(dm, b_local, &b_array);</div><div class="">  DMDAGetCorners (dm, &local_index, NULL, NULL,&local_width, NULL, NULL);</div><div class=""><br class=""></div><div class="">  /* Zero out the ghost points */</div><div class="">  if(info.xs == 0){</div><div class="">    b_array[-1].u =0.0;</div><div class="">    b_array[-1].v =0.0;    </div><div class="">  }</div><div class="">  if(info.xs + info.xm == <a href="http://info.mx" class="">info.mx</a>){</div><div class="">    b_array[<a href="http://info.mx" class="">info.mx</a>].u =0.0;</div><div class="">    b_array[<a href="http://info.mx" class="">info.mx</a>].v =0.0;    </div><div class="">  }</div><div class=""><br class=""></div><div class="">  /* Manually inspect */</div><div class="">  for(i=local_index;i<local_index+local_width;i++){</div><div class="">    u = b_array[i].u;</div><div class="">    v = b_array[i].v;</div><div class="">    PetscPrintf(PETSC_COMM_WORLD," %i: u = %g, v = %g\n", i, u, v);</div><div class="">  }</div><div class=""><br class=""></div><div class="">  DMDAVecRestoreArray (dm,b_local,&b_array);</div><div class="">  DMRestoreLocalVector(dm,&b_local);</div><div class="">  </div><div class="">  VecDestroy(&b);</div><div class="">  DMDestroy(&dm) ;</div><div class=""><br class=""></div><div class="">  PetscFinalize();</div><div class="">  return 0;</div><div class="">  </div><div class="">}</div></div><div class=""><br class=""></div><div class="">I am getting the output </div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Vec Object: 1 MPI processes</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  type: seq</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Vec Object:Vec_0x84000000_0 1 MPI processes</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  type: mpi</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Process [0]</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">1.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">0.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">6.12323e-17</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">1.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-1.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">1.22465e-16</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-1.83697e-16</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-1.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">-0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 0: u = 0., v = 0.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 1: u = 0.707107, v = 0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 2: u = 6.12323e-17, v = 1.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 3: u = -0.707107, v = 0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 4: u = -1., v = 1.22465e-16</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 5: u = -0.707107, v = -0.707107</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 6: u = -1.83697e-16, v = -1.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> 7: u = 0.707107, v = -0.707107</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">The input vector is an alternating sequence of cos( pi / 4 * j), sin(pi/4 * j), for j = 0,1,2…7.  What I want to point out is that the first element of this vector, as it is read in,  is 1.  But when we do the manually looping, it spits out u = 0 at index i = 0.  If i turn off the piece of code that zeros out the ghost points, the problem disappears.  The reason I am concerned is that this kind of looping through the local vector with ghost points shows up in a piece of my code, and I am now concerned about the output.  Do I have a bug here?  </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; border-spacing: 0px;">-gideon</span>

</div>

<br class=""></div></body></html>