<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Simple examples are always better. <br class="">e.g.<br class=""><br class=""><font face="Menlo" class="">alist = [/ 189., 25., 76., 34./]<br class="">write_table("list.txt", "a", alist, "%5.5fâ)</font><div class=""><font face="Menlo" class=""><br class="">;;<br class="">;;more list.txt<br class="">;189.00000<br class=""></font><br class=""><br class="">This also makes it easier for you to test the problem. <br class=""><br class=""><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/write_table.shtml" class="">http://www.ncl.ucar.edu/Document/Functions/Built-in/write_table.shtml</a><br class=""><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><i class=""></i><blockquote type="cite" class=""></blockquote></blockquote><blockquote type="cite" class=""><i class="">format</i><br class="">The format for of each (first) element of the list. <br class=""></blockquote><br class="">you need a format string for each column of your list (your list is only one row long but you still need a format for each column). <br class=""><br class="">e.g.<br class=""><br class=""><font face="Menlo" class="">write_table("list.txt", "a", alist, "%5.5f %5.5f %5.5f %5.5f â)</font><div class=""><font face="Menlo" class=""><br class=""></font>dynamically you could get clever about it and do the below:<br class=""><br class=""><font face="Menlo" class="">fmt = new( ListCount(alist), "string")<br class="">fmt = "%5.5f â <span class="Apple-tab-span" style="white-space:pre">                </span> ;; only works if every column has the same format.<br class="">write_table("list.txt", "a", alist, str_concat(</font><span style="font-family: Menlo;" class="">fmt</span><font face="Menlo" class="">) ) ;; turn array of formats into long string. </font><br class=""><br class=""><br class=""><br class=""><br class=""><br class="">Good luck. <div class=""><br class=""></div><div class="">Alan</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="orphans: 2; widows: 2;" class="">##############################</span><br style="orphans: 2; widows: 2;" class=""><span style="orphans: 2; widows: 2;" class="">Alan Brammer,</span><div style="orphans: 2; widows: 2;" class="">Post-Doc Researcher</div><div style="orphans: 2; widows: 2;" class=""><br class=""></div><div style="orphans: 2; widows: 2;" class="">Department of Atmospheric and Environmental Sciences,<br class="">University at Albany, State University of New York, Albany, NY, 12222<div class="">abrammer@albany.edu<br class="">##############################</div></div><br class=""><br class=""><blockquote type="cite" class="">On 14 Jun 2016, at 01:52, snow <snowflake_822@yahoo.com> wrote:<br class=""><br class=""><br class=""> <br class="">To whom it may concern,<br class=""><br class="">I have written a simple NCL code to extract and take the average of my data and write the table of my data. but in the write part the output is only one data instead of 4.<br class=""><br class="">I wrote this email. to find any kind of help.<br class=""><br class="">I appreciate your time and kindness.<br class=""><br class="">Best regards,<br class=""><br class="">Snow Sho<br class=""><br class=""><br class="">this is the code:<br class=""><blockquote id="yui_3_16_0_ym19_1_1465879989122_8121" style="font-size: 13px;" abp="3357" type="cite" class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br class="">begin<br class="">;----------------------------------------------------------------------<br class="">; WRF data translate NetCDF file to ascii file <br class="">;----------------------------------------------------------------------<br class=""><br class=""> infile=("wrfout_d03_2007-07-24_00_00_00")<br class=""> fn=dimsizes(infile)<br class=""> fin=addfile(infile,"r")<br class=""> R=fin->RAINNC(0,:,:)<br class=""> a=(/189,193,191,192,192,193,192,188,198,196,192,187,197,194,190,187,197,196,195,195,196/)<br class=""> b=(/285,286,287,288,289,290,291,292,293,294,295,296,296,297,298,299,298,299,300,301,302/)<br class=""> c=(/180,174,172,181,179,173,184,175,185,174,184,173,183,193,182,191,179,189,178,188,176/)<br class=""> d=(/264,266,267,267,268,269,270,270,271,271,272,273,273,273,274,273,275,274,276,275,277/)<br class=""> e=(/202,205,206,206,198,197,206,205,204,202,200,200,200,200,210,209,205,202,212,208,204,203/)<br class=""> f=(/270,271,272,273,274,276,277,278,279,280,281,282,283,284,284,284,285,286,287,288,289,290/)<br class=""> g=(/208,208,209,210,211,210,207,205,215,212,213,215,216,207,209,210,211,214,215,209,211,215,214/)<br class=""> h=(/263,264,265,266,267,267,268,269,269,270,271,273,274,276,277,278,279,279,280,282,283,284,287/)<br class=""> R1=new((/21/),"float") <br class=""> R2=new((/21/),"float")<br class=""> R3=new((/22/),"float")<br class=""> R4=new((/23/),"float")<br class=""><br class=""> do k=0,20<br class=""> R1(k)=R(a(k),b(k))<br class=""> end do<br class=""> ; print(R1)<br class=""> do k=0,20<br class=""> R2(k)=R(c(k),d(k))<br class=""> end do<br class=""> do k=0,21<br class=""> R3(k)=R(e(k),f(k))<br class=""> end do<br class=""> do k=0,22<br class=""> R4(k)=R(g(k),h(k))<br class=""> end do<br class=""> R5=avg(R1(:))<br class=""> R6=avg(R2(:))<br class=""> R7=avg(R3(:))<br class=""> R8=avg(R4(:))<br class=""><br class=""> ca=new((/1/),"float")<br class=""> ca=(/R5/)<br class=""> cb=new((/1/),"float")<br class=""> cb=(/R6/)<br class=""> cc=new((/1/),"float")<br class=""> cc=(/R7/)<br class=""> cd=new((/1/),"float")<br class=""> cd=(/R8/)<br class=""><br class="">; alist=[/R5,R6,R7,R8/]<br class=""> alist=[/ca,cb,cc,cd/]<br class=""> write_table("list.txt", "a", alist, "%5.5f")<br class=""> end<br class=""></blockquote><br class=""><br class=""><br class="">_______________________________________________<br class="">ncl-talk mailing list<br class="">ncl-talk@ucar.edu<br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></blockquote><br class=""></div><br class=""><div class=""><br class="">
</div>
<br class=""></div></div></body></html>