<div dir="ltr"><div class="gmail_default">It helps if you provide more information about what the problem is. Are you getting an error of any kind? If so, please indicate which line the error occurs on.</div><div class="gmail_default"><br></div><div class="gmail_default">I think the problem is here:</div><div class="gmail_default"><br></div><div class="gmail_default"><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> do ip = 0, 18</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> do it = 0,ntimes-1 ;ntimes-1</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> data (it)= (sprintf("%5.0f",it) +" " \</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%21.2f", temp(it)) +" " \</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%22.2f", rain_expp(it)) +" " \</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%23.2f", rain_conn(it)) +" " \</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%24.2f", rain_tot(it)) +" " \</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%17.2f", wspd(it)) +" " \ </font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%25.2f", wdir(it)) +" " \ </font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%18.2f", snoww_eq(it)) +" " \</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> +sprintf("%19.2f", snowh_h(it)) +" " )</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace">end do</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> end do ; end of time loop</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"><br></font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><font face="monospace, monospace"> asciiwrite (fName , data)</font></div><div style="line-height:21.3px;color:rgb(68,68,68)"><br></div><div style="line-height:21.3px;color:rgb(68,68,68)">You have a double "do" loop, where "data" is getting created inside the inner do loop. For each iteration of "ip", then, the previous strings assigned to "data" are getting clobbered. In fact, I'm not even sure why you are looping across "ip=0,18", because the inside loop is doing the exact same thing every time.</div><div style="line-height:21.3px;color:rgb(68,68,68)"><br></div><div style="line-height:21.3px;color:rgb(68,68,68)">Finally, you call "asciiwrite", but this is only going to contain "data" from the last iteration of "ip" (ip=18).</div><div style="line-height:21.3px;color:rgb(68,68,68)">--Mary</div><div style="line-height:21.3px;color:rgb(68,68,68)"><br></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 7, 2016 at 8:52 AM, Ramchandra Karki <span dir="ltr"><<a href="mailto:rammetro@hotmail.com" target="_blank">rammetro@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div dir="ltr"><div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> Dear NCL help,</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">I am trying to extract multiple stations time series (ascci output for each stations) from wrfoutput file but i could not succeed in doing so. Would you please kindly guide me to get the solution?</div></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> ; -------------- LOAD FUNCTIONS AND PROCEDURES ----------------</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> ; -------------- BEGINING OF NCL SCRIPT ----------------</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">begin</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">DATADir = "/mnt/gpfs1/data/private/fgvy024/Build_WRF/WRFV6/run/"</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d03* ")</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">numFILES = dimsizes(FILES)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">a = addfiles(FILES+".nc","r")</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">times = wrf_user_list_times(a) ; get times in the file</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">ntimes = dimsizes(times) ; number of times in the file or 1584 for domain1 4750</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">;new parameters naming</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">temp = new(ntimes,float) </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_expp = new(ntimes,float) </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_conn = new(ntimes,float) </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_tot = new(ntimes,float)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">wspd = new(ntimes,float)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">wdir = new(ntimes,float)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">snoww_eq = new(ntimes,float)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">snowh_h = new(ntimes,float)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">;rhh = new(ntimes,float)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">;******************************* time loop</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">do it = 0, ntimes-1 </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">time = it</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> ;************************************************</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><span style="line-height:22.72px;font-size:12pt">do ip = 0, 18 ;loop for number of station locations</span></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">ip_lats = (/ 27.3081, 27.6331,<span style="line-height:21.3px;white-space:pre-wrap">        </span>27.86,<span style="line-height:21.3px;white-space:pre-wrap">        </span>27.959167, \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> 27.696667, 27.8024,<span style="line-height:21.3px;white-space:pre-wrap">        </span>27.8953, 27.99,<span style="line-height:21.3px;white-space:pre-wrap">        </span>27.9818, \ </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> 27.90506667, 27.89671667, 27.901, 27.8987, \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> 27.89261111, 27.87828333, 27.85911111, \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> 27.60111, 27.74661, 27.85722 /)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">ip_lons = (/ 86.5042, 86.2331, 86.46, 86.81278, 86.721389, 86.7144, \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> 86.8188, 86.83, 86.7649, 86.37536667, 86.37428333, 86.37625, 86.37911667, \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><span style="line-height:21.3px;white-space:pre-wrap">        </span> 86.37594444,<span style="line-height:21.3px;white-space:pre-wrap">        </span>86.43361667, 86.43388889, 86.74028, 86.713, 86.79417 /)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">res = True </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">res@returnInt = True </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">point = wrf_user_ll_to_ij(a, ip_lons(ip), ip_lats(ip), True)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">x = point(0) - 1</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">y = point(1) - 1 </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><span style="line-height:22.72px;font-size:12pt">tc2 = wrf_user_getvar(a,"T2",it) ; temp extraction</span></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">tc2 = tc2 -273.16</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">temp(it) = tc2(y,x) ; temperature extraction for station location</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_exp = wrf_user_getvar(a,"RAINNC",it) </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_con = wrf_user_getvar(a,"RAINC",it) </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_expp(it) = rain_exp(y,x)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_conn(it) = rain_con(y,x)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">rain_tot(it) = rain_exp(y,x) + rain_con(y,x)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">u10 = wrf_user_getvar(a,"U10",it) ; u at 10 m, mass point</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">v10 = wrf_user_getvar(a,"V10",it) ; v at 10 m, mass point</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">wspd(it) = ndtooned( sqrt(u10(y,x)^2 + v10(y,x)^2) )</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">wdir(it) = ndtooned( atan2(u10(y,x),v10(y,x))/0.01745329 +180. ) </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><span style="line-height:22.72px;font-size:12pt">snow_eq = wrf_user_getvar(a,"SNOW",it)</span></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">snow_h = wrf_user_getvar(a,"SNOWH",it)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">snoww_eq(it) = snow_eq(y,x)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">snowh_h (it) = snow_h(y,x)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">end do ; end of station loop</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">end do ; end of time loop</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br style="line-height:21.3px"></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> npts=ntimes</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> fName = ip+"T2oben_1kmtemp_rainnonc_rainc_raintot_wspd_wdir_snow_snowh.txt"</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> data = new( npts, "string") </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> ;print(" Time temp ")</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> do ip = 0, 18</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> do it = 0,ntimes-1 ;ntimes-1</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> data (it)= (sprintf("%5.0f",it) +" " \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%21.2f", temp(it)) +" " \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%22.2f", rain_expp(it)) +" " \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%23.2f", rain_conn(it)) +" " \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%24.2f", rain_tot(it)) +" " \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%17.2f", wspd(it)) +" " \ </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%25.2f", wdir(it)) +" " \ </div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%18.2f", snoww_eq(it)) +" " \</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> +sprintf("%19.2f", snowh_h(it)) +" " )</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">end do</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> end do ; end of time loop</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"> asciiwrite (fName , data)</div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)"><br></div><div style="line-height:21.3px;color:rgb(68,68,68);font-size:15px;background-color:rgb(255,255,255)">end</div><div><br></div><div><i><br></i></div>                                            </div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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>
<br></blockquote></div><br></div>