[petsc-users] about Vecgetarray()

Matthew Knepley knepley at gmail.com
Sat Apr 17 09:15:22 CDT 2010


2010/4/16 陈乐平(Leping Chen) <chenleping at yahoo.cn>

>  petsc teams,
>
> if I want create the relation between u() [array] and x [Vec] ,I can do it
> as follows,
>
> #define u(ib)  xx_v(xx_i + (ib))
>         call VecGetArray(x,xx_v,xx_i,ierr)
>        do 30 i=1,n
>           u(i) = 1000.0*i
>   30   continue
>         call VecRestoreArray(x,xx_v,xx_i,ierr)
>
> However, I don't understand why can not I do it as follows,
>
>       double precision u(1) or u(6)
>        call VecGetArray(x,u,xx_i,ierr)
>        do 30 i=1,n
>           u(i) = 1000.0*i
>   30   continue
>         call VecRestoreArray(x,u,xx_i,ierr)
>
>  Why u() must be created by #define, and u() cannot be defined again,for
> example "double precision u(1)" or u(5).
>

1) It does not have to be #define. This is shown for convenience.

2) You must still declare xx_v in your first example, probably exactly as
you
    declare u in your second example.

These are not PETSc questions. They are basic Fortran programming questions.
There are many excellent books on this.

    Matt


>
> By the way, if u() is a array of common blocks(fortran), how can I create
> the relation between u() and x?
>
> thanks,
>
> Leping
> ------------------------------
>   2010-04-16
>
>



-- 
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100417/8d8a78e4/attachment.htm>


More information about the petsc-users mailing list