<div dir="ltr">Jiongming,<div><br></div><div>Sorry, I missed something in your first message. For the following method to work, do not use filevarattdef from the NCL website example. Just write each NC_CHAR attribute directly using the single command below.</div><div><br></div><div>--Dave</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 27, 2018 at 1:48 PM, Dave Allured - NOAA Affiliate <span dir="ltr"><<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@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">Jiongming,<div><br></div><div>I think you want to write an attribute as type NC_CHAR, to a netcdf4 file. Is that right? If so, then use this kind of type conversion in NCL:<div><br></div><div> f->var@attrib = tochar ("any string")</div><div><br></div><div>Please note that any_string must be scalar (single string, not array) for this method, because of a netcdf format constraint. That is the most common need. There are more complicated methods for arrays of strings.</div><div><br></div><div>--Dave</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 27, 2018 at 5:07 AM, Pang Jiongming <span dir="ltr"><<a href="mailto:pang.j.m@hotmail.com" target="_blank">pang.j.m@hotmail.com</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">Hi there,<br><br>
I’m a NCL user, and being facing with a problem when I use NCL to add a new variable with attributes to an existing netcdf4 file.<br>
<br>
My wrfoutput from WRF/Chem is netcdf4 format. I need to add a new variable with attributes. By following the example in NCL website, functions addfile, filevardef, and filevarattdef were used. After that, there is a tag ’string’ before all attributes which contains characters of the new variable. I search online, it shows that it is NC_STRING, not NC_CHAR. Could you help me to solve it? Thank you very much.<br>
<br>
Best regards,<br>
Jiongming</blockquote></div></div></div></div></div></blockquote></div></div></div></div>