<div dir="ltr"><div><div><div>Fortran (some other languages too!) has the capability to provide user specified <b>granularity</b> in parsing strings of numbers and characters.<br><br></div>fortran: format(i2,5i5)<br> 299999999999999999999999999999<wbr>9<br><br></div><div>The problem is someone must tell you the structure. You could read as follows:<br></div><div> format(i2,i2,i3,i5,i4,i1,.......)<br></div><div><br></div>However, any 'automatic' software must have some separator between the numbers. <br><br>--<br></div><div>NCDC has text files the include letters, numbers, periods (76.5) all together.<br><br>====<br>fortran: format(i2,5(1x,i5))<br> 2 99999 99999 99999 99999 99999 9999<wbr>9<br><br></div><div>Just a comment<br></div><div>D<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 10, 2017 at 12:02 PM, Rabah Hachelaf <span dir="ltr"><<a href="mailto:hachelaf@sca.uqam.ca" target="_blank">hachelaf@sca.uqam.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Mary and Karin,<div><br></div><div>Adding white-spaces by default is a limitation if we need to write some data using a FORTRAN format.</div><div>We could bypass this "issue" by removing one character starting from the 2nd variable but we would have liked to keep the same format between FORTRAN and NCL</div><div><br></div><div>Regards,</div><div><br></div><div>Rabah</div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">2017-08-10 13:15 GMT-04:00 Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small">Hi Rabah,</div><div style="font-size:small"><br></div><div style="font-size:small">I see Karin already responded, and had the same response I was just about to send!</div><div style="font-size:small"><br></div><div style="font-size:small">I'll go ahead and include my response here. I've updated the documentation to indicate this behavior, and also created a ticket just in case.</div><div style="font-size:small"><br></div><div style="font-size:small">Unfortunately, I think this is a "feature" of write_table. Even if there's a case for declaring this a bug, we probably couldn't change the behavior because we'd likely break a bunch of existing scripts that depend on the space being there.</div><div style="font-size:small"><br></div><div style="font-size:small">I created a ticket on this (NCL-2646), in case it's an issue for other users.</div><div style="font-size:small"><br></div><div style="font-size:small">Meanwhile, as Karin pointed out, I think the only way around this is to concatenate the strings yourself:</div><div>
<p class="m_3290279408905660257m_1503823825792911241m_-94122198865401503gmail-p1"><font face="monospace, monospace">int1 = 2<br>int2 = "99999"<br>int3 = "99999"<br>int4 = "99999"<br>int5 = "99999"<br>int6 = "99999"<br>int7 = "99999"<br>int_cat = int2+int3+int4+int5+int6+int7<br>sounding_check = [/int1,int_cat/]<br>write_table(outfile,"w",soundi<wbr>ng_check,"%2i%s")</font></p><p class="m_3290279408905660257m_1503823825792911241m_-94122198865401503gmail-p1" style="font-size:small"><span class="m_3290279408905660257m_1503823825792911241m_-94122198865401503gmail-s1">In general, I would caution against writing numbers to a file without any spaces, because this makes it potentially very difficult for somebody else looking at the file to know how to read it. However, I do understand that some of these files have historically been written this way for other purposes</span></p><p class="m_3290279408905660257m_1503823825792911241m_-94122198865401503gmail-p1" style="font-size:small"><span class="m_3290279408905660257m_1503823825792911241m_-94122198865401503gmail-s1">--Mary</span></p><p class="m_3290279408905660257m_1503823825792911241m_-94122198865401503gmail-p1" style="font-size:small"><span class="m_3290279408905660257m_1503823825792911241m_-94122198865401503gmail-s1"><br></span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_3290279408905660257h5">On Wed, Aug 9, 2017 at 3:13 PM, Rabah Hachelaf <span dir="ltr"><<a href="mailto:hachelaf@sca.uqam.ca" target="_blank">hachelaf@sca.uqam.ca</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_3290279408905660257h5"><div dir="ltr"><br clear="all"><div><div style="font-size:12.8px">Hello,</div><div style="font-size:12.8px">I am wounding why there is a systematic white-spaces between values although they are removed from the format specifier. </div><div style="font-size:12.8px">How can i remove white spaces from in this case.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thank you</div><div style="font-size:12.8px"> </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">begin</div><div style="font-size:12.8px">outfile = "test.txt"</div><div style="font-size:12.8px">sounding_check = [/2,"99999","99999","99999","9<wbr>9999","99999","99999"/]</div><div style="font-size:12.8px">write_table(outfile,"a",soundi<wbr>ng_check,"%2i%s%s%s%s%s%s")</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">end</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">output : </div><div style="font-size:12.8px"> 2 99999 99999 99999 99999 99999 99999</div></div><span class="m_3290279408905660257m_1503823825792911241HOEnZb"><font color="#888888">-- <br><div class="m_3290279408905660257m_1503823825792911241m_6849795089286736669gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>------------------------------</div>Best regards,<br>Rabah Hachelaf <br> <br><br></div></div></div></div>
</font></span></div>
<br></div></div>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_3290279408905660257gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>------------------------------</div>Cordialement,<br>Best regards,<br>Rabah Hachelaf <br></div></div>
</font></span></div></div>
<br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>