<div dir="ltr"><div>Tabish, NCL string references work for file variables, but not for in-memory variables. See NCL reference manual, section "String references".</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 26, 2023 at 8:46 AM Tabish Ansari via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:"trebuchet ms",sans-serif">Hi</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">I have several systematically named variables that I want to refer to by generating the corresponding string via a loop. I'm able to generate a string that exactly matches the variable name but I'm unable to perform any operations over the variables by referring to the string.</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Here's my code:</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">begin</div><div style="font-family:"trebuchet ms",sans-serif">y1 = ispan(0,1000,1)<br>y2 = ispan(1000,2000,1)<br>y3 = ispan(2000,3000,1)<br>y4 = ispan(3000,4000,1)<br>y5 = ispan(4000,5000,1)<br>y6 = ispan(5000,6000,1)<br>y7 = ispan(6000,7000,1)<br>y8 = ispan(7000,8000,1)<br>y9 = ispan(8000,9000,1)<br>y10 = ispan(9000,10000,1)<br>y11 = ispan(10000,11000,1)<br>y12 = ispan(11000,12000,1)<br>y13 = ispan(12000,13000,1)<br>y14 = ispan(13000,14000,1)<br>y15 = ispan(14000,15000,1)<br>y16 = ispan(15000,16000,1)<br>y17 = ispan(16000,17000,1)<br>y18 = ispan(17000,18000,1)<br>y19 = ispan(18000,19000,1)<br><br>do i = 1,19<br> var = "y"+tostring(i)<br> M = max($var$)<br> m = min($var$)<br> print(M+" "+m)<br>end do<br></div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">end</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">I get a syntax error with this. Is it possible to achieve the same thing through some other syntax in an efficient way?</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Thanks a lot.</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif">Tabish</div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div style="font-family:"trebuchet ms",sans-serif"><br></div><div><div dir="ltr"><div dir="ltr"><div><font face="trebuchet ms, sans-serif" color="#666666">-------------------------------<br><span style="background-color:rgb(255,255,255)">Dr Tabish Ansari</span></font></div><div><font face="trebuchet ms, sans-serif" color="#666666">Research Associate </font></div><div><font face="trebuchet ms, sans-serif" color="#666666">Air Quality Modelling Group</font></div><div><span style="background-color:rgb(255,255,255)"><span style="font-weight:normal"><font face="trebuchet ms, sans-serif" color="#666666">IASS-Potsdam </font></span></span></div><div><font face="trebuchet ms, sans-serif" color="#666666">Germany</font></div></div></div></div></div>
</blockquote></div></div>