Thanks s lot for your detailed answer,the solution is very smart!(*^__^*)<p>在2016-11-10 16:19:12,Hoffman Cheung<a href="mailto:hoffmancheung@gmail.com">hoffmancheung@gmail.com</a>写道:</p><blockquote name="replyContent" style="padding-left: 1ex;margin: 0 0 0 0.8ex;border-left: 1px solid #ccc;"><div><div dir="ltr">Sorry for a careless mistake in the previous reply.<div><br></div><div>The do loop should be better starting from 0 in NCL.</div><div><br></div><div><div style="font-size:14px"><font color="#ff0000">izMin = (/.../)</font></div><div style="font-size:14px"><font color="#ff0000">izMax = (/.../)</font></div><div style="font-size:14px"><br></div><span style="font-size:14px">do i = 0, 12</span><div style="font-size:14px"><font color="#0000ff"> iz = ind(field(0,:).ge.izMin(i) .and. field(0,:).lt.izMax(i)) </font><font color="#ff0000">; define izMin and izMax explicitly before executing the loop</font></div><div style="font-size:14px"><br></div><div style="font-size:14px"> if (.not. any(ismissing(iz)) then</div><div style="font-size:14px"> print("Number of data fall between "+ izMin(i) + " and " + izMax(i) + " = " + dimsizes(iz))</div><div style="font-size:14px"> else</div><div style="font-size:14px"> print("No data can be found for the values between "+ izMin(i) + " and " + izMax(i))</div><div style="font-size:14px"> end if</div><div style="font-size:14px"><font color="#0000ff"><br></font></div><div style="font-size:14px"><font color="#0000ff"> delete(iz)</font></div><div style="font-size:14px">end do</div></div><div style="font-size:14px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-11-10 9:05 GMT+01:00 Hoffman Cheung <span dir="ltr"><<a href="mailto:hoffmancheung@gmail.com" target="_blank">hoffmancheung@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Zoey,</div><div><br></div><div>In this case, you may just read the values inside the do loop, and delete the variable at the end of the loop.</div><div><br></div><div><font color="#ff0000">izMin = (/.../)</font></div><div><font color="#ff0000">izMax = (/.../)</font></div><div><br></div>do i = 1, 13<div><font color="#0000ff"> iz = ind(field(0,:).ge.izMin(i) .and. field(0,:).lt.izMax(i)) </font><font color="#ff0000">; define izMin and izMax explicitly before executing the loop</font></div><div><br></div><div> if (.not. any(ismissing(iz)) then</div><div> print("Number of data fall between "+ izMin(i) + " and " + izMax(i) + " = " + dimsizes(iz))</div><div> else</div><div> print("No data can be found for the values between "+ izMin(i) + " and " + izMax(i))</div><div> end if</div><div><font color="#0000ff"><br></font></div><div><font color="#0000ff"> delete(iz)</font></div><div>end do</div><div><br></div><div>Cheers, </div><div>Hoffman</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2016-11-10 3:44 GMT+01:00 <span dir="ltr"><<a href="mailto:xyzheng@mail.ustc.edu.cn" target="_blank">xyzheng@mail.ustc.edu.cn</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><font size="4"><font face="
Times New Roman
">Hello,</font></font><br><font size="4"><font face="
Times New Roman
">I am looking for a way to <font face="
Times New Roman
"><font face="
Times New Roman
">call a<font face="
Times New Roman
"> series of variables</font></font></font> through their names (string) in NCL<font face="
Times New Roman
">.</font></font></font><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
">These variables are of different sizes,so <font face="
Times New Roman
"><font face="
Times New Roman
">they</font> can't be set as an array iz(k) of<font face="
Times New Roman
"> fixed size. <font face="
Times New Roman
"> <font face="
Times New Roman
">A<font face="
Times New Roman
">nd <font face="
Times New Roman
">I</font></font></font> <font face="
Times New Roman
">don't know how to do loop <font face="
Times New Roman
">and </font></font></font></font></font></font></font></font></font></font></font></font></font><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
">some other operation<font face="
Times New Roman
">s </font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font>based on these similar names<font face="
Times New Roman
"> <font face="
Times New Roman
">since <font face="
Times New Roman
">(<font face="
Times New Roman
">"iz"+<font face="
Times New Roman
">i) can't be identified as a<font face="
Times New Roman
"> variable</font></font></font></font></font></font> in the following script.<font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"> </font></font></font></font></font></font><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"><font size="4"><font face="
Times New Roman
"><font face="
Times New Roman
"> </font>Can anyone help?</font></font></font><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
"><font face="
Times New Roman
"><br>..............................<wbr>...................<font face="
Times New Roman
">...........<wbr>..............................<wbr>...........................</wbr></wbr></font><br></wbr></font></font></font></font></font></font></font> <br>fieldf(0,:) = asciiread(fi,-1,"<font face="
Times New Roman
">float</font>")<br> iz1=ind(fieldf(0,:).ge.0.and.f<wbr>ieldf(0,:).lt.1.5) <br> iz2=ind(fieldf(0,:).ge.1.and.f<wbr>ieldf(0,:).lt.2.2) <br> iz3=ind(fieldf(0,:).ge.2.<font face="
Times New Roman
">2</font>.and<wbr>.fieldf(0,:).lt.3)<br> iz4=ind(fieldf(0,:).ge.3.and.f<wbr>ieldf(0,:).lt.4.2) <br> iz5=ind(fieldf(0,:).ge.4.2<font face="
Times New Roman
">.</font>and<wbr>.fieldf(0,:).lt.5.6) <br> iz6=ind(fieldf(0,:).ge.5.6.and<wbr>.fieldf(0,:).lt.6) <br> iz7=ind(fieldf(0,:).ge.6.and.f<wbr>ieldf(0,:).lt.7) <br> iz8=ind(fieldf(0,:).ge.7.and.f<wbr>ieldf(0,:).lt.8) <br> iz9=ind(fieldf(0,:).ge.8.and.f<wbr>ieldf(0,:).lt.9.1) <br> iz10=ind(fieldf(0,:).ge.9.<font face="
Times New Roman
">1<font face="
Times New Roman
">.</font></font>an<wbr>d.fieldf(0,:).lt.10) <br> iz11=ind(fieldf(0,:).ge.10.and<wbr>.fieldf(0,:).lt.11) <br> iz12=ind(fieldf(0,:).ge.11.and<wbr>.fieldf(0,:).lt.12) <br> iz13=ind(fieldf(0,:).ge.12.and<wbr>.fieldf(0,:).lt.13) <br><br> do i=<font face="
Times New Roman
">1</font>,1<font face="
Times New Roman
">3</font><br> print(dimsizes("iz"+i))<br> end do<br><font face="
Times New Roman
">..............................<wbr>..............................<wbr>..................</wbr></wbr></font><font size="4"><font face="
Times New Roman
">............<wbr>..........<br> <br>Thanks very much,<br> <br><font face="
Times New Roman
">Zoey</font></wbr></font></font><br><br></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></div></div>______________________________<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</wbr></a><br>
<br></wbr></blockquote></div><br></div>
</blockquote></div><br></div>
</div></blockquote>