Hi, I am writing the following loop for accessing the vectors in a 3D grid.
for (k=zs; k<zs+zm; k++) {
for (j=ys; j<ys+ym; j++) {
for (i=xs; i<xs+xm; i++) {
if (i<(mx-1))
{
Cx=u_localptr[k][j][i+1]-u_localptr[k][j][i];
}
else
{
Cx=u_localptr[k][j][i]-u_localptr[k][j][i-1];
}
if (j<(my-1))
{
// Cy=v_localptr[k][j+1][i]-v_localptr[k][j][i];
Cy=v_localptr[k][j][i]-v_localptr[k][j][i];
}
else
{
Cy=v_localptr[k][j][i]-v_localptr[k][j-1][i];
}
if (k<(mz-1))
{
// Cz=w_localptr[k+1][j][i]-w_localptr[k][j][i];
Cz=w_localptr[k][j][i]-w_localptr[k][j][i];
}
else
{
Cz=w_localptr[k][j][i]-w_localptr[k-1][j][i];
}
In this code if I uncomment the two commented lines, then the program
gives memory access out of range error when run on multiple processors. Could
you please tell me what is the problem with the two commented out lines.
Thanks.
Khalid
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101130/f70680b5/attachment.htm>