[ncl-talk] write ubyte data to NetCDF file

David Brown dbrown at ucar.edu
Thu Sep 22 18:36:05 MDT 2016


Hi,
NetCDF only supports the ubyte type in NetCDF4, not NetCDF3. NCL still
creates NetCDF3 files by default.
In order to create a NetCDF4 file you need to execute the following
prior to the addfile command:
setfileoption("nc","Format","NetCDF4")

There have been many improvements in NCL's handling of NetCDF4 files
since 6.1.2.
You may need to upgrade to a more recent version to get satisfactory results.
 -dave



On Thu, Sep 22, 2016 at 6:05 PM, Tang, Qi <tang30 at llnl.gov> wrote:
> Hello,
>
> I need to write some data of ubyte type (unsigned 1 bit integer) to a NetCDF
> file.
>
> But I got an error saying the ubyte type is not supported by the NetCDF
> format. I checked and found both NCL and NetCDF support ubyte. I am using
> v6.1.2.
>
> Does anyone know a solution? The small example below shows the error:
> ncl 0> f=addfile("tst.nc","c")
> ncl 1> a=23B
> ncl 2> f->a=a
> fatal:["NclFile.c":474]:FileAddVar: an error occurred while adding a
> variable to a file, check to make sure data type is supported by the output
> format
> fatal:["Execute.c":8126]:Execute: Error occurred at or near line 2
>
> ncl 3> print(a)
>
>
> Variable: a
> Type: ubyte
> Total Size: 1 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> (0)     23
>
> Thanks,
> --
> Qi Tang
> Research Scientist
> Atmospheric, Earth and Energy Division
> Lawrence Livermore National Laboratory
> 7000 East Ave L-103, Livermore, CA 94550
> +1 (925) 423-3514
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list