<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Dave,
<div class=""><br class="">
</div>
<div class="">Thanks a lot. The problem is solved.</div>
<div class=""><br class="">
</div>
<div class="">Jiongming</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Apr 28, 2018, at 06:34, Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" class="">dave.allured@noaa.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Jiongming,
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">--Dave</div>
<div class=""><br class="">
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Fri, Apr 27, 2018 at 1:48 PM, Dave Allured - NOAA Affiliate
<span dir="ltr" class=""><<a href="mailto:dave.allured@noaa.gov" target="_blank" class="">dave.allured@noaa.gov</a>></span> wrote:<br class="">
<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" class="">Jiongming,
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class=""> f->var@attrib = tochar ("any string")</div>
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">--Dave</div>
<div class=""><br class="">
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Fri, Apr 27, 2018 at 5:07 AM, Pang Jiongming <span dir="ltr" class="">
<<a href="mailto:pang.j.m@hotmail.com" target="_blank" class="">pang.j.m@hotmail.com</a>></span> wrote:<br class="">
<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 class="">
<br class="">
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 class="">
<br class="">
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 class="">
<br class="">
Best regards,<br class="">
Jiongming</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>