<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<STYLE type=text/css>@import url( C:\Users\chenleping\AppData\Local\Microsoft\Windows\Temporary Internet Files\scrollbar.css );
</STYLE>
<META content="text/html; charset=GB2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16535">
<STYLE>@font-face {
        font-family: 宋体;
}
@font-face {
        font-family: Verdana;
}
@font-face {
        font-family: @宋体;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; layout-grid: 15.6pt; }
P.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
LI.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
DIV.MsoNormal {
        TEXT-JUSTIFY: inter-ideograph; TEXT-ALIGN: justify; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; FONT-SIZE: 10.5pt
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        FONT-STYLE: normal; FONT-FAMILY: Verdana; COLOR: windowtext; FONT-WEIGHT: normal; TEXT-DECORATION: none; mso-style-type: personal-compose
}
DIV.Section1 {
        page: Section1
}
UNKNOWN {
        FONT-SIZE: 10pt
}
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>
</HEAD>
<BODY style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><FONT
color=#0000ff size=3 face=Verdana>
<DIV> petsc teams,</DIV>
<DIV> </DIV>
<DIV> <FONT color=#ff6600>
PetscOffset xx_i</FONT></DIV>
<DIV><FONT color=#ff6600>
Vec x</FONT></DIV>
<DIV><FONT
color=#ff6600> double precision u(6) </FONT></DIV>
<DIV><FONT color=#ff6600> </FONT>
<DIV><FONT
color=#ff6600> call VecGetArray(x,u,xx_i,ierr)</FONT></DIV>
<DIV><FONT color=#ff6600></FONT></DIV>
<DIV><FONT
color=#ff6600> do 30 i=1,n</FONT></DIV>
<DIV><FONT
color=#ff6600> u(i) = 1000.0*i</FONT></DIV>
<DIV><FONT color=#ff6600> 30 continue</FONT></DIV>
<DIV><FONT color=#ff6600></FONT></DIV>
<DIV><FONT
color=#ff6600> call VecRestoreArray(x,u,xx_i,ierr)</FONT></DIV>
<DIV><FONT color=#ff6600></FONT> </DIV></FONT></DIV>
<DIV><FONT face=Verdana></FONT><FONT color=#0000ff size=3>I don't understand why
x cannot be changed when u() has been changed?</FONT></DIV>
<DIV><FONT color=#0000ff size=3>how can I do it?</FONT></DIV>
<DIV><FONT color=#0000ff size=3>the output are as follows,</FONT></DIV>
<DIV>
<DIV>x vector:</DIV>
<DIV>10</DIV>
<DIV>20</DIV>
<DIV>30</DIV>
<DIV>40</DIV>
<DIV>50</DIV>
<DIV>60</DIV>
<DIV>u() array</DIV>
<DIV>1000</DIV>
<DIV>2000</DIV>
<DIV>3000</DIV>
<DIV>4000</DIV>
<DIV>5000</DIV>
<DIV>6000</DIV></DIV>
<DIV><FONT face=Verdana></FONT><FONT color=#0000ff size=3>thanks,</FONT></DIV>
<DIV><FONT color=#0000ff size=3>leping</FONT></DIV>
<DIV><FONT color=#0000ff size=3 face=Verdana> <SPAN>
<DIV></SPAN></FONT>
<HR color=#b5c4df SIZE=1>
</DIV></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发件人:</STRONG> Matthew Knepley
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>发送时间:</STRONG> 2010-04-17 22:15:24
</FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>收件人:</STRONG> chenleping; PETSc users
list </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>抄送:</STRONG> </FONT></DIV>
<DIV><FONT size=2 face=Verdana><STRONG>主题:</STRONG> Re: [petsc-users] about
Vecgetarray() </FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT></DIV>
<DIV><FONT size=2 face=Verdana>2010/4/16 陈乐平(Leping Chen) <SPAN dir=ltr><<A
href="mailto:chenleping@yahoo.cn">chenleping@yahoo.cn</A>></SPAN><BR>
<DIV class=gmail_quote>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV><FONT color=#0000ff size=3 face=Verdana>petsc teams,</FONT></DIV>
<DIV><FONT color=#0000ff size=3></FONT> </DIV>
<DIV><FONT color=#0000ff size=3>if I want create the relation between u()
<FONT color=#333333>[array]</FONT> and x <FONT color=#333333>[Vec]
,</FONT><FONT color=#0000ff>I can do it as follows,</FONT></FONT></DIV>
<DIV><FONT color=#333333 size=3></FONT> </DIV>
<DIV><FONT color=#ff6600 size=3 face=Verdana><FONT
size=2>#define u(ib) xx_v(xx_i + (ib))</FONT>
</FONT></DIV>
<DIV>
<DIV><FONT color=#ff6600>
call VecGetArray(x,xx_v,xx_i,ierr)</FONT></DIV>
<DIV><FONT
color=#ff6600> do 30 i=1,n</FONT></DIV>
<DIV><FONT
color=#ff6600> u(i) = 1000.0*i</FONT></DIV>
<DIV><FONT color=#ff6600> 30 continue</FONT></DIV>
<DIV><FONT color=#ff6600></FONT></DIV>
<DIV><FONT
color=#ff6600> call VecRestoreArray(x,xx_v,xx_i,ierr)</FONT></DIV>
<DIV><FONT color=#ff6600></FONT> </DIV></DIV>
<DIV><FONT color=#0000ff size=3 face=Verdana>However, I don't understand
why can not I do it as follows,</FONT></DIV>
<DIV><FONT color=#0000ff size=3></FONT> </DIV>
<DIV><FONT color=#0000ff size=3><FONT
color=#000000> </FONT><FONT color=#ff6600
size=2>double precision u(1) <FONT color=#000000>or
u(6)</FONT></FONT></FONT></DIV>
<DIV><FONT color=#0000ff size=3><FONT color=#ff6600
size=2>
call VecGetArray(x,u,xx_i,ierr)</FONT></FONT></DIV>
<DIV><FONT color=#ff6600
size=2> do 30 i=1,n</FONT></DIV>
<DIV><FONT color=#ff6600
size=2> u(i) = 1000.0*i</FONT></DIV>
<DIV><FONT color=#ff6600
size=2> 30 continue</FONT></DIV>
<DIV><FONT color=#ff6600 size=2></FONT></DIV>
<DIV><FONT color=#ff6600
size=2> call VecRestoreArray(x,u,xx_i,ierr)</FONT></DIV>
<DIV><FONT color=#ff6600 size=2></FONT> </DIV>
<DIV align=left><FONT color=#0000ff size=3 face=Verdana> Why u() must be
created by #define, and u() cannot be defined again,for example "double
precision u(1)" or u(5).</FONT></DIV></DIV></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>1) It does not have to be #define. This is shown for convenience.</DIV>
<DIV><BR></DIV>
<DIV>2) You must still declare xx_v in your first example, probably exactly as
you</DIV>
<DIV> declare u in your second example.</DIV>
<DIV><BR></DIV>
<DIV>These are not PETSc questions. They are basic Fortran programming
questions.</DIV>
<DIV>There are many excellent books on this.</DIV>
<DIV><BR></DIV>
<DIV> Matt</DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV align=left><FONT color=#0000ff size=3 face=Verdana><SPAN
style="FONT-FAMILY: verdana; COLOR: rgb(0,0,0); FONT-SIZE: 13px"
class=Apple-style-span></SPAN></FONT> </DIV>
<DIV align=left><FONT color=#0000ff size=3 face=Verdana><SPAN>By the way, if
u() is a array of common blocks<FONT color=#000000>(fortran),</FONT> how can I
create the relation between u() and x?</SPAN></FONT></DIV>
<DIV align=left><FONT color=#0000ff size=3
face=Verdana><SPAN></SPAN></FONT> </DIV>
<DIV align=left><FONT color=#0000ff size=3
face=Verdana><SPAN>thanks,</SPAN></FONT></DIV>
<DIV align=left>
<DIV><FONT size=2 face=Verdana></FONT><FONT color=#0000ff size=3
face=华文行楷></FONT> </DIV>
<DIV><FONT face=华文行楷>Leping</FONT> </DIV></DIV><FONT size=2
face=Verdana><FONT color=#0000ff size=3>
<HR style="MIN-HEIGHT: 2px; WIDTH: 122px" align=left SIZE=2>
</FONT>
<DIV><FONT color=#0000ff size=3 face=Verdana> 2010-04-16</FONT></DIV>
<DIV> </DIV></FONT></DIV></BLOCKQUOTE></DIV><BR><BR clear=all><BR>--
<BR>What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.<BR>-- Norbert Wiener<BR></FONT></DIV></BODY></HTML>