[petsc-users] about Vecgetarray()

陈乐平(Leping Chen) chenleping at yahoo.cn
Fri Apr 16 09:07:05 CDT 2010


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).

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100416/e1e4e79e/attachment.htm>


More information about the petsc-users mailing list