<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Many thanks for your reply! Just double check. So when I call MatCreateSeqAIJWithArrays from Fortran, I should define:<br>i(1)=0<br>j(1)=0<br>Correct?<br><br>Thanks again!<br><br>> From: bsmith@mcs.anl.gov<br>> To: petsc-users@mcs.anl.gov<br>> Subject: Re: fortran interface for MatCreateSeqAIJWithArrays<br>> Date: Mon, 24 Aug 2009 16:37:47 -0500<br>> <br>> <br>> On Aug 24, 2009, at 4:19 PM, tsjb00 wrote:<br>> <br>> > Hi, there!<br>> ><br>> > I have a quick question on the Fortran interface of  <br>> > MatCreateSeqAIJWithArrays.<br>> ><br>> > The documentation indicates 'The i and j indices are 0 based'.<br>> <br>>     This means the values in i and j start with zero; it does not mean  <br>> you have to declare them as PetscInt i(0:a big number) you can declare  <br>> them either as<br>> (0:a big number minus 1) or (1:a big number)<br>> <br>> > Is it so when called in Fortran? Should the array be 0 based too?<br>> <br>>     That does not matter.<br>> <br>> > Any precautions to be taken to avoid segmentation error?<br>> <br>>     This routine does NOT copy the values in the arrays. This means  <br>> that the arrays that YOU pass in, i,j,a must exist until you finish  <br>> using the matrix. If you allocate them<br>> then don't deallocate them until you destroy the matrix. If you  <br>> declare them, for example PetscScalar a(somebignumber) then make sure  <br>> this variable does not go out of<br>> scope until the matrix is destroyed.<br>> <br>> ><br>> > Another question is about the storage of vector/arrays when using  <br>> > Fortran. In the PETSc examples, say a vector X_v is created using  <br>> > DACreateXXXVector, then the values are accessed with array X_a using  <br>> > DAVecGetArray. To access individual value, the loop is coded as:<br>> >     for (k=zs; k<zs+zm; k++) {<br>> >       for (j=ys; j<ys+ym; j++) {<br>> >     for (i=xs; i<xs+xm; i++) {<br>> >       for (idof=0;idof<dof;idof++){<br>> >                   X_a[k][j][i][idof]=.............<br>> > ...............................................<br>> > &nb sp;         }<br>> >         }<br>> >      }<br>> >  }<br>> > If in Fortran, how should the loop be structured? Please check if  <br>> > the following is right.<br>> >      do k=zs,zs+zm<br>> >      do j=ys,ys+ym<br>> >      do i=xs,xs+xm<br>> >      do iof=1,dof<br>> >            X_a(iof,i,j,k)=..............<br>> >       enddo<br>> > .............<br>> <br>>     Yes.<br>> <br>>     Barry<br>> <br>> ><br>> ><br>> > Many thanks in advance!<br>> > 使用新一代 Windows Live Messenger 轻松交流和共享! 立刻下载!<br>> <br><br /><hr />搜索本应是快乐的,不是么?  快乐搜索,有问必应!微软隆重推出! <a href='http://bing.com.cn?FORM=M00HCN&Publ=WLHMTAG&Crea=TEXT_Search_Where_You_Are_1X1' target='_new'>立即试用!</a></body>
</html>