$Header$ -*-text-*-

netCDF Operators NCO version 5.3.0 wag their tails

http://nco.sf.net (Homepage, Mailing lists, Help)
http://github.com/nco/nco (Source Code, Issues, Releases)

What's new?
Version 5.3.0 significantly improves the unpacking of ELM/CLM/CTSM
history and restart datasets, and seems complete in this regard.
ncrcat has more friendly behavior when appending, and ncclimo now
outputs more metrics (such as valid area per gridcell) when in
regional statistics mode. This release many be skipped if these
changes do not interest you. 

Work on 5.3.1 is underway and includes improved NC_STRING for
common text attributes.

Enjoy,
Charlie

NEW FEATURES (full details always in ChangeLog):

A. Once again, ncks leveled-up how it unpacks ELM/CLM history/restart
files. New features include automatic writing of fractional landunit
and fractional column variables frc_landunit and frc_column,
respectivly. frc_landunit is equivalent to the variable PCT_LANDUNIT
sometimes placed in history files, but is expressed as a decimal
fraction (not a percent) and is derived from restart files.
The landunit dimension of frc_landunit is of size ten: Index zero
contains the sum (should be 1.0) of standard landunit types/indexes
1-9 soil, crop, ..., urban medium density).
frc_column is a bespoke version of the same, only for column (not
landunit) types. For datasets with Multiple Elevation Classes (MECs):
index = 0 is soil column, index = 1 is MEC == 1, indexes 2..10
are remaining MEC columns, index 11 is sub-total of MEC columns, index
= 12 is deep lake column, index = 13 is wetland column, and index = 14
is grand total of natural columns. For non-MEC datasets, index = 0 is
soil column, index = 1 is glaciated column, index = 2 is deep lake
column, index = 3 is wetland column, and index = 4 is grand total of
natural columns. 

ncks --s1d --hrz=history.nc restart.nc s1d_r05.nc # Restart file
ncks -m -v frc.? s1d_r05.nc
netcdf s1d_r05 {
  dimensions:
    column = 15 ;
    landunit = 10 ;
    lat = 360 ;
    lon = 720 ;

  variables:
    float frc_column(column,lat,lon) ;
    float frc_landunit(landunit,lat,lon) ;
} 

http://nco.sf.net/nco.html#s1d
http://nco.sf.net/nco.html#unpack_sparse

B. ncks can now grid snow-related variables into a top-down
(ocean-like) vertical grid that many think is more intuitive. 
By default ELM/CLM/CTSM store the negative of the number of active
snow layers in the variable SNLSNO. Restart files for these models
store the active snow layer butted-up against the lowest layers in
the level dimension (so that they are continguous with soil layers
to simplify hydrologic calculations). This makes snow variables in
restart files hard to visualize. By default S1D now uses SNLSNO, if
present, to unpack snow variables in a first layer downwards order,
increasing with depth. Inactive layers at the bottom (i.e., where they
reside physically). The resulting snow variables appear like ocean
state variables over uneven bathymetry, with missing value
underneath. We call this "snow-ocean" ordering to contrast it with
the on-disk storage order of snow variables. 

http://nco.sf.net/nco.html#s1d
http://nco.sf.net/nco.html#snw_ocn
http://nco.sf.net/nco.html#snw_rdr
http://nco.sf.net/nco.html#no_snw_ocn

C. ncks S1D now accepts the "--rgr lut_out=$lut_out" option to specify 
which column type(s) to place in each gridcell in the output file.
The argument lut_out is the standard landunit type of the column,
with (thus far) two additional values that will output area-weighted
averages of multiple landunit types:

lut_out Output will be value of column(s) in this Landunit 
1       Vegetated or bare soil
2       Crop
3       Landice (plain, no MEC)
4       Landice multiple elevation classes
5       Deep lake
6       Wetland
7       Urban tall building district
8       Urban high density
9       Urban medium density
10      Area-weighted average of all landunit types except MEC glaciers
13      Area-weighted average of soil+(non-MEC) glacier

For example,
ncks --s1d --rgr lut_out=1 --hrz=hst.nc rst.nc s1d.nc # Output Soil LUT
ncks --s1d --rgr lut_out=13 --hrz=hst.nc rst.nc s1d.nc # Avg Soil+Glacier

http://nco.sf.net/nco.html#s1d
http://nco.sf.net/nco.html#lut_out

D. ncremap always warns when it regrids land model files that contain
a "landfrac" variable and SGS renormalization is not requested. 
This is because ELM/CLM/CTSM use "landfrac" for sub-gridscale
fraction, and ignoring that causes errors along coastlines.
EAMxx also archives that same "landfrac" but every EAMxx variable
is valid throughout every gridcell so renormalization would be
superfluous at best. Now ncremap no longer emits the "landfrac"
WARNING for EAMxx files.
http://nco.sf.net/nco.html#eamxx

E. As of NCO version 5.3.0 (December, 2025) ncclimo automatically
outputs additional metrics with global statistics. The output files
containing the global timeseries also contain the variable
valid_area_per_gridcell. This field is equivalent to the product of
the area variable and the sgs_frc variable (if any). Thus for
ELM/CLM/CTSM, this field equals area times landfrac, while for EAM/CAM
this variable simply equals area. The output files also contain the
area and sgs_frc variables separately. The presence of these variables
in output allows downstream processors (e.g., zppy) to generate
additional masks and weights for rescaling the statistics. For
example, these fields can be used to rescale global sums into any
units desired. 
ncclimo -P elm --split --rgn_stt=sum -c v3.LR.piControl -s 460 -e 461 \
--drc_in=drc_in --drc_out=drc_out
http://nco.sf.net/nco.html#glb_stt
http://nco.sf.net/nco.html#rgn_stt

