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 class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<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 class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="margin:10px;font-family:verdana;font-size:10pt"><div align="left"><font color="#0000ff" size="3" face="Verdana"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana; font-size: 13px; "> </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="width:122px;min-height:2px" 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>