<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div> The manual page that Jed pointed out to you has links to several examples that use VecGetArray() from Fortran. For example<div><a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/vec/vec/examples/tutorials/ex4f.F.html">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/vec/vec/examples/tutorials/ex4f.F.html</a></div><div>In particular you don't declare u(n) you just declare u(1)</div><div><br></div><div><blockquote type="cite"><div style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; font-family: verdana; font-size: 10pt; "><div><font color="#0000ff">it seems don't work. </font></div></div></blockquote><div><br></div> This is the most useless type of email. If all you tell us is "it seems don't work", then we have NO idea of what happened, what didn't work, so cannot provide advice. Cut and paste all error messages and everything that that would help us see "what didn't work". </div><div><br></div><div> Barry</div><div><br><div><div>On Apr 15, 2010, at 8:55 PM, 陈乐平(Leping Chen) wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; font-family: verdana; font-size: 10pt; "><div><font color="#0000ff" size="3" face="Verdana">thanks,</font></div><div><font color="#0000ff" size="3"></font> </div><div><font color="#0000ff" size="3">but I don't understand<span class="Apple-converted-space"> </span><font color="#000000" size="2">VecGetArray(),<span class="Apple-converted-space"> </span><font color="#0000ff">that is to say, I don't know how to call VecGetArray()</font></font></font></div><div><font size="3"><font color="#0000ff" size="2"></font></font> </div><div><font size="3"><font color="#0000ff" size="2">when I plan to get any local values of x, </font></font></div><div><font color="#0000ff"></font> </div><div><font color="#0000ff">Maybe,</font></div><div><font color="#0000ff"></font> </div><div><font color="#ff0000">double precision u(n)</font></div><div><font color="#ff0000"></font> </div><div><font color="#ff0000">Vec x</font></div><div><font color="#ff0000"></font> </div><div><font color="#ff0000">PetscOffset uu_i</font></div><div><font color="#ff0000"></font> </div><div><font color="#ff0000">call VecGetArray(x,u,uu_i,ierr)</font></div><div><font color="#0000ff"></font> </div><div><font color="#0000ff">is it right?</font></div><div><font color="#0000ff"></font> </div><div><font color="#0000ff">it seems don't work. how can I call it?</font></div><div><font face="Verdana"></font><font color="#0000ff" size="3"></font> </div><div><div><div align="left"><div align="left"><font color="#0000ff" size="2" face="宋体"></font></div></div></div></div><div>thanks,</div><div> </div><div>leping</div><div><hr color="#b5c4df" size="1"></div><div><font size="2" face="Verdana"><strong>发件人:</strong><span class="Apple-converted-space"> </span>Matthew Knepley</font></div><div><font size="2" face="Verdana"><strong>发送时间:</strong><span class="Apple-converted-space"> </span>2010-04-16 22:48:18</font></div><div><font size="2" face="Verdana"><strong>收件人:</strong><span class="Apple-converted-space"> </span>chenleping; PETSc users list</font></div><div><font size="2" face="Verdana"><strong>抄送:</strong></font></div><div><font size="2" face="Verdana"><strong>主题:</strong><span class="Apple-converted-space"> </span>Re: [petsc-users] array and vec</font></div><div><font size="2" face="Verdana"></font></div><div><font size="2" face="Verdana">2010/4/15 陈乐平(Leping Chen)<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:chenleping@yahoo.cn" style="color: blue; text-decoration: underline; ">chenleping@yahoo.cn</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid; margin-right: 0px; padding-left: 1ex; "><div style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; font-family: verdana; font-size: 10pt; "><div><font color="#0000ff" size="3" face="Verdana">hello, petsc teams,</font></div><div><font color="#0000ff" size="3"></font> </div><div><font color="#0000ff" size="3">when I use FormFuncion(), I need use a value of x;</font></div><div><font color="#0000ff" size="3"></font> </div><div><font color="#0000ff" size="3">but x is defined by Vec, I don't know how to get a value of x, for example, the 3rd value.</font></div></div></blockquote><div><br></div><div>Exactly as Jed wrote, you can use VecGetArray() to access any local values</div><div>of x.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid; margin-right: 0px; padding-left: 1ex; "><div style="margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; font-family: verdana; font-size: 10pt; "><div><font color="#0000ff" size="3"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-size: 13px; "></span></font> </div><div><font face="Verdana"></font><font color="#0000ff" size="3">thanks,</font></div><div><font color="#0000ff" size="3"></font> </div><div><font color="#0000ff" size="3">leping</font></div><div><font color="#0000ff" size="3" face="Verdana"> <span><div></div></span></font><hr color="#b5c4df" size="1"></div></div><div><font size="2" face="Verdana"><strong>发件人:</strong><span class="Apple-converted-space"> </span>Jed Brown</font></div><div><font size="2" face="Verdana"><strong>发送时间:</strong><span class="Apple-converted-space"> </span>2010-04-16 21:21:47</font></div><div><font size="2" face="Verdana"><strong>收件人:</strong><span class="Apple-converted-space"> </span>chenleping; PETSc users list</font></div><div><font size="2" face="Verdana"><strong>抄送:</strong></font></div><div><font size="2" face="Verdana"><strong>主题:</strong><span class="Apple-converted-space"> </span>Re: [petsc-users] array and vec</font></div><div><font size="2" face="Verdana"></font></div><div><font size="2" face="Verdana"><div>On Thu, 15 Apr 2010 21:17:19 +0800, "=?gb2312?B?s8LA1sa9?=" <<a href="mailto:chenleping@yahoo.cn" target="_blank" style="color: blue; text-decoration: underline; ">chenleping@yahoo.cn</a>> wrote:</div><div>> petsc teams,</div><div>> </div><div>> for following definitions:</div><div>> </div><div>> double precision u(n)</div><div>> Vec v</div><div>> </div><div>> then, how can I actualize mutual updating between u(n) and v?</div><div></div><div>I'm not sure what you mean, if these are the same quantity then they</div><div>shouldn't be stored in separate locations. See VecGetArray:</div><div></div><div> <a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Vec/VecGetArray.html" target="_blank" style="color: blue; text-decoration: underline; ">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Vec/VecGetArray.html</a></div><div></div><div>Jed</div></font></div></blockquote></div><br><br clear="all"><br>--<span class="Apple-converted-space"> </span><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></div></blockquote></div><br></div></body></html>