<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Tabish,<div>Yes, a do loop could be used:</div><div><br></div><div>DATADir =  "/mnt/rasher/60sensruns/run"</div><div>do gg = 1,60</div><div>     FILES1 = systemfunc (" ls -1 " + DATADir +gg+ "subset_d03_2014-* ")</div><div>     a1 = addfiles(FILES1,"r")    <br></div><div>.....</div><div><br></div><div>Also note, you could set up a string array that houses the directories using a do loop</div><div>DATADir = new(60,string)</div><div>do gg = 1,dimsizes(DATADir)-1</div><div>     DATADir(gg-1) = "/mnt/rasher/60sensruns/run"+gg</div><div>end do</div><div><br></div><div>Adam</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 21, 2019 at 1:15 PM Tabish Ansari <<a href="mailto:tabishumaransari@gmail.com">tabishumaransari@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Hi</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">I am currently reading in files in a very inefficient way from 60 directories:</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">DATADir1 = "/mnt/rasher/60sensruns/run1/"<br>DATADir2 = "/mnt/rasher/60sensruns/run2/"<br>DATADir3 = "/mnt/rasher/60sensruns/run3/"<br>DATADir4 = "/mnt/rasher/60sensruns/run4/"<br>DATADir5 = "/mnt/rasher/60sensruns/run5/"<br>DATADir6 = "/mnt/rasher/60sensruns/run6/"<br>DATADir7 = "/mnt/rasher/60sensruns/run7/"<br>DATADir8 = "/mnt/rasher/60sensruns/run8/"<br>DATADir9 = "/mnt/rasher/60sensruns/run9/"<br>DATADir10 = "/mnt/rasher/60sensruns/run10/"<br>DATADir11 = "/mnt/rasher/60sensruns/run11/"<br>DATADir12 = "/mnt/rasher/60sensruns/run12/"<br>DATADir13 = "/mnt/rasher/60sensruns/run13/"<br>DATADir14 = "/mnt/rasher/60sensruns/run14/"<br>DATADir15 = "/mnt/rasher/60sensruns/run15/"<br>DATADir16 = "/mnt/rasher/60sensruns/run16/"<br>DATADir17 = "/mnt/rasher/60sensruns/run17/"<br>DATADir18 = "/mnt/rasher/60sensruns/run18/"<br>DATADir19 = "/mnt/rasher/60sensruns/run19/"<br>DATADir20 = "/mnt/rasher/60sensruns/run20/"<br>DATADir21 = "/mnt/rasher/60sensruns/run21/"<br>DATADir22 = "/mnt/rasher/60sensruns/run22/"<br>DATADir23 = "/mnt/rasher/60sensruns/run23/"<br>DATADir24 = "/mnt/rasher/60sensruns/run24/"<br>DATADir25 = "/mnt/rasher/60sensruns/run25/"<br>DATADir26 = "/mnt/rasher/60sensruns/run26/"<br>DATADir27 = "/mnt/rasher/60sensruns/run27/"<br>DATADir28 = "/mnt/rasher/60sensruns/run28/"<br>DATADir29 = "/mnt/rasher/60sensruns/run29/"<br>DATADir30 = "/mnt/rasher/60sensruns/run30/"<br>DATADir31 = "/mnt/rasher/60sensruns/run31/"<br>DATADir32 = "/mnt/rasher/60sensruns/run32/"<br>DATADir33 = "/mnt/rasher/60sensruns/run33/"<br>DATADir34 = "/mnt/rasher/60sensruns/run34/"<br>DATADir35 = "/mnt/rasher/60sensruns/run35/"<br>DATADir36 = "/mnt/rasher/60sensruns/run36/"<br>DATADir37 = "/mnt/rasher/60sensruns/run37/"<br>DATADir38 = "/mnt/rasher/60sensruns/run38/"<br>DATADir39 = "/mnt/rasher/60sensruns/run39/"<br>DATADir40 = "/mnt/rasher/60sensruns/run40/"<br>DATADir41 = "/mnt/rasher/60sensruns/run41/"<br>DATADir42 = "/mnt/rasher/60sensruns/run42/"<br>DATADir43 = "/mnt/rasher/60sensruns/run43/"<br>DATADir44 = "/mnt/rasher/60sensruns/run44/"<br>DATADir45 = "/mnt/rasher/60sensruns/run45/"<br>DATADir46 = "/mnt/rasher/60sensruns/run46/"<br>DATADir47 = "/mnt/rasher/60sensruns/run47/"<br>DATADir48 = "/mnt/rasher/60sensruns/run48/"<br>DATADir49 = "/mnt/rasher/60sensruns/run49/"<br>DATADir50 = "/mnt/rasher/60sensruns/run50/"<br>DATADir51 = "/mnt/rasher/60sensruns/run51/"<br>DATADir52 = "/mnt/rasher/60sensruns/run52/"<br>DATADir53 = "/mnt/rasher/60sensruns/run53/"<br>DATADir54 = "/mnt/rasher/60sensruns/run54/"<br>DATADir55 = "/mnt/rasher/60sensruns/run55/"<br>DATADir56 = "/mnt/rasher/60sensruns/run56/"<br>DATADir57 = "/mnt/rasher/60sensruns/run57/"<br>DATADir58 = "/mnt/rasher/60sensruns/run58/"<br>DATADir59 = "/mnt/rasher/60sensruns/run59/"<br>DATADir60 = "/mnt/rasher/60sensruns/run60/"<br><br>For each directory I will further have to do this:</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">FILES1 = systemfunc (" ls -1 " + DATADir1 + "subset_d03_2014-* ")<br>a1 = addfiles(FILES1,"r")<br>pm25_sim_a1    = a1[:]->PM2_5_DRY(:,0,145,79)<br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">(I will have to type this another 59 times for the other directories)<br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Is there a way to do this more efficiently perhaps in a loop?</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Thanks</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Tabish<br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br clear="all"></div><div><div dir="ltr" class="gmail-m_-6874606385713140125gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div></div></div></div>
_______________________________________________<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/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>