<div dir="ltr"><div>Thanks Rick and Dennis. <br></div><div><br></div><div>Will try some things out here. My main program loads the library of my local functions similar to what Dennis is recommending. I'm curious to try setting the global variables in the main program outside of the begin/end block and see if it is passed to the loaded library functions. If that doesn't work, I'm happy to hardcode a set of variables at the top of each main and function library.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 2, 2018 at 4:23 PM, Rick Brownrigg <span dir="ltr"><<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Any variable declared/defined outside of the scope of a procedure/function/outer-<wbr>begin-end block will be in the global scope. It has to have been defined before it is ever referenced. <br><div><br> a = 3.14<br><br>procedure foo()<br>begin<br> print("foo sees a: " + a)<br>end<br><br>procedure bar()<br>begin<br> print("bar sees a: " + a) <br>end<br><br>begin<br> print("main sees a: " + a)<br> foo()<br> bar()<br>end<br>(0) main sees a: 3.14<br>(0) foo sees a: 3.14<br>(0) bar sees a: 3.14<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Jul 2, 2018 at 1:43 PM, Jon Meyer <span dir="ltr"><<a href="mailto:jonathan.meyer@aggiemail.usu.edu" target="_blank">jonathan.meyer@aggiemail.usu.<wbr>edu</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Hello,</div><div><br></div><div>I'm hoping to streamline some automated cron job NCL code I've written that could greatly benefit from having global variables set that the main program and functions/procedures can all share..mainly, the directory system I'm navigating around so I don't have to hardcode or pass directory strings in and out of variables.</div><div><br></div><div>I know NCL isn't directly able to do global variables, but some reading into this shows the ability to take advantage of NCL's scoping to essentially create global variables.<br></div><div><br></div><div>I've looked through past ncl-talk threads but the discussion on how to accomplish this is light other than it can be done, and the scoping discussion on the ncl page isn't as visually helpful on how to do this. After a few attempts, I've failed trying to follow the basic example included in the few ncl-talk threads from the past so I'm hoping someone can elaborate or provide an example for setting string (or other type) variables to be accessible to functions/procedures called from main code where the strings are set.<br></div><div><br></div><div>Any help of time is appreciated.<span class="m_-7011044776661257627HOEnZb"><font color="#888888"><br></font></span></div><span class="m_-7011044776661257627HOEnZb"><font color="#888888"><div><br>-- <br><div class="m_-7011044776661257627m_-5696537245400187505gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Jonathan D.D. Meyer, Ph.D.<div>Utah State University<br><div>Department of Plants, Soils & Climate</div><div>Utah Climate Center</div></div></div></div></div></div>
</div></font></span></div>
<br></div></div><span class="">______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Jonathan D.D. Meyer, Ph.D.<div>Utah State University<br><div>Department of Plants, Soils & Climate</div><div>Utah Climate Center</div></div></div></div></div></div>
</div>