<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Just use an If statement.<div class=""><br class=""></div><div class="">do t = 1,1<br class=""><div class=""><br class=""></div><div class="">if (t .lt. 10) then&nbsp;</div><div class="">&nbsp;&nbsp;<font face="Times New Roman" class="">input="/dir/data.000”+t +”.nc”</font></div><div class=""><font face="Times New Roman" class="">else if (t .lt. 100) then</font></div><div class=""><font face="Times New Roman" class="">&nbsp;&nbsp;input="/dir/data.00”+t +”.nc"</font></div><div class="">else if (t .lt. 1000) then</div><div class="">&nbsp; &nbsp;<font face="Times New Roman" class="">input="/dir/data.0"+t +”.nc”</font></div><div class=""><font face="Times New Roman" class="">else&nbsp;</font></div><div class="">&nbsp;&nbsp;<font face="Times New Roman" class="">input="/dir/data.”&nbsp;+ t +”.nc"</font></div><div class="">end if</div><div class="">end if</div><div class="">end if</div><div class=""><br class=""></div><div class="">file = addfile(input,”r”)</div><div class=""><br class=""></div><div class="">end do</div><div class=""><br class=""></div><div class="">I would set the filename in the if statements and load the file after them; all done within the loop</div><div class=""><br class=""></div><div class="">Other option is&nbsp;</div><div class=""><br class=""></div><div class="">ifiles = systemfunc( “ls /dir/data.*.nc”) ; This gets all of your data file names</div><div class=""><br class=""></div><div class="">nfiles = dimsizes(ifiles)</div><div class=""><br class=""></div><div class="">do t = 0, nfiles-1</div><div class=""><br class=""></div><div class="">&nbsp; ifile = addfile(ifiles(t), “r”)</div><div class="">&nbsp;&nbsp;</div><div class="">&nbsp;; Now do your work</div><div class=""><br class=""></div><div class="">end do</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">the latter option is smoother but either should work for the purpose.</div><div class=""><br class=""></div><div class="">-Alex</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 12, 2016, at 9:44 AM, Kacie Shourd &lt;<a href="mailto:Kacie.Shourd@dri.edu" class="">Kacie.Shourd@dri.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; direction: ltr; font-family: Tahoma; font-size: 10pt;" class="">Hi, Chang<div class=""><br class=""></div><div class="">I have yet to figure out how to loop through files in such a way using purely NCL. There is the "addfiles" function, but I don't believe that loops through files -- it just pulls in the variables from all files and I'm not sure how to keep things separate.&nbsp;</div><div class=""><br class=""></div><div class="">I have handled this problem in the past by using a wrapper in an external language (Python, for example), and running things directly from the shell. Looping in other languages is much more straight forward (in my opinion), and shouldn't be too difficult to accomplish.&nbsp;<span style="font-size: 10pt;" class="">&nbsp;</span></div><div class=""><span style="font-size: 10pt;" class=""><br class=""></span></div><div class=""><span style="font-size: 10pt;" class="">If you need assistance doing this, I would be happy to lend a hand/provide an example.&nbsp;</span></div><div class=""><span style="font-size: 10pt;" class=""><br class=""></span></div><div class=""><span style="font-size: 10pt;" class="">Best,</span></div><div class=""><span style="font-size: 10pt;" class="">Kacie</span></div><div class=""><span style="font-size: 10pt;" class=""><br class=""></span></div><div class=""><span style="font-size: 10pt;" class="">---</span></div><div class=""><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white;" class=""><span style="font-size: 10pt; font-family: 'Courier New';" class="">Kacie N. Shourd</span><span style="font-size: 9.5pt; font-family: Arial, sans-serif; color: rgb(34, 34, 34);" class=""></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white;" class=""><span style="font-size: 10pt; font-family: 'Malgun Gothic', sans-serif;" class="">드림</span><span style="font-size: 9.5pt; font-family: Arial, sans-serif; color: rgb(34, 34, 34);" class=""></span></div><p class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial;"><span style="font-size: 9.5pt; font-family: Arial, sans-serif; color: rgb(34, 34, 34);" class="">&nbsp;</span></p><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white;" class=""><span style="font-size: 10pt; font-family: 'Courier New'; color: rgb(34, 34, 34);" class="">Graduate Research Assistant</span><span style="font-size: 9.5pt; font-family: Arial, sans-serif; color: rgb(34, 34, 34);" class=""></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white;" class=""><span style="font-size: 10pt; font-family: 'Courier New'; color: rgb(34, 34, 34);" class="">Desert Research Institute</span><span style="font-size: 9.5pt; font-family: Arial, sans-serif; color: rgb(34, 34, 34);" class=""></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white;" class=""><span style="font-size: 10pt; font-family: 'Courier New'; color: rgb(34, 34, 34);" class=""><a href="mailto:Kacie.Shourd@dri.edu" target="_blank" style="color: rgb(149, 79, 114);" class=""><span style="color: blue;" class="">Kacie.Shourd@dri.edu</span></a></span><span style="font-size: 9.5pt; font-family: Arial, sans-serif; color: rgb(34, 34, 34);" class=""></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white;" class=""><span style="font-size: 10pt; font-family: 'Courier New'; color: rgb(34, 34, 34);" class="">Work: (775) 674-7049</span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: white;" class=""><span style="font-size: 10pt; font-family: 'Courier New'; color: rgb(34, 34, 34);" class=""><br class=""></span></div></div><div class=""><div style="font-family: 'Times New Roman'; font-size: 16px;" class=""><hr tabindex="-1" class=""><div id="divRpF881273" style="direction: ltr;" class=""><font face="Tahoma" size="2" class=""><b class="">From:</b><span class="Apple-converted-space">&nbsp;</span><a href="mailto:ncl-talk-bounces@ucar.edu" class="">ncl-talk-bounces@ucar.edu</a><span class="Apple-converted-space">&nbsp;</span>[<a href="mailto:ncl-talk-bounces@ucar.edu" class="">ncl-talk-bounces@ucar.edu</a>] on behalf of Xi Chang [<a href="mailto:xi.chang01@gmail.com" class="">xi.chang01@gmail.com</a>]<br class=""><b class="">Sent:</b><span class="Apple-converted-space">&nbsp;</span>Tuesday, July 12, 2016 6:34 AM<br class=""><b class="">To:</b><span class="Apple-converted-space">&nbsp;</span><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space">&nbsp;</span>[ncl-talk] loop over a unique filename<br class=""></font><br class=""></div><div class=""></div><div class=""><div dir="ltr" class="">Dear NCL,<div class=""><br class=""></div><div class="">I have a unique *nc file like this (with increment 1):</div><div class=""><br class=""></div><div class=""><a href="http://data.0001.nc/" target="_blank" class="">data.0001.nc</a></div><div class=""><a href="http://data.0002.nc/" target="_blank" class="">data.0002.nc</a><br class=""></div><div class=""><a href="http://data.0003.nc/" target="_blank" class="">data.0003.nc</a><br class=""></div><div class="">.</div><div class="">.</div><div class=""><a href="http://data.0010.nc/" target="_blank" class="">data.0010.nc</a></div><div class=""><a href="http://data.0011.nc/" target="_blank" class="">data.0011.nc</a><br class=""></div><div class=""><a href="http://data.0012.nc/" target="_blank" class="">data.0012.nc</a><br class=""></div><div class="">.</div><div class="">.</div><div class="">.</div><div class=""><a href="http://data.0101.nc/" target="_blank" class="">data.0101.nc</a><br class=""></div><div class=""><a href="http://data.0102.nc/" target="_blank" class="">data.0102.nc</a><br class=""></div><div class=""><br class=""></div><div class="">I want to call this data using a loop, something like this:</div><div class=""><br class=""></div><div class="">t=1,1</div><div class=""><br class=""></div><div class="">input="/dir/data.000+"t".nc</div><div class=""><br class=""></div><div class="">but it doesnt work when then zero is reduced infront of the filename.</div><div class="">anys suggestion how to call this files on a loop?</div><div class=""><br class=""></div><div class="">Thanks</div><div class=""><br class=""></div><div class="">Chang</div><div class=""><br class=""></div></div></div></div></div></div><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><font face="Arial" size="2" style="font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class="">PUBLIC RECORDS NOTICE: In accordance with NRS Chapter 239, this email and responses, unless otherwise made confidential by law, may be subject to the Nevada Public Records laws and may be disclosed to the public upon request.</font><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">ncl-talk mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:ncl-talk@ucar.edu" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class="">ncl-talk@ucar.edu</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">List instructions, subscriber options, unsubscribe:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div><br class=""></div></div></body></html>