[ncl-talk] Adding a new variable to an existing netcdf4 file

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Fri Apr 27 13:48:36 MDT 2018


Jiongming,

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:

    f->var at attrib = tochar ("any string")

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.

--Dave


On Fri, Apr 27, 2018 at 5:07 AM, Pang Jiongming <pang.j.m at hotmail.com>
wrote:

> Hi there,
>
> 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.
>
> 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.
>
> Best regards,
> Jiongming
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180427/0e886b7a/attachment.html>


More information about the ncl-talk mailing list