<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hi, there!<br><br>I have a quick question on the Fortran interface of MatCreateSeqAIJWithArrays. <br><br>The documentation indicates 'The i and j indices are 0 based'. Is it so when called in Fortran? Should the array be 0 based too? Any precautions to be taken to avoid segmentation error?<br><br>Another question is about the storage of vector/arrays when using Fortran. In the PETSc examples, say a vector X_v is created using DACreateXXXVector, then the values are accessed with array X_a using DAVecGetArray. To access individual value, the loop is coded as:<br>&nbsp;&nbsp;&nbsp; for (k=zs; k&lt;zs+zm; k++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (j=ys; j&lt;ys+ym; j++) {<br>&nbsp;&nbsp; &nbsp;for (i=xs; i&lt;xs+xm; i++) {<br>&nbsp;&nbsp; &nbsp;&nbsp; for (idof=0;idof&lt;dof;idof++){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X_a[k][j][i][idof]=.............<br>...............................................<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;}<br>If in Fortran, how should the loop be structured? Please check if the following is right.<br>&nbsp;&nbsp;&nbsp;&nbsp; do k=zs,zs+zm<br>&nbsp;&nbsp;&nbsp;&nbsp; do j=ys,ys+ym<br>&nbsp;&nbsp;&nbsp;&nbsp; do i=xs,xs+xm<br>&nbsp;&nbsp;&nbsp;&nbsp; do iof=1,dof<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X_a(iof,i,j,k)=..............<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enddo<br>.............<br><br><br>Many thanks in advance!<br /><hr />使用新一代 Windows Live Messenger 轻松交流和共享! <a href='http://www.windowslive.cn/Messenger/' target='_new'>立刻下载!</a></body>
</html>