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