<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div>&nbsp;&nbsp;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.&nbsp;</font></div></div></blockquote><div><br></div>&nbsp;&nbsp; &nbsp;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".&nbsp;</div><div><br></div><div>&nbsp;&nbsp; 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>&nbsp;</div><div><font color="#0000ff" size="3">but I don't understand<span class="Apple-converted-space">&nbsp;</span><font color="#000000" size="2">VecGetArray(),<span class="Apple-converted-space">&nbsp;</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>&nbsp;</div><div><font size="3"><font color="#0000ff" size="2">when I plan to get any local values of x,&nbsp;</font></font></div><div><font color="#0000ff"></font>&nbsp;</div><div><font color="#0000ff">Maybe,</font></div><div><font color="#0000ff"></font>&nbsp;</div><div><font color="#ff0000">double precision u(n)</font></div><div><font color="#ff0000"></font>&nbsp;</div><div><font color="#ff0000">Vec x</font></div><div><font color="#ff0000"></font>&nbsp;</div><div><font color="#ff0000">PetscOffset uu_i</font></div><div><font color="#ff0000"></font>&nbsp;</div><div><font color="#ff0000">call VecGetArray(x,u,uu_i,ierr)</font></div><div><font color="#0000ff"></font>&nbsp;</div><div><font color="#0000ff">is it right?</font></div><div><font color="#0000ff"></font>&nbsp;</div><div><font color="#0000ff">it seems don't work. how can I&nbsp;call it?</font></div><div><font face="Verdana"></font><font color="#0000ff" size="3"></font>&nbsp;</div><div><div><div align="left"><div align="left"><font color="#0000ff" size="2" face="宋体"></font></div></div></div></div><div>thanks,</div><div>&nbsp;</div><div>leping</div><div><hr color="#b5c4df" size="1"></div><div><font size="2" face="Verdana"><strong>发件人:</strong><span class="Apple-converted-space">&nbsp;</span>Matthew Knepley</font></div><div><font size="2" face="Verdana"><strong>发送时间:</strong><span class="Apple-converted-space">&nbsp;</span>2010-04-16&nbsp; 22:48:18</font></div><div><font size="2" face="Verdana"><strong>收件人:</strong><span class="Apple-converted-space">&nbsp;</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">&nbsp;</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">&nbsp;</span><span dir="ltr">&lt;<a href="mailto:chenleping@yahoo.cn" style="color: blue; text-decoration: underline; ">chenleping@yahoo.cn</a>&gt;</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>&nbsp;</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>&nbsp;</div><div><font color="#0000ff" size="3">but x is defined by Vec, I don't know how to get&nbsp; 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>&nbsp;&nbsp; Matt</div><div>&nbsp;</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>&nbsp;</div><div><font face="Verdana"></font><font color="#0000ff" size="3">thanks,</font></div><div><font color="#0000ff" size="3"></font>&nbsp;</div><div><font color="#0000ff" size="3">leping</font></div><div><font color="#0000ff" size="3" face="Verdana">&nbsp;<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">&nbsp;</span>Jed Brown</font></div><div><font size="2" face="Verdana"><strong>发送时间:</strong><span class="Apple-converted-space">&nbsp;</span>2010-04-16&nbsp; 21:21:47</font></div><div><font size="2" face="Verdana"><strong>收件人:</strong><span class="Apple-converted-space">&nbsp;</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">&nbsp;</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&nbsp;Thu,&nbsp;15&nbsp;Apr&nbsp;2010&nbsp;21:17:19&nbsp;+0800,&nbsp;"=?gb2312?B?s8LA1sa9?="&nbsp;&lt;<a href="mailto:chenleping@yahoo.cn" target="_blank" style="color: blue; text-decoration: underline; ">chenleping@yahoo.cn</a>&gt;&nbsp;wrote:</div><div>&gt;&nbsp;petsc&nbsp;teams,</div><div>&gt;&nbsp;</div><div>&gt;&nbsp;for&nbsp;following&nbsp;definitions:</div><div>&gt;&nbsp;</div><div>&gt;&nbsp;double&nbsp;precision&nbsp;u(n)</div><div>&gt;&nbsp;Vec&nbsp;&nbsp;v</div><div>&gt;&nbsp;</div><div>&gt;&nbsp;then,&nbsp;how&nbsp;can&nbsp;I&nbsp;actualize&nbsp;mutual&nbsp;updating&nbsp;between&nbsp;u(n)&nbsp;and&nbsp;v?</div><div></div><div>I'm&nbsp;not&nbsp;sure&nbsp;what&nbsp;you&nbsp;mean,&nbsp;if&nbsp;these&nbsp;are&nbsp;the&nbsp;same&nbsp;quantity&nbsp;then&nbsp;they</div><div>shouldn't&nbsp;be&nbsp;stored&nbsp;in&nbsp;separate&nbsp;locations.&nbsp;&nbsp;See&nbsp;VecGetArray:</div><div></div><div>&nbsp;&nbsp;<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">&nbsp;</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>