<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Elin,</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">First, it is better to use write_matrix, rather than write_table, as the later is more for a mixed type of data.</div><div class="gmail_default" style><font face="verdana, sans-serif"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/write_matrix.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/write_matrix.shtml</a></font><br></div><div class="gmail_default" style><font face="verdana, sans-serif"><br></font></div><div class="gmail_default" style><font face="verdana, sans-serif">Secondly, the index in your list create is wrong, you'd better use:</font></div><div class="gmail_default" style><span style="font-family:'Courier New';font-size:12.727272033691406px">ListPush(dlist45,(/tslice45(j,:</span><span style="font-family:'Courier New';font-size:12.727272033691406px">)/))</span><font face="verdana, sans-serif"><br></font></div><div class="gmail_default" style><br></div><div class="gmail_default" style>Then your loop index could be wrong as well, but could not see from this short script snap.</div><div class="gmail_default" style><br></div><div class="gmail_default" style>Regards,</div><div class="gmail_default" style><br></div><div class="gmail_default" style>Wei</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><font face="tahoma, sans-serif">================================================</font><div><font face="tahoma, sans-serif">1850 Table Mesa Dr.</font></div><div><font face="tahoma, sans-serif">Boulder, CO 80307</font></div><div><font face="tahoma, sans-serif">Phone: 303-497-8924</font></div></div></div>
<br><div class="gmail_quote">On Tue, Sep 23, 2014 at 1:47 AM, Sjökvist Elin <span dir="ltr"><<a href="mailto:elin.sjokvist@smhi.se" target="_blank">elin.sjokvist@smhi.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="SV" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">I’m trying to print data to an ascii file using the write_table function.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">My data is a 19x12 matrix (tslice45) that I use to create a list, then trying to write:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin:0cm;margin-bottom:.0001pt"><span lang="EN-US" style="font-family:"Courier New"">dlist45 = NewList("lifo")<u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm;margin-bottom:.0001pt"><span lang="EN-US" style="font-family:"Courier New"">do j=0,nr_columns-1<u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm;margin-bottom:.0001pt"><span lang="EN-US" style="font-family:"Courier New""> ListPush(dlist45,(/tslice45(:,j)/))<u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm;margin-bottom:.0001pt"><span lang="EN-US" style="font-family:"Courier New"">end do<u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm;margin-bottom:.0001pt"><span lang="EN-US" style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin:0cm;margin-bottom:.0001pt"><span lang="EN-US" style="font-family:"Courier New"">format_string="%4.2f%4.2f%4.2f%4.2f%4.2f%4.2f%4.2f%4.2f%4.2f%4.2f%4.2f%4.2f"<u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm;margin-bottom:.0001pt"><span lang="EN-US" style="font-family:"Courier New"">write_table(filename,"w",dlist45,format_string)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">I get a file with what seems to be correct output data, but when looking closer some values are wrong and some values are completely missing! This I found out
by printing the tslice45 matrix just before creating the list and comparing with the output. The errors seem to occur randomly.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">I have tried changing the format of the data, my script uses double precision as standard so I added the function doubletofloat for tslice45 just before creating
the list, but it makes no difference.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">What is going on?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">I’m using NCL v6.1.0.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Thankful for all help,<br>
Elin<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
</div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>