<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div style="direction:ltr;font-family:Tahoma;color:rgb(0, 0, 0);font-size:13px"><div>save running time. </div>
</div></div></blockquote><div><br></div><div>You will see no measurable difference in runtime by using global variables (as opposed to calling a function). If you are worried about performance at this level, then you should consider writing your code in assembly.</div>
<div><br></div><div>To verify, try running any of the many helpful examples in PETSc with the option -log_summary to see where most of the time is being spent. You should concentrate on improving your solver or discretization method to improve your program&#39;s speed.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div style="direction:ltr;font-family:Tahoma;color:rgb(0, 0, 0);font-size:13px"><div>But I don&#39;t see any examples of using this in PETSc before.
 And I&#39;ve tried this but it doesn&#39;t work or cannot pass the compiling check.</div></div></div></blockquote><div><br></div><div>There is a reason people don&#39;t use global variables in writing code, and that is extendability and robustness. You will waste FAR more time debugging code with global variables than you would ever see in the (nonexistent) speedup.</div>
<div><br></div><div>Sean</div></div>