<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Thanks.</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif, Helvetica, EmojiFont, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, NotoColorEmoji, &quot;Segoe UI Symbol&quot;, &quot;Android Emoji&quot;, EmojiSymbols;">
Michael Notaro<br>
<div>Associate Director<br>
</div>
<div>Nelson Institute Center for Climatic Research<br>
</div>
<div>University of Wisconsin-Madison<br>
</div>
<div>Phone: (608) 261-1503<br>
</div>
<div>Email: mnotaro@wisc.edu<br>
</div>
</div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Alan Brammer &lt;abrammer@albany.edu&gt;<br>
<b>Sent:</b> Friday, June 30, 2017 9:41 AM<br>
<b>To:</b> Michael Notaro<br>
<b>Cc:</b> ncl-talk@ucar.edu<br>
<b>Subject:</b> Re: [ncl-talk] flexible variable names in new</font>
<div>&nbsp;</div>
</div>
<div>You can save variables to netcdf with dynamic names:
<div class=""><font face="InputMono-Regular" class="">ncdf-&gt;$tostring(&quot;var&quot;&#43;i)$ = some_variable</font></div>
<div class=""><br class="">
</div>
<div class="">But you can’t have dynamic variable names in the script. &nbsp;The closet would be attaching attributes with dynamic names. e.g.</div>
<div class=""><br class="">
</div>
<div class=""><font face="InputMono-Regular" class="">x = ispan(0,5,1)</font></div>
<div class="">
<div class=""><font face="InputMono-Regular" class="">holder = True</font></div>
<div class=""><font face="InputMono-Regular" class="">do i=0,5</font></div>
<div class=""><font face="InputMono-Regular" class="">&nbsp; &nbsp;holder@$tostring(&quot;var&quot;&#43;i)$ = x(i)</font></div>
<div class=""><font face="InputMono-Regular" class="">end do</font></div>
</div>
<div class=""><font face="InputMono-Regular" class=""><br class="">
</font></div>
<div class=""><font face="InputMono-Regular" class="">
<div class="">&gt; &nbsp;Variable: holder</div>
<div class="">&gt; &nbsp;Type: logical</div>
<div class="">&gt; &nbsp;Total Size: 4 bytes</div>
<div class="">&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 values</div>
<div class="">&gt; &nbsp;Number of Dimensions: 1</div>
<div class="">&gt; &nbsp;Dimensions and sizes:<span class="Apple-tab-span" style="white-space:pre">
</span>[1]</div>
<div class="">&gt; &nbsp;Coordinates:</div>
<div class="">&gt; &nbsp;Number Of Attributes: 6</div>
<div class="">&gt; &nbsp; &nbsp;var5 :<span class="Apple-tab-span" style="white-space:pre"> </span>
5</div>
<div class="">&gt; &nbsp; &nbsp;var4 :<span class="Apple-tab-span" style="white-space:pre"> </span>
4</div>
<div class="">&gt; &nbsp; &nbsp;var3 :<span class="Apple-tab-span" style="white-space:pre"> </span>
3</div>
<div class="">&gt; &nbsp; &nbsp;var2 :<span class="Apple-tab-span" style="white-space:pre"> </span>
2</div>
<div class="">&gt; &nbsp; &nbsp;var1 :<span class="Apple-tab-span" style="white-space:pre"> </span>
1</div>
<div class="">&gt; &nbsp; &nbsp;var0 :<span class="Apple-tab-span" style="white-space:pre"> </span>
0</div>
<div class="">&gt; &nbsp;(0)<span class="Apple-tab-span" style="white-space:pre"> </span>
True</div>
</font></div>
<div class=""><font face="InputMono-Regular" class=""><br class="">
</font></div>
<div class=""><br class="">
</div>
<div class="">This is could get messy pretty quickly though.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Google &quot;ncl-talk dynamic variable names” and you’ll find a bunch of old threads asking similar questions. &nbsp;</div>
<div class="">It usually boils down to why would you want this? &nbsp;For output there is the method above, otherwise save variables in an array, the names are somewhat irrelevant. &nbsp;Also I imagine trying to debug a script with unknown variable names would be a nightmare.&nbsp;</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Good luck,&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Alan</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class="">
<div class="" style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div class="" style="color:rgb(0,0,0); 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; word-wrap:break-word">
<span class="Apple-style-span" style="border-collapse:separate; color:rgb(0,0,0); 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; border-spacing:0px">
<div class="" style="word-wrap:break-word">##############################<br class="">
Alan Brammer,
<div class="">Post-Doc Researcher</div>
<div class=""><br class="">
</div>
<div class="">Department of Atmospheric and&nbsp;Environmental Sciences,<br class="">
University at Albany,&nbsp;State University of New&nbsp;York,&nbsp;Albany, NY, 12222
<div class=""><a href="mailto:abrammer@albany.edu" class="">abrammer@albany.edu</a><br class="">
##############################</div>
</div>
</div>
</span></div>
</div>
</div>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 30 Jun 2017, at 10:01, Michael Notaro &lt;<a href="mailto:mnotaro@wisc.edu" class="">mnotaro@wisc.edu</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div id="divtagdefaultwrapper" dir="ltr" class="" style="font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
<div class="" style="margin-top:0px; margin-bottom:0px">Is there any way to create new variables with flexible names? &nbsp;For example,</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px">do i=0,5</div>
<div class="" style="margin-top:0px; margin-bottom:0px">&nbsp; var$i$= ........</div>
<div class="" style="margin-top:0px; margin-bottom:0px">end do</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px">So that would (if done right)&nbsp;define new variables named&nbsp;var0, var1, var2, var3, var4, and var5.</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px">Michael</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div id="Signature" class="">
<div id="divtagdefaultwrapper" class="" style="font-size:12pt; background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,Helvetica,EmojiFont,'Apple Color Emoji','Segoe UI Emoji',NotoColorEmoji,'Segoe UI Symbol','Android Emoji',EmojiSymbols">
Michael Notaro<br class="">
<div class="">Associate Director<br class="">
</div>
<div class="">Nelson Institute Center for Climatic Research<br class="">
</div>
<div class="">University of Wisconsin-Madison<br class="">
</div>
<div class="">Phone: (608) 261-1503<br class="">
</div>
<div class="">Email:<span class="Apple-converted-space">&nbsp;</span><a href="mailto:mnotaro@wisc.edu" class="">mnotaro@wisc.edu</a><br class="">
</div>
</div>
</div>
</div>
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; float:none; display:inline!important">_______________________________________________</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px">
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; float:none; display:inline!important">ncl-talk
 mailing list</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px">
<a href="mailto:ncl-talk@ucar.edu" class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">ncl-talk@ucar.edu</a><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px">
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; float:none; display:inline!important">List
 instructions, subscriber options, unsubscribe:</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</div>
</body>
</html>