<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div><br></div>&nbsp;&nbsp; Since a PETSc C program is just C, you can, of course, use global variables like you can in any C program.<div><br></div><div>&nbsp;&nbsp; We recommend against programming in this way.; any good book on programming should explain why it is a bad idea from the point of view of program maintainability and extensibility. &nbsp;Given that 99+% of PETSc program run time is taken inside long running routines like matrix and vector operations the overhead of function calls like DAGetInfo() is so small that it is going to be un-measurable, you are trading a more understandable, maintainable and extensible program for a microscopic improvement in run time.</div><div><br></div><div>&nbsp;&nbsp; Barry</div><div><br></div><div><br><div><div>On Jul 21, 2010, at 6:19 PM, Li, Zhisong (lizs) wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div ocsi="0" fpstyle="1"><div style="direction: ltr; font-family: Tahoma; color: rgb(0, 0, 0); font-size: 13px; "><div>&nbsp;Hi, Petsc Team,<br><br>I wonder if we can utilize a global variable when using PETSc, such as a declaration and definition in the main function:<br><br>extern PetscScalar x, y, z;<br>&nbsp;&nbsp;&nbsp; x = 1.0;<br><br>This should be a regular usage in ANSI C and will help a lot when we have user-defined functions. If it can work, then it will easily replace those functions like DAGetInfo( ) and save running time. But I don't see any examples of using this in PETSc before. And I've tried this but it doesn't work or cannot pass the compiling check.<br><br><br>Thank you.<br><br><br>Zhisong Li<br></div></div></div></span></blockquote></div><br></div></body></html>