'NetCDF re-ordering dimension

I have 1 netCDF file with a variable ppt and three dimension ppt(time,lat,lon). See below:

dimensions:
    time = UNLIMITED ; // (756 currently)
    lon = 55 ;
    lat = 60 ;
variables:
    double time(time) ;
        time:standard_name = "time" ;
        time:long_name = "time" ;
        time:units = "days since 1900-01-01 00:00:00" ;
        time:calendar = "gregorian" ;
        time:axis = "T" ;
    double lon(lon) ;
        lon:standard_name = "longitude" ;
        lon:long_name = "longitude" ;
        lon:units = "degrees_east" ;
        lon:axis = "X" ;
    double lat(lat) ;
        lat:standard_name = "latitude" ;
        lat:long_name = "latitude" ;
        lat:units = "degrees_north" ;
        lat:axis = "Y" ;
    int ppt(time, lat, lon) ;
        ppt:standard_name = "precipitation_amount" ;
        ppt:long_name = "precipitation_amount" ;
        ppt:units = "mm" ;
        ppt:add_offset = 0. ;
        ppt:scale_factor = 0.1 ;
        ppt:_FillValue = -2147483648 ;
        ppt:missing_value = -2147483648 ;
        ppt:description = "Accumulated Precipitation" ;
        ppt:dimensions = "lon lat time" ;
        ppt:coordinate_system = "WGS84,EPSG:4326" ;

I would like re-order the dimension from time,lat,lon to lat,lon,time.

I use command: ncpdq -a lat,lon,time in.nc out.nc After re-ordering the variables, the lat dimension becomes UNLIMITED which is wrong. The time dimension should be the UNLIMITED dimension.

dimensions:
    time = 756 ;
    lon = 55 ;
    lat = UNLIMITED ; // (60 currently)

...
...

    int ppt(lat, lon, time) ;

Then I tried to fix the lat dimension who becomes UNLIMITED using ncks command below:

ncks --fix_rec_dmn lat out.nc out1.nc

It's worked, see below:

dimensions:
    lat = 60 ;
    lon = 55 ;
    time = 756 ;

Now I would like to make UNLIMITED the time dimension again using ncks command below:

ncks --fix_rec_dmn time out1.nc out2.nc

Unfortunately nothing happen, the result remain same. See below:

dimensions:
    lat = 60 ;
    lon = 55 ;
    time = 756 ;

My question, how to make UNLIMITED the time dimension again?



Solution 1:[1]

I found similar problem and answer from https://stackoverflow.com/a/55883675/10874805

My mistake, to make UNLIMITED the time dimension, I must use --mk_rec_dmn instead of --fix_rec_dmn

So the code should be: ncks --mk_rec_dmn time out1.nc out2.nc

Solution 2:[2]

In netCDF3 files, variables can only have the unlimited dimension, if any, as their first dimension. netCDF4 relaxes this restriction, so if you want the record dimension in a position other than the most rapidly varying dimension, you must ensure the output is a netCDF4 file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Charlie Zender