<div dir="ltr">Andrew,<div><br></div><div>The constructors (/ /) around the tochar function should be unnecessary in that context. Try removing them.<br><div><br></div><div>A workaround is to write the string as an attribute instead of a data variable. This is the more usual way of storing single descriptive strings. This should completely avoid the mysterious ncdimdef error, and the code is more straightforward. Will this work for your application?</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"> p@wnd_dir_top_string = wnd_dir_top_string</span></div><div><br></div><div>If you need to debug the original statement, then more information is needed. Insert an exit statement right before line 806, and show us the full output from ncdump -hs on the vestigial output file.</div><div><br></div><div>--Dave</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 4, 2018 at 11:19 AM, Andrew Kren - NOAA Affiliate <span dir="ltr"><<a href="mailto:andrew.kren@noaa.gov" target="_blank">andrew.kren@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><font face="arial, helvetica, sans-serif">Hi,</font><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">In my previous programs I have used the tochar function to convert strings to characters for writing string data to netcdf using NCL. However, for some reason, its not working for me this time. It fails with this error:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div>
<font face="arial, helvetica, sans-serif"><span></span>
</font><p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">ncdimdef: ncid 65536: NetCDF: String match to name in use</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">fatal:["Execute.c":8575]:<wbr>Execute: Error occurred at or near line 806 in file nam_foothills.ncl</font></span></p>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">My section to write the netcdf file is here:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div>
<font face="arial, helvetica, sans-serif"><span></span>
</font><p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">filo = "/home/arsenic1/scripts/nam/<wbr>00z/<a href="http://saved_foothills_variables_nam.nc" target="_blank">saved_foothills_variables_<wbr>nam.nc</a>"</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">system("rm -rf "+filo) ; remove any pre-existing file</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p = addfile(filo,"c")</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p@title = "Saved Foothills Variables for comparison page"</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p@source = filo</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p@creation_date = systemfunc("date")</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">filedimdef(p,"time",-1,True) ; make time unlimited dimension</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p2" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255);min-height:19px"><font face="arial, helvetica, sans-serif"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></font></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->temperature_top = temperature_top</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->wnd_spd_top = wnd_spd_top</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->clouds = clouds</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->lightning = lightning</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->precip_chance = precip_chance</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->precip_type_top = precip_type_top</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->precip_amount = precip_6hr_top</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->wnd_dir_top_string = (/tochar(wnd_dir_top_string)/)</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->day_of_week_string = (/tochar(day_of_week_string)/)</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->months = (/tochar(months)/)</font></span></p>
<p class="gmail-m_8129731019499483947gmail-p1" style="margin:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);background-color:rgb(255,255,255)"><span class="gmail-m_8129731019499483947gmail-s1" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">p->valid_day = (/tochar(valid_day)/)</font></span></p>
<font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Line 806 is the first line where it tries to write the wind direction string:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0);font-style:normal;font-variant-ligatures:no-common-ligatures;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline">p->wnd_dir_top_string = (/tochar(wnd_dir_top_string)/)</span><br></font></div><div><span style="color:rgb(0,0,0);font-style:normal;font-variant-ligatures:no-common-ligatures;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span style="color:rgb(0,0,0);font-style:normal;font-variant-ligatures:no-common-ligatures;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline"><font face="arial, helvetica, sans-serif">Is there any remedy to this? I've looked online, but have not found much help.</font></span></div><div><span style="color:rgb(0,0,0);font-style:normal;font-variant-ligatures:no-common-ligatures;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span style="color:rgb(0,0,0);font-style:normal;font-variant-ligatures:no-common-ligatures;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline"><font face="arial, helvetica, sans-serif">Thanks,</font></span></div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="gmail-m_8129731019499483947gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>Andrew Kren<br>Assistant Scientist<br>CIMAS & NOAA/AOML<br>
325 Broadway, Boulder, CO 80305<br>
(303) 497-5418</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></font></span></div></div></blockquote></div></div></div></div>