BUG FIXES:
   
A. ncrcat ensures that the last time value and monotonicity are
both defined before the monotonicity check is performed in REC_APN
mode. This fixes overly noisy false-negative WARNINGs about
monotonicity. Thanks to Seth McGinnis (NCAR) for reporting this
problem.

Full release statement at http://nco.sf.net/ANNOUNCE
    
KNOWN PROBLEMS DUE TO NCO:

This section of ANNOUNCE reports and reminds users of the
existence and severity of known, not yet fixed, problems. 
These problems occur with NCO 5.2.7 built/tested under
MacOS 15.2 with netCDF 4.9.4-development on HDF5 1.14.3
and with Linux FC40 with netCDF 4.9.2 on HDF5 1.14.3.

A. NOT YET FIXED (NCO problem)
   Correctly read arrays of NC_STRING with embedded delimiters in ncatted arguments

   Demonstration:
   ncatted -D 5 -O -a new_string_att,att_var,c,sng,"list","of","str,ings" ~/nco/data/in_4.nc ~/foo.nc
   ncks -m -C -v att_var ~/foo.nc

   20130724: Verified problem still exists
   TODO nco1102
   Cause: NCO parsing of ncatted arguments is not sophisticated
   enough to handle arrays of NC_STRINGS with embedded delimiters.

B. NOT YET FIXED (NCO problem?)
   ncra/ncrcat (not ncks) hyperslabbing can fail on variables with multiple record dimensions

   Demonstration:
   ncrcat -O -d time,0 ~/nco/data/mrd.nc ~/foo.nc

   20140826: Verified problem still exists
   20140619: Problem reported by rmla
   Cause: Unsure. Maybe ncra.c loop structure not amenable to MRD?
   Workaround: Convert to fixed dimensions then hyperslab

KNOWN PROBLEMS DUE TO BASE LIBRARIES/PROTOCOLS:

A. NOT YET FIXED (netCDF4 or HDF5 problem?)
   Specifying strided hyperslab on large netCDF4 datasets leads
   to slowdown or failure with recent netCDF versions.

   Demonstration with NCO <= 4.4.5:
   time ncks -O -d time,0,,12 ~/ET_2000-01_2001-12.nc ~/foo.nc
   Demonstration with NCL:
   time ncl < ~/nco/data/ncl.ncl   
   20140718: Problem reported by Parker Norton
   20140826: Verified problem still exists
   20140930: Finish NCO workaround for problem
   20190201: Possibly this problem was fixed in netCDF 4.6.2 by https://github.com/Unidata/netcdf-c/pull/1001
   Cause: Slow algorithm in nc_var_gets()?
   Workaround #1: Use NCO 4.4.6 or later (avoids nc_var_gets())
   Workaround #2: Convert file to netCDF3 first, then use stride
   Workaround #3: Compile NCO with netCDF >= 4.6.2

B. NOT YET FIXED (netCDF4 library bug)
   Simultaneously renaming multiple dimensions in netCDF4 file can corrupt output

   Demonstration:
   ncrename -O -d lev,z -d lat,y -d lon,x ~/nco/data/in_grp.nc ~/foo.nc # Completes but produces unreadable file foo.nc
   ncks -v one ~/foo.nc

   20150922: Confirmed problem reported by Isabelle Dast, reported to Unidata
   20150924: Unidata confirmed problem
   20160212: Verified problem still exists in netCDF library
   20160512: Ditto
   20161028: Verified problem still exists with netCDF 4.4.1
   20170323: Verified problem still exists with netCDF 4.4.2-development
   20170323: https://github.com/Unidata/netcdf-c/issues/381
   20171102: Verified problem still exists with netCDF 4.5.1-development
   20171107: https://github.com/Unidata/netcdf-c/issues/597
   20190202: Progress has recently been made in netCDF 4.6.3-development
   More details: http://nco.sf.net/nco.html#ncrename_crd

C. NOT YET FIXED (would require DAP protocol change?)
   Unable to retrieve contents of variables including period '.' in name
   Periods are legal characters in netCDF variable names.
   Metadata are returned successfully, data are not.
   DAP non-transparency: Works locally, fails through DAP server.

   Demonstration:
   ncks -O -C -D 3 -v var_nm.dot -p http://thredds-test.ucar.edu/thredds/dodsC/testdods in.nc # Fails to find variable

   20130724: Verified problem still exists. 
   Stopped testing because inclusion of var_nm.dot broke all test scripts.
   NB: Hard to fix since DAP interprets '.' as structure delimiter in HTTP query string.

   Bug tracking: https://www.unidata.ucar.edu/jira/browse/NCF-47

D. NOT YET FIXED (would require DAP protocol change)
   Correctly read scalar characters over DAP.
   DAP non-transparency: Works locally, fails through DAP server.
   Problem, IMHO, is with DAP definition/protocol

   Demonstration:
   ncks -O -D 1 -H -C -m --md5_dgs -v md5_a -p http://thredds-test.ucar.edu/thredds/dodsC/testdods in.nc

   20120801: Verified problem still exists
   Bug report not filed
   Cause: DAP translates scalar characters into 64-element (this
   dimension is user-configurable, but still...), NUL-terminated
   strings so MD5 agreement fails 

"Sticky" reminders:

A. Reminder that NCO works on most HDF4 and HDF5 datasets, e.g., 
   HDF4: AMSR MERRA MODIS ...
   HDF5: GLAS ICESat Mabel SBUV ...
   HDF-EOS5: AURA HIRDLS OMI ...

B. Pre-built executables for many OS's at:
   http://nco.sf.net#bnr

