<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr; font-family: Tahoma; color: rgb(0, 0, 0); font-size: 13px;">
<div style=""><br>
Hi, Petsc Team, <br>
<br>
Recently I encounter a weird problem for segmentation violation. I wrote a simple test code to describe it. Here the line " pp = sk[j+1][i].p; " causes segmentation violation trouble when I try to invoke values of ghost points in j direction. If I change it
into "pp = sk[j][i+1].p;" invoking ghost point values in i diection, then it works smoothly. I check previous archives about segmentation violation, but cannot find any clue for this. Can you point out where is wrong here or is it a bug?<br>
<br>
<br>
Thank you.<br>
<br>
<br>
Zhisong Li<br>
<br>
<br>
<br>
static char help[] = "test";<br>
#include "petscda.h"<br>
<br>
typedef struct { PetscScalar p; } Field;<br>
<br>
int main(int argc, char **args)<br>
{ Vec xx; <br>
PetscInt dof = 1, m = 24, n= 32, i, j, xs, ys, xm, ym, yints, yinte, xints, xinte;<br>
PetscScalar pp;<br>
DA da;<br>
Field **sk;<br>
PetscInitialize(&argc, &args, (char *)0, help) ;<br>
<br>
DACreate2d(PETSC_COMM_WORLD, DA_NONPERIODIC, DA_STENCIL_STAR, m, n, PETSC_DECIDE, PETSC_DECIDE, dof, 1, PETSC_NULL, PETSC_NULL, &da);<br>
DACreateGlobalVector(da, &xx); <br>
DAGetCorners(da, &xs, &ys, 0, &xm, &ym, 0);<br>
xints = xs; xinte = xs+xm; yints = ys; yinte = ys+ym; <br>
<br>
VecSet(xx,1.0);<br>
<br>
DAVecGetArray(da, xx, &sk); <br>
if (xints == 0){ xints = xints + 1; } <br>
if (yints == 0){ yints = yints + 1; } <br>
if (xinte == m){ xinte = xinte - 1; } <br>
if (yinte == n){ yinte = yinte - 1; } <br>
<br>
for (j=yints; j<yinte; j++){ <br>
for (i=xints; i<xinte; i++) { pp = sk[j+1][i].p; }<br>
} <br>
<br>
DAVecRestoreArray(da, xx, &sk); <br>
VecDestroy(xx);<br>
DADestroy(da); <br>
PetscFinalize();<br>
PetscFunctionReturn(0);<br>
}<br>
<br>
</div>
</div>
</body>
</html>