fortran interface for MatCreateSeqAIJWithArrays
tsjb00
tsjb00 at hotmail.com
Mon Aug 24 16:42:27 CDT 2009
Many thanks for your reply! Just double check. So when I call MatCreateSeqAIJWithArrays from Fortran, I should define:
i(1)=0
j(1)=0
Correct?
Thanks again!
> From: bsmith at mcs.anl.gov
> To: petsc-users at mcs.anl.gov
> Subject: Re: fortran interface for MatCreateSeqAIJWithArrays
> Date: Mon, 24 Aug 2009 16:37:47 -0500
>
>
> On Aug 24, 2009, at 4:19 PM, tsjb00 wrote:
>
> > Hi, there!
> >
> > I have a quick question on the Fortran interface of
> > MatCreateSeqAIJWithArrays.
> >
> > The documentation indicates 'The i and j indices are 0 based'.
>
> This means the values in i and j start with zero; it does not mean
> you have to declare them as PetscInt i(0:a big number) you can declare
> them either as
> (0:a big number minus 1) or (1:a big number)
>
> > Is it so when called in Fortran? Should the array be 0 based too?
>
> That does not matter.
>
> > Any precautions to be taken to avoid segmentation error?
>
> This routine does NOT copy the values in the arrays. This means
> that the arrays that YOU pass in, i,j,a must exist until you finish
> using the matrix. If you allocate them
> then don't deallocate them until you destroy the matrix. If you
> declare them, for example PetscScalar a(somebignumber) then make sure
> this variable does not go out of
> scope until the matrix is destroyed.
>
> >
> > 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:
> > for (k=zs; k<zs+zm; k++) {
> > for (j=ys; j<ys+ym; j++) {
> > for (i=xs; i<xs+xm; i++) {
> > for (idof=0;idof<dof;idof++){
> > X_a[k][j][i][idof]=.............
> > ...............................................
> > &nb sp; }
> > }
> > }
> > }
> > If in Fortran, how should the loop be structured? Please check if
> > the following is right.
> > do k=zs,zs+zm
> > do j=ys,ys+ym
> > do i=xs,xs+xm
> > do iof=1,dof
> > X_a(iof,i,j,k)=..............
> > enddo
> > .............
>
> Yes.
>
> Barry
>
> >
> >
> > Many thanks in advance!
> > 使用新一代 Windows Live Messenger 轻松交流和共享! 立刻下载!
>
_________________________________________________________________
上Windows Live 中国首页,下载最新版Messenger!
http://www.windowslive.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20090824/2e89f332/attachment.htm>
More information about the petsc-users
mailing list