[ncl-talk] Error in nc_def_var_chunking in file (domain_cfg.nc) for writing

Rick Brownrigg brownrig at ucar.edu
Tue Oct 27 08:27:49 MDT 2020


Hi,

I don't know the issue for certain. However, "rw" is not a valid open mode
-- its either "r" (read) or "w" (read-write), and I am speculating that the
code is looking at only the first character and proceeding from there, in
which case the file would be in read mode. "enddef" refers to ending
"define mode", which is an esoteric property of NetCDF files whereby one
must define structural properties (vars, shapes, dims, etc.) before writing
the actual data. If you read the description of "DefineMode" at the link
below, it indicates the file would only be in define mode if opened for
writing.

http://ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml

Again, I'm just speculating, but it would be easy to test!

Rick


On Tue, Oct 27, 2020 at 1:39 AM 边晴云 via ncl-talk <ncl-talk at mailman.ucar.edu>
wrote:

>
> Dear All,
>
>
> I was trying to change the value of an int variable in a netcdf file using
> NCL. Followed are my code:
>
>
> begin
>
> fin = addfile("domain_cfg.nc","rw")
> data=fin->jperio
> data_v = new(dimsizes(data),typeof(data),data at _FillValue)
> data_v = 0
>
>
> copy_VarMeta(data,data_v)
> fin->jperio = data_v
>
> end
>
>
> However, I got the following error message:
>
> --------
>
> fatal:["NclNetCDF4.c":3073]:NclNetCDF4.c: Error in nc_def_var_chunking in
> file (domain_cfg.nc) for writing, at line: 3073
>
> line 3074 of NclNetCDF4.c: NetCDF: Attempt to define var properties, like
> deflate, after enddef.
>
>
> I have no idea how to resolve it. Any suggestions?
>
> Thank you!
>
>
> Followed are some information about the  netcdf file.
>
> ---------
>
> netcdf domain_cfg {
> dimensions:
>         x = 2710 ;
>         y = 1542 ;
>         z = 75 ;
>         t = UNLIMITED ; // (1 currently)
> variables:
>         float nav_lon(y, x) ;
>                 nav_lon:_Storage = "chunked" ;
>                 nav_lon:_ChunkSizes = 135, 206 ;
>                 nav_lon:_Endianness = "little" ;
>         float nav_lat(y, x) ;
>                 nav_lat:_Storage = "chunked" ;
>                 nav_lat:_ChunkSizes = 135, 206 ;
>                 nav_lat:_Endianness = "little" ;
>         float nav_lev(z) ;
>                 nav_lev:_Storage = "chunked" ;
>                 nav_lev:_ChunkSizes = 1 ;
>                 nav_lev:_Endianness = "little" ;
>         double time_counter(t) ;
>                 time_counter:_Storage = "chunked" ;
>                 time_counter:_ChunkSizes = 1 ;
>                 time_counter:_Endianness = "little" ;
>         int jpiglo ;
>                 jpiglo:_Endianness = "little" ;
>         int jpjglo ;
>                 jpjglo:_Endianness = "little" ;
>         int jpkglo ;
>                 jpkglo:_Endianness = "little" ;
>         int jperio ;
>                 jperio:_Endianness = "little" ;
>         double glamt(t, y, x) ;
>                 glamt:_Storage = "chunked" ;
>                 glamt:_ChunkSizes = 1, 135, 206 ;
>                 glamt:_Endianness = "little" ;
>         double glamu(t, y, x) ;
>                 glamu:_Storage = "chunked" ;
>                 glamu:_ChunkSizes = 1, 135, 206 ;
>                 glamu:_Endianness = "little" ;
>
> // global attributes:
>                 :file_name = "domain_cfg.nc" ;
>                 :TimeStamp = "24/08/2020 16:38:57 +0800" ;
>                 :_NCProperties =
> "version=1|netcdflibversion=4.4.1|hdf5libversion=1.8.13" ;
>                 :_SuperblockVersion = 0 ;
>                 :_IsNetcdf4 = 1 ;
>                 :_Format = "netCDF-4" ;
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20201027/6a3412d3/attachment.html>


More information about the ncl-talk mailing list