[nco] 01/07: Imported Upstream version 4.6.0

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Fri May 13 08:31:23 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository nco.

commit ea959a6d7644358100ce0d813457ddaa0d5ecf19
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri May 13 09:39:47 2016 +0200

    Imported Upstream version 4.6.0
---
 bld/Makefile                      |   13 +-
 bld/nco.spec                      |   11 +-
 bld/nco_dst.pl                    |   30 +-
 bm/NCO_bm.pm                      |    4 +-
 bm/NCO_rgr.pm                     |  350 ++--
 configure                         |   38 +-
 configure.ac                      |   18 +-
 configure.eg                      |   54 +-
 data/Makefile.am                  |   11 +-
 data/Makefile.in                  |   11 +-
 data/bsc_tst.nco                  |  453 +++++
 data/gsl_sf.in                    |   99 +-
 data/in.cdl                       |   30 +-
 data/in_grp_8.cdl                 |   72 +-
 data/ncclimo                      | 1019 +++++++++++
 data/ncremap                      |  326 +++-
 data/vpointer-ex1.nco             |   47 +
 data/vpointer-ex2.nco             |   91 +
 data/vpointer-tst.nco             |   41 +
 debian/changelog                  |    6 +
 doc/ANNOUNCE                      |  220 ++-
 doc/ChangeLog                     |  331 ++++
 doc/MANIFEST                      |    2 +
 doc/TODO                          |    5 +-
 doc/VERSION                       |    2 +-
 doc/debian.txt                    |  162 +-
 doc/index.shtml                   |   96 +-
 doc/milestones_old.shtml          |    9 +-
 doc/nco.texi                      | 1138 ++++++++++--
 man/Makefile.am                   |    2 +-
 man/Makefile.in                   |    2 +-
 man/ncap.1                        |   17 +
 man/ncap2.1                       |   17 +
 man/ncatted.1                     |   25 +-
 man/ncbo.1                        |    2 +-
 man/{ncremap.1 => ncclimo.1}      |   75 +-
 man/ncecat.1                      |    1 +
 man/nces.1                        |   17 +
 man/ncflint.1                     |   17 +
 man/ncks.1                        |    1 +
 man/nco.1                         |    1 +
 man/ncpdq.1                       |   17 +
 man/ncra.1                        |    1 +
 man/ncrcat.1                      |   17 +
 man/ncremap.1                     |    2 +-
 man/ncrename.1                    |    1 +
 man/ncwa.1                        |    1 +
 src/nco++/NcapVarVector.cc        |   32 +
 src/nco++/NcapVarVector.hh        |    1 +
 src/nco++/VarOpNew.hh             |  787 +++++++++
 src/nco++/fmc_all_cls.cc          | 1026 +++++++++--
 src/nco++/fmc_all_cls.hh          |   33 +-
 src/nco++/ncap2.cc                |   44 +-
 src/nco++/ncap2_utl.cc            |  647 +++++--
 src/nco++/ncap2_utl.hh            |   41 +-
 src/nco++/ncoEnumTokenTypes.hpp   |  135 +-
 src/nco++/ncoGrammer.g            |  911 ++++++----
 src/nco++/ncoLexer.cpp            |  180 +-
 src/nco++/ncoLexer.hpp            |    2 +-
 src/nco++/ncoParser.cpp           |  714 ++++----
 src/nco++/ncoParser.hpp           |    9 +-
 src/nco++/ncoParserTokenTypes.hpp |  135 +-
 src/nco++/ncoTree.cpp             | 3501 +++++++++++++++++++++++--------------
 src/nco++/ncoTree.hpp             |   19 +-
 src/nco++/vtl_cls.hh              |   15 +-
 src/nco/libnco.h                  |    2 +-
 src/nco/mpncbo.c                  |    8 +-
 src/nco/mpncecat.c                |    6 +-
 src/nco/mpncflint.c               |    6 +-
 src/nco/mpncpdq.c                 |    6 +-
 src/nco/mpncra.c                  |    8 +-
 src/nco/mpncwa.c                  |    6 +-
 src/nco/ncap.c                    |    6 +-
 src/nco/ncap_yacc.y               |    2 +-
 src/nco/ncatted.c                 |   12 +-
 src/nco/ncbo.c                    |    6 +-
 src/nco/ncecat.c                  |    6 +-
 src/nco/ncflint.c                 |    6 +-
 src/nco/ncks.c                    |   50 +-
 src/nco/nco.h                     |  109 +-
 src/nco/nco_att_utl.c             |   64 +-
 src/nco/nco_att_utl.h             |    3 +-
 src/nco/nco_aux.c                 |    4 +-
 src/nco/nco_bnr.c                 |   39 +-
 src/nco/nco_bnr.h                 |   19 +-
 src/nco/nco_cnf_dmn.c             |    8 +-
 src/nco/nco_cnv_csm.c             |   52 +-
 src/nco/nco_cnv_csm.h             |    3 +-
 src/nco/nco_ctl.c                 |   14 +-
 src/nco/nco_fl_utl.c              |   11 +-
 src/nco/nco_fl_utl.h              |    2 +-
 src/nco/nco_grp_trv.c             |   22 +
 src/nco/nco_grp_trv.h             |    5 +
 src/nco/nco_grp_utl.c             |  152 +-
 src/nco/nco_grp_utl.h             |    4 +-
 src/nco/nco_mmr.c                 |    2 +-
 src/nco/nco_msa.h                 |    2 +-
 src/nco/nco_netcdf.c              |   81 +-
 src/nco/nco_netcdf.h              |    2 +
 src/nco/nco_omp.c                 |    2 +-
 src/nco/nco_pck.c                 |   40 +-
 src/nco/nco_ppc.c                 |   24 +-
 src/nco/nco_prn.c                 |   17 +-
 src/nco/nco_rgr.c                 | 1021 +++++++++--
 src/nco/nco_scm.c                 |   21 +-
 src/nco/nco_sld.c                 |  553 ++++++
 src/nco/nco_sld.h                 |   26 +
 src/nco/nco_sng_utl.c             |   47 +
 src/nco/nco_sng_utl.h             |    5 +-
 src/nco/nco_typ.h                 |   29 +
 src/nco/nco_var_lst.c             |    2 +
 src/nco/nco_var_utl.c             |   93 +-
 src/nco/nco_var_utl.h             |    7 +-
 src/nco/ncpdq.c                   |  128 +-
 src/nco/ncra.c                    |  279 ++-
 src/nco/ncwa.c                    |    8 +-
 src/nco_c++/Makefile.am           |    2 +-
 src/nco_c++/Makefile.in           |    2 +-
 src/nco_c++/Makefile.old          |    2 +-
 src/nco_c++/tst.cc                |    2 +-
 120 files changed, 12241 insertions(+), 3934 deletions(-)

diff --git a/bld/Makefile b/bld/Makefile
index d7dc64c..95cfe80 100644
--- a/bld/Makefile
+++ b/bld/Makefile
@@ -284,7 +284,7 @@ endif # endif ZNETCDF
 # These tokens should not be altered by hand
 
 # NB: CPP_TKN is recursively expanded variable, define only when components are ready
-CPP_TKN = ${USR_TKN} -D${PVM_ARCH} -DNO_NETCDF_2 -DVERSION='${VRS_SNG}' -DHOSTNAME='${HOST}' -DUSER='${USER}' -DNCO_ABORT_ON_ERROR
+CPP_TKN = ${USR_TKN} -D${PVM_ARCH} -DNO_NETCDF_2 -DNCO_VERSION='${VRS_SNG}' -DHOSTNAME='${HOST}' -DUSER='${USER}' -DNCO_ABORT_ON_ERROR
 ifndef LFLAGS # Flags for Flex (Lex)
  LFLAGS := -P${NCO_YY_PFX}
 endif
@@ -521,7 +521,7 @@ CPP_PTH := $(foreach dir,${MDL_PTH},-I${dir})
 # Variables having to do with binary executables created by module
 MDL_BIN_TRG := ncap ncatted ncbo ncecat ncflint ncks ncpdq ncra ncrename ncwa # NCO binary targets
 MDL_BIN_SYM_LNK := ncdiff ncea nces ncrcat # Symbolic links
-MDL_BIN_SPT := ncremap # Scripts
+MDL_BIN_SPT := ncclimo ncremap # Scripts
 ifeq (${MPI},Y)
 # MDL_MPI_TRG := mpncbo mpncecat mpncflint mpncpdq mpncra mpncwa # MPI binary targets
  MDL_MPI_TRG := # MPI binary targets
@@ -1666,6 +1666,9 @@ ${MY_BIN_DIR}/ncbo:	${MY_OBJ_DIR}/ncbo.o lib
 	${CC} -o $@${BNR_SFX} $< ${LDFLAGS}
 	chmod 755 $@${BNR_SFX}
 	cd ${MY_BIN_DIR}; rm -f ncdiff; ln -s -f ncbo ncdiff
+ncclimo:   ${MY_BIN_DIR}/ncclimo
+${MY_BIN_DIR}/ncclimo:	${MY_DAT_DIR}/ncclimo
+	/bin/cp -f ${MY_DAT_DIR}/ncclimo ${MY_BIN_DIR}
 ncecat:   ${MY_BIN_DIR}/ncecat
 ${MY_BIN_DIR}/ncecat:	${MY_OBJ_DIR}/ncecat.o lib
 	${CC} -o $@${BNR_SFX} $< ${LDFLAGS}
@@ -1788,7 +1791,7 @@ ${MY_DAT_DIR}/buggy.nc: ${MY_DAT_DIR}/buggy.cdl
 dap:	data
 	-cd ~/nco/data; scp in.nc in.cdl dust.ess.uci.edu:/var/www/html/dodsdata; scp in.nc in.cdl esmf.ess.uci.edu:/var/www/html/dodsdata; scp in.nc in.cdl esmf.ess.uci.edu:/data/dodsdata
 data:	dat
-dat:	${MY_DAT_DIR}/cmip5.nc ${MY_DAT_DIR}/obs.nc ${MY_DAT_DIR}/dsm.nc ${MY_DAT_DIR}/hdn.nc ${MY_DAT_DIR}/hdf.hdf ${MY_DAT_DIR}/mdl_1.nc ${MY_DAT_DIR}/mdl_2.nc ${MY_DAT_DIR}/mdl_3.nc ${MY_DAT_DIR}/mrd.nc ${MY_DAT_DIR}/in.nc ${MY_DAT_DIR}/in_4c.nc ${MY_DAT_DIR}/in_grp.nc ${MY_DAT_DIR}/in_4.nc ${MY_DAT_DIR}/in_grp_1.nc ${MY_DAT_DIR}/in_grp_2.nc ${MY_DAT_DIR}/in_grp_3.nc ${MY_DAT_DIR}/in_grp_4.nc ${MY_DAT_DIR}/in_grp_5.nc ${MY_DAT_DIR}/in_grp_6.nc ${MY_DAT_DIR}/in_grp_7.nc ${MY_DAT_DIR}/in_r [...]
+dat:	${MY_DAT_DIR}/cmip5.nc ${MY_DAT_DIR}/obs.nc ${MY_DAT_DIR}/dsm.nc ${MY_DAT_DIR}/hdn.nc ${MY_DAT_DIR}/hdf.hdf ${MY_DAT_DIR}/mdl_1.nc ${MY_DAT_DIR}/mdl_2.nc ${MY_DAT_DIR}/mdl_3.nc ${MY_DAT_DIR}/mrd.nc ${MY_DAT_DIR}/in.nc ${MY_DAT_DIR}/in_4c.nc ${MY_DAT_DIR}/in_grp.nc ${MY_DAT_DIR}/in_4.nc ${MY_DAT_DIR}/in_grp_1.nc ${MY_DAT_DIR}/in_grp_2.nc ${MY_DAT_DIR}/in_grp_3.nc ${MY_DAT_DIR}/in_grp_4.nc ${MY_DAT_DIR}/in_grp_5.nc ${MY_DAT_DIR}/in_grp_6.nc ${MY_DAT_DIR}/in_grp_7.nc ${MY_DAT_DIR}/in_g [...]
 	-for fl in ${MDL_DAT_STB}; do cd ${MY_DAT_DIR}; ln -s -f in.nc $$fl; done
 ${MY_DAT_DIR}/in.nc: ${MY_DAT_DIR}/in.cdl
 	ncgen -b -o $@ $<
@@ -1820,6 +1823,8 @@ ${MY_DAT_DIR}/in_grp_6.nc: ${MY_DAT_DIR}/in_grp_6.cdl
 	-ncgen -k netCDF-4 -b -o $@ $<
 ${MY_DAT_DIR}/in_grp_7.nc: ${MY_DAT_DIR}/in_grp_7.cdl
 	-ncgen -k netCDF-4 -b -o $@ $<
+${MY_DAT_DIR}/in_grp_8.nc: ${MY_DAT_DIR}/in_grp_8.cdl
+	-ncgen -k netCDF-4 -b -o $@ $<
 ${MY_DAT_DIR}/cmip5.nc: ${MY_DAT_DIR}/cmip5.cdl
 	-ncgen -k netCDF-4 -b -o $@ $<
 ${MY_DAT_DIR}/hdn.nc: ${MY_DAT_DIR}/hdn.cdl
@@ -2089,7 +2094,7 @@ dbg:
 distclean: dst_cln
 dst_cln: cln bin_cln dat_cln doc_cln root_cln
 	cd ${MY_BLD_DIR}; rm -f *~
-	cd ${MY_DAT_DIR}; rm -f buggy.nc cmip5.nc dsm.nc obs.nc hdf.hdf mdl_1.nc mdl_2.nc mdl_3.nc in.nc in_4c.nc in_4.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc in_rec_zero.nc *~
+	cd ${MY_DAT_DIR}; rm -f buggy.nc cmip5.nc dsm.nc obs.nc hdf.hdf mdl_1.nc mdl_2.nc mdl_3.nc in.nc in_4c.nc in_4.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc in_grp_8.nc in_rec_zero.nc *~
 tags: 
 	etags ${TAGS_FILES}
 #	etags ${MY_SRC_DIR}/*.h $(filter-out ${TAGS_FILTER_FILES},${SRC_LST}) ${MDL_DOC_SRC} ${MDL_MAN} ${MDL_BLD_SRC} ${MDL_CXX_SRC} ${MDL_NCAP_SRC} ${MDL_QT_SRC}
diff --git a/bld/nco.spec b/bld/nco.spec
index 3ae4ee2..45dfcca 100644
--- a/bld/nco.spec
+++ b/bld/nco.spec
@@ -2,17 +2,17 @@
 # http://cvs.fedoraproject.org/viewvc/devel/nco/nco.spec?view=co
 
 Name:           nco
-Version:        4.5.5
+Version:        4.6.0
 Release:        1%{?dist}
 Summary:        Programs that manipulate netCDF files
 Group:          Applications/Engineering
 License:        GPL3
 URL:            http://nco.sf.net/
 
-# Obtain NCO version 4.5.5-1 tar.gz from Sourceforge using CVS:
+# Obtain NCO version 4.6.0-1 tar.gz from Sourceforge using CVS:
 # cvs -d:pserver:anonymous at nco.cvs.sf.net:/cvsroot/nco login
-# cvs -z3 -d:pserver:anonymous at nco.cvs.sf.net:/cvsroot/nco co -r nco-4.5.5-1 -d nco-%{version} nco
-# tar czf nco-%{version}.tar.gz --exclude='nco-4.5.5/debian*' --exclude='.cvsignore' --exclude=ncap_lex.c --exclude='ncap_yacc.[ch]' ./nco-%{version}
+# cvs -z3 -d:pserver:anonymous at nco.cvs.sf.net:/cvsroot/nco co -r nco-4.6.0-1 -d nco-%{version} nco
+# tar czf nco-%{version}.tar.gz --exclude='nco-4.6.0/debian*' --exclude='.cvsignore' --exclude=ncap_lex.c --exclude='ncap_yacc.[ch]' ./nco-%{version}
 Source0:        nco-%{version}.tar.gz
 #Patch0:		nco_install_C_headers.patch
 #Patch1:         nco_find_udunits-dat.patch
@@ -108,6 +108,9 @@ fi
 # %{_libdir}/libnco++.so
 
 %changelog
+* Thu May 12 2016 Charlie Zender <zender at uci.edu> - 4.6.0-1
+- new upstream 4.6.0
+
 * Thu Feb 07 2016 Charlie Zender <zender at uci.edu> - 4.5.5-1
 - new upstream 4.5.5
 
diff --git a/bld/nco_dst.pl b/bld/nco_dst.pl
index 230e050..8344ee7 100755
--- a/bld/nco_dst.pl
+++ b/bld/nco_dst.pl
@@ -5,20 +5,20 @@
 
 # Usage:
 # Export tagged, public versions
-# /usr/bin/scp ${DATA}/nco-4.5.5.tar.gz zender,nco at web.sf.net:/home/project-web/nco/htdocs/src
-
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln nco-4.5.5 # Build, do not release on SF
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln --sf nco-4.5.5 # Build, release on SF
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --nst_all nco-4.5.5 # Install, do not build
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln --nst_all nco-4.5.5 # Build and install
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --acd_cnt nco-4.5.5
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --acd_prs nco-4.5.5
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --cgd_cnt nco-4.5.5
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --cray_prs nco-4.5.5
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --bbl_cnt nco-4.5.5
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --blk_cnt nco-4.5.5
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --dat_cnt nco-4.5.5
-# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --ute_prs nco-4.5.5
+# /usr/bin/scp ${DATA}/nco-4.6.0.tar.gz zender,nco at web.sf.net:/home/project-web/nco/htdocs/src
+
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln nco-4.6.0 # Build, do not release on SF
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln --sf nco-4.6.0 # Build, release on SF
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --nst_all nco-4.6.0 # Install, do not build
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln --nst_all nco-4.6.0 # Build and install
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --acd_cnt nco-4.6.0
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --acd_prs nco-4.6.0
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --cgd_cnt nco-4.6.0
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --cray_prs nco-4.6.0
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --bbl_cnt nco-4.6.0
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --blk_cnt nco-4.6.0
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --dat_cnt nco-4.6.0
+# ${HOME}/nco/bld/nco_dst.pl --dbg=2 --cln --ute_prs nco-4.6.0
 
 # Export daily snapshot
 # ${HOME}/nco/bld/nco_dst.pl --dbg=2 
@@ -256,7 +256,7 @@ if($bld){
 # Set up FTP server
     chdir $dst_pth_pfx or die "$prg_nm: ERROR unable to chdir to $dst_pth_pfx: $!\n"; # $! is system error string
     cmd_prc("$cp_cmd $doc_fl ./$dst_vrs/doc"); # Copy derived documentation to source directory
-    cmd_prc("$tar_cmd cvzf $dst_fl --exclude='nco-4.5.5/debian*' --exclude='.cvsignore' --exclude=ncap_lex.c --exclude=ncap_yacc.[ch] ./$dst_vrs"); # Create gzipped tarfile
+    cmd_prc("$tar_cmd cvzf $dst_fl --exclude='nco-4.6.0/debian*' --exclude='.cvsignore' --exclude=ncap_lex.c --exclude=ncap_yacc.[ch] ./$dst_vrs"); # Create gzipped tarfile
     cmd_prc("$rsh_cmd $www_mch $rm_cmd $www_drc/src/$dst_fl"); # Remove any distribution with same name
     if($dly_snp){cmd_prc("$rsh_cmd $www_mch $rm_cmd -r $www_drc/src/nco-????????.tar.gz");} # Remove previous daily snapshots from WWW server
     cmd_prc("$rcp_cmd $dst_fl $www_mch:$www_drc/src"); # Copy local tarfile to WWW server
diff --git a/bm/NCO_bm.pm b/bm/NCO_bm.pm
index 11e7ccd..f3946cc 100644
--- a/bm/NCO_bm.pm
+++ b/bm/NCO_bm.pm
@@ -150,8 +150,8 @@ sub bm_ntl($$){
     my $dbg_lvl; # [flg] Debugging level
     ($bch_flg,$dbg_lvl)=@_;
 # Enumerate operators to test
-    @opr_lst_all = qw( ncap2 ncdiff ncatted ncbo ncflint nces ncecat ncks ncpdq ncra ncrcat ncrename ncwa net);
-    @opr_lst_mpi = qw( ncbo ncecat ncflint ncpdq ncra ncwa ncpdq ncra);
+    @opr_lst_all = qw( ncap2 ncdiff ncatted ncbo ncclimo ncflint nces ncecat ncks ncpdq ncra ncrcat ncremap ncrename ncwa net);
+    @opr_lst_mpi = qw( ncbo ncecat ncflint ncpdq ncra ncwa ncpdq ncra );
     $opr_sng_mpi = "ncbo ncdiff ncecat ncflint nces ncpdq ncra ncwa "; # ncpdq ncra MPI, but fail bench
     $opr_rgr_mpi = "ncbo ncdiff ncecat ncflint nces ncpdq ncra ncwa ncrcat"; # need all of them for regression
     
diff --git a/bm/NCO_rgr.pm b/bm/NCO_rgr.pm
index 3078a2c..df898f9 100644
--- a/bm/NCO_rgr.pm
+++ b/bm/NCO_rgr.pm
@@ -30,7 +30,7 @@ use vars qw(
 	    $foo_fl $foo_tst $foo_x_fl $foo_xy_fl
 	    $foo_xymyx_fl $foo_y_fl $foo_yx_fl $mpi_prc $nco_D_flg $localhostname
 	    $nsr_xpc $omp_flg $opr_nm $opr_rgr_mpi $fl_out_rgn
-	    $fl_out $pth_rmt_scp_tst $prsrv_fl @tst_cmd $USER %NCO_RC
+	    $fl_out $pth_rmt_scp_tst $prsrv_fl @tst_cmd $HOME $DATA $USER %NCO_RC
 	    );
 
 sub tst_rgr {
@@ -110,6 +110,7 @@ sub tst_rgr {
   if($exit_value == 433){print "netCDF version 4.3.3 detected\n";}
   if($exit_value == 440){print "netCDF version 4.4.0 detected\n";}
   if($exit_value == 441){print "netCDF version 4.4.1 detected\n";}
+  if($exit_value == 442){print "netCDF version 4.4.2 detected\n";}
 
   if($exit_value >= 400){$RUN_NETCDF4_TESTS=1;}
   if($exit_value >= 431){$RUN_NETCDF4_TESTS_VERSION_GE_431=1;}
@@ -117,6 +118,165 @@ sub tst_rgr {
 print "\n";
 
 ####################
+#### ncclimo tests #
+####################
+    $opr_nm="ncclimo";
+    $USER=$ENV{'USER'};
+    $DATA=$ENV{'DATA'};
+    $HOME=$ENV{'HOME'};
+if($USER eq 'zender'){
+# ncclimo -v FSNT,AODVIS -c famipc5_ne30_v0.3_00003 -s 1980 -e 1983 -i ${DATA}/ne30/raw -o ${DATA}/ne30/clm
+# ncwa -O -w area ${DATA}/ne30/clm/famipc5_ne30_v0.3_00003_ANN_197912_198311_climo.nc ~/foo.nc
+# ncks -O -H -u -C -v FSNT ~/foo.nc
+	$dsc_sng="ncclimo (depends on input files in ${DATA}/ne30/raw)";
+	$tst_cmd[0]="ncclimo -v FSNT,AODVIS,area -c famipc5_ne30_v0.3_00003 -s 1980 -e 1983 -i ${DATA}/ne30/raw -o ${DATA}/ne30/clm > ${HOME}/foo.ncclimo";
+	$tst_cmd[1]="ncwa -O $fl_fmt $nco_D_flg -w area ${DATA}/ne30/clm/famipc5_ne30_v0.3_00003_ANN_197912_198311_climo.nc %tmp_fl_00%";
+	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_00%";
+	$tst_cmd[3]="FSNT = 235.503 W/m2";
+	$tst_cmd[4]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+} # !zender
+
+####################
+#### ncremap tests #
+####################
+    $opr_nm="ncremap";
+####################
+    $USER=$ENV{'USER'};
+    $DATA=$ENV{'DATA'};
+    $HOME=$ENV{'HOME'};
+if($USER eq 'zender'){
+	# Regridding regression tests
+	# valgrind --leak-check=yes --show-reachable=yes --suppressions=${HOME}/nco/doc/valgrind.txt --tool=memcheck ncks -O -D 5 --map=${DATA}/maps/map_ne30np4_to_fv129x256_aave.150418.nc ${DATA}/ne30/rgr/ne30_tst.nc ~/foo.nc > ~/foo 2>&1
+	# ncks -O -D 5 --map=${DATA}/maps/map_ne30np4_to_fv129x256_aave.150418.nc ${DATA}/ne30/rgr/ne30_tst.nc ~/foo.nc
+	# ncwa -O -w area ~/foo.nc ~/foo2.nc
+	# ncks -H -u -C -v FSNT ~/foo2.nc
+	# ncwa -O -y ttl -v area ~/foo.nc ~/foo3.nc
+	# ncks -H -u -C -v area ~/foo3.nc
+	
+	$dsc_sng="ncks regrid FSNT 1D->2D to test conservation (does SSH/scp to dust.ess.uci.edu)";
+	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc .";
+	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_tst.nc .";
+	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_ne30np4_to_fv129x256_aave.20150901.nc ne30_tst.nc %tmp_fl_00%";
+#	my $pwd=`pwd`; chomp $pwd; print $pwd;
+#	$dsc_sng="ncks regrid FSNT to regridding conservation (does wget to dust.ess.uci.edu)";
+#	$tst_cmd[0]="wget -c -P $drc_dat http://dust.ess.uci.edu/maps/map_ne30np4_to_fv129x256_aave.20150901.nc";
+#	$tst_cmd[1]="wget -c -P $drc_dat http://dust.ess.uci.edu/ne30/rgr/ne30_tst.nc";
+#	$tst_cmd[2]="ncks -h -O $fl_fmt $nco_D_flg --map=".$drc_dat."/map_ne30np4_to_fv129x256_aave.20150901.nc ".$drc_dat."/ne30_tst.nc %tmp_fl_00%";
+	$tst_cmd[3]="/bin/cp -f %tmp_fl_00% ne30_2D.nc";
+	$tst_cmd[4]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
+	$tst_cmd[5]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
+	$tst_cmd[6]="FSNT = 244.124 W/m2";
+	$tst_cmd[7]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+	$dsc_sng="ncks regrid AODVIS 1D->2D to test missing value treatment";
+	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v AODVIS %tmp_fl_01%";
+	$tst_cmd[1]="AODVIS = 0.151705";
+	$tst_cmd[2]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+	$dsc_sng="ncks regrid area 1D->2D to test grid area integral/normalization";
+	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg --map=${drc_dat}/map_ne30np4_to_fv129x256_aave.20150901.nc ${drc_dat}/ne30_tst.nc %tmp_fl_00%";
+	$tst_cmd[1]="ncwa -O $fl_fmt $nco_D_flg -y ttl -v area %tmp_fl_00% %tmp_fl_02%";
+	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v area %tmp_fl_02%";
+	$tst_cmd[3]="area = 12.5663706144 steradian";
+	$tst_cmd[4]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+	$dsc_sng="ncks regrid FSNT 1D->2D to test bilinear remapping (does SSH/scp to dust.ess.uci.edu)";
+	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_ne30np4_to_fv257x512_bilin.20150901.nc .";
+	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_tst.nc .";
+	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_ne30np4_to_fv257x512_bilin.20150901.nc ne30_tst.nc %tmp_fl_00%";
+	$tst_cmd[3]="ncwa -O $fl_fmt $nco_D_flg -w gw %tmp_fl_00% %tmp_fl_01%";
+	$tst_cmd[4]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
+	$tst_cmd[5]="FSNT = 244.237 W/m2";
+	$tst_cmd[6]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+	$dsc_sng="ncks regrid FSNT 2D->1D to test conservation (does SSH/scp to dust.ess.uci.edu)";
+	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_fv129x256_to_ne30np4_aave.20150901.nc .";
+	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg --map=map_fv129x256_to_ne30np4_aave.20150901.nc ne30_2D.nc %tmp_fl_00%";
+	$tst_cmd[2]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
+	$tst_cmd[3]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
+	$tst_cmd[4]="FSNT = 244.124 W/m2";
+	$tst_cmd[5]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+	$dsc_sng="ncks regrid FSNT 2D->2D to test conservation (does SSH/scp to dust.ess.uci.edu)";
+	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_fv129x256_to_fv257x512_aave.20150901.nc .";
+	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_2D.nc .";
+	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_fv129x256_to_fv257x512_aave.20150901.nc ne30_2D.nc %tmp_fl_00%";
+	$tst_cmd[3]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
+	$tst_cmd[4]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
+	$tst_cmd[5]="FSNT = 244.124 W/m2";
+	$tst_cmd[6]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+	$dsc_sng="ncks regrid FSNT 1D->1D to test identity mapping and conservation (does SSH/scp to dust.ess.uci.edu)";
+	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_ne30np4_to_ne30np4_aave.20150603.nc .";
+	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_tst.nc .";
+	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_ne30np4_to_ne30np4_aave.20150603.nc ne30_tst.nc %tmp_fl_00%";
+	$tst_cmd[3]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
+	$tst_cmd[4]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
+	$tst_cmd[5]="FSNT = 244.124 W/m2";
+	$tst_cmd[6]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+# ncks -O --rgr grid=~/foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
+# ncks -O -H -u -C -s %18.15f -d grid_size,0 -v grid_center_lat ~/foo_grid.nc
+# 20151205: using %tmp_fl_00% in arguments like "--rgr grid=%tmp_fl_00%" leads to epic fail, so hard-code filenames that are arguments
+	$dsc_sng="ncks generate T42 gridfile";
+	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg --rgr grid=foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr $in_pth_arg in.nc %tmp_fl_01%";
+	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg -H -u -C -s %18.15f -d grid_size,0 -v grid_center_lat foo_grid.nc";
+	$tst_cmd[2]="-87.863798839232629";
+	$tst_cmd[3]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+# ncks -O -D 1 --rgr skl=~/foo_skl.nc --rgr grid=~/foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
+# ncks -O -H -u -C -s %g -d lat,0 -v gw ~/foo_skl.nc
+	$dsc_sng="ncks generate T42-grid skeleton file";
+	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg --rgr skl=foo_skl.nc --rgr grid=foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr $in_pth_arg in.nc %tmp_fl_02%";
+	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg -H -u -C -s %g -d lat,0 -v gw foo_skl.nc";
+	$tst_cmd[2]="0.00178328";
+	$tst_cmd[3]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+# ncks -O --rgr nfr=y --rgr grid=~/foo_grid.nc ~/nco/data/ne30_2D.nc ~/foo.nc
+# ncks -O -H -u -C -s %8.5f -d grid_size,256 -v grid_center_lat ~/foo_grid.nc
+# 20151205: using %tmp_fl_00% in arguments like "--rgr grid=%tmp_fl_00%" leads to epic fail, so hard-code filenames that are arguments
+	$dsc_sng="ncks infer 129x256 FV gridfile (does SSH/scp to dust.ess.uci.edu)";
+	$tst_cmd[0]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_2D.nc .";
+	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg --rgr nfr=y --rgr grid=foo_grid.nc ne30_2D.nc %tmp_fl_01%";
+	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg -H -u -C -s %8.5f -d grid_size,256 -v grid_center_lat foo_grid.nc";
+	$tst_cmd[3]="-88.59375";
+	$tst_cmd[4]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+
+	$dsc_sng="ncremap regrid FSNT 1D->2D to test conservation (depends on SSH/scp to dust.ess.uci.edu)";
+	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc .";
+	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_tst.nc .";
+	$tst_cmd[2]="ncremap -i ne30_tst.nc -m map_ne30np4_to_fv129x256_aave.20150901.nc -o %tmp_fl_00%";
+	$tst_cmd[3]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
+	$tst_cmd[4]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
+	$tst_cmd[5]="FSNT = 244.124 W/m2";
+	$tst_cmd[6]="SS_OK";
+	NCO_bm::tst_run(\@tst_cmd);
+	$#tst_cmd=0; # Reset array
+} # !zender
+
+####################
 #### ncap2 tests ####
 ####################
     $opr_nm='ncap2';
@@ -241,128 +401,23 @@ print "\n";
     NCO_bm::tst_run(\@tst_cmd);
     $#tst_cmd=0; # Reset array
 
+    $dsc_sng="Run script to to test casting, hyperslabbing and intrinsic functions";
+    $tst_cmd[0]="ncap2 -h -O $fl_fmt $nco_D_flg -v -S '../data/bsc_tst.nco' $in_pth_arg in.nc %tmp_fl_00%";
+    $tst_cmd[1]="ncks -C -H -v nbr_err_ttl -s '%d' %tmp_fl_00%";
+    $tst_cmd[2]="0";
+    $tst_cmd[3]="SS_OK";
+    NCO_bm::tst_run(\@tst_cmd);
+    $#tst_cmd=0; # Reset array
 
+    $dsc_sng="Run script to test conversion of input vars to type NC_DOUBLE using var-pointers";
+    $tst_cmd[0]="ncap2 -h -O $fl_fmt $nco_D_flg -v -S '../data/vpointer_tst.nco' $in_pth_arg in.nc %tmp_fl_00%";
+    $tst_cmd[1]="ncks -C -H -v nbr_err -s '%d' %tmp_fl_00%";
+    $tst_cmd[2]="0";
+    $tst_cmd[3]="SS_OK";
+    NCO_bm::tst_run(\@tst_cmd);
+    $#tst_cmd=0; # Reset array
 
 
-    $USER=$ENV{'USER'};
-    if($USER eq 'zender'){
-	# Regridding regression tests
-	# valgrind --leak-check=yes --show-reachable=yes --suppressions=${HOME}/nco/doc/valgrind.txt --tool=memcheck ncks -O -D 5 --map=${DATA}/maps/map_ne30np4_to_fv129x256_aave.150418.nc ${DATA}/ne30/rgr/ne30_tst.nc ~/foo.nc > ~/foo 2>&1
-	# ncks -O -D 5 --map=${DATA}/maps/map_ne30np4_to_fv129x256_aave.150418.nc ${DATA}/ne30/rgr/ne30_tst.nc ~/foo.nc
-	# ncwa -O -w area ~/foo.nc ~/foo2.nc
-	# ncks -H -u -C -v FSNT ~/foo2.nc
-	# ncwa -O -y ttl -v area ~/foo.nc ~/foo3.nc
-	# ncks -H -u -C -v area ~/foo3.nc
-	
-	$dsc_sng="Regridding FSNT 1D->2D to test conservation (uses SSH/scp to dust.ess.uci.edu)";
-	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc .";
-	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_tst.nc .";
-	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_ne30np4_to_fv129x256_aave.20150901.nc ne30_tst.nc %tmp_fl_00%";
-#	my $pwd=`pwd`; chomp $pwd; print $pwd;
-#	$dsc_sng="Regridding FSNT to regridding conservation (uses wget to dust.ess.uci.edu)";
-#	$tst_cmd[0]="wget -c -P $drc_dat http://dust.ess.uci.edu/maps/map_ne30np4_to_fv129x256_aave.20150901.nc";
-#	$tst_cmd[1]="wget -c -P $drc_dat http://dust.ess.uci.edu/ne30/rgr/ne30_tst.nc";
-#	$tst_cmd[2]="ncks -h -O $fl_fmt $nco_D_flg --map=".$drc_dat."/map_ne30np4_to_fv129x256_aave.20150901.nc ".$drc_dat."/ne30_tst.nc %tmp_fl_00%";
-	$tst_cmd[3]="/bin/cp -f %tmp_fl_00% ne30_2D.nc";
-	$tst_cmd[4]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
-	$tst_cmd[5]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
-	$tst_cmd[6]="FSNT = 244.124 W/m2";
-	$tst_cmd[7]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-	$dsc_sng="Regridding AODVIS 1D->2D to test missing value treatment";
-	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v AODVIS %tmp_fl_01%";
-	$tst_cmd[1]="AODVIS = 0.151705";
-	$tst_cmd[2]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-	$dsc_sng="Regridding area 1D->2D to test grid area integral/normalization";
-	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg --map=${drc_dat}/map_ne30np4_to_fv129x256_aave.20150901.nc $drc_dat/ne30_tst.nc %tmp_fl_00%";
-	$tst_cmd[1]="ncwa -O $fl_fmt $nco_D_flg -y ttl -v area %tmp_fl_00% %tmp_fl_02%";
-	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v area %tmp_fl_02%";
-	$tst_cmd[3]="area = 12.5663706144 steradian";
-	$tst_cmd[4]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-	$dsc_sng="Regridding FSNT 1D->2D to test bilinear remapping (uses SSH/scp to dust.ess.uci.edu)";
-	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_ne30np4_to_fv257x512_bilin.20150901.nc .";
-	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_tst.nc .";
-	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_ne30np4_to_fv257x512_bilin.20150901.nc ne30_tst.nc %tmp_fl_00%";
-	$tst_cmd[3]="ncwa -O $fl_fmt $nco_D_flg -w gw %tmp_fl_00% %tmp_fl_01%";
-	$tst_cmd[4]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
-	$tst_cmd[5]="FSNT = 244.237 W/m2";
-	$tst_cmd[6]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-	$dsc_sng="Regridding FSNT 2D->1D to test conservation (uses SSH/scp to dust.ess.uci.edu)";
-	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_fv129x256_to_ne30np4_aave.20150901.nc .";
-	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg --map=map_fv129x256_to_ne30np4_aave.20150901.nc ne30_2D.nc %tmp_fl_00%";
-	$tst_cmd[2]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
-	$tst_cmd[3]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
-	$tst_cmd[4]="FSNT = 244.124 W/m2";
-	$tst_cmd[5]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-	$dsc_sng="Regridding FSNT 2D->2D to test conservation (uses SSH/scp to dust.ess.uci.edu)";
-	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_fv129x256_to_fv257x512_aave.20150901.nc .";
-	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_2D.nc .";
-	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_fv129x256_to_fv257x512_aave.20150901.nc ne30_2D.nc %tmp_fl_00%";
-	$tst_cmd[3]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
-	$tst_cmd[4]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
-	$tst_cmd[5]="FSNT = 244.124 W/m2";
-	$tst_cmd[6]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-	$dsc_sng="Regridding FSNT 1D->1D to test identity mapping and conservation (uses SSH/scp to dust.ess.uci.edu)";
-	$tst_cmd[0]="scp dust.ess.uci.edu:data/maps/map_ne30np4_to_ne30np4_aave.20150603.nc .";
-	$tst_cmd[1]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_tst.nc .";
-	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg --map=map_ne30np4_to_ne30np4_aave.20150603.nc ne30_tst.nc %tmp_fl_00%";
-	$tst_cmd[3]="ncwa -O $fl_fmt $nco_D_flg -w area %tmp_fl_00% %tmp_fl_01%";
-	$tst_cmd[4]="ncks -O $fl_fmt $nco_D_flg -H -u -C -v FSNT %tmp_fl_01%";
-	$tst_cmd[5]="FSNT = 244.124 W/m2";
-	$tst_cmd[6]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-# ncks -O --rgr grid=~/foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
-# ncks -O -H -u -C -s %18.15f -d grid_size,0 -v grid_center_lat ~/foo_grid.nc
-# 20151205: using %tmp_fl_00% in arguments like "--rgr grid=%tmp_fl_00%" leads to epic fail, so hard-code filenames that are arguments
-	$dsc_sng="Generate T42 gridfile";
-	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg --rgr grid=foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr $in_pth_arg in.nc %tmp_fl_01%";
-	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg -H -u -C -s %18.15f -d grid_size,0 -v grid_center_lat foo_grid.nc";
-	$tst_cmd[2]="-87.863798839232629";
-	$tst_cmd[3]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-# ncks -O -D 1 --rgr skl=~/foo_skl.nc --rgr grid=~/foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
-# ncks -O -H -u -C -s %g -d lat,0 -v gw ~/foo_skl.nc
-	$dsc_sng="Generate T42-grid skeleton file";
-	$tst_cmd[0]="ncks -O $fl_fmt $nco_D_flg --rgr skl=foo_skl.nc --rgr grid=foo_grid.nc --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr $in_pth_arg in.nc %tmp_fl_02%";
-	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg -H -u -C -s %g -d lat,0 -v gw foo_skl.nc";
-	$tst_cmd[2]="0.00178328";
-	$tst_cmd[3]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-
-# ncks -O --rgr nfr=y --rgr grid=~/foo_grid.nc ~/nco/data/ne30_2D.nc ~/foo.nc
-# ncks -O -H -u -C -s %8.5f -d grid_size,256 -v grid_center_lat ~/foo_grid.nc
-# 20151205: using %tmp_fl_00% in arguments like "--rgr grid=%tmp_fl_00%" leads to epic fail, so hard-code filenames that are arguments
-	$dsc_sng="Infer 129x256 FV gridfile (uses SSH/scp to dust.ess.uci.edu)";
-	$tst_cmd[0]="scp dust.ess.uci.edu:data/ne30/rgr/ne30_2D.nc .";
-	$tst_cmd[1]="ncks -O $fl_fmt $nco_D_flg --rgr nfr=y --rgr grid=foo_grid.nc ne30_2D.nc %tmp_fl_01%";
-	$tst_cmd[2]="ncks -O $fl_fmt $nco_D_flg -H -u -C -s %8.5f -d grid_size,256 -v grid_center_lat foo_grid.nc";
-	$tst_cmd[3]="-88.59375";
-	$tst_cmd[4]="SS_OK";
-	NCO_bm::tst_run(\@tst_cmd);
-	$#tst_cmd=0; # Reset array
-    } # !zender
     
     if($dodap eq "FALSE"){
 ####################
@@ -1199,7 +1254,7 @@ print "\n";
     $dsc_sng="Test tabs on coordinate";
     $tst_cmd[0]="ncra -Y ncfe -y tabs -v lond $omp_flg -O $fl_fmt $nco_D_flg $in_pth_arg in.nc in.nc %tmp_fl_00%";
     $tst_cmd[1]="ncks -C -H -v lon -d lon,3 %tmp_fl_00%";
-    $tst_cmd[2]="lon[3] = 270";
+    $tst_cmd[2]="lon[3]=270";
     $tst_cmd[3]="SS_OK";
     NCO_bm::tst_run(\@tst_cmd);
     $#tst_cmd=0; # Reset array	
@@ -3316,19 +3371,52 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
 
 #ncpdq #41
 #ncpdq -O -a -lat -g g23,g24 ~/nco/data/in_grp_3.nc ~/foo.nc
-   $dsc_sng="(Groups) Reverse -a lat -g g24 several groups (expect failure TODO)";
+   $dsc_sng="(Groups) Reverse -a lat -g g24 several groups";
    $tst_cmd[0]="ncpdq $omp_flg $fl_fmt $nco_D_flg -O -a -lat -g g23,g24 $in_pth_arg in_grp_3.nc %tmp_fl_00%";
    $tst_cmd[1]="ncks -v lat -g g24 %tmp_fl_00%";
    $tst_cmd[2]="lat[1]=-60 degrees_north";
    $tst_cmd[3]="SS_OK";
    if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
-   $#tst_cmd=0; # Reset array      
+   $#tst_cmd=0; # Reset array    
+
+#ncpdq #42
+#ncpdq -O -v lat,lon -a -lat,-lon -g g1,g2 ~/nco/data/in_grp_8.nc out1.nc
+#ncks -H out1.nc
+   $dsc_sng="(Groups) Reverse -a -lat,-lon several groups";
+   $tst_cmd[0]="ncpdq $omp_flg $fl_fmt $nco_D_flg -O -a -lat,-lon -g g1,g2 $in_pth_arg in_grp_8.nc %tmp_fl_00%";
+   $tst_cmd[1]="ncks -H -v lon -g g2 %tmp_fl_00%";
+   $tst_cmd[2]="lon[2]=0";
+   $tst_cmd[3]="SS_OK";
+   if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
+   $#tst_cmd=0; # Reset array    
+
+#ncpdq #43
+#ncpdq -O -v lat,lon -a lat,-lon -g g1,g2 ~/nco/data/in_grp_8.nc out1.nc
+#ncks -H out1.nc
+   $dsc_sng="(Groups) Reverse -a lat,-lon several groups";
+   $tst_cmd[0]="ncpdq $omp_flg $fl_fmt $nco_D_flg -O -a lat,-lon -g g1,g2 $in_pth_arg in_grp_8.nc %tmp_fl_00%";
+   $tst_cmd[1]="ncks -H -v lon -g g2 %tmp_fl_00%";
+   $tst_cmd[2]="lon[2]=0";
+   $tst_cmd[3]="SS_OK";
+   if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
+   $#tst_cmd=0; # Reset array  
+
+#ncpdq #44
+#ncpdq -O -v lat,lon -a -lat,lon -g g1,g2 ~/nco/data/in_grp_8.nc out1.nc
+#ncks -H out1.nc
+   $dsc_sng="(Groups) Reverse -a -lat,lon several groups";
+   $tst_cmd[0]="ncpdq $omp_flg $fl_fmt $nco_D_flg -O -a -lat,lon -g g1,g2 $in_pth_arg in_grp_8.nc %tmp_fl_00%";
+   $tst_cmd[1]="ncks -H -v lon -g g2 %tmp_fl_00%";
+   $tst_cmd[2]="lon[2]=2";
+   $tst_cmd[3]="SS_OK";
+   if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
+   $#tst_cmd=0; # Reset array               
 
 #####################
 #### ncpdq PACK GROUP tests 
 #####################   
 
-#ncpdq #42
+#ncpdq #45
 #ncpdq -h -O -P all_new -v upk in.nc ~/foo.nc
 #ncpdq -h -O -P upk -v upk ~/foo.nc ~/foo.nc
 #ncks -C -H -s '%g' -v upk ~/foo.nc
@@ -3342,7 +3430,7 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
    if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
    $#tst_cmd=0; # Reset array  
 
-#ncpdq #43
+#ncpdq #46
 # same as ncpdq #30
 # ncpdq -g g19g4 -h -O -C -P upk -v rec_var_dbl_mss_val_dbl_pck -d time,0,4 -d time,6 in_grp_3.nc ~/foo.nc
 # ncks -g g19g4 -C -H -s '%f' -v rec_var_dbl_mss_val_dbl_pck -d time,5 ~/foo.nc
@@ -3356,7 +3444,7 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
    if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
    $#tst_cmd=0; # Reset array  
    	
-#ncpdq #44
+#ncpdq #47
 # ncpdq -O -4 -a lon,lat --cnk_min=1 --cnk_plc=xpl --cnk_dmn lat,1 --cnk_dmn lon,2 -v lat_2D_rct ~/nco/data/in.nc ~/foo.nc
 # ncks -m ~/foo.nc | grep 'lat_2D_rct dimension 0'
    $dsc_sng="Chunking -a lon,lat --cnk_min=1 --cnk_plc=xpl --cnk_dmn lat,1 --cnk_dmn lon,2 -v lat_2D_rct";
@@ -3369,7 +3457,7 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
 	
 } ##### Group tests	
 	
-#ncpdq #45
+#ncpdq #48
     $dsc_sng="Unpack 1D variable twice to verify first unpacking does not inadvertently store packing attributes";
     $tst_cmd[0]="ncpdq $omp_flg -h -O -C $fl_fmt $nco_D_flg -P upk -v pck_7 $in_pth_arg in.nc %tmp_fl_00%";
     $tst_cmd[1]="ncpdq $omp_flg -h -O -C $fl_fmt $nco_D_flg -P upk -v pck_7 %tmp_fl_00% %tmp_fl_01%";
@@ -3379,7 +3467,7 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
     if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
     $#tst_cmd=0; # Reset array
 	
-#ncpdq #46
+#ncpdq #49
     $dsc_sng="Unpack 1D variable with netCDF convention";
     $tst_cmd[0]="ncpdq $omp_flg -h -O -C $fl_fmt $nco_D_flg -P upk -v pck_7 $in_pth_arg in.nc %tmp_fl_00%";
     $tst_cmd[1]="ncks -C -H -s '%f' -v pck_7 %tmp_fl_00%";
@@ -3388,7 +3476,7 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
     if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
     $#tst_cmd=0; # Reset array
 	
-#ncpdq #47
+#ncpdq #50
     $dsc_sng="Unpack 1D variable with HDF convention";
     $tst_cmd[0]="ncpdq $omp_flg -h -O -C $fl_fmt $nco_D_flg -P upk --hdf_upk -v pck_7 $in_pth_arg in.nc %tmp_fl_00%";
     $tst_cmd[1]="ncks -C -H -s '%f' -v pck_7 %tmp_fl_00%";
@@ -3397,7 +3485,7 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
     if($mpi_prc == 0 || ($mpi_prc > 0 && !($localhostname =~ /pbs/))){NCO_bm::tst_run(\@tst_cmd);} # ncpdq hangs with MPI TODO nco772
     $#tst_cmd=0; # Reset array
 	
-#ncpdq #48
+#ncpdq #51
     $dsc_sng="Re-pack 1D variable from HDF convention to netCDF convention";
     $tst_cmd[0]="ncpdq $omp_flg -h -O -C $fl_fmt $nco_D_flg -P xst_new --hdf_upk -v pck_7 $in_pth_arg in.nc %tmp_fl_00%";
     $tst_cmd[1]="ncpdq $omp_flg -h -O -C $fl_fmt $nco_D_flg -P upk -v pck_7 %tmp_fl_00% %tmp_fl_01%";
@@ -5516,7 +5604,7 @@ if($RUN_NETCDF4_TESTS_VERSION_GE_431){
 #ncrename -O -d lev,z -d lat,y -d lon,x ~/nco/data/in_grp.nc ~/foo.nc
 #ncks -H -s %d -v one ~/foo.nc
 # Check for corruption after simultaneously renaming multiple dimensions in netCDF4 file
-    $dsc_sng="netCDF4: Simultaneously rename multiple dimensions (requires netCDF 4.4.1)";
+    $dsc_sng="netCDF4: Simultaneously rename multiple dimensions (requires netCDF 4.4.2)";
     $tst_cmd[0]="ncrename -O $fl_fmt $nco_D_flg -d lev,z -d lat,y -d lon,x $in_pth_arg in_grp.nc %tmp_fl_00%";
     $tst_cmd[1]="ncks -H -s %d -v one %tmp_fl_00%";
     $tst_cmd[2]="1";
diff --git a/configure b/configure
index 01a07c4..c55f0a7 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for NCO netCDF Operators 4.5.5.
+# Generated by GNU Autoconf 2.69 for NCO netCDF Operators 4.6.0.
 #
 # Report bugs to <nco-bugs at lists.sourceforge.net>.
 #
@@ -592,8 +592,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='NCO netCDF Operators'
 PACKAGE_TARNAME='nco'
-PACKAGE_VERSION='4.5.5'
-PACKAGE_STRING='NCO netCDF Operators 4.5.5'
+PACKAGE_VERSION='4.6.0'
+PACKAGE_STRING='NCO netCDF Operators 4.6.0'
 PACKAGE_BUGREPORT='nco-bugs at lists.sourceforge.net'
 PACKAGE_URL=''
 
@@ -1393,7 +1393,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures NCO netCDF Operators 4.5.5 to adapt to many kinds of systems.
+\`configure' configures NCO netCDF Operators 4.6.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1464,7 +1464,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of NCO netCDF Operators 4.5.5:";;
+     short | recursive ) echo "Configuration of NCO netCDF Operators 4.6.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1508,7 +1508,7 @@ Optional Features:
   --enable-esmf           Build-in ESMF support for integrated (instead of
                           off-line) regridding. WARNING: Development code =
                           Unsupported (and not necessary for regridding!
-                          Dragons lurk here.) [[default=yes]]
+                          Dragons lurk here.) [[default=no]]
   --enable-gsl            Build-in GSL support if possible [[default=yes]]
   --enable-regex          Allow extended regular expressions [[default=yes]]
   --enable-udunits        Build-in UDUnits support if possible [[default=no]]
@@ -1632,7 +1632,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-NCO netCDF Operators configure 4.5.5
+NCO netCDF Operators configure 4.6.0
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2498,7 +2498,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by NCO netCDF Operators $as_me 4.5.5, which was
+It was created by NCO netCDF Operators $as_me 4.6.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3003,7 +3003,7 @@ test -n "$target_alias" &&
 # Get NCO version
 if test -r doc/VERSION; then
     nco_version=`cat doc/VERSION`
-#  AC_DEFINE_UNQUOTED(VERSION,${nco_version},NCO Version)
+#  AC_DEFINE_UNQUOTED(NCO_VERSION,${nco_version},NCO Version)
 fi
 
 # Set egrep
@@ -3747,7 +3747,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='nco'
- VERSION='4.5.5'
+ VERSION='4.6.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -19264,9 +19264,9 @@ fi
 
 # End nco_c++
 
-echo "########################################"
-echo "#     Testing for ESMF support          #"
-echo "########################################"
+echo "##################################################"
+echo "# Testing for ESMF support (only for developers) #"
+echo "##################################################"
 # Begin ESMF
 
 # Begin mandatory link test with libnetcdf.a
@@ -19282,7 +19282,7 @@ nco_CPPFLAGS_no_ESMF="${CPPFLAGS}"
 if test "${enable_esmf+set}" = set; then :
   enableval=$enable_esmf; enable_esmf=${enableval}
 else
-  enable_esmf=yes
+  enable_esmf=no
 fi
 
 if test "${enable_esmf}" != 'yes'; then
@@ -19975,9 +19975,11 @@ fi
 	fi
     elif test "${NETCDF_INC}"; then
 	nco_udunits2_xml="${NETCDF_INC}/../share/udunits/udunits2.xml"
-    else
+    fi
+    if test "${UDUNITS2_PATH}" = ''; then
 	# NO UDUNITS2_PATH section
 	# Fedora 1.7 has /usr/include/udunits2/udunits2.h
+	# 20160418 FC23 has /usr/include/udunits2/udunits2.h
 	# Add this path to CPPFLAGS if it exists, otherwise do nothing
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for /usr/include/udunits2/udunits2.h" >&5
 $as_echo_n "checking for /usr/include/udunits2/udunits2.h... " >&6; }
@@ -20748,6 +20750,8 @@ fi
 # Tell GNU C compiler to use C99 standard (older gcc versions default to C89)
 # fxm: only do this for gcc, not g++
 if test $ac_compiler_gnu = 'yes'; then
+    # _BSD_SOURCE needed for backward compatibility with old GCC
+    # 20160418: default cori gcc is 4.3.4 from 2008!
     CFLAGS="${CFLAGS} -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE"
     case ${host} in
 # MacOSX does not understand shared libraries
@@ -21470,7 +21474,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by NCO netCDF Operators $as_me 4.5.5, which was
+This file was extended by NCO netCDF Operators $as_me 4.6.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -21536,7 +21540,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-NCO netCDF Operators config.status 4.5.5
+NCO netCDF Operators config.status 4.6.0
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index db98a5d..d14e8d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,7 +51,7 @@
 
 # Process configure input with autoconf to produce configure script
 # (package name,version,bug-report-address,tarball name)
-AC_INIT([NCO netCDF Operators],[4.5.5],[nco-bugs at lists.sourceforge.net],[nco])
+AC_INIT([NCO netCDF Operators],[4.6.0],[nco-bugs at lists.sourceforge.net],[nco])
 
 # Print GNU copyright in configure script
 AC_COPYRIGHT
@@ -74,7 +74,7 @@ AC_CANONICAL_TARGET
 # Get NCO version
 if test -r doc/VERSION; then
     nco_version=`cat doc/VERSION`
-#  AC_DEFINE_UNQUOTED(VERSION,${nco_version},NCO Version)
+#  AC_DEFINE_UNQUOTED(NCO_VERSION,${nco_version},NCO Version)
 fi
 
 # Set egrep
@@ -517,9 +517,9 @@ fi
 AC_ARG_ENABLE(nco_cplusplus,AS_HELP_STRING([--enable-nco_cplusplus],[Build NCO C++ interface library [[default=yes]]]),enable_nco_cxx=${enableval},enable_nco_cxx=yes)
 # End nco_c++
 
-echo "########################################"
-echo "#     Testing for ESMF support          #"
-echo "########################################"
+echo "##################################################"
+echo "# Testing for ESMF support (only for developers) #"
+echo "##################################################"
 # Begin ESMF
 
 # Begin mandatory link test with libnetcdf.a
@@ -531,7 +531,7 @@ AC_ARG_VAR(ESMF_LIB,Location of ESMF library (compile-time))
 # Store pre-ESMF LIBS value to restore from later
 nco_LIBS_no_ESMF="${LIBS}"
 nco_CPPFLAGS_no_ESMF="${CPPFLAGS}"
-AC_ARG_ENABLE(esmf,AS_HELP_STRING([--enable-esmf],[Build-in ESMF support for integrated (instead of off-line) regridding. WARNING: Development code = Unsupported (and not necessary for regridding! Dragons lurk here.) [[default=yes]]]),enable_esmf=${enableval},enable_esmf=yes)
+AC_ARG_ENABLE(esmf,AS_HELP_STRING([--enable-esmf],[Build-in ESMF support for integrated (instead of off-line) regridding. WARNING: Development code = Unsupported (and not necessary for regridding! Dragons lurk here.) [[default=no]]]),enable_esmf=${enableval},enable_esmf=no)
 if test "${enable_esmf}" != 'yes'; then
     enable_esmf='no'
 fi
@@ -725,9 +725,11 @@ if test "${enable_udunits2}" != 'no'; then
 	fi
     elif test "${NETCDF_INC}"; then
 	nco_udunits2_xml="${NETCDF_INC}/../share/udunits/udunits2.xml"
-    else
+    fi
+    if test "${UDUNITS2_PATH}" = ''; then
 	# NO UDUNITS2_PATH section
 	# Fedora 1.7 has /usr/include/udunits2/udunits2.h
+	# 20160418 FC23 has /usr/include/udunits2/udunits2.h
 	# Add this path to CPPFLAGS if it exists, otherwise do nothing
 	AC_CHECK_FILE([/usr/include/udunits2/udunits2.h], [CPPFLAGS="$CPPFLAGS -I/usr/include/udunits2"], [])
 	# Ubuntu
@@ -1132,6 +1134,8 @@ fi
 # Tell GNU C compiler to use C99 standard (older gcc versions default to C89)
 # fxm: only do this for gcc, not g++
 if test $ac_compiler_gnu = 'yes'; then
+    # _BSD_SOURCE needed for backward compatibility with old GCC
+    # 20160418: default cori gcc is 4.3.4 from 2008!
     CFLAGS="${CFLAGS} -std=c99 -D_BSD_SOURCE -D_POSIX_SOURCE"
     case ${host} in
 # MacOSX does not understand shared libraries
diff --git a/configure.eg b/configure.eg
index d871c60..3e92289 100644
--- a/configure.eg
+++ b/configure.eg
@@ -257,7 +257,7 @@ make check >> nco.make.${GNU_TRP}.foo 2>&1
 make install >> nco.make.${GNU_TRP}.foo 2>&1
 scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
 
-# gcc/g++ Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on cooley:
+# 20150901: gcc/g++ Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on cooley:
 export GNU_TRP=`~/nco/autobld/config.guess`
 cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
 ANTLR_ROOT=${HOME} CC='gcc' CXX='g++' NETCDF_ROOT='/soft/libraries/unsupported/netcdf-4.3.2' UDUNITS2_PATH=${HOME} ./configure --prefix=${HOME} --bindir=${MY_BIN_DIR} --datadir=${HOME}/nco/data --libdir=${MY_LIB_DIR} --mandir=${HOME}/nco/man > nco.configure.${GNU_TRP}.foo 2>&1
@@ -268,6 +268,30 @@ make check >> nco.make.${GNU_TRP}.foo 2>&1
 make install >> nco.make.${GNU_TRP}.foo 2>&1
 scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
 
+# 20160421: gcc/g++ Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on mira:
+export GNU_TRP=`~/nco/autobld/config.guess`
+cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
+ANTLR_ROOT=${HOME} CC='gcc' CXX='g++' NETCDF_ROOT='/soft/libraries/netcdf/current' UDUNITS2_PATH=${HOME} ./configure --prefix=${HOME} --bindir=${MY_BIN_DIR} --datadir=${HOME}/nco/data --libdir=${MY_LIB_DIR} --mandir=${HOME}/nco/man > nco.configure.${GNU_TRP}.foo 2>&1
+/bin/cp -f config.log nco.config.log.${GNU_TRP}.foo
+/bin/cp -f libtool nco.libtool.${GNU_TRP}.foo
+make clean;make > nco.make.${GNU_TRP}.foo 2>&1
+make check >> nco.make.${GNU_TRP}.foo 2>&1
+make install >> nco.make.${GNU_TRP}.foo 2>&1
+scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
+
+# 20160421: gcc/g++ Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on roger:
+module load netcdf/4.4.0
+module load udunits
+export GNU_TRP=`~/nco/autobld/config.guess`
+cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
+ANTLR_ROOT=${HOME} CC='gcc' CXX='g++' ./configure --prefix=${HOME} --bindir=${MY_BIN_DIR} --datadir=${HOME}/nco/data --libdir=${MY_LIB_DIR} --mandir=${HOME}/nco/man > nco.configure.${GNU_TRP}.foo 2>&1
+/bin/cp -f config.log nco.config.log.${GNU_TRP}.foo
+/bin/cp -f libtool nco.libtool.${GNU_TRP}.foo
+make clean;make > nco.make.${GNU_TRP}.foo 2>&1
+make check >> nco.make.${GNU_TRP}.foo 2>&1
+make install >> nco.make.${GNU_TRP}.foo 2>&1
+scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
+
 # gcc/g++ Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on cori:
 # Used 20151204-
 module load szip
@@ -276,7 +300,7 @@ module load udunits
 module load cray-netcdf
 export GNU_TRP=`~/nco/autobld/config.guess`
 cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
-ANTLR_ROOT=${HOME} CC='icc' CXX='icpc' GSL_ROOT='/usr/common/software/gsl/1.16/intel' NETCDF_ROOT='/opt/cray/netcdf/4.3.3.1/INTEL/14.0' UDUNITS2_PATH='/usr/common/software/udunits/2.2.19/hsw/intel' ./configure --prefix=${HOME} --bindir=${HOME}/bin --datadir=${HOME}/nco/data --libdir=${HOME}/lib --mandir=${HOME}/man > nco.configure.${GNU_TRP}.foo 2>&1
+ANTLR_ROOT=${HOME} CC='icc' CXX='icpc' GSL_ROOT='/usr/common/software/gsl/1.16/intel' NETCDF_ROOT='/opt/cray/netcdf/4.3.3.1/INTEL/14.0' UDUNITS2_PATH='/usr/common/software/udunits/2.2.19/hsw/intel' ./configure --prefix=${HOME} --bindir=${HOME}/bin_cori --datadir=${HOME}/nco/data --libdir=${HOME}/lib_cori --mandir=${HOME}/man > nco.configure.${GNU_TRP}.foo 2>&1
 /bin/cp -f config.log nco.config.log.${GNU_TRP}.foo
 /bin/cp -f libtool nco.libtool.${GNU_TRP}.foo
 make clean;make > nco.make.${GNU_TRP}.foo 2>&1
@@ -284,6 +308,7 @@ make check >> nco.make.${GNU_TRP}.foo 2>&1
 make install >> nco.make.${GNU_TRP}.foo 2>&1
 scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
 
+# acme: http://www.gnu.org/software/automake/manual/automake.html search for "shared by two hosts" use 
 # gcc/g++ Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on edison:
 # Used 20150825-
 module load szip
@@ -292,7 +317,7 @@ module load udunits
 module load cray-netcdf
 export GNU_TRP=`~/nco/autobld/config.guess`
 cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
-ANTLR_ROOT='/usr' CC='icc' CXX='icpc' GSL_ROOT='/usr/common/usg/gsl/1.16/intel' NETCDF_INC='/opt/cray/netcdf/4.3.2/INTEL/140/include' NETCDF_LIB='/opt/cray/netcdf/4.3.2/INTEL/140/lib' NETCDF_ROOT='/opt/cray/netcdf/4.3.2' UDUNITS2_PATH='/usr/common/usg/udunits/2.1.24/intel' ./configure --prefix=${HOME} --bindir=${HOME}/bin --datadir=${HOME}/nco/data --libdir=${HOME}/lib --mandir=${HOME}/man > nco.configure.${GNU_TRP}.foo 2>&1
+ANTLR_ROOT='/usr' CC='icc' CXX='icpc' GSL_ROOT='/usr/common/usg/gsl/1.16/intel' NETCDF_INC='/opt/cray/netcdf/4.3.2/INTEL/140/include' NETCDF_LIB='/opt/cray/netcdf/4.3.2/INTEL/140/lib' NETCDF_ROOT='/opt/cray/netcdf/4.3.2' UDUNITS2_PATH='/usr/common/usg/udunits/2.1.24/intel' ./configure --prefix=${HOME} --bindir=${HOME}/bin_edison --datadir=${HOME}/nco/data --libdir=${HOME}/lib_edison --mandir=${HOME}/man > nco.configure.${GNU_TRP}.foo 2>&1
 /bin/cp -f config.log nco.config.log.${GNU_TRP}.foo
 /bin/cp -f libtool nco.libtool.${GNU_TRP}.foo
 make clean;make > nco.make.${GNU_TRP}.foo 2>&1
@@ -354,6 +379,12 @@ make check >> nco.make.${GNU_TRP}.foo 2>&1
 make install >> nco.make.${GNU_TRP}.foo 2>&1
 scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
 
+# icc/icpc 20160217 Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on yellowstone:
+module add intel;module add gsl;module add netcdf/4.3.0;
+export PATH=${PATH}:/glade/apps/opt/netcdf/4.3.0/intel/12.1.5/bin # needed for ncgen
+export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/glade/apps/opt/netcdf/4.3.0/intel/12.1.5/lib # needed to run NCO
+cd ~/nco/bld;make NETCDF_ROOT='/glade/apps/opt/netcdf/4.3.0/intel/default' UDUNITS_INC='/glade/apps/opt/udunits/2.1.24/intel/12.1.4/include' UDUNITS_LIB='/glade/apps/opt/udunits/2.1.24/intel/12.1.4/lib' OPTS=D allinone;cd -
+
 # gcc/g++ 20160107 Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on rhea:
 export LINUX_CC='gcc -std=c99 -pedantic -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE'
 export LINUX_CXX='g++ -std=c++11'
@@ -366,6 +397,15 @@ export NETCDF_ROOT='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4'
 export PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/bin':${PATH}
 cd ~/nco/bld;make ANTLR_ROOT=${HOME} NETCDF_ROOT='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4' SZ=Y SZ_LIB='/sw/redhat6/szip/2.1/rhel6.6_gnu4.8.2/lib' UDUNITS_INC='/sw/redhat6/udunits/2.1.24/rhel6.4_intel13.1.3/include' UDUNITS_LIB='/sw/redhat6/udunits/2.1.24/rhel6.4_intel13.1.3/lib' OPTS=D OMP=Y allinone;cd -
 
+# gcc/g++ 2016420 Zender uses this to develop/install/update netCDF4-enabled NCO in personal directories on titan:
+export LINUX_CC='gcc -std=c99 -pedantic -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE'
+module add gcc # change GCC from v 4.3.4 to 4.9.0
+#module add gsl # not used yet
+#module add cray-netcdf # not used yet
+#module add udunits # not used yet
+export PATH=${PATH}:'/opt/cray/netcdf/4.3.2/bin'
+cd ~/nco/bld;make ANTLR_ROOT=${HOME} GSL=N NETCDF_ROOT='/opt/cray/netcdf/4.3.2' NETCDF_INC='/opt/cray/netcdf/4.3.2/GNU/49/include' NETCDF_LIB='/opt/cray/netcdf/4.3.2/GNU/49/lib' OPTS=D OMP=Y UDUNITS_INC='/sw/xk6/udunits/2.1.24/sl_gcc4.5.3/include' UDUNITS_LIB='/sw/xk6/udunits/2.1.24/sl_gcc4.5.3/lib -lexpat' allinone;cd -
+
 # icc/icpc 20160107 Zender tried and failed to use this to develop/install/update netCDF4-enabled NCO in personal directories on rhea:
 export GNU_TRP=`~/nco/autobld/config.guess`
 # Commands used for Makefile builds
@@ -549,7 +589,7 @@ Linux sand.ess.uci.edu 2.6.8.1-4-amd64-generic #1 Thu Dec 16 11:44:05 UTC 2004 x
 x86_64-unknown-linux-gnu
 
 # gcc/g++ Regular (non-root) users build NCO with system-supplied netCDF and install in your own directories
-# Zender uses this on MACOSX aerosol as well
+# Zender uses this on MACOSX aerosol/firn as well
 export GNU_TRP=`~/nco/autobld/config.guess`
 cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
 CC='gcc' CFLAGS='' CXX='g++' CXXFLAGS='' ./configure --prefix=${HOME} --bindir=${MY_BIN_DIR} --datadir=${HOME}/nco/data --libdir=${MY_LIB_DIR} --mandir=${HOME}/nco/man > nco.configure.${GNU_TRP}.foo 2>&1
@@ -571,10 +611,10 @@ make check >> nco.make.${GNU_TRP}.foo 2>&1
 sudo make install >> nco.make.${GNU_TRP}.foo 2>&1
 scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
 
-# gcc/g++ Zender uses this to test building NCO with pre-built (i.e., yum install'd or aptitude install'd) netCDF
+# gcc/g++ Zender uses this to debug NCO with pre-built (i.e., yum/dnf install'd or aptitude install'd) netCDF (frazil)
 export GNU_TRP=`~/nco/autobld/config.guess`
 cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
-CC='gcc' CFLAGS='' CXX='g++' CXXFLAGS='' NETCDF_INC='/usr/include' NETCDF_LIB='/usr/lib' ./configure --prefix=${HOME} --bindir=${MY_BIN_DIR} --datadir=${HOME}/nco/data --libdir=${MY_LIB_DIR} --mandir=${HOME}/nco/man > nco.configure.${GNU_TRP}.foo 2>&1
+CC='gcc' CFLAGS='' CXX='g++' CXXFLAGS='' NETCDF_INC='/usr/include' NETCDF_LIB='/usr/lib' ./configure --enable-debug-custom --prefix=${HOME} --bindir=${MY_BIN_DIR} --datadir=${HOME}/nco/data --libdir=${MY_LIB_DIR} --mandir=${HOME}/nco/man > nco.configure.${GNU_TRP}.foo 2>&1
 /bin/cp -f config.log nco.config.log.${GNU_TRP}.foo
 /bin/cp -f libtool nco.libtool.${GNU_TRP}.foo
 make clean;make > nco.make.${GNU_TRP}.foo 2>&1
@@ -582,7 +622,7 @@ make check >> nco.make.${GNU_TRP}.foo 2>&1
 make install >> nco.make.${GNU_TRP}.foo 2>&1
 scp nco.configure.${GNU_TRP}.foo nco.config.log.${GNU_TRP}.foo nco.libtool.${GNU_TRP}.foo nco.make.${GNU_TRP}.foo dust.ess.uci.edu:/var/www/html/nco/rgr
 
-# gcc/g++ Zender uses this to debug NCO with custom-install netCDF (and ESMF) binaries in /usr/local
+# gcc/g++ Zender uses this to debug NCO with custom-install netCDF (and ESMF) binaries in /usr/local (givre, roulee)
 export GNU_TRP=`~/nco/autobld/config.guess`
 cd ~/nco;/bin/rm -f *.${GNU_TRP}.foo;make distclean
 CC='gcc' CXX='g++' NETCDF_INC='/usr/local/include' NETCDF_LIB='/usr/local/lib' ./configure --enable-debug-custom --prefix=${HOME} --bindir=${MY_BIN_DIR} --datadir=${HOME}/nco/data --libdir=${MY_LIB_DIR} --mandir=${HOME}/nco/man > nco.configure.${GNU_TRP}.foo 2>&1
diff --git a/data/Makefile.am b/data/Makefile.am
index a55bc00..f76e036 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -2,7 +2,7 @@
 
 test_data = big.nc in.nc in_rec_zero.nc
 
-test_data_netCDF4 = in_4c.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc cmip5.nc obs.nc mdl_1.nc mdl_2.nc mdl_3.nc hdn.nc mrd.nc
+test_data_netCDF4 = in_4c.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc in_grp_8.nc cmip5.nc obs.nc mdl_1.nc mdl_2.nc mdl_3.nc hdn.nc mrd.nc
 
 # netCDF build rules
 %.nc : %.cdl
@@ -43,6 +43,9 @@ in_grp_6.nc : in_grp_6.cdl
 in_grp_7.nc : in_grp_7.cdl
 	- at PATH_TO_NCGEN@ -k netCDF-4 -o $@ $< 
 
+in_grp_8.nc : in_grp_8.cdl
+	- at PATH_TO_NCGEN@ -k netCDF-4 -o $@ $< 
+
 cmip5.nc : cmip5.cdl
 	- at PATH_TO_NCGEN@ -k netCDF-4 -o $@ $< 
 
@@ -71,9 +74,9 @@ all: ${test_data} ${test_data_netCDF4}
 
 # Autoconf/automake instructions for scripts:
 # https://www.gnu.org/software/automake/manual/html_node/Scripts.html
-dist_bin_SCRIPTS = ncremap
+dist_bin_SCRIPTS = ncclimo ncremap
 
-EXTRA_DIST = big.cdl dsm.cdl hdn.cdl mrd.cdl in.cdl in_grp.cdl in_grp_1.cdl in_grp_2.cdl in_grp_3.cdl in_grp_4.cdl in_grp_5.cdl in_grp_6.cdl in_grp_7.cdl in_1.cdl in_2.cdl cmip5.cdl obs.cdl mdl_1.cdl buggy.cdl in_rec_zero.cdl ncap.in ncap.in2 ncap2.in tst.nco
+EXTRA_DIST = big.cdl dsm.cdl hdn.cdl mrd.cdl in.cdl in_grp.cdl in_grp_1.cdl in_grp_2.cdl in_grp_3.cdl in_grp_4.cdl in_grp_5.cdl in_grp_6.cdl in_grp_7.cdl in_grp_8.cdl in_1.cdl in_2.cdl cmip5.cdl obs.cdl mdl_1.cdl buggy.cdl in_rec_zero.cdl ncap.in ncap.in2 ncap2.in tst.nco
 
 # Automake manual section 14:
 # If configure built it, 'distclean' should delete it
@@ -81,7 +84,7 @@ EXTRA_DIST = big.cdl dsm.cdl hdn.cdl mrd.cdl in.cdl in_grp.cdl in_grp_1.cdl in_g
 DISTCLEANFILES = foo*
 
 # Build procedure produces these files:
-CLEANFILES = 85.nc 86.nc 87.nc 88.nc 89.nc big.nc foo.nc h0001.nc h0002.nc h0003.nc in.nc in_1.nc in_2.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc cmip5.nc hdn.nc mrd.nc dsm.nc lrg_bm1.nc lrg_bm.nc obs.nc mdl.nc mdl2.nc mdl_1.nc mdl_2.nc mdl_3.nc buggy.nc in_rec_zero.nc ../src/nco_c++/in.nc
+CLEANFILES = 85.nc 86.nc 87.nc 88.nc 89.nc big.nc foo.nc h0001.nc h0002.nc h0003.nc in.nc in_1.nc in_2.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc in_grp_8.nc cmip5.nc hdn.nc mrd.nc dsm.nc lrg_bm1.nc lrg_bm.nc obs.nc mdl.nc mdl2.nc mdl_1.nc mdl_2.nc mdl_3.nc buggy.nc in_rec_zero.nc ../src/nco_c++/in.nc
 
 MAINTAINERCLEANFILES = Makefile.in
 
diff --git a/data/Makefile.in b/data/Makefile.in
index e7522e6..0ea676c 100644
--- a/data/Makefile.in
+++ b/data/Makefile.in
@@ -304,12 +304,12 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 test_data = big.nc in.nc in_rec_zero.nc
-test_data_netCDF4 = in_4c.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc cmip5.nc obs.nc mdl_1.nc mdl_2.nc mdl_3.nc hdn.nc mrd.nc
+test_data_netCDF4 = in_4c.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc in_grp_8.nc cmip5.nc obs.nc mdl_1.nc mdl_2.nc mdl_3.nc hdn.nc mrd.nc
 
 # Autoconf/automake instructions for scripts:
 # https://www.gnu.org/software/automake/manual/html_node/Scripts.html
-dist_bin_SCRIPTS = ncremap
-EXTRA_DIST = big.cdl dsm.cdl hdn.cdl mrd.cdl in.cdl in_grp.cdl in_grp_1.cdl in_grp_2.cdl in_grp_3.cdl in_grp_4.cdl in_grp_5.cdl in_grp_6.cdl in_grp_7.cdl in_1.cdl in_2.cdl cmip5.cdl obs.cdl mdl_1.cdl buggy.cdl in_rec_zero.cdl ncap.in ncap.in2 ncap2.in tst.nco
+dist_bin_SCRIPTS = ncclimo ncremap
+EXTRA_DIST = big.cdl dsm.cdl hdn.cdl mrd.cdl in.cdl in_grp.cdl in_grp_1.cdl in_grp_2.cdl in_grp_3.cdl in_grp_4.cdl in_grp_5.cdl in_grp_6.cdl in_grp_7.cdl in_grp_8.cdl in_1.cdl in_2.cdl cmip5.cdl obs.cdl mdl_1.cdl buggy.cdl in_rec_zero.cdl ncap.in ncap.in2 ncap2.in tst.nco
 
 # Automake manual section 14:
 # If configure built it, 'distclean' should delete it
@@ -317,7 +317,7 @@ EXTRA_DIST = big.cdl dsm.cdl hdn.cdl mrd.cdl in.cdl in_grp.cdl in_grp_1.cdl in_g
 DISTCLEANFILES = foo*
 
 # Build procedure produces these files:
-CLEANFILES = 85.nc 86.nc 87.nc 88.nc 89.nc big.nc foo.nc h0001.nc h0002.nc h0003.nc in.nc in_1.nc in_2.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc cmip5.nc hdn.nc mrd.nc dsm.nc lrg_bm1.nc lrg_bm.nc obs.nc mdl.nc mdl2.nc mdl_1.nc mdl_2.nc mdl_3.nc buggy.nc in_rec_zero.nc ../src/nco_c++/in.nc
+CLEANFILES = 85.nc 86.nc 87.nc 88.nc 89.nc big.nc foo.nc h0001.nc h0002.nc h0003.nc in.nc in_1.nc in_2.nc in_grp.nc in_grp_1.nc in_grp_2.nc in_grp_3.nc in_grp_4.nc in_grp_5.nc in_grp_6.nc in_grp_7.nc in_grp_8.nc cmip5.nc hdn.nc mrd.nc dsm.nc lrg_bm1.nc lrg_bm.nc obs.nc mdl.nc mdl2.nc mdl_1.nc mdl_2.nc mdl_3.nc buggy.nc in_rec_zero.nc ../src/nco_c++/in.nc
 MAINTAINERCLEANFILES = Makefile.in
 all: all-am
 
@@ -592,6 +592,9 @@ in_grp_6.nc : in_grp_6.cdl
 in_grp_7.nc : in_grp_7.cdl
 	- at PATH_TO_NCGEN@ -k netCDF-4 -o $@ $< 
 
+in_grp_8.nc : in_grp_8.cdl
+	- at PATH_TO_NCGEN@ -k netCDF-4 -o $@ $< 
+
 cmip5.nc : cmip5.cdl
 	- at PATH_TO_NCGEN@ -k netCDF-4 -o $@ $< 
 
diff --git a/data/bsc_tst.nco b/data/bsc_tst.nco
new file mode 100644
index 0000000..fd7a8d0
--- /dev/null
+++ b/data/bsc_tst.nco
@@ -0,0 +1,453 @@
+// $Header$ -*-C++-*-
+
+// Purpose: Script to test instinsic operations (=-*/)  and basic functions 
+//          like casting variables and hyperslabbing variables               
+
+/* Usage: 
+   ncap2 -O -v -S ~/nco/data/gsl_sf.in ~/nco/data/in.nc ~/foo.nc
+   ncks ~/foo.nc | /bin/more */
+
+print("Test script for basic and intrinsic functions\n");
+
+// Count number of errors
+nbr_err=0;
+nbr_err_ttl=0;
+
+// casting variables block a
+{
+  // recast vars in input to diffferent types and/or shape
+  one[]=1.0d;
+  od[time]=od.short();
+
+  three_dmn_var_dbl[time,lon,lat]=three_dmn_var_dbl.int();
+  three_dmn_var_dbl.set_miss(-99);
+
+  three_dmn_var_sht[lat,lon]={1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0};
+
+  
+  // poulate vars existing in input
+  three_dmn_var_int(:,:,:)=-1;
+  one_dmn_rec_wgt(:)=2.0;
+
+  // cast a hyperslab
+  three_new[time,lat,lon]=three_dmn_var_int(0,:,:);
+
+  a10[time,lat,lon,lev]=P0*hyam+hybm*PS; 
+
+  if(one.type() != NC_DOUBLE || one.size() !=1 )
+  {
+     print("ERROR: a:one\n");
+     nbr_err++;	
+  }
+
+  if(od.type() != NC_SHORT || od.size() !=10 )
+  {
+     print("ERROR: a:od\n");
+     nbr_err++;	
+  }
+
+  if(three_dmn_var_dbl.total() !=2802)
+  {
+     print("ERROR: a:three_dmn_var_dbl\n");
+     nbr_err++;	
+  }
+
+  if(three_dmn_var_sht.type() != NC_DOUBLE || three_dmn_var_sht.size() != 8  )
+  {
+     print("ERROR: a:three_dmn_var_sht\n");
+     nbr_err++;	
+  }
+
+  if(three_dmn_var_int.total() != -80)
+  {
+     print("ERROR: a:three_dmn_var_int\n");
+     nbr_err++;	
+  }
+
+  if(one_dmn_rec_wgt.total() != 20.0d)
+  {
+     print("ERROR: a:one_dmn_rec_wgt\n");
+     nbr_err++;	
+  }
+
+  if(three_new.total() != -80 || three_new.type() != NC_INT)
+  {
+     print("ERROR: a:three_new\n");
+     nbr_err++;	
+  }
+
+  if(a10.ndims() != 4 ||  a10.type() != NC_FLOAT || fabs(a10.total() - 1.230098e+07)>1.0e2)
+  {
+     print("ERROR: a10\n");
+     nbr_err++;	
+  }
+
+
+  print("RESULTS block a: Num errors="); print(nbr_err,"%d");
+  nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+}
+
+
+// more casting and hyperslabbing
+{
+  b1[ilev]=0.0;
+  b1(::2)=1.0;
+  b1(1::2)=2.0;  
+
+  b2[time,lon]=time.int();
+  
+  // RHS isnt cast as its already the right size -try negative indices
+  b3[ilev]=time(6:9)/ time(-4:-1);
+
+  // cast a hyperslab     
+  b4[ilev,lat,lon]=lat_2D_rct(0,:);
+
+  // cast a hyperslab from a attribute
+  b5 at fill=20L;
+  b5[ilev]=b5 at fill;  
+
+  // cast from a "value list"
+  b6 at fill={1.0,4.0,9.0,16.0};
+  b6[ilev]=b6 at fill;
+ 
+  // cast from a single hyperslab
+  b7[ilev]=time(9);
+
+  // casting expressions
+  b8[ilev]=b5/b7 + 1.0;;
+
+  
+  // use var/att to index into array
+  b9=three_dmn_rec_var;
+  b9 at idx_a={1,1,2};       // srt
+  b9 at idx_b={0,0,0,1,0,3}; // srt, end
+
+  b9a=b9(b9 at idx_a); 
+  b9b=b9(b9 at idx_b); 
+
+  if(b1.total()!=6.0)
+  {
+     print("ERROR: b1\n");
+     nbr_err++;	
+  }
+
+  if(b2.total()!=220)
+  {
+     print("ERROR: b2\n");
+     nbr_err++;	
+  }
+
+
+  if(b3.total()!=4)
+  {
+     print("ERROR: b3\n");
+     nbr_err++;	
+  }
+
+  if(b4.total()!=-2880.0f)
+  {
+     print("ERROR: b4\n");
+     nbr_err++;	
+  }
+
+  if(b5.total()!=80)
+  {
+     print("ERROR: b5\n");
+     nbr_err++;	
+  }
+
+  if(b6.total()!= 30.0)
+  {
+     print("ERROR: b6\n");
+     nbr_err++;	
+  }
+
+  if(b7.avg()!= 10.0)
+  {
+     print("ERROR: b7\n");
+     nbr_err++;	
+  }
+
+  if(b8.avg()!= 3.0 || b8.type() != NC_DOUBLE)
+  {
+     print("ERROR: b8\n");
+     nbr_err++;	
+  }
+  
+  if( b9a != 15 || b9a.ndims()!=0   ) 
+  {  
+     print("ERROR: b9a - variable indices\n");
+     nbr_err++;	
+
+  }
+
+  if( b9b(0,0)!=1 || b9b(1,3)!=8 || b9b.ndims()!=2   ) 
+  {  
+     print("ERROR: b9b - variable indices\n");
+     nbr_err++;	
+
+  }
+
+
+
+  print("RESULTS block b: Num errors="); print(nbr_err,"%d");
+  nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+}
+
+// type conversion - var/var and var/att and att/att
+{ 
+  c1=time;
+  c1_byte=time.byte();
+  c1_short=time.short();
+  c1_int=time.int();
+  c1_float=time.float();
+  c1_float=time.double();
+
+  c1 at byte=10b;
+  c1 at short=20s;
+  c1 at int=30;
+  c1 at int2=23L;
+  c1 at int3=24l;
+  c1 at float=40f;
+  c1 at double=50d;
+
+  //var var
+  c2=c1_float / c1_short *c1_int;  
+  c3=c1_byte*1.0d; 
+
+  //var att 
+  c4=2L * c1 at double; 
+  c5=c1_int * c1 at float;
+   
+  // att att 
+  c1 at result=c1 at double/c1 at byte;  
+
+  if(c2.type() != NC_FLOAT || c2.size() !=10 )
+  {
+     print("ERROR: c2\n");
+     nbr_err++;	
+  }
+  
+  if(c3.type() != NC_DOUBLE || c3.size() != 10 )
+  {
+     print("ERROR: c3\n");
+     nbr_err++;	
+  }
+
+  if(c4.type() != NC_INT || c4.size() != 1 )
+  {
+     print("ERROR: c4\n");
+     nbr_err++;	
+  }
+
+  if(c1 at result.type() != NC_DOUBLE || c1 at result.size() != 1 )
+  {
+     print("ERROR: c1 at result\n");
+     nbr_err++;	
+  }
+
+
+
+  print("RESULTS block c: Num errors="); print(nbr_err,"%d");
+  nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+}
+
+// attributes
+{
+
+  // attribute propgation
+  d1=(2*3+4-3/time);
+  if( !exists(d1 at units) || !exists(d1 at long_name))
+  {
+     print("ERROR: d1 at attribute propagation\n");
+     nbr_err++;	
+  }
+  
+
+  // attribute inheritance
+  lon_grd(0:1)={-46,46};
+  if( !exists(lon_grd at units) || !exists(lon_grd at long_name))
+  {
+     print("ERROR: d2/lon_grd @attribute inheritance\n");
+     nbr_err++;	
+  }
+  
+  lon_grd at total=lon_grd.ttl();
+  lon_grd at delta=1e-6;
+
+  // attribute propgation
+  d3=2.0f+3.0 - 1.0*lon_grd;
+  if( !( exists(d3 at units) && exists(d3 at long_name) && exists(d3 at delta) && exists(d3 at total)) )
+  {
+     print("ERROR: d3 at attribute propagation\n");
+     nbr_err++;	
+  }
+
+  // attribute hyperslab
+  d3 at time=time;
+  d3 at time_odd=time(::2);
+  d3 at time_even=time(1::2);
+
+  if( d3 at time(9)!=10.0d )  
+  {
+     print("ERROR: d3 at attribute single-slab\n");
+     nbr_err++;	
+  }
+  
+  // nb cant use total() as att has no dimension -doh doh doh 
+  if( d3 at time_odd.size() != 5 || d3 at time_odd.gsl_stats_mean() * d3 at time_odd.size() != 25.0 )  
+  {
+     print("ERROR: d3 at attribute odd hyperslab\n");
+     nbr_err++;	
+  }
+  
+  if( d3 at time_even.size() != 5 || d3 at time_even.gsl_stats_mean() * d3 at time_even.size() != 30.0 )  
+  {
+     print("ERROR: d3 at attribute even hyperslab\n");
+     nbr_err++;	
+  }
+
+  // RHS attribute hyperslab;
+  d4=4;
+  d4 at time_odd=time(::2);
+ 
+  // Attributes comparison
+  if( d4 at time_odd != d3 at time_odd)  
+  {
+     print("ERROR: d4a at attribute comparison\n");
+     nbr_err++;	
+  }
+  
+  // Attributes comparison
+  if( ++d4 at time_odd != d3 at time_even)  
+  {
+     print("ERROR: d4b at attribute comparison\n");
+     nbr_err++;	
+  }
+
+  d4 at time_odd=d3 at time_odd;
+  // use assign operands
+  d4 at time_odd+=10;       
+  d4 at time_odd*=20;       
+  d4 at time_odd/=20;       
+  d4 at time_odd-=10;
+
+  // Attributes comparison
+  if( d4 at time_odd != d3 at time_odd)  
+  {
+     print("ERROR: d4c at unary operands test\n");
+     nbr_err++;	
+  }
+
+
+
+
+  print("RESULTS block d: Num errors="); print(nbr_err,"%d");
+  nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+}
+
+// missing values and missing methods
+{
+  defdim("plon",20);
+
+  e1=array(0.0,0.5,$plon);
+
+  if(e1.total()!=95.0)
+  {
+     print("ERROR: e1:total()\n");
+     nbr_err++;	
+  }
+  
+  e1(0:2)=-999.0;
+  e1.set_miss(-999.0);
+
+  if(e1.total()!=93.5)
+  {
+     print("ERROR: e1:set_miss()\n");
+     nbr_err++;	
+  }
+
+  e1.change_miss(-666.0);
+  if(e1.total()!=93.5)
+  {
+     print("ERROR: e1:change_miss()\n");
+     nbr_err++;	
+  }
+
+  if(e1.number_miss() != 3)
+  {
+     print("ERROR: e1:number_miss()\n");
+     nbr_err++;	
+  }
+ 
+  e1.delete_miss();
+  if(e1.total()!=-1904.5)
+  {
+     print("ERROR: e1:delete_miss()\n");
+     nbr_err++;	
+  }
+  
+  // add two variables with different missing values 
+  // in var_var_op() as of Sun Sep 20 12:03:53 2015 / 99a7f11b0a3802b901c8f684997e55b5fcadba01 
+  // missing values in op2 are changed to op1 
+  e2=three_dmn_rec_var;  
+  e3=three_dmn_rec_var;
+
+  e2(0,0,0:3)=-99.0;
+  e2(9,1,0:3)=-99.0;  
+  e2.set_miss(-99.0);
+
+  e3(0,0,0:1)=-99.0;
+  e3(1,1,0:1)=-99.0;  
+  e3.set_miss(-99.0);
+  
+  e4=e2+e3;
+  
+  e3.change_miss(-88.0);   
+  
+  e5=e2+e3; 
+
+
+  if(e4 != e5 )
+  {
+     print("ERROR: e6 missing values not made cognizant");
+     nbr_err++;	
+  }
+  
+  print("RESULTS block e: Num errors="); print(nbr_err,"%d");
+  nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+}
+
+// Check gsl_stats and gsl_ran functions
+{
+  nbr_err=0;
+
+  print("RESULTS block f: Num errors="); print(nbr_err,"%d");
+  //nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+
+}
+
+// Cumulative distribution functions
+{
+
+  print("RESULTS block g: Num errors="); print(nbr_err,"%d");
+  nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+}
+
+// Least Squares Fitting 
+{
+
+  print("RESULTS block h: Num errors="); print(nbr_err,"%d");
+  nbr_err_ttl+=nbr_err;
+  nbr_err=0;
+}
+
+// Results summany
+print("RESULTS SUMMARY: total errors=");print(nbr_err_ttl,"%d");
diff --git a/data/gsl_sf.in b/data/gsl_sf.in
index 8d13a75..8d279e1 100644
--- a/data/gsl_sf.in
+++ b/data/gsl_sf.in
@@ -1,6 +1,6 @@
 // $Header$ -*-C++-*-
 
-// Purpose: Script to test gsl special functions
+// Purpose: Script to test GSL special functions
 
 /* Usage: 
    ncap2 -O -v -S ~/nco/data/gsl_sf.in ~/nco/data/in.nc ~/foo.nc
@@ -11,18 +11,14 @@ print("Test script for gsl Special Functions\n");
 // Count number of errors
 nbr_err=0;
 nbr_err_ttl=0;
-
-
 {
   arg1[time]=1.0;
   a1 at arg1=1s; 
   a1 at arg2=3s;
   a1 at arg3={1,2,3,4,5,6,7,8,9,10};
   time3[time]=1.0;
-
 }
 
-
 // Bessel functions
 {
   // a1,a2,a3,a4 all the same
@@ -48,38 +44,29 @@ nbr_err_ttl=0;
     nbr_err++;	
   }
 
-
   if( fabs(a3.total()-a4.total()) >0.01){
      print("ERROR: a2:Bessel functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(a5.total()-a6.total()) >0.01){
      print("ERROR: a5:Bessel functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(a7.avg()-a8.avg()) >0.01){
      print("ERROR: a7:Bessel functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(a9.total()-165.063) >0.01){
      print("ERROR: a9:Bessel functions\n");
      nbr_err++;	
   }
 
-
-
   print("RESULTS block a: Num errors="); print(nbr_err,"%d");
   nbr_err_ttl+=nbr_err;
   nbr_err=0;
-
-
-
 }
 
 // Elliptical Integrals
@@ -92,53 +79,43 @@ nbr_err_ttl=0;
   // takes four double args
   b5=gsl_sf_ellint_RJ(bnd_var at double_att,bnd_var at int_att,time,three_dmn_var_dbl);
 
-
   if( fabs(b0.total()-103.67256)  >0.01){
      print("ERROR: b0:Elliptical Integral functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(b1.total()-4.82441) >0.01){
      print("ERROR: b1:Elliptical Integral functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(b2.total()-0.010359 ) >0.0001){
      print("ERROR: b2:Elliptical Integral functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(b3.total()-0.94582 ) >0.001){
      print("ERROR: b3:Elliptical Integral functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(b4.total()-1.58596 ) >0.001){
      print("ERROR: b4:Elliptical Integral functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(b5.total()-0.441753 ) >0.0001){
      print("ERROR: b5:Elliptical Integral functions\n");
      nbr_err++;	
   }
 
-
   print("RESULTS block b: Num errors="); print(nbr_err,"%d");
   nbr_err_ttl+=nbr_err;
   nbr_err=0;
-
-
 }
 
 //hyper-geometric functions
 {
-
   chglon=lon;
   set_miss(chglon,-2000);
 
@@ -148,49 +125,38 @@ nbr_err_ttl=0;
   c3=gsl_sf_hyperg_2F1(2.0,1.0,chglon,0.1);
   c4=gsl_sf_hyperg_2F0(1.5,0.5,chglon/10);
 
-
   if( fabs(c0.total()-309.23826 ) >0.01){
      print("ERROR: c0:Hypergeometric functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(c1.total()-800.97646 ) >0.01){
      print("ERROR: c1:Hypergeometric functions\n");
      nbr_err++;	
   }
 
-
-
   if( fabs(c2.total()-2.02375 ) >0.001){
      print("ERROR: c2:Hypergeometric functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(c3.total()-3.0041 ) >0.001){
      print("ERROR: c3:Hypergeometric functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(c4.total()-1.0 ) >0.01){
      print("ERROR: c4:Hypergeometric functions\n");
      nbr_err++;	
   }
 
-
   print("RESULTS block c: Num errors="); print(nbr_err,"%d");
   nbr_err_ttl+=nbr_err;
   nbr_err=0;
-
 }
 
-
-
 // Legendre functions
 {
-
   leg[lon]={0,1,2,3};
 
   // d0,d1 identical
@@ -200,31 +166,26 @@ nbr_err_ttl=0;
 
   // d2,d3 identical
   d2=gsl_sf_legendre_Plm(time.int()-1,0,0.7);
-
     
   // not in gsl 2.0
   //gsl_sf_legendre_Plm_array(9,0,0.7,&d3);
 
   // d4,d5 identical
   d4=gsl_sf_legendre_sphPlm(leg,0,0.7);
-  
 
   // not in gsl 2.0
   // gsl_sf_legendre_sphPlm_array(3,0,0.7,&d5);
 
-
   if( fabs(d0.total()-d1.total() ) >0.01){
      print("ERROR: d0:Legendre functions\n");
      nbr_err++;	
   }
-
   
   if( fabs(d2.total()- 1.56887  ) >0.01){
      print("ERROR: d2:Legendre functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(d4.ttl()- 0.628677 ) >0.01){
      print("ERROR: d4:Legendre functions\n");
      nbr_err++;	
@@ -233,7 +194,6 @@ nbr_err_ttl=0;
   print("RESULTS block d: Num errors="); print(nbr_err,"%d");
   nbr_err_ttl+=nbr_err;
   nbr_err=0;
-
 }
 
 // Miscellaneous Functions
@@ -251,7 +211,6 @@ nbr_err_ttl=0;
   e6=gsl_sf_Chi(three_dmn_var_int/10);
   e7=gsl_sf_fermi_dirac_half(lon);
 
-
   e8=gsl_sf_lngamma(time/10);
   e9=gsl_sf_gamma_inc(time/10,time);
   e10=gsl_sf_gegenpoly_n(time.int()-1,0.1,0.3);
@@ -261,111 +220,84 @@ nbr_err_ttl=0;
   e13=time.gsl_sf_synchrotron_1();
   e14=gsl_sf_transport_4(lon/100);
 
-
-
-
-
   if( fabs(e0.total()-56.1677 >0.01)){
      print("ERROR: e0:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e1.total()-2.02447)>0.01){
      print("ERROR: e1:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e2.total()-2.50099553)>0.01){
      print("ERROR: e2:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e3.avg()-0.3631 >1e-3)){
      print("ERROR: e3:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs( fabs(e4.avg())-406.3444 >0.001)){
      print("ERROR: e4:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e5.min()-2.7182818 >0.001)){
      print("ERROR: e5:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e6.total()-1667.04887 >0.001)){
      print("ERROR: e6:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e7.avg()-1449.3344 >0.001)){
      print("ERROR: e7:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e8.avg()-0.71191 >0.001)){
      print("ERROR: e8:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e9.avg()-0.032042 >0.0001)){
      print("ERROR: e9:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e10.total()-0.95417 >0.001)){
      print("ERROR: e10:Misc functions\n");
      nbr_err++;	
   }
 
-
   if(e11.total()-490 !=0){
      print("ERROR: e11:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e12.avg()-1.2985 >0.001)){
      print("ERROR: e12:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e13.avg()- 0.11694 >0.001)){
      print("ERROR: e13:Misc functions\n");
      nbr_err++;	
   }
 
-
   if( fabs(e14.max()- 4.6764 >0.001)){
      print("ERROR: e14:Misc functions\n");
      nbr_err++;	
   }
 
-
-
-
-
-
   print("RESULTS block e: Num errors="); print(nbr_err,"%d");
   nbr_err_ttl+=nbr_err;
   nbr_err=0;
-
-
-
-
 }
 
 // Check gsl_stats and gsl_ran functions
@@ -385,21 +317,18 @@ nbr_err_ttl=0;
      nbr_err++;	
   }
 
-
   //compare sd with sd input in ran generator
   if( abs(f2.gsl_stats_sd()-3.0) >0.5){  
        print("ERROR: f2:sd functions\n");
      nbr_err++;	
   }
 
-
   //compare nco min with gsl min
   if( abs(f2.min()- f2.gsl_stats_min()) >0.01){  
        print("ERROR: f2:min functions\n");
      nbr_err++;	
   }
 
-
   //compare nco max with gsl max
   if( abs(f2.max()- f2.gsl_stats_max()) >0.01){  
        print("ERROR: f2:max functions\n");
@@ -412,14 +341,11 @@ nbr_err_ttl=0;
      nbr_err++;	
   }
 
-
-
   // repeat exercise with integers
   f3[f_size]=100;
   // create array of random numbers less than 100
   f4=gsl_rng_uniform_int(f3);
 
-
   //compare nco average with gsl average
   if( abs(f4.avg()- f4.gsl_stats_mean()) >1){  
        print("ERROR: f4:mean functions\n");
@@ -432,7 +358,6 @@ nbr_err_ttl=0;
      nbr_err++;	
   }
 
-
   //compare nco max with gsl max
   if( abs(f4.max()- f4.gsl_stats_max()) >0.01){  
        print("ERROR: f4:max functions\n");
@@ -445,63 +370,47 @@ nbr_err_ttl=0;
       nbr_err++;	
   }
 
-
   // check sd and sd_m
   if( abs(  gsl_stats_sd(f4) - gsl_stats_sd_m(f4,1,f4.size(),gsl_stats_mean(f4)))>0.01){
       print("ERROR: f4:gsl variance functions\n");
       nbr_err++;	
   }
 
-
   f5[f_size]=2.0;
 
   f6=gsl_ran_exponential(f5).sort();
 
-
    // check weighted functions
  if( abs( gsl_stats_wmean(1.0d,1,f2,1,f2.size())- gsl_stats_mean(f2)) >0.01){  
        print("ERROR: f6: weighted mean function\n");
      nbr_err++;	
   }
 
-
    // check weighted functions
  if( abs( gsl_stats_wmean(0.5d,1,f6,1,f6.size())- gsl_stats_mean(f6)) >0.01){  
        print("ERROR: f6: weighted mean2 function\n");
      nbr_err++;	
   }
 
-
-
-
   print("RESULTS block f: Num errors="); print(nbr_err,"%d");
   //nbr_err_ttl+=nbr_err;
   nbr_err=0;
 
 }
 
-
-
-
 // Cumulative distribution functions
 {
   g1=gsl_cdf_ugaussian_P(three_dmn_var_dbl/10);
   g2=gsl_cdf_gaussian_P(three_dmn_var_dbl/20,2.0);
   g3=gsl_cdf_gamma_P(time,1.0,2.0);
-  
-
 
   print("RESULTS block g: Num errors="); print(nbr_err,"%d");
   nbr_err_ttl+=nbr_err;
   nbr_err=0;
-
 }
 
-
 // Least Squares Fitting 
 {
-
-
   h_xin[time]={1,2,3,4,5,6,7,8,9,10.0};
   h_yin[time]={3.1,6.2,9.1,12.2,15.1,18.2,21.3,24.0,27.0,30.0};
   h_win[time]=1.0;
@@ -519,16 +428,10 @@ nbr_err_ttl=0;
      nbr_err++;	
   }
 
-
-
   print("RESULTS block h: Num errors="); print(nbr_err,"%d");
   nbr_err_ttl+=nbr_err;
   nbr_err=0;
-
 }
 
-
-
-
 // Results summany
 print("RESULTS SUMMARY: total errors=");print(nbr_err_ttl,"%d");
diff --git a/data/in.cdl b/data/in.cdl
index cdb6574..ed70bc3 100644
--- a/data/in.cdl
+++ b/data/in.cdl
@@ -118,7 +118,7 @@ variables:
 	int lat_times_lon(lat_times_lon);
 	lat_times_lon:long_name = "Element index (i.e., C-based storage order) for 2D coordinate grids stored as 1D arrays";
 
-	float lat_2D_rct(lat,lon);
+        float lat_2D_rct(lat,lon);
 	lat_2D_rct:long_name = "Latitude for 2D rectangular grid stored as 2D array";
 	lat_2D_rct:units = "degrees_north";
 
@@ -286,6 +286,23 @@ variables:
 	P0:long_name = "reference pressure";
 	P0:units = "pascal";
 
+        float cnv_CF_grd(lat,lon);
+	cnv_CF_grd:long_name = "test CF grid_mapping convention";
+        cnv_CF_grd:grid_mapping = "albers_conical_equal_area";
+        cnv_CF_grd:purpose = "Test whether grid_mapping is propagated with coordinate";
+
+	char albers_conical_equal_area;
+        albers_conical_equal_area:long_name = "Albers Conical Equal Area Projection";
+        albers_conical_equal_area:purpose = "Test that this grid_mapping is propagated with all associated variables (like cnv_CF_grd)";
+        albers_conical_equal_area:grid_mapping_name = "albers_conical_equal_area";
+        albers_conical_equal_area:false_easting = 0.;
+        albers_conical_equal_area:false_northing = 0.;
+        albers_conical_equal_area:latitude_of_projection_origin = 40.;
+        albers_conical_equal_area:longitude_of_central_meridian = -101.;
+        albers_conical_equal_area:standard_parallel = 20., 60.;
+        albers_conical_equal_area:longitude_of_prime_meridian = 0.;
+        albers_conical_equal_area:semi_major_axis = 6378137.;
+
 	float cnv_CF_crd(gds_crd);
 	cnv_CF_crd:long_name = "test CF coordinates conventions";
 	cnv_CF_crd:coordinates = "lat_gds lon_gds ";
@@ -570,6 +587,14 @@ variables:
 	pi:long_name = "Pi";
 	pi:units = "fraction";
 
+	double pi_arr_dbl(lat,lon);
+	pi_arr_dbl:long_name = "Pi array double precision";
+	pi_arr_dbl:units = "fraction";
+
+	float pi_arr_flt(lat,lon);
+	pi_arr_flt:long_name = "Pi array single precision";
+	pi_arr_flt:units = "fraction";
+
 	int int_var;
 	int_var:long_name = "int";
 
@@ -1242,6 +1267,7 @@ data:
 	// char_var_multinul='0','\n','\0';
 	char_var_nul='\0';
 	char_var_space=" ";
+        cnv_CF_grd=1,2,3,4,5,6,7,8;
 	cnv_CF_crd=273.1,273.2,273.3,273.4,273.5,273.6,273.7,273.8;
 	cnv_CF_ncl=1.,2.,3.,4.,5.,6.,7.,8.,9.,10.;
 	cnv_CF_ncl_var_1=11.,22.,23.,24.,25.,26.,27.,28.,29.,30.;
@@ -1396,6 +1422,8 @@ data:
 	rec_var_pck_scale_factor_only=1,2,3,4,5,6,7,8,9,10;
 	pck_arr=-32767,0,1,32767;
 	pi=3.1415926535897932384626433832795029;
+	pi_arr_dbl=3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029;
+	pi_arr_flt=3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029,3.1415926535897932384626433832795029;
 	upk=3.;
 	upk_arr=-32767.,0.,1.,32767.;
 	H2O=1.0;
diff --git a/data/in_grp_8.cdl b/data/in_grp_8.cdl
index 43cd57d..f7d46e3 100644
--- a/data/in_grp_8.cdl
+++ b/data/in_grp_8.cdl
@@ -1,44 +1,42 @@
 // -*-C++-*-
 // Purpose: 
+// ncpdq tests
 // Generate netCDF files with:
-// ncgen -k 4 -b -o ~/nco/data/in_grp_8.nc ~/nco/data/in_grp_8.cdl
+// ncgen -k netCDF-4  -b -o ~/nco/data/in_grp_8.nc ~/nco/data/in_grp_8.cdl
 
 netcdf in_grp_8 {
- dimensions:
-  lat=2;
-  lon=4;
-  time=unlimited; 
- variables:
-  float two_dmn_rec_var(time,lat);
-  float three_dmn_rec_var1(time,lat,lon);
-  float three_dmn_rec_var2(time,lat,lon);
-  double time(time); 
-  float lat(lat);
-  float lon(lon);
- data:
-  lat=-90,90;
-  lon=0,90,180,270;
-  time=1.,2.,3.,4.,5.,6.,7.,8.,9.,10.;
-  two_dmn_rec_var=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20;
-  three_dmn_rec_var1=1, 2, 3, 4, 5, 6, 7, 8,
-      9,10,11,12,13,14,15,16,
-      17,18,19,20,21,22,23,24,
-      25,26,27,28,29,30,31,32,
-      33,34,35,36,37,38,39,40,
-      41,42,43,44,45,46,47,48,
-      49,50,51,52,53,54,55,56,
-      57,58,59,60,61,62,63,64,
-      65,66,67,68,69,70,71,72,
-      73,74,75,76,77,78,79,80;
-  three_dmn_rec_var2=1, 2, 3, 4, 5, 6, 7, 8,
-      9,10,11,12,13,14,15,16,
-      17,18,19,20,21,22,23,24,
-      25,26,27,28,29,30,31,32,
-      33,34,35,36,37,38,39,40,
-      41,42,43,44,45,46,47,48,
-      49,50,51,52,53,54,55,56,
-      57,58,59,60,61,62,63,64,
-      65,66,67,68,69,70,71,72,
-      73,74,75,76,77,78,79,80;	  
+ group: g1 { 
+   dimensions:
+    lat=2;
+    lon=3;
+    time=unlimited;
+    variables:
+    float lat(lat);
+    float lon(lon);
+    double time(time);
+    float snd(time,lat,lon);
+    data:
+    lat=0,1;
+    lon=0,1,2;
+    time=0,1;
+    snd=0,1,2,3,4,5,6,7,8,9,10,11;
+  } // end g1
+  
+  group: g2 { 
+   dimensions:
+    lat=2;
+    lon=3;
+    time=unlimited;
+    variables:
+    float lat(lat);
+    float lon(lon);
+    double time(time);
+    float snd(time,lat,lon);
+    data:
+    lat=0,1;
+    lon=0,1,2;
+    time=0,1;
+    snd=0,1,2,3,4,5,6,7,8,9,10,11;
+  } // end g2
  
 } // root group
diff --git a/data/ncclimo b/data/ncclimo
new file mode 100755
index 0000000..c352460
--- /dev/null
+++ b/data/ncclimo
@@ -0,0 +1,1019 @@
+#!/bin/bash
+
+# Purpose: Climatology script tailored to CESM'ish monthly input and ACME output guidelines
+# Produces and optionally regrids climatological monthly means, seasonal means, annual mean
+
+# Copyright (C) 2015-2016 Charlie Zender
+# This file is part of NCO, the netCDF Operators. NCO is free software.
+# You may redistribute and/or modify NCO under the terms of the 
+# GNU General Public License (GPL) Version 3.
+
+# As a special exception to the terms of the GPL, you are permitted 
+# to link the NCO source code with the HDF, netCDF, OPeNDAP, and UDUnits
+# libraries and to distribute the resulting executables under the terms 
+# of the GPL, but in addition obeying the extra stipulations of the 
+# HDF, netCDF, OPeNDAP, and UDUnits licenses.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+# See the GNU General Public License for more details.
+
+# The original author of this software, Charlie Zender, seeks to improve
+# it with your suggestions, contributions, bug-reports, and patches.
+# Please contact the NCO project at http://nco.sf.net or write to
+# Charlie Zender
+# Department of Earth System Science
+# University of California, Irvine
+# Irvine, CA 92697-3100
+
+# Prerequisites: Bash, NCO
+# Script could use other shells, e.g., dash (Debian default) after rewriting function definition and looping constructs
+
+# Source: https://github.com/nco/nco/tree/master/data/ncclimo
+# Documentation: http://nco.sf.net/nco.html#ncclimo
+# Additional Documentation:
+# HowTo: https://acme-climate.atlassian.net/wiki/display/ATM/Generating+Climo+files
+# ACME Climatology Requirements: https://acme-climate.atlassian.net/wiki/display/ATM/Climo+Files+-+v0.3+AMIP+runs
+
+# Direct install:
+# scp ~/nco/data/ncclimo aims4.llnl.gov:bin
+# scp ~/nco/data/ncclimo cooley.alcf.anl.gov:bin
+# scp ~/nco/data/ncclimo cori.nersc.gov:bin_cori
+# scp ~/nco/data/ncclimo edison.nersc.gov:bin_edison
+# scp ~/nco/data/ncclimo rhea.ccs.ornl.gov:bin
+# scp ~/nco/data/ncclimo yellowstone.ucar.edu:bin
+# scp dust.ess.uci.edu:nco/data/ncclimo ~/bin
+
+# Configure paths at High-Performance Computer Centers (HPCCs) based on ${HOSTNAME}
+if [ -z "${HOSTNAME}" ]; then
+    if [ -f /bin/hostname ] && [ -x /bin/hostname ]; then
+	export HOSTNAME=`/bin/hostname`
+    elif [ -f /usr/bin/hostname ] && [ -x /usr/bin/hostname ]; then
+	export HOSTNAME=`/usr/bin/hostname`
+    fi # !hostname
+fi # HOSTNAME
+# Default input and output directory is ${DATA}
+if [ -z "${DATA}" ]; then
+    case "${HOSTNAME}" in 
+	cooley* | cc* | mira* ) DATA="/projects/HiRes_EarthSys/${USER}" ; ;; # ALCF cooley compute nodes named ccNNN, 384 GB/node 
+	cori* | edison* ) DATA="${SCRATCH}" ; ;; # NERSC cori/edison compute nodes all named nidNNNNN, edison 24|64 cores|GB/node; cori 32|128 cores|GB/node (cori login nodes 512 GB)
+	pileus* ) DATA="/lustre/atlas/world-shared/cli115/${USER}" ; ;; # OLCF CADES
+	rhea* | titan* ) DATA="/lustre/atlas/world-shared/cli115/${USER}" ; ;; # OLCF rhea compute nodes named rheaNNN, 128 GB/node
+	ys* ) DATA="/glade/p/work/${USER}" ; ;; # NCAR yellowstone compute nodes named ysNNN, 32 GB/node
+	* ) DATA='/tmp' ; ;; # Other
+    esac # !HOSTNAME
+fi # DATA
+# Ensure batch jobs access correct 'mpirun' (or, on cori/edison, 'srun') command, netCDF library, and NCO executables and library:
+case "${HOSTNAME}" in 
+    aims* )
+	export PATH='/export/zender1/bin'\:${PATH}
+        export LD_LIBRARY_PATH='/export/zender1/lib'\:${LD_LIBRARY_PATH} ; ;;
+    cooley* )
+	# 20160421: Split cooley from mira binary locations to allow for different system libraries
+	# http://www.mcs.anl.gov/hs/software/systems/softenv/softenv-intro.html
+	soft add +mvapich2 
+        export PBS_NUM_PPN=12 # Spoof PBS on Soft (which knows nothing about node capabilities)
+	export PATH='/home/zender/bin_cooley'\:${PATH}
+	export LD_LIBRARY_PATH='/home/zender/lib_cooley'\:${LD_LIBRARY_PATH} ; ;;
+    mira* )
+	export PATH='/home/zender/bin_mira'\:${PATH}
+	export LD_LIBRARY_PATH='/soft/libraries/netcdf/current/library:/home/zender/lib_mira'\:${LD_LIBRARY_PATH} ; ;;
+    cori* )
+	# 20160407: Split cori from edison binary locations to allow for different system libraries
+	# 20160420: module load gsl, udunits required for non-interactive batch submissions by Wuyin Lin
+	# Not necessary for interactive, nor for CSZ non-interactive, batch submisssions
+	# Must be due to home environment differences between CSZ and other users
+	# Loading gsl and udunits seems to do no harm, so always do it
+	# This is equivalent to LD_LIBRARY_PATH method used for netCDF and SZIP on rhea
+	# Why do cori/edison and rhea require workarounds for different packages?
+	module load gsl
+	module load udunits
+	# On cori, module load ncl installs ERWG in ${NCARG_ROOT}/../intel/bin
+	if [ -n "${NCARG_ROOT}" ]; then
+            export PATH="${NCARG_ROOT}/bin:${PATH}"
+	fi # !NCARG_ROOT
+	export PATH='/global/homes/z/zender/bin_cori'\:${PATH}
+        export LD_LIBRARY_PATH='/global/homes/z/zender/lib_cori'\:${LD_LIBRARY_PATH} ; ;;
+    edison* )
+	module load gsl
+	module load udunits
+	export PATH='/global/homes/z/zender/bin_edison'\:${PATH}
+        export LD_LIBRARY_PATH='/global/homes/z/zender/lib_edison'\:${LD_LIBRARY_PATH} ; ;;
+    pileus* )
+	export PATH='/home/zender/bin'\:${PATH}
+	export LD_LIBRARY_PATH='/opt/ACME/uvcdat-2.2-build/install/Externals/lib:/home/zender/lib'\:${LD_LIBRARY_PATH} ; ;;
+    rhea* )
+	# 20151017: CSZ next three lines guarantee finding mpirun
+	source ${MODULESHOME}/init/sh # 20150607: PMC Ensures find module commands will be found
+	module unload PE-intel # Remove Intel-compiled mpirun environment
+	module load PE-gnu # Provides GCC-compiled mpirun environment (CSZ uses GCC to build NCO on rhea)
+	# 20160219: CSZ UVCDAT setup causes failures with mpirun, attempting a work-around
+	if [ -n "${UVCDAT_SETUP_PATH}" ]; then
+	    module unload python ompi paraview PE-intel PE-gnu
+	    module load gcc
+	    source /lustre/atlas1/cli900/world-shared/sw/rhea/uvcdat/latest_full/bin/setup_runtime.sh
+	    export ${UVCDAT_SETUP_PATH}
+	fi # !UVCDAT_SETUP_PATH
+	# On rhea, module load ncl installs ERWG in ${NCL_DIR}/bin
+	if [ -n "${NCL_DIR}" ]; then
+            export PATH="${NCL_DIR}/bin:${PATH}"
+	fi # !NCL_DIR
+        export PATH='/ccs/home/zender/bin_rhea'\:${PATH}
+	export LD_LIBRARY_PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/lib:/sw/redhat6/szip/2.1/rhel6.6_gnu4.8.2/lib:/ccs/home/zender/lib_rhea'\:${LD_LIBRARY_PATH} ; ;;
+    titan* )
+	source ${MODULESHOME}/init/sh # 20150607: PMC Ensures find module commands will be found
+	module load gcc
+        export PATH='/ccs/home/zender/bin_titan'\:${PATH}
+	export LD_LIBRARY_PATH='/opt/cray/netcdf/4.3.2/GNU/49/lib:/sw/xk6/udunits/2.1.24/sl_gcc4.5.3/lib:/ccs/home/zender/lib_titan'\:${LD_LIBRARY_PATH} ; ;;
+    ys* )
+	# 20151018: Yellowstone support not yet tested in batch mode
+	# On yellowstone, module load ncl installs ERWG in /glade/apps/opt/ncl/6.3.0/intel/12.1.5/bin (not in ${NCARG_ROOT}/bin)
+	if [ -n "${NCARG_ROOT}" ]; then
+#            export PATH="${NCARG_ROOT}/bin:${PATH}"
+            export PATH="${PATH}:/glade/apps/opt/ncl/6.3.0/intel/12.1.5/bin"
+	fi # !NCARG_ROOT
+        export PATH='/glade/u/home/zender/bin'\:${PATH}
+        export LD_LIBRARY_PATH='/glade/apps/opt/netcdf/4.3.0/intel/12.1.5/lib:/glade/u/home/zender/lib'\:${LD_LIBRARY_PATH}
+esac # !HOSTNAME
+
+# Production usage:
+# ncclimo -c famipc5_ne120_v0.3_00003 -s 1980 -e 1983 -i /lustre/atlas1/cli115/world-shared/mbranst/famipc5_ne30_v0.3_00003-wget-test -o ${DATA}/ne30/clm
+# ncclimo -c famipc5_ne120_v0.3_00003 -s 1980 -e 1983 -i /lustre/atlas1/cli115/world-shared/mbranst/famipc5_ne120_v0.3_00003-wget-test -o ${DATA}/ne120/clm
+# ncclimo -c B1850C5e1_ne30 -s 2 -e 199 -i /lustre/atlas1/cli115/world-shared/mbranst/B1850C5e1_ne30/atm/hist -o ${DATA}/ne30/clm
+
+# Debugging and Benchmarking:
+# ncclimo -v FSNT,AODVIS -c famipc5_ne30_v0.3_00003 -s 1980 -e 1983 -i ${DATA}/ne30/raw -o ${DATA}/ne30/clm -r ${DATA}/maps/map_ne30np4_to_fv129x256_aave.20150901.nc
+# ncclimo -v TOTEXTTAU -c merra2_198001.nc4 -s 1980 -e 2015 -a sdd -i ${DATA}/merra2/raw -o ${DATA}/merra2/clm
+# ncclimo > ~/ncclimo.out 2>&1 &
+# ncclimo -c B1850C5e1_ne30 -s 2 -e 199 > ~/ncclimo.out 2>&1 &
+# ncclimo -c ne30_gx1.B1850c5d -s 6 -e 7 > ~/ncclimo.out 2>&1 &
+# ncclimo -d 2 -v FSNT -m cam2 -c essgcm14 -s 1 -e 20 -i ${DATA}/essgcm14 -o ${DATA}/anl > ~/ncclimo.out 2>&1 &
+# ncclimo -c famipc5_ne30_v0.3_00003 -s 1980 -e 1983 -i /lustre/atlas1/cli115/world-shared/mbranst/famipc5_ne30_v0.3_00003-wget-test -o ${DATA}/ne30/clm > ~/ncclimo.out 2>&1 &
+# ncclimo -c famipc5_ne120_v0.3_00003 -s 1980 -e 1983 -i /lustre/atlas1/cli115/world-shared/mbranst/famipc5_ne120_v0.3_00003-wget-test -o ${DATA}/ne120/clm > ~/ncclimo.out 2>&1 &
+# MPAS: Prior to running ncclimo on MPAS output, annotate missing values of input with, e.g.,
+# for fl in `ls hist.*` ; do
+#  ncatted -O -t -a _FillValue,,o,d,-9.99999979021476795361e+33 ${fl}
+# done
+# ncclimo -v temperature -c hist -s 2 -e 3 -m ocn -i /lustre/atlas1/cli112/proj-shared/golaz/ACME_simulations/20160121.A_B2000ATMMOD.ne30_oEC.titan.a00/run -r ${DATA}/maps/map_oEC60to30_to_t62_bilin.20160301.nc -o ${DATA}/mpas/clm > ~/ncclimo.out 2>&1 &
+# ncclimo -v iceAreaCell -c hist -s 2 -e 3 -m ice -i /lustre/atlas1/cli112/proj-shared/golaz/ACME_simulations/20160121.A_B2000ATMMOD.ne30_oEC.titan.a00/run -r ${DATA}/maps/map_oEC60to30_to_t62_bilin.20160301.nc -o ${DATA}/mpas/clm > ~/ncclimo.out 2>&1 &
+
+# Best performance on resolutions finer than ne30 (~1x1 degree) requires a job scheduler/batch processor
+# Cobalt (cooley), SLURM (cori,edison), Torque (a PBS-variant) (hopper), and PBS (rhea) schedulers allow both interactive and non-interactive (i.e., script) batch jobs
+# ALCF Cobalt:
+# softenv # lists available packages
+# http://www.mcs.anl.gov/hs/software/systems/softenv/softenv-intro.html
+# http://www.alcf.anl.gov/user-guides/using-cobalt-cooley
+# https://www.alcf.anl.gov/user-guides/cobalt-job-control
+# NERSC SLURM:
+# https://www.nersc.gov/users/computational-systems/cori/running-jobs/slurm-introduction
+# https://www.nersc.gov/users/computational-systems/cori/running-jobs/for-edison-users/torque-moab-vs-slurm-comparisons
+# https://www.nersc.gov/users/computational-systems/cori/running-jobs/queues-and-policies/
+# https://www.nersc.gov/users/computational-systems/edison/running-jobs/queues-and-policies/
+# OLCF PBS: 
+# https://www.olcf.ornl.gov/support/system-user-guides/rhea-user-guide/#903
+# Requesting interactive nodes, Submitting non-interactive batch jobs, Monitoring queues, Deleting jobs:
+# Cobalt: qsub -I,   qsub,  qstat,    qdel
+# PBS:    qsub -I,   qsub,  qstat,    qdel
+# SLURM:   salloc, sbatch, squeue, scancel
+# Interactive queue: a) Reserve nodes and acquire prompt on control node b) Execute ncclimo command interactively
+#   Cooley: qsub -I -A HiRes_EarthSys --nodecount=12 --time=00:30:00 --jobname=ncclimo
+#   Cori:   salloc  -A acme --nodes=12 --partition=debug --time=00:30:00 --job-name=ncclimo # NB: 30 minute limit, Edison too
+#   Hopper: qsub -I -A acme -V -l mppwidth=288 -l walltime=00:30:00 -q debug -N ncclimo # deprecated, old Edison
+#   Rhea:   qsub -I -A CLI115 -V -l nodes=12 -l walltime=00:30:00 -N ncclimo # Bigmem: -l partition=gpu
+#   Yellow: fxm # Bigmem: 
+# Non-interactive batch procedure: a) Store ncclimo command in ncclimo.[cobalt|pbs|slurm] b) qsub ncclimo.[cobalt|pbs|slurm]
+# Non-interactive batch queue differences (besides argument syntax):
+# 1. Cobalt and SLURM require initial 'shebang' line to specify the shell interpreter (not required on PBS)
+# 2. Cobalt appends stdout/stderr to existing output files, if any, whereas PBS overwrites existing files
+# 3. Cobalt uses ${COBALT_NODEFILE} and (NA) whereas PBS uses ${PBS_NODEFILE} and ${PBS_NUM_PPN}, respectively, and SLURM uses ${SLURM_NODELIST} and ${SLURM_CPUS_ON_NODE}, respectively
+# 4. SLURM automatically combines stdout and stderr, yet does not understand tilde (~ = home directory) expansion in error/output filenames
+# Differences 1 & 2 impose slightly different invocations; difference 3 requires abstracting environment variables; difference 4 requires omitting ~'s
+#   Cooley a): /bin/rm -f ~/ncclimo.err  ~/ncclimo.out
+#              echo '#!/bin/bash' > ~/ncclimo.cobalt
+#              echo "ncclimo -d 1 -p mpi -c b1850c5_m2a -s 55 -e 58 -i /home/taylorm/scratch1.qtang/b1850c5_m2a/run -o ${DATA}/ne120/clm" >> ~/ncclimo.cobalt;chmod a+x ~/ncclimo.cobalt
+#   Cori,Edison a): echo '#!/bin/bash' > ~/ncclimo.slurm
+#                   echo "ncclimo -a scd -d 1 -p mpi -c famipc5_ne30_v0.3_00003 -s 1980 -e 1983 -i ${DATA}/ne30/raw -o ${DATA}/ne30/clm -r ${DATA}/maps/map_ne30np4_to_fv129x256_aave.20150901.nc" >> ~/ncclimo.slurm;chmod a+x ~/ncclimo.slurm
+#   Rhea a):   echo "ncclimo -a scd -d 1 -p mpi -c famipc5_ne120_v0.3_00003 -s 1980 -e 1983 -i /lustre/atlas1/cli115/world-shared/mbranst/famipc5_ne120_v0.3_00003-wget-test -o ${DATA}/ne120/clm -r ${DATA}/maps/map_ne120np4_to_fv257x512_aave.20150901.nc"  > ~/ncclimo.pbs;chmod a+x ~/ncclimo.pbs
+#   Cooley b): qsub -A HiRes_EarthSys --nodecount=12 --time=00:30:00 --jobname ncclimo --error ~/ncclimo.err --output ~/ncclimo.out --notify zender at uci.edu ~/ncclimo.cobalt
+#   Cori,Edison b): sbatch -A acme --nodes=12 --time=00:30:00 --partition=regular --job-name=ncclimo --mail-type=END --output=ncclimo.out ~/ncclimo.slurm
+#   Hopper b): qsub -A acme -V -l mppwidth=288 -l walltime=00:30:00 -q regular -N ncclimo -j oe -m e -o ~/ncclimo.out ~/ncclimo.pbs
+#   Rhea b):   qsub -A CLI115 -V -l nodes=12 -l walltime=00:30:00 -N ncclimo -j oe -m e -o ~/ncclimo.out ~/ncclimo.pbs
+
+# Normal use: Set five "mandatory" inputs (caseid, yr_srt, yr_end, drc_in, drc_out), and possibly rgr_map, on command line
+# caseid:  Simulation name (filenames must start with ${caseid})
+# drc_in:  Input directory for raw data
+#          Years outside yr_srt and yr_end are ignored
+#          yr_srt should, and for SDD mode must, contain complete year of output
+#          SCD mode ignores Jan-Nov of yr_srt
+#          Dec of yr_end is excluded from the seasonal and monthly analysis in SCD mode
+#          yr_end should, and for SDD mode must, contain complete year of output
+# drc_out: Output directory for processed, climatological data ("climo files")
+#          User needs write permission for ${drc_out}
+# rgr_map: Regridding map, if non-NULL, invoke regridder with specified map on output datasets
+#          Pass options intended exclusively for the NCO regridder as arguments to the -R switch
+# yr_srt:  Year of first January to analyze
+# yr_end:  Year of last  January to analyze
+
+# Other options (often their default settings work well):
+# clm_md:  Climatology mode, i.e., how to treat December. One of two options:
+#          Seasonally-contiguous-december (SCD) mode (clm_md=scd) (default)
+#          Seasonally-discontiguous-december (SDD) mode (clm_md=sdd)
+#          Both modes use an integral multiple of 12 months, and _never alter any input files_
+#          SCD climatologies begin in Dec of yr_srt-1, and end in Nov of yr_end
+#          SDD climatologies begin in Jan of yr_srt,   and end in Dec of yr_end
+#          SCD excludes Jan-Nov of yr_srt-1 and Dec of yr_end (i.e., SCD excludes 12 months of available data)
+#          SDD uses all months of yr_srt through yr_end (i.e., SDD can use all available data)
+#          SCD seasonal averages are inconsistent with (calendar-year-based) annual averages, but better capture seasonal the "natural" (not calendar-year-based) climate year
+#          SDD seasonal averages are fully consistent with (calendar-year-based) annual averages
+# drc_rgr: Regridding directory---store regridded files, if any, in drc_rgr rather than drc_out
+# lnk_flg: Link ACME-climo to AMWG-climo filenames
+#          AMWG omits the YYYYMM components of climo filenames, resulting in shorter names
+#          This switch (on by default) symbolically links the full (ACME) filename to the shorter (AMWG) name
+#          AMWG diagnostics scripts can produce plots directly from these linked filenames
+# par_typ: Parallelism type---all values _except_ exact matches to "bck" and "mpi" are interpreted as "nil" (and invoke serial mode)
+#          bck = Background: Spawn children (basic blocks) as background processes on control node then wait()
+#                Works best when available RAM > 12*4*sizeof(monthly input file), otherwise jobs swap-to-disk
+#          mpi = MPI: Spawn children (basic blocks) as MPI processes (one per node in batch environment) then wait()
+#                Requires batch system with PBS and MPI. Use when available RAM/node < 12*2.5*sizeof(monthly input file).
+#                Optimized for batch with 12 nodes. Factors thereof (6, 4, 3, 2 nodes) should also work.
+#                Remember to request 12 nodes if possible!
+#          nil = None: Execute script in serial mode on single node
+#                Works best when available RAM < 12*4*sizeof(monthly input file), otherwise jobs swap-to-disk
+# var_lst: Variables to include, or, with nco_opt='-x', to exclude, in comma-separated list format, e.g.,
+#          'FSNT,AODVIS'. Regular expressions work, too: 'AOD.?'
+
+# Infrequently used options:
+# bnd_nm:  Name of bounds dimension (examples include 'nbnd' (default), 'tbnd' (CAM2, CAM3), 'hist_interval' (CLM2)
+# dbg_lvl: 0 = Quiet, print basic status during evaluation
+#          1 = Print configuration, full commands, and status to output during evaluation
+#          2 = As in dbg_lvl=1, but do not evaluate commands
+#          3 = As in dbg_lvl=2, with additional information (mainly for batch queues)
+# fml_nm:  Family name (nickname) of output files referring to $fml_nm character sequence used in output climo file names:
+#          fml_nm_XX_YYYYMM_YYYYMM.nc (examples include '' (default), 'control', 'experiment')
+#          By default, fml_nm=$caseid. Use fml_nm instead of $caseid to simplify long names, avoid overlap, etc.
+# hst_nm:  History volume name referring to the $hst_nm character sequence used in history tape names:
+#          caseid.mdl_nm.hst_nm.YYYY-MM.nc (examples include 'h0' (default, works for cam, clm), 'h1', 'h' (for cism))
+# mdl_nm:  Model name referring to the character sequence $mdl_nm used in history tape names:
+#          caseid.mdl_nm.h0.YYYY-MM.nc (examples include 'cam' (default), 'clm2', 'cam2', 'cism', 'pop')
+# nco_opt: String of options to pass-through to NCO, e.g.,
+#          '-D 2 -7 -L 1' for NCO debugging level 2, netCDF4-classic output, compression level 1
+#          '--no_tmp_fl -x' to skip temporary files, turn extraction into exclusion list
+# rgr_opt: String of options (besides thread-number) to pass-through exclusively to NCO regridder, e.g., 
+#          ncclimo -m clm2 ... -R col_nm=lndgrid -r map.nc ...
+# thr_nbr: Thread number to use in NCO regridder, '-t 1' for one thread, '-t 2' for two threads...
+
+# Set script name and run directory
+drc_pwd=`pwd` # [sng] Run directory
+nco_version=$(ncks --version 2>&1 >/dev/null | grep NCO | awk '{print $5}')
+spt_nm=`basename ${0}` # [sng] Script name
+spt_pid=$$ # [nbr] Script PID (process ID)
+
+# When running in a terminal window (not in a non-interactive batch queue)...
+if [ -n "${TERM}" ]; then
+    # Set fonts for legibility
+    fnt_nrm=`tput sgr0` # Normal
+    fnt_bld=`tput bold` # Bold
+    fnt_rvr=`tput smso` # Reverse
+fi # !TERM
+    
+# Defaults for command-line options and some derived variables
+# Modify these defaults to save typing later
+bnd_nm='nbnd' # [sng] Bounds dimension name (e.g., 'nbnd', 'tbnd')
+clm_md='scd' # [sng] Climatology mode ('scd' or 'sdd' as per above)
+caseid='' # [sng] Case ID
+caseid_xmp='famipc5_ne30_v0.3_00003' # [sng] Case ID for examples
+cf_flg='Yes' # [sng] Produce CF climatology attribute?
+lnk_flg='Yes' # [sng] Link ACME-climo to AMWG-climo filenames
+dbg_lvl=0 # [nbr] Debugging level
+drc_in='' # [sng] Input file directory
+drc_in_xmp="${DATA}/ne30/raw" # [sng] Input file directory for examples
+drc_in_mps="${DATA}/mpas/raw" # [sng] Input file directory for MPAS examples
+drc_out='' # [sng] Output file directory
+drc_out_xmp="${DATA}/ne30/clm" # [sng] Output file directory for examples
+drc_out_mps="${DATA}/mpas/clm" # [sng] Output file directory for MPAS examples
+drc_rgr='' # [sng] Regridded file directory
+drc_rgr_xmp="${DATA}/ne30/rgr" # [sng] Regrid file directory for examples
+fml_nm='' # [sng] Family name (i.e., nickname, e.g., 'amip', 'control', 'experiment')
+gaa_sng="--gaa climo_script=${spt_nm} --gaa climo_hostname=${HOSTNAME} --gaa climo_version=${nco_version}" # [sng] Global attributes to add
+hdr_pad='1000' # [B] Pad at end of header section
+hst_nm='h0' # [sng] History volume (e.g., 'h0', 'h1', 'h')
+mdl_nm='cam' # [sng] Model name (e.g., 'cam', 'cam2', 'cice', 'cism', 'clm', 'clm2', 'ocn')
+mdl_typ='cesm' # [sng] Model type ('cesm', 'mpas') (for filenames and regridding)
+mpi_flg='No' # [sng] Parallelize over nodes
+nco_opt='--no_tmp_fl' # [sng] NCO options (e.g., '-7 -D 1 -L 1')
+nd_nbr=1 # [nbr] Number of nodes
+par_opt='' # [sng] Parallel options to shell
+par_typ='bck' # [sng] Parallelism type
+rgr_map='' # [sng] Regridding map
+#rgr_map="${DATA}/maps/map_ne30np4_to_fv129x256_aave.20150901.nc"
+#rgr_map="${DATA}/maps/map_ne30np4_to_fv257x512_bilin.20150901.nc"
+#rgr_map="${DATA}/maps/map_ne120np4_to_fv257x512_aave.20150901.nc"
+#rgr_map="${DATA}/maps/map_ne120np4_to_fv801x1600_bilin.20150901.nc"
+rgr_opt='' # [sng] Regridding options (e.g., '--rgr col_nm=lndgrid', '--rgr col_nm=nCells')
+thr_nbr=2 # [nbr] Thread number for regridder
+#var_lst='FSNT,AODVIS' # [sng] Variables to process (empty means all)
+var_lst='' # [sng] Variables to process (empty means all)
+yr_srt='1980' # [yr] Start year
+yr_end='1983' # [yr] End year
+
+function fnc_usg_prn { # NB: dash supports fnc_nm (){} syntax, not function fnc_nm{} syntax
+    # Print usage
+    printf "\nQuick documentation for ${fnt_bld}${spt_nm}${fnt_nrm} (read script for more thorough explanations)\n\n"
+    printf "${fnt_rvr}Basic usage:${fnt_nrm} ${fnt_bld}$spt_nm -c caseid -s yr_srt -e yr_end -i drc_in -o drc_out -r rgr_map${fnt_nrm}\n\n"
+    echo "Command-line options:"
+    echo "${fnt_rvr}-a${fnt_nrm} ${fnt_bld}clm_md${fnt_nrm}   Annual climatology mode (default ${fnt_bld}${clm_md}${fnt_nrm})"
+    echo "${fnt_rvr}-b${fnt_nrm} ${fnt_bld}bnd_nm${fnt_nrm}   Bounds dimension name (default ${fnt_bld}${bnd_nm}${fnt_nrm})"
+    echo "${fnt_rvr}-c${fnt_nrm} ${fnt_bld}caseid${fnt_nrm}   Case ID string (default ${fnt_bld}${caseid}${fnt_nrm})"
+    echo "${fnt_rvr}-d${fnt_nrm} ${fnt_bld}dbg_lvl${fnt_nrm}  Debugging level (default ${fnt_bld}${dbg_lvl}${fnt_nrm})"
+    echo "${fnt_rvr}-e${fnt_nrm} ${fnt_bld}yr_end${fnt_nrm}   Ending year (default ${fnt_bld}${yr_end}${fnt_nrm})"
+    echo "${fnt_rvr}-f${fnt_nrm} ${fnt_bld}fml_nm${fnt_nrm}   Family name (nickname) (empty means none) (default ${fnt_bld}${fml_nm}${fnt_nrm})"
+    echo "${fnt_rvr}-h${fnt_nrm} ${fnt_bld}hst_nm${fnt_nrm}   History volume name (default ${fnt_bld}${hst_nm}${fnt_nrm})"
+    echo "${fnt_rvr}-i${fnt_nrm} ${fnt_bld}drc_in${fnt_nrm}   Input directory (default ${fnt_bld}${drc_in}${fnt_nrm})"
+    echo "${fnt_rvr}-l${fnt_nrm} ${fnt_bld}lnk_flg${fnt_nrm}  Link ACME-climo to AMWG-climo filenames (default ${fnt_bld}${lnk_flg}${fnt_nrm})"
+    echo "${fnt_rvr}-m${fnt_nrm} ${fnt_bld}mdl_nm${fnt_nrm}   Model name (default ${fnt_bld}${mdl_nm}${fnt_nrm})"
+    echo "${fnt_rvr}-n${fnt_nrm} ${fnt_bld}nco_opt${fnt_nrm}  NCO options (empty means none) (default ${fnt_bld}${nco_opt}${fnt_nrm})"
+    echo "${fnt_rvr}-O${fnt_nrm} ${fnt_bld}drc_rgr${fnt_nrm}  Regridded directory (default ${fnt_bld}${drc_rgr}${fnt_nrm})"
+    echo "${fnt_rvr}-o${fnt_nrm} ${fnt_bld}drc_out${fnt_nrm}  Output directory (default ${fnt_bld}${drc_out}${fnt_nrm})"
+    echo "${fnt_rvr}-p${fnt_nrm} ${fnt_bld}par_typ${fnt_nrm}  Parallelism type (default ${fnt_bld}${par_typ}${fnt_nrm})"
+    echo "${fnt_rvr}-r${fnt_nrm} ${fnt_bld}rgr_map${fnt_nrm}  Regridding map (empty means none) (default ${fnt_bld}${rgr_map}${fnt_nrm})"
+    echo "${fnt_rvr}-R${fnt_nrm} ${fnt_bld}rgr_opt${fnt_nrm}  Regridding options (empty means none) (default ${fnt_bld}${rgr_opt}${fnt_nrm})"
+    echo "${fnt_rvr}-t${fnt_nrm} ${fnt_bld}thr_nbr${fnt_nrm}  Thread number for regridder (default ${fnt_bld}${thr_nbr}${fnt_nrm})"
+    echo "${fnt_rvr}-s${fnt_nrm} ${fnt_bld}yr_srt${fnt_nrm}   Starting year (default ${fnt_bld}${yr_srt}${fnt_nrm})"
+    echo "${fnt_rvr}-v${fnt_nrm} ${fnt_bld}var_lst${fnt_nrm}  Variable list (empty means all) (default ${fnt_bld}${var_lst}${fnt_nrm})"
+    echo "${fnt_rvr}-x${fnt_nrm} ${fnt_bld}cf_flg${fnt_nrm}   Xperimental switch (for developers) (default ${fnt_bld}${cf_flg}${fnt_nrm})"
+    printf "\n"
+    printf "Examples: ${fnt_bld}$spt_nm -c ${caseid_xmp} -s ${yr_srt} -e ${yr_end} -i ${drc_in_xmp} -o ${drc_out_xmp} ${fnt_nrm}\n"
+    printf "          ${fnt_bld}$spt_nm -c ${caseid_xmp} -s ${yr_srt} -e ${yr_end} -i ${drc_in_xmp} -o ${drc_out_xmp} -r ~zender/data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc ${fnt_nrm}\n"
+    printf "          ${fnt_bld}$spt_nm -c control -m clm2 -s ${yr_srt} -e ${yr_end} -i ${drc_in_xmp} -o ${drc_out_xmp} -r ~zender/data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc ${fnt_nrm}\n"
+    printf "          ${fnt_bld}$spt_nm -c hist    -m ice  -s ${yr_srt} -e ${yr_end} -i ${drc_in_mps} -o ${drc_out_mps} -r ~zender/data/maps/map_oEC60to30_to_t62_bilin.20160301.nc ${fnt_nrm}\n"
+    printf "          ${fnt_bld}$spt_nm -c hist    -m ocn -p mpi -s 1 -e 5 -i ${drc_in_mps} -o ${drc_out_mps} -r ~zender/data/maps/map_oEC60to30_to_t62_bilin.20160301.nc ${fnt_nrm}\n\n"
+    printf "Interactive batch queues on ...\n"
+    printf "cooley: qsub -I -A HiRes_EarthSys --nodecount=1 --time=00:30:00 --jobname=ncclimo\n"
+    printf "cori  : salloc  -A acme --nodes=1 --time=00:30:00 --partition=debug --job-name=ncclimo\n"
+    printf "edison: salloc  -A acme --nodes=1 --time=00:30:00 --partition=debug --job-name=ncclimo\n"
+    printf "rhea  : qsub -I -A CLI115 -V -l nodes=1 -l walltime=00:30:00 -N ncclimo\n"
+    printf "rhea  : qsub -I -A CLI115 -V -l nodes=1 -l walltime=00:30:00 -lpartition=gpu -N ncclimo # Bigmem\n\n"
+#    echo "3-yrs  ne30: ncclimo -c famipc5_ne30_v0.3_00003 -s 1980 -e 1982 -i /lustre/atlas1/cli115/world-shared/mbranst/famipc5_ne30_v0.3_00003-wget-test -o ${DATA}/ne30/clm -r ~zender/data/maps/map_ne30np4_to_fv129x256_aave.20150901.nc > ~/ncclimo.out 2>&1 &"
+#    printf "3-yrs ne120: ncclimo -p mpi -c famipc5_ne120_v0.3_00003 -s 1980 -e 1982 -i /lustre/atlas1/cli115/world-shared/mbranst/famipc5_ne120_v0.3_00003-wget-test -o ${DATA}/ne120/clm -r ~zender/data/maps/map_ne120np4_to_fv257x512_aave.20150901.nc > ~/ncclimo.out 2>&1 &\n\n"
+    exit 1
+} # end fnc_usg_prn()
+
+function trim_leading_zeros {
+    # Purpose: Trim leading zeros from string representing an integer
+    # Why, you ask? Because Bash treats zero-padded integers as octal!
+    # This is surprisingly hard to workaround
+    # My workaround is to remove leading zeros prior to arithmetic
+    # Usage: trim_leading zeros ${sng}
+    sng_trm=${1} # [sng] Trimmed string
+    # Use Bash 2.X pattern matching to remove up to three leading zeros, one at a time
+    sng_trm=${sng_trm##0} # NeR98 p. 99
+    sng_trm=${sng_trm##0}
+    sng_trm=${sng_trm##0}
+    # If all zeros removed, replace with single zero
+    if [ ${sng_trm} = '' ]; then 
+	sng_trm='0'
+    fi # endif
+} # end trim_leading_zeros()
+
+get_spt_drc () {
+# SMB (20150814):
+# Get calling script location to call other utilities in the PreAndPostProcessingScripts package
+# Resolve symlinks in case script is linked elsewhere with technique from
+# http://www.ostricher.com/2014/10/the-right-way-to-get-the-directory-of-a-bash-script
+    spt_src="${BASH_SOURCE[0]}"
+    # If ${spt_src} is a symlink, resolve it
+    while [ -h "${spt_src}" ]; do
+	spt_drc="$(cd -P "$(dirname "${spt_src}")" && pwd)"
+        spt_src="$(readlink "${spt_src}")"
+        # Resolve relative symlinks (no initial "/") against symlink base directory
+        [[ ${spt_src} != /* ]] && spt_src="${spt_drc}/${spt_src}"
+    done
+    spt_drc="$(cd -P "$(dirname "${spt_src}")" && pwd)"
+    echo ${spt_drc}
+} # end get_spt_drc()
+
+# Check argument number and complain accordingly
+arg_nbr=$#
+#printf "\ndbg: Number of arguments: ${arg_nbr}"
+if [ ${arg_nbr} -eq 0 ]; then
+  fnc_usg_prn
+fi # !arg_nbr
+
+# Parse command-line options:
+# http://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options
+# http://tuxtweaks.com/2014/05/bash-getopts
+cmd_ln="${spt_nm} ${@}"
+while getopts :a:b:c:d:e:f:h:i:l:m:n:O:o:p:R:r:s:t:v:x: OPT; do
+    case ${OPT} in
+	a) clm_md=${OPTARG} ;; # Climatology mode
+	b) bnd_nm=${OPTARG} ;; # Bounds dimension name
+	c) caseid=${OPTARG} ;; # CASEID
+	d) dbg_lvl=${OPTARG} ;; # Debugging level
+	e) yr_end=${OPTARG} ;; # End year
+	f) fml_nm=${OPTARG} ;; # Family name
+	h) hst_nm=${OPTARG} ;; # History tape name
+	i) drc_in=${OPTARG} ;; # Input directory
+	l) lnk_flg=${OPTARG} ;; # Link ACME to AMWG name
+	m) mdl_nm=${OPTARG} ;; # Model name
+	n) nco_opt=${OPTARG} ;; # NCO options
+	o) drc_out_usr=${OPTARG} ;; # Output directory
+	O) drc_rgr_usr=${OPTARG} ;; # Regridded directory
+	p) par_typ=${OPTARG} ;; # Parallelism type
+	R) rgr_opt=${OPTARG} ;; # Regridding options
+	r) rgr_map=${OPTARG} ;; # Regridding map
+	s) yr_srt=${OPTARG} ;; # Start year
+	t) thr_usr=${OPTARG} ;; # Thread number
+	v) var_lst=${OPTARG} ;; # Variables
+	x) cf_flg=${OPTARG} ;; # CF annotation
+	\?) # Unrecognized option
+	    printf "\nERROR: Option ${fnt_bld}-$OPTARG${fnt_nrm} not allowed"
+	    fnc_usg_prn ;;
+    esac
+done
+shift $((OPTIND-1)) # Advance one argument
+
+# Derived variable
+if [ -n "${drc_out_usr}" ]; then
+    # Fancy %/ syntax removes trailing slash (e.g., from $TMPDIR)
+    drc_out="${drc_out_usr%/}"
+fi # !drc_out_usr
+if [ -n "${drc_rgr_usr}" ]; then 
+    drc_rgr="${drc_rgr_usr%/}"
+else 
+    drc_rgr="${drc_out%/}"
+fi # !drc_rgr_usr
+
+# Determine first full year
+trim_leading_zeros ${yr_srt}
+yr_srt_rth=${sng_trm}
+yyyy_srt=`printf "%04d" ${yr_srt_rth}`
+let yr_srtm1=${yr_srt_rth}-1
+trim_leading_zeros ${yr_end}
+yr_end_rth=${sng_trm}
+yyyy_end=`printf "%04d" ${yr_end_rth}`
+let yr_endm1=${yr_end_rth}-1
+let yr_nbr=${yr_end_rth}-${yr_srt_rth}+1
+
+# Derived variables
+out_nm=${caseid}
+if [ "${caseid}" = 'hist' ]; then
+    mdl_typ='mpas'
+fi # !caseid
+if [ "${mdl_typ}" = 'mpas' ]; then
+    out_nm="mpas_${mdl_nm}"
+fi # !mdl_typ
+if [ -n "${fml_nm}" ]; then 
+    out_nm="${fml_nm}"
+fi # !fml_nm
+if [ "${mdl_nm}" = 'cam2' ]; then
+    bnd_nm='tbnd'
+fi # !caseid
+# http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
+# http://stackoverflow.com/questions/17420994/bash-regex-match-string
+if [[ "${caseid}" =~ ^(.*)([0-9][0-9][0-9][0-9][01][0-9].nc.?)$ ]]; then
+    mdl_typ='yyyymm'
+    bs_nm="${BASH_REMATCH[1]}"
+    bs_nm="$(basename ${bs_nm})"
+    bs_nm="${bs_nm%.*}"
+    bs_nm="${bs_nm%_*}"
+    out_nm=${bs_nm}
+    bs_sfx="${caseid#*.}"
+fi # !caseid
+if [ "${mdl_typ}" = 'yyyymm' ]; then
+    printf "Dataset type is generic with YYYYMM. Filenames constructed as ${bs_nm}_YYYYMM.${bs_sfx}\n"
+else # !mdl_typ
+    printf "Dataset type is not generic.\n"
+fi # !mdl_typ
+
+if [ -n "${gaa_sng}" ]; then
+    if [ "${yr_nbr}" -gt 1 ] ; then
+	yrs_avg_sng="${yr_srt}-${yr_end}"
+    else
+	yrs_avg_sng="${yr_srt}"
+    fi # !yr_nbr
+    gaa_sng="${gaa_sng} --gaa yrs_averaged=${yrs_avg_sng}"
+    nco_opt="${nco_opt} ${gaa_sng}"
+fi # !var_lst
+if [ -n "${var_lst}" ]; then
+    nco_opt="${nco_opt} -v ${var_lst}"
+fi # !var_lst
+if [ -n "${hdr_pad}" ]; then
+    nco_opt="${nco_opt} --hdr_pad=${hdr_pad}"
+fi # !hdr_pad
+if [ "${par_typ}" = 'bck' ]; then 
+    par_opt=' &'
+    par_opt_cf=''
+elif [ "${par_typ}" = 'mpi' ]; then 
+    mpi_flg='Yes'
+    par_opt=' &'
+    par_opt_cf=''
+    if [ -n "${UVCDAT_SETUP_PATH}" ]; then
+	printf "${spt_nm}: UVCDAT has been initialized in the shell running this job, and MPI-mode parallelization of ${spt_nm} is requested. Unfortunately UVCDAT's environment and the MPI-mode of ${spt_nm} do not play well together. The Workflow group is working toward a solution. The current workarounds are 1) do not use MPI-mode when UVCDAT is loaded or 2) do not initialize UVCDAT when invoking MPI-mode.\n"
+    fi # !UVCDAT_SETUP_PATH
+fi # !par_typ
+if [ -n "${rgr_map}" ]; then 
+    if [ ! -f "${rgr_map}" ]; then
+	echo "ERROR: Unable to find specified regrid map ${rgr_map}"
+	echo "HINT: Supply the full path-name for the regridding map"
+	exit 1
+    fi # ! -f
+    rgr_opt="${rgr_opt} --map ${rgr_map}"
+fi # !rgr_map
+if [ -n "${thr_usr}" ]; then 
+    thr_nbr="${thr_usr}"
+fi # !thr_usr
+yyyy_clm_srt=${yyyy_srt}
+yyyy_clm_end=${yyyy_end}
+yyyy_clm_srt_dec=${yyyy_srt}
+yyyy_clm_end_dec=${yyyy_end}
+mm_ann_srt='01' # [idx] First month used in annual climatology
+mm_ann_end='12' # [idx] Last  month used in annual climatology
+mm_djf_srt='01' # [idx] First month used in DJF climatology
+mm_djf_end='12' # [idx] Last  month used in DJF climatology
+yr_cln=${yr_nbr} # [nbr] Calendar years in climatology
+if [ ${clm_md} = 'scd' ]; then 
+    yyyy_clm_srt_dec=`printf "%04d" ${yr_srtm1}`
+    yyyy_clm_end_dec=`printf "%04d" ${yr_endm1}`
+    mm_ann_srt='12'
+    mm_ann_end='11'
+    mm_djf_srt='12'
+    mm_djf_end='02'
+    let yr_cln=${yr_cln}+1
+fi # !scd
+
+if [ "${mpi_flg}" = 'Yes' ]; then
+    if [ -n "${COBALT_NODEFILE}" ]; then 
+	nd_fl="${COBALT_NODEFILE}"
+    elif [ -n "${PBS_NODEFILE}" ]; then 
+	nd_fl="${PBS_NODEFILE}"
+    elif [ -n "${SLURM_NODELIST}" ]; then 
+	# SLURM returns compressed lists (e.g., "nid00[076-078,559-567]")
+	# Convert this to file with uncompressed list (like Cobalt, PBS)
+	# http://www.ceci-hpc.be/slurm_faq.html#Q12
+	nd_fl='ncclimo.slurm_nodelist'
+	nd_lst=`scontrol show hostname ${SLURM_NODELIST}`
+	echo ${nd_lst} > ${nd_fl}
+    else
+	echo "ERROR: MPI job unable to find node list"
+	echo "HINT: ${spt_nm} uses first node list found in \$COBALT_NODEFILE (= \"${COBALT_NODEFILE}\"), \$PBS_NODEFILE (= \"${PBS_NODEFILE}\"), \$SLURM_NODELIST (= \"${SLURM_NODELIST}\")"
+	exit 1
+    fi # !PBS
+    if [ -n "${nd_fl}" ]; then 
+	# NB: nodes are 0-based, e.g., [0..11]
+	nd_idx=0
+	for nd in `cat ${nd_fl} | uniq` ; do
+	    nd_nm[${nd_idx}]=${nd}
+	    let nd_idx=${nd_idx}+1
+	done # !nd
+	nd_nbr=${#nd_nm[@]}
+	for ((clm_idx=1;clm_idx<=17;clm_idx++)); do
+	    case "${HOSTNAME}" in 
+		# 20160502: Remove tasks-per-node limits (ntasks, npernode) so round-robin algorithm can schedule multiple jobs on same node
+		cori* | edison* | nid* )
+		    # 20160502: Non-interactive batch jobs at NERSC return HOSTNAME as nid*, not cori* or edison*
+		    # NB: NERSC staff says srun automatically assigns to unique nodes even without "-L $node" argument?
+ 		    cmd_mpi[${clm_idx}]="srun --nodelist ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} --nodes=1" ; ;; # NERSC
+# 		    cmd_mpi[${clm_idx}]="srun --nodelist ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} --nodes=1 --ntasks=1" ; ;; # NERSC
+		hopper* )
+		    # NB: NERSC migrated from aprun to srun in 201601. Hopper commands will soon be deprecated.
+		    cmd_mpi[${clm_idx}]="aprun -L ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} -n 1" ; ;; # NERSC
+		* )
+		    cmd_mpi[${clm_idx}]="mpirun -H ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} -n 1" ; ;; # Other (Cobalt)
+#		    cmd_mpi[${clm_idx}]="mpirun -H ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} -npernode 1 -n 1" ; ;; # Other
+	    esac # !HOSTNAME
+	done # !clm_idx
+	if [ -n "${SLURM_NODELIST}" ]; then 
+	    /bin/rm -f ${nd_fl}
+	fi # !SLURM
+    else # !nd_fl
+	mpi_flg='No'
+	for ((clm_idx=1;clm_idx<=17;clm_idx++)); do
+	    cmd_mpi[${clm_idx}]=''
+	done # !clm_idx
+    fi # !nd_fl
+    if [ -z "${thr_usr}" ]; then 
+	if [ -n "${PBS_NUM_PPN}" ]; then
+#	NB: use export OMP_NUM_THREADS when thr_nbr > 8
+#	thr_nbr=${PBS_NUM_PPN}
+	    thr_nbr=$((PBS_NUM_PPN > 8 ? 8 : PBS_NUM_PPN))
+	fi # !pbs
+    fi # !thr_usr
+fi # !mpi
+
+# Print initial state
+if [ ${dbg_lvl} -ge 1 ]; then
+    printf "dbg: bnd_nm   = ${bnd_nm}\n"
+    printf "dbg: caseid   = ${caseid}\n"
+    printf "dbg: cf_flg   = ${cf_flg}\n"
+    printf "dbg: clm_md   = ${clm_md}\n"
+    printf "dbg: dbg_lvl  = ${dbg_lvl}\n"
+    printf "dbg: drc_in   = ${drc_in}\n"
+    printf "dbg: drc_out  = ${drc_out}\n"
+    printf "dbg: drc_pwd  = ${drc_pwd}\n"
+    printf "dbg: drc_rgr  = ${drc_rgr}\n"
+    printf "dbg: fml_nm   = ${fml_nm}\n"
+    printf "dbg: gaa_sng  = ${gaa_sng}\n"
+    printf "dbg: hdr_pad  = ${hdr_pad}\n"
+    printf "dbg: hst_nm   = ${hst_nm}\n"
+    printf "dbg: lnk_flg  = ${lnk_flg}\n"
+    printf "dbg: mdl_nm   = ${mdl_nm}\n"
+    printf "dbg: mpi_flg  = ${mpi_flg}\n"
+    printf "dbg: nco_opt  = ${nco_opt}\n"
+    printf "dbg: nd_nbr   = ${nd_nbr}\n"
+    printf "dbg: par_typ  = ${par_typ}\n"
+    printf "dbg: rgr_map  = ${rgr_map}\n"
+    printf "dbg: rgr_sfx  = ${rgr_sfx}\n"
+    printf "dbg: thr_nbr  = ${thr_nbr}\n"
+    printf "dbg: var_lst  = ${var_lst}\n"
+    printf "dbg: yyyy_end = ${yyyy_end}\n"
+    printf "dbg: yyyy_srt = ${yyyy_srt}\n"
+fi # !dbg
+if [ ${dbg_lvl} -ge 2 ]; then
+    printf "dbg: yyyy_srt   = ${yyyy_srt}\n"
+    printf "dbg: yr_srt_rth = ${yr_srt_rth}\n"
+    printf "dbg: yr_srtm1   = ${yr_srtm1}\n"
+    printf "dbg: yr_endm1   = ${yr_endm1}\n"
+    if [ ${mpi_flg} = 'Yes' ]; then
+	for ((nd_idx=0;nd_idx<${nd_nbr};nd_idx++)); do
+	    printf "dbg: nd_nm[${nd_idx}] = ${nd_nm[${nd_idx}]}\n"
+	done # !nd
+    fi # !mpi
+fi # !dbg
+
+# Create output directory
+mkdir -p ${drc_out}
+mkdir -p ${drc_rgr}
+
+# Human-readable summary
+date_srt=$(date +"%s")
+if [ ${dbg_lvl} -ge 0 ]; then
+    printf "Climatology generation invoked with command:\n"
+    echo "${cmd_ln}"
+fi # !dbg
+printf "Started climatology generation for dataset ${caseid} at `date`.\n"
+printf "Climatology from ${yr_nbr} years of contiguous data crossing ${yr_cln} calendar years from YYYYMM = ${yyyy_clm_srt_dec}${mm_ann_srt} to ${yyyy_end}${mm_ann_end}.\n"
+if [ ${clm_md} = 'scd' ]; then 
+    printf "Winter statistics based on seasonally contiguous December (scd-mode): DJF sequences are consecutive months that cross calendar-year boundaries.\n"
+else
+    printf "Winter statistics based on seasonally discontiguous December (sdd-mode): DJF sequences comprise three months from the same calendar year.\n"
+fi # !scd
+if [ ${cf_flg} = 'Yes' ]; then 
+    printf "Annotation for CF climatology attribute and climatology_bounds variable will be performed.\n"
+else
+    printf "Annotation for CF climatology attribute and climatology_bounds variable will not be performed.\n"
+fi # !cf
+if [ -n "${rgr_map}" ]; then 
+    printf "This climatology will be regridded.\n"
+else
+    printf "This climatology will not be regridded.\n"
+fi # !rgr
+printf "NCO version is ${nco_version}\n"
+
+# Block 1: Climatological monthly means
+# Block 1 Loop 1: Generate, check, and store (but do not yet execute) monthly commands
+printf "Generating climatology...\n"
+clm_idx=0
+for mth in {01..12}; do
+    let clm_idx=${clm_idx}+1
+    MM=`printf "%02d" ${clm_idx}`
+    yr_fl=''
+    for yr in `seq ${yyyy_srt} ${yyyy_end}`; do
+	YYYY=`printf "%04d" ${yr}`
+	if [ ${mdl_typ} = 'cesm' ]; then
+	    yr_fl="${yr_fl} ${caseid}.${mdl_nm}.${hst_nm}.${YYYY}-${MM}.nc"
+	elif [ ${mdl_typ} = 'mpas' ]; then # Use MPAS not CESM conventions
+	    yr_fl="${yr_fl} ${caseid}.${mdl_nm}.${YYYY}-${MM}-01_00.00.00.nc"
+	elif [ ${mdl_typ} = 'yyyymm' ]; then # Generate from caseid + YYYYMM
+	    yr_fl="${yr_fl} ${bs_nm}_${YYYY}${MM}.${bs_sfx}"
+	fi # !cesm
+    done # !yr
+    if [ ${clm_md} = 'scd' ] && [ ${MM} = '12' ]; then 
+	yr_fl=''
+	for yr in `seq ${yr_srtm1} ${yr_endm1}`; do
+	    YYYY=`printf "%04d" ${yr}`
+	    if [ ${mdl_typ} = 'cesm' ]; then
+		yr_fl="${yr_fl} ${caseid}.${mdl_nm}.${hst_nm}.${YYYY}-${MM}.nc"
+	    elif [ ${mdl_typ} = 'mpas' ]; then # Use MPAS not CESM conventions
+		yr_fl="${yr_fl} ${caseid}.${mdl_nm}.${YYYY}-${MM}-01_00.00.00.nc"
+	    elif [ ${mdl_typ} = 'yyyymm' ]; then # Generate from caseid + YYYYMM
+		yr_fl="${yr_fl} ${bs_nm}_${YYYY}${MM}.${bs_sfx}"
+	    fi # !cesm
+	done # !yr
+	yyyy_clm_srt=${yyyy_clm_srt_dec}
+	yyyy_clm_end=${yyyy_clm_end_dec}
+    fi # !scd
+    for fl_in in ${yr_fl} ; do
+	if [ ! -f "${drc_in}/${fl_in}" ]; then
+	    echo "ERROR: Unable to find required input file ${drc_in}/${fl_in}"
+	    echo "HINT: All files implied to exist by the climatology bounds (start/end year/month) must be in ${drc_in} before ${spt_nm} will proceed"
+	    exit 1
+	fi # ! -f
+    done # !fl_in
+    fl_out[${clm_idx}]="${drc_out}/${out_nm}_${MM}_${yyyy_clm_srt}${MM}_${yyyy_clm_end}${MM}_climo.nc"
+    cmd_clm[${clm_idx}]="${cmd_mpi[${clm_idx}]} ncra --cb -O ${nco_opt} -p ${drc_in} ${yr_fl} ${fl_out[${clm_idx}]}"
+done # !mth
+
+# Monthly output filenames constructed above; specify remaining (seasonal, annual) output names
+fl_out[13]="${drc_out}/${out_nm}_MAM_${yyyy_srt}03_${yyyy_end}05_climo.nc"
+fl_out[14]="${drc_out}/${out_nm}_JJA_${yyyy_srt}06_${yyyy_end}08_climo.nc"
+fl_out[15]="${drc_out}/${out_nm}_SON_${yyyy_srt}09_${yyyy_end}11_climo.nc"
+fl_out[16]="${drc_out}/${out_nm}_DJF_${yyyy_clm_srt_dec}${mm_djf_srt}_${yyyy_end}${mm_djf_end}_climo.nc"
+fl_out[17]="${drc_out}/${out_nm}_ANN_${yyyy_clm_srt_dec}${mm_ann_srt}_${yyyy_end}${mm_ann_end}_climo.nc"
+# Derive all seventeen regridded and AMWG names from output names
+for ((clm_idx=1;clm_idx<=17;clm_idx++)); do
+    fl_amwg[${clm_idx}]=`expr match "${fl_out[${clm_idx}]}" '\(.*\)_.*_.*_climo.nc'` # Prune _YYYYYMM_YYYYMM_climo.nc
+    fl_amwg[${clm_idx}]="${fl_amwg[${clm_idx}]}_climo.nc" # Replace with _climo.nc
+    fl_amwg[${clm_idx}]="${fl_amwg[${clm_idx}]/${drc_out}\//}" # Delete prepended path to ease symlinking
+    if [ -n "${rgr_map}" ]; then
+	fl_rgr[${clm_idx}]="${fl_out[${clm_idx}]/${drc_out}/${drc_rgr}}"
+	if [ "${drc_out}" = "${drc_rgr}" ]; then 
+	    # Append geometry suffix to regridded files in same directory as native climo
+	    # http://tldp.org/LDP/abs/html/string-manipulation.html
+	    dfl_sfx='rgr'
+	    rgr_sfx=`expr match "${rgr_map}" '.*_to_\(.*\).nc'`
+	    if [ "${#rgr_sfx}" -eq  0 ]; then
+		printf "${spt_nm}: WARNING Unable to extract geometric suffix from mapfile, will suffix regridded files with \"${dfl_sfx}\" instead\n"
+		rgr_sfx=${dfl_sfx}
+	    else
+		yyyymmdd_sng=`expr match "${rgr_sfx}" '.*\(\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)'` # Find YYYYYMMDD
+		if [ "${#yyyymmdd_sng}" -ne  0 ]; then
+		    rgr_sfx=${rgr_sfx%%${yyyymmdd_sng}} # Delete YYYYYMMDD
+		fi # !strlen
+	    fi # !strlen
+	    #    rgr_sfx=`expr match "${rgr_sfx}" '\(.*\)\.[0-9][0-9][0-9][0-9][0-9][0-9]'` # 
+	    fl_rgr[${clm_idx}]="${fl_rgr[${clm_idx}]/.nc/_${rgr_sfx}.nc}"
+	fi # !drc_rgr
+    fi # !rgr_map
+done # !clm_idx
+    
+# Block 1 Loop 2: Execute and/or echo monthly climatology commands
+for ((clm_idx=1;clm_idx<=12;clm_idx++)); do
+    printf "Climatological monthly mean for month ${clm_idx} ...\n"
+    if [ ${dbg_lvl} -ge 1 ]; then
+	echo ${cmd_clm[${clm_idx}]}
+    fi # !dbg
+    if [ ${dbg_lvl} -le 1 ]; then
+	if [ -z "${par_opt}" ]; then
+	    eval ${cmd_clm[${clm_idx}]}
+	    if [ $? -ne 0 ]; then
+		printf "${spt_nm}: ERROR monthly climo cmd_clm[${clm_idx}] failed. Debug this:\n${cmd_clm[${clm_idx}]}\n"
+		exit 1
+	    fi # !err
+	else # !par_opt
+	    eval ${cmd_clm[${clm_idx}]} ${par_opt} # eval always returns 0 on backgrounded processes
+	    clm_pid[${clm_idx}]=$!
+	    # Potential alternatives to eval:
+#	eval "${cmd_clm[${clm_idx}]}" # borken
+#       ${cmd_clm[${clm_idx}]} # borken
+#       "${cmd_clm[${clm_idx}]}" # borken
+#	exec "${cmd_clm[${clm_idx}]}" # borken
+#	$(${cmd_clm[${clm_idx}]}) # borken
+#	$("${cmd_clm[${clm_idx}]}") # works (when & inside cmd quotes)
+	fi # !par_opt
+    fi # !dbg
+done # !clm_idx
+if [ -n "${par_opt}" ]; then
+    for ((clm_idx=1;clm_idx<=12;clm_idx++)); do
+	wait ${clm_pid[${clm_idx}]}
+	if [ $? -ne 0 ]; then
+	    printf "${spt_nm}: ERROR monthly climo cmd_clm[${clm_idx}] failed. Debug this:\n${cmd_clm[${clm_idx}]}\n"
+	    exit 1
+	fi # !err
+    done # !clm_idx
+fi # !par_opt
+wait
+
+# Block 1: Loop 4: Regrid first twelve files. Load-balance by using idle nodes (nodes not used for seasonal climatologies).
+if [ -n "${rgr_map}" ]; then 
+    printf "Regrid monthly data...\n"
+    for ((clm_idx=1;clm_idx<=12;clm_idx++)); do
+	# NB: Months, seasons, files are 1-based ([1..12], [13..16], [1..17]), nodes are 0-based ([0..11])
+	let nd_idx=$(((clm_idx-1+4) % nd_nbr))
+	if [ ${nd_idx} -lt 4 ]; then
+	    let nd_idx=${nd_idx}+4
+	fi # !nd
+	cmd_rgr[${clm_idx}]="${cmd_mpi[${nd_idx}]} ncks -t ${thr_nbr} -O ${nco_opt} ${rgr_opt} ${fl_out[${clm_idx}]} ${fl_rgr[${clm_idx}]}"
+	if [ "${mdl_typ}" = 'mpas' ]; then
+	    cmd_rgr[${clm_idx}]="${cmd_mpi[${nd_idx}]} ncremap -C -u .pid${spt_pid}.climo.${clm_idx}.tmp -P mpas -t ${thr_nbr} -m ${rgr_map} -i ${fl_out[${clm_idx}]} -o ${fl_rgr[${clm_idx}]}"
+	fi # !mdl_typ
+	if [ ${dbg_lvl} -ge 1 ]; then
+	    echo ${cmd_rgr[${clm_idx}]}
+	fi # !dbg
+	if [ ${dbg_lvl} -le 1 ]; then
+	    if [ -z "${par_opt}" ]; then
+		eval ${cmd_rgr[${clm_idx}]}
+		if [ $? -ne 0 ]; then
+		    printf "${spt_nm}: ERROR monthly regrid cmd_rgr[${clm_idx}] failed. Debug this:\n${cmd_rgr[${clm_idx}]}\n"
+		    exit 1
+		fi # !err
+	    else # !par_opt
+		eval ${cmd_rgr[${clm_idx}]} ${par_opt}
+		rgr_pid[${clm_idx}]=$!
+	    fi # !par_opt
+	fi # !dbg
+    done 
+    # Start seasonal means first, then wait() for monthly regridding to finish
+fi # !rgr_map
+
+# Block 2: Climatological seasonal means
+# Block 2 Loop 1: Generate seasonal commands
+printf "Climatological seasonal means...\n"
+cmd_clm[13]="${cmd_mpi[13]} ncra --cb -O -w 31,30,31 ${nco_opt} ${fl_out[3]} ${fl_out[4]} ${fl_out[5]} ${fl_out[13]}"
+cmd_clm[14]="${cmd_mpi[14]} ncra --cb -O -w 30,31,31 ${nco_opt} ${fl_out[6]} ${fl_out[7]} ${fl_out[8]} ${fl_out[14]}"
+cmd_clm[15]="${cmd_mpi[15]} ncra --cb -O -w 30,31,30 ${nco_opt} ${fl_out[9]} ${fl_out[10]} ${fl_out[11]} ${fl_out[15]}"
+cmd_clm[16]="${cmd_mpi[16]} ncra --cb -O -w 31,31,28 ${nco_opt} ${fl_out[12]} ${fl_out[1]} ${fl_out[2]} ${fl_out[16]}"
+
+# PMC: next line hacks code to use AMWG weights instead of NCO weights
+#printf "MAJOR KLUDGE: FORCING USE OF AMWG WTS!!!"
+#cmd_clm[13]="${cmd_mpi[13]} ncra -O --no_nrm -w 0.3369565308094025,0.3260869681835175,0.3369565308094025 ${nco_opt} ${fl_out[3]} ${fl_out[4]} ${fl_out[5]} ${fl_out[13]}"
+#cmd_clm[14]="${cmd_mpi[14]} ncra -O --no_nrm -w 0.3260869681835175,0.3369565308094025,0.3369565308094025 ${nco_opt} ${fl_out[6]} ${fl_out[7]} ${fl_out[8]} ${fl_out[14]}"
+#cmd_clm[15]="${cmd_mpi[15]} ncra -O --no_nrm -w 0.32967033,0.34065934,0.32967033 ${nco_opt} ${fl_out[9]} ${fl_out[10]} ${fl_out[11]} ${fl_out[15]}"
+#cmd_clm[16]="${cmd_mpi[16]} ncra -O --no_nrm -w 0.3444444537162781,0.3444444537162781,0.3111111223697662 ${nco_opt} ${fl_out[12]} ${fl_out[1]} ${fl_out[2]} ${fl_out[16]}"
+
+# Block 2 Loop 2: Execute and/or echo seasonal climatology commands
+for ((clm_idx=13;clm_idx<=16;clm_idx++)); do
+    if [ ${dbg_lvl} -ge 1 ]; then
+	echo ${cmd_clm[${clm_idx}]}
+    fi # !dbg
+    if [ ${dbg_lvl} -le 1 ]; then
+	if [ -z "${par_opt}" ]; then
+	    eval ${cmd_clm[${clm_idx}]}
+	    if [ $? -ne 0 ]; then
+		printf "${spt_nm}: ERROR seasonal climo cmd_clm[${clm_idx}] failed. Debug this:\n${cmd_clm[${clm_idx}]}\n"
+		exit 1
+	    fi # !err
+	else # !par_opt
+	    eval ${cmd_clm[${clm_idx}]} ${par_opt}
+	    clm_pid[${clm_idx}]=$!
+	fi # !par_opt
+    fi # !dbg
+done # !clm_idx
+# wait() for monthly regridding, if any, to finish
+if [ -n "${rgr_map}" ]; then 
+    if [ -n "${par_opt}" ]; then
+	for ((clm_idx=1;clm_idx<=12;clm_idx++)); do
+	    wait ${rgr_pid[${clm_idx}]}
+	    if [ $? -ne 0 ]; then
+		printf "${spt_nm}: ERROR monthly regrid cmd_rgr[${clm_idx}] failed. Debug this:\n${cmd_rgr[${clm_idx}]}\n"
+		exit 1
+	    fi # !err
+	done # !clm_idx
+    fi # !par_opt
+fi # !rgr_map
+# wait() for seasonal climatologies to finish
+if [ -n "${par_opt}" ]; then
+    for ((clm_idx=13;clm_idx<=16;clm_idx++)); do
+	wait ${clm_pid[${clm_idx}]}
+	if [ $? -ne 0 ]; then
+	    printf "${spt_nm}: ERROR seasonal climo cmd_clm[${clm_idx}] failed. Debug this:\n${cmd_clm[${clm_idx}]}\n"
+	    exit 1
+	fi # !err
+    done # !clm_idx
+fi # !par_opt
+wait
+
+# Block 2: Loop 4: Regrid seasonal files. Load-balance by using idle nodes (nodes not used for annual mean).
+if [ -n "${rgr_map}" ]; then 
+    printf "Regrid seasonal data...\n"
+    for ((clm_idx=13;clm_idx<=16;clm_idx++)); do
+	let nd_idx=$(((clm_idx-1+4) % nd_nbr))
+	if [ ${nd_idx} -lt 4 ]; then
+	    let nd_idx=${nd_idx}+4
+	fi # !nd
+	cmd_rgr[${clm_idx}]="${cmd_mpi[${nd_idx}]} ncks -t ${thr_nbr} -O ${nco_opt} ${rgr_opt} ${fl_out[${clm_idx}]} ${fl_rgr[${clm_idx}]}"
+	if [ "${mdl_typ}" = 'mpas' ]; then
+	    cmd_rgr[${clm_idx}]="${cmd_mpi[${nd_idx}]} ncremap -C -u .pid${spt_pid}.climo.${clm_idx}.tmp -P mpas -t ${thr_nbr} -m ${rgr_map} -i ${fl_out[${clm_idx}]} -o ${fl_rgr[${clm_idx}]}"
+	fi # !mdl_typ
+	if [ ${dbg_lvl} -ge 1 ]; then
+	    echo ${cmd_rgr[${clm_idx}]}
+	fi # !dbg
+	if [ ${dbg_lvl} -le 1 ]; then
+	    if [ -z "${par_opt}" ]; then
+		eval ${cmd_rgr[${clm_idx}]}
+		if [ $? -ne 0 ]; then
+		    printf "${spt_nm}: ERROR seasonal regrid cmd_rgr[${clm_idx}] failed. Debug this:\n${cmd_rgr[${clm_idx}]}\n"
+		    exit 1
+		fi # !err
+	    else # !par_opt
+		eval ${cmd_rgr[${clm_idx}]} ${par_opt}
+		rgr_pid[${clm_idx}]=$!
+	    fi # !par_opt
+	fi # !dbg
+    done 
+    # Start annual mean first, then wait() for seasonal regridding to finish
+fi # !rgr_map
+
+# Block 3: Climatological annual mean (seventeenth file)
+printf "Climatological annual mean...\n"
+cmd_clm[17]="${cmd_mpi[17]} ncra --c2b -O -w 92,92,91,90 ${nco_opt} ${fl_out[13]} ${fl_out[14]} ${fl_out[15]} ${fl_out[16]} ${fl_out[17]}"
+if [ ${dbg_lvl} -ge 1 ]; then
+    echo ${cmd_clm[17]}
+fi # !dbg
+if [ ${dbg_lvl} -le 1 ]; then
+    if [ -z "${par_opt}" ]; then
+	eval ${cmd_clm[17]}
+	if [ $? -ne 0 ]; then
+	    printf "${spt_nm}: ERROR annual climo cmd_clm[17] failed. Debug this:\n${cmd_clm[17]}\n"
+	    exit 1
+	fi # !err
+    else # !par_opt
+	eval ${cmd_clm[17]} ${par_opt}
+	clm_pid[17]=$!
+    fi # !par_opt
+fi # !dbg
+# wait() for seasonal regridding, if any, to finish
+if [ -n "${rgr_map}" ]; then 
+    if [ -n "${par_opt}" ]; then
+	for ((clm_idx=13;clm_idx<=16;clm_idx++)); do
+	    wait ${rgr_pid[${clm_idx}]}
+	    if [ $? -ne 0 ]; then
+		printf "${spt_nm}: ERROR seasonal regrid cmd_rgr[${clm_idx}] failed. Debug this:\n${cmd_rgr[${clm_idx}]}\n"
+		exit 1
+	    fi # !err
+	done # !clm_idx
+    fi # !par_opt
+fi # !rgr_map
+# wait() for annual climatology to finish
+if [ -n "${par_opt}" ]; then
+    wait ${clm_pid[17]}
+    if [ $? -ne 0 ]; then
+	printf "${spt_nm}: ERROR annual climo cmd_clm[17] failed. Debug this:\n${cmd_clm[17]}\n"
+	exit 1
+    fi # !err
+fi # !par_opt
+
+# Block 5: Regrid climatological annual mean
+if [ -n "${rgr_map}" ]; then 
+    printf "Regrid annual data...\n"
+    for ((clm_idx=17;clm_idx<=17;clm_idx++)); do
+	cmd_rgr[${clm_idx}]="${cmd_mpi[${clm_idx}]} ncks -t ${thr_nbr} -O ${nco_opt} ${rgr_opt} ${fl_out[${clm_idx}]} ${fl_rgr[${clm_idx}]}"
+	if [ "${mdl_typ}" = 'mpas' ]; then
+	    cmd_rgr[${clm_idx}]="${cmd_mpi[${clm_idx}]} ncremap -C -u .pid${spt_pid}.climo.${clm_idx}.tmp -P mpas -t ${thr_nbr} -m ${rgr_map} -i ${fl_out[${clm_idx}]} -o ${fl_rgr[${clm_idx}]}"
+	fi # !mdl_typ
+	if [ ${dbg_lvl} -ge 1 ]; then
+	    echo ${cmd_rgr[${clm_idx}]}
+	fi # !dbg
+	if [ ${dbg_lvl} -le 1 ]; then
+	    # NB: Do not background climatological mean regridding
+	    eval ${cmd_rgr[${clm_idx}]}
+	    if [ $? -ne 0 ]; then
+		printf "${spt_nm}: ERROR annual regrid cmd_rgr[${clm_idx}] failed. Debug this:\n${cmd_rgr[${clm_idx}]}\n"
+		exit 1
+	    fi # !err
+	fi # !dbg
+    done 
+fi # !rgr_map
+
+# Link ACME-climo to AMWG-climo filenames
+# drc_pwd is always fully qualified path but drc_out and drc_rgr may be relative paths
+# Strategy: Start in drc_pwd, cd to drc_rgr, then link so return code comes from ln not cd
+if [ ${lnk_flg} = 'Yes' ]; then
+    printf "Link ACME-climo to AMWG-climo filenames...\n"
+    for ((clm_idx=1;clm_idx<=17;clm_idx++)); do
+	if [ -n "${rgr_map}" ]; then 
+	    cmd_lnk[${clm_idx}]="cd ${drc_pwd};cd ${drc_rgr};ln -s -f ${fl_rgr[${clm_idx}]/${drc_rgr}\//} ${fl_amwg[${clm_idx}]/${drc_rgr}\//}"
+	else
+	    cmd_lnk[${clm_idx}]="cd ${drc_pwd};cd ${drc_out};ln -s -f ${fl_out[${clm_idx}]/${drc_out}\//} ${fl_amwg[${clm_idx}]/${drc_out}\//}"
+	fi # !rgr_map
+	if [ ${dbg_lvl} -ge 1 ]; then
+	    echo ${cmd_lnk[${clm_idx}]}
+	fi # !dbg
+	if [ ${dbg_lvl} -le 1 ]; then
+	    eval ${cmd_lnk[${clm_idx}]}
+	    if [ $? -ne 0 ]; then
+		printf "${spt_nm}: ERROR linking ACME to AMWG filename cmd_lnk[${clm_idx}] failed. Debug this:\n${cmd_lnk[${clm_idx}]}\n"
+		exit 1
+	    fi # !err
+	fi # !dbg
+    done # !clm_idx
+    cd ${drc_pwd}
+fi # !lnk_flg
+    
+date_end=$(date +"%s")
+printf "Completed climatology generation for dataset ${caseid} at `date`.\n"
+date_dff=$((date_end-date_srt))
+echo "Quick plots of climatological annual mean:"
+if [ -n "${rgr_map}" ]; then 
+    echo "ncview ${fl_rgr[17]} &"
+    echo "panoply ${fl_rgr[17]} &"
+else
+    echo "ncview ${fl_out[17]} &"
+    echo "panoply ${fl_out[17]} &"
+fi # !rgr_map    
+echo "Elapsed time $((date_dff/60))m$((date_dff % 60))s"
+
+# PMC: add SMB's Git (SHA1) hash info to climo files
+# Assumes utility to add Git hash resides in ../utils/add_git_hash_to_netcdf_metadata
+for ((clm_idx=1;clm_idx<=17;clm_idx++)); do
+    fl_out_lst="${fl_out_lst} ${fl_out[${clm_idx}]}"
+done
+spt_drc=$(get_spt_drc)
+if [ ${dbg_lvl} -ge 1 ]; then
+    echo "Script is in directory: ${spt_drc}"
+fi # !dbg
+# CSZ: 20150826 disable until less fragile (than relative path) solution is found 
+#cd ${spt_drc}
+# ../utils/add_git_hash_to_netcdf_metadata ${fl_out_lst}
+
+exit 0
diff --git a/data/ncremap b/data/ncremap
index 5ef29b3..63e1b23 100755
--- a/data/ncremap
+++ b/data/ncremap
@@ -44,9 +44,9 @@
 
 # Configure paths at High-Performance Computer Centers (HPCCs) based on ${HOSTNAME}
 if [ -z "${HOSTNAME}" ]; then
-    if [ -f /bin/hostname ] && [ -x /bin/hostname ] ; then
+    if [ -f /bin/hostname ] && [ -x /bin/hostname ]; then
 	export HOSTNAME=`/bin/hostname`
-    elif [ -f /usr/bin/hostname ] && [ -x /usr/bin/hostname ] ; then
+    elif [ -f /usr/bin/hostname ] && [ -x /usr/bin/hostname ]; then
 	export HOSTNAME=`/usr/bin/hostname`
     fi # !hostname
 fi # HOSTNAME
@@ -61,35 +61,85 @@ if [ -z "${DATA}" ]; then
 	* ) DATA='/tmp' ; ;; # Other
     esac # !HOSTNAME
 fi # DATA
-# Ensure batch jobs access correct 'mpirun' (or, on edison, 'aprun') command, netCDF library, and NCO executables and library:
+# Ensure batch jobs access correct 'mpirun' (or, on cori/edison, 'srun') command, netCDF library, and NCO executables and library:
 case "${HOSTNAME}" in 
+    aims* )
+	export PATH='/export/zender1/bin'\:${PATH}
+        export LD_LIBRARY_PATH='/export/zender1/lib'\:${LD_LIBRARY_PATH} ; ;;
     cooley* | cc* | mira* )
 	# http://www.mcs.anl.gov/hs/software/systems/softenv/softenv-intro.html
 	soft add +mvapich2 
         export PBS_NUM_PPN=12 # Spoof PBS on Soft (which knows nothing about node capabilities)
 	export PATH='/home/zender/bin'\:${PATH}
 	export LD_LIBRARY_PATH='/home/zender/lib'\:${LD_LIBRARY_PATH} ; ;;
-    cori* | edison* | hopper* | nid* )
-	export PATH='/global/homes/z/zender/bin'\:${PATH}
-        export LD_LIBRARY_PATH='/global/homes/z/zender/lib'\:${LD_LIBRARY_PATH} ; ;;
+    # 20160407: Split cori from edison binary locations to allow for different system libraries
+    cori* )
+	# 20160420: module load gsl, udunits required for non-interactive batch submissions by Wuyin Lin
+	# Not necessary for interactive, nor for CSZ non-interactive, batch submisssions
+	# Must be due to home environment differences between CSZ and other users
+	# Loading gsl and udunits seems to do no harm, so always do it
+	# This is equivalent to LD_LIBRARY_PATH method used for netCDF and SZIP on rhea
+	# Why do cori/edison and rhea require workarounds for different packages?
+	module load gsl
+	module load udunits
+	# On cori, module load ncl installs ERWG in ${NCARG_ROOT}/../intel/bin
+	if [ -n "${NCARG_ROOT}" ]; then
+            export PATH="${NCARG_ROOT}/bin:${PATH}"
+	fi # !NCARG_ROOT
+	export PATH='/global/homes/z/zender/bin_cori'\:${PATH}
+        export LD_LIBRARY_PATH='/global/homes/z/zender/lib_cori'\:${LD_LIBRARY_PATH} ; ;;
+    edison* )
+	module load gsl
+	module load udunits
+	export PATH='/global/homes/z/zender/bin_edison'\:${PATH}
+        export LD_LIBRARY_PATH='/global/homes/z/zender/lib_edison'\:${LD_LIBRARY_PATH} ; ;;
     pileus* )
 	export PATH='/home/zender/bin'\:${PATH}
 	export LD_LIBRARY_PATH='/opt/ACME/uvcdat-2.2-build/install/Externals/lib:/home/zender/lib'\:${LD_LIBRARY_PATH} ; ;;
-    rhea* | titan* )
+    rhea* )
 	# 20151017: CSZ next three lines guarantee finding mpirun
-	source ${MODULESHOME}/init/sh # 20150607: PMC added to find module command
-	module unload PE-intel # CSZ 
-	module load PE-gnu # CSZ 
-        export PATH='/ccs/home/zender/bin'\:${PATH}
-	export LD_LIBRARY_PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/lib:/sw/redhat6/szip/2.1/rhel6.6_gnu4.8.2/lib:/ccs/home/zender/lib'\:${LD_LIBRARY_PATH} ; ;;
+	source ${MODULESHOME}/init/sh # 20150607: PMC Ensures find module commands will be found
+	module unload PE-intel # Remove Intel-compiled mpirun environment
+	module load PE-gnu # Provides GCC-compiled mpirun environment (CSZ uses GCC to build NCO on rhea)
+	# 20160219: CSZ UVCDAT setup causes failures with mpirun, attempting a work-around
+	if [ -n "${UVCDAT_SETUP_PATH}" ]; then
+	    module unload python ompi paraview PE-intel PE-gnu
+	    module load gcc
+	    source /lustre/atlas1/cli900/world-shared/sw/rhea/uvcdat/latest_full/bin/setup_runtime.sh
+	    export ${UVCDAT_SETUP_PATH}
+	fi # !UVCDAT_SETUP_PATH
+	# On rhea, module load ncl installs ERWG in ${NCL_DIR}/bin
+	if [ -n "${NCL_DIR}" ]; then
+            export PATH="${NCL_DIR}/bin:${PATH}"
+	fi # !NCL_DIR
+        export PATH='/ccs/home/zender/bin_rhea'\:${PATH}
+	export LD_LIBRARY_PATH='/sw/redhat6/netcdf/4.3.3.1/rhel6.6_gcc4.8.2--with-dap+hdf4/lib:/sw/redhat6/szip/2.1/rhel6.6_gnu4.8.2/lib:/ccs/home/zender/lib_rhea'\:${LD_LIBRARY_PATH} ; ;;
+    titan* )
+	source ${MODULESHOME}/init/sh # 20150607: PMC Ensures find module commands will be found
+	module load gcc
+        export PATH='/ccs/home/zender/bin_titan'\:${PATH}
+	export LD_LIBRARY_PATH='/opt/cray/netcdf/4.3.2/GNU/49/lib:/sw/xk6/udunits/2.1.24/sl_gcc4.5.3/lib:/ccs/home/zender/lib_titan'\:${LD_LIBRARY_PATH} ; ;;
     ys* )
 	# 20151018: Yellowstone support not yet tested in batch mode
+	# On yellowstone, module load ncl installs ERWG in /glade/apps/opt/ncl/6.3.0/intel/12.1.5/bin (not in ${NCARG_ROOT}/bin)
+	if [ -n "${NCARG_ROOT}" ]; then
+#            export PATH="${NCARG_ROOT}/bin:${PATH}"
+            export PATH="${PATH}:/glade/apps/opt/ncl/6.3.0/intel/12.1.5/bin"
+	fi # !NCARG_ROOT
         export PATH='/glade/u/home/zender/bin'\:${PATH}
         export LD_LIBRARY_PATH='/glade/apps/opt/netcdf/4.3.0/intel/12.1.5/lib:/glade/u/home/zender/lib'\:${LD_LIBRARY_PATH}
 esac # !HOSTNAME
 
-# Test cases (examples for Charlie's machines):
-# ls ${DATA}/sld/raw/*.nc | ncremap -a conserve -D 0 -d ${DATA}/dstmch90/dstmch90_clm.nc -O ~/rgr
+# Insta-install
+# scp ~/nco/data/ncremap cori.nersc.gov:bin
+
+# Test cases (for Charlie's machines)
+# Map-only:
+# ncremap -s ${DATA}/grids/oEC60to30.SCRIP.150729.nc -g ${DATA}/grids/t62_SCRIP.20150901.nc -m ~/map.nc -w esmf -a bilinear
+# ncremap -s ${DATA}/grids/oEC60to30.SCRIP.150729.nc -g ${DATA}/grids/t62_SCRIP.20150901.nc -m ~/map.nc -w tempest
+# ncremap -s ${DATA}/grids/oEC60to30.SCRIP.150729.nc -d ${DATA}/dstmch90/dstmch90_clm.nc -m ~/map.nc -w tempest
+# Regrid:
+# ls ${DATA}/ne30/raw/*1979*.nc | ncremap -m ${DATA}/maps/map_ne30np4_to_fv129x256_aave.20150901.nc -O ~/rgr
 # ncremap -a conserve -v FSNT -I ${DATA}/ne30/raw -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/dstmch90/dstmch90_clm.nc -O ~/rgr
 # ls ${DATA}/essgcm14/essgcm14*cam*0007*.nc | ncremap -a conserve -M -d ${DATA}/dstmch90/dstmch90_clm.nc -O ~/rgr
 # ncremap -a conserve -v FSNT -I ${DATA}/ne30/raw -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/dstmch90/dstmch90_clm.nc -O ~/rgr
@@ -111,8 +161,8 @@ esac # !HOSTNAME
 # ncremap -i ${DATA}/ne120/raw/b1850c5_m2a.pop.h.0060-01.nc -g ${DATA}/grids/180x360_SCRIP.20150901.nc -O ~/rgr
 # ncremap -i ${DATA}/ne120/raw/b1850c5_m2a.rtm.h0.0060-01.nc -g ${DATA}/grids/180x360_SCRIP.20150901.nc -O ~/rgr
 # MPAS:
-# ncremap -P mpas -i ${DATA}/mpas/raw/hist.ocn.0003-12-01_00.00.00.nc -m ${DATA}/maps/map_mpas120_TO_T62_aave.121116.nc -O ~/rgr
-# ncremap -P mpas -i ${DATA}/mpas/raw/hist.ocn.0003-12-01_00.00.00.nc -s ${DATA}/grids/fxm -d ${DATA}/dstmch90/dstmch90_clm.nc -O ~/rgr
+# ncremap -P mpas -i ${DATA}/mpas/raw/hist.ocn.0001-01-01_00.00.00.nc -m ${DATA}/maps/map_oEC60to30_to_t62_bilin.20160301.nc -O ~/rgr
+# ncremap -P mpas -i ${DATA}/mpas/raw/hist.ice.0003-12-01_00.00.00.nc -m ${DATA}/maps/map_mpas120_TO_T62_aave.121116.nc -O ~/rgr
 # ACME benchmarks:
 # ncremap -v FSNT,AODVIS -i ${DATA}/ne30/raw/famipc5_ne30_v0.3_00003.cam.h0.1979-01.nc -m ${DATA}/maps/map_ne30np4_to_fv129x256_aave.150418.nc   -O ~/rgr
 # ncremap -v FSNT,AODVIS -i ${DATA}/ne30/raw/famipc5_ne30_v0.3_00003.cam.h0.1979-01.nc -m ${DATA}/maps/map_ne30np4_to_fv129x256_aave.20150901.nc -O ~/rgr
@@ -129,8 +179,9 @@ esac # !HOSTNAME
 
 # Set script name and run directory
 drc_pwd=${PWD}
-spt_nm=$(basename ${0}) # [sng] Script name
 nco_version=$(ncks --version 2>&1 >/dev/null | grep NCO | awk '{print $5}')
+spt_nm=$(basename ${0}) # [sng] Script name
+spt_pid=$$ # [nbr] Script PID (process ID)
 
 # Set fonts for legibility
 fnt_nrm=`tput sgr0` # Normal
@@ -140,6 +191,8 @@ fnt_rvr=`tput smso` # Reverse
 # Defaults for command-line options and some derived variables
 # Modify these defaults to save typing later
 alg_typ='bilinear' # [nbr] Algorithm for ESMF interpolation (bilinear|patch|neareststod|nearestdtos|conserve)
+cln_flg='Yes' # [flg] Clean-up (remove) intermediate files before exiting
+clm_flg='No' # [flg] Invoked by climo_nco.sh script
 dbg_lvl=0 # [nbr] Debugging level
 #drc_in="${drc_pwd}" # [sng] Input file directory
 drc_in='' # [sng] Input file directory
@@ -149,9 +202,10 @@ drc_out_xmp="~/rgr" # [sng] Output file directory for examples
 dst_fl='' # [sng] Destination file
 dst_xmp='dst.nc' # [sng] Destination file for examples
 #esmf_opt='--src_regional --dst_regional --ignore_unmapped' # [sng] ESMF_RegridWeightGen options
+#esmf_opt='--ignore_unmapped --netcdf4' # [sng] ESMF_RegridWeightGen options
 esmf_opt='--ignore_unmapped' # [sng] ESMF_RegridWeightGen options
 fl_nbr=0 # [nbr] Number of files to remap
-gaa_sng="--gaa rgr_script=${spt_nm} --gaa rgr_hostname=${HOSTNAME} --gaa rgr_version=${nco_version}" # [sng] Global attributes to add
+gaa_sng="--gaa remap_script=${spt_nm} --gaa remap_hostname=${HOSTNAME} --gaa remap_version=${nco_version}" # [sng] Global attributes to add
 grd_dst='' # [sng] Destination grid-file
 grd_dst_glb="${DATA}/grids/180x360_SCRIP.20150901.nc" # [sng] Grid-file (destination) global
 grd_dst_xmp='grd_dst.nc' # [sng] Destination grid-file for examples
@@ -173,7 +227,7 @@ nco_usr='' # [sng] NCO user-configurable options (e.g., '-D 1')
 nd_nbr=1 # [nbr] Number of nodes
 out_fl='' # [sng] Output file
 out_xmp='out.nc' # [sng] Output file for examples
-par_typ='' # [sng] Parallelism type
+par_typ='nil' # [sng] Parallelism type
 pdq_typ='' # [sng] Permutation type
 #rgr_opt='--rgr lat_nm_out=lat --rgr lon_nm_out=lon --rnr=0.0' # [sng] Regridding options
 rgr_opt='--rgr lat_nm_out=lat --rgr lon_nm_out=lon' # [sng] Regridding options
@@ -182,11 +236,23 @@ tmp_out_fl='ncremap_grd_tmp.nc' # [sng] Temporary output file
 #tps_opt='--mono' # [sng] TempestRemap options
 tps_opt='' # [sng] TempestRemap options
 #var_lst='FSNT,AODVIS' # [sng] Variables to process (empty means all)
+unq_sfx=".pid${spt_pid}" # [sng] Unique suffix
 var_lst='' # [sng] Variables to process (empty means all)
+var_rgr='' # [sng] CF template variable
 var_xmp='FSNT' # [sng] Variable list for examples
 wgt_gnr='esmf' # [sng] Weight-generator program
 xtn_var='' # [sng] Extensive variables (e.g., 'TSurfStd_ct')
 
+# Set temporary-file directory
+if [ -d "${TMPDIR}" ]; then
+    # Fancy %/ syntax removes trailing slash (e.g., from $TMPDIR)
+    drc_tmp="${TMPDIR%/}"
+elif [ -d '/tmp' ]; then
+    drc_tmp='/tmp'
+else
+    drc_tmp=${PWD}
+fi # !gpfs
+
 function fnc_usg_prn { # NB: dash supports fnc_nm (){} syntax, not function fnc_nm{} syntax
     # Print usage
     printf "\nComplete documentation for ${fnt_bld}${spt_nm}${fnt_nrm} at http://nco.sf.net/nco.html#ncremap\n\n"
@@ -200,7 +266,7 @@ function fnc_usg_prn { # NB: dash supports fnc_nm (){} syntax, not function fnc_
     echo "${fnt_rvr}-G${fnt_nrm} ${fnt_bld}grd_sng${fnt_nrm}  Grid generation argument string (empty means none) (default ${fnt_bld}${grd_sng}${fnt_nrm})"
     echo "${fnt_rvr}-I${fnt_nrm} ${fnt_bld}drc_in${fnt_nrm}   Input directory (empty means none) (default ${fnt_bld}${drc_in}${fnt_nrm})"
     echo "${fnt_rvr}-i${fnt_nrm} ${fnt_bld}in_fl${fnt_nrm}    Input file (empty means use stdin or drc_in) (default ${fnt_bld}${in_fl}${fnt_nrm})"
-    echo "${fnt_rvr}-b${fnt_nrm} ${fnt_bld}job_nbr${fnt_nrm}  Job simultaneity for parallelism (default ${fnt_bld}${job_nbr}${fnt_nrm})"
+    echo "${fnt_rvr}-j${fnt_nrm} ${fnt_bld}job_nbr${fnt_nrm}  Job simultaneity for parallelism (default ${fnt_bld}${job_nbr}${fnt_nrm})"
     echo "${fnt_rvr}-M${fnt_nrm}          Multi-map-file toggle (unset means generate one map-file per input file)"
     echo "${fnt_rvr}-m${fnt_nrm} ${fnt_bld}map_fl${fnt_nrm}   Map-file (empty means generate internally) (default ${fnt_bld}${map_fl}${fnt_nrm})"
     echo "${fnt_rvr}-n${fnt_nrm} ${fnt_bld}nco_opt${fnt_nrm}  NCO options (empty means none) (default ${fnt_bld}${nco_opt}${fnt_nrm})"
@@ -212,6 +278,8 @@ function fnc_usg_prn { # NB: dash supports fnc_nm (){} syntax, not function fnc_
     echo "${fnt_rvr}-s${fnt_nrm} ${fnt_bld}grd_src${fnt_nrm}  Grid-file (source) (empty means infer or use map_fl) (default ${fnt_bld}${grd_src}${fnt_nrm})"
     echo "${fnt_rvr}-t${fnt_nrm} ${fnt_bld}thr_nbr${fnt_nrm}  Thread number for regridder (default ${fnt_bld}${thr_nbr}${fnt_nrm})"
     echo "${fnt_rvr}-T${fnt_nrm} ${fnt_bld}tps_opt${fnt_nrm}  TempestRemap GenerateOfflineMap options (default ${fnt_bld}${tps_opt}${fnt_nrm})"
+    echo "${fnt_rvr}-u${fnt_nrm} ${fnt_bld}unq_sfx${fnt_nrm}  Unique suffix (prevents intermediate files from sharing names) (default ${fnt_bld}${unq_sfx}${fnt_nrm})"
+    echo "${fnt_rvr}-V${fnt_nrm} ${fnt_bld}var_rgr${fnt_nrm}  CF template variable (empty means none) (default ${fnt_bld}${var_rgr}${fnt_nrm})"
     echo "${fnt_rvr}-v${fnt_nrm} ${fnt_bld}var_lst${fnt_nrm}  Variable list (empty means all) (default ${fnt_bld}${var_lst}${fnt_nrm})"
     echo "${fnt_rvr}-w${fnt_nrm} ${fnt_bld}wgt_gnr${fnt_nrm}  Weight-generator (default ${fnt_bld}${wgt_gnr}${fnt_nrm})"
     echo "${fnt_rvr}-x${fnt_nrm} ${fnt_bld}xtn_var${fnt_nrm}  Extensive variables (empty means none) (default ${fnt_bld}${xtn_var}${fnt_nrm})"
@@ -256,9 +324,10 @@ fi # !arg_nbr
 # http://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options
 # http://tuxtweaks.com/2014/05/bash-getopts
 cmd_ln="${spt_nm} ${@}"
-while getopts :a:D:d:E:f:g:G:h:I:i:j:Mm:n:O:o:P:p:R:s:T:t:v:w:x: OPT; do
+while getopts :a:CD:d:E:f:g:G:h:I:i:j:Mm:n:O:o:P:p:R:s:T:t:U:u:V:v:w:x: OPT; do
     case ${OPT} in
 	a) alg_typ=${OPTARG} ;; # Algorithm
+	C) clm_flg='Yes' ;; # Climo flag (undocumented)
 	D) dbg_lvl=${OPTARG} ;; # Debugging level
 	d) dst_fl=${OPTARG} ;; # Destination file
 	E) esmf_opt=${OPTARG} ;; # ESMF options
@@ -278,6 +347,9 @@ while getopts :a:D:d:E:f:g:G:h:I:i:j:Mm:n:O:o:P:p:R:s:T:t:v:w:x: OPT; do
 	s) grd_src=${OPTARG} ;; # Source grid-file
 	T) tps_opt=${OPTARG} ;; # Tempest options
 	t) thr_usr=${OPTARG} ;; # Thread number
+	U) tmp_usr=${OPTARG} ;; # Temporary directory
+	u) unq_usr=${OPTARG} ;; # Unique suffix
+	V) var_rgr=${OPTARG} ;; # CF template variable 
 	v) var_lst=${OPTARG} ;; # Variables
 	w) wgt_usr=${OPTARG} ;; # Weight-generator
 	x) xtn_var=${OPTARG} ;; # Extensive variables
@@ -290,24 +362,54 @@ shift $((OPTIND-1)) # Advance one argument
 
 # Derived variables
 if [ -n "${drc_usr}" ]; then
-    drc_out="${drc_usr}"
+    drc_out="${drc_usr%/}"
+else
+    if [ -n "${out_fl}" ]; then
+	drc_out="$(dirname ${out_fl})"
+    fi # !out_fl
 fi # !drc_usr
-grd_dst_dfl="${drc_out}/ncremap_tmp_grd_dst.nc" # [sng] Grid-file (destination) default
-grd_src_dfl="${drc_out}/ncremap_tmp_grd_src.nc" # [sng] Grid-file (source) default
-pdq_fl="${drc_out}/ncremap_tmp_pdq.nc" # [sng] Permuted data default
-tmp_out_fl="${drc_out}/${tmp_out_fl}" # [sng] Temporary output file
-ncwa_fl="${drc_out}/ncremap_tmp_ncwa.nc" # [sng] ncwa workflow (HIRDLS, MLS) default
-znl_fl="${drc_out}/ncremap_tmp_znl.nc" # [sng] Zonal workflow (HIRDLS, MLS) default
-if [ ${alg_typ} = 'bilinear' ] || [ ${alg_typ} = 'bln' ] ; then 
+
+if [ -n "${tmp_usr}" ]; then
+    # Fancy %/ syntax removes trailing slash (e.g., from $TMPDIR)
+    drc_tmp=${tmp_usr%/}
+fi # !out_fl
+att_fl="${drc_tmp}/ncremap_tmp_att.nc" # [sng] Missing value workflow (MPAS) default
+grd_dst_dfl="${drc_tmp}/ncremap_tmp_grd_dst.nc" # [sng] Grid-file (destination) default
+grd_src_dfl="${drc_tmp}/ncremap_tmp_grd_src.nc" # [sng] Grid-file (source) default
+ncwa_fl="${drc_tmp}/ncremap_tmp_ncwa.nc" # [sng] ncwa workflow (HIRDLS, MLS) default
+pdq_fl="${drc_tmp}/ncremap_tmp_pdq.nc" # [sng] Permuted data default (AIRS, HIRDLS, MLS, MPAS) 
+tmp_out_fl="${drc_tmp}/${tmp_out_fl}" # [sng] Temporary output file
+znl_fl="${drc_tmp}/ncremap_tmp_znl.nc" # [sng] Zonal workflow (HIRDLS, MLS) default
+
+if [ -n "${unq_usr}" ]; then
+    if [ "${unq_usr}" = 'noclean' ]; then
+	cln_flg='No'
+    else
+	if [ "${unq_usr}" != 'none' ] && [ "${unq_usr}" != 'nil' ]; then
+	    unq_sfx="${unq_usr}"
+	else # !unq_usr
+	    unq_sfx=""
+	fi # !unq_usr
+    fi # !unq_usr
+fi # !unq_sfx
+att_fl=${att_fl}${unq_sfx}
+grd_dst_dfl=${grd_dst_dfl}${unq_sfx}
+grd_src_dfl=${grd_src_dfl}${unq_sfx}
+ncwa_fl=${ncwa_fl}${unq_sfx}
+pdq_fl=${pdq_fl}${unq_sfx}
+tmp_out_fl=${tmp_out_fl}${unq_sfx}
+znl_fl=${znl_fl}${unq_sfx}
+
+if [ ${alg_typ} = 'bilinear' ] || [ ${alg_typ} = 'bln' ]; then 
     # ESMF algorithms are bilinear|patch|neareststod|nearestdtos|conserve
     alg_opt='bilinear'
-elif [ ${alg_typ} = 'conserve' ] || [ ${alg_typ} = 'conservative' ] || [ ${alg_typ} = 'cns' ] ; then 
+elif [ ${alg_typ} = 'conserve' ] || [ ${alg_typ} = 'conservative' ] || [ ${alg_typ} = 'cns' ]; then 
     alg_opt='conserve'
-elif [ ${alg_typ} = 'nearestdtos' ] || [ ${alg_typ} = 'nds' ] || [ ${alg_typ} = 'dtos' ] ; then 
+elif [ ${alg_typ} = 'nearestdtos' ] || [ ${alg_typ} = 'nds' ] || [ ${alg_typ} = 'dtos' ]; then 
     alg_opt='nearestdtos'
-elif [ ${alg_typ} = 'neareststod' ] || [ ${alg_typ} = 'nsd' ] || [ ${alg_typ} = 'stod' ] ; then 
+elif [ ${alg_typ} = 'neareststod' ] || [ ${alg_typ} = 'nsd' ] || [ ${alg_typ} = 'stod' ]; then 
     alg_opt='nearestdtos'
-elif [ ${alg_typ} = 'patch' ] || [ ${alg_typ} = 'pch' ] || [ ${alg_typ} = 'ptc' ] ; then 
+elif [ ${alg_typ} = 'patch' ] || [ ${alg_typ} = 'pch' ] || [ ${alg_typ} = 'ptc' ]; then 
     alg_opt='patch'
 fi # !alg_typ
 if [ -z "${drc_in}" ]; then
@@ -333,6 +435,9 @@ fi # !hdr_pad
 if [ -n "${var_lst}" ]; then 
     nco_var_lst="-v ${var_lst}"
 fi # !var_lst
+if [ -n "${var_rgr}" ]; then 
+    nco_var_rgr="--rgr_var=${var_rgr}"
+fi # !var_rgr
 if [ -n "${xtn_var}" ]; then 
     rgr_opt="${rgr_opt} --xtn=${xtn_var}"
 fi # !var_lst
@@ -369,7 +474,10 @@ if [ "${pdq_typ}" = 'mls' ]; then
     pdq_opt='-a CO_Pressure,CO_Latitude,lon'
 fi # !mls
 if [ "${pdq_typ}" = 'mpas' ]; then 
-    pdq_opt='-a Time,nVertLevels,maxEdges,MaxEdges2,nEdges,nCells'
+#    pdq_opt='-a Time,nVertLevels,maxEdges,MaxEdges2,nEdges,nCells' # Ocean only
+#    pdq_opt='-a Time,nCategories,ONE,nEdges,nCells' # Ice only
+    pdq_opt='-a Time,nVertLevels,maxEdges,MaxEdges2,nCategories,ONE,nEdges,nCells' # Ocean and Ice in one swell foop
+    rgr_opt="${rgr_opt} --rnr=0.0"
 fi # !mpas
 if [ -n "${thr_usr}" ]; then 
     thr_nbr="${thr_usr}"
@@ -377,35 +485,35 @@ fi # !thr_usr
 if [ -n "${wgt_usr}" ]; then 
     wgt_gnr="${wgt_usr}"
 fi # !wgt_usr    
-if [ "${wgt_gnr}" != 'esmf' ] && [ "${wgt_gnr}" != 'tempest' ] ; then 
+if [ "${wgt_gnr}" != 'esmf' ] && [ "${wgt_gnr}" != 'tempest' ]; then 
 	    echo "ERROR: Invalid -w wgt_gnr option = ${wgt_gnr}"
 	    echo "HINT: Valid wgt_gnr arguments are 'esmf' and 'tempest'"
 	    exit 1
 fi # !wgt_gnr
 
 if [ -n "${dst_fl}" ]; then 
-    if [ ! -e "${dst_fl}" ]; then
+    if [ ! -f "${dst_fl}" ]; then
 	echo "ERROR: Unable to find specified destination-file ${dst_fl}"
 	echo "HINT: Supply the full path-name for the destination-file"
 	exit 1
-    fi # ! -e
+    fi # ! -f
     dst_usr_flg='Yes'
 fi # !dst_fl
 if [ -n "${grd_dst}" ]; then 
-    if [ ! -e "${grd_dst}" ]; then
+    if [ ! -f "${grd_dst}" ]; then
 	echo "ERROR: Unable to find specified destination grid-file ${grd_dst}"
 	echo "HINT: Supply the full path-name for the destination grid, or generate one automatically with -G"
 	exit 1
-    fi # ! -e
+    fi # ! -f
     grd_dst_usr_flg='Yes'
 else
     grd_dst=${grd_dst_dfl} # [sng] Grid-file default
 fi # !grd_dst
 if [ -n "${grd_src}" ]; then 
-    if [ ! -e "${grd_src}" ]; then
+    if [ ! -f "${grd_src}" ]; then
 	echo "ERROR: Unable to find specified source grid-file ${grd_src}"
 	exit 1
-    fi # ! -e
+    fi # ! -f
     grd_src_usr_flg='Yes'
 else
     grd_src=${grd_src_dfl} # [sng] Grid-file default
@@ -423,9 +531,9 @@ fi # !map_mk
 if [ -n "${map_fl}" ]; then 
     map_usr_flg='Yes'
     if [ "${map_mk}" = 'Yes' ]; then
-        if [ -e "${map_fl}" ]; then
+        if [ -f "${map_fl}" ]; then
 	    rsp_kbd_nbr=0
-	    while [ ${rsp_kbd_nbr} -lt 10 ] ; do
+	    while [ ${rsp_kbd_nbr} -lt 10 ]; do
 		echo "WARNING: The file ${map_fl} already exists and will be over-written by the newly generated map-file."
 		read -p "Continue (y/n)? " rsp_kbd
 		let rsp_kbd_nbr+=1
@@ -439,25 +547,25 @@ if [ -n "${map_fl}" ]; then
 		echo "ERROR: Too many invalid responses, exiting"
 		exit 1
 	    fi # !rsp_kbd_nbr
-	fi # ! -e
+	fi # ! -f
     else # !map_mk
-        if [ ! -e "${map_fl}" ]; then
+        if [ ! -f "${map_fl}" ]; then
 	    echo "ERROR: Unable to find specified regrid map ${map_fl}"
 	    echo "HINT: Supply a valid map-file (weight-file) name or supply the grid files or data files and let ncremap create a mapfile for you"
 	    exit 1
-	fi # ! -e
+	fi # ! -f
     fi # !map_mk
 else # !map_fl
     if [ "${wgt_gnr}" = 'esmf' ]; then 
-	map_fl_dfl="${drc_out}/ncremap_tmp_map_${wgt_gnr}_${alg_opt}.nc" # [sng] Map-file default
+	map_fl_dfl="${drc_tmp}/ncremap_tmp_map_${wgt_gnr}_${alg_opt}.nc${unq_sfx}" # [sng] Map-file default
     fi # !esmf
     if [ "${wgt_gnr}" = 'tempest' ]; then 
-	map_fl_dfl="${drc_out}/ncremap_tmp_map_${wgt_gnr}.nc" # [sng] Map-file default
+	map_fl_dfl="${drc_tmp}/ncremap_tmp_map_${wgt_gnr}.nc${unq_sfx}" # [sng] Map-file default
     fi # !tempest
     map_fl=${map_fl_dfl}
 fi # !map_fl
 if [ "${map_mk}" = 'Yes' ] && [ "${wgt_gnr}" = 'tempest' ]; then 
-    msh_fl_dfl="${drc_out}/ncremap_tmp_msh_ovr_${wgt_gnr}.g" # [sng] Mesh-file default
+    msh_fl_dfl="${drc_tmp}/ncremap_tmp_msh_ovr_${wgt_gnr}.g${unq_sfx}" # [sng] Mesh-file default
     msh_fl=${msh_fl_dfl}
 fi # !tempest
 
@@ -500,7 +608,16 @@ if [ "${mpi_flg}" = 'Yes' ]; then
     elif [ -n "${PBS_NODEFILE}" ]; then 
 	nd_fl="${PBS_NODEFILE}"
     elif [ -n "${SLURM_NODELIST}" ]; then 
-	nd_fl="${SLURM_NODELIST}"
+	# SLURM returns compressed lists (e.g., "nid00[076-078,559-567]")
+	# Convert this to file with uncompressed list (like Cobalt, PBS)
+	# http://www.ceci-hpc.be/slurm_faq.html#Q12
+	nd_fl='ncclimo.slurm_nodelist'
+	nd_lst=`scontrol show hostname ${SLURM_NODELIST}`
+	echo ${nd_lst} > ${nd_fl}
+    else
+	echo "ERROR: MPI job unable to find node list"
+	echo "HINT: ${spt_nm} uses first node list found in \$COBALT_NODEFILE (= \"${COBALT_NODEFILE}\"), \$PBS_NODEFILE (= \"${PBS_NODEFILE}\"), \$SLURM_NODELIST (= \"${SLURM_NODELIST}\")"
+	exit 1
     fi # !PBS
     if [ -n "${nd_fl}" ]; then 
 	# NB: nodes are 0-based, e.g., [0..11]
@@ -510,24 +627,31 @@ if [ "${mpi_flg}" = 'Yes' ]; then
 	    let nd_idx=${nd_idx}+1
 	done # !nd
 	nd_nbr=${#nd_nm[@]}
-	for ((fl_idx=0;fl_idx<fl_nbr;fl_idx++)); do
+	for ((clm_idx=1;clm_idx<=17;clm_idx++)); do
 	    case "${HOSTNAME}" in 
+		# 20160502: Remove limits on tasks per node so round-robin algorithm can schedule multiple jobs on same node
 		cori* | edison* | nid* )
+		    # 20160502: Non-interactive batch jobs at NERSC return HOSTNAME as nid*, not cori* or edison*
 		    # NB: NERSC staff says srun automatically assigns to unique nodes even without "-L $node" argument?
-		    cmd_mpi[${fl_idx}]="srun -L ${nd_nm[$((${fl_idx} % ${nd_nbr}))]} -n 1" ; ;; # NERSC
+ 		    cmd_mpi[${clm_idx}]="srun --nodelist ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} --nodes=1" ; ;; # NERSC
+# 		    cmd_mpi[${clm_idx}]="srun --nodelist ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} --nodes=1 --ntasks=1" ; ;; # NERSC
 		hopper* )
 		    # NB: NERSC migrated from aprun to srun in 201601. Hopper commands will soon be deprecated.
-		    cmd_mpi[${fl_idx}]="aprun -L ${nd_nm[$((${fl_idx} % ${nd_nbr}))]} -n 1" ; ;; # NERSC
+		    cmd_mpi[${clm_idx}]="aprun -L ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} -n 1" ; ;; # NERSC
 		* )
-		    cmd_mpi[${fl_idx}]="mpirun -H ${nd_nm[$((${fl_idx} % ${nd_nbr}))]} -npernode 1 -n 1" ; ;; # Other
+		    cmd_mpi[${clm_idx}]="mpirun -H ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} -n 1" ; ;; # Other (Cobalt)
+#		    cmd_mpi[${clm_idx}]="mpirun -H ${nd_nm[$(((${clm_idx}-1) % ${nd_nbr}))]} -npernode 1 -n 1" ; ;; # Other
 	    esac # !HOSTNAME
-	done # !fl_idx
-    else # ! pbs
+	done # !clm_idx
+	if [ -n "${SLURM_NODELIST}" ]; then 
+	    /bin/rm -f ${nd_fl}
+	fi # !SLURM
+    else # !nd_fl
 	mpi_flg='No'
 	for ((fl_idx=0;fl_idx<fl_nbr;fl_idx++)); do
 	    cmd_mpi[${fl_idx}]=""
 	done # !fl_idx
-    fi # !pbs
+    fi # !nd_fl
     if [ -z "${job_usr}" ]; then 
 	job_nbr=${nd_nbr}
     fi # !job_usr
@@ -543,9 +667,11 @@ fi # !mpi
 # Print initial state
 if [ ${dbg_lvl} -ge 2 ]; then
     printf "dbg: alg_opt  = ${alg_opt}\n"
+    printf "dbg: cln_flg  = ${cln_flg}\n"
     printf "dbg: dbg_lvl  = ${dbg_lvl}\n"
     printf "dbg: drc_in   = ${drc_in}\n"
     printf "dbg: drc_out  = ${drc_out}\n"
+    printf "dbg: drc_tmp  = ${drc_tmp}\n"
     printf "dbg: dst_fl   = ${dst_fl}\n"
     printf "dbg: gaa_sng  = ${gaa_sng}\n"
     printf "dbg: grd_dst  = ${grd_dst}\n"
@@ -562,8 +688,12 @@ if [ ${dbg_lvl} -ge 2 ]; then
     printf "dbg: nd_nbr   = ${nd_nbr}\n"
     printf "dbg: out_fl   = ${out_fl}\n"
     printf "dbg: par_typ  = ${par_typ}\n"
+    printf "dbg: spt_pid  = ${spt_pid}\n"
     printf "dbg: thr_nbr  = ${thr_nbr}\n"
+    printf "dbg: unq_sfx  = ${unq_sfx}\n"
     printf "dbg: var_lst  = ${var_lst}\n"
+    printf "dbg: var_rgr  = ${var_rgr}\n"
+    printf "dbg: wgt_usr  = ${wgt_usr}\n"
     printf "Asked to regrid ${fl_nbr} files:\n"
     for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
 	printf "${fl_in[${fl_idx}]}\n"
@@ -579,6 +709,7 @@ fi # !dbg
 
 # Create output directory
 mkdir -p ${drc_out}
+mkdir -p ${drc_tmp}
 
 # Human-readable summary
 if [ ${dbg_lvl} -ge 1 ]; then
@@ -592,8 +723,8 @@ if [ -f 'PET0.RegridWeightGen.Log' ]; then
     /bin/rm -f PET0.RegridWeightGen.Log
 fi # !PETO
 printf "Started processing at `date`.\n"
-printf "NCO version is ${nco_version}\n"
-if [ "${map_mk}" != 'Yes' ] && [ "${map_usr_flg}" = 'Yes' ] && [ -n "${wgt_usr}" ] ; then
+printf "NCO ${spt_nm} version is ${nco_version}\n"
+if [ "${map_mk}" != 'Yes' ] && [ "${map_usr_flg}" = 'Yes' ] && [ -n "${wgt_usr}" ]; then
     printf "${spt_nm}: ERROR Specifying both '-m map_fl' and '-w wgt_gnr' is only allowed when creating a map (weight generator is superfluous when map is supplied)\n"
     exit 1
 fi # wgt_usr
@@ -604,7 +735,7 @@ if [ "${dst_usr_flg}" = 'Yes' ]; then
 	exit 1
     fi # !grd_dst_usr_flg
 fi # !dst_usr_flg
-if [ "${dst_usr_flg}" != 'Yes' ] && [ "${grd_dst_usr_flg}" != 'Yes' ] && [ "${map_usr_flg}" != 'Yes' ] && [ "${grd_sng_usr_flg}" != 'Yes' ] ; then 
+if [ "${dst_usr_flg}" != 'Yes' ] && [ "${grd_dst_usr_flg}" != 'Yes' ] && [ "${map_usr_flg}" != 'Yes' ] && [ "${grd_sng_usr_flg}" != 'Yes' ]; then 
     printf "${spt_nm}: ERROR Must use one of '-d dst_fl', '-g grd_dst', '-G grd_sng', or '-m map_fl'\n"
     exit 1
 fi # !dst_usr_flg
@@ -620,6 +751,12 @@ fi # !fl_nbr
 if [ -n "${pdq_opt}" ]; then 
     printf "Input data obey \"${pdq_typ}\"-ordering and will be permuted with \"ncpdq ${pdq_opt}\"\n"
 fi # !pdq_opt
+if [ "${pdq_typ}" = 'mpas' ]; then
+    printf "Input assumed to be MPAS-O/I data: will apply renormalized regridding (--rnr=0.0)\n"
+    if [ "${clm_flg}" = 'No' ]; then
+ 	printf "Input assumed to be barenaked of attributes: will annotate NC_DOUBLE variables with _FillValue prior to regridding\n"
+    fi # !clm_flg
+fi # !mpas
 if [ "${map_mk}" != 'Yes' ] && [ "${map_usr_flg}" = 'Yes' ]; then 
     printf "Source and destination grids will both be read from supplied map-file\n"
 else # !map_usr_flg
@@ -628,7 +765,7 @@ else # !map_usr_flg
 	# Block 1 Loop 1: Generate, check, and store (but do not yet execute) commands
 	# Infer destination grid-file from data file
 	printf "Destination grid will be inferred from data-file\n"
-	cmd_dst[${fl_idx}]="ncks ${nco_opt} --rgr nfr=y --rgr grid=${grd_dst} ${dst_fl} ${tmp_out_fl}"
+	cmd_dst[${fl_idx}]="ncks ${nco_opt} --rgr nfr=y ${nco_var_rgr} --rgr grid=${grd_dst} ${dst_fl} ${tmp_out_fl}"
     else # !dst_usr_flg
 	if [ "${grd_dst_usr_flg}" = 'Yes' ]; then 
 	    printf "Destination grid supplied by user\n"
@@ -660,12 +797,15 @@ else # !map_usr_flg
     fi # !dst_usr_flg || grd_dst_usr_flg
     printf "Weight-generation type: ${wgt_gnr}\n"
     if [ "${wgt_gnr}" = 'esmf' ]; then 
-	printf "ESMF's ESMF_RegridWeightGen will generate map-file\n"
+	printf "ESMF's ESMF_RegridWeightGen will generate mapping weights and map-file\n"
 	printf "Algorithm used to generate weights in map-file is: ${alg_opt}\n"
+	wgt_cmd='ESMF_RegridWeightGen'
     fi # !esmf
     if [ "${wgt_gnr}" = 'tempest' ]; then 
-	printf "TempestRemap's GenerateOverlapMesh and GenerateOfflineMap will generate map-file\n"
+	printf "TempestRemap's GenerateOverlapMesh and GenerateOfflineMap will generate mapping weights and map-file\n"
+	wgt_cmd='GenerateOverlapMesh'
     fi # !tempest
+    command -v ${wgt_cmd} 2>&1 /dev/null || { printf "${spt_nm}: ERROR cannot find weight-generation command ${wgt_cmd}. Please install the executable, or change your PATH to find it.\n${spt_nm}: HINT ESMF_RegridWeightGen is often provided in NCL packages. Tempest executables must be installed from source."; exit 1; }
     if [ ${fl_nbr} -ge 2 ]; then 
 	if [ "${mlt_map_flg}" = 'Yes' ]; then 
 	    printf "Input files assumed to use unique input grids\nOne source grid-file will be inferred and one map-file generated per input file\n"
@@ -710,8 +850,11 @@ if [ "${grd_src_usr_flg}" = 'Yes' ]; then
 	    fi # !esmf
 	    exit 1
 	fi # !err
-	if [ "${map_usr_flg}" = 'Yes' ] ; then
+	if [ "${map_usr_flg}" = 'Yes' ]; then
 	    hst_att="`date`: ${cmd_ln};${cmd_map[${fl_idx}]}"
+	    if [ "${wgt_gnr}" = 'tempest' ]; then 
+		hst_att="${hst_att};${cmd_msh[${fl_idx}]}"
+	    fi # !tempest
 	    cmd_att[${fl_idx}]="ncatted -O ${gaa_sng} --gaa history='${hst_att}' ${map_fl}"
 	    eval ${cmd_att[${fl_idx}]}
 	    if [ $? -ne 0 ]; then
@@ -766,22 +909,22 @@ for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
 	    fi # !dbg
 	    if [ ${dbg_lvl} -ne 2 ]; then
 		eval ${cmd_znl[${fl_idx}]}
-		if [ $? -ne 0 ] || [ ! -f "${znl_fl/znl/znl3}" ] ; then
+		if [ $? -ne 0 ] || [ ! -f "${znl_fl/znl/znl3}" ]; then
 		    printf "${spt_nm}: ERROR Failed to generate lat-lon file from zonal file. Debug this:\n${cmd_znl[${fl_idx}]}\n"
 		    exit 1
 		fi # !err
 	    fi # !dbg
 	fi # !znl
-	
+
 	# Block 2: Source grid
 	# Block 2 Loop 1: Source gridfile command
-	if [ ! -e "${in_fl}" ]; then
+	if [ ! -f "${in_fl}" ]; then
 	    echo "${spt_nm}: ERROR Unable to find Input file ${in_fl}"
 	    echo "HINT: All files implied to exist must be in the directory specified by their filename or in ${drc_in} before ${spt_nm} will proceed"
 	    exit 1
-	fi # ! -e
+	fi # ! -f
 	# Infer source grid-file from input data file
-	cmd_src[${fl_idx}]="ncks ${nco_opt} --rgr nfr=y --rgr grid=${grd_src} ${in_fl} ${tmp_out_fl}"
+	cmd_src[${fl_idx}]="ncks ${nco_opt} --rgr nfr=y ${nco_var_rgr} --rgr grid=${grd_src} ${in_fl} ${tmp_out_fl}"
 	
 	# Block 2 Loop 2: Execute and/or echo commands
 	if [ ${dbg_lvl} -ge 1 ]; then
@@ -811,7 +954,7 @@ for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
 	    fi # !dbg
 	    if [ ${dbg_lvl} -ne 2 ]; then
 		eval ${cmd_msh[${fl_idx}]}
-		if [ $? -ne 0 ] || [ ! -f ${msh_fl} ] ; then
+		if [ $? -ne 0 ] || [ ! -f ${msh_fl} ]; then
 		    printf "${spt_nm}: ERROR Failed to generate mesh-file. Debug this:\n${cmd_msh[${fl_idx}]}\n"
 		    exit 1
 		fi # !err
@@ -824,14 +967,14 @@ for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
 	fi # !dbg
 	if [ ${dbg_lvl} -ne 2 ]; then
 	    eval ${cmd_map[${fl_idx}]}
-	    if [ $? -ne 0 ] || [ ! -f ${map_fl} ] ; then
+	    if [ $? -ne 0 ] || [ ! -f ${map_fl} ]; then
 		printf "${spt_nm}: ERROR Failed to generate map-file. Debug this:\n${cmd_map[${fl_idx}]}\n"
 		if [ "${wgt_gnr}" = 'esmf' ]; then 
 		    printf "${spt_nm}: HINT When ESMF fails to generate map-files, it often puts additional debugging information in the file named PET0.RegridWeightGen.Log in the invocation directory (${drc_pwd})\n"
 		fi # !esmf
 		exit 1
 	    fi # !err
-	    if [ "${map_usr_flg}" = 'Yes' ] ; then
+	    if [ "${map_usr_flg}" = 'Yes' ]; then
 		hst_att="`date`: ${cmd_ln};${cmd_map[${fl_idx}]}"
 		cmd_att[${fl_idx}]="ncatted -O ${gaa_sng} --gaa history='${hst_att}' ${map_fl}"
 		eval ${cmd_att[${fl_idx}]}
@@ -843,27 +986,41 @@ for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
 	fi # !dbg
 
 	# Prevent creating new source gridfile and map-file after first iteration
-	if [ "${mlt_map_flg}" = 'No' ] && [ ${fl_idx} -eq 0 ] ; then 
+	if [ "${mlt_map_flg}" = 'No' ] && [ ${fl_idx} -eq 0 ]; then 
 	    map_mk='Already made map once. Never again.'
 	fi # !mlt_map_flg
 
     fi # !map_mk
     
-    # Block 4: Generic Permutation (AIRS, HIRDLS, MLS, MPAS)
+    # Block 4: Special cases
+    # Block 4a: Add missing metadata to MPAS files unless script was invoked by climo_nco.sh (it makes no sense to give naked files to climo_nco.sh and then annotate here, so assume climo_nco.sh is working with annotated files)
+    if [ "${pdq_typ}" = 'mpas' ] && [ "${clm_flg}" = 'No' ]; then
+	cmd_att[${fl_idx}]="ncatted -O -t -a _FillValue,,o,d,-9.99999979021476795361e+33 ${in_fl} ${att_fl};"
+	in_fl="${att_fl}"
+	if [ ${dbg_lvl} -ge 1 ]; then
+	    echo ${cmd_att[${fl_idx}]}
+	fi # !dbg
+	if [ ${dbg_lvl} -ne 2 ]; then
+	    eval ${cmd_att[${fl_idx}]}
+	    if [ $? -ne 0 ] || [ ! -f "${att_fl}" ]; then
+		printf "${spt_nm}: ERROR Failed to annotate MPAS file with _FillValue. Debug this:\n${cmd_att[${fl_idx}]}\n"
+		exit 1
+	    fi # !err
+	fi # !dbg
+    fi # !mpas
+	
+    # Block 4b: Generic Permutation (AIRS, HIRDLS, MLS, MPAS)
     if [ -n "${pdq_opt}" ]; then
 	printf "PDQ(in)  : ${in_fl}\n"
 	printf "PDQ(out) : ${pdq_fl}\n"
 	cmd_pdq[${fl_idx}]="ncpdq ${nco_opt} ${nco_var_lst} ${pdq_opt} ${in_fl} ${pdq_fl}"
-	# Cause next block (regridding) to operate on PDQ file
 	in_fl=${pdq_fl}
-	
-	# Block 4 Loop 2: Execute and/or echo commands
 	if [ ${dbg_lvl} -ge 1 ]; then
 	    echo ${cmd_pdq[${fl_idx}]}
 	fi # !dbg
 	if [ ${dbg_lvl} -ne 2 ]; then
 	    eval ${cmd_pdq[${fl_idx}]}
-	    if [ $? -ne 0 ] || [ ! -f ${pdq_fl} ] ; then
+	    if [ $? -ne 0 ] || [ ! -f ${pdq_fl} ]; then
 		printf "${spt_nm}: ERROR Failed to generate pdq-file. Debug this:\n${cmd_pdq[${fl_idx}]}\n"
 		exit 1
 	    fi # !err
@@ -873,7 +1030,7 @@ for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
     # Block 5: Regrid
     printf "Map/Wgt  : ${map_fl}\n"
     printf "Regridded: ${out_fl}\n"
-    cmd_rgr[${fl_idx}]="${cmd_mpi[${fl_idx}]} ncks -t ${thr_nbr} ${nco_opt} ${nco_var_lst} ${rgr_opt} --map=${map_fl} ${in_fl} ${out_fl}"
+    cmd_rgr[${fl_idx}]="${cmd_mpi[${fl_idx}]} ncks -t ${thr_nbr} ${nco_opt} ${nco_var_rgr} ${nco_var_lst} ${rgr_opt} --map=${map_fl} ${in_fl} ${out_fl}"
     
     # Block 5 Loop 2: Execute and/or echo commands
     if [ ${dbg_lvl} -ge 1 ]; then
@@ -899,7 +1056,7 @@ for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
 	let bch_idx=$((fl_idx / job_nbr))
 	let bch_flg=$(((fl_idx+1) % job_nbr))
 	#printf "${spt_nm}: fl_idx = ${fl_idx}, bch_idx = ${bch_idx}, bch_flg = ${bch_flg}\n"
-	if [ ${bch_flg} -eq 0 ] ; then
+	if [ ${bch_flg} -eq 0 ]; then
 	    if [ ${dbg_lvl} -ge 1 ]; then
 		printf "${spt_nm}: Waiting for batch ${bch_idx} to finish at fl_idx = ${fl_idx}...\n"
 	    fi # !dbg
@@ -925,7 +1082,7 @@ for ((fl_idx=0;fl_idx<${fl_nbr};fl_idx++)); do
 	fi # !dbg
 	if [ ${dbg_lvl} -ne 2 ]; then
 	    eval ${cmd_znl[${fl_idx}]}
-	    if [ $? -ne 0 ] || [ ! -f "${out_fl}" ] ; then
+	    if [ $? -ne 0 ] || [ ! -f "${out_fl}" ]; then
 		printf "${spt_nm}: ERROR Failed to generate zonal file from lat-lon file. Debug this:\n${cmd_znl[${fl_idx}]}\n"
 		exit 1
 	    fi # !err
@@ -937,7 +1094,7 @@ done # !fl_idx
 # Parallel mode will often exit loop after a partial batch, wait() for remaining jobs to finish
 if [ -n "${par_opt}" ]; then
     let bch_flg=$((fl_nbr % job_nbr))
-    if [ ${bch_flg} -ne 0 ] ; then
+    if [ ${bch_flg} -ne 0 ]; then
 	let bch_idx=$((bch_idx+1))
 	printf "${spt_nm}: Waiting for (partial) batch ${bch_idx} to finish...\n"
 	for ((pid_idx=${idx_srt};pid_idx<${fl_nbr};pid_idx++)); do
@@ -950,6 +1107,11 @@ if [ -n "${par_opt}" ]; then
     fi # !bch_flg
 fi # !par_typ
 
+if [ "${cln_flg}" = 'Yes' ]; then
+    printf "Cleaning-up intermediate files...\n"
+    /bin/rm -f ${att_fl} ${grd_dst_dfl} ${grd_src_dfl} ${map_fl_dfl} ${msh_fl_dfl} ${ncwa_fl} ${pdq_fl} ${tmp_out_fl} ${znl_fl/znl/znl1} ${znl_fl/znl/znl2} ${znl_fl/znl/znl3}
+fi # !cln_flg
+
 date_end=$(date +"%s")
 if [ ${fl_nbr} -eq 0 ]; then
     printf "Completed generating map-file(s) at `date`.\n"
diff --git a/data/vpointer-ex1.nco b/data/vpointer-ex1.nco
new file mode 100644
index 0000000..bd1c783
--- /dev/null
+++ b/data/vpointer-ex1.nco
@@ -0,0 +1,47 @@
+
+// Produce a list of all vars in input
+// each element of att list  is of type NC_STRING
+// nb get_var_in() can take a single argument that can be a var name or regular expression
+// lists are  of type NC_STRING and can are in essence ragged arrays
+
+ at all=get_vars_in();
+
+*sz=@all.size();
+*idx=0;
+
+for(idx=0;idx<sz;idx++)
+{
+  // remember @var_nm is of type NC_STRING
+  @var_nm=@all(idx);
+ 
+  if( *@var_nm.type()==NC_FLOAT)
+     *@var_nm=*@var_nm.double();
+
+  else if( *@var_nm.type()==NC_DOUBLE )
+     *@var_nm=*@var_nm; 
+}
+
+ at out=get_vars_out();
+
+
+print("\n/****************************/\n");
+print(@out);
+print("\n/****************************/\n");
+
+
+
+*sz=@out.size();
+*idx=0;
+
+for(idx=0;idx<sz;idx++)
+{
+  // remember @var_nm is of type NC_STRING
+  @var_nm=@out(idx);
+ 
+  if( *@var_nm.type()==NC_DOUBLE && *@var_nm.has_miss() )
+  {  print(@var_nm,"about to change miss %s\n");
+     *@var_nm.change_miss(-1.0);
+  }
+
+}
+
diff --git a/data/vpointer-ex2.nco b/data/vpointer-ex2.nco
new file mode 100644
index 0000000..a2231e8
--- /dev/null
+++ b/data/vpointer-ex2.nco
@@ -0,0 +1,91 @@
+
+// Produce a list of all vars in input
+// each element of att list  is of type NC_STRING
+// nb get_var_in() can take a single argument that can be a var name or regular expression
+// lists are  of type NC_STRING and can are in essence ragged arrays
+ at all=get_vars_in();
+
+*sz=@all.size();
+*idx=0;
+
+
+// sort vars into three buckets     
+// DOUBLE, FLOAT, INT
+for(idx=0;idx<sz;idx++)
+{
+  // remember @var_nm is of type NC_STRING
+  @var_nm=@all(idx);
+  ltype=*@var_nm.type();
+
+  // push is quite clever if it is called with a "&" (reference) att
+  // and that att doesnt exist then it is created on the fly
+  if(ltype==NC_DOUBLE)
+   push(&@dv, @var_nm);
+  else if(ltype==NC_FLOAT)
+     push(&@fv, @var_nm);     
+  else if(ltype==NC_INT)
+     push(&@iv, @var_nm);
+
+}
+
+
+
+// change missing values
+sz=@dv.size();
+
+print("starting doubles\n");
+
+for(idx=0;idx<sz;idx++)
+{
+  @var_nm=@dv(idx);
+
+  if( *@var_nm.ndims()>0)
+  { 
+    *@var_nm=*@var_nm;  
+    *@var_nm.change_miss(-666.0);
+  }
+}
+
+print("starting floats\n");
+
+// average floats
+sz=@fv.size();
+
+for(idx=0;idx<sz;idx++)
+{
+  // we wish to append "_avg" to the var_nm. Since we cant easily append to NC_STRING 
+  // we convert the  NC_STRING to type NC_CHAR using sprint()
+  // then we can easily append to the NC_CHAR using push() again
+  @var_nm=sprint(@fv(idx)); 
+  @var_nm_avg=push(@var_nm,"_avg");
+  
+  if(*@var_nm.ndims() >0)
+     *@var_nm_avg=*@var_nm.avg();  
+
+}
+
+
+// permute last two dims of ints
+sz=@iv.size();
+
+print("starting ints\n");
+
+for(idx=0;idx<sz;idx++)
+{
+  @var_nm=@iv(idx);
+          
+  /// since we dont know the names of the dims -we can use placeholder arguments
+  if(*@var_nm.ndims() ==3)
+    *@var_nm=*@var_nm.permute($0,$2,$1);    
+  else if(*@var_nm.ndims() ==4)
+    *@var_nm=*@var_nm.permute($0,$1,$3,$2);    
+
+
+
+}
+
+
+
+
+
+
diff --git a/data/vpointer-tst.nco b/data/vpointer-tst.nco
new file mode 100644
index 0000000..6d41507
--- /dev/null
+++ b/data/vpointer-tst.nco
@@ -0,0 +1,41 @@
+ at all=get_vars_in();
+
+*sz=@all.size();
+
+nbr_err=0;
+*cnt_in=0;
+
+for(*idx=0;idx<sz;idx++)
+{
+  @var_nm=@all(idx);
+  // print(@var_nm,"about to test %s\n");
+  if(*@var_nm.type() == NC_INT || *@var_nm.type() == NC_FLOAT)
+  {
+       *@var_nm=*@var_nm.double();
+       cnt_in++; 
+  }
+
+} 
+
+ at out=get_vars_out();
+*sz=@out.size();
+*cnt_out=0;
+
+
+/* now check the number of conversions */
+for(*idx=0;idx<sz;idx++)
+{
+  @var_nm=@out(idx);
+
+  if(*@var_nm.type() == NC_DOUBLE)
+     cnt_out++; 
+  else
+     nbr_err++;         
+
+}
+
+if(cnt_in != cnt_out)
+{
+   nbr_err++;
+   print("ERROR with vpointer convert script\n");
+}
diff --git a/debian/changelog b/debian/changelog
index 767810c..13243f4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+nco (4.6.0-1) unstable; urgency=low
+
+  * new upstream version ncclimo, ncap2	vlists, climatology bounds, CF, terraref, ncpdq fixes
+
+ -- Charlie Zender <zender at uci.edu>  Thu, 12 May 2016 12:25:14 -0700
+
 nco (4.5.5-1) unstable; urgency=low
 
   * new upstream version crv brnch-cut
diff --git a/doc/ANNOUNCE b/doc/ANNOUNCE
index da4c24f..58d45c5 100644
--- a/doc/ANNOUNCE
+++ b/doc/ANNOUNCE
@@ -1,107 +1,172 @@
 $Header$ -*-text-*-
 
-The netCDF Operators NCO version 4.5.5 are ready. 
+The netCDF Operators NCO version 4.6.0 are ready. 
 
 http://nco.sf.net (Homepage, Mailing lists)
 http://github.com/nco (Source Code, Releases, Developers)
 
 What's new?
-NCO fully supports CDF5-format datasets, ncremap continues to
-accrue useful features, and some corner case bugs were fixed.
-
-Work on NCO 4.5.6 has commenced and will better support eliciting
-latitude/longitude coordinates using the CF "coordinates" convention
-and regridding variables whose horizontal dimensions are not the
-most-rapidly-varying.
+4.6.0 may be most notable for the debut of ncclimo, a new operator
+that generates climatologies from monthly-mean input. 
+Perhaps it's a tie with ncap2, which has a singularly useful new
+feature: variable lists/pointers. ncap2 also has a reduced memory
+footprint and a function to simplify adding CF-bounds variables
+(Thanks Henry!). As usual, ncremap continues to accrue useful
+features, the most notable of which is learning grid information
+from the CF "coordinates" attribute, if any.
+
+Work on NCO 4.6.1 has commenced and will better support regridding
+variables whose horizontal dimensions are not the
+most-rapidly-varying. 
 
 Enjoy,
 Charlie
 
 NEW FEATURES (full details always in ChangeLog):
 
-A. NCO supports the CDF5 file type first introduced by pnetCDF and now  
-   supported in Unidata netCDF as of version 4.4.0.
-   CDF5 uses 64-bit offsets for a large address space (like the netCDF
-   64BIT type) AND arrays may have more than 2^32 elements.
-   Use '-5', '--5', '--fl_fmt=[cdf5|64bit_data|pnetcdf]'.
-   Conversion to and between all netCDF filetypes is supported:
-   ncks -5 in_3.nc out_5.nc
-   ncks -5 in_7.nc out_5.nc
-   ncks -7 in_5.nc out_7.nc
-   http://nco.sf.net/nco.html#cdf5
-
-B. ncremap: -P option triggers filetype-specific workflow procedures
-   (such as automatic permutation). Currently filetype-specific
-   handling is defined for AIRS, HIRDLS, MLS, and MPAS files:
-   ncremap -P airs   -i airs.nc -m map.nc -o out.nc
-   ncremap -P hirdls -i airs.nc -m map.nc -o out.nc
-   ncremap -P mls    -i airs.nc -m map.nc -o out.nc
-   ncremap -P mpas   -i mpas.nc -m map.nc -o out.nc
-   One aspect of this handling is to rearrange dimension ordering
-   from the way NASA/MPAS distributes generates these datasets so 
-   that horizontal spatial dimensions (lat, lon) come last.
-   This is friendlier for regridding applications.
-
-C. ncremap: -m map_fl supplies names to generated mapfiles and ncremap 
-   annotates map-files it creates with full history. This helps retain
-   provenance in generated mapfiles. And ncremap has a friendlier
-   mode, "map-only" mode, to generate mapfiles for later use.
-   To use this mode, call ncremap without any input files to remap.  
-   ncremap will then generate the mapfile then exit.
-   ncremap -i in.nc -d dst.nc -m map.nc -o out.nc # Named mapfile
-   ncremap -s grd_in.nc -g grd_out.nc -m map.nc # Map-only mode
+A. ncclimo produces climatological monthly means, seasonal means, 
+   annual mean, and optionally regrids all these files. Like ncremap,
+   ncclimo is actually a front-end script to manage the complexity
+   of invoking the underlying operators (ncks for ncremap and ncra for
+   ncclimo). ncclimo produces climatologies starting from monthly-mean
+   files of most CESM-like model and observational data formats.
+   Invoke ncclimo with, e.g.,
+   ncclimo -s start_yr -e end_yr -c run_id -i drc_in -o drc_out
+   ncclimo -s 5 -e 10 -c hist -m ocn -i drc_in -o drc_out
+   ncclimo -s 1980 -e 2016 -c merra2_198001.nc -i drc_in -o drc_out
+   ncclimo has sophisticated parallelism and regridding options.
+   Datasets tested include ALM, CAM, CLM, CICE, CISM, CLM, MPAS-I,
+   MPAS-O, and POP. ncclimo resulted from work with the DOE ACME
+   project, and we are grateful for their support.
+   http://nco.sf.net/nco.html#ncclimo
+   http://nco.sf.net/nco.html#merra2
+
+B. ncap2 now works with pointers to variables and attributes.
+   This allows, e.g., loops over arbitrary sets of variables, and
+   make creating aggregations of variables much simpler. An ncap2
+   script that converts all float variables to double precision:
+   @all=get_vars_in();
+   *sz=@all.size();
+   for(idx=0;idx<sz;idx++){
+     @var_nm=sprint(@all(idx));
+     if(*@var_nm.type() == NC_FLOAT) *@var_nm=*@var_nm.double();
+   }
+   Congratulations Henry for finishing this impressive functionality! 
+   More documentation will be added in the coming weeks. For now,      
+   http://nco.sf.net/nco.html#ncap2
+
+C. ncap2 has reduced memory usage. Scalars are no longer stretched
+   to conform to arrays prior to arithmetic.
+
+D. ncap2 has a new function to create CF-compliant bounds:
+   defdim("bnd_dmn",2);
+   bounds_var=make_bounds(crd_var,$bnd_dmn,"bounds_var_nm");
+   The "bounds_var_nm" is optional. Passing it causes make_bounds() to 
+   add the attribute crd_var at bounds="bounds_var_nm".
+   http://nco.sf.net/nco.html#make_bounds
+
+E. ncap2 now propagates metadata when Left-Hand-Casting variables.
+   Previous versions did not propagate metadata to LHC variables.
+   This fix makes converting the _type_ of a variable easier.
+   For example, to change one_dmn_rec_var to NC_SHORT, use
+   ncap2 -s 'one_dmn_rec_var[time]=short(one_dmn_rec_var)' in.nc out.nc
+   The output file will contain the original metadata.
+   http://nco.sf.net/nco.html#ncap2
+
+F. ncatted new mode "nappend" appends only to existing attributes.
+   If the attribute does not yet exist, it is not created.
+   Same as "append" mode, except "append" will create attributes.
+   ncatted -a long_name,T,n,c,' nappended text' in.nc
+   http://nco.sf.net/nco.html#ncatted
+
+G. ncpdq now has a third unpacking mode.
+   Access non-default modes with --upk=[0,1,2] where
+   Mode 0: Applies netCDF convention. Default mode:
+   upk=scale_factor*pck+add_offset   
+   Mode 1: HDF4 MODIS MOD08 convention: 
+   upk=scale_factor*(pck-add_offset)
+   Mode 2: HDF4 MODIS MOD13 convention: 
+   upk=(pck-add_offset)/scale_factor
+   Yes, be careful unpacking HDF4 data!
+   http://nco.sf.net/nco.html#hdf_upk
+   
+H. ncra can now honor the CF convention for climatology bounds.
+   Currently this is opt-in with the --cb or --c2b switches.
+   --cb causes ncra to:
+   1. Add a "climatology" attribute with value "climatology_bounds" to 
+   the time coordinate, if necessary
+   2. Remove the "bounds" from the time coordinate, if necessary
+   3. Output a variable named "climatology_bounds" with values that
+   are minima/maxima of the input time coordinate bounds 
+   4. Omit any input time coordinate bounds attribute and variable
+   5. Ensure cell_methods attribute for all variables is appropriate 
+   --c2b is like --cb except --c2b converts the input "climatology"
+   bounds to a non-climatology "bounds" in the output. 
+   Use --c2b when averaging sub-sampled climatologies to produce a
+   continuous (non-climatologically sub-sampled) mean.
+   ncra --cb *_01.nc clm_JAN.nc
+   ncra --cb clm_DEC.nc clm_JAN.nc clm_FEB.nc clm_DJF.nc
+   ncra --c2b clm_DJF.nc clm_MAM.nc clm_JJA.nc clm_SON.nc clm_ANN.nc
+   Depending on feedback, we may make --cb the default
+   http://nco.sf.net/nco.html#cb
+
+I. ncremap now defaults to $TMPDIR for storing intermediate files.
+   This is user-configurable with the -U switch.
    http://nco.sf.net/nco.html#ncremap
 
-D. ncremap -j job_nbr option for MPI parallelism
+J. ncks can now ingest and de-interleave ENVI images in BIL, BSQ, and
+   BIP formats and store them as any netCDF type. ncks is a viable
+   (and faster) replacement for that small subset of tasks normally
+   done by the venerable GDAL toolkit (gdal_translate in particular).
+   Thanks to David LeBauer of the University of Illinois/NCSA and DOE
+   TERRAREF for supporting this feature.
+   ncks --trr_wxy=926,1600,1 --trr typ_in=NC_USHORT --trr ntl_in=bil \
+   --trr_in=in.nc foo.nc out.nc
+   http://nco.sf.net/nco.html#terraref
+
+K. NCO now treats as associated coordinates all variables listed in
+   "grid_mapping" attributes. Variables such as
+   "char albers_conical_equal_area" are automatically extracted along
+   with variables that them. ncecat will not wrap mappings in a record
+   dimension. 
+   http://nco.sf.net/nco.html#grid_mapping
+
+L. ncremap and ncks now follow the CF "coordinates" convention when
+   inferring grids and remapping. One specifies the variable that may
+   have the "coordinates" attribute, and NCO will inspect and apply
+   the "coordinates" convention for that variable for grid generation
+   and remapping.  
+   ncremap -V var_nm -s src.nc -d dst.nc -m map.nc
+   ncremap -V var_nm --map map.nc in.nc out.nc
+   ncks --rgr_var=var_nm --rgr nfr=y --rgr grid=grd.nc in.nc foo.nc
+   ncks --rgr_var=var_nm --map map.nc in.nc out.nc
    http://nco.sf.net/nco.html#ncremap
-
-E. ncra/nces/ncwa: New operation tabs()=total_absolute_value.
-   The the -y tabs option is like -y ttl except the sum is over
-   absolute values. tabs(), mibs(), mebs(), and mabs() are analogous
-   to ttl(), min(), mean(), and max(). 
-   nces -y tabs in.nc in.nc out.nc
-   ncra -y tabs in.nc in.nc out.nc
-   ncwa -y tabs in.nc out.nc
-   http://nco.sf.net/nco.html#op_typ
-
-F. Improve support for Cygwin builds
+   http://nco.sf.net/nco.html#regrid
 
 BUG FIXES:
 
-A. ncremap: Inferred curvilinear grids always return points now in
-   counterclockwise order. Version 4.5.4 sometimes did not. 
-   This caused bad things to happen in the weight-generators.
-
-B. ncremap: Inferring grids from curvilinear coordinates no longer
-   confused by "branch cuts" (i.e., the date-line). ncremap version
-   4.5.4 would sometimes infer concave gridcells that then confused
-   mapping software. Thanks to Feng Ding for reporting the problem.
-
-C. ncpdq: Fix problem that could cause '--gaa' option to fail in
-   earlier versions. 
-
-D. nces: Copy attributes of coordinate variables in nces --nsm_grp.
-   Previous versions omitted the attributes of coordinates (not
-   regular variables) in the ensemble average group. Thanks to Hannah
-   Nissan for reporting and Pedro Vicente for fixing this.
+A. Correct ncatted documentation for "append" mode.
 
-E. ncra/nces: Correctly normalize "mebs" arithmetic. Under certain
-   conditions previous versions did not correctly normalize sums
-   computed with the mebs (mean absolute value) operator. Problem
-   reported by Will Koeppen. 
+B. Fix Append mode to follow same code path and defaults when
+   requested with -A and with interactive responses to the
+   exit/append/overwrite question. Thanks to Parker Norton for
+   pointing out this inconsistency. 
 
-F. ncap2: Fix incorrect handling of negative dimension indices.
-   Problem reported by Maksym Petrenko.
+C. ncpdq fix complex reordering in group hierarchies.
+   Previously ncpdq could misorder dimensions when multiple
+   different dimensions shared the same short name (in different
+   groups). Thanks to Pedro Vicente for tracking-down and fixing
+   this bug! And finding and fixing another ncpdq bug that had
+   not yet been reported in the wild.
 
-G. ncatted/ncrename: Fully support --glb_att_add=--gaa.
-   This corrects an earlier oversight.
-   http://nco.sf.net/nco.html#gaa
+D. ncap2 fix bug propagating attributes of variables with whitespace
+   in their names. 
 
 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 4.5.5 built/tested under
+   These problems occur with NCO 4.6.0 built/tested under
    MacOS with netCDF 4.3.3.1 on HDF5 1.8.16 and with
    Linux with netCDF 4.4.1-development (20160212) on HDF5 1.8.13.
 
@@ -155,6 +220,7 @@ B. NOT YET FIXED (netCDF4 library bug)
    20150922: Confirmed problem reported by Isabelle Dast, reported to Unidata
    20150924: Unidata confirmed problem
    20160212: Verified problem still exists in netCDF library
+   20160512: Ditto
 
    Bug tracking: https://www.unidata.ucar.edu/jira/browse/fxm
    More details: http://nco.sf.net/nco.html#ncrename_crd
diff --git a/doc/ChangeLog b/doc/ChangeLog
index c68211f..6469871 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,334 @@
+2016-05-12  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.6.0 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.6.0 final changes';git push
+	git tag -a 4.6.0 -m 'Version 4.6.0 new features: ncclimo, ncap2	vlists, climatology bounds, CF, terraref, ncpdq fixes';git push --tags
+
+2016-05-12  Henry Butowsky  <henryb at hush.com>
+
+	* Fix nasty bug in out()/att(hyperslab) action for NC_STRING that caused double free() on clang
+
+2016-05-11  Charlie Zender  <zender at uci.edu>
+
+	* Allow for "coordinates"-ordering opposite to storage (LRV->MRV) order, e.g., "coordinates=[longitude,latitude]" instead of "coordinates=[longitude,latitude]"
+
+2016-05-09  Charlie Zender  <zender at uci.edu>
+
+	* Shorten unique name suffix in ncremap
+
+	* Add -V var_rgr option to ncremap to invoke --rgr_var=var_rgr for CF grid inferral and remapping
+
+2016-05-06  Charlie Zender  <zender at uci.edu>
+
+	* Pedro committed ncpdq patches that fix vexing longstanding problems permuting in group hierarchies
+
+2016-05-05  Henry Butowsky  <henryb at hush.com>
+
+	* Add space ' ' to allowed chars in a quoted var or att which can be:
+	  VAR_NM_QT: (LPHDGT|'-'|'+'|'.'|'('|')'|':'|' ' )+  ;
+	  Full NetCDF specification for ID includes UTF8 characters (save that for another day)
+
+2016-05-04  Charlie Zender  <zender at uci.edu>
+
+	* Fix nces tabs regression test
+
+2016-05-03  Charlie Zender  <zender at uci.edu>
+
+	* Successfully used CF-coordinate method in both nco_rgr_map() and nco_grd_nfr() when triggered by --rgr_var option
+
+	* Improve and simplify nco_grd_nfr() logic for grid determination, introduce and respect lon_dmn and lat_dmn options for dimension names
+
+	* Inferring grids from CF "coordinates" attribute works, now remapping needs same logic...
+
+	* Check units of coordinate variables
+
+	* Add stubs to check CF "coordinates" attribute to infer grid
+
+2016-05-02  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.6.0-beta05 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.6.0-beta05 final changes';git push
+	git tag -a 4.6.0-beta05 -m 'Version 4.6.0-beta05 new features: ncclimo/ncremap rgr, netCDF4 grids, upk MOD13, SLURM_NODELIST';git push --tags
+
+	* ncpdq: initialize REDEFINED_RECORD_DIMENSION=False only once, before variable loop (bug caught by Pedro)
+
+	* ncpdq: change "break;" to "continue;" (bug caught by Pedro)
+
+	* Fix non-interactive batch mode on SLURM to expand SLURM_NODELIST and store as file like PBS and Cobalt
+
+2016-05-01  Charlie Zender  <zender at uci.edu>
+
+	* Change --upk switch. Was flag and synonym for -U, --unpack (ncpdq only)
+	Now --upk arg where arg=[0,1,2]=[netCDF=MOD04,MOD10,MOD13] unpacking algorithm
+
+	* Expand HDF4 hdf_upk logic to nco_upk_HDF_MOD10, nco_upk_HDF_MOD13 for MODIS MOD10CM and MOD13C2 datasets
+
+	* Correct order of shuffle,deflate in nco_var_def_deflate()
+
+	* Respect fl_fm_out and dfl_lvl in nco_grd_mk(), nco_grd_nfr(), nco_rgr_map()
+
+2016-04-29  Charlie Zender  <zender at uci.edu>
+
+	* Add ncremap and ncclimo regression tests when $USER=zender
+
+2016-04-29  Henry Butowsky  <henryb at hush.com>
+
+	* Add has_miss() to the _miss() familty in utl_cls()
+
+2016-04-28  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.6.0-beta04 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.6.0-beta04 final changes';git push
+	git tag -a 4.6.0-beta04 -m 'Version 4.6.0-beta04 new features: TMPDIR, var=var.double(), c2b, grid_mapping';git push --tags
+
+	* Finish first pass at documenting ncclimo
+
+2016-04-28  Henry Butowsky  <henryb at hush.com>
+
+	* IMPORTANT: revert mods in 4.5.4. Once again variables in input can be redefined in output without a cast:
+	  time=time.int() is once again exactly equivalent to time[$time]=time.int()
+
+	* Add to regular assign statement conformance of RHS, e.g, n2[time,lat,lon]=10.0;n2=time; // stretches time to conform to n2
+
+2016-04-28  Henry Butowsky  <henryb at hush.com>
+
+        * Add bsc_tst.nco to ncap2 perl test suite. Currently tests casting, hyperslabbing, and intrinsic functions.
+
+2016-04-28  Henry Butowsky  <henryb at hush.com>
+
+	* Changed RAM variables that represent netCDF types from __FLOAT, __DOUBLE ... to
+          NC_NAT, NC_BYTE, NC_UBYTE, ... NC_FLOAT, NC_DOUBLE
+	  Use these with the type() method,  e.g, if(var.type() == NC_FLOAT) var=var.double()
+
+2016-04-27  Charlie Zender  <zender at uci.edu>
+
+	* ncremap fix drc_tmp logic to work without $TMPDIR
+
+	* ncremap search for ERWG, Tempest before trying to execute them
+
+	* ncclimo add debugging info for MPI node list
+
+2016-04-26  Charlie Zender  <zender at uci.edu>
+
+	* Reset rcd handling in CF bounds logic
+
+	* Add ncclimo support for "generic" datasets (like NASA MERRA) with YYYYMM format
+
+2016-04-22  Charlie Zender  <zender at uci.edu>
+
+	* Document --cb, --c2b
+
+2016-04-20  Charlie Zender  <zender at uci.edu>
+
+	* Treat as coordinates all variables listed in a "grid_mapping" attribute
+
+	* Default source code download links now point to GitHub not SF
+
+2016-04-18  Charlie Zender  <zender at uci.edu>
+
+	* Excise old CF-handling from ncclimo
+
+	* NCO 4.6.0-beta03 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.6.0-beta03 final changes';git push
+	git tag -a 4.6.0-beta03 -m 'Version 4.6.0-beta03 new features: ncclimo, climatology bounds';git push --tags
+
+	* Turn-off dysfunctional legible (lgb) print-formatting until it works
+
+	* Coordinate cell_methods with climatology bounds
+
+	* Copy missing calendar to temporal bounds so ncdump -t prints correct date
+
+2016-04-17  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.6.0-beta02 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.6.0-beta02 final changes';git push
+	git tag -a 4.6.0-beta02 -m 'Version 4.6.0-beta02 new features: ncclimo, climatology bounds';git push --tags
+
+	* Copy missing units to temporal bounds so ncdump -t prints correct date
+
+2016-04-16  Charlie Zender  <zender at uci.edu>
+
+	* Work on climatology_bounds for ACME...
+
+2016-04-15  Henry Butowsky  <henryb at hush.com>
+
+	* Modify out() and assign() so ASSIGN familiy of operands and '++', -- operands a value is returned only if needed
+
+	* Fix bug introduced in 4.5.4: Regular assign statements in two-parse operations did not propagate missing values from RHS to LHS. Following test now works ncap2 -v -O -S gsl_sf.in in.nc foo.nc
+
+2016-04-12  Charlie Zender  <zender at uci.edu>
+
+	* Print blank line after global attributes in CDL mode in nco_prn_att()
+
+2016-04-08  Henry Butowsky  <henryb at hush.com>
+
+	* Modify ncap_var_var_op() and ncap_var_var_inc() so two operand functions need not stretch or conform scalars
+
+2016-04-07  Charlie Zender  <zender at uci.edu>
+
+	* Split cori from edison binary locations to allow for different system libraries
+
+2016-04-06  Charlie Zender  <zender at uci.edu>
+
+	* Add skeleton structure to implement climatology_bnds convention in ncra
+
+2016-04-04  Charlie Zender  <zender at uci.edu>
+
+	* Clarify ncks -H documentation, say clearly that it toggles
+
+2016-04-01  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.6.0-beta01 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.6.0-beta01 final changes';git push
+	git tag -a 4.6.0-beta01 -m 'Version 4.6.0-beta01 new features: Terraref works well';git push --tags
+
+	* Change default temporary directory (for intermediate files) from $drc_out to $TMPDIR
+
+	* Trim trailing slash from drc_out, drc_tmp so $TMPDIR looks right
+
+2016-03-31  Charlie Zender  <zender at uci.edu>
+
+	* Make FORCE_APPEND I/O in nco_fl_out_open(), and set to true when user interactively selects append
+	This ensures specifying -A follows same code path as interactively selecting append. Fixes bug reported by Parker Norton.
+
+2016-03-31  Henry Butowsky  <henryb at hush.com>
+
+	* Modify LHC casting so "pathological" expressions like 'three_dmn_var_dbl[time,lon,lat]=three_dmn_var_dbl.int()' work
+
+2016-03-30  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.5.6-alpha06 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.5.6-alpha06 final changes';git push
+	git tag -a 4.5.6-alpha06 -m 'Version 4.5.6-alpha06 new features: trr ntl ncap2 att prp';git push --tags
+
+	* Successfully (de-)interleave ENVI files (viable GDAL replacement)!
+
+	* Change default gaa mode (back from) append to overwrite to prevent repeated values in climo_nco.sh ANN files
+
+2016-03-29  Charlie Zender  <zender at uci.edu>
+
+	* Functionalize nco_sng2typ()
+
+	* Full Terraref trr infrastructure: nco_trr_ini(), nco_trr_read(), nco_trr_free()
+
+2016-03-28  Charlie Zender  <zender at uci.edu>
+
+	* Add binary file read utilities
+
+	* Clarify append message to include metadata consequences
+
+2016-03-24  Henry Butowsky  <henryb at hush.com>
+
+	* Implement new notation to LHC a scalar, e.g., four[]=10;
+
+2016-03-24  Charlie Zender  <zender at uci.edu>
+
+	* Initialize kvm.val to NULL to handle empty values, e.g., --gaa history=""
+
+2016-03-24  Henry Butowsky  <henryb at hush.com>
+
+	* Attribute propagation from RHS now works with LHC
+
+2016-03-22  Charlie Zender  <zender at uci.edu>
+
+	* ncremap uses append not overwrite mode
+
+	* ncatted new nappend mode appends only to existing attributes
+
+2016-03-18  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.5.6-alpha05 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.5.6-alpha05 final changes';git push
+	git tag -a 4.5.6-alpha05 -m 'Version 4.5.6-alpha05 new features: ncap2 pointers, terraref';git push --tags
+
+	* Add paths for LLNL aims machines to ncremap, climo_nco.sh, climo_ann.sh
+
+2016-03-18  Henry Butowsky  <henryb at hush.com>
+
+	* Removed all print functions from ncoGrammar
+
+	* Print now handled as method by print_cls() in fmc_all_cls.cc
+
+2016-03-09  Charlie Zender  <zender at uci.edu>
+
+	* Change CPP VERSION token to NCO_VERSION to prevent namespace conflict with other packages
+
+2016-03-08  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.5.6-alpha04 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.5.6-alpha04 final changes';git push
+	git tag -a 4.5.6-alpha04 -m 'Version 4.5.6-alpha04 new features: ncremap handles 1D pseudo-rectangular input like OCO2';git push --tags
+
+	* Finalize modifications to handle OCO2 and properly diagnose bad input data
+
+	* Perform branch-cut analysis and CCW correction on pseudo-rectangular input
+
+2016-03-07  Charlie Zender  <zender at uci.edu>
+
+	* OCO2 bounds are given as CW not CCW so must ensure CCW before writing to output
+
+	* Add OCO2 bounds latitude_bnds, longitude_bnds and fixes for 1D-pseudo-rectangular bounds
+
+2016-03-06  Charlie Zender  <zender at uci.edu>
+
+	* Fix Bit-Set algorithm (--baa=2) not to quantize zero upward
+
+	* Fix Bit-Set algorithm (--baa=2) to "or and" not "and and"
+
+2016-03-01  Charlie Zender  <zender at uci.edu>
+
+	* Test automatic double->float conversion for regridding storage to conserve space. Abandon until missing value conversion also done.
+
+	* Allow flg_frc_nrm && rgr->flg_rnr to work so MPAS-I bilinear regridding with --rnr completes.	Full ramifications unclear.
+
+2016-02-29  Charlie Zender  <zender at uci.edu>
+
+	* Modify ncpdq -a option in ncremap to handle MPAS ice dimensions
+
+	* NCO 4.5.6-alpha03 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.5.6-alpha03 final changes';git push
+	git tag -a 4.5.6-alpha03 -m 'Version 4.5.6-alpha03 new features: ncremap add cmd_msh to history';git push --tags
+
+	* Brown paper bag release--switching from nco_put_vara() to nco_put_var() broke ... a lot
+
+	* Add cmd_msh to history attribute of maps generated by Tempest
+
+2016-02-28  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.5.6-alpha02 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.5.6-alpha02 final changes';git push
+	git tag -a 4.5.6-alpha02 -m 'Version 4.5.6-alpha02 new features: FV slat/slon, unique names, clean-up, ncatted -t, NC_NOFILL,nc_put_var(),ncremap -U';git push --tags
+
+	* Add specifiable directory for intermediate files: ncremap -U drc_tmp
+
+	* Add list of MPAS grid and extensive variables to exclude
+
+	* Add wrappers for nc_put_var(), nc_get_var() families
+
+	* Add ncatted -t --typ_mch --type_match switch for editing all variables whose type matches attribute type and no others
+
+	* Turn-off fill mode in regridding
+
+	* Add history to ncatted when called by ncremap
+
+2016-02-27  Charlie Zender  <zender at uci.edu>
+
+	* ncremap does not annotate with ncatted when called from climo_nco.sh
+
+	* Use unique intermediate filenames by default in ncremap, to prevent interference during parallel invocations
+
+	* Add slat/slon coordinates to FV output grids for interoperability with AMWG diagnostics
+
+2016-02-26  Charlie Zender  <zender at uci.edu>
+
+	* NCO 4.5.6-alpha01 release procedure:
+	cd ~/nco;git commit -a -m 'Version 4.5.6-alpha01 final changes';git push
+	git tag -a 4.5.6-alpha01 -m 'Version 4.5.6-alpha01 new features: ncremap MPAS --rnr=0.0';git push --tags
+
+	* ncremap: use ncatted to add _FillValue for MPAS
+
+	* ncremap: make --rnr=0.0 default for MPAS
+
 2016-02-17  Charlie Zender  <zender at uci.edu>
 
 	* NCO 4.5.5 release procedure:
diff --git a/doc/MANIFEST b/doc/MANIFEST
index beddcc8..44463d9 100644
--- a/doc/MANIFEST
+++ b/doc/MANIFEST
@@ -112,6 +112,7 @@ nco/data/ncap2.in	Sample ncap2 input script
 nco/data/ncap2_tst.nco  ncap2 self-printing test script
 nco/data/ncl.ncl	NCL script to compare to NCO scripts for speed
 nco/data/nco_bnch.sh	Old (deprecated) NCO benchmark script
+nco/data/ncclimo	ncclimo operator
 nco/data/ncremap	ncremap operator
 nco/data/netcdf4.nco	Sample input script for netCDF4-enabled ncap2
 nco/data/obs.cdl 	CDL file to test group broadcasting
@@ -175,6 +176,7 @@ nco/man/Makefile.in(v)	Autotools-generated Makefile
 nco/man/ncap.1		ncap man page
 nco/man/ncatted.1	ncatted man page
 nco/man/ncbo.1		ncbo man page
+nco/man/ncclimo.1	ncclimo man page
 nco/man/nces.1		nces man page
 nco/man/ncecat.1	ncecat man page
 nco/man/ncflint.1	ncflint man page
diff --git a/doc/TODO b/doc/TODO
index b4231f0..437f988 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -675,7 +675,10 @@ nco1126. ncra segfault with MSA christine smit regardless of presence of scale_f
       ncra -O -C -v one_dmn_rec_var -d time,0,0 -d time,2,2 ~/nco/data/in.nc ~/foo.nc # borken
       ncra -O -C -v one_dmn_rec_var -d time,0,0 -d time,1,1 ~/nco/data/in.nc ~/foo.nc # works
 nco1127. nco: replicate nco_var_dpl() method of deep-copying NC_STRING in nco_var_avg() so nco_var_free() can correctly free() var_sct for NC_STRING
-nco1128. 
+nco1128. nco: ncrename --lowercase --uppercase options? MERRA2 merra
+       ncrename -v all,lowercase in.nc out.nc
+       ncrename --lowercase --var .ONE,.TWO,... in.nc out.nc
+nco1129. 
 qrk
 ************************************************************************
 End ncoXXX TODOs
diff --git a/doc/VERSION b/doc/VERSION
index 3afbea7..6016e8a 100644
--- a/doc/VERSION
+++ b/doc/VERSION
@@ -1 +1 @@
-4.5.5
+4.6.0
diff --git a/doc/debian.txt b/doc/debian.txt
index 1baa8ce..73ef62e 100644
--- a/doc/debian.txt
+++ b/doc/debian.txt
@@ -29,18 +29,18 @@ apt-get install dh-make debhelper devscripts fakeroot gnupg debian-policy develo
 
 2. Debian build procedure recommends placing entire package source in
    subdirectory of main package. 
-   For starters, we wish to create .debs of tagged releases, e.g., nco-4.5.5
-   First we create a clean source distribution of nco and place it in nco-4.5.5
+   For starters, we wish to create .debs of tagged releases, e.g., nco-4.6.0
+   First we create a clean source distribution of nco and place it in nco-4.6.0
    Until we know what is necessary, however, we just copy a snapshot
    
    2.1 Clean all build files from development directory
 
 cd ~/nco;make distclean;cd bld;make clean;cd ~
 tar cvzf ./nco/nco.tar.gz ./nco/*
-cd ~/nco;tar xvzf nco.tar.gz;mv nco nco-4.5.5
-/bin/rm nco.tar.gz;tar cvzf nco-4.5.5.tar.gz ./nco-4.5.5/*
-cd ~/nco/nco-4.5.5
-dh_make -e zender at uci.edu -f ../nco-4.5.5.tar.gz
+cd ~/nco;tar xvzf nco.tar.gz;mv nco nco-4.6.0
+/bin/rm nco.tar.gz;tar cvzf nco-4.6.0.tar.gz ./nco-4.6.0/*
+cd ~/nco/nco-4.6.0
+dh_make -e zender at uci.edu -f ../nco-4.6.0.tar.gz
 
     2.2 The preceding steps created template debian files for a .deb,
     Those files now reside in ~/nco/debian.
@@ -55,7 +55,7 @@ dh_make -e zender at uci.edu -f ../nco-4.5.5.tar.gz
    from previous build
 
    cd ~/nco;/bin/rm *.gz
-   cd ~/nco/nco-4.5.5
+   cd ~/nco/nco-4.6.0
    dpkg-buildpackage -rfakeroot > foo 2>&1
    dpkg-buildpackage -rsudo > foo 2>&1
 
@@ -84,33 +84,33 @@ patch -p0 < nco_X.Y.Z-3.diff   # Patch destination with Debian diff
    make tags
 # Put cute version-specific string in nco_ctl.c:nco_nmn_get()
 # Install correct version numbers before updating Debian
-# tags-query replace 4.5.5 with X.Y.Z+1
+# tags-query replace 4.6.0 with X.Y.Z+1
 # If tags-query replace does not work, be sure to manually change
 # versions in configure.ac, debian/files, doc/ANNOUNCE, doc/debian.txt,
 # doc/index.shtml, doc/nco.texi, bld/nco_dst.pl, doc/VERSION
 # 20141201: Change NCO_VERSION_PATCH in src/nco.h!!!!!!!!!!!!!!!!!!!!!!
-   cd ~/nco/debian;dch -b --force-distribution --distribution=unstable -v 4.5.5-1 # Update changelog (-b forces this version number)
+   cd ~/nco/debian;dch -b --force-distribution --distribution=unstable -v 4.6.0-1 # Update changelog (-b forces this version number)
    emacs ~/nco/bld/nco.spec # Update changelog
 # For unknown reason rules file may lose its executable bit
    chmod a+x ~/nco/debian/rules
 # Rebuild autotools so new version # propagates
    cd ~/nco;aclocal;autoheader;automake --foreign;autoconf
 # Save all files in emacs before tagging
-   ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln nco-4.5.5
+   ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln nco-4.6.0
 # Upload tarball to SF https://sourceforge.net/projects/nco/files 
-   cd;scp dust.ess.uci.edu:/var/www/html/nco/src/nco-4.5.5.tar.gz .
+   cd;scp dust.ess.uci.edu:/var/www/html/nco/src/nco-4.6.0.tar.gz .
 
 7. Ubuntu PPA
 https://help.launchpad.net/Packaging/PPA
-dput NCO nco_4.5.5-2~ppa1_source.changes
+dput NCO nco_4.6.0-2~ppa1_source.changes
 sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com
 
 # Location of build diagnostics for mentors to help 
-http://dust.ess.uci.edu/nco/src/nco_4.5.5-1.dpkg-buildpackage.txt
-http://dust.ess.uci.edu/nco/src/nco_4.5.5-1.dsc
-http://dust.ess.uci.edu/nco/src/nco_4.5.5-1_i386.changes
-http://dust.ess.uci.edu/nco/src/nco_4.5.5-1_i386.deb
-http://dust.ess.uci.edu/nco/src/nco_4.5.5.orig.tar.gz
+http://dust.ess.uci.edu/nco/src/nco_4.6.0-1.dpkg-buildpackage.txt
+http://dust.ess.uci.edu/nco/src/nco_4.6.0-1.dsc
+http://dust.ess.uci.edu/nco/src/nco_4.6.0-1_i386.changes
+http://dust.ess.uci.edu/nco/src/nco_4.6.0-1_i386.deb
+http://dust.ess.uci.edu/nco/src/nco_4.6.0.orig.tar.gz
 
 # Becoming a Debian developer
 http://www.debian.org/devel/join/newmaint
@@ -164,31 +164,31 @@ Matej Vela <vela at debian.org>, Daniel Baumann <daniel at debian.org>, Warren Turkal
 # export LD_LIBRARY_PATH=/usr/lib:/lib:/usr/X11R6/lib
 # sudo aptitude install antlr bison flex gsl-bin libgsl0-dev libantlr-dev netcdf-bin libnetcdfc7 libnetcdf-dev texinfo libcurl4-gnutls-dev libexpat1-dev libxml2-dev udunits-bin libudunits2-0 libudunits2-dev
 cd ~/nco;cvc
-sudo /bin/rm -rf ${DATA}/nco-4.5.5 ${DATA}/nco_4.5.5* ${DATA}/debian # Cleanup last build. sudo necessary for removal because dpkg-buildpackage uses sudo?
-# cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -r nco-4.5.5-1 -d nco-4.5.5 nco # Export based on tag
-cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -D "1 second ago" -d nco-4.5.5 nco # Export most recent
-tar cvzf ./nco_4.5.5.orig.tar.gz --exclude='nco-4.5.5/debian*' --exclude='.cvsignore' --exclude='ncap_lex.c' --exclude='ncap_yacc.[ch]' ./nco-4.5.5 
-/bin/rm -rf ${DATA}/nco-4.5.5 # Remove cvs-exported directory
-tar xvzf ./nco_4.5.5.orig.tar.gz # Untar to get directory without excluded files
-mkdir -p ${DATA}/nco-4.5.5/debian/source;cd ~/nco/debian;/bin/cp changelog compat control convert copyright doc-base files info rules ${DATA}/nco-4.5.5/debian;cd ~/nco/debian/source;/bin/cp format ${DATA}/nco-4.5.5/debian/source # Replace debian directory with _CURRENT_ (main trunk) settings
+sudo /bin/rm -rf ${DATA}/nco-4.6.0 ${DATA}/nco_4.6.0* ${DATA}/debian # Cleanup last build. sudo necessary for removal because dpkg-buildpackage uses sudo?
+# cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -r nco-4.6.0-1 -d nco-4.6.0 nco # Export based on tag
+cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -D "1 second ago" -d nco-4.6.0 nco # Export most recent
+tar cvzf ./nco_4.6.0.orig.tar.gz --exclude='nco-4.6.0/debian*' --exclude='.cvsignore' --exclude='ncap_lex.c' --exclude='ncap_yacc.[ch]' ./nco-4.6.0 
+/bin/rm -rf ${DATA}/nco-4.6.0 # Remove cvs-exported directory
+tar xvzf ./nco_4.6.0.orig.tar.gz # Untar to get directory without excluded files
+mkdir -p ${DATA}/nco-4.6.0/debian/source;cd ~/nco/debian;/bin/cp changelog compat control convert copyright doc-base files info rules ${DATA}/nco-4.6.0/debian;cd ~/nco/debian/source;/bin/cp format ${DATA}/nco-4.6.0/debian/source # Replace debian directory with _CURRENT_ (main trunk) settings
 #export DEB_BUILD_OPTIONS='disable-dap-netcdf disable-netcdf4 disable-udunits2'; # Disable optional packages based on available Debian support
-#cd ${DATA}/nco-4.5.5;dpkg-buildpackage -rsudo -uc -us > ~/foo.nco 2>&1 # -uc -us: Do not sign changes or source files
-#cd ${DATA}/nco-4.5.5;dpkg-buildpackage -rsudo -sa > ~/foo.nco 2>&1 # -sa: Include _orig.tar.gz in .changes 
-cd ${DATA}/nco-4.5.5;dpkg-buildpackage -rsudo > ~/foo.nco 2>&1
+#cd ${DATA}/nco-4.6.0;dpkg-buildpackage -rsudo -uc -us > ~/foo.nco 2>&1 # -uc -us: Do not sign changes or source files
+#cd ${DATA}/nco-4.6.0;dpkg-buildpackage -rsudo -sa > ~/foo.nco 2>&1 # -sa: Include _orig.tar.gz in .changes 
+cd ${DATA}/nco-4.6.0;dpkg-buildpackage -rsudo > ~/foo.nco 2>&1
 sudo dpkg --remove nco
-sudo dpkg --install ${DATA}/nco_4.5.5-1_*.deb
+sudo dpkg --install ${DATA}/nco_4.6.0-1_*.deb
 cd ~/nco/bld;MY_BIN_DIR=/usr/bin ../bm/nco_bm.pl --regress
 # http://lintian.debian.org/full/zender@uci.edu.html
-lintian ${DATA}/nco_4.5.5-1_*.deb
-ls -l ${DATA}/nco_4.5.5*
+lintian ${DATA}/nco_4.6.0-1_*.deb
+ls -l ${DATA}/nco_4.6.0*
 m ~/foo.nco
 # Upload Ubuntu (rather than Debian) packages to websites
-scp ${DATA}/nco_4.5.5* dust.ess.uci.edu:/var/www/html/nco/src
-scp ${DATA}/nco_4.5.5* zender,nco at web.sf.net:/home/project-web/nco/htdocs/src
+scp ${DATA}/nco_4.6.0* dust.ess.uci.edu:/var/www/html/nco/src
+scp ${DATA}/nco_4.6.0* zender,nco at web.sf.net:/home/project-web/nco/htdocs/src
 # NB: Make sure RPMs build before uploading to debian, since changing
 # Debian versions is a PITA
 # NB: Only upload pbuilder Debian Sid (not personal Ubuntu) .deb builds to Debian mentors
-# cd ${DATA};dupload -t mentors nco_4.5.5-1_*.changes
+# cd ${DATA};dupload -t mentors nco_4.6.0-1_*.changes
 bsrc # Reset shell environment for regular development
 
 # New build system #2
@@ -202,52 +202,52 @@ DIST=sid sudo pbuilder update # Update chroot before building package in it
 # dget http://ftp.debian.org/debian/pool/main/n/nco/nco_3.9.0-1.dsc
 # dget http://ftp.debian.org/debian/pool/main/n/netcdf/netcdf_3.6.1-1.dsc
 # apt-get source nco # Get package source
-sudo /bin/rm /var/cache/pbuilder/result/nco_4.5.5* # Cleanup prior build
+sudo /bin/rm /var/cache/pbuilder/result/nco_4.6.0* # Cleanup prior build
 # To pass DEB_BUILD_OPTIONS to pbuilder while using sudo, one must first
 # modify sudoers with visudo to prevent sudo from resetting environment
 #export DEB_BUILD_OPTIONS='disable-dap-netcdf disable-netcdf4 disable-udunits2'; # Disable optional packages based on available Debian support
-cd ${DATA};DIST=sid sudo pbuilder build nco_4.5.5-1.dsc > ~/foo.nco.pbuilder 2>&1
-cd /var/cache/pbuilder/result;debsign -k6F635D10 nco_4.5.5-1_*.changes
-lintian /var/cache/pbuilder/result/nco_4.5.5-1_*.deb
+cd ${DATA};DIST=sid sudo pbuilder build nco_4.6.0-1.dsc > ~/foo.nco.pbuilder 2>&1
+cd /var/cache/pbuilder/result;debsign -k6F635D10 nco_4.6.0-1_*.changes
+lintian /var/cache/pbuilder/result/nco_4.6.0-1_*.deb
 sudo dpkg --remove nco
-sudo dpkg --install /var/cache/pbuilder/result/nco_4.5.5-1_*.deb
+sudo dpkg --install /var/cache/pbuilder/result/nco_4.6.0-1_*.deb
 cd ~/nco/bld;MY_BIN_DIR=/usr/bin ../bm/nco_bm.pl --regress
 # NB: Upload pbuilder Debian Sid packages to Debian mentors, but not
 # to personal or NCO websites since most people use Ubuntu not Debian
 # NB: Debian versions are a PITA, ensure RPMs build before uploading to Debian
-cd /var/cache/pbuilder/result;dupload -t mentors nco_4.5.5-1_*.changes
+cd /var/cache/pbuilder/result;dupload -t mentors nco_4.6.0-1_*.changes
 
 # RPM builds as root
 export rpm_root='/usr/src/redhat'
 # export sudo_sng='' # sudo not-necessary when builing in user directories
 export sudo_sng='sudo' # sudo necessary when building in system directories
 cd ~/nco;cvc;cvu
-/bin/rm -rf ${DATA}/nco-4.5.5 ${DATA}/nco-4.5.5* # Cleanup last build
+/bin/rm -rf ${DATA}/nco-4.6.0 ${DATA}/nco-4.6.0* # Cleanup last build
 ${sudo_sng} /bin/rm -r -f \
-${rpm_root}/BUILD/nco-4.5.5 \
-${rpm_root}/RPMS/i386/nco-4.5.5-?.i386.rpm \
-${rpm_root}/RPMS/i386/nco-debuginfo-4.5.5-?.i386.rpm \
-${rpm_root}/RPMS/i386/nco-devel-4.5.5-?.i386.rpm \
-${rpm_root}/SOURCES/nco-4.5.5.tar.gz \
-${rpm_root}/SPECS/nco-4.5.5.spec \
-${rpm_root}/SRPMS/nco-4.5.5-?.src.rpm
-cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -r nco-4.5.5-1 -d nco-4.5.5 nco # Export based on tag
-${sudo_sng} ln -s ${HOME}/nco/bld/nco.spec ${rpm_root}/SPECS/nco-4.5.5.spec
-tar cvzf ./nco-4.5.5.tar.gz --exclude='nco-4.5.5/debian*' --exclude='.cvsignore' --exclude='ncap_lex.c' --exclude='ncap_yacc.[ch]' ./nco-4.5.5 
-${sudo_sng} /bin/cp ${DATA}/nco-4.5.5.tar.gz ${rpm_root}/SOURCES
+${rpm_root}/BUILD/nco-4.6.0 \
+${rpm_root}/RPMS/i386/nco-4.6.0-?.i386.rpm \
+${rpm_root}/RPMS/i386/nco-debuginfo-4.6.0-?.i386.rpm \
+${rpm_root}/RPMS/i386/nco-devel-4.6.0-?.i386.rpm \
+${rpm_root}/SOURCES/nco-4.6.0.tar.gz \
+${rpm_root}/SPECS/nco-4.6.0.spec \
+${rpm_root}/SRPMS/nco-4.6.0-?.src.rpm
+cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -r nco-4.6.0-1 -d nco-4.6.0 nco # Export based on tag
+${sudo_sng} ln -s ${HOME}/nco/bld/nco.spec ${rpm_root}/SPECS/nco-4.6.0.spec
+tar cvzf ./nco-4.6.0.tar.gz --exclude='nco-4.6.0/debian*' --exclude='.cvsignore' --exclude='ncap_lex.c' --exclude='ncap_yacc.[ch]' ./nco-4.6.0 
+${sudo_sng} /bin/cp ${DATA}/nco-4.6.0.tar.gz ${rpm_root}/SOURCES
 cd ${rpm_root}/SPECS
-${sudo_sng} rpmbuild -ba --sign nco-4.5.5.spec > ~/foo.nco 2>&1
+${sudo_sng} rpmbuild -ba --sign nco-4.6.0.spec > ~/foo.nco 2>&1
 scp \
-${rpm_root}/RPMS/i386/nco-4.5.5-?.i386.rpm \
-${rpm_root}/RPMS/i386/nco-debuginfo-4.5.5-?.i386.rpm \
-${rpm_root}/RPMS/i386/nco-devel-4.5.5-?.i386.rpm \
-${rpm_root}/SRPMS/nco-4.5.5-?.src.rpm \
+${rpm_root}/RPMS/i386/nco-4.6.0-?.i386.rpm \
+${rpm_root}/RPMS/i386/nco-debuginfo-4.6.0-?.i386.rpm \
+${rpm_root}/RPMS/i386/nco-devel-4.6.0-?.i386.rpm \
+${rpm_root}/SRPMS/nco-4.6.0-?.src.rpm \
 dust.ess.uci.edu:/var/www/html/nco/src
 scp \
-${rpm_root}/RPMS/i386/nco-4.5.5-?.i386.rpm \
-${rpm_root}/RPMS/i386/nco-debuginfo-4.5.5-?.i386.rpm \
-${rpm_root}/RPMS/i386/nco-devel-4.5.5-?.i386.rpm \
-${rpm_root}/SRPMS/nco-4.5.5-?.src.rpm \
+${rpm_root}/RPMS/i386/nco-4.6.0-?.i386.rpm \
+${rpm_root}/RPMS/i386/nco-debuginfo-4.6.0-?.i386.rpm \
+${rpm_root}/RPMS/i386/nco-devel-4.6.0-?.i386.rpm \
+${rpm_root}/SRPMS/nco-4.6.0-?.src.rpm \
 zender,nco at web.sf.net:/home/project-web/nco/htdocs/src
 
 # RPM builds as user
@@ -256,33 +256,33 @@ zender,nco at web.sf.net:/home/project-web/nco/htdocs/src
 export rpm_root="${DATA}/rpm/nco"
 #cd ~/nco;cvc;cvu # This risks committing unwanted *.[ch]pp files
 mkdir -p ${DATA}/rpm/nco/TMP ${DATA}/rpm/nco/BUILD
-/bin/rm -rf ${DATA}/nco-4.5.5 ${DATA}/nco-4.5.5* # Cleanup last build
+/bin/rm -rf ${DATA}/nco-4.6.0 ${DATA}/nco-4.6.0* # Cleanup last build
 /bin/rm -r -f \
-${rpm_root}/nco-4.5.5-?.src.rpm \
-${rpm_root}/nco-4.5.5.spec \
-${rpm_root}/nco-4.5.5.tar.gz \
-${rpm_root}/*/nco-4.5.5-?.*.rpm \
-${rpm_root}/*/nco-debuginfo-4.5.5-?.*.rpm \
-${rpm_root}/*/nco-devel-4.5.5-?.*.rpm
-# cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -r nco-4.5.5-1 -d nco-4.5.5 nco # Export based on tag
-cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -D "1 second ago" -dnco-4.5.5 nco # Export most recent and build as 4.5.5-1
-tar cvzf ./nco-4.5.5.tar.gz --exclude='nco-4.5.5/debian*' --exclude='.cvsignore' --exclude='ncap_lex.c' --exclude='ncap_yacc.[ch]' ./nco-4.5.5 
-/bin/cp ${DATA}/nco-4.5.5.tar.gz ${rpm_root}
+${rpm_root}/nco-4.6.0-?.src.rpm \
+${rpm_root}/nco-4.6.0.spec \
+${rpm_root}/nco-4.6.0.tar.gz \
+${rpm_root}/*/nco-4.6.0-?.*.rpm \
+${rpm_root}/*/nco-debuginfo-4.6.0-?.*.rpm \
+${rpm_root}/*/nco-devel-4.6.0-?.*.rpm
+# cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -r nco-4.6.0-1 -d nco-4.6.0 nco # Export based on tag
+cd ${DATA};cvs -d zender at nco.cvs.sf.net:/cvsroot/nco export -kkv -D "1 second ago" -dnco-4.6.0 nco # Export most recent and build as 4.6.0-1
+tar cvzf ./nco-4.6.0.tar.gz --exclude='nco-4.6.0/debian*' --exclude='.cvsignore' --exclude='ncap_lex.c' --exclude='ncap_yacc.[ch]' ./nco-4.6.0 
+/bin/cp ${DATA}/nco-4.6.0.tar.gz ${rpm_root}
 ln -s ${HOME}/nco/bld/nco.spec ${rpm_root}/nco.spec
 cd ${rpm_root}
 rpmbuild -ba --sign nco.spec > ~/foo.nco 2>&1
-rpmlint ${rpm_root}/*/nco-4.5.5-?.*.rpm
+rpmlint ${rpm_root}/*/nco-4.6.0-?.*.rpm
 sudo yum remove nco
-sudo yum install ${rpm_root}/*/nco-4.5.5-?.*.rpm
+sudo yum install ${rpm_root}/*/nco-4.6.0-?.*.rpm
 scp \
-${rpm_root}/*/nco-4.5.5-?.*.rpm \
-${rpm_root}/*/nco-debuginfo-4.5.5-?.*.rpm \
-${rpm_root}/*/nco-devel-4.5.5-?.*.rpm \
-${rpm_root}/nco-4.5.5-?.*.src.rpm \
+${rpm_root}/*/nco-4.6.0-?.*.rpm \
+${rpm_root}/*/nco-debuginfo-4.6.0-?.*.rpm \
+${rpm_root}/*/nco-devel-4.6.0-?.*.rpm \
+${rpm_root}/nco-4.6.0-?.*.src.rpm \
 dust.ess.uci.edu:/var/www/html/nco/src
 scp \
-${rpm_root}/*/nco-4.5.5-?.*.rpm \
-${rpm_root}/*/nco-debuginfo-4.5.5-?.*.rpm \
-${rpm_root}/*/nco-devel-4.5.5-?.*.rpm \
-${rpm_root}/nco-4.5.5-?.*.src.rpm \
+${rpm_root}/*/nco-4.6.0-?.*.rpm \
+${rpm_root}/*/nco-debuginfo-4.6.0-?.*.rpm \
+${rpm_root}/*/nco-devel-4.6.0-?.*.rpm \
+${rpm_root}/nco-4.6.0-?.*.src.rpm \
 zender,nco at web.sf.net:/home/project-web/nco/htdocs/src
diff --git a/doc/index.shtml b/doc/index.shtml
index a684a6d..41ec6c9 100644
--- a/doc/index.shtml
+++ b/doc/index.shtml
@@ -60,10 +60,10 @@ Try to disable Spammers' machines:
 [<a href="http://cfconventions.org/1.6.html">CF</a>] 
 [<a href="https://wiki.earthdata.nasa.gov/display/ESDSWG/Dataset+Interoperability+Working+Group">DIWG</a>] 
 [<a href="http://www.gnu.org/software/gsl">GSL</a>]
-[<a href="http://www.unidata.ucar.edu/packages/netcdf">netCDF</a>] 
+[<a href="http://www.unidata.ucar.edu/software/netcdf">netCDF</a>] 
 [<a href="http://opendap.org">OPeNDAP</a>] 
 [<a href="http://github.com/nco/swamp">SWAMP</a>] 
-[<a href="http://www.unidata.ucar.edu/packages/udunits">UDUnits</a>] 
+[<a href="http://www.unidata.ucar.edu/software/udunits">UDUnits</a>] 
 </td></tr></table>
 
 <p><hr width="100%"></p>
@@ -149,7 +149,12 @@ and
 <h2>Recent Releases & Milestones</h2>
 
 <ul>
-<li>2016 Mar ??: 4.5.6 (<i>In progress</i>)
+<!-- <li>2016 Jul ??: 4.6.2 (<i>In progress</i>) -->
+<li>2016 Jun ??: 4.6.1 (<i>In progress</i>) -->
+<li>2016 May 12: 4.6.0 (<tt>ncclimo</tt>)
+<li>2016 Apr 20: <a href="http://www.geosci-model-dev-discuss.net/gmd-2016-63">Manuscript</a> on PPC, <i>Geosci. Model Dev. Discuss.</i></li>
+<li>2016 Apr 06: <a href="http://dust.ess.uci.edu/smn/pst_nco_esds_201604.pdf">Poster</a> at NASA ESDSWG, Greenbelt</li>
+<li>2016 Apr 05: <a href="http://dust.ess.uci.edu/smn/smn_nco_gsfc_201604.pdf">Talk</a> at NASA GES DISC, Greenbelt</li>
 <li>2016 Feb 17: 4.5.5 (Stability)
 <li>2016 Jan 07: 4.5.4 (<tt>ncremap</tt>)
 <li>2015 Dec 16: <a href="http://dust.ess.uci.edu/smn/pst_nco_agu_201512.pdf">Poster</a> at Fall AGU, San Francisco</li>
@@ -160,28 +165,21 @@ and
 <li>2015 Jul 10: 4.5.1 (Stability)
 <li>2015 Jun 11: 4.5.0 (Regridding)
 <li>2015 May 21: 4.4.9 (<tt>ncra</tt> weights)
-<li>2015 Feb 16: 4.4.8 (Precision-preserving Compression)
+<li>2015 Feb 16: 4.4.8 (Precision-Preserving Compression)
 <li>2014 Dec 15: DOE ACME <a href="#prp_acme">project</a> commences</li>
 <li>2014 Nov 26: 4.4.7 (Chunking features)
 <li>2014 Oct 01: 4.4.6 (<tt>ncra, ncwa</tt> packing bugfixes, stride optimization)
 <li>2014 Aug 26: 4.4.5 (Stability)
 <li>2014 Jul 01: NASA ACCESS 2013 <a href="#prp_axs">project</a> commences</li>
-<li>2014 May 29: 4.4.4 (Stability)
-<li>2014 Apr 02: 4.4.3 (Stability)
-<li>2014 Mar 27: <a href="http://dust.ess.uci.edu/smn/smn_nco_gsfc_201403.pdf">Talk</a> at NASA GSFC, Greenbelt</li>
-<li>2014 Mar 25: <a href="http://dust.ess.uci.edu/smn/pst_nco_esds_201403.pdf">Poster</a> at NASA ESDSWG, Greenbelt</li>
-<li>2014 Feb 20: 4.4.2 (Stability)
-<li>2014 Jan 29: 4.4.1 (Stability)
-<li>2014 Jan 09: 4.4.0 (Stability)
-<li><a href="./milestones_old.shtml">Milestones from 2003–2013 (versions 2.8.4–4.3.9)</a></li>
-<li><a href="./nco_news.shtml">News and Announcements from 1998–2003 (version 1.1.0–2.8.3) and earlier</a></li>
+<li><a href="./milestones_old.shtml">Milestones from 200301–201406 (versions 2.8.4–4.4.4)</a></li>
+<li><a href="./nco_news.shtml">News and Announcements from 199801–200212 (version 1.1.0–2.8.3) and earlier</a></li>
 </ul>
 <hr></p>
 
 <!-- http://nco.sf.net#Definition -->
 <dt><a name="Definition"></a><a name="dfn"></a></dt>
 <h2>What is NCO?</h2>
-<p>The netCDF Operators (NCO) comprise a dozen standalone,
+<p>The netCDF Operators (NCO) comprise about a dozen standalone,
 command-line programs that take 
 <a href="http://www.unidata.ucar.edu/packages/netcdf">netCDF</a>,
 <a href="http://hdfgroup.org">HDF</a>, and/or
@@ -225,6 +223,7 @@ techniques for climate data analysis:
 <li><a href="./nco.html#ncap2"><tt>ncap2</tt></a> netCDF Arithmetic Processor (<a href="./nco.html#xmp_ncap">examples</a>)</li>
 <li><a href="./nco.html#ncatted"><tt>ncatted</tt></a> netCDF ATTribute EDitor (<a href="./nco.html#xmp_ncatted">examples</a>)</li>
 <li><a href="./nco.html#ncbo"><tt>ncbo</tt></a> netCDF Binary Operator (addition, multiplication...) (<a href="./nco.html#xmp_ncbo">examples</a>)</li>
+<li><a href="./nco.html#ncclimo"><tt>ncclimo</tt></a> netCDF CLIMatOlogy Generator (<a href="./nco.html#xmp_ncclimo">examples</a>)</li>
 <li><a href="./nco.html#nces"><tt>nces</tt></a> netCDF Ensemble Statistics (<a href="./nco.html#xmp_nces">examples</a>)</li>
 <li><a href="./nco.html#ncecat"><tt>ncecat</tt></a> netCDF Ensemble conCATenator (<a href="./nco.html#xmp_ncecat">examples</a>)</li>
 <li><a href="./nco.html#ncflint"><tt>ncflint</tt></a> netCDF FiLe INTerpolator (<a href="./nco.html#xmp_ncflint">examples</a>)</li>
@@ -259,10 +258,13 @@ special cases.
 <!-- http://nco.sf.net#Contribute -->
 <dt><a name="Contribute"></a></dt>
 <h2>How to Contribute: Volunteer, Endorse, or Donate</h2>
-<p>In March, 2000, NCO became an Open Source project hosted by
-<a href="http://sf.net">SourceForge.net</a>.
-This facilitates collaboration, code contributions, and support.
-<p>In March, 2015, NCO source code moved to <a href="http://github.com">GitHub.com</a>.
+<p>NCO has always (since 1995) been GPL'd Open Source.
+<a href="http://sf.net">SourceForge.net</a> started hosting NCO 
+in March, 2000.
+This facilitated collaboration, code contributions, and support.
+<p>In March, 2015, NCO development moved to <a href="http://github.com">GitHub.com</a>.
+We continue to use the SourceForge discussion fora for historical
+continuity (seventeen years of searchable Q&A).
 No matter what your programming background there is a task you can help with. 
 From re-organizing the TODO list itself, to improving this cheesy
 webpage, to documentation, to designing and implementing new features
@@ -676,13 +678,15 @@ San Francisco, CA, December 5–9, 2006.
 <!-- http://nco.sf.net#hgh -->
 <dt><a name="Highlights"></a><a name="hgh"></a></dt>
 <h2>Release Highlights</h2>
-Stable releases receive unique tags and their tarballs are stored  
-<a href="http://nco.sf.net/src">here</a> on SourceForge and
+Stable releases receive unique tags and their tarballs are created and stored  
 <a href="https://github.com/nco/nco/releases">here</a> at GitHub.
-You may also retrieve the source of tagged versions directly with, e.g.,
+Identical copies of those tarballs are also stored
+<a href="http://nco.sf.net/src">here</a> on SourceForge for historical
+continuity.
+You may retrieve the source of tagged versions directly with, e.g.,
 <tt>git clone -b 4.5.5 http://github.com/nco/nco.git nco-4.5.5</tt></a>.
 <ul>
-<li><b>NCO 4.5.7</b>: (<i>Future</i>) 
+<li><b>NCO 4.6.2</b>: (<i>Future</i>) 
 <tt>ncks</tt> prints human-legible ISO8601 dates;
 <a href="http://nco.sf.net/nco.html#cnk">Chunking</a> bytes not elements, caching;
 <tt>ncks</tt> prints human-legible ISO8601 dates;
@@ -691,10 +695,19 @@ netCDF4 compound types?;
 <tt>ncremap</tt> use CF to find coordinates;
 <tt>ncks --xtn</tt> better extensive variable treatment;
 Optimize diskless files?;</li>
-<li><b>NCO 4.5.6</b>: (<i>In Progress, features in-progress or completed include</i>)
+<li><b>NCO 4.6.1</b>: (<i>In Progress, features in-progress or completed include</i>)
 <tt>ncremap</tt> use CF to find coordinates;
 <tt>ncks --xtn</tt> better extensive variable treatment;
 <tt>ncpdq</tt> fix permutation with multiple groups;</li>
+<li><b>NCO 4.6.0</b>: 
+<tt>ncap2</tt> LHC metadata propagation;
+<tt>ncatted</tt> nappend mode;
+<tt>ncclimo</tt> debut;
+<tt>ncks</tt> reads ENVI bsq/bip/bil images;
+<tt>ncks</tt> Terraref features;
+<tt>ncks -A</tt> append consistency;
+<tt>ncra --cb</tt> climatology bounds</li>
+<tt>ncremap</tt> uses $TMPDIR;</li>
 <li><b>NCO 4.5.5</b>: (<i>Current Stable Release</i>)
 All operators support CDF5 format;
 <tt>ncap2</tt> fix negative dimension indices handling;
@@ -1151,7 +1164,7 @@ The simplest way to acquire the source is to download the compressed tarball:
 <ul>
 <li>
 <!-- scp ${DATA}/nco-4.5.5.tar.gz zender,nco at web.sf.net:/home/project-web/nco/htdocs/src -->
-<a href="src/nco-4.5.5.tar.gz">nco-4.5.5.tar.gz</a> 
+<a href="https://github.com/nco/nco/archive/4.5.5.tar.gz">nco-4.5.5.tar.gz</a> 
 (<!--#fsize file="src/nco-4.5.5.tar.gz"--> compressed tar-file)<br>
 <!--#exec cmd="openssl dgst -md5 src/nco-4.5.5.tar.gz"--><br>
 <!--#exec cmd="openssl dgst -sha1 src/nco-4.5.5.tar.gz"--> 
@@ -1175,11 +1188,12 @@ Usually you wish to retrieve a recent tagged (i.e., released) version.
 This command retrieves the entire NCO repository (< 20 MB) and
 then checks out NCO version <tt>4.5.5</tt>:
 <p><tt>git clone https://github.com/nco/nco.git;cd nco;git checkout 4.5.5</tt></p>
-This command retrieves the current (“bleeding edge”)
+These commands retrieve the current (“bleeding edge”)
 development version of NCO into a local directory named <tt>nco</tt>:
-<p><tt>git clone https://github.com/nco/nco.git ~/nco</tt></p>
+<p><tt>git clone https://github.com/nco/nco.git ~/nco</tt></p> or
+<p><tt>git clone git at github.com:/nco/nco.git</tt></p>,
 Track changes to the development version using
-<p><tt>cd ~/nco;git pull</tt></p>
+<p><tt>cd nco;git pull</tt></p>
 One difference between running a "tagged" release 
 (e.g., <tt>4.5.5</tt>) and the development version is that the
 tagged release operators will print a valid version number (e.g.,
@@ -1226,22 +1240,23 @@ system, e.g.,
 If pre-built executables do not satisfy you (e.g., are out-of-date)
 and you want the latest, greatest features, then the first steps to
 build (i.e., compile, for the most part) NCO from source code are to
-install the prerequisites:
-<a href="http://www.antlr.org">ANTLR</a> version 2.7.7 (like <a href="http://dust.ess.uci.edu/tmp/antlr-2.7.7.tar.gz">this one</a> <i>not</i> version 3.x or 4.x!) (required for <tt>ncap2</tt>), 
+install the pre-requisites:
+<a href="http://www.antlr.org">ANTLR</a> version 2.7.7 (like <a href="http://dust.ess.uci.edu/nco/antlr-2.7.7.tar.gz">this one</a> <i>not</i> version 3.x or 4.x!) (required for <tt>ncap2</tt>), 
 <a href="http://www.gnu.org/software/gsl">GSL</a> (desirable for <tt>ncap2</tt>), 
 <a href="http://www.unidata.ucar.edu/packages/netcdf">netCDF</a> (absolutely required), 
 <a href="http://opendap.org">OPeNDAP</a> (enables network transparency), and
 <a href="http://www.unidata.ucar.edu/packages/udunits">UDUnits</a> (allows dimensional unit transformations).
 If possible, install this software stack from pre-built binaries 
-(commands to do so on Debian and RPM systems are given just below).
+(commands to do so on Debian, Mac, and RPM systems follow below).
 ANTLR binaries from major distributions are pre-built with the source
 patch necessary to allow NCO to link to ANTLR.
 If you must build the source stack yourself (e.g., due to lack of root
 access, or systems without packages such as AIX), build all libraries
 with the same compiler and switches.
-The ANTLR distributions must be built with the source file
-<tt>CharScanner.hpp</tt> patched to include this line:
-<tt>#include <cstring></tt> or else <tt>ncap2</tt> will not compile.
+The ANTLR source file <tt>CharScanner.hpp</tt> must include this line:
+<tt>#include <cstring></tt> or else <tt>ncap2</tt> will not
+compile (<a href="http://dust.ess.uci.edu/tmp/antlr-2.7.7.tar.gz">this</a>
+tarball is already patched).
 Recent versions of netCDF automatically build OPeNDAP and UDUnits.
 NCO is mostly written in C99, and although you <i>may</i> mix and
 match compilers, this is often difficult in practice and is not recommended.
@@ -1258,7 +1273,13 @@ For the reasons explained above (compiler compatibility) install as
 much pre-requisite and optional software as possible from pre-compiled
 packages. 
 This is easy on modern package-oriented OSs. 
-For Debian-based systems:
+The NCL/ESMF packages provide ESMF_RegridWeightGen for use
+by <tt>ncremap</tt>, they are not required to <i>build</i> NCO. 
+Remember, to compile NCO from source, you need not only the library
+dependencies the "devel" versions 
+(which include the header files) of the 
+
+For Debian-based systems (like Ubuntu) (<tt>aptitude</tt> is similar to and interchangeable, I think, with <tt>apt-get</tt>):
 <tt>
 <dt>sudo aptitude install antlr libantlr-dev # ANTLR</dt>
 <dt>sudo aptitude install libcurl4-gnutls-dev libexpat1-dev libxml2-dev # DAP-prereqs (curl, expat XML parser) </dt>
@@ -1266,6 +1287,7 @@ For Debian-based systems:
 <dt>sudo aptitude install gsl-bin libgsl0-dev # GSL</dt>
 <dt>sudo aptitude install libnetcdf6 libnetcdf-dev netcdf-bin # netCDF and DAP</dt>
 <dt>sudo aptitude install libhdf5-serial-dev # HDF5</dt>
+<dt>sudo aptitude install ncl-ncarg # ESMF_RegridWeightGen (for ncremap)</dt>
 <dt>sudo aptitude install udunits-bin libudunits2-0 libudunits2-dev # UDUnits</dt>
 </tt>
 
@@ -1280,6 +1302,7 @@ For RPM-based systems (substitute <tt>yum</tt> for <tt>dnf</tt> on older Fedora
 <dt>sudo dnf install expat expat-devel -y # expat XML parser, a UDUnits-prereq (RHEL only?)</dt>
 <dt>sudo dnf install libdap libdap-devel -y # DAP</dt>
 <dt>sudo dnf install bison flex gcc gcc-c++ -y # GNU toolchain</dt>
+<dt>sudo dnf install ncl # ESMF_RegridWeightGen (for ncremap)</dt>
 <dt>sudo dnf install gsl gsl-devel -y # GSL</dt>
 <dt>sudo dnf install netcdf netcdf-devel -y # netCDF</dt>
 <dt>sudo dnf install librx librx-devel -y # RX</dt>
@@ -1291,11 +1314,14 @@ For RPM-based systems (substitute <tt>yum</tt> for <tt>dnf</tt> on older Fedora
 For Mac OS X with MacPorts:
 <tt>
 <dt>sudo port install antlr # Antlr</dt>
+<dt>sudo port install esmf # ESMF_RegridWeightGen (for ncremap)</dt>
 <dt>sudo port install libdap # DAP</dt>
 <dt>sudo port install gsl # GSL</dt>
 <dt>sudo port install netcdf # netCDF</dt>
 <dt>sudo port install udunits2 # UDUnits</dt>
-</tt>
+Without MacPorts, the system TeXInfo may be too old to build the
+documentation.
+If so, use <tt>configure --disable-doc</tt>.
 
 <dt><a name="bld_cygwin"></a></dt> <!-- http://nco.sf.net#bld_cygwin -->
 For Windows with Cygwin, select and install the following packages with Cygwin Setup:
diff --git a/doc/milestones_old.shtml b/doc/milestones_old.shtml
index 3e30322..0d299a6 100644
--- a/doc/milestones_old.shtml
+++ b/doc/milestones_old.shtml
@@ -23,9 +23,16 @@ scp -p ~/nco/doc/milestones_old.shtml dust.ess.uci.edu:/var/www/html/nco
 <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#008080" alink="#FF0000">
 
 <dt><a name="News"></a></dt>
-<h2>Releases & Milestones from 2003–2013 (versions 2.8.4–4.3.9)</h2>
+<h2>Releases & Milestones from 2003–2013 (versions 2.8.4–4.4.4)</h2>
 
 <ul>
+<li>2014 May 29: 4.4.4 (Stability)
+<li>2014 Apr 02: 4.4.3 (Stability)
+<li>2014 Mar 27: <a href="http://dust.ess.uci.edu/smn/smn_nco_gsfc_201403.pdf">Talk</a> at NASA GSFC, Greenbelt</li>
+<li>2014 Mar 25: <a href="http://dust.ess.uci.edu/smn/pst_nco_esds_201403.pdf">Poster</a> at NASA GES DISC, Greenbelt</li>
+<li>2014 Feb 20: 4.4.2 (Stability)
+<li>2014 Jan 29: 4.4.1 (Stability)
+<li>2014 Jan 09: 4.4.0 (Stability)
 <li>2013 Dec 13: <a href="http://dust.ess.uci.edu/smn/smn_nco_agu_201312.pdf">Talk</a> at Fall AGU, San Francisco</li>
 <li>2013 Dec 02: 4.3.9 (new operator, <tt>nces</tt>)
 <li>2013 Nov 06: 4.3.8 (<tt>ncatted</tt> groups)
diff --git a/doc/nco.texi b/doc/nco.texi
index 12eb3cc..44c2297 100644
--- a/doc/nco.texi
+++ b/doc/nco.texi
@@ -30,7 +30,7 @@ Irvine, CA 92697-3100
 
 After editing any hyperlink locations, Emacs users update indices with
 C-c C-u C-a	texinfo-all-menus-update
-C-c C-u C-e	texinfo-every-node-update
+C-c C-u C-e	texitnfo-every-node-update
 
 Multiple files:
 M-x texinfo-multiple-files-update
@@ -91,7 +91,7 @@ Legend (defined in "highlighting" section of TeXInfo manual):
 @samp{}: Extended commands, character sequences, e.g., @samp{ncra in.nc out.nc}
 @uref{}: URL with optional alternate text, e.g., @uref{http://nco.sf.net,NCO homepage}
 @url{}: URL, synonym for @uref
- at var{}: Metasyntactic variable, e.g., @var{input}
+ at var{}: Metasyntactic variable, e.g., @var{fl_in}
 @verbatim: Anything goes inside environment (no @'s needed to protect special characters like braces)
 @verbatiminclude: Insert contents of file here, e.g., @verbatiminclude{nco.sh}
 @example: Quoted environment (@'s needed to protect special characters like braces)
@@ -102,6 +102,11 @@ Use '@:', after periods, questions marks, exclamation marks, or colons
 that do not end sentences, e.g., 'vs.@:'
 Use '@.', '@!', and `@?' to end sentences that end with single capital letters (e.g., initials)
 
+Outline Hierarchy:
+ at section
+ at subsection
+ at unnumberedsubsec
+
 Resources:
 Octave TeXInfo manual shows clean TeXInfo structure
 /usr/share/doc/octave-2.1.34/interpreter/octave.texi
@@ -113,12 +118,12 @@ Octave TeXInfo manual shows clean TeXInfo structure
 @setfilename nco.info
 
 @c Define edition, date, ...
- at set nco-edition 4.5.5
- at set doc-edition 4.5.5
+ at set nco-edition 4.6.0
+ at set doc-edition 4.6.0
 @set copyright-years 1995--2016
- at set update-year 2015
- at set update-date 17 February 2016
- at set update-month February 2016
+ at set update-year 2016
+ at set update-date 9 May 2016
+ at set update-month May 2016
 
 @settitle @acronym{NCO} @value{nco-edition} User Guide
 
@@ -162,6 +167,7 @@ x
 % Use \gdef instead of \def to make definition persistent across TeX blocks
 % These should be consistent with any TeXInfo macros
 % 1. Primary commands
+\gdef\cod{{\rm CO}_{2}} % [frc] Math pi
 \gdef\dmn{D} % [dmn] Variable dimension
 \gdef\rdr{R} % [dmn] Re-order dimension
 \gdef\shr{S} % [dmn] Share dimension
@@ -2437,7 +2443,7 @@ Leaks cause peak memory usage to increase monotonically with time
 regardless of script complexity. 
 Slow leaks are very difficult to find.
 Sometimes a @command{malloc()} (or @command{new[]}) failure is the
-only noticeable clue to their existance.
+only noticeable clue to their existence.
 If you have good reasons to believe that a memory allocation failure  
 is ultimately due to an @acronym{NCO} memory leak (rather than
 inadequate @acronym{RAM} on your system), then we would be very
@@ -2663,7 +2669,7 @@ First, users may request a specific number of threads @var{thr_nbr} with
 the @samp{-t} switch (or its long option equivalents, @samp{--thr_nbr},
 @samp{--threads}, and @samp{--omp_num_threads}).
 If not user-specified, OpenMP obtains @var{thr_nbr} from the
- at code{OMP_NUM_THREADS} environment variable, if present, or from the
+ at env{OMP_NUM_THREADS} environment variable, if present, or from the
 @acronym{OS}, if not.
 
 @cartouche
@@ -2688,7 +2694,7 @@ goal of our current funding and would require new volunteers or funding.
 @end cartouche
 
 @cindex @var{thr_nbr}
- at cindex @code{OMP_NUM_THREADS}
+ at cindex @env{OMP_NUM_THREADS}
 @cindex @command{ncrcat}
 @cindex @command{ncwa}
 @cindex @command{ncap2}
@@ -4474,6 +4480,9 @@ convention described in @ref{CF Conventions}.
 As of @acronym{NCO} version 3.9.6 (January, 2009) 
 both @samp{-c} and @samp{-C} honor the @acronym{CF} @code{coordinates}
 convention described in @ref{CF Conventions}.
+As of @acronym{NCO} version 4.6.0 (April, 2016) 
+both @samp{-c} and @samp{-C} honor the @acronym{CF} @code{grid_mapping}
+convention described in @ref{CF Conventions}. 
 
 @html
 <a name="gpe"></a> <!-- http://nco.sf.net/nco.html#gpe -->
@@ -4875,6 +4884,10 @@ as @code{NC_STRING} and @code{NC_UBYTE}) to corresponding netCDF3
 atomic types (@code{NC_CHAR} and @code{NC_SHORT}) when the output format
 is netCDF3. 
 
+ at html
+<a name="cf-compliance"></a> <!-- http://nco.sf.net/nco.html#cf-compliance -->
+<a name="nccf"></a> <!-- http://nco.sf.net/nco.html#nccf -->
+ at end html
 @node Checking CF-compliance,  , Dismembering Files, Group Path Editing
 @subsection Checking CF-compliance
 @cindex @acronym{CF} compliance checker
@@ -4886,12 +4899,11 @@ is netCDF3.
 One application of dismembering is to check the @acronym{CF}-compliance of each 
 group in a file. 
 When invoked with the optional third argumnt @samp{cf},
- at command{ncdismember} passes each file it generates to the freely
-available
+ at command{ncdismember} passes each file it generates to freely available 
+compliance checkers, such as @command{cfchecker}
 @footnote{CFchecker is developed by Michael Decker and Martin Schultz at
 Forschungszentrum J@"ulich and distributed at
- at uref{https://bitbucket.org/mde_/cfchecker}.} 
- at command{cfchecker} command.
+ at uref{https://bitbucket.org/mde_/cfchecker}.}.
 @example
 @verbatim
 zender at roulee:~$ ncdismember ~/nco/data/mdl_1.nc /data/zender/nco/tmp cf
@@ -4915,8 +4927,8 @@ cesm.cesm_02.nc:
 @end example
 By default the @acronym{CF} version checked is determined automatically by
 @command{cfchecker}. 
-The user can override this default by supplying a supported @acronym{CF} version,
-e.g., @samp{1.3}, as an optional fourth argument to
+The user can override this default by supplying a supported @acronym{CF}
+version, e.g., @samp{1.3}, as an optional fourth argument to
 @command{ncdismember}. 
 Current valid @acronym{CF} options are @samp{1.0}, @samp{1.1},
 @samp{1.2}, @samp{1.3}, @samp{1.4}, and @samp{1.5}. 
@@ -6242,6 +6254,11 @@ ncks --rgr grd_ttl='Equi-Angular grid 128x256' --rgr grid=${DATA}/grids/128x256_
 # T42 Gaussian grid, first longitude centered at Greenwich
 ncks --rgr grd_ttl='T42 Gaussian grid' --rgr grid=${DATA}/grids/t42_SCRIP.20150901.nc \
      --rgr latlon=64,128 --rgr lat_typ=gss --rgr lon_typ=Grn_ctr ~zender/nco/data/in.nc ~/foo.nc
+
+# NASA Climate Modeling Grid (CMG) 3600x7200 (0.05x0.05 degree) Equi-Angular grid
+# Date-line west edge of first longitude, east edge of last longitude
+ncks --rgr grd_ttl='Equi-Angular grid 3600x7200 (NASA CMG)' --rgr grid=${DATA}/grids/3600x7200_SCRIP.20160301.nc \
+     --rgr latlon=3600,7200 --rgr lat_typ=uni --rgr lon_typ=grn_ctr ~zender/nco/data/in.nc ~/foo.nc
 @end verbatim
 @end example
 
@@ -6334,7 +6351,7 @@ overwritten (its contents are immaterial).
 @cindex @code{--rgr_map}
 @cindex @var{--map-file}
 @cartouche
-Availability: @command{ncks}, @command{ncremap}@*
+Availability: @command{ncclimo}, @command{ncks}, @command{ncremap}@*
 Short options: None@*
 Long options: 
 @samp{--map @var{map-file}} or @samp{--rgr_map @var{map-file}}@*
@@ -6343,9 +6360,25 @@ Long options:
 @samp{--renormalize=@var{wgt_thr}}@*
 @end cartouche
 
-As of @acronym{NCO} version 4.5.0 (June, 2015), @command{ncks} supports 
-horizontal regridding of global datasets where the grids and weights are
-all stored in an external @var{map-file}.
+ at acronym{NCO} includes extensive regridding features in 
+ at command{ncclimo} (as of version 4.6.0 in April, 2016),
+ at command{ncremap} (as of version 4.5.4 in November, 2015)
+and @command{ncks} (since version 4.5.0 in June, 2015). 
+Regridding can involve many choices, options, inputs, and outputs.
+The appropriate operator for this workflow is the @command{ncremap}
+script which automatically handles many details of regridding and
+passes the required commands to @command{ncks} and external programs.
+Occasionally users need access to lower-level remapping functionality
+present in @command{ncks} and not exposed to direct manipulation
+through @command{ncremap} or @command{ncclimo}.
+This section describes the lower-level functionality and switches
+as implemented in @command{ncks}.
+Knowing what these features are will help @command{ncremap} and
+ at command{ncclimo} users understand the full potential of these
+operators. 
+
+ at command{ncks} supports horizontal regridding of datasets where the
+grids and weights are all stored in an external @var{map-file}.
 Use the @samp{--map} or @samp{--rgr_map} options to specify the
 @var{map-file}, and @acronym{NCO} will regrid the @var{input-file} to
 a new (or possibly the same, aka, an identity mapping) horizontal grid
@@ -8885,7 +8918,7 @@ the task when reads/writes to disk are avoided.
 Most @acronym{NCO} operations are simple enough that they require a
 single read-from/write-to disk for every block of input/output. 
 Diskless access does not change this, but it does add an extra
-read-from/write-to RAM. 
+read-from/write-to @acronym{RAM}. 
 However this extra @acronym{RAM} write/read does avoid contention for limited
 system resources like disk-head access.
 Operators which may benefit from @acronym{RAM} disks include @command{ncwa}, which
@@ -8916,14 +8949,14 @@ of four) smaller than your available system @acronym{RAM}.
 See @ref{Memory Requirements} for further details. 
 
 @cindex @acronym{RAM} variables
-The @samp{--create_ram} switch causes output files to be created in RAM,
+The @samp{--create_ram} switch causes output files to be created in @acronym{RAM},
 rather than on disk. 
 These files are copied to disk only when closed, i.e., when the
 operator completes.
 Creating files in @acronym{RAM} may save time, especially with @command{ncap2}
 computations that are iterative, e.g., loops, and for multi-file
 operators that write output every record (timestep) or file.
-RAM files provide many of the same benefits as @acronym{RAM} variables in such
+ at acronym{RAM} files provide many of the same benefits as @acronym{RAM} variables in such
 cases (@pxref{RAM variables}). 
 
 Two switches, @samp{--ram_all} and @samp{--diskless_all}, are convenient
@@ -9098,14 +9131,18 @@ unpacked data, i.e., @code{int}, @code{float} or @code{double}.
 @end html
 @cindex interoperability
 @cindex @acronym{HDF} unpacking
-Most files originally written in @acronym{HDF} format use the
- at acronym{HDF} packing/unpacking algorithm.
-This algorithm is incompatible with the netCDF packing algorithm 
+Many (most?) files originally written in @acronym{HDF4} format use
+poorly documented @acronym{HDF} packing/unpacking algorithms that are
+incompatible and easily confused with the netCDF packing algorithm 
 described above.   
-The unpacking component of the @acronym{HDF} algorithm (described
- at uref{http://www.hdfgroup.org/HDF5/doc/UG/UG_frame10Datasets.html, here}
-and in Section 3.10.6 of the HDF4 Users Guide
- at uref{http://www.hdfgroup.org/release4/doc/UsrGuide_html/UG_PDF.pdf, here}) is
+The unpacking component of the ``conventional'' @acronym{HDF} algorithm
+(described @uref{http://www.hdfgroup.org/HDF5/doc/UG/UG_frame10Datasets.html, here}
+and in Section 3.10.6 of the @acronym{HDF4} Users Guide
+ at uref{http://www.hdfgroup.org/release4/doc/UsrGuide_html/UG_PDF.pdf,
+here}) 
+and in the @acronym{FAQ} for @acronym{MODIS} @acronym{MOD08} data
+ at uref{http://modis-atmos.gsfc.nasa.gov/MOD08_D3/faq.html, here}) 
+is
 @tex
 $$
 \rm
@@ -9117,16 +9154,43 @@ $$
 @var{upk} = @var{scale_factor}*(@var{pck} - @var{add_offset})@*
 @sp 1
 @end ifnottex
+
+The unpacking component of the @acronym{HDF} algorithm employed
+for @acronym{MODIS} @acronym{MOD13} data
+is
+ at tex
+$$
+\rm
+\hbox{upk} = (\hbox{pck} - \hbox{add\_offset})/\hbox{scale\_factor}
+$$
+ at end tex
+ at ifnottex
+ at sp 1
+ at var{upk} = (@var{pck} - @var{add_offset})/@var{scale_factor}@*
+ at sp 1
+ at end ifnottex
+
+The unpacking component of the @acronym{HDF} algorithm employed
+for @acronym{MODIS} @acronym{MOD04} data is the same as the netCDF
+algorithm.
+
 @ignore
-NB: HDF packing documentation is hard to follow
-MODIS HDF4 datasets definitely use the ``HDF algorithm''
-However, must discriminate between HDF4 and HDF5 packing.
-HDF4, or at least some HDF4 datasets implement the ``HDF algorithm'',
-aka linear scale_factor and add_offset in other order from netCDF.
-HDF5 only implements D-scaling, aka, decimal-scaling bit-packing.
-D-Scaling uses add_offset (i.e., minimum data value) and scale_factor
-(integer power of 10 by which the add_offset corrected data are divided
-before storage) to control D-scaling.
+Unfortunately, @acronym{HDF} packing is hard to understand and
+documentation is often lacking.
+Many @acronym{MODIS} @acronym{HDF4} datasets use what we used to call
+``the @acronym{HDF} algorithm'', until we realized there was more than
+one incompatible (with netCDF) @acronym{HDF} algorithm.
+These include @acronym{MODIS} @acronym{MOD10CM} datasets.
+However, we must discriminate between @acronym{HDF4} and @acronym{HDF5}  
+packing. 
+ at acronym{HDF4}, or at least some @acronym{HDF4} datasets implement the
+``@acronym{HDF} algorithm'', aka linear @code{scale_factor} and 
+ at code{add_offset} in the other order from netCDF. 
+ at acronym{HDF5} only implements D-scaling, aka, decimal-scaling
+bit-packing. 
+D-Scaling uses @code{add_offset} as a minimum data value, and
+ at code{scale_factor} as the integer power @w{of 10} by which the
+ at code{add_offset} corrected data are divided before storage.
 
 @cindex scale-offset compression
 @cindex scale-offset filter
@@ -10303,6 +10367,18 @@ external type @code{NC_DOUBLE} (a C-type @code{double}).
 @example
 ncap2 -s 'tpt=short(tpt);prs=double(prs)' in.nc out.nc
 @end example
+With ncap2 there also is the @code{convert()} method that takes an integer 
+argument. For example the above statements become:
+ at example
+ncap2 -s 'tpt=tpt.convert(NC_SHORT);prs=prs.convert(NC_DOUBLE)' in.nc out.nc
+ at end example
+Can also use @code{convert()} in combination with @code{type()} so to make variable 
+ at code{ilev_new} the same type as @code{ilev} just do:
+ at example
+ncap2 -s 'ilev_new=ilev_new.convert(ilev.type())' in.nc out.nc
+ at end example
+
+
 @xref{ncap2 netCDF Arithmetic Processor}, for more details.
 
 @html
@@ -10370,11 +10446,13 @@ multiple uses of the @samp{--glb} (or equivalent @samp{--gaa} or
 @samp{--glb_att_add}) switch.
 The switch takes mandatory arguments 
 @samp{--glb @var{att_nm}=@var{att_val}}   
-where @var{att_nm} is the desired name of the global attriute to add, 
+where @var{att_nm} is the desired name of the global attribute to add, 
 and @var{att_val} is its value.
 Currently only text attributes are supported (recorded as type
 @code{NC_CHAR}), and regular expressions are not allowed (unlike
 @pxref{ncatted netCDF Attribute Editor}).    
+Attributes are added in ``Append'' mode, meaning that values are
+appended to pre-existing values, if any. 
 @example
 @verbatim
 ncra --glb machine=${HOSTNAME} --glb created_by=${USER} in*.nc out.nc
@@ -10706,7 +10784,7 @@ Bounds are subject to the user-specified override switches
 @cindex @code{climatology} attribute
 @cindex climatology convention
 As of @acronym{NCO} version 4.4.9 (May, 2015), @acronym{NCO} 
-supports the @acronym{CF} @code{climatology} convention for climatology 
+supports the @acronym{CF} @code{climatology} convention for climatological 
 statistics described 
 @uref{http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/cf-conventions.html#climatological-statistics, here}.
 This convention allows coordinate variables (including multidimensional
@@ -10745,6 +10823,26 @@ Ancillary variables are subject to the user-specified override switches
 @ref{Subsetting Coordinate Variables}. 
 
 @html
+<a name="cnv_CF_grd"></a> <!-- http://nco.sf.net/nco.html#cnv_CF_grd -->
+<a name="grd_map"></a> <!-- http://nco.sf.net/nco.html#grd_map -->
+<a name="grid_mapping"></a> <!-- http://nco.sf.net/nco.html#grid_mapping -->
+ at end html
+ at cindex @code{grid_mapping} attribute
+ at cindex ancillary variables convention
+As of @acronym{NCO} version 4.6.0 (April, 2016), @acronym{NCO} 
+supports the @acronym{CF} @code{grid_mapping} convention for 
+described 
+ at uref{http://cfconventions.org/cf-conventions/cf-conventions.html#grid-mappings-and-projections, here}.
+This convention allows descriptions of map-projections to be associated    
+with variables.
+ at acronym{NCO} attaches any such map-projection variables to the
+extraction list along with the primary variable and its usual
+(one-dimensional) coordinates, if any. 
+Map-projection variables are subject to the user-specified override
+switches (including @samp{-c} and @samp{-C}) described in 
+ at ref{Subsetting Coordinate Variables}. 
+
+ at html
 <a name="cnv_CF_crd"></a> <!-- http://nco.sf.net/nco.html#cnv_CF_crd -->
 <a name="coordinates"></a> <!-- http://nco.sf.net/nco.html#coordinates -->
 @end html
@@ -10942,6 +11040,7 @@ described in any detail in the sections below.
 * ncpdq netCDF Permute Dimensions Quickly::
 * ncra netCDF Record Averager::
 * ncrcat netCDF Record Concatenator::
+* ncclimo netCDF Climatology Generator::
 * ncremap netCDF Remapper::
 * ncrename netCDF Renamer::
 * ncwa netCDF Weighted Averager::
@@ -11267,7 +11366,14 @@ tm5=!tm4;               // tm5=1, 1, 0, 1, 1, 0, 1, 1, 1, 1 double
 	
 @noindent @strong{Regular Assign Operator}@*
 @noindent @emph{var1 '=' exp1} @*
-If var1 does not already exist in Output then var1 is written to Output with the values and dimensions from expr1. If var1 already exists in Output, then the only requirement on expr1 is that the number of elements must match the number already on disk. The type of expr1 is converted if necessary to the disk type.
+If var1 does not already exist in Input or Output then var1 is written to Output with the values, type and dimensions from expr1. If var1 is in Input only it is copied to Output first. Once the var is in Ouptut then the only reqirement on expr1 is that the number of elements must match the number already on disk. The type of expr1 is converted as necessary to the disk type.
+
+If you wish to change the type or shape of a variable in Input then you have to cast the variable. See @pxref{Left hand casting}
+ at example
+time[time]=time.int();
+three_dmn_var_dbl[time,lon,lat]=666L;
+ at end example
+
 
 @noindent @strong{ Other Assign Operators +=,-=,*=./= }@*
         @noindent  @emph{var1 'ass_op' exp1 }@*
@@ -11494,8 +11600,6 @@ prs_dlt[time,lat,lon,lev]=prs_ntf(:,:,:,1:$ilev.size-1)-prs_ntf(:,:,:,0:$ilev.si
 // Divide by gravity to obtain total mass path in layer aka mpl [kg m-2] 
 mpl=prs_dlt/grv_sfc;
 // Multiply by mass mixing ratio to obtain mass path of constituent
-// Everything up to here works fine. The following line (commented-out) breaks the script.
-// However, it breaks it silently, no error is printed. Please try to fix this.
 mpl_CO2=mpl*mmr_CO2;
 EOF
 ncap2 -O -v -S ~/pdel.nco ~/nco/data/in.nc ~/foo.nc
@@ -11514,6 +11618,14 @@ However, this syntax only works with @acronym{NCO} version 4.5.4
 From the pressure differences, one can obtain the mass path in each
 layer as shown.
 
+Another reason to cast a variable is to modify the shape or type 
+of a variable already in Input 
+ at example
+gds_var[gds_crd]=gds_var.double();
+three_dmn_var_crd[lat,lon,lev]=10.0d;
+four[]=four.int();
+ at end example
+
 @html
 <a name="ncap_arr"></a> <!-- http://nco.sf.net/nco.html#ncap_arr -->
 @end html
@@ -12078,11 +12190,11 @@ They only work on variables in Output.
 @cindex @code{set_miss()}
  The numeric argument @var{expr} becomes the new missing value,
  overwriting the old missing value, if any.
- The argument given is converted if necessary to the variable type.
- NB: This only changes the missing value attribute. 
+ The argument given is converted if necessary to the variable's type.
+ NB: This only changes the missing value attribute.
  Missing values in the original variable remain unchanged, and thus 
  are no long considered missing values.
- They are ``orphaned''.
+ They are effectively ``orphaned''.
  Thus @code{set_miss()} is normally used only when creating new
  variables.
  The intrinsic function @code{change_miss()} (see below) is typically 
@@ -12274,13 +12386,17 @@ These functions are used to manipulate missing values and @acronym{RAM} variable
 @end table
 
 @sp 1
- at noindent @strong{PDQ Methods @*}
+ at noindent @strong{PDQ Methods@*}
 See @pxref{ncpdq netCDF Permute Dimensions Quickly}
 @table @code
 @item reverse(dim args)
- Reverses the dimension ordering of elements in a variable. 
+ Reverse the dimension ordering of elements in a variable. 
 @item permute(dim args)
- Re-shapes variables by re-ordering the dimensions. All the dims of the variable must be specified in the arguments. A limitation of this permute (unlike ncpdq) is that the record dimension cannot be re-assigned. 
+ Re-shape variables by re-ordering the dimensions. 
+ All the dimensions of the variable must be specified in the
+ arguments. 
+ A limitation of this permute (unlike @command{ncpdq}) is that the
+ record dimension cannot be re-assigned.  
 @end table 
 // Swap dimensions about and reorder along lon
 @example
@@ -12289,9 +12405,14 @@ lat_2D_rrg_new=0,90,-30,30,-30,30,-90,0
 @end example
 
 @sp 1
- at noindent @strong{Type Conversion Methods @*}
- at noindent These methods allow @command{ncap2} to convert variables and attributes to the different netcdf types. For more details on automatic and manual type conversion see (@pxref{Type Conversion}). You may only use the new netCDF4 types if you have compiled/links @acronym{NCO} with the netCDF4 library and the Output file is HDF5.
-
+ at noindent @strong{Type Conversion Methods and Functions@*}
+ at noindent These methods allow @command{ncap2} to convert variables and
+attributes to the different netCDF types. 
+For more details on automatic and manual type conversion see
+(@pxref{Type Conversion}). 
+netCDF4 types are only available if you have compiled/links
+ at acronym{NCO} with the netCDF4 library and the Output file is
+ at acronym{HDF5}.
 @table @code
 @item @strong{netCDF3/4 Types}
 @item byte()	 
@@ -12330,6 +12451,18 @@ lat_2D_rrg_new=0,90,-30,30,-30,30,-90,0
  convert to @code{NC_UINT64}, an unsigned 8-byte integer
 @end table
 
+You can also use the @code{convert()} method to do type conversion. 
+This takes an integer agument. 
+For convenience, @command{ncap2} defines the netCDF pre-processor tokens
+as @acronym{RAM} variables. 
+For example you may wish to convert a non-floating point variable to the
+same type as another variable. 
+ at example
+lon_type=lon.type();
+if(time.type() != NC_DOUBLE && time.type() != NC_FLOAT) 
+   time=time.convert(lon_type);
+ at end example
+
 @noindent @strong{Intrinsic Mathematical Methods @*}
 The list of mathematical methods is system dependant.
 For the full list @pxref{Intrinsic mathematical methods} 
@@ -14786,8 +14919,8 @@ netcdf-4.0 Final  2008/08/28@*
 SYNTAX
 @example
 ncatted [-a @var{att_dsc}] [-a @dots{}] [-D @var{dbg}] [-h] [--hdr_pad @var{nbr}]
-[-l @var{path}] [-O] [-o @var{output-file}] [-p @var{path}] [-R] [-r] [--ram_all]
- at var{input-file} [[@var{output-file}]]
+[-l @var{path}] [-O] [-o @var{output-file}] [-p @var{path}] [-R] [-r]
+[--ram_all] [-t] @var{input-file} [[@var{output-file}]]
 @end example
  
 @noindent
@@ -14921,27 +15054,33 @@ Finally, if @var{var_nm} is left blank, then @command{ncatted}
 attempts to perform the editing operation on every variable in the file.
 This option may be convenient to use if you decide to change the
 conventions you use for describing the data.
+As of @acronym{NCO} 4.6.0 (May, 2016), @command{ncatted} accepts 
+the @samp{-t} (or long-option equivalent @samp{--typ_mch} or
+ at samp{--type_match}) option.
+This causes @command{ncatted} to perform the editing operation only on
+variables that are the same type as the specified attribute.
 
 @html
 <a name="mode"></a> <!-- http://nco.sf.net/nco.html#mode -->
 <a name="att_mode"></a> <!-- http://nco.sf.net/nco.html#att_mode -->
 @end html
 The value of @var{mode} is a single character abbreviation (@code{a},
- at code{c}, @code{d}, @code{m}, or @code{o}) standing for one of
+ at code{c}, @code{d}, @code{m}, @code{n}, or @code{o}) standing for one of 
 five editing modes:@*
 @cindex attributes, appending
 @cindex attributes, creating
 @cindex attributes, deleting
 @cindex attributes, modifying
 @cindex attributes, editing
+ at cindex attributes, nappending
 @cindex attributes, overwriting
 @table @code
 @item a 
 @dfn{Append}.
 Append value @var{att_val} to current @var{var_nm} attribute
 @var{att_nm} value @var{att_val}, if any.  
-If @var{var_nm} does not have an attribute @var{att_nm}, there is no
-effect.
+If @var{var_nm} does not already have an existing attribute
+ at var{att_nm}, it is created with the value @var{att_val}.
 @item c
 @dfn{Create}.
 Create variable @var{var_nm} attribute @var{att_nm} with @var{att_val}
@@ -14963,6 +15102,17 @@ Change value of current @var{var_nm} attribute @var{att_nm} to value
 @var{att_val}. 
 If @var{var_nm} does not have an attribute @var{att_nm}, there is no
 effect. 
+ at item n 
+ at dfn{Nappend}.
+Append value @var{att_val} to @var{var_nm} attribute @var{att_nm} value 
+ at var{att_val} if @var{att_nm} already exists.
+If @var{var_nm} does not have an attribute @var{att_nm}, there is no
+effect. 
+In other words, if @var{att_nm} already exist, Nappend behaves like
+Append otherwise it does nothing.
+The mnenomic is ``non-create append''.
+Nappend mode was added to @command{ncatted} in version 4.6.0 (May,
+2016). 
 @item o
 @dfn{Overwrite}.
 Write attribute @var{att_nm} with value @var{att_val} to variable
@@ -15150,6 +15300,31 @@ ncatted -a long_name,T,o,c,temperature in.nc
 @end example
 
 @html
+<a name="MPAS"></a> <!-- http://nco.sf.net/nco.html#MPAS -->
+<a name="typ_mch"></a> <!-- http://nco.sf.net/nco.html#typ_mch -->
+<a name="type_match"></a> <!-- http://nco.sf.net/nco.html#type_match -->
+ at end html
+ at cindex MPAS
+ at cindex @code{_FillValue}
+Many model and observational datasets use missing values that are not
+annotated in the standard manner.
+For example, the MPAS ocean and ice models use
+ at math{-9.99999979021476795361e+33} as the missing value.
+To prevent arithmetic from treating these values as normal, designate
+this value as the @code{_FillValue} attribute:
+ at example
+ncatted    -a _FillValue,,o,d,-9.99999979021476795361e+33 in.nc
+ncatted -t -a _FillValue,,o,d,-9.99999979021476795361e+33 in.nc
+ncatted -t -a _FillValue,,o,d,-9.99999979021476795361e+33 \
+           -a _FillValue,,o,f,1.0e36 -a _FillValue,,o,i,-999 in.nc
+ at end example
+The first example adds the attribute to all variables. 
+The @samp{-t} switch causes the second example to add the attribute only
+to double precision variables.
+This is often more useful, and can be used to provide distinct missing
+value attributes to each numeric type, as in the third example.
+
+ at html
 <a name="NaN"></a> <!-- http://nco.sf.net/nco.html#NaN -->
 <a name="nan"></a> <!-- http://nco.sf.net/nco.html#nan -->
 @end html
@@ -15536,7 +15711,7 @@ not rank, while, @command{ncwa} changes both variable size and rank.}.
 In this case the input files to @command{ncbo}, @var{file_1} and
 @var{file_2}, will have unequally sized @code{time} dimensions which
 causes @command{ncbo} to fail.
-To prevent this from occuring, use @command{ncwa} to remove the
+To prevent this from occurring, use @command{ncwa} to remove the
 @code{time} dimension from @var{file_2}.
 See the example below.
 
@@ -15738,6 +15913,605 @@ ncrcat t_anm_8589_??.nc t_anm_8589_0112.nc
 
 @page
 @html
+<a name="ncclimo"></a> <!-- http://nco.sf.net/nco.html#ncclimo -->
+ at end html
+ at node ncclimo netCDF Climatology Generator, ncremap netCDF Remapper, ncrcat netCDF Record Concatenator, Reference Manual
+ at section @command{ncclimo} netCDF Climatology Generator
+ at cindex climo
+ at cindex climatology
+ at findex ncclimo
+
+ at noindent
+SYNTAX
+ at example
+ncclimo [-a @var{clm_md}] [-b @var{bnd_nm}] [-c @var{caseid}] [-d @var{dbg_lvl}]
+[-e @var{yr_end}] [-f @var{fml_nm}] [-h @var{hst_nm}] [-i @var{drc_in}]
+[-l @var{lnk_flg}] [-m @var{mdl_nm}] [-n @var{nco_opt}] [-O @var{drc_rgr}] [-o @var{drc_out}]
+[-p @var{par_typ}] [-R @var{rgr_opt}] [-r @var{rgr_map}] [-s @var{yr_srt}] [-t @var{thr_nbr}]
+[-v @var{var_lst}] [-x @var{cf_flg}] 
+ at end example
+
+ at noindent
+DESCRIPTION
+
+ at command{ncclimo} produces climatological monthly means, seasonal means,
+annual mean, and optionally regrids all these files.
+Standard @command{ncclimo} usage looks like
+ at example
+ncclimo           -c caseid -s srt_yr -e end_yr -i drc_in -o drc_out
+ncclimo -m mdl_nm -c caseid -s srt_yr -e end_yr -i drc_in -o drc_out
+ at end example
+A complete description of all available flags is given in comments
+embedded in @command{ncclimo}.
+The standard options are:
+ at table @option
+ at item -s srt_yr
+Start year (example: 1980). 
+Unless the option @samp{-a sdd} is specified, the first month used will
+be December of the year before the start year (to allow for contiguous
+DJF climos).   
+If @samp{-a sdd} is specified, the first month used will be January of
+the specified start year. 
+ at item -e end_yr
+End year (example: 2000). 
+Unless the option @samp{-a sdd} is specified, the last month used will
+be November of the specified end year. 
+If @samp{-a sdd} is specified, the last month will be December of the
+specified end year.  
+ at item -i drc_in
+Directory containing all netCDF files that will be input to produce the
+climo. 
+ at item -o drc_out
+Directory to hold computed (output) climo files.
+ at item -c caseid
+Simulation name, or any input filename for non- at acronym{CESM}'ish files.  
+For @acronym{CESM}'ish input files like
+ at file{famipc5_ne30_v0.3_00001.cam.h0.1980-01.nc}, 
+specify @samp{-c famipc5_ne30_v0.3_00001}. 
+The @samp{.cam.} and @samp{.h0.} bits are added internally to produce
+the input filenames.
+These can be modified via the @option{-m @var{mdl_nm}} and 
+ at option{-h @var{hst_nm}} switches if needed.  
+For input files like @file{merra2_198001.nc},
+specify @samp{-c merra2_198001.nc}. 
+See comments in @command{ncclimo} for further documentation.   
+ at item -m mdl_nm
+Model name (as embedded in monthly input filenames). 
+Default is @samp{cam}. Other options are @samp{clm2}, @samp{ocn},
+ at samp{ice}, @samp{cism}, @samp{cice}, @samp{pop}. 
+ at end table
+ at noindent
+
+ at unnumberedsubsec @acronym{MPAS-O/I} considerations
+ at acronym{MPAS} ocean and ice models currently have their own
+(non- at acronym{CESM}'ish) naming convention for monthly output files.  
+ at command{ncclimo} recognizes input files as being from @acronym{MPAS}
+when invoked with @samp{-c hist} and @samp{-m ocn} or @samp{-m ice}. 
+Use the optional @option{-f @var{fml_nm}} switch to replace @code{hist}
+with a more descriptive simulation name for the output. 
+Invocation looks like
+ at example
+ncclimo -c hist -m ocn -s 1980 -e 1983 -i $drc_in -o $drc_out # MPAS-O
+ncclimo -c hist -m ice -s 1980 -e 1983 -i $drc_in -o $drc_out # MPAS-I
+ at end example
+ at acronym{MPAS} climos are unaware of missing values until/unless
+input files are ``fixed''. 
+We recommend that simulation producers annotate all floating point
+variables with the appropriate @code{_FillValue} prior to invoking
+ at command{ncclimo}. 
+Run something like this once in the history-file directory: 
+ at example
+ at verbatim
+for fl in `ls hist.*` ; do
+  ncatted -O -t -a _FillValue,,o,d,-9.99999979021476795361e+33 ${fl}
+done
+ at end verbatim
+ at end example
+If/when @acronym{MPAS-O/I} generates the @code{_FillValue} attributes itself,
+this step can and should be skipped. 
+All other @command{ncclimo} features like regridding (below) are invoked
+identically for @acronym{MPAS} as for @acronym{CAM}/@acronym{CLM} users
+although under-the-hood @command{ncclimo} does do some special
+pre-processing (dimension permutation, metadata annotation) for
+ at acronym{MPAS}.  
+A five-year oEC60to30 @acronym{MPAS-O} climo with regridding to T62
+takes < 10 minutes on @file{rhea}. 
+
+ at unnumberedsubsec Regridding Climos and Other Files
+ at command{ncclimo} will (optionally) regrid during climatology generation 
+and produce climatology files on both native and analysis grids. 
+This regridding is virtually free, because it is performed on idle
+nodes/cores after monthly climatologies have been computed and while
+seasonal climatologies are being computed.  
+This load-balancing can save half-an-hour on ne120 datasets. 
+To regrid, simply pass the desired mapfile name with @samp{-r map.nc},
+e.g., @samp{-r maps/map_ne120np4_to_fv257x512_aave.20150901.nc}. 
+Although this should not be necessary for normal use, you may pass any
+options specific to regridding with @samp{-R opt1 opt2}.
+
+Specifying @samp{-O @var{drc_rgr}} (NB: uppercase @samp{O}) causes
+ at command{ncclimo} to place the regridded files in the directory
+ at var{drc_rgr}.  
+These files have the same names as the native grid climos from which
+they were derived. 
+There is no namespace conflict because they are in separate
+directories. 
+These files also have symbolic links to their @acronym{AMWG} filenames. 
+If @samp{-O @var{drc_rgr}} is not specified, @command{ncclimo} places 
+all regridded files in the native grid climo output directory,
+ at var{drc_out}, specified by @samp{-o @var{drc_out}} (NB: lowercase 
+ at samp{o}). 
+To avoid namespace conflicts when both climos are stored in the same
+directory, the names of regridded files are suffixed by the destination
+geometry string obtained from the mapfile, e.g., 
+ at file{*_climo_fv257x512_bilin.nc}. 
+These files also have symbolic links to their @acronym{AMWG} filenames. 
+ at example
+ncclimo -c amip_xpt -s 1980 -e 1983 -i drc_in -o drc_out
+ncclimo -c amip_xpt -s 1980 -e 1983 -i drc_in -r map_fl -o drc_out
+ncclimo -c amip_xpt -s 1980 -e 1983 -i drc_in -r map_fl -o drc_out -O drc_rgr
+ at end example
+ at noindent
+The above commands perform a climatology without regridding, then with
+regridding (all climos stored in @var{drc_out}), then with regridding and
+storing regridded files separately. 
+Paths specified by @var{drc_in}, @var{drc_out}, and @var{drc_rgr} may be
+relative or absolute.  
+An alternative to regridding during climatology generation is to regrid
+afterwards with @command{ncremap}, which has more special features
+built-in for regridding. 
+To use @command{ncremap} to regrid a climatology in @var{drc_out} and
+place the results in @var{drc_rgr}, use something like
+ at example
+ncremap -I drc_out -m map.nc -O drc_rgr
+ls drc_out/*climo* | ncremap -m map.nc -O drc_rgr
+ at end example
+See @ref{ncremap netCDF Remapper} for more details (including
+ at acronym{MPAS}!).  
+ 
+ at unnumberedsubsec Coupled Runs
+ at command{ncclimo} works on all @acronym{ACME} models. 
+It can simultaneously generate climatologies for a coupled run, where
+climatologies mean both native and regridded monthly, seasonal, and
+annual averages as per @acronym{ACME} specifications (which mandate
+the inclusion of certain helpful metadata and provenance information).
+Here are template commands for a recent simulation:
+ at example
+ at verbatim
+caseid=20160121.A_B2000ATMMOD.ne30_oEC.titan.a00
+drc_in=/scratch/simulations/$caseid/run
+drc_out=${DATA}/acme
+map_atm=${DATA}/maps/map_ne30np4_to_fv129x256_aave.20150901.nc
+map_lnd=$map_atm
+map_ocn=${DATA}/maps/map_oEC60to30_to_t62_bilin.20160301.nc
+map_ice=$map_ocn
+ncclimo -p mpi -c $caseid -m cam  -s 2 -e 5 -i $drc_in -r $map_atm -o $drc_out/atm
+ncclimo        -c $caseid -m clm2 -s 2 -e 5 -i $drc_in -r $map_lnd -o $drc_out/lnd
+ncclimo -p mpi -c hist    -m ocn  -s 2 -e 5 -i $drc_in -r $map_ocn -o $drc_out/ocn 
+ncclimo        -c hist    -m ice  -s 2 -e 5 -i $drc_in -r $map_ice -o $drc_out/ice
+ at end verbatim
+ at end example
+Atmosphere and ocean model output is typically larger than land and ice
+model output.  
+These commands recognize that by using different parallelization
+strategies that may (@file{rhea} standard queue) or may not
+(@file{cooley}, or @file{rhea}'s @code{bigmem} queue) be required,
+depending on the fatness of the analysis nodes, as explained below. 
+
+ at unnumberedsubsec Memory Considerations
+It is important to employ the optimal @command{ncclimo}  parallelization
+strategy for your computer hardware resources. 
+Select from the three available choices with the 
+ at option{-p @var{par_typ}} switch.
+The options are serial mode (@samp{-p nil} or @samp{-p serial}), 
+background mode parallelism (@samp{-p bck}), and @acronym{MPI}
+parallelism @samp{-p mpi}. 
+The default is background-mode parallelism.
+This is appropriate for lower resolution (e.g., ne30L30) simulations on
+most nodes at high-performance computer centers. 
+Use (or at least start with) serial mode on personal
+laptops/workstations.   
+Serial mode requires twelve times less @acronym{RAM} than the parallel
+modes, and is much less likely to deadlock or cause @acronym{OOM}
+(out-of-memory) conditions on your personal computer. 
+If the available @acronym{RAM} (plus swap) is 
+ at math{< 12*4*}@code{sizeof(}monthly input file at code{)}, then try serial
+mode first (12 is the optimal number of parallel processes for monthly
+climos, the computational overhead is a factor of four). 
+ at acronym{CAM-SE} ne30L30 output is about @w{1 GB/month} so each month
+requires about @w{4 GB} of @acronym{RAM}. 
+ at acronym{CAM-SE} ne30L72 output (with @acronym{LINOZ}) is about 
+ at w{10 GB/month} so each month requires about @w{40 GB} @acronym{RAM}. 
+ at acronym{CAM-SE} ne120 output is about @w{12 GB/month} so each month
+requires about @w{48 GB} @acronym{RAM}. 
+The computer does not actually use all this memory at one time, and many
+kernels compress @acronym{RAM} usage to below what top reports, so the
+actual physical usage is hard to pin-down, but may be a factor of
+2.5--3.0 (rather than a factor of four) times the size of the input
+file. 
+For instance, my @w{16 GB} 2014 MacBookPro successfully runs an ne30L30 
+climatology (that requests @w{48 GB} @acronym{RAM}) in background mode. 
+However the laptop is slow and unresponsive for other uses until it
+finishes (in 6--8 minutes) the climos. 
+Experiment and choose the parallelization option that performs best.
+
+Serial-mode, as its name implies, uses one core at a time for climos,
+and proceeds sequentially from months to seasons to annual
+climatologies. 
+Serial mode means that climos are performed serially, while regridding
+still employs OpenMP threading (up to @w{16 cores}) on platforms that
+support it. 
+By design each month and each season is independent of the others, so
+all months can be computed in parallel, then each season can be computed
+in parallel (using monthly climatologies), from which annual average is
+computed. 
+Background parallelization mode exploits this parallelism and executes
+the climos in parallel as background processes on a single node, so that
+twelve cores are simultaneously employed for monthly climatologies, four
+for seasonal, and one for annual. 
+The optional regridding will employ, by default, up to two cores per
+process. 
+The @acronym{MPI} parallelism mode executes the climatologies on
+different nodes so that up to (optimally) twelve nodes compute monthly 
+climos. 
+The full memory of each node is available for each individual climo. 
+The optional regridding employs, by default, up to eight cores per node
+in @acronym{MPI}-mode.
+ at acronym{MPI}-mode (or Background-mode on a big memory node) must be
+used to process ne30L72 and ne120L30 climos on some, but not all, 
+ at acronym{DOE} computers. 
+For example, attempting an ne120L30 climo on in background mode on
+ at file{rhea} (i.e., on one @w{128 GB} compute node) will fail due to 
+ at acronym{OOM}. 
+(Unfortunately @acronym{OOM} errors do not produce useful return codes
+so if your climo processes die without printing useful information, the
+cause may be @acronym{OOM}). 
+However the same climo will succeed if executed on a single big-memory
+(@w{1 TB}) node on @file{rhea} (use @samp{-lpartition=gpu}, as shown
+below). 
+Or @acronym{MPI}-mode can be used for any climatology. 
+The same ne120L30 climo will also finish blazingly fast in background
+mode on @file{cooley} (i.e., on one @w{384 GB} compute node), so
+ at acronym{MPI}-mode is unnecessary on @file{cooley}. 
+In general, the fatter the memory, the better the performance.  
+
+ at unnumberedsubsec Single, Dedicated Nodes at @acronym{LCF}s
+The basic approach above (running the script from a standard terminal
+window) that works well for small cases can be unpleasantly slow on
+login nodes of @acronym{LCF}s and for longer or higher resolution (e.g.,
+ne120) climatologies. 
+As a baseline, generating a climatology of @w{5 years} of ne30 (~1x1
+degree) @acronym{CAM-SE} output with @command{ncclimo} takes 1--2
+minutes on @file{rhea} (at a time with little contention), and 6--8
+minutes on a 2014 MacBook Pro. 
+To make things a bit faster at @acronym{LCF}s, request a dedicated node
+(this only makes sense on supercomputers or clusters with
+job-schedulers).  
+On @file{rhea} or @file{titan}, which use the @acronym{PBS} scheduler,
+do this with 
+ at example
+# Standard node (128 GB), PBS scheduler
+qsub -I -A CLI115 -V -l nodes=1 -l walltime=00:10:00 -N ncclimo
+# Bigmem node (1 TB), PBS scheduler
+qsub -I -A CLI115 -V -l nodes=1 -l walltime=00:10:00 -lpartition=gpu -N ncclimo
+ at end example
+The equivalent requests on @file{cooley} or @file{mira} (Cobalt
+scheduler) and @file{cori} or @file{titan} (@acronym{SLURM} scheduler)
+are:  
+ at example
+# Cooley node (384 GB) with Cobalt
+qsub -I -A HiRes_EarthSys --nodecount=1 --time=00:10:00 --jobname=ncclimo 
+# Cori node (128 GB) with SLURM
+salloc  -A acme --nodes=1 --partition=debug --time=00:10:00 --job-name=ncclimo
+ at end example
+ at noindent
+Flags used and their meanings:
+ at table @option
+ at item -I 
+Submit in interactive mode. 
+This returns a new terminal shell rather than running a program. 
+ at item --time
+How long to keep this dedicated node for. 
+Unless you kill the shell created by the @command{qsub} command, the
+shell will exist for this amount of time, then die suddenly. 
+In the above examples, @w{10 minutes} is requested. 
+ at item -l nodes=1 
+ at acronym{PBS} syntax (e.g., on @file{rhea}) for nodes.
+ at item --nodecount 1 
+Cobalt syntax (e.g., on @file{cooley}) for nodes.
+ at item --nodes=1
+ at acronym{SLURM} syntax (e.g., on @file{cori} or @file{edison}) for nodes.
+These scheduler-dependent variations request a quantity of nodes. 
+Request @w{1 node} for Serial or Background-mode, and up to @w{12 nodes} 
+for @acronym{MPI}-mode parallelism.
+In all cases @command{ncclimo} will use multiple cores per node if
+available. 
+ at item -V
+Export existing environmental variables into the new interactive shell.
+This may not actually be needed.  
+ at item -q name
+Queue name.
+This is needed for locations like @file{edison} that have multiple
+queues with no default queue. 
+ at item -A 
+Name of account to charge for time used. 
+ at end table
+Acquiring a dedicated node is useful for any workflow, not just creating climos.
+This command returns a prompt once nodes are assigned (the prompt is
+returned in your home directory so you may then have to @command{cd} to
+the location you meant to run from). 
+Then run your code with the basic @command{ncclimo} invocation.
+It will be faster because it has exclusive access to the node.
+Again, ne30L30 climos only require @w{< 2} minutes, so the 
+ at w{10 minutes} requested in the example is excessive and conservative.  
+Tune it with experience. 
+
+ at unnumberedsubsec @w{12 node} @acronym{MPI}-mode Jobs
+The above parallel approaches will fail when a single node lacks enough 
+ at acronym{RAM} (plus swap) to store all twelve monthly input files, plus
+extra @acronym{RAM} for computations. 
+One should employ @acronym{MPI} multinode parallelism @samp{-p mpi}
+on nodes with less @acronym{RAM} than
+ at math{12*3*}@code{sizeof(}input at code{)}. 
+The longest an ne120 climo will take is less than half an hour (~25
+minutes on @file{edison} or @file{rhea}), so the simplest method to run
+ at acronym{MPI} jobs is to request 12-interactive nodes using the above
+commands (though remember to add @samp{-p mpi}), then execute the script
+at the command line. 
+
+It is also possible, and sometimes preferable, to request
+non-interactive compute nodes in a batch queue. 
+Executing an @acronym{MPI}-mode climo (on machines with job scheduling
+and, optimally, @w{12 nodes}) in a batch queue can be done in two
+commands. 
+First, write an executable file which calls the @command{ncclimo} script
+with appropriate arguments. 
+We do this below by echoing to a file, @file{ncclimo.pbs}.
+ at example
+ at verbatim
+echo "ncclimo -p mpi -c $caseid -s 1 -e 20 -i $drc_in -o $drc_out" > ncclimo.pbs
+ at end verbatim
+ at end example
+The only new argument here is @samp{-p mpi} that tells @command{ncclimo}
+to use @acronym{MPI} parallelism. 
+Then execute this command file with a @w{12 node} non-interactive job: 
+ at example
+qsub -A CLI115 -V -l nodes=12 -l walltime=00:30:00 -j oe -m e -N ncclimo \
+     -o ncclimo.out ncclimo.pbs
+ at end example
+This script adds new flags:
+ at samp{-j oe} (combine output and error streams into standard error),
+ at samp{-m e} (send email to the job submitter when the job ends),
+ at samp{-o ncclimo.out} (write all output to @file{ncclimo.out}).
+The above commands are meant for @acronym{PBS} schedulers like on
+ at file{rhea}.  
+Equivalent commands for @file{cooley}/@file{mira} (Cobalt) and
+ at file{cori}/@file{edison} (@acronym{SLURM}) are
+ at example
+ at verbatim
+# Cooley (Cobalt scheduler)
+/bin/rm -f ncclimo.err ncclimo.out
+echo '#!/bin/bash' > ncclimo.cobalt
+echo "ncclimo -p mpi -c $caseid -s 1 -e 20 -i $drc_in -o $drc_out" >> ncclimo.cobalt
+chmod a+x ncclimo.cobalt
+qsub -A HiRes_EarthSys --nodecount=12 --time=00:30:00 --jobname ncclimo \
+     --error ncclimo.err --output ncclimo.out --notify zender at uci.edu ncclimo.cobalt
+
+# Cori/Edison (SLURM scheduler)
+echo "ncclimo -p mpi -c $caseid -s 1 -e 20 -i $drc_in -o $drc_out -r $map_fl" \
+      > ncclimo.pbs
+chmod a+x ncclimo.slurm
+sbatch -A acme --nodes=12 --time=03:00:00 --partition=regular --job-name=ncclimo \
+       --mail-type=END --error=ncclimo.err --output=ncclimo.out ncclimo.slurm
+ at end verbatim
+ at end example
+Notice that Cobalt and @acronym{SLURM} require the introductory
+shebang-interpreter line (@code{#!/bin/bash}) which @acronym{PBS} does
+not need.  
+Set only the scheduler batch queue parameters mentioned above. 
+In @acronym{MPI}-mode, @command{ncclimo} determines the appropriate
+number of tasks-per-node based on the number of nodes available and
+script internals (like load-balancing for regridding). 
+Hence do not set a tasks-per-node parameter with scheduler configuration
+parameters as this could cause conflicts.
+
+ at unnumberedsubsec What does @command{ncclimo} do?
+For monthly climatologies (e.g., @acronym{JAN}), @command{ncclimo} passes
+the list of all relevant January monthly files to @acronym{NCO}'s
+ at command{ncra} command, which averages each variable in these monthly
+files over their time-dimension (if it exists) or copies the value from
+the first month unchanged (if no time-axis exists). 
+Seasonal climos are then created by taking the average of the monthly
+climo files using @command{ncra}. 
+To account for differing numbers of days per month, the @command{ncra}
+ at samp{-w} flag is used, followed by the number of days in the relevant
+months. 
+For example, the @acronym{MAM} climo is computed with 
+ at samp{ncra -w 31,30,31 MAR_climo.nc APR_climo.nc MAY_climo.nc MAM_climo.nc} 
+(details about file names and other optimization flags have been
+stripped here to make the concept easier to follow). 
+The annual (@acronym{ANN}) climo is then computed as a weighted
+average of the seasonal climos.
+
+ at unnumberedsubsec Assumptions, Approximations, and Algorithms (@acronym{AAA}) Employed: 
+A climatology embodies many algorithmic choices, and regridding from the
+native to the analysis grid involves still more choices. 
+A separate method should reproduce the @command{ncclimo} and
+ at acronym{NCO} answers to round-off precision if it implements the same
+algorithmic choices. 
+For example, @command{ncclimo} agrees to round-off with @acronym{AMWG}
+diagnostics when making the same (sometimes questionable) choices. 
+The most important choices have to do with converting single- to
+double-precision (@acronym{SP} and @acronym{DP}, respectively),
+treatment of missing values, and generation/application of regridding
+weights. 
+For concreteness and clarity we describe the algorithmic choices made in
+processing a @acronym{CAM-SE} monthly output into a climatological
+annual mean (@acronym{ANN}) and then regridding that. 
+Other climatologies (e.g., daily to monthly, or
+annual-to-climatological) involve similar choices. 
+
+ at acronym{ACME} (and @acronym{CESM}) computes fields in @acronym{DP} and
+outputs history (not restart) files as monthly means in @acronym{SP}. 
+The @acronym{NCO} climatology generator (@command{ncclimo}) processes
+these data in four stages. 
+Stage @var{N} accesses input only from stage @math{@var{N-1}}, never
+from stage @math{@var{N-2}} or earlier. 
+Thus the (on-disk) files from stage @var{N} determine the highest
+precision achievable by stage @math{@var{N+1}}. 
+The general principal is to perform math (addition, weighting,
+normalization) in @acronym{DP} and output results to disk in the same
+precision in which they were input from disk (usually @acronym{SP}). 
+In @w{Stage 1}, @acronym{NCO} ingests @w{Stage 0} monthly means (raw
+ at acronym{CAM-SE} output), converts @acronym{SP} input to @acronym{DP},
+performs the average across all years, then converts the answer from
+ at acronym{DP} to @acronym{SP} for storage on-disk as the climatological
+monthly mean. 
+In @w{Stage 2}, @acronym{NCO} ingests @w{Stage 1} climatological monthly
+means, converts @acronym{SP} input to @acronym{DP}, performs the average
+across all months in the season (e.g., @acronym{DJF}), then converts the  
+answer from @acronym{DP} to @acronym{SP} for storage on-disk as the
+climatological seasonal mean. 
+In @w{Stage 3}, @acronym{NCO} ingests @w{Stage 2} climatological
+seasonal means, converts @acronym{SP} input to @acronym{DP}, performs
+the average across all four seasons (@acronym{DJF}, @acronym{MAM},
+ at acronym{JJA}, @acronym{SON}), then converts the answer from
+ at acronym{DP} to @acronym{SP} for storage on-disk as the climatological
+annual mean.  
+
+ at w{Stage 2} weights each input month by its number of days (e.g., 31 for 
+January), and @w{Stage 3} weights each input season by its number of days 
+(e.g., 92 for @acronym{MAM}). 
+ at acronym{ACME} runs @acronym{CAM-SE} with a 365-day calendar, so these
+weights are independent of year and never change. 
+The treatment of missing values in @w{Stages 1--3} is limited by the
+lack of missing value tallies provided by @w{Stage 0} (model) output. 
+ at w{Stage 0} records a value as missing if it is missing for the entire
+month, and present if the value is valid for one or more timesteps. 
+ at w{Stage 0} does not record the missing value tally (number of valid
+timesteps) for each spatial point. 
+Thus a point with a single valid timestep during a month is weighted the
+same in @w{Stages 1--4} as a point with 100% valid timesteps during the
+month. 
+The absence of tallies inexorably degrades the accuracy of subsequent
+statistics by an amount that varies in time and space. 
+On the positive side, it reduces the output size (by a factor of two) 
+and complexity of analyzing fields that contain missing values. 
+Due to the ambiguous nature of missing values, it is debatable whether
+they merit efforts to treat them more exactly. 
+
+The vast majority of fields undergo three promotion/demotion cycles 
+between @acronym{CAM-SE} and @acronym{ANN}. 
+No promotion/demotion cycles occur for history fields that
+ at acronym{CAM-SE} outputs in @acronym{DP} rather than @acronym{SP}, nor
+for fields without a time dimension. 
+Typically these fields are grid coordinates (e.g., longitude, latitude) 
+or model constants (e.g., 
+ at set flg
+ at tex
+$\cod$
+ at clear flg
+ at end tex
+ at ifinfo
+CO2
+ at clear flg
+ at end ifinfo
+ at ifset flg
+CO2
+ at clear flg
+ at end ifset
+mixing ratio). 
+ at acronym{NCO} never performs any arithmetic on grid coordinates or
+non-time-varying input, regardless of whether they are @acronym{SP} or
+ at acronym{DP}. 
+Instead, @acronym{NCO} copies these fields directly from the first input
+file.  
+ at w{Stage 4} uses a mapfile to regrid climos from the native to the
+desired analysis grid. 
+ at acronym{ACME} currently uses mapfiles generated by
+ at command{ESMF_RegridWeightGen} (@acronym{ERWG}) and by TempestRemap.  
+
+The algorithmic choices, approximations, and commands used to generate
+mapfiles from input gridfiles are separate issues.
+We mention only some of these issues here for brevity.
+Input gridfiles used by @acronym{ACME} until ~20150901, and by
+ at acronym{CESM} (then and currently, at least for Gaussian grids)
+contained flaws that effectively reduced their precision, especially at
+regional scales, and especially for Gaussian grids. 
+ at acronym{ACME} (and @acronym{CESM}) mapfiles continue to approximate
+grids as connected by great circles, whereas most analysis grids (and
+some models) use great circles for longitude and small circles for
+latitude. 
+The great circle assumption may be removed in the future. 
+Constraints imposed by @acronym{ERWG} during weight-generation ensure
+that global integrals of fields undergoing conservative regridding are
+exactly conserved. 
+
+Application of weights from the mapfile to regrid the native data to the
+analysis grid is straightforward. 
+Grid fields (e.g., latitude, longitude, area) are not regridded. 
+Instead they are copied (and area is reconstructed if absent) directly
+from the mapfile. 
+ at acronym{NCO} ingests all other native grid (source) fields, converts
+ at acronym{SP} to @acronym{DP}, and accumulates destination gridcell
+values as the sum of the @acronym{DP} weight (from the sparse matrix in
+the mapfile) times the (usually @acronym{SP}-promoted-to- at acronym{DP})
+source values. 
+Fields without missing values are then stored to disk in their
+original precision. 
+Fields with missing values are treated (by default) with what
+ at acronym{NCO} calls the ``conservative'' algorithm. 
+This algorithm uses all valid data from the source grid on the
+destination grid once and only once. 
+Destination cells receive the weighted valid values of the source
+cells. 
+This is conservative because the global integrals of the source and
+destination fields are equal. 
+See @ref{ncremap netCDF Remapper} for more description of the
+conservative and of the optional (``renormalized'') algorithm. 
+
+ at noindent
+ at html
+<a name="xmp_ncclimo"></a> <!-- http://nco.sf.net/nco.html#xmp_ncclimo -->
+ at end html
+EXAMPLES
+
+ at html
+<a name="merra2"></a> <!-- http://nco.sf.net/nco.html#merra2 -->
+ at end html
+How to create a climo from a collection of monthly
+non- at acronym{CESM}'ish files?
+This is a two-step procedure:
+First be sure the names are arranged with a @acronym{YYYYMM}-format date
+preceding the suffix (usually @samp{.nc}).
+Then give @emph{any} monthly input filename to @command{ncclimo}.
+Consider the @acronym{MERRA2} collection, for example.
+As retrieved from @acronym{NASA}, @acronym{MERRA2} files have names like
+ at file{svc_MERRA2_300.tavgM_2d_aer_Nx.200903.nc4}. 
+While the sub-string @samp{200903} is easy to recognize as a month in
+ at acronym{YYYYMM} format, other parts (specifically the @samp{300} code)
+of the filename also change with date. 
+We can use Bash regular expressions to extract dates and create symbolic
+links to simpler filenames with regularly patterned @acronym{YYYYMM}
+strings like @file{merra2_200903.nc4}:
+ at example
+ at verbatim
+for fl in `ls *.nc4` ; do
+# Convert svc_MERRA2_300.tavgM_2d_aer_Nx.YYYYMM.nc4 to merra2_YYYYMM.nc4
+    sfx_out=`expr match "${fl}" '.*_Nx.\(.*.nc4\)'`
+    fl_out="merra2_${sfx_out}"
+    ln -s ${fl} ${fl_out}
+done
+ at end verbatim
+ at end example
+Then call @command{ncclimo} with @file{merra2_200903.nc4} as
+ at var{caseid}: 
+ at example
+ncclimo -c merra2_200903.nc4 -s 1980 -e 2016 -i $drc_in -o $drc_out
+ at end example
+
+ at page
+ at html
 <a name="nces"></a> <!-- http://nco.sf.net/nco.html#nces -->
 <a name="ncea"></a> <!-- http://nco.sf.net/nco.html#ncea -->
 @end html
@@ -16688,12 +17462,12 @@ Examine the netCDF output file to see the variables in the binary file.
 Use the @samp{-C} switch, if necessary, to avoid wanting unwanted
 coordinates to the binary file:
 @example
-% ncks -O -v one_dmn_rec_var -b ~/bnr.dat -p ~/nco/data in.nc ~/out.nc
-% ls -l ~/bnr.dat | cut -d ' ' -f 5 # 200 B contains time and one_dmn_rec_var
+% ncks -O -v one_dmn_rec_var -b bnr.dat -p ~/nco/data in.nc out.nc
+% ls -l bnr.dat | cut -d ' ' -f 5 # 200 B contains time and one_dmn_rec_var
 200
-% ls -l ~/bnr.dat
-% ncks -C -O -v one_dmn_rec_var -b ~/bnr.dat -p ~/nco/data in.nc ~/out.nc
-% ls -l ~/bnr.dat | cut -d ' ' -f # 40 B contains one_dmn_rec_var only
+% ls -l bnr.dat
+% ncks -C -O -v one_dmn_rec_var -b bnr.dat -p ~/nco/data in.nc out.nc
+% ls -l bnr.dat | cut -d ' ' -f # 40 B contains one_dmn_rec_var only
 40
 @end example
 
@@ -16856,15 +17630,18 @@ changing variable dimensionality, including the record dimension.
 @cindex @code{--data}
 @cindex @code{--hieronymus}
 @item -H 
-Turn-on printing to screen or turn-off copying data (not metadata).
+Toggle default behavior of printing to screen or copying data (not
+metadata). 
 Also activated using @samp{--print} or @samp{--prn}.
-By default @command{ncks} prints all metadata and data to screen if
-no netCDF output file is specified.
-Use @samp{-H} to print data to screen if a netCDF output is specified,
-or to restrict printing to data (no metadata) when no netCDF output is 
-specified.
-Also use @samp{-H} to turn-off copying data (not metadata) to an output
-file. 
+By default @command{ncks} prints all metadata but no data to screen 
+when no netCDF @var{output-file} when one is specified.
+And if @var{output-file} is specified, @command{ncks} copies all
+metadata and all data to it.
+In other words, the printing/copying default is context-sensitive,
+and @samp{-H} toggles the default behavior.
+Hence, use @samp{-H} to turn-off copying data (not metadata) to an
+output file. 
+And use @samp{-H} to turn-on printing data (not metadata) to screen.
 Unless otherwise specified (with @code{-s}), each element of the data
 hyperslab prints on a separate line containing the names, indices,
 and, values, if any, of all of the variables dimensions.
@@ -17606,6 +18383,7 @@ Using the @code{%s} format code on strings which are not NUL-terminated
 @cindex @code{climatology} attribute
 @cindex @code{bounds} attribute
 @cindex @code{ancillary_variables} attribute
+ at cindex @code{grid_mapping} attribute
 Create netCDF @file{out.nc} containing all variables, and any associated 
 coordinates, except variable @code{time}, from netCDF @file{in.nc}:
 @example
@@ -17614,15 +18392,15 @@ ncks -x -v time in.nc out.nc
 As a special case of this, consider how to remove a 
 variable such as @code{time_bounds} that is identified in a
 @acronym{CF} Convention (@pxref{CF Conventions}) compliant
- at code{ancillary_variables}, @code{bounds}, @code{climatology}, or
- at code{coordinates} attribute. 
+ at code{ancillary_variables}, @code{bounds}, @code{climatology}, 
+ at code{coordinates}, or @code{grid_mapping} attribute. 
 @acronym{NCO} subsetting assumes the user wants all ancillary variables,
 axes, bounds and coordinates associated with all extracted variables 
 (@pxref{Subsetting Coordinate Variables}).
 Hence to exclude a @code{ancillary_variables}, @code{bounds},
- at code{climatology}, or @code{coordinates} variable while retaining the
-``parent'' variable (here @code{time}), one must use the @samp{-C}
-switch:  
+ at code{climatology}, @code{coordinates}, or @code{grid_mapping} variable
+while retaining the ``parent'' variable (here @code{time}), one must use
+the @samp{-C} switch:  
 @example
 ncks -C -x -v time_bounds in.nc out.nc
 @end example
@@ -17651,7 +18429,7 @@ two variables @code{time} and @code{pressure}.
 Create netCDF @file{out.nc} containing all variables from file
 @file{in.nc}.  
 Restrict the dimensions of these variables to a hyperslab. 
-Print (with @code{-H}) the hyperslabs to the screen for good measure.  
+ at c Print (with @code{-H}) the hyperslabs to the screen for good measure.  
 The specified hyperslab is: the fifth value in dimension @code{time};
 the 
 half-open range @math{@var{lat} > 0.} in coordinate @code{lat}; the
@@ -17662,7 +18440,7 @@ Note that limits applied to coordinate values are specified with a
 decimal point, and limits applied to dimension indices do not have a 
 decimal point @xref{Hyperslabs}.
 @example
-ncks -H -d time,5 -d lat,,0.0 -d lon,330.0, -d band,0.3,0.5 
+ncks -d time,5 -d lat,,0.0 -d lon,330.0, -d band,0.3,0.5 
 -d lev,1000.0 in.nc out.nc 
 @end example
 
@@ -17800,10 +18578,9 @@ Similarly, @command{ncunpack} is a synonym for @command{ncpdq}
 except that @command{ncpack} implicitly assumes a request to unpack, 
 i.e., @samp{-P pck_upk}.
 @cindex @code{-U}
- at cindex @code{--upk}
 @cindex @code{--unpack}
 Finally, the @command{ncpdq} @samp{-U} switch (or its long option
-equivalents, @samp{--upk} and @samp{--unpack}) requires no argument.
+equivalents @samp{--unpack}) requires no argument.
 It simply requests unpacking.
 
 Given the menagerie of synonyms, equivalent options, and implied
@@ -18110,8 +18887,10 @@ ncpdq --hdf_upk -P xst_new modis.nc modis.nc
 Prior to @acronym{NCO} 4.4.0 and netCDF 4.3.1 (January, 2014),
 @acronym{NCO} requires the @samp{--hdf4} switch to correctly read
 HDF4 input files.
-For example, @samp{ncpdq --hdf4 --hdf_upk -P xst_new modis.hdf modis.nc}.
-That switch is now obsolete, though harmless for backwards compatibility.
+For example, 
+ at samp{ncpdq --hdf4 --hdf_upk -P xst_new modis.hdf modis.nc}. 
+That switch is now obsolete, though harmless for backwards
+compatibility. 
 Prior to version 4.3.7 (October, 2013), @acronym{NCO} lacked the
 software necessary to workaround netCDF library flaws handling
 @acronym{HDF4} files, and thus @acronym{NCO} failed to convert
@@ -18176,7 +18955,12 @@ ncpdq -a lon,-lat in.nc out.nc # OK. No whitespace before "-"
 ncpdq --rdr=-lat in.nc out.nc # Preferred. Uses "=" not whitespace
 @end example
 
+ at cindex transpose
 @cindex reverse dimensions
+ at html
+<a name="ncpdq_trn"></a> <!-- http://nco.sf.net/nco.html#ncpdq_trn -->
+<a name="transpose"></a> <!-- http://nco.sf.net/nco.html#transpose -->
+ at end html
 To create the mathematical transpose of a variable, place all its
 dimensions in the dimension re-order list in reversed order.
 This example creates the transpose of @code{three_dmn_var}: 
@@ -18291,7 +19075,7 @@ changing variable dimensionality, including the record dimension.
 @noindent
 SYNTAX
 @example
-ncra [-3] [-4] [-6] [-7] [-A] [-C] [-c]
+ncra [-3] [-4] [-6] [-7] [-A] [-C] [-c] [--cb]
 [--cnk_dmn nm,sz] [--cnk_map map] [--cnk_min sz] [--cnk_plc plc] [--cnk_scl sz]
 [-D @var{dbg}] [-d @var{dim},[@var{min}][,[@var{max}][,[@var{stride}][,[@var{subcycle}]]]] [-F]
 [-G @var{gpe_dsc}] [-g @var{grp}[, at dots{}]] [--glb ...] [-h] [--hdf] [--hdr_pad @var{nbr}] 
@@ -18390,6 +19174,58 @@ Second, weights are never applied for minimization, square-roots, etc.
 @code{time}) regardless of the weighting performed on non-coordinate
 variables.
 
+ at html
+<a name="cb"></a> <!-- http://nco.sf.net/nco.html#cb -->
+<a name="c2b"></a> <!-- http://nco.sf.net/nco.html#c2b -->
+<a name="clm_bnd"></a> <!-- http://nco.sf.net/nco.html#clm_bnd -->
+<a name="clm2bnd"></a> <!-- http://nco.sf.net/nco.html#clm2bnd -->
+ at end html
+ at cindex @code{--cb}
+ at cindex @code{--c2b}
+ at cindex @code{--clm_bnd}
+ at cindex @code{--clm2bnd}
+As of @acronym{NCO} version 4.6.0 (April, 2016) @command{ncra} can honor 
+the @acronym{CF} @code{climatology} and climatological statistics
+conventions described in @ref{CF Conventions}.
+Currently this is opt-in with the @samp{--cb} flag (or long-option
+equivalent @samp{--clm_bnd}), or with the @samp{--c2b} flag (or its
+long-option equivalent @samp{--clm2bnd}) switches. 
+Invoking @samp{--cb} causes @command{ncra} to:
+ at enumerate
+ at item Add a @code{climatology} attribute with value
+``climatology_bounds'' the time coordinate, if necessary
+ at item Remove the @code{bounds} attribute from the time coordinate, if
+necessary 
+ at item Output a variable named @code{climatology_bounds} with values that
+      are minima/maxima of the input time coordinate @code{bounds}
+      variable. 
+ at item Omit any input time coordinate @code{bounds} attribute and
+      variable 
+ at item Ensure the @code{cell_methods} attribute for all variables is
+      appropriate for climatolgies within and over years.
+      Climatologies within days will have incorrect units (the switch is
+      currently opt-in so that incorrect units are not inadvertently generated).
+      Please contact the authors if this functionality is important to you
+      (The omission of climatologies within days is mainly a matter of
+      trying to keep the switches and interface clean).
+ at end enumerate
+Use the @samp{--c2b} flag (instead of @samp{--cb}) to convert the input
+ at code{climatology} bounds to a non-climatology @code{bounds} in the
+output.  
+In other words, use @samp{--c2b} when averaging sub-sampled
+climatologies together to produce a continuous (non-climatologically
+sub-sampled) mean. 
+ at example
+# Use --cb to average months into a climatological month
+ncra --cb 2014_01.nc 2015_01.nc 2016_01.nc clm_JAN.nc
+# Use --cb to average climatological months into a climatological season
+ncra --cb clm_DEC.nc clm_JAN.nc clm_FEB.nc clm_DJF.nc
+# Four seasons make a complete year so use --c2b
+ncra --c2b clm_DJF.nc clm_MAM.nc clm_JJA.nc clm_SON.nc clm_ANN.nc
+ at end example
+Currently this functionality only works with climatologies within and
+over years (not within or over days).
+
 @noindent
 @html
 <a name="xmp_ncra"></a> <!-- http://nco.sf.net/nco.html#xmp_ncra -->
@@ -18456,7 +19292,7 @@ weighted mean statistics.
 @html
 <a name="ncrcat"></a> <!-- http://nco.sf.net/nco.html#ncrcat -->
 @end html
- at node ncrcat netCDF Record Concatenator, ncremap netCDF Remapper, ncra netCDF Record Averager, Reference Manual
+ at node ncrcat netCDF Record Concatenator, ncclimo netCDF Climatology Generator, ncra netCDF Record Averager, Reference Manual
 @section @command{ncrcat} netCDF Record Concatenator
 @cindex concatenation
 @cindex record concatenation
@@ -18590,7 +19426,7 @@ ncrcat -d time,6.,54. ??.nc 8506_8906.nc
 @html
 <a name="ncremap"></a> <!-- http://nco.sf.net/nco.html#ncremap -->
 @end html
- at node ncremap netCDF Remapper, ncrename netCDF Renamer, ncrcat netCDF Record Concatenator, Reference Manual
+ at node ncremap netCDF Remapper, ncrename netCDF Renamer, ncclimo netCDF Climatology Generator, Reference Manual
 @section @command{ncremap} netCDF Remapper
 @cindex remap
 @cindex regrid
@@ -18603,7 +19439,7 @@ ncremap [-a @var{alg_typ}] [-D @var{dbg_lvl}] [-d @var{dst_fl}] [-E @var{esmf_op
 [-G @var{grd_sng}] [-g @var{grd_dst}] [-I @var{drc_in}] [-i @var{input-file}] [-j @var{job_nbr}]
 [-M] [-m @var{map_fl}] [-n @var{nco_opt}] [-O @var{drc_out}] [-o @var{output-file}]
 [-P @var{pdq_typ}] [-p @var{par_typ}] [-R @var{rgr_opt}] [-s @var{grd_src}] 
-[-T @var{tempest_opt}] [-t @var{thr_nbr}] [-v @var{var_lst}[, at dots{}]] 
+[-T @var{tempest_opt}] [-t @var{thr_nbr}] [-u @var{unq_sfx}] [-V @var{rgr_var}] [-v @var{var_lst}[, at dots{}]] 
 [-w @var{wgt_gnr}] [-x @var{xtn_lst}[, at dots{}]] 
 @end example
 
@@ -18650,13 +19486,18 @@ generate weights and mapfiles.
 In order to use the weight-generation options, ensure that one or both
 of the weight-generation packages is installed and on your
 @code{$PATH}. 
- at acronym{ERWG} is distributed in binary format with @acronym{NCL}, which
-many (most?) @acronym{NCO} users already have on their system(s). 
- at acronym{ERWG} may also be installed from source:
+The recommended way to obtain @acronym{ERWG} is as distributed in binary
+format with @acronym{NCL}, which many (most?) @acronym{NCO} users
+already have on their system(s).
+Then be sure the directory containing the @acronym{ERWG} executable is
+on your @code{$PATH} before using @command{ncremap}.
+As a fallback, @acronym{ERWG} may also be installed from source:
 @url{https://earthsystemcog.org/projects/esmf/download_last_public}.
 @command{ncremap} can also generate and utilize mapfiles created by
 TempestRemap, 
 @url{https://github.com/ClimateGlobalChange/tempestremap}.
+As far as we know TempestRemap must be built from source because there
+are no binary distributions of it. 
 Please contact those projects for support on building and installing
 their software, which makes @command{ncremap} more functional and
 user-friendly.
@@ -18992,7 +19833,7 @@ using @samp{-I @var{in_drc}} or standard input) generates an error
 @cindex @var{pdq_typ}
 @item -P @var{pdq_typ}
 Specifies the permutation mode desired.
-As of January 15, 2016, one can tell @command{ncremap} to automatically
+As of January~15, 2016, one can tell @command{ncremap} to automatically
 tagpermute the dimensions in the data file prior to regridding for a
 limited (though growning) number of data-file types that suffer from
 the @command{ncremap} limitation concerning dimension ordering.
@@ -19029,8 +19870,6 @@ In @acronym{MPI} mode these commands are issued round-robin fashion
 to all the compute nodes available to the job.
 Typically both parallel modes scale well with sufficent @acronym{CPU}s
 until I/O contention becomes the bottleneck. 
-Currently there is no way to limit the number of regridding commands 
-spawned in parallel mode, so be sure not to overwhelm your system.
 Furthermore, a naming conflict among intermediate files still exists
 (see Limitations, below) so parallel mode is currently only supported
 when all source files share the same grid.
@@ -19102,6 +19941,29 @@ Specifies the number of threads used per regridding process
 The @acronym{NCO} regridder scales well up to 8--16 threads.
 
 @html
+<a name="unq_sfx"></a> <!-- http://nco.sf.net/nco.html#unq_sfx -->
+ at end html
+ at cindex @code{-u @var{unq_sfx}}
+ at cindex @var{unq_sfx}
+ at cindex noclean
+ at item -u @var{unq_sfx}
+Specifies the suffix used to label intermediate (internal) files
+generated by the regridding workflow.
+Unique names are required to avoid interference among parallel
+invocations of @command{ncremap}. 
+The default @var{unq_sfx} is @samp{.pid at var{PID}.ncremap.tmp}, where
+ at var{PID} is the process ID.
+Applications that invoke ncremap can provide more or less informative
+suffixes.
+The suffix should be unique so that no two simultaneously executing 
+instances of @command{ncremap} can generate the same file.
+For instance, a climatology script that issues a dozen @command{ncremap} 
+commands may find it useful to encode the climatological month in the
+unique suffix.
+If @var{unq_sfx} is @samp{noclean} then @command{ncremap} retains
+(not removes) all intermediate files after completion.
+
+ at html
 <a name="var_lst"></a> <!-- http://nco.sf.net/nco.html#var_lst -->
 @end html
 @cindex @code{-v @var{var_lst}}
@@ -19113,6 +19975,42 @@ It behaves like subsetting (@pxref{Subsetting Files}) in the rest of
 @acronym{NCO}.   
 
 @html
+<a name="rgr_var"></a> <!-- http://nco.sf.net/nco.html#rgr_var -->
+ at end html
+ at cindex @code{-V @var{rgr_var}}
+ at cindex @var{rgr_var}
+ at item -V @var{rgr_var}
+The @samp{-V} option tells @command{ncremap} to use the same grid as 
+ at var{rgr_var} in the input file.
+If @var{rgr_var} adheres to the @acronym{CF} @code{coordinates}
+convention described 
+ at uref{http://cfconventions.org/1.6.html#coordinate-system, here},
+then @command{ncclimo} will infer the grid as represented by those
+coordinate variables.
+This option simplifies inferring grids when the grid coordinate names 
+are unknown, since @command{ncclimo} will follow the @acronym{CF}
+convention to learn the identity of the grid coordinates.
+
+Until @acronym{NCO} version 4.6.0 (May, 2016), @command{ncremap} would 
+not follow @acronym{CF} conventions to identify coordinate variables.
+Instead, @command{ncremap} used an internal database of ``usual
+suspects'' to identify latitude and longitude coordinate variables.
+Now, if @var{rgr_var} is @acronym{CF}-compliant, then @command{ncremap}
+will automatically identify the horizontal spatial dimensions. 
+If @var{rgr_var} is supplied but is not @acronym{CF}-compliant, then
+ at command{ncremap} will use its internal database to identify 
+horizontal spatial dimensions.
+If both these automated methods fail, manually supply @command{ncremap}
+with the names of the horizontal spatial dimensions 
+ at example
+# Method used to obtain horizontal spatial coordinates:
+ncremap -V rgr_var -i in.nc -d dst.nc -O ~/rgr # CF coordinates convention
+ncremap -i in.nc -d dst.nc -O ~/rgr # Internal database
+ncremap -R "--rgr lat_nm=xq --rgr lon_nm=zj" -i in.nc -d dst.nc -O ~/rgr # Manual
+ at end example
+ at noindent
+
+ at html
 <a name="wgt_gnr"></a> <!-- http://nco.sf.net/nco.html#wgt_gnr -->
 @end html
 @cindex @code{-w @var{wgt_gnr}}
@@ -19141,7 +20039,7 @@ Currently variables marked as extensive are summed, not regridded.
 
 @unnumberedsubsec Limitations to @command{ncremap}
 
-There are three significant limitations to @command{ncremap} that we
+There are two significant limitations to @command{ncremap} that we
 hope to remove in the coming year.
 First, the fields to be regridded must have latitude and longitude as
 the final two dimension in @var{in_fl}. 
@@ -19169,7 +20067,7 @@ necessary:
 @example
 # AIRS Level2 vertical profiles
 ncremap -P airs -i AIRS_L2.nc -d dst_1x1.nc -O ~/rgr
-# MPAS-O fields
+# MPAS-O/I fields
 ncremap -P mpas -i mpas.nc -m mpas120_to_t62.nc -O ~/rgr
 @end example
 @noindent
@@ -19179,20 +20077,7 @@ If you work with common datasets that could benefit from their own
 @command{ncremap} @samp{-P} options, contact us and we will try to
 implement them. 
 
-The second limitation is that @command{ncremap} does not yet follow
- at acronym{CF} conventions to identify coordinate variables.
-Instead, @command{ncremap} uses an internal database of ``usual
-suspects'' to identify latitude and longitude coordinate variables.
-Hence even if the @var{input-file} is completely @acronym{CF}-compliant,
- at command{ncremap} may not automatically identify the spatial dimensions.
-To workaround this limitation, supply @command{ncremap} with the names
-of the horizontal spatial dimensions 
- at example
-ncremap -R "--rgr lat_nm=xq --rgr lon_nm=zj" -i in.nc -d dst.nc -O ~/rgr
- at end example
- at noindent
-
-The third limitation is that @command{ncremap} currently must read
+The second limitation is that @command{ncremap} currently must read
 weights from an on-disk mapfile, it cannot yet compute weights itself 
 and use them directly from @acronym{RAM}.
 This makes @command{ncremap} an ``offline regridder'' and unnecessarily
@@ -19210,18 +20095,21 @@ to call @acronym{ERWG} with the options to exploit those capabilities.
 A side-effect of @command{ncremap} being an offline regridder is that,
 when necessary, it generates intermediate files to store grids and maps.  
 These files are named, by default, 
- at file{ncremap_tmp_grd_dst.nc},
- at file{ncremap_tmp_grd_src.nc},   
- at file{ncremap_tmp_gnr_out.nc},  
- at file{ncremap_tmp_map_*.nc}, 
- at file{ncremap_tmp_msh_ovr_*.nc}, and
- at file{ncremap_tmp_pdq.nc},  
-They are placed in @var{drc_out}, which is the current working directory
-unless otherwise specified.
-No intermediate grid or map files are generated when the map-file is
-provided. 
-No intermediate permuted file is generated unless the 
- at samp{-P @var{prm_typ}} option is invoked.
+ at file{ncremap_tmp_grd_dst.nc}@samp{unq_sfx},
+ at file{ncremap_tmp_grd_src.nc}@samp{unq_sfx},
+ at file{ncremap_tmp_gnr_out.nc}@samp{unq_sfx},
+ at file{ncremap_tmp_map_*.nc}@samp{unq_sfx},
+ at file{ncremap_tmp_msh_ovr_*.nc}@samp{unq_sfx}, and
+ at file{ncremap_tmp_pdq.nc}@samp{unq_sfx}.
+They are placed in @var{drc_out} with the output file(s).
+In general, no intermediate grid or map files are generated when the
+map-file is provided. 
+Intermediate files are always generated when the @samp{-P @var{prm_typ}}
+option is invoked. 
+By default these files are automatically removed upon successful
+completion of the script.
+Early or unexpected termination of @command{ncremap} leaves these
+intermediate files behind.
 Should intermediate files proliferate and/or annoy you, locate and/or
 remove all such files under the current directory with 
 @example
@@ -19229,12 +20117,6 @@ find . -name 'ncremap_tmp*'
 rm `find . -name 'ncremap_tmp*'`
 @end example
 @noindent
-When @command{ncremap} is run in parallel mode, the intermediate files
-can interfere with one-another, and must be uniquely named.
-We have not yet addressed this issue, so parallel mode is supported when 
-all input files are on the same grid, and unsupported otherwise.
-If this limitation affects your workflow, please let us know and we will
-increase the priority of addressing it.
 
 @noindent
 @html
@@ -20806,7 +21688,7 @@ The following script shows how.
 Each dataset becomes a group in the output file.
 There can be several levels of groups.
 In this example, we employ two experiments (``scenarios'') as the top-level.
-The second-level comprises different models (e.g., CCSM4, CESM1-BGC).
+The second-level comprises different models (e.g., @acronym{CCSM4}, @acronym{CESM1-BGC}).
 Many models are run multiple times with slight perturbed initial
 conditions to produce an ensemble of realizations.
 These ensemble members comprise the third level of the hierarchy.
diff --git a/man/Makefile.am b/man/Makefile.am
index 7f9fd9c..acea894 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -1,4 +1,4 @@
 # $Header$ -*-makefile-*-
 
-man_MANS = ncap.1 ncap2.1 ncatted.1 ncbo.1 nces.1 ncecat.1 ncflint.1 ncks.1 nco.1 ncra.1 ncremap.1 ncrename.1 ncpdq.1 ncrcat.1 ncwa.1
+man_MANS = ncap.1 ncap2.1 ncatted.1 ncbo.1 ncclimo.1 nces.1 ncecat.1 ncflint.1 ncks.1 nco.1 ncra.1 ncremap.1 ncrename.1 ncpdq.1 ncrcat.1 ncwa.1
 EXTRA_DIST = $(man_MANS)
diff --git a/man/Makefile.in b/man/Makefile.in
index e9eb358..42c2ec5 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -303,7 +303,7 @@ target_vendor = @target_vendor@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-man_MANS = ncap.1 ncap2.1 ncatted.1 ncbo.1 nces.1 ncecat.1 ncflint.1 ncks.1 nco.1 ncra.1 ncremap.1 ncrename.1 ncpdq.1 ncrcat.1 ncwa.1
+man_MANS = ncap.1 ncap2.1 ncatted.1 ncbo.1 ncclimo.1 nces.1 ncecat.1 ncflint.1 ncks.1 nco.1 ncra.1 ncremap.1 ncrename.1 ncpdq.1 ncrcat.1 ncwa.1
 EXTRA_DIST = $(man_MANS)
 all: all-am
 
diff --git a/man/ncap.1 b/man/ncap.1
index a21596f..588f9ef 100644
--- a/man/ncap.1
+++ b/man/ncap.1
@@ -142,6 +142,23 @@ programs are properly installed at your site, the command
 should give you access to the complete manual, except for the
 TeX-intensive portions.
 
+.BR ncap (1), 
+.BR ncap2 (1), 
+.BR ncatted (1), 
+.BR ncbo (1), 
+.BR ncclimo (1), 
+.BR nces (1), 
+.BR ncecat (1), 
+.BR ncflint (1), 
+.BR ncks (1), 
+.BR nco (1), 
+.BR ncpdq (1), 
+.BR ncra (1), 
+.BR ncrcat (1), 
+.BR ncremap (1), 
+.BR ncrename (1), 
+.BR ncwa (1) 
+
 .SH HOMEPAGE
 The 
 .B NCO
diff --git a/man/ncap2.1 b/man/ncap2.1
index 975b1c0..566cb84 100644
--- a/man/ncap2.1
+++ b/man/ncap2.1
@@ -146,6 +146,23 @@ programs are properly installed at your site, the command
 should give you access to the complete manual, except for the
 TeX-intensive portions.
 
+.BR ncap (1), 
+.BR ncap2 (1), 
+.BR ncatted (1), 
+.BR ncbo (1), 
+.BR ncclimo (1), 
+.BR nces (1), 
+.BR ncecat (1), 
+.BR ncflint (1), 
+.BR ncks (1), 
+.BR nco (1), 
+.BR ncpdq (1), 
+.BR ncra (1), 
+.BR ncrcat (1), 
+.BR ncremap (1), 
+.BR ncrename (1), 
+.BR ncwa (1) 
+
 .SH HOMEPAGE
 The 
 .B NCO
diff --git a/man/ncatted.1 b/man/ncatted.1
index 5eef2ca..82e4e74 100644
--- a/man/ncatted.1
+++ b/man/ncatted.1
@@ -16,7 +16,7 @@ ncatted [\-a
 .IR att_val ]]
 [\-h] [\-\-hdr_pad
 .IR sz ]
-[\-l path] [\-O] [\-p path] [\-R] [\-r] [\-\-ram_all]
+[\-l path] [\-O] [\-p path] [\-R] [\-r] [\-\-ram_all] [\-t]
 .I input-file
 [
 .IR output-file ]
@@ -198,8 +198,8 @@ If
 .I var_nm
 does not have an attribute 
 .IR att_nm ,
-there is no
-effect.
+it is created with value
+.IR att_val.
 .TP
 .B c
 .IR Create .
@@ -254,6 +254,24 @@ does not have an attribute
 there is no
 effect. 
 .TP
+.B n 
+.IR Nappend .
+Append value 
+.I att_val
+to current 
+.I var_nm
+attribute
+.I att_nm
+value 
+.IR att_val ,
+if any.  
+If 
+.I var_nm
+does not have an attribute 
+.IR att_nm ,
+there is no
+effect. 
+.TP
 .B o
 .IR Overwrite .
 Write attribute 
@@ -527,6 +545,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/man/ncbo.1 b/man/ncbo.1
index d7ef8c2..dd457dd 100644
--- a/man/ncbo.1
+++ b/man/ncbo.1
@@ -149,7 +149,7 @@ dimensions which
 causes 
 .B ncbo
 to fail.
-To prevent this from occuring, use 
+To prevent this from occurring, use 
 .B ncwa
 to remove the 
 .B time
diff --git a/man/ncremap.1 b/man/ncclimo.1
similarity index 75%
copy from man/ncremap.1
copy to man/ncclimo.1
index efbfba0..d1bc60d 100644
--- a/man/ncremap.1
+++ b/man/ncclimo.1
@@ -1,70 +1,58 @@
 .\" $Header$ -*-nroff-*-
-.\" Purpose: ROFF man page for ncremap
+.\" Purpose: ROFF man page for ncclimo
 .\" Usage:
-.\" nroff -man ~/nco/man/ncremap.1 | less
-.TH NCREMAP 1
+.\" nroff -man ~/nco/man/ncclimo.1 | less
+.TH NCCLIMO 1
 .SH NAME
-ncremap \- netCDF Renamer
+ncclimo \- netCDF Climatology Generator
 .SH SYNTAX
-ncremap
+ncclimo
 [\-a
-.IR alg_typ ]
-[\-D
-.IR dbg_lvl ] 
+.IR clm_md ]
+[\-b
+.IR bnd_nm ]
+[\-c
+.IR caseid ]
 [\-d
-.IR dst_fl ] 
-[\-E
-.IR esmf_opt ] 
-[\-G
-.IR grd_sng ] 
-[\-g
-.IR grd_fl ] 
-[\-I
-.IR in_drc ] 
+.IR dbg_lvl ] 
+[\-e
+.IR yr_end ] 
+[\-f
+.IR fml_nm ] 
+[\-h
+.IR hst_nm ] 
 [\-i
-.IR in_fl ] 
-[\-j
-.IR job_nbr ] 
-[\-M] [\-m
-.IR map_fl ] 
+.IR drc_in ] 
+[\-l
+.IR lnk_flg ] 
+[\-m
+.IR mdl_nm ] 
 [\-n
 .IR nco_usr ] 
 [\-O
-.IR out_drc ] 
+.IR drc_rgr ] 
 [\-o
-.IR output-file ] 
-[\-P
-.IR pdq_typ ] 
+.IR drc_out ] 
 [\-p
 .IR par_typ ] 
 [\-R
 .IR rgr_opt ] 
+[\-r
+.IR rgr_map ] 
 [\-s
-.IR grd_src ] 
-[\-T
-.IR tempest_opt ] 
+.IR yr_srt ] 
 [\-t
 .IR thr_nbr ] 
 [\-v
 .IR var_lst ] 
-[\-w
-.IR wgt_gnr ] 
 [\-x
-.IR xtn_var ] 
+.IR cf_flg ] 
 
 .SH DESCRIPTION
 .PP
-.B ncremap
-remaps the data in the
-.I input-file
-file(s) to the grid specified by (in descending order of precedence)
-.I map_fl ,
-.I dst_fl, 
-.I grd_dst, or
-.I grd_sng,
-and stores the result(s) in the
-.I output-file
-file(s).
+.B ncclimo
+produces climatological monthly means, seasonal means, annual mean,
+and optionally regrids all these files.
 
 .\" NB: Append man_end.txt here
 .\" $Header$ -*-nroff-*-
@@ -118,6 +106,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/man/ncecat.1 b/man/ncecat.1
index d7269d6..4e1828e 100644
--- a/man/ncecat.1
+++ b/man/ncecat.1
@@ -179,6 +179,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/man/nces.1 b/man/nces.1
index 561fceb..9698f23 100644
--- a/man/nces.1
+++ b/man/nces.1
@@ -188,6 +188,23 @@ programs are properly installed at your site, the command
 should give you access to the complete manual, except for the
 TeX-intensive portions.
 
+.BR ncap (1), 
+.BR ncap2 (1), 
+.BR ncatted (1), 
+.BR ncbo (1), 
+.BR ncclimo (1), 
+.BR nces (1), 
+.BR ncecat (1), 
+.BR ncflint (1), 
+.BR ncks (1), 
+.BR nco (1), 
+.BR ncpdq (1), 
+.BR ncra (1), 
+.BR ncrcat (1), 
+.BR ncremap (1), 
+.BR ncrename (1), 
+.BR ncwa (1) 
+
 .SH HOMEPAGE
 The 
 .B NCO
diff --git a/man/ncflint.1 b/man/ncflint.1
index dba85d9..18e14f9 100644
--- a/man/ncflint.1
+++ b/man/ncflint.1
@@ -225,6 +225,23 @@ programs are properly installed at your site, the command
 should give you access to the complete manual, except for the
 TeX-intensive portions.
 
+.BR ncap (1), 
+.BR ncap2 (1), 
+.BR ncatted (1), 
+.BR ncbo (1), 
+.BR ncclimo (1), 
+.BR nces (1), 
+.BR ncecat (1), 
+.BR ncflint (1), 
+.BR ncks (1), 
+.BR nco (1), 
+.BR ncpdq (1), 
+.BR ncra (1), 
+.BR ncrcat (1), 
+.BR ncremap (1), 
+.BR ncrename (1), 
+.BR ncwa (1) 
+
 .SH HOMEPAGE
 The 
 .B NCO
diff --git a/man/ncks.1 b/man/ncks.1
index 19f96b4..d482902 100644
--- a/man/ncks.1
+++ b/man/ncks.1
@@ -661,6 +661,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/man/nco.1 b/man/nco.1
index 479d74a..13747a4 100644
--- a/man/nco.1
+++ b/man/nco.1
@@ -163,6 +163,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/man/ncpdq.1 b/man/ncpdq.1
index 0892a21..8be9a25 100644
--- a/man/ncpdq.1
+++ b/man/ncpdq.1
@@ -173,6 +173,23 @@ programs are properly installed at your site, the command
 should give you access to the complete manual, except for the
 TeX-intensive portions.
 
+.BR ncap (1), 
+.BR ncap2 (1), 
+.BR ncatted (1), 
+.BR ncbo (1), 
+.BR ncclimo (1), 
+.BR nces (1), 
+.BR ncecat (1), 
+.BR ncflint (1), 
+.BR ncks (1), 
+.BR nco (1), 
+.BR ncpdq (1), 
+.BR ncra (1), 
+.BR ncrcat (1), 
+.BR ncremap (1), 
+.BR ncrename (1), 
+.BR ncwa (1) 
+
 .SH HOMEPAGE
 The 
 .B NCO
diff --git a/man/ncra.1 b/man/ncra.1
index 5915adc..57b2b04 100644
--- a/man/ncra.1
+++ b/man/ncra.1
@@ -206,6 +206,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/man/ncrcat.1 b/man/ncrcat.1
index 5adfc1b..f174dce 100644
--- a/man/ncrcat.1
+++ b/man/ncrcat.1
@@ -219,6 +219,23 @@ programs are properly installed at your site, the command
 should give you access to the complete manual, except for the
 TeX-intensive portions.
 
+.BR ncap (1), 
+.BR ncap2 (1), 
+.BR ncatted (1), 
+.BR ncbo (1), 
+.BR ncclimo (1), 
+.BR nces (1), 
+.BR ncecat (1), 
+.BR ncflint (1), 
+.BR ncks (1), 
+.BR nco (1), 
+.BR ncpdq (1), 
+.BR ncra (1), 
+.BR ncrcat (1), 
+.BR ncremap (1), 
+.BR ncrename (1), 
+.BR ncwa (1) 
+
 .SH HOMEPAGE
 The 
 .B NCO
diff --git a/man/ncremap.1 b/man/ncremap.1
index efbfba0..b81731c 100644
--- a/man/ncremap.1
+++ b/man/ncremap.1
@@ -4,7 +4,7 @@
 .\" nroff -man ~/nco/man/ncremap.1 | less
 .TH NCREMAP 1
 .SH NAME
-ncremap \- netCDF Renamer
+ncremap \- netCDF Remapper
 .SH SYNTAX
 ncremap
 [\-a
diff --git a/man/ncrename.1 b/man/ncrename.1
index 564da46..d025cf2 100644
--- a/man/ncrename.1
+++ b/man/ncrename.1
@@ -246,6 +246,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/man/ncwa.1 b/man/ncwa.1
index 3e637e3..c0074ed 100644
--- a/man/ncwa.1
+++ b/man/ncwa.1
@@ -262,6 +262,7 @@ TeX-intensive portions.
 .BR ncap2 (1), 
 .BR ncatted (1), 
 .BR ncbo (1), 
+.BR ncclimo (1), 
 .BR nces (1), 
 .BR ncecat (1), 
 .BR ncflint (1), 
diff --git a/src/nco++/NcapVarVector.cc b/src/nco++/NcapVarVector.cc
index 4b0963b..75af424 100644
--- a/src/nco++/NcapVarVector.cc
+++ b/src/nco++/NcapVarVector.cc
@@ -140,7 +140,39 @@ void NcapVarVector::sort(){
 }
 
 
+// takes a variable name as an argument and 
+// deletes that and all associated attributes 
+// of the form var_m@
+void NcapVarVector::erase_all(std::string var_nm){
+  bool match=false;
+  long sz;
+  long idx;
+  long srt=-1;
+  long end=-1;
+  idx=findi(var_nm);
+  
+  if(idx >=0) erase(idx);
+  
+  sz=this->size();
 
+  for(idx=0; idx<sz;idx++)
+  {
+    if( (*this)[idx]->xpr_typ==ncap_att &&  (*this)[idx]->getVar()==var_nm)
+      if(srt==-1) srt=idx;    
+    else      
+      if(srt>=0)
+      {    
+	end=idx-1;
+        break; 
+      } 
+  }  
+
+  if(srt >=0) 
+    // call base class 
+    std::vector<NcapVar*>::erase(begin()+srt,begin()+end);
+
+
+}
 /*
 NcapVar* NcapVarVector::find(const char*nm){
   long idx;
diff --git a/src/nco++/NcapVarVector.hh b/src/nco++/NcapVarVector.hh
index f632427..f32c1a5 100644
--- a/src/nco++/NcapVarVector.hh
+++ b/src/nco++/NcapVarVector.hh
@@ -19,6 +19,7 @@ public:
   void    push_ow(NcapVar *Nvar);
   void    push(NcapVar *Nvar);
   void    erase(std::string s_fnm);
+  void    erase_all(std::string var_nm);
   void    erase(long idx); 
   void    sort();
 
diff --git a/src/nco++/VarOpNew.hh b/src/nco++/VarOpNew.hh
new file mode 100644
index 0000000..cc3f9a0
--- /dev/null
+++ b/src/nco++/VarOpNew.hh
@@ -0,0 +1,787 @@
+#ifndef INC_VAR_OP_hh_
+#define INC_VAR_OP_hh_
+
+#include <algorithm>
+#include "nco.h"
+// #include "ncoParserTokenTypes.hpp"
+#include "ncoEnumTokenTypes.hpp"
+ 
+template<class T>
+var_sct* tmp_var_var_op_equal(var_sct* var1, var_sct* var2, int op) {
+
+    bool bmss=false;
+    long idx;
+    long sz;
+    T tmss=T(0);
+    T* tp1;
+    T* tp2;
+
+    sz=var1->sz;
+    
+    tp1=(T*)(var1->val.vp);
+    tp2=(T*)(var2->val.vp);  
+
+
+    if(var1->has_mss_val) {
+      tmss=((T*)(var1->mss_val.vp))[0];
+      bmss=true;
+    }else if(var2->has_mss_val) {
+	
+      tmss=((T*)(var2->mss_val.vp))[0];
+      bmss=true;
+      // Now copy missing value to var1 as on return var2 will be freed 
+      (void)nco_mss_val_cnf(var2,var1);
+    }  
+ 
+    switch(op) {
+      
+      case PLUS_ASSIGN:   
+      case PLUS:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]+=tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]+=tp2[idx];
+            else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case MINUS_ASSIGN:
+      case MINUS:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]-=tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss &&  tp2[idx] != tmss)
+	      tp1[idx]-=tp2[idx];
+            else tp1[idx]=tmss;
+	  }
+	}  
+
+        break;
+
+      case TIMES_ASSIGN:
+      case TIMES:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]*=tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]*=tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+
+        break;
+
+      case DIVIDE_ASSIGN:
+      case DIVIDE:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx] /= tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx] /= tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+
+
+        break;
+
+      case MOD:
+	// deal with else-where - can't template this function
+
+        break;
+
+      case CARET:
+	// deal with else-where - can't template this function
+        break;
+
+	// Logical & Comparison Operators
+
+      case LAND:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] &&  tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] &&  tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case LOR:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] ||  tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] ||  tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case LTHAN:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] < tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] < tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case GTHAN:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] > tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] >  tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case GEQ:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] >= tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] >= tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case LEQ:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] <= tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] <= tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case EQ:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]= (tp1[idx]==tp2[idx]);
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] == tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+      case NEQ:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] != tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] != tp2[idx];
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        break;
+
+
+      case FLTHAN:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) 
+           if(tp1[idx] >= tp2[idx])
+             tp1[idx]=tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+            if(tp1[idx]==tmss || tp2[idx]==tmss)
+               tp1[idx]=tmss; 
+	    else if(tp1[idx] >= tp2[idx]  )
+	      tp1[idx]=tp2[idx];
+	  }
+	}  
+        break;
+
+      case FGTHAN:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) 
+           if(tp1[idx] <= tp2[idx])
+             tp1[idx]=tp2[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+            if(tp1[idx]==tmss || tp2[idx]==tmss)
+               tp1[idx]=tmss; 
+            else if(tp1[idx] <= tp2[idx] )
+	      tp1[idx]=tp2[idx];
+	  }
+	}  
+        break;
+
+
+    } // end switch
+    
+    return var1;
+  } // end var_var_equal
+
+
+template<class T>
+var_sct* tmp_var_var_op_unequal(var_sct* var1, var_sct* var2, int op) {
+
+    bool bmss=false;
+    bool bun;
+    long idx;
+    long sz;
+    T tmss=T(0);
+    T* tp1;
+    T* tp2;
+    T *tp_swp;
+           
+    tp1=(T*)(var1->val.vp);
+    tp2=(T*)(var2->val.vp);  
+
+
+    if(var1->sz >1 && var2->sz ==1 ) 
+    {      
+      bun=true;
+      sz=var1->sz;  
+    }
+    else if( var1->sz==1 && var2->sz > 1 ) 
+    {
+      bun=false;
+      sz=var2->sz;   
+    }
+    else
+      return (var_sct*)NULL;      
+
+
+
+    if(var1->has_mss_val) 
+    {
+      tmss=((T*)(var1->mss_val.vp))[0];
+      bmss=true;
+    }
+    else if(var2->has_mss_val) 
+    {
+	
+      tmss=((T*)(var2->mss_val.vp))[0];
+      bmss=true;
+      // Now copy missing value to var1 as on return var2 will be freed 
+      (void)nco_mss_val_cnf(var2,var1);
+    }  
+ 
+    // if singleton operand is missing-value 
+    // then set whole array to missing !!
+    if(bmss && bun && *tp2==tmss)
+    {
+      for(idx=0;idx<sz;idx++)  
+        tp1[idx]=tmss; 
+
+      return var1;
+    }   
+
+    if(bmss && !bun && *tp1==tmss)
+    {
+      for(idx=0;idx<sz;idx++)  
+        tp2[idx]=tmss; 
+
+      return var1;
+    }   
+
+
+    switch(op) 
+    {
+      
+      case PLUS_ASSIGN:   
+      case PLUS:
+      // swap values around  
+	if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]+=*tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]+=*tp2;
+            else tp1[idx]=tmss;
+	    
+       if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+
+       break;
+
+      case MINUS_ASSIGN:
+      case MINUS:
+          if(bun)   
+	  {
+	    if(!bmss) 
+	      for(idx=0 ; idx<sz ; idx++) tp1[idx]-=*tp2;
+	    else
+		for(idx=0 ; idx<sz ; idx++)
+		  if( tp1[idx] != tmss )
+		    tp1[idx]-=*tp2;
+		  else tp1[idx]=tmss;
+	  }
+          else
+	  {
+	    if(!bmss) 
+	      for(idx=0 ; idx<sz ; idx++) tp2[idx]=*tp1-tp2[idx];
+	    else
+		for(idx=0 ; idx<sz ; idx++)
+		  if( tp2[idx] != tmss )
+		    tp2[idx]=*tp1-tp2[idx];
+		  else tp2[idx]=tmss;
+	  }
+          break;
+
+      case TIMES_ASSIGN:
+      case TIMES:
+
+        if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]*=*tp2;
+	else
+        {
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss )
+	      tp1[idx]*=*tp2;
+	    else tp1[idx]=tmss;
+	  }
+	}  
+        if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+        break;
+
+      case DIVIDE_ASSIGN:
+      case DIVIDE:
+        if(bun) 
+        { 
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx] /= *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx] /= *tp2;
+	    else tp1[idx]=tmss;
+	  
+	}  
+        else
+        { 
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp2[idx]= *tp1 / tp2[idx];
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp2[idx] != tmss )
+	      tp2[idx]= *tp1 / tp2[idx];
+	    else tp2[idx]=tmss;
+	  
+	}  
+
+        break;
+
+      case MOD:
+	// deal with else-where - can't template this function
+
+        break;
+
+      case CARET:
+	// deal with else-where - can't template this function
+        break;
+
+	// Logical & Comparison Operators
+
+      /***************************************************************************/
+      case LAND:
+        if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+          
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] &&  *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]=tp1[idx] &&  *tp2;
+	    else tp1[idx]=tmss;
+	  
+	 
+        if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+
+        break;
+
+      /***************************************************************************/
+      case LOR:
+
+        if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+   
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] ||  *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss && tp2[idx] != tmss)
+	      tp1[idx]=tp1[idx] ||  *tp2;
+	    else tp1[idx]=tmss;
+	
+        if(!bun) 
+          { tp_swp=tp1;tp1=tp2;tp2=tp_swp;}    
+    
+        break;
+
+      /***************************************************************************/
+      case LTHAN:
+        if(bun) 
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] < *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]=tp1[idx] < *tp2;
+	    else tp1[idx]=tmss;
+	} 
+        else
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp2[idx]=*tp1 < tp2[idx];
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp2[idx] != tmss )
+	      tp2[idx]=*tp1 < tp2[idx];
+	    else tp2[idx]=tmss;
+	}  
+        break;
+
+      /***************************************************************************/
+      case GTHAN:
+        if(bun) 
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] > *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]=tp1[idx] > *tp2;
+	    else tp1[idx]=tmss;
+	  
+	}  
+        else
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp2[idx]=*tp1 > tp2[idx];
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp2[idx] != tmss )
+	      tp2[idx]=*tp1 > tp2[idx];
+	    else tp2[idx]=tmss;
+	  
+	}  
+        break;
+
+
+      /***************************************************************************/
+      case GEQ:
+        if(bun) 
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] >= *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]=tp1[idx] >= *tp2;
+	    else tp1[idx]=tmss;
+	  
+	}  
+        else
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp2[idx]=*tp1 >= tp2[idx];
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp2[idx] != tmss )
+	      tp2[idx]=*tp1 >= tp2[idx];
+	    else tp2[idx]=tmss;
+	  
+	}  
+        break;
+
+      /***************************************************************************/
+      case LEQ:
+        if(bun) 
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] <= *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]=tp1[idx] <= *tp2;
+	    else tp1[idx]=tmss;
+	  
+	}  
+        else
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp2[idx]=*tp1 <= tp2[idx];
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp2[idx] != tmss )
+	      tp2[idx]= *tp1 <= tp2[idx];
+	    else tp2[idx]=tmss;
+	  
+	}  
+        break;
+
+      /***************************************************************************/
+      case EQ:
+        if(bun) 
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] == *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]=tp1[idx] == *tp2;
+	    else tp1[idx]=tmss;
+	  
+	}  
+        else
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp2[idx]=*tp1 == tp2[idx];
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp2[idx] != tmss )
+	      tp2[idx]=*tp1 == tp2[idx];
+	    else tp2[idx]=tmss;
+	  
+	}  
+        break;
+
+      /***************************************************************************/ 
+      case NEQ:
+        if(bun) 
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=tp1[idx] != *tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss )
+	      tp1[idx]=tp1[idx] != *tp2;
+	    else tp1[idx]=tmss;
+	}  
+        else
+        {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) tp2[idx]=*tp1 != tp2[idx];
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp2[idx] != tmss )
+	      tp2[idx]=*tp1 != tp2[idx];
+	    else tp2[idx]=tmss;
+	}  
+        break;
+
+
+      /***************************************************************************/ 
+      case FLTHAN:
+        if(bun) 
+        { 
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) 
+           if(tp1[idx] >= *tp2) tp1[idx]=*tp2;
+	else
+	{  
+          for(idx=0 ; idx<sz ; idx++)
+            if(tp1[idx]==tmss )
+               tp1[idx]=tmss; 
+	    else if(tp1[idx] >= *tp2  )
+	      tp1[idx]=*tp2;
+	}  
+	}
+        else
+        { 
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) 
+           if(*tp1 >= tp2[idx]) tp2[idx]=*tp1;
+	else
+	{  
+	  for(idx=0 ; idx<sz ; idx++)
+            if(tp2[idx]==tmss )
+               tp2[idx]=tmss; 
+	    else if(*tp1 >= tp2[idx]  )
+	      tp2[idx]=*tp1;
+	}  
+	}
+        break;
+
+      /***************************************************************************/ 
+      case FGTHAN:
+      if(bun)
+      {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) 
+           if(tp1[idx] <= *tp2)
+             tp1[idx]=*tp2;
+	else
+	  for(idx=0 ; idx<sz ; idx++)
+            if(tp1[idx]==tmss )
+               tp1[idx]=tmss; 
+            else if(tp1[idx] <= *tp2 )
+	      tp1[idx]=*tp2;
+      }
+      else
+      {
+	if(!bmss) 
+	  for(idx=0 ; idx<sz ; idx++) 
+	    if(tp2[idx]>*tp1)
+               tp2[idx]=*tp1;
+	else
+	{
+	  for(idx=0 ; idx<sz ; idx++)
+            if(tp2[idx]==tmss )
+               tp2[idx]=tmss; 
+            else if(tp2[idx]>*tp1 )
+	      tp2[idx]=*tp1;
+        }
+      }
+      break;
+
+
+    } // end switch
+    
+    return var1;
+  } // end var_var_op_unequal
+
+
+template<class T>
+var_sct* tmp_var_op(var_sct* var1, int op) {
+    bool bmss=false;
+    long idx;
+    long sz;
+    T tmss=T(0);
+    T* tp1;
+
+    sz=var1->sz;
+    
+    tp1=(T*)(var1->val.vp);
+
+    if(var1->has_mss_val) {
+      bmss=true;
+      tmss=((T*)(var1->mss_val.vp))[0];
+    }  
+
+    switch(op) {
+
+
+      case PLUS:
+      // Do nothing
+        break;
+      
+      case MINUS:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]*=-1;
+	}else{
+	  for(idx=0 ; idx<sz ; idx++)
+	    if( tp1[idx] != tmss ) tp1[idx]*=-1;
+	    
+	}
+        break;
+       
+    case LNOT: 	
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]=!tp1[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss ) tp1[idx]=!tp1[idx];
+	  }  
+	}
+        break;
+
+    case POST_INC:
+    case INC:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) ++tp1[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss ) ++tp1[idx];
+	  }  
+	}
+        break;
+
+    case POST_DEC:
+    case DEC:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) --tp1[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss ) --tp1[idx];
+	  }  
+	}
+        break;
+
+
+    case MISS2ZERO:
+	if(bmss) 
+	  for(idx=0 ; idx<sz ; idx++) 
+            if( tp1[idx]==tmss) tp1[idx]=0;
+
+        break;
+
+    case VSQR2:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++) tp1[idx]*=tp1[idx];
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss ) tp1[idx]*=tp1[idx];
+	  }  
+	}
+        break;
+
+    case VSORT: 
+         std::sort(tp1,tp1+sz );  
+         break; 
+
+	 // reverse sort 
+    case VRSORT: 
+         std::sort(tp1,tp1+sz,std::greater<T>() );  
+         break; 
+
+    // return absolute value 
+    case VABS:
+	if(!bmss) {
+	  for(idx=0 ; idx<sz ; idx++)
+            if(tp1[idx] < 0) tp1[idx]*=-1;  
+	}else{
+	  for(idx=0 ; idx<sz ; idx++){
+	    if( tp1[idx] != tmss && tp1[idx] < 0 ) tp1[idx]*=-1;
+	  }  
+	}
+        break;
+
+
+    default: break;	
+
+    } // end switch	
+
+    return var1;
+  } // end var_op
+
+
+
+
+
+#endif
diff --git a/src/nco++/fmc_all_cls.cc b/src/nco++/fmc_all_cls.cc
index 47dea1b..12e0153 100644
--- a/src/nco++/fmc_all_cls.cc
+++ b/src/nco++/fmc_all_cls.cc
@@ -376,9 +376,10 @@
        err_prn(fnc_nm,styp+" \""+sfnm+"\" has been called with no arguments"); 
      
      // deal with is_miss in a seperate function     
-     if(fdx==NUM_MISS)
+     if(fdx==NUM_MISS||fdx==HAS_MISS)
        return is_fnd(is_mtd, vtr_args,fmc_obj,walker);           
-   
+     if(fdx==GET_MISS)       
+       return get_fnd(is_mtd, vtr_args,fmc_obj,walker);             
   
 
     if( fdx==SET_MISS || fdx==CH_MISS) {
@@ -391,53 +392,26 @@
     } 
      
             
-    lcl_typ=expr_typ(vtr_args[0]);          
+    lcl_typ=expr_typ(vtr_args[0]);         
 
     /* allow att identifier for RAM_DELETE */
-    if(lcl_typ !=VVAR && !(fdx == RAM_DELETE && lcl_typ==VATT)) {
-      serr="The first operand of the " + sfnm+ " must be a variable identifier only.";
+    if(lcl_typ != VVAR &&  lcl_typ != VPOINTER &&  !(fdx == RAM_DELETE && lcl_typ==VATT)) {
+      serr="The first operand of the " + sfnm+ " must be a variable identifier or a variable pointer only.";
       err_prn(fnc_nm,serr);
     }
 
-    va_nm=vtr_args[0]->getText();
+    if(lcl_typ==VVAR || lcl_typ==VATT )       
+       va_nm=vtr_args[0]->getText();
+    else if(lcl_typ==VPOINTER)
+      { // get contents of att for var-pointer  
+      std::string att_nm=vtr_args[0]->getFirstChild()->getText();
+      va_nm=ncap_att2var(prs_arg,att_nm);
+    }
+
     Nvar=prs_arg->var_vtr.find(va_nm);
 
 
     /* Deal with GET_MISS as its different from other methods */
-    if(fdx==GET_MISS){
-      var_sct *var_tmp=NULL_CEWI;
-      var_sct *var_ret=NULL_CEWI;
-   
-      var_tmp=prs_arg->ncap_var_init(va_nm,false);
-
-      // Initial scan
-      if(prs_arg->ntl_scn) 
-        if(var_tmp)  
-	  var_ret= ncap_sclr_var_mk(SCS
-("~utility_function"),var_tmp->type,false);
-        else
-	  var_ret=ncap_var_udf("~utility_function");
-
-      // Final scan
-      if(!prs_arg->ntl_scn){
-        if(var_tmp){
-           // nb ncap_sclr_var_mk() calls nco_mss_val_mk() and fills var_ret with the default fill value
-           // for that type.  So if the var has no missing value then this is the value returned 
-           // Default fill  values are defined in  netcdf.h . 
-           var_ret=ncap_sclr_var_mk(SCS("~utility_function"),var_tmp->type,true);
-           if(var_tmp->has_mss_val)
-             (void)memcpy(var_ret->val.vp, var_tmp->mss_val.vp,nco_typ_lng(var_tmp->type)); 
-        }else{          
-        /* Cant find variable blow out */ 
-          serr=sfnm+ " Unable to locate missing value for "+ va_nm;
-          err_prn(fnc_nm,serr);
-        } 
-      } // end else
- 
-      if(var_tmp) var_tmp=nco_var_free(var_tmp);
-
-      return var_ret; 	
-     } // end GET_MISS 
 
 
     if(prs_arg->ntl_scn) {
@@ -544,8 +518,8 @@
                  wrn_prn(fnc_nm,sfnm+" cannot remove disk variable:\""+va_nm+ "\". Delete can only remove RAM variables.");
                  rval=0;  
 	        }else{ 
-                 prs_arg->var_vtr.erase(va_nm); 
-                 prs_arg->int_vtr.erase(va_nm); 
+                 prs_arg->var_vtr.erase_all(va_nm); 
+                 prs_arg->int_vtr.erase_all(va_nm); 
                  rval=1;
                }
              } 
@@ -596,8 +570,12 @@ var_sct * utl_cls::is_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &
        return ncap_sclr_var_mk(SCS("~utility_function"),styp,false);         
     }  
 
-    // from now on dealing with a final scan !!
-    if(var->has_mss_val){
+    if(!var->has_mss_val)      
+      icnt=0; 
+    else if( fdx==HAS_MISS)    
+      icnt=1; 
+    else if( fdx==NUM_MISS)   
+    {
       char *cp_out=(char*)var->val.vp; 
       long idx;
       size_t slb_sz;  
@@ -605,15 +583,13 @@ var_sct * utl_cls::is_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &
       icnt=0;       
 
       slb_sz=nco_typ_lng(var->type); 
-      for(idx=0 ;idx<var->sz;idx++){
+      for(idx=0 ;idx<var->sz;idx++)
+      {
         if( !memcmp(cp_out,var->mss_val.vp,slb_sz))
 	  icnt++;
         cp_out+=(ptrdiff_t)slb_sz;
       }   
-    }else{
-       icnt=0; 
-    }     
-
+    }
     nco_var_free(var); 
 
     if(styp==NC_UINT64) 
@@ -621,7 +597,89 @@ var_sct * utl_cls::is_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &
     else 
       return ncap_sclr_var_mk(SCS("~utility_function"),(nco_int)icnt);
 }  
-    
+
+ 
+// custom function for GET_MISS
+var_sct * utl_cls::get_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker){
+  const std::string fnc_nm("srt_cls::imap_fnd");
+    int nbr_args;
+    int fdx=fmc_obj.fdx();
+    var_sct *var=NULL_CEWI;
+    var_sct *var_ret=NULL_CEWI;
+    std::string sfnm =fmc_obj.fnm(); //method name
+    vtl_typ lcl_typ;
+    std::string va_nm;
+    std::string susg;
+    std::string serr;
+    prs_cls *prs_arg=walker.prs_arg;    
+
+
+    nbr_args=args_vtr.size(); 
+
+    if(nbr_args ==0) 
+       err_prn(fnc_nm," \""+sfnm+"\" has been called with no arguments"); 
+
+
+      
+    lcl_typ=expr_typ(args_vtr[0]);         
+
+    if(lcl_typ != VVAR &&  lcl_typ != VPOINTER ) 
+    {
+      serr="The first operand of the " + sfnm+ " must be a variable identifier or a variable pointer only.";
+      err_prn(fnc_nm,serr);
+    }
+
+    if(lcl_typ==VVAR )       
+       va_nm=args_vtr[0]->getText();
+    else if(lcl_typ==VPOINTER)
+    { 
+      // get contents of att for var-pointer  
+      std::string att_nm=args_vtr[0]->getFirstChild()->getText();
+      va_nm=ncap_att2var(prs_arg,att_nm);
+    }
+
+
+    if(va_nm.size())
+       var=prs_arg->ncap_var_init(va_nm,false);
+
+    // Initial scan
+    if(prs_arg->ntl_scn) 
+    {
+        if(var)  
+	  var_ret= ncap_sclr_var_mk(SCS ("~utility_function"),var->type,false);
+        else
+	  var_ret=ncap_var_udf("~utility_function");
+
+        nco_var_free(var);  
+        return var_ret;      
+    }     
+
+    // Final scan
+    if(var)
+    {
+        // nb ncap_sclr_var_mk() calls nco_mss_val_mk() and fills var_ret with the default fill value
+	// for that type.  So if the var has no missing value then this is the value returned 
+	// Default fill  values are defined in  netcdf.h . 
+	var_ret=ncap_sclr_var_mk(SCS("~utility_function"),var->type,true);
+        if(var->has_mss_val)
+	  (void)memcpy(var_ret->val.vp, var->mss_val.vp,nco_typ_lng(var->type)); 
+    }
+    else
+    {          
+        /* Cant find variable blow out */ 
+        serr=sfnm+ " Unable to locate missing value for "+ va_nm;
+        err_prn(fnc_nm,serr);
+    } 
+
+ 
+    if(var) 
+      var=nco_var_free(var);
+
+    return var_ret; 	
+
+} 
+
+
 
 
 
@@ -706,7 +764,7 @@ var_sct * utl_cls::is_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &
     if(prs_arg->ntl_scn){
 
       // Evaluate argument on first scan for side-effects eg var1++ or var1+=10 etc 
-      if( lcl_typ!=VVAR && lcl_typ !=VATT){
+      if( lcl_typ!=VVAR && lcl_typ !=VATT && lcl_typ !=VPOINTER){
       var1=walker.out(tr) ;
       var1=nco_var_free(var1);
       }
@@ -714,13 +772,23 @@ var_sct * utl_cls::is_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &
     }
        
     // from here on dealing with final scan
-    va_nm=tr->getText();
+    if(lcl_typ==VVAR || lcl_typ==VATT )       
+       va_nm=vtr_args[0]->getText();
+    else if(lcl_typ==VPOINTER)
+      { // get contents of att for var-pointer  
+      std::string att_nm=vtr_args[0]->getFirstChild()->getText();
+      va_nm=ncap_att2var(prs_arg,att_nm);
+    }
+
+
 
 
     // deal with PEXISTS here 
     if(fdx==PEXISTS){
       int iret=0;
       switch(lcl_typ){
+
+      case VPOINTER: 
         case VVAR: 
           if(prs_arg->ncap_var_init_chk(va_nm)) 
             iret=1;
@@ -743,7 +811,7 @@ var_sct * utl_cls::is_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &
     }
 
      
-      if(lcl_typ==VVAR)
+      if(lcl_typ==VVAR || lcl_typ==VPOINTER)
 	var1=prs_arg->ncap_var_init(va_nm,false); 
       else 
         var1=walker.out(tr);
@@ -2333,6 +2401,212 @@ var_sct * srt_cls::mst_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls
 
   } 
 
+// Bounds function - calculates bounds of a 1D coordinate variable
+  bnds_cls::bnds_cls(bool flg_dbg){
+    //Populate only on  constructor call
+    if(fmc_vtr.empty()){
+          fmc_vtr.push_back( fmc_cls("make_bounds",this,PBOUNDS)); 
+
+    }		      
+  } 
+  var_sct * bnds_cls::fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker){
+  const std::string fnc_nm("arr_cls::fnd");
+  int fdx;
+  int nbr_args;
+  int idx;
+  int nbr_dim;
+  nc_type itype;
+  dmn_sct **dim;
+  var_sct *var1=NULL_CEWI;
+  var_sct *var_txt=NULL_CEWI;
+  var_sct *var_ret;
+           
+  std::string susg;
+  std::string sfnm=fmc_obj.fnm();
+
+  RefAST tr;
+  std::vector<RefAST> args_vtr; 
+  std::vector<std::string> cst_vtr;              
+
+  // de-reference 
+  prs_cls *prs_arg=walker.prs_arg;            
+  vtl_typ lcl_typ;
+
+  fdx=fmc_obj.fdx();
+ 
+
+  if(expr)
+      args_vtr.push_back(expr);
+
+   if(tr=fargs->getFirstChild()) 
+   {
+      do  
+	args_vtr.push_back(tr);
+      while(tr=tr->getNextSibling());    
+   } 
+      
+  nbr_args=args_vtr.size();  
+
+  susg="usage: var_out="+sfnm+"(coordinate_var,$dim, string_nm ?"; 
+
+  
+  if(nbr_args<2)
+      err_prn(sfnm,"Function has been called with less than two arguments\n"+susg); 
+
+
+
+  if(nbr_args >4 &&!prs_arg->ntl_scn) 
+      wrn_prn(sfnm,"Function been called with more than three arguments"); 
+
+
+   
+  
+  var1=walker.out(args_vtr[0]);  
+  if(nbr_args >=3)
+    var_txt=walker.out(args_vtr[2]); 
+
+
+  /* second argument must be a single dimension */
+  if(args_vtr[1]->getType() != DIM_ID ) 
+     err_prn(sfnm,"Second argument must be a dimension\n"+susg); 
+
+  // cast a var from using the dim arg
+  if(var1->undefined==False &&  args_vtr[1]->getType() == DIM_ID   ) 
+  {
+    for(idx=0;idx<var1->nbr_dim;idx++)    
+      cst_vtr.push_back( var1->dim[idx]->nm);     
+
+   cst_vtr.push_back(args_vtr[1]->getText());
+     
+   var_ret=ncap_cst_mk(cst_vtr,prs_arg);
+
+   // use coordinate var name so we get attribute propagation
+   nco_free(var_ret->nm);
+   var_ret->nm=strdup(var1->nm);      
+
+   // convert to type of first arg
+   var_ret=nco_var_cnf_typ(var1->type,var_ret);  
+
+  }
+
+
+  if(prs_arg->ntl_scn)
+  {
+    if(var_txt) 
+      nco_var_free(var_txt);    
+
+    if(var1->undefined) 
+      return var1; 
+    else 
+    {     
+      var1=nco_var_free(var1);
+      return var_ret;    
+    }
+  }
+
+  if(var_txt)
+  {
+    std::string att_nm;
+    NcapVar *Nvar;
+
+    if(var_txt->type !=NC_CHAR && var_txt->type !=NC_STRING)     
+      wrn_prn(fnc_nm,"Third argument is the bounds name and must be a  text type");  
+    else
+    {
+      att_nm=var_ret->nm;att_nm+="@bounds";
+      Nvar=new NcapVar(var_txt,att_nm);
+      prs_arg->var_vtr.push_ow(Nvar);       
+    }       
+
+  }
+
+
+  // if type less than float then promote to double do calculation the convert back to original type
+  // else if float then leave as is 
+  itype=var1->type;   
+
+  if( itype !=NC_FLOAT && itype !=NC_DOUBLE) 
+  {  
+    nco_var_cnf_typ(NC_DOUBLE, var1);
+    nco_var_cnf_typ(NC_DOUBLE, var_ret);
+  }  
+
+  
+  (void)cast_void_nctype(var1->type,&var1->val);
+  (void)cast_void_nctype(var_ret->type,&var_ret->val);
+
+
+   // allocate space for results 
+  void *vp=nco_malloc( var_ret->sz * nco_typ_lng(var_ret->type)); 
+  var_ret->val.vp=vp;
+
+
+ 
+  // do the heavy lifting 
+  if(var1->type==NC_DOUBLE)
+  {  
+    long sz; 
+    double *idp;
+    double *rdp;
+    double dprev;
+
+
+    // reduce indrection 
+    idp=var1->val.dp;
+    rdp=var_ret->val.dp;
+    
+    sz=var1->sz;
+
+    dprev=2* idp[0]-idp[1];     
+    for(idx=0;idx<sz;idx++)  
+    {
+      rdp[2*idx]= 0.5*(dprev+idp[idx]);                                                                                   
+      if(idx>0)  
+	rdp[2*idx-1] = rdp[2*idx];
+
+      dprev=idp[idx]; 
+    }
+    // calculate final value 
+    rdp[2*sz-1]= 2*dprev-rdp[2*sz-2]; 
+
+
+  }
+  else if(var1->type==NC_FLOAT)
+  {  
+    long sz; 
+    float *ifp;
+    float *rfp;
+    float fprev;
+
+    ifp=var1->val.fp;
+    rfp=var_ret->val.fp;
+    
+    sz=var1->sz;
+
+    fprev=2* ifp[0]-ifp[1];     
+    for(idx=0;idx<sz;idx++)  
+    {
+      rfp[2*idx]= 0.5*(fprev+ifp[idx]);                                                                                   
+      if(idx>0)  
+	rfp[2*idx-1] = rfp[2*idx];
+
+      fprev=ifp[idx]; 
+    }
+    // calculate final value 
+    rfp[2*sz-1]= 2*fprev-rfp[2*sz-2]; 
+
+  }
+
+  (void)cast_nctype_void(var1->type,&var1->val);
+  (void)cast_nctype_void(var_ret->type,&var_ret->val);
+  
+  // convert results back to orignal type
+  nco_var_cnf_typ(itype,var_ret);  
+  nco_var_free(var1);
+
+  return var_ret;
+
+  }
 
 
 //Bilinear  Interpolation Functions /****************************************/
@@ -3331,6 +3605,10 @@ double bil_cls::clc_lin_ipl(double x1,double x2, double x, double Q0,double Q1){
     if(fmc_vtr.empty()){
       fmc_vtr.push_back( fmc_cls("join",this,(int)PJOIN));
       fmc_vtr.push_back( fmc_cls("push",this,(int)PPUSH));
+      fmc_vtr.push_back( fmc_cls("get_vars_in",this,(int)PGET_VARS_IN));
+      fmc_vtr.push_back( fmc_cls("get_vars_out",this,(int)PGET_VARS_OUT));
+      fmc_vtr.push_back( fmc_cls("atoi",this,(int)PATOI));
+      fmc_vtr.push_back( fmc_cls("atol",this,(int)PATOL));
     }
   }
 
@@ -3338,27 +3616,19 @@ double bil_cls::clc_lin_ipl(double x1,double x2, double x, double Q0,double Q1){
   var_sct *vlist_cls::fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker){
   const std::string fnc_nm("vlist_cls::fnd");
   bool bret;
-  int idx;
   int fdx;
   int nbr_args;
-  int nbr_dim;         
-  char *cstr;
+
   std::string susg;
   std::string sfnm=fmc_obj.fnm();
   std::string att_nm;
 
-  var_sct *var=NULL_CEWI;
-  var_sct *var_att=NULL_CEWI;
-  var_sct *var_add=NULL_CEWI;
-
-
-  RefAST aRef;
   RefAST tr;
   std::vector<RefAST> vtr_args; 
   prs_cls *prs_arg=walker.prs_arg;
 
-  NcapVar *Nvar=NULL;
-          
+  bool is_mtd;  
+        
   fdx=fmc_obj.fdx();
 
 
@@ -3367,12 +3637,56 @@ double bil_cls::clc_lin_ipl(double x1,double x2, double x, double Q0,double Q1){
     vtr_args.push_back(expr);
 
   if(tr=fargs->getFirstChild())
-  {
     do  
       vtr_args.push_back(tr);
     while(tr=tr->getNextSibling());    
-  } 
-            
+  
+  
+  is_mtd=(expr ? true: false);
+
+  switch(fdx) 
+  {
+     case PPUSH:  
+       return push_fnd(is_mtd, vtr_args,fmc_obj, walker);   
+       break; 
+
+     case PGET_VARS_IN:  
+     case PGET_VARS_OUT:  
+       return get_fnd(is_mtd, vtr_args,fmc_obj, walker);    
+       break;
+  
+     case PATOI: 
+       return atoi_fnd(is_mtd, vtr_args,fmc_obj, walker);     
+       break;
+  }
+
+  }
+
+
+var_sct *vlist_cls::push_fnd(bool &is_mtd, std::vector<RefAST> &vtr_args, fmc_cls &fmc_obj, ncoTree &walker)
+  {
+  const std::string fnc_nm("push_fnd::fnd");
+  bool bret;
+  int idx;
+  int fdx;
+  int nbr_args;
+  std::string susg;
+  std::string sfnm=fmc_obj.fnm();
+  std::string att_nm;
+
+  var_sct *var=NULL_CEWI;
+  var_sct *var_att=NULL_CEWI;
+  var_sct *var_add=NULL_CEWI;
+
+
+  RefAST aRef;
+  RefAST tr;
+  prs_cls *prs_arg=walker.prs_arg;
+
+  NcapVar *Nvar=NULL;
+          
+  fdx=fmc_obj.fdx();
+
   nbr_args=vtr_args.size();  
 
   susg="usage: att_out="+sfnm+"(att_id, att_nm|var_nm|string)";
@@ -3380,68 +3694,84 @@ double bil_cls::clc_lin_ipl(double x1,double x2, double x, double Q0,double Q1){
   if(nbr_args!=2)
     err_prn(sfnm, " Function has been called with wrong number of arguments arguments\n"+susg); 
 
-  
+  // get var to push -maybe a call by ref
+  if(vtr_args[1]->getType() == CALL_REF )     
+  {
+    nco_string val_string;
+    std::string add_nm=vtr_args[1]->getFirstChild()->getText();      
+
+    var_add=ncap_sclr_var_mk(SCS("~zz at string"), NC_STRING,false ); 
+
+    // malloc space directly if final scan
+    if(!prs_arg->ntl_scn)
+    {   
+       var_add->val.vp=(void*)nco_malloc(nco_typ_lng(NC_STRING));
+       cast_void_nctype(NC_STRING, &var_add->val);        
+       var_add->val.sngp[0]=strdup(add_nm.c_str());   
+       cast_nctype_void(NC_STRING, &var_add->val);        
+    }
+           
 
+  }
+  else 
+   var_add=walker.out(vtr_args[1]);
+             
 
 
   // deal with call by ref 
   if(vtr_args[0]->getType() == CALL_REF )     
   {   
-    bret=false; 
-  }
-  else
-  {
-    var_att=walker.out(vtr_args[0]);      
-    bret=true;
-  }
-
-  var_add=walker.out(vtr_args[1]);
-
-  // inital scan just return udf
-  if(prs_arg->ntl_scn)
-  {
-    if(var_att)
-       nco_var_free(var_att);
-     
-    nco_var_free(var_add);        
-
-    if( bret) 
-      var=ncap_var_udf("~zz at join_methods");  
-    else
-      var=ncap_sclr_var_mk(std::string(var_add->nm),(nc_type)NC_INT,false);  
 
-    return var;
-  }
-
-  // deal with call by ref final scan
-  if( !bret)
-  {     
+    bret=false;   
+    // final scan starts here   
      att_nm=vtr_args[0]->getFirstChild()->getText();  
-     
 
-     Nvar=prs_arg->var_vtr.find(att_nm);
+    // do nothing on initial scan with call-by ref 
+    if(prs_arg->ntl_scn)
+    { 
+      nco_var_free(var_add);  
+      var=ncap_sclr_var_mk(att_nm,(nc_type)NC_INT,false);  
+      return var;
+    }
 
+    Nvar=prs_arg->var_vtr.find(att_nm);
 
-     if(Nvar !=NULL)
-         var_att=nco_var_dpl(Nvar->var);
-     else    
-        var_att=ncap_att_init(att_nm,prs_arg);
+    if(Nvar !=NULL)
+      var_att=nco_var_dpl(Nvar->var);
+    else    
+      var_att=ncap_att_init(att_nm,prs_arg);
   
-     // if new var then write var - end of story   
-     if(!var_att) 
-     {   
-       nco_free(var_add->nm);
-       var_add->nm=strdup(att_nm.c_str());      
-       Nvar=new NcapVar(var_add,att_nm);
+    // if new var then write var - end of story   
+    if(!var_att) 
+    {   
+	nco_free(var_add->nm);
+	var_add->nm=strdup(att_nm.c_str());      
+	Nvar=new NcapVar(var_add,att_nm);
 
-       var=ncap_sclr_var_mk(att_nm,(nco_int)var_add->sz);
-       prs_arg->var_vtr.push_ow(Nvar);       
+	var=ncap_sclr_var_mk(att_nm,(nco_int)var_add->sz);
+	prs_arg->var_vtr.push_ow(Nvar);       
 
-       return var;
+	return var;
+    } 
 
-     } 
+  }
+  // deal with regular argument
+  else
+  {
+    bret=true;
+    var_att=walker.out(vtr_args[0]);      
+  
+    if(prs_arg->ntl_scn) 
+    {   
+     nco_var_free(var_add);
+     nco_var_free(var_att);
+     var=ncap_var_udf("~zz at join_methods");  
+     return var; 
+    
+    } 
+  }
 
-  } 
+  
 
   if(!var_att )
      err_prn(sfnm, " first argument has evaluated to null\n"+susg); 
@@ -3520,12 +3850,274 @@ double bil_cls::clc_lin_ipl(double x1,double x2, double x, double Q0,double Q1){
   }
 
 
+  }
+
+  var_sct *vlist_cls::get_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker)
+  {
+  const std::string fnc_nm("push_fnd::fnd");
+  bool bret;
+  int idx;
+  int fdx;
+  int nbr_args;
+  std::string susg;
+  std::string sfnm=fmc_obj.fnm();
+  std::string att_nm;
+
+  var_sct *var=NULL_CEWI;
+  var_sct *var_att=NULL_CEWI;
+  var_sct *var_add=NULL_CEWI;
+  var_sct *var_regexp=NULL_CEWI;
+  
+  nc_type vtype;
+  prs_cls *prs_arg=walker.prs_arg;
+
+  fdx=fmc_obj.fdx();
+
+  nbr_args=args_vtr.size();  
+
+  susg="usage: att_out="+sfnm+"( (regexp|var_nm)? )";
+
+  if(nbr_args<0)
+    err_prn(sfnm, " Function has been called with wrong number of arguments arguments\n"+susg); 
+
+
+  if(nbr_args)
+     var_regexp=walker.out(args_vtr[0]);
+  
+   
+  if(prs_arg->ntl_scn)  
+  { 
+    if(var_regexp)
+      nco_var_free(var_regexp); 
+      
+    var=ncap_var_udf("~zz at join_methods");  
+    return var;
+  }
+    
 
+  if(var_regexp)
+  {
+    vtype=var_regexp->type;
+    if(vtype !=NC_STRING && vtype != NC_CHAR) 
+       err_prn(sfnm,"First argument must be a text type\n" );
+    else
+      cast_void_nctype(vtype,&var_regexp->val);
   }
+  // no regexp or var list
+  else
+    vtype=NC_NAT;
+
+  
+  // local scope
+  {   
+    int idx;
+    int xtr_nbr;
+    int nbr_var_fl;
+    int fl_id;
+    int rcd;
+    nm_id_sct *xtr_lst; 
+    nco_string *val_str;        
+    char **lst_cp;
+
+    xtr_nbr=0;
+    nbr_var_fl=0;
+    fl_id=0;   
+ 
+    if(fdx==PGET_VARS_IN)
+      fl_id=prs_arg->in_id; 
+    else if(fdx==PGET_VARS_OUT)
+      fl_id=prs_arg->out_id; 
 
+    rcd=nco_inq(fl_id,(int *)NULL,&nbr_var_fl,(int *)NULL,(int*)NULL);
 
+    if(vtype==NC_STRING)
+    {  
+       xtr_nbr=var_regexp->sz;
+       xtr_lst=nco_var_lst_mk(fl_id, nbr_var_fl, var_regexp->val.sngp  , False, False, &xtr_nbr);    
+    }
 
-  var_sct *vlist_cls::fnd_join(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker){
+    if(vtype==NC_CHAR)
+    {
+      char *lcp;   
+      char buffer[1200];
+ 
+      strncpy(buffer, var_regexp->val.cp, var_regexp->sz);   
+      buffer[var_regexp->sz]='\0';
+      lcp=&buffer[0];
+      xtr_nbr=1;
+      xtr_lst=nco_var_lst_mk(fl_id, nbr_var_fl, &lcp  , False, False,&xtr_nbr);       
+    }
+   
+    // extract all vars   
+    if(vtype==NC_NAT) 
+    {
+      xtr_nbr=0; 
+      xtr_lst=nco_var_lst_mk(fl_id, nbr_var_fl, (char**)NULL  , False, False, &xtr_nbr);    
+    }
+
+    var=ncap_sclr_var_mk(SCS("~zz at string"), NC_STRING,false );  
+
+
+
+    if(nco_dbg_lvl_get() >= nco_dbg_scl)     
+          wrn_prn(sfnm,"nbr_var_fl="+nbr2sng(nbr_var_fl)+" xtr_nbr="+nbr2sng(xtr_nbr));
+
+    if(xtr_nbr==0) 
+    {   
+      wrn_prn(sfnm,"this function has returned an empty variable list");
+      var->sz=0;  
+    }
+    else
+    {   
+      val_str=(nco_string*)nco_malloc( xtr_nbr* nco_typ_lng(NC_STRING));
+      var->sz=xtr_nbr;
+    
+      for(idx=0; idx<xtr_nbr;idx++)
+        val_str[idx]=strdup(xtr_lst[idx].nm); 
+      
+      cast_void_nctype(NC_STRING, &var->val);        
+      var->val.sngp=val_str;
+      cast_nctype_void(NC_STRING, &var->val);        
+   
+
+    }
+
+    xtr_lst=nco_nm_id_lst_free(xtr_lst,xtr_nbr);
+
+  }
+  
+  if(var_regexp)
+  {
+    cast_nctype_void(vtype,&var_regexp->val);
+    nco_var_free(var_regexp);
+  }
+
+
+
+  return var;
+
+  }
+
+  var_sct *vlist_cls::atoi_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker)
+  {
+  const std::string fnc_nm("push_fnd::fnd");
+  bool bret;
+  int idx;
+  int fdx;
+  int ierr=0;
+  int nbr_args;
+  char buffer[100];
+  std::string susg;
+  std::string sfnm=fmc_obj.fnm();
+  std::string att_nm;
+   
+  nc_type vtype;
+  var_sct *var=NULL_CEWI;
+  var_sct *var_in=NULL_CEWI;
+  var_sct *var_err=NULL_CEWI;
+
+  prs_cls *prs_arg=walker.prs_arg;
+
+  fdx=fmc_obj.fdx();
+
+  nbr_args=args_vtr.size();  
+
+  susg="usage: att_out="+sfnm+"( nc_char|nc_string  )";
+
+  if(nbr_args<1)
+    err_prn(sfnm, " Function has been called with wrong number of arguments arguments\n"+susg); 
+
+  var_in=walker.out(args_vtr[0]);
+  
+  if(var_in->type != NC_CHAR && var_in->type != NC_STRING)
+        err_prn(sfnm, " Function must be called with a text type argument"+susg); 
+
+  // deal with initial scan      
+  switch(fdx)
+  {
+     case PATOI: 
+       vtype=NC_INT;     
+       break; 
+
+     case PATOL: 
+       vtype=NC_INT64; 
+  }
+
+
+  if(prs_arg->ntl_scn)
+  {
+    var=ncap_sclr_var_mk( SCS("~zz at value_list"), vtype,false); 
+    nco_var_free(var_in);
+    return var; 
+
+  }
+   
+  cast_void_nctype(var_in->type,&var_in->val);
+  if(var_in->type==NC_CHAR)
+  {
+    strncpy(buffer, var_in->val.cp, var_in->sz); 
+    buffer[var_in->sz]='\0';
+  }
+  else if(var_in->type==NC_STRING)
+    strcpy(buffer, var_in->val.sngp[0]); 
+ 
+  cast_nctype_void(var_in->type,&var_in->val);
+  nco_var_free(var_in);
+  
+  
+
+  switch(fdx)
+  {
+     case PATOI: 
+       {          
+         char *pend='\0';
+         nco_int iout;
+         iout=0; 
+
+	 // allows whites space prefix & suffix                                                                                                                                
+         iout=std::strtol(buffer,&pend,10);
+
+         if( pend !=buffer  && (*pend=='\0'|| *pend==' ') )
+            ierr=0;
+         else
+            ierr=errno;
+
+         var=ncap_sclr_var_mk( SCS("~zz at value_list"), vtype,iout);  
+
+       }   
+       break; 
+
+     case PATOL: 
+       {          
+         char *pend='\0';
+         nco_int64 lout;
+         lout=0; 
+
+	 // allows whites space prefix & suffix                                                                                                                                
+         lout=std::strtoll(buffer,&pend,10);
+
+         if( pend !=buffer  && (*pend=='\0'|| *pend==' ') )
+            ierr=0;
+         else
+	   ierr=errno;
+
+         var=ncap_sclr_var_mk( SCS("~zz at value_list"), vtype,lout);  
+
+       }   
+       break; 
+  }
+  
+  var_err=ncap_sclr_var_mk(std::string("~zz at atoi_methods_err"), ierr);
+  prs_arg->ncap_var_write(var_err,true);
+                 
+
+
+
+  return var;
+
+  }
+
+  var_sct *vlist_cls::join_fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker){
   const std::string fnc_nm("vlist_cls::fnd");
   int idx;
   int fdx;
@@ -3536,10 +4128,11 @@ double bil_cls::clc_lin_ipl(double x1,double x2, double x, double Q0,double Q1){
   std::string sfnm=fmc_obj.fnm();
   var_sct *var;
   var_sct *var_att;
+  var_sct *var_add;
 
-
-  RefAST aRef;
   RefAST tr;
+  RefAST aRef;
+
   std::vector<RefAST> vtr_args; 
   prs_cls *prs_arg=walker.prs_arg;
   std::vector<std::string> str_vtr;
@@ -3790,7 +4383,208 @@ double bil_cls::clc_lin_ipl(double x1,double x2, double x, double Q0,double Q1){
 
 
 
+//Print Function family /************************************************/
+
+  print_cls::print_cls(bool flg_dbg){
+    //Populate only on first constructor call
+    if(fmc_vtr.empty()){
+      fmc_vtr.push_back( fmc_cls("print",this,(int)PPRINT));
+      fmc_vtr.push_back( fmc_cls("sprint",this,(int)PSPRINT));
+      fmc_vtr.push_back( fmc_cls("snprint",this,(int)PSNPRINT));
+
+    }
+  }		      
+
+  var_sct *print_cls::fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker){
+  const std::string fnc_nm("print_cls::fnd");
+  int fdx;
+  int nbr_args;
+  int idx;
+  int nbr_dim;
+  int avg_nbr_dim; 
+    
+  char *fmt_sng=(char*)NULL;
+  vtl_typ lcl_type;
+  std::string susg;
+  std::string sfnm=fmc_obj.fnm();
+  std::vector<RefAST> vtr_args;             
+  RefAST aRef;
+  RefAST tr;
+
+  // de-reference 
+  ddra_info_sct ddra_info;        
+  prs_cls *prs_arg=walker.prs_arg;
+  var_sct *var =NULL_CEWI;
+  var_sct *var_att=NULL_CEWI; 
+  var_sct *var_fmt=NULL_CEWI; 
+        
+
+  fdx=fmc_obj.fdx();
+ 
+ 
+  // Put args into vector 
+  if(expr)
+    vtr_args.push_back(expr);
+
+  if(tr=fargs->getFirstChild()) {
+    do  
+      vtr_args.push_back(tr);
+    while(tr=tr->getNextSibling());    
+  } 
+
+  nbr_args=vtr_args.size();
+
+  susg="usage: att_out ?="+sfnm+"( att_id|var_id format_string?  )";
+  if( nbr_args <1 ) 
+     err_prn(sfnm, " Function has been called with wrong number of arguments arguments\n"+susg);  
+
+  lcl_type=expr_typ(vtr_args[0]);          
+  
+  if(lcl_type == VVAR && fdx==PPRINT)  
+    var_att=NULL;
+  else if(lcl_type==VSTRING)
+  {
+    char *cp;
+    nco_string val_string;
+
+    cp = strdup(vtr_args[0]->getText().c_str());          
+    (void)sng_ascii_trn(cp);            
+    val_string=cp; 
+    var_att=ncap_sclr_var_mk("~zz at print_methods", val_string); 
+
+  }
+  else  
+    var_att=walker.out(vtr_args[0]);       
+
+
+ if(nbr_args>1)
+   var_fmt=walker.out(vtr_args[1]);
+ 
+ if(prs_arg->ntl_scn)
+ {   
+   if(var_att)
+     nco_var_free(var_att);
+   if(var_fmt)
+     nco_var_free(var_fmt);
+
+   var=ncap_var_udf("~zz at print_methods");
+   return  var;
+
+ }
+
+ 
+ if(var_fmt) 
+ {
+   if(var_fmt->type != NC_CHAR && var_fmt->type != NC_STRING) 
+     err_prn(sfnm,"Format string must be a text type");
+
+   cast_void_nctype(var_fmt->type,&var_fmt->val); 
+   fmt_sng=(char*)nco_malloc(sizeof(char)*(var_fmt->sz+1));      
+  
+   if(var_fmt->type==NC_STRING)
+     strcpy(fmt_sng,var_fmt->val.sngp[0]);
+   else
+   {
+     strncpy(fmt_sng,var_fmt->val.cp, var_fmt->sz);  
+     fmt_sng[var_fmt->sz]='\0';   
+   }
+
+  cast_nctype_void(var_fmt->type,&var_fmt->val); 
+
+  nco_var_free(var_fmt);
+ }
+
+ // deal with important special case print && VVAR 
+ if(fdx==PPRINT &&  lcl_type==VVAR )
+ {
+   // check output first -nb can only print out vars that are defined AND written
+   // flg_stt==2 means var defined with data
+   int var_id;
+   int fl_id=-1;
+
+   const char *var_nm;
+   NcapVar *Nvar;
+   var_nm=vtr_args[0]->getText().c_str();
+
+   Nvar=prs_arg->var_vtr.find(var_nm);
 
+  
+    
+
+   if(Nvar && Nvar->flg_stt==2)
+     fl_id=prs_arg->out_id;   
+   else
+    // Check input file for var   
+    if(NC_NOERR==nco_inq_varid_flg(prs_arg->in_id,var_nm,&var_id))
+     fl_id=prs_arg->in_id;
+    
+
+   if(fl_id==-1) 
+   {
+    wrn_prn(fnc_nm,"Print function cannot find var \""+SCS(var_nm)+"\" in input or output");
+    return var;
+   }
+
+   
+   if( fl_id >=0)
+     (void)nco_prn_var_val_lmt(fl_id,var_nm,(lmt_sct*)NULL,0L,fmt_sng,prs_arg->FORTRAN_IDX_CNV,False,False);
+
+   nco_free(fmt_sng);
+   return var;
+ }
+
+
+
+
+
+ switch(fdx)
+ {
+   case PPRINT:
+       ncap_att_prn(var_att,fmt_sng);  
+       var=NULL_CEWI;   
+     break;
+   case PSPRINT:
+     {
+       char *cp;   
+       long sz;  
+       cp=ncap_att_sprn(var_att,fmt_sng);
+       sz=strlen(cp);
+       var=ncap_sclr_var_mk("~zz at print_methods",NC_CHAR,false);    
+       cast_void_nctype(NC_CHAR,&var->val);
+       var->val.cp=(char*) nco_malloc( sizeof(char)*sz);
+       strncpy(var->val.cp,cp,sz);
+       var->sz=sz;
+       cast_nctype_void(NC_CHAR,&var->val);            
+       free(cp);
+     }
+     break; 
+  case PSNPRINT:
+     {
+       char *cp; 
+       long sz;   
+       cp=ncap_att_sprn(var_att,fmt_sng);
+       sz=strlen(cp);  
+       var=ncap_sclr_var_mk("~zz at print_methods",NC_STRING,true);    
+       cast_void_nctype(NC_STRING,&var->val);
+       var->val.sngp[0]=(nco_string)cp;   
+       cast_nctype_void(NC_STRING,&var->val);            
+       var->sz=1; 
+     }
+    break;
+
+ }
+
+ if(var_att)
+    nco_var_free(var_att);
+
+ if(fmt_sng)
+   nco_free(fmt_sng);
+
+
+
+ return var;
+
+}
 
 /* ncap2 functions and methods */
 
diff --git a/src/nco++/fmc_all_cls.hh b/src/nco++/fmc_all_cls.hh
index 5699fe3..2910684 100644
--- a/src/nco++/fmc_all_cls.hh
+++ b/src/nco++/fmc_all_cls.hh
@@ -96,6 +96,7 @@ public:
   utl_cls(bool flg_dbg);
   var_sct *fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
   var_sct *is_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker);  
+  var_sct *get_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker);  
 };
 
 //Basic Functions /****************************************/
@@ -191,6 +192,7 @@ private:
    enum {PABS,PSQR };
    bool _flg_dbg;
 public:
+
   unr_cls(bool flg_dbg);
   var_sct *fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
 };
@@ -205,6 +207,18 @@ public:
   var_sct *fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
 };
 
+//Array Function /****************************************/
+class  bnds_cls: public vtl_cls {
+private:
+   enum {PBOUNDS };
+   bool _flg_dbg;
+public:
+  bnds_cls(bool flg_dbg);
+  var_sct *fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
+};
+
+
+
 //Bilinear  Interpolation Functions /****************************************/
 class bil_cls: public vtl_cls {
 private:
@@ -243,12 +257,15 @@ public:
 // var list class /*********************************************************/
 class vlist_cls: public vtl_cls {
 private:
-  enum {PJOIN,PPUSH };
+  enum {PJOIN,PPUSH,PGET_VARS_IN,PGET_VARS_OUT,PATOI,PATOL};
    bool _flg_dbg;
 public:
   vlist_cls(bool flg_dbg);
   var_sct *fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
-  var_sct *fnd_join(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
+  var_sct *push_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker);  
+  var_sct *get_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker);  
+  var_sct *atoi_fnd(bool &is_mtd, std::vector<RefAST> &args_vtr, fmc_cls &fmc_obj, ncoTree &walker);  
+  var_sct *join_fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
 };
 
 
@@ -263,6 +280,18 @@ public:
 };
 
 
+// print  Function family    /***************************************/
+class print_cls: public vtl_cls {
+private:
+  enum{ PPRINT, PSPRINT,PSNPRINT};
+  bool _flg_dbg;
+public:
+  print_cls(bool flg_dbg);
+  var_sct *fnd(RefAST expr, RefAST fargs,fmc_cls &fmc_obj, ncoTree &walker);
+};
+
+
+
 
 
 #endif // FMC_ALL_CLS_HH
diff --git a/src/nco++/ncap2.cc b/src/nco++/ncap2.cc
index 6d69edc..da53663 100644
--- a/src/nco++/ncap2.cc
+++ b/src/nco++/ncap2.cc
@@ -96,7 +96,7 @@ int
 main(int argc,char **argv)
 {
   const char fnc_nm[]="main"; 
-  FILE *yyin; /* File handle used to check file existance */
+  FILE *yyin; /* File handle used to check file existence */
   int parse_antlr(std::vector<prs_cls> &prs_vtr ,char*,char*);
   
   /* fxm TODO nco652 */
@@ -377,7 +377,7 @@ main(int argc,char **argv)
         hdr_pad=strtoul(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
         if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtoul",sng_cnv_rcd);
       } /* endif "hdr_pad" */
-      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
+      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF_MOD10; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
       if(!strcmp(opt_crr,"lbr") || !strcmp(opt_crr,"library")){
         (void)nco_lbr_vrs_prn();
         nco_exit(EXIT_SUCCESS);
@@ -548,6 +548,11 @@ main(int argc,char **argv)
   misc_cls misc_obj(true); 
   // string list functions
   vlist_cls vlist_obj(true);
+  // string list functions
+  print_cls print_obj(true);
+  // string list functions
+  bnds_cls bnds_obj(true);
+
 
   // Populate vector
   (void)pop_fmc_vtr(fmc_vtr,&cnv_obj);
@@ -568,6 +573,8 @@ main(int argc,char **argv)
   (void)pop_fmc_vtr(fmc_vtr,&cod_obj);
   (void)pop_fmc_vtr(fmc_vtr,&misc_obj);
   (void)pop_fmc_vtr(fmc_vtr,&vlist_obj);
+  (void)pop_fmc_vtr(fmc_vtr,&print_obj);
+  (void)pop_fmc_vtr(fmc_vtr,&bnds_obj);
 
 #ifdef ENABLE_GSL
 # ifdef ENABLE_NCO_GSL
@@ -658,7 +665,7 @@ main(int argc,char **argv)
   /* Open output file */
   if(FL_OUT_NEW){
     /* Normal case, like rest of NCO, where writes are made to temporary file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
   }else{ /* Existing file */
     /* ncap2, like ncrename and ncatted, directly modifies fl_in if fl_out is omitted
        If fl_out resolves to _same name_ as fl_in, method above is employed */
@@ -965,6 +972,8 @@ main(int argc,char **argv)
     if(var_vtr[idx]->xpr_typ == ncap_att){
       /* Skip missing values (for now) */
       if(var_vtr[idx]->getAtt() == nco_mss_val_sng_get()) continue;     
+      /* skip NC_STRING without warning - we  use NC_STRING as  variable pointers */  
+      if( fl_out_fmt != NC_FORMAT_NETCDF4 &&  var_vtr[idx]->var->type==NC_STRING ) continue;   
       att_item.att_nm=strdup(var_vtr[idx]->getAtt().c_str());
       att_item.var_nm=strdup(var_vtr[idx]->getVar().c_str());
       att_item.sz=var_vtr[idx]->var->sz;
@@ -1110,39 +1119,46 @@ ram_vars_add
 {
   var_sct *var1;
   
-  var1=ncap_sclr_var_mk(std::string("__BYTE"),nco_int(NC_BYTE));
+  var1=ncap_sclr_var_mk(std::string("NC_BYTE"),nco_int(NC_NAT));
+  prs_arg->ncap_var_write(var1,true);
+  
+  var1=ncap_sclr_var_mk(std::string("NC_BYTE"),nco_int(NC_BYTE));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__CHAR"),nco_int(NC_CHAR));
+  var1=ncap_sclr_var_mk(std::string("NC_CHAR"),nco_int(NC_CHAR));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__SHORT"),nco_int(NC_SHORT));
+  var1=ncap_sclr_var_mk(std::string("NC_SHORT"),nco_int(NC_SHORT));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__INT"),nco_int(NC_INT));
+  var1=ncap_sclr_var_mk(std::string("NC_INT"),nco_int(NC_INT));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__FLOAT"),nco_int(NC_FLOAT));
+  var1=ncap_sclr_var_mk(std::string("NC_FLOAT"),nco_int(NC_FLOAT));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__DOUBLE"),nco_int(NC_DOUBLE));
+  var1=ncap_sclr_var_mk(std::string("NC_DOUBLE"),nco_int(NC_DOUBLE));
   prs_arg->ncap_var_write(var1,true);
   
 #ifdef ENABLE_NETCDF4
-  var1=ncap_sclr_var_mk(std::string("__UBYTE"),nco_int(NC_UBYTE));
+  var1=ncap_sclr_var_mk(std::string("NC_UBYTE"),nco_int(NC_UBYTE));
   prs_arg->ncap_var_write(var1,true); 
   
-  var1=ncap_sclr_var_mk(std::string("__USHORT"),nco_int(NC_USHORT));
+  var1=ncap_sclr_var_mk(std::string("NC_USHORT"),nco_int(NC_USHORT));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__UINT"),nco_int(NC_UINT));
+  var1=ncap_sclr_var_mk(std::string("NC_UINT"),nco_int(NC_UINT));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__INT64"),nco_int(NC_INT64));
+  var1=ncap_sclr_var_mk(std::string("NC_INT64"),nco_int(NC_INT64));
   prs_arg->ncap_var_write(var1,true);
   
-  var1=ncap_sclr_var_mk(std::string("__UINT64"),nco_int(NC_UINT64));
+  var1=ncap_sclr_var_mk(std::string("NC_UINT64"),nco_int(NC_UINT64));
+  prs_arg->ncap_var_write(var1,true);
+
+  var1=ncap_sclr_var_mk(std::string("NC_STRING"),nco_int(NC_STRING));
   prs_arg->ncap_var_write(var1,true);
+
 #endif // !ENABLE_NETCDF4
   
 #ifdef INFINITY
diff --git a/src/nco++/ncap2_utl.cc b/src/nco++/ncap2_utl.cc
index 13f3155..9210e75 100644
--- a/src/nco++/ncap2_utl.cc
+++ b/src/nco++/ncap2_utl.cc
@@ -39,6 +39,23 @@ ncap_var_udf(const char *var_nm)
   return var_ret;
 }
 
+// check if we can do a 2 operand operation 
+// WITHOUT making them conform
+nco_bool 
+ncap_var_is_op_doable( var_sct *var1, var_sct *var2) 
+{
+  if( var1->sz==var2->sz) 
+    return True; 
+  
+  if( var1->sz >1 && var2->sz==1 || var1->sz==1 && var2->sz>1)
+    return True;
+
+  return False;
+}
+
+
+
+
 var_sct*
 ncap_att_get
 (int var_id,
@@ -89,6 +106,68 @@ ncap_att_get
   return var_ret; 
 }
 
+
+
+std::string ncap_att2var
+( prs_cls *prs_arg,   
+  std::string att_nm)
+{
+
+  std::string fnc_nm("ncap_att2var");
+  std::string sn; 
+  var_sct *var_att=NULL_CEWI; 
+  NcapVar *Nvar=NULL;
+
+  if(prs_arg->ntl_scn)
+    Nvar=prs_arg->int_vtr.find(att_nm);
+
+  if(Nvar==NULL) 
+    Nvar=prs_arg->var_vtr.find(att_nm);
+
+  if(Nvar !=NULL)
+    var_att=nco_var_dpl(Nvar->var);
+  else    
+    var_att=ncap_att_init(att_nm,prs_arg);
+
+  if(prs_arg->ntl_scn==False  && var_att==NULL_CEWI )
+    err_prn(fnc_nm,"Unable to locate attribute " +att_nm+ " in input or output files.");
+
+            
+  /* empty so return empty string */ 
+  if(var_att==NULL_CEWI )
+    return sn;
+
+  /* cant resolve pointer here */
+  if(var_att->val.vp==NULL_CEWI)
+  {
+    nco_var_free(var_att);      
+    return sn;
+  }
+
+  if(var_att->type !=NC_STRING && var_att->type !=NC_CHAR )
+    err_prn("To use that attribute "+ att_nm +" as a variable pointer it must be a text type  NC_CHAR or NC_STRING"); 
+    
+  cast_void_nctype(var_att->type, &var_att->val );
+  if(var_att->type == NC_STRING)
+  {
+      sn=var_att->val.sngp[0];
+  }
+  else if( var_att->type==NC_CHAR)
+  {        
+      char buffer[100]={'\0'};
+      strncpy(buffer, var_att->val.cp, var_att->sz);
+      sn=buffer;  
+  } 
+ 
+  cast_nctype_void(var_att->type, &var_att->val);
+  nco_var_free(var_att);  
+
+  return sn;
+
+}
+
+
+
 var_sct * /* O [sct] variable containing attribute */
 ncap_att_init /* [fnc] Grab an attribute from input file */
 (const std::string s_va_nm, /* I [sng] att name of form var_nm&att_nm */ 
@@ -301,7 +380,8 @@ ncap_att_prn     /* [fnc] Print a single attribute*/
   att_sz=var->sz;
   
   if(att_in_sng ==(char*)NULL) {        
-    (void)fprintf(stdout,"%s, size = %li %s, value = ",var->nm,att_sz,nco_typ_sng(var->type));
+    if(var->type != NC_CHAR && var->type != NC_STRING)
+       (void)fprintf(stdout,"%s, size = %li %s, value = ",var->nm,att_sz,nco_typ_sng(var->type));
     /* Typecast pointer to values before access */
     (void)cast_void_nctype(var->type,&var->val);
     (void)strcpy(dlm_sng,", ");
@@ -356,7 +436,10 @@ ncap_att_prn     /* [fnc] Print a single attribute*/
   default: nco_dfl_case_nc_type_err();
     break;
   } /* end switch */
-  (void)fprintf(stdout,"\n");
+
+  /* only print if format string NOT user defined  */
+  if(att_in_sng ==(char*)NULL && var->type != NC_CHAR && var->type != NC_STRING )
+      (void)fprintf(stdout,"\n");
   
   (void)cast_nctype_void(var->type,&var->val);
   
@@ -365,6 +448,125 @@ ncap_att_prn     /* [fnc] Print a single attribute*/
 } /* end ncap_att_prn() */
 
 
+char * 
+ncap_att_sprn     /* [fnc] Print a single attribute*/
+(var_sct *var,   /* I Variable containing att */
+ char *const att_in_sng) /* user defined format string */
+{
+
+  char char_foo;
+  char dlm_sng[3];
+  char att_sng[NCO_MAX_LEN_FMT_SNG];
+   
+  char *tp;
+  char *cp;    
+  char *cp_max;  
+
+  long att_lmn;
+  long att_sz; 
+  long max_sz;
+  
+  /* Copy value to avoid indirection in loop over att_sz */
+  att_sz=var->sz;
+  
+  cp=(char*)nco_calloc(sizeof(char),(NC_MAX_ATTRS+100)); 
+  tp=cp;  
+  cp_max=cp+ (size_t)(NC_MAX_ATTRS+100); 
+
+
+
+  if(att_in_sng ==(char*)NULL) {        
+    /* default dont bother if att info if type is text */
+    if(var->type != NC_CHAR && var->type != NC_STRING)
+    {     
+      (void)sprintf(tp,"%s, size = %li %s, value = ",var->nm,att_sz,nco_typ_sng(var->type));
+      tp+=strlen(tp); 
+    }
+    /* Typecast pointer to values before access */
+    (void)strcpy(dlm_sng,", ");
+    (void)sprintf(att_sng,"%s%%s",nco_typ_fmt_sng(var->type));
+    /* user defined format string */ 
+  } else {
+    (void)strcpy(att_sng,att_in_sng);
+    (void)strcpy(dlm_sng,"");
+  }
+      
+  (void)cast_void_nctype(var->type,&var->val);
+
+  
+  switch(var->type){
+  case NC_FLOAT:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max ;att_lmn++) { (void)sprintf(tp,att_sng,var->val.fp[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_DOUBLE:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max ;att_lmn++) { (void)sprintf(tp,att_sng,var->val.dp[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : "");  tp+=strlen(tp); }
+    break;
+  case NC_SHORT:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,var->val.sp[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_INT:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,(long)var->val.ip[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_CHAR:
+    if(att_in_sng ==(char*)NULL)    
+      /* remember string initialized to nulls */
+      strncpy(tp,var->val.cp,att_sz);
+    else          
+    {
+      for(att_lmn=0;att_lmn<att_sz && tp<cp_max ;att_lmn++)
+        /* Assume \0 is string terminator and do not print it */
+        if((char_foo=var->val.cp[att_lmn]) != '\0') 
+	{ 
+           (void)sprintf(tp,att_sng,char_foo);   
+           tp+=strlen(tp); 
+        } 
+    } /* end loop over element */
+
+    break;
+  case NC_BYTE:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,var->val.bp[att_lmn], (att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_UBYTE:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,var->val.ubp[att_lmn], (att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_USHORT:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,var->val.usp[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_UINT:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,var->val.uip[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_INT64:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,var->val.i64p[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_UINT64:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max;att_lmn++) { (void)sprintf(tp,att_sng,var->val.ui64p[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : ""); tp+=strlen(tp); }
+    break;
+  case NC_STRING:
+    for(att_lmn=0;att_lmn<att_sz && tp<cp_max ; att_lmn++) { (void)sprintf(tp,att_sng,var->val.sngp[att_lmn],(att_lmn != att_sz-1) ? dlm_sng : "");tp+=strlen(tp); }
+    break;
+  default: nco_dfl_case_nc_type_err();
+    break;
+  } /* end switch */
+  
+  (void)cast_nctype_void(var->type,&var->val);
+  
+  if( tp >= cp_max )
+  {
+    cp=(char*)nco_realloc(cp, NC_MAX_ATTRS*sizeof(char));     
+    cp[NC_MAX_ATTRS-1]='\0';
+  }
+  else
+  {
+    cp=(char*)nco_realloc(cp, sizeof(char) * (strlen(cp)+1));     
+  }       
+  
+  return cp;
+
+} /* end ncap_att_prn() */
+
+
+
+
 int          /* number appended */ 
 ncap_att_str /* extract string(s) from a NC_CHAR or NC_STRING type attribute */
 (var_sct *var_att, 
@@ -407,10 +609,27 @@ ncap_var_var_mod /* [fnc] Remainder (modulo) operation of two variables */
 (var_sct *var1, /* I [sc,t] Variable structure containing field */
  var_sct *var2) /* I [sct] Variable structure containing divisor */
 {
+  scv_sct scv;
   ptr_unn op_swp;
   const char fnc_nm[]="ncap_var_var_mod"; 
   
   if(nco_dbg_lvl_get() >= 4) dbg_prn(fnc_nm,"Entered function");
+
+  if(var2->sz==1)   
+  {
+    scv=ptr_unn_2_scv (var2->type, var2->val); 
+    nco_var_scv_mod(var1->type, var1->sz,var1->has_mss_val, var1->mss_val, var1->val, &scv);     
+    return var1;
+  }
+  else if( var1->sz==1) 
+  {
+    scv=ptr_unn_2_scv (var1->type, var1->val); 
+    nco_var_scv_mod(var2->type, var2->sz,var2->has_mss_val, var2->mss_val, var2->val, &scv);     
+    return var1;
+  }
+
+  
+
   
   if(var1->has_mss_val){
     (void)nco_var_mod(var1->type,var1->sz,var1->has_mss_val,var1->mss_val,var1->val,var2->val);
@@ -422,8 +641,6 @@ ncap_var_var_mod /* [fnc] Remainder (modulo) operation of two variables */
   // Swap values about
   op_swp=var1->val;var1->val=var2->val;var2->val=op_swp;
   
-  var2=nco_var_free(var2);
-  
   return var1;
 } /* end ncap_var_var_mod() */
 
@@ -474,9 +691,7 @@ ncap_var_var_atan2
     (void)cast_nctype_void(NC_DOUBLE,&var1->mss_val);  
   else if(var2->has_mss_val)
     (void)cast_nctype_void(NC_DOUBLE,&var2->mss_val);  
-  
-  var2=nco_var_free(var2); 
-  
+    
   return var1;
 } /* end ncap_var_var_atan2 */
 
@@ -550,10 +765,26 @@ ncap_var_var_pwr  /* [fnc] Empowerment of two variables */
 (var_sct *var1,   /* I [sct] Variable structure containing base */
  var_sct *var2)   /* I [sct] Variable structure containing exponent */
 {
+  scv_sct scv; 
   ptr_unn op_swp;
   const char fnc_nm[]="ncap_var_var_pwr";
-  
+
   if(nco_dbg_lvl_get() >= 4) dbg_prn(fnc_nm,"Entered function");
+
+  if(var2->sz==1)   
+  {
+    scv=ptr_unn_2_scv (var2->type, var2->val); 
+    nco_var_scv_pwr(var1->type, var1->sz,var1->has_mss_val, var1->mss_val, var1->val, &scv);     
+    return var1;
+  }
+  else if(var1->sz==1)
+  {
+    scv=ptr_unn_2_scv (var1->type, var1->val); 
+    nco_scv_var_pwr(var2->type, var2->sz,var2->has_mss_val, var2->mss_val,&scv, var2->val);     
+    return var1;
+  }
+
+  // if we are here than var1->sz==var2->sz >1
   if(var1->has_mss_val){
     (void)nco_var_pwr(var1->type,var1->sz,var1->has_mss_val,var1->mss_val,var1->val,var2->val);
   }else{
@@ -565,7 +796,6 @@ ncap_var_var_pwr  /* [fnc] Empowerment of two variables */
   op_swp=var1->val;
   var1->val=var2->val;
   var2->val=op_swp;
-  var2=nco_var_free(var2);
   
   return var1;
 } /* end ncap_var_var_pwr() */
@@ -1327,65 +1557,106 @@ nco_shp_chk
 /* This file is generated in makefile from ncoParserTokenTypes.hpp */ 
 #include "ncoEnumTokenTypes.hpp"
 
+
+var_sct* var_op(var_sct* var1 , int op)
+{
+   
+  switch (var1->type) 
+  {
+    case NC_DOUBLE: (void)tmp_var_op<double>(var1,op); break;
+    case NC_FLOAT: (void)tmp_var_op<float>(var1,op); break;
+    case NC_INT: (void)tmp_var_op<nco_int>(var1,op); break;            
+    case NC_SHORT: (void)tmp_var_op<nco_short>(var1,op); break;
+    case NC_USHORT: (void)tmp_var_op<nco_ushort>(var1,op); break;
+    case NC_UINT: (void)tmp_var_op<nco_uint>(var1,op); break;
+    case NC_INT64: (void)tmp_var_op<nco_int64>(var1,op); break;
+    case NC_UINT64: (void)tmp_var_op<nco_uint64>(var1,op); break;
+    case NC_BYTE: (void)tmp_var_op<nco_byte>(var1,op); break;
+    case NC_UBYTE: (void)tmp_var_op<nco_ubyte>(var1,op); break;
+    case NC_CHAR:  (void)tmp_var_op<nco_char>(var1,op); break;
+    case NC_STRING:  break; 
+    default: nco_dfl_case_nc_type_err(); break;
+
+  }
+  return var1;
+
+}
+
+
+
+
+var_sct* var_var_op(var_sct* var1 , var_sct* var2, int op)
+{
+
+  
+  if(var1->sz==var2->sz)
+  {
+    switch (var1->type) 
+      {
+      case NC_DOUBLE: (void)tmp_var_var_op_equal<double>(var1,var2,op); break;
+      case NC_FLOAT: (void)tmp_var_var_op_equal<float>(var1,var2,op); break;
+      case NC_INT: (void)tmp_var_var_op_equal<nco_int>(var1,var2,op); break;            
+      case NC_SHORT: (void)tmp_var_var_op_equal<nco_short>(var1,var2,op); break;
+      case NC_USHORT: (void)tmp_var_var_op_equal<nco_ushort>(var1,var2,op); break;
+      case NC_UINT: (void)tmp_var_var_op_equal<nco_uint>(var1,var2,op); break;
+      case NC_INT64: (void)tmp_var_var_op_equal<nco_int64>(var1,var2,op); break;
+      case NC_UINT64: (void)tmp_var_var_op_equal<nco_uint64>(var1,var2,op); break;
+      case NC_BYTE: (void)tmp_var_var_op_equal<nco_byte>(var1,var2,op); break;
+      case NC_UBYTE: (void)tmp_var_var_op_equal<nco_ubyte>(var1,var2,op); break;
+      case NC_CHAR:  (void)tmp_var_var_op_equal<nco_char>(var1,var2,op); break;
+      case NC_STRING:  break; 
+      default: nco_dfl_case_nc_type_err(); break;
+      }
+  }
+   else if( var1->sz ==1 && var2->sz>1 || var1->sz>1 && var2->sz==1 ) 
+   {
+     switch (var1->type) 
+      {
+      case NC_DOUBLE: (void)tmp_var_var_op_unequal<double>(var1,var2,op); break;
+      case NC_FLOAT: (void)tmp_var_var_op_unequal<float>(var1,var2,op); break;
+      case NC_INT: (void)tmp_var_var_op_unequal<nco_int>(var1,var2,op); break;            
+      case NC_SHORT: (void)tmp_var_var_op_unequal<nco_short>(var1,var2,op); break;
+      case NC_USHORT: (void)tmp_var_var_op_unequal<nco_ushort>(var1,var2,op); break;
+      case NC_UINT: (void)tmp_var_var_op_unequal<nco_uint>(var1,var2,op); break;
+      case NC_INT64: (void)tmp_var_var_op_unequal<nco_int64>(var1,var2,op); break;
+      case NC_UINT64: (void)tmp_var_var_op_unequal<nco_uint64>(var1,var2,op); break;
+      case NC_BYTE: (void)tmp_var_var_op_unequal<nco_byte>(var1,var2,op); break;
+      case NC_UBYTE: (void)tmp_var_var_op_unequal<nco_ubyte>(var1,var2,op); break;
+      case NC_CHAR:  (void)tmp_var_var_op_unequal<nco_char>(var1,var2,op); break;
+      case NC_STRING:  break; 
+      default: nco_dfl_case_nc_type_err(); break;
+     }
+   }
+   else  
+     err_prn("var_var_op","unable to perform operation"); 
+    
+
+  return var1;
+
+}
+
+
+
 var_sct *
 ncap_var_var_stc
 (var_sct *var1,
  var_sct *var2,
  int op)
 {
-  static VarOp<double> Vd;
-  static VarOp<float> Vf;
-  static VarOp<nco_int> Vi;
-  static VarOp<nco_short> Vs;
-  static VarOp<nco_ushort> Vus;
-  static VarOp<nco_uint> Vui;
-  static VarOp<nco_int64> Vi64;
-  static VarOp<nco_uint64> Vui64;
-  static VarOp<nco_byte> Vb;
-  static VarOp<nco_ubyte> Vub;
-  static VarOp<nco_char> Vc;
-  var_sct *var_ret=NULL_CEWI;
-  
+
   //If var2 is null then we are dealing with a unary function
-  if( var2 == NULL_CEWI) {
-    
-    switch (var1->type) {
-    case NC_DOUBLE: var_ret=Vd.var_op(var1,op); break;
-    case NC_FLOAT: var_ret=Vf.var_op(var1,op); break;
-    case NC_INT: var_ret=Vi.var_op(var1,op); break;            
-    case NC_SHORT: var_ret=Vs.var_op(var1,op); break;
-    case NC_USHORT: var_ret=Vus.var_op(var1,op); break;
-    case NC_UINT: var_ret=Vui.var_op(var1,op); break;
-    case NC_INT64: var_ret=Vi64.var_op(var1,op); break;
-    case NC_UINT64: var_ret=Vui64.var_op(var1,op); break;
-    case NC_BYTE: var_ret=Vb.var_op(var1,op); break;
-    case NC_UBYTE: var_ret=Vub.var_op(var1,op); break;
-    case NC_CHAR:  var_ret=Vs.var_op(var1,op); break;
-    case NC_STRING:  break; /* Do nothing */
-    default: nco_dfl_case_nc_type_err(); break;
-    }
-    return var_ret;
-  }
-  
-  switch (var1->type) {
-  case NC_DOUBLE: var_ret=Vd.var_var_op(var1,var2,op); break;
-  case NC_FLOAT: var_ret=Vf.var_var_op(var1,var2,op); break;
-  case NC_INT:var_ret=Vi.var_var_op(var1,var2,op); break;            
-  case NC_SHORT: var_ret=Vs.var_var_op(var1,var2,op); break;
-  case NC_USHORT: var_ret=Vus.var_var_op(var1,var2,op); break;
-  case NC_UINT: var_ret=Vui.var_var_op(var1,var2,op); break;
-  case NC_INT64: var_ret=Vi64.var_var_op(var1,var2,op); break;
-  case NC_UINT64: var_ret=Vui64.var_var_op(var1,var2,op); break;
-  case NC_BYTE: var_ret=Vb.var_var_op(var1,var2,op); break;
-  case NC_UBYTE: var_ret=Vub.var_var_op(var1,var2,op); break;
-  case NC_CHAR: break; /* Do nothing */
-  case NC_STRING: break; /* Do nothing */
-  default: nco_dfl_case_nc_type_err(); break;
-  } 
-  
-  return var_ret;
+  if( var2 == NULL_CEWI) 
+    (void)var_op(var1,op);
+  else
+    (void)var_var_op(var1,var2,op);       
+    
+  return var1;
 }
 
+
+
+
+
 int                /* [flg] true they conform */         
 ncap_var_att_cnf   /* [fnc] Make vars/atts conform */
 (var_sct *&var1,   /* I [sct] Input variable structure  */
@@ -1404,26 +1675,31 @@ ncap_var_att_cnf   /* [fnc] Make vars/atts conform */
     char *swp_nm;
     // (void)ncap_var_retype(var1,var2);
     
-    // if hyperslabs then check they conform
-    if( (var1->has_dpl_dmn ==-1 || var2->has_dpl_dmn==-1) && var1->sz >1 && var2->sz>1){  
-      if(var1->sz != var2->sz) {
+    //if hyperslabs then check they conform
+    if( (var1->has_dpl_dmn ==-1 || var2->has_dpl_dmn==-1) && var1->sz >1 && var2->sz>1)
+    {  
+      if(var1->sz != var2->sz) 
+      {
 	std::ostringstream os;
 	os<<"Hyperslabbed variable:"<<var1->nm <<" and variable:"<<var2->nm <<" have different number of elements, so cannot perform arithmetic operation.";
 	err_prn(fnc_nm,os.str());
       }
-      if( nco_shp_chk(var1,var2)==False){ 
+      if( nco_shp_chk(var1,var2)==False)
+      { 
 	std::ostringstream os;
         os<<"Hyperslabbed variable:"<<var1->nm <<" and variable:"<<var2->nm <<" have same  number of elements, but different shapes.";
 	wrn_prn(fnc_nm,os.str());
       }
-    }else{   
-      (void)ncap_var_cnf_dmn(&var1,&var2);
     }
+    else
+     (void)ncap_var_cnf_dmn(&var1,&var2);
+    
     // Bare numbers have name prefixed with"_"
     // for attribute propagation to work we need
     // to swap names about if first operand is a bare number
     // and second operand is a var
-    if( (var1->nm[0]=='~') && (var2->nm[0]!='~') ){
+    if( (var1->nm[0]=='~') && (var2->nm[0]!='~') )
+    {
       swp_nm=var1->nm; var1->nm=var2->nm; var2->nm=swp_nm; 
     }  
     // var & att
@@ -1600,8 +1876,8 @@ ncap_var_var_op   /* [fnc] Add two variables */
   
   // If var2 is null then we are dealing with a unary function
   if( var2 == NULL_CEWI){ 
-    var_ret=ncap_var_var_stc(var1,var2,op);   
-    return var_ret;
+    ncap_var_var_stc(var1,var2,op);   
+    return var1;
   }
   
   // Deal with pwr_in fuction
@@ -1621,19 +1897,28 @@ ncap_var_var_op   /* [fnc] Add two variables */
     char *swp_nm;
     (void)ncap_var_retype(var1,var2);
     
+    // can we do the op without any stretching or conformance ?
+    if( ncap_var_is_op_doable(var1,var2) ) 
+      ; 
     // if hyperslabs then check they conform
-    if( (var1->has_dpl_dmn ==-1 || var2->has_dpl_dmn==-1) && var1->sz >1 && var2->sz>1){  
-      if(var1->sz != var2->sz) {
-	std::ostringstream os;
-	os<<"Hyperslabbed variable:"<<var1->nm <<" and variable:"<<var2->nm <<" have different number of elements, so cannot perform arithmetic operation.";
-	err_prn(fnc_nm,os.str());
-      }
-      if( nco_shp_chk(var1,var2)==False){ 
-	std::ostringstream os;
-        os<<"Hyperslabbed variable:"<<var1->nm <<" and variable:"<<var2->nm <<" have same  number of elements, but different shapes.";
-	wrn_prn(fnc_nm,os.str());
-      }
-    }else{   
+    else if( (var1->has_dpl_dmn ==-1 || var2->has_dpl_dmn==-1) && var1->sz >1 && var2->sz>1)
+    {  
+	  if(var1->sz != var2->sz) 
+	  {
+	    std::ostringstream os;
+	    os<<"Hyperslabbed variable:"<<var1->nm <<" and variable:"<<var2->nm <<" have different number of elements, so cannot perform arithmetic operation.";
+	    err_prn(fnc_nm,os.str());
+	  }
+
+	  if( nco_shp_chk(var1,var2)==False)
+	  { 
+	    std::ostringstream os;
+	    os<<"Hyperslabbed variable:"<<var1->nm <<" and variable:"<<var2->nm <<" have same  number of elements, but different shapes.";
+	    wrn_prn(fnc_nm,os.str());
+	  }
+    }
+    else
+    {   
       (void)ncap_var_cnf_dmn(&var1,&var2);
     }
     // Bare numbers have name prefixed with"_"
@@ -1648,51 +1933,44 @@ ncap_var_var_op   /* [fnc] Add two variables */
     // nb this function is expensive 
     nco_mss_val_cnf(var1,var2); 
   
-    // var & att
-  }else  if( !vb1 && vb2 ){ 
+
+  }
+  // var & att
+  else if( !vb1 && vb2 )
+  { 
     var2=nco_var_cnf_typ(var1->type,var2);
-    if(var1->sz > 1 && var2->sz==1)
-      (void)ncap_var_cnf_dmn(&var1,&var2);
     
-    if(var1->sz != var2->sz) {
+    if(var1->sz != var2->sz &&  var2->sz !=1 ) {
       std::ostringstream os;
       os<<"Cannot make variable:"<<var1->nm <<" and attribute:"<<var2->nm <<" conform. So cannot perform arithmetic operation.";
       err_prn(fnc_nm,os.str()); 
     }
     
-    // att & var
-  }else if( vb1 && !vb2){
+  
+  }
+  // att & var
+  else if( vb1 && !vb2)
+  {
     var_sct *var_swp;
     ptr_unn val_swp;  // Used to swap values around
     
     var1=nco_var_cnf_typ(var2->type,var1);
-    if(var2->sz > 1 && var1->sz==1) (void)ncap_var_cnf_dmn(&var1,&var2);
+    //if(var2->sz > 1 && var1->sz==1) (void)ncap_var_cnf_dmn(&var1,&var2);
     
-    if(var1->sz != var2->sz){
+    if(var1->sz != var2->sz && var1->sz !=1){
       std::ostringstream os;
       os<<"Cannot make attribute:"<<var1->nm <<" and variable:"<<var2->nm <<" conform. So cannot perform arithmetic operation.";
       err_prn(fnc_nm,os.str()); 
     }
-    // Swap values around in var1 and var2;   
-    val_swp=var1->val;
-    var1->val=var2->val;
-    var2->val=val_swp;;
-    // Swap names about 
-    var_swp=var1;
-    var1=var2;
-    var2=var_swp;
-    
-    // att && att
-  } else if (vb1 && vb2) {
+  } 
+  // att && att
+  else if (vb1 && vb2) 
+  {
+
     (void)ncap_var_retype(var1,var2);
-    
-    if( var1->sz ==1 && var2->sz >1) 
-      (void)ncap_att_stretch(var1,var2->sz);
-    else if(var1->sz >1 && var2->sz==1)
-      (void)ncap_att_stretch(var2,var1->sz);
-    
-    // Crash out if atts not equal size
-    if(var1->sz != var2->sz) {
+        
+    // Crash out if not doable
+    if( !ncap_var_is_op_doable(var1,var2)) {
       std::ostringstream os;
       os<<"Cannot make attribute:"<<var1->nm <<" and attribute:"<<var2->nm <<" conform. So cannot perform arithmetic operation.";
       err_prn(fnc_nm,os.str()); 
@@ -1700,25 +1978,46 @@ ncap_var_var_op   /* [fnc] Add two variables */
   }
   
   // Deal with pwr fuction ( nb pwr function can't be templated )
-  if(op== CARET){
-    var_ret=ncap_var_var_pwr(var1,var2);
-    return var_ret;     
-  }
- 
- // deal with mod function
-  if(op==MOD){
-    var_ret=ncap_var_var_mod(var1,var2);
-    return var_ret;     
-  }
+  if(op==CARET)
+     ncap_var_var_pwr(var1,var2);
+  else if (op==MOD)
+     ncap_var_var_mod(var1,var2);
+  else if( op==ATAN2 )
+     ncap_var_var_atan2(var1,var2);
+  else  
+     ncap_var_var_stc(var1,var2,op);
+
+  // swap var data about -results of an asymetrical operation
+  if( var1->sz ==1 && var2->sz >1)
+  {
+    char *cswp; 
+    var_sct *var_swp;      
+  
+    var_swp=var1;     
+    var1=var2;
+    var2=var_swp;
+
+    // swap names about to preserve att propagation
+    cswp=var1->nm;
+    var1->nm=var2->nm;
+    var2->nm=cswp;           
+
 
-  if(op==ATAN2){
-    var_ret=ncap_var_var_atan2(var1,var2);
-    return var_ret;
   }
-  
-  var_ret=ncap_var_var_stc(var1,var2,op);
+
+  // swap about names so attribute propagation works 
+  if( ncap_var_is_att(var1) &&  !ncap_var_is_att(var2)) 
+  {
+    char *cswp;
+    cswp=var1->nm;
+    var1->nm=var2->nm;
+    var2->nm=cswp;           
+
+  } 
+
+
   var2=nco_var_free(var2);
-  return var_ret;
+  return var1;
 }
 
 var_sct *             /* O [sct] Sum of input variables (var1+var2) INITIAL SCAN ONLY */
@@ -1735,7 +2034,8 @@ ncap_var_var_op_ntl   /* [fnc] Add two variables */
     return var1;
   
   // deal with pwr fuction
-  if( (op == CARET ) && nco_rth_prc_rnk(var1->type) < nco_rth_prc_rnk_float && nco_rth_prc_rnk(var2->type) < nco_rth_prc_rnk_float) var1=nco_var_cnf_typ((nc_type)NC_FLOAT,var1);
+  if( (op == CARET ) && nco_rth_prc_rnk(var1->type) < nco_rth_prc_rnk_float && nco_rth_prc_rnk(var2->type) < nco_rth_prc_rnk_float) 
+        var1=nco_var_cnf_typ((nc_type)NC_FLOAT,var1);
 
   //Deal with atan2 function
   if(op==ATAN2 ){
@@ -1797,6 +2097,7 @@ ncap_var_var_inc   /* [fnc] Add two variables */
  var_sct *var2,    /* I [sct] Input variable structure containing second operand */
  int op,            /* Deal with incremental operators i.e +=,-=,*=,/= */
  bool bram,         /* I [bool] If true make a RAM variable */ 
+ bool bret, 
  prs_cls *prs_arg)
 {
   const char fnc_nm[]="ncap_var_var_inc"; 
@@ -1810,16 +2111,19 @@ ncap_var_var_inc   /* [fnc] Add two variables */
   vb1 = ncap_var_is_att(var1);
   
   // If initial Scan
-  if(prs_arg->ntl_scn){
+  if(prs_arg->ntl_scn)
+  {
     
     // deal with variable
-    if(!vb1){
+    if(!vb1)
+    {
       var_ret=nco_var_dpl(var1); 
       (void)prs_arg->ncap_var_write(var1,bram);  
-      // deal with attribute 
-    }else{
-      var_ret=var1;
     }
+    // deal with attribute 
+    else
+      var_ret=var1;
+
     if(var2) 
       var2=(var_sct*)nco_var_free(var2);
     
@@ -1827,18 +2131,24 @@ ncap_var_var_inc   /* [fnc] Add two variables */
   }   
   
   //Deal with unary functions first
-  if(var2==NULL_CEWI){
-    if(op==INC||op==DEC){ 
+  if(var2==NULL_CEWI)
+  {
+    if(op==INC||op==DEC)
+    { 
       var1=ncap_var_var_stc(var1,var2,op);
-      var_ret=nco_var_dpl(var1);
+      var_ret= (bret ? nco_var_dpl(var1): NULL);
     }
-    if(op==POST_INC||op==POST_DEC){ 
-      var_ret=nco_var_dpl(var1);
+
+    if(op==POST_INC||op==POST_DEC)
+    { 
+      var_ret=(bret ? nco_var_dpl(var1): NULL);
       var1=ncap_var_var_stc(var1,var2,op);
     }
-    if(!vb1){
+
+    if(!vb1)
       (void)prs_arg->ncap_var_write(var1,bram);  
-    }else{
+    else
+    {
       std::string sa(var1->nm);
       NcapVar *Nvar=new NcapVar(var1,sa);
       prs_arg->var_vtr.push_ow(Nvar);       
@@ -1855,41 +2165,48 @@ ncap_var_var_inc   /* [fnc] Add two variables */
   var2=nco_var_cnf_typ(var1->type,var2);
   
   // var & var
-  if(!vb1 && !vb2) {
-    nco_bool DO_CONFORM=True;;
-    var_sct *var_tmp=NULL_CEWI;
+  if(!vb1 && !vb2) 
+  {
+
+    if( var1->sz != var2->sz && var2->sz !=1)   
+    {
+      nco_bool DO_CONFORM=True;;
+      var_sct *var_tmp=NULL_CEWI;
     
-    var_tmp=nco_var_cnf_dmn(var1,var2,var_tmp,True,&DO_CONFORM);
-    if(var2 != var_tmp){
-      var2=nco_var_free(var2);
-      var2=var_tmp;
-    }
+      var_tmp=nco_var_cnf_dmn(var1,var2,var_tmp,True,&DO_CONFORM);
+      if(var2 != var_tmp){
+        var2=nco_var_free(var2);
+        var2=var_tmp;
+      }
     
-    if(DO_CONFORM==False) {
+      if(DO_CONFORM==False) 
+      {
+	std::ostringstream os;
+	os<<"Cannot make variable:"<<var1->nm <<" and variable:"<<var2->nm <<" conform. So cannot perform arithmetic operation.";
+	err_prn(fnc_nm,os.str()); 
+      }
+    }
+  } 
+  // att & var ,att & att, var & att  
+  else 
+  {
+    if(var1->sz != var2->sz && var2->sz !=1 )
+    {      
       std::ostringstream os;
-      os<<"Cannot make variable:"<<var1->nm <<" and variable:"<<var2->nm <<" conform. So cannot perform arithmetic operation.";
+      os<<"Cannot make " << cvar1<<":"<<var1->nm <<" and " <<cvar2 <<":"<<var2->nm <<" conform. So cannot perform arithmetic operation.";
       err_prn(fnc_nm,os.str()); 
-    }
-    // att & var ,att & att  
-  } else {
-    
-    if(var1->sz > 1 && var2->sz==1)
-      (void)ncap_att_stretch(var2,var1->sz);
-  }   
-  
-  if(var1->sz != var2->sz) {
-    std::ostringstream os;
-    os<<"Cannot make " << cvar1<<":"<<var1->nm <<" and " <<cvar2 <<":"<<var2->nm <<" conform. So cannot perform arithmetic operation.";
-    err_prn(fnc_nm,os.str()); 
+     
+    }   
   }
   
-  var1=ncap_var_var_stc(var1,var2,op);
-  var_ret=nco_var_dpl(var1);
+  (void)ncap_var_var_stc(var1,var2,op);
+  var_ret=(bret ? nco_var_dpl(var1): NULL);
   
   // if LHS is a variable then write to disk
-  if(!vb1){
+  if(!vb1)
     prs_arg->ncap_var_write(var1,bram);
-  }else{
+  else
+  {
     // deal with attribute
     std::string sa(var1->nm);
     NcapVar *Nvar=new NcapVar(var1,sa);
@@ -2478,7 +2795,7 @@ ncap_sclr_var_mk
   return var;
 }
 
-/* fxm: Allow ncap2 to instantiate NC_STRINGs
+/* fxm: Allow ncap2 to instantiate NC_STRINGs */
    var_sct *
    ncap_sclr_var_mk(
    const std::string var_nm,
@@ -2490,7 +2807,7 @@ ncap_sclr_var_mk
    *var->val.sngp=val_string;
    (void)cast_nctype_void((nc_type)NC_STRING,&var->val);
    return var;
-   } */ 
+   } 
 
 // Do an in-memory hyperslab !!
 void 
diff --git a/src/nco++/ncap2_utl.hh b/src/nco++/ncap2_utl.hh
index c2df2c9..ea63243 100644
--- a/src/nco++/ncap2_utl.hh
+++ b/src/nco++/ncap2_utl.hh
@@ -55,7 +55,7 @@
 #include "NcapVarVector.hh"
 #include "NcapVar.hh"
 #include "sdo_utl.hh"
-#include "VarOp.hh" 
+#include "VarOpNew.hh" 
 #include "prs_cls.hh"
 
 
@@ -76,6 +76,11 @@
 
 /* Begin funtions in ncap2_utl.cc */
 
+std::string ncap_att2var
+( prs_cls *prs_arg,   
+  std::string att_nm);
+
+
 var_sct*               /* O [sct] variable containing attribute */
 ncap_att_get	       /*   [fnc] Grab an attribute from input file */	
 (int var_id,           /*   I  var id        */ 
@@ -127,6 +132,13 @@ ncap_att_prn
 (var_sct *var, 
  char *const att_in_sng);
 
+char *            /* [0] sng - malloced inside function */
+ncap_att_sprn     /* [fnc] Print a single attribute*/
+(var_sct *var,   /* I Variable containing att */
+ char *const att_in_sng); /* user defined format string */
+
+
+
 int                 /* number appended */ 
 ncap_att_str        /* extract string(s) from a NC_CHAR or NC_STRING type attribute */
 (var_sct *var_att,  /* I [sct] input attribute */
@@ -236,6 +248,12 @@ ncap_var_var_stc
  var_sct *var2,  /* I [sct] Input variable structure containing second operand */
  int op);
 
+var_sct *             /* O [sct] Sum of input variables (var1+var2) INITIAL SCAN ONLY */
+ncap_var_var_op_ntl   /* [fnc] Add two variables */
+(var_sct *var1,       /* I [sct] Input variable structure containing first operand */
+ var_sct *var2,       /* I [sct] Input variable structure containing second operand */
+ int op);             /* Operation +-% */
+
 var_sct *         /* O [sct] Sum of input variables (var1+var2) */
 ncap_var_var_op   /* [fnc] Add two variables */
 (var_sct *var1,  /* I [sct] Input variable structure containing first operand */
@@ -248,13 +266,9 @@ ncap_var_var_inc    /* [fnc] Add two variables */
  var_sct *var2,     /* I [sct] Input variable structure containing second operand */
  int op,            /* Deal with incremental operators i.e +=,-=,*=,/= */
  bool bram,         /* I [flg] Make a RAM variable */
+ bool bret,         /* I [flg] if true then return var else return NULL */
  prs_cls *prs_arg);
 
-var_sct *             /* O [sct] Sum of input variables (var1+var2) INITIAL SCAN ONLY */
-ncap_var_var_op_ntl   /* [fnc] Add two variables */
-(var_sct *var1,       /* I [sct] Input variable structure containing first operand */
- var_sct *var2,       /* I [sct] Input variable structure containing second operand */
- int op);             /* Operation +-% */
 
 bool            /* O [flg] true if all var elemenst are true */
 ncap_var_lgcl   /* [fnc] calculate a aggregate bool value from a variable */
@@ -285,6 +299,12 @@ nco_bool        /* Reurns True if var has attribute style name */
 ncap_var_is_att( 
 var_sct *var);
 
+nco_bool 
+ncap_var_is_op_doable( 
+var_sct *var1, 
+var_sct *var2); 
+
+
 bool           /* Returns true if expression contains a utility fuction */ 
 ncap_fnc_srh(
 RefAST ntr
@@ -372,6 +392,15 @@ var_sct *
 ncap_sclr_var_mk(
 const std::string var_nm,
 nco_uint64 val_uint64);
+
+
+
+var_sct *
+ncap_sclr_var_mk(
+const std::string var_nm,
+nco_string val_string);
+
+
 // end ncap_sclr_var_mk() overloads
 
 void
diff --git a/src/nco++/ncoEnumTokenTypes.hpp b/src/nco++/ncoEnumTokenTypes.hpp
index 4e26b59..1f1bd3b 100644
--- a/src/nco++/ncoEnumTokenTypes.hpp
+++ b/src/nco++/ncoEnumTokenTypes.hpp
@@ -1,7 +1,7 @@
 #ifndef INC_ncoEnumTokenTypes_hpp_
 #define INC_ncoEnumTokenTypes_hpp_
 
-/* $ANTLR 2.7.7 (2006-11-01): "ncoGrammer.g" -> "ncoEnumTokenTypes.hpp"$ */
+/* $ANTLR 2.7.7 (20130428): "ncoGrammer.g" -> "ncoEnumTokenTypes.hpp"$ */
 
 #ifndef CUSTOM_API
 # define CUSTOM_API
@@ -49,19 +49,19 @@
 		ELSE = 41,
 		WHERE = 42,
 		ELSEWHERE = 43,
-		PRINT = 44,
-		VAR_ID = 45,
-		ATT_ID = 46,
-		LCURL = 47,
-		RCURL = 48,
-		FOR = 49,
-		COLON = 50,
-		LSQUARE = 51,
-		DIM_ID = 52,
-		RSQUARE = 53,
-		DIVIDE = 54,
-		DIM_MTD_ID = 55,
-		CALL_REF = 56,
+		LCURL = 44,
+		RCURL = 45,
+		FOR = 46,
+		COLON = 47,
+		LSQUARE = 48,
+		VAR_ID = 49,
+		DIM_ID = 50,
+		RSQUARE = 51,
+		DIVIDE = 52,
+		DIM_MTD_ID = 53,
+		ATT_ID = 54,
+		CALL_REF = 55,
+		TIMES = 56,
 		DOT = 57,
 		FUNC = 58,
 		INC = 59,
@@ -69,60 +69,59 @@
 		LNOT = 61,
 		PLUS = 62,
 		MINUS = 63,
-		TIMES = 64,
-		CARET = 65,
-		MOD = 66,
-		FLTHAN = 67,
-		FGTHAN = 68,
-		LTHAN = 69,
-		GTHAN = 70,
-		GEQ = 71,
-		LEQ = 72,
-		EQ = 73,
-		NEQ = 74,
-		LAND = 75,
-		LOR = 76,
-		QUESTION = 77,
-		ASSIGN = 78,
-		PLUS_ASSIGN = 79,
-		MINUS_ASSIGN = 80,
-		TIMES_ASSIGN = 81,
-		DIVIDE_ASSIGN = 82,
-		NCAP_FLOAT = 83,
-		NCAP_DOUBLE = 84,
-		NCAP_INT = 85,
-		NCAP_BYTE = 86,
-		NCAP_UBYTE = 87,
-		NCAP_SHORT = 88,
-		NCAP_USHORT = 89,
-		NCAP_UINT = 90,
-		NCAP_INT64 = 91,
-		NCAP_UINT64 = 92,
-		N4STRING = 93,
-		DIM_ID_SIZE = 94,
-		NRootAST = 95,
-		SHIFTL = 96,
-		SHIFTR = 97,
-		QUOTE = 98,
-		DGT = 99,
-		LPH = 100,
-		LPHDGT = 101,
-		XPN = 102,
-		VAR_NM_QT = 103,
-		BLASTOUT = 104,
-		UNUSED_OPS = 105,
-		WS = 106,
-		CXX_COMMENT = 107,
-		C_COMMENT = 108,
-		NUMBER_DOT = 109,
-		NUMBER = 110,
-		VAR_ATT = 111,
-		VAR_ATT_QT = 112,
-		STR_ATT_QT = 113,
-		DIM_QT = 114,
-		DIM_VAL = 115,
-		INCLUDE = 116,
-		LMT_DMN = 117,
+		CARET = 64,
+		MOD = 65,
+		FLTHAN = 66,
+		FGTHAN = 67,
+		LTHAN = 68,
+		GTHAN = 69,
+		GEQ = 70,
+		LEQ = 71,
+		EQ = 72,
+		NEQ = 73,
+		LAND = 74,
+		LOR = 75,
+		QUESTION = 76,
+		ASSIGN = 77,
+		PLUS_ASSIGN = 78,
+		MINUS_ASSIGN = 79,
+		TIMES_ASSIGN = 80,
+		DIVIDE_ASSIGN = 81,
+		NCAP_FLOAT = 82,
+		NCAP_DOUBLE = 83,
+		NCAP_INT = 84,
+		NCAP_BYTE = 85,
+		NCAP_UBYTE = 86,
+		NCAP_SHORT = 87,
+		NCAP_USHORT = 88,
+		NCAP_UINT = 89,
+		NCAP_INT64 = 90,
+		NCAP_UINT64 = 91,
+		N4STRING = 92,
+		DIM_ID_SIZE = 93,
+		NRootAST = 94,
+		SHIFTL = 95,
+		SHIFTR = 96,
+		QUOTE = 97,
+		DGT = 98,
+		LPH = 99,
+		LPHDGT = 100,
+		XPN = 101,
+		VAR_NM_QT = 102,
+		BLASTOUT = 103,
+		UNUSED_OPS = 104,
+		WS = 105,
+		CXX_COMMENT = 106,
+		C_COMMENT = 107,
+		NUMBER_DOT = 108,
+		NUMBER = 109,
+		VAR_ATT = 110,
+		VAR_ATT_QT = 111,
+		STR_ATT_QT = 112,
+		DIM_QT = 113,
+		DIM_VAL = 114,
+		INCLUDE = 115,
+		LMT_DMN = 116,
 		NULL_TREE_LOOKAHEAD = 3
 	};
 #endif /*INC_ncoEnumTokenTypes_hpp_*/
diff --git a/src/nco++/ncoGrammer.g b/src/nco++/ncoGrammer.g
index bc68354..3b358da 100644
--- a/src/nco++/ncoGrammer.g
+++ b/src/nco++/ncoGrammer.g
@@ -128,8 +128,6 @@ statement:
          ( //standard if-else ambiguity
          options {warnWhenFollowAmbig = false;} 
         : ELSEWHERE! statement )?
-        // print statement
-        | PRINT^ LPAREN! (VAR_ID|ATT_ID|NSTRING) (COMMA! NSTRING)?  RPAREN! SEMI! 
         // Code block
         | block
    ;        
@@ -161,12 +159,12 @@ lmt_list: LPAREN! lmt (COMMA! lmt)*  RPAREN!
 // be used with or with out $ prefix. ie "$lon" or "lon" 
 // So parser is compatible with ncap1
 dmn_list_p:
-   LSQUARE! (VAR_ID|DIM_ID) (COMMA! (VAR_ID|DIM_ID))* RSQUARE!
+   LSQUARE! (VAR_ID|DIM_ID)? (COMMA! (VAR_ID|DIM_ID))* RSQUARE!
       { #dmn_list_p = #( [DMN_LIST_P, "dmn_list_p"], #dmn_list_p ); }
     ;
 
 dmn_list:
-   LPAREN! DIM_ID (COMMA! DIM_ID)* RPAREN!
+   LPAREN! (DIM_ID) (COMMA! DIM_ID)* RPAREN!
       { #dmn_list = #( [DMN_LIST, "dmn_list"], #dmn_list ); }
     ;
 
@@ -196,8 +194,12 @@ call_ref: CALL_REF^(VAR_ID|ATT_ID)
      ;
 
 /*************************************************************/
-/* start  expressions */
-meth_exp: primary_exp (DOT^ FUNC func_arg)*
+
+top_exp: ur:TIMES^ {#ur->setType(UTIMES);#ur->setText("UTIMES");}  top_exp
+             | primary_exp
+     ;  
+             
+meth_exp: top_exp (DOT^ FUNC func_arg)*
      ;
 
 // unary left association   
@@ -210,17 +212,16 @@ unaryleft_exp: meth_exp (
     ;
 
 // unary right association   
-/*
-unary_exp:  ( LNOT^| PLUS^| MINUS^ |INC^ | DEC^ | TIMES^ ) unary_exp
+unary_exp:  ( LNOT^| PLUS^| MINUS^ |INC^ | DEC^ ) unary_exp
             | unaryleft_exp
 	;
-*/
 
+/*
 unary_exp:  ( LNOT^| PLUS^| MINUS^ |INC^ | DEC^ 
              | ur:TIMES^ {#ur->setType(UTIMES);#ur->setText("UTIMES");} ) unary_exp
              | unaryleft_exp
     ;    
-
+*/
 // right association
 pow_exp: unary_exp (CARET^ pow_exp )? 
     ;
@@ -322,7 +323,6 @@ tokens {
     WHILE="while";    
     FOR="for";
    
-    PRINT="print";  
     DEFDIMA="defdim";
     DEFDIMU="defdimunlim";
  
@@ -445,11 +445,13 @@ DOT options {paraphrase="dot operator";} : '.';
 
 CALL_REF options {paraphrase="call by reference";} : '&';
 
+
+
 protected DGT:     ('0'..'9');
 protected LPH:     ( 'a'..'z' | 'A'..'Z' | '_' );
 protected LPHDGT:  ( 'a'..'z' | 'A'..'Z' | '_' | '0'..'9');
 protected XPN:     ( 'e' | 'E' ) ( '+' | '-' )? ('0'..'9')+ ;
-protected VAR_NM_QT: (LPHDGT|'-'|'+'|'.'|'('|')'|':' )+  ;      
+protected VAR_NM_QT: (LPHDGT|'-'|'+'|'.'|'('|')'|':'|' ' )+  ;      
 
 protected BLASTOUT: .
          {
@@ -531,11 +533,13 @@ NUMBER:
 ;
 
 
+
+
 // Return var or att (var_nm at att_nm)
 VAR_ATT options {testLiterals=true; paraphrase="variable or function or attribute identifier"; } 
      :  (LPH)(LPH|DGT)*   
             {
-             // try to intelligently guess the type to avoid un-necessary function search  
+             // try to intelligently guess the type to avoid un-necessary function search    
             bool bDoSearch;
             switch( LA(1) ){
                case ' ': 
@@ -607,6 +611,7 @@ DIM_VAL options { paraphrase="dimension identifier"; }
          )? 
    ;  
 
+
 // Shorthand for naming dims in method e.g., $0,$1, $2 etc
 DIM_MTD_ID 
   options{paraphrase="dimension identifier";} 
@@ -824,8 +829,7 @@ NcapVector<lmt_sct*> &lmt_vtr )
              break;
            case 1: //end
              lmt_ptr->is_usr_spc_max=True;
-             lmt_ptr->end=uival;
-             break;
+             lmt_ptr->end=uival;             break;
            case 2: //srd
              lmt_ptr->srd_sng=strdup("~fill_in");
              lmt_ptr->srd=uival;
@@ -953,7 +957,7 @@ if( nbr_dmn!=lmt_init(lmt,ast_lmt_vtr) )
      int wlk_nbr);
 
      if(tr== ANTLR_USE_NAMESPACE(antlr)nullAST)
-        err_prn("run_dbl"," REPORTS given a null AST Refrence\n");
+        err_prn("run_dbl"," REPORTS given a null AST Reference\n");
             
      //small list dont bother with double parsing     
      // just do a final parse
@@ -1078,7 +1082,7 @@ RefAST nco_dupList(RefAST tr){
       RefAST otr;  
       // nb astFactory is protected- must call from within class
       otr=astFactory->dupList(tr);      
-      otr->setNextSibling( ANTLR_USE_NAMESPACE(antlr)nullAST ) ;
+      //otr->setNextSibling( ANTLR_USE_NAMESPACE(antlr)nullAST ) ;
       /*  
       if(otr->getNextSibling()!= ANTLR_USE_NAMESPACE(antlr)ASTNULL )     
         err_prn("nco_dupList", "NON NULL AST SIBLING\n");
@@ -1117,26 +1121,23 @@ static std::vector<std::string> lpp_vtr;
             
                 }
 
-    | #(exp:EXPR ass:.) {
-       RefAST tr;
-       RefAST ntr;  
+    | #(exp:EXPR ass:.) 
+     {
+       int aType; 
        
-       if(ass->getType()==ASSIGN && prs_arg->ntl_scn ){
-         ntr=ass->getFirstChild();
-         if(ntr->getType()==UTIMES) 
-           ntr=ntr->getFirstChild();
-        
-         if(ntr->getType() == VAR_ID || ntr->getType() ==ATT_ID){
-            ntr->addChild( astFactory->create(NORET,"no_ret") );
-           // std::cout << "Modified assign "<<exp->toStringTree()<<std::endl;      
-         }
-       } 
+       aType=ass->getType(); 
+
+     
+      
+      if( aType==ASSIGN || aType==POST_INC || aType==POST_DEC || aType==INC || aType==DEC||aType==PLUS_ASSIGN || aType==MINUS_ASSIGN || aType==TIMES_ASSIGN || aType==DIVIDE_ASSIGN )
+            ass->setText("NO_RET"); 
 
        var=out(exp->getFirstChild());
+
        if(var != (var_sct*)NULL)
          var=nco_var_free(var);
        iret=EXPR;
-     }
+    }
 
     // These expressions excute in their own basic blocks
     // Any expressions  which use the utility functions
@@ -1147,6 +1148,8 @@ static std::vector<std::string> lpp_vtr;
        if(var != (var_sct*)NULL)
          var=nco_var_free(var);
        iret=FEXPR;
+
+       dbg_prn(fnc_nm,"executed FEXPR "+ fss->getText());    
      }
 
     | #(IF var=out stmt:. ) {
@@ -1202,7 +1205,7 @@ static std::vector<std::string> lpp_vtr;
         where_assign(stmt3,var);
     
       // deal with else-where
-      if(tr=stmt3->getNextSibling()) {
+      if((tr=stmt3->getNextSibling())!=ANTLR_USE_NAMESPACE(antlr)nullAST) {
 
         //invert mask
         var=ncap_var_var_stc(var,NULL_CEWI,LNOT); 
@@ -1347,126 +1350,11 @@ static std::vector<std::string> lpp_vtr;
         } 
 
         (void)ncap_def_dim(def->getText(),sz,bunlimited,prs_arg);
-     }
-
-    // All the following functions have iret=0
-    | (#(PRINT VAR_ID))=> #(PRINT pvid:VAR_ID){
-
-          int var_id;
-          int fl_id=-1;
-          char *fmt_sng;
-         
-          std::string va_nm(pvid->getText());
-          NcapVar *Nvar;
-          
-          if(prs_arg->ntl_scn) goto end2;
-          Nvar=prs_arg->var_vtr.find(va_nm);
-
-          if(Nvar && Nvar->flg_mem){   
-            wrn_prn(fnc_nm,"Cannot print out RAM variables at the moment!");
-            goto end2;
-          }
-
-          // check output first -nb can only print out vars that are defined AND written
-          // it is possible to get with the var defined in output but no data
-          // flg_stt==1 mean var defined but no data !!
-          // So we try to use var in input -if it exist their    
-          if(Nvar && Nvar->flg_stt==2){
-             fl_id=prs_arg->out_id;   
-          }else{
-           // Check input file for var   
-           if(NC_NOERR==nco_inq_varid_flg(prs_arg->in_id,va_nm.c_str(),&var_id))
-            fl_id=prs_arg->in_id;
-          }
-
-          if(fl_id==-1) {
-            wrn_prn(fnc_nm,"Print function cannot find var \""+va_nm+"\" in input or output");
-            goto end2;
-          }
-
-          // Grab format string 
-          if(pvid->getNextSibling() && pvid->getNextSibling()->getType()==NSTRING)
-            fmt_sng=strdup(pvid->getNextSibling()->getText().c_str());
-          else 
-            fmt_sng=(char*)NULL; 
-   
-          if( fl_id >=0)
-           (void)nco_prn_var_val_lmt(fl_id,va_nm.c_str(),(lmt_sct*)NULL,0L,fmt_sng,prs_arg->FORTRAN_IDX_CNV,False,False);
-             
-          if(fmt_sng) fmt_sng=(char*)nco_free(fmt_sng); 
-
-        end2: ;
-    }
-    | (#(PRINT ATT_ID))=> #(PRINT patt:ATT_ID){
-
-          int apsn;
-          var_sct *var1;
-          char *fmt_sng;
-          std::string fl_nm;
-          std::string att_nm;
-          std::string var_nm;
-          NcapVar *Nvar;
-          
-          var=NULL_CEWI;
-
-          // print only on second parse
-          if(prs_arg->ntl_scn) goto end3;
-
-          fl_nm=patt->getText();
-          apsn=fl_nm.find("@");
-          var_nm=fl_nm.substr(0,apsn);
-          att_nm=fl_nm.substr(apsn+1);            
-          
-          Nvar=prs_arg->var_vtr.find(var_nm);
-          if( Nvar && att_nm==std::string(nco_mss_val_sng_get()) ){         
-              if(Nvar->var->has_mss_val==True){
-                var1=ncap_sclr_var_mk(fl_nm,Nvar->var->type,true);
-                (void)memcpy(var1->val.vp,Nvar->var->mss_val.vp, nco_typ_lng(Nvar->var->type));
-                var=var1;
-              }else{
-                wrn_prn(fnc_nm,"Cannot print missing value \""+ fl_nm+ "\" for variable \""+ var_nm +"\" as it is undefined");
-                goto end3;    
-              }
-          }else{   
-             Nvar=prs_arg->var_vtr.find(fl_nm);
-             if(Nvar==NULL_CEWI) 
-                var=ncap_att_init(fl_nm,prs_arg);
-             else
-                var=nco_var_dpl(Nvar->var); 
-          }
-
-          if(var==NULL_CEWI ){
-            wrn_prn(fnc_nm,"Cannot print  attribute \"" +fl_nm+ "\". Not present in input or output files.");
-            goto end3;    
-           }
-
-          // Grab format string 
-          if(patt->getNextSibling() && patt->getNextSibling()->getType()==NSTRING)
-            fmt_sng=strdup(patt->getNextSibling()->getText().c_str());
-          else 
-            fmt_sng=(char*)NULL; 
-
-          (void)ncap_att_prn(var,fmt_sng);
-          var=nco_var_free(var); 
-
-          end3:   ;
-    }
-
-    | (#(PRINT NSTRING))=> #(PRINT pstr:NSTRING){
-       char *prn_sng;
-       
-       if(!prs_arg->ntl_scn){
-        prn_sng=strdup(pstr->getText().c_str());
-        (void)sng_ascii_trn(prn_sng);            
-
-        fprintf(stdout,"%s",prn_sng);
-        prn_sng=(char*)nco_free(prn_sng);
-      }    
-    }
+      }
     ;
 
 // Parse assign statement - Initial Scan
-assign_ntl [bool bram] returns [var_sct *var]
+assign_ntl [bool bram,bool bret] returns [var_sct *var]
 {
 const std::string fnc_nm("assign_ntl"); 
 var=NULL_CEWI;
@@ -1487,10 +1375,13 @@ var=NULL_CEWI;
                var_rhs=nco_var_free(var_rhs);               
 
                var_lhs=prs_arg->ncap_var_init(var_nm,false);
-               if(var_lhs){
+               if(var_lhs)
+               {
                  var=nco_var_dpl(var_lhs);
                  (void)prs_arg->ncap_var_write(var_lhs,bram);
-               } else {
+               } 
+               else 
+               {
                  // set var to udf
                  var_lhs=ncap_var_udf(var_nm.c_str());
                  var=nco_var_dpl(var_lhs);
@@ -1518,6 +1409,8 @@ var=NULL_CEWI;
               bcst=true;  
               var_cst=NULL_CEWI;
 
+               
+                
               aRef=dmn->getFirstChild();
          
               // pPut dimension names in vector       
@@ -1533,33 +1426,38 @@ var=NULL_CEWI;
                    && prs_arg->dmn_out_vtr.findi(str_vtr[idx]) ==-1)      
                   break;
 
-               // return undef if dim missing 
-               if( idx <str_vtr_sz){
-                  var=NULL_CEWI;
-               } else {
+              // return undef if dim missing 
+              if( idx <str_vtr_sz)
+                 var1=ncap_var_udf(var_nm.c_str());
+              else 
+              {
                  // Cast is applied in VAR_ID action in function out()
                  var_cst=ncap_cst_mk(str_vtr,prs_arg);
-
                  var1=out(vid1->getNextSibling());
-                 if(var1->undefined) {
-                    var=NULL_CEWI;
-                 } else {
+
+                 if(!var1->undefined) 
+                 {
                    var_cst=nco_var_cnf_typ(var1->type,var_cst);
                    var_cst->typ_dsk=var1->type;
-                   var=nco_var_dpl(var_cst);
-                   }
-                 var1=nco_var_free(var1);
+                   var1=nco_var_free(var1); 
+                   var1=nco_var_dpl(var_cst);
+                 }
+
               }
               
-              if(!var){
+              if(var1->undefined)
+              {
+                var1=nco_var_free(var1);   
                 var1=ncap_var_udf(var_nm.c_str());
                 Nvar=new NcapVar(var1);
                 (void)prs_arg->int_vtr.push_ow(Nvar);
                 var=nco_var_dpl(var1);
-              } else{
-                var->nm=(char*)nco_free(var->nm);
-                var->nm=strdup(var_nm.c_str());
-                var1=nco_var_dpl(var);
+              } 
+              else
+              {
+                var1->nm=(char*)nco_free(var1->nm);
+                var1->nm=strdup(var_nm.c_str());
+                var=nco_var_dpl(var1);
                 prs_arg->ncap_var_write(var1,bram);
              }
 
@@ -1570,47 +1468,35 @@ var=NULL_CEWI;
             }
 
           | vid2:VAR_ID {   
-
-              var_sct *var_lhs=(var_sct*)NULL;              
-              var_sct *var_rhs=(var_sct*)NULL;              
+              
+              var_sct *var_rhs;
               std::string var_nm;
               
               var_nm=vid2->getText();
 
               if(nco_dbg_lvl_get() >= nco_dbg_var) dbg_prn(fnc_nm,var_nm);
-      
-              // Set class wide variables           
-              bcst=false;
-              var_cst=NULL_CEWI; 
-              
-              // get shape from RHS
-              var_rhs=out(vid2->getNextSibling());
-           
-              // use init_chk() to avoid warning from ncap_var_init() if var not present  
-              if(prs_arg->ncap_var_init_chk(var_nm)) 
-                var_lhs=prs_arg->ncap_var_init(var_nm,false); 
+               
+               // Set class wide variables           
+               bcst=false;
+               var_cst=NULL_CEWI; 
+             
+               // get shape from RHS
+               var_rhs=out(vid2->getNextSibling());
+               (void)nco_free(var_rhs->nm);                
+               var_rhs->nm =strdup(var_nm.c_str());
+
+               //Copy return variable
+               if(bret)
+                  var=nco_var_dpl(var_rhs);
+               else
+                  var=(var_sct*)NULL;  
+                
+               // Write var to int_vtr
+               // if var already in int_vtr or var_vtr then write call does nothing
+               (void)prs_arg->ncap_var_write(var_rhs,bram);
+               //(void)ncap_var_write_omp(var_rhs,bram,prs_arg);
+
 
-              if(var_lhs)
-              {
-                 var=nco_var_dpl(var_lhs);
-                 (void)prs_arg->ncap_var_write(var_lhs,bram);
-                 nco_var_free(var_rhs); 
-              }
-              else if(var_rhs)
-              {
-                 //Copy return variable
-                 (void)nco_free(var_rhs->nm);                
-                 var_rhs->nm =strdup(var_nm.c_str());
-                 //Copy return variable
-                var=nco_var_dpl(var_rhs);
-                // Write var to int_vtr
-                // if var already in int_vtr or var_vtr then write call does nothing
-                (void)prs_arg->ncap_var_write(var_rhs,bram);
-              }   
-              else 
-              {               
-                var=ncap_var_udf(var_nm.c_str());   
-              }  
         } // end action
        
    |   (#(ATT_ID LMT_LIST))=> #(att:ATT_ID LMT_LIST){
@@ -1627,7 +1513,10 @@ var=NULL_CEWI;
             prs_arg->int_vtr.push_ow(Nvar);          
 
             // Copy return variable
-            var=nco_var_dpl(var1);    
+            if(bret)
+              var=nco_var_dpl(var1);    
+            else
+              var=(var_sct*)NULL; 
 
        } //end action
 
@@ -1648,13 +1537,16 @@ var=NULL_CEWI;
         prs_arg->int_vtr.push_ow(Nvar);          
 
         // Copy return variable
-        var=nco_var_dpl(var1);    
+        if(bret)
+          var=nco_var_dpl(var1);    
+        else
+          var=(var_sct*)NULL;    
 
-       } //end action
+    } //end action
 
     ; // end assign block
 
-assign [bool bram] returns [var_sct *var]
+assign [bool bram,bool bret] returns [var_sct *var]
 {
 const std::string fnc_nm("assign"); 
 var=NULL_CEWI;
@@ -1849,12 +1741,13 @@ var=NULL_CEWI;
                 (void)nco_lmt_free(lmt_vtr[idx]);
 
               // See If we have to return something
-end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORET)
-                var=NULL_CEWI;
-              else 
+end0:         if(bret)
                 var=prs_arg->ncap_var_init(var_nm,true);
+              else 
+                var=NULL_CEWI;
+
                
-        } // end action
+    } // end action
 
         // Deal with LHS casting 
         | (#(VAR_ID (DMN_LIST|DMN_LIST_P) ))=> #(vid1:VAR_ID dmn:.){   
@@ -1872,22 +1765,38 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
               bcst=true;  
               var_cst=NULL_CEWI;
 
-              //aRef=vid->getFirstChild()->getFirstChild();
-              aRef=dmn->getFirstChild();
-         
-              // pPut dimension names in vector       
-              while(aRef) {
-                str_vtr.push_back(aRef->getText());
-                aRef=aRef->getNextSibling();      
-              }
 
-              // Cast is applied in VAR_ID action in function out()
-              // Note cast is NOT applied to an attribute, an irregular hyperslab
-              // or any entity which has a size of one.
-              var_cst=ncap_cst_mk(str_vtr,prs_arg);     
-              var1=out(vid1->getNextSibling());
 
-              /* NB var_cst->val.vp always now set to null */ 
+              if(dmn)
+              { 
+
+                  aRef=dmn->getFirstChild();                  
+                  // pPut dimension names in vector       
+                  while(aRef) 
+                  {
+                    str_vtr.push_back(aRef->getText());
+                    aRef=aRef->getNextSibling();      
+                  }
+
+                  // Cast is applied in VAR_ID action in function out()
+                  // Note cast is NOT applied to an attribute, an irregular hyperslab
+                  // or any entity which has a size of one.
+                  var_cst=ncap_cst_mk(str_vtr,prs_arg);     
+                  var1=out(vid1->getNextSibling());
+              }  
+              // deal with an empty hyperslab ie casting a scalar
+              else
+              {  
+                 var1=out(vid1->getNextSibling());    
+                 var_cst=ncap_sclr_var_mk("Internally generated template",var1->type,false);   
+              }    
+
+
+
+             // do attribute propagation only  from RHS -if not an att
+             if( !ncap_var_is_att(var1))  
+                 ncap_att_gnrl(var_nm,var1->nm,1,prs_arg);
+
 
 
               // If the RHS has size one or is an attribute or an irregular hyperslab
@@ -1897,24 +1806,27 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
               bool br1=(var_cst->sz >=1 && var1->sz==1);
               bool br2=(var_cst->sz==var1->sz &&  ( ncap_var_is_att(var1) ||var1->has_dpl_dmn==-1 ));
 
+              // NB var_cst->val.vp always now set to null 
               // The code rebuilds var1 with the shape from the casting variable  
               if( br1 || br2){
                 var_sct *var_nw;
-                void *vp_swp;
 
-                var_nw=nco_var_dpl(var_cst);
-                var_nw=nco_var_cnf_typ(var1->type,var_nw);
                 if(br1)
-                   (void)ncap_att_stretch(var1,var_nw->sz);
+                   (void)ncap_att_stretch(var1,var_cst->sz);
+
+                var_nw=nco_var_dpl(var_cst);
+                (void)nco_var_cnf_typ(var1->type,var_nw);
                  
-                vp_swp=var_nw->val.vp;
                 var_nw->val.vp=var1->val.vp;
-                var1->val.vp=vp_swp;
+                var1->val.vp=(void*)NULL;
 
                 var1=nco_var_free(var1);
                 var1=var_nw;
              }
-               
+             
+
+ 
+
                //blow out if vars not the same size      
              if(var1->sz != var_cst->sz) 
                   err_prn(fnc_nm, "LHS cast for "+var_nm+" - cannot make RHS "+ std::string(var1->nm) + " conform.");          
@@ -1922,10 +1834,10 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
               var1->nm =strdup(var_nm.c_str());
 
               // See If we have to return something
-              if(dmn->getNextSibling() && dmn->getNextSibling()->getType()==NORET)
-                var=NULL_CEWI;
-              else 
+              if(bret)
                 var=nco_var_dpl(var1);     
+              else 
+                var=NULL_CEWI;
 
               //call to nco_var_get() in ncap_var_init() uses this property
               var1->typ_dsk=var1->type;
@@ -1934,18 +1846,19 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
               bcst=false;
               var_cst=nco_var_free(var_cst); 
 
-          } // end action
+    } // end action
            
-          | vid2:VAR_ID {   
+          | vid2:VAR_ID {
+
                // Set class wide variables
-               var_sct *var_lhs=(var_sct*)NULL;
-               var_sct *var_rhs=(var_sct*)NULL;
+               var_sct *var_rhs;
                NcapVar *Nvar;
                std::string var_nm;
  
                var_nm=vid2->getText();       
 
-               if(nco_dbg_lvl_get() >= nco_dbg_var) dbg_prn(fnc_nm,var_nm);
+
+              if(nco_dbg_lvl_get() >= nco_dbg_var) dbg_prn(fnc_nm,var_nm);
                
                bcst=false;
                var_cst=NULL_CEWI; 
@@ -1955,55 +1868,57 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
                // Save name 
                std::string s_var_rhs(var_rhs->nm);
 
+               // Do attribute propagation only if
+               // var doesn't already exist or is defined but NOT
+               // populated
                Nvar=prs_arg->var_vtr.find(var_nm);
+               //rcd=nco_inq_varid_flg(prs_arg->out_id,var_rhs->nm ,&var_id);
 
                if(!Nvar || (Nvar && Nvar->flg_stt==1))
-                   (void)ncap_att_cpy(var_nm,s_var_rhs,prs_arg);
-
-               if(Nvar)
-                 var_lhs=nco_var_dpl(Nvar->var);
-               // use init_chk() to avoid warning from ncap_var_init() if var not present  
-               else if(prs_arg->ncap_var_init_chk(var_nm))
-                  var_lhs=prs_arg->ncap_var_init(var_nm,false); 
- 
-               if(var_lhs)
-               {
-                   // var is defined and populated &  RHS is scalar -then stretch var to match
-                   var_rhs=nco_var_cnf_typ(var_lhs->type,var_rhs);   
-                   if(var_rhs->sz ==1 && var_lhs->sz >1)
-                   {
-                       (void)ncap_att_stretch(var_rhs,var_lhs->sz);
-                        // this is a special case -- if the RHS scalar has
-                        // no missing value then retain LHS missing value
-                        // else LHS missing value gets over written by RHS
-                        if(!var_rhs->has_mss_val)
-                         (void)nco_mss_val_cp(var_lhs,var_rhs);   
-                    }   
-
-                   if( var_rhs->sz != var_lhs->sz) 
-                       err_prn(fnc_nm,"regular assign - var size missmatch between \""+var_nm+"\" and RHS of expression");                        
-
-                   var_lhs->val.vp=var_rhs->val.vp;
+                 (void)ncap_att_cpy(var_nm,s_var_rhs,prs_arg);
                
-                   var_rhs->val.vp=(void*)NULL;                
-                   nco_var_free(var_rhs);  
-                   // Write var to disk
-                   (void)prs_arg->ncap_var_write(var_lhs,bram);
-               }
-               else
-               {
-                   nco_free(var_rhs->nm);
-                   var_rhs->nm=strdup(var_nm.c_str());  
-                   (void)prs_arg->ncap_var_write(var_rhs,bram);  
-               }  
+                // var is defined and populated &  RHS is scalar -then stretch var to match
+               if(Nvar && Nvar->flg_stt==2)
+               {  
+                  long n_sz=Nvar->var->sz;
+
+                  if(var_rhs->sz ==1 && Nvar->var->sz >1)
+                  {
+                    var_rhs=nco_var_cnf_typ(Nvar->var->type,var_rhs);  
+                    (void)ncap_att_stretch(var_rhs,n_sz);
+                    
+                    // this is a special case -- if the RHS scalar has
+                    // no missing value then retain LHS missing value
+                    // else LHS missing value gets over written by RHS
+                    if(!var_rhs->has_mss_val)
+                      (void)nco_mss_val_cp(Nvar->var,var_rhs);   
+                  }
+                  
+                  else if( var_rhs->sz >1 && n_sz >1 && var_rhs->sz != n_sz && n_sz % var_rhs->sz ==0)  
+                      ncap_var_cnf_dmn(&Nvar->var,&var_rhs); 
+                   
+                
+                  if(var_rhs->sz != Nvar->var->sz)
+                   err_prn(fnc_nm, "size miss-match in simple assign between \""+ var_nm +"\""+ " size="+nbr2sng(Nvar->var->sz) + "var_rhs expr size="+nbr2sng(var_rhs->sz) );
+
+               } 
+
+               // finally add new name before write  
+               (void)nco_free(var_rhs->nm);                
+               var_rhs->nm =strdup(var_nm.c_str());
+
+               // Write var to disk
+               (void)prs_arg->ncap_var_write(var_rhs,bram);
+               //(void)ncap_var_write_omp(var_rhs,bram,prs_arg);
 
                 // See If we have to return something
-               if(vid2->getFirstChild() && vid2->getFirstChild()->getType()==NORET)
-                 var=NULL_CEWI;
+               if(bret)
+                 var=prs_arg->ncap_var_init(var_nm,true);   
                else 
-                 var=prs_arg->ncap_var_init(var_nm,true);               ;
-                         
-       } // end action
+                 var=NULL_CEWI;
+
+   
+    } // end action
  
    |   (#(ATT_ID LMT_LIST)) => #(att:ATT_ID lmta:LMT_LIST){
 
@@ -2074,7 +1989,7 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
               {
                 // check size
                if(  var_rhs->sz!=1L &&  var_rhs->sz != cnt)   
-                  err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesnt match RHS size=" + nbr2sng(var_rhs->sz));
+                  err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesn't match RHS size=" + nbr2sng(var_rhs->sz));
 
                    
                 szn=(var_rhs->sz >1 ? 1: 0);     
@@ -2121,7 +2036,7 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
 
                // check size
                if(  var_rhs->sz!=1L &&  var_rhs->sz != cnt)   
-                  err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesnt match RHS size=" + nbr2sng(var_rhs->sz));
+                  err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesn't match RHS size=" + nbr2sng(var_rhs->sz));
 
  
                nco_var_cnf_typ(var_lhs->type,var_rhs);               
@@ -2150,16 +2065,15 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
             prs_arg->var_vtr.push_ow(Nvar);       
 
                // See If we have to return something
-            if(lmta->getFirstChild() && lmta->getFirstChild()->getType()==NORET)
-              var=NULL_CEWI;
+            if(bret)
+              var=nco_var_dpl(var_lhs);             
             else 
-              var=nco_var_dpl(var_lhs);               ;
- 
+              var=NULL_CEWI; 
 
            att_end: ; 
 
         
-        } 
+    }
 
    |   (#(ATT_ID DMN_LIST))=> #(att1:ATT_ID DMN_LIST){
         ;
@@ -2196,20 +2110,32 @@ end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORE
             prs_arg->var_vtr.push_ow(Nvar);       
 
                // See If we have to return something
-            if(att2->getFirstChild() && att2->getFirstChild()->getType()==NORET)
-              var=NULL_CEWI;
+            if(bret)
+              var=nco_var_dpl(var1);               
             else 
-              var=nco_var_dpl(var1);               ;
+              var=NULL_CEWI;
+
                   
-       } // end action
+    } // end action
    ;
                
 out returns [var_sct *var]
 {
+    bool bret=true;   
     const std::string fnc_nm("out"); 
 	var_sct *var1;
     var_sct *var2;
     var=NULL_CEWI;
+  
+    // on the following tokens if text is set to NO_RET then make sure out return var=NULL
+    // the check is done in statements / EXPR
+    // out_AST_in declared an inialized  to the first arg of out() (see ncoTree.cpp/out() for actual code )
+    if( out_AST_in != ANTLR_USE_NAMESPACE(antlr)nullAST && out_AST_in->getText()=="NO_RET" )
+    {
+       int aType=out_AST_in->getType();
+       if(aType==ASSIGN ||aType==POST_INC || aType==POST_DEC || aType==INC || aType==DEC||aType==PLUS_ASSIGN || aType==MINUS_ASSIGN || aType==DIVIDE_ASSIGN || aType==TIMES_ASSIGN)
+          bret=false;
+    }      
 }  
     // arithmetic operators 
 
@@ -2217,19 +2143,22 @@ out returns [var_sct *var]
            { var=ncap_var_var_op(var1,var2, PLUS );}
 	|  (#(MINUS out out)) => #( MINUS var1=out var2=out)
             { var=ncap_var_var_op(var1,var2, MINUS );}
-    |  (#(UTIMES #(POST_INC out)))=> #( UTIMES #(POST_INC var1=out_asn)){
-             var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,true,prs_arg);      
+    |  (#(POST_INC #(UTIMES ATT_ID)))=> #( POST_INC #(UTIMES aposti:ATT_ID)){
+             var1=out(att2var(aposti));     
+             var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,false,bret,prs_arg);      
        } 
-    |  (#(UTIMES #(POST_DEC out)))=> #( UTIMES #(POST_DEC var1=out_asn)){
-             var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,true,prs_arg);      
+    |  (#(POST_DEC #(UTIMES ATT_ID)))=> #( POST_DEC #(UTIMES apostd:ATT_ID)){
+             var1=out(att2var(apostd));     
+             var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,false,bret,prs_arg);      
        } 
-    |  (#(UTIMES #(INC out)))=> #( UTIMES #(INC var1=out_asn)){
-             var=ncap_var_var_inc(var1,NULL_CEWI,INC,true,prs_arg);      
+    |  (#(INC #(UTIMES ATT_ID)))=> #( INC #(UTIMES aprei:ATT_ID)){
+             var1=out(att2var(aprei));     
+             var=ncap_var_var_inc(var1,NULL_CEWI,INC,false,bret,prs_arg);      
        } 
-    |  (#(UTIMES #(DEC out)))=> #( UTIMES #(DEC var1=out_asn)){
-             var=ncap_var_var_inc(var1,NULL_CEWI,DEC,true,prs_arg);      
+    |  (#(DEC #(UTIMES ATT_ID)))=> #( DEC #(UTIMES apred:ATT_ID)){
+             var1=out(att2var(apred));     
+             var=ncap_var_var_inc(var1,NULL_CEWI,DEC,false,bret,prs_arg);      
        } 
-
 	|	#(TIMES var1=out var2=out)
             { var=ncap_var_var_op(var1,var2, TIMES );}	
 
@@ -2247,15 +2176,16 @@ out returns [var_sct *var]
     |   #(PLUS var1=out ) // do nothing   
 
     |   #(INC var1=out_asn )      
-            { var=ncap_var_var_inc(var1,NULL_CEWI,INC,false,prs_arg);}
+            { var=ncap_var_var_inc(var1,NULL_CEWI,INC,false,bret,prs_arg);}
+
     |   #(DEC var1=out_asn )      
-            { var=ncap_var_var_inc(var1,NULL_CEWI, DEC,false,prs_arg );}
-    
+            {var=ncap_var_var_inc(var1,NULL_CEWI, DEC,false,bret,prs_arg );}
+
     |   #(POST_INC var1=out_asn ){
-            var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,false,prs_arg);
+            var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,false,bret,prs_arg);
         }
     |   #(POST_DEC var1=out_asn ){      
-            var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,false,prs_arg);
+            var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,false,bret,prs_arg);
         }
     // Logical Operators
     | #(LAND var1=out var2=out)  
@@ -2270,7 +2200,7 @@ out returns [var_sct *var]
     | #(GEQ  var1=out var2=out)   
             { var=ncap_var_var_op(var1,var2, GEQ );}
     | #(LEQ  var1=out var2=out)   
-            { var=ncap_var_var_op(var1,var2, LEQ );}
+             { var=ncap_var_var_op(var1,var2, LEQ );}
     | #(EQ  var1=out var2=out)    
             { var=ncap_var_var_op(var1,var2, EQ );}
     | #(NEQ  var1=out var2=out)   
@@ -2281,62 +2211,147 @@ out returns [var_sct *var]
     | #(FGTHAN  var1=out var2=out) 
             { var=ncap_var_var_op(var1,var2, FGTHAN );}
     // Assign Operators 
-    | #(PLUS_ASSIGN pls_asn:. var2=out) {
-       var1=out_asn(pls_asn);
-       var=ncap_var_var_inc(var1,var2, PLUS_ASSIGN ,(pls_asn->getType()==UTIMES), prs_arg);
+    // | #(PLUS_ASSIGN pls_asn:. var2=out) {
+    //    var1=out_asn(pls_asn);
+    //    var=ncap_var_var_inc(var1,var2, PLUS_ASSIGN ,(pls_asn->getType()==UTIMES), prs_arg);
+    //    }
+    // Assign Operators 
+    
+    | ( #(PLUS_ASSIGN  (VAR_ID|ATT_ID)  var2=out)) => #(PLUS_ASSIGN var1=out  var2=out)  {
+       var=ncap_var_var_inc(var1,var2,PLUS_ASSIGN ,false, bret,prs_arg);
+       }
+
+    | (#(PLUS_ASSIGN  #(UTIMES VAR_ID) var2=out)) => #(PLUS_ASSIGN  #(UTIMES var1=out)  var2=out)  {
+       var=ncap_var_var_inc(var1,var2, PLUS_ASSIGN ,true, bret,prs_arg);
+       }
+
+    | (#(PLUS_ASSIGN  #(UTIMES ATT_ID) var2=out)) => #(PLUS_ASSIGN  #(UTIMES atp:ATT_ID)  var2=out)  {
+
+       var1=out(att2var(atp));     
+       var=ncap_var_var_inc(var1,var2, PLUS_ASSIGN ,false,bret, prs_arg);
        }
-	| #(MINUS_ASSIGN min_asn:. var2=out){
-       var1=out_asn(min_asn);
-       var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,(min_asn->getType()==UTIMES), prs_arg);
+
+
+    | ( #(MINUS_ASSIGN  (VAR_ID|ATT_ID)  var2=out)) => #(MINUS_ASSIGN  var1=out  var2=out)  {
+       var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,false, bret,prs_arg);
        }
-	| #(TIMES_ASSIGN tim_asn:. var2=out){       
-       var1=out_asn(tim_asn);
-       var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,(tim_asn->getType()==UTIMES), prs_arg);
+
+    | (#(MINUS_ASSIGN #(UTIMES VAR_ID) var2=out)) => #(MINUS_ASSIGN #(UTIMES var1=out)  var2=out)  {
+       var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,true, bret,prs_arg);
        }
-	| #(DIVIDE_ASSIGN div_asn:. var2=out){	
-       var1=out_asn(div_asn);
-       var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,(div_asn->getType()==UTIMES), prs_arg);
+
+    | (#(MINUS_ASSIGN #(UTIMES ATT_ID) var2=out)) => #(MINUS_ASSIGN #(UTIMES atm:ATT_ID)  var2=out)  {
+       var1=out(att2var(atm));     
+       var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,false, bret,prs_arg);
        }
 
-    | #(ASSIGN asn:. ) 
-            {
+    | (#(TIMES_ASSIGN  (VAR_ID|ATT_ID)  var2=out)) => #(TIMES_ASSIGN  var1=out  var2=out)  {
+       var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,false, bret,prs_arg);
+       }
+
+    | (#(TIMES_ASSIGN #(UTIMES VAR_ID) var2=out)) => #(TIMES_ASSIGN #(UTIMES var1=out)  var2=out)  {
+       var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,true, bret,prs_arg);
+       }
+
+    | (#(TIMES_ASSIGN #(UTIMES ATT_ID) var2=out)) => #(TIMES_ASSIGN #(UTIMES attm:ATT_ID)  var2=out)  {
+       var1=out(att2var(attm));     
+       var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,false, bret,prs_arg);
+       }
+
+    | (#(DIVIDE_ASSIGN  (VAR_ID|ATT_ID)  var2=out)) => #(DIVIDE_ASSIGN  var1=out  var2=out)  {
+       var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,false, bret,prs_arg);
+       }
+
+    | (#(DIVIDE_ASSIGN #(UTIMES VAR_ID) var2=out)) => #(DIVIDE_ASSIGN #(UTIMES var1=out)  var2=out)  {
+       var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,true, bret,prs_arg);
+       }
+
+    | (#(DIVIDE_ASSIGN #(UTIMES ATT_ID) var2=out)) => #(DIVIDE_ASSIGN #(UTIMES atd:ATT_ID)  var2=out)  {
+       var1=out(att2var(atd));        
+       var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,false, bret,prs_arg);
+       }
+
+
+    | (#(ASSIGN (VAR_ID|ATT_ID))) => #(ASSIGN asn:.) {
+             if(prs_arg->ntl_scn)
+               var=assign_ntl(asn,false,bret); 
+             else
+               var=assign(asn,false,bret);
+    }
+
+    // dealing with a variable pointer  
+    | (#(ASSIGN #(UTIMES ATT_ID) )) =>  #(ASSIGN #(atta:UTIMES ATT_ID)) {
+
+             RefAST tr;
+             tr=atta->getFirstChild();
+             tr->setNextSibling(atta->getNextSibling());
+             
+             // remember tr siblings and children are  duplicated here   
+             tr=att2var(tr);   
+
+             if(prs_arg->ntl_scn)
+               var=assign_ntl(tr,false,bret); 
+             else
+               var=assign(tr,false,bret);
+    }  
+    
+    //  memory var - regular and pointer
+    | #(ASSIGN #(asn2:UTIMES (VAR_ID| #(UTIMES  asn2a:ATT_ID)) )) {
               // Check for RAM variable - if present 
               // change tree - for example from:
               //     ( EXPR ( = ( * n1 ) ( + four four ) ) )
               // to  ( EXPR ( = n1 ( + four four ) ) )
+
              RefAST tr;
-             bool bram;
-             NcapVar *Nvar;
-
-             if(asn->getType()==UTIMES){
-               tr=asn->getFirstChild();
-               tr->setNextSibling(asn->getNextSibling());
-               bram=true;
-             } else { 
-               tr=asn; 
-               bram=false;
-             }
-             
-             // Die if attempting to create a RAM var 
-             // from an existing disk var   
-             Nvar= prs_arg->var_vtr.find(tr->getText());
+             NcapVar *Nvar;          
+
+             // deal with ATT_ID 
+             if(asn2a)  
+             { 
+               // remember tr and siblings and children are  duplicated here
+               tr=att2var(asn2a);   
+               tr->setNextSibling(asn2->getNextSibling());
+
+             } 
+             // must be VAR_ID 
+             else 
+             { 
+                  
+               tr=asn2->getFirstChild();
+               tr->setNextSibling(asn2->getNextSibling());
+
+               // Die if attempting to create a RAM var 
+               // from an existing disk var   
+                Nvar= prs_arg->var_vtr.find(tr->getText());
 
-             if(bram && tr->getType()==VAR_ID && Nvar && Nvar->flg_mem==false){
-              std::string serr;
-              serr= "It is impossible to recast disk variable: \"" + tr->getText() +"\" as a RAM variable.";
-              err_prn(fnc_nm,serr );       
-              }                
+                if(Nvar && Nvar->flg_mem==false)
+                {
+                  std::string serr;
+                  serr= "It is impossible to recast disk variable: \"" + tr->getText() +"\" as a RAM variable.";
+                  err_prn(fnc_nm,serr );       
+                
+                }                
+             }
 
              if(prs_arg->ntl_scn)
-               var=assign_ntl(tr,bram); 
+               var=assign_ntl(tr,true,bret); 
              else
-               var=assign(tr,bram);
+               var=assign(tr, true,bret);
                
-            }  
+        }
+   
+
+
+    | #(UTIMES attz:ATT_ID) {
+          var=out(att2var(attz));    
+    }
+
+
+
      | #(WHERE_ASSIGN wasn:. ) {
 
      }
-
+    
     //ternary Operator
      |   #(QUESTION var1=out qus:.) {
            bool br;
@@ -2491,49 +2506,58 @@ out returns [var_sct *var]
                char *cp_in;
                char *cp_out;  
                long idx;
+               long jdx;  
                long srt=lmt_vtr[0]->srt;
                long cnt=lmt_vtr[0]->cnt;
                long srd=lmt_vtr[0]->srd; 
+               long end=lmt_vtr[0]->end; 
                size_t slb_sz=nco_typ_lng(var_att->type); 
                 
                /* create output att */
-               var=ncap_sclr_var_mk(att_nm,var_att->type,true);                 
-               (void)ncap_att_stretch(var,cnt);     
-
-               cp_in=(char*)( var_att->val.vp); 
-               cp_in+= (ptrdiff_t)slb_sz*srt;
-               cp_out=(char*)var->val.vp; 
-                    
-               idx=0;
-  
-               while(idx++ < cnt )
-               { 
-                  memcpy(cp_out, cp_in, slb_sz);                   
-                  cp_in+=srd*slb_sz;
-                  cp_out+=slb_sz; 
-               } 
-               
-               // if type NC_STRING then realloc ragged array  
-               if(var_att->type==NC_STRING)
-               { 
-                 idx=0;  
-                 (void)cast_void_nctype((nc_type)NC_STRING,&var->val);                  
-
-                 while(idx<cnt)
-                   var->val.sngp[idx]=strdup(var->val.sngp[idx++]);    
+                 
+               if( var_att->type ==NC_STRING )  
+               {
+                   var=ncap_sclr_var_mk(att_nm,var_att->type,false);                
+                   var->val.vp=(void*)nco_malloc(slb_sz*cnt);       
+                   (void)cast_void_nctype((nc_type)NC_STRING,&var->val);                 
+                   (void)cast_void_nctype((nc_type)NC_STRING,&var_att->val);                  
+                   
+                   jdx=0;  
+                   for(idx=srt;idx<=end;idx+=srd)  
+                     var->val.sngp[jdx++]=strdup(var_att->val.sngp[idx]);
 
                 
                  (void)cast_nctype_void((nc_type)NC_STRING,&var->val); 
+                 (void)cast_nctype_void((nc_type)NC_STRING,&var_att->val); 
+               
+               }
+               else
+               {     
+                   var=ncap_sclr_var_mk(att_nm,var_att->type,true);                 
+                   (void)ncap_att_stretch(var,cnt);     
 
-               }  
+                   cp_in=(char*)( var_att->val.vp); 
+                   cp_in+= (ptrdiff_t)slb_sz*srt;
+                   cp_out=(char*)var->val.vp; 
+                   
+                   idx=0;
+                   
+                   while(idx++ < cnt )
+                   { 
+                       memcpy(cp_out, cp_in, slb_sz);                   
+                       cp_in+=srd*slb_sz;
+                       cp_out+=slb_sz; 
+                   } 
 
+               }               
 
             }
             else
             {
               err_prn(fnc_nm,"Hyperslab limits for attribute "+ att_nm+" doesn't include any elements");  
             }
-             
+
+            nco_lmt_free(lmt_vtr[0]);  
             nco_var_free(var_att);    
 
             attl_end: ; 
@@ -2544,24 +2568,41 @@ out returns [var_sct *var]
     // plain Variable
 	|   v:VAR_ID       
         { 
-
+          //dbg_prn(fnc_nm,"getting regular var in out "+v->getText());
+   
           var=prs_arg->ncap_var_init(v->getText(),true);
-          if(var== NULL){
-               if(prs_arg->ntl_scn){
-                 var=ncap_var_udf(v->getText().c_str());
-                 return var;
-               }else
-                 nco_exit(EXIT_FAILURE);
-          }
 
-          // apply cast only if sz >1 
-          if(bcst && var->sz >1)
-            var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);
-        } /* end action */
+         // initial scan 
+         if(prs_arg->ntl_scn)  
+         {  
+           if(var==NULL)     
+              var=ncap_var_udf(v->getText().c_str());
+           else if(bcst && var_cst && var->sz >1)      
+              var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);  
+         } 
+         // final scan  
+         else
+         { 
+           if(var==NULL)
+             err_prn(fnc_nm,"Could not read var "+ v->getText());
+  
+           if(bcst && var_cst && var->sz >1)          
+             if(var_cst->nbr_dim==var->nbr_dim)     
+               ncap_var_cnf_dmn(&var,&var_cst);
+             else    
+             {
+               var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);
+             }
+         }
+
+
+    } /* end action */
 
     // PLain attribute
     |   att:ATT_ID { 
-
+   
+            var=att_plain(att);  
+            /*  
             NcapVar *Nvar=NULL;
          
             if(prs_arg->ntl_scn)
@@ -2587,6 +2628,7 @@ out returns [var_sct *var]
             
             if(prs_arg->ntl_scn && var->val.vp !=NULL)
                 var->val.vp=(void*)nco_free(var->val.vp);
+            */
               
         }
 
@@ -2681,6 +2723,7 @@ out returns [var_sct *var]
 
 ;
 
+
 // Return a var or att WITHOUT applying a cast 
 // and checks that the operand is a valid Lvalue
 // ie that the var or att has NO children!!
@@ -2740,7 +2783,9 @@ NcapVar *Nvar;
             if(att->getFirstChild())
                 err_prn(fnc_nm,"Invalid Lvalue " +att->getText() );
 
+            var=att_plain(att);
 
+            /* 
             if(prs_arg->ntl_scn)
               Nvar=prs_arg->int_vtr.find(att->getText());
 
@@ -2763,10 +2808,104 @@ NcapVar *Nvar;
 
             if(prs_arg->ntl_scn && var->val.vp !=NULL)
                 var->val.vp=(void*)nco_free(var->val.vp);
+            */ 
+              
 
        }// end action    
 ;
 
+
+
+att_plain returns [var_sct *var]
+{
+const std::string fnc_nm("att_plain");
+var=NULL_CEWI; 
+string att_nm; 
+NcapVar *Nvar;
+   
+}
+
+: att:ATT_ID 
+      { 
+            // check "output"
+            NcapVar *Nvar=NULL;
+             
+            att_nm=att->getText();       
+
+            if(prs_arg->ntl_scn)
+              Nvar=prs_arg->int_vtr.find(att_nm);
+
+            if(Nvar==NULL) 
+              Nvar=prs_arg->var_vtr.find(att_nm);
+
+            var=NULL_CEWI;    
+            if(Nvar !=NULL)
+                var=nco_var_dpl(Nvar->var);
+            else    
+                var=ncap_att_init(att_nm,prs_arg);
+
+            if(prs_arg->ntl_scn==False  && var==NULL_CEWI )
+                err_prn(fnc_nm,"Unable to locate attribute " +att_nm+ " in input or output files.");
+
+            
+            // if att not found return undefined
+            if(prs_arg->ntl_scn && var==NULL_CEWI )
+                var=ncap_var_udf(att_nm.c_str());
+
+            if(prs_arg->ntl_scn && var->val.vp !=NULL)
+                var->val.vp=(void*)nco_free(var->val.vp);
+
+       }// end action    
+;
+
+
+
+
+
+// takes an ATT_ID pointer and converts it to a VAR_ID
+att2var returns [ RefAST tr ]
+{
+  var_sct *var=NULL_CEWI; 
+  NcapVar *Nvar;
+  std::string sn;
+  std::string att_nm;
+  std::string fnc_nm("att2var");
+
+}
+
+: (att:ATT_ID) 
+   {
+    /* sn can be empty on 1st Parse but not 2nd */
+   att_nm=att->getText();
+   
+   if(nco_dbg_lvl_get() >= nco_dbg_scl) 
+      dbg_prn(fnc_nm,"att_nm="+att_nm);
+       
+    sn=ncap_att2var(prs_arg,att_nm); 
+   
+    if(prs_arg->ntl_scn && sn.empty())     
+    {
+       sn="_empty_"+att_nm;   
+       var=ncap_var_udf(sn.c_str());
+       Nvar=new NcapVar(var);
+       prs_arg->int_vtr.push_ow(Nvar);            
+    }
+    
+
+    tr=nco_dupList(att);
+    
+    if(sn.find('@') != std::string::npos)
+      tr->setType(ATT_ID);       
+    else
+      tr->setType(VAR_ID);       
+
+    tr->setText(sn);
+
+    }
+;
+
+
+
 value_list returns [var_sct *var]
 {
 const std::string fnc_nm("value_list");
@@ -3384,7 +3523,7 @@ var=NULL_CEWI;
                var=nco_var_cnf_typ(var_rhs->type,var);
                 
                // apply LHS cast if necessary 
-               if(var->sz>1 && bcst) 
+               if(var->sz>1 && bcst && var_cst) 
                  var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);
               }else{
                 var=ncap_var_udf("~rhs_undefined");             
@@ -3504,7 +3643,7 @@ var=NULL_CEWI;
               /* Casting a hyperslab --this makes my brain  hurt!!! 
               if the var is already the correct size then do nothing 
                what not even dimension reordering ?  */  
-              if(bcst && var1->sz != var_cst->sz)
+              if(bcst && var_cst &&  var1->sz != var_cst->sz)
                  var1=ncap_cst_do(var1,var_cst,prs_arg->ntl_scn);
               
               var=var1;
diff --git a/src/nco++/ncoLexer.cpp b/src/nco++/ncoLexer.cpp
index 627122c..050a3e2 100644
--- a/src/nco++/ncoLexer.cpp
+++ b/src/nco++/ncoLexer.cpp
@@ -30,15 +30,14 @@ ncoLexer::ncoLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& state)
 
 void ncoLexer::initLiterals()
 {
-	literals["<<"] = 96;
-	literals["for"] = 49;
-	literals["print"] = 44;
+	literals["<<"] = 95;
+	literals["for"] = 46;
 	literals["defdimunlim"] = 32;
 	literals["where"] = 42;
 	literals["elsewhere"] = 43;
 	literals["continue"] = 39;
 	literals["while"] = 37;
-	literals[">>"] = 97;
+	literals[">>"] = 96;
 	literals["break"] = 38;
 	literals["if"] = 40;
 	literals["else"] = 41;
@@ -1312,6 +1311,11 @@ void ncoLexer::mVAR_NM_QT(bool _createToken) {
 			match(':' /* charlit */ );
 			break;
 		}
+		case 0x20 /* ' ' */ :
+		{
+			match(' ' /* charlit */ );
+			break;
+		}
 		default:
 		{
 			if ( _cnt146>=1 ) { goto _loop146; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
@@ -1335,7 +1339,7 @@ void ncoLexer::mBLASTOUT(bool _createToken) {
 	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
 	
 	matchNot(EOF/*_CHAR*/);
-#line 455 "ncoGrammer.g"
+#line 457 "ncoGrammer.g"
 	
 	// blast out of lexer & parser
 	// Can't use RecognitionException() as 
@@ -1350,7 +1354,7 @@ void ncoLexer::mBLASTOUT(bool _createToken) {
 	ANTLR_USE_NAMESPACE(antlr)RecognitionException re(os.str());
 	throw  ANTLR_USE_NAMESPACE(antlr)TokenStreamRecognitionException(re);
 	
-#line 1354 "ncoLexer.cpp"
+#line 1358 "ncoLexer.cpp"
 	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
 	   _token = makeToken(_ttype);
 	   _token->setText(text.substr(_begin, text.length()-_begin));
@@ -1392,7 +1396,7 @@ void ncoLexer::mUNUSED_OPS(bool _createToken) {
 	}
 	}
 	}
-#line 471 "ncoGrammer.g"
+#line 473 "ncoGrammer.g"
 	
 	
 	ostringstream os;
@@ -1402,7 +1406,7 @@ void ncoLexer::mUNUSED_OPS(bool _createToken) {
 	ANTLR_USE_NAMESPACE(antlr)RecognitionException re(os.str());
 	throw  ANTLR_USE_NAMESPACE(antlr)TokenStreamRecognitionException(re);
 	
-#line 1406 "ncoLexer.cpp"
+#line 1410 "ncoLexer.cpp"
 	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
 	   _token = makeToken(_ttype);
 	   _token->setText(text.substr(_begin, text.length()-_begin));
@@ -1426,9 +1430,9 @@ void ncoLexer::mWS(bool _createToken) {
 	case 0x9 /* '\t' */ :
 	{
 		match('\t' /* charlit */ );
-#line 484 "ncoGrammer.g"
+#line 486 "ncoGrammer.g"
 		tab();
-#line 1432 "ncoLexer.cpp"
+#line 1436 "ncoLexer.cpp"
 		break;
 	}
 	case 0xc /* '\14' */ :
@@ -1439,9 +1443,9 @@ void ncoLexer::mWS(bool _createToken) {
 	case 0xa /* '\n' */ :
 	{
 		match('\n' /* charlit */ );
-#line 484 "ncoGrammer.g"
+#line 486 "ncoGrammer.g"
 		newline();
-#line 1445 "ncoLexer.cpp"
+#line 1449 "ncoLexer.cpp"
 		break;
 	}
 	default:
@@ -1450,9 +1454,9 @@ void ncoLexer::mWS(bool _createToken) {
 	}
 	}
 	}
-#line 485 "ncoGrammer.g"
+#line 487 "ncoGrammer.g"
 	_ttype = antlr::Token::SKIP;
-#line 1456 "ncoLexer.cpp"
+#line 1460 "ncoLexer.cpp"
 	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
 	   _token = makeToken(_ttype);
 	   _token->setText(text.substr(_begin, text.length()-_begin));
@@ -1480,9 +1484,9 @@ void ncoLexer::mCXX_COMMENT(bool _createToken) {
 	_loop154:;
 	} // ( ... )*
 	match('\n' /* charlit */ );
-#line 490 "ncoGrammer.g"
+#line 492 "ncoGrammer.g"
 	_ttype = antlr::Token::SKIP; newline();
-#line 1486 "ncoLexer.cpp"
+#line 1490 "ncoLexer.cpp"
 	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
 	   _token = makeToken(_ttype);
 	   _token->setText(text.substr(_begin, text.length()-_begin));
@@ -1521,9 +1525,9 @@ void ncoLexer::mC_COMMENT(bool _createToken) {
 			}
 			}
 			}
-#line 497 "ncoGrammer.g"
+#line 499 "ncoGrammer.g"
 			newline();
-#line 1527 "ncoLexer.cpp"
+#line 1531 "ncoLexer.cpp"
 		}
 		else if ((_tokenSet_4.member(LA(1)))) {
 			{
@@ -1538,9 +1542,9 @@ void ncoLexer::mC_COMMENT(bool _createToken) {
 	_loop159:;
 	} // ( ... )*
 	match("*/");
-#line 501 "ncoGrammer.g"
+#line 503 "ncoGrammer.g"
 	_ttype = antlr::Token::SKIP;
-#line 1544 "ncoLexer.cpp"
+#line 1548 "ncoLexer.cpp"
 	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
 	   _token = makeToken(_ttype);
 	   _token->setText(text.substr(_begin, text.length()-_begin));
@@ -1577,9 +1581,9 @@ void ncoLexer::mNUMBER_DOT(bool _createToken) {
 	}
 	
 	}
-#line 508 "ncoGrammer.g"
+#line 510 "ncoGrammer.g"
 	_ttype = NCAP_DOUBLE;
-#line 1583 "ncoLexer.cpp"
+#line 1587 "ncoLexer.cpp"
 	{
 	switch ( LA(1)) {
 	case 0x44 /* 'D' */ :
@@ -1603,9 +1607,9 @@ void ncoLexer::mNUMBER_DOT(bool _createToken) {
 		}
 		}
 		}
-#line 509 "ncoGrammer.g"
+#line 511 "ncoGrammer.g"
 		_ttype = NCAP_DOUBLE;
-#line 1609 "ncoLexer.cpp"
+#line 1613 "ncoLexer.cpp"
 		break;
 	}
 	case 0x46 /* 'F' */ :
@@ -1629,9 +1633,9 @@ void ncoLexer::mNUMBER_DOT(bool _createToken) {
 		}
 		}
 		}
-#line 510 "ncoGrammer.g"
+#line 512 "ncoGrammer.g"
 		_ttype = NCAP_FLOAT;
-#line 1635 "ncoLexer.cpp"
+#line 1639 "ncoLexer.cpp"
 		break;
 	}
 	case 0x4c /* 'L' */ :
@@ -1655,9 +1659,9 @@ void ncoLexer::mNUMBER_DOT(bool _createToken) {
 		}
 		}
 		}
-#line 511 "ncoGrammer.g"
+#line 513 "ncoGrammer.g"
 		_ttype = NCAP_DOUBLE;
-#line 1661 "ncoLexer.cpp"
+#line 1665 "ncoLexer.cpp"
 		break;
 	}
 	default:
@@ -1692,9 +1696,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 	}
 	_loop170:;
 	}  // ( ... )+
-#line 516 "ncoGrammer.g"
+#line 518 "ncoGrammer.g"
 	_ttype = NCAP_INT;
-#line 1698 "ncoLexer.cpp"
+#line 1702 "ncoLexer.cpp"
 	{
 	switch ( LA(1)) {
 	case 0x2e /* '.' */ :
@@ -1747,9 +1751,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 		
 		}
 		}
-#line 517 "ncoGrammer.g"
+#line 519 "ncoGrammer.g"
 		_ttype = NCAP_DOUBLE;
-#line 1753 "ncoLexer.cpp"
+#line 1757 "ncoLexer.cpp"
 		break;
 	}
 	case 0x45 /* 'E' */ :
@@ -1758,9 +1762,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 		{
 		mXPN(false);
 		}
-#line 518 "ncoGrammer.g"
+#line 520 "ncoGrammer.g"
 		_ttype = NCAP_DOUBLE;
-#line 1764 "ncoLexer.cpp"
+#line 1768 "ncoLexer.cpp"
 		break;
 	}
 	case 0x53 /* 'S' */ :
@@ -1784,9 +1788,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 		}
 		}
 		}
-#line 520 "ncoGrammer.g"
+#line 522 "ncoGrammer.g"
 		_ttype = NCAP_SHORT;
-#line 1790 "ncoLexer.cpp"
+#line 1794 "ncoLexer.cpp"
 		break;
 	}
 	case 0x42 /* 'B' */ :
@@ -1810,9 +1814,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 		}
 		}
 		}
-#line 521 "ncoGrammer.g"
+#line 523 "ncoGrammer.g"
 		_ttype = NCAP_BYTE;
-#line 1816 "ncoLexer.cpp"
+#line 1820 "ncoLexer.cpp"
 		break;
 	}
 	default:
@@ -1835,9 +1839,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 			}
 			}
 			}
-#line 526 "ncoGrammer.g"
+#line 528 "ncoGrammer.g"
 			_ttype = NCAP_UINT64;
-#line 1841 "ncoLexer.cpp"
+#line 1845 "ncoLexer.cpp"
 		}
 		else if ((LA(1) == 0x55 /* 'U' */  || LA(1) == 0x75 /* 'u' */ ) && (LA(2) == 0x42 /* 'B' */  || LA(2) == 0x62 /* 'b' */ )) {
 			{
@@ -1858,9 +1862,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 			}
 			}
 			}
-#line 522 "ncoGrammer.g"
+#line 524 "ncoGrammer.g"
 			_ttype = NCAP_UBYTE;
-#line 1864 "ncoLexer.cpp"
+#line 1868 "ncoLexer.cpp"
 		}
 		else if ((LA(1) == 0x55 /* 'U' */  || LA(1) == 0x75 /* 'u' */ ) && (LA(2) == 0x53 /* 'S' */  || LA(2) == 0x73 /* 's' */ )) {
 			{
@@ -1881,9 +1885,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 			}
 			}
 			}
-#line 523 "ncoGrammer.g"
+#line 525 "ncoGrammer.g"
 			_ttype = NCAP_USHORT;
-#line 1887 "ncoLexer.cpp"
+#line 1891 "ncoLexer.cpp"
 		}
 		else if ((LA(1) == 0x4c /* 'L' */  || LA(1) == 0x6c /* 'l' */ ) && (LA(2) == 0x4c /* 'L' */  || LA(2) == 0x6c /* 'l' */ )) {
 			{
@@ -1904,9 +1908,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 			}
 			}
 			}
-#line 525 "ncoGrammer.g"
+#line 527 "ncoGrammer.g"
 			_ttype = NCAP_INT64;
-#line 1910 "ncoLexer.cpp"
+#line 1914 "ncoLexer.cpp"
 		}
 		else if ((LA(1) == 0x4c /* 'L' */  || LA(1) == 0x6c /* 'l' */ ) && (true)) {
 			{
@@ -1927,9 +1931,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 			}
 			}
 			}
-#line 519 "ncoGrammer.g"
+#line 521 "ncoGrammer.g"
 			_ttype = NCAP_INT;
-#line 1933 "ncoLexer.cpp"
+#line 1937 "ncoLexer.cpp"
 		}
 		else if ((LA(1) == 0x55 /* 'U' */  || LA(1) == 0x75 /* 'u' */ ) && (true) && (true)) {
 			{
@@ -1950,9 +1954,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 			}
 			
 			}
-#line 524 "ncoGrammer.g"
+#line 526 "ncoGrammer.g"
 			_ttype = NCAP_UINT;
-#line 1956 "ncoLexer.cpp"
+#line 1960 "ncoLexer.cpp"
 		}
 		else {
 		}
@@ -1981,9 +1985,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 		}
 		}
 		}
-#line 528 "ncoGrammer.g"
+#line 530 "ncoGrammer.g"
 		_ttype = NCAP_FLOAT;
-#line 1987 "ncoLexer.cpp"
+#line 1991 "ncoLexer.cpp"
 		break;
 	}
 	case 0x44 /* 'D' */ :
@@ -2007,9 +2011,9 @@ void ncoLexer::mNUMBER(bool _createToken) {
 		}
 		}
 		}
-#line 529 "ncoGrammer.g"
+#line 531 "ncoGrammer.g"
 		_ttype = NCAP_DOUBLE;
-#line 2013 "ncoLexer.cpp"
+#line 2017 "ncoLexer.cpp"
 		break;
 	}
 	default:
@@ -2115,9 +2119,9 @@ void ncoLexer::mVAR_ATT(bool _createToken) {
 	}
 	_loop193:;
 	} // ( ... )*
-#line 537 "ncoGrammer.g"
+#line 541 "ncoGrammer.g"
 	
-	// try to intelligently guess the type to avoid un-necessary function search  
+	// try to intelligently guess the type to avoid un-necessary function search    
 	bool bDoSearch;
 	switch( LA(1) ){
 	case ' ': 
@@ -2152,7 +2156,7 @@ void ncoLexer::mVAR_ATT(bool _createToken) {
 	}             
 	} 
 	
-#line 2156 "ncoLexer.cpp"
+#line 2160 "ncoLexer.cpp"
 	{
 	if ((LA(1) == 0x40 /* '@' */ )) {
 		match('@' /* charlit */ );
@@ -2241,9 +2245,9 @@ void ncoLexer::mVAR_ATT(bool _createToken) {
 		}
 		_loop197:;
 		} // ( ... )*
-#line 573 "ncoGrammer.g"
+#line 577 "ncoGrammer.g"
 		_ttype = ATT_ID;
-#line 2247 "ncoLexer.cpp"
+#line 2251 "ncoLexer.cpp"
 	}
 	else {
 	}
@@ -2269,18 +2273,18 @@ void ncoLexer::mVAR_ATT_QT(bool _createToken) {
 	text.erase(_saveIndex);
 	}
 	mVAR_NM_QT(false);
-#line 579 "ncoGrammer.g"
+#line 583 "ncoGrammer.g"
 	_ttype = VAR_ID;
-#line 2275 "ncoLexer.cpp"
+#line 2279 "ncoLexer.cpp"
 	{
 	switch ( LA(1)) {
 	case 0x40 /* '@' */ :
 	{
 		match('@' /* charlit */ );
 		mVAR_NM_QT(false);
-#line 580 "ncoGrammer.g"
+#line 584 "ncoGrammer.g"
 		_ttype = ATT_ID;
-#line 2284 "ncoLexer.cpp"
+#line 2288 "ncoLexer.cpp"
 		break;
 	}
 	case 0x27 /* '\'' */ :
@@ -2397,9 +2401,9 @@ void ncoLexer::mATT_ID(bool _createToken) {
 	}
 	_loop205:;
 	} // ( ... )*
-#line 585 "ncoGrammer.g"
+#line 589 "ncoGrammer.g"
 	string an=text.substr(_begin,text.length()-_begin);{ text.erase(_begin); text += "global"+an; };_ttype = ATT_ID;
-#line 2403 "ncoLexer.cpp"
+#line 2407 "ncoLexer.cpp"
 	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
 	   _token = makeToken(_ttype);
 	   _token->setText(text.substr(_begin, text.length()-_begin));
@@ -2420,9 +2424,9 @@ void ncoLexer::mSTR_ATT_QT(bool _createToken) {
 	}
 	match('@' /* charlit */ );
 	mVAR_NM_QT(false);
-#line 590 "ncoGrammer.g"
+#line 594 "ncoGrammer.g"
 	_ttype = STR_ATT_QT;
-#line 2426 "ncoLexer.cpp"
+#line 2430 "ncoLexer.cpp"
 	{
 	_saveIndex = text.length();
 	match('\'' /* charlit */ );
@@ -2451,9 +2455,9 @@ void ncoLexer::mDIM_QT(bool _createToken) {
 	match('$' /* charlit */ );
 	text.erase(_saveIndex);
 	mVAR_NM_QT(false);
-#line 597 "ncoGrammer.g"
+#line 601 "ncoGrammer.g"
 	_ttype = DIM_ID;
-#line 2457 "ncoLexer.cpp"
+#line 2461 "ncoLexer.cpp"
 	}
 	{
 	_saveIndex = text.length();
@@ -2465,9 +2469,9 @@ void ncoLexer::mDIM_QT(bool _createToken) {
 		_saveIndex = text.length();
 		match(".size");
 		text.erase(_saveIndex);
-#line 599 "ncoGrammer.g"
+#line 603 "ncoGrammer.g"
 		_ttype = DIM_ID_SIZE;
-#line 2471 "ncoLexer.cpp"
+#line 2475 "ncoLexer.cpp"
 	}
 	else {
 	}
@@ -2574,17 +2578,17 @@ void ncoLexer::mDIM_VAL(bool _createToken) {
 	}
 	_loop217:;
 	} // ( ... )*
-#line 604 "ncoGrammer.g"
+#line 608 "ncoGrammer.g"
 	_ttype = DIM_ID;
-#line 2580 "ncoLexer.cpp"
+#line 2584 "ncoLexer.cpp"
 	{
 	if ((LA(1) == 0x2e /* '.' */ )) {
 		_saveIndex = text.length();
 		match(".size");
 		text.erase(_saveIndex);
-#line 606 "ncoGrammer.g"
+#line 610 "ncoGrammer.g"
 		_ttype = DIM_ID_SIZE;
-#line 2588 "ncoLexer.cpp"
+#line 2592 "ncoLexer.cpp"
 	}
 	else {
 	}
@@ -2653,17 +2657,17 @@ void ncoLexer::mNSTRING(bool _createToken) {
 	_saveIndex = text.length();
 	match('\"' /* charlit */ );
 	text.erase(_saveIndex);
-#line 619 "ncoGrammer.g"
+#line 624 "ncoGrammer.g"
 	_ttype = NSTRING;
-#line 2659 "ncoLexer.cpp"
+#line 2663 "ncoLexer.cpp"
 	{
 	if ((LA(1) == 0x73 /* 's' */ )) {
 		_saveIndex = text.length();
 		match('s' /* charlit */ );
 		text.erase(_saveIndex);
-#line 620 "ncoGrammer.g"
+#line 625 "ncoGrammer.g"
 		_ttype = N4STRING;
-#line 2667 "ncoLexer.cpp"
+#line 2671 "ncoLexer.cpp"
 	}
 	else {
 	}
@@ -2706,7 +2710,7 @@ void ncoLexer::mINCLUDE(bool _createToken) {
 	}
 	mNSTRING(true);
 	f=_returnToken;
-#line 625 "ncoGrammer.g"
+#line 630 "ncoGrammer.g"
 	
 			// ANTLR_USING_NAMESPACE(std)
 			// create lexer to handle include
@@ -2736,7 +2740,7 @@ void ncoLexer::mINCLUDE(bool _createToken) {
 			// of the new instance of this lexer.
 			selector.retry(); // throws TokenStreamRetryException
 			
-#line 2740 "ncoLexer.cpp"
+#line 2744 "ncoLexer.cpp"
 	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
 	   _token = makeToken(_ttype);
 	   _token->setText(text.substr(_begin, text.length()-_begin));
@@ -2749,33 +2753,33 @@ void ncoLexer::mINCLUDE(bool _createToken) {
 const unsigned long ncoLexer::_tokenSet_0_data_[] = { 0UL, 96UL, 1073741824UL, 268435456UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // % & ^ 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoLexer::_tokenSet_0(_tokenSet_0_data_,10);
-const unsigned long ncoLexer::_tokenSet_1_data_[] = { 0UL, 134179584UL, 2281701374UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
-// ( ) + - . 0 1 2 3 4 5 6 7 8 9 : A B C D E F G H I J K L M N O P Q R 
-// S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t u 
+const unsigned long ncoLexer::_tokenSet_1_data_[] = { 0UL, 134179585UL, 2281701374UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+//   ( ) + - . 0 1 2 3 4 5 6 7 8 9 : A B C D E F G H I J K L M N O P Q 
+// R S T U V W X Y Z _ a b c d e f g h i j k l m n o p q r s t 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoLexer::_tokenSet_1(_tokenSet_1_data_,10);
 const unsigned long ncoLexer::_tokenSet_2_data_[] = { 0UL, 0UL, 2281701374UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ a b c d e f g 
-// h i j k l m n o p q r s t u 
+// h i j k l m n o p q r s t 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoLexer::_tokenSet_2(_tokenSet_2_data_,10);
 const unsigned long ncoLexer::_tokenSet_3_data_[] = { 4294966271UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xd 0xe 0xf 0x10 0x11 
 // 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 
 //   ! \" # $ % & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 
 // A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ 0x5c ] ^ _ ` a 
-// b c d e f g h i j k l m n o p q r s t u 
+// b c d e f g h i j k l m n o p q r s t 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoLexer::_tokenSet_3(_tokenSet_3_data_,16);
 const unsigned long ncoLexer::_tokenSet_4_data_[] = { 4294958079UL, 4294966271UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xe 0xf 0x10 0x11 0x12 
 // 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f   ! 
 // \" # $ % & \' ( ) + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C 
 // D E F G H I J K L M N O P Q R S T U V W X Y Z [ 0x5c ] ^ _ ` a b c d 
-// e f g h i j k l m n o p q r s t u 
+// e f g h i j k l m n o p q r s t 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoLexer::_tokenSet_4(_tokenSet_4_data_,16);
 const unsigned long ncoLexer::_tokenSet_5_data_[] = { 4294966271UL, 4294967291UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xd 0xe 0xf 0x10 0x11 
 // 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 
 //   ! # $ % & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B 
 // C D E F G H I J K L M N O P Q R S T U V W X Y Z [ 0x5c ] ^ _ ` a b c 
-// d e f g h i j k l m n o p q r s t u 
+// d e f g h i j k l m n o p q r s t 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoLexer::_tokenSet_5(_tokenSet_5_data_,16);
 
diff --git a/src/nco++/ncoLexer.hpp b/src/nco++/ncoLexer.hpp
index 0c49f69..f932894 100644
--- a/src/nco++/ncoLexer.hpp
+++ b/src/nco++/ncoLexer.hpp
@@ -2,7 +2,7 @@
 #define INC_ncoLexer_hpp_
 
 #include <antlr/config.hpp>
-/* $ANTLR 2.7.7 (20130428): "ncoGrammer.g" -> "ncoLexer.hpp"$ */
+/* $ANTLR 2.7.7 (20151030): "ncoGrammer.g" -> "ncoLexer.hpp"$ */
 #include <antlr/CommonToken.hpp>
 #include <antlr/InputBuffer.hpp>
 #include <antlr/BitSet.hpp>
diff --git a/src/nco++/ncoParser.cpp b/src/nco++/ncoParser.cpp
index afc88c7..2dd1ed0 100644
--- a/src/nco++/ncoParser.cpp
+++ b/src/nco++/ncoParser.cpp
@@ -1,4 +1,4 @@
-/* $ANTLR 2.7.7 (20130428): "ncoGrammer.g" -> "ncoParser.cpp"$ */
+/* $ANTLR 2.7.7 (20151030): "ncoGrammer.g" -> "ncoParser.cpp"$ */
 #include "ncoParser.hpp"
 #include <antlr/NoViableAltException.hpp>
 #include <antlr/SemanticException.hpp>
@@ -67,13 +67,13 @@ void ncoParser::statement() {
 	case NSTRING:
 	case VAR_ID:
 	case ATT_ID:
+	case TIMES:
 	case FUNC:
 	case INC:
 	case DEC:
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
 	case NCAP_INT:
@@ -291,71 +291,6 @@ void ncoParser::statement() {
 		statement_AST = currentAST.root;
 		break;
 	}
-	case PRINT:
-	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp24_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp24_AST = astFactory->create(LT(1));
-		astFactory->makeASTRoot(currentAST, tmp24_AST);
-		match(PRINT);
-		match(LPAREN);
-		{
-		switch ( LA(1)) {
-		case VAR_ID:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp26_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp26_AST = astFactory->create(LT(1));
-			astFactory->addASTChild(currentAST, tmp26_AST);
-			match(VAR_ID);
-			break;
-		}
-		case ATT_ID:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp27_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp27_AST = astFactory->create(LT(1));
-			astFactory->addASTChild(currentAST, tmp27_AST);
-			match(ATT_ID);
-			break;
-		}
-		case NSTRING:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp28_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp28_AST = astFactory->create(LT(1));
-			astFactory->addASTChild(currentAST, tmp28_AST);
-			match(NSTRING);
-			break;
-		}
-		default:
-		{
-			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
-		}
-		}
-		}
-		{
-		switch ( LA(1)) {
-		case COMMA:
-		{
-			match(COMMA);
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp30_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp30_AST = astFactory->create(LT(1));
-			astFactory->addASTChild(currentAST, tmp30_AST);
-			match(NSTRING);
-			break;
-		}
-		case RPAREN:
-		{
-			break;
-		}
-		default:
-		{
-			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
-		}
-		}
-		}
-		match(RPAREN);
-		match(SEMI);
-		statement_AST = currentAST.root;
-		break;
-	}
 	case LCURL:
 	{
 		block();
@@ -391,9 +326,9 @@ void ncoParser::for_stmt() {
 	ANTLR_USE_NAMESPACE(antlr)RefAST e3_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST st_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	
-	ANTLR_USE_NAMESPACE(antlr)RefAST tmp33_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	tmp33_AST = astFactory->create(LT(1));
-	astFactory->makeASTRoot(currentAST, tmp33_AST);
+	ANTLR_USE_NAMESPACE(antlr)RefAST tmp24_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	tmp24_AST = astFactory->create(LT(1));
+	astFactory->makeASTRoot(currentAST, tmp24_AST);
 	match(FOR);
 	match(LPAREN);
 	{
@@ -402,13 +337,13 @@ void ncoParser::for_stmt() {
 	case NSTRING:
 	case VAR_ID:
 	case ATT_ID:
+	case TIMES:
 	case FUNC:
 	case INC:
 	case DEC:
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
 	case NCAP_INT:
@@ -444,13 +379,13 @@ void ncoParser::for_stmt() {
 	case NSTRING:
 	case VAR_ID:
 	case ATT_ID:
+	case TIMES:
 	case FUNC:
 	case INC:
 	case DEC:
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
 	case NCAP_INT:
@@ -486,13 +421,13 @@ void ncoParser::for_stmt() {
 	case NSTRING:
 	case VAR_ID:
 	case ATT_ID:
+	case TIMES:
 	case FUNC:
 	case INC:
 	case DEC:
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
 	case NCAP_INT:
@@ -542,17 +477,17 @@ void ncoParser::block() {
 			astFactory->addASTChild( currentAST, returnAST );
 		}
 		else {
-			goto _loop13;
+			goto _loop11;
 		}
 		
 	}
-	_loop13:;
+	_loop11:;
 	} // ( ... )*
 	match(RCURL);
 	block_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 140 "ncoGrammer.g"
+#line 138 "ncoGrammer.g"
 	block_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(BLOCK,"block"))->add(block_AST)));
-#line 556 "ncoParser.cpp"
+#line 491 "ncoParser.cpp"
 	currentAST.root = block_AST;
 	if ( block_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		block_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -575,13 +510,13 @@ void ncoParser::lmt() {
 	case NSTRING:
 	case VAR_ID:
 	case ATT_ID:
+	case TIMES:
 	case FUNC:
 	case INC:
 	case DEC:
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
 	case NCAP_INT:
@@ -614,9 +549,9 @@ void ncoParser::lmt() {
 	{ // ( ... )*
 	for (;;) {
 		if ((LA(1) == COLON)) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp40_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp40_AST = astFactory->create(LT(1));
-			astFactory->addASTChild(currentAST, tmp40_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp31_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp31_AST = astFactory->create(LT(1));
+			astFactory->addASTChild(currentAST, tmp31_AST);
 			match(COLON);
 			{
 			switch ( LA(1)) {
@@ -624,13 +559,13 @@ void ncoParser::lmt() {
 			case NSTRING:
 			case VAR_ID:
 			case ATT_ID:
+			case TIMES:
 			case FUNC:
 			case INC:
 			case DEC:
 			case LNOT:
 			case PLUS:
 			case MINUS:
-			case TIMES:
 			case NCAP_FLOAT:
 			case NCAP_DOUBLE:
 			case NCAP_INT:
@@ -662,16 +597,16 @@ void ncoParser::lmt() {
 			}
 		}
 		else {
-			goto _loop22;
+			goto _loop20;
 		}
 		
 	}
-	_loop22:;
+	_loop20:;
 	} // ( ... )*
 	lmt_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 153 "ncoGrammer.g"
+#line 151 "ncoGrammer.g"
 	lmt_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(LMT,"lmt"))->add(lmt_AST)));
-#line 675 "ncoParser.cpp"
+#line 610 "ncoParser.cpp"
 	currentAST.root = lmt_AST;
 	if ( lmt_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		lmt_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -699,17 +634,17 @@ void ncoParser::lmt_list() {
 			astFactory->addASTChild( currentAST, returnAST );
 		}
 		else {
-			goto _loop25;
+			goto _loop23;
 		}
 		
 	}
-	_loop25:;
+	_loop23:;
 	} // ( ... )*
 	match(RPAREN);
 	lmt_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 157 "ncoGrammer.g"
+#line 155 "ncoGrammer.g"
 	lmt_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(LMT_LIST,"lmt_list"))->add(lmt_list_AST)));
-#line 713 "ncoParser.cpp"
+#line 648 "ncoParser.cpp"
 	currentAST.root = lmt_list_AST;
 	if ( lmt_list_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		lmt_list_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -731,20 +666,25 @@ void ncoParser::dmn_list_p() {
 	switch ( LA(1)) {
 	case VAR_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp45_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp45_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp45_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp36_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp36_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp36_AST);
 		match(VAR_ID);
 		break;
 	}
 	case DIM_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp46_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp46_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp46_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp37_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp37_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp37_AST);
 		match(DIM_ID);
 		break;
 	}
+	case COMMA:
+	case RSQUARE:
+	{
+		break;
+	}
 	default:
 	{
 		throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
@@ -759,17 +699,17 @@ void ncoParser::dmn_list_p() {
 			switch ( LA(1)) {
 			case VAR_ID:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp48_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp48_AST = astFactory->create(LT(1));
-				astFactory->addASTChild(currentAST, tmp48_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp39_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp39_AST = astFactory->create(LT(1));
+				astFactory->addASTChild(currentAST, tmp39_AST);
 				match(VAR_ID);
 				break;
 			}
 			case DIM_ID:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp49_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp49_AST = astFactory->create(LT(1));
-				astFactory->addASTChild(currentAST, tmp49_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp40_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp40_AST = astFactory->create(LT(1));
+				astFactory->addASTChild(currentAST, tmp40_AST);
 				match(DIM_ID);
 				break;
 			}
@@ -781,17 +721,17 @@ void ncoParser::dmn_list_p() {
 			}
 		}
 		else {
-			goto _loop30;
+			goto _loop28;
 		}
 		
 	}
-	_loop30:;
+	_loop28:;
 	} // ( ... )*
 	match(RSQUARE);
 	dmn_list_p_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 165 "ncoGrammer.g"
+#line 163 "ncoGrammer.g"
 	dmn_list_p_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(DMN_LIST_P,"dmn_list_p"))->add(dmn_list_p_AST)));
-#line 795 "ncoParser.cpp"
+#line 735 "ncoParser.cpp"
 	currentAST.root = dmn_list_p_AST;
 	if ( dmn_list_p_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		dmn_list_p_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -809,31 +749,33 @@ void ncoParser::dmn_list() {
 	ANTLR_USE_NAMESPACE(antlr)RefAST dmn_list_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	
 	match(LPAREN);
-	ANTLR_USE_NAMESPACE(antlr)RefAST tmp52_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	tmp52_AST = astFactory->create(LT(1));
-	astFactory->addASTChild(currentAST, tmp52_AST);
+	{
+	ANTLR_USE_NAMESPACE(antlr)RefAST tmp43_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	tmp43_AST = astFactory->create(LT(1));
+	astFactory->addASTChild(currentAST, tmp43_AST);
 	match(DIM_ID);
+	}
 	{ // ( ... )*
 	for (;;) {
 		if ((LA(1) == COMMA)) {
 			match(COMMA);
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp54_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp54_AST = astFactory->create(LT(1));
-			astFactory->addASTChild(currentAST, tmp54_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp45_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp45_AST = astFactory->create(LT(1));
+			astFactory->addASTChild(currentAST, tmp45_AST);
 			match(DIM_ID);
 		}
 		else {
-			goto _loop33;
+			goto _loop32;
 		}
 		
 	}
-	_loop33:;
+	_loop32:;
 	} // ( ... )*
 	match(RPAREN);
 	dmn_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 170 "ncoGrammer.g"
+#line 168 "ncoGrammer.g"
 	dmn_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(DMN_LIST,"dmn_list"))->add(dmn_list_AST)));
-#line 837 "ncoParser.cpp"
+#line 779 "ncoParser.cpp"
 	currentAST.root = dmn_list_AST;
 	if ( dmn_list_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		dmn_list_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -855,17 +797,17 @@ void ncoParser::dmn_arg_list() {
 	switch ( LA(1)) {
 	case DIM_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp57_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp57_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp57_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp48_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp48_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp48_AST);
 		match(DIM_ID);
 		break;
 	}
 	case DIM_MTD_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp58_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp58_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp58_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp49_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp49_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp49_AST);
 		match(DIM_MTD_ID);
 		break;
 	}
@@ -883,17 +825,17 @@ void ncoParser::dmn_arg_list() {
 			switch ( LA(1)) {
 			case DIM_ID:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp60_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp60_AST = astFactory->create(LT(1));
-				astFactory->addASTChild(currentAST, tmp60_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp51_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp51_AST = astFactory->create(LT(1));
+				astFactory->addASTChild(currentAST, tmp51_AST);
 				match(DIM_ID);
 				break;
 			}
 			case DIM_MTD_ID:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp61_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp61_AST = astFactory->create(LT(1));
-				astFactory->addASTChild(currentAST, tmp61_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp52_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp52_AST = astFactory->create(LT(1));
+				astFactory->addASTChild(currentAST, tmp52_AST);
 				match(DIM_MTD_ID);
 				break;
 			}
@@ -905,17 +847,17 @@ void ncoParser::dmn_arg_list() {
 			}
 		}
 		else {
-			goto _loop38;
+			goto _loop37;
 		}
 		
 	}
-	_loop38:;
+	_loop37:;
 	} // ( ... )*
 	match(DIVIDE);
 	dmn_arg_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 176 "ncoGrammer.g"
+#line 174 "ncoGrammer.g"
 	dmn_arg_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(DMN_ARG_LIST,"dmn_arg_list"))->add(dmn_arg_list_AST)));
-#line 919 "ncoParser.cpp"
+#line 861 "ncoParser.cpp"
 	currentAST.root = dmn_arg_list_AST;
 	if ( dmn_arg_list_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		dmn_arg_list_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -943,17 +885,17 @@ void ncoParser::value_list() {
 			astFactory->addASTChild( currentAST, returnAST );
 		}
 		else {
-			goto _loop41;
+			goto _loop40;
 		}
 		
 	}
-	_loop41:;
+	_loop40:;
 	} // ( ... )*
 	match(RCURL);
 	value_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 181 "ncoGrammer.g"
+#line 179 "ncoGrammer.g"
 	value_list_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(VALUE_LIST,"value_list"))->add(value_list_AST)));
-#line 957 "ncoParser.cpp"
+#line 899 "ncoParser.cpp"
 	currentAST.root = value_list_AST;
 	if ( value_list_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		value_list_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -975,13 +917,13 @@ void ncoParser::arg_list() {
 	case NSTRING:
 	case VAR_ID:
 	case ATT_ID:
+	case TIMES:
 	case FUNC:
 	case INC:
 	case DEC:
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
 	case NCAP_INT:
@@ -1009,18 +951,18 @@ void ncoParser::arg_list() {
 	}
 	case DIM_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp66_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp66_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp66_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp57_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp57_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp57_AST);
 		match(DIM_ID);
 		arg_list_AST = currentAST.root;
 		break;
 	}
 	case DIM_MTD_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp67_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp67_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp67_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp58_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp58_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp58_AST);
 		match(DIM_MTD_ID);
 		arg_list_AST = currentAST.root;
 		break;
@@ -1045,25 +987,25 @@ void ncoParser::call_ref() {
 	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST call_ref_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	
-	ANTLR_USE_NAMESPACE(antlr)RefAST tmp68_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	tmp68_AST = astFactory->create(LT(1));
-	astFactory->makeASTRoot(currentAST, tmp68_AST);
+	ANTLR_USE_NAMESPACE(antlr)RefAST tmp59_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	tmp59_AST = astFactory->create(LT(1));
+	astFactory->makeASTRoot(currentAST, tmp59_AST);
 	match(CALL_REF);
 	{
 	switch ( LA(1)) {
 	case VAR_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp69_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp69_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp69_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp60_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp60_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp60_AST);
 		match(VAR_ID);
 		break;
 	}
 	case ATT_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp70_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp70_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp70_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp61_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp61_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp61_AST);
 		match(ATT_ID);
 		break;
 	}
@@ -1088,18 +1030,18 @@ void ncoParser::func_arg() {
 	case LPAREN:
 	case NSTRING:
 	case VAR_ID:
-	case ATT_ID:
 	case DIM_ID:
 	case DIVIDE:
 	case DIM_MTD_ID:
+	case ATT_ID:
 	case CALL_REF:
+	case TIMES:
 	case FUNC:
 	case INC:
 	case DEC:
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
 	case NCAP_INT:
@@ -1136,17 +1078,17 @@ void ncoParser::func_arg() {
 			astFactory->addASTChild( currentAST, returnAST );
 		}
 		else {
-			goto _loop46;
+			goto _loop45;
 		}
 		
 	}
-	_loop46:;
+	_loop45:;
 	} // ( ... )*
 	match(RPAREN);
 	func_arg_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
-#line 188 "ncoGrammer.g"
+#line 186 "ncoGrammer.g"
 	func_arg_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(FUNC_ARG,"func_arg"))->add(func_arg_AST)));
-#line 1150 "ncoParser.cpp"
+#line 1092 "ncoParser.cpp"
 	currentAST.root = func_arg_AST;
 	if ( func_arg_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
 		func_arg_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -1167,17 +1109,17 @@ void ncoParser::hyper_slb() {
 	switch ( LA(1)) {
 	case VAR_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp74_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp74_AST = astFactory->create(LT(1));
-		astFactory->makeASTRoot(currentAST, tmp74_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp65_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp65_AST = astFactory->create(LT(1));
+		astFactory->makeASTRoot(currentAST, tmp65_AST);
 		match(VAR_ID);
 		break;
 	}
 	case ATT_ID:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp75_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp75_AST = astFactory->create(LT(1));
-		astFactory->makeASTRoot(currentAST, tmp75_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp66_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp66_AST = astFactory->create(LT(1));
+		astFactory->makeASTRoot(currentAST, tmp66_AST);
 		match(ATT_ID);
 		break;
 	}
@@ -1201,12 +1143,12 @@ void ncoParser::hyper_slb() {
 	case RCURL:
 	case COLON:
 	case DIVIDE:
+	case TIMES:
 	case DOT:
 	case INC:
 	case DEC:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case CARET:
 	case MOD:
 	case FLTHAN:
@@ -1247,36 +1189,57 @@ void ncoParser::hyper_slb() {
 }
 
 /*************************************************************/
-void ncoParser::meth_exp() {
+void ncoParser::top_exp() {
 	returnAST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
-	ANTLR_USE_NAMESPACE(antlr)RefAST meth_exp_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST top_exp_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefToken  ur = ANTLR_USE_NAMESPACE(antlr)nullToken;
+	ANTLR_USE_NAMESPACE(antlr)RefAST ur_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	
-	primary_exp();
-	astFactory->addASTChild( currentAST, returnAST );
-	{ // ( ... )*
-	for (;;) {
-		if ((LA(1) == DOT)) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp76_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp76_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp76_AST);
-			match(DOT);
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp77_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp77_AST = astFactory->create(LT(1));
-			astFactory->addASTChild(currentAST, tmp77_AST);
-			match(FUNC);
-			func_arg();
-			astFactory->addASTChild( currentAST, returnAST );
-		}
-		else {
-			goto _loop54;
-		}
-		
+	switch ( LA(1)) {
+	case TIMES:
+	{
+		ur = LT(1);
+		ur_AST = astFactory->create(ur);
+		astFactory->makeASTRoot(currentAST, ur_AST);
+		match(TIMES);
+#line 198 "ncoGrammer.g"
+		ur_AST->setType(UTIMES);ur_AST->setText("UTIMES");
+#line 1209 "ncoParser.cpp"
+		top_exp();
+		astFactory->addASTChild( currentAST, returnAST );
+		top_exp_AST = currentAST.root;
+		break;
 	}
-	_loop54:;
-	} // ( ... )*
-	meth_exp_AST = currentAST.root;
-	returnAST = meth_exp_AST;
+	case LPAREN:
+	case NSTRING:
+	case VAR_ID:
+	case ATT_ID:
+	case FUNC:
+	case NCAP_FLOAT:
+	case NCAP_DOUBLE:
+	case NCAP_INT:
+	case NCAP_BYTE:
+	case NCAP_UBYTE:
+	case NCAP_SHORT:
+	case NCAP_USHORT:
+	case NCAP_UINT:
+	case NCAP_INT64:
+	case NCAP_UINT64:
+	case N4STRING:
+	case DIM_ID_SIZE:
+	{
+		primary_exp();
+		astFactory->addASTChild( currentAST, returnAST );
+		top_exp_AST = currentAST.root;
+		break;
+	}
+	default:
+	{
+		throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
+	}
+	}
+	returnAST = top_exp_AST;
 }
 
 void ncoParser::primary_exp() {
@@ -1287,117 +1250,117 @@ void ncoParser::primary_exp() {
 	switch ( LA(1)) {
 	case NCAP_FLOAT:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp78_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp78_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp78_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp67_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp67_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp67_AST);
 		match(NCAP_FLOAT);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_DOUBLE:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp79_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp79_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp79_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp68_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp68_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp68_AST);
 		match(NCAP_DOUBLE);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_INT:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp80_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp80_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp80_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp69_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp69_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp69_AST);
 		match(NCAP_INT);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_BYTE:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp81_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp81_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp81_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp70_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp70_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp70_AST);
 		match(NCAP_BYTE);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_UBYTE:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp82_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp82_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp82_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp71_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp71_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp71_AST);
 		match(NCAP_UBYTE);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_SHORT:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp83_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp83_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp83_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp72_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp72_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp72_AST);
 		match(NCAP_SHORT);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_USHORT:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp84_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp84_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp84_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp73_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp73_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp73_AST);
 		match(NCAP_USHORT);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_UINT:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp85_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp85_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp85_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp74_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp74_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp74_AST);
 		match(NCAP_UINT);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_INT64:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp86_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp86_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp86_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp75_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp75_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp75_AST);
 		match(NCAP_INT64);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NCAP_UINT64:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp87_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp87_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp87_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp76_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp76_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp76_AST);
 		match(NCAP_UINT64);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case NSTRING:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp88_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp88_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp88_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp77_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp77_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp77_AST);
 		match(NSTRING);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case N4STRING:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp89_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp89_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp89_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp78_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp78_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp78_AST);
 		match(N4STRING);
 		primary_exp_AST = currentAST.root;
 		break;
 	}
 	case DIM_ID_SIZE:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp90_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp90_AST = astFactory->create(LT(1));
-		astFactory->addASTChild(currentAST, tmp90_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp79_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp79_AST = astFactory->create(LT(1));
+		astFactory->addASTChild(currentAST, tmp79_AST);
 		match(DIM_ID_SIZE);
 		primary_exp_AST = currentAST.root;
 		break;
@@ -1413,9 +1376,9 @@ void ncoParser::primary_exp() {
 	}
 	case FUNC:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp93_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp93_AST = astFactory->create(LT(1));
-		astFactory->makeASTRoot(currentAST, tmp93_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp82_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp82_AST = astFactory->create(LT(1));
+		astFactory->makeASTRoot(currentAST, tmp82_AST);
 		match(FUNC);
 		func_arg();
 		astFactory->addASTChild( currentAST, returnAST );
@@ -1438,6 +1401,38 @@ void ncoParser::primary_exp() {
 	returnAST = primary_exp_AST;
 }
 
+void ncoParser::meth_exp() {
+	returnAST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST meth_exp_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	
+	top_exp();
+	astFactory->addASTChild( currentAST, returnAST );
+	{ // ( ... )*
+	for (;;) {
+		if ((LA(1) == DOT)) {
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp83_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp83_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp83_AST);
+			match(DOT);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp84_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp84_AST = astFactory->create(LT(1));
+			astFactory->addASTChild(currentAST, tmp84_AST);
+			match(FUNC);
+			func_arg();
+			astFactory->addASTChild( currentAST, returnAST );
+		}
+		else {
+			goto _loop54;
+		}
+		
+	}
+	_loop54:;
+	} // ( ... )*
+	meth_exp_AST = currentAST.root;
+	returnAST = meth_exp_AST;
+}
+
 void ncoParser::unaryleft_exp() {
 	returnAST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
@@ -1457,10 +1452,10 @@ void ncoParser::unaryleft_exp() {
 		in_AST = astFactory->create(in);
 		astFactory->makeASTRoot(currentAST, in_AST);
 		match(INC);
-#line 205 "ncoGrammer.g"
+#line 207 "ncoGrammer.g"
 		in_AST->setType(POST_INC);
 		in_AST->setText("POST_INC");
-#line 1464 "ncoParser.cpp"
+#line 1459 "ncoParser.cpp"
 		break;
 	}
 	case DEC:
@@ -1469,10 +1464,10 @@ void ncoParser::unaryleft_exp() {
 		de_AST = astFactory->create(de);
 		astFactory->makeASTRoot(currentAST, de_AST);
 		match(DEC);
-#line 207 "ncoGrammer.g"
+#line 209 "ncoGrammer.g"
 		de_AST->setType(POST_DEC);
 		de_AST->setText("POST_DEC");
-#line 1476 "ncoParser.cpp"
+#line 1471 "ncoParser.cpp"
 		break;
 	}
 	case SEMI:
@@ -1481,9 +1476,9 @@ void ncoParser::unaryleft_exp() {
 	case RCURL:
 	case COLON:
 	case DIVIDE:
+	case TIMES:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case CARET:
 	case MOD:
 	case FLTHAN:
@@ -1519,8 +1514,6 @@ void ncoParser::unary_exp() {
 	returnAST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST unary_exp_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	ANTLR_USE_NAMESPACE(antlr)RefToken  ur = ANTLR_USE_NAMESPACE(antlr)nullToken;
-	ANTLR_USE_NAMESPACE(antlr)RefAST ur_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	
 	switch ( LA(1)) {
 	case INC:
@@ -1528,61 +1521,49 @@ void ncoParser::unary_exp() {
 	case LNOT:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	{
 		{
 		switch ( LA(1)) {
 		case LNOT:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp94_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp94_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp94_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp85_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp85_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp85_AST);
 			match(LNOT);
 			break;
 		}
 		case PLUS:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp95_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp95_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp95_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp86_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp86_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp86_AST);
 			match(PLUS);
 			break;
 		}
 		case MINUS:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp96_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp96_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp96_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp87_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp87_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp87_AST);
 			match(MINUS);
 			break;
 		}
 		case INC:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp97_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp97_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp97_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp88_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp88_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp88_AST);
 			match(INC);
 			break;
 		}
 		case DEC:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp98_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp98_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp98_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp89_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp89_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp89_AST);
 			match(DEC);
 			break;
 		}
-		case TIMES:
-		{
-			ur = LT(1);
-			ur_AST = astFactory->create(ur);
-			astFactory->makeASTRoot(currentAST, ur_AST);
-			match(TIMES);
-#line 220 "ncoGrammer.g"
-			ur_AST->setType(UTIMES);ur_AST->setText("UTIMES");
-#line 1584 "ncoParser.cpp"
-			break;
-		}
 		default:
 		{
 			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
@@ -1598,6 +1579,7 @@ void ncoParser::unary_exp() {
 	case NSTRING:
 	case VAR_ID:
 	case ATT_ID:
+	case TIMES:
 	case FUNC:
 	case NCAP_FLOAT:
 	case NCAP_DOUBLE:
@@ -1636,9 +1618,9 @@ void ncoParser::pow_exp() {
 	switch ( LA(1)) {
 	case CARET:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp99_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp99_AST = astFactory->create(LT(1));
-		astFactory->makeASTRoot(currentAST, tmp99_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp90_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp90_AST = astFactory->create(LT(1));
+		astFactory->makeASTRoot(currentAST, tmp90_AST);
 		match(CARET);
 		pow_exp();
 		astFactory->addASTChild( currentAST, returnAST );
@@ -1650,9 +1632,9 @@ void ncoParser::pow_exp() {
 	case RCURL:
 	case COLON:
 	case DIVIDE:
+	case TIMES:
 	case PLUS:
 	case MINUS:
-	case TIMES:
 	case MOD:
 	case FLTHAN:
 	case FGTHAN:
@@ -1697,25 +1679,25 @@ void ncoParser::mexpr() {
 			switch ( LA(1)) {
 			case TIMES:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp100_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp100_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp100_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp91_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp91_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp91_AST);
 				match(TIMES);
 				break;
 			}
 			case DIVIDE:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp101_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp101_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp101_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp92_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp92_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp92_AST);
 				match(DIVIDE);
 				break;
 			}
 			case MOD:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp102_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp102_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp102_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp93_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp93_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp93_AST);
 				match(MOD);
 				break;
 			}
@@ -1753,17 +1735,17 @@ void ncoParser::add_expr() {
 			switch ( LA(1)) {
 			case PLUS:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp103_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp103_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp103_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp94_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp94_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp94_AST);
 				match(PLUS);
 				break;
 			}
 			case MINUS:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp104_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp104_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp104_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp95_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp95_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp95_AST);
 				match(MINUS);
 				break;
 			}
@@ -1801,17 +1783,17 @@ void ncoParser::frel_expr() {
 			switch ( LA(1)) {
 			case FLTHAN:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp105_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp105_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp105_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp96_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp96_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp96_AST);
 				match(FLTHAN);
 				break;
 			}
 			case FGTHAN:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp106_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp106_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp106_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp97_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp97_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp97_AST);
 				match(FGTHAN);
 				break;
 			}
@@ -1849,33 +1831,33 @@ void ncoParser::rel_expr() {
 			switch ( LA(1)) {
 			case LTHAN:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp107_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp107_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp107_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp98_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp98_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp98_AST);
 				match(LTHAN);
 				break;
 			}
 			case GTHAN:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp108_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp108_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp108_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp99_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp99_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp99_AST);
 				match(GTHAN);
 				break;
 			}
 			case GEQ:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp109_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp109_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp109_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp100_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp100_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp100_AST);
 				match(GEQ);
 				break;
 			}
 			case LEQ:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp110_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp110_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp110_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp101_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp101_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp101_AST);
 				match(LEQ);
 				break;
 			}
@@ -1913,17 +1895,17 @@ void ncoParser::eq_expr() {
 			switch ( LA(1)) {
 			case EQ:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp111_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp111_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp111_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp102_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp102_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp102_AST);
 				match(EQ);
 				break;
 			}
 			case NEQ:
 			{
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp112_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-				tmp112_AST = astFactory->create(LT(1));
-				astFactory->makeASTRoot(currentAST, tmp112_AST);
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp103_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+				tmp103_AST = astFactory->create(LT(1));
+				astFactory->makeASTRoot(currentAST, tmp103_AST);
 				match(NEQ);
 				break;
 			}
@@ -1957,9 +1939,9 @@ void ncoParser::lmul_expr() {
 	{ // ( ... )*
 	for (;;) {
 		if ((LA(1) == LAND)) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp113_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp113_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp113_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp104_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp104_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp104_AST);
 			match(LAND);
 			eq_expr();
 			astFactory->addASTChild( currentAST, returnAST );
@@ -1985,9 +1967,9 @@ void ncoParser::lor_expr() {
 	{ // ( ... )*
 	for (;;) {
 		if ((LA(1) == LOR)) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp114_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp114_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp114_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp105_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp105_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp105_AST);
 			match(LOR);
 			lmul_expr();
 			astFactory->addASTChild( currentAST, returnAST );
@@ -2014,9 +1996,9 @@ void ncoParser::cond_expr() {
 	switch ( LA(1)) {
 	case QUESTION:
 	{
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp115_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-		tmp115_AST = astFactory->create(LT(1));
-		astFactory->makeASTRoot(currentAST, tmp115_AST);
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp106_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+		tmp106_AST = astFactory->create(LT(1));
+		astFactory->makeASTRoot(currentAST, tmp106_AST);
 		match(QUESTION);
 		ass_expr();
 		astFactory->addASTChild( currentAST, returnAST );
@@ -2067,41 +2049,41 @@ void ncoParser::ass_expr() {
 		switch ( LA(1)) {
 		case ASSIGN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp117_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp117_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp117_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp108_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp108_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp108_AST);
 			match(ASSIGN);
 			break;
 		}
 		case PLUS_ASSIGN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp118_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp118_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp118_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp109_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp109_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp109_AST);
 			match(PLUS_ASSIGN);
 			break;
 		}
 		case MINUS_ASSIGN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp119_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp119_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp119_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp110_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp110_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp110_AST);
 			match(MINUS_ASSIGN);
 			break;
 		}
 		case TIMES_ASSIGN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp120_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp120_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp120_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp111_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp111_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp111_AST);
 			match(TIMES_ASSIGN);
 			break;
 		}
 		case DIVIDE_ASSIGN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp121_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-			tmp121_AST = astFactory->create(LT(1));
-			astFactory->makeASTRoot(currentAST, tmp121_AST);
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp112_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+			tmp112_AST = astFactory->create(LT(1));
+			astFactory->makeASTRoot(currentAST, tmp112_AST);
 			match(DIVIDE_ASSIGN);
 			break;
 		}
@@ -2117,13 +2099,13 @@ void ncoParser::ass_expr() {
 		case NSTRING:
 		case VAR_ID:
 		case ATT_ID:
+		case TIMES:
 		case FUNC:
 		case INC:
 		case DEC:
 		case LNOT:
 		case PLUS:
 		case MINUS:
-		case TIMES:
 		case NCAP_FLOAT:
 		case NCAP_DOUBLE:
 		case NCAP_INT:
@@ -2179,9 +2161,9 @@ void ncoParser::imaginary_token() {
 	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST imaginary_token_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	
-	ANTLR_USE_NAMESPACE(antlr)RefAST tmp122_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	tmp122_AST = astFactory->create(LT(1));
-	astFactory->addASTChild(currentAST, tmp122_AST);
+	ANTLR_USE_NAMESPACE(antlr)RefAST tmp113_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	tmp113_AST = astFactory->create(LT(1));
+	astFactory->addASTChild(currentAST, tmp113_AST);
 	match(NRootAST);
 	imaginary_token_AST = currentAST.root;
 	returnAST = imaginary_token_AST;
@@ -2189,7 +2171,7 @@ void ncoParser::imaginary_token() {
 
 void ncoParser::initializeASTFactory( ANTLR_USE_NAMESPACE(antlr)ASTFactory& factory )
 {
-	factory.setMaxNodeType(117);
+	factory.setMaxNodeType(116);
 }
 const char* ncoParser::tokenNames[] = {
 	"<0>",
@@ -2236,19 +2218,19 @@ const char* ncoParser::tokenNames[] = {
 	"\"else\"",
 	"\"where\"",
 	"\"elsewhere\"",
-	"\"print\"",
-	"VAR_ID",
-	"ATT_ID",
 	"{",
 	"}",
 	"\"for\"",
 	":",
 	"[",
+	"VAR_ID",
 	"DIM_ID",
 	"]",
 	"/",
 	"dimension identifier",
+	"ATT_ID",
 	"call by reference",
+	"*",
 	"dot operator",
 	"FUNC",
 	"++",
@@ -2256,7 +2238,6 @@ const char* ncoParser::tokenNames[] = {
 	"!",
 	"+",
 	"-",
-	"*",
 	"power of operator",
 	"%",
 	"<<",
@@ -2313,40 +2294,41 @@ const char* ncoParser::tokenNames[] = {
 	0
 };
 
-const unsigned long ncoParser::_tokenSet_0_data_[] = { 3221225472UL, 4228052455UL, 2146959361UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+const unsigned long ncoParser::_tokenSet_0_data_[] = { 3221225472UL, 4248983015UL, 1073479680UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // SEMI "defdim" "defdimunlim" LPAREN NSTRING "while" "break" "continue" 
-// "if" "where" "print" VAR_ID ATT_ID LCURL "for" FUNC INC DEC LNOT PLUS 
-// MINUS TIMES NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE NCAP_UBYTE NCAP_SHORT 
+// "if" "where" LCURL "for" VAR_ID ATT_ID TIMES FUNC INC DEC LNOT PLUS 
+// MINUS NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE NCAP_UBYTE NCAP_SHORT 
 // NCAP_USHORT NCAP_UINT NCAP_INT64 NCAP_UINT64 N4STRING DIM_ID_SIZE 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoParser::_tokenSet_0(_tokenSet_0_data_,8);
-const unsigned long ncoParser::_tokenSet_1_data_[] = { 3221225474UL, 4266393575UL, 2147483647UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+const unsigned long ncoParser::_tokenSet_1_data_[] = { 3221225474UL, 4283662311UL, 1073741823UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // EOF SEMI "defdim" "defdimunlim" LPAREN NSTRING "while" "break" "continue" 
-// "if" "else" "where" "elsewhere" "print" VAR_ID ATT_ID LCURL RCURL "for" 
-// LSQUARE DIVIDE DOT FUNC INC DEC LNOT PLUS MINUS TIMES CARET MOD FLTHAN 
-// FGTHAN LTHAN GTHAN GEQ LEQ EQ NEQ LAND LOR QUESTION ASSIGN PLUS_ASSIGN 
-// MINUS_ASSIGN TIMES_ASSIGN DIVIDE_ASSIGN NCAP_FLOAT NCAP_DOUBLE NCAP_INT 
-// NCAP_BYTE NCAP_UBYTE NCAP_SHORT NCAP_USHORT NCAP_UINT NCAP_INT64 NCAP_UINT64 
-// N4STRING DIM_ID_SIZE 
+// "if" "else" "where" "elsewhere" LCURL RCURL "for" LSQUARE VAR_ID DIVIDE 
+// ATT_ID TIMES DOT FUNC INC DEC LNOT PLUS MINUS CARET MOD FLTHAN FGTHAN 
+// LTHAN GTHAN GEQ LEQ EQ NEQ LAND LOR QUESTION ASSIGN PLUS_ASSIGN MINUS_ASSIGN 
+// TIMES_ASSIGN DIVIDE_ASSIGN NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE 
+// NCAP_UBYTE NCAP_SHORT NCAP_USHORT NCAP_UINT NCAP_INT64 NCAP_UINT64 N4STRING 
+// DIM_ID_SIZE 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoParser::_tokenSet_1(_tokenSet_1_data_,8);
-const unsigned long ncoParser::_tokenSet_2_data_[] = { 3221225474UL, 4228120551UL, 2146959361UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+const unsigned long ncoParser::_tokenSet_2_data_[] = { 3221225474UL, 4248993767UL, 1073479680UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // EOF SEMI "defdim" "defdimunlim" LPAREN NSTRING "while" "break" "continue" 
-// "if" "else" "where" "elsewhere" "print" VAR_ID ATT_ID LCURL RCURL "for" 
-// FUNC INC DEC LNOT PLUS MINUS TIMES NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE 
+// "if" "else" "where" "elsewhere" LCURL RCURL "for" VAR_ID ATT_ID TIMES 
+// FUNC INC DEC LNOT PLUS MINUS NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE 
 // NCAP_UBYTE NCAP_SHORT NCAP_USHORT NCAP_UINT NCAP_INT64 NCAP_UINT64 N4STRING 
 // DIM_ID_SIZE 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoParser::_tokenSet_2(_tokenSet_2_data_,8);
-const unsigned long ncoParser::_tokenSet_3_data_[] = { 3221225474UL, 4292870143UL, 2147483647UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+const unsigned long ncoParser::_tokenSet_3_data_[] = { 3221225474UL, 4294967295UL, 1073741823UL, 0UL, 0UL, 0UL, 0UL, 0UL };
 // EOF SEMI "defdim" "defdimunlim" LPAREN NSTRING COMMA RPAREN "while" 
-// "break" "continue" "if" "else" "where" "elsewhere" "print" VAR_ID ATT_ID 
-// LCURL RCURL "for" COLON LSQUARE DIM_ID DIVIDE DIM_MTD_ID CALL_REF DOT 
-// FUNC INC DEC LNOT PLUS MINUS TIMES CARET MOD FLTHAN FGTHAN LTHAN GTHAN 
-// GEQ LEQ EQ NEQ LAND LOR QUESTION ASSIGN PLUS_ASSIGN MINUS_ASSIGN TIMES_ASSIGN 
-// DIVIDE_ASSIGN NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE NCAP_UBYTE NCAP_SHORT 
-// NCAP_USHORT NCAP_UINT NCAP_INT64 NCAP_UINT64 N4STRING DIM_ID_SIZE 
+// "break" "continue" "if" "else" "where" "elsewhere" LCURL RCURL "for" 
+// COLON LSQUARE VAR_ID DIM_ID RSQUARE DIVIDE DIM_MTD_ID ATT_ID CALL_REF 
+// TIMES DOT FUNC INC DEC LNOT PLUS MINUS CARET MOD FLTHAN FGTHAN LTHAN 
+// GTHAN GEQ LEQ EQ NEQ LAND LOR QUESTION ASSIGN PLUS_ASSIGN MINUS_ASSIGN 
+// TIMES_ASSIGN DIVIDE_ASSIGN NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE 
+// NCAP_UBYTE NCAP_SHORT NCAP_USHORT NCAP_UINT NCAP_INT64 NCAP_UINT64 N4STRING 
+// DIM_ID_SIZE 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoParser::_tokenSet_3(_tokenSet_3_data_,8);
-const unsigned long ncoParser::_tokenSet_4_data_[] = { 0UL, 4228145182UL, 2146959361UL, 0UL, 0UL, 0UL, 0UL, 0UL };
-// LPAREN NSTRING COMMA RPAREN VAR_ID ATT_ID COLON FUNC INC DEC LNOT PLUS 
-// MINUS TIMES NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE NCAP_UBYTE NCAP_SHORT 
+const unsigned long ncoParser::_tokenSet_4_data_[] = { 0UL, 4248993822UL, 1073479680UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+// LPAREN NSTRING COMMA RPAREN COLON VAR_ID ATT_ID TIMES FUNC INC DEC LNOT 
+// PLUS MINUS NCAP_FLOAT NCAP_DOUBLE NCAP_INT NCAP_BYTE NCAP_UBYTE NCAP_SHORT 
 // NCAP_USHORT NCAP_UINT NCAP_INT64 NCAP_UINT64 N4STRING DIM_ID_SIZE 
 const ANTLR_USE_NAMESPACE(antlr)BitSet ncoParser::_tokenSet_4(_tokenSet_4_data_,8);
 
diff --git a/src/nco++/ncoParser.hpp b/src/nco++/ncoParser.hpp
index e4350f6..70a403f 100644
--- a/src/nco++/ncoParser.hpp
+++ b/src/nco++/ncoParser.hpp
@@ -2,7 +2,7 @@
 #define INC_ncoParser_hpp_
 
 #include <antlr/config.hpp>
-/* $ANTLR 2.7.7 (20130428): "ncoGrammer.g" -> "ncoParser.hpp"$ */
+/* $ANTLR 2.7.7 (20151030): "ncoGrammer.g" -> "ncoParser.hpp"$ */
 #include <antlr/TokenStream.hpp>
 #include <antlr/TokenBuffer.hpp>
 #include "ncoParserTokenTypes.hpp"
@@ -98,8 +98,9 @@ public:
 	public: void call_ref();
 	public: void func_arg();
 	public: void hyper_slb();
-	public: void meth_exp();
+	public: void top_exp();
 	public: void primary_exp();
+	public: void meth_exp();
 	public: void unaryleft_exp();
 	public: void unary_exp();
 	public: void pow_exp();
@@ -124,10 +125,10 @@ protected:
 private:
 	static const char* tokenNames[];
 #ifndef NO_STATIC_CONSTS
-	static const int NUM_TOKENS = 118;
+	static const int NUM_TOKENS = 117;
 #else
 	enum {
-		NUM_TOKENS = 118
+		NUM_TOKENS = 117
 	};
 #endif
 	
diff --git a/src/nco++/ncoParserTokenTypes.hpp b/src/nco++/ncoParserTokenTypes.hpp
index b41781d..8bd0255 100644
--- a/src/nco++/ncoParserTokenTypes.hpp
+++ b/src/nco++/ncoParserTokenTypes.hpp
@@ -1,7 +1,7 @@
 #ifndef INC_ncoParserTokenTypes_hpp_
 #define INC_ncoParserTokenTypes_hpp_
 
-/* $ANTLR 2.7.7 (2006-11-01): "ncoGrammer.g" -> "ncoParserTokenTypes.hpp"$ */
+/* $ANTLR 2.7.7 (20151030): "ncoGrammer.g" -> "ncoParserTokenTypes.hpp"$ */
 
 #ifndef CUSTOM_API
 # define CUSTOM_API
@@ -52,19 +52,19 @@ struct CUSTOM_API ncoParserTokenTypes {
 		ELSE = 41,
 		WHERE = 42,
 		ELSEWHERE = 43,
-		PRINT = 44,
-		VAR_ID = 45,
-		ATT_ID = 46,
-		LCURL = 47,
-		RCURL = 48,
-		FOR = 49,
-		COLON = 50,
-		LSQUARE = 51,
-		DIM_ID = 52,
-		RSQUARE = 53,
-		DIVIDE = 54,
-		DIM_MTD_ID = 55,
-		CALL_REF = 56,
+		LCURL = 44,
+		RCURL = 45,
+		FOR = 46,
+		COLON = 47,
+		LSQUARE = 48,
+		VAR_ID = 49,
+		DIM_ID = 50,
+		RSQUARE = 51,
+		DIVIDE = 52,
+		DIM_MTD_ID = 53,
+		ATT_ID = 54,
+		CALL_REF = 55,
+		TIMES = 56,
 		DOT = 57,
 		FUNC = 58,
 		INC = 59,
@@ -72,60 +72,59 @@ struct CUSTOM_API ncoParserTokenTypes {
 		LNOT = 61,
 		PLUS = 62,
 		MINUS = 63,
-		TIMES = 64,
-		CARET = 65,
-		MOD = 66,
-		FLTHAN = 67,
-		FGTHAN = 68,
-		LTHAN = 69,
-		GTHAN = 70,
-		GEQ = 71,
-		LEQ = 72,
-		EQ = 73,
-		NEQ = 74,
-		LAND = 75,
-		LOR = 76,
-		QUESTION = 77,
-		ASSIGN = 78,
-		PLUS_ASSIGN = 79,
-		MINUS_ASSIGN = 80,
-		TIMES_ASSIGN = 81,
-		DIVIDE_ASSIGN = 82,
-		NCAP_FLOAT = 83,
-		NCAP_DOUBLE = 84,
-		NCAP_INT = 85,
-		NCAP_BYTE = 86,
-		NCAP_UBYTE = 87,
-		NCAP_SHORT = 88,
-		NCAP_USHORT = 89,
-		NCAP_UINT = 90,
-		NCAP_INT64 = 91,
-		NCAP_UINT64 = 92,
-		N4STRING = 93,
-		DIM_ID_SIZE = 94,
-		NRootAST = 95,
-		SHIFTL = 96,
-		SHIFTR = 97,
-		QUOTE = 98,
-		DGT = 99,
-		LPH = 100,
-		LPHDGT = 101,
-		XPN = 102,
-		VAR_NM_QT = 103,
-		BLASTOUT = 104,
-		UNUSED_OPS = 105,
-		WS = 106,
-		CXX_COMMENT = 107,
-		C_COMMENT = 108,
-		NUMBER_DOT = 109,
-		NUMBER = 110,
-		VAR_ATT = 111,
-		VAR_ATT_QT = 112,
-		STR_ATT_QT = 113,
-		DIM_QT = 114,
-		DIM_VAL = 115,
-		INCLUDE = 116,
-		LMT_DMN = 117,
+		CARET = 64,
+		MOD = 65,
+		FLTHAN = 66,
+		FGTHAN = 67,
+		LTHAN = 68,
+		GTHAN = 69,
+		GEQ = 70,
+		LEQ = 71,
+		EQ = 72,
+		NEQ = 73,
+		LAND = 74,
+		LOR = 75,
+		QUESTION = 76,
+		ASSIGN = 77,
+		PLUS_ASSIGN = 78,
+		MINUS_ASSIGN = 79,
+		TIMES_ASSIGN = 80,
+		DIVIDE_ASSIGN = 81,
+		NCAP_FLOAT = 82,
+		NCAP_DOUBLE = 83,
+		NCAP_INT = 84,
+		NCAP_BYTE = 85,
+		NCAP_UBYTE = 86,
+		NCAP_SHORT = 87,
+		NCAP_USHORT = 88,
+		NCAP_UINT = 89,
+		NCAP_INT64 = 90,
+		NCAP_UINT64 = 91,
+		N4STRING = 92,
+		DIM_ID_SIZE = 93,
+		NRootAST = 94,
+		SHIFTL = 95,
+		SHIFTR = 96,
+		QUOTE = 97,
+		DGT = 98,
+		LPH = 99,
+		LPHDGT = 100,
+		XPN = 101,
+		VAR_NM_QT = 102,
+		BLASTOUT = 103,
+		UNUSED_OPS = 104,
+		WS = 105,
+		CXX_COMMENT = 106,
+		C_COMMENT = 107,
+		NUMBER_DOT = 108,
+		NUMBER = 109,
+		VAR_ATT = 110,
+		VAR_ATT_QT = 111,
+		STR_ATT_QT = 112,
+		DIM_QT = 113,
+		DIM_VAL = 114,
+		INCLUDE = 115,
+		LMT_DMN = 116,
 		NULL_TREE_LOOKAHEAD = 3
 	};
 #ifdef __cplusplus
diff --git a/src/nco++/ncoTree.cpp b/src/nco++/ncoTree.cpp
index 9c5b297..9affe67 100644
--- a/src/nco++/ncoTree.cpp
+++ b/src/nco++/ncoTree.cpp
@@ -13,7 +13,7 @@ ncoTree::ncoTree()
 }
 
 int  ncoTree::lmt_peek(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
-#line 1091 "ncoGrammer.g"
+#line 1095 "ncoGrammer.g"
 	int nbr_dmn=0;
 #line 19 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST lmt_peek_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
@@ -24,7 +24,7 @@ int  ncoTree::lmt_peek(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 		match(_t,LMT_LIST);
 		_t = _t->getNextSibling();
 		if ( inputState->guessing==0 ) {
-#line 1093 "ncoGrammer.g"
+#line 1097 "ncoGrammer.g"
 			
 			RefAST aRef;     
 			aRef=lmt->getFirstChild();
@@ -51,7 +51,7 @@ int  ncoTree::lmt_peek(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 }
 
 int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
-#line 1104 "ncoGrammer.g"
+#line 1108 "ncoGrammer.g"
 	int iret=0;
 #line 57 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST statements_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
@@ -69,10 +69,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 	ANTLR_USE_NAMESPACE(antlr)RefAST stmt2 = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST dtyp = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST def = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	ANTLR_USE_NAMESPACE(antlr)RefAST pvid = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	ANTLR_USE_NAMESPACE(antlr)RefAST patt = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	ANTLR_USE_NAMESPACE(antlr)RefAST pstr = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 1104 "ncoGrammer.g"
+#line 1108 "ncoGrammer.g"
 	
 	var_sct *var=NULL;
 	var_sct *var2=NULL;
@@ -82,7 +79,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 	// nested block
 	static std::vector<std::string> lpp_vtr;
 	
-#line 86 "ncoTree.cpp"
+#line 83 "ncoTree.cpp"
 	
 	try {      // for error handling
 		if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -94,13 +91,13 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,BLOCK);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1114 "ncoGrammer.g"
+#line 1118 "ncoGrammer.g"
 				
 				//std::cout <<"Num of Children in block="<<blk->getNumberOfChildren()<<endl;
 				iret=run_exe(blk->getFirstChild(),lpp_vtr.size() );
 				
 				
-#line 104 "ncoTree.cpp"
+#line 101 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -116,35 +113,31 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			_t = __t231;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1120 "ncoGrammer.g"
+#line 1125 "ncoGrammer.g"
 				
-				RefAST tr;
-				RefAST ntr;  
+				int aType; 
 				
-				if(ass->getType()==ASSIGN && prs_arg->ntl_scn ){
-				ntr=ass->getFirstChild();
-				if(ntr->getType()==UTIMES) 
-				ntr=ntr->getFirstChild();
+				aType=ass->getType(); 
 				
-				if(ntr->getType() == VAR_ID || ntr->getType() ==ATT_ID){
-				ntr->addChild( astFactory->create(NORET,"no_ret") );
-				// std::cout << "Modified assign "<<exp->toStringTree()<<std::endl;      
-				}
-				} 
+				
+				
+				if( aType==ASSIGN || aType==POST_INC || aType==POST_DEC || aType==INC || aType==DEC||aType==PLUS_ASSIGN || aType==MINUS_ASSIGN || aType==TIMES_ASSIGN || aType==DIVIDE_ASSIGN )
+				ass->setText("NO_RET"); 
 				
 				var=out(exp->getFirstChild());
+				
 				if(var != (var_sct*)NULL)
 				var=nco_var_free(var);
 				iret=EXPR;
 				
-#line 141 "ncoTree.cpp"
+#line 134 "ncoTree.cpp"
 			}
 			break;
 		}
 		case FEXPR:
 		{
 			ANTLR_USE_NAMESPACE(antlr)RefAST __t232 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp123_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp114_AST_in = _t;
 			match(_t,FEXPR);
 			_t = _t->getFirstChild();
 			fss = _t;
@@ -153,7 +146,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			_t = __t232;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1144 "ncoGrammer.g"
+#line 1145 "ncoGrammer.g"
 				
 				
 				var=out(fss);
@@ -161,14 +154,16 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				var=nco_var_free(var);
 				iret=FEXPR;
 				
-#line 165 "ncoTree.cpp"
+				dbg_prn(fnc_nm,"executed FEXPR "+ fss->getText());    
+				
+#line 160 "ncoTree.cpp"
 			}
 			break;
 		}
 		case IF:
 		{
 			ANTLR_USE_NAMESPACE(antlr)RefAST __t233 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp124_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp115_AST_in = _t;
 			match(_t,IF);
 			_t = _t->getFirstChild();
 			var=out(_t);
@@ -179,7 +174,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			_t = __t233;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1152 "ncoGrammer.g"
+#line 1155 "ncoGrammer.g"
 				
 				//if can have only 3 or 4 parts  , 1 node and 2 or 3 siblings
 				// IF LOGICAL_EXP STATEMENT1 STATEMENT2
@@ -209,14 +204,14 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				var=NULL_CEWI;
 				
 				
-#line 213 "ncoTree.cpp"
+#line 208 "ncoTree.cpp"
 			}
 			break;
 		}
 		case WHERE:
 		{
 			ANTLR_USE_NAMESPACE(antlr)RefAST __t234 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp125_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp116_AST_in = _t;
 			match(_t,WHERE);
 			_t = _t->getFirstChild();
 			var=out(_t);
@@ -227,7 +222,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			_t = __t234;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1182 "ncoGrammer.g"
+#line 1185 "ncoGrammer.g"
 				
 				// convert mask to short 
 				RefAST tr; 
@@ -251,7 +246,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				where_assign(stmt3,var);
 				
 				// deal with else-where
-				if(tr=stmt3->getNextSibling()) {
+				if((tr=stmt3->getNextSibling())!=ANTLR_USE_NAMESPACE(antlr)nullAST) {
 				
 				//invert mask
 				var=ncap_var_var_stc(var,NULL_CEWI,LNOT); 
@@ -271,14 +266,14 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				var=nco_var_free(var);
 				iret=WHERE;      
 				
-#line 275 "ncoTree.cpp"
+#line 270 "ncoTree.cpp"
 			}
 			break;
 		}
 		case WHILE:
 		{
 			ANTLR_USE_NAMESPACE(antlr)RefAST __t235 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp126_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp117_AST_in = _t;
 			match(_t,WHILE);
 			_t = _t->getFirstChild();
 			lgcl = _t;
@@ -290,7 +285,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			_t = __t235;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1226 "ncoGrammer.g"
+#line 1229 "ncoGrammer.g"
 				
 				
 				bool br;
@@ -319,14 +314,14 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				var=NULL_CEWI; 
 				
 				
-#line 323 "ncoTree.cpp"
+#line 318 "ncoTree.cpp"
 			}
 			break;
 		}
 		case FOR:
 		{
 			ANTLR_USE_NAMESPACE(antlr)RefAST __t236 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp127_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp118_AST_in = _t;
 			match(_t,FOR);
 			_t = _t->getFirstChild();
 			e1 = _t;
@@ -344,7 +339,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			_t = __t236;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1255 "ncoGrammer.g"
+#line 1258 "ncoGrammer.g"
 				
 				bool b1,b2,b3,br;
 				var_sct *var_f1;
@@ -395,55 +390,55 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				var=NULL_CEWI;                
 				
 				
-#line 399 "ncoTree.cpp"
+#line 394 "ncoTree.cpp"
 			}
 			break;
 		}
 		case ELSE:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp128_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp119_AST_in = _t;
 			match(_t,ELSE);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1306 "ncoGrammer.g"
+#line 1309 "ncoGrammer.g"
 				iret=ELSE;
-#line 411 "ncoTree.cpp"
+#line 406 "ncoTree.cpp"
 			}
 			break;
 		}
 		case BREAK:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp129_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp120_AST_in = _t;
 			match(_t,BREAK);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1307 "ncoGrammer.g"
+#line 1310 "ncoGrammer.g"
 				iret=BREAK;
-#line 423 "ncoTree.cpp"
+#line 418 "ncoTree.cpp"
 			}
 			break;
 		}
 		case CONTINUE:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp130_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp121_AST_in = _t;
 			match(_t,CONTINUE);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1308 "ncoGrammer.g"
+#line 1311 "ncoGrammer.g"
 				iret=CONTINUE;
-#line 435 "ncoTree.cpp"
+#line 430 "ncoTree.cpp"
 			}
 			break;
 		}
 		case NULL_NODE:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp131_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp122_AST_in = _t;
 			match(_t,NULL_NODE);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1309 "ncoGrammer.g"
+#line 1312 "ncoGrammer.g"
 				iret=NULL_NODE;
-#line 447 "ncoTree.cpp"
+#line 442 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -469,8 +464,9 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			case WHERE_ASSIGN:
 			case NSTRING:
 			case VAR_ID:
-			case ATT_ID:
 			case DIVIDE:
+			case ATT_ID:
+			case TIMES:
 			case DOT:
 			case FUNC:
 			case INC:
@@ -478,7 +474,6 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			case LNOT:
 			case PLUS:
 			case MINUS:
-			case TIMES:
 			case CARET:
 			case MOD:
 			case FLTHAN:
@@ -527,7 +522,7 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			_t = __t237;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1311 "ncoGrammer.g"
+#line 1314 "ncoGrammer.g"
 				
 				
 				bool bunlimited=false;      
@@ -568,252 +563,15 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				
 				(void)ncap_def_dim(def->getText(),sz,bunlimited,prs_arg);
 				
-#line 572 "ncoTree.cpp"
+#line 567 "ncoTree.cpp"
 			}
 			break;
 		}
 		default:
-			bool synPredMatched241 = false;
-			if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
-				_t = ASTNULL;
-			if (((_t->getType() == PRINT))) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t241 = _t;
-				synPredMatched241 = true;
-				inputState->guessing++;
-				try {
-					{
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t240 = _t;
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp132_AST_in = _t;
-					match(_t,PRINT);
-					_t = _t->getFirstChild();
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp133_AST_in = _t;
-					match(_t,VAR_ID);
-					_t = _t->getNextSibling();
-					_t = __t240;
-					_t = _t->getNextSibling();
-					}
-				}
-				catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-					synPredMatched241 = false;
-				}
-				_t = __t241;
-				inputState->guessing--;
-			}
-			if ( synPredMatched241 ) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t242 = _t;
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp134_AST_in = _t;
-				match(_t,PRINT);
-				_t = _t->getFirstChild();
-				pvid = _t;
-				match(_t,VAR_ID);
-				_t = _t->getNextSibling();
-				_t = __t242;
-				_t = _t->getNextSibling();
-				if ( inputState->guessing==0 ) {
-#line 1353 "ncoGrammer.g"
-					
-					
-					int var_id;
-					int fl_id=-1;
-					char *fmt_sng;
-					
-					std::string va_nm(pvid->getText());
-					NcapVar *Nvar;
-					
-					if(prs_arg->ntl_scn) goto end2;
-					Nvar=prs_arg->var_vtr.find(va_nm);
-					
-					if(Nvar && Nvar->flg_mem){   
-					wrn_prn(fnc_nm,"Cannot print out RAM variables at the moment!");
-					goto end2;
-					}
-					
-					// check output first -nb can only print out vars that are defined AND written
-					// it is possible to get with the var defined in output but no data
-					// flg_stt==1 mean var defined but no data !!
-					// So we try to use var in input -if it exist their    
-					if(Nvar && Nvar->flg_stt==2){
-					fl_id=prs_arg->out_id;   
-					}else{
-					// Check input file for var   
-					if(NC_NOERR==nco_inq_varid_flg(prs_arg->in_id,va_nm.c_str(),&var_id))
-					fl_id=prs_arg->in_id;
-					}
-					
-					if(fl_id==-1) {
-					wrn_prn(fnc_nm,"Print function cannot find var \""+va_nm+"\" in input or output");
-					goto end2;
-					}
-					
-					// Grab format string 
-					if(pvid->getNextSibling() && pvid->getNextSibling()->getType()==NSTRING)
-					fmt_sng=strdup(pvid->getNextSibling()->getText().c_str());
-					else 
-					fmt_sng=(char*)NULL; 
-					
-					if( fl_id >=0)
-					(void)nco_prn_var_val_lmt(fl_id,va_nm.c_str(),(lmt_sct*)NULL,0L,fmt_sng,prs_arg->FORTRAN_IDX_CNV,False,False);
-					
-					if(fmt_sng) fmt_sng=(char*)nco_free(fmt_sng); 
-					
-					end2: ;
-					
-#line 662 "ncoTree.cpp"
-				}
-			}
-			else {
-				bool synPredMatched245 = false;
-				if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
-					_t = ASTNULL;
-				if (((_t->getType() == PRINT))) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t245 = _t;
-					synPredMatched245 = true;
-					inputState->guessing++;
-					try {
-						{
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t244 = _t;
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp135_AST_in = _t;
-						match(_t,PRINT);
-						_t = _t->getFirstChild();
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp136_AST_in = _t;
-						match(_t,ATT_ID);
-						_t = _t->getNextSibling();
-						_t = __t244;
-						_t = _t->getNextSibling();
-						}
-					}
-					catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-						synPredMatched245 = false;
-					}
-					_t = __t245;
-					inputState->guessing--;
-				}
-				if ( synPredMatched245 ) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t246 = _t;
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp137_AST_in = _t;
-					match(_t,PRINT);
-					_t = _t->getFirstChild();
-					patt = _t;
-					match(_t,ATT_ID);
-					_t = _t->getNextSibling();
-					_t = __t246;
-					_t = _t->getNextSibling();
-					if ( inputState->guessing==0 ) {
-#line 1400 "ncoGrammer.g"
-						
-						
-						int apsn;
-						var_sct *var1;
-						char *fmt_sng;
-						std::string fl_nm;
-						std::string att_nm;
-						std::string var_nm;
-						NcapVar *Nvar;
-						
-						var=NULL_CEWI;
-						
-						// print only on second parse
-						if(prs_arg->ntl_scn) goto end3;
-						
-						fl_nm=patt->getText();
-						apsn=fl_nm.find("@");
-						var_nm=fl_nm.substr(0,apsn);
-						att_nm=fl_nm.substr(apsn+1);            
-						
-						Nvar=prs_arg->var_vtr.find(var_nm);
-						if( Nvar && att_nm==std::string(nco_mss_val_sng_get()) ){         
-						if(Nvar->var->has_mss_val==True){
-						var1=ncap_sclr_var_mk(fl_nm,Nvar->var->type,true);
-						(void)memcpy(var1->val.vp,Nvar->var->mss_val.vp, nco_typ_lng(Nvar->var->type));
-						var=var1;
-						}else{
-						wrn_prn(fnc_nm,"Cannot print missing value \""+ fl_nm+ "\" for variable \""+ var_nm +"\" as it is undefined");
-						goto end3;    
-						}
-						}else{   
-						Nvar=prs_arg->var_vtr.find(fl_nm);
-						if(Nvar==NULL_CEWI) 
-						var=ncap_att_init(fl_nm,prs_arg);
-						else
-						var=nco_var_dpl(Nvar->var); 
-						}
-						
-						if(var==NULL_CEWI ){
-						wrn_prn(fnc_nm,"Cannot print  attribute \"" +fl_nm+ "\". Not present in input or output files.");
-						goto end3;    
-						}
-						
-						// Grab format string 
-						if(patt->getNextSibling() && patt->getNextSibling()->getType()==NSTRING)
-						fmt_sng=strdup(patt->getNextSibling()->getText().c_str());
-						else 
-						fmt_sng=(char*)NULL; 
-						
-						(void)ncap_att_prn(var,fmt_sng);
-						var=nco_var_free(var); 
-						
-						end3:   ;
-						
-#line 758 "ncoTree.cpp"
-					}
-				}
-				else {
-					bool synPredMatched249 = false;
-					if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
-						_t = ASTNULL;
-					if (((_t->getType() == PRINT))) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t249 = _t;
-						synPredMatched249 = true;
-						inputState->guessing++;
-						try {
-							{
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t248 = _t;
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp138_AST_in = _t;
-							match(_t,PRINT);
-							_t = _t->getFirstChild();
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp139_AST_in = _t;
-							match(_t,NSTRING);
-							_t = _t->getNextSibling();
-							_t = __t248;
-							_t = _t->getNextSibling();
-							}
-						}
-						catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-							synPredMatched249 = false;
-						}
-						_t = __t249;
-						inputState->guessing--;
-					}
-					if ( synPredMatched249 ) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t250 = _t;
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp140_AST_in = _t;
-						match(_t,PRINT);
-						_t = _t->getFirstChild();
-						pstr = _t;
-						match(_t,NSTRING);
-						_t = _t->getNextSibling();
-						_t = __t250;
-						_t = _t->getNextSibling();
-						if ( inputState->guessing==0 ) {
-#line 1455 "ncoGrammer.g"
-							
-							char *prn_sng;
-							
-							if(!prs_arg->ntl_scn){
-							prn_sng=strdup(pstr->getText().c_str());
-							(void)sng_ascii_trn(prn_sng);            
-							
-							fprintf(stdout,"%s",prn_sng);
-							prn_sng=(char*)nco_free(prn_sng);
-							}    
-							
-#line 811 "ncoTree.cpp"
-						}
-					}
-		else {
+		{
 			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
 		}
-		}}}
+		}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
 		if( inputState->guessing == 0 ) {
@@ -829,15 +587,23 @@ int  ncoTree::statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 }
 
 var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
-#line 2207 "ncoGrammer.g"
+#line 2122 "ncoGrammer.g"
 	var_sct *var;
-#line 835 "ncoTree.cpp"
+#line 593 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST out_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
-	ANTLR_USE_NAMESPACE(antlr)RefAST pls_asn = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	ANTLR_USE_NAMESPACE(antlr)RefAST min_asn = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	ANTLR_USE_NAMESPACE(antlr)RefAST tim_asn = ANTLR_USE_NAMESPACE(antlr)nullAST;
-	ANTLR_USE_NAMESPACE(antlr)RefAST div_asn = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST aposti = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST apostd = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST aprei = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST apred = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST atp = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST atm = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST attm = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST atd = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST asn = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST atta = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST asn2 = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST asn2a = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST attz = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST wasn = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST qus = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST m = ANTLR_USE_NAMESPACE(antlr)nullAST;
@@ -865,14 +631,25 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 	ANTLR_USE_NAMESPACE(antlr)RefAST val_uint = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST val_int64 = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST val_uint64 = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 2207 "ncoGrammer.g"
+#line 2122 "ncoGrammer.g"
 	
+	bool bret=true;   
 	const std::string fnc_nm("out"); 
 		var_sct *var1;
 	var_sct *var2;
 	var=NULL_CEWI;
 	
-#line 876 "ncoTree.cpp"
+	// on the following tokens if text is set to NO_RET then make sure out return var=NULL
+	// the check is done in statements / EXPR
+	// out_AST_in declared an inialized  to the first arg of out() (see ncoTree.cpp/out() for actual code )
+	if( out_AST_in != ANTLR_USE_NAMESPACE(antlr)nullAST && out_AST_in->getText()=="NO_RET" )
+	{
+	int aType=out_AST_in->getType();
+	if(aType==ASSIGN ||aType==POST_INC || aType==POST_DEC || aType==INC || aType==DEC||aType==PLUS_ASSIGN || aType==MINUS_ASSIGN || aType==DIVIDE_ASSIGN || aType==TIMES_ASSIGN)
+	bret=false;
+	}      
+	
+#line 653 "ncoTree.cpp"
 	
 	try {      // for error handling
 		if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -880,526 +657,331 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 		switch ( _t->getType()) {
 		case TIMES:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t320 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp141_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t308 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp123_AST_in = _t;
 			match(_t,TIMES);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t320;
+			_t = __t308;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2234 "ncoGrammer.g"
+#line 2163 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, TIMES );
-#line 897 "ncoTree.cpp"
+#line 674 "ncoTree.cpp"
 			}
 			break;
 		}
 		case DIVIDE:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t321 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp142_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t309 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp124_AST_in = _t;
 			match(_t,DIVIDE);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t321;
+			_t = __t309;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2237 "ncoGrammer.g"
+#line 2166 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, DIVIDE );
-#line 916 "ncoTree.cpp"
+#line 693 "ncoTree.cpp"
 			}
 			break;
 		}
 		case MOD:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t322 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp143_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t310 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp125_AST_in = _t;
 			match(_t,MOD);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t322;
+			_t = __t310;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2239 "ncoGrammer.g"
+#line 2168 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, MOD);
-#line 935 "ncoTree.cpp"
+#line 712 "ncoTree.cpp"
 			}
 			break;
 		}
 		case CARET:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t323 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp144_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t311 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp126_AST_in = _t;
 			match(_t,CARET);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t323;
+			_t = __t311;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2241 "ncoGrammer.g"
+#line 2170 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, CARET);
-#line 954 "ncoTree.cpp"
+#line 731 "ncoTree.cpp"
 			}
 			break;
 		}
 		case LNOT:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t324 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp145_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t312 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp127_AST_in = _t;
 			match(_t,LNOT);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
-			_t = __t324;
+			_t = __t312;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2244 "ncoGrammer.g"
+#line 2173 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,NULL_CEWI, LNOT );
-#line 971 "ncoTree.cpp"
-			}
-			break;
-		}
-		case INC:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t327 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp146_AST_in = _t;
-			match(_t,INC);
-			_t = _t->getFirstChild();
-			var1=out_asn(_t);
-			_t = _retTree;
-			_t = __t327;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2250 "ncoGrammer.g"
-				var=ncap_var_var_inc(var1,NULL_CEWI,INC,false,prs_arg);
-#line 988 "ncoTree.cpp"
-			}
-			break;
-		}
-		case DEC:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t328 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp147_AST_in = _t;
-			match(_t,DEC);
-			_t = _t->getFirstChild();
-			var1=out_asn(_t);
-			_t = _retTree;
-			_t = __t328;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2252 "ncoGrammer.g"
-				var=ncap_var_var_inc(var1,NULL_CEWI, DEC,false,prs_arg );
-#line 1005 "ncoTree.cpp"
-			}
-			break;
-		}
-		case POST_INC:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t329 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp148_AST_in = _t;
-			match(_t,POST_INC);
-			_t = _t->getFirstChild();
-			var1=out_asn(_t);
-			_t = _retTree;
-			_t = __t329;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2254 "ncoGrammer.g"
-				
-				var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,false,prs_arg);
-				
-#line 1024 "ncoTree.cpp"
-			}
-			break;
-		}
-		case POST_DEC:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t330 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp149_AST_in = _t;
-			match(_t,POST_DEC);
-			_t = _t->getFirstChild();
-			var1=out_asn(_t);
-			_t = _retTree;
-			_t = __t330;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2257 "ncoGrammer.g"
-				
-				var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,false,prs_arg);
-				
-#line 1043 "ncoTree.cpp"
+#line 748 "ncoTree.cpp"
 			}
 			break;
 		}
 		case LAND:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t331 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp150_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t319 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp128_AST_in = _t;
 			match(_t,LAND);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t331;
+			_t = __t319;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2262 "ncoGrammer.g"
+#line 2192 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, LAND );
-#line 1062 "ncoTree.cpp"
+#line 767 "ncoTree.cpp"
 			}
 			break;
 		}
 		case LOR:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t332 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp151_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t320 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp129_AST_in = _t;
 			match(_t,LOR);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t332;
+			_t = __t320;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2264 "ncoGrammer.g"
+#line 2194 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, LOR );
-#line 1081 "ncoTree.cpp"
+#line 786 "ncoTree.cpp"
 			}
 			break;
 		}
 		case LTHAN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t333 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp152_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t321 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp130_AST_in = _t;
 			match(_t,LTHAN);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t333;
+			_t = __t321;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2267 "ncoGrammer.g"
+#line 2197 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, LTHAN );
-#line 1100 "ncoTree.cpp"
+#line 805 "ncoTree.cpp"
 			}
 			break;
 		}
 		case GTHAN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t334 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp153_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t322 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp131_AST_in = _t;
 			match(_t,GTHAN);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t334;
+			_t = __t322;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2269 "ncoGrammer.g"
+#line 2199 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, GTHAN );
-#line 1119 "ncoTree.cpp"
+#line 824 "ncoTree.cpp"
 			}
 			break;
 		}
 		case GEQ:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t335 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp154_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t323 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp132_AST_in = _t;
 			match(_t,GEQ);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t335;
+			_t = __t323;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2271 "ncoGrammer.g"
+#line 2201 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, GEQ );
-#line 1138 "ncoTree.cpp"
+#line 843 "ncoTree.cpp"
 			}
 			break;
 		}
 		case LEQ:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t336 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp155_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t324 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp133_AST_in = _t;
 			match(_t,LEQ);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t336;
+			_t = __t324;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2273 "ncoGrammer.g"
+#line 2203 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, LEQ );
-#line 1157 "ncoTree.cpp"
+#line 862 "ncoTree.cpp"
 			}
 			break;
 		}
 		case EQ:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t337 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp156_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t325 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp134_AST_in = _t;
 			match(_t,EQ);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t337;
+			_t = __t325;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2275 "ncoGrammer.g"
+#line 2205 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, EQ );
-#line 1176 "ncoTree.cpp"
+#line 881 "ncoTree.cpp"
 			}
 			break;
 		}
 		case NEQ:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t338 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp157_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t326 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp135_AST_in = _t;
 			match(_t,NEQ);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t338;
+			_t = __t326;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2277 "ncoGrammer.g"
+#line 2207 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, NEQ );
-#line 1195 "ncoTree.cpp"
+#line 900 "ncoTree.cpp"
 			}
 			break;
 		}
 		case FLTHAN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t339 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp158_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t327 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp136_AST_in = _t;
 			match(_t,FLTHAN);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t339;
+			_t = __t327;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2280 "ncoGrammer.g"
+#line 2210 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, FLTHAN );
-#line 1214 "ncoTree.cpp"
+#line 919 "ncoTree.cpp"
 			}
 			break;
 		}
 		case FGTHAN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t340 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp159_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t328 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp137_AST_in = _t;
 			match(_t,FGTHAN);
 			_t = _t->getFirstChild();
 			var1=out(_t);
 			_t = _retTree;
 			var2=out(_t);
 			_t = _retTree;
-			_t = __t340;
+			_t = __t328;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2282 "ncoGrammer.g"
+#line 2212 "ncoGrammer.g"
 				var=ncap_var_var_op(var1,var2, FGTHAN );
-#line 1233 "ncoTree.cpp"
-			}
-			break;
-		}
-		case PLUS_ASSIGN:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t341 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp160_AST_in = _t;
-			match(_t,PLUS_ASSIGN);
-			_t = _t->getFirstChild();
-			pls_asn = _t;
-			if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
-			_t = _t->getNextSibling();
-			var2=out(_t);
-			_t = _retTree;
-			_t = __t341;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2284 "ncoGrammer.g"
-				
-				var1=out_asn(pls_asn);
-				var=ncap_var_var_inc(var1,var2, PLUS_ASSIGN ,(pls_asn->getType()==UTIMES), prs_arg);
-				
-#line 1256 "ncoTree.cpp"
+#line 938 "ncoTree.cpp"
 			}
 			break;
 		}
-		case MINUS_ASSIGN:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t342 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp161_AST_in = _t;
-			match(_t,MINUS_ASSIGN);
-			_t = _t->getFirstChild();
-			min_asn = _t;
-			if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
-			_t = _t->getNextSibling();
-			var2=out(_t);
-			_t = _retTree;
-			_t = __t342;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2288 "ncoGrammer.g"
-				
-				var1=out_asn(min_asn);
-				var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,(min_asn->getType()==UTIMES), prs_arg);
-				
-#line 1279 "ncoTree.cpp"
-			}
-			break;
-		}
-		case TIMES_ASSIGN:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t343 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp162_AST_in = _t;
-			match(_t,TIMES_ASSIGN);
-			_t = _t->getFirstChild();
-			tim_asn = _t;
-			if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
-			_t = _t->getNextSibling();
-			var2=out(_t);
-			_t = _retTree;
-			_t = __t343;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2292 "ncoGrammer.g"
-				
-				var1=out_asn(tim_asn);
-				var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,(tim_asn->getType()==UTIMES), prs_arg);
-				
-#line 1302 "ncoTree.cpp"
-			}
-			break;
-		}
-		case DIVIDE_ASSIGN:
-		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t344 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp163_AST_in = _t;
-			match(_t,DIVIDE_ASSIGN);
-			_t = _t->getFirstChild();
-			div_asn = _t;
-			if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
-			_t = _t->getNextSibling();
-			var2=out(_t);
-			_t = _retTree;
-			_t = __t344;
-			_t = _t->getNextSibling();
-			if ( inputState->guessing==0 ) {
-#line 2296 "ncoGrammer.g"
-					
-				var1=out_asn(div_asn);
-				var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,(div_asn->getType()==UTIMES), prs_arg);
-				
-#line 1325 "ncoTree.cpp"
-			}
-			break;
-		}
-		case ASSIGN:
+		case UTIMES:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t345 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp164_AST_in = _t;
-			match(_t,ASSIGN);
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t412 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp138_AST_in = _t;
+			match(_t,UTIMES);
 			_t = _t->getFirstChild();
-			asn = _t;
-			if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
+			attz = _t;
+			match(_t,ATT_ID);
 			_t = _t->getNextSibling();
-			_t = __t345;
+			_t = __t412;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2302 "ncoGrammer.g"
-				
-				// Check for RAM variable - if present 
-				// change tree - for example from:
-				//     ( EXPR ( = ( * n1 ) ( + four four ) ) )
-				// to  ( EXPR ( = n1 ( + four four ) ) )
-				RefAST tr;
-				bool bram;
-				NcapVar *Nvar;
-				
-				if(asn->getType()==UTIMES){
-				tr=asn->getFirstChild();
-				tr->setNextSibling(asn->getNextSibling());
-				bram=true;
-				} else { 
-				tr=asn; 
-				bram=false;
-				}
-				
-				// Die if attempting to create a RAM var 
-				// from an existing disk var   
-				Nvar= prs_arg->var_vtr.find(tr->getText());
+#line 2345 "ncoGrammer.g"
 				
-				if(bram && tr->getType()==VAR_ID && Nvar && Nvar->flg_mem==false){
-				std::string serr;
-				serr= "It is impossible to recast disk variable: \"" + tr->getText() +"\" as a RAM variable.";
-				err_prn(fnc_nm,serr );       
-				}                
+				var=out(att2var(attz));    
 				
-				if(prs_arg->ntl_scn)
-				var=assign_ntl(tr,bram); 
-				else
-				var=assign(tr,bram);
-				
-				
-#line 1376 "ncoTree.cpp"
+#line 958 "ncoTree.cpp"
 			}
 			break;
 		}
 		case WHERE_ASSIGN:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t346 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp165_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t413 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp139_AST_in = _t;
 			match(_t,WHERE_ASSIGN);
 			_t = _t->getFirstChild();
 			wasn = _t;
 			if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
 			_t = _t->getNextSibling();
-			_t = __t346;
+			_t = __t413;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2336 "ncoGrammer.g"
+#line 2351 "ncoGrammer.g"
 				
 				
 				
-#line 1396 "ncoTree.cpp"
+#line 978 "ncoTree.cpp"
 			}
 			break;
 		}
 		case QUESTION:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t347 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp166_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t414 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp140_AST_in = _t;
 			match(_t,QUESTION);
 			_t = _t->getFirstChild();
 			var1=out(_t);
@@ -1407,10 +989,10 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			qus = _t;
 			if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
 			_t = _t->getNextSibling();
-			_t = __t347;
+			_t = __t414;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2341 "ncoGrammer.g"
+#line 2356 "ncoGrammer.g"
 				
 				bool br;
 				
@@ -1427,23 +1009,23 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				}   
 				var1=nco_var_free(var1);
 				
-#line 1431 "ncoTree.cpp"
+#line 1013 "ncoTree.cpp"
 			}
 			break;
 		}
 		case FUNC:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t348 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t415 = _t;
 			m = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 			match(_t,FUNC);
 			_t = _t->getFirstChild();
 			args = _t;
 			match(_t,FUNC_ARG);
 			_t = _t->getNextSibling();
-			_t = __t348;
+			_t = __t415;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2359 "ncoGrammer.g"
+#line 2374 "ncoGrammer.g"
 				
 				// The lexer has appended the index of the function to the function name m - (name#index)
 				//  the index is into fmc_vtr  
@@ -1453,14 +1035,14 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				RefAST tr;  
 				var=prs_arg->fmc_vtr[idx].vfnc()->fnd(tr ,args, prs_arg->fmc_vtr[idx],*this); 
 				
-#line 1457 "ncoTree.cpp"
+#line 1039 "ncoTree.cpp"
 			}
 			break;
 		}
 		case DOT:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t349 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp167_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t416 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp141_AST_in = _t;
 			match(_t,DOT);
 			_t = _t->getFirstChild();
 			mtd = _t;
@@ -1472,10 +1054,10 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			margs = _t;
 			match(_t,FUNC_ARG);
 			_t = _t->getNextSibling();
-			_t = __t349;
+			_t = __t416;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2370 "ncoGrammer.g"
+#line 2385 "ncoGrammer.g"
 				
 				// The lexer has appended the index of the function to the function name m - (name#index)
 				//  the index is into fmc_vtr  
@@ -1484,7 +1066,7 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				int idx=atoi(sdx.c_str());
 				var=prs_arg->fmc_vtr[idx].vfnc()->fnd(mtd ,margs, prs_arg->fmc_vtr[idx],*this); 
 				
-#line 1488 "ncoTree.cpp"
+#line 1070 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1494,7 +1076,7 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,DIM_ID_SIZE);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2380 "ncoGrammer.g"
+#line 2395 "ncoGrammer.g"
 				
 				string sDim=dval->getText();
 				dmn_sct *dmn_fd;
@@ -1534,7 +1116,7 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				} 
 				
 				
-#line 1538 "ncoTree.cpp"
+#line 1120 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1544,11 +1126,11 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,VALUE_LIST);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2594 "ncoGrammer.g"
+#line 2636 "ncoGrammer.g"
 				
 				var=value_list(vlst);
 				
-#line 1552 "ncoTree.cpp"
+#line 1134 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1558,7 +1140,7 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NSTRING);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2599 "ncoGrammer.g"
+#line 2641 "ncoGrammer.g"
 				
 				char *tsng;
 				
@@ -1580,7 +1162,7 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				}
 				tsng=(char*)nco_free(tsng);      
 				
-#line 1584 "ncoTree.cpp"
+#line 1166 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1590,7 +1172,7 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,N4STRING);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2622 "ncoGrammer.g"
+#line 2664 "ncoGrammer.g"
 				
 				char *tsng;
 				
@@ -1618,7 +1200,7 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				}
 				tsng=(char*)nco_free(tsng);      
 				
-#line 1622 "ncoTree.cpp"
+#line 1204 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1628,9 +1210,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_FLOAT);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2652 "ncoGrammer.g"
+#line 2694 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~float"),(nc_type)NC_FLOAT,false); else var=ncap_sclr_var_mk(SCS("~float"),static_cast<float>(std::strtod(val_float->getText().c_str(),(char **)NULL)));
-#line 1634 "ncoTree.cpp"
+#line 1216 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1640,9 +1222,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_DOUBLE);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2654 "ncoGrammer.g"
+#line 2696 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~double"),(nc_type)NC_DOUBLE,false); else var=ncap_sclr_var_mk(SCS("~double"),strtod(val_double->getText().c_str(),(char **)NULL));
-#line 1646 "ncoTree.cpp"
+#line 1228 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1652,9 +1234,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_INT);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2656 "ncoGrammer.g"
+#line 2698 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~int"),(nc_type)NC_INT,false); else var=ncap_sclr_var_mk(SCS("~int"),static_cast<nco_int>(std::strtol(val_int->getText().c_str(),(char **)NULL,NCO_SNG_CNV_BASE10)));
-#line 1658 "ncoTree.cpp"
+#line 1240 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1664,9 +1246,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_SHORT);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2658 "ncoGrammer.g"
+#line 2700 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~short"),(nc_type)NC_SHORT,false); else var=ncap_sclr_var_mk(SCS("~short"),static_cast<nco_short>(std::strtol(val_short->getText().c_str(),(char **)NULL,NCO_SNG_CNV_BASE10)));
-#line 1670 "ncoTree.cpp"
+#line 1252 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1676,9 +1258,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_BYTE);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2660 "ncoGrammer.g"
+#line 2702 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~byte"),(nc_type)NC_BYTE,false); else var=ncap_sclr_var_mk(SCS("~byte"),static_cast<nco_byte>(std::strtol(val_byte->getText().c_str(),(char **)NULL,NCO_SNG_CNV_BASE10)));
-#line 1682 "ncoTree.cpp"
+#line 1264 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1688,9 +1270,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_UBYTE);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2665 "ncoGrammer.g"
+#line 2707 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~ubyte"),(nc_type)NC_UBYTE,false); else var=ncap_sclr_var_mk(SCS("~ubyte"),static_cast<nco_ubyte>(std::strtoul(val_ubyte->getText().c_str(),(char **)NULL,NCO_SNG_CNV_BASE10)));
-#line 1694 "ncoTree.cpp"
+#line 1276 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1700,9 +1282,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_USHORT);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2669 "ncoGrammer.g"
+#line 2711 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~ushort"),(nc_type)NC_USHORT,false); else var=ncap_sclr_var_mk(SCS("~ushort"),static_cast<nco_ushort>(std::strtoul(val_ushort->getText().c_str(),(char **)NULL,NCO_SNG_CNV_BASE10)));
-#line 1706 "ncoTree.cpp"
+#line 1288 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1712,9 +1294,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_UINT);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2671 "ncoGrammer.g"
+#line 2713 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~uint"),(nc_type)NC_UINT,false); else var=ncap_sclr_var_mk(SCS("~uint"),static_cast<nco_uint>(std::strtoul(val_uint->getText().c_str(),(char **)NULL,NCO_SNG_CNV_BASE10)));
-#line 1718 "ncoTree.cpp"
+#line 1300 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1724,9 +1306,9 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_INT64);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2673 "ncoGrammer.g"
+#line 2715 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~int64"),(nc_type)NC_INT64,false); else var=ncap_sclr_var_mk(SCS("~int64"),sng2nbr(val_int64->getText(),nco_int64_CEWI));
-#line 1730 "ncoTree.cpp"
+#line 1312 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -1736,615 +1318,1711 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,NCAP_UINT64);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2677 "ncoGrammer.g"
+#line 2719 "ncoGrammer.g"
 				if(prs_arg->ntl_scn) var=ncap_sclr_var_mk(SCS("~uint64"),(nc_type)NC_UINT64,false); else var=ncap_sclr_var_mk(SCS("~uint64"),sng2nbr(val_uint64->getText(),nco_uint64_CEWI));
-#line 1742 "ncoTree.cpp"
+#line 1324 "ncoTree.cpp"
 			}
 			break;
 		}
 		default:
-			bool synPredMatched290 = false;
+			bool synPredMatched278 = false;
 			if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 				_t = ASTNULL;
 			if (((_t->getType() == PLUS))) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t290 = _t;
-				synPredMatched290 = true;
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t278 = _t;
+				synPredMatched278 = true;
 				inputState->guessing++;
 				try {
 					{
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t289 = _t;
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp168_AST_in = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t277 = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST tmp142_AST_in = _t;
 					match(_t,PLUS);
 					_t = _t->getFirstChild();
 					out(_t);
 					_t = _retTree;
 					out(_t);
 					_t = _retTree;
-					_t = __t289;
+					_t = __t277;
 					_t = _t->getNextSibling();
 					}
 				}
 				catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-					synPredMatched290 = false;
+					synPredMatched278 = false;
 				}
-				_t = __t290;
+				_t = __t278;
 				inputState->guessing--;
 			}
-			if ( synPredMatched290 ) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t291 = _t;
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp169_AST_in = _t;
+			if ( synPredMatched278 ) {
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t279 = _t;
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp143_AST_in = _t;
 				match(_t,PLUS);
 				_t = _t->getFirstChild();
 				var1=out(_t);
 				_t = _retTree;
 				var2=out(_t);
 				_t = _retTree;
-				_t = __t291;
+				_t = __t279;
 				_t = _t->getNextSibling();
 				if ( inputState->guessing==0 ) {
-#line 2217 "ncoGrammer.g"
+#line 2143 "ncoGrammer.g"
 					var=ncap_var_var_op(var1,var2, PLUS );
-#line 1788 "ncoTree.cpp"
+#line 1370 "ncoTree.cpp"
 				}
 			}
 			else {
-				bool synPredMatched294 = false;
+				bool synPredMatched282 = false;
 				if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 					_t = ASTNULL;
 				if (((_t->getType() == MINUS))) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t294 = _t;
-					synPredMatched294 = true;
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t282 = _t;
+					synPredMatched282 = true;
 					inputState->guessing++;
 					try {
 						{
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t293 = _t;
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp170_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t281 = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp144_AST_in = _t;
 						match(_t,MINUS);
 						_t = _t->getFirstChild();
 						out(_t);
 						_t = _retTree;
 						out(_t);
 						_t = _retTree;
-						_t = __t293;
+						_t = __t281;
 						_t = _t->getNextSibling();
 						}
 					}
 					catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-						synPredMatched294 = false;
+						synPredMatched282 = false;
 					}
-					_t = __t294;
+					_t = __t282;
 					inputState->guessing--;
 				}
-				if ( synPredMatched294 ) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t295 = _t;
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp171_AST_in = _t;
+				if ( synPredMatched282 ) {
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t283 = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST tmp145_AST_in = _t;
 					match(_t,MINUS);
 					_t = _t->getFirstChild();
 					var1=out(_t);
 					_t = _retTree;
 					var2=out(_t);
 					_t = _retTree;
-					_t = __t295;
+					_t = __t283;
 					_t = _t->getNextSibling();
 					if ( inputState->guessing==0 ) {
-#line 2219 "ncoGrammer.g"
+#line 2145 "ncoGrammer.g"
 						var=ncap_var_var_op(var1,var2, MINUS );
-#line 1833 "ncoTree.cpp"
+#line 1415 "ncoTree.cpp"
 					}
 				}
 				else {
-					bool synPredMatched299 = false;
+					bool synPredMatched287 = false;
 					if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 						_t = ASTNULL;
-					if (((_t->getType() == UTIMES))) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t299 = _t;
-						synPredMatched299 = true;
+					if (((_t->getType() == POST_INC))) {
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t287 = _t;
+						synPredMatched287 = true;
 						inputState->guessing++;
 						try {
 							{
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t297 = _t;
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp172_AST_in = _t;
-							match(_t,UTIMES);
-							_t = _t->getFirstChild();
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t298 = _t;
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp173_AST_in = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST __t285 = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp146_AST_in = _t;
 							match(_t,POST_INC);
 							_t = _t->getFirstChild();
-							out(_t);
-							_t = _retTree;
-							_t = __t298;
+							ANTLR_USE_NAMESPACE(antlr)RefAST __t286 = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp147_AST_in = _t;
+							match(_t,UTIMES);
+							_t = _t->getFirstChild();
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp148_AST_in = _t;
+							match(_t,ATT_ID);
+							_t = _t->getNextSibling();
+							_t = __t286;
 							_t = _t->getNextSibling();
-							_t = __t297;
+							_t = __t285;
 							_t = _t->getNextSibling();
 							}
 						}
 						catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-							synPredMatched299 = false;
+							synPredMatched287 = false;
 						}
-						_t = __t299;
+						_t = __t287;
 						inputState->guessing--;
 					}
-					if ( synPredMatched299 ) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t300 = _t;
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp174_AST_in = _t;
-						match(_t,UTIMES);
-						_t = _t->getFirstChild();
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t301 = _t;
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp175_AST_in = _t;
+					if ( synPredMatched287 ) {
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t288 = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp149_AST_in = _t;
 						match(_t,POST_INC);
 						_t = _t->getFirstChild();
-						var1=out_asn(_t);
-						_t = _retTree;
-						_t = __t301;
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t289 = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp150_AST_in = _t;
+						match(_t,UTIMES);
+						_t = _t->getFirstChild();
+						aposti = _t;
+						match(_t,ATT_ID);
+						_t = _t->getNextSibling();
+						_t = __t289;
 						_t = _t->getNextSibling();
-						_t = __t300;
+						_t = __t288;
 						_t = _t->getNextSibling();
 						if ( inputState->guessing==0 ) {
-#line 2220 "ncoGrammer.g"
+#line 2146 "ncoGrammer.g"
 							
-							var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,true,prs_arg);      
+							var1=out(att2var(aposti));     
+							var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,false,bret,prs_arg);      
 							
-#line 1888 "ncoTree.cpp"
+#line 1473 "ncoTree.cpp"
 						}
 					}
 					else {
-						bool synPredMatched305 = false;
+						bool synPredMatched293 = false;
 						if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 							_t = ASTNULL;
-						if (((_t->getType() == UTIMES))) {
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t305 = _t;
-							synPredMatched305 = true;
+						if (((_t->getType() == POST_DEC))) {
+							ANTLR_USE_NAMESPACE(antlr)RefAST __t293 = _t;
+							synPredMatched293 = true;
 							inputState->guessing++;
 							try {
 								{
-								ANTLR_USE_NAMESPACE(antlr)RefAST __t303 = _t;
-								ANTLR_USE_NAMESPACE(antlr)RefAST tmp176_AST_in = _t;
-								match(_t,UTIMES);
-								_t = _t->getFirstChild();
-								ANTLR_USE_NAMESPACE(antlr)RefAST __t304 = _t;
-								ANTLR_USE_NAMESPACE(antlr)RefAST tmp177_AST_in = _t;
+								ANTLR_USE_NAMESPACE(antlr)RefAST __t291 = _t;
+								ANTLR_USE_NAMESPACE(antlr)RefAST tmp151_AST_in = _t;
 								match(_t,POST_DEC);
 								_t = _t->getFirstChild();
-								out(_t);
-								_t = _retTree;
-								_t = __t304;
+								ANTLR_USE_NAMESPACE(antlr)RefAST __t292 = _t;
+								ANTLR_USE_NAMESPACE(antlr)RefAST tmp152_AST_in = _t;
+								match(_t,UTIMES);
+								_t = _t->getFirstChild();
+								ANTLR_USE_NAMESPACE(antlr)RefAST tmp153_AST_in = _t;
+								match(_t,ATT_ID);
 								_t = _t->getNextSibling();
-								_t = __t303;
+								_t = __t292;
+								_t = _t->getNextSibling();
+								_t = __t291;
 								_t = _t->getNextSibling();
 								}
 							}
 							catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-								synPredMatched305 = false;
+								synPredMatched293 = false;
 							}
-							_t = __t305;
+							_t = __t293;
 							inputState->guessing--;
 						}
-						if ( synPredMatched305 ) {
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t306 = _t;
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp178_AST_in = _t;
-							match(_t,UTIMES);
-							_t = _t->getFirstChild();
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t307 = _t;
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp179_AST_in = _t;
+						if ( synPredMatched293 ) {
+							ANTLR_USE_NAMESPACE(antlr)RefAST __t294 = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp154_AST_in = _t;
 							match(_t,POST_DEC);
 							_t = _t->getFirstChild();
-							var1=out_asn(_t);
-							_t = _retTree;
-							_t = __t307;
+							ANTLR_USE_NAMESPACE(antlr)RefAST __t295 = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp155_AST_in = _t;
+							match(_t,UTIMES);
+							_t = _t->getFirstChild();
+							apostd = _t;
+							match(_t,ATT_ID);
+							_t = _t->getNextSibling();
+							_t = __t295;
 							_t = _t->getNextSibling();
-							_t = __t306;
+							_t = __t294;
 							_t = _t->getNextSibling();
 							if ( inputState->guessing==0 ) {
-#line 2223 "ncoGrammer.g"
+#line 2150 "ncoGrammer.g"
 								
-								var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,true,prs_arg);      
+								var1=out(att2var(apostd));     
+								var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,false,bret,prs_arg);      
 								
-#line 1943 "ncoTree.cpp"
+#line 1531 "ncoTree.cpp"
 							}
 						}
 						else {
-							bool synPredMatched311 = false;
+							bool synPredMatched299 = false;
 							if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 								_t = ASTNULL;
-							if (((_t->getType() == UTIMES))) {
-								ANTLR_USE_NAMESPACE(antlr)RefAST __t311 = _t;
-								synPredMatched311 = true;
+							if (((_t->getType() == INC))) {
+								ANTLR_USE_NAMESPACE(antlr)RefAST __t299 = _t;
+								synPredMatched299 = true;
 								inputState->guessing++;
 								try {
 									{
-									ANTLR_USE_NAMESPACE(antlr)RefAST __t309 = _t;
-									ANTLR_USE_NAMESPACE(antlr)RefAST tmp180_AST_in = _t;
-									match(_t,UTIMES);
-									_t = _t->getFirstChild();
-									ANTLR_USE_NAMESPACE(antlr)RefAST __t310 = _t;
-									ANTLR_USE_NAMESPACE(antlr)RefAST tmp181_AST_in = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t297 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp156_AST_in = _t;
 									match(_t,INC);
 									_t = _t->getFirstChild();
-									out(_t);
-									_t = _retTree;
-									_t = __t310;
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t298 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp157_AST_in = _t;
+									match(_t,UTIMES);
+									_t = _t->getFirstChild();
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp158_AST_in = _t;
+									match(_t,ATT_ID);
 									_t = _t->getNextSibling();
-									_t = __t309;
+									_t = __t298;
+									_t = _t->getNextSibling();
+									_t = __t297;
 									_t = _t->getNextSibling();
 									}
 								}
 								catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-									synPredMatched311 = false;
+									synPredMatched299 = false;
 								}
-								_t = __t311;
+								_t = __t299;
 								inputState->guessing--;
 							}
-							if ( synPredMatched311 ) {
-								ANTLR_USE_NAMESPACE(antlr)RefAST __t312 = _t;
-								ANTLR_USE_NAMESPACE(antlr)RefAST tmp182_AST_in = _t;
-								match(_t,UTIMES);
-								_t = _t->getFirstChild();
-								ANTLR_USE_NAMESPACE(antlr)RefAST __t313 = _t;
-								ANTLR_USE_NAMESPACE(antlr)RefAST tmp183_AST_in = _t;
+							if ( synPredMatched299 ) {
+								ANTLR_USE_NAMESPACE(antlr)RefAST __t300 = _t;
+								ANTLR_USE_NAMESPACE(antlr)RefAST tmp159_AST_in = _t;
 								match(_t,INC);
 								_t = _t->getFirstChild();
-								var1=out_asn(_t);
-								_t = _retTree;
-								_t = __t313;
+								ANTLR_USE_NAMESPACE(antlr)RefAST __t301 = _t;
+								ANTLR_USE_NAMESPACE(antlr)RefAST tmp160_AST_in = _t;
+								match(_t,UTIMES);
+								_t = _t->getFirstChild();
+								aprei = _t;
+								match(_t,ATT_ID);
+								_t = _t->getNextSibling();
+								_t = __t301;
 								_t = _t->getNextSibling();
-								_t = __t312;
+								_t = __t300;
 								_t = _t->getNextSibling();
 								if ( inputState->guessing==0 ) {
-#line 2226 "ncoGrammer.g"
+#line 2154 "ncoGrammer.g"
 									
-									var=ncap_var_var_inc(var1,NULL_CEWI,INC,true,prs_arg);      
+									var1=out(att2var(aprei));     
+									var=ncap_var_var_inc(var1,NULL_CEWI,INC,false,bret,prs_arg);      
 									
-#line 1998 "ncoTree.cpp"
+#line 1589 "ncoTree.cpp"
 								}
 							}
 							else {
-								bool synPredMatched317 = false;
+								bool synPredMatched305 = false;
 								if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 									_t = ASTNULL;
-								if (((_t->getType() == UTIMES))) {
-									ANTLR_USE_NAMESPACE(antlr)RefAST __t317 = _t;
-									synPredMatched317 = true;
+								if (((_t->getType() == DEC))) {
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t305 = _t;
+									synPredMatched305 = true;
 									inputState->guessing++;
 									try {
 										{
-										ANTLR_USE_NAMESPACE(antlr)RefAST __t315 = _t;
-										ANTLR_USE_NAMESPACE(antlr)RefAST tmp184_AST_in = _t;
-										match(_t,UTIMES);
-										_t = _t->getFirstChild();
-										ANTLR_USE_NAMESPACE(antlr)RefAST __t316 = _t;
-										ANTLR_USE_NAMESPACE(antlr)RefAST tmp185_AST_in = _t;
+										ANTLR_USE_NAMESPACE(antlr)RefAST __t303 = _t;
+										ANTLR_USE_NAMESPACE(antlr)RefAST tmp161_AST_in = _t;
 										match(_t,DEC);
 										_t = _t->getFirstChild();
-										out(_t);
-										_t = _retTree;
-										_t = __t316;
+										ANTLR_USE_NAMESPACE(antlr)RefAST __t304 = _t;
+										ANTLR_USE_NAMESPACE(antlr)RefAST tmp162_AST_in = _t;
+										match(_t,UTIMES);
+										_t = _t->getFirstChild();
+										ANTLR_USE_NAMESPACE(antlr)RefAST tmp163_AST_in = _t;
+										match(_t,ATT_ID);
+										_t = _t->getNextSibling();
+										_t = __t304;
 										_t = _t->getNextSibling();
-										_t = __t315;
+										_t = __t303;
 										_t = _t->getNextSibling();
 										}
 									}
 									catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-										synPredMatched317 = false;
+										synPredMatched305 = false;
 									}
-									_t = __t317;
+									_t = __t305;
 									inputState->guessing--;
 								}
-								if ( synPredMatched317 ) {
-									ANTLR_USE_NAMESPACE(antlr)RefAST __t318 = _t;
-									ANTLR_USE_NAMESPACE(antlr)RefAST tmp186_AST_in = _t;
-									match(_t,UTIMES);
-									_t = _t->getFirstChild();
-									ANTLR_USE_NAMESPACE(antlr)RefAST __t319 = _t;
-									ANTLR_USE_NAMESPACE(antlr)RefAST tmp187_AST_in = _t;
+								if ( synPredMatched305 ) {
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t306 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp164_AST_in = _t;
 									match(_t,DEC);
 									_t = _t->getFirstChild();
-									var1=out_asn(_t);
-									_t = _retTree;
-									_t = __t319;
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t307 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp165_AST_in = _t;
+									match(_t,UTIMES);
+									_t = _t->getFirstChild();
+									apred = _t;
+									match(_t,ATT_ID);
 									_t = _t->getNextSibling();
-									_t = __t318;
+									_t = __t307;
+									_t = _t->getNextSibling();
+									_t = __t306;
 									_t = _t->getNextSibling();
 									if ( inputState->guessing==0 ) {
-#line 2229 "ncoGrammer.g"
+#line 2158 "ncoGrammer.g"
 										
-										var=ncap_var_var_inc(var1,NULL_CEWI,DEC,true,prs_arg);      
+										var1=out(att2var(apred));     
+										var=ncap_var_var_inc(var1,NULL_CEWI,DEC,false,bret,prs_arg);      
 										
-#line 2053 "ncoTree.cpp"
+#line 1647 "ncoTree.cpp"
 									}
 								}
 								else if ((_t->getType() == MINUS)) {
-									ANTLR_USE_NAMESPACE(antlr)RefAST __t325 = _t;
-									ANTLR_USE_NAMESPACE(antlr)RefAST tmp188_AST_in = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t313 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp166_AST_in = _t;
 									match(_t,MINUS);
 									_t = _t->getFirstChild();
 									var1=out(_t);
 									_t = _retTree;
-									_t = __t325;
+									_t = __t313;
 									_t = _t->getNextSibling();
 									if ( inputState->guessing==0 ) {
-#line 2246 "ncoGrammer.g"
+#line 2175 "ncoGrammer.g"
 										var=ncap_var_var_op(var1,NULL_CEWI, MINUS );
-#line 2068 "ncoTree.cpp"
+#line 1662 "ncoTree.cpp"
 									}
 								}
 								else if ((_t->getType() == PLUS)) {
-									ANTLR_USE_NAMESPACE(antlr)RefAST __t326 = _t;
-									ANTLR_USE_NAMESPACE(antlr)RefAST tmp189_AST_in = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t314 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp167_AST_in = _t;
 									match(_t,PLUS);
 									_t = _t->getFirstChild();
 									var1=out(_t);
 									_t = _retTree;
-									_t = __t326;
+									_t = __t314;
+									_t = _t->getNextSibling();
+								}
+								else if ((_t->getType() == INC)) {
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t315 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp168_AST_in = _t;
+									match(_t,INC);
+									_t = _t->getFirstChild();
+									var1=out_asn(_t);
+									_t = _retTree;
+									_t = __t315;
 									_t = _t->getNextSibling();
+									if ( inputState->guessing==0 ) {
+#line 2179 "ncoGrammer.g"
+										var=ncap_var_var_inc(var1,NULL_CEWI,INC,false,bret,prs_arg);
+#line 1687 "ncoTree.cpp"
+									}
+								}
+								else if ((_t->getType() == DEC)) {
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t316 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp169_AST_in = _t;
+									match(_t,DEC);
+									_t = _t->getFirstChild();
+									var1=out_asn(_t);
+									_t = _retTree;
+									_t = __t316;
+									_t = _t->getNextSibling();
+									if ( inputState->guessing==0 ) {
+#line 2182 "ncoGrammer.g"
+										var=ncap_var_var_inc(var1,NULL_CEWI, DEC,false,bret,prs_arg );
+#line 1702 "ncoTree.cpp"
+									}
+								}
+								else if ((_t->getType() == POST_INC)) {
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t317 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp170_AST_in = _t;
+									match(_t,POST_INC);
+									_t = _t->getFirstChild();
+									var1=out_asn(_t);
+									_t = _retTree;
+									_t = __t317;
+									_t = _t->getNextSibling();
+									if ( inputState->guessing==0 ) {
+#line 2184 "ncoGrammer.g"
+										
+										var=ncap_var_var_inc(var1,NULL_CEWI,POST_INC,false,bret,prs_arg);
+										
+#line 1719 "ncoTree.cpp"
+									}
+								}
+								else if ((_t->getType() == POST_DEC)) {
+									ANTLR_USE_NAMESPACE(antlr)RefAST __t318 = _t;
+									ANTLR_USE_NAMESPACE(antlr)RefAST tmp171_AST_in = _t;
+									match(_t,POST_DEC);
+									_t = _t->getFirstChild();
+									var1=out_asn(_t);
+									_t = _retTree;
+									_t = __t318;
+									_t = _t->getNextSibling();
+									if ( inputState->guessing==0 ) {
+#line 2187 "ncoGrammer.g"
+										
+										var=ncap_var_var_inc(var1,NULL_CEWI,POST_DEC,false,bret,prs_arg);
+										
+#line 1736 "ncoTree.cpp"
+									}
 								}
 								else {
-									bool synPredMatched352 = false;
+									bool synPredMatched332 = false;
 									if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 										_t = ASTNULL;
-									if (((_t->getType() == VAR_ID))) {
-										ANTLR_USE_NAMESPACE(antlr)RefAST __t352 = _t;
-										synPredMatched352 = true;
+									if (((_t->getType() == PLUS_ASSIGN))) {
+										ANTLR_USE_NAMESPACE(antlr)RefAST __t332 = _t;
+										synPredMatched332 = true;
 										inputState->guessing++;
 										try {
 											{
-											ANTLR_USE_NAMESPACE(antlr)RefAST __t351 = _t;
-											ANTLR_USE_NAMESPACE(antlr)RefAST tmp190_AST_in = _t;
-											match(_t,VAR_ID);
+											ANTLR_USE_NAMESPACE(antlr)RefAST __t330 = _t;
+											ANTLR_USE_NAMESPACE(antlr)RefAST tmp172_AST_in = _t;
+											match(_t,PLUS_ASSIGN);
 											_t = _t->getFirstChild();
-											ANTLR_USE_NAMESPACE(antlr)RefAST tmp191_AST_in = _t;
-											match(_t,LMT_LIST);
-											_t = _t->getNextSibling();
-											_t = __t351;
+											{
+											if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+												_t = ASTNULL;
+											switch ( _t->getType()) {
+											case VAR_ID:
+											{
+												ANTLR_USE_NAMESPACE(antlr)RefAST tmp173_AST_in = _t;
+												match(_t,VAR_ID);
+												_t = _t->getNextSibling();
+												break;
+											}
+											case ATT_ID:
+											{
+												ANTLR_USE_NAMESPACE(antlr)RefAST tmp174_AST_in = _t;
+												match(_t,ATT_ID);
+												_t = _t->getNextSibling();
+												break;
+											}
+											default:
+											{
+												throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
+											}
+											}
+											}
+											var2=out(_t);
+											_t = _retTree;
+											_t = __t330;
 											_t = _t->getNextSibling();
 											}
 										}
 										catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-											synPredMatched352 = false;
+											synPredMatched332 = false;
 										}
-										_t = __t352;
+										_t = __t332;
 										inputState->guessing--;
 									}
-									if ( synPredMatched352 ) {
-										ANTLR_USE_NAMESPACE(antlr)RefAST __t353 = _t;
-										vid = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
-										match(_t,VAR_ID);
+									if ( synPredMatched332 ) {
+										ANTLR_USE_NAMESPACE(antlr)RefAST __t333 = _t;
+										ANTLR_USE_NAMESPACE(antlr)RefAST tmp175_AST_in = _t;
+										match(_t,PLUS_ASSIGN);
 										_t = _t->getFirstChild();
-										lmt = _t;
-										match(_t,LMT_LIST);
-										_t = _t->getNextSibling();
-										_t = __t353;
+										var1=out(_t);
+										_t = _retTree;
+										var2=out(_t);
+										_t = _retTree;
+										_t = __t333;
 										_t = _t->getNextSibling();
 										if ( inputState->guessing==0 ) {
-#line 2421 "ncoGrammer.g"
-											
-													
-													    // fxm: 4 Oct 2015
-														/*
-														  the following is valid syntx var_nm(array_var)-
-														  array_var now contains all the indices - that is 
-														  srt vectors  
-														  srt & end vectors
-														  srt,end,srd vectors
-														
-														  so for now indexing into a multi-dmensional var using a single index has
-														  temporarily been disabled
-														
-											// see if hyperslab limit is a single value
-											if(lmt->getNumberOfChildren()==1 && 
-											lmt->getFirstChild()->getNumberOfChildren()==1 &&
-											lmt->getFirstChild()->getFirstChild()->getType() != COLON)
-											
-											var=var_lmt_one(vid);
-											else   
-											var=var_lmt(vid);
-											*/
-											var=var_lmt(vid);  
-											
-											
-											
-#line 2146 "ncoTree.cpp"
-										}
-									}
-									else {
-										bool synPredMatched356 = false;
-										if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
-											_t = ASTNULL;
-										if (((_t->getType() == ATT_ID))) {
-											ANTLR_USE_NAMESPACE(antlr)RefAST __t356 = _t;
-											synPredMatched356 = true;
-											inputState->guessing++;
-											try {
-												{
-												ANTLR_USE_NAMESPACE(antlr)RefAST __t355 = _t;
-												ANTLR_USE_NAMESPACE(antlr)RefAST tmp192_AST_in = _t;
-												match(_t,ATT_ID);
-												_t = _t->getFirstChild();
-												ANTLR_USE_NAMESPACE(antlr)RefAST tmp193_AST_in = _t;
-												match(_t,LMT_LIST);
-												_t = _t->getNextSibling();
-												_t = __t355;
-												_t = _t->getNextSibling();
-												}
-											}
-											catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-												synPredMatched356 = false;
-											}
-											_t = __t356;
-											inputState->guessing--;
-										}
-										if ( synPredMatched356 ) {
-											ANTLR_USE_NAMESPACE(antlr)RefAST __t357 = _t;
-											attl = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
-											match(_t,ATT_ID);
-											_t = _t->getFirstChild();
-											lmtl = _t;
-											match(_t,LMT_LIST);
-											_t = _t->getNextSibling();
-											_t = __t357;
-											_t = _t->getNextSibling();
-											if ( inputState->guessing==0 ) {
-#line 2449 "ncoGrammer.g"
-												
-												
-												std::string att_nm=attl->getText();
-												std::string fnc_nm("att_lmt"); 
-												NcapVar *Nvar=NULL;
-												NcapVector<lmt_sct*> lmt_vtr;
-												
-												var_sct *var_att=NULL_CEWI; 
-												
-												
-												if(prs_arg->ntl_scn)
-												{ 
-												// only final scan for this attribute hyperslab 
-												var=ncap_var_udf(att_nm.c_str());
-												// can't return here -- have to use goto
-												goto attl_end; 
-												} 
-												
-												Nvar=prs_arg->var_vtr.find(attl->getText());
-												
-												if(Nvar!=NULL)
-												var_att=nco_var_dpl(Nvar->var);
-												else    
-												var_att=ncap_att_init(att_nm,prs_arg);
-												
-												
-												if(var_att==NULL_CEWI )
-												err_prn(fnc_nm,"Unable to locate attribute " +att_nm+ " in input or output files.");
-												
-														    lmt_mk(1L,lmtl,lmt_vtr);
-												
-												
-												if( lmt_vtr.size() != 1)
-												err_prn(fnc_nm,"Number of hyperslab limits for an attribute "+ att_nm+"must be one ");
-												
-												// fxm - very soon  
-												lmt_vtr[0]->nm=strdup("zz at attribute");    
-												(void)ncap_lmt_evl(1,lmt_vtr[0],var_att->sz,prs_arg); 
-												
-												// we have something to hyperslab
-												if( lmt_vtr[0]->cnt > 0)
-												{  
-												char *cp_in;
-												char *cp_out;  
-												long idx;
-												long srt=lmt_vtr[0]->srt;
-												long cnt=lmt_vtr[0]->cnt;
-												long srd=lmt_vtr[0]->srd; 
-												size_t slb_sz=nco_typ_lng(var_att->type); 
-												
-												/* create output att */
-												var=ncap_sclr_var_mk(att_nm,var_att->type,true);                 
-												(void)ncap_att_stretch(var,cnt);     
-												
-												cp_in=(char*)( var_att->val.vp); 
-												cp_in+= (ptrdiff_t)slb_sz*srt;
-												cp_out=(char*)var->val.vp; 
-												
-												idx=0;
-												
-												while(idx++ < cnt )
-												{ 
-												memcpy(cp_out, cp_in, slb_sz);                   
-												cp_in+=srd*slb_sz;
-												cp_out+=slb_sz; 
-												} 
-												
-												// if type NC_STRING then realloc ragged array  
-												if(var_att->type==NC_STRING)
-												{ 
-												idx=0;  
-												(void)cast_void_nctype((nc_type)NC_STRING,&var->val);                  
-												
-												while(idx<cnt)
-												var->val.sngp[idx]=strdup(var->val.sngp[idx++]);    
-												
-												
-												(void)cast_nctype_void((nc_type)NC_STRING,&var->val); 
-												
-												}  
-												
-												
-												}
-												else
+#line 2220 "ncoGrammer.g"
+											
+											var=ncap_var_var_inc(var1,var2,PLUS_ASSIGN ,false, bret,prs_arg);
+											
+#line 1805 "ncoTree.cpp"
+										}
+									}
+									else {
+										bool synPredMatched337 = false;
+										if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+											_t = ASTNULL;
+										if (((_t->getType() == PLUS_ASSIGN))) {
+											ANTLR_USE_NAMESPACE(antlr)RefAST __t337 = _t;
+											synPredMatched337 = true;
+											inputState->guessing++;
+											try {
 												{
-												err_prn(fnc_nm,"Hyperslab limits for attribute "+ att_nm+" doesn't include any elements");  
+												ANTLR_USE_NAMESPACE(antlr)RefAST __t335 = _t;
+												ANTLR_USE_NAMESPACE(antlr)RefAST tmp176_AST_in = _t;
+												match(_t,PLUS_ASSIGN);
+												_t = _t->getFirstChild();
+												ANTLR_USE_NAMESPACE(antlr)RefAST __t336 = _t;
+												ANTLR_USE_NAMESPACE(antlr)RefAST tmp177_AST_in = _t;
+												match(_t,UTIMES);
+												_t = _t->getFirstChild();
+												ANTLR_USE_NAMESPACE(antlr)RefAST tmp178_AST_in = _t;
+												match(_t,VAR_ID);
+												_t = _t->getNextSibling();
+												_t = __t336;
+												_t = _t->getNextSibling();
+												var2=out(_t);
+												_t = _retTree;
+												_t = __t335;
+												_t = _t->getNextSibling();
 												}
-												
-												nco_var_free(var_att);    
-												
-												attl_end: ; 
-												
-#line 2280 "ncoTree.cpp"
 											}
+											catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+												synPredMatched337 = false;
+											}
+											_t = __t337;
+											inputState->guessing--;
 										}
-										else if ((_t->getType() == VAR_ID)) {
-											v = _t;
-											match(_t,VAR_ID);
+										if ( synPredMatched337 ) {
+											ANTLR_USE_NAMESPACE(antlr)RefAST __t338 = _t;
+											ANTLR_USE_NAMESPACE(antlr)RefAST tmp179_AST_in = _t;
+											match(_t,PLUS_ASSIGN);
+											_t = _t->getFirstChild();
+											ANTLR_USE_NAMESPACE(antlr)RefAST __t339 = _t;
+											ANTLR_USE_NAMESPACE(antlr)RefAST tmp180_AST_in = _t;
+											match(_t,UTIMES);
+											_t = _t->getFirstChild();
+											var1=out(_t);
+											_t = _retTree;
+											_t = __t339;
+											_t = _t->getNextSibling();
+											var2=out(_t);
+											_t = _retTree;
+											_t = __t338;
 											_t = _t->getNextSibling();
 											if ( inputState->guessing==0 ) {
-#line 2546 "ncoGrammer.g"
-												
+#line 2224 "ncoGrammer.g"
 												
-												var=prs_arg->ncap_var_init(v->getText(),true);
-												if(var== NULL){
-												if(prs_arg->ntl_scn){
-												var=ncap_var_udf(v->getText().c_str());
-												return var;
-												}else
-												nco_exit(EXIT_FAILURE);
-												}
-												
-												// apply cast only if sz >1 
-												if(bcst && var->sz >1)
-												var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);
+												var=ncap_var_var_inc(var1,var2, PLUS_ASSIGN ,true, bret,prs_arg);
 												
-#line 2304 "ncoTree.cpp"
+#line 1865 "ncoTree.cpp"
 											}
 										}
-										else if ((_t->getType() == ATT_ID)) {
-											att = _t;
-											match(_t,ATT_ID);
-											_t = _t->getNextSibling();
-											if ( inputState->guessing==0 ) {
-#line 2563 "ncoGrammer.g"
-												
-												
-												NcapVar *Nvar=NULL;
-												
-												if(prs_arg->ntl_scn)
-												Nvar=prs_arg->int_vtr.find(att->getText());
-												
-												if(Nvar==NULL) 
-												Nvar=prs_arg->var_vtr.find(att->getText());
-												
-												var=NULL_CEWI;    
-												if(Nvar !=NULL)
-												var=nco_var_dpl(Nvar->var);
-												else    
-												// Check input file for attribute
-												var=ncap_att_init(att->getText(),prs_arg);
-												
-												if(!prs_arg->ntl_scn && var==NULL_CEWI ){
-												err_prn(fnc_nm,"Unable to locate attribute " +att->getText()+ " in input or output files.");
+										else {
+											bool synPredMatched343 = false;
+											if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+												_t = ASTNULL;
+											if (((_t->getType() == PLUS_ASSIGN))) {
+												ANTLR_USE_NAMESPACE(antlr)RefAST __t343 = _t;
+												synPredMatched343 = true;
+												inputState->guessing++;
+												try {
+													{
+													ANTLR_USE_NAMESPACE(antlr)RefAST __t341 = _t;
+													ANTLR_USE_NAMESPACE(antlr)RefAST tmp181_AST_in = _t;
+													match(_t,PLUS_ASSIGN);
+													_t = _t->getFirstChild();
+													ANTLR_USE_NAMESPACE(antlr)RefAST __t342 = _t;
+													ANTLR_USE_NAMESPACE(antlr)RefAST tmp182_AST_in = _t;
+													match(_t,UTIMES);
+													_t = _t->getFirstChild();
+													ANTLR_USE_NAMESPACE(antlr)RefAST tmp183_AST_in = _t;
+													match(_t,ATT_ID);
+													_t = _t->getNextSibling();
+													_t = __t342;
+													_t = _t->getNextSibling();
+													var2=out(_t);
+													_t = _retTree;
+													_t = __t341;
+													_t = _t->getNextSibling();
+													}
 												}
-												
-												// if att not found return undefined
-												if(prs_arg->ntl_scn && var==NULL_CEWI )
-												var=ncap_var_udf(att->getText().c_str());
-												
-												if(prs_arg->ntl_scn && var->val.vp !=NULL)
-												var->val.vp=(void*)nco_free(var->val.vp);
-												
-												
-#line 2342 "ncoTree.cpp"
+												catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+													synPredMatched343 = false;
+												}
+												_t = __t343;
+												inputState->guessing--;
 											}
-										}
+											if ( synPredMatched343 ) {
+												ANTLR_USE_NAMESPACE(antlr)RefAST __t344 = _t;
+												ANTLR_USE_NAMESPACE(antlr)RefAST tmp184_AST_in = _t;
+												match(_t,PLUS_ASSIGN);
+												_t = _t->getFirstChild();
+												ANTLR_USE_NAMESPACE(antlr)RefAST __t345 = _t;
+												ANTLR_USE_NAMESPACE(antlr)RefAST tmp185_AST_in = _t;
+												match(_t,UTIMES);
+												_t = _t->getFirstChild();
+												atp = _t;
+												match(_t,ATT_ID);
+												_t = _t->getNextSibling();
+												_t = __t345;
+												_t = _t->getNextSibling();
+												var2=out(_t);
+												_t = _retTree;
+												_t = __t344;
+												_t = _t->getNextSibling();
+												if ( inputState->guessing==0 ) {
+#line 2228 "ncoGrammer.g"
+													
+													
+													var1=out(att2var(atp));     
+													var=ncap_var_var_inc(var1,var2, PLUS_ASSIGN ,false,bret, prs_arg);
+													
+#line 1928 "ncoTree.cpp"
+												}
+											}
+											else {
+												bool synPredMatched349 = false;
+												if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+													_t = ASTNULL;
+												if (((_t->getType() == MINUS_ASSIGN))) {
+													ANTLR_USE_NAMESPACE(antlr)RefAST __t349 = _t;
+													synPredMatched349 = true;
+													inputState->guessing++;
+													try {
+														{
+														ANTLR_USE_NAMESPACE(antlr)RefAST __t347 = _t;
+														ANTLR_USE_NAMESPACE(antlr)RefAST tmp186_AST_in = _t;
+														match(_t,MINUS_ASSIGN);
+														_t = _t->getFirstChild();
+														{
+														if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+															_t = ASTNULL;
+														switch ( _t->getType()) {
+														case VAR_ID:
+														{
+															ANTLR_USE_NAMESPACE(antlr)RefAST tmp187_AST_in = _t;
+															match(_t,VAR_ID);
+															_t = _t->getNextSibling();
+															break;
+														}
+														case ATT_ID:
+														{
+															ANTLR_USE_NAMESPACE(antlr)RefAST tmp188_AST_in = _t;
+															match(_t,ATT_ID);
+															_t = _t->getNextSibling();
+															break;
+														}
+														default:
+														{
+															throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
+														}
+														}
+														}
+														var2=out(_t);
+														_t = _retTree;
+														_t = __t347;
+														_t = _t->getNextSibling();
+														}
+													}
+													catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+														synPredMatched349 = false;
+													}
+													_t = __t349;
+													inputState->guessing--;
+												}
+												if ( synPredMatched349 ) {
+													ANTLR_USE_NAMESPACE(antlr)RefAST __t350 = _t;
+													ANTLR_USE_NAMESPACE(antlr)RefAST tmp189_AST_in = _t;
+													match(_t,MINUS_ASSIGN);
+													_t = _t->getFirstChild();
+													var1=out(_t);
+													_t = _retTree;
+													var2=out(_t);
+													_t = _retTree;
+													_t = __t350;
+													_t = _t->getNextSibling();
+													if ( inputState->guessing==0 ) {
+#line 2235 "ncoGrammer.g"
+														
+														var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,false, bret,prs_arg);
+														
+#line 1997 "ncoTree.cpp"
+													}
+												}
+												else {
+													bool synPredMatched354 = false;
+													if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+														_t = ASTNULL;
+													if (((_t->getType() == MINUS_ASSIGN))) {
+														ANTLR_USE_NAMESPACE(antlr)RefAST __t354 = _t;
+														synPredMatched354 = true;
+														inputState->guessing++;
+														try {
+															{
+															ANTLR_USE_NAMESPACE(antlr)RefAST __t352 = _t;
+															ANTLR_USE_NAMESPACE(antlr)RefAST tmp190_AST_in = _t;
+															match(_t,MINUS_ASSIGN);
+															_t = _t->getFirstChild();
+															ANTLR_USE_NAMESPACE(antlr)RefAST __t353 = _t;
+															ANTLR_USE_NAMESPACE(antlr)RefAST tmp191_AST_in = _t;
+															match(_t,UTIMES);
+															_t = _t->getFirstChild();
+															ANTLR_USE_NAMESPACE(antlr)RefAST tmp192_AST_in = _t;
+															match(_t,VAR_ID);
+															_t = _t->getNextSibling();
+															_t = __t353;
+															_t = _t->getNextSibling();
+															var2=out(_t);
+															_t = _retTree;
+															_t = __t352;
+															_t = _t->getNextSibling();
+															}
+														}
+														catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+															synPredMatched354 = false;
+														}
+														_t = __t354;
+														inputState->guessing--;
+													}
+													if ( synPredMatched354 ) {
+														ANTLR_USE_NAMESPACE(antlr)RefAST __t355 = _t;
+														ANTLR_USE_NAMESPACE(antlr)RefAST tmp193_AST_in = _t;
+														match(_t,MINUS_ASSIGN);
+														_t = _t->getFirstChild();
+														ANTLR_USE_NAMESPACE(antlr)RefAST __t356 = _t;
+														ANTLR_USE_NAMESPACE(antlr)RefAST tmp194_AST_in = _t;
+														match(_t,UTIMES);
+														_t = _t->getFirstChild();
+														var1=out(_t);
+														_t = _retTree;
+														_t = __t356;
+														_t = _t->getNextSibling();
+														var2=out(_t);
+														_t = _retTree;
+														_t = __t355;
+														_t = _t->getNextSibling();
+														if ( inputState->guessing==0 ) {
+#line 2239 "ncoGrammer.g"
+															
+															var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,true, bret,prs_arg);
+															
+#line 2057 "ncoTree.cpp"
+														}
+													}
+													else {
+														bool synPredMatched360 = false;
+														if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+															_t = ASTNULL;
+														if (((_t->getType() == MINUS_ASSIGN))) {
+															ANTLR_USE_NAMESPACE(antlr)RefAST __t360 = _t;
+															synPredMatched360 = true;
+															inputState->guessing++;
+															try {
+																{
+																ANTLR_USE_NAMESPACE(antlr)RefAST __t358 = _t;
+																ANTLR_USE_NAMESPACE(antlr)RefAST tmp195_AST_in = _t;
+																match(_t,MINUS_ASSIGN);
+																_t = _t->getFirstChild();
+																ANTLR_USE_NAMESPACE(antlr)RefAST __t359 = _t;
+																ANTLR_USE_NAMESPACE(antlr)RefAST tmp196_AST_in = _t;
+																match(_t,UTIMES);
+																_t = _t->getFirstChild();
+																ANTLR_USE_NAMESPACE(antlr)RefAST tmp197_AST_in = _t;
+																match(_t,ATT_ID);
+																_t = _t->getNextSibling();
+																_t = __t359;
+																_t = _t->getNextSibling();
+																var2=out(_t);
+																_t = _retTree;
+																_t = __t358;
+																_t = _t->getNextSibling();
+																}
+															}
+															catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																synPredMatched360 = false;
+															}
+															_t = __t360;
+															inputState->guessing--;
+														}
+														if ( synPredMatched360 ) {
+															ANTLR_USE_NAMESPACE(antlr)RefAST __t361 = _t;
+															ANTLR_USE_NAMESPACE(antlr)RefAST tmp198_AST_in = _t;
+															match(_t,MINUS_ASSIGN);
+															_t = _t->getFirstChild();
+															ANTLR_USE_NAMESPACE(antlr)RefAST __t362 = _t;
+															ANTLR_USE_NAMESPACE(antlr)RefAST tmp199_AST_in = _t;
+															match(_t,UTIMES);
+															_t = _t->getFirstChild();
+															atm = _t;
+															match(_t,ATT_ID);
+															_t = _t->getNextSibling();
+															_t = __t362;
+															_t = _t->getNextSibling();
+															var2=out(_t);
+															_t = _retTree;
+															_t = __t361;
+															_t = _t->getNextSibling();
+															if ( inputState->guessing==0 ) {
+#line 2243 "ncoGrammer.g"
+																
+																var1=out(att2var(atm));     
+																var=ncap_var_var_inc(var1,var2, MINUS_ASSIGN ,false, bret,prs_arg);
+																
+#line 2119 "ncoTree.cpp"
+															}
+														}
+														else {
+															bool synPredMatched366 = false;
+															if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																_t = ASTNULL;
+															if (((_t->getType() == TIMES_ASSIGN))) {
+																ANTLR_USE_NAMESPACE(antlr)RefAST __t366 = _t;
+																synPredMatched366 = true;
+																inputState->guessing++;
+																try {
+																	{
+																	ANTLR_USE_NAMESPACE(antlr)RefAST __t364 = _t;
+																	ANTLR_USE_NAMESPACE(antlr)RefAST tmp200_AST_in = _t;
+																	match(_t,TIMES_ASSIGN);
+																	_t = _t->getFirstChild();
+																	{
+																	if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																		_t = ASTNULL;
+																	switch ( _t->getType()) {
+																	case VAR_ID:
+																	{
+																		ANTLR_USE_NAMESPACE(antlr)RefAST tmp201_AST_in = _t;
+																		match(_t,VAR_ID);
+																		_t = _t->getNextSibling();
+																		break;
+																	}
+																	case ATT_ID:
+																	{
+																		ANTLR_USE_NAMESPACE(antlr)RefAST tmp202_AST_in = _t;
+																		match(_t,ATT_ID);
+																		_t = _t->getNextSibling();
+																		break;
+																	}
+																	default:
+																	{
+																		throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
+																	}
+																	}
+																	}
+																	var2=out(_t);
+																	_t = _retTree;
+																	_t = __t364;
+																	_t = _t->getNextSibling();
+																	}
+																}
+																catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																	synPredMatched366 = false;
+																}
+																_t = __t366;
+																inputState->guessing--;
+															}
+															if ( synPredMatched366 ) {
+																ANTLR_USE_NAMESPACE(antlr)RefAST __t367 = _t;
+																ANTLR_USE_NAMESPACE(antlr)RefAST tmp203_AST_in = _t;
+																match(_t,TIMES_ASSIGN);
+																_t = _t->getFirstChild();
+																var1=out(_t);
+																_t = _retTree;
+																var2=out(_t);
+																_t = _retTree;
+																_t = __t367;
+																_t = _t->getNextSibling();
+																if ( inputState->guessing==0 ) {
+#line 2248 "ncoGrammer.g"
+																	
+																	var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,false, bret,prs_arg);
+																	
+#line 2188 "ncoTree.cpp"
+																}
+															}
+															else {
+																bool synPredMatched371 = false;
+																if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																	_t = ASTNULL;
+																if (((_t->getType() == TIMES_ASSIGN))) {
+																	ANTLR_USE_NAMESPACE(antlr)RefAST __t371 = _t;
+																	synPredMatched371 = true;
+																	inputState->guessing++;
+																	try {
+																		{
+																		ANTLR_USE_NAMESPACE(antlr)RefAST __t369 = _t;
+																		ANTLR_USE_NAMESPACE(antlr)RefAST tmp204_AST_in = _t;
+																		match(_t,TIMES_ASSIGN);
+																		_t = _t->getFirstChild();
+																		ANTLR_USE_NAMESPACE(antlr)RefAST __t370 = _t;
+																		ANTLR_USE_NAMESPACE(antlr)RefAST tmp205_AST_in = _t;
+																		match(_t,UTIMES);
+																		_t = _t->getFirstChild();
+																		ANTLR_USE_NAMESPACE(antlr)RefAST tmp206_AST_in = _t;
+																		match(_t,VAR_ID);
+																		_t = _t->getNextSibling();
+																		_t = __t370;
+																		_t = _t->getNextSibling();
+																		var2=out(_t);
+																		_t = _retTree;
+																		_t = __t369;
+																		_t = _t->getNextSibling();
+																		}
+																	}
+																	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																		synPredMatched371 = false;
+																	}
+																	_t = __t371;
+																	inputState->guessing--;
+																}
+																if ( synPredMatched371 ) {
+																	ANTLR_USE_NAMESPACE(antlr)RefAST __t372 = _t;
+																	ANTLR_USE_NAMESPACE(antlr)RefAST tmp207_AST_in = _t;
+																	match(_t,TIMES_ASSIGN);
+																	_t = _t->getFirstChild();
+																	ANTLR_USE_NAMESPACE(antlr)RefAST __t373 = _t;
+																	ANTLR_USE_NAMESPACE(antlr)RefAST tmp208_AST_in = _t;
+																	match(_t,UTIMES);
+																	_t = _t->getFirstChild();
+																	var1=out(_t);
+																	_t = _retTree;
+																	_t = __t373;
+																	_t = _t->getNextSibling();
+																	var2=out(_t);
+																	_t = _retTree;
+																	_t = __t372;
+																	_t = _t->getNextSibling();
+																	if ( inputState->guessing==0 ) {
+#line 2252 "ncoGrammer.g"
+																		
+																		var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,true, bret,prs_arg);
+																		
+#line 2248 "ncoTree.cpp"
+																	}
+																}
+																else {
+																	bool synPredMatched377 = false;
+																	if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																		_t = ASTNULL;
+																	if (((_t->getType() == TIMES_ASSIGN))) {
+																		ANTLR_USE_NAMESPACE(antlr)RefAST __t377 = _t;
+																		synPredMatched377 = true;
+																		inputState->guessing++;
+																		try {
+																			{
+																			ANTLR_USE_NAMESPACE(antlr)RefAST __t375 = _t;
+																			ANTLR_USE_NAMESPACE(antlr)RefAST tmp209_AST_in = _t;
+																			match(_t,TIMES_ASSIGN);
+																			_t = _t->getFirstChild();
+																			ANTLR_USE_NAMESPACE(antlr)RefAST __t376 = _t;
+																			ANTLR_USE_NAMESPACE(antlr)RefAST tmp210_AST_in = _t;
+																			match(_t,UTIMES);
+																			_t = _t->getFirstChild();
+																			ANTLR_USE_NAMESPACE(antlr)RefAST tmp211_AST_in = _t;
+																			match(_t,ATT_ID);
+																			_t = _t->getNextSibling();
+																			_t = __t376;
+																			_t = _t->getNextSibling();
+																			var2=out(_t);
+																			_t = _retTree;
+																			_t = __t375;
+																			_t = _t->getNextSibling();
+																			}
+																		}
+																		catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																			synPredMatched377 = false;
+																		}
+																		_t = __t377;
+																		inputState->guessing--;
+																	}
+																	if ( synPredMatched377 ) {
+																		ANTLR_USE_NAMESPACE(antlr)RefAST __t378 = _t;
+																		ANTLR_USE_NAMESPACE(antlr)RefAST tmp212_AST_in = _t;
+																		match(_t,TIMES_ASSIGN);
+																		_t = _t->getFirstChild();
+																		ANTLR_USE_NAMESPACE(antlr)RefAST __t379 = _t;
+																		ANTLR_USE_NAMESPACE(antlr)RefAST tmp213_AST_in = _t;
+																		match(_t,UTIMES);
+																		_t = _t->getFirstChild();
+																		attm = _t;
+																		match(_t,ATT_ID);
+																		_t = _t->getNextSibling();
+																		_t = __t379;
+																		_t = _t->getNextSibling();
+																		var2=out(_t);
+																		_t = _retTree;
+																		_t = __t378;
+																		_t = _t->getNextSibling();
+																		if ( inputState->guessing==0 ) {
+#line 2256 "ncoGrammer.g"
+																			
+																			var1=out(att2var(attm));     
+																			var=ncap_var_var_inc(var1,var2, TIMES_ASSIGN ,false, bret,prs_arg);
+																			
+#line 2310 "ncoTree.cpp"
+																		}
+																	}
+																	else {
+																		bool synPredMatched383 = false;
+																		if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																			_t = ASTNULL;
+																		if (((_t->getType() == DIVIDE_ASSIGN))) {
+																			ANTLR_USE_NAMESPACE(antlr)RefAST __t383 = _t;
+																			synPredMatched383 = true;
+																			inputState->guessing++;
+																			try {
+																				{
+																				ANTLR_USE_NAMESPACE(antlr)RefAST __t381 = _t;
+																				ANTLR_USE_NAMESPACE(antlr)RefAST tmp214_AST_in = _t;
+																				match(_t,DIVIDE_ASSIGN);
+																				_t = _t->getFirstChild();
+																				{
+																				if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																					_t = ASTNULL;
+																				switch ( _t->getType()) {
+																				case VAR_ID:
+																				{
+																					ANTLR_USE_NAMESPACE(antlr)RefAST tmp215_AST_in = _t;
+																					match(_t,VAR_ID);
+																					_t = _t->getNextSibling();
+																					break;
+																				}
+																				case ATT_ID:
+																				{
+																					ANTLR_USE_NAMESPACE(antlr)RefAST tmp216_AST_in = _t;
+																					match(_t,ATT_ID);
+																					_t = _t->getNextSibling();
+																					break;
+																				}
+																				default:
+																				{
+																					throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
+																				}
+																				}
+																				}
+																				var2=out(_t);
+																				_t = _retTree;
+																				_t = __t381;
+																				_t = _t->getNextSibling();
+																				}
+																			}
+																			catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																				synPredMatched383 = false;
+																			}
+																			_t = __t383;
+																			inputState->guessing--;
+																		}
+																		if ( synPredMatched383 ) {
+																			ANTLR_USE_NAMESPACE(antlr)RefAST __t384 = _t;
+																			ANTLR_USE_NAMESPACE(antlr)RefAST tmp217_AST_in = _t;
+																			match(_t,DIVIDE_ASSIGN);
+																			_t = _t->getFirstChild();
+																			var1=out(_t);
+																			_t = _retTree;
+																			var2=out(_t);
+																			_t = _retTree;
+																			_t = __t384;
+																			_t = _t->getNextSibling();
+																			if ( inputState->guessing==0 ) {
+#line 2261 "ncoGrammer.g"
+																				
+																				var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,false, bret,prs_arg);
+																				
+#line 2379 "ncoTree.cpp"
+																			}
+																		}
+																		else {
+																			bool synPredMatched388 = false;
+																			if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																				_t = ASTNULL;
+																			if (((_t->getType() == DIVIDE_ASSIGN))) {
+																				ANTLR_USE_NAMESPACE(antlr)RefAST __t388 = _t;
+																				synPredMatched388 = true;
+																				inputState->guessing++;
+																				try {
+																					{
+																					ANTLR_USE_NAMESPACE(antlr)RefAST __t386 = _t;
+																					ANTLR_USE_NAMESPACE(antlr)RefAST tmp218_AST_in = _t;
+																					match(_t,DIVIDE_ASSIGN);
+																					_t = _t->getFirstChild();
+																					ANTLR_USE_NAMESPACE(antlr)RefAST __t387 = _t;
+																					ANTLR_USE_NAMESPACE(antlr)RefAST tmp219_AST_in = _t;
+																					match(_t,UTIMES);
+																					_t = _t->getFirstChild();
+																					ANTLR_USE_NAMESPACE(antlr)RefAST tmp220_AST_in = _t;
+																					match(_t,VAR_ID);
+																					_t = _t->getNextSibling();
+																					_t = __t387;
+																					_t = _t->getNextSibling();
+																					var2=out(_t);
+																					_t = _retTree;
+																					_t = __t386;
+																					_t = _t->getNextSibling();
+																					}
+																				}
+																				catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																					synPredMatched388 = false;
+																				}
+																				_t = __t388;
+																				inputState->guessing--;
+																			}
+																			if ( synPredMatched388 ) {
+																				ANTLR_USE_NAMESPACE(antlr)RefAST __t389 = _t;
+																				ANTLR_USE_NAMESPACE(antlr)RefAST tmp221_AST_in = _t;
+																				match(_t,DIVIDE_ASSIGN);
+																				_t = _t->getFirstChild();
+																				ANTLR_USE_NAMESPACE(antlr)RefAST __t390 = _t;
+																				ANTLR_USE_NAMESPACE(antlr)RefAST tmp222_AST_in = _t;
+																				match(_t,UTIMES);
+																				_t = _t->getFirstChild();
+																				var1=out(_t);
+																				_t = _retTree;
+																				_t = __t390;
+																				_t = _t->getNextSibling();
+																				var2=out(_t);
+																				_t = _retTree;
+																				_t = __t389;
+																				_t = _t->getNextSibling();
+																				if ( inputState->guessing==0 ) {
+#line 2265 "ncoGrammer.g"
+																					
+																					var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,true, bret,prs_arg);
+																					
+#line 2439 "ncoTree.cpp"
+																				}
+																			}
+																			else {
+																				bool synPredMatched394 = false;
+																				if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																					_t = ASTNULL;
+																				if (((_t->getType() == DIVIDE_ASSIGN))) {
+																					ANTLR_USE_NAMESPACE(antlr)RefAST __t394 = _t;
+																					synPredMatched394 = true;
+																					inputState->guessing++;
+																					try {
+																						{
+																						ANTLR_USE_NAMESPACE(antlr)RefAST __t392 = _t;
+																						ANTLR_USE_NAMESPACE(antlr)RefAST tmp223_AST_in = _t;
+																						match(_t,DIVIDE_ASSIGN);
+																						_t = _t->getFirstChild();
+																						ANTLR_USE_NAMESPACE(antlr)RefAST __t393 = _t;
+																						ANTLR_USE_NAMESPACE(antlr)RefAST tmp224_AST_in = _t;
+																						match(_t,UTIMES);
+																						_t = _t->getFirstChild();
+																						ANTLR_USE_NAMESPACE(antlr)RefAST tmp225_AST_in = _t;
+																						match(_t,ATT_ID);
+																						_t = _t->getNextSibling();
+																						_t = __t393;
+																						_t = _t->getNextSibling();
+																						var2=out(_t);
+																						_t = _retTree;
+																						_t = __t392;
+																						_t = _t->getNextSibling();
+																						}
+																					}
+																					catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																						synPredMatched394 = false;
+																					}
+																					_t = __t394;
+																					inputState->guessing--;
+																				}
+																				if ( synPredMatched394 ) {
+																					ANTLR_USE_NAMESPACE(antlr)RefAST __t395 = _t;
+																					ANTLR_USE_NAMESPACE(antlr)RefAST tmp226_AST_in = _t;
+																					match(_t,DIVIDE_ASSIGN);
+																					_t = _t->getFirstChild();
+																					ANTLR_USE_NAMESPACE(antlr)RefAST __t396 = _t;
+																					ANTLR_USE_NAMESPACE(antlr)RefAST tmp227_AST_in = _t;
+																					match(_t,UTIMES);
+																					_t = _t->getFirstChild();
+																					atd = _t;
+																					match(_t,ATT_ID);
+																					_t = _t->getNextSibling();
+																					_t = __t396;
+																					_t = _t->getNextSibling();
+																					var2=out(_t);
+																					_t = _retTree;
+																					_t = __t395;
+																					_t = _t->getNextSibling();
+																					if ( inputState->guessing==0 ) {
+#line 2269 "ncoGrammer.g"
+																						
+																						var1=out(att2var(atd));        
+																						var=ncap_var_var_inc(var1,var2, DIVIDE_ASSIGN ,false, bret,prs_arg);
+																						
+#line 2501 "ncoTree.cpp"
+																					}
+																				}
+																				else {
+																					bool synPredMatched400 = false;
+																					if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																						_t = ASTNULL;
+																					if (((_t->getType() == ASSIGN))) {
+																						ANTLR_USE_NAMESPACE(antlr)RefAST __t400 = _t;
+																						synPredMatched400 = true;
+																						inputState->guessing++;
+																						try {
+																							{
+																							ANTLR_USE_NAMESPACE(antlr)RefAST __t398 = _t;
+																							ANTLR_USE_NAMESPACE(antlr)RefAST tmp228_AST_in = _t;
+																							match(_t,ASSIGN);
+																							_t = _t->getFirstChild();
+																							{
+																							if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																								_t = ASTNULL;
+																							switch ( _t->getType()) {
+																							case VAR_ID:
+																							{
+																								ANTLR_USE_NAMESPACE(antlr)RefAST tmp229_AST_in = _t;
+																								match(_t,VAR_ID);
+																								_t = _t->getNextSibling();
+																								break;
+																							}
+																							case ATT_ID:
+																							{
+																								ANTLR_USE_NAMESPACE(antlr)RefAST tmp230_AST_in = _t;
+																								match(_t,ATT_ID);
+																								_t = _t->getNextSibling();
+																								break;
+																							}
+																							default:
+																							{
+																								throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
+																							}
+																							}
+																							}
+																							_t = __t398;
+																							_t = _t->getNextSibling();
+																							}
+																						}
+																						catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																							synPredMatched400 = false;
+																						}
+																						_t = __t400;
+																						inputState->guessing--;
+																					}
+																					if ( synPredMatched400 ) {
+																						ANTLR_USE_NAMESPACE(antlr)RefAST __t401 = _t;
+																						ANTLR_USE_NAMESPACE(antlr)RefAST tmp231_AST_in = _t;
+																						match(_t,ASSIGN);
+																						_t = _t->getFirstChild();
+																						asn = _t;
+																						if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
+																						_t = _t->getNextSibling();
+																						_t = __t401;
+																						_t = _t->getNextSibling();
+																						if ( inputState->guessing==0 ) {
+#line 2275 "ncoGrammer.g"
+																							
+																							if(prs_arg->ntl_scn)
+																							var=assign_ntl(asn,false,bret); 
+																							else
+																							var=assign(asn,false,bret);
+																							
+#line 2570 "ncoTree.cpp"
+																						}
+																					}
+																					else {
+																						bool synPredMatched405 = false;
+																						if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																							_t = ASTNULL;
+																						if (((_t->getType() == ASSIGN))) {
+																							ANTLR_USE_NAMESPACE(antlr)RefAST __t405 = _t;
+																							synPredMatched405 = true;
+																							inputState->guessing++;
+																							try {
+																								{
+																								ANTLR_USE_NAMESPACE(antlr)RefAST __t403 = _t;
+																								ANTLR_USE_NAMESPACE(antlr)RefAST tmp232_AST_in = _t;
+																								match(_t,ASSIGN);
+																								_t = _t->getFirstChild();
+																								ANTLR_USE_NAMESPACE(antlr)RefAST __t404 = _t;
+																								ANTLR_USE_NAMESPACE(antlr)RefAST tmp233_AST_in = _t;
+																								match(_t,UTIMES);
+																								_t = _t->getFirstChild();
+																								ANTLR_USE_NAMESPACE(antlr)RefAST tmp234_AST_in = _t;
+																								match(_t,ATT_ID);
+																								_t = _t->getNextSibling();
+																								_t = __t404;
+																								_t = _t->getNextSibling();
+																								_t = __t403;
+																								_t = _t->getNextSibling();
+																								}
+																							}
+																							catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																								synPredMatched405 = false;
+																							}
+																							_t = __t405;
+																							inputState->guessing--;
+																						}
+																						if ( synPredMatched405 ) {
+																							ANTLR_USE_NAMESPACE(antlr)RefAST __t406 = _t;
+																							ANTLR_USE_NAMESPACE(antlr)RefAST tmp235_AST_in = _t;
+																							match(_t,ASSIGN);
+																							_t = _t->getFirstChild();
+																							ANTLR_USE_NAMESPACE(antlr)RefAST __t407 = _t;
+																							atta = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+																							match(_t,UTIMES);
+																							_t = _t->getFirstChild();
+																							ANTLR_USE_NAMESPACE(antlr)RefAST tmp236_AST_in = _t;
+																							match(_t,ATT_ID);
+																							_t = _t->getNextSibling();
+																							_t = __t407;
+																							_t = _t->getNextSibling();
+																							_t = __t406;
+																							_t = _t->getNextSibling();
+																							if ( inputState->guessing==0 ) {
+#line 2283 "ncoGrammer.g"
+																								
+																								
+																								RefAST tr;
+																								tr=atta->getFirstChild();
+																								tr->setNextSibling(atta->getNextSibling());
+																								
+																								// remember tr siblings and children are  duplicated here   
+																								tr=att2var(tr);   
+																								
+																								if(prs_arg->ntl_scn)
+																								var=assign_ntl(tr,false,bret); 
+																								else
+																								var=assign(tr,false,bret);
+																								
+#line 2638 "ncoTree.cpp"
+																							}
+																						}
+																						else if ((_t->getType() == ASSIGN)) {
+																							ANTLR_USE_NAMESPACE(antlr)RefAST __t408 = _t;
+																							ANTLR_USE_NAMESPACE(antlr)RefAST tmp237_AST_in = _t;
+																							match(_t,ASSIGN);
+																							_t = _t->getFirstChild();
+																							ANTLR_USE_NAMESPACE(antlr)RefAST __t409 = _t;
+																							asn2 = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+																							match(_t,UTIMES);
+																							_t = _t->getFirstChild();
+																							{
+																							if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																								_t = ASTNULL;
+																							switch ( _t->getType()) {
+																							case VAR_ID:
+																							{
+																								ANTLR_USE_NAMESPACE(antlr)RefAST tmp238_AST_in = _t;
+																								match(_t,VAR_ID);
+																								_t = _t->getNextSibling();
+																								break;
+																							}
+																							case UTIMES:
+																							{
+																								ANTLR_USE_NAMESPACE(antlr)RefAST __t411 = _t;
+																								ANTLR_USE_NAMESPACE(antlr)RefAST tmp239_AST_in = _t;
+																								match(_t,UTIMES);
+																								_t = _t->getFirstChild();
+																								asn2a = _t;
+																								match(_t,ATT_ID);
+																								_t = _t->getNextSibling();
+																								_t = __t411;
+																								_t = _t->getNextSibling();
+																								break;
+																							}
+																							default:
+																							{
+																								throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
+																							}
+																							}
+																							}
+																							_t = __t409;
+																							_t = _t->getNextSibling();
+																							_t = __t408;
+																							_t = _t->getNextSibling();
+																							if ( inputState->guessing==0 ) {
+#line 2299 "ncoGrammer.g"
+																								
+																								// Check for RAM variable - if present 
+																								// change tree - for example from:
+																								//     ( EXPR ( = ( * n1 ) ( + four four ) ) )
+																								// to  ( EXPR ( = n1 ( + four four ) ) )
+																								
+																								RefAST tr;
+																								NcapVar *Nvar;          
+																								
+																								// deal with ATT_ID 
+																								if(asn2a)  
+																								{ 
+																								// remember tr and siblings and children are  duplicated here
+																								tr=att2var(asn2a);   
+																								tr->setNextSibling(asn2->getNextSibling());
+																								
+																								} 
+																								// must be VAR_ID 
+																								else 
+																								{ 
+																								
+																								tr=asn2->getFirstChild();
+																								tr->setNextSibling(asn2->getNextSibling());
+																								
+																								// Die if attempting to create a RAM var 
+																								// from an existing disk var   
+																								Nvar= prs_arg->var_vtr.find(tr->getText());
+																								
+																								if(Nvar && Nvar->flg_mem==false)
+																								{
+																								std::string serr;
+																								serr= "It is impossible to recast disk variable: \"" + tr->getText() +"\" as a RAM variable.";
+																								err_prn(fnc_nm,serr );       
+																								
+																								}                
+																								}
+																								
+																								if(prs_arg->ntl_scn)
+																								var=assign_ntl(tr,true,bret); 
+																								else
+																								var=assign(tr, true,bret);
+																								
+																								
+#line 2729 "ncoTree.cpp"
+																							}
+																						}
+																						else {
+																							bool synPredMatched419 = false;
+																							if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																								_t = ASTNULL;
+																							if (((_t->getType() == VAR_ID))) {
+																								ANTLR_USE_NAMESPACE(antlr)RefAST __t419 = _t;
+																								synPredMatched419 = true;
+																								inputState->guessing++;
+																								try {
+																									{
+																									ANTLR_USE_NAMESPACE(antlr)RefAST __t418 = _t;
+																									ANTLR_USE_NAMESPACE(antlr)RefAST tmp240_AST_in = _t;
+																									match(_t,VAR_ID);
+																									_t = _t->getFirstChild();
+																									ANTLR_USE_NAMESPACE(antlr)RefAST tmp241_AST_in = _t;
+																									match(_t,LMT_LIST);
+																									_t = _t->getNextSibling();
+																									_t = __t418;
+																									_t = _t->getNextSibling();
+																									}
+																								}
+																								catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																									synPredMatched419 = false;
+																								}
+																								_t = __t419;
+																								inputState->guessing--;
+																							}
+																							if ( synPredMatched419 ) {
+																								ANTLR_USE_NAMESPACE(antlr)RefAST __t420 = _t;
+																								vid = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+																								match(_t,VAR_ID);
+																								_t = _t->getFirstChild();
+																								lmt = _t;
+																								match(_t,LMT_LIST);
+																								_t = _t->getNextSibling();
+																								_t = __t420;
+																								_t = _t->getNextSibling();
+																								if ( inputState->guessing==0 ) {
+#line 2436 "ncoGrammer.g"
+																									
+																											
+																											    // fxm: 4 Oct 2015
+																												/*
+																												  the following is valid syntx var_nm(array_var)-
+																												  array_var now contains all the indices - that is 
+																												  srt vectors  
+																												  srt & end vectors
+																												  srt,end,srd vectors
+																												
+																												  so for now indexing into a multi-dmensional var using a single index has
+																												  temporarily been disabled
+																												
+																									// see if hyperslab limit is a single value
+																									if(lmt->getNumberOfChildren()==1 && 
+																									lmt->getFirstChild()->getNumberOfChildren()==1 &&
+																									lmt->getFirstChild()->getFirstChild()->getType() != COLON)
+																									
+																									var=var_lmt_one(vid);
+																									else   
+																									var=var_lmt(vid);
+																									*/
+																									var=var_lmt(vid);  
+																									
+																									
+																									
+#line 2797 "ncoTree.cpp"
+																								}
+																							}
+																							else {
+																								bool synPredMatched423 = false;
+																								if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+																									_t = ASTNULL;
+																								if (((_t->getType() == ATT_ID))) {
+																									ANTLR_USE_NAMESPACE(antlr)RefAST __t423 = _t;
+																									synPredMatched423 = true;
+																									inputState->guessing++;
+																									try {
+																										{
+																										ANTLR_USE_NAMESPACE(antlr)RefAST __t422 = _t;
+																										ANTLR_USE_NAMESPACE(antlr)RefAST tmp242_AST_in = _t;
+																										match(_t,ATT_ID);
+																										_t = _t->getFirstChild();
+																										ANTLR_USE_NAMESPACE(antlr)RefAST tmp243_AST_in = _t;
+																										match(_t,LMT_LIST);
+																										_t = _t->getNextSibling();
+																										_t = __t422;
+																										_t = _t->getNextSibling();
+																										}
+																									}
+																									catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
+																										synPredMatched423 = false;
+																									}
+																									_t = __t423;
+																									inputState->guessing--;
+																								}
+																								if ( synPredMatched423 ) {
+																									ANTLR_USE_NAMESPACE(antlr)RefAST __t424 = _t;
+																									attl = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+																									match(_t,ATT_ID);
+																									_t = _t->getFirstChild();
+																									lmtl = _t;
+																									match(_t,LMT_LIST);
+																									_t = _t->getNextSibling();
+																									_t = __t424;
+																									_t = _t->getNextSibling();
+																									if ( inputState->guessing==0 ) {
+#line 2464 "ncoGrammer.g"
+																										
+																										
+																										std::string att_nm=attl->getText();
+																										std::string fnc_nm("att_lmt"); 
+																										NcapVar *Nvar=NULL;
+																										NcapVector<lmt_sct*> lmt_vtr;
+																										
+																										var_sct *var_att=NULL_CEWI; 
+																										
+																										
+																										if(prs_arg->ntl_scn)
+																										{ 
+																										// only final scan for this attribute hyperslab 
+																										var=ncap_var_udf(att_nm.c_str());
+																										// can't return here -- have to use goto
+																										goto attl_end; 
+																										} 
+																										
+																										Nvar=prs_arg->var_vtr.find(attl->getText());
+																										
+																										if(Nvar!=NULL)
+																										var_att=nco_var_dpl(Nvar->var);
+																										else    
+																										var_att=ncap_att_init(att_nm,prs_arg);
+																										
+																										
+																										if(var_att==NULL_CEWI )
+																										err_prn(fnc_nm,"Unable to locate attribute " +att_nm+ " in input or output files.");
+																										
+																												    lmt_mk(1L,lmtl,lmt_vtr);
+																										
+																										
+																										if( lmt_vtr.size() != 1)
+																										err_prn(fnc_nm,"Number of hyperslab limits for an attribute "+ att_nm+"must be one ");
+																										
+																										// fxm - very soon  
+																										lmt_vtr[0]->nm=strdup("zz at attribute");    
+																										(void)ncap_lmt_evl(1,lmt_vtr[0],var_att->sz,prs_arg); 
+																										
+																										// we have something to hyperslab
+																										if( lmt_vtr[0]->cnt > 0)
+																										{  
+																										char *cp_in;
+																										char *cp_out;  
+																										long idx;
+																										long jdx;  
+																										long srt=lmt_vtr[0]->srt;
+																										long cnt=lmt_vtr[0]->cnt;
+																										long srd=lmt_vtr[0]->srd; 
+																										long end=lmt_vtr[0]->end; 
+																										size_t slb_sz=nco_typ_lng(var_att->type); 
+																										
+																										/* create output att */
+																										
+																										if( var_att->type ==NC_STRING )  
+																										{
+																										var=ncap_sclr_var_mk(att_nm,var_att->type,false);                
+																										var->val.vp=(void*)nco_malloc(slb_sz*cnt);       
+																										(void)cast_void_nctype((nc_type)NC_STRING,&var->val);                 
+																										(void)cast_void_nctype((nc_type)NC_STRING,&var_att->val);                  
+																										
+																										jdx=0;  
+																										for(idx=srt;idx<=end;idx+=srd)  
+																										var->val.sngp[jdx++]=strdup(var_att->val.sngp[idx]);
+																										
+																										
+																										(void)cast_nctype_void((nc_type)NC_STRING,&var->val); 
+																										(void)cast_nctype_void((nc_type)NC_STRING,&var_att->val); 
+																										
+																										}
+																										else
+																										{     
+																										var=ncap_sclr_var_mk(att_nm,var_att->type,true);                 
+																										(void)ncap_att_stretch(var,cnt);     
+																										
+																										cp_in=(char*)( var_att->val.vp); 
+																										cp_in+= (ptrdiff_t)slb_sz*srt;
+																										cp_out=(char*)var->val.vp; 
+																										
+																										idx=0;
+																										
+																										while(idx++ < cnt )
+																										{ 
+																										memcpy(cp_out, cp_in, slb_sz);                   
+																										cp_in+=srd*slb_sz;
+																										cp_out+=slb_sz; 
+																										} 
+																										
+																										}               
+																										
+																										}
+																										else
+																										{
+																										err_prn(fnc_nm,"Hyperslab limits for attribute "+ att_nm+" doesn't include any elements");  
+																										}
+																										
+																										nco_lmt_free(lmt_vtr[0]);  
+																										nco_var_free(var_att);    
+																										
+																										attl_end: ; 
+																										
+#line 2940 "ncoTree.cpp"
+																									}
+																								}
+																								else if ((_t->getType() == VAR_ID)) {
+																									v = _t;
+																									match(_t,VAR_ID);
+																									_t = _t->getNextSibling();
+																									if ( inputState->guessing==0 ) {
+#line 2570 "ncoGrammer.g"
+																										
+																										//dbg_prn(fnc_nm,"getting regular var in out "+v->getText());
+																										
+																										var=prs_arg->ncap_var_init(v->getText(),true);
+																										
+																										// initial scan 
+																										if(prs_arg->ntl_scn)  
+																										{  
+																										if(var==NULL)     
+																										var=ncap_var_udf(v->getText().c_str());
+																										else if(bcst && var_cst && var->sz >1)      
+																										var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);  
+																										} 
+																										// final scan  
+																										else
+																										{ 
+																										if(var==NULL)
+																										err_prn(fnc_nm,"Could not read var "+ v->getText());
+																										
+																										if(bcst && var_cst && var->sz >1)          
+																										if(var_cst->nbr_dim==var->nbr_dim)     
+																										ncap_var_cnf_dmn(&var,&var_cst);
+																										else    
+																										{
+																										var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);
+																										}
+																										}
+																										
+																										
+																										
+#line 2979 "ncoTree.cpp"
+																									}
+																								}
+																								else if ((_t->getType() == ATT_ID)) {
+																									att = _t;
+																									match(_t,ATT_ID);
+																									_t = _t->getNextSibling();
+																									if ( inputState->guessing==0 ) {
+#line 2602 "ncoGrammer.g"
+																										
+																										
+																										var=att_plain(att);  
+																										/*  
+																										NcapVar *Nvar=NULL;
+																										
+																										if(prs_arg->ntl_scn)
+																										Nvar=prs_arg->int_vtr.find(att->getText());
+																										
+																										if(Nvar==NULL) 
+																										Nvar=prs_arg->var_vtr.find(att->getText());
+																										
+																										var=NULL_CEWI;    
+																										if(Nvar !=NULL)
+																										var=nco_var_dpl(Nvar->var);
+																										else    
+																										// Check input file for attribute
+																										var=ncap_att_init(att->getText(),prs_arg);
+																										
+																										if(!prs_arg->ntl_scn && var==NULL_CEWI ){
+																										err_prn(fnc_nm,"Unable to locate attribute " +att->getText()+ " in input or output files.");
+																										}
+																										
+																										// if att not found return undefined
+																										if(prs_arg->ntl_scn && var==NULL_CEWI )
+																										var=ncap_var_udf(att->getText().c_str());
+																										
+																										if(prs_arg->ntl_scn && var->val.vp !=NULL)
+																										var->val.vp=(void*)nco_free(var->val.vp);
+																										*/
+																										
+																										
+#line 3020 "ncoTree.cpp"
+																									}
+																								}
 		else {
 			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
 		}
-		}}}}}}}}
+		}}}}}}}}}}}}}}}}}}}}}}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
 		if( inputState->guessing == 0 ) {
@@ -2360,11 +3038,11 @@ var_sct * ncoTree::out(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 }
 
 var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
-	bool bram
+	bool bram,bool bret
 ) {
-#line 1469 "ncoGrammer.g"
+#line 1357 "ncoGrammer.g"
 	var_sct *var;
-#line 2368 "ncoTree.cpp"
+#line 3046 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST assign_ntl_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST lmt = ANTLR_USE_NAMESPACE(antlr)nullAST;
@@ -2374,52 +3052,52 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 	ANTLR_USE_NAMESPACE(antlr)RefAST att = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST att1 = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST att2 = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 1469 "ncoGrammer.g"
+#line 1357 "ncoGrammer.g"
 	
 	const std::string fnc_nm("assign_ntl"); 
 	var=NULL_CEWI;
 	
-#line 2383 "ncoTree.cpp"
+#line 3061 "ncoTree.cpp"
 	
 	try {      // for error handling
-		bool synPredMatched254 = false;
+		bool synPredMatched242 = false;
 		if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 			_t = ASTNULL;
 		if (((_t->getType() == VAR_ID))) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t254 = _t;
-			synPredMatched254 = true;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t242 = _t;
+			synPredMatched242 = true;
 			inputState->guessing++;
 			try {
 				{
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t253 = _t;
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp194_AST_in = _t;
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t241 = _t;
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp244_AST_in = _t;
 				match(_t,VAR_ID);
 				_t = _t->getFirstChild();
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp195_AST_in = _t;
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp245_AST_in = _t;
 				match(_t,LMT_LIST);
 				_t = _t->getNextSibling();
-				_t = __t253;
+				_t = __t241;
 				_t = _t->getNextSibling();
 				}
 			}
 			catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-				synPredMatched254 = false;
+				synPredMatched242 = false;
 			}
-			_t = __t254;
+			_t = __t242;
 			inputState->guessing--;
 		}
-		if ( synPredMatched254 ) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t255 = _t;
+		if ( synPredMatched242 ) {
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t243 = _t;
 			vid = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 			match(_t,VAR_ID);
 			_t = _t->getFirstChild();
 			lmt = _t;
 			match(_t,LMT_LIST);
 			_t = _t->getNextSibling();
-			_t = __t255;
+			_t = __t243;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1474 "ncoGrammer.g"
+#line 1362 "ncoGrammer.g"
 				
 				
 				std::string var_nm; 
@@ -2436,10 +3114,13 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 				var_rhs=nco_var_free(var_rhs);               
 				
 				var_lhs=prs_arg->ncap_var_init(var_nm,false);
-				if(var_lhs){
+				if(var_lhs)
+				{
 				var=nco_var_dpl(var_lhs);
 				(void)prs_arg->ncap_var_write(var_lhs,bram);
-				} else {
+				} 
+				else 
+				{
 				// set var to udf
 				var_lhs=ncap_var_udf(var_nm.c_str());
 				var=nco_var_dpl(var_lhs);
@@ -2448,21 +3129,21 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 				(void)prs_arg->int_vtr.push_ow(Nvar);
 				}
 				
-#line 2452 "ncoTree.cpp"
+#line 3133 "ncoTree.cpp"
 			}
 		}
 		else {
-			bool synPredMatched259 = false;
+			bool synPredMatched247 = false;
 			if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 				_t = ASTNULL;
 			if (((_t->getType() == VAR_ID))) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t259 = _t;
-				synPredMatched259 = true;
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t247 = _t;
+				synPredMatched247 = true;
 				inputState->guessing++;
 				try {
 					{
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t257 = _t;
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp196_AST_in = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t245 = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST tmp246_AST_in = _t;
 					match(_t,VAR_ID);
 					_t = _t->getFirstChild();
 					{
@@ -2471,14 +3152,14 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					switch ( _t->getType()) {
 					case DMN_LIST:
 					{
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp197_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp247_AST_in = _t;
 						match(_t,DMN_LIST);
 						_t = _t->getNextSibling();
 						break;
 					}
 					case DMN_LIST_P:
 					{
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp198_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp248_AST_in = _t;
 						match(_t,DMN_LIST_P);
 						_t = _t->getNextSibling();
 						break;
@@ -2489,28 +3170,28 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					}
 					}
 					}
-					_t = __t257;
+					_t = __t245;
 					_t = _t->getNextSibling();
 					}
 				}
 				catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-					synPredMatched259 = false;
+					synPredMatched247 = false;
 				}
-				_t = __t259;
+				_t = __t247;
 				inputState->guessing--;
 			}
-			if ( synPredMatched259 ) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t260 = _t;
+			if ( synPredMatched247 ) {
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t248 = _t;
 				vid1 = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 				match(_t,VAR_ID);
 				_t = _t->getFirstChild();
 				dmn = _t;
 				if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
 				_t = _t->getNextSibling();
-				_t = __t260;
+				_t = __t248;
 				_t = _t->getNextSibling();
 				if ( inputState->guessing==0 ) {
-#line 1503 "ncoGrammer.g"
+#line 1394 "ncoGrammer.g"
 					
 					
 					int idx;
@@ -2529,6 +3210,8 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					bcst=true;  
 					var_cst=NULL_CEWI;
 					
+					
+					
 					aRef=dmn->getFirstChild();
 					
 					// pPut dimension names in vector       
@@ -2545,32 +3228,37 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					break;
 					
 					// return undef if dim missing 
-					if( idx <str_vtr_sz){
-					var=NULL_CEWI;
-					} else {
+					if( idx <str_vtr_sz)
+					var1=ncap_var_udf(var_nm.c_str());
+					else 
+					{
 					// Cast is applied in VAR_ID action in function out()
 					var_cst=ncap_cst_mk(str_vtr,prs_arg);
-					
 					var1=out(vid1->getNextSibling());
-					if(var1->undefined) {
-					var=NULL_CEWI;
-					} else {
+					
+					if(!var1->undefined) 
+					{
 					var_cst=nco_var_cnf_typ(var1->type,var_cst);
 					var_cst->typ_dsk=var1->type;
-					var=nco_var_dpl(var_cst);
+					var1=nco_var_free(var1); 
+					var1=nco_var_dpl(var_cst);
 					}
-					var1=nco_var_free(var1);
+					
 					}
 					
-					if(!var){
+					if(var1->undefined)
+					{
+					var1=nco_var_free(var1);   
 					var1=ncap_var_udf(var_nm.c_str());
 					Nvar=new NcapVar(var1);
 					(void)prs_arg->int_vtr.push_ow(Nvar);
 					var=nco_var_dpl(var1);
-					} else{
-					var->nm=(char*)nco_free(var->nm);
-					var->nm=strdup(var_nm.c_str());
-					var1=nco_var_dpl(var);
+					} 
+					else
+					{
+					var1->nm=(char*)nco_free(var1->nm);
+					var1->nm=strdup(var_nm.c_str());
+					var=nco_var_dpl(var1);
 					prs_arg->ncap_var_write(var1,bram);
 					}
 					
@@ -2579,7 +3267,7 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					
 					bcst=false;   
 					
-#line 2583 "ncoTree.cpp"
+#line 3271 "ncoTree.cpp"
 				}
 			}
 			else if ((_t->getType() == VAR_ID)) {
@@ -2587,11 +3275,10 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 				match(_t,VAR_ID);
 				_t = _t->getNextSibling();
 				if ( inputState->guessing==0 ) {
-#line 1572 "ncoGrammer.g"
+#line 1470 "ncoGrammer.g"
 					
 					
-					var_sct *var_lhs=(var_sct*)NULL;              
-					var_sct *var_rhs=(var_sct*)NULL;              
+					var_sct *var_rhs;
 					std::string var_nm;
 					
 					var_nm=vid2->getText();
@@ -2604,75 +3291,64 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					
 					// get shape from RHS
 					var_rhs=out(vid2->getNextSibling());
-					
-					// use init_chk() to avoid warning from ncap_var_init() if var not present  
-					if(prs_arg->ncap_var_init_chk(var_nm)) 
-					var_lhs=prs_arg->ncap_var_init(var_nm,false); 
-					
-					if(var_lhs)
-					{
-					var=nco_var_dpl(var_lhs);
-					(void)prs_arg->ncap_var_write(var_lhs,bram);
-					nco_var_free(var_rhs); 
-					}
-					else if(var_rhs)
-					{
-					//Copy return variable
 					(void)nco_free(var_rhs->nm);                
 					var_rhs->nm =strdup(var_nm.c_str());
+					
 					//Copy return variable
+					if(bret)
 					var=nco_var_dpl(var_rhs);
+					else
+					var=(var_sct*)NULL;  
+					
 					// Write var to int_vtr
 					// if var already in int_vtr or var_vtr then write call does nothing
 					(void)prs_arg->ncap_var_write(var_rhs,bram);
-					}   
-					else 
-					{               
-					var=ncap_var_udf(var_nm.c_str());   
-					}  
+					//(void)ncap_var_write_omp(var_rhs,bram,prs_arg);
+					
 					
-#line 2635 "ncoTree.cpp"
+					
+#line 3311 "ncoTree.cpp"
 				}
 			}
 			else {
-				bool synPredMatched263 = false;
+				bool synPredMatched251 = false;
 				if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 					_t = ASTNULL;
 				if (((_t->getType() == ATT_ID))) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t263 = _t;
-					synPredMatched263 = true;
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t251 = _t;
+					synPredMatched251 = true;
 					inputState->guessing++;
 					try {
 						{
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t262 = _t;
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp199_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t250 = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp249_AST_in = _t;
 						match(_t,ATT_ID);
 						_t = _t->getFirstChild();
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp200_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp250_AST_in = _t;
 						match(_t,LMT_LIST);
 						_t = _t->getNextSibling();
-						_t = __t262;
+						_t = __t250;
 						_t = _t->getNextSibling();
 						}
 					}
 					catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-						synPredMatched263 = false;
+						synPredMatched251 = false;
 					}
-					_t = __t263;
+					_t = __t251;
 					inputState->guessing--;
 				}
-				if ( synPredMatched263 ) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t264 = _t;
+				if ( synPredMatched251 ) {
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t252 = _t;
 					att = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 					match(_t,ATT_ID);
 					_t = _t->getFirstChild();
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp201_AST_in = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST tmp251_AST_in = _t;
 					match(_t,LMT_LIST);
 					_t = _t->getNextSibling();
-					_t = __t264;
+					_t = __t252;
 					_t = _t->getNextSibling();
 					if ( inputState->guessing==0 ) {
-#line 1616 "ncoGrammer.g"
+#line 1502 "ncoGrammer.g"
 						
 						
 						//In Initial scan all newly defined atts are flagged as Undefined
@@ -2687,55 +3363,58 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 						prs_arg->int_vtr.push_ow(Nvar);          
 						
 						// Copy return variable
+						if(bret)
 						var=nco_var_dpl(var1);    
+						else
+						var=(var_sct*)NULL; 
 						
 						
-#line 2694 "ncoTree.cpp"
+#line 3373 "ncoTree.cpp"
 					}
 				}
 				else {
-					bool synPredMatched267 = false;
+					bool synPredMatched255 = false;
 					if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 						_t = ASTNULL;
 					if (((_t->getType() == ATT_ID))) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t267 = _t;
-						synPredMatched267 = true;
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t255 = _t;
+						synPredMatched255 = true;
 						inputState->guessing++;
 						try {
 							{
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t266 = _t;
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp202_AST_in = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST __t254 = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp252_AST_in = _t;
 							match(_t,ATT_ID);
 							_t = _t->getFirstChild();
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp203_AST_in = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp253_AST_in = _t;
 							match(_t,LMT_DMN);
 							_t = _t->getNextSibling();
-							_t = __t266;
+							_t = __t254;
 							_t = _t->getNextSibling();
 							}
 						}
 						catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-							synPredMatched267 = false;
+							synPredMatched255 = false;
 						}
-						_t = __t267;
+						_t = __t255;
 						inputState->guessing--;
 					}
-					if ( synPredMatched267 ) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t268 = _t;
+					if ( synPredMatched255 ) {
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t256 = _t;
 						att1 = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 						match(_t,ATT_ID);
 						_t = _t->getFirstChild();
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp204_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp254_AST_in = _t;
 						match(_t,DMN_LIST);
 						_t = _t->getNextSibling();
-						_t = __t268;
+						_t = __t256;
 						_t = _t->getNextSibling();
 						if ( inputState->guessing==0 ) {
-#line 1634 "ncoGrammer.g"
+#line 1523 "ncoGrammer.g"
 							
 							;
 							
-#line 2739 "ncoTree.cpp"
+#line 3418 "ncoTree.cpp"
 						}
 					}
 					else if ((_t->getType() == ATT_ID)) {
@@ -2743,7 +3422,7 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 						match(_t,ATT_ID);
 						_t = _t->getNextSibling();
 						if ( inputState->guessing==0 ) {
-#line 1637 "ncoGrammer.g"
+#line 1526 "ncoGrammer.g"
 							
 							
 							//In Initial scan all newly defined atts are flagged as Undefined
@@ -2758,10 +3437,13 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 							prs_arg->int_vtr.push_ow(Nvar);          
 							
 							// Copy return variable
+							if(bret)
 							var=nco_var_dpl(var1);    
+							else
+							var=(var_sct*)NULL;    
 							
 							
-#line 2765 "ncoTree.cpp"
+#line 3447 "ncoTree.cpp"
 						}
 					}
 		else {
@@ -2783,11 +3465,11 @@ var_sct * ncoTree::assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 }
 
 var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
-	bool bram
+	bool bram,bool bret
 ) {
-#line 1657 "ncoGrammer.g"
+#line 1549 "ncoGrammer.g"
 	var_sct *var;
-#line 2791 "ncoTree.cpp"
+#line 3473 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST assign_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST lmt = ANTLR_USE_NAMESPACE(antlr)nullAST;
@@ -2798,52 +3480,52 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 	ANTLR_USE_NAMESPACE(antlr)RefAST lmta = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST att1 = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST att2 = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 1657 "ncoGrammer.g"
+#line 1549 "ncoGrammer.g"
 	
 	const std::string fnc_nm("assign"); 
 	var=NULL_CEWI;
 	
-#line 2807 "ncoTree.cpp"
+#line 3489 "ncoTree.cpp"
 	
 	try {      // for error handling
-		bool synPredMatched272 = false;
+		bool synPredMatched260 = false;
 		if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 			_t = ASTNULL;
 		if (((_t->getType() == VAR_ID))) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t272 = _t;
-			synPredMatched272 = true;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t260 = _t;
+			synPredMatched260 = true;
 			inputState->guessing++;
 			try {
 				{
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t271 = _t;
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp205_AST_in = _t;
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t259 = _t;
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp255_AST_in = _t;
 				match(_t,VAR_ID);
 				_t = _t->getFirstChild();
-				ANTLR_USE_NAMESPACE(antlr)RefAST tmp206_AST_in = _t;
+				ANTLR_USE_NAMESPACE(antlr)RefAST tmp256_AST_in = _t;
 				match(_t,LMT_LIST);
 				_t = _t->getNextSibling();
-				_t = __t271;
+				_t = __t259;
 				_t = _t->getNextSibling();
 				}
 			}
 			catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-				synPredMatched272 = false;
+				synPredMatched260 = false;
 			}
-			_t = __t272;
+			_t = __t260;
 			inputState->guessing--;
 		}
-		if ( synPredMatched272 ) {
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t273 = _t;
+		if ( synPredMatched260 ) {
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t261 = _t;
 			vid = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 			match(_t,VAR_ID);
 			_t = _t->getFirstChild();
 			lmt = _t;
 			match(_t,LMT_LIST);
 			_t = _t->getNextSibling();
-			_t = __t273;
+			_t = __t261;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 1663 "ncoGrammer.g"
+#line 1555 "ncoGrammer.g"
 				
 				
 				int idx;
@@ -3033,27 +3715,28 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 				(void)nco_lmt_free(lmt_vtr[idx]);
 				
 				// See If we have to return something
-				end0:         if(lmt->getNextSibling() && lmt->getNextSibling()->getType()==NORET)
-				var=NULL_CEWI;
-				else 
+				end0:         if(bret)
 				var=prs_arg->ncap_var_init(var_nm,true);
+				else 
+				var=NULL_CEWI;
+				
 				
 				
-#line 3043 "ncoTree.cpp"
+#line 3726 "ncoTree.cpp"
 			}
 		}
 		else {
-			bool synPredMatched277 = false;
+			bool synPredMatched265 = false;
 			if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 				_t = ASTNULL;
 			if (((_t->getType() == VAR_ID))) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t277 = _t;
-				synPredMatched277 = true;
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t265 = _t;
+				synPredMatched265 = true;
 				inputState->guessing++;
 				try {
 					{
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t275 = _t;
-					ANTLR_USE_NAMESPACE(antlr)RefAST tmp207_AST_in = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t263 = _t;
+					ANTLR_USE_NAMESPACE(antlr)RefAST tmp257_AST_in = _t;
 					match(_t,VAR_ID);
 					_t = _t->getFirstChild();
 					{
@@ -3062,14 +3745,14 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					switch ( _t->getType()) {
 					case DMN_LIST:
 					{
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp208_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp258_AST_in = _t;
 						match(_t,DMN_LIST);
 						_t = _t->getNextSibling();
 						break;
 					}
 					case DMN_LIST_P:
 					{
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp209_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp259_AST_in = _t;
 						match(_t,DMN_LIST_P);
 						_t = _t->getNextSibling();
 						break;
@@ -3080,28 +3763,28 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					}
 					}
 					}
-					_t = __t275;
+					_t = __t263;
 					_t = _t->getNextSibling();
 					}
 				}
 				catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-					synPredMatched277 = false;
+					synPredMatched265 = false;
 				}
-				_t = __t277;
+				_t = __t265;
 				inputState->guessing--;
 			}
-			if ( synPredMatched277 ) {
-				ANTLR_USE_NAMESPACE(antlr)RefAST __t278 = _t;
+			if ( synPredMatched265 ) {
+				ANTLR_USE_NAMESPACE(antlr)RefAST __t266 = _t;
 				vid1 = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 				match(_t,VAR_ID);
 				_t = _t->getFirstChild();
 				dmn = _t;
 				if ( _t == ANTLR_USE_NAMESPACE(antlr)nullAST ) throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
 				_t = _t->getNextSibling();
-				_t = __t278;
+				_t = __t266;
 				_t = _t->getNextSibling();
 				if ( inputState->guessing==0 ) {
-#line 1860 "ncoGrammer.g"
+#line 1753 "ncoGrammer.g"
 					
 					
 					var_sct *var1;
@@ -3117,11 +3800,15 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					bcst=true;  
 					var_cst=NULL_CEWI;
 					
-					//aRef=vid->getFirstChild()->getFirstChild();
-					aRef=dmn->getFirstChild();
 					
+					
+					if(dmn)
+					{ 
+					
+					aRef=dmn->getFirstChild();                  
 					// pPut dimension names in vector       
-					while(aRef) {
+					while(aRef) 
+					{
 					str_vtr.push_back(aRef->getText());
 					aRef=aRef->getNextSibling();      
 					}
@@ -3131,8 +3818,20 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					// or any entity which has a size of one.
 					var_cst=ncap_cst_mk(str_vtr,prs_arg);     
 					var1=out(vid1->getNextSibling());
+					}  
+					// deal with an empty hyperslab ie casting a scalar
+					else
+					{  
+					var1=out(vid1->getNextSibling());    
+					var_cst=ncap_sclr_var_mk("Internally generated template",var1->type,false);   
+					}    
+					
+					
+					
+					// do attribute propagation only  from RHS -if not an att
+					if( !ncap_var_is_att(var1))  
+					ncap_att_gnrl(var_nm,var1->nm,1,prs_arg);
 					
-					/* NB var_cst->val.vp always now set to null */ 
 					
 					
 					// If the RHS has size one or is an attribute or an irregular hyperslab
@@ -3142,24 +3841,27 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					bool br1=(var_cst->sz >=1 && var1->sz==1);
 					bool br2=(var_cst->sz==var1->sz &&  ( ncap_var_is_att(var1) ||var1->has_dpl_dmn==-1 ));
 					
+					// NB var_cst->val.vp always now set to null 
 					// The code rebuilds var1 with the shape from the casting variable  
 					if( br1 || br2){
 					var_sct *var_nw;
-					void *vp_swp;
 					
-					var_nw=nco_var_dpl(var_cst);
-					var_nw=nco_var_cnf_typ(var1->type,var_nw);
 					if(br1)
-					(void)ncap_att_stretch(var1,var_nw->sz);
+					(void)ncap_att_stretch(var1,var_cst->sz);
+					
+					var_nw=nco_var_dpl(var_cst);
+					(void)nco_var_cnf_typ(var1->type,var_nw);
 					
-					vp_swp=var_nw->val.vp;
 					var_nw->val.vp=var1->val.vp;
-					var1->val.vp=vp_swp;
+					var1->val.vp=(void*)NULL;
 					
 					var1=nco_var_free(var1);
 					var1=var_nw;
 					}
 					
+					
+					
+					
 					//blow out if vars not the same size      
 					if(var1->sz != var_cst->sz) 
 					err_prn(fnc_nm, "LHS cast for "+var_nm+" - cannot make RHS "+ std::string(var1->nm) + " conform.");          
@@ -3167,10 +3869,10 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					var1->nm =strdup(var_nm.c_str());
 					
 					// See If we have to return something
-					if(dmn->getNextSibling() && dmn->getNextSibling()->getType()==NORET)
-					var=NULL_CEWI;
-					else 
+					if(bret)
 					var=nco_var_dpl(var1);     
+					else 
+					var=NULL_CEWI;
 					
 					//call to nco_var_get() in ncap_var_init() uses this property
 					var1->typ_dsk=var1->type;
@@ -3180,7 +3882,7 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					var_cst=nco_var_free(var_cst); 
 					
 					
-#line 3184 "ncoTree.cpp"
+#line 3886 "ncoTree.cpp"
 				}
 			}
 			else if ((_t->getType() == VAR_ID)) {
@@ -3188,16 +3890,17 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 				match(_t,VAR_ID);
 				_t = _t->getNextSibling();
 				if ( inputState->guessing==0 ) {
-#line 1939 "ncoGrammer.g"
+#line 1851 "ncoGrammer.g"
+					
 					
 					// Set class wide variables
-					var_sct *var_lhs=(var_sct*)NULL;
-					var_sct *var_rhs=(var_sct*)NULL;
+					var_sct *var_rhs;
 					NcapVar *Nvar;
 					std::string var_nm;
 					
 					var_nm=vid2->getText();       
 					
+					
 					if(nco_dbg_lvl_get() >= nco_dbg_var) dbg_prn(fnc_nm,var_nm);
 					
 					bcst=false;
@@ -3208,97 +3911,99 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 					// Save name 
 					std::string s_var_rhs(var_rhs->nm);
 					
+					// Do attribute propagation only if
+					// var doesn't already exist or is defined but NOT
+					// populated
 					Nvar=prs_arg->var_vtr.find(var_nm);
+					//rcd=nco_inq_varid_flg(prs_arg->out_id,var_rhs->nm ,&var_id);
 					
 					if(!Nvar || (Nvar && Nvar->flg_stt==1))
 					(void)ncap_att_cpy(var_nm,s_var_rhs,prs_arg);
 					
-					if(Nvar)
-					var_lhs=nco_var_dpl(Nvar->var);
-					// use init_chk() to avoid warning from ncap_var_init() if var not present  
-					else if(prs_arg->ncap_var_init_chk(var_nm))
-					var_lhs=prs_arg->ncap_var_init(var_nm,false); 
-					
-					if(var_lhs)
-					{
 					// var is defined and populated &  RHS is scalar -then stretch var to match
-					var_rhs=nco_var_cnf_typ(var_lhs->type,var_rhs);   
-					if(var_rhs->sz ==1 && var_lhs->sz >1)
+					if(Nvar && Nvar->flg_stt==2)
+					{  
+					long n_sz=Nvar->var->sz;
+					
+					if(var_rhs->sz ==1 && Nvar->var->sz >1)
 					{
-					(void)ncap_att_stretch(var_rhs,var_lhs->sz);
+					var_rhs=nco_var_cnf_typ(Nvar->var->type,var_rhs);  
+					(void)ncap_att_stretch(var_rhs,n_sz);
+					
 					// this is a special case -- if the RHS scalar has
 					// no missing value then retain LHS missing value
 					// else LHS missing value gets over written by RHS
 					if(!var_rhs->has_mss_val)
-					(void)nco_mss_val_cp(var_lhs,var_rhs);   
-					}   
+					(void)nco_mss_val_cp(Nvar->var,var_rhs);   
+					}
+					
+					else if( var_rhs->sz >1 && n_sz >1 && var_rhs->sz != n_sz && n_sz % var_rhs->sz ==0)  
+					ncap_var_cnf_dmn(&Nvar->var,&var_rhs); 
 					
-					if( var_rhs->sz != var_lhs->sz) 
-					err_prn(fnc_nm,"regular assign - var size missmatch between \""+var_nm+"\" and RHS of expression");                        
 					
-					var_lhs->val.vp=var_rhs->val.vp;
+					if(var_rhs->sz != Nvar->var->sz)
+					err_prn(fnc_nm, "size miss-match in simple assign between \""+ var_nm +"\""+ " size="+nbr2sng(Nvar->var->sz) + "var_rhs expr size="+nbr2sng(var_rhs->sz) );
+					
+					} 
+					
+					// finally add new name before write  
+					(void)nco_free(var_rhs->nm);                
+					var_rhs->nm =strdup(var_nm.c_str());
 					
-					var_rhs->val.vp=(void*)NULL;                
-					nco_var_free(var_rhs);  
 					// Write var to disk
-					(void)prs_arg->ncap_var_write(var_lhs,bram);
-					}
-					else
-					{
-					nco_free(var_rhs->nm);
-					var_rhs->nm=strdup(var_nm.c_str());  
-					(void)prs_arg->ncap_var_write(var_rhs,bram);  
-					}  
+					(void)prs_arg->ncap_var_write(var_rhs,bram);
+					//(void)ncap_var_write_omp(var_rhs,bram,prs_arg);
 					
 					// See If we have to return something
-					if(vid2->getFirstChild() && vid2->getFirstChild()->getType()==NORET)
-					var=NULL_CEWI;
+					if(bret)
+					var=prs_arg->ncap_var_init(var_nm,true);   
 					else 
-					var=prs_arg->ncap_var_init(var_nm,true);               ;
+					var=NULL_CEWI;
+					
 					
 					
-#line 3261 "ncoTree.cpp"
+#line 3966 "ncoTree.cpp"
 				}
 			}
 			else {
-				bool synPredMatched281 = false;
+				bool synPredMatched269 = false;
 				if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 					_t = ASTNULL;
 				if (((_t->getType() == ATT_ID))) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t281 = _t;
-					synPredMatched281 = true;
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t269 = _t;
+					synPredMatched269 = true;
 					inputState->guessing++;
 					try {
 						{
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t280 = _t;
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp210_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t268 = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp260_AST_in = _t;
 						match(_t,ATT_ID);
 						_t = _t->getFirstChild();
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp211_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp261_AST_in = _t;
 						match(_t,LMT_LIST);
 						_t = _t->getNextSibling();
-						_t = __t280;
+						_t = __t268;
 						_t = _t->getNextSibling();
 						}
 					}
 					catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-						synPredMatched281 = false;
+						synPredMatched269 = false;
 					}
-					_t = __t281;
+					_t = __t269;
 					inputState->guessing--;
 				}
-				if ( synPredMatched281 ) {
-					ANTLR_USE_NAMESPACE(antlr)RefAST __t282 = _t;
+				if ( synPredMatched269 ) {
+					ANTLR_USE_NAMESPACE(antlr)RefAST __t270 = _t;
 					att = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 					match(_t,ATT_ID);
 					_t = _t->getFirstChild();
 					lmta = _t;
 					match(_t,LMT_LIST);
 					_t = _t->getNextSibling();
-					_t = __t282;
+					_t = __t270;
 					_t = _t->getNextSibling();
 					if ( inputState->guessing==0 ) {
-#line 2008 "ncoGrammer.g"
+#line 1923 "ncoGrammer.g"
 						
 						
 						long srt,end,cnt,srd;  
@@ -3368,7 +4073,7 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 						{
 						// check size
 						if(  var_rhs->sz!=1L &&  var_rhs->sz != cnt)   
-						err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesnt match RHS size=" + nbr2sng(var_rhs->sz));
+						err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesn't match RHS size=" + nbr2sng(var_rhs->sz));
 						
 						
 						szn=(var_rhs->sz >1 ? 1: 0);     
@@ -3415,7 +4120,7 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 						
 						// check size
 						if(  var_rhs->sz!=1L &&  var_rhs->sz != cnt)   
-						err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesnt match RHS size=" + nbr2sng(var_rhs->sz));
+						err_prn(fnc_nm,"Hyperslab limits for attribute "+att_nm + " on LHS size="+nbr2sng(cnt)+ " doesn't match RHS size=" + nbr2sng(var_rhs->sz));
 						
 						
 						nco_var_cnf_typ(var_lhs->type,var_rhs);               
@@ -3444,62 +4149,61 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 						prs_arg->var_vtr.push_ow(Nvar);       
 						
 						// See If we have to return something
-						if(lmta->getFirstChild() && lmta->getFirstChild()->getType()==NORET)
-						var=NULL_CEWI;
+						if(bret)
+						var=nco_var_dpl(var_lhs);             
 						else 
-						var=nco_var_dpl(var_lhs);               ;
-						
+						var=NULL_CEWI; 
 						
 						att_end: ; 
 						
 						
 						
-#line 3458 "ncoTree.cpp"
+#line 4162 "ncoTree.cpp"
 					}
 				}
 				else {
-					bool synPredMatched285 = false;
+					bool synPredMatched273 = false;
 					if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
 						_t = ASTNULL;
 					if (((_t->getType() == ATT_ID))) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t285 = _t;
-						synPredMatched285 = true;
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t273 = _t;
+						synPredMatched273 = true;
 						inputState->guessing++;
 						try {
 							{
-							ANTLR_USE_NAMESPACE(antlr)RefAST __t284 = _t;
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp212_AST_in = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST __t272 = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp262_AST_in = _t;
 							match(_t,ATT_ID);
 							_t = _t->getFirstChild();
-							ANTLR_USE_NAMESPACE(antlr)RefAST tmp213_AST_in = _t;
+							ANTLR_USE_NAMESPACE(antlr)RefAST tmp263_AST_in = _t;
 							match(_t,DMN_LIST);
 							_t = _t->getNextSibling();
-							_t = __t284;
+							_t = __t272;
 							_t = _t->getNextSibling();
 							}
 						}
 						catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
-							synPredMatched285 = false;
+							synPredMatched273 = false;
 						}
-						_t = __t285;
+						_t = __t273;
 						inputState->guessing--;
 					}
-					if ( synPredMatched285 ) {
-						ANTLR_USE_NAMESPACE(antlr)RefAST __t286 = _t;
+					if ( synPredMatched273 ) {
+						ANTLR_USE_NAMESPACE(antlr)RefAST __t274 = _t;
 						att1 = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 						match(_t,ATT_ID);
 						_t = _t->getFirstChild();
-						ANTLR_USE_NAMESPACE(antlr)RefAST tmp214_AST_in = _t;
+						ANTLR_USE_NAMESPACE(antlr)RefAST tmp264_AST_in = _t;
 						match(_t,DMN_LIST);
 						_t = _t->getNextSibling();
-						_t = __t286;
+						_t = __t274;
 						_t = _t->getNextSibling();
 						if ( inputState->guessing==0 ) {
-#line 2164 "ncoGrammer.g"
+#line 2078 "ncoGrammer.g"
 							
 							;
 							
-#line 3503 "ncoTree.cpp"
+#line 4207 "ncoTree.cpp"
 						}
 					}
 					else if ((_t->getType() == ATT_ID)) {
@@ -3507,7 +4211,7 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 						match(_t,ATT_ID);
 						_t = _t->getNextSibling();
 						if ( inputState->guessing==0 ) {
-#line 2167 "ncoGrammer.g"
+#line 2081 "ncoGrammer.g"
 							
 							
 							var_sct *var1;
@@ -3540,13 +4244,14 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 							prs_arg->var_vtr.push_ow(Nvar);       
 							
 							// See If we have to return something
-							if(att2->getFirstChild() && att2->getFirstChild()->getType()==NORET)
-							var=NULL_CEWI;
+							if(bret)
+							var=nco_var_dpl(var1);               
 							else 
-							var=nco_var_dpl(var1);               ;
+							var=NULL_CEWI;
+							
 							
 							
-#line 3550 "ncoTree.cpp"
+#line 4255 "ncoTree.cpp"
 						}
 					}
 		else {
@@ -3568,14 +4273,14 @@ var_sct * ncoTree::assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 }
 
 var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
-#line 2687 "ncoGrammer.g"
+#line 2730 "ncoGrammer.g"
 	var_sct *var;
-#line 3574 "ncoTree.cpp"
+#line 4279 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST out_asn_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid1 = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST att = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 2687 "ncoGrammer.g"
+#line 2730 "ncoGrammer.g"
 	
 	const std::string fnc_nm("assign_asn");
 	var=NULL_CEWI; 
@@ -3583,7 +4288,7 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 	NcapVar *Nvar;
 	
 	
-#line 3587 "ncoTree.cpp"
+#line 4292 "ncoTree.cpp"
 	
 	try {      // for error handling
 		if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
@@ -3591,17 +4296,17 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 		switch ( _t->getType()) {
 		case UTIMES:
 		{
-			ANTLR_USE_NAMESPACE(antlr)RefAST __t359 = _t;
-			ANTLR_USE_NAMESPACE(antlr)RefAST tmp215_AST_in = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST __t426 = _t;
+			ANTLR_USE_NAMESPACE(antlr)RefAST tmp265_AST_in = _t;
 			match(_t,UTIMES);
 			_t = _t->getFirstChild();
 			vid1 = _t;
 			match(_t,VAR_ID);
 			_t = _t->getNextSibling();
-			_t = __t359;
+			_t = __t426;
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2697 "ncoGrammer.g"
+#line 2740 "ncoGrammer.g"
 				
 				if(vid1->getFirstChild())
 				err_prn(fnc_nm,"Invalid Lvalue " +vid1->getText() );
@@ -3619,7 +4324,7 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				}
 				
 				
-#line 3623 "ncoTree.cpp"
+#line 4328 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -3629,7 +4334,7 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,VAR_ID);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2715 "ncoGrammer.g"
+#line 2758 "ncoGrammer.g"
 				
 				var_nm_s=vid->getText();  
 				if(vid->getFirstChild())
@@ -3650,7 +4355,7 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				}
 				
 				
-#line 3654 "ncoTree.cpp"
+#line 4359 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -3660,7 +4365,7 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			match(_t,ATT_ID);
 			_t = _t->getNextSibling();
 			if ( inputState->guessing==0 ) {
-#line 2736 "ncoGrammer.g"
+#line 2779 "ncoGrammer.g"
 				
 				// check "output"
 				NcapVar *Nvar=NULL;
@@ -3668,7 +4373,9 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				if(att->getFirstChild())
 				err_prn(fnc_nm,"Invalid Lvalue " +att->getText() );
 				
+				var=att_plain(att);
 				
+				/* 
 				if(prs_arg->ntl_scn)
 				Nvar=prs_arg->int_vtr.find(att->getText());
 				
@@ -3691,9 +4398,11 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 				
 				if(prs_arg->ntl_scn && var->val.vp !=NULL)
 				var->val.vp=(void*)nco_free(var->val.vp);
+				*/ 
+				
 				
 				
-#line 3697 "ncoTree.cpp"
+#line 4406 "ncoTree.cpp"
 			}
 			break;
 		}
@@ -3716,18 +4425,155 @@ var_sct * ncoTree::out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 	return var;
 }
 
+var_sct * ncoTree::att_plain(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
+#line 2819 "ncoGrammer.g"
+	var_sct *var;
+#line 4432 "ncoTree.cpp"
+	ANTLR_USE_NAMESPACE(antlr)RefAST att_plain_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+	ANTLR_USE_NAMESPACE(antlr)RefAST att = ANTLR_USE_NAMESPACE(antlr)nullAST;
+#line 2819 "ncoGrammer.g"
+	
+	const std::string fnc_nm("att_plain");
+	var=NULL_CEWI; 
+	string att_nm; 
+	NcapVar *Nvar;
+	
+	
+#line 4443 "ncoTree.cpp"
+	
+	try {      // for error handling
+		att = _t;
+		match(_t,ATT_ID);
+		_t = _t->getNextSibling();
+		if ( inputState->guessing==0 ) {
+#line 2829 "ncoGrammer.g"
+			
+			// check "output"
+			NcapVar *Nvar=NULL;
+			
+			att_nm=att->getText();       
+			
+			if(prs_arg->ntl_scn)
+			Nvar=prs_arg->int_vtr.find(att_nm);
+			
+			if(Nvar==NULL) 
+			Nvar=prs_arg->var_vtr.find(att_nm);
+			
+			var=NULL_CEWI;    
+			if(Nvar !=NULL)
+			var=nco_var_dpl(Nvar->var);
+			else    
+			var=ncap_att_init(att_nm,prs_arg);
+			
+			if(prs_arg->ntl_scn==False  && var==NULL_CEWI )
+			err_prn(fnc_nm,"Unable to locate attribute " +att_nm+ " in input or output files.");
+			
+			
+			// if att not found return undefined
+			if(prs_arg->ntl_scn && var==NULL_CEWI )
+			var=ncap_var_udf(att_nm.c_str());
+			
+			if(prs_arg->ntl_scn && var->val.vp !=NULL)
+			var->val.vp=(void*)nco_free(var->val.vp);
+			
+			
+#line 4481 "ncoTree.cpp"
+		}
+	}
+	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
+		if( inputState->guessing == 0 ) {
+			reportError(ex);
+			if ( _t != ANTLR_USE_NAMESPACE(antlr)nullAST )
+				_t = _t->getNextSibling();
+		} else {
+			throw;
+		}
+	}
+	_retTree = _t;
+	return var;
+}
+
+ RefAST  ncoTree::att2var(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
+#line 2866 "ncoGrammer.g"
+	 RefAST tr ;
+#line 4500 "ncoTree.cpp"
+	ANTLR_USE_NAMESPACE(antlr)RefAST att2var_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+	ANTLR_USE_NAMESPACE(antlr)RefAST att = ANTLR_USE_NAMESPACE(antlr)nullAST;
+#line 2866 "ncoGrammer.g"
+	
+	var_sct *var=NULL_CEWI; 
+	NcapVar *Nvar;
+	std::string sn;
+	std::string att_nm;
+	std::string fnc_nm("att2var");
+	
+	
+#line 4512 "ncoTree.cpp"
+	
+	try {      // for error handling
+		{
+		att = _t;
+		match(_t,ATT_ID);
+		_t = _t->getNextSibling();
+		}
+		if ( inputState->guessing==0 ) {
+#line 2877 "ncoGrammer.g"
+			
+			/* sn can be empty on 1st Parse but not 2nd */
+			att_nm=att->getText();
+			
+			if(nco_dbg_lvl_get() >= nco_dbg_scl) 
+			dbg_prn(fnc_nm,"att_nm="+att_nm);
+			
+			sn=ncap_att2var(prs_arg,att_nm); 
+			
+			if(prs_arg->ntl_scn && sn.empty())     
+			{
+			sn="_empty_"+att_nm;   
+			var=ncap_var_udf(sn.c_str());
+			Nvar=new NcapVar(var);
+			prs_arg->int_vtr.push_ow(Nvar);            
+			}
+			
+			
+			tr=nco_dupList(att);
+			
+			if(sn.find('@') != std::string::npos)
+			tr->setType(ATT_ID);       
+			else
+			tr->setType(VAR_ID);       
+			
+			tr->setText(sn);
+			
+			
+#line 4550 "ncoTree.cpp"
+		}
+	}
+	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
+		if( inputState->guessing == 0 ) {
+			reportError(ex);
+			if ( _t != ANTLR_USE_NAMESPACE(antlr)nullAST )
+				_t = _t->getNextSibling();
+		} else {
+			throw;
+		}
+	}
+	_retTree = _t;
+	return tr ;
+}
+
 var_sct * ncoTree::value_list(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
-#line 2770 "ncoGrammer.g"
+#line 2909 "ncoGrammer.g"
 	var_sct *var;
-#line 3723 "ncoTree.cpp"
+#line 4569 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST value_list_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vlst = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 2770 "ncoGrammer.g"
+#line 2909 "ncoGrammer.g"
 	
 	const std::string fnc_nm("value_list");
 	var=NULL_CEWI; 
 	
-#line 3731 "ncoTree.cpp"
+#line 4577 "ncoTree.cpp"
 	
 	try {      // for error handling
 		{
@@ -3736,7 +4582,7 @@ var_sct * ncoTree::value_list(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 		_t = _t->getNextSibling();
 		}
 		if ( inputState->guessing==0 ) {
-#line 2775 "ncoGrammer.g"
+#line 2914 "ncoGrammer.g"
 			
 			
 			char *cp;
@@ -3824,7 +4670,7 @@ var_sct * ncoTree::value_list(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			var=var_ret;
 			
 			
-#line 3828 "ncoTree.cpp"
+#line 4674 "ncoTree.cpp"
 		}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
@@ -3843,20 +4689,20 @@ var_sct * ncoTree::value_list(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 var_sct * ncoTree::value_list_string(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 	 std::vector<var_sct*> &exp_vtr
 ) {
-#line 2866 "ncoGrammer.g"
+#line 3005 "ncoGrammer.g"
 	var_sct *var;
-#line 3849 "ncoTree.cpp"
+#line 4695 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST value_list_string_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
-#line 2866 "ncoGrammer.g"
+#line 3005 "ncoGrammer.g"
 	
 	const std::string fnc_nm("value_list_string");
 	var=NULL_CEWI; 
 	
-#line 3856 "ncoTree.cpp"
+#line 4702 "ncoTree.cpp"
 	
 	try {      // for error handling
 		if ( inputState->guessing==0 ) {
-#line 2872 "ncoGrammer.g"
+#line 3011 "ncoGrammer.g"
 			
 			int idx;
 			int nbr_lst;
@@ -3905,7 +4751,7 @@ var_sct * ncoTree::value_list_string(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 			end_val: var=var_ret;
 			
 			
-#line 3909 "ncoTree.cpp"
+#line 4755 "ncoTree.cpp"
 		}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
@@ -3924,26 +4770,26 @@ var_sct * ncoTree::value_list_string(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 bool  ncoTree::where_assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 	var_sct *var_msk
 ) {
-#line 2923 "ncoGrammer.g"
+#line 3062 "ncoGrammer.g"
 	bool bret=false;
-#line 3930 "ncoTree.cpp"
+#line 4776 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST where_assign_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 2923 "ncoGrammer.g"
+#line 3062 "ncoGrammer.g"
 	
 	const std::string fnc_nm("where_assign");
 	var_sct *var_rhs;
 	
 	
-#line 3939 "ncoTree.cpp"
+#line 4785 "ncoTree.cpp"
 	
 	try {      // for error handling
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t364 = _t;
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp216_AST_in = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t434 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp266_AST_in = _t;
 		match(_t,EXPR);
 		_t = _t->getFirstChild();
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t365 = _t;
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp217_AST_in = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t435 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp267_AST_in = _t;
 		match(_t,ASSIGN);
 		_t = _t->getFirstChild();
 		vid = _t;
@@ -3951,12 +4797,12 @@ bool  ncoTree::where_assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 		_t = _t->getNextSibling();
 		var_rhs=out(_t);
 		_t = _retTree;
-		_t = __t365;
+		_t = __t435;
 		_t = _t->getNextSibling();
-		_t = __t364;
+		_t = __t434;
 		_t = _t->getNextSibling();
 		if ( inputState->guessing==0 ) {
-#line 2929 "ncoGrammer.g"
+#line 3068 "ncoGrammer.g"
 			
 			
 			bool bfr=false;
@@ -4058,7 +4904,7 @@ bool  ncoTree::where_assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 			prs_arg->ncap_var_write(var_lhs,false);
 			bret=true;
 			
-#line 4062 "ncoTree.cpp"
+#line 4908 "ncoTree.cpp"
 		}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
@@ -4075,42 +4921,42 @@ bool  ncoTree::where_assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 }
 
 var_sct * ncoTree::var_lmt_one(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
-#line 3034 "ncoGrammer.g"
+#line 3173 "ncoGrammer.g"
 	var_sct *var;
-#line 4081 "ncoTree.cpp"
+#line 4927 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST var_lmt_one_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 3034 "ncoGrammer.g"
+#line 3173 "ncoGrammer.g"
 	
 	const std::string fnc_nm("var_lmt_one");
 	var=NULL_CEWI; 
 	var_sct *var_nbr;
 	
-#line 4090 "ncoTree.cpp"
+#line 4936 "ncoTree.cpp"
 	
 	try {      // for error handling
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t367 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t437 = _t;
 		vid = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 		match(_t,VAR_ID);
 		_t = _t->getFirstChild();
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t368 = _t;
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp218_AST_in = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t438 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp268_AST_in = _t;
 		match(_t,LMT_LIST);
 		_t = _t->getFirstChild();
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t369 = _t;
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp219_AST_in = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t439 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp269_AST_in = _t;
 		match(_t,LMT);
 		_t = _t->getFirstChild();
 		var_nbr=out(_t);
 		_t = _retTree;
-		_t = __t369;
+		_t = __t439;
 		_t = _t->getNextSibling();
-		_t = __t368;
+		_t = __t438;
 		_t = _t->getNextSibling();
-		_t = __t367;
+		_t = __t437;
 		_t = _t->getNextSibling();
 		if ( inputState->guessing==0 ) {
-#line 3040 "ncoGrammer.g"
+#line 3179 "ncoGrammer.g"
 			
 			
 			int idx;
@@ -4211,7 +5057,7 @@ var_sct * ncoTree::var_lmt_one(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			end0:       var_nbr=nco_var_free(var_nbr);
 			var_rhs=nco_var_free(var_rhs);   
 			
-#line 4215 "ncoTree.cpp"
+#line 5061 "ncoTree.cpp"
 		}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
@@ -4230,42 +5076,42 @@ var_sct * ncoTree::var_lmt_one(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 var_sct * ncoTree::var_lmt_one_lhs(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 	bool bram
 ) {
-#line 3145 "ncoGrammer.g"
+#line 3284 "ncoGrammer.g"
 	var_sct *var;
-#line 4236 "ncoTree.cpp"
+#line 5082 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST var_lmt_one_lhs_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 3145 "ncoGrammer.g"
+#line 3284 "ncoGrammer.g"
 	
 	const std::string fnc_nm("var_lmt_one_lhs");
 	var=NULL_CEWI; 
 	var_sct *var_nbr;
 	
-#line 4245 "ncoTree.cpp"
+#line 5091 "ncoTree.cpp"
 	
 	try {      // for error handling
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t371 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t441 = _t;
 		vid = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 		match(_t,VAR_ID);
 		_t = _t->getFirstChild();
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t372 = _t;
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp220_AST_in = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t442 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp270_AST_in = _t;
 		match(_t,LMT_LIST);
 		_t = _t->getFirstChild();
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t373 = _t;
-		ANTLR_USE_NAMESPACE(antlr)RefAST tmp221_AST_in = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t443 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp271_AST_in = _t;
 		match(_t,LMT);
 		_t = _t->getFirstChild();
 		var_nbr=out(_t);
 		_t = _retTree;
-		_t = __t373;
+		_t = __t443;
 		_t = _t->getNextSibling();
-		_t = __t372;
+		_t = __t442;
 		_t = _t->getNextSibling();
-		_t = __t371;
+		_t = __t441;
 		_t = _t->getNextSibling();
 		if ( inputState->guessing==0 ) {
-#line 3151 "ncoGrammer.g"
+#line 3290 "ncoGrammer.g"
 			
 			int idx; 
 			int var_id; 
@@ -4410,7 +5256,7 @@ var_sct * ncoTree::var_lmt_one_lhs(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 			var_rhs=nco_var_free(var_rhs); 
 			var_nbr=nco_var_free(var_nbr); 
 			
-#line 4414 "ncoTree.cpp"
+#line 5260 "ncoTree.cpp"
 		}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
@@ -4427,31 +5273,31 @@ var_sct * ncoTree::var_lmt_one_lhs(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 }
 
 var_sct * ncoTree::var_lmt(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
-#line 3299 "ncoGrammer.g"
+#line 3438 "ncoGrammer.g"
 	var_sct *var;
-#line 4433 "ncoTree.cpp"
+#line 5279 "ncoTree.cpp"
 	ANTLR_USE_NAMESPACE(antlr)RefAST var_lmt_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 	ANTLR_USE_NAMESPACE(antlr)RefAST vid = ANTLR_USE_NAMESPACE(antlr)nullAST;
 	ANTLR_USE_NAMESPACE(antlr)RefAST lmt = ANTLR_USE_NAMESPACE(antlr)nullAST;
-#line 3299 "ncoGrammer.g"
+#line 3438 "ncoGrammer.g"
 	
 	const std::string fnc_nm("var_lmt");
 	var=NULL_CEWI; 
 	
-#line 4442 "ncoTree.cpp"
+#line 5288 "ncoTree.cpp"
 	
 	try {      // for error handling
-		ANTLR_USE_NAMESPACE(antlr)RefAST __t375 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t445 = _t;
 		vid = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
 		match(_t,VAR_ID);
 		_t = _t->getFirstChild();
 		lmt = _t;
 		match(_t,LMT_LIST);
 		_t = _t->getNextSibling();
-		_t = __t375;
+		_t = __t445;
 		_t = _t->getNextSibling();
 		if ( inputState->guessing==0 ) {
-#line 3304 "ncoGrammer.g"
+#line 3443 "ncoGrammer.g"
 			
 			bool bram;   // Check for a RAM variable
 			bool bnrm;
@@ -4535,7 +5381,7 @@ var_sct * ncoTree::var_lmt(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			var=nco_var_cnf_typ(var_rhs->type,var);
 			
 			// apply LHS cast if necessary 
-			if(var->sz>1 && bcst) 
+			if(var->sz>1 && bcst && var_cst) 
 			var=ncap_cst_do(var,var_cst,prs_arg->ntl_scn);
 			}else{
 			var=ncap_var_udf("~rhs_undefined");             
@@ -4655,7 +5501,7 @@ var_sct * ncoTree::var_lmt(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			/* Casting a hyperslab --this makes my brain  hurt!!! 
 			if the var is already the correct size then do nothing 
 			what not even dimension reordering ?  */  
-			if(bcst && var1->sz != var_cst->sz)
+			if(bcst && var_cst &&  var1->sz != var_cst->sz)
 			var1=ncap_cst_do(var1,var_cst,prs_arg->ntl_scn);
 			
 			var=var1;
@@ -4692,7 +5538,7 @@ var_sct * ncoTree::var_lmt(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
 			
 			end2: var_rhs=nco_var_free(var_rhs); 
 			
-#line 4696 "ncoTree.cpp"
+#line 5542 "ncoTree.cpp"
 		}
 	}
 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
@@ -4756,19 +5602,19 @@ const char* ncoTree::tokenNames[] = {
 	"\"else\"",
 	"\"where\"",
 	"\"elsewhere\"",
-	"\"print\"",
-	"VAR_ID",
-	"ATT_ID",
 	"{",
 	"}",
 	"\"for\"",
 	":",
 	"[",
+	"VAR_ID",
 	"DIM_ID",
 	"]",
 	"/",
 	"dimension identifier",
+	"ATT_ID",
 	"call by reference",
+	"*",
 	"dot operator",
 	"FUNC",
 	"++",
@@ -4776,7 +5622,6 @@ const char* ncoTree::tokenNames[] = {
 	"!",
 	"+",
 	"-",
-	"*",
 	"power of operator",
 	"%",
 	"<<",
diff --git a/src/nco++/ncoTree.hpp b/src/nco++/ncoTree.hpp
index 9a9063d..b114adb 100644
--- a/src/nco++/ncoTree.hpp
+++ b/src/nco++/ncoTree.hpp
@@ -51,7 +51,7 @@
 #line 52 "ncoTree.hpp"
 class CUSTOM_API ncoTree : public ANTLR_USE_NAMESPACE(antlr)TreeParser, public ncoParserTokenTypes
 {
-#line 657 "ncoGrammer.g"
+#line 662 "ncoGrammer.g"
 
 
 private:
@@ -222,8 +222,7 @@ NcapVector<lmt_sct*> &lmt_vtr )
              break;
            case 1: //end
              lmt_ptr->is_usr_spc_max=True;
-             lmt_ptr->end=uival;
-             break;
+             lmt_ptr->end=uival;             break;
            case 2: //srd
              lmt_ptr->srd_sng=strdup("~fill_in");
              lmt_ptr->srd=uival;
@@ -351,7 +350,7 @@ if( nbr_dmn!=lmt_init(lmt,ast_lmt_vtr) )
      int wlk_nbr);
 
      if(tr== ANTLR_USE_NAMESPACE(antlr)nullAST)
-        err_prn("run_dbl"," REPORTS given a null AST Refrence\n");
+        err_prn("run_dbl"," REPORTS given a null AST Reference\n");
             
      //small list dont bother with double parsing     
      // just do a final parse
@@ -476,7 +475,7 @@ RefAST nco_dupList(RefAST tr){
       RefAST otr;  
       // nb astFactory is protected- must call from within class
       otr=astFactory->dupList(tr);      
-      otr->setNextSibling( ANTLR_USE_NAMESPACE(antlr)nullAST ) ;
+      //otr->setNextSibling( ANTLR_USE_NAMESPACE(antlr)nullAST ) ;
       /*  
       if(otr->getNextSibling()!= ANTLR_USE_NAMESPACE(antlr)ASTNULL )     
         err_prn("nco_dupList", "NON NULL AST SIBLING\n");
@@ -504,12 +503,14 @@ public:
 	public: int  statements(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
 	public: var_sct * out(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
 	public: var_sct * assign_ntl(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
-		bool bram
+		bool bram,bool bret
 	);
 	public: var_sct * assign(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
-		bool bram
+		bool bram,bool bret
 	);
 	public: var_sct * out_asn(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
+	public: var_sct * att_plain(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
+	public:  RefAST  att2var(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
 	public: var_sct * value_list(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
 	public: var_sct * value_list_string(ANTLR_USE_NAMESPACE(antlr)RefAST _t,
 		 std::vector<var_sct*> &exp_vtr
@@ -534,10 +535,10 @@ protected:
 private:
 	static const char* tokenNames[];
 #ifndef NO_STATIC_CONSTS
-	static const int NUM_TOKENS = 118;
+	static const int NUM_TOKENS = 117;
 #else
 	enum {
-		NUM_TOKENS = 118
+		NUM_TOKENS = 117
 	};
 #endif
 	
diff --git a/src/nco++/vtl_cls.hh b/src/nco++/vtl_cls.hh
index 959c0d2..b54ddfb 100644
--- a/src/nco++/vtl_cls.hh
+++ b/src/nco++/vtl_cls.hh
@@ -16,7 +16,7 @@
 class ncoTree;
 
 
-enum vtl_typ { VVAR,VLVAR,VDVAR, VATT,VLATT,VDATT,VDIM, VDIM_SIZE,VEXPR,VCALL_REF };
+enum vtl_typ { VVAR,VLVAR,VDVAR, VATT,VLATT,VDATT,VDIM, VDIM_SIZE,VEXPR,VCALL_REF,VPOINTER,VSTRING };
 
 class vtl_cls: public ncoParserTokenTypes {
 public:
@@ -74,6 +74,19 @@ public:
 	        lcl_typ=VCALL_REF;
                 break;      
 
+    case UTIMES:
+               {
+		 if(nbr_chd ==1 && chd_typ==ATT_ID)   
+                   lcl_typ=VPOINTER;
+		 else
+                   lcl_typ=VEXPR;    
+               }      
+               break;
+
+    case NSTRING:
+    case N4STRING:    
+              lcl_typ=VSTRING;  
+              break; 
       default:
            lcl_typ=VEXPR;
            break;
diff --git a/src/nco/libnco.h b/src/nco/libnco.h
index 7b99bee..5e39353 100644
--- a/src/nco/libnco.h
+++ b/src/nco/libnco.h
@@ -22,7 +22,7 @@
 /* Library headers */
 #include "nco_att_utl.h" /* Attribute utilities */
 #include "nco_aux.h" /* Auxiliary coordinates */
-#include "nco_bnr.h" /* Binary write utilities */
+#include "nco_bnr.h" /* Binary file utilities */
 #include "nco_cln_utl.h" /* Calendar utilities */
 #include "nco_cnf_dmn.h" /* Conform dimensions */
 #include "nco_cnf_typ.h" /* Conform variable types */
diff --git a/src/nco/mpncbo.c b/src/nco/mpncbo.c
index 9cab523..d86eacf 100644
--- a/src/nco/mpncbo.c
+++ b/src/nco/mpncbo.c
@@ -709,7 +709,7 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
   
   /* 20101019 fxm got to here merging ncbo 4.0.5 into mpncbo */
 
@@ -723,7 +723,7 @@ main(int argc,char **argv)
     if(fl_out_fmt == NCO_FORMAT_UNDEFINED) fl_out_fmt=fl_in_fmt_1;
 
     /* Open output file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     
     /* Copy global attributes */
     (void)nco_att_cpy(in_id_1,out_id,NC_GLOBAL,NC_GLOBAL,(nco_bool)True);
@@ -751,7 +751,7 @@ main(int argc,char **argv)
     /* Set chunksize parameters */
     if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl_1,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 
-    /* Turn off default filling behavior to enhance efficiency */
+    /* Turn-off default filling behavior to enhance efficiency */
     nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
     
     /* Take output file out of define mode */
@@ -960,7 +960,7 @@ main(int argc,char **argv)
 	    /* Set chunksize parameters */
 	    if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl_1,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 
-	    /* Turn off default filling behavior to enhance efficiency */
+	    /* Turn-off default filling behavior to enhance efficiency */
 	    nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 #else /* !ENABLE_MPI */
 #ifdef _OPENMP
diff --git a/src/nco/mpncecat.c b/src/nco/mpncecat.c
index 6f3ac03..5000295 100644
--- a/src/nco/mpncecat.c
+++ b/src/nco/mpncecat.c
@@ -592,7 +592,7 @@ main(int argc,char **argv)
     (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
     
     /* Open output file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     
     /* Copy global attributes */
     (void)nco_att_cpy(in_id,out_id,NC_GLOBAL,NC_GLOBAL,(nco_bool)True);
@@ -714,7 +714,7 @@ main(int argc,char **argv)
     /* Set chunksize parameters */
     if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
     
-    /* Turn off default filling behavior to enhance efficiency */
+    /* Turn-off default filling behavior to enhance efficiency */
     nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
     
     /* Take output file out of define mode */
@@ -870,7 +870,7 @@ main(int argc,char **argv)
 	      /* Set chunksize parameters */
 	      if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 	      
-	      /* Turn off default filling behavior to enhance efficiency */
+	      /* Turn-off default filling behavior to enhance efficiency */
 	      nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 #else /* !ENABLE_MPI */
 #ifdef _OPENMP
diff --git a/src/nco/mpncflint.c b/src/nco/mpncflint.c
index c1f2705..aed9f43 100644
--- a/src/nco/mpncflint.c
+++ b/src/nco/mpncflint.c
@@ -650,7 +650,7 @@ main(int argc,char **argv)
     if(fl_out_fmt == NCO_FORMAT_UNDEFINED) fl_out_fmt=fl_in_fmt_1;
     
     /* Open output file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     
     /* Copy global attributes */
     (void)nco_att_cpy(in_id_1,out_id,NC_GLOBAL,NC_GLOBAL,(nco_bool)True);
@@ -677,7 +677,7 @@ main(int argc,char **argv)
     /* Set chunksize parameters */
     if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
     
-    /* Turn off default filling behavior to enhance efficiency */
+    /* Turn-off default filling behavior to enhance efficiency */
     nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
     
     /* Take output file out of define mode */
@@ -907,7 +907,7 @@ main(int argc,char **argv)
 	    /* Set chunksize parameters */
 	    if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 	    
-	    /* Turn off default filling behavior to enhance efficiency */
+	    /* Turn-off default filling behavior to enhance efficiency */
 	    nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 #else /* !ENABLE_MPI */
 #ifdef _OPENMP
diff --git a/src/nco/mpncpdq.c b/src/nco/mpncpdq.c
index f0dd485..c896ecc 100644
--- a/src/nco/mpncpdq.c
+++ b/src/nco/mpncpdq.c
@@ -690,7 +690,7 @@ main(int argc,char **argv)
     (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
     
     /* Open output file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     if(nco_dbg_lvl >= nco_dbg_sbr) (void)fprintf(stderr,"Input, output file IDs = %d, %d\n",in_id,out_id);
     
     /* Copy global attributes */
@@ -899,7 +899,7 @@ main(int argc,char **argv)
     /* Set chunksize parameters */
     if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
     
-    /* Turn off default filling behavior to enhance efficiency */
+    /* Turn-off default filling behavior to enhance efficiency */
     nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
     
     /* Take output file out of define mode */
@@ -1073,7 +1073,7 @@ main(int argc,char **argv)
 	    /* Set chunksize parameters */
 	    if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 	    
-	    /* Turn off default filling behavior to enhance efficiency */
+	    /* Turn-off default filling behavior to enhance efficiency */
 	    nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 #else /* !ENABLE_MPI */
 #ifdef _OPENMP
diff --git a/src/nco/mpncra.c b/src/nco/mpncra.c
index 4c06952..5b0b876 100644
--- a/src/nco/mpncra.c
+++ b/src/nco/mpncra.c
@@ -705,7 +705,7 @@ main(int argc,char **argv)
     (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
     
     /* Open output file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     
     /* Copy global attributes */
     (void)nco_att_cpy(in_id,out_id,NC_GLOBAL,NC_GLOBAL,(nco_bool)True);
@@ -735,7 +735,7 @@ main(int argc,char **argv)
     /* Set chunksize parameters */
     if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
     
-    /* Turn off default filling behavior to enhance efficiency */
+    /* Turn-off default filling behavior to enhance efficiency */
     (void)nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
     
     /* Take output file out of define mode */
@@ -943,7 +943,7 @@ main(int argc,char **argv)
 	      /* Set chunksize parameters */
 	      if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 	      
-	      /* Turn off default filling behavior to enhance efficiency */
+	      /* Turn-off default filling behavior to enhance efficiency */
 	      nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 	      if(var_prc_out[idx]->sz_rec > 1L) (void)nco_put_vara(out_id,var_prc_out[idx]->id,var_prc_out[idx]->srt,var_prc_out[idx]->cnt,var_prc[idx]->val.vp,var_prc_out[idx]->type);
 	      else (void)nco_put_var1(out_id,var_prc_out[idx]->id,var_prc_out[idx]->srt,var_prc[idx]->val.vp,var_prc_out[idx]->type);
@@ -1198,7 +1198,7 @@ main(int argc,char **argv)
 		  /* Set chunksize parameters */
 		  if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 		  
-		  /* Turn off default filling behavior to enhance efficiency */
+		  /* Turn-off default filling behavior to enhance efficiency */
 		  nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 #else /* !ENABLE_MPI */
 #ifdef _OPENMP
diff --git a/src/nco/mpncwa.c b/src/nco/mpncwa.c
index 522c703..19e3ae0 100644
--- a/src/nco/mpncwa.c
+++ b/src/nco/mpncwa.c
@@ -779,7 +779,7 @@ main(int argc,char **argv)
     (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
     
     /* Open output file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     if(nco_dbg_lvl >= nco_dbg_sbr) (void)fprintf(stderr,"Input, output file IDs = %d, %d\n",in_id,out_id);
     
     /* Copy all global attributes */
@@ -830,7 +830,7 @@ main(int argc,char **argv)
     /* Set chunksize parameters */
     if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
     
-    /* Turn off default filling behavior to enhance efficiency */
+    /* Turn-off default filling behavior to enhance efficiency */
     nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
     
     /* Take output file out of define mode */
@@ -1221,7 +1221,7 @@ main(int argc,char **argv)
 	      /* Set chunksize parameters */
 	      if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,lmt_all_lst,nbr_dmn_fl,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 	      
-	      /* Turn off default filling behavior to enhance efficiency */
+	      /* Turn-off default filling behavior to enhance efficiency */
 	      nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 #endif /* !ENABLE_MPI */
 	      
diff --git a/src/nco/ncap.c b/src/nco/ncap.c
index 06ddcf9..3d0c1e8 100644
--- a/src/nco/ncap.c
+++ b/src/nco/ncap.c
@@ -398,7 +398,7 @@ main(int argc,char **argv)
         gaa_arg[gaa_nbr++]=(char *)strdup(optarg);
       } /* endif gaa */
       if(!strcmp(opt_crr,"hdf4")) nco_fmt_xtn=nco_fmt_xtn_hdf4; /* [enm] Treat file as HDF4 */
-      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
+      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF_MOD10; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
       if(!strcmp(opt_crr,"hdr_pad") || !strcmp(opt_crr,"header_pad")){
         hdr_pad=strtoul(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
         if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtoul",sng_cnv_rcd);
@@ -658,7 +658,7 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
   
   /* Copy global attributes */
   (void)nco_att_cpy(in_id,out_id,NC_GLOBAL,NC_GLOBAL,(nco_bool)True);
@@ -896,7 +896,7 @@ main(int argc,char **argv)
   /* Set chunksize parameters */
   if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) (void)nco_cnk_sz_set(out_id,(lmt_msa_sct **)NULL_CEWI,(int)0,&cnk_map,&cnk_plc,cnk_sz_scl,cnk_dmn,cnk_nbr);
 
-  /* Turn off default filling behavior to enhance efficiency */
+  /* Turn-off default filling behavior to enhance efficiency */
   nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
   
   /* Take output file out of define mode */
diff --git a/src/nco/ncap_yacc.y b/src/nco/ncap_yacc.y
index a9ee62c..b9edc15 100644
--- a/src/nco/ncap_yacc.y
+++ b/src/nco/ncap_yacc.y
@@ -64,7 +64,7 @@
 #define YY_DECL int yylex(YYSTYPE *lval_ptr,prs_sct *prs_arg)
   YY_DECL;
 
-/* Turn on parser debugging option (Bison manual p. 85) */
+/* Turn-on parser debugging option (Bison manual p. 85) */
 #define YYDEBUG 0
 int yydebug=0; /* 0: Normal operation. 1: Print parser rules during execution */
 
diff --git a/src/nco/ncatted.c b/src/nco/ncatted.c
index e8a2b10..d8643b4 100644
--- a/src/nco/ncatted.c
+++ b/src/nco/ncatted.c
@@ -167,7 +167,7 @@ main(int argc,char **argv)
 
   const char * const CVS_Id="$Id$"; 
   const char * const CVS_Revision="$Revision$";
-  const char * const opt_sht_lst="Aa:D:hl:Oo:p:Rr-:";
+  const char * const opt_sht_lst="Aa:D:hl:Oo:p:Rrt-:";
 
 #if defined(__cplusplus) || defined(PGI_CC)
   ddra_info_sct ddra_info;
@@ -198,6 +198,7 @@ main(int argc,char **argv)
   nco_bool RAM_OPEN=False; /* [flg] Open (netCDF3-only) file(s) in RAM */
   nco_bool RM_RMT_FL_PST_PRC=True; /* Option R */
   nco_bool flg_cln=False; /* [flg] Clean memory prior to exit */
+  nco_bool flg_typ_mch=False; /* [flg] Type-match attribute edits */
 
   size_t bfr_sz_hnt=NC_SIZEHINT_DEFAULT; /* [B] Buffer size hint */
   size_t hdr_pad=0UL; /* [B] Pad at end of header section */
@@ -251,6 +252,8 @@ main(int argc,char **argv)
     {"path",required_argument,0,'p'},
     {"retain",no_argument,0,'R'},
     {"rtn",no_argument,0,'R'},
+    {"typ_mch",no_argument,0,'t'},
+    {"type_match",no_argument,0,'t'},
     {"help",no_argument,0,'?'},
     {"hlp",no_argument,0,'?'},
     {0,0,0,0}
@@ -346,6 +349,9 @@ main(int argc,char **argv)
       (void)nco_cnf_prn();
       nco_exit(EXIT_SUCCESS);
       break;
+    case 't': /* Type-match attribute edits */
+      flg_typ_mch=True;
+      break;
     case '?': /* Print proper usage */
       (void)nco_usg_prn();
       nco_exit(EXIT_SUCCESS);
@@ -419,7 +425,7 @@ main(int argc,char **argv)
   for(int idx_aed=0;idx_aed<nbr_aed;idx_aed++){
     if(!aed_lst[idx_aed].var_nm){
       /* Variable name is blank so edit same attribute for all variables */
-      (void)nco_aed_prc_var_all(nc_id,aed_lst[idx_aed],trv_tbl);
+      (void)nco_aed_prc_var_all(nc_id,aed_lst[idx_aed],flg_typ_mch,trv_tbl);
     }else if(strpbrk(aed_lst[idx_aed].var_nm,".*^$\\[]()<>+?|{}")){
       /* Variable name contains a "regular expression" (rx) */
       trv_tbl_sct *trv_tbl_rx;
@@ -441,7 +447,7 @@ main(int argc,char **argv)
       /* Variable name of "global" means edit global attributes */
       (void)nco_aed_prc_glb(nc_id,aed_lst[idx_aed],trv_tbl);
     }else{ 
-      /* Regular ole' variable name means edits attributes that match absoluted and relative names */
+      /* Regular ole' variable name means edits attributes that match absolute and relative names */
       (void)nco_aed_prc_var_nm(nc_id,aed_lst[idx_aed],trv_tbl);
     } /* end var_nm */
   } /* end loop over aed structures */
diff --git a/src/nco/ncbo.c b/src/nco/ncbo.c
index 2e3a9b1..9667c54 100644
--- a/src/nco/ncbo.c
+++ b/src/nco/ncbo.c
@@ -408,7 +408,7 @@ main(int argc,char **argv)
         gaa_arg[gaa_nbr++]=(char *)strdup(optarg);
       } /* endif gaa */
       if(!strcmp(opt_crr,"hdf4")) nco_fmt_xtn=nco_fmt_xtn_hdf4; /* [enm] Treat file as HDF4 */
-      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
+      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF_MOD10; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
       if(!strcmp(opt_crr,"hdr_pad") || !strcmp(opt_crr,"header_pad")){
         hdr_pad=strtoul(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
         if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtoul",sng_cnv_rcd);
@@ -619,7 +619,7 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Initialize chunking from user-specified inputs */
   if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) rcd+=nco_cnk_ini(in_id_1,fl_out,cnk_arg,cnk_nbr,cnk_map,cnk_plc,cnk_min_byt,cnk_sz_byt,cnk_sz_scl,&cnk);
@@ -643,7 +643,7 @@ main(int argc,char **argv)
   if(gaa_nbr > 0) (void)nco_glb_att_add(out_id,gaa_arg,gaa_nbr);
   if(HISTORY_APPEND) (void)nco_vrs_att_cat(out_id);
 
-  /* Turn off default filling behavior to enhance efficiency */
+  /* Turn-off default filling behavior to enhance efficiency */
   nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 
   /* Take output file out of define mode */
diff --git a/src/nco/ncecat.c b/src/nco/ncecat.c
index 9f1e4aa..0a4eb90 100644
--- a/src/nco/ncecat.c
+++ b/src/nco/ncecat.c
@@ -630,7 +630,7 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Initialize chunking from user-specified inputs */
   if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) rcd+=nco_cnk_ini(in_id,fl_out,cnk_arg,cnk_nbr,cnk_map,cnk_plc,cnk_min_byt,cnk_sz_byt,cnk_sz_scl,&cnk);
@@ -681,7 +681,7 @@ main(int argc,char **argv)
     if(FL_LST_IN_APPEND && HISTORY_APPEND && FL_LST_IN_FROM_STDIN) (void)nco_fl_lst_att_cat(out_id,fl_lst_in,fl_nbr);
     if(thr_nbr > 0 && HISTORY_APPEND) (void)nco_thr_att_cat(out_id,thr_nbr);
 
-    /* Turn off default filling behavior to enhance efficiency */
+    /* Turn-off default filling behavior to enhance efficiency */
     nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 
     /* Take output file out of define mode */
@@ -819,7 +819,7 @@ main(int argc,char **argv)
       /* Define extracted groups, variables, and attributes in output file */
       (void)nco_xtr_dfn(in_id,out_id,&cnk,dfl_lvl,gpe,md5,CPY_GLB_METADATA,(nco_bool)True,(nco_bool)False,nco_pck_plc_nil,rec_dmn_nm,trv_tbl_gpr);
 
-      /* Turn off default filling behavior to enhance efficiency */
+      /* Turn-off default filling behavior to enhance efficiency */
       nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 
       /* Write extracted data to output file */
diff --git a/src/nco/ncflint.c b/src/nco/ncflint.c
index 5bd3a6c..5b4dd45 100644
--- a/src/nco/ncflint.c
+++ b/src/nco/ncflint.c
@@ -400,7 +400,7 @@ main(int argc,char **argv)
         gaa_arg[gaa_nbr++]=(char *)strdup(optarg);
       } /* endif gaa */
       if(!strcmp(opt_crr,"hdf4")) nco_fmt_xtn=nco_fmt_xtn_hdf4; /* [enm] Treat file as HDF4 */
-      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
+      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF_MOD10; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
       if(!strcmp(opt_crr,"hdr_pad") || !strcmp(opt_crr,"header_pad")){
         hdr_pad=strtoul(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
         if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtoul",sng_cnv_rcd);
@@ -649,7 +649,7 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Initialize chunking from user-specified inputs */
   if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) rcd+=nco_cnk_ini(in_id_1,fl_out,cnk_arg,cnk_nbr,cnk_map,cnk_plc,cnk_min_byt,cnk_sz_byt,cnk_sz_scl,&cnk);
@@ -667,7 +667,7 @@ main(int argc,char **argv)
   if(HISTORY_APPEND) (void)nco_vrs_att_cat(out_id);
   if(thr_nbr > 0 && HISTORY_APPEND) (void)nco_thr_att_cat(out_id,thr_nbr);
 
-  /* Turn off default filling behavior to enhance efficiency */
+  /* Turn-off default filling behavior to enhance efficiency */
   nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 
   /* Take output file out of define mode */
diff --git a/src/nco/ncks.c b/src/nco/ncks.c
index 493cdba..2ec8c03 100644
--- a/src/nco/ncks.c
+++ b/src/nco/ncks.c
@@ -115,6 +115,7 @@ main(int argc,char **argv)
   char **gaa_arg=NULL; /* [sng] Global attribute arguments */
   char **grp_lst_in=NULL;
   char **rgr_arg=NULL; /* [sng] Regridding arguments */
+  char **trr_arg=NULL; /* [sng] Terraref arguments */
   char **var_lst_in=NULL;
   char **xtn_lst_in=NULL; /* [sng] Extensive variables */
   char *aux_arg[NC_MAX_DIMS];
@@ -147,6 +148,8 @@ main(int argc,char **argv)
   char *sng_cnv_rcd=NULL_CEWI; /* [sng] strtol()/strtoul() return code */
   char *spr_chr=NULL; /* [sng] Separator for XML character types */
   char *spr_nmr=NULL; /* [sng] Separator for XML numeric types */
+  char *trr_in=NULL; /* [sng] File containing raw Terraref imagery */
+  char *trr_wxy=NULL; /* [sng] Terraref dimension sizes */
 
   char trv_pth[]="/"; /* [sng] Root path of traversal tree */
 
@@ -200,6 +203,7 @@ main(int argc,char **argv)
   int opt;
   int ppc_nbr=0; /* [nbr] Number of PPC arguments */
   int rgr_nbr=0; /* [nbr] Number of regridding arguments */
+  int trr_nbr=0; /* [nbr] Number of TERRAREF arguments */
   int rcd=NC_NOERR; /* [rcd] Return code */
   int thr_idx; /* [idx] Index of current thread */
   int thr_nbr=int_CEWI; /* [nbr] Thread number Option t */
@@ -258,6 +262,9 @@ main(int argc,char **argv)
   nco_bool WRT_TMP_FL=True; /* [flg] Write output to temporary file */
   nco_bool flg_cln=True; /* [flg] Clean memory prior to exit */
   nco_bool flg_rgr=False; /* [flg] Regrid */
+  nco_bool flg_trr=False; /* [flg] Terraref */
+
+  nco_dmn_dne_t *flg_dne=NULL; /* [lst] Flag to check if input dimension -d "does not exist" */
 
   size_t bfr_sz_hnt=NC_SIZEHINT_DEFAULT; /* [B] Buffer size hint */
   size_t cnk_min_byt=NCO_CNK_SZ_MIN_BYT_DFL; /* [B] Minimize size of variable to chunk */
@@ -267,8 +274,6 @@ main(int argc,char **argv)
 
   trv_tbl_sct *trv_tbl=NULL; /* [lst] Traversal table */
 
-  nco_dmn_dne_t *flg_dne=NULL; /* [lst] Flag to check if input dimension -d "does not exist" */
-
 #ifdef ENABLE_MPI
   /* Declare all MPI-specific variables here */
   MPI_Comm mpi_cmm=MPI_COMM_WORLD; /* [prc] Communicator */
@@ -383,6 +388,10 @@ main(int argc,char **argv)
     {"rnr",required_argument,0,0}, /* [flg] Renormalize destination values by valid area */
     {"renormalize",required_argument,0,0}, /* [flg] Renormalize destination values by valid area */
     {"scrip",required_argument,0,0}, /* SCRIP file */
+    {"trr",required_argument,0,0}, /* [sng] Terraref */
+    {"terraref",required_argument,0,0}, /* [sng] Terraref */
+    {"trr_in",required_argument,0,0}, /* [sng] File containing raw Terraref imagery */
+    {"trr_wxy",required_argument,0,0}, /* [sng] Terraref dimension sizes */
     {"tst_udunits",required_argument,0,0},
     {"xml_spr_chr",required_argument,0,0}, /* [flg] Separator for XML character types */
     {"xml_spr_nmr",required_argument,0,0}, /* [flg] Separator for XML numeric types */
@@ -637,6 +646,13 @@ main(int argc,char **argv)
 	maxrss+=0; /* CEWI */
         nco_exit(EXIT_SUCCESS);
       } /* endif "sysconf" */
+      if(!strcmp(opt_crr,"trr") || !strcmp(opt_crr,"terraref")){
+        flg_trr=True;
+        trr_arg=(char **)nco_realloc(trr_arg,(trr_nbr+1)*sizeof(char *));
+        trr_arg[trr_nbr++]=(char *)strdup(optarg);
+      } /* endif "trr" */
+      if(!strcmp(opt_crr,"trr_in")){trr_in=(char *)strdup(optarg);flg_trr=True;}
+      if(!strcmp(opt_crr,"trr_wxy")){trr_wxy=(char *)strdup(optarg);flg_trr=True;}
       if(!strcmp(opt_crr,"tst_udunits")){ 
 	/* Use this feature with, e.g.,
 	   ncks --tst_udunits='5 meters',centimeters ~/nco/data/in.nc
@@ -966,8 +982,8 @@ main(int argc,char **argv)
   } /* endif fl_bnr */
     
   if(flg_rgr && !fl_out){
-	(void)fprintf(stdout,"%s: ERROR Regridding requested but no output file specified\nHINT: Specify output file with \"-o fl_out\" or as last argument\n",nco_prg_nm_get());
-        nco_exit(EXIT_FAILURE);
+    (void)fprintf(stdout,"%s: ERROR Regridding requested but no output file specified\nHINT: Specify output file with \"-o fl_out\" or as last argument\n",nco_prg_nm_get());
+    nco_exit(EXIT_FAILURE);
   } /* !flg_rgr */
     
   if(gpe){
@@ -975,6 +991,20 @@ main(int argc,char **argv)
     if(fl_out && fl_out_fmt != NC_FORMAT_NETCDF4 && nco_dbg_lvl >= nco_dbg_std) (void)fprintf(stderr,"%s: WARNING Group Path Edit (GPE) requires netCDF4 output format in most cases (except flattening) but user explicitly requested output format = %s. This command will fail if the output file requires netCDF4 features like groups, non-atomic types, or multiple record dimensions. However, it _will_ autoconvert netCDF4 atomic types (e.g., NC_STRING, NC_UBYTE...) to netCDF3 atomic types (e.g [...]
   } /* !gpe */
 
+    /* Terraref */
+  if(flg_trr){
+    char *trr_out;
+    trr_sct *trr_nfo;
+    trr_out=(char *)strdup(fl_out);
+    trr_nfo=nco_trr_ini(cmd_ln,dfl_lvl,trr_arg,trr_nbr,trr_in,trr_out,trr_wxy);
+    (void)nco_trr_read(trr_nfo);
+    /* Free Terraref structure */
+    trr_nfo=nco_trr_free(trr_nfo);
+    if(trr_wxy) trr_wxy=(char *)nco_free(trr_wxy);
+    nco_exit_gracefully();
+    return EXIT_SUCCESS;
+  } /* !Terraref */
+  
   if(fl_out){
     /* Output file was specified so PRN_ tokens refer to (meta)data copying */
     int out_id;
@@ -989,7 +1019,9 @@ main(int argc,char **argv)
       rgr_in=(char *)strdup(fl_in);
       rgr_out=(char *)strdup(fl_out);
       rgr_nfo=nco_rgr_ini(cmd_ln,in_id,rgr_arg,rgr_nbr,rgr_in,rgr_out,rgr_grd_src,rgr_grd_dst,rgr_map,rgr_var,wgt_vld_thr,xtn_lst_in,xtn_nbr);
-      rgr_nfo->fl_out_tmp=nco_fl_out_open(rgr_nfo->fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+      rgr_nfo->fl_out_fmt=fl_out_fmt;
+      rgr_nfo->dfl_lvl=dfl_lvl;
+      rgr_nfo->fl_out_tmp=nco_fl_out_open(rgr_nfo->fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
       /* Copy Global Metadata */
       rgr_nfo->out_id=out_id;
@@ -1022,13 +1054,13 @@ main(int argc,char **argv)
       (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
       
       /* Open output file */
-      fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+      fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     
       /* Initialize chunking from user-specified inputs */
       if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) rcd+=nco_cnk_ini(in_id,fl_out,cnk_arg,cnk_nbr,cnk_map,cnk_plc,cnk_min_byt,cnk_sz_byt,cnk_sz_scl,&cnk);
 
       /* Define extracted groups, variables, and attributes in output file */
-      CPY_GRP_METADATA = FORCE_APPEND ? False : PRN_GLB_METADATA;
+      CPY_GRP_METADATA=PRN_GLB_METADATA;
       (void)nco_xtr_dfn(in_id,out_id,&cnk,dfl_lvl,gpe,md5,CPY_GRP_METADATA,PRN_VAR_METADATA,RETAIN_ALL_DIMS,nco_pck_plc_nil,rec_dmn_nm,trv_tbl);
 
       /* Catenate time-stamped command line to "history" global attribute */
@@ -1041,7 +1073,7 @@ main(int argc,char **argv)
 	if(prc_nbr > 0 && HISTORY_APPEND) (void)nco_mpi_att_cat(out_id,prc_nbr);
 #endif /* !ENABLE_MPI */
       
-      /* Turn off default filling behavior to enhance efficiency */
+      /* Turn-off default filling behavior to enhance efficiency */
       nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
       
       /* Take output file out of define mode */
@@ -1053,7 +1085,7 @@ main(int argc,char **argv)
       } /* hdr_pad */
 
       /* [fnc] Open unformatted binary data file for writing */
-      if(fl_bnr) fp_bnr=nco_bnr_open(fl_bnr);
+      if(fl_bnr) fp_bnr=nco_bnr_open(fl_bnr,"w");
       
       /* Timestamp end of metadata setup and disk layout */
       rcd+=nco_ddra((char *)NULL,(char *)NULL,&ddra_info);
diff --git a/src/nco/nco.h b/src/nco/nco.h
index b9ac419..088ad56 100644
--- a/src/nco/nco.h
+++ b/src/nco/nco.h
@@ -310,26 +310,26 @@ extern "C" {
 # define NC_LIB_VERSION ( NC_VERSION_MAJOR * 100 + NC_VERSION_MINOR * 10 + NC_VERSION_PATCH )
 #endif /* !NC_LIB_VERSION */
 
-  /* NCO meta-information available in VERSION token since forever
+  /* NCO meta-information available in NCO_VERSION token since forever
      20141008: Define NCO tokens consistent with new netcdf_meta.h tokens */
 #ifndef NCO_VERSION_MAJOR
 # define NCO_VERSION_MAJOR 4
 #endif /* !NCO_VERSION_MAJOR */
 #ifndef NCO_VERSION_MINOR
-# define NCO_VERSION_MINOR 5
+# define NCO_VERSION_MINOR 6
 #endif /* !NCO_VERSION_MINOR */
 #ifndef NCO_VERSION_PATCH
-# define NCO_VERSION_PATCH 5
+# define NCO_VERSION_PATCH 0
 #endif /* !NCO_VERSION_PATCH */
 #ifndef NCO_VERSION_NOTE
-# define NCO_VERSION_NOTE  "alpha07" /* Blank for final versions, non-blank (e.g., "beta37") for pre-release versions */
+# define NCO_VERSION_NOTE  "" /* Blank for final versions, non-blank (e.g., "beta37") for pre-release versions */
 #endif /* !NCO_VERSION_NOTE */
 #ifndef NCO_LIB_VERSION
   /* Define NC_LIB_VERSION as three-digit number for arithmetic comparisons by CPP */
 # define NCO_LIB_VERSION ( NCO_VERSION_MAJOR * 100 + NCO_VERSION_MINOR * 10 + NCO_VERSION_PATCH )
 #endif /* !NCO_LIB_VERSION */
 #ifndef NCO_VERSION
-# define NCO_VERSION "4.5.5"
+# define NCO_VERSION "4.6.0"
 #endif /* !NCO_VERSION */
 
 /* Compatibility tokens new to netCDF4 netcdf.h: */
@@ -691,11 +691,12 @@ extern "C" {
     nco_baa_set, /* 2 Bit Set (option since 20160117) */
   }; /* end nco_baa_cnv */
 
-  enum nco_upk_cnv{ /* [enm] Unpacking convention to assume */
+  enum nco_upk_cnv{ /* [enm] Unpacking convention to utilize */
     /* netCDF convention  : http://www.unidata.ucar.edu/software/netcdf/docs/netcdf/Attribute-Conventions.html
        HDF/NASA convention: http://modis-atmos.gsfc.nasa.gov/MOD08_D3/faq.html */
     nco_upk_netCDF, /* 0 netCDF unpack convention: unpacked=(scale_factor*packed)+add_offset */
-    nco_upk_HDF     /* 1 HDF unpack convention:    unpacked=scale_factor*(packed-add_offset) */
+    nco_upk_HDF_MOD10, /* 1 HDF MODIS MOD10 unpack convention: unpacked=scale_factor*(packed-add_offset) */
+    nco_upk_HDF_MOD13, /* 2 HDF MODIS MOD13 unpack convention: unpacked=(packed-add_offset)/scale_factor */
   }; /* end nco_upk_cnv */
 
   typedef enum aed{ /* [enm] Attribute editor mode */
@@ -703,6 +704,7 @@ extern "C" {
     aed_create,
     aed_delete,
     aed_modify,
+    aed_nappend,
     aed_overwrite
   } aed_enm; /* end aed enum */
   
@@ -955,6 +957,15 @@ extern "C" {
     nco_bool PRN_VAR_METADATA; /* [flg] Print variable metadata */
   } prn_fmt_sct;
   
+  /* Types used in Terraref structure */
+  typedef enum nco_trr_ntl_typ_enm{ /* [enm] Interleave-type enum */
+    nco_trr_ntl_nil=0,
+    nco_trr_ntl_unk, /* Unknown or unclassified interleave-type */ 
+    nco_trr_ntl_bsq, /* Band Sequential */
+    nco_trr_ntl_bip, /* Band-interleaved-by-pixel */
+    nco_trr_ntl_bil, /* Band-interleaved-by-line */
+  } nco_trr_ntl_typ_enm;
+
   /* Types used in regrid structure */
   typedef enum nco_grd_2D_typ_enm{ /* [enm] Two-dimensional grid-type enum */
     nco_grd_2D_nil=0,
@@ -982,6 +993,75 @@ extern "C" {
     nco_grd_lon_bb, /* Longitude grid determined by bounding box (lon_wst/lon_est) and gridcell number (lon_nbr) */
   } nco_grd_lon_typ_enm;
 
+  /* CF Coordinates structure (20160503: Used only in ncks.c for to infer grids from CF coordinates convention) */
+  typedef struct{ /* clm_bnd_sct */
+    char *crd_nm[2]; /* [sng] Coordinate names */
+    char *crd_sng; /* [sng] Coordinates attribute value */
+    char *dmn_nm[2]; /* [sng] Dimension names */
+    char *unt_sng[2]; /* [sng] Units strings */
+    char *var_nm; /* [sng] Coordinates variable name */
+    int crd_id[2]; /* [id] Coordinate IDs */
+    int dmn_id[2]; /* [id] Dimension IDs */
+    int var_id; /* [id] Coordinate variable ID */
+    nc_type var_type; /* [enm] Coordinates variable type */
+    nco_bool crd; /* [flg] CF coordinates information is complete */
+  } cf_crd_sct; /* end CF coordinates structure */
+
+  /* Climatology bounds structure (20160503: Used only in ncra.c for climos) */
+  typedef struct{ /* clm_bnd_sct */
+    char *bnd_dmn_nm; /* [sng] Bounds dimension name name */
+    char *clm_bnd_nm; /* [sng] Climatology bounds variable name (to create) */
+    char *tm_bnd_nm; /* [sng] Time bounds variable name (to delete) */
+    char *tm_crd_nm; /* [sng] Name of time coordinate variable */
+    char *cln_val; /* [sng] Bounds calendar value */
+    char *unt_val; /* [sng] Bounds units value */
+    double val[2]; /* [frc] Climatology bounds variable attribute values */
+    int clm_bnd_id_in; /* [id] Variable ID for clm_bnds in input */
+    int clm_bnd_id_out; /* [id] Variable ID for clm_bnds in output */
+    int tm_bnd_id_in; /* [id] Variable ID for tm_bnds in input */
+    int tm_bnd_id_out; /* [id] Variable ID for tm_bnds in output */
+    int tm_crd_id_in; /* [id] Variable ID for tm_crd in input */
+    int tm_crd_id_out; /* [id] Variable ID for tm_crd in output */
+    int dmn_ids[2]; /* [idx] Dimension IDs for new bounds variable */
+    long dmn_srt_srt[2]; /* [idx] Start indices for retrieving start bounds */
+    long dmn_srt_end[2]; /* [idx] Start indices for retrieving end bounds */
+    nc_type type; /* [enm] Type of (time and) climatology bounds variable(s) */
+    nco_bool bnd2clm; /* [flg] Convert time bounds to climatology bounds */
+    nco_bool clm2bnd; /* [flg] Convert climatology bounds to time bounds */
+    nco_bool clm2clm; /* [flg] Convert climatology bounds to climatology bounds */
+    nco_bool clm_bnd_in; /* [flg] Climatology bounds appear in input */
+    nco_bool tm_bnd_in; /* [flg] Time bounds appear in input */
+  } clm_bnd_sct; /* end climatology bounds structure */
+
+  /* Terraref structure */
+  typedef struct{ /* trr_sct */
+    // File names specifiable with individual command line switches
+    char *fl_in; /* [sng] File containing raw imagery */
+    char *fl_out; /* [sng] File containing netCDF imagery */
+    char *fl_out_tmp; /* [sng] Temporary file containing netCDF imagery */
+    // Metadata specifiable with key-value syntax
+    char **trr_arg; /* [sng] Terraref arguments */
+    char *wvl_nm; /* [sng] Name of wavelength dimension */
+    char *xdm_nm; /* [sng] Name of x-coordinate dimension */
+    char *ydm_nm; /* [sng] Name of y-coordinate dimension */
+    char *var_nm; /* [sng] Variable containing imagery */
+    char *wvl_bnd_nm; /* [sng] Name of dimension to employ for wavelength bounds */
+    char *xdm_bnd_nm; /* [sng] Name of dimension to employ for x-coordinate bounds */
+    char *ydm_bnd_nm; /* [sng] Name of dimension to employ for y-coordinate bounds */
+    long wvl_nbr; /* [nbr] Number of wavelengths */
+    long xdm_nbr; /* [nbr] Number of pixels in x-dimension */
+    long ydm_nbr; /* [nbr] Number of pixels in y-dimension */
+    nc_type var_typ_in; /* [enm] NetCDF type */
+    nc_type var_typ_out; /* [enm] NetCDF type */
+    // Other internal data and metadata 
+    char *cmd_ln; /* [sng] Command-line */
+    char *ttl; /* [sng] Title */
+    int dfl_lvl; /* [enm] Deflate level [0..9] */
+    int trr_nbr; /* [nbr] Number of Terraref arguments */
+    nco_trr_ntl_typ_enm ntl_typ_in; /* [enm] Interleave-type of raw data */
+    nco_trr_ntl_typ_enm ntl_typ_out; /* [enm] Interleave-type or output */
+  } trr_sct; /* end Terraref structure */
+
   /* Regrid structure */
   typedef struct{ /* rgr_sct */
     // File names specifiable with individual command line switches
@@ -1002,11 +1082,13 @@ extern "C" {
     char *col_nm_out; /* [sng] Name of horizontal spatial output dimension on unstructured grid */
     char *frc_nm; /* [sng] Name of variable containing gridcell fraction */
     char *lat_bnd_nm; /* [sng] Name of rectangular boundary variable for latitude */
+    char *lat_dmn_nm; /* [sng] Name of latitude dimension in inferred grid */
     char *lat_nm_in; /* [sng] Name of input dimension to recognize as latitude */
     char *lat_nm_out; /* [sng] Name of output dimension for latitude */
     char *lat_vrt_nm; /* [sng] Name of non-rectangular boundary variable for latitude */
     char *lat_wgt_nm; /* [sng] Name of variable containing latitude weights */
     char *lon_bnd_nm; /* [sng] Name of rectangular boundary variable for longitude */
+    char *lon_dmn_nm; /* [sng] Name of longitude dimension in inferred grid */
     char *lon_nm_in; /* [sng] Name of dimension to recognize as longitude */
     char *lon_nm_out; /* [sng] Name of output dimension for longitude */
     char *lon_vrt_nm; /* [sng] Name of non-rectangular boundary variable for longitude */
@@ -1030,6 +1112,8 @@ extern "C" {
     char **xtn_var; /* [sng] Extensive variables */
     char *cmd_ln; /* [sng] Command-line */
     double wgt_vld_thr; /* [frc] Weight threshold for valid destination value */
+    int dfl_lvl; /* [enm] Deflate level */
+    int fl_out_fmt; /* [enm] Output file format */
     int in_id; /* [id] Input netCDF file ID */
     int out_id; /* [id] Output netCDF file ID */
     int rgr_nbr; /* [nbr] Number of regridding arguments */
@@ -1044,7 +1128,7 @@ extern "C" {
     nco_bool flg_nfr; /* [flg] Infer SCRIP-format grid file */
     nco_bool flg_map; /* [flg] User-specified mapping weights */
     nco_bool flg_rnr; /* [flg] Renormalize destination values by valid area */
-  } rgr_sct;
+  } rgr_sct; /* end Regrid structure */
 
   /* Key-value structure */
   typedef struct{
@@ -1101,7 +1185,7 @@ extern "C" {
     int lmt_crr;          /* [nbr] Index of current limit structure being initialized (helper to initialze lmt_sct*) */
   } lmt_msa_sct;
 
-   /* GTT coordinate variable structure; it contains netCDF model fields and an MSA field */
+  /* GTT coordinate variable structure; it contains netCDF model fields and an MSA field */
   typedef struct{ 
     char *crd_nm_fll;       /* [sng] Full coordinate name */
     char *dmn_nm_fll;       /* [sng] Full name of dimension for *this* coordinate  */  
@@ -1160,7 +1244,6 @@ extern "C" {
     /* Following are members only used by transformation operators (non-ncks) */
     nco_bool flg_dmn_avg;    /* [flg] Diferentiate between dimensions to average or keep for this variable (ncwa) */  
     nco_bool flg_rdd;        /* [flg] Retain dimension as degenerate (size 1) (ncwa) */  
-    nco_bool flg_rvr;        /* [flg] Reverse dimension (option -a - of ncpdq) FXM_PVN */
   } var_dmn_sct; 
 
   /* Processing type enumerator */
@@ -1365,7 +1448,7 @@ extern "C" {
     int nc_id; /* [id] File ID */
     int pck_dsk; /* [flg] Variable is packed on disk (valid scale_factor, add_offset, or both attributes exist) */
     int pck_ram; /* [flg] Variable is packed in memory (valid scale_factor, add_offset, or both attributes exist) */
-    int shuffle; /* [flg] Turn on shuffle filter */
+    int shuffle; /* [flg] Turn-on shuffle filter */
     int undefined; /* [flg] Variable is still undefined (in first parser pass) */
     long *cnt; /* [nbr] Contiguous vector of lengths of hyperslab */
     long *end; /* [idx] Contiguous vector of indices to end of hyperslab */
@@ -1389,14 +1472,14 @@ extern "C" {
     struct var_sct_tag *xrf; /* [sct] Cross-reference to associated variable structure (usually structure for variable on output) fxm: deprecate! TODO nco226 */
   } var_sct; /* end var_sct_tag */
 
-   /* Dimension utility structure to share common fields; used in nco_cnk_sz_set_trv() */
+  /* Utility structure to share dimension common fields; used in nco_cnk_sz_set_trv() */
   typedef struct{
     char *nm_fll; /* [sng] Full dimension name */
     char nm[NC_MAX_NAME+1L];/* [sng] Name of dimension/coordinate */
     int id; /* [id] Dimension ID */
     nco_bool NON_HYP_DMN; /* [flg] Limit is same as dimension in input file */
     nco_bool is_rec_dmn; /* [flg] Dimension is unlimited/record dimension */
-    size_t dmn_cnt; /* [nbr] Hyperslabbed size of dimension (= sz iff !NON_HYP_DMN) */
+    size_t dmn_cnt; /* [nbr] Hyperslabbed size of dimension (= sz iff NON_HYP_DMN) */
     size_t sz; /* [nbr] Size (non-hyperslabbed) of dimension */
   } dmn_cmn_sct;
 
diff --git a/src/nco/nco_att_utl.c b/src/nco/nco_att_utl.c
index e2a1951..f019bd8 100644
--- a/src/nco/nco_att_utl.c
+++ b/src/nco/nco_att_utl.c
@@ -148,7 +148,7 @@ nco_aed_prc_wrp /* [fnc] Expand regular expressions then pass attribute edits to
   return flg_chg; /* [flg] Attribute was altered */
 } /* end nco_aed_prc() */
 
- nco_bool /* [flg] Attribute was changed */
+nco_bool /* [flg] Attribute was changed */
 nco_aed_prc /* [fnc] Process single attribute edit for single variable */
 (const int nc_id, /* I [id] Input netCDF file ID */
  const int var_id, /* I [id] ID of variable on which to perform attribute editing */
@@ -384,6 +384,7 @@ nco_aed_prc /* [fnc] Process single attribute edit for single variable */
 
   switch(aed.mode){
   case aed_append:	
+  case aed_nappend:	
     if(rcd_inq_att == NC_NOERR){
       /* Append to existing attribute value */
       if(aed.type != att_typ){
@@ -405,7 +406,7 @@ nco_aed_prc /* [fnc] Process single attribute edit for single variable */
       rcd+=nco_put_att(nc_id,var_id,aed.att_nm,aed.type,att_sz+aed.sz,att_val_new);
       flg_chg=True; /* [flg] Attribute was altered */
       att_val_new=nco_free(att_val_new);
-    }else{
+    }else if(aed.mode == aed_append){
       /* Create new attribute */
       rcd+=nco_put_att(nc_id,var_id,aed.att_nm,aed.type,aed.sz,aed.val.vp);
       flg_chg=True; /* [flg] Attribute was altered */
@@ -513,6 +514,7 @@ nco_bool /* [flg] Attribute was changed */
 nco_aed_prc_var_all /* [fnc] Process attributes in all variables */
 (const int nc_id, /* I [id] netCDF file ID */
  const aed_sct aed, /* I [sct] Attribute-edit information */
+ const nco_bool flg_typ_mch, /* I [flg] Type-match attribute edits */
  const trv_tbl_sct * const trv_tbl) /* I [lst] Traversal table */ 
 {
   /* Purpose: Process attributes in all variables */
@@ -524,10 +526,12 @@ nco_aed_prc_var_all /* [fnc] Process attributes in all variables */
 
   for(unsigned tbl_idx=0;tbl_idx<trv_tbl->nbr;tbl_idx++){
     if(trv_tbl->lst[tbl_idx].nco_typ == nco_obj_typ_var){
-      (void)nco_inq_grp_full_ncid(nc_id,trv_tbl->lst[tbl_idx].grp_nm_fll,&grp_id);
-      (void)nco_inq_varid(grp_id,trv_tbl->lst[tbl_idx].nm,&var_id);
-      flg_chg|=nco_aed_prc_wrp(grp_id,var_id,aed);
-      var_fnd=True;
+      if((flg_typ_mch && trv_tbl->lst[tbl_idx].var_typ == aed.type) || !flg_typ_mch){
+	(void)nco_inq_grp_full_ncid(nc_id,trv_tbl->lst[tbl_idx].grp_nm_fll,&grp_id);
+	(void)nco_inq_varid(grp_id,trv_tbl->lst[tbl_idx].nm,&var_id);
+	flg_chg|=nco_aed_prc_wrp(grp_id,var_id,aed);
+	var_fnd=True;
+      } /* !typ */
     } /* !var */
   } /* !tbl */ 
 
@@ -1214,12 +1218,14 @@ nco_prs_aed_lst /* [fnc] Parse user-specified attribute edits into structure lis
 	  }else if(!strcmp("create",arg_lst[2])){aed_lst[idx].mode=aed_create;
 	  }else if(!strcmp("delete",arg_lst[2])){aed_lst[idx].mode=aed_delete;
 	  }else if(!strcmp("modify",arg_lst[2])){aed_lst[idx].mode=aed_modify;
+	  }else if(!strcmp("nappend",arg_lst[2])){aed_lst[idx].mode=aed_nappend;
 	  }else if(!strcmp("overwrite",arg_lst[2])){aed_lst[idx].mode=aed_overwrite;} */
     switch(*(arg_lst[2])){
     case 'a': aed_lst[idx].mode=aed_append; break;
     case 'c': aed_lst[idx].mode=aed_create; break;
     case 'd': aed_lst[idx].mode=aed_delete; break;
     case 'm': aed_lst[idx].mode=aed_modify; break;
+    case 'n': aed_lst[idx].mode=aed_nappend; break;
     case 'o': aed_lst[idx].mode=aed_overwrite; break;
     default: 
       (void)fprintf(stderr,"%s: ERROR `%s' is not a supported mode\n",nco_prg_nm_get(),arg_lst[2]);
@@ -1237,42 +1243,12 @@ nco_prs_aed_lst /* [fnc] Parse user-specified attribute edits into structure lis
       nco_exit(EXIT_FAILURE);
     } /* !ATT_TYP_INHERIT */
 
-    /* Attribute type and value do not matter if we are deleting it */
+    /* Attribute type and value do not matter when we will delete attribute */
     if(aed_lst[idx].mode != aed_delete && !ATT_TYP_INHERIT){
 
       /* Set type of current aed structure */
-      /* Convert single letter code to type enum */
-      switch(*(arg_lst[3])){
-      case 'F':	
-      case 'f':	aed_lst[idx].type=(nc_type)NC_FLOAT; break;
-      case 'D':	
-      case 'd':	aed_lst[idx].type=(nc_type)NC_DOUBLE; break;
-      case 'C':	
-      case 'c':	aed_lst[idx].type=(nc_type)NC_CHAR; break;
-      case 'B':	
-      case 'b':	aed_lst[idx].type=(nc_type)NC_BYTE; break;
-      default: 
-        /* Ambiguous single letters must use full string comparisons */
-        if(!strcasecmp(arg_lst[3],"l") || !strcasecmp(arg_lst[3],"i")) aed_lst[idx].type=(nc_type)NC_INT; 
-        else if(!strcasecmp(arg_lst[3],"s")) aed_lst[idx].type=(nc_type)NC_SHORT; 
-#ifdef ENABLE_NETCDF4
-        else if(!strcasecmp(arg_lst[3],"ub")) aed_lst[idx].type=(nc_type)NC_UBYTE; 
-        else if(!strcasecmp(arg_lst[3],"us")) aed_lst[idx].type=(nc_type)NC_USHORT; 
-        else if(!strcasecmp(arg_lst[3],"u") || !strcasecmp(arg_lst[3],"ui") || !strcasecmp(arg_lst[3],"ul")) aed_lst[idx].type=(nc_type)NC_UINT; 
-        else if(!strcasecmp(arg_lst[3],"ll") || !strcasecmp(arg_lst[3],"int64")) aed_lst[idx].type=(nc_type)NC_INT64; 
-        else if(!strcasecmp(arg_lst[3],"ull") || !strcasecmp(arg_lst[3],"uint64")) aed_lst[idx].type=(nc_type)NC_UINT64; 
-        else if(!strcasecmp(arg_lst[3],"sng") || !strcasecmp(arg_lst[3],"string")) aed_lst[idx].type=(nc_type)NC_STRING; 
-        else{
-          (void)fprintf(stderr,"%s: ERROR `%s' is not a supported netCDF data type\n",nco_prg_nm_get(),arg_lst[3]);
-          (void)fprintf(stderr,"%s: HINT: Valid data types are `c' = char, `f' = float, `d' = double,`s' = short, `i' = `l' = integer, `b' = byte",nco_prg_nm_get());
-
-          (void)fprintf(stderr,", `ub' = unsigned byte, `us' = unsigned short, `u' or `ui' or `ul' = unsigned int,`ll' or `int64' = 64-bit signed integer, `ull' or `uint64` = unsigned 64-bit integer, `sng' or `string' = string");
-
-          (void)fprintf(stderr,"\n");
-          nco_exit(EXIT_FAILURE);} /*  end if error */
-#endif /* ENABLE_NETCDF4 */
-        break;
-      } /* end switch */
+      aed_lst[idx].type=nco_sng2typ(arg_lst[3]);
+
     } /* end if not delete mode and !ATT_TYP_INHERIT */
 
     if(aed_lst[idx].mode != aed_delete){
@@ -1913,7 +1889,7 @@ nco_vrs_att_cat /* [fnc] Add NCO version global attribute */
   /* Purpose: Write NCO version information to global metadata */
   aed_sct vrs_sng_aed;
   char att_nm[]="NCO"; /* [sng] Name of attribute in which to store NCO version */
-  char vrs_git[]=TKN2SNG(VERSION); /* [sng] Version according to Git */
+  char vrs_git[]=TKN2SNG(NCO_VERSION); /* [sng] Version according to Git */
   char *vrs_cvs; /* [sng] Version according to RCS/CVS-like release tag */
   char *vrs_sng; /* [sng] NCO version */
   ptr_unn att_val;
@@ -1968,12 +1944,13 @@ nco_glb_att_add /* [fnc] Add global attributes */
     /* nco_sng2kvm() converts argument "--gaa one,two=3" into kvm.key="one,two" and kvm.val=3
        Then nco_lst_prs_2D() converts kvm.key into two items, "one" and "two", with the same value, 3 */
     if(kvm.key){
-      int att_idx; /* [idx] Index over attribute names in current GAA argument */
+      int att_idx; /* [idx] Index over qattribute names in current GAA argument */
       int att_nbr; /* [nbr] Number of attribute names in current GAA argument */
       char **att_lst;
       att_lst=nco_lst_prs_2D(kvm.key,",",&att_nbr);
       for(att_idx=0;att_idx<att_nbr;att_idx++){ /* Expand multi-attribute-name specification */
         gaa_lst[gaa_nbr].key=strdup(att_lst[att_idx]);
+	/* 20160324: fxm: can next line break when kvm.val is NULL? */
 	gaa_lst[gaa_nbr].val=strdup(kvm.val);
         gaa_nbr++;
       } /* end for */
@@ -1992,6 +1969,11 @@ nco_glb_att_add /* [fnc] Add global attributes */
     /* Insert value into attribute structure */
     gaa_aed.val=att_val;
     gaa_aed.sz=strlen(gaa_aed.val.cp);
+    /* 20160324: which is better mode for gaa---overwrite or append? 
+       20160330: answer is overwrite. otherwise, climo_nco.sh produces ANN file with, e.g.,
+       :climo_script = "climo_nco.shclimo_nco.shclimo_nco.sh" ;
+       :climo_hostname = "aerosolaerosolaerosol" ;
+       :climo_version = "4.5.6-alpha054.5.6-alpha054.5.6-alpha05" ; */
     gaa_aed.mode=aed_overwrite;
     /* Write attribute to disk */
     (void)nco_aed_prc(out_id,NC_GLOBAL,gaa_aed);
diff --git a/src/nco/nco_att_utl.h b/src/nco/nco_att_utl.h
index 6236aa4..9cdb71e 100644
--- a/src/nco/nco_att_utl.h
+++ b/src/nco/nco_att_utl.h
@@ -53,7 +53,7 @@ nco_aed_prc_wrp /* [fnc] Expand regular expressions then pass attribute edits to
  const int var_id, /* I [id] ID of variable on which to perform attribute editing */
  const aed_sct aed); /* I [sct] Attribute-edit information */
 
-  nco_bool /* [flg] Attribute was altered */
+nco_bool /* [flg] Attribute was altered */
 nco_aed_prc /* [fnc] Process single attribute edit for single variable */
 (const int nc_id, /* I [id] Input netCDF file ID */
  const int var_id, /* I [id] ID of variable on which to perform attribute editing */
@@ -75,6 +75,7 @@ nco_bool /* [flg] Attribute was changed */
 nco_aed_prc_var_all /* [fnc] Process attributes in all variables */
 (const int nc_id, /* I [id] netCDF file ID */
  const aed_sct aed, /* I [sct] Attribute-edit information */
+ const nco_bool flg_typ_mch, /* I [flg] Type-match attribute edits */
  const trv_tbl_sct * const trv_tbl); /* I [lst] Traversal table */ 
 
 nco_bool /* [flg] Attribute was changed */
diff --git a/src/nco/nco_aux.c b/src/nco/nco_aux.c
index 7cb0d81..74a31eb 100644
--- a/src/nco/nco_aux.c
+++ b/src/nco/nco_aux.c
@@ -286,7 +286,7 @@ nco_aux_evl
         lmt_tpl.max_idx=lmt_tpl.end=cll_idx_min+cll_nbr_cns-1;
         lmt_tpl.cnt=cll_nbr_cns;
         (*lmt_nbr)++;
-        if(*lmt_nbr > MAX_LMT_NBR) nco_err_exit(0,"%s: Number of slabs exceeds allocated mamory");
+        if(*lmt_nbr > MAX_LMT_NBR) nco_err_exit(0,"%s: Number of slabs exceeds allocated memory");
         lmt[(*lmt_nbr)-1]=(lmt_sct *)nco_malloc(sizeof(lmt_sct));
         *lmt[(*lmt_nbr)-1]=lmt_tpl;
         cll_grp_nbr++;
@@ -509,7 +509,7 @@ nco_aux_evl_trv
         lmt_tpl.max_idx=lmt_tpl.end=cll_idx_min+cll_nbr_cns-1;
         lmt_tpl.cnt=cll_nbr_cns;
         (*aux_lmt_nbr)++;
-        if(*aux_lmt_nbr > MAX_LMT_NBR) nco_err_exit(0,"%s: Number of slabs exceeds allocated mamory");
+        if(*aux_lmt_nbr > MAX_LMT_NBR) nco_err_exit(0,"%s: Number of slabs exceeds allocated memory");
         lmt[(*aux_lmt_nbr)-1]=(lmt_sct *)nco_malloc(sizeof(lmt_sct));
         *lmt[(*aux_lmt_nbr)-1]=lmt_tpl;
         cll_grp_nbr++;
diff --git a/src/nco/nco_bnr.c b/src/nco/nco_bnr.c
index 75e34d8..5b6da18 100644
--- a/src/nco/nco_bnr.c
+++ b/src/nco/nco_bnr.c
@@ -1,22 +1,23 @@
 /* $Header$ */
 
-/* Purpose: Binary write utilities */
+/* Purpose: Binary file utilities */
 
 /* Copyright (C) 1995--2016 Charlie Zender
    This file is part of NCO, the netCDF Operators. NCO is free software.
    You may redistribute and/or modify NCO under the terms of the 
    GNU General Public License (GPL) Version 3 with exceptions described in the LICENSE file */
 
-#include "nco_bnr.h" /* Binary write utilities */
+#include "nco_bnr.h" /* Binary file utilities */
 
-FILE * /* O [fl] Unformatted binary output file handle */
-nco_bnr_open /* [fnc] Open unformatted binary data file for writing */
-(const char * const fl_bnr) /* [sng] Unformatted binary output file */
+FILE * /* O [fl] Unformatted binary file handle */
+nco_bnr_open /* [fnc] Open unformatted binary data file */
+(const char * const fl_bnr, /* [sng] Unformatted binary file */
+ const char * const fl_mode) /* [sng] Open-mode ("r", "w", ...) */
 {
   /* Purpose: Open unformatted binary data file for writing */
   FILE *fp_bnr; /* [fl] Unformatted binary output file handle */
   /* Open output file */
-  if((fp_bnr=fopen(fl_bnr,"w")) == NULL){
+  if((fp_bnr=fopen(fl_bnr,fl_mode)) == NULL){
     (void)fprintf(stderr,"%s: ERROR unable to open binary output file %s\n",nco_prg_nm_get(),fl_bnr);
     nco_exit(EXIT_FAILURE);
   } /* end if */
@@ -53,7 +54,7 @@ nco_bnr_wrt /* [fnc] Write unformatted binary data */
 {
   /* Purpose: Write unformatted binary data */
   /* Testing:
-     ncks -O -D 3 -B -b foo.bnr ~/nco/data/in.nc ~/nco/data/foo.nc */
+     ncks -O -D 3 -B -b foo.bnr ~/nco/data/in.nc ~/foo.nc */
 
   long wrt_nbr; /* [nbr] Number of elements successfully written */
   /* Write unformatted data to binary output file */
@@ -66,3 +67,27 @@ nco_bnr_wrt /* [fnc] Write unformatted binary data */
   if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fflush(stderr);
   return wrt_nbr; /* O [nbr] Number of elements successfully written */
 } /* end nco_bnr_wrt() */
+
+size_t /* O [nbr] Number of elements successfully read */
+nco_bnr_rd /* [fnc] Read unformatted binary data */
+(FILE * const fp_bnr, /* I [fl] Unformatted binary input file handle */
+ const char * const var_nm, /* I [sng] Variable name */
+ const long var_sz, /* I [nbr] Variable size */
+ const nc_type var_typ, /* I [enm] Variable type */
+ void * const void_ptr) /* O [ptr] Data to read */
+{
+  /* Purpose: Read unformatted binary data */
+  /* Testing:
+     ncks -O -D 73 ~/nco/data/in.nc ~/foo.nc */
+
+  long rd_nbr; /* [nbr] Number of elements successfully written */
+  /* Read unformatted data from binary input file */
+  rd_nbr=fread(void_ptr,(size_t)nco_typ_lng(var_typ),(size_t)var_sz,fp_bnr);
+  if(rd_nbr != var_sz){
+    (void)fprintf(stderr,"%s: ERROR only succeeded in reading %ld of %ld elements into variable %s\n",nco_prg_nm_get(),rd_nbr,var_sz,var_nm);
+    nco_exit(EXIT_FAILURE);
+  } /* end if */
+  if(nco_dbg_lvl_get() >= nco_dbg_scl) (void)fprintf(stdout,"Binary read of %s (%s, %ld x %lu b)",var_nm,c_typ_nm(var_typ),var_sz,(unsigned long)nco_typ_lng(var_typ));
+  if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fflush(stderr);
+  return rd_nbr; /* O [nbr] Number of elements successfully written */
+} /* end nco_bnr_rd() */
diff --git a/src/nco/nco_bnr.h b/src/nco/nco_bnr.h
index fcfb072..037db03 100644
--- a/src/nco/nco_bnr.h
+++ b/src/nco/nco_bnr.h
@@ -1,6 +1,6 @@
 /* $Header$ */
 
-/* Purpose: Binary write utilities */
+/* Purpose: Binary file utilities */
 
 /* Copyright (C) 1995--2016 Charlie Zender
    This file is part of NCO, the netCDF Operators. NCO is free software.
@@ -8,7 +8,7 @@
    GNU General Public License (GPL) Version 3 with exceptions described in the LICENSE file */
 
 /* Usage:
-   #include "nco_bnr.h" *//* Binary write utilities */
+   #include "nco_bnr.h" *//* Binary file utilities */
 
 #ifndef NCO_BNR_H
 #define NCO_BNR_H
@@ -28,9 +28,10 @@
 extern "C" {
 #endif /* __cplusplus */
 
-FILE * /* O [fl] Unformatted binary output file handle */
-nco_bnr_open /* [fnc] Open unformatted binary data file for writing */
-(const char * const fl_bnr); /* [sng] Unformatted binary output file */
+FILE * /* O [fl] Unformatted binary file handle */
+nco_bnr_open /* [fnc] Open unformatted binary data file */
+(const char * const fl_bnr, /* [sng] Unformatted binary file */
+ const char * const fl_mode); /* [sng] Open-mode ("r", "w", ...) */
 
 int /* [rcd] Return code */
 nco_bnr_close /* [fnc] Close unformatted binary data file for writing */
@@ -45,6 +46,14 @@ nco_bnr_wrt /* [fnc] Write unformatted binary data */
  const nc_type var_typ, /* I [enm] Variable type */
  const void * const void_ptr); /* I [ptr] Data to write */
 
+size_t /* O [nbr] Number of elements successfully read */
+nco_bnr_rd /* [fnc] Read unformatted binary data */
+(FILE * const fp_bnr, /* I [fl] Unformatted binary input file handle */
+ const char * const var_nm, /* I [sng] Variable name */
+ const long var_sz, /* I [nbr] Variable size */
+ const nc_type var_typ, /* I [enm] Variable type */
+ void * const void_ptr); /* O [ptr] Data to read */
+
 #ifdef __cplusplus
 } /* end extern "C" */
 #endif /* __cplusplus */
diff --git a/src/nco/nco_cnf_dmn.c b/src/nco/nco_cnf_dmn.c
index 9c11e3f..f1b2494 100644
--- a/src/nco/nco_cnf_dmn.c
+++ b/src/nco/nco_cnf_dmn.c
@@ -505,16 +505,14 @@ nco_var_dmn_rdr_mtd /* [fnc] Change dimension ordering of variable metadata */
   
   /* On entry to this section of code, we assume:
      1. var_out duplicates var_in */
-  
+ 
   /* Create complete 1-to-1 ordered list of dimensions in new output variable */
   /* For each dimension in re-ordered dimension list... */
   for(dmn_rdr_idx=0;dmn_rdr_idx<dmn_rdr_nbr;dmn_rdr_idx++){
     /* ...see if re-order dimension exists in dmn_in dimension list... */
     for(dmn_in_idx=0;dmn_in_idx<dmn_in_nbr;dmn_in_idx++){
-      
-      /* ...must compare by dimension IDs ...dimensions can have same names  */
-      if(var_in->dim[dmn_in_idx]->id == dmn_rdr[dmn_rdr_idx]->id){
-	
+      /* ...by comparing names, not dimension IDs... */
+      if(!strcmp(var_in->dim[dmn_in_idx]->nm,dmn_rdr[dmn_rdr_idx]->nm)){
         dmn_idx_in_rdr[dmn_in_idx]=dmn_rdr_idx;
         dmn_idx_shr_rdr[dmn_shr_nbr]=dmn_rdr_idx;
         dmn_idx_shr_in[dmn_shr_nbr]=dmn_in_idx;
diff --git a/src/nco/nco_cnv_csm.c b/src/nco/nco_cnv_csm.c
index 408026b..04c7c38 100644
--- a/src/nco/nco_cnv_csm.c
+++ b/src/nco/nco_cnv_csm.c
@@ -234,6 +234,7 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
  const int dmn_nbr_rdc,              /* I [sct] Number of dimensions to reduce variable over */
  const int nco_op_typ,               /* I [enm] Operation type, default is average */
  gpe_sct *gpe,                       /* I [sng] Group Path Editing (GPE) structure */
+ const clm_bnd_sct * const cb,       /* I [sct] Climatology bounds structure */
  const trv_tbl_sct * const trv_tbl)  /* I [sct] Traversal table */
 {
   /* Purpose: Add/modify CF cell_methods attribute
@@ -277,6 +278,7 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
   char *att_val_cpy; /* [sng] Copy of attribute */
   char *grp_out_fll=NULL; /* [sng] Group name */
   char *sbs_ptr; /* [sng] Pointer to substring */
+  char *cll_mth_clm; /* [sng] Cell methods for climatology */
   
   int *dmn_mch; /* [idx] Indices of dimensions reduced in this variable */
 
@@ -309,6 +311,11 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
   /* Allocate space for maximum number of matching dimensions */
   dmn_mch=(int *)nco_calloc(dmn_nbr_rdc,sizeof(int));
 
+  if(cb){
+    if(cb->bnd2clm || cb->clm2clm) cll_mth_clm=strdup("time: mean within years time: mean over years");
+    if(cb->clm2bnd) cll_mth_clm=strdup("time: mean");
+  } /* !cb */
+
   /* Process all variables */
   for(var_idx=0;var_idx<var_nbr;var_idx++){ 
 
@@ -334,6 +341,23 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
     dmn_nbr_mch=0;
     flg_dpl=False;
 
+    if(cb){
+      /* Does variable use time coordinate? */
+      for(dmn_idx_var=0;dmn_idx_var<var_trv->nbr_dmn;dmn_idx_var++)
+	if(!strcmp(var_trv->var_dmn[dmn_idx_var].dmn_nm,cb->tm_crd_nm)) break;
+      if(dmn_idx_var < var_trv->nbr_dmn){
+	/* Stamp with appropriate cell_methods temporal attribute */
+	att_val=strdup(cll_mth_clm);
+	aed.sz=strlen(att_val);
+	aed.type=NC_CHAR;
+	aed.val.cp=att_val;
+	aed.mode=aed_overwrite;
+	(void)nco_aed_prc(grp_out_id,var_out_id,aed);
+	if(att_val) att_val=(char *)nco_free(att_val);
+	continue;
+      } /* !dmn_idx_var */
+    } /* !cb */
+
     /* cell_methods format: blank-separated phrases of form "dmn1[, dmn2[...]]: op_typ", e.g., "lat, lon: mean" */ 
     for(dmn_idx_var=0;dmn_idx_var<var_trv->nbr_dmn;dmn_idx_var++){
       for(dmn_idx_rdc=0;dmn_idx_rdc<dmn_nbr_rdc;dmn_idx_rdc++){
@@ -407,9 +431,15 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
       if(att_typ == NC_STRING) (void)fprintf(stderr,"%s: WARNING %s reports existing cell_methods attribute for variable %s is type NC_STRING. Unpredictable results...\n",nco_prg_nm_get(),fnc_nm,aed.var_nm);
       if(att_typ != NC_STRING && att_typ != NC_CHAR) (void)fprintf(stderr,"%s: WARNING %s reports existing cell_methods attribute for variable %s is type %s. Unpredictable results...\n",nco_prg_nm_get(),fnc_nm,aed.var_nm,nco_typ_sng(att_typ));
 
-      /* 20150625: Often climatologies are multiply-averaged over time
+      /* Often climatologies are multiply-averaged over time
+	 NCO's treatment of this has changed with time
+	 pre-20140131: 
+	 NCO has no special treatment of cell_methods
+	 20140131: 
+	 First NCO implementation (ncra, ncea, ncwa) of cell_methods with 
+	 20150625: 
 	 For example, climate model output is often archived as monthly means in each gridcell
-	 The cell_methods attribute of these monthly data begin as "time: mean" (i.e., monthly mean).
+	 cell_methods attributes of these monthly data begin as "time: mean" (i.e., monthly mean).
 	 We then create a climatology by a sequence of one or two more temporal-averaging steps
 	 The one-step method puts all the months in the hopper and averages those
 	 Variables in the resultiing file may have cell_methods = "time: mean time: mean"
@@ -417,7 +447,17 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
 	 Then it averages those four seasons into the climatological annual mean
 	 Variables in the resultiing file may have cell_methods = "time: mean time: mean time: mean"
 	 To avoid this redundancy, we check that the new cell_method does not duplicate the old 
-	 If it would, then skip adding the new */
+	 If it would, then skip adding the new
+	 20160418: 
+	 Treatment of multiply-time-averaged quantities requires climatology bounds attribute
+	 One-step methods (e.g., monthly mean) should have time-bounds attribute
+	 cell_methods = "time: mean"
+	 Two-step methods (e.g., climatological March) should have climatology-bounds attribute
+	 cell_methods = "time: mean within years time: mean over years"
+	 Three-step methods (e.g., climatological MAM) should have climatology-bounds attribute
+	 cell_methods = "time: mean within years time: mean over years"
+	 Four-step methods (e.g., climatological ANN) should have time-bounds attribute
+	 cell_methods = "time: mean" */
       ptr_unn val_old; /* [sng] Old cell_methods attribute */
       val_old.vp=(void *)nco_malloc((att_lng+1L)*sizeof(char));
       (void)nco_get_att(grp_out_id,var_out_id,aed.att_nm,val_old.vp,NC_CHAR);
@@ -436,9 +476,9 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
       aed.val.cp[1]='\0';
       (void)strncat(aed.val.cp,att_val_cpy,aed.sz-1L);
       if(att_val_cpy) att_val_cpy=(char *)nco_free(att_val_cpy);
-    }else{
+    }else{ /* !cell_methods attribute already exists */
       aed.mode=aed_create;
-    } /* endif attribute exists */
+    } /* !cell_methods attribute already exists */
 
     /* Edit attribute */
     if(!flg_dpl) (void)nco_aed_prc(grp_out_id,var_out_id,aed);
@@ -481,7 +521,7 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
 		dmn_sng_lng=strlen(dmn_rdc[dmn_idx_rdc]->nm);
 		sbs_sng_lng=(size_t)(sbs_ptr-att_val);
 		aed.mode=aed_overwrite;
-		/* If dimension to excise is trailed by a space, also remove the space, i.e., count it as part of dimension string
+		/* Remove whitespace immediately following excised dimension, i.e., count it as part of dimension string
 		   True for all dimensions except final dimension (trailed by a NUL, not a space) */
 		if(sbs_ptr[dmn_sng_lng] == ' ') dmn_sng_lng++;
 		aed.sz=att_lng-dmn_sng_lng;
diff --git a/src/nco/nco_cnv_csm.h b/src/nco/nco_cnv_csm.h
index 8d6636f..81118b1 100644
--- a/src/nco/nco_cnv_csm.h
+++ b/src/nco/nco_cnv_csm.h
@@ -56,7 +56,8 @@ nco_cnv_cf_cll_mth_add               /* [fnc] Add cell_methods attributes */
  dmn_sct * const * const dmn,        /* I [sct] Dimensions over which to reduce variable */
  const int dmn_nbr,                  /* I [sct] Number of dimensions to reduce variable over */
  const int nco_op_typ,               /* I [enm] Operation type, default is average */
- gpe_sct *gpe,                       /* [sng] Group Path Editing (GPE) structure */
+ gpe_sct *gpe,                       /* I [sng] Group Path Editing (GPE) structure */
+ const clm_bnd_sct * const cb,       /* I [sct] Climatology bounds structure */
  const trv_tbl_sct * const trv_tbl); /* I [sct] Traversal table */
 
 int /* I [enm] Operation type */
diff --git a/src/nco/nco_ctl.c b/src/nco/nco_ctl.c
index bd996c8..54a52d6 100644
--- a/src/nco/nco_ctl.c
+++ b/src/nco/nco_ctl.c
@@ -843,7 +843,7 @@ nco_nmn_get(void) /* [fnc] Return mnemonic that describes current NCO version */
 { 
   /* Purpose: Return mnemonic describing current NCO version
      Always include terminal \n so mnemonic does not dangle */
-  return "VESL SUP\n";
+  return "AP Lang\n";
 } /* end nco_nmn_get() */
 
 char * /* O [sng] nm_in stripped of any path (i.e., program name stub) */ 
@@ -957,7 +957,7 @@ nco_usg_prn(void)
     opt_sng=(char *)strdup("[-3] [-4] [-6] [-7] [-A] [--bfr sz] [-C] [-c] [--cnk_byt sz] [--cnk_dmn nm,sz] [--cnk_map map] [--cnk_min min] [--cnk_plc plc] [--cnk_scl sz] [-D nco_dbg_lvl] [-F] [-f] [--fl_fmt fmt] [--glb ...] [-h] [--hdf] [--hdr_pad nbr] [-L lvl] [-l path] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [-R] [-r] [--ram_all] [-s algebra] [-S fl.nco] [-t thr_nbr] [-v] in.nc [out.nc]\n");
     break;
   case ncatted:
-    opt_sng=(char *)strdup("[-a ...] [--bfr sz] [-D nco_dbg_lvl] [--glb ...] [-h] [--hdr_pad nbr] [-l path] [-O] [-o out.nc] [-p path] [-R] [-r] in.nc [[out.nc]]\n");
+    opt_sng=(char *)strdup("[-a ...] [--bfr sz] [-D nco_dbg_lvl] [--glb ...] [-h] [--hdr_pad nbr] [-l path] [-O] [-o out.nc] [-p path] [-R] [-r] [-t] in.nc [[out.nc]]\n");
     break;
   case ncbo:
     opt_sng=(char *)strdup("[-3] [-4] [-6] [-7] [-A] [--bfr sz] [-C] [-c] [--cnk_byt sz] [--cnk_dmn nm,sz] [--cnk_map map] [--cnk_min min] [--cnk_plc plc] [--cnk_scl sz] [-D nco_dbg_lvl] [-d ...] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-h] [--hdf] [--hdr_pad nbr] [-L lvl] [-l path] [--msa] [-n ...] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [-R] [-r] [--ram_all] [-t thr_nbr] [--unn] [-v ...] [-X box] [-x] [-y op_typ] in_1.nc in_2.nc [out.nc]\n");
@@ -972,7 +972,7 @@ nco_usg_prn(void)
     opt_sng=(char *)strdup("[-3] [-4] [-6] [-7] [-A] [-a ...] [--bfr sz] [-C] [-c] [--cnk_byt sz] [--cnk_dmn nm,sz] [--cnk_map map] [--cnk_min min] [--cnk_plc plc] [--cnk_scl sz] [-D nco_dbg_lvl] [-d ...] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-h] [--hdf] [--hdr_pad nbr] [-L lvl] [-l path] [-M pck_map] [--mrd] [--msa] [--no_tmp_fl] [-O] [-o out.nc] [-P pck_plc] [-p path] [--ppc ...] [-R] [-r] [--ram_all] [-t thr_nbr] [--unn] [-U] [-v ...] [-X box] [-x] in.nc [out.nc]\n");
     break;
   case ncra:
-    opt_sng=(char *)strdup("[-3] [-4] [-6] [-7] [-A] [--bfr sz] [-C] [-c] [--cnk_byt sz] [--cnk_dmn nm,sz] [--cnk_map map] [--cnk_min min] [--cnk_plc plc] [--cnk_scl sz] [-D nco_dbg_lvl] [-d ...]  [--dbl|flt] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [-L lvl] [-l path] [--mro] [--msa] [-N] [-n ...] [--no_cll_mth] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [--ppc ...] [-R] [-r] [--ram_all] [--rec_apn] [-t thr_nbr] [--unn] [-w wgt] [-v ...] [-X b [...]
+    opt_sng=(char *)strdup("[-3] [-4] [-6] [-7] [-A] [--bfr sz] [-C] [-c] [--cb] [--cnk_byt sz] [--cnk_dmn nm,sz] [--cnk_map map] [--cnk_min min] [--cnk_plc plc] [--cnk_scl sz] [-D nco_dbg_lvl] [-d ...]  [--dbl|flt] [-F] [--fl_fmt fmt] [-G grp:lvl] [-g ...] [--glb ...] [-H] [-h] [--hdf] [--hdr_pad nbr] [-L lvl] [-l path] [--mro] [--msa] [-N] [-n ...] [--no_cll_mth] [--no_tmp_fl] [-O] [-o out.nc] [-p path] [--ppc ...] [-R] [-r] [--ram_all] [--rec_apn] [-t thr_nbr] [--unn] [-w wgt] [-v ... [...]
     break;
   case ncfe:
   case ncge:
@@ -1025,6 +1025,7 @@ nco_usg_prn(void)
   if(strstr(opt_sng,"--bfr")) (void)fprintf(stdout,"    --bfr_sz, --buffer_size sz\tBuffer size to open files with\n");
   if(strstr(opt_sng,"[-C]")) (void)fprintf(stdout,"-C, --nocoords\t\tAssociated coordinate variables should not be processed\n");
   if(strstr(opt_sng,"[-c]")) (void)fprintf(stdout,"-c, --crd, --coords\tCoordinate variables will all be processed\n");
+  if(strstr(opt_sng,"--cb")) (void)fprintf(stdout,"    --cb, --clm_bnd\tCF Climatology bounds will be processed (see also --c2b)\n");
   if(strstr(opt_sng,"--cdl")) (void)fprintf(stdout,"    --cdl\t\tPrint CDL (netCDF lingua franca used by ncdump/ncgen)\n");
   if(strstr(opt_sng,"--cnk_dmn")) (void)fprintf(stdout,"    --cnk_dmn, --chunk_dimension nm,sz\tChunksize of dimension nm is sz\n");
   if(strstr(opt_sng,"--cnk_map")) (void)fprintf(stdout,"    --cnk_map, --chunk_map map\t\tChunking map [dmn,lfp,prd,rd1,rew,scl,xpl,xst]\n");
@@ -1126,8 +1127,11 @@ nco_usg_prn(void)
   } /* end if */
   if(strstr(opt_sng,"[-S")) (void)fprintf(stdout,"-S, --fl_spt, --script-file fl.nco\tScript file containing multiple algebraic commands\n");
   if(strstr(opt_sng,"[-T")) (void)fprintf(stdout,"-T, --mask_comparator, --msk_cmp_typ, --op_rlt comparator\tComparator for mask condition: eq,ne,ge,le,gt,lt\n");
-  if(strstr(opt_sng,"[-t")) (void)fprintf(stdout,"-t, --thr_nbr, --threads, --omp_num_threads thr_nbr\tThread number for OpenMP\n");
-  if(strstr(opt_sng,"[-U]")) (void)fprintf(stdout,"-U, --upk, --unpack\tUnpack input file\n");
+  if(strstr(opt_sng,"[-t")){
+    if(prg_lcl == ncatted) (void)fprintf(stdout,"-t, --typ_mch, --type_match \tType-match attribute edits\n");
+    if(prg_lcl != ncatted) (void)fprintf(stdout,"-t, --thr_nbr, --threads, --omp_num_threads thr_nbr\tThread number for OpenMP\n");
+  } /* end if */
+  if(strstr(opt_sng,"[-U]")) (void)fprintf(stdout,"-U, --unpack\tUnpack input file\n");
   if(strstr(opt_sng,"[-u")){
     if(prg_lcl == ncks) (void)fprintf(stdout,"-u, --units\t\tToggle printing units of variables, if any\n");
     if(prg_lcl == ncecat) (void)fprintf(stdout,"-u, --ulm_nm --rcd_nm\tNew unlimited (record) dimension name\n");
diff --git a/src/nco/nco_fl_utl.c b/src/nco/nco_fl_utl.c
index 1df3e58..59b9587 100644
--- a/src/nco/nco_fl_utl.c
+++ b/src/nco/nco_fl_utl.c
@@ -767,7 +767,7 @@ nco_fl_mk_lcl /* [fnc] Retrieve input file and return local filename */
         /* rmt_fch_cmd_sct nrnet={"nrnet msget %s r flnm=%s l mail=FAIL",4,asynchronous,lcl_rmt};*/ /* Deprecated 20110419 */
         /* rmt_fch_cmd_sct rcp={"rcp -p %s %s",4,synchronous,rmt_lcl};*/ /* Deprecated ~2000 */
         /* wget -p: fxm (and enables clobber)
-        wget -r: Turn on recursive retrieving (and enables clobber)
+        wget -r: Turn-on recursive retrieving (and enables clobber)
         wget --tries: Set number of retries. Default is 20. */
         rmt_fch_cmd_sct http={"wget --tries=1 --output-document=%s %s",4,synchronous,lcl_rmt};
         rmt_fch_cmd_sct scp={"scp -p %s %s",4,synchronous,rmt_lcl};
@@ -1482,7 +1482,7 @@ nco_fl_blocksize /* [fnc] Find blocksize of filesystem will or does contain this
 char * /* O [sng] Name of temporary file actually opened */
 nco_fl_out_open /* [fnc] Open output file subject to availability and user input */
 (const char * const fl_out, /* I [sng] Name of file to open */
- const nco_bool FORCE_APPEND, /* I [flg] Append to existing file, if any */
+ nco_bool * const FORCE_APPEND, /* I/O [flg] Append to existing file, if any */
  const nco_bool FORCE_OVERWRITE, /* I [flg] Overwrite existing file, if any */
  const int fl_out_fmt, /* I [enm] Output file format */
  const size_t * const bfr_sz_hnt, /* I [B] Buffer size hint */
@@ -1532,7 +1532,7 @@ nco_fl_out_open /* [fnc] Open output file subject to availability and user input
   md_create=nco_create_mode_mrg(md_create,fl_out_fmt);
   if(RAM_CREATE) md_create|=NC_DISKLESS|NC_WRITE;
 
-  if(FORCE_OVERWRITE && FORCE_APPEND){
+  if(FORCE_OVERWRITE && *FORCE_APPEND){
     (void)fprintf(stdout,"%s: ERROR FORCE_OVERWRITE and FORCE_APPEND are both set\n",nco_prg_nm_get());
     (void)fprintf(stdout,"%s: HINT: Overwrite (-O) and Append (-A) options are mutually exclusive. Re-run your command, setting at most one of these switches.\n",nco_prg_nm_get());
     nco_exit(EXIT_FAILURE);
@@ -1655,7 +1655,7 @@ nco_fl_out_open /* [fnc] Open output file subject to availability and user input
 
     if(RAM_OPEN) md_open=NC_WRITE|NC_DISKLESS; else md_open=NC_WRITE;
 
-    if(FORCE_APPEND){
+    if(*FORCE_APPEND){
       /* Incur expense of copying current file to temporary file
 	 This is a no-op when files are identical */
       (void)nco_fl_cp(fl_out,fl_out_tmp);
@@ -1673,7 +1673,7 @@ nco_fl_out_open /* [fnc] Open output file subject to availability and user input
 	nco_exit(EXIT_FAILURE);
       } /* end if */
       if(nbr_itr > 1) (void)fprintf(stdout,"%s: ERROR Invalid response.\n",nco_prg_nm_get());
-      (void)fprintf(stdout,"%s: %s exists---`e'xit, `o'verwrite (i.e., delete existing file), or `a'ppend (i.e., replace duplicate variables in and add new variables to existing file) (e/o/a)? ",nco_prg_nm_get(),fl_out);
+      (void)fprintf(stdout,"%s: %s exists---`e'xit, `o'verwrite (i.e., clobber existing file), or `a'ppend (i.e., replace duplicate variables in, and add metadata and new variables to, existing file) (e/o/a)? ",nco_prg_nm_get(),fl_out);
       (void)fflush(stdout);
       /*       fgets() reads (at most one less than NCO_USR_RPL_MAX_LNG) to first newline or EOF */
       rcd_fgets=fgets(usr_rpl,NCO_USR_RPL_MAX_LNG,stdin);
@@ -1713,6 +1713,7 @@ nco_fl_out_open /* [fnc] Open output file subject to availability and user input
       (void)nco_fl_cp(fl_out,fl_out_tmp);
       rcd+=nco_fl_open(fl_out_tmp,md_open,&bfr_sz_hnt_lcl,out_id);
       (void)nco_redef(*out_id);
+      *FORCE_APPEND=True;
       break;
     default: nco_dfl_case_nc_type_err(); break;
     } /* end switch */
diff --git a/src/nco/nco_fl_utl.h b/src/nco/nco_fl_utl.h
index c3dca10..120d654 100644
--- a/src/nco/nco_fl_utl.h
+++ b/src/nco/nco_fl_utl.h
@@ -140,7 +140,7 @@ nco_fl_blocksize /* [fnc] Find blocksize of filesystem will or does contain this
 char * /* O [sng] Name of temporary file actually opened */
 nco_fl_out_open /* [fnc] Open output file subject to availability and user input */
 (const char * const fl_out, /* I [sng] Name of file to open */
- const nco_bool FORCE_APPEND, /* I [flg] Append to existing file, if any */
+ nco_bool * const FORCE_APPEND, /* I/O [flg] Append to existing file, if any */
  const nco_bool FORCE_OVERWRITE, /* I [flg] Overwrite existing file, if any */
  const int fl_out_fmt, /* I [enm] Output file format */
  const size_t * const bfr_sz_hnt, /* I [B] Buffer size hint */
diff --git a/src/nco/nco_grp_trv.c b/src/nco/nco_grp_trv.c
index be6a42f..0abf20d 100644
--- a/src/nco/nco_grp_trv.c
+++ b/src/nco/nco_grp_trv.c
@@ -250,6 +250,28 @@ trv_tbl_prn_flg_xtr                  /* [fnc] Print table items that have .flg_x
   } /* end loop over trv_tbl */
 } /* end trv_tbl_prn_flg_xtr() */
 
+void
+trv_tbl_prn_dbg                      /* [fnc] Print several table members fields (debug only) */
+(const char * const fnc_nm,          /* I [sng] Function name  */
+const trv_tbl_sct * const trv_tbl)   /* I [sct] Traversal table */
+{
+  (void)fprintf(stdout, "%s: INFO %s reports extracted objects:\n", nco_prg_nm_get(), fnc_nm);
+  /* Print all matching objects from traversal table */
+  trv_sct trv_obj;
+  for(unsigned int tbl_idx=0;tbl_idx<trv_tbl->nbr;tbl_idx++){
+    trv_obj=trv_tbl->lst[tbl_idx];
+    if(trv_obj.flg_xtr && trv_obj.nco_typ == nco_obj_typ_var){
+      (void)fprintf(stdout,"%s\n",trv_obj.nm_fll);
+      (void)fprintf(stdout,"   %d dimensions: ",trv_obj.nbr_dmn);
+      for(int idx_dmn=0; idx_dmn<trv_obj.nbr_dmn;idx_dmn++)
+        (void)fprintf(stdout, " %s ",trv_obj.var_dmn[idx_dmn].dmn_nm);
+      (void)fprintf(stdout,"\n");
+      (void)fprintf(stdout,"   record dimension name: ");
+      if(trv_obj.rec_dmn_nm_out) (void)fprintf(stdout, "%s\n ", trv_obj.rec_dmn_nm_out); else (void)fprintf(stdout, "NULL\n");
+    }
+  } /* end loop over trv_tbl */
+} /* end trv_tbl_prn_flg_xtr() */
+
 void                          
 trv_tbl_prn                          /* [fnc] Print table with -z */
 (const trv_tbl_sct * const trv_tbl)  /* I [sct] Traversal table */  
diff --git a/src/nco/nco_grp_trv.h b/src/nco/nco_grp_trv.h
index ab75ffb..8787049 100644
--- a/src/nco/nco_grp_trv.h
+++ b/src/nco/nco_grp_trv.h
@@ -123,6 +123,11 @@ trv_tbl_prn_flg_xtr                   /* [fnc] Print table items that have .flg_
 (const char * const fnc_nm,           /* I [sng] Function name  */
  const trv_tbl_sct * const trv_tbl);  /* I [sct] Traversal table */
 
+void
+trv_tbl_prn_dbg                       /* [fnc] Print several table members fields (debug only) */
+(const char * const fnc_nm,           /* I [sng] Function name  */
+const trv_tbl_sct * const trv_tbl);   /* I [sct] Traversal table */
+
 void                          
 trv_tbl_cmn_nm_prt                     /* [fnc] Print list of common objects (same absolute path) */
 (const nco_cmn_t * const cmn_lst,      /* I [sct] List of common names */
diff --git a/src/nco/nco_grp_utl.c b/src/nco/nco_grp_utl.c
index 25adbcc..81fcd84 100644
--- a/src/nco/nco_grp_utl.c
+++ b/src/nco/nco_grp_utl.c
@@ -1065,10 +1065,10 @@ void
 nco_xtr_cf_var_add /* [fnc] Add variables associated (via CF) with specified variable to extraction list */
 (const int nc_id, /* I [ID] netCDF file ID */
  const trv_sct * const var_trv, /* I [sct] Variable (object) */
- const char * const cf_nm, /* I [sng] CF convention ("ancillary_variables", "bounds", "climatology", or "coordinates") */
+ const char * const cf_nm, /* I [sng] CF convention ("ancillary_variables", "bounds", "climatology", "coordinates", and "grid_mapping") */
  trv_tbl_sct * const trv_tbl) /* I/O [sct] GTT (Group Traversal Table) */
 {
-  /* Detect associated variables specified by CF "ancillary_variables", "bounds", "climatology", or "coordinates" convention
+  /* Detect associated variables specified by CF "ancillary_variables", "bounds", "climatology", "coordinates", and "grid_mapping" convention
      Private routine called by nco_xtr_cf_add()
      http://cfconventions.org/1.6.html#ancillary-data
      http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.1/cf-conventions.html#coordinate-system */ 
@@ -1080,7 +1080,7 @@ nco_xtr_cf_var_add /* [fnc] Add variables associated (via CF) with specified var
 
   int grp_id; /* [id] Group ID */
   int nbr_att; /* [nbr] Number of attributes */
-  int nbr_cf; /* [nbr] Number of variables specified in CF attribute ("ancillary_variables", "bounds", "climatology", or "coordinates") */
+  int nbr_cf; /* [nbr] Number of variables specified in CF attribute ("ancillary_variables", "bounds", "climatology", "coordinates", and "grid_mapping") */
   int var_id; /* [id] Variable ID */
 
   assert(var_trv->nco_typ == nco_obj_typ_var);
@@ -1114,7 +1114,7 @@ nco_xtr_cf_var_add /* [fnc] Add variables associated (via CF) with specified var
       /* Split list into separate coordinate names
 	 Use nco_lst_prs_sgl_2D() not nco_lst_prs_2D() to avert TODO nco944 */
       cf_lst=nco_lst_prs_sgl_2D(att_val,dlm_sng,&nbr_cf);
-      /* ...for each variable in CF convention attribute, i.e., for each variable listed in "ancillary_variables", or in "bounds", or in "coordinates"... */
+      /* ...for each variable in CF convention attribute, i.e., for each variable listed in "ancillary_variables", or in "bounds", or in "coordinates", or in "grid_mapping", ... */
       for(int idx_cf=0;idx_cf<nbr_cf;idx_cf++){
         char *cf_lst_var=cf_lst[idx_cf];
         if(!cf_lst_var) continue;
@@ -2825,16 +2825,14 @@ nco_crd_var_dmn_scp                    /* [fnc] Is coordinate variable in dimens
   size_t var_nm_fll_lng;                     /* [nbr] Length of full variable name */
   size_t dmn_nm_fll_lng;                     /* [nbr] Length of of full dimension name */
   
-  /* Coordinate variables are 1D */
-  if(var_trv->nbr_dmn !=1 ){
-    return False;
-  }
+  /* True Coordinate variables are 1D */
+  if(var_trv->nbr_dmn != 1) return False;
   
-  /* Most common case is for the unique dimension full name to match the full variable name   */
+  /* Most common case is that unique dimension full name matches full variable name */
   if(!strcmp(var_trv->nm_fll,dmn_trv->nm_fll)){
     if(nco_dbg_lvl_get() == nco_dbg_old) (void)fprintf(stdout,"%s: INFO %s found absolute match of variable <%s> and dimension <%s>:\n",nco_prg_nm_get(),fnc_nm,var_trv->nm_fll,dmn_trv->nm_fll);
     return True;
-  }
+  } /* !strcmp() */
   
   /* Deal with in-scope cases */
   var_nm_fll_lng=strlen(var_trv->nm_fll);
@@ -4114,7 +4112,7 @@ nco_var_fll_trv                       /* [fnc] Allocate variable structure and f
 
   /* Set deflate and chunking to defaults */  
   var->dfl_lvl=NCO_DFL_LVL_UNDEFINED; /* [enm] Deflate level */
-  var->shuffle=NC_NOSHUFFLE; /* [flg] Turn on shuffle filter */
+  var->shuffle=NC_NOSHUFFLE; /* [flg] Turn-on shuffle filter */
 
   for(int idx=0;idx<var->nbr_dim;idx++) var->cnk_sz[idx]=(size_t)0L;
 
@@ -4629,13 +4627,11 @@ nco_cpy_var_dfn_trv                 /* [fnc] Define specified variable in output
     for(int idx_dmn=0;idx_dmn<nbr_dmn_var;idx_dmn++)
       dmn_out_id[dmn_idx_in_out[idx_dmn]]=dmn_out_id_tmp[idx_dmn];
 
-    if (nco_dbg_lvl_get() >= nco_dbg_dev){
+    if(nco_dbg_lvl_get() >= nco_dbg_dev){
       (void)fprintf(stdout, "%s: DEBUG %s dimensions for %s:\n",nco_prg_nm_get(),fnc_nm,var_trv->nm_fll);
-      for (int idx_dmn=0; idx_dmn<nbr_dmn_var;idx_dmn++){
-        char *dmm_nm_fll=nco_get_dmn_nm_fll(dmn_out_id[idx_dmn],dmn_cmn,nbr_dmn_var);
-        (void)fprintf(stdout, "%s %d\n",dmm_nm_fll,dmn_cmn[idx_dmn].id);
-      }
-    }
+      for (int idx_dmn=0; idx_dmn<nbr_dmn_var;idx_dmn++)
+        (void)fprintf(stdout, "%s %d\n",nco_get_dmn_nm_fll(dmn_out_id[idx_dmn],dmn_cmn,nbr_dmn_var),dmn_cmn[idx_dmn].id);
+    } /* !dbg */
   } /* !var_trv->rdr */
 
   if(nco_prg_id == ncecat && rec_dmn_nm && var_trv->enm_prc_typ == prc_typ){ 
@@ -4756,9 +4752,9 @@ nco_cpy_var_dfn_trv                 /* [fnc] Define specified variable in output
 
     /* Deflation */
     if(nbr_dmn_var > 0){
-      int deflate; /* [flg] Turn on deflate filter */
+      int deflate; /* [flg] Turn-on deflate filter */
       int dfl_lvl_in; /* [enm] Deflate level [0..9] */
-      int shuffle; /* [flg] Turn on shuffle filter */
+      int shuffle; /* [flg] Turn-on shuffle filter */
       rcd=nco_inq_var_deflate(grp_in_id,var_in_id,&shuffle,&deflate,&dfl_lvl_in);
       /* Copy original deflation settings */
       if(deflate || shuffle) (void)nco_def_var_deflate(grp_out_id,var_out_id,shuffle,deflate,dfl_lvl_in);
@@ -4883,8 +4879,8 @@ nco_dfn_dmn                            /* [fnc] Define dimension size and ID in
 
 } /* nco_dmn_dfn */
 
-char *
-nco_get_dmn_nm_fll                     /* [fnc] Return dimension name with input id (debug) */
+const char *
+nco_get_dmn_nm_fll                     /* [fnc] Return name corresponding to input dimension ID (debug) */
 (const int dmn_id,                     /* I [id] ID of dimension */
  const dmn_cmn_sct * const dmn_cmn,    /* I [sct] Dimension structure array */
  const int nbr_dmn)                    /* I [nbr] Number of dimensions (size of above array) */
@@ -4909,18 +4905,16 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
  const nco_bool *dmn_rvr_rdr)         /* I [flg] Reverse dimension */
 {
   /* Purpose: Determine and set new dimensionality in metadata of each re-ordered variable
-     Based in nco_var_dmn_rdr_mtd(). 
-     NB: first record dimension for object variable is used
+     Based on nco_var_dmn_rdr_mtd()
+     NB: first record dimension for target variable is used
      Test case: ncpdq -O -a lev,time -v two_dmn_rec_var in.nc out.nc
      Mark lev as record and un-mark time as record (by setting record name to lev) */
 
   char *rec_dmn_nm_out_crr; /* [sng] Name of record dimension, if any, required by re-order */
   char *rec_dmn_nm_in; /* [sng] Record dimension name, original */
   char *rec_dmn_nm_out; /* [sng] Record dimension name, re-ordered */
-  int dmn_idx_out_in[NC_MAX_DIMS]; /* [idx] Dimension correspondence, output->input (Stored in GTT) */
   int nco_prg_id; /* [enm] Program ID */
   nco_bool REDEFINED_RECORD_DIMENSION; /* [flg] Re-defined record dimension */
-  nco_bool dmn_rvr_in[NC_MAX_DIMS]; /* [flg] Reverse dimension (Stored in GTT) */
   nm_lst_sct *rec_dmn_nm; /* [sct] Record dimension names array */
 
   /* Get Program ID */
@@ -4928,18 +4922,21 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
   assert(nco_prg_id == ncpdq);
   CEWI_unused(nco_prg_id);
   
+  /* Initialize for this variable */
+  REDEFINED_RECORD_DIMENSION=False;
+
   /* Loop processed variables */
   for(int idx_var_prc=0;idx_var_prc<nbr_var_prc;idx_var_prc++){
 
+    int *dmn_idx_out_in=NULL; /* [idx] Dimension correspondence, output->input CEWI */
+    nco_bool *dmn_rvr_in=NULL; /* [flg] Reverse dimension */
+
     /* Obtain variable GTT *pointer using full variable name */
     trv_sct *var_trv=trv_tbl_var_nm_fll(var_prc[idx_var_prc]->nm_fll,trv_tbl);
 
     assert(var_trv->flg_xtr); 
     assert(var_trv->nbr_dmn == var_prc_out[idx_var_prc]->nbr_dim);
 
-    /* Initialize for this variable */
-    REDEFINED_RECORD_DIMENSION=False;
-
     /* Mark re-order flag */
     var_trv->flg_rdr=True;
 
@@ -4958,24 +4955,14 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
       rec_dmn_nm_out=(char *)strdup(rec_dmn_nm->lst[0].nm);
     } /* !rec_dmn_nm->lst */
 
-#ifdef FXM_PVN
-    nco_bool dmn_rvr_rdr_[NC_MAX_DIMS]; /* [flg] Reverse dimension */
-    /* Define a local dmn_rvr_rdr array upon reverse flag defined in dimensions for variable */
-    for(int idx_dmn=0;idx_dmn<var_trv->nbr_dmn;idx_dmn++){
-      dmn_rvr_rdr_[idx_dmn]=False;
-      if(var_trv->var_dmn[idx_dmn].flg_rvr == True){
-        dmn_rvr_rdr_[idx_dmn]=True;
-      }
-    }
-#endif
-
+    dmn_idx_out_in=(int *)nco_malloc(var_prc[idx_var_prc]->nbr_dim*sizeof(int));
+    dmn_rvr_in=(nco_bool *)nco_malloc(var_prc[idx_var_prc]->nbr_dim*sizeof(nco_bool));
     /* nco_var_dmn_rdr_mtd() does re-order heavy lifting */
     rec_dmn_nm_out_crr=nco_var_dmn_rdr_mtd(var_prc[idx_var_prc],var_prc_out[idx_var_prc],dmn_rdr,dmn_rdr_nbr,dmn_idx_out_in,dmn_rvr_rdr,dmn_rvr_in);
 
+    /* Transfer dimension structures to be re-ordered into GTT */
     var_trv->dmn_idx_out_in=(int *)nco_malloc(var_trv->nbr_dmn*sizeof(int));
     var_trv->dmn_rvr_in=(nco_bool *)nco_malloc(var_trv->nbr_dmn*sizeof(nco_bool));
-
-    /* Transfer dimension structures to be re-ordered into GTT */
     for(int idx_dmn=0;idx_dmn<var_trv->nbr_dmn;idx_dmn++){
       var_trv->dmn_idx_out_in[idx_dmn]=dmn_idx_out_in[idx_dmn];
       var_trv->dmn_rvr_in[idx_dmn]=dmn_rvr_in[idx_dmn];
@@ -4990,7 +4977,7 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
         if(REDEFINED_RECORD_DIMENSION){
           /* ...then requested re-order requires multiple record dimensions... */
           if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stdout,"%s: WARNING Re-order requests multiple record dimensions\n. Only first request will be honored (netCDF3 allows only one record dimension). Record dimensions involved [original,first change request (honored),latest change request (made by variable %s)]=[%s,%s,%s]\n",nco_prg_nm_get(),var_prc[idx_var_prc]->nm,rec_dmn_nm_in,rec_dmn_nm_out,rec_dmn_nm_out_crr);
-          break;
+          continue;
         }else{ /* !REDEFINED_RECORD_DIMENSION */
           /* ...otherwise, update output record dimension name... */
           rec_dmn_nm_out=rec_dmn_nm_out_crr;
@@ -5013,6 +5000,9 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
       rec_dmn_nm=(nm_lst_sct *)nco_free(rec_dmn_nm);
     } /* !rec_dmn_nm */
 
+    /* Free current dimension correspondence */
+    dmn_idx_out_in=(int *)nco_free(dmn_idx_out_in);
+    dmn_rvr_in=(nco_bool *)nco_free(dmn_rvr_in);
     if(rec_dmn_nm_in)rec_dmn_nm_in=(char *)nco_free(rec_dmn_nm_in);
     if(rec_dmn_nm_out)rec_dmn_nm_out=(char *)nco_free(rec_dmn_nm_out);
 
@@ -5080,6 +5070,9 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
     /* Update is_rec_var flag for var_prc */
     for(int idx_var_prc=0;idx_var_prc<nbr_var_prc;idx_var_prc++){
 
+      int *dmn_idx_out_in=NULL; /* [idx] Dimension correspondence, output->input CEWI */
+      dmn_idx_out_in=(int *)nco_malloc(var_prc[idx_var_prc]->nbr_dim*sizeof(int));
+
       /* Match by full variable name  */
       if(strcmp(var_prc_out[idx_var_prc]->nm_fll,var_trv.nm_fll) == 0){
 
@@ -5122,8 +5115,8 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
               if(NEEDS_REORDER){
 
                 /* NB:
-		   --- use found index of processed idx_var_prc_out
-		   --- use search index of GTT idx_var_mrk */
+                 --- use found index of processed idx_var_prc_out
+                 --- use search index of GTT idx_var_mrk */
 
                 /* Find index of processed variables that corresponds to found GTT variable */
                 nco_var_prc_idx_trv(var_trv_mrk.nm_fll,var_prc_out,nbr_var_prc,&idx_var_prc_out);        
@@ -5141,8 +5134,8 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
                 if(dmn_out_idx == var_prc_out[idx_var_prc_out]->nbr_dim){
                   /* ...No. Variable will be non-record---does this change its status?... */
                   if(nco_dbg_lvl_get() >= nco_dbg_var)
-		    if(var_prc_out[idx_var_prc_out]->is_rec_var) 
-		      (void)fprintf(stdout,"%s: INFO Requested re-order will change variable %s from record to non-record variable\n",nco_prg_nm_get(),var_prc_out[idx_var_prc_out]->nm);
+                    if(var_prc_out[idx_var_prc_out]->is_rec_var)
+                      (void)fprintf(stdout, "%s: INFO Requested re-order will change variable %s from record to non-record variable\n", nco_prg_nm_get(), var_prc_out[idx_var_prc_out]->nm);
                   /* Assign record flag dictated by re-order */
                   var_prc_out[idx_var_prc_out]->is_rec_var=False; 
                 }else{ /* ...otherwise variable will be record variable... */
@@ -5210,11 +5203,15 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
           } /* NEEDS_REORDER */
         } /* ...look if there is a record name to find  */
       } /* Match by full variable name  */
+      /* Free current dimension correspondence */
+      dmn_idx_out_in=(int *)nco_free(dmn_idx_out_in);
     } /* end loop over var_prc */
   } /* Loop table */
 
   /* Final step: search for all redefined record dimension variables and mark other variables */
 
+  if(nco_dbg_lvl_get() == nco_dbg_dev) trv_tbl_prn_dbg("nco_var_dmn_rdr_mtd_trv", trv_tbl);
+
   /* Loop table */
   for(unsigned idx_var=0;idx_var<trv_tbl->nbr;idx_var++){
     trv_sct var_trv=trv_tbl->lst[idx_var];
@@ -5241,15 +5238,18 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
             dmn_trv_sct *dmn_trv;
 
             /* Store name of record dimension on output */
-            if(!strcmp(var_trv_mrk.var_dmn[idx_dmn].dmn_nm,rec_dmn_nm_out))
+            if(!strcmp(var_trv_mrk.var_dmn[idx_dmn].dmn_nm, rec_dmn_nm_out)){
               trv_tbl->lst[idx_var_mrk].rec_dmn_nm_out=(char *)strdup(rec_dmn_nm_out);
+            }
 
             /* Get unique dimension object from unique dimension ID, in input list */
             dmn_trv=nco_dmn_trv_sct(var_trv_mrk.var_dmn[idx_dmn].dmn_id,trv_tbl);
 
             /* Is record? */
             /* Store record dimension name on output */
-            if(dmn_trv->is_rec_dmn) trv_tbl->lst[idx_var_mrk].rec_dmn_nm_out=(char *)strdup(rec_dmn_nm_out);
+            if(dmn_trv->is_rec_dmn){
+              trv_tbl->lst[idx_var_mrk].rec_dmn_nm_out=(char *)strdup(rec_dmn_nm_out);
+            }
 
           } /* Loop variable dimensions */
         } /* Avoid same */
@@ -5257,6 +5257,8 @@ nco_var_dmn_rdr_mtd_trv /* [fnc] Set new dimensionality in metadata of each re-o
     } /* Has re-defined record dimension */
   } /* Loop table */
 
+  if(nco_dbg_lvl_get() == nco_dbg_dev) trv_tbl_prn_dbg("nco_var_dmn_rdr_mtd_trv", trv_tbl);
+
   return;
 
 } /* nco_var_dmn_rdr_mtd_trv() */
@@ -5983,29 +5985,8 @@ nco_dmn_avg_mk                         /* [fnc] Build dimensions to average(ncwa
           /* Dimension name relative */
           char *dmn_nm=trv_obj.var_dmn[idx_var_dmn].dmn_nm;
 
-          char *sng_dmn=NULL;
-
-          trv_tbl->lst[idx_tbl].var_dmn[idx_var_dmn].flg_rvr=False;
-
-          /* Option -a '-' (minus), reverse dimesnion Strip-out '-' and compare name */
-          if (usr_sng[0] == '-'){
-            sng_dmn=(char *)strdup(usr_sng+1L);
-            if (!strcmp(sng_dmn,dmn_nm)){
-              trv_tbl->lst[idx_tbl].var_dmn[idx_var_dmn].flg_rvr=True;
-            }
-          }else{ /* Not -a '-', duplicate user string to use in nco_pth_mch() */
-            sng_dmn=(char *)strdup(usr_sng);
-          }
-
           /* Must meet necessary flags */
-          nco_bool pth_mth=nco_pth_mch(dmn_nm_fll,dmn_nm,sng_dmn); 
-
-          /* If does not meet criteria, reverse flag */
-          if(!pth_mth){
-            trv_tbl->lst[idx_tbl].var_dmn[idx_var_dmn].flg_rvr=False;
-          }
-
-          sng_dmn=(char *)nco_free(sng_dmn);
+          nco_bool pth_mth=nco_pth_mch(dmn_nm_fll,dmn_nm,usr_sng);
 
           if(pth_mth){
             int idx_dmn_out; /* [idx] Index for output dimensions */
@@ -6511,16 +6492,18 @@ nco_bld_trv_tbl                       /* [fnc] Construct GTT, Group Traversal Ta
     CNV_CCM_CCSM_CF=True;
   } /* endif */
   if(CNV_CCM_CCSM_CF && EXTRACT_ASSOCIATED_COORDINATES){
-    /* Implement CF "ancillary_variables", "bounds", "climatology", and "coordinates" */
+    /* Implement CF "ancillary_variables", "bounds", "climatology", "coordinates", and "grid_mapping" */
     (void)nco_xtr_cf_add(nc_id,"ancillary_variables",trv_tbl);
     (void)nco_xtr_cf_add(nc_id,"bounds",trv_tbl);
     (void)nco_xtr_cf_add(nc_id,"climatology",trv_tbl);
     (void)nco_xtr_cf_add(nc_id,"coordinates",trv_tbl);
-    /* Do all twice, so that, e.g., auxiliary coordinates retrieved because of "coordinates" come with their bounds variables */
+    (void)nco_xtr_cf_add(nc_id,"grid_mapping",trv_tbl);
+    /* Do all twice, so that, e.g., auxiliary coordinates retrieved because of "coordinates" come with their "bounds" variables */
     (void)nco_xtr_cf_add(nc_id,"ancillary_variables",trv_tbl);
     (void)nco_xtr_cf_add(nc_id,"climatology",trv_tbl);
     (void)nco_xtr_cf_add(nc_id,"coordinates",trv_tbl);
     (void)nco_xtr_cf_add(nc_id,"bounds",trv_tbl);
+    (void)nco_xtr_cf_add(nc_id,"grid_mapping",trv_tbl);
   } /* CNV_CCM_CCSM_CF */
 
   /* Mark extracted dimensions */
@@ -7185,13 +7168,13 @@ nco_grp_var_lst                        /* [fnc] Export list of variable names fo
 } /* end nco_grp_var_lst() */
 
 char * /* O [sng] Name of variable   */
-nco_var_has_cf /* [fnc] Variable has CF-compliant attributes ("ancillary_variables", "bounds", "climatology", or "coordinates") */
+nco_var_has_cf /* [fnc] Variable has CF-compliant attributes ("ancillary_variables", "bounds", "climatology", "coordinates" and "grid_mapping") */
 (const int nc_id, /* I [ID] netCDF file ID */
  const trv_sct * const var_trv, /* I [sct] Variable (object) */
- const char * const cf_nm, /* I [sng] CF convention ("ancillary_variables", "bounds", "climatology", or "coordinates") */
+ const char * const cf_nm, /* I [sng] CF convention ("ancillary_variables", "bounds", "climatology", "coordinates", and "grid_mapping") */
  nco_bool *flg_cf_fnd) /* I/O [flg] CF variable was found */
 {
-  /* Detect associated variables specified by CF "ancillary_variables", "bounds", "climatology", or "coordinates" convention
+  /* Detect associated variables specified by CF "ancillary_variables", "bounds", "climatology", "coordinates", and "grid_mapping" conventions
      http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.1/cf-conventions.html#coordinate-system */ 
 
   const char dlm_sng[]=" "; /* [sng] Delimiter string */
@@ -7201,7 +7184,7 @@ nco_var_has_cf /* [fnc] Variable has CF-compliant attributes ("ancillary_variabl
 
   int grp_id; /* [id] Group ID */
   int nbr_att; /* [nbr] Number of attributes */
-  int nbr_cf; /* [nbr] Number of coordinates specified in "bounds" or "coordinates" attribute */
+  int nbr_cf; /* [nbr] Number of coordinates specified in "bounds" or "coordinates" attributes */
   int var_id; /* [id] Variable ID */
 
   assert(var_trv->nco_typ == nco_obj_typ_var);
@@ -7249,7 +7232,7 @@ nco_var_has_cf /* [fnc] Variable has CF-compliant attributes ("ancillary_variabl
       /* Split list into separate coordinate names
 	 Use nco_lst_prs_sgl_2D() not nco_lst_prs_2D() to avert TODO nco944 */
       cf_lst=nco_lst_prs_sgl_2D(att_val,dlm_sng,&nbr_cf);
-      /* ...for each associated variable in CF convention attribute, i.e., "ancillary_variables", "bounds", "climatology", or "coordinates"... */
+      /* ...for each associated variable in CF convention attribute, i.e., "ancillary_variables", "bounds", "climatology", "coordinates", and "grid_mapping", ... */
       for(int idx_cf=0;idx_cf<nbr_cf;idx_cf++){
         char *cf_lst_var=cf_lst[idx_cf];
         if(!cf_lst_var) continue;
@@ -7477,8 +7460,7 @@ nco_lmt_aux                           /* [fnc] Apply auxiliary -X limits (Auxili
 {
 
   /* a) case where the dimension has coordinate variables */
-  if(trv_tbl->lst[idx_tbl].var_dmn[idx_dmn].crd)
-  {
+  if(trv_tbl->lst[idx_tbl].var_dmn[idx_dmn].crd){
 
     /* For this call (-X) the *same* limits are applied to all coordinates, and other variables might apply
     them too, so make sure they are applied only once by setting -1 in lmt_crr */
@@ -7582,15 +7564,8 @@ nco_lmt_aux                           /* [fnc] Apply auxiliary -X limits (Auxili
     } /* Loop limits */
   } /* a) case where the dimension has coordinate variables */
 
-
   /* b) Dimension only (no coordinate variable for this dimension) */
-  else if(trv_tbl->lst[idx_tbl].var_dmn[idx_dmn].ncd)
-  {
-
-    if(nco_dbg_lvl_get() >= nco_dbg_dev)
-    {
-
-    }
+  else if(trv_tbl->lst[idx_tbl].var_dmn[idx_dmn].ncd){
 
     /* For this call (-X) the *same* limits are applied to all coordinates, and other variables might apply
     them too, so make sure they are applied only once by setting -1 in lmt_crr */
@@ -8289,7 +8264,7 @@ nco_nsm_dfn_wrt                      /* [fnc] Define OR write ensemble fixed var
 
       /* Define variable  */
       if(flg_def){
-        int var_out_id=nco_cpy_var_dfn_trv(nc_id, nc_out_id, cnk, grp_out_fll, dfl_lvl, gpe, NULL, var_trv, NULL, 0, trv_tbl);
+        int var_out_id=nco_cpy_var_dfn_trv(nc_id,nc_out_id,cnk,grp_out_fll,dfl_lvl,gpe,NULL,var_trv,NULL,0,trv_tbl);
         /* Copy attributes */
         (void)nco_wrt_atr(nc_id,grp_id_out,var_out_id,var_trv);
       } /* endif */
@@ -9744,7 +9719,6 @@ nco_rad                                /* [fnc] Retain all dimensions */
   } /* Loop unique dimensions list */
 } /* nco_rad() */
 
-
 void                                               
 nco_prc_cmn_nsm_att                    /* [fnc] Process (define, write) variables belonging to ensembles in both files (ncbo) */
 (const int nc_id_1,                    /* I [id] netCDF input-file ID */
diff --git a/src/nco/nco_grp_utl.h b/src/nco/nco_grp_utl.h
index 3ffd6f9..7736e62 100644
--- a/src/nco/nco_grp_utl.h
+++ b/src/nco/nco_grp_utl.h
@@ -919,8 +919,8 @@ nco_wrt_atr
  const int var_out_id,               /* I [id] netCDF output variable ID */
  const trv_sct *var_trv);            /* I [sct] traversal variable */
 
-char*
-nco_get_dmn_nm_fll                     /* [fnc] Return dimension name with input id (debug) */
+const char *
+nco_get_dmn_nm_fll                     /* [fnc] Return name corresponding to input dimension ID (debug) */
 (const int dmn_id,                     /* I [id] ID of dimension */
  const dmn_cmn_sct * const dmn_cmn,    /* I [sct] Dimension structure array */
  const int nbr_dmn);                   /* I [nbr] Number of dimensions (size of above array) */
diff --git a/src/nco/nco_mmr.c b/src/nco/nco_mmr.c
index 8d26a43..e6e39be 100644
--- a/src/nco/nco_mmr.c
+++ b/src/nco/nco_mmr.c
@@ -199,7 +199,7 @@ nco_malloc_err_hnt_prn /* [fnc] Explain meaning and workarounds for malloc() fai
 (void)
 {
   /* Purpose: Explain meaning and workarounds for malloc() failures */
-  (void)fprintf(stdout,"%s: INFO NCO has reported a malloc() failure. malloc() failures usually indicate that your machine does not have enough free memory (RAM+swap) to perform the requested operation. As such, malloc() failures result from the physical limitations imposed by your hardware. Read http://nco.sf.net/nco.html#mmr for a description of NCO memory usage. The likiest case is that this problem is caused by inadequate RAM on your system, and is not an NCO bug. If so, there are tw [...]
+  (void)fprintf(stdout,"%s: INFO NCO has reported a malloc() failure. malloc() failures usually indicate that your machine does not have enough free memory (RAM+swap) to perform the requested operation. As such, malloc() failures result from the physical limitations imposed by your hardware. Read http://nco.sf.net/nco.html#mmr for a description of NCO memory usage. The likiest case is that this problem is caused by inadequate RAM on your system, and is not an NCO bug. If so, there are tw [...]
 } /* nco_malloc_err_hnt_prn() */
 
 /* fxm: when are const qualifiers on return values legal? is this a GNUism? */
diff --git a/src/nco/nco_msa.h b/src/nco/nco_msa.h
index 0638ecb..f89665d 100644
--- a/src/nco/nco_msa.h
+++ b/src/nco/nco_msa.h
@@ -28,7 +28,7 @@
 
 /* Personal headers */
 #include "nco.h" /* netCDF Operator (NCO) definitions */
-#include "nco_bnr.h" /* Binary write utilities */
+#include "nco_bnr.h" /* Binary file utilities */
 #include "nco_ctl.h" /* Program flow control functions */
 #include "nco_grp_utl.h" /* Group utilities */
 #include "nco_lmt.h" /* Hyperslab limits */
diff --git a/src/nco/nco_netcdf.c b/src/nco/nco_netcdf.c
index d6ba1d8..a9baa3e 100644
--- a/src/nco/nco_netcdf.c
+++ b/src/nco/nco_netcdf.c
@@ -1209,6 +1209,9 @@ nco_def_dim(const int nc_id,const char * const dmn_nm,const long dmn_sz,int * co
   const char fnc_nm[]="nco_def_dim()";
   int rcd;
   rcd=nc_def_dim(nc_id,dmn_nm,(size_t)dmn_sz,dmn_id);
+  if(rcd == NC_ENAMEINUSE){
+    (void)fprintf(stdout,"ERROR: %s cannot define dimension name \"%s\" which is already in use\n",fnc_nm,dmn_nm);
+  } /* endif */
   if(rcd == NC_EBADNAME){
     char *nm_nc=NULL; /* [sng] netCDF-compatible name */
     (void)fprintf(stdout,"INFO: %s reports input file dimension name \"%s\" contains illegal characters. ",fnc_nm,dmn_nm);
@@ -1350,6 +1353,10 @@ nco_def_var(const int nc_id,const char * const var_nm,const nc_type var_typ,cons
     if(nm_nc) free(nm_nc);
     if(rcd == NC_NOERR) (void)fprintf(stdout,"Original variable name is preserved in \"%s\" attribute.\n",att_nm);
   } /* endif */
+  if(rcd != NC_NOERR){
+    (void)fprintf(stdout,"ERROR: %s failed to nc_def_var() variable \"%s\"\n",fnc_nm,var_nm);
+  } /* endif */
+
   if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_def_var()");
   return rcd;
 } /* end nco_def_var */
@@ -1380,8 +1387,8 @@ int nco_def_var_chunking
 int nco_def_var_deflate
 (const int nc_id, /* [ID] netCDF ID */
  const int var_id, /* [ID] Variable ID */
- const int shuffle, /* [flg] Turn on shuffle filter */
- const int deflate, /* [flg] Turn on deflate filter */
+ const int shuffle, /* [flg] Turn-on shuffle filter */
+ const int deflate, /* [flg] Turn-on deflate filter */
  const int dfl_lvl) /* [enm] Deflate level [0..9] */
 {
   /* Purpose: Wrapper for nc_def_var_deflate() */
@@ -1430,8 +1437,8 @@ int
 nco_inq_var_deflate
 (const int nc_id, /* I [ID] netCDF ID */
  const int var_id, /* I [ID] Variable ID */
- int * const shuffle, /* O [flg] Turn on shuffle filter */
- int * const deflate, /* O [flg] Turn on deflate filter */
+ int * const shuffle, /* O [flg] Turn-on shuffle filter */
+ int * const deflate, /* O [flg] Turn-on deflate filter */
  int * const dfl_lvl) /* O [enm] Deflate level [0..9] */
 {
   /* Purpose: Wrapper for nc_inq_var_deflate() */
@@ -1691,6 +1698,66 @@ nco_rename_var(const int nc_id,const int var_id,const char * const var_nm)
 
 /* Start _get _put _var */
 int
+nco_get_var(const int nc_id,const int var_id,void * const vp,const nc_type type)
+{
+  /* Purpose: Wrapper for nc_get_var_*() */
+  int rcd=NC_NOERR;
+  switch(type){
+  case NC_FLOAT: rcd=nc_get_var_float(nc_id,var_id,(float *)vp); break;
+  case NC_DOUBLE: rcd=nc_get_var_double(nc_id,var_id,(double *)vp); break;
+  case NC_INT: rcd=NCO_GET_VAR_INT(nc_id,var_id,(nco_int *)vp); break;
+  case NC_SHORT: rcd=nc_get_var_short(nc_id,var_id,(nco_short *)vp); break;
+  case NC_CHAR: rcd=NCO_GET_VAR_CHAR(nc_id,var_id,(nco_char *)vp); break;
+  case NC_BYTE: rcd=NCO_GET_VAR_BYTE(nc_id,var_id,(nco_byte *)vp); break;
+#ifdef ENABLE_NETCDF4
+  case NC_UBYTE: rcd=NCO_GET_VAR_UBYTE(nc_id,var_id,(nco_ubyte *)vp); break;
+  case NC_USHORT: rcd=NCO_GET_VAR_USHORT(nc_id,var_id,(nco_ushort *)vp); break;
+  case NC_UINT: rcd=NCO_GET_VAR_UINT(nc_id,var_id,(nco_uint *)vp); break;
+  case NC_INT64: rcd=NCO_GET_VAR_INT64(nc_id,var_id,(nco_int64 *)vp); break;
+  case NC_UINT64: rcd=NCO_GET_VAR_UINT64(nc_id,var_id,(nco_uint64 *)vp); break;
+  case NC_STRING: rcd=NCO_GET_VAR_STRING(nc_id,var_id,(nco_string *)vp); break;
+#endif /* !ENABLE_NETCDF4 */
+  default: nco_dfl_case_nc_type_err(); break;
+  } /* end switch */
+  if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_get_var()");
+  return rcd;
+} /* end nco_get_var */
+
+int
+nco_put_var(const int nc_id,const int var_id,const void * const vp,const nc_type type)
+{
+  /* Purpose: Wrapper for nc_put_var_*()
+     20160228: nc_put_var() family does type conversion, nc_put_vara() family does not */
+  const char fnc_nm[]="nco_put_var()";
+  int rcd=NC_NOERR;
+  switch(type){
+  case NC_FLOAT: rcd=nc_put_var_float(nc_id,var_id,(const float *)vp); break;
+  case NC_DOUBLE: rcd=nc_put_var_double(nc_id,var_id,(const double *)vp); break;
+  case NC_INT: rcd=NCO_PUT_VAR_INT(nc_id,var_id,(const nco_int *)vp); break;
+  case NC_SHORT: rcd=nc_put_var_short(nc_id,var_id,(const short *)vp); break;
+  case NC_CHAR: rcd=NCO_PUT_VAR_CHAR(nc_id,var_id,(const nco_char *)vp); break;
+  case NC_BYTE: rcd=NCO_PUT_VAR_BYTE(nc_id,var_id,(const nco_byte *)vp); break;
+#ifdef ENABLE_NETCDF4
+  case NC_UBYTE: rcd=NCO_PUT_VAR_UBYTE(nc_id,var_id,(const nco_ubyte *)vp); break;
+  case NC_USHORT: rcd=NCO_PUT_VAR_USHORT(nc_id,var_id,(const nco_ushort *)vp); break;
+  case NC_UINT: rcd=NCO_PUT_VAR_UINT(nc_id,var_id,(const nco_uint *)vp); break;
+  case NC_INT64: rcd=NCO_PUT_VAR_INT64(nc_id,var_id,(const nco_int64 *)vp); break;
+  case NC_UINT64: rcd=NCO_PUT_VAR_UINT64(nc_id,var_id,(const nco_uint64 *)vp); break;
+    /* NC_STRING prototype next causes same compiler warnings described in nco_put_var1() above */
+  case NC_STRING: rcd=NCO_PUT_VAR_STRING(nc_id,var_id,(const char **)vp); break;
+#endif /* !ENABLE_NETCDF4 */
+  default: nco_dfl_case_nc_type_err(); break;
+  } /* end switch */
+  if(rcd != NC_NOERR){
+    char var_nm[NC_MAX_NAME+1L];
+    (void)nco_inq_varname(nc_id,var_id,var_nm);
+    (void)fprintf(stdout,"ERROR: %s failed to nc_put_var() variable \"%s\"\n",fnc_nm,var_nm);
+  } /* endif */
+  if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_put_var()");
+  return rcd;
+} /* end nco_put_var */
+
+int
 nco_get_var1(const int nc_id,const int var_id,const long * const srt,void * const vp,const nc_type var_typ)
 {
   /* Purpose: Wrapper for nc_get_var1_*() */
@@ -1790,6 +1857,7 @@ int
 nco_put_vara(const int nc_id,const int var_id,const long * const srt,const long * const cnt,const void * const vp,const nc_type type)
 {
   /* Purpose: Wrapper for nc_put_vara_*() */
+  const char fnc_nm[]="nco_put_vara()";
   int rcd=NC_NOERR;
   switch(type){
   case NC_FLOAT: rcd=nc_put_vara_float(nc_id,var_id,(const size_t *)srt,(const size_t *)cnt,(const float *)vp); break;
@@ -1809,6 +1877,11 @@ nco_put_vara(const int nc_id,const int var_id,const long * const srt,const long
 #endif /* !ENABLE_NETCDF4 */
   default: nco_dfl_case_nc_type_err(); break;
   } /* end switch */
+  if(rcd != NC_NOERR){
+    char var_nm[NC_MAX_NAME+1L];
+    (void)nco_inq_varname(nc_id,var_id,var_nm);
+    (void)fprintf(stdout,"ERROR: %s failed to nc_put_vara() variable \"%s\"\n",fnc_nm,var_nm);
+  } /* endif */
   if(rcd != NC_NOERR) nco_err_exit(rcd,"nco_put_vara()");
   return rcd;
 } /* end nco_put_vara */
diff --git a/src/nco/nco_netcdf.h b/src/nco/nco_netcdf.h
index 082546f..4ca646c 100644
--- a/src/nco/nco_netcdf.h
+++ b/src/nco/nco_netcdf.h
@@ -378,6 +378,8 @@ int nco_inq_vartype(const int nc_id,const int var_id,nc_type * const var_typ);
 int nco_rename_var(const int nc_id,const int var_id,const char * const var_nm);
 
 /* Start _get _put _var */
+int nco_get_var(const int nc_id,const int var_id,void * const vp,const nc_type type);
+int nco_put_var(const int nc_id,const int var_id,const void * const vp,const nc_type type);
 int nco_get_var1(const int nc_id,const int var_id,const long * const srt,void * const vp,const nc_type var_typ);
 int nco_put_var1(const int nc_id,const int var_id,const long * const srt,const void * const vp,const nc_type type);
 int nco_get_vara(const int nc_id,const int var_id,const long * const srt,const long * const cnt,void * const vp,const nc_type type);
diff --git a/src/nco/nco_omp.c b/src/nco/nco_omp.c
index 34f5eff..64de490 100644
--- a/src/nco/nco_omp.c
+++ b/src/nco/nco_omp.c
@@ -58,7 +58,7 @@ nco_openmp_ini /* [fnc] Initialize OpenMP threading environment */
   int thr_nbr_rqs=int_CEWI; /* [nbr] Number of threads to request */
 
 #ifndef _OPENMP
-  if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(fp_stderr,"%s: INFO Build compiler lacked (or user turned off) OpenMP support. Code will execute with single thread in Uni-Processor (UP) mode.\n",nco_prg_nm_get());
+  if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(fp_stderr,"%s: INFO Build compiler lacked (or user turned-off) OpenMP support. Code will execute with single thread in Uni-Processor (UP) mode.\n",nco_prg_nm_get());
   return (int)1;
 #endif /* !_OPENMP */
 
diff --git a/src/nco/nco_pck.c b/src/nco/nco_pck.c
index 07bc494..47eeaef 100644
--- a/src/nco/nco_pck.c
+++ b/src/nco/nco_pck.c
@@ -1059,6 +1059,7 @@ nco_var_upk /* [fnc] Unpack variable in memory */
   const char fnc_nm[]="nco_var_upk()";
   const char scl_fct_sng[]="scale_factor"; /* [sng] Unidata standard string for scale factor */
   const char add_fst_sng[]="add_offset"; /* [sng] Unidata standard string for add offset */
+  int nco_upk_cnv_typ;
 
   /* Return if variable in memory is not currently packed */
   if(!var->pck_ram) return var;
@@ -1086,7 +1087,8 @@ nco_var_upk /* [fnc] Unpack variable in memory */
      ncpdq -O -C -U --hdf -v ^pck_.? ~/nco/data/in.nc ~/foo.nc # Unpack HDF
      ncpdq -O -C -P --hdf -v ^pck_.? ~/nco/data/in.nc ~/foo.nc # Unpack HDF and re-pack netCDF */
 
-  if(nco_upk_cnv_get() == nco_upk_netCDF){
+  nco_upk_cnv_typ=nco_upk_cnv_get();
+  if(nco_upk_cnv_typ == nco_upk_netCDF){
     /* netCDF unpack definition: unpacked=(scale_factor*packed)+add_offset */
     
     if(var->has_scl_fct){ /* [flg] Valid scale_factor attribute exists */
@@ -1111,8 +1113,8 @@ nco_var_upk /* [fnc] Unpack variable in memory */
       (void)nco_var_scv_add(var->type,var->sz,var->has_mss_val,var->mss_val,var->val,&add_fst_scv);
     } /* endif has_add_fst */
 
-  }else{ /* !netCDF_unpack_convention */
-    /* 20130729: NASA HDF unpack definition: unpacked=scale_factor*(packed-add_offset) */
+  }else if(nco_upk_cnv_typ == nco_upk_HDF_MOD10){ /* !netCDF_unpack_convention */
+    /* 20130729: NASA HDF MODIS MOD10 unpack definition: unpacked=scale_factor*(packed-add_offset) */
 
     if(var->has_add_fst){ /* [flg] Valid add_offset attribute exists */
       scv_sct add_fst_scv;
@@ -1135,7 +1137,37 @@ nco_var_upk /* [fnc] Unpack variable in memory */
       /* Multiply var by scale_factor */
       (void)nco_var_scv_mlt(var->type,var->sz,var->has_mss_val,var->mss_val,var->val,&scl_fct_scv);
     } /* endif has_scl_fct */
-    
+
+  }else if(nco_upk_cnv_typ == nco_upk_HDF_MOD13){ /* !netCDF_unpack_convention */
+    /* 20160501: NASA HDF MODIS MOD13 unpack definition: unpacked=(packed-add_offset)/scale_factor */
+
+    if(var->has_add_fst){ /* [flg] Valid add_offset attribute exists */
+      scv_sct add_fst_scv;
+      var->add_fst.vp=(void *)nco_malloc(nco_typ_lng(var->typ_upk));
+      (void)nco_get_att(var->nc_id,var->id,add_fst_sng,var->add_fst.vp,var->typ_upk);
+      add_fst_scv=ptr_unn_2_scv(var->typ_upk,var->add_fst);
+      /* Convert var to type of scale_factor for expansion */
+      var=nco_var_cnf_typ(add_fst_scv.type,var);
+      /* Subtract add_offset from var */
+      (void)nco_var_scv_sub(var->type,var->sz,var->has_mss_val,var->mss_val,var->val,&add_fst_scv);
+    } /* endif has_add_fst */
+
+    if(var->has_scl_fct){ /* [flg] Valid scale_factor attribute exists */
+      scv_sct scl_fct_scv;
+      var->scl_fct.vp=(void *)nco_malloc(nco_typ_lng(var->typ_upk));
+      (void)nco_get_att(var->nc_id,var->id,scl_fct_sng,var->scl_fct.vp,var->typ_upk);
+      scl_fct_scv=ptr_unn_2_scv(var->typ_upk,var->scl_fct);
+      /* Convert var to type of scale_factor for expansion */
+      var=nco_var_cnf_typ(scl_fct_scv.type,var);
+      /* Divide var by scale_factor */
+      (void)nco_var_scv_dvd(var->type,var->sz,var->has_mss_val,var->mss_val,var->val,&scl_fct_scv);
+    } /* endif has_scl_fct */
+
+  }else{ /* !netCDF_unpack_convention */
+
+    (void)fprintf(stdout,"%s: ERROR %s reports unknown nco_upk_cnv\n",nco_prg_nm_get(),fnc_nm);
+    nco_exit(EXIT_FAILURE);
+
   } /* !netCDF_unpack_convention */
 
   if(var->has_mss_val) var=nco_cnv_mss_val_typ(var,var->type);
diff --git a/src/nco/nco_ppc.c b/src/nco/nco_ppc.c
index ec6ed4c..d58aa8d 100644
--- a/src/nco/nco_ppc.c
+++ b/src/nco/nco_ppc.c
@@ -595,8 +595,8 @@ nco_ppc_bitmask /* [fnc] Mask-out insignificant bits of significand */
   /* Use constants defined in math.h */
   const double bit_per_dcm_dgt_prc=M_LN10/M_LN2; /* 3.32 [frc] Bits per decimal digit of precision */
   
-  const int bit_xpl_nbr_sgn_flt=23; /* [nbr] Bits 0-22 of SP significands are explicit. Bit 23 is implicit. */
-  const int bit_xpl_nbr_sgn_dbl=53; /* [nbr] Bits 0-52 of DP significands are explicit. Bit 53 is implicit. */
+  const int bit_xpl_nbr_sgn_flt=23; /* [nbr] Bits 0-22 of SP significands are explicit. Bit 23 is implicitly 1. */
+  const int bit_xpl_nbr_sgn_dbl=53; /* [nbr] Bits 0-52 of DP significands are explicit. Bit 53 is implicitly 1. */
   
   double prc_bnr_xct; /* [nbr] Binary digits of precision, exact */
   
@@ -621,7 +621,7 @@ nco_ppc_bitmask /* [fnc] Mask-out insignificant bits of significand */
   assert(nsd > 0);
   assert(nsd <= 16);
 
-    /* How many bits to preserve? */
+  /* How many bits to preserve? */
   prc_bnr_xct=nsd*bit_per_dcm_dgt_prc;
   /* Be conservative, round upwards */
   prc_bnr_ceil=(unsigned short)ceil(prc_bnr_xct);
@@ -654,8 +654,9 @@ nco_ppc_bitmask /* [fnc] Mask-out insignificant bits of significand */
     /* Create mask */
     msk_f32_u32_zro=0u; /* Zero all bits */
     msk_f32_u32_zro=~msk_f32_u32_zro; /* Turn all bits to ones */
-    /* Left shift zeros into bits to be rounded */
+    /* Bit Shave mask for AND: Left shift zeros into bits to be rounded, leave ones in untouched bits */
     msk_f32_u32_zro <<= bit_xpl_nbr_zro;
+    /* Bit Set   mask for OR:  Put ones into bits to be set, zeros in untouched bits */
     msk_f32_u32_one=~msk_f32_u32_zro;
     if(nco_baa_cnv_get() == nco_baa_grm){
       /* Bit-Groom: alternately shave and set LSBs */
@@ -683,11 +684,13 @@ nco_ppc_bitmask /* [fnc] Mask-out insignificant bits of significand */
     }else if(nco_baa_cnv_get() == nco_baa_set){
       /* Bit-Set: always set LSBs */
       if(!has_mss_val){
-	for(idx=0L;idx<sz;idx++) u32_ptr[idx]&=msk_f32_u32_one;
+	for(idx=0L;idx<sz;idx++)
+	  if(u32_ptr[idx] != 0U) /* Never quantize upwards floating point values of zero */
+	    u32_ptr[idx]|=msk_f32_u32_one;
       }else{
 	const float mss_val_flt=*mss_val.fp;
 	for(idx=0L;idx<sz;idx++)
-	  if(op1.fp[idx] != mss_val_flt) u32_ptr[idx]&=msk_f32_u32_one;
+	  if(op1.fp[idx] != mss_val_flt) u32_ptr[idx]|=msk_f32_u32_one;
       } /* end else */
     }else abort();
     break;
@@ -699,8 +702,9 @@ nco_ppc_bitmask /* [fnc] Mask-out insignificant bits of significand */
     /* Create mask */
     msk_f64_u64_zro=0ul; /* Zero all bits */
     msk_f64_u64_zro=~msk_f64_u64_zro; /* Turn all bits to ones */
-    /* Left shift zeros into bits to be rounded */
+    /* Bit Shave mask for AND: Left shift zeros into bits to be rounded, leave ones in untouched bits */
     msk_f64_u64_zro <<= bit_xpl_nbr_zro;
+    /* Bit Set   mask for OR:  Put ones into bits to be set, zeros in untouched bits */
     msk_f64_u64_one=~msk_f64_u64_zro;
     if(nco_baa_cnv_get() == nco_baa_grm){
       /* Bit-Groom: alternately shave and set LSBs */
@@ -728,11 +732,13 @@ nco_ppc_bitmask /* [fnc] Mask-out insignificant bits of significand */
     }else if(nco_baa_cnv_get() == nco_baa_set){
       /* Bit-Set: always set LSBs */
       if(!has_mss_val){
-	for(idx=0L;idx<sz;idx++) u64_ptr[idx]&=msk_f64_u64_one;
+	for(idx=0L;idx<sz;idx++)
+	  if(u64_ptr[idx] != 0UL) /* Never quantize upwards floating point values of zero */
+	    u64_ptr[idx]|=msk_f64_u64_one;
       }else{
 	const double mss_val_dbl=*mss_val.dp;
 	for(idx=0L;idx<sz;idx++)
-	  if(op1.dp[idx] != mss_val_dbl) u64_ptr[idx]&=msk_f64_u64_one;
+	  if(op1.dp[idx] != mss_val_dbl && u64_ptr[idx] != 0UL) u64_ptr[idx]|=msk_f64_u64_one;
       } /* end else */
     }else abort();
     break;
diff --git a/src/nco/nco_prn.c b/src/nco/nco_prn.c
index 73f8ae4..6cb9999 100644
--- a/src/nco/nco_prn.c
+++ b/src/nco/nco_prn.c
@@ -65,6 +65,8 @@ nco_prn_att /* [fnc] Print all attributes of single variable or group */
   
   nc_type var_typ;
 
+  nco_bool flg_glb=False; /* [flg] Printing attributes for root-level group */
+
   const nco_bool CDL=prn_flg->cdl; /* [flg] CDL output */
   const nco_bool XML=prn_flg->xml; /* [flg] XML output */
   const nco_bool TRD=prn_flg->trd; /* [flg] Traditional output */
@@ -83,7 +85,8 @@ nco_prn_att /* [fnc] Print all attributes of single variable or group */
     (void)nco_inq(grp_id,(int *)NULL,(int *)NULL,&att_nbr_vsb,(int *)NULL);
     /* Which group is this? */
     rcd=nco_inq_grp_parent_flg(grp_id,&grp_id_prn);
-    if(rcd == NC_ENOGRP) (void)strcpy(src_sng,(CDL) ? "" : "Global"); else (void)strcpy(src_sng,(CDL) ? "" : "Group");
+    if(rcd == NC_ENOGRP) flg_glb=True;
+    if(flg_glb) (void)strcpy(src_sng,(CDL) ? "" : "Global"); else (void)strcpy(src_sng,(CDL) ? "" : "Group");
     if(CDL) prn_ndn+=prn_flg->sxn_fst;
   }else{
     /* Get name and number of attributes for variable */
@@ -443,6 +446,8 @@ nco_prn_att /* [fnc] Print all attributes of single variable or group */
     
   } /* end loop over attributes */
 
+  /* Print extra line after global attributes */
+  if(CDL && flg_glb) (void)fprintf(stdout,"\n");
   if(!prn_flg->new_fmt && CDL_OR_TRD) (void)fprintf(stdout,"\n");
   (void)fflush(stdout);
   
@@ -1862,7 +1867,15 @@ nco_prn_var_val_trv /* [fnc] Print variable data (GTT version) */
 		/* Are units those of a calendar? */
 		unit_cln_crd=nco_cln_chk_tm(unit_sng_crd);
 		if(nco_dbg_lvl_get() == nco_dbg_crr) (void)fprintf(stdout,"%s: INFO %s reports units string \"%s\" is %sa calendar string\n",nco_prg_nm_get(),fnc_nm,unit_sng_crd,unit_cln_crd ? "" : "not " );
-
+		if(unit_cln_crd){
+#ifdef HAVE_UDUNITS2_H
+		/* 20160418: Even when UDUnits is available, the lgb software produces poor formatting and needs work so turn-off for now */
+		unit_cln_crd=False;
+#else /* !HAVE_UDUNITS2 */
+		  if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stdout,"%s: INFO %s reports units string \"%s\" is a calendar string, but UDUNITS2 not built-in, so will not attempt to print calendar dates legibly\n",nco_prg_nm_get(),fnc_nm,unit_sng_crd);
+		  unit_cln_crd=False;
+#endif /* !HAVE_UDUNITS2 */
+                } /* !unit_cln_crd */
 	      } /* end if att_typ */
 	    } /* end if rcd_lcl */
 	  } /* end if True */
diff --git a/src/nco/nco_rgr.c b/src/nco/nco_rgr.c
index 196579b..4df49b0 100644
--- a/src/nco/nco_rgr.c
+++ b/src/nco/nco_rgr.c
@@ -176,7 +176,7 @@ nco_rgr_ini /* [fnc] Initialize regridding structure */
   /* Initialize arguments after copying */
   if(!rgr->fl_out) rgr->fl_out=(char *)strdup("/data/zender/rgr/rgr_out.nc");
   if(!rgr->fl_grd_dst) rgr->fl_grd_dst=(char *)strdup("/data/zender/scrip/grids/remap_grid_T42.nc");
-  if(!rgr->var_nm) rgr->var_nm=(char *)strdup("ORO");
+  //  if(!rgr->var_nm) rgr->var_nm=(char *)strdup("ORO");
   
   if(nco_dbg_lvl_get() >= nco_dbg_crr){
     (void)fprintf(stderr,"%s: INFO %s reports ",nco_prg_nm_get(),fnc_nm);
@@ -246,11 +246,13 @@ nco_rgr_ini /* [fnc] Initialize regridding structure */
   rgr->col_nm_out=NULL; /* [sng] Name of horizontal spatial output dimension on unstructured grid */
   rgr->frc_nm=NULL; /* [sng] Name of variable containing gridcell fraction */
   rgr->lat_bnd_nm=NULL; /* [sng] Name of rectangular boundary variable for latitude */
+  rgr->lat_dmn_nm=NULL; /* [sng] Name of latitude dimension in inferred grid */
   rgr->lat_nm_in=NULL; /* [sng] Name of input dimension to recognize as latitude */
   rgr->lat_nm_out=NULL; /* [sng] Name of output dimension for latitude */
   rgr->lat_vrt_nm=NULL; /* [sng] Name of non-rectangular boundary variable for latitude */
   rgr->lat_wgt_nm=NULL; /* [sng] Name of variable containing latitude weights */
   rgr->lon_bnd_nm=NULL; /* [sng] Name of rectangular boundary variable for longitude */
+  rgr->lon_dmn_nm=NULL; /* [sng] Name of longitude dimension in inferred grid */
   rgr->lon_nm_in=NULL; /* [sng] Name of dimension to recognize as longitude */
   rgr->lon_nm_out=NULL; /* [sng] Name of output dimension for longitude */
   rgr->lon_vrt_nm=NULL; /* [sng] Name of non-rectangular boundary variable for longitude */
@@ -426,6 +428,10 @@ nco_rgr_ini /* [fnc] Initialize regridding structure */
       rgr->lat_bnd_nm=(char *)strdup(rgr_lst[rgr_var_idx].val);
       continue;
     } /* !lat_bnd_nm */
+    if(!strcasecmp(rgr_lst[rgr_var_idx].key,"lat_dmn_nm") || !strcasecmp(rgr_lst[rgr_var_idx].key,"lat_dmn")){
+      rgr->lat_dmn_nm=(char *)strdup(rgr_lst[rgr_var_idx].val);
+      continue;
+    } /* !lat_dmn_nm */
     if(!strcasecmp(rgr_lst[rgr_var_idx].key,"lat_nm_in") || !strcasecmp(rgr_lst[rgr_var_idx].key,"lat_nm")){
       rgr->lat_nm_in=(char *)strdup(rgr_lst[rgr_var_idx].val);
       continue;
@@ -446,6 +452,10 @@ nco_rgr_ini /* [fnc] Initialize regridding structure */
       rgr->lon_bnd_nm=(char *)strdup(rgr_lst[rgr_var_idx].val);
       continue;
     } /* !lon_bnd_nm */
+    if(!strcasecmp(rgr_lst[rgr_var_idx].key,"lon_dmn_nm") || !strcasecmp(rgr_lst[rgr_var_idx].key,"lon_dmn")){
+      rgr->lon_dmn_nm=(char *)strdup(rgr_lst[rgr_var_idx].val);
+      continue;
+    } /* !lon_dmn_nm */
     if(!strcasecmp(rgr_lst[rgr_var_idx].key,"lon_nm_in") || !strcasecmp(rgr_lst[rgr_var_idx].key,"lon_nm")){
       rgr->lon_nm_in=(char *)strdup(rgr_lst[rgr_var_idx].val);
       continue;
@@ -593,9 +603,12 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   int md_open; /* [enm] Mode flag for nc_open() call */
   int rcd=NC_NOERR;
 
+  int dfl_lvl=NCO_DFL_LVL_UNDEFINED; /* [enm] Deflate level */
   int dst_grid_corners_id; /* [id] Destination grid corners dimension ID */
   int dst_grid_rank_id; /* [id] Destination grid rank dimension ID */
   int dst_grid_size_id; /* [id] Destination grid size dimension ID */
+  int fl_out_fmt=NCO_FORMAT_UNDEFINED; /* [enm] Output file format */
+  int fll_md_old; /* [enm] Old fill mode */
   int num_links_id; /* [id] Number of links dimension ID */
   int num_wgts_id; /* [id] Number of weights dimension ID */
   int src_grid_corners_id; /* [id] Source grid corners dimension ID */
@@ -639,9 +652,9 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   char *att_val;
   char *cnv_sng=NULL_CEWI;
   /* netCDF standard is uppercase Conventions, though some models user lowercase */
-  char cnv_sng_UC[]="Conventions"; /* Unidata standard     string (uppercase) */
-  char cnv_sng_LC[]="conventions"; /* Unidata non-standard string (lowercase) */
-  char cnv_sng_tps[]="Title"; /* Tempest uses "Title" not "Conventions" attribute */
+  char cnv_sng_UC[]="Conventions"; /* [sng] Unidata standard     string (uppercase) */
+  char cnv_sng_LC[]="conventions"; /* [sng] Unidata non-standard string (lowercase) */
+  char cnv_sng_tps[]="Title"; /* [sng] Tempest uses "Title" not "Conventions" attribute */
   char name0_sng[]="name0"; /* [sng] Attribute where Tempest stores least-rapidly-varying dimension name */
   
   long att_sz;
@@ -909,6 +922,8 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   double *lon_crn_out=NULL; /* [dgr] Longitude corners of rectangular destination grid */
   double *lon_ctr_out=NULL_CEWI; /* [dgr] Longitude centers of rectangular destination grid */
   double *lon_ntf_out=NULL; /* [dgr] Longitude interfaces of rectangular destination grid */
+  double *slat_ctr_out=NULL_CEWI; /* [dgr] Latitude  centers of staggered FV destination grid */
+  double *slon_ctr_out=NULL_CEWI; /* [dgr] Longitude centers of staggered FV destination grid */
   double *wgt_raw; /* [frc] Remapping weights */
   int *col_src_adr; /* [idx] Source address (col) */
   int *row_dst_adr; /* [idx] Destination address (row) */
@@ -938,11 +953,11 @@ nco_rgr_map /* [fnc] Regrid with external weights */
 
   /* Check-for and workaround faulty Tempest and MPAS-O/I grid sizes */
   if(flg_grd_in_1D && (rgr_map.src_grid_size != dmn_sz_in_int[0])){
-    (void)fprintf(stdout,"%s: WARNING %s reports input grid dimension sizes disagree rgr_map.src_grid_size = %ld != %d = dmn_sz_in[0]. Problem may be caused by incorrect src_grid_dims variable. This is a known issue with some Tempest mapfiles generated prior to ~20150901, and in some ESMF mapfiles for MPAS-O/I. Attempting workaround ...\n",nco_prg_nm_get(),fnc_nm,rgr_map.src_grid_size,dmn_sz_in_int[0]);
+    (void)fprintf(stdout,"%s: INFO %s reports input grid dimension sizes disagree: rgr_map.src_grid_size = %ld != %d = dmn_sz_in[0]. Problem may be caused by incorrect src_grid_dims variable. This is a known issue with some Tempest mapfiles generated prior to ~20150901, and in some ESMF mapfiles for MPAS-O/I. This problem can be safely ignored if workaround succeeds. Attempting workaround ...\n",nco_prg_nm_get(),fnc_nm,rgr_map.src_grid_size,dmn_sz_in_int[0]);
       dmn_sz_in_int[0]=rgr_map.src_grid_size;
   } /* !bug */
   if(flg_grd_out_1D && (rgr_map.dst_grid_size != dmn_sz_out_int[0])){
-    (void)fprintf(stdout,"%s: WARNING %s reports output grid dimension sizes disagree rgr_map.dst_grid_size = %ld != %d = dmn_sz_out[0]. Problem may be caused by incorrect dst_grid_dims variable. This is a known issue with some Tempest mapfiles generated prior to ~20150901, and in some ESMF mapfiles for MPAS-O/I. Attempting workaround ...\n",nco_prg_nm_get(),fnc_nm,rgr_map.dst_grid_size,dmn_sz_out_int[0]);
+    (void)fprintf(stdout,"%s: INFO %s reports output grid dimension sizes disagree: rgr_map.dst_grid_size = %ld != %d = dmn_sz_out[0]. Problem may be caused by incorrect dst_grid_dims variable. This is a known issue with some Tempest mapfiles generated prior to ~20150901, and in some ESMF mapfiles for MPAS-O/I. This problem can be safely ignored if workaround succeeds. Attempting workaround ...\n",nco_prg_nm_get(),fnc_nm,rgr_map.dst_grid_size,dmn_sz_out_int[0]);
     dmn_sz_out_int[0]=rgr_map.dst_grid_size;
   } /* !bug */
  
@@ -968,6 +983,8 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   long col_nbr_out=long_CEWI; /* [nbr] Number of columns in destination grid */
   long lon_nbr_out=long_CEWI; /* [nbr] Number of longitudes in rectangular destination grid */
   long lat_nbr_out=long_CEWI; /* [nbr] Number of latitudes  in rectangular destination grid */
+  long slat_nbr_out=long_CEWI; /* [nbr] Number of latitudes in staggered FV grid destination grid */
+  long slon_nbr_out=long_CEWI; /* [nbr] Number of longitudes in staggered FV grid destination grid */
   if(flg_grd_out_1D){
     bnd_nbr_out=rgr_map.dst_grid_corners;
     col_nbr_out=dmn_sz_out_int[0];
@@ -979,6 +996,8 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     col_nbr_out=lat_nbr_out*lon_nbr_out;
     lat_nbr_out=dmn_sz_out_int[lat_psn_dst];
     lon_nbr_out=dmn_sz_out_int[lon_psn_dst];
+    slat_nbr_out=lat_nbr_out-1L;
+    slon_nbr_out=lon_nbr_out;
     /* Sanity-check */
     assert(lat_nbr_out*lon_nbr_out == (long)grd_sz_out);
   } /* !dst_grid_rank */
@@ -986,7 +1005,7 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   /* Ensure coordinates are in degrees not radians for simplicity and CF-compliance
      NB: ${DATA}/scrip/rmp_T42_to_POP43_conserv.nc has [xy]?_a in degrees and [xy]?_b in radians! */
   nco_bool flg_crd_rdn=False; /* [flg] Destination coordinates are in radians not degrees */
-  char unt_sng[]="units";
+  char unt_sng[]="units"; /* [sng] netCDF-standard units attribute name */
   rcd=nco_inq_att_flg(in_id,dst_grd_ctr_lat_id,unt_sng,&att_typ,&att_sz);
   if(rcd == NC_NOERR && att_typ == NC_CHAR){
     att_val=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
@@ -1235,7 +1254,7 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     double lat_ctr_tst_gss;
     /* In diagnosing grids, agreement with input to single-precision is "good enough for government work"
        Hence some comparisons cast from double to float before comparison
-       20150526: T42 grid from SCRIP and related maps are only accurate to ~eight digits
+       20150526: T42 grid from SCRIP and related maps, and NCL-generated Gaussian grids for CESM, are accurate to at most ~eight digits
        20150611: map_ne120np4_to_fv801x1600_bilin.150418.nc has yc_b[1600]=-89.775000006 not expected exact value lat_ctr[1]=-89.775000000000006 */
     if((float)lat_ctr_out[1] == (float)lat_ctr_tst_eqa) nco_grd_lat_typ=nco_grd_lat_eqa;
     if((float)lat_ctr_out[1] == (float)lat_ctr_tst_fv) nco_grd_lat_typ=nco_grd_lat_fv;
@@ -1283,6 +1302,17 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s diagnosed output longitude grid-type: %s\n",nco_prg_nm_get(),fnc_nm,nco_grd_lon_sng(nco_grd_lon_typ));
     if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s diagnosed output grid-extent: %s\n",nco_prg_nm_get(),fnc_nm,nco_grd_xtn_sng(nco_grd_xtn));
     
+    if(nco_grd_lat_typ == nco_grd_lat_fv){
+      slat_ctr_out=(double *)nco_malloc(slat_nbr_out*nco_typ_lng(crd_typ_out));
+      slon_ctr_out=(double *)nco_malloc(slon_nbr_out*nco_typ_lng(crd_typ_out));
+      for(idx=0;idx<slat_nbr_out;idx++){
+	slat_ctr_out[idx]=lat_ntf_out[idx+1];
+      } /* !lat_nbr_out */
+      for(idx=0;idx<slon_nbr_out;idx++){
+	slon_ctr_out[idx]=lon_ntf_out[idx];
+      } /* !lat_nbr_out */
+    } /* !nco_grd_lat_fv */
+
     switch(nco_grd_lat_typ){
     case nco_grd_lat_eqa:
     case nco_grd_lat_fv:
@@ -1355,7 +1385,7 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     if(flg_grd_out_rct && nco_grd_2D_typ != nco_grd_2D_unk){
       /* Mr. Enenstein and George O. Abell taught me the area of spherical zones
 	 Spherical zone area is exact and faithful to underlying rectangular equi-angular grid
-	 However, ESMF and Tempest both appear to always approximate spherical polygons as connected by great circle arcs
+	 However, ESMF and Tempest approximate spherical polygons as connected by great circle arcs
 	 fxm: Distinguish spherical zone shapes (e.g., equi-angular) from great circle arcs (e.g., unstructured polygons) */
       for(lat_idx=0;lat_idx<lat_nbr_out;lat_idx++)
 	for(lon_idx=0;lon_idx<lon_nbr_out;lon_idx++)
@@ -1371,7 +1401,7 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   } /* !tst */
 
   /* Verify frc_out is sometimes non-zero
-     ESMF: "For bilinear and patch remapping, the destination grid frac array [brac_b] is one where the grid point participates in the remapping and zero otherwise. For bilinear and patch remapping, the source grid frac array is always set to zero." */
+     ESMF: "For bilinear and patch remapping, the destination grid frac array [frac_b] is one where the grid point participates in the remapping and zero otherwise. For bilinear and patch remapping, the source grid frac array is always set to zero." */
   for(idx=0;idx<(long)grd_sz_out;idx++)
     if(frc_out[idx] != 0.0) break;
   if(idx == (long)grd_sz_out){
@@ -1407,8 +1437,8 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stdout,"%s: INFO %s reports global metadata specifies conservative remapping with normalization of type = %s. Furthermore, destination fractions frc_dst = dst_frac = frac_b = frc_out contain non-unity elements (maximum deviation from unity of %g occurs for frc_out[%ld] = %g). Thus normalization issues cannot be ignored. Will apply \'destarea\' normalization (i.e., divide by non-zero frc_out[dst_idx]) to all regridded arrays.\n",nco_p [...]
   } /* !sometimes non-unity */
   if(flg_frc_nrm && rgr->flg_rnr){
-    (void)fprintf(stdout,"%s: ERROR %s reports manual request (with --rnr) to renormalize fields with non-unity frc_dst = dst_frac = frac_b at same time global metadata specifies normalization type = %s. Normalizing twice may be an error, depending on intent of each. Call Charlie and tell him how NCO should handle this :)\n",nco_prg_nm_get(),fnc_nm,nco_rgr_nrm_sng(nco_rgr_nrm_typ));
-    nco_exit(EXIT_FAILURE);
+    (void)fprintf(stdout,"%s: WARNING %s reports manual request (with --rnr) to renormalize fields with non-unity frc_dst = dst_frac = frac_b at same time global metadata specifies normalization type = %s. Normalizing twice may be an error, depending on intent of each. Call Charlie and tell him how NCO should handle this :)\n",nco_prg_nm_get(),fnc_nm,nco_rgr_nrm_sng(nco_rgr_nrm_typ));
+    //nco_exit(EXIT_FAILURE);
   } /* !flg_rnr */
 
   /* Detailed summary of 2D grids now available including quality-checked coordinates and area */
@@ -1498,9 +1528,175 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   int dmn_id_col; /* [id] Dimension ID */
   int dmn_id_lat; /* [id] Dimension ID */
   int dmn_id_lon; /* [id] Dimension ID */
+
+  /* 20160503 Discover coordinates via CF Convention if indicated
+     This copies method used in nco_grd_nfr() */
+  /* Begin CF-coordinates block */
+  cf_crd_sct *cf=NULL;
+  char *rgr_var; /* [sng] Variable for special regridding treatment */
+  nco_bool flg_cf=False; /* [flg] Follow CF Coordinates convention to find and infer grid */
+  rgr_var=rgr->var_nm;
+  if(rgr_var){
+    /* Infer grid from special variable
+       Intended to be variable that has both horizontal dimensions and "coordinates" attribute, e.g.,
+       ncks --cdl -m ${DATA}/hdf/narrmon-a_221_20100101_0000_000.nc | grep coordinates
+       4LFTX_221_SPDY_S113:coordinates = "gridlat_221 gridlon_221" ;
+       Usage:
+       ncks -O -D 3 --rgr nfr=y --rgr_var=ALBDO_221_SFC_S113 --rgr grid=~/grd_narr.nc ${DATA}/hdf/narrmon-a_221_20100101_0000_000.nc ~/foo.nc */
+    char crd_sng[]="coordinates"; /* CF-standard coordinates attribute name */
+    
+    cf=(cf_crd_sct *)nco_malloc(sizeof(cf_crd_sct));
+    cf->crd=False; /* [flg] CF coordinates information is complete */
+    cf->crd_id[0]=NC_MIN_INT; /* [id] Coordinate ID, first */
+    cf->crd_id[1]=NC_MIN_INT; /* [id] Coordinate ID, second */
+    cf->crd_nm[0]=NULL; /* [sng] Coordinate name, first */
+    cf->crd_nm[1]=NULL; /* [sng] Coordinate name, second */
+    cf->crd_sng=NULL; /* [sng] Coordinates attribute value */
+    cf->dmn_id[0]=NC_MIN_INT; /* [id] Dimension ID, first */
+    cf->dmn_id[1]=NC_MIN_INT; /* [id] Dimension ID, second */
+    cf->dmn_nm[0]=NULL; /* [sng] Dimension name, first */
+    cf->dmn_nm[1]=NULL; /* [sng] Dimension name, second */
+    cf->unt_sng[0]=NULL; /* [sng] Units string, first coordinate */
+    cf->unt_sng[1]=NULL; /* [sng] Units string, second coordinate */
+    cf->var_id=NC_MIN_INT; /* [id] Coordinate variable ID */
+    cf->var_nm=NULL; /* [sng] Coordinates variable name */
+    cf->var_type=NC_NAT; /* [enm] Coordinates variable type */
+
+    if((rcd=nco_inq_varid_flg(in_id,rgr_var,&cf->var_id)) != NC_NOERR){
+      (void)fprintf(stderr,"%s: WARNING %s reports special \"coordinates\" variable %s not found. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,rgr_var);
+      goto skp_cf;
+    } /* !rcd */ 
+
+    rcd=nco_inq_att_flg(in_id,cf->var_id,crd_sng,&att_typ,&att_sz);
+    if(rcd == NC_NOERR && att_typ == NC_CHAR){
+      cf->crd_sng=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+      rcd+=nco_get_att(in_id,cf->var_id,crd_sng,cf->crd_sng,att_typ);
+      /* NUL-terminate attribute before using strstr() */
+      cf->crd_sng[att_sz]='\0';
+      cf->crd=True;
+    }else{ /* !rcd && att_typ */
+      (void)fprintf(stderr,"%s: WARNING %s reports coordinates variable %s does not have character-valued \"coordinates\" attribute. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,rgr_var);
+      goto skp_cf;
+    } /* !rcd && att_typ */
+      
+    /* Valid coordinates attribute requires two coordinate names separated by space character */
+    char *sbs_srt; /* [sng] Coordinate name start position */
+    char *sbs_end; /* [sng] Coordinate name   end position */
+    cf->crd_nm[0]=(char *)strdup(cf->crd_sng);
+    sbs_end=strchr(cf->crd_nm[0],' ');
+    /* NUL-terminate first coordinate name */
+    *sbs_end='\0'; 
+    sbs_srt=sbs_end+1; 
+    cf->crd_nm[1]=(char *)strdup(sbs_srt);
+
+    if((rcd=nco_inq_varid_flg(in_id,cf->crd_nm[0],&cf->crd_id[0])) != NC_NOERR){
+      (void)fprintf(stderr,"%s: WARNING %s reports first coordinates variable %s not found. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0]);
+      goto skp_cf;
+    } /* !rcd */ 
+    if((rcd=nco_inq_varid_flg(in_id,cf->crd_nm[1],&cf->crd_id[1])) != NC_NOERR){
+      (void)fprintf(stderr,"%s: WARNING %s reports second coordinates variable %s not found. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[1]);
+      goto skp_cf;
+    } /* !rcd */ 
+
+    rcd=nco_inq_att_flg(in_id,cf->crd_id[0],unt_sng,&att_typ,&att_sz);
+    if(rcd == NC_NOERR && att_typ == NC_CHAR){
+      cf->unt_sng[0]=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+      rcd=nco_get_att(in_id,cf->crd_id[0],unt_sng,cf->unt_sng[0],att_typ);
+      /* NUL-terminate attribute before using strstr() */
+      *(cf->unt_sng[0]+att_sz)='\0';
+      if(!strcasestr(cf->unt_sng[0],"degrees_")) (void)fprintf(stderr,"%s: WARNING %s reports first coordinates variable %s has weird units attribute = %s. May not detect correct ordering of latitude and longitude coordinates\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0],cf->unt_sng[0]);
+    } /* !rcd && att_typ */
+    rcd=nco_inq_att_flg(in_id,cf->crd_id[1],unt_sng,&att_typ,&att_sz);
+    if(rcd == NC_NOERR && att_typ == NC_CHAR){
+      cf->unt_sng[1]=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+      rcd=nco_get_att(in_id,cf->crd_id[1],unt_sng,cf->unt_sng[1],att_typ);
+      /* NUL-terminate attribute before using strstr() */
+      *(cf->unt_sng[1]+att_sz)='\0';
+      if(!strcasestr(cf->unt_sng[1],"degrees_")) (void)fprintf(stderr,"%s: WARNING %s reports second coordinates variable %s has weird units attribute = %s. May not detect correct ordering of latitude and longitude coordinates\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[1],cf->unt_sng[1]);
+    } /* !rcd && att_typ */
+      
+    int crd_rnk; /* [nbr] Coordinate rank */
+    rcd=nco_inq_varndims(in_id,cf->crd_id[0],&crd_rnk);
+    if(crd_rnk != 2){
+      (void)fprintf(stderr,"%s: INFO %s reports coordinates variable %s has %i dimension(s). Skipping CF coordinates method.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0],crd_rnk);
+      goto skp_cf;
+    } /* !crd_rnk */
+    rcd=nco_inq_vardimid(in_id,cf->crd_id[0],cf->dmn_id);
+    cf->dmn_nm[0]=(char *)nco_malloc(NC_MAX_NAME*sizeof(NC_CHAR));
+    cf->dmn_nm[1]=(char *)nco_malloc(NC_MAX_NAME*sizeof(NC_CHAR));
+    rcd=nco_inq_dimname(in_id,cf->dmn_id[0],cf->dmn_nm[0]);
+    rcd=nco_inq_dimname(in_id,cf->dmn_id[1],cf->dmn_nm[1]);
+    
+    /* "coordinates" convention does not guarantee lat, lon are specified in that order
+       Use "units" values, if any, to determine order
+       In absence of "units", assume order is lat, lon */ 
+    nco_bool crd0_is_lat=False; /* [flg] First coordinate is latitude */
+    nco_bool crd0_is_lon=False; /* [flg] First coordinate is longitude */
+    nco_bool crd1_is_lat=False; /* [flg] Second coordinate is latitude */
+    nco_bool crd1_is_lon=False; /* [flg] Second coordinate is longitude */
+    if(cf->unt_sng[0]){
+      if(!strcasecmp(cf->unt_sng[0],"degrees_north")) crd0_is_lat=True;
+      if(!strcasecmp(cf->unt_sng[0],"degrees_east")) crd0_is_lon=True;
+    } /* endif */      
+    if(cf->unt_sng[1]){
+      if(!strcasecmp(cf->unt_sng[1],"degrees_north")) crd1_is_lat=True;
+      if(!strcasecmp(cf->unt_sng[1],"degrees_east")) crd1_is_lon=True;
+    } /* endif */      
+    assert((crd0_is_lat && crd1_is_lon) || (crd0_is_lon && crd1_is_lat));
+    int idx_lat;
+    int idx_lon;
+    if(crd0_is_lat && crd1_is_lon){
+      idx_lat=0;
+      idx_lon=1;
+    }else{
+      idx_lat=1;
+      idx_lon=0;
+    } /* endif */
+    
+    /* Dimensions and coordinates have been vetted. Store as primary lookup names.
+       Dimensions are always returned in order [LRV,MRV]=[0,1]
+       LRV is along-track direction, and MRV is across-track (at least in NASA data)
+       Internally we label LRV as "lat" and MRV as "lon" so that code looks similar for curvilinear and rectangular grids */
+    dmn_id_lat=cf->dmn_id[0];
+    dmn_id_lon=cf->dmn_id[1];
+    /* Subtlety: lat_nm_in is coordinate (variable+dimension) name when specified from command-line (as in nco_grd_nfr()), dimension name when found through CF-method (as in nco_rgr_map()). This confusing distinction could be avoided by passing command-line dimension names through-to nco_rgr_map(). However, that route would require complex priorities for what to do when passing command-line coordinate names not dimension names and visa-versa. */
+    lat_nm_in=strdup(cf->dmn_nm[0]);
+    lon_nm_in=strdup(cf->dmn_nm[1]);
+    //lat_nm_in=strdup(cf->crd_nm[idx_lat]);
+    //lon_nm_in=strdup(cf->crd_nm[idx_lon]);
+    /* Next four lines unnecessary in nco_rgr_map() which only needs dimension names (it reads input coordinates from map- not data-file) */
+    //lat_ctr_id=cf->crd_id[idx_lat];
+    //lon_ctr_id=cf->crd_id[idx_lon];
+    //lat_dmn_nm=strdup(cf->dmn_nm[0]);
+    //lon_dmn_nm=strdup(cf->dmn_nm[1]);
+    
+    if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s reports coordinates variable %s \"coordinates\" attribute \"%s\" points to coordinates %s and %s. Latitude coordinate \"%s\" has dimensions \"%s\" and \"%s\". Longitude coordinate \"%s\" has dimensions \"%s\" and \"%s\".\n",nco_prg_nm_get(),fnc_nm,rgr_var,cf->crd_sng,cf->crd_nm[0],cf->crd_nm[1],cf->crd_nm[idx_lat],cf->dmn_nm[idx_lat],cf->dmn_nm[idx_lon],cf->crd_nm[idx_lon],cf->dmn_nm[idx_lat],cf->dmn_nm[idx_lon]);
+    if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s Coordinates %s and %s \"units\" values are \"%s\" and \"%s\", respectively.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0],cf->crd_nm[1],cf->unt_sng[0] ? cf->unt_sng[0] : "(non-existent)",cf->unt_sng[1] ? cf->unt_sng[1] : "(non-existent)");
+
+    /* Clean-up CF coordinates memory */
+    if(cf->crd_nm[0]) cf->crd_nm[0]=(char *)nco_free(cf->crd_nm[0]);
+    if(cf->crd_nm[1]) cf->crd_nm[1]=(char *)nco_free(cf->crd_nm[1]);
+    if(cf->crd_sng) cf->crd_sng=(char *)nco_free(cf->crd_sng);
+    if(cf->dmn_nm[0]) cf->dmn_nm[0]=(char *)nco_free(cf->dmn_nm[0]);
+    if(cf->dmn_nm[1]) cf->dmn_nm[1]=(char *)nco_free(cf->dmn_nm[1]);
+    if(cf->unt_sng[0]) cf->unt_sng[0]=(char *)nco_free(cf->unt_sng[0]);
+    if(cf->unt_sng[1]) cf->unt_sng[1]=(char *)nco_free(cf->unt_sng[1]);
+    //    if(foo) foo=(char *)nco_free(foo);
+  } /* !rgr_var */
+
+  /* goto skp_cf */
+ skp_cf: 
+  /* free() any abandoned cf structure now */
+  if(!flg_cf)
+    if(cf) cf=(cf_crd_sct *)nco_free(cf);
+  rcd=NC_NOERR;
+  /* End CF-coordinates block */
+
+
   if(flg_grd_in_1D){
     long col_nbr_in_dat; /* [nbr] Number of columns in input datafile */
-    if((rcd=nco_inq_dimid_flg(in_id,col_nm_in,&dmn_id_col)) == NC_NOERR) ; /* Default or command-line option worked, otherwise search usual suspects */
+    /* Check default or command-line option first, then search usual suspects */
+    if(col_nm_in && (rcd=nco_inq_dimid_flg(in_id,col_nm_in,&dmn_id_col)) == NC_NOERR) /* do nothing */; 
     else if((rcd=nco_inq_dimid_flg(in_id,"lndgrid",&dmn_id_col)) == NC_NOERR) col_nm_in=strdup("lndgrid"); /* CLM */
     else if((rcd=nco_inq_dimid_flg(in_id,"nCells",&dmn_id_col)) == NC_NOERR) col_nm_in=strdup("nCells"); /* MPAS-O/I */
     else if((rcd=nco_inq_dimid_flg(in_id,"nEdges",&dmn_id_col)) == NC_NOERR) col_nm_in=strdup("nEdges"); /* MPAS-O/I */
@@ -1517,58 +1713,56 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   } /* !1D */
   if(flg_grd_in_2D){
     long lat_nbr_in_dat; /* [nbr] Number of latitudes in input datafile */
-    rcd=nco_inq_dimid_flg(in_id,lat_nm_in,&dmn_id_lat);
-    if(rcd != NC_NOERR){
-      if((rcd=nco_inq_dimid_flg(in_id,"latitude",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("latitude");
-      else if((rcd=nco_inq_dimid_flg(in_id,"lat",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("lat");
-      else if((rcd=nco_inq_dimid_flg(in_id,"Latitude",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("Latitude");
-      else if((rcd=nco_inq_dimid_flg(in_id,"Lat",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("Lat");
-      else if((rcd=nco_inq_dimid_flg(in_id,"south_north",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("south_north");
-      else if((rcd=nco_inq_dimid_flg(in_id,"south_north_stag",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("south_north_stag");
-      else if((rcd=nco_inq_dimid_flg(in_id,"YDim:location",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("YDim:location");
-      else if((rcd=nco_inq_dimid_flg(in_id,"natrack",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("natrack");
-      else if((rcd=nco_inq_dimid_flg(in_id,"nj",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nj");
-      else if((rcd=nco_inq_dimid_flg(in_id,"nlat",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nlat");
-      else if((rcd=nco_inq_dimid_flg(in_id,"nscan",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nscan");
-      else if((rcd=nco_inq_dimid_flg(in_id,"nTimes",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nTimes");
-      else if((rcd=nco_inq_dimid_flg(in_id,"GeoTrack",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("GeoTrack");
-      else if((rcd=nco_inq_dimid_flg(in_id,"GeoTrack:L2_Standard_atmospheric&surface_product",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("GeoTrack:L2_Standard_atmospheric&surface_product");
-      else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Along_Swath:mod04",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("Cell_Along_Swath:mod04");
-      else if((rcd=nco_inq_dimid_flg(in_id,"CO_Latitude",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("CO_Latitude");
-      else{
-	(void)fprintf(stdout,"%s: ERROR %s reports unable to find latitude dimension in input file. Tried the usual suspects. HINT: Inform regridder of latitude dimension name with --rgr lat_nm=name\n",nco_prg_nm_get(),fnc_nm);
-	nco_exit(EXIT_FAILURE);
-      } /* !lat */
-    } /* !rcd */
+    if(lat_nm_in && (rcd=nco_inq_dimid_flg(in_id,lat_nm_in,&dmn_id_lat)) == NC_NOERR) /* do nothing */; 
+    else if((rcd=nco_inq_dimid_flg(in_id,"latitude",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("latitude");
+    else if((rcd=nco_inq_dimid_flg(in_id,"lat",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("lat");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Latitude",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("Latitude");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Lat",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("Lat");
+    else if((rcd=nco_inq_dimid_flg(in_id,"south_north",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("south_north");
+    else if((rcd=nco_inq_dimid_flg(in_id,"south_north_stag",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("south_north_stag");
+    else if((rcd=nco_inq_dimid_flg(in_id,"YDim:location",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("YDim:location");
+    else if((rcd=nco_inq_dimid_flg(in_id,"YDim:MOD_Grid_monthly_CMG_VI",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("YDim:MOD_Grid_monthly_CMG_VI");
+    else if((rcd=nco_inq_dimid_flg(in_id,"natrack",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("natrack");
+    else if((rcd=nco_inq_dimid_flg(in_id,"nj",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nj");
+    else if((rcd=nco_inq_dimid_flg(in_id,"nlat",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nlat");
+    else if((rcd=nco_inq_dimid_flg(in_id,"nscan",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nscan");
+    else if((rcd=nco_inq_dimid_flg(in_id,"nTimes",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("nTimes");
+    else if((rcd=nco_inq_dimid_flg(in_id,"GeoTrack",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("GeoTrack");
+    else if((rcd=nco_inq_dimid_flg(in_id,"GeoTrack:L2_Standard_atmospheric&surface_product",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("GeoTrack:L2_Standard_atmospheric&surface_product");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Along_Swath:mod04",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("Cell_Along_Swath:mod04");
+    else if((rcd=nco_inq_dimid_flg(in_id,"CO_Latitude",&dmn_id_lat)) == NC_NOERR) lat_nm_in=strdup("CO_Latitude");
+    else{
+      (void)fprintf(stdout,"%s: ERROR %s reports unable to find latitude dimension in input file. Tried the usual suspects. HINT: Inform regridder of latitude dimension name with --rgr lat_nm=name\n",nco_prg_nm_get(),fnc_nm);
+      nco_exit(EXIT_FAILURE);
+    } /* !lat */
     rcd=nco_inq_dimlen(in_id,dmn_id_lat,&lat_nbr_in_dat);
     if(lat_nbr_in != lat_nbr_in_dat){
       (void)fprintf(stdout,"%s: ERROR %s reports mapfile and data file dimension sizes disagree: mapfile lat_nbr_in = %ld != %ld = lat_nbr_in from datafile. HINT: Check that source grid (i.e., \"grid A\") used to create mapfile matches grid on which data are stored in input datafile.\n",nco_prg_nm_get(),fnc_nm,lat_nbr_in,lat_nbr_in_dat);
       nco_exit(EXIT_FAILURE);
     } /* !err */
     long lon_nbr_in_dat; /* [nbr] Number of longitudes in input datafile */
-    rcd=nco_inq_dimid_flg(in_id,lon_nm_in,&dmn_id_lon);
-    if(rcd != NC_NOERR){
-      if((rcd=nco_inq_dimid_flg(in_id,"longitude",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("longitude");
-      else if((rcd=nco_inq_dimid_flg(in_id,"lon",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("lon");
-      else if((rcd=nco_inq_dimid_flg(in_id,"Longitude",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("Longitude");
-      else if((rcd=nco_inq_dimid_flg(in_id,"Lon",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("Lon");
-      else if((rcd=nco_inq_dimid_flg(in_id,"west_east",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("west_east");
-      else if((rcd=nco_inq_dimid_flg(in_id,"west_east_stag",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("west_east_stag");
-      else if((rcd=nco_inq_dimid_flg(in_id,"XDim:location",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("XDim:location");
-      else if((rcd=nco_inq_dimid_flg(in_id,"ni",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("ni");
-      else if((rcd=nco_inq_dimid_flg(in_id,"nlon",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("nlon");
-      else if((rcd=nco_inq_dimid_flg(in_id,"npix",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("npix");
-      else if((rcd=nco_inq_dimid_flg(in_id,"npixel",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("npixel");
-      else if((rcd=nco_inq_dimid_flg(in_id,"nxtrack",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("nxtrack");
-      else if((rcd=nco_inq_dimid_flg(in_id,"nXtrack",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("nXtrack");
-      else if((rcd=nco_inq_dimid_flg(in_id,"GeoXTrack",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("GeoXTrack");
-      else if((rcd=nco_inq_dimid_flg(in_id,"GeoXTrack:L2_Standard_atmospheric&surface_product",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("GeoXTrack:L2_Standard_atmospheric&surface_product");
-      else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Across_Swath:mod04",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("Cell_Across_Swath:mod04");
-      else{
-	(void)fprintf(stdout,"%s: ERROR %s reports unable to find longitude dimension in input file. Tried the usual suspects. HINT: Inform regridder of longitude dimension name with --rgr lon_nm=name\n",nco_prg_nm_get(),fnc_nm);
-	nco_exit(EXIT_FAILURE);
-      } /* !lat */
-    } /* !rcd */
+    if(lon_nm_in && (rcd=nco_inq_dimid_flg(in_id,lon_nm_in,&dmn_id_lon)) == NC_NOERR) /* do nothing */; 
+    else if((rcd=nco_inq_dimid_flg(in_id,"longitude",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("longitude");
+    else if((rcd=nco_inq_dimid_flg(in_id,"lon",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("lon");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Longitude",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("Longitude");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Lon",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("Lon");
+    else if((rcd=nco_inq_dimid_flg(in_id,"west_east",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("west_east");
+    else if((rcd=nco_inq_dimid_flg(in_id,"west_east_stag",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("west_east_stag");
+    else if((rcd=nco_inq_dimid_flg(in_id,"XDim:location",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("XDim:location");
+    else if((rcd=nco_inq_dimid_flg(in_id,"XDim:MOD_Grid_monthly_CMG_VI",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("XDim:MOD_Grid_monthly_CMG_VI");
+    else if((rcd=nco_inq_dimid_flg(in_id,"ni",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("ni");
+    else if((rcd=nco_inq_dimid_flg(in_id,"nlon",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("nlon");
+    else if((rcd=nco_inq_dimid_flg(in_id,"npix",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("npix");
+    else if((rcd=nco_inq_dimid_flg(in_id,"npixel",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("npixel");
+    else if((rcd=nco_inq_dimid_flg(in_id,"nxtrack",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("nxtrack");
+    else if((rcd=nco_inq_dimid_flg(in_id,"nXtrack",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("nXtrack");
+    else if((rcd=nco_inq_dimid_flg(in_id,"GeoXTrack",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("GeoXTrack");
+    else if((rcd=nco_inq_dimid_flg(in_id,"GeoXTrack:L2_Standard_atmospheric&surface_product",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("GeoXTrack:L2_Standard_atmospheric&surface_product");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Across_Swath:mod04",&dmn_id_lon)) == NC_NOERR) lon_nm_in=strdup("Cell_Across_Swath:mod04");
+    else{
+      (void)fprintf(stdout,"%s: ERROR %s reports unable to find longitude dimension in input file. Tried the usual suspects. HINT: Inform regridder of longitude dimension name with --rgr lon_nm=name\n",nco_prg_nm_get(),fnc_nm);
+      nco_exit(EXIT_FAILURE);
+    } /* !lat */
     rcd=nco_inq_dimlen(in_id,dmn_id_lon,&lon_nbr_in_dat);
     if(lon_nbr_in != lon_nbr_in_dat){
       (void)fprintf(stdout,"%s: ERROR %s reports mapfile and data file dimension sizes disagree: mapfile lon_nbr_in = %ld != %ld = lon_nbr_in from datafile. HINT: Check that source grid (i.e., \"grid A\") used to create mapfile matches grid on which data are stored in input datafile.\n",nco_prg_nm_get(),fnc_nm,lon_nbr_in,lon_nbr_in_dat);
@@ -1579,11 +1773,12 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   /* Do not extract grid variables (that are also extensive variables) like lon, lat, and area
      If necessary, use remap data to diagnose them from scratch
      Other extensive variables (like counts, population) will be extracted and summed not averaged */
-  const int var_xcl_lst_nbr=37; /* [nbr] Number of objects on exclusion list */
+  const int var_xcl_lst_nbr=42; /* [nbr] Number of objects on exclusion list */
   /* Exception list source:
      AMSR: Latitude, Longitude
      CAM, CERES, CMIP5: lat, lon
      CAM, CMIP5: gw, lat_bnds, lon_bnds
+     CAM-FV: slon, slat, w_stag
      CAM-SE: area
      CICE: latt_bounds, lont_bounds, latu_bounds, lonu_bounds, TLAT, TLON, ULAT, ULON (NB: CICE uses ?LON and POP uses ?LONG)
      ESMF: gridcell_area
@@ -1593,12 +1788,13 @@ nco_rgr_map /* [fnc] Regrid with external weights */
      MLS: CO_Latitude
      MPAS-O/I: areaCell, latCell, lonCell
      NCO: lat_vertices, lon_vertices
+     OCO2: latitude_bnds, longitude_bnds
      POP: TLAT, TLONG, ULAT, ULONG  (NB: CICE uses ?LON and POP uses ?LONG) (POP does not archive spatial bounds)
      TRMM: Latitude, Longitude
      UV-CDAT regridder: bounds_lat, bounds_lon
      Unknown: XLAT_M, XLONG_M
      WRF: XLAT, XLONG */
-  const char *var_xcl_lst[]={"/area","/areaCell","/gridcell_area","/gw","/LAT","/lat","/latCell","/Latitude","/latitude","/CO_Latitude","/S1_Latitude","/TLAT","/ULAT","/XLAT","/XLAT_M","/lat_bnds","/lat_vertices","/latt_bounds","/latu_bounds","/bounds_lat","/LON","/lon","/lonCell","/Longitude","/longitude","/S1_Longitude","/TLON","/TLONG","/ULON","/ULONG","/XLONG","/XLONG_M","/lon_bnds","/lon_vertices","/lont_bounds","/lonu_bounds","/bounds_lon"};
+  const char *var_xcl_lst[]={"/area","/areaCell","/gridcell_area","/gw","/LAT","/lat","/latCell","/Latitude","/latitude","/CO_Latitude","/slat","/S1_Latitude","/TLAT","/ULAT","/XLAT","/XLAT_M","/lat_bnds","/lat_vertices","/latt_bounds","/latu_bounds","/latitude_bnds","/bounds_lat","/LON","/lon","/lonCell","/Longitude","/longitude","/slon","/S1_Longitude","/TLON","/TLONG","/ULON","/ULONG","/XLONG","/XLONG_M","/lon_bnds","/lon_vertices","/lont_bounds","/lonu_bounds","/longitude_bnds","/bou [...]
   int var_cpy_nbr=0; /* [nbr] Number of copied variables */
   int var_rgr_nbr=0; /* [nbr] Number of regridded variables */
   int var_xcl_nbr=0; /* [nbr] Number of deleted variables */
@@ -1616,7 +1812,24 @@ nco_rgr_map /* [fnc] Regrid with external weights */
       } /* endif */
       trv_tbl->lst[idx_tbl].flg_xtr=False;
     } /* endif */
-  } /* end loop */
+  } /* !idx */
+
+  if(False){
+    /* 20160228: MPAS has a host of mysterious grid and extensive variables that should probably not be regridded */
+    const int mpas_xcl_lst_nbr=18;
+    const char *mpas_xcl_lst[]={"cellMask,cellsOnCell,cellsOnEdge,cellsOnVertex,edgeMask,edgesOnCell,edgesOnEdge,edgesOnVertex,indexToCellID,indexToEdgeID,indexToVertexID,maxLevelCell,maxLevelEdgeTop,nEdgesOnCell,nEdgesOnEdge,vertexMask,verticesOnCell,verticesOnEdge"};
+    for(idx=0;idx<mpas_xcl_lst_nbr;idx++){
+      for(idx_tbl=0;idx_tbl<trv_nbr;idx_tbl++)
+	if(!strcmp(trv_tbl->lst[idx_tbl].nm_fll,mpas_xcl_lst[idx])) break;
+      if(idx_tbl < trv_nbr){
+	if(trv_tbl->lst[idx_tbl].flg_xtr){
+	  if(nco_dbg_lvl_get() >= nco_dbg_var) (void)fprintf(stdout,"%s: INFO automatically omitting (not copying or regridding from input) pre-defined exclusion-list variable %s\n",nco_prg_nm_get(),trv_tbl->lst[idx_tbl].nm_fll);
+	  var_xcl_nbr++;
+	} /* endif */
+	trv_tbl->lst[idx_tbl].flg_xtr=False;
+      } /* endif */
+    } /* !idx */
+  } /* !False */
   
   char *dmn_nm_cp; /* [sng] Dimension name as char * to reduce indirection */
   int dmn_idx; /* [idx] Dimension index */
@@ -1705,8 +1918,12 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   char *lat_wgt_nm;
   char *lon_bnd_nm_out;
   char *lon_nm_out;
+  char *slat_nm_out=NULL;
+  char *slon_nm_out=NULL;
   int dmn_id_bnd; /* [id] Dimension ID */
   int dmn_id_bnd_tm; /* [id] Dimension ID */
+  int dmn_id_slat; /* [id] Dimension ID */
+  int dmn_id_slon; /* [id] Dimension ID */
   int area_out_id; /* [id] Variable ID for area */
   int frc_out_id; /* [id] Variable ID for fraction */
   int lon_out_id; /* [id] Variable ID for longitude */
@@ -1714,6 +1931,8 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   int lat_wgt_id; /* [id] Variable ID for latitude weight */
   int lon_bnd_id; /* [id] Variable ID for lon_bnds/lon_vertices */
   int lat_bnd_id; /* [id] Variable ID for lat_bnds/lat_vertices */
+  int slat_out_id; /* [id] Variable ID for staggered latitude */
+  int slon_out_id; /* [id] Variable ID for staggered longitude */
   int dmn_ids_out[dmn_nbr_grd_max]; /* [id] Dimension IDs array for output variable */
   long dmn_srt_out[dmn_nbr_grd_max];
   long dmn_cnt_tuo[dmn_nbr_grd_max];
@@ -1740,6 +1959,10 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     lat_bnd_nm_out=rgr->lat_bnd_nm;
     lon_bnd_nm_out=rgr->lon_bnd_nm;
   } /* !flg_grd_out_2D */
+  if(nco_grd_lat_typ == nco_grd_lat_fv){
+    slat_nm_out=strdup("slat");
+    slon_nm_out=strdup("slon");
+  } /* !nco_grd_lat_fv */
 
   /* Persistent metadata */
   aed_sct aed_mtd_crd;
@@ -1761,6 +1984,10 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   if(flg_grd_out_2D){
     rcd+=nco_def_dim(out_id,lat_nm_out,lat_nbr_out,&dmn_id_lat);
     rcd+=nco_def_dim(out_id,lon_nm_out,lon_nbr_out,&dmn_id_lon);
+    if(nco_grd_lat_typ == nco_grd_lat_fv){
+      rcd+=nco_def_dim(out_id,slat_nm_out,slat_nbr_out,&dmn_id_slat);
+      rcd+=nco_def_dim(out_id,slon_nm_out,slon_nbr_out,&dmn_id_slon);
+    } /* !nco_grd_lat_fv */
   } /* !flg_grd_out_2D */
   rcd=nco_inq_dimid_flg(out_id,bnd_tm_nm_out,&dmn_id_bnd_tm);
   /* If dimension has not been defined, define it */
@@ -1779,24 +2006,37 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   nc_type var_typ_rgr; /* [enm] Variable type used during regridding */
   nco_bool PCK_ATT_CPY=True; /* [flg] Copy attributes "scale_factor", "add_offset" */
 
+  int shuffle; /* [flg] Turn-on shuffle filter */
+  int deflate; /* [flg] Turn-on deflate filter */
+  deflate=(int)True;
+  shuffle=NC_SHUFFLE;
+  dfl_lvl=rgr->dfl_lvl;
+  fl_out_fmt=rgr->fl_out_fmt;
+
   /* Define new coordinates and variables in regridded file */
   if(flg_grd_out_1D){
     rcd+=nco_def_var(out_id,lat_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_col,&lat_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     rcd+=nco_def_var(out_id,lon_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_col,&lon_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     dmn_ids_out[0]=dmn_id_col;
     dmn_ids_out[1]=dmn_id_bnd;
     rcd+=nco_def_var(out_id,lat_bnd_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&lat_bnd_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_bnd_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     dmn_ids_out[0]=dmn_id_col;
     dmn_ids_out[1]=dmn_id_bnd;
     rcd+=nco_def_var(out_id,lon_bnd_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&lon_bnd_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_bnd_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     rcd+=nco_def_var(out_id,area_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_col,&area_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     if(flg_frc_out_wrt){
       rcd+=nco_def_var(out_id,frc_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_col,&frc_out_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,frc_out_id,shuffle,deflate,dfl_lvl);
       var_crt_nbr++;
     } /* !flg_frc_out_wrt */
   } /* !flg_grd_out_1D */
@@ -1804,44 +2044,65 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     dmn_ids_out[0]=dmn_id_lat;
     dmn_ids_out[1]=dmn_id_lon;
     rcd+=nco_def_var(out_id,lat_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&lat_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     rcd+=nco_def_var(out_id,lon_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&lon_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     rcd+=nco_def_var(out_id,area_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&area_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     if(flg_frc_out_wrt){
       rcd+=nco_def_var(out_id,frc_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&frc_out_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,frc_out_id,shuffle,deflate,dfl_lvl);
       var_crt_nbr++;
     } /* !flg_frc_out_wrt */
     dmn_ids_out[0]=dmn_id_lat;
     dmn_ids_out[1]=dmn_id_lon;
     dmn_ids_out[2]=dmn_id_bnd;
     rcd+=nco_def_var(out_id,lat_bnd_nm_out,crd_typ_out,dmn_nbr_3D,dmn_ids_out,&lat_bnd_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_bnd_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     rcd+=nco_def_var(out_id,lon_bnd_nm_out,crd_typ_out,dmn_nbr_3D,dmn_ids_out,&lon_bnd_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_bnd_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
   } /* !flg_grd_out_crv */
   if(flg_grd_out_rct){
     rcd+=nco_def_var(out_id,lat_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_lat,&lat_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     rcd+=nco_def_var(out_id,lon_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_lon,&lon_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
+    if(nco_grd_lat_typ == nco_grd_lat_fv){
+      rcd+=nco_def_var(out_id,slat_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_slat,&slat_out_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,slat_out_id,shuffle,deflate,dfl_lvl);
+      var_crt_nbr++;
+      rcd+=nco_def_var(out_id,slon_nm_out,crd_typ_out,dmn_nbr_1D,&dmn_id_slon,&slon_out_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,slon_out_id,shuffle,deflate,dfl_lvl);
+      var_crt_nbr++;
+    } /* !nco_grd_lat_fv */
     dmn_ids_out[0]=dmn_id_lat;
     dmn_ids_out[1]=dmn_id_bnd;
     rcd+=nco_def_var(out_id,lat_bnd_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&lat_bnd_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_bnd_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     dmn_ids_out[0]=dmn_id_lon;
     dmn_ids_out[1]=dmn_id_bnd;
     rcd+=nco_def_var(out_id,lon_bnd_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&lon_bnd_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_bnd_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     rcd+=nco_def_var(out_id,lat_wgt_nm,crd_typ_out,dmn_nbr_1D,&dmn_id_lat,&lat_wgt_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_wgt_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     dmn_ids_out[0]=dmn_id_lat;
     dmn_ids_out[1]=dmn_id_lon;
     rcd+=nco_def_var(out_id,area_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&area_out_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_out_id,shuffle,deflate,dfl_lvl);
     var_crt_nbr++;
     if(flg_frc_out_wrt){
       rcd+=nco_def_var(out_id,frc_nm_out,crd_typ_out,dmn_nbr_2D,dmn_ids_out,&frc_out_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,frc_out_id,shuffle,deflate,dfl_lvl);
       var_crt_nbr++;
     } /* !flg_frc_out_wrt */
   } /* !flg_grd_out_rct */
@@ -1875,7 +2136,10 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     trv=trv_tbl->lst[idx_tbl];
     if(trv.nco_typ == nco_obj_typ_var && trv.flg_xtr){
       var_nm=trv.nm;
+      /* Preserve input type in output type */
       var_typ_out=trv.var_typ;
+      /* Demote DP to SP to save space. fxm: missing value type will then be inconsistent if copied without demotion */
+      //if(trv.var_typ == NC_DOUBLE) var_typ_out=NC_FLOAT; else var_typ_out=trv.var_typ;
       dmn_nbr_in=trv.nbr_dmn;
       dmn_nbr_out=trv.nbr_dmn;
       rcd=nco_inq_varid(in_id,var_nm,&var_id_in);
@@ -1983,6 +2247,23 @@ nco_rgr_map /* [fnc] Regrid with external weights */
 	  } /* !dmn_idx */
 	} /* !flg_rgr */
 	rcd=nco_def_var(out_id,var_nm,var_typ_out,dmn_nbr_out,dmn_id_out,&var_id_out);
+	/* Duplicate netCDF4 settings when possible */
+	if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC){
+	  /* Deflation */
+	  if(dmn_nbr_out > 0){
+	    int dfl_lvl_in; /* [enm] Deflate level [0..9] */
+	    rcd=nco_inq_var_deflate(in_id,var_id_in,&shuffle,&deflate,&dfl_lvl_in);
+	    /* Copy original deflation settings */
+	    if(deflate || shuffle) (void)nco_def_var_deflate(out_id,var_id_out,shuffle,deflate,dfl_lvl_in);
+	    /* Overwrite HDF Lempel-Ziv compression level, if requested */
+	    if(dfl_lvl == 0) deflate=(int)False; else deflate=(int)True;
+	    /* Turn-off shuffle when uncompressing otherwise chunking requests may fail */
+	    if(dfl_lvl == 0) shuffle=NC_NOSHUFFLE;
+	    /* Shuffle never, to my knowledge, increases filesize, so shuffle by default when manually deflating */
+	    if(dfl_lvl >= 0) shuffle=NC_SHUFFLE;
+	    if(dfl_lvl >= 0) (void)nco_def_var_deflate(out_id,var_id_out,shuffle,deflate,dfl_lvl);
+	  } /* !dmn_nbr_out */
+	} /* !NC_FORMAT_NETCDF4 */ 
 	(void)nco_att_cpy(in_id,out_id,var_id_in,var_id_out,PCK_ATT_CPY);
 	if(trv.flg_rgr){
 	  aed_mtd_crd.var_nm=var_nm;
@@ -2270,6 +2551,60 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   if(att_nm) att_nm=(char *)nco_free(att_nm);
   if(att_val) att_val=(char *)nco_free(att_val);
 
+  if(nco_grd_lat_typ == nco_grd_lat_fv){
+    att_nm=strdup("long_name");
+    att_val=strdup("latitude for staggered FV grid");
+    aed_mtd.att_nm=att_nm;
+    aed_mtd.var_nm=slat_nm_out;
+    aed_mtd.id=slat_out_id;
+    aed_mtd.sz=strlen(att_val);
+    aed_mtd.type=NC_CHAR;
+    aed_mtd.val.cp=att_val;
+    aed_mtd.mode=aed_create;
+    (void)nco_aed_prc(out_id,slat_out_id,aed_mtd);
+    if(att_nm) att_nm=(char *)nco_free(att_nm);
+    if(att_val) att_val=(char *)nco_free(att_val);
+
+    att_nm=strdup("units");
+    att_val=strdup("degrees_north");
+    aed_mtd.att_nm=att_nm;
+    aed_mtd.var_nm=slat_nm_out;
+    aed_mtd.id=slat_out_id;
+    aed_mtd.sz=strlen(att_val);
+    aed_mtd.type=NC_CHAR;
+    aed_mtd.val.cp=att_val;
+    aed_mtd.mode=aed_create;
+    (void)nco_aed_prc(out_id,slat_out_id,aed_mtd);
+    if(att_nm) att_nm=(char *)nco_free(att_nm);
+    if(att_val) att_val=(char *)nco_free(att_val);
+
+    att_nm=strdup("long_name");
+    att_val=strdup("longitude for staggered FV grid");
+    aed_mtd.att_nm=att_nm;
+    aed_mtd.var_nm=slon_nm_out;
+    aed_mtd.id=slon_out_id;
+    aed_mtd.sz=strlen(att_val);
+    aed_mtd.type=NC_CHAR;
+    aed_mtd.val.cp=att_val;
+    aed_mtd.mode=aed_create;
+    (void)nco_aed_prc(out_id,slon_out_id,aed_mtd);
+    if(att_nm) att_nm=(char *)nco_free(att_nm);
+    if(att_val) att_val=(char *)nco_free(att_val);
+
+    att_nm=strdup("units");
+    att_val=strdup("degrees_east");
+    aed_mtd.att_nm=att_nm;
+    aed_mtd.var_nm=slon_nm_out;
+    aed_mtd.id=slon_out_id;
+    aed_mtd.sz=strlen(att_val);
+    aed_mtd.type=NC_CHAR;
+    aed_mtd.val.cp=att_val;
+    aed_mtd.mode=aed_create;
+    (void)nco_aed_prc(out_id,slon_out_id,aed_mtd);
+    if(att_nm) att_nm=(char *)nco_free(att_nm);
+    if(att_val) att_val=(char *)nco_free(att_val);
+  } /* !nco_grd_lat_fv */
+
   if(flg_grd_out_2D){
     att_nm=strdup("long_name");
     att_val=strdup("latitude quadrature weights (normalized to sum to 2.0 on global grids)");
@@ -2336,6 +2671,14 @@ nco_rgr_map /* [fnc] Regrid with external weights */
   if(att_nm_crd) att_nm_crd=(char *)nco_free(att_nm_crd);
   if(att_val_crd) att_val_crd=(char *)nco_free(att_val_crd);
 
+  if(nco_grd_lat_typ == nco_grd_lat_fv){
+    if(slat_nm_out) slat_nm_out=(char *)nco_free(slat_nm_out);
+    if(slon_nm_out) slon_nm_out=(char *)nco_free(slon_nm_out);
+  } /* !nco_grd_lat_fv */
+  
+  /* Turn-off default filling behavior to enhance efficiency */
+  nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
+      
   /* Begin data mode */
   (void)nco_enddef(out_id);
 
@@ -2383,6 +2726,16 @@ nco_rgr_map /* [fnc] Regrid with external weights */
     dmn_srt_out[0]=0L;
     dmn_cnt_tuo[0]=lon_nbr_out;
     (void)nco_put_vara(out_id,lon_out_id,dmn_srt_out,dmn_cnt_tuo,lon_ctr_out,crd_typ_out);
+    if(nco_grd_lat_typ == nco_grd_lat_fv){
+      dmn_srt_out[0]=0L;
+      dmn_cnt_tuo[0]=slat_nbr_out;
+      (void)nco_put_vara(out_id,slat_out_id,dmn_srt_out,dmn_cnt_tuo,slat_ctr_out,crd_typ_out);
+      dmn_srt_out[0]=0L;
+      dmn_cnt_tuo[0]=slon_nbr_out;
+      (void)nco_put_vara(out_id,slon_out_id,dmn_srt_out,dmn_cnt_tuo,slon_ctr_out,crd_typ_out);
+      if(slat_ctr_out) slat_ctr_out=(double *)nco_free(slat_ctr_out);
+      if(slon_ctr_out) slon_ctr_out=(double *)nco_free(slon_ctr_out);
+    } /* !nco_grd_lat_fv */
     dmn_srt_out[0]=0L;
     dmn_cnt_tuo[0]=lat_nbr_out;
     (void)nco_put_vara(out_id,lat_wgt_id,dmn_srt_out,dmn_cnt_tuo,lat_wgt_out,crd_typ_out);
@@ -2711,7 +3064,7 @@ nco_rgr_map /* [fnc] Regrid with external weights */
 	       NB: Non-conservative interpolation methods (e.g., bilinear) should NOT apply this normalization (theoretically there is no danger in doing so because frc_out == 1 always for all gridcells that participate in bilinear remapping and frc_out == 0 otherwise, but still, best not to tempt the Fates)
 	       NB: Both frc_out and NCO's renormalization (below) could serve the same purpose
 	       Applying both could lead to double-normalizing by missing values!
-	       20151018: Be sure this does not occur! current this is done by only executing flg_frc_nrm block when !has_mss_val
+	       20151018: Be sure this does not occur! currently this is done by only executing flg_frc_nrm block when !has_mss_val
 	       and having a separate normalization block for has_mss_val
 	       fxm: Use better logic and more metadata information to determine code path */
 	    if(lvl_nbr == 1){
@@ -2767,6 +3120,7 @@ nco_rgr_map /* [fnc] Regrid with external weights */
 	
 #pragma omp critical
 	{ /* begin OpenMP critical */
+	  //	  rcd=nco_put_var(out_id,var_id_out,var_val_dbl_out,var_typ_rgr);
 	  rcd=nco_put_vara(out_id,var_id_out,dmn_srt,dmn_cnt_out,var_val_dbl_out,var_typ_rgr);
 	} /* end OpenMP critical */
 	
@@ -3526,20 +3880,32 @@ nco_grd_mk /* [fnc] Create SCRIP-format grid file */
      ESMF_RegridWeightGen -s ${DATA}/grids/ne120np4_pentagons.100310.nc -d ${DATA}/grids/257x512_SCRIP.20150910.nc -w ${DATA}/maps/map_ne120np4_to_fv257x512_aave.20150910.nc --method conserve
      ESMF_RegridWeightGen -s ${DATA}/grids/ne120np4_pentagons.100310.nc -d ${DATA}/grids/801x1600_SCRIP.20150910.nc -w ${DATA}/maps/map_ne120np4_to_fv801x1600_bilin.20150910.nc --method bilinear
 
-     AMWG grids:
-     ncks -O -D 1 --rgr grd_ttl='CAM FV-scalar grid 97x144 for horizontal resolution 1.9x2.5 degrees' --rgr grid=${DATA}/grids/97x144_SCRIP.20160301.nc --rgr latlon=97,144 --rgr lat_typ=cap --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
-     ncks -O -D 1 --rgr grd_ttl='CAM FV-scalar grid 193x288 for horizontal resolution 0.9x1.25 degrees' --rgr grid=${DATA}/grids/193x288_SCRIP.20160301.nc --rgr latlon=193,288 --rgr lat_typ=cap --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
-
-     AMWG maps:
-     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/97x144_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv97x144_bilin.20160301.nc --method bilinear
-     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/193x288_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv193x288_bilin.20160301.nc --method bilinear
-     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/97x144_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv97x144_aave.20160301.nc --method conserve
-     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/193x288_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv193x288_aave.20160301.nc --method conserve
-
-     ncremap -s ${DATA}/grids/ne30np4_pentagons.091226.nc -g ${DATA}/grids/97x144_SCRIP.20160301.nc -m ${DATA}/maps/map_ne30np4_to_fv97x144_bilin.20160301.nc -w tempest -a bilinear
-     ncremap -s ${DATA}/grids/ne30np4_pentagons.091226.nc -g ${DATA}/grids/193x288_SCRIP.20160301.nc -m ${DATA}/maps/map_ne30np4_to_fv193x288_bilin.20160301.nc -w tempest -a bilinear
-     ncremap -s ${DATA}/grids/ne30np4_pentagons.091226.nc -g ${DATA}/grids/97x144_SCRIP.20160301.nc -m ${DATA}/maps/map_ne30np4_to_fv97x144_aave.20160301.nc -w tempest -a conserve
-     ncremap -s ${DATA}/grids/ne30np4_pentagons.091226.nc -g ${DATA}/grids/193x288_SCRIP.20160301.nc -m ${DATA}/maps/map_ne30np4_to_fv193x288_aave.20160301.nc -w tempest -a conserve
+     AMWG grids: AMWG diagnostics (until ~2016) mis-diagnose FV grids with odd numbers of latitudes as Gaussian Grids
+     ncks -O -D 1 --rgr grd_ttl='CAM FV-scalar grid 96x144 for horizontal resolution 1.9x2.5 degrees' --rgr grid=${DATA}/grids/96x144_SCRIP.20160301.nc --rgr latlon=96,144 --rgr lat_typ=cap --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
+     ncks -O -D 1 --rgr grd_ttl='CAM FV-scalar grid 192x288 for horizontal resolution 0.9x1.25 degrees' --rgr grid=${DATA}/grids/192x288_SCRIP.20160301.nc --rgr latlon=192,288 --rgr lat_typ=cap --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
+     ncks -O -D 1 --rgr grd_ttl='CAM FV-scalar grid 128x256 for horizontal resolution 1.4x1.4 degrees' --rgr grid=${DATA}/grids/128x256_SCRIP.20160301.nc --rgr latlon=128,256 --rgr lat_typ=cap --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
+     ncks -O -D 1 --rgr grd_ttl='CAM FV-scalar grid 256x512 for horizontal resolution 0.7x0.7 degrees' --rgr grid=${DATA}/grids/256x512_SCRIP.20160301.nc --rgr latlon=256,512 --rgr lat_typ=cap --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
+     ncks -O -D 1 --rgr grd_ttl='CAM FV-scalar grid 800x1600 for horizontal resolution 0.225x0.225 degrees' --rgr grid=${DATA}/grids/800x1600_SCRIP.20160301.nc --rgr latlon=800,1600 --rgr lat_typ=cap --rgr lon_typ=Grn_ctr ~/nco/data/in.nc ~/foo.nc
+     ncks -O -D 1 --rgr grd_ttl='Equiangular grid 360x720 produced by RTM' --rgr grid=${DATA}/grids/360x720rtm_SCRIP.20160301.nc --rgr latlon=360,720 --rgr lat_typ=eqa --rgr lon_typ=180_wst ~/nco/data/in.nc ~/foo.nc
+
+     AMWG maps old method (no provenance archived):
+     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/128x256_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv128x256_aave.20160301.nc --method conserve
+     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/256x512_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv256x512_bilin.20160301.nc --method bilinear
+     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/256x512_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv256x512_aave.20160301.nc --method conserve
+     ESMF_RegridWeightGen -s ${DATA}/grids/ne30np4_pentagons.091226.nc -d ${DATA}/grids/800x1600_SCRIP.20160301.nc -w ${DATA}/maps/map_ne30np4_to_fv800x1600_bilin.20160301.nc --method bilinear
+
+     AMWG maps with ncremap (preferred method):
+     ncremap -s ${DATA}/grids/ne30np4_pentagons.091226.nc -g ${DATA}/grids/128x256_SCRIP.20160301.nc -m ${DATA}/maps/map_ne30np4_to_fv128x256_aave.20160301.nc -w esmf -a conserve
+     ncremap -s ${DATA}/grids/ne30np4_pentagons.091226.nc -g ${DATA}/grids/256x512_SCRIP.20160301.nc -m ${DATA}/maps/map_ne30np4_to_fv256x512_bilin.20160301.nc -w esmf -a bilinear
+     ncremap -s ${DATA}/grids/ne120np4_pentagons.100310.nc -g ${DATA}/grids/256x512_SCRIP.20160301.nc -m ${DATA}/maps/map_ne120np4_to_fv256x512_aave.20160301.nc -w esmf -a conserve
+     ncremap -s ${DATA}/grids/ne120np4_pentagons.100310.nc -g ${DATA}/grids/800x1600_SCRIP.20160301.nc -m ${DATA}/maps/map_ne120np4_to_fv800x1600_bilin.20160301.nc -w esmf -a bilinear
+
+     MPAS grids:
+     NCO cannot yet generate MPAS grids, but given an MPAS grid it can generate appropriate maps
+
+     MPAS maps:
+     ncremap -s ${DATA}/grids/oEC60to30.SCRIP.150729.nc -g ${DATA}/grids/t62_SCRIP.20150901.nc -m ${DATA}/maps/map_oEC60to30_to_t62_aave.20160301.nc -w esmf -a conserve
+     ncremap -s ${DATA}/grids/oEC60to30.SCRIP.150729.nc -g ${DATA}/grids/t62_SCRIP.20150901.nc -m ${DATA}/maps/map_oEC60to30_to_t62_bilin.20160301.nc -w esmf -a bilinear
 
      Regional RLL grids:
      ncks -O -D 1 --rgr grd_ttl='Equiangular grid 180x360' --rgr grid=${DATA}/sld/rgr/grd_dst.nc --rgr latlon=100,100 --rgr snwe=30.0,70.0,-120.0,-90.0 ~/nco/data/in.nc ~/foo.nc
@@ -3618,6 +3984,7 @@ nco_grd_mk /* [fnc] Create SCRIP-format grid file */
 
   int dmn_ids[dmn_nbr_grd_max]; /* [id] Dimension IDs array for output variable */
 
+  int dfl_lvl=NCO_DFL_LVL_UNDEFINED; /* [enm] Deflate level */
   int fl_out_fmt=NC_FORMAT_CLASSIC; /* [enm] Output file format */
   int out_id; /* I [id] Output netCDF file ID */
   int rcd=NC_NOERR;
@@ -3667,8 +4034,10 @@ nco_grd_mk /* [fnc] Create SCRIP-format grid file */
 
   size_t bfr_sz_hnt=NC_SIZEHINT_DEFAULT; /* [B] Buffer size hint */
 
+  dfl_lvl=rgr->dfl_lvl;
   grd_typ=rgr->grd_typ; /* [enm] Grid type */
   fl_out=rgr->fl_grd;
+  fl_out_fmt=rgr->fl_out_fmt;
   lat_typ=rgr->lat_typ; /* [enm] Latitude grid type */
   lon_typ=rgr->lon_typ; /* [enm] Longitude grid type */
   lat_nbr=rgr->lat_nbr; /* [nbr] Number of latitudes in grid */
@@ -4035,26 +4404,37 @@ nco_grd_mk /* [fnc] Create SCRIP-format grid file */
   } /* endif dbg */
 
   /* Open grid file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Define dimensions */
   rcd=nco_def_dim(out_id,grd_crn_nm,grd_crn_nbr,&dmn_id_grd_crn);
   rcd=nco_def_dim(out_id,grd_sz_nm,grd_sz_nbr,&dmn_id_grd_sz);
   rcd=nco_def_dim(out_id,grd_rnk_nm,grd_rnk_nbr,&dmn_id_grd_rnk);
   
+  int shuffle; /* [flg] Turn-on shuffle filter */
+  int deflate; /* [flg] Turn-on deflate filter */
+  deflate=(int)True;
+  shuffle=NC_SHUFFLE;
+
   /* Define variables */
-  (void)nco_def_var(out_id,dmn_sz_nm,(nc_type)NC_INT,dmn_nbr_1D,&dmn_id_grd_rnk,&dmn_sz_int_id);
+  (void)nco_def_var(out_id,dmn_sz_nm,(nc_type)NC_INT,dmn_nbr_1D,&dmn_id_grd_rnk,&dmn_sz_int_id); /* NB: Too small to deflate */
   (void)nco_def_var(out_id,grd_area_nm,(nc_type)crd_typ,dmn_nbr_1D,&dmn_id_grd_sz,&area_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_id,shuffle,deflate,dfl_lvl);
   (void)nco_def_var(out_id,msk_nm,(nc_type)NC_INT,dmn_nbr_1D,&dmn_id_grd_sz,&msk_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,msk_id,shuffle,deflate,dfl_lvl);
   (void)nco_def_var(out_id,grd_ctr_lat_nm,crd_typ,dmn_nbr_1D,&dmn_id_grd_sz,&grd_ctr_lat_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_ctr_lat_id,shuffle,deflate,dfl_lvl);
   (void)nco_def_var(out_id,grd_ctr_lon_nm,crd_typ,dmn_nbr_1D,&dmn_id_grd_sz,&grd_ctr_lon_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_ctr_lon_id,shuffle,deflate,dfl_lvl);
   dmn_ids[0]=dmn_id_grd_sz;
   dmn_ids[1]=dmn_id_grd_crn;
   (void)nco_def_var(out_id,grd_crn_lat_nm,crd_typ,dmn_nbr_2D,dmn_ids,&grd_crn_lat_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_crn_lat_id,shuffle,deflate,dfl_lvl);
   dmn_ids[0]=dmn_id_grd_sz;
   dmn_ids[1]=dmn_id_grd_crn;
   (void)nco_def_var(out_id,grd_crn_lon_nm,crd_typ,dmn_nbr_2D,dmn_ids,&grd_crn_lon_id);
-  
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_crn_lon_id,shuffle,deflate,dfl_lvl);
+
   /* Define "units" attributes */
   aed_sct aed_mtd;
   char *att_nm;
@@ -4249,7 +4629,7 @@ nco_grd_mk /* [fnc] Create SCRIP-format grid file */
     } /* !flg_grd_2D */
     
     /* Open grid file */
-    fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+    fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
     
     /* Define dimensions */
     if(flg_grd_crv){
@@ -4265,42 +4645,58 @@ nco_grd_mk /* [fnc] Create SCRIP-format grid file */
       rcd=nco_def_dim(out_id,lon_nm_out,lon_nbr,&dmn_id_lon);
     } /* !flg_grd_2D */
     
-  /* Define new coordinates and variables in regridded file */
+    /* Define new coordinates and variables in regridded file */
     if(flg_grd_1D){
       (void)nco_def_var(out_id,lat_nm_out,crd_typ,dmn_nbr_1D,&dmn_id_col,&lat_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_id,shuffle,deflate,dfl_lvl);
       (void)nco_def_var(out_id,lon_nm_out,crd_typ,dmn_nbr_1D,&dmn_id_col,&lon_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_id,shuffle,deflate,dfl_lvl);
       dmn_ids[0]=dmn_id_col;
       dmn_ids[1]=dmn_id_bnd;
       (void)nco_def_var(out_id,lat_bnd_nm,crd_typ,dmn_nbr_2D,dmn_ids,&lat_bnd_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_bnd_id,shuffle,deflate,dfl_lvl);
       dmn_ids[0]=dmn_id_col;
       dmn_ids[1]=dmn_id_bnd;
       (void)nco_def_var(out_id,lon_bnd_nm,crd_typ,dmn_nbr_2D,dmn_ids,&lon_bnd_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_bnd_id,shuffle,deflate,dfl_lvl);
       (void)nco_def_var(out_id,area_nm,crd_typ,dmn_nbr_1D,&dmn_id_col,&area_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_id,shuffle,deflate,dfl_lvl);
     } /* !flg_grd_1D */
     if(flg_grd_crv){
       dmn_ids[0]=dmn_id_lat;
       dmn_ids[1]=dmn_id_lon;
       (void)nco_def_var(out_id,lat_nm_out,crd_typ,dmn_nbr_2D,dmn_ids,&lat_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_id,shuffle,deflate,dfl_lvl);
       (void)nco_def_var(out_id,lon_nm_out,crd_typ,dmn_nbr_2D,dmn_ids,&lon_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_id,shuffle,deflate,dfl_lvl);
       (void)nco_def_var(out_id,area_nm,crd_typ,dmn_nbr_2D,dmn_ids,&area_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_id,shuffle,deflate,dfl_lvl);
       dmn_ids[0]=dmn_id_lat;
       dmn_ids[1]=dmn_id_lon;
       dmn_ids[2]=dmn_id_bnd;
       (void)nco_def_var(out_id,lat_bnd_nm,crd_typ,dmn_nbr_3D,dmn_ids,&lat_bnd_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_bnd_id,shuffle,deflate,dfl_lvl);
       (void)nco_def_var(out_id,lon_bnd_nm,crd_typ,dmn_nbr_3D,dmn_ids,&lon_bnd_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_bnd_id,shuffle,deflate,dfl_lvl);
     }else if(flg_grd_2D){
       (void)nco_def_var(out_id,lat_nm_out,crd_typ,dmn_nbr_1D,&dmn_id_lat,&lat_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_id,shuffle,deflate,dfl_lvl);
       (void)nco_def_var(out_id,lon_nm_out,crd_typ,dmn_nbr_1D,&dmn_id_lon,&lon_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_id,shuffle,deflate,dfl_lvl);
       dmn_ids[0]=dmn_id_lat;
       dmn_ids[1]=dmn_id_bnd;
       (void)nco_def_var(out_id,lat_bnd_nm,crd_typ,dmn_nbr_2D,dmn_ids,&lat_bnd_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_bnd_id,shuffle,deflate,dfl_lvl);
       dmn_ids[0]=dmn_id_lon;
       dmn_ids[1]=dmn_id_bnd;
       (void)nco_def_var(out_id,lon_bnd_nm,crd_typ,dmn_nbr_2D,dmn_ids,&lon_bnd_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lon_bnd_id,shuffle,deflate,dfl_lvl);
       (void)nco_def_var(out_id,lat_wgt_nm,crd_typ,dmn_nbr_1D,&dmn_id_lat,&lat_wgt_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,lat_wgt_id,shuffle,deflate,dfl_lvl);
       dmn_ids[0]=dmn_id_lat;
       dmn_ids[1]=dmn_id_lon;
       (void)nco_def_var(out_id,area_nm,crd_typ,dmn_nbr_2D,dmn_ids,&area_id);
+      if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_id,shuffle,deflate,dfl_lvl);
     } /* !flg_grd_2D */
     
     /* Define "units" attributes */
@@ -4515,6 +4911,8 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   const int dmn_nbr_3D=3; /* [nbr] Rank of 3-D grid variables */
   const int dmn_nbr_grd_max=dmn_nbr_3D; /* [nbr] Maximum rank of grid variables */
   const int itr_nbr_max=20; // [nbr] Maximum number of iterations
+  const int idx_ccw=0; /* [idx] Index of starting vertice for CCW check (Point A = tail side AB) */
+  const int rcr_lvl=1; /* [nbr] Recursion level (1 is top level, 2 and greater are recursed */
  
   const nc_type crd_typ=NC_DOUBLE;
 
@@ -4536,7 +4934,8 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   char grd_rnk_nm[]="grid_rank";
   char grd_sz_nm[]="grid_size";
   char msk_nm[]="grid_imask";
-  
+  char unt_sng[]="units"; /* netCDF-standard units attribute name */
+    
   double *grd_ctr_lat; /* [dgr] Latitude  centers of grid */
   double *grd_ctr_lon; /* [dgr] Longitude centers of grid */
   double *grd_crn_lat; /* [dgr] Latitude  corners of grid */
@@ -4571,6 +4970,7 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
 
   int dmn_ids[dmn_nbr_grd_max]; /* [id] Dimension IDs array for output variable */
 
+  int dfl_lvl=NCO_DFL_LVL_UNDEFINED; /* [enm] Deflate level */
   int dmn_idx; /* [idx] Dimension index */
   int fl_out_fmt=NC_FORMAT_CLASSIC; /* [enm] Output file format */
   int in_id; /* I [id] Input netCDF file ID */
@@ -4590,8 +4990,8 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   int itr_cnt; /* Iteration counter */
   int lat_rnk; /* [nbr] Rank of latitude coordinate */
   int lon_rnk; /* [nbr] Rank of longitude coordinate */
-  int lat_ctr_id; /* [id] Latitude centers of rectangular grid variable ID */
-  int lon_ctr_id; /* [id] Longitude centers of rectangular grid variable ID */
+  int lat_ctr_id=NC_MIN_INT; /* [id] Latitude centers of rectangular grid variable ID */
+  int lon_ctr_id=NC_MIN_INT; /* [id] Longitude centers of rectangular grid variable ID */
   int lat_bnd_id=NC_MIN_INT; /* [id] Latitude centers of rectangular grid variable ID */
   int lon_bnd_id=NC_MIN_INT; /* [id] Longitude centers of rectangular grid variable ID */
   int msk_id=NC_MIN_INT; /* [id] Mask variable ID */
@@ -4600,8 +5000,10 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   long dmn_srt[dmn_nbr_grd_max];
   long dmn_cnt[dmn_nbr_grd_max];
 
+  long att_sz;
   long bnd_idx;
   long bnd_nbr; /* [nbr] Number of bounds in gridcell */
+  long col_idx;
   long col_nbr; /* [nbr] Number of columns in grid */
   long crn_idx; /* [idx] Counting index for corners */
   long dmn_sz; /* [nbr] Size of current dimension */
@@ -4618,6 +5020,13 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   long lon_idx;
   long lon_nbr; /* [nbr] Number of longitudes in grid */
   
+  long int idx_crn_ll;
+  long int idx_crn_lr;
+  long int idx_crn_ur;
+  long int idx_crn_ul;
+  
+  nc_type att_typ;
+
   nco_bool FL_RTR_RMT_LCN;
   nco_bool FORCE_APPEND=False; /* Option A */
   nco_bool FORCE_OVERWRITE=True; /* Option O */
@@ -4625,11 +5034,12 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   nco_bool RAM_OPEN=False; /* [flg] Open (netCDF3-only) file(s) in RAM */
   nco_bool RM_RMT_FL_PST_PRC=True; /* Option R */
   nco_bool WRT_TMP_FL=False; /* [flg] Write output to temporary file */
+  nco_bool flg_1D_psd_rct_bnd=False; /* [flg] Unstructured input grid with pseudo-rectangular bounds */
   nco_bool flg_grd_1D=False;
   nco_bool flg_grd_2D=False;
   nco_bool flg_grd_crv=False;
   nco_bool flg_wrt_crn=True;
-  nco_bool has_mss_val_ctr;
+  nco_bool has_mss_val_ctr=False;
   nco_bool has_mss_val_msk;
 
   nco_grd_2D_typ_enm grd_typ; /* [enm] Grid-type enum */
@@ -4668,8 +5078,8 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   char *lon_bnd_nm=NULL_CEWI; /* [sng] Name of longitude boundary variable */
   int dmn_id_bnd=NC_MIN_INT; /* [id] Dimension ID for spatial bounds */
   int dmn_id_col=NC_MIN_INT; /* [id] Dimension ID for unstructured grids */
-  int dmn_id_lat; /* [id] Dimension ID */
-  int dmn_id_lon; /* [id] Dimension ID */
+  int dmn_id_lat=NC_MIN_INT; /* [id] Dimension ID */
+  int dmn_id_lon=NC_MIN_INT; /* [id] Dimension ID */
 
   /* Locate dimensions that must be present in unstructured files */
   if((rcd=nco_inq_dimid_flg(in_id,"ncol",&dmn_id_col)) == NC_NOERR) col_dmn_nm=strdup("ncol"); /* CAM */
@@ -4679,53 +5089,220 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   else if((rcd=nco_inq_dimid_flg(in_id,"sounding_id",&dmn_id_col)) == NC_NOERR) col_dmn_nm=strdup("sounding_id"); /* OCO2 */
   if(col_dmn_nm) flg_grd_1D=True;
 
+  /* Begin CF-coordinates block */
+  cf_crd_sct *cf=NULL;
+  char *rgr_var; /* [sng] Variable for special regridding treatment */
+  nco_bool flg_cf=False; /* [flg] Follow CF Coordinates convention to find and infer grid */
+  rgr_var=rgr->var_nm;
+  if(rgr_var){
+    /* Infer grid from special variable
+       Intended to be variable that has both horizontal dimensions and "coordinates" attribute, e.g.,
+       ncks --cdl -m ${DATA}/hdf/narrmon-a_221_20100101_0000_000.nc | grep coordinates
+       4LFTX_221_SPDY_S113:coordinates = "gridlat_221 gridlon_221" ;
+       Usage:
+       ncks -O -D 3 --rgr nfr=y --rgr_var=4LFTX_221_SPDY_S113 --rgr grid=~/grd_narr.nc ${DATA}/hdf/narrmon-a_221_20100101_0000_000.nc ~/foo.nc */
+    char crd_sng[]="coordinates"; /* CF-standard coordinates attribute name */
+    
+    cf=(cf_crd_sct *)nco_malloc(sizeof(cf_crd_sct));
+    cf->crd=False; /* [flg] CF coordinates information is complete */
+    cf->crd_id[0]=NC_MIN_INT; /* [id] Coordinate ID, first */
+    cf->crd_id[1]=NC_MIN_INT; /* [id] Coordinate ID, second */
+    cf->crd_nm[0]=NULL; /* [sng] Coordinate name, first */
+    cf->crd_nm[1]=NULL; /* [sng] Coordinate name, second */
+    cf->crd_sng=NULL; /* [sng] Coordinates attribute value */
+    cf->dmn_id[0]=NC_MIN_INT; /* [id] Dimension ID, first */
+    cf->dmn_id[1]=NC_MIN_INT; /* [id] Dimension ID, second */
+    cf->dmn_nm[0]=NULL; /* [sng] Dimension name, first */
+    cf->dmn_nm[1]=NULL; /* [sng] Dimension name, second */
+    cf->unt_sng[0]=NULL; /* [sng] Units string, first coordinate */
+    cf->unt_sng[1]=NULL; /* [sng] Units string, second coordinate */
+    cf->var_id=NC_MIN_INT; /* [id] Coordinate variable ID */
+    cf->var_nm=NULL; /* [sng] Coordinates variable name */
+    cf->var_type=NC_NAT; /* [enm] Coordinates variable type */
+
+    if((rcd=nco_inq_varid_flg(in_id,rgr_var,&cf->var_id)) != NC_NOERR){
+      (void)fprintf(stderr,"%s: WARNING %s reports special \"coordinates\" variable %s not found. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,rgr_var);
+      goto skp_cf;
+    } /* !rcd */ 
+
+    rcd=nco_inq_att_flg(in_id,cf->var_id,crd_sng,&att_typ,&att_sz);
+    if(rcd == NC_NOERR && att_typ == NC_CHAR){
+      cf->crd_sng=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+      rcd+=nco_get_att(in_id,cf->var_id,crd_sng,cf->crd_sng,att_typ);
+      /* NUL-terminate attribute before using strstr() */
+      cf->crd_sng[att_sz]='\0';
+      cf->crd=True;
+    }else{ /* !rcd && att_typ */
+      (void)fprintf(stderr,"%s: WARNING %s reports coordinates variable %s does not have character-valued \"coordinates\" attribute. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,rgr_var);
+      goto skp_cf;
+    } /* !rcd && att_typ */
+      
+    /* Valid coordinates attribute requires two coordinate names separated by space character */
+    char *sbs_srt; /* [sng] Coordinate name start position */
+    char *sbs_end; /* [sng] Coordinate name   end position */
+    cf->crd_nm[0]=(char *)strdup(cf->crd_sng);
+    sbs_end=strchr(cf->crd_nm[0],' ');
+    /* NUL-terminate first coordinate name */
+    *sbs_end='\0'; 
+    sbs_srt=sbs_end+1; 
+    cf->crd_nm[1]=(char *)strdup(sbs_srt);
+
+    if((rcd=nco_inq_varid_flg(in_id,cf->crd_nm[0],&cf->crd_id[0])) != NC_NOERR){
+      (void)fprintf(stderr,"%s: WARNING %s reports first coordinates variable %s not found. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0]);
+      goto skp_cf;
+    } /* !rcd */ 
+    if((rcd=nco_inq_varid_flg(in_id,cf->crd_nm[1],&cf->crd_id[1])) != NC_NOERR){
+      (void)fprintf(stderr,"%s: WARNING %s reports second coordinates variable %s not found. Turning-off CF coordinates search.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[1]);
+      goto skp_cf;
+    } /* !rcd */ 
+
+    rcd=nco_inq_att_flg(in_id,cf->crd_id[0],unt_sng,&att_typ,&att_sz);
+    if(rcd == NC_NOERR && att_typ == NC_CHAR){
+      cf->unt_sng[0]=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+      rcd=nco_get_att(in_id,cf->crd_id[0],unt_sng,cf->unt_sng[0],att_typ);
+      /* NUL-terminate attribute before using strstr() */
+      *(cf->unt_sng[0]+att_sz)='\0';
+      if(!strcasestr(cf->unt_sng[0],"degrees_")) (void)fprintf(stderr,"%s: WARNING %s reports first coordinates variable %s has weird units attribute = %s. May not detect correct ordering of latitude and longitude coordinates\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0],cf->unt_sng[0]);
+    } /* !rcd && att_typ */
+    rcd=nco_inq_att_flg(in_id,cf->crd_id[1],unt_sng,&att_typ,&att_sz);
+    if(rcd == NC_NOERR && att_typ == NC_CHAR){
+      cf->unt_sng[1]=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+      rcd=nco_get_att(in_id,cf->crd_id[1],unt_sng,cf->unt_sng[1],att_typ);
+      /* NUL-terminate attribute before using strstr() */
+      *(cf->unt_sng[1]+att_sz)='\0';
+      if(!strcasestr(cf->unt_sng[1],"degrees_")) (void)fprintf(stderr,"%s: WARNING %s reports second coordinates variable %s has weird units attribute = %s. May not detect correct ordering of latitude and longitude coordinates\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[1],cf->unt_sng[1]);
+    } /* !rcd && att_typ */
+      
+    int crd_rnk; /* [nbr] Coordinate rank */
+    rcd=nco_inq_varndims(in_id,cf->crd_id[0],&crd_rnk);
+    if(crd_rnk != 2){
+      (void)fprintf(stderr,"%s: INFO %s reports coordinates variable %s has %i dimension(s). Skipping CF coordinates method.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0],crd_rnk);
+      goto skp_cf;
+    } /* !crd_rnk */
+    rcd=nco_inq_vardimid(in_id,cf->crd_id[0],cf->dmn_id);
+    cf->dmn_nm[0]=(char *)nco_malloc(NC_MAX_NAME*sizeof(NC_CHAR));
+    cf->dmn_nm[1]=(char *)nco_malloc(NC_MAX_NAME*sizeof(NC_CHAR));
+    rcd=nco_inq_dimname(in_id,cf->dmn_id[0],cf->dmn_nm[0]);
+    rcd=nco_inq_dimname(in_id,cf->dmn_id[1],cf->dmn_nm[1]);
+    
+    /* "coordinates" convention does not guarantee lat, lon are specified in that order
+       Use "units" values, if any, to determine order
+       In absence of "units", assume order is lat, lon */ 
+    nco_bool crd0_is_lat=False; /* [flg] First coordinate is latitude */
+    nco_bool crd0_is_lon=False; /* [flg] First coordinate is longitude */
+    nco_bool crd1_is_lat=False; /* [flg] Second coordinate is latitude */
+    nco_bool crd1_is_lon=False; /* [flg] Second coordinate is longitude */
+    if(cf->unt_sng[0]){
+      if(!strcasecmp(cf->unt_sng[0],"degrees_north")) crd0_is_lat=True;
+      if(!strcasecmp(cf->unt_sng[0],"degrees_east")) crd0_is_lon=True;
+    } /* endif */      
+    if(cf->unt_sng[1]){
+      if(!strcasecmp(cf->unt_sng[1],"degrees_north")) crd1_is_lat=True;
+      if(!strcasecmp(cf->unt_sng[1],"degrees_east")) crd1_is_lon=True;
+    } /* endif */      
+    assert((crd0_is_lat && crd1_is_lon) || (crd0_is_lon && crd1_is_lat));
+    int idx_lat;
+    int idx_lon;
+    if(crd0_is_lat && crd1_is_lon){
+      idx_lat=0;
+      idx_lon=1;
+    }else{
+      idx_lat=1;
+      idx_lon=0;
+    } /* endif */
+    
+    /* Dimensions and coordinates have been vetted. Store as primary lookup names.
+       Dimensions are always returned in order [LRV,MRV]=[0,1]
+       LRV is along-track direction, and MRV is across-track (at least in NASA data)
+       Internally we label LRV as "lat" and MRV as "lon" so that code looks similar for curvilinear and rectangular grids */
+    dmn_id_lat=cf->dmn_id[0];
+    dmn_id_lon=cf->dmn_id[1];
+    /* Subtlety: lat_nm_in is coordinate (variable+dimension) name when specified from command-line (as in nco_grd_nfr()), dimension name when found through CF-method (as in nco_rgr_map()). This confusing distinction could be avoided by passing command-line dimension names through-to nco_rgr_map(). However, that route would require complex priorities for what to do when passing command-line coordinate names not dimension names and visa-versa. */
+    //lat_nm_in=strdup(cf->dmn_nm[0]);
+    //lon_nm_in=strdup(cf->dmn_nm[1]);
+    lat_nm_in=strdup(cf->crd_nm[idx_lat]);
+    lon_nm_in=strdup(cf->crd_nm[idx_lon]);
+    /* Next four lines unnecessary in nco_rgr_map() which only needs dimension names (it reads input coordinates from map- not data-file) */
+    lat_ctr_id=cf->crd_id[idx_lat];
+    lon_ctr_id=cf->crd_id[idx_lon];
+    lat_dmn_nm=strdup(cf->dmn_nm[0]);
+    lon_dmn_nm=strdup(cf->dmn_nm[1]);
+    
+    if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s reports coordinates variable %s \"coordinates\" attribute \"%s\" points to coordinates %s and %s. Latitude coordinate \"%s\" has LRV (along-track) and MRV (across-track) dimensions \"%s\" and \"%s\", respectively.\n",nco_prg_nm_get(),fnc_nm,rgr_var,cf->crd_sng,cf->crd_nm[0],cf->crd_nm[1],cf->crd_nm[idx_lat],cf->dmn_nm[0],cf->dmn_nm[1]);
+    if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s Coordinates %s and %s \"units\" values are \"%s\" and \"%s\", respectively.\n",nco_prg_nm_get(),fnc_nm,cf->crd_nm[0],cf->crd_nm[1],cf->unt_sng[0] ? cf->unt_sng[0] : "(non-existent)",cf->unt_sng[1] ? cf->unt_sng[1] : "(non-existent)");
+
+    /* Clean-up CF coordinates memory */
+    if(cf->crd_nm[0]) cf->crd_nm[0]=(char *)nco_free(cf->crd_nm[0]);
+    if(cf->crd_nm[1]) cf->crd_nm[1]=(char *)nco_free(cf->crd_nm[1]);
+    if(cf->crd_sng) cf->crd_sng=(char *)nco_free(cf->crd_sng);
+    if(cf->dmn_nm[0]) cf->dmn_nm[0]=(char *)nco_free(cf->dmn_nm[0]);
+    if(cf->dmn_nm[1]) cf->dmn_nm[1]=(char *)nco_free(cf->dmn_nm[1]);
+    if(cf->unt_sng[0]) cf->unt_sng[0]=(char *)nco_free(cf->unt_sng[0]);
+    if(cf->unt_sng[1]) cf->unt_sng[1]=(char *)nco_free(cf->unt_sng[1]);
+    //    if(foo) foo=(char *)nco_free(foo);
+  } /* !rgr_var */
+
+  /* goto skp_cf */
+ skp_cf: 
+  /* free() any abandoned cf structure now */
+  if(!flg_cf)
+    if(cf) cf=(cf_crd_sct *)nco_free(cf);
+  rcd=NC_NOERR;
+  /* End CF-coordinates block */
+  
   /* Locate dimensions that must be present in rectangular files */
-  if((rcd=nco_inq_dimid_flg(in_id,"latitude",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("latitude");
-  else if((rcd=nco_inq_dimid_flg(in_id,"lat",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("lat");
-  else if((rcd=nco_inq_dimid_flg(in_id,"Latitude",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("Latitude"); /* HIRDLS */
-  else if((rcd=nco_inq_dimid_flg(in_id,"Lat",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("Lat");
-  else if((rcd=nco_inq_dimid_flg(in_id,"CO_Latitude",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("CO_Latitude"); /* MLS */
-
-  if((rcd=nco_inq_dimid_flg(in_id,"longitude",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("longitude");
-  else if((rcd=nco_inq_dimid_flg(in_id,"lon",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("lon");
-  else if((rcd=nco_inq_dimid_flg(in_id,"Longitude",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("Longitude");
-  else if((rcd=nco_inq_dimid_flg(in_id,"Lon",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("Lon");
-  if(lat_dmn_nm && lon_dmn_nm) flg_grd_2D=True;
-
+  if(dmn_id_lat == NC_MIN_INT){
+    if(lat_dmn_nm && (rcd=nco_inq_dimid_flg(in_id,rgr->lat_dmn_nm,&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup(rgr->lat_dmn_nm);
+    else if((rcd=nco_inq_dimid_flg(in_id,"latitude",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("latitude");
+    else if((rcd=nco_inq_dimid_flg(in_id,"lat",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("lat");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Latitude",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("Latitude"); /* HIRDLS */
+    else if((rcd=nco_inq_dimid_flg(in_id,"Lat",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("Lat");
+    else if((rcd=nco_inq_dimid_flg(in_id,"CO_Latitude",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("CO_Latitude"); /* MLS */
+  } /* !dmn_id_lat */
+  
+  if(dmn_id_lon == NC_MIN_INT){
+    if(lon_dmn_nm && (rcd=nco_inq_dimid_flg(in_id,rgr->lon_dmn_nm,&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup(rgr->lon_dmn_nm);
+    else if((rcd=nco_inq_dimid_flg(in_id,"longitude",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("longitude");
+    else if((rcd=nco_inq_dimid_flg(in_id,"lon",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("lon");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Longitude",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("Longitude");
+    else if((rcd=nco_inq_dimid_flg(in_id,"Lon",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("Lon");
+  } /* !dmn_id_lon */
+  
   /* Try known curvilinear dimension names for latitude and longitude */
   if(!lat_dmn_nm || !lon_dmn_nm){
     if(!lat_dmn_nm){
       if((rcd=nco_inq_dimid_flg(in_id,"south_north",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("south_north"); /* WRF */
       else if((rcd=nco_inq_dimid_flg(in_id,"YDim:location",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("YDim:location"); /* AIRS L3 */
+      else if((rcd=nco_inq_dimid_flg(in_id,"YDim:MOD_Grid_monthly_CMG_VI",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("YDim:MOD_Grid_monthly_CMG_VI"); /* MODIS MOD13C2 */
       else if((rcd=nco_inq_dimid_flg(in_id,"nTimes",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("nTimes"); /* OMI L2 */
       else if((rcd=nco_inq_dimid_flg(in_id,"GeoTrack",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("GeoTrack"); /* AIRS L2 DAP NC */
       else if((rcd=nco_inq_dimid_flg(in_id,"GeoTrack:L2_Standard_atmospheric&surface_product",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("GeoTrack:L2_Standard_atmospheric&surface_product"); /* AIRS L2 HDF */
-      else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Along_Swath:mod04",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("Cell_Along_Swath:mod04"); /* MODIS L2 */
+      else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Along_Swath:mod04",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("Cell_Along_Swath:mod04"); /* MODIS MOD04 L2 */
       else if((rcd=nco_inq_dimid_flg(in_id,"phony_dim_0",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("phony_dim_0"); /* OMI */
       else if((rcd=nco_inq_dimid_flg(in_id,"y",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("phony_dim_0"); /* MAR */
       else if((rcd=nco_inq_dimid_flg(in_id,"lat2d",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("phony_dim_0"); /* RACMO */
       else if((rcd=nco_inq_dimid_flg(in_id,"natrack",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("natrack"); /* MODIS DeepBlue SeaWiFS L2 */
-      else if((rcd=nco_inq_dimid_flg(in_id,"nj",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("nj"); /* CICE */
+      else if((rcd=nco_inq_dimid_flg(in_id,"nj",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("nj"); /* CICE RTM */
       else if((rcd=nco_inq_dimid_flg(in_id,"nlat",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("nlat"); /* POP */
       else if((rcd=nco_inq_dimid_flg(in_id,"nscan",&dmn_id_lat)) == NC_NOERR) lat_dmn_nm=strdup("nscan"); /* AMSR, TRMM */
     } /* !lat_dmn_nm */
     if(!lon_dmn_nm){
       if((rcd=nco_inq_dimid_flg(in_id,"west_east",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("west_east"); /* WRF */
       else if((rcd=nco_inq_dimid_flg(in_id,"XDim:location",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("XDim:location"); /* AIRS L3 */
+      else if((rcd=nco_inq_dimid_flg(in_id,"XDim:MOD_Grid_monthly_CMG_VI",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("XDim:MOD_Grid_monthly_CMG_VI"); /* MODIS MOD13C2 */
       else if((rcd=nco_inq_dimid_flg(in_id,"nxtrack",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("nxtrack"); /* MODIS DeepBlue SeaWiFS L2 */
       else if((rcd=nco_inq_dimid_flg(in_id,"nXtrack",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("nXtrack"); /* OMI L2 */
       else if((rcd=nco_inq_dimid_flg(in_id,"GeoXTrack",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("GeoXTrack"); /* AIRS L2 DAP NC */
       else if((rcd=nco_inq_dimid_flg(in_id,"GeoXTrack:L2_Standard_atmospheric&surface_product",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("GeoXTrack:L2_Standard_atmospheric&surface_product"); /* AIRS L2 HDF */
-      else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Across_Swath:mod04",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("Cell_Across_Swath:mod04"); /* MODIS L2 */
+      else if((rcd=nco_inq_dimid_flg(in_id,"Cell_Across_Swath:mod04",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("Cell_Across_Swath:mod04"); /* MODIS MOD04 L2 */
       else if((rcd=nco_inq_dimid_flg(in_id,"phony_dim_1",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("phony_dim_1"); /* OMI */
       else if((rcd=nco_inq_dimid_flg(in_id,"x",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("phony_dim_1"); /* MAR */
       else if((rcd=nco_inq_dimid_flg(in_id,"lon2d",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("phony_dim_1"); /* RACMO */
-      else if((rcd=nco_inq_dimid_flg(in_id,"ni",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("ni"); /* CICE */
+      else if((rcd=nco_inq_dimid_flg(in_id,"ni",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("ni"); /* CICE RTM */
       else if((rcd=nco_inq_dimid_flg(in_id,"nlon",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("nlon"); /* POP */
       else if((rcd=nco_inq_dimid_flg(in_id,"npix",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("npix"); /* AMSR */
       else if((rcd=nco_inq_dimid_flg(in_id,"npixel",&dmn_id_lon)) == NC_NOERR) lon_dmn_nm=strdup("npixel"); /* TRMM */
     } /* !lon_dmn_nm */
-    if(lat_dmn_nm && lon_dmn_nm) flg_grd_crv=True;
   } /* !lat_dmn_nm */
 
   if(!(lat_dmn_nm && lon_dmn_nm) && !col_dmn_nm){
@@ -4746,33 +5323,41 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
      Currently these variables must be in root group
      This fails for, e.g., OMI L2 which has coordinates /GEOLOCATION_DATA/[Latitude,Longitude]
      fxm: Generalize with traversal table so usual suspect coordinates may be in any group */
-  if((rcd=nco_inq_varid_flg(in_id,"latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("latitude");
-  else if((rcd=nco_inq_varid_flg(in_id,"Latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("Latitude"); /* AMSR, HIRDLS, TRMM */
-  else if((rcd=nco_inq_varid_flg(in_id,"lat",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("lat"); /* CAM */
-  else if((rcd=nco_inq_varid_flg(in_id,"Lat",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("Lat");
-  else if((rcd=nco_inq_varid_flg(in_id,"XLAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("XLAT"); /* WRF */
-  else if((rcd=nco_inq_varid_flg(in_id,"XLAT_M",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("XLAT_M"); /* Unknown */
-  else if((rcd=nco_inq_varid_flg(in_id,"LAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("LAT"); /* MAR */
-  else if((rcd=nco_inq_varid_flg(in_id,"TLAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("TLAT"); /* CICE, POP */
-  else if((rcd=nco_inq_varid_flg(in_id,"CO_Latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("CO_Latitude"); /* MLS */
-  else if((rcd=nco_inq_varid_flg(in_id,"S1_Latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("S1_Latitude"); /* GPM */
-  else if((rcd=nco_inq_varid_flg(in_id,"ULAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("ULAT"); /* CICE, POP */
-  else if((rcd=nco_inq_varid_flg(in_id,"latCell",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("latCell"); /* MPAS-O/I */
-
-  if((rcd=nco_inq_varid_flg(in_id,"longitude",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("longitude");
-  else if((rcd=nco_inq_varid_flg(in_id,"Longitude",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("Longitude"); /* AMSR, TRMM */
-  else if((rcd=nco_inq_varid_flg(in_id,"lon",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("lon"); /* CAM */
-  else if((rcd=nco_inq_varid_flg(in_id,"Lon",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("Lon");
-  else if((rcd=nco_inq_varid_flg(in_id,"XLONG",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("XLONG"); /* WRF */
-  else if((rcd=nco_inq_varid_flg(in_id,"XLONG_M",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("XLONG_M"); /* Unknown */
-  else if((rcd=nco_inq_varid_flg(in_id,"LON",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("LON"); /* MAR */
-  else if((rcd=nco_inq_varid_flg(in_id,"S1_Longitude",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("S1_Longitude"); /* GPM */
-  else if((rcd=nco_inq_varid_flg(in_id,"TLON",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("TLON"); /* CICE */
-  else if((rcd=nco_inq_varid_flg(in_id,"TLONG",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("TLONG"); /* POP */
-  else if((rcd=nco_inq_varid_flg(in_id,"ULON",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("ULON"); /* CICE */
-  else if((rcd=nco_inq_varid_flg(in_id,"ULONG",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("ULONG"); /* POP */
-  else if((rcd=nco_inq_varid_flg(in_id,"lonCell",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("lonCell"); /* MPAS-O/I */
-
+  if(lat_ctr_id == NC_MIN_INT){
+    if(rgr->lat_nm_in && (rcd=nco_inq_dimid_flg(in_id,rgr->lat_nm_in,&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup(rgr->lat_nm_in);
+    else if((rcd=nco_inq_varid_flg(in_id,"latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("latitude");
+    else if((rcd=nco_inq_varid_flg(in_id,"Latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("Latitude"); /* AMSR, HIRDLS, TRMM */
+    else if((rcd=nco_inq_varid_flg(in_id,"lat",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("lat"); /* CAM */
+    else if((rcd=nco_inq_varid_flg(in_id,"Lat",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("Lat");
+    else if((rcd=nco_inq_varid_flg(in_id,"XLAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("XLAT"); /* WRF */
+    else if((rcd=nco_inq_varid_flg(in_id,"XLAT_M",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("XLAT_M"); /* Unknown */
+    else if((rcd=nco_inq_varid_flg(in_id,"LAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("LAT"); /* MAR */
+    else if((rcd=nco_inq_varid_flg(in_id,"TLAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("TLAT"); /* CICE, POP */
+    else if((rcd=nco_inq_varid_flg(in_id,"CO_Latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("CO_Latitude"); /* MLS */
+    else if((rcd=nco_inq_varid_flg(in_id,"S1_Latitude",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("S1_Latitude"); /* GPM */
+    else if((rcd=nco_inq_varid_flg(in_id,"ULAT",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("ULAT"); /* CICE, POP */
+    else if((rcd=nco_inq_varid_flg(in_id,"latCell",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("latCell"); /* MPAS-O/I */
+    else if((rcd=nco_inq_varid_flg(in_id,"yc",&lat_ctr_id)) == NC_NOERR) lat_nm_in=strdup("yc"); /* RTM */
+  } /* !lat_ctr_id */
+  
+  if(lon_ctr_id == NC_MIN_INT){
+    if(rgr->lon_nm_in && (rcd=nco_inq_dimid_flg(in_id,rgr->lon_nm_in,&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup(rgr->lon_nm_in);
+    else if((rcd=nco_inq_varid_flg(in_id,"longitude",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("longitude");
+    else if((rcd=nco_inq_varid_flg(in_id,"Longitude",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("Longitude"); /* AMSR, TRMM */
+    else if((rcd=nco_inq_varid_flg(in_id,"lon",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("lon"); /* CAM */
+    else if((rcd=nco_inq_varid_flg(in_id,"Lon",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("Lon");
+    else if((rcd=nco_inq_varid_flg(in_id,"XLONG",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("XLONG"); /* WRF */
+    else if((rcd=nco_inq_varid_flg(in_id,"XLONG_M",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("XLONG_M"); /* Unknown */
+    else if((rcd=nco_inq_varid_flg(in_id,"LON",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("LON"); /* MAR */
+    else if((rcd=nco_inq_varid_flg(in_id,"S1_Longitude",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("S1_Longitude"); /* GPM */
+    else if((rcd=nco_inq_varid_flg(in_id,"TLON",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("TLON"); /* CICE */
+    else if((rcd=nco_inq_varid_flg(in_id,"TLONG",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("TLONG"); /* POP */
+    else if((rcd=nco_inq_varid_flg(in_id,"ULON",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("ULON"); /* CICE */
+    else if((rcd=nco_inq_varid_flg(in_id,"ULONG",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("ULONG"); /* POP */
+    else if((rcd=nco_inq_varid_flg(in_id,"lonCell",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("lonCell"); /* MPAS-O/I */
+    else if((rcd=nco_inq_varid_flg(in_id,"xc",&lon_ctr_id)) == NC_NOERR) lon_nm_in=strdup("xc"); /* RTM */
+  } /* !lon_ctr_id */
+  
   if(!lat_nm_in || !lon_nm_in){
     (void)fprintf(stdout,"%s: ERROR %s unable to identify latitude and/or longitude variable.\n",nco_prg_nm_get(),fnc_nm);
     nco_exit(EXIT_FAILURE);
@@ -4793,6 +5378,10 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   /* Rank of coordinates determines whether grid is curvilinear */
   rcd+=nco_inq_varndims(in_id,lat_ctr_id,&lat_rnk);
   rcd+=nco_inq_varndims(in_id,lon_ctr_id,&lon_rnk);
+  if(lat_rnk*lon_rnk == 1 && dmn_id_lat != NC_MIN_INT && dmn_id_lon != NC_MIN_INT){
+    flg_grd_crv=False;
+    flg_grd_2D=True;
+  } /* !lat_rnk */
   if(lat_rnk == dmn_nbr_2D || lon_rnk == dmn_nbr_2D){
     flg_grd_crv=True;
     flg_grd_2D=False;
@@ -4821,6 +5410,15 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
 	 By default do not write grid corner values */
       grd_crn_nbr=4;
     } /* !dmn_id_bnd */
+    if(bnd_nbr == 2){
+      /* Unstructured grids with bounds information (e.g., OCO2) may use a pseudo-rectangular convention of archiving
+	 latitude and longitude bounds as 2xN (rather than 4XN) arrays even though cell have four corners.
+	 "convention" is that two latitudes and two longitudes can specify rectangular boundary cell
+	 In this case, bnd_nbr=grd_crn_nbr=2=sizeof(nv)=sizeof(nvertices) currently
+	 Set number of corners to rectangular and leave bnd_nbr as is */
+      grd_crn_nbr=4;
+      flg_1D_psd_rct_bnd=True;
+    } /* !bnd_nbr */
   }else if(flg_grd_2D){ /* !flg_grd_1D */
     /* Assume 2D grid of uninitialized type */
     grd_rnk_nbr=dmn_nbr_2D;
@@ -4853,12 +5451,12 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   msk=(int *)nco_malloc(grd_sz_nbr*nco_typ_lng((nc_type)NC_INT));
   
   if(flg_grd_1D){
-    lat_bnd=(double *)nco_malloc(grd_sz_nbr*grd_crn_nbr*nco_typ_lng(crd_typ));
+    lat_bnd=(double *)nco_malloc(grd_sz_nbr*bnd_nbr*nco_typ_lng(crd_typ));
     lat_crn=(double *)nco_malloc(grd_sz_nbr*grd_crn_nbr*nco_typ_lng(crd_typ));
     lat_ctr=(double *)nco_malloc(grd_sz_nbr*nco_typ_lng(crd_typ));
     lat_ntf=(double *)nco_malloc((lat_nbr+1L)*nco_typ_lng(crd_typ));
     lat_wgt=(double *)nco_malloc(lat_nbr*nco_typ_lng(crd_typ));
-    lon_bnd=(double *)nco_malloc(grd_sz_nbr*grd_crn_nbr*nco_typ_lng(crd_typ));
+    lon_bnd=(double *)nco_malloc(grd_sz_nbr*bnd_nbr*nco_typ_lng(crd_typ));
     lon_crn=(double *)nco_malloc(grd_sz_nbr*grd_crn_nbr*nco_typ_lng(crd_typ));
     lon_ctr=(double *)nco_malloc(grd_sz_nbr*nco_typ_lng(crd_typ));
     lon_ntf=(double *)nco_malloc((lon_nbr+1L)*nco_typ_lng(crd_typ));
@@ -4895,11 +5493,13 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   else if((rcd=nco_inq_varid_flg(in_id,"latu_bounds",&lat_bnd_id)) == NC_NOERR) lat_bnd_nm=strdup("latu_bounds");
   else if((rcd=nco_inq_varid_flg(in_id,"lat_ntf",&lat_bnd_id)) == NC_NOERR) lat_bnd_nm=strdup("lat_ntf");
   else if((rcd=nco_inq_varid_flg(in_id,"lat_vertices",&lat_bnd_id)) == NC_NOERR) lat_bnd_nm=strdup("lat_vertices");
+  else if((rcd=nco_inq_varid_flg(in_id,"latitude_bnds",&lat_bnd_id)) == NC_NOERR) lat_bnd_nm=strdup("latitude_bnds"); /* OCO2 */
   if((rcd=nco_inq_varid_flg(in_id,"lon_bnds",&lon_bnd_id)) == NC_NOERR) lon_bnd_nm=strdup("lon_bnds");
   else if((rcd=nco_inq_varid_flg(in_id,"lont_bounds",&lon_bnd_id)) == NC_NOERR) lon_bnd_nm=strdup("lont_bounds");
   else if((rcd=nco_inq_varid_flg(in_id,"lonu_bounds",&lon_bnd_id)) == NC_NOERR) lon_bnd_nm=strdup("lonu_bounds");
   else if((rcd=nco_inq_varid_flg(in_id,"lon_ntf",&lon_bnd_id)) == NC_NOERR) lon_bnd_nm=strdup("lon_ntf");
   else if((rcd=nco_inq_varid_flg(in_id,"lon_vertices",&lon_bnd_id)) == NC_NOERR) lon_bnd_nm=strdup("lon_vertices");
+  else if((rcd=nco_inq_varid_flg(in_id,"longitude_bnds",&lon_bnd_id)) == NC_NOERR) lon_bnd_nm=strdup("longitude_bnds"); /* OCO2 */
 
   if((rcd=nco_inq_varid_flg(in_id,"area",&area_id)) == NC_NOERR) area_nm_in=strdup("area");
   else if((rcd=nco_inq_varid_flg(in_id,"Area",&area_id)) == NC_NOERR) area_nm_in=strdup("Area");
@@ -4921,6 +5521,11 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
     msk_unn.vp=(void *)nco_malloc(grd_sz_nbr*nco_typ_lng(msk_typ));
   } /* !msk */
 
+  /* All grids: 
+     Some real-world datasets violate convention that coordinates ought never have missing values 
+     CICE lists missing value for lat/lon_ctr arrays (TLAT, TLONG) and re-uses that for bounds arrays */
+  has_mss_val_ctr=nco_mss_val_get_dbl(in_id,lat_ctr_id,&mss_val_ctr_dbl);
+
   if(flg_grd_1D){
     /* Obtain fields that must be present in unstructured input file */
     dmn_srt[0]=0L;
@@ -4933,9 +5538,15 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
     if(msk_id != NC_MIN_INT)  rcd=nco_get_vara(in_id,msk_id,dmn_srt,dmn_cnt,msk_unn.vp,msk_typ);
     dmn_srt[0]=dmn_srt[1]=0L;
     dmn_cnt[0]=col_nbr;
-    dmn_cnt[1]=grd_crn_nbr;
-    if(lat_bnd_id != NC_MIN_INT) rcd=nco_get_vara(in_id,lat_bnd_id,dmn_srt,dmn_cnt,lat_crn,crd_typ);
-    if(lon_bnd_id != NC_MIN_INT) rcd=nco_get_vara(in_id,lon_bnd_id,dmn_srt,dmn_cnt,lon_crn,crd_typ);
+    if(flg_1D_psd_rct_bnd){
+      dmn_cnt[1]=bnd_nbr;
+      if(lat_bnd_id != NC_MIN_INT) rcd=nco_get_vara(in_id,lat_bnd_id,dmn_srt,dmn_cnt,lat_bnd,crd_typ);
+      if(lon_bnd_id != NC_MIN_INT) rcd=nco_get_vara(in_id,lon_bnd_id,dmn_srt,dmn_cnt,lon_bnd,crd_typ);
+    }else{
+      dmn_cnt[1]=grd_crn_nbr;
+      if(lat_bnd_id != NC_MIN_INT) rcd=nco_get_vara(in_id,lat_bnd_id,dmn_srt,dmn_cnt,lat_crn,crd_typ);
+      if(lon_bnd_id != NC_MIN_INT) rcd=nco_get_vara(in_id,lon_bnd_id,dmn_srt,dmn_cnt,lon_crn,crd_typ);
+    } /* !flg_1D_psd_rct_bnd */
   } /* !flg_grd_1D */
 
   if(flg_grd_crv){
@@ -4945,8 +5556,6 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
     dmn_cnt[1]=lon_nbr;
     rcd=nco_get_vara(in_id,lat_ctr_id,dmn_srt,dmn_cnt,lat_ctr,crd_typ);
     rcd=nco_get_vara(in_id,lon_ctr_id,dmn_srt,dmn_cnt,lon_ctr,crd_typ);
-    /* CICE lists missing value for lat/lon_ctr arrays (TLAT, TLONG) and re-uses that for bounds arrays */
-    has_mss_val_ctr=nco_mss_val_get_dbl(in_id,lat_ctr_id,&mss_val_ctr_dbl);
     
     /* 20150923: Also input, if present in curvilinear file, corners, area, and mask
        area and mask are same size as lat and lon */
@@ -5041,7 +5650,9 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
 
   /* Above this line, fl_in and in_id refer to input file to be regridded
      Below this line, fl_out and out_id refer to grid-file to be output */
+  dfl_lvl=rgr->dfl_lvl;
   fl_out=rgr->fl_grd;
+  fl_out_fmt=rgr->fl_out_fmt;
 
   /* Define output variable values */
   int lon_psn; /* [idx] Ordinal position of longitude size in rectangular grid */
@@ -5061,10 +5672,6 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   if(flg_grd_crv){
     /* For curvilinear grids first, if necessary, infer corner boundaries
        Then perform sanity check using same code on inferred and copied grids */
-    long int idx_crn_ll;
-    long int idx_crn_lr;
-    long int idx_crn_ur;
-    long int idx_crn_ul;
     
     if(lat_bnd_id == NC_MIN_INT && lon_bnd_id == NC_MIN_INT){
       /* Interfaces (ntf) and boundaries (bnd) for curvilinear grids are ill-defined since sides need not follow latitudes nor meridians 
@@ -5151,8 +5758,6 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
 	(void)fprintf(stderr,"%s: INFO %s idx_dbg = %li, Fake Center [lat,lon]=[%g,%g]\n",nco_prg_nm_get(),fnc_nm,idx_dbg,lat_ctr_fk[idx_dbg],lon_ctr_fk[idx_dbg]);
       } /* !dbg */
       
-      const int idx_ccw=0; /* [idx] Index of starting vertice for CCW check (Point A = tail side AB) */
-      const int rcr_lvl=1; /* [nbr] Recursion level */
       long int lat_idx_fk; /* [idx] Index into fake (extrapolated) latitude  array */
       long int lon_idx_fk; /* [idx] Index into fake (extrapolated) longitude array */
       long int idx_fk_crn_ll_ctr_ll;
@@ -5212,19 +5817,8 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
 	  idx_fk_crn_ul_ctr_ul=idx_fk+(lon_nbr+2)-1; // (lat_idx+1)*lon_nbr+lon_idx-1;
 	  
 	  /* 20160111: Algorithm requires that all longitudes in template be on same "branch cut"
-	     If, say, LL longitude is 179.0 and LR longitude is -179.0 then their sum and average are zero, not 180.0 or -180.0 as desired */
-	  crn_lat[0]=lat_ctr_fk[idx_fk_crn_ll_ctr_ll];
-	  crn_lat[1]=lat_ctr_fk[idx_fk_crn_ll_ctr_lr];
-	  crn_lat[2]=lat_ctr_fk[idx_fk_crn_ll_ctr_ur];
-	  crn_lat[3]=lat_ctr_fk[idx_fk_crn_ll_ctr_ul];
-	  crn_lon[0]=lon_ctr_fk[idx_fk_crn_ll_ctr_ll];
-	  crn_lon[1]=lon_ctr_fk[idx_fk_crn_ll_ctr_lr];
-	  crn_lon[2]=lon_ctr_fk[idx_fk_crn_ll_ctr_ur];
-	  crn_lon[3]=lon_ctr_fk[idx_fk_crn_ll_ctr_ul];
-	  //	  flg_ccw=nco_ccw_chk(crn_lat,crn_lon,grd_crn_nbr,idx_ccw,rcr_lvl);
-
-	  //	  if(flg_ccw) nco_crn2ctr(crn_lat,crn_lon,crn_nbr,lat_crn+idx_crn_ll,lon_crn+idx_crn_ll);
-
+	     If, say, LL longitude is 179.0 and LR longitude is -179.0 then their sum and average are zero, not 180.0 or -180.0 as desired
+	     Routines labeled "*_brnch" in the following ensure that branch-cut rules are followed */
 	  idx_crn_ll=grd_crn_nbr*idx_rl+0;
 	  lat_crn[idx_crn_ll]=0.25*(lat_ctr_fk[idx_fk_crn_ll_ctr_ll]+lat_ctr_fk[idx_fk_crn_ll_ctr_lr]+lat_ctr_fk[idx_fk_crn_ll_ctr_ur]+lat_ctr_fk[idx_fk_crn_ll_ctr_ul]);
 	  lon_crn[idx_crn_ll]=nco_lon_crn_avg_brnch(lon_ctr_fk[idx_fk_crn_ll_ctr_ll],lon_ctr_fk[idx_fk_crn_ll_ctr_lr],lon_ctr_fk[idx_fk_crn_ll_ctr_ur],lon_ctr_fk[idx_fk_crn_ll_ctr_ul]);
@@ -5265,8 +5859,54 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
       if(crn_lat) crn_lat=(double *)nco_free(crn_lat);
     } /* !(lat_bnd_id && lon_bnd_id) */
     
-    /* As of 20151205, use same sanity check for both inferred and copied curvilinear grids
-       20151129: Above extrapolation technique yields corners outside [-90.0,90.0], [-180.0,360.0]
+  } /* !flg_grd_crv */
+
+  if(flg_1D_psd_rct_bnd){
+    double lon_brnch_min;
+    double lon_brnch_max;
+    double lon_dff;
+    assert(grd_crn_nbr == 4);
+    /* Make boundaries that were provided as pseudo-rectangular branch-cut-compliant */
+    for(col_idx=0;col_idx<col_nbr;col_idx++){
+      lon_brnch_min=(lon_bnd[2*col_idx] <= lon_bnd[2*col_idx+1]) ? lon_bnd[2*col_idx] : lon_bnd[2*col_idx+1];
+      lon_brnch_max=(lon_bnd[2*col_idx] >= lon_bnd[2*col_idx+1]) ? lon_bnd[2*col_idx] : lon_bnd[2*col_idx+1];
+      lon_dff=lon_brnch_max-lon_brnch_min;
+      if(lon_dff >= 180.0){
+	if(nco_dbg_lvl_get() >= nco_dbg_crr) (void)fprintf(stdout,"%s: INFO %s reports 1D pseudo-rectangular bounds branch-cut straddle at col_idx=%ld lon_brnch_max, lon_brnch_min, lon_dff = %g, %g, %g\n",nco_prg_nm_get(),fnc_nm,col_idx,lon_brnch_max,lon_brnch_min,lon_dff);
+	lon_brnch_max-=360.0;
+      }else if(lon_dff <= -180.0){
+	lon_brnch_max+=360.0;
+      } /* !lon_dff */
+      /* Extra condition to convert CW bounds to CCW bounds (necessary for OCO2) */
+      if(lon_brnch_min <= lon_brnch_max){
+	lon_bnd[2*col_idx]=lon_brnch_min;
+	lon_bnd[2*col_idx+1]=lon_brnch_max;
+      }else{
+	lon_bnd[2*col_idx]=lon_brnch_max;
+	lon_bnd[2*col_idx+1]=lon_brnch_min;
+      } /* end else */
+    } /* !col_idx */
+    /* Convert boundaries that were provided as pseudo-rectangular to corners */
+    for(col_idx=0;col_idx<col_nbr;col_idx++){
+      idx=grd_crn_nbr*col_idx;
+      /* fxm: OCO2 provides boundaries in CW not CCW orientation */
+      lon_crn[idx]=lon_bnd[2*col_idx]; /* LL */
+      lon_crn[idx+1]=lon_bnd[2*col_idx+1]; /* LR */
+      lon_crn[idx+2]=lon_bnd[2*col_idx+1]; /* UR */
+      lon_crn[idx+3]=lon_bnd[2*col_idx]; /* UL */
+      lat_crn[idx]=lat_bnd[2*col_idx]; /* LL */
+      lat_crn[idx+1]=lat_bnd[2*col_idx]; /* LR */
+      lat_crn[idx+2]=lat_bnd[2*col_idx+1]; /* UR */
+      lat_crn[idx+3]=lat_bnd[2*col_idx+1]; /* UL */
+      /* fxm: OCO2 provides boundaries in CW not CCW orientation */
+    } /* !col_idx */
+  } /* flg_1D_psd_rct_bnd */
+
+  if(flg_grd_crv || flg_1D_psd_rct_bnd){
+    /* As of 20160308, use same sanity check for 1D pseudo-rectangular grids as for curvilinear grids
+       Pseudo-rectangular grids rely on user-produced boundaries which may be psychotic (CW, non-branch-cut)
+       Starting 20151205, use same sanity check for both inferred and copied curvilinear grids
+       20151129: Curvilinear extrapolation technique above yields corners outside [-90.0,90.0], [-180.0,360.0]
        Also, it may assume input is ascending swath and fail for descending swaths
        Complications not fully addressed:
        Swaths may (verify this) turn from ascending to descending, or visa-versa, when satellite crosses latitude extrema
@@ -5291,6 +5931,8 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
       lon_min_min=-180.0;
       lon_max_max=180.0;
     } /* !NCO_LON_0_TO_360 */
+
+    /* Correct for extrapolation outside boundaries */
     for(idx=0;idx<grd_sz_nbr*grd_crn_nbr;idx++){
       idx_ctr=idx/grd_crn_nbr;
       if(has_mss_val_ctr)
@@ -5301,7 +5943,7 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
 	  idx_crn_lr=grd_crn_nbr*idx_ctr+1;
 	  idx_crn_ur=grd_crn_nbr*idx_ctr+2;
 	  idx_crn_ul=grd_crn_nbr*idx_ctr+3;
-	  if(nco_dbg_lvl_get() >= nco_dbg_crr) (void)fprintf(stderr,"%s: INFO %s Curvilinear corner issue (from %s corners) at idx = %li, Center [lat,lon]=[%g,%g]; Corners LL [%g,%g] LR [%g,%g] UR [%g,%g] UL [%g,%g]\n",nco_prg_nm_get(),fnc_nm,(lat_bnd_id == NC_MIN_INT) ? "inferred" : "copied",idx_ctr,lat_ctr[idx_ctr],lon_ctr[idx_ctr],lat_crn[idx_crn_ll],lon_crn[idx_crn_ll],lat_crn[idx_crn_lr],lon_crn[idx_crn_lr],lat_crn[idx_crn_ur],lon_crn[idx_crn_ur],lat_crn[idx_crn_ul],lon_crn[idx_crn_ul]);
+	  if(nco_dbg_lvl_get() >= nco_dbg_crr) (void)fprintf(stderr,"%s: INFO %s reports %s corner outside canonical bounds at idx = %li, Center [lat,lon]=[%g,%g]; Corners LL [%g,%g] LR [%g,%g] UR [%g,%g] UL [%g,%g]\n",nco_prg_nm_get(),fnc_nm,(lat_bnd_id == NC_MIN_INT) ? "inferred" : "copied",idx_ctr,lat_ctr[idx_ctr],lon_ctr[idx_ctr],lat_crn[idx_crn_ll],lon_crn[idx_crn_ll],lat_crn[idx_crn_lr],lon_crn[idx_crn_lr],lat_crn[idx_crn_ur],lon_crn[idx_crn_ur],lat_crn[idx_crn_ul],lon_crn[idx_crn_ul]);
 	  /* Restrict grid to real latitudes and to the 360-degree range detected from input cell-centers */
 	  if(lat_crn[idx] < -90.0) lat_crn[idx]=-90.0;
 	  if(lat_crn[idx] >  90.0) lat_crn[idx]=90.0;
@@ -5310,6 +5952,23 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
       } /* !sanity */
     } /* !idx */
 
+    /* Vertices (for valid points) are now within 360 degrees (either [0,360] or [-180,180]) implied by input coordinate system
+       Curvilinear inferred grid are, by construction, branch-cut compliant
+       fxm: Curvilinear and 1D pseudo-rectangular grids prescribed by (i.e., read-in from) input may not be branch-cut compliant */
+
+    if(nco_dbg_lvl_get() >= nco_dbg_std){
+      long idx_dbg;
+      idx_dbg=rgr->idx_dbg;
+      idx_crn_ll=grd_crn_nbr*idx_dbg+0;
+      idx_crn_lr=grd_crn_nbr*idx_dbg+1;
+      idx_crn_ur=grd_crn_nbr*idx_dbg+2;
+      idx_crn_ul=grd_crn_nbr*idx_dbg+3;
+      (void)fprintf(stderr,"%s: INFO %s idx_dbg = %li, Center [lat,lon]=[%g,%g]; Corners LL [%g,%g] LR [%g,%g] UR [%g,%g] UL [%g,%g]\n",nco_prg_nm_get(),fnc_nm,idx_dbg,lat_ctr[idx_dbg],lon_ctr[idx_dbg],lat_crn[idx_crn_ll],lon_crn[idx_crn_ll],lat_crn[idx_crn_lr],lon_crn[idx_crn_lr],lat_crn[idx_crn_ur],lon_crn[idx_crn_ur],lat_crn[idx_crn_ul],lon_crn[idx_crn_ul]);
+    } /* !dbg */
+
+  } /* !flg_grd_crv || flg_1D_psd_rct_bnd */
+
+  if(flg_grd_crv){
     /* Copy centers into empty output array */
     for(idx=0;idx<grd_sz_nbr;idx++){
       grd_ctr_lat[idx]=lat_ctr[idx];
@@ -5320,16 +5979,6 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
       grd_crn_lat[idx]=lat_crn[idx];
       grd_crn_lon[idx]=lon_crn[idx];
     } /* !idx */
-  
-    if(nco_dbg_lvl_get() >= nco_dbg_std){
-      long idx_dbg;
-      idx_dbg=rgr->idx_dbg;
-      idx_crn_ll=grd_crn_nbr*idx_dbg+0;
-      idx_crn_lr=grd_crn_nbr*idx_dbg+1;
-      idx_crn_ur=grd_crn_nbr*idx_dbg+2;
-      idx_crn_ul=grd_crn_nbr*idx_dbg+3;
-      (void)fprintf(stderr,"%s: INFO %s idx_dbg = %li, Center [lat,lon]=[%g,%g]; Corners LL [%g,%g] LR [%g,%g] UR [%g,%g] UL [%g,%g]\n",nco_prg_nm_get(),fnc_nm,idx_dbg,lat_ctr[idx_dbg],lon_ctr[idx_dbg],lat_crn[idx_crn_ll],lon_crn[idx_crn_ll],lat_crn[idx_crn_lr],lon_crn[idx_crn_lr],lat_crn[idx_crn_ur],lon_crn[idx_crn_ur],lat_crn[idx_crn_ul],lon_crn[idx_crn_ul]);
-    } /* !dbg */
   } /* !flg_grd_crv */
 
   if(flg_grd_2D){
@@ -5727,7 +6376,7 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   } /* endif dbg */
 
   /* Open grid file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Define dimensions */
   /* 20151230 ERWG appears to require presence of corner arrays in grid file even when they are not used (e.g., bilinear)
@@ -5737,17 +6386,28 @@ nco_grd_nfr /* [fnc] Infer SCRIP-format grid file from input data file */
   rcd=nco_def_dim(out_id,grd_sz_nm,grd_sz_nbr,&dmn_id_grd_sz);
   rcd=nco_def_dim(out_id,grd_rnk_nm,grd_rnk_nbr,&dmn_id_grd_rnk);
   
+  int shuffle; /* [flg] Turn-on shuffle filter */
+  int deflate; /* [flg] Turn-on deflate filter */
+  deflate=(int)True;
+  shuffle=NC_SHUFFLE;
+
   /* Define variables */
-  (void)nco_def_var(out_id,dmn_sz_nm,(nc_type)NC_INT,dmn_nbr_1D,&dmn_id_grd_rnk,&dmn_sz_int_id);
+  (void)nco_def_var(out_id,dmn_sz_nm,(nc_type)NC_INT,dmn_nbr_1D,&dmn_id_grd_rnk,&dmn_sz_int_id); /* NB: Too small to deflate */
   (void)nco_def_var(out_id,area_nm,crd_typ,dmn_nbr_1D,&dmn_id_grd_sz,&area_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,area_id,shuffle,deflate,dfl_lvl);
   (void)nco_def_var(out_id,msk_nm,(nc_type)NC_INT,dmn_nbr_1D,&dmn_id_grd_sz,&msk_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,msk_id,shuffle,deflate,dfl_lvl);
   (void)nco_def_var(out_id,grd_ctr_lat_nm,crd_typ,dmn_nbr_1D,&dmn_id_grd_sz,&grd_ctr_lat_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_ctr_lat_id,shuffle,deflate,dfl_lvl);
   (void)nco_def_var(out_id,grd_ctr_lon_nm,crd_typ,dmn_nbr_1D,&dmn_id_grd_sz,&grd_ctr_lon_id);
+  if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_ctr_lon_id,shuffle,deflate,dfl_lvl);
   if(flg_wrt_crn){
     dmn_ids[0]=dmn_id_grd_sz;
     dmn_ids[1]=dmn_id_grd_crn;
     (void)nco_def_var(out_id,grd_crn_lat_nm,crd_typ,dmn_nbr_2D,dmn_ids,&grd_crn_lat_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_crn_lat_id,shuffle,deflate,dfl_lvl);
     (void)nco_def_var(out_id,grd_crn_lon_nm,crd_typ,dmn_nbr_2D,dmn_ids,&grd_crn_lon_id);
+    if(dfl_lvl > 0) (void)nco_def_var_deflate(out_id,grd_crn_lon_id,shuffle,deflate,dfl_lvl);
   } /* !flg_wrt_crn */
   
   /* Define "units" attributes */
@@ -6011,6 +6671,9 @@ nco_ccw_chk /* [fnc] Convert quadrilateral gridcell corners to CCW orientation *
      Function can call itself, and rcr_lvl indicates recursion level:
      rcr_lvl=1: Called by host code, i.e., nco_grd_nfr()
      rcr_lvl=2: Called by itself, i.e., nco_ccw_chk()
+     Assumptions:
+     Quadrilateral vertices are already corrected to obey branch-cut rules, i.e.,
+     all vertices are on "same side" of dateline or Greenwich as appropriate
      Algorithm:
      Start crn_idx=0, i.e., quadrilateral LL corner
      Vector A runs from crn_idx=0 to crn_idx=1, i.e., quadrilateral LL->LR
@@ -6039,7 +6702,14 @@ nco_ccw_chk /* [fnc] Convert quadrilateral gridcell corners to CCW orientation *
      All cases return True (i.e., CCW) from rcr_lvl=1 except last
      Last case returns False, and calling code should mask such an aberrant point */ 
   const char fnc_nm[]="nco_ccw_chk()";
+
+  /* MSVC compiler chokes unless array size is compile-time constant */
   const int CRN_NBR_MSVC=4;
+  double sin_lat[CRN_NBR_MSVC];
+  double sin_lon[CRN_NBR_MSVC];
+  double cos_lat[CRN_NBR_MSVC];
+  double cos_lon[CRN_NBR_MSVC];
+
   double A_tail_x,A_tail_y,A_tail_z;
   double A_head_x,A_head_y,A_head_z;
   double A_x,A_y,A_z;
@@ -6050,11 +6720,6 @@ nco_ccw_chk /* [fnc] Convert quadrilateral gridcell corners to CCW orientation *
   double R_x,R_y,R_z;
   double lat_rdn;
   double lon_rdn;
-  /* fxm dumb MSVC compiler chokes unless array size is compile-time constant */
-  double sin_lat[CRN_NBR_MSVC];
-  double sin_lon[CRN_NBR_MSVC];
-  double cos_lat[CRN_NBR_MSVC];
-  double cos_lon[CRN_NBR_MSVC];
   double dot_prd;
   int crn_idx; /* [idx] Corner idx */
   int A_tail_idx,A_head_idx;
diff --git a/src/nco/nco_scm.c b/src/nco/nco_scm.c
index 1a515ad..6386425 100644
--- a/src/nco/nco_scm.c
+++ b/src/nco/nco_scm.c
@@ -158,9 +158,9 @@ nco_vrs_prn /* [fnc] Print NCO version */
  const char * const CVS_Revision) /* I [sng] CVS revision string */
 {
   /* Purpose: Print NCO version */
-  char *date_cvs; /* Date this file was last modified */
-  char *vrs_rcs; /* Version of this file, e.g., 1.213 */
-  char *vrs_cvs; /* Version according to CVS release tag */
+  char *date_cvs=NULL; /* Date this file was last modified */
+  char *vrs_rcs=NULL; /* Version of this file, e.g., 1.213 */
+  char *vrs_cvs=NULL; /* Version according to CVS release tag */
 
   int date_cvs_lng;
   int vrs_cvs_lng;
@@ -168,7 +168,7 @@ nco_vrs_prn /* [fnc] Print NCO version */
   const char date_cpp[]=__DATE__; /* [sng] Date from C pre-processor */
   const char time_cpp[]=__TIME__; /* [sng] Time from C pre-processor */
   /*  const char time_cpp[]=__TIME__; *//* [sng] Time from C pre-processor */
-  const char vrs_cpp[]=TKN2SNG(VERSION); /* [sng] Version from C pre-processor */
+  const char vrs_cpp[]=TKN2SNG(NCO_VERSION); /* [sng] Version from C pre-processor */
   const char hst_cpp[]=TKN2SNG(HOSTNAME); /* [sng] Hostname from C pre-processor */
   const char usr_cpp[]=TKN2SNG(USER); /* [sng] Hostname from C pre-processor */
 
@@ -183,7 +183,7 @@ nco_vrs_prn /* [fnc] Print NCO version */
     date_cvs=(char *)strdup("Current");
   } /* endif */
 
-  if(strlen(CVS_Revision) > strlen("*Revision*") || strlen(CVS_Revision) < strlen("*Revision*")){
+  if(strlen(CVS_Revision) != strlen("*Revision*")){
     /* CVS_Revision is defined */
     vrs_cvs_lng=strrchr(CVS_Revision,'$')-strchr(CVS_Revision,':')-3L;
     vrs_rcs=(char *)nco_malloc((vrs_cvs_lng+1L)*sizeof(char));
@@ -194,23 +194,22 @@ nco_vrs_prn /* [fnc] Print NCO version */
     vrs_rcs=(char *)strdup("Current");
   } /* endif */
 
-  vrs_cvs=cvs_vrs_prs();
-
   if(strlen(CVS_Id) > strlen("*Id*")){
     (void)fprintf(stderr,"NCO netCDF Operators version %s last modified %s built %s on %s by %s\n",vrs_cpp,date_cvs,date_cpp,hst_cpp,usr_cpp);
   }else{
     /* 20141008: Try new nco.h-based versioning */
     /*    (void)fprintf(stderr,"NCO netCDF Operators version %s built %s on %s by %s\n",vrs_cpp,date_cpp,hst_cpp,usr_cpp);*/
-    (void)fprintf(stderr,"NCO netCDF Operators version %s built by %s on %s at %s %s\n",NCO_VERSION,usr_cpp,hst_cpp,date_cpp,time_cpp);
+    (void)fprintf(stderr,"NCO netCDF Operators version %s built by %s on %s at %s %s\n",vrs_cpp,usr_cpp,hst_cpp,date_cpp,time_cpp);
   } /* endif */
   if(strlen(CVS_Id) > strlen("*Id*")){
+    vrs_cvs=cvs_vrs_prs();
     (void)fprintf(stderr,"%s version %s\n",nco_prg_nm_get(),vrs_cvs);
   }else{
     (void)fprintf(stderr,"%s version %s\n",nco_prg_nm_get(),vrs_cpp);
   } /* endif */
 
-  date_cvs=(char *)nco_free(date_cvs);
-  vrs_rcs=(char *)nco_free(vrs_rcs);
-  vrs_cvs=(char *)nco_free(vrs_cvs);
+  if(date_cvs) date_cvs=(char *)nco_free(date_cvs);
+  if(vrs_rcs) vrs_rcs=(char *)nco_free(vrs_rcs);
+  if(vrs_cvs) vrs_cvs=(char *)nco_free(vrs_cvs);
 } /* end nco_vrs_prn() */
 
diff --git a/src/nco/nco_sld.c b/src/nco/nco_sld.c
index c6588cb..8e32ff5 100644
--- a/src/nco/nco_sld.c
+++ b/src/nco/nco_sld.c
@@ -9,6 +9,559 @@
 
 #include "nco_sld.h" /* Swath-Like Data */
 
+trr_sct * /* O [sct] Terraref structure */
+nco_trr_ini /* [fnc] Initialize Terraref structure */
+(const char * const cmd_ln, /* I [sng] Command-line */
+ const int dfl_lvl, /* I [enm] Deflate level [0..9] */
+ char **trr_arg, /* I [sng] Terraref arguments */
+ const int trr_arg_nbr, /* I [nbr] Number of Terraref arguments */
+ char * const trr_in, /* I [sng] File containing raw Terraref imagery */
+ char * const trr_out, /* I [sng] File containing netCDF Terraref imagery */
+ char * const trr_wxy) /* I [sng] Terraref dimension sizes */
+{
+  /* Purpose: Initialize regridding structure */
+     
+  const char fnc_nm[]="nco_trr_ini()";
+  
+  int cnv_nbr; /* [nbr] Number of elements converted by sscanf() */
+
+  trr_sct *trr;
+
+  /* Allocate */
+  trr=(trr_sct *)nco_malloc(sizeof(trr_sct));
+  
+  /* Initialize variable directly or indirectly set via command-line (except for key-value arguments) */
+  trr->cmd_ln=strdup(cmd_ln); /* [sng] Command-line */
+  trr->dfl_lvl=dfl_lvl; /* I [enm] Deflate level [0..9] */
+
+  trr->trr_arg=trr_arg; /* [sng] Terraref arguments */
+  trr->trr_nbr=trr_arg_nbr; /* [nbr] Number of Terraref arguments */
+
+  trr->fl_in=trr_in; /* [sng] File containing raw Terrraref imagery */
+  trr->fl_out=trr_out; /* [sng] File containing netCDF Terraref imagery */
+  trr->fl_out_tmp=NULL_CEWI; /* [sng] Temporary file containing netCDF Terraref imagery */
+
+  /* Initialize arguments after copying */
+  if(!trr->fl_out) trr->fl_out=(char *)strdup("/data/zender/terraref/trr_out.nc");
+  
+  if(nco_dbg_lvl_get() >= nco_dbg_crr){
+    (void)fprintf(stderr,"%s: INFO %s reports ",nco_prg_nm_get(),fnc_nm);
+    (void)fprintf(stderr,"trr_nbr = %d, ",trr->trr_nbr);
+    (void)fprintf(stderr,"fl_in = %s, ",trr->fl_in ? trr->fl_in : "NULL");
+    (void)fprintf(stderr,"fl_out = %s, ",trr->fl_out ? trr->fl_out : "NULL");
+    (void)fprintf(stderr,"fl_out_tmp = %s, ",trr->fl_out_tmp ? trr->fl_out_tmp : "NULL");
+    (void)fprintf(stderr,"\n");
+  } /* endif dbg */
+  
+  /* Parse extended kvm options */
+  int trr_arg_idx; /* [idx] Index over trr_arg (i.e., separate invocations of "--trr var1[,var2]=val") */
+  int trr_var_idx; /* [idx] Index over trr_lst (i.e., all names explicitly specified in all "--trr var1[,var2]=val" options) */
+  int trr_var_nbr=0;
+  kvm_sct *trr_lst; /* [sct] List of all regrid specifications */
+  kvm_sct kvm;
+
+  trr_lst=(kvm_sct *)nco_malloc(NC_MAX_VARS*sizeof(kvm_sct));
+
+  /* Parse TRRs */
+  for(trr_arg_idx=0;trr_arg_idx<trr_arg_nbr;trr_arg_idx++){
+    if(!strstr(trr_arg[trr_arg_idx],"=")){
+      (void)fprintf(stdout,"%s: Invalid --trr specification: %s. Must contain \"=\" sign, e.g., \"key=value\".\n",nco_prg_nm_get(),trr_arg[trr_arg_idx]);
+      if(trr_lst) trr_lst=(kvm_sct *)nco_free(trr_lst);
+      nco_exit(EXIT_FAILURE);
+    } /* endif */
+    kvm=nco_sng2kvm(trr_arg[trr_arg_idx]);
+    /* nco_sng2kvm() converts argument "--trr one,two=3" into kvm.key="one,two" and kvm.val=3
+       Then nco_lst_prs_2D() converts kvm.key into two items, "one" and "two", with the same value, 3 */
+    if(kvm.key){
+      int var_idx; /* [idx] Index over variables in current TRR argument */
+      int var_nbr; /* [nbr] Number of variables in current TRR argument */
+      char **var_lst;
+      var_lst=nco_lst_prs_2D(kvm.key,",",&var_nbr);
+      for(var_idx=0;var_idx<var_nbr;var_idx++){ /* Expand multi-variable specification */
+        trr_lst[trr_var_nbr].key=strdup(var_lst[var_idx]);
+        trr_lst[trr_var_nbr].val=strdup(kvm.val);
+        trr_var_nbr++;
+      } /* end for */
+      var_lst=nco_sng_lst_free(var_lst,var_nbr);
+    } /* end if */
+  } /* end for */
+  
+  /* NULL-initialize key-value properties required for string variables */
+  trr->ttl=NULL; /* [sng] Title */
+  trr->wvl_nm=NULL; /* [sng] Name of wavelength dimension */
+  trr->xdm_nm=NULL; /* [sng] Name of x-coordinate dimension */
+  trr->ydm_nm=NULL; /* [sng] Name of y-coordinate dimension */
+  trr->var_nm=NULL; /* [sng] Variable containing imagery */
+  trr->wvl_bnd_nm=NULL; /* [sng] Name of dimension to employ for wavelength bounds */
+  trr->xdm_bnd_nm=NULL; /* [sng] Name of dimension to employ for x-coordinate bounds */
+  trr->ydm_bnd_nm=NULL; /* [sng] Name of dimension to employ for y-coordinate bounds */
+
+  /* Initialize numeric key-value properties used in data processing */
+  trr->var_typ_in=NC_USHORT; /* [enm] NetCDF type-equivalent of binary data (raw imagery) */
+  trr->var_typ_out=NC_USHORT; /* [enm] NetCDF type of data in output file */
+  trr->wvl_nbr=272; /* [nbr] Number of wavelengths */
+  trr->xdm_nbr=384; /* [nbr] Number of pixels in x-dimension */
+  trr->ydm_nbr=893; /* [nbr] Number of pixels in y-dimension */
+  trr->ntl_typ_in=nco_trr_ntl_bil; /* [enm] Interleave-type of raw data */
+  trr->ntl_typ_out=nco_trr_ntl_bsq; /* [enm] Interleave-type of output data */
+
+  /* Initialize variables settable by global switches */
+  if(trr_wxy){
+    cnv_nbr=sscanf(trr_wxy,"%ld,%ld,%ld",&trr->wvl_nbr,&trr->xdm_nbr,&trr->ydm_nbr);
+    assert(cnv_nbr == 3);
+  } /* !trr_wxy */
+
+  /* Parse key-value properties */
+  char *sng_cnv_rcd=NULL_CEWI; /* [sng] strtol()/strtoul() return code */
+  for(trr_var_idx=0;trr_var_idx<trr_var_nbr;trr_var_idx++){
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"ntl_in")){
+      trr->ntl_typ_in=nco_trr_sng_ntl(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !ntl_in */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"ntl_out")){
+      trr->ntl_typ_out=nco_trr_sng_ntl(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !ntl_out */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"ttl")){
+      trr->ttl=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !ttl */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"var_nm")){
+      trr->var_nm=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !var_nm */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"typ_in")){
+      trr->var_typ_in=nco_sng2typ(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !var_typ_in */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"typ_out")){
+      trr->var_typ_out=nco_sng2typ(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !var_typ_out */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"wxy")){
+      cnv_nbr=sscanf(trr_lst[trr_var_idx].val,"%ld,%ld,%ld",&trr->wvl_nbr,&trr->xdm_nbr,&trr->ydm_nbr);
+      assert(cnv_nbr == 3);
+      continue;
+    } /* !wxy */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"wvl_nbr")){
+      trr->wvl_nbr=strtol(trr_lst[trr_var_idx].val,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
+      if(*sng_cnv_rcd) nco_sng_cnv_err(trr_lst[trr_var_idx].val,"strtol",sng_cnv_rcd);
+      continue;
+    } /* !wvl_nbr */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"xdm_nbr")){
+      trr->xdm_nbr=strtol(trr_lst[trr_var_idx].val,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
+      if(*sng_cnv_rcd) nco_sng_cnv_err(trr_lst[trr_var_idx].val,"strtol",sng_cnv_rcd);
+      continue;
+    } /* !xdm_nbr */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"ydm_nbr")){
+      trr->ydm_nbr=strtol(trr_lst[trr_var_idx].val,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
+      if(*sng_cnv_rcd) nco_sng_cnv_err(trr_lst[trr_var_idx].val,"strtol",sng_cnv_rcd);
+      continue;
+    } /* !ydm_nbr */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"wvl_nm")){
+      trr->wvl_nm=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !wvl_nm */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"xdm_nm")){
+      trr->xdm_nm=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !xdm_nm */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"ydm_nm")){
+      trr->ydm_nm=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !ydm_nm */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"wvl_bnd_nm")){
+      trr->wvl_bnd_nm=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !wvl_bnd_nm */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"xdm_bnd_nm")){
+      trr->xdm_bnd_nm=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !xdm_bnd_nm */
+    if(!strcasecmp(trr_lst[trr_var_idx].key,"ydm_bnd_nm")){
+      trr->ydm_bnd_nm=(char *)strdup(trr_lst[trr_var_idx].val);
+      continue;
+    } /* !ydm_bnd_nm */
+    (void)fprintf(stderr,"%s: ERROR %s reports unrecognized key-value option to --trr switch: %s\n",nco_prg_nm_get(),fnc_nm,trr_lst[trr_var_idx].key);
+    nco_exit(EXIT_FAILURE);
+  } /* end for */
+  
+  /* Revert to defaults for any names not specified on command-line */
+  if(!trr->ttl) trr->ttl=(char *)strdup("None given (supply with --trr ttl=\"Title\")"); /* [sng] Title */
+  if(!trr->wvl_nm) trr->wvl_nm=(char *)strdup("wavelength"); /* [sng] Name of wavelength dimension */
+  if(!trr->xdm_nm) trr->xdm_nm=(char *)strdup("x"); /* [sng] Name of x-coordinate dimension */
+  if(!trr->ydm_nm) trr->ydm_nm=(char *)strdup("y"); /* [sng] Name of y-coordinate dimension */
+  if(!trr->var_nm) trr->var_nm=(char *)strdup("xps_img"); /* [sng] Variable containing imagery */
+  if(!trr->wvl_bnd_nm) trr->wvl_bnd_nm=(char *)strdup("wvl_bnds"); /* [sng] Name of dimension to employ for wavelength bounds */
+  if(!trr->xdm_bnd_nm) trr->xdm_bnd_nm=(char *)strdup("x_bnds"); /* [sng] Name of dimension to employ for x-coordinate bounds */
+  if(!trr->ydm_bnd_nm) trr->ydm_bnd_nm=(char *)strdup("y_bnds"); /* [sng] Name of dimension to employ for y-coordinate bounds */
+  
+  /* Free kvms */
+  if(trr_lst) trr_lst=nco_kvm_lst_free(trr_lst,trr_var_nbr);
+  
+  return trr;
+} /* end nco_trr_ini() */
+
+trr_sct * /* O [sct] Pointer to free'd Terraref structure */
+nco_trr_free /* [fnc] Deallocate Terraref structure */
+(trr_sct *trr) /* I/O [sct] Terraref structure */
+{
+  /* Purpose: Free all dynamic memory in Terraref structure */
+
+  /* free() standalone command-line arguments */
+  if(trr->cmd_ln) trr->cmd_ln=(char *)nco_free(trr->cmd_ln);
+  if(trr->fl_in) trr->fl_in=(char *)nco_free(trr->fl_in);
+  if(trr->fl_out) trr->fl_out=(char *)nco_free(trr->fl_out);
+  if(trr->fl_out_tmp) trr->fl_out_tmp=(char *)nco_free(trr->fl_out_tmp);
+  if(trr->var_nm) trr->var_nm=(char *)nco_free(trr->var_nm);
+
+  /* free() memory used to construct KVMs */
+  if(trr->trr_nbr > 0) trr->trr_arg=nco_sng_lst_free(trr->trr_arg,trr->trr_nbr);
+
+  /* free() memory copied from KVMs */
+  if(trr->ttl) trr->ttl=(char *)nco_free(trr->ttl);
+  if(trr->wvl_nm) trr->wvl_nm=(char *)nco_free(trr->wvl_nm);
+  if(trr->xdm_nm) trr->xdm_nm=(char *)nco_free(trr->xdm_nm);
+  if(trr->ydm_nm) trr->ydm_nm=(char *)nco_free(trr->ydm_nm);
+  if(trr->var_nm) trr->var_nm=(char *)nco_free(trr->var_nm);
+  if(trr->wvl_bnd_nm) trr->wvl_bnd_nm=(char *)nco_free(trr->wvl_bnd_nm);
+  if(trr->xdm_bnd_nm) trr->xdm_bnd_nm=(char *)nco_free(trr->xdm_bnd_nm);
+  if(trr->ydm_bnd_nm) trr->ydm_bnd_nm=(char *)nco_free(trr->ydm_bnd_nm);
+
+  /* Lastly, free() regrid structure itself */
+  if(trr) trr=(trr_sct *)nco_free(trr);
+
+  return trr;
+} /* end nco_trr_free() */
+  
+int /* O [rcd] Return code */
+nco_trr_read /* [fnc] Read, parse, and print contents of TERRAREF file */
+(trr_sct *trr) /* I/O [sct] Terraref information */
+{
+  /* Purpose: Read TERRAREF file */
+  const char fnc_nm[]="nco_trr_read()"; /* [sng] Function name */
+
+  const int dmn_nbr_3D=3; /* [nbr] Rank of 3-D grid variables */
+  const int dmn_nbr_grd_max=dmn_nbr_3D; /* [nbr] Maximum rank of grid variables */
+
+  //  const nc_type crd_typ=NC_FLOAT;
+
+  char *fl_in;
+  char *fl_out;
+  char *fl_out_tmp=NULL_CEWI;
+  char *var_nm;
+  char *wvl_nm;
+  char *xdm_nm;
+  char *ydm_nm;
+
+  FILE *fp_in=NULL; /* [fl] Unformatted binary input file handle */
+
+  int dmn_ids[dmn_nbr_grd_max]; /* [id] Dimension IDs array for output variable */
+
+  int dmn_idx_wvl; /* [idx] Index of wavelength dimension */
+  int dmn_idx_ydm; /* [idx] Index of y-coordinate dimension */
+  int dmn_idx_xdm; /* [idx] Index of x-coordinate dimension */
+  int dmn_id_wvl; /* [id] Wavelength dimension ID */
+  int dmn_id_xdm; /* [id] X-dimension ID */
+  int dmn_id_ydm; /* [id] Y-dimension ID */
+  int dfl_lvl; /* [enm] Deflate level [0..9] */
+  int fl_out_fmt=NC_FORMAT_NETCDF4; /* [enm] Output file format */
+  int out_id; /* I [id] Output netCDF file ID */
+  int rcd=NC_NOERR;
+  int var_id; /* [id] Current variable ID */
+
+  long dmn_srt[dmn_nbr_grd_max];
+  long dmn_cnt[dmn_nbr_grd_max];
+
+  long wvl_nbr; /* [nbr] Number of wavelengths */
+  long xdm_nbr; /* [nbr] Number of pixels in x-dimension */
+  long ydm_nbr; /* [nbr] Number of pixels in y-dimension */
+  long wvl_idx;
+  long ydm_idx;
+  long var_sz; /* [nbr] Size of variable */
+
+  nc_type var_typ_in; /* [enm] NetCDF type-equivalent of binary data (raw imagery) */
+  nc_type var_typ_out; /* [enm] NetCDF type of data in output file */
+
+  nco_bool FORCE_APPEND=False; /* Option A */
+  nco_bool FORCE_OVERWRITE=True; /* Option O */
+  nco_bool RAM_CREATE=False; /* [flg] Create file in RAM */
+  nco_bool RAM_OPEN=False; /* [flg] Open (netCDF3-only) file(s) in RAM */
+  nco_bool WRT_TMP_FL=False; /* [flg] Write output to temporary file */
+
+  size_t bfr_sz_hnt=NC_SIZEHINT_DEFAULT; /* [B] Buffer size hint */
+
+  nco_trr_ntl_typ_enm ntl_typ_in; /* [enm] Interleave-type of raw data */
+  nco_trr_ntl_typ_enm ntl_typ_out; /* [enm] Interleave-type of output data */
+
+  ptr_unn var_raw;
+  ptr_unn var_val;
+  
+  /* Initialize local copies of command-line values */
+  fl_in=trr->fl_in;
+  fl_out=trr->fl_out;
+  var_nm=trr->var_nm;
+  wvl_nm=trr->wvl_nm;
+  xdm_nm=trr->xdm_nm;
+  ydm_nm=trr->ydm_nm;
+  
+  wvl_nbr=trr->wvl_nbr; /* bands */
+  xdm_nbr=trr->xdm_nbr; /* samples */
+  ydm_nbr=trr->ydm_nbr; /* lines */
+
+  ntl_typ_in=trr->ntl_typ_in; /* [enm] Interleave-type of raw data */
+  ntl_typ_out=trr->ntl_typ_out; /* [enm] Interleave-type of output data */
+
+  var_typ_in=trr->var_typ_in; /* [enm] NetCDF type-equivalent of binary data (raw imagery) */
+  var_typ_out=trr->var_typ_out; /* [enm] NetCDF type of data in output file */
+
+  dfl_lvl=trr->dfl_lvl;
+
+  if(nco_dbg_lvl_get() >= nco_dbg_std){
+    (void)fprintf(stderr,"%s: INFO %s Terraref metadata: ",nco_prg_nm_get(),fnc_nm);
+    (void)fprintf(stderr,"wvl_nbr = %li, xdm_nbr = %li, ydm_nbr = %li, ntl_typ_in = %s, ntl_typ_out = %s, var_typ_in = %s, var_typ_out = %s\n",wvl_nbr,xdm_nbr,ydm_nbr,nco_trr_ntl_sng(ntl_typ_in),nco_trr_ntl_sng(ntl_typ_out),nco_typ_sng(var_typ_in),nco_typ_sng(var_typ_out));
+  } /* endif dbg */
+
+  var_sz=wvl_nbr*xdm_nbr*ydm_nbr;
+  var_val.vp=(void *)nco_malloc(var_sz*nctypelen(var_typ_in));
+  var_raw.vp=(void *)nco_malloc(var_sz*nctypelen(var_typ_in));
+  
+  /* [fnc] Open unformatted binary data file for reading */
+  fp_in=nco_bnr_open(fl_in,"r");
+      
+  /* [fnc] Read unformatted binary data */
+  nco_bnr_rd(fp_in,var_nm,var_sz,var_typ_in,var_raw.vp);
+
+  /* [fnc] Close unformatted binary data file */
+  if(fp_in) (void)nco_bnr_close(fp_in,fl_in);
+
+  /* ENVI Image Files documentation:
+     http://www.harrisgeospatial.com/docs/enviimagefiles.html
+     Band Sequential: BSQ format is the simplest format, where each line of the data is followed immediately by the next line in the same spectral band. This format is optimal for spatial (x,y) access of any part of a single spectral band.
+     Band-interleaved-by-pixel: BIP format stores the first pixel for all bands in sequential order, followed by the second pixel for all bands, followed by the third pixel for all bands, and so forth, interleaved up to the number of pixels. This format provides optimum performance for spectral (z) access of the image data.
+     Band-interleaved-by-line: BIL format stores the first line of the first band, followed by the first line of the second band, followed by the first line of the third band, interleaved up to the number of bands. Subsequent lines for each band are interleaved in similar fashion. This format provides a compromise in performance between spatial and spectral processing and is the recommended file format for most ENVI processing tasks. */
+
+  if(ntl_typ_in == nco_trr_ntl_bil && ntl_typ_out == nco_trr_ntl_bsq){
+    /* De-interleave */
+    long ln_sz; /* [nbr] Number of pixels in line */
+    long ln_sz_byt; /* [B] Number of bytes in line */
+    long img_sz_byt; /* [B] Image size in bytes */
+    long src_fst_byt; /* [B] Line offset in bytes, source */
+    long dst_fst_byt; /* [B] Line offset in bytes, destination */
+    
+    ln_sz=xdm_nbr;
+    ln_sz_byt=ln_sz*nctypelen(var_typ_in);
+    img_sz_byt=xdm_nbr*ydm_nbr*nctypelen(var_typ_in);
+    
+    if(nco_dbg_lvl_get() >= nco_dbg_std) (void)fprintf(stderr,"%s: INFO %s de-interleaving input image from ENVI type %s\n",nco_prg_nm_get(),fnc_nm,nco_trr_ntl_sng(ntl_typ_in));
+    for(ydm_idx=0;ydm_idx<ydm_nbr;ydm_idx++){
+      for(wvl_idx=0;wvl_idx<wvl_nbr;wvl_idx++){
+	src_fst_byt=(ydm_idx*wvl_nbr+wvl_idx)*ln_sz_byt;
+	dst_fst_byt=wvl_idx*img_sz_byt+ydm_idx*ln_sz_byt;
+	memcpy((void *)(var_val.cp+dst_fst_byt),(void *)(var_raw.cp+src_fst_byt),ln_sz_byt);
+      } /* !wvl_idx */
+    } /* !ydm_idx */
+  }else{
+    if(var_val.vp) var_val.vp=(void *)nco_free(var_val.vp);
+    var_val.vp=var_raw.vp;
+    var_raw.vp=NULL;
+  } /* !ntl_bil */
+
+  if(nco_dbg_lvl_get() >= nco_dbg_std){
+    if(var_typ_in == NC_USHORT){
+      long idx;
+      double val_min;
+      double val_max;
+      double val_avg;
+      val_min=var_val.usp[0];
+      val_max=var_val.usp[0];
+      val_avg=0.0;
+      for(idx=0;idx<var_sz;idx++){
+	if(var_val.usp[idx] < val_min) val_min=var_val.usp[idx];
+	if(var_val.usp[idx] > val_max) val_max=var_val.usp[idx];
+	val_avg+=var_val.usp[idx];
+      } /* !idx */
+      val_avg/=var_sz;
+      (void)fprintf(stderr,"%s: INFO %s image diagnostics: min=%g, max=%g, avg=%g\n",nco_prg_nm_get(),fnc_nm,val_min,val_max,val_avg);
+    } /* !NC_USHORT */
+  } /* !dbg */
+
+    /* Free input data memory */
+  if(var_raw.vp) var_raw.vp=(void *)nco_free(var_raw.vp);
+
+  /* Open grid file */  
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+
+  /* Define dimensions */
+  rcd=nco_def_dim(out_id,wvl_nm,wvl_nbr,&dmn_id_wvl);
+  rcd=nco_def_dim(out_id,xdm_nm,xdm_nbr,&dmn_id_xdm);
+  rcd=nco_def_dim(out_id,ydm_nm,ydm_nbr,&dmn_id_ydm);
+  
+  /* Define variables */
+  if(ntl_typ_out == nco_trr_ntl_bsq){
+    /* Band-sequential order */
+    dmn_idx_wvl=0;
+    dmn_idx_ydm=1;
+    dmn_idx_xdm=2;
+  }else if(ntl_typ_out == nco_trr_ntl_bip){
+    /* Band-interleaved-by-pixel order */
+    dmn_idx_wvl=2;
+    dmn_idx_ydm=0;
+    dmn_idx_xdm=1;
+  }else if(ntl_typ_out == nco_trr_ntl_bil){
+    /* Band-interleaved-by-line order */
+    dmn_idx_wvl=1;
+    dmn_idx_ydm=0;
+    dmn_idx_xdm=2;
+  } /* !ntl_typ_out */
+  dmn_ids[dmn_idx_wvl]=dmn_id_wvl;
+  dmn_ids[dmn_idx_xdm]=dmn_id_xdm;
+  dmn_ids[dmn_idx_ydm]=dmn_id_ydm;
+  dmn_cnt[dmn_idx_wvl]=wvl_nbr;
+  dmn_cnt[dmn_idx_xdm]=xdm_nbr;
+  dmn_cnt[dmn_idx_ydm]=ydm_nbr;
+
+  (void)nco_def_var(out_id,var_nm,var_typ_out,dmn_nbr_3D,dmn_ids,&var_id);
+
+  if(dfl_lvl > 0){
+    int shuffle; /* [flg] Turn-on shuffle filter */
+    int deflate; /* [flg] Turn-on deflate filter */
+    deflate=(int)True;
+    shuffle=NC_SHUFFLE;
+    (void)nco_def_var_deflate(out_id,var_id,shuffle,deflate,dfl_lvl);
+  } /* !dfl_lvl */
+  
+  /* Define "units" attributes */
+  aed_sct aed_mtd;
+  char *att_nm;
+  char *att_val;
+  
+  att_nm=strdup("title");
+  att_val=strdup(trr->ttl);
+  aed_mtd.att_nm=att_nm;
+  aed_mtd.var_nm=NULL;
+  aed_mtd.id=NC_GLOBAL;
+  aed_mtd.sz=strlen(att_val);
+  aed_mtd.type=NC_CHAR;
+  aed_mtd.val.cp=att_val;
+  aed_mtd.mode=aed_create;
+  (void)nco_aed_prc(out_id,NC_GLOBAL,aed_mtd);
+  if(att_nm) att_nm=(char *)nco_free(att_nm);
+  if(att_val) att_val=(char *)nco_free(att_val);
+  
+  const char usr_cpp[]=TKN2SNG(USER); /* [sng] Hostname from C pre-processor */
+  att_nm=strdup("created_by");
+  att_val=strdup(usr_cpp);
+  aed_mtd.att_nm=att_nm;
+  aed_mtd.var_nm=NULL;
+  aed_mtd.id=NC_GLOBAL;
+  aed_mtd.sz=strlen(att_val);
+  aed_mtd.type=NC_CHAR;
+  aed_mtd.val.cp=att_val;
+  aed_mtd.mode=aed_create;
+  (void)nco_aed_prc(out_id,NC_GLOBAL,aed_mtd);
+  if(att_nm) att_nm=(char *)nco_free(att_nm);
+  if(att_val) att_val=(char *)nco_free(att_val);
+  
+  att_nm=strdup("history");
+  att_val=strdup(trr->cmd_ln);
+  aed_mtd.att_nm=att_nm;
+  aed_mtd.var_nm=NULL;
+  aed_mtd.id=NC_GLOBAL;
+  aed_mtd.sz=strlen(att_val);
+  aed_mtd.type=NC_CHAR;
+  aed_mtd.val.cp=att_val;
+  aed_mtd.mode=aed_create;
+  (void)nco_aed_prc(out_id,NC_GLOBAL,aed_mtd);
+  if(att_nm) att_nm=(char *)nco_free(att_nm);
+  if(att_val) att_val=(char *)nco_free(att_val);
+  
+  att_nm=strdup("long_name");
+  att_val=strdup("Exposure counts");
+  aed_mtd.att_nm=att_nm;
+  aed_mtd.var_nm=var_nm;
+  aed_mtd.id=var_id;
+  aed_mtd.sz=strlen(att_val);
+  aed_mtd.type=NC_CHAR;
+  aed_mtd.val.cp=att_val;
+  aed_mtd.mode=aed_create;
+  (void)nco_aed_prc(out_id,var_id,aed_mtd);
+  if(att_nm) att_nm=(char *)nco_free(att_nm);
+  if(att_val) att_val=(char *)nco_free(att_val);
+  
+  att_nm=strdup("meaning");
+  att_val=strdup("Counts on scale from 0 to 2^16-1 = 65535");
+  aed_mtd.att_nm=att_nm;
+  aed_mtd.var_nm=var_nm;
+  aed_mtd.id=var_id;
+  aed_mtd.sz=strlen(att_val);
+  aed_mtd.type=NC_CHAR;
+  aed_mtd.val.cp=att_val;
+  aed_mtd.mode=aed_create;
+  (void)nco_aed_prc(out_id,var_id,aed_mtd);
+  if(att_nm) att_nm=(char *)nco_free(att_nm);
+  if(att_val) att_val=(char *)nco_free(att_val);
+  
+  att_nm=strdup("units");
+  att_val=strdup("1");
+  aed_mtd.att_nm=att_nm;
+  aed_mtd.var_nm=var_nm;
+  aed_mtd.id=var_id;
+  aed_mtd.sz=strlen(att_val);
+  aed_mtd.type=NC_CHAR;
+  aed_mtd.val.cp=att_val;
+  aed_mtd.mode=aed_create;
+  (void)nco_aed_prc(out_id,var_id,aed_mtd);
+  if(att_nm) att_nm=(char *)nco_free(att_nm);
+  if(att_val) att_val=(char *)nco_free(att_val);
+  
+  /* Begin data mode */
+  (void)nco_enddef(out_id);
+  
+  /* Write variables */
+  dmn_srt[0]=0L;
+  dmn_srt[1]=0L;
+  dmn_srt[2]=0L;
+  rcd=nco_put_vara(out_id,var_id,dmn_srt,dmn_cnt,var_val.vp,var_typ_in);
+
+  /* Close output file and move it from temporary to permanent location */
+  (void)nco_fl_out_cls(fl_out,fl_out_tmp,out_id);
+
+  /* Free output data memory */
+  if(var_val.vp) var_val.vp=(void *)nco_free(var_val.vp);
+
+  return rcd;
+} /* end nco_trr_read() */
+  
+nco_trr_ntl_typ_enm /* O [enm] Interleave-type */
+nco_trr_sng_ntl /* [fnc] Convert user-supplied string to interleave-type enum */
+(const char * const typ_sng) /* I [sng] String indicating interleave-type */
+{
+  /* Purpose: Convert user-supplied string to interleave-type */
+  if(!strcasecmp(typ_sng,"bsq") || !strcasecmp(typ_sng,"band_sequential")) return nco_trr_ntl_bsq;
+  else if(!strcasecmp(typ_sng,"bip") || !strcasecmp(typ_sng,"band_interleaved_by_pixel")) return nco_trr_ntl_bip;
+  else if(!strcasecmp(typ_sng,"bil") || !strcasecmp(typ_sng,"band_interleaved_by_line")) return nco_trr_ntl_bil;
+  else abort();
+  
+  return nco_trr_ntl_unk;
+} /* end nco_trr_sng_ntl() */
+
+const char * /* O [sng] String describing interleave-type */
+nco_trr_ntl_sng /* [fnc] Convert interleave-type enum to string */
+(const nco_trr_ntl_typ_enm nco_trr_ntl_typ) /* I [enm] Interleave-type enum */
+{
+  /* Purpose: Convert interleave-type enum to string */
+  switch(nco_trr_ntl_typ){
+  case nco_trr_ntl_bsq: return "band_sequential (BSQ format)";
+  case nco_trr_ntl_bip: return "band_interleaved_by_pixel (BIP format)";
+  case nco_trr_ntl_bil: return "band_interleaved_by_line (BIL format)";
+  default: nco_dfl_case_generic_err(); break;
+  } /* end switch */
+
+  /* Some compilers: e.g., SGI cc, need return statement to end non-void functions */
+  return (char *)NULL;
+} /* end nco_trr_ntl_sng() */
+
 int /* O [rcd] Return code */
 nco_scrip_read /* [fnc] Read, parse, and print contents of SCRIP file */
 (char *fl_scrip, /* SCRIP file name with proper path */
diff --git a/src/nco/nco_sld.h b/src/nco/nco_sld.h
index 47c4429..4d07ffc 100644
--- a/src/nco/nco_sld.h
+++ b/src/nco/nco_sld.h
@@ -38,6 +38,32 @@ extern "C" {
   (char *fl_scrip, /* I [sng] SCRIP file name with proper path */
    kvm_sct *kvm_scrip); /* I/O [sct] Structure to hold contents of SCRIP file */ 
 
+  int /* O [rcd] Return code */
+  nco_trr_read /* [fnc] Read, parse, and print contents of TERRAREF file */
+  (trr_sct *trr_nfo); /* I/O [sct] Terraref information */
+  
+  trr_sct * /* O [sct] Terraref structure */
+  nco_trr_ini /* [fnc] Initialize Terraref structure */
+  (const char * const cmd_ln, /* I [sng] Command-line */
+   const int dfl_lvl, /* I [enm] Deflate level [0..9] */
+   char **trr_arg, /* I [sng] Terraref arguments */
+   const int trr_arg_nbr, /* I [nbr] Number of Terraref arguments */
+   char * const trr_in, /* I [sng] File containing raw Terraref imagery */
+   char * const trr_out, /* I [sng] File containing netCDF Terraref imagery */
+   char * const trr_wxy); /* I [sng] Terraref dimension sizes */
+  
+  trr_sct * /* O [sct] Pointer to free'd Terraref structure */
+  nco_trr_free /* [fnc] Deallocate Terraref structure */
+  (trr_sct *trr); /* I/O [sct] Terraref structure */
+
+  nco_trr_ntl_typ_enm /* O [enm] Interleave-type */
+  nco_trr_sng_ntl /* [fnc] Convert user-supplied string to interleave-type enum */
+  (const char * const typ_sng); /* I [sng] String indicating interleave-type */
+
+  const char * /* O [sng] String describing interleave-type */
+  nco_trr_ntl_sng /* [fnc] Convert interleave-type enum to string */
+  (const nco_trr_ntl_typ_enm nco_trr_ntl_typ); /* I [enm] Interleave-type enum */
+
 #ifdef ENABLE_ESMF
   int /* O [enm] Return code */
   nco_rgr_esmf /* [fnc] Regrid using ESMF library */
diff --git a/src/nco/nco_sng_utl.c b/src/nco/nco_sng_utl.c
index 133d0e9..fcf55e7 100644
--- a/src/nco/nco_sng_utl.c
+++ b/src/nco/nco_sng_utl.c
@@ -601,6 +601,50 @@ sng_trm_trl_zro /* [fnc] Trim zeros trailing decimal point and preceding exponen
   return;
 } /* end sng_trm_trl_zro() */
 
+nc_type /* O [enm] netCDF type */
+nco_sng2typ /* [fnc] Convert user-supplied string to netCDF type enum */
+(const char * const typ_sng) /* I [sng] String indicating type */
+{
+  /* Purpose: Convert user-supplied string to netCDF type */
+  const char fnc_nm[]="nco_sng2typ()";
+
+  /* Convert single letter code to type enum */
+  switch(*typ_sng){
+  case 'F':	
+  case 'f': return (nc_type)NC_FLOAT; break;
+  case 'D':	
+  case 'd': return (nc_type)NC_DOUBLE; break;
+  case 'C':	
+  case 'c': return (nc_type)NC_CHAR; break;
+  case 'B':	
+  case 'b': return (nc_type)NC_BYTE; break;
+  default: 
+    /* Ambiguous single letters and extended matches must use full string comparisons */
+    if(!strcasecmp(typ_sng,"float") || !strcasecmp(typ_sng,"float32") || !strcasecmp(typ_sng,"NC_FLOAT")) return (nc_type)NC_FLOAT; 
+    else if(!strcasecmp(typ_sng,"l") || !strcasecmp(typ_sng,"i") || !strcasecmp(typ_sng,"int") || !strcasecmp(typ_sng,"int32") || !strcasecmp(typ_sng,"NC_INT")) return (nc_type)NC_INT; 
+    else if(!strcasecmp(typ_sng,"s") || !strcasecmp(typ_sng,"short") || !strcasecmp(typ_sng,"int16") || !strcasecmp(typ_sng,"NC_SHORT")) return (nc_type)NC_SHORT; 
+#ifdef ENABLE_NETCDF4
+    else if(!strcasecmp(typ_sng,"ub") || !strcasecmp(typ_sng,"ubyte") || !strcasecmp(typ_sng,"uint8") || !strcasecmp(typ_sng,"NC_UBYTE")) return (nc_type)NC_UBYTE; 
+    else if(!strcasecmp(typ_sng,"us") || !strcasecmp(typ_sng,"ushort") || !strcasecmp(typ_sng,"uint16") || !strcasecmp(typ_sng,"NC_USHORT")) return (nc_type)NC_USHORT; 
+    else if(!strcasecmp(typ_sng,"u") || !strcasecmp(typ_sng,"ui") || !strcasecmp(typ_sng,"uint") || !strcasecmp(typ_sng,"uint32") || !strcasecmp(typ_sng,"ul") || !strcasecmp(typ_sng,"NC_UINT")) return (nc_type)NC_UINT; 
+    else if(!strcasecmp(typ_sng,"ll") || !strcasecmp(typ_sng,"int64") || !strcasecmp(typ_sng,"NC_INT64")) return (nc_type)NC_INT64; 
+    else if(!strcasecmp(typ_sng,"ull") || !strcasecmp(typ_sng,"uint64") || !strcasecmp(typ_sng,"NC_UINT64")) return (nc_type)NC_UINT64; 
+    else if(!strcasecmp(typ_sng,"sng") || !strcasecmp(typ_sng,"string") || !strcasecmp(typ_sng,"NC_STRING")) return (nc_type)NC_STRING; 
+    else{
+      (void)fprintf(stderr,"NCO: ERROR `%s' is not a supported netCDF data type\n",typ_sng);
+      (void)fprintf(stderr,"NCO: HINT: Valid data types are `c' = char, `f' = float, `d' = double,`s' = short, `i' = `l' = integer, `b' = byte");
+      (void)fprintf(stderr,", `ub' = unsigned byte, `us' = unsigned short, `u' or `ui' or `ul' = unsigned int,`ll' or `int64' = 64-bit signed integer, `ull' or `uint64` = unsigned 64-bit integer, `sng' or `string' = string");
+      (void)fprintf(stderr,"\n");
+      nco_err_exit(0,fnc_nm);
+    }
+#endif /* ENABLE_NETCDF4 */
+    break;
+  } /* end switch */
+  
+  return (nc_type)NC_NAT;
+
+} /* end nco_sng2typ() */
+
 kvm_sct /* O [sct] Key-value pair */
 nco_sng2kvm /* [fnc] Parse string into key-value pair */
 (char *sng) /* I [sng] String to parse, including "=" */
@@ -613,6 +657,9 @@ nco_sng2kvm /* [fnc] Parse string into key-value pair */
   int arg_idx=0; /* [nbr] */
   kvm_sct kvm;
 
+  /* 20160324: Initialize val to NULL so that can handle empty values, e.g., --gaa history="" */
+  kvm.val=NULL;
+  
   /* NB: Replace strtok() by strsep()? strtok() does not handle consecutive delimiters well
      20160216: String values that contain delimiter will fail
      fxm replace all but first delimiter with temporary character until strtok() finishes */
diff --git a/src/nco/nco_sng_utl.h b/src/nco/nco_sng_utl.h
index 74995f3..ded2aa7 100644
--- a/src/nco/nco_sng_utl.h
+++ b/src/nco/nco_sng_utl.h
@@ -42,7 +42,6 @@
 extern "C" {
 #endif /* __cplusplus */
 
-
 #ifdef NEED_ISBLANK
   int /* O [flg] Character is a space or horizontal tab */
   isblank /* [fnc] Is character a space or horizontal tab? */
@@ -123,6 +122,10 @@ extern "C" {
   (char * const sng, /* I/O [sng] String to process */
    const int trl_zro_max); /* [nbr] Maximum number of trailing zeros allowed */
   
+  nc_type /* O [enm] netCDF type */
+  nco_sng2typ /* [fnc] Convert user-supplied string to netCDF type enum */
+  (const char * const typ_sng); /* I [sng] String indicating type */
+
   kvm_sct /* O [sct] Key-value pair */
   nco_sng2kvm /* [fnc] Parse string into key-value pair */
   (char *sng); /* I [sng] String to parse, including "=" */
diff --git a/src/nco/nco_typ.h b/src/nco/nco_typ.h
index 67a8f4d..450760c 100644
--- a/src/nco/nco_typ.h
+++ b/src/nco/nco_typ.h
@@ -159,11 +159,13 @@ typedef char nco_byte; /* [typ] NC_BYTE */
 # define NCO_BYTE_SNG "char"
 # define NCO_BYTE_IO_SFX text
 # define NCO_GET_ATT_BYTE nc_get_att_text
+# define NCO_GET_VAR_BYTE nc_get_var_text
 # define NCO_GET_VAR1_BYTE nc_get_var1_text
 # define NCO_GET_VARA_BYTE nc_get_vara_text
 # define NCO_GET_VARS_BYTE nc_get_vars_text
 # define NCO_GET_VARM_BYTE nc_get_varm_text
 # define NCO_PUT_ATT_BYTE nc_put_att_text
+# define NCO_PUT_VAR_BYTE nc_put_var_text
 # define NCO_PUT_VAR1_BYTE nc_put_var1_text
 # define NCO_PUT_VARA_BYTE nc_put_vara_text
 # define NCO_PUT_VARS_BYTE nc_put_vars_text
@@ -174,11 +176,13 @@ typedef signed char nco_byte; /* [typ] NC_BYTE */
 # define NCO_BYTE_SNG "signed char"
 # define NCO_BYTE_IO_SFX schar
 # define NCO_GET_ATT_BYTE nc_get_att_schar
+# define NCO_GET_VAR_BYTE nc_get_var_schar
 # define NCO_GET_VAR1_BYTE nc_get_var1_schar
 # define NCO_GET_VARA_BYTE nc_get_vara_schar
 # define NCO_GET_VARS_BYTE nc_get_vars_schar
 # define NCO_GET_VARM_BYTE nc_get_varm_schar
 # define NCO_PUT_ATT_BYTE nc_put_att_schar
+# define NCO_PUT_VAR_BYTE nc_put_var_schar
 # define NCO_PUT_VAR1_BYTE nc_put_var1_schar
 # define NCO_PUT_VARA_BYTE nc_put_vara_schar
 # define NCO_PUT_VARS_BYTE nc_put_vars_schar
@@ -189,11 +193,13 @@ typedef unsigned char nco_byte; /* [typ] NC_BYTE */
 # define NCO_BYTE_SNG "unsigned char"
 # define NCO_BYTE_IO_SFX uchar
 # define NCO_GET_ATT_BYTE nc_get_att_uchar
+# define NCO_GET_VAR_BYTE nc_get_var_uchar
 # define NCO_GET_VAR1_BYTE nc_get_var1_uchar
 # define NCO_GET_VARA_BYTE nc_get_vara_uchar
 # define NCO_GET_VARS_BYTE nc_get_vars_uchar
 # define NCO_GET_VARM_BYTE nc_get_varm_uchar
 # define NCO_PUT_ATT_BYTE nc_put_att_uchar
+# define NCO_PUT_VAR_BYTE nc_put_var_uchar
 # define NCO_PUT_VAR1_BYTE nc_put_var1_uchar
 # define NCO_PUT_VARA_BYTE nc_put_vara_uchar
 # define NCO_PUT_VARS_BYTE nc_put_vars_uchar
@@ -214,11 +220,13 @@ typedef unsigned char nco_ubyte; /* [typ] NC_UBYTE */
 # define NCO_UBYTE_SNG "unsigned char"
 # define NCO_UBYTE_IO_SFX ubyte
 # define NCO_GET_ATT_UBYTE nc_get_att_ubyte
+# define NCO_GET_VAR_UBYTE nc_get_var_ubyte
 # define NCO_GET_VAR1_UBYTE nc_get_var1_ubyte
 # define NCO_GET_VARA_UBYTE nc_get_vara_ubyte
 # define NCO_GET_VARS_UBYTE nc_get_vars_ubyte
 # define NCO_GET_VARM_UBYTE nc_get_varm_ubyte
 # define NCO_PUT_ATT_UBYTE nc_put_att_ubyte
+# define NCO_PUT_VAR_UBYTE nc_put_var_ubyte
 # define NCO_PUT_VAR1_UBYTE nc_put_var1_ubyte
 # define NCO_PUT_VARA_UBYTE nc_put_vara_ubyte
 # define NCO_PUT_VARS_UBYTE nc_put_vars_ubyte
@@ -239,12 +247,14 @@ typedef char nco_char; /* [typ] NC_CHAR */
 # define NCO_CHAR_SNG "char"
 # define NCO_CHAR_IO_SFX text
 # define NCO_GET_ATT_CHAR nc_get_att_text
+# define NCO_GET_VAR_CHAR nc_get_var_text
 # define NCO_GET_VAR1_CHAR nc_get_var1_text
 # define NCO_GET_VARA_CHAR nc_get_vara_text
 # define NCO_GET_VARS_CHAR nc_get_vars_text
 # define NCO_GET_VARM_CHAR nc_get_varm_text
 /* nc_put_att_text() is unique---it uses strlen() to determine argument length */
 # define NCO_PUT_ATT_CHAR(a,b,c,d,e,f) nc_put_att_text(a,b,c,e,f)
+# define NCO_PUT_VAR_CHAR nc_put_var_text
 # define NCO_PUT_VAR1_CHAR nc_put_var1_text
 # define NCO_PUT_VARA_CHAR nc_put_vara_text
 # define NCO_PUT_VARS_CHAR nc_put_vars_text
@@ -255,12 +265,15 @@ typedef signed char nco_char; /* [typ] NC_CHAR */
 # define NCO_CHAR_SNG "signed char"
 # define NCO_CHAR_IO_SFX schar
 # define NCO_GET_ATT_CHAR nc_get_att_schar
+# define NCO_GET_VAR_CHAR nc_get_var_schar
 # define NCO_GET_VAR1_CHAR nc_get_var1_schar
 # define NCO_GET_VARA_CHAR nc_get_vara_schar
 # define NCO_GET_VARS_CHAR nc_get_vars_schar
 # define NCO_GET_VARM_CHAR nc_get_varm_schar
 # define NCO_PUT_ATT_CHAR nc_put_att_schar
+# define NCO_PUT_VAR_CHAR nc_put_var_schar
 # define NCO_PUT_VAR1_CHAR nc_put_var1_schar
+# define NCO_PUT_VARA_CHAR nc_put_vara_schar
 # define NCO_PUT_VARS_CHAR nc_put_vars_schar
 # define NCO_PUT_VARM_CHAR nc_put_varm_schar
 #elif NCO_CHAR == NCO_TYP_UCHAR
@@ -269,11 +282,13 @@ typedef unsigned char nco_char; /* [typ] NC_CHAR */
 # define NCO_CHAR_SNG "unsigned char"
 # define NCO_CHAR_IO_SFX uchar
 # define NCO_GET_ATT_CHAR nc_get_att_uchar
+# define NCO_GET_VAR_CHAR nc_get_var_uchar
 # define NCO_GET_VAR1_CHAR nc_get_var1_uchar
 # define NCO_GET_VARA_CHAR nc_get_vara_uchar
 # define NCO_GET_VARS_CHAR nc_get_vars_uchar
 # define NCO_GET_VARM_CHAR nc_get_varm_uchar
 # define NCO_PUT_ATT_CHAR nc_put_att_uchar
+# define NCO_PUT_VAR_CHAR nc_put_var_uchar
 # define NCO_PUT_VAR1_CHAR nc_put_var1_uchar
 # define NCO_PUT_VARA_CHAR nc_put_vara_uchar
 # define NCO_PUT_VARS_CHAR nc_put_vars_uchar
@@ -294,11 +309,13 @@ typedef unsigned short nco_ushort; /* [typ] NC_USHORT */
 # define NCO_USHORT_SNG "unsigned short"
 # define NCO_USHORT_IO_SFX ushort
 # define NCO_GET_ATT_USHORT nc_get_att_ushort
+# define NCO_GET_VAR_USHORT nc_get_var_ushort
 # define NCO_GET_VAR1_USHORT nc_get_var1_ushort
 # define NCO_GET_VARA_USHORT nc_get_vara_ushort
 # define NCO_GET_VARS_USHORT nc_get_vars_ushort
 # define NCO_GET_VARM_USHORT nc_get_varm_ushort
 # define NCO_PUT_ATT_USHORT nc_put_att_ushort
+# define NCO_PUT_VAR_USHORT nc_put_var_ushort
 # define NCO_PUT_VAR1_USHORT nc_put_var1_ushort
 # define NCO_PUT_VARA_USHORT nc_put_vara_ushort
 # define NCO_PUT_VARS_USHORT nc_put_vars_ushort
@@ -320,11 +337,13 @@ typedef int nco_int; /* [typ] NC_INT */
 # define NCO_INT_SNG "int"
 # define NCO_INT_IO_SFX int
 # define NCO_GET_ATT_INT nc_get_att_int
+# define NCO_GET_VAR_INT nc_get_var_int
 # define NCO_GET_VAR1_INT nc_get_var1_int
 # define NCO_GET_VARA_INT nc_get_vara_int
 # define NCO_GET_VARS_INT nc_get_vars_int
 # define NCO_GET_VARM_INT nc_get_varm_int
 # define NCO_PUT_ATT_INT nc_put_att_int
+# define NCO_PUT_VAR_INT nc_put_var_int
 # define NCO_PUT_VAR1_INT nc_put_var1_int
 # define NCO_PUT_VARA_INT nc_put_vara_int
 # define NCO_PUT_VARS_INT nc_put_vars_int
@@ -335,11 +354,13 @@ typedef long nco_int; /* [typ] NC_INT */
 # define NCO_INT_SNG "long"
 # define NCO_INT_IO_SFX long
 # define NCO_GET_ATT_INT nc_get_att_long
+# define NCO_GET_VAR_INT nc_get_var_long
 # define NCO_GET_VAR1_INT nc_get_var1_long
 # define NCO_GET_VARA_INT nc_get_vara_long
 # define NCO_GET_VARS_INT nc_get_vars_long
 # define NCO_GET_VARM_INT nc_get_varm_long
 # define NCO_PUT_ATT_INT nc_put_att_long
+# define NCO_PUT_VAR_INT nc_put_var_long
 # define NCO_PUT_VAR1_INT nc_put_var1_long
 # define NCO_PUT_VARA_INT nc_put_vara_long
 # define NCO_PUT_VARS_INT nc_put_vars_long
@@ -360,11 +381,13 @@ typedef unsigned int nco_uint; /* [typ] NC_UINT */
 # define NCO_UINT_SNG "unsigned int"
 # define NCO_UINT_IO_SFX uint
 # define NCO_GET_ATT_UINT nc_get_att_uint
+# define NCO_GET_VAR_UINT nc_get_var_uint
 # define NCO_GET_VAR1_UINT nc_get_var1_uint
 # define NCO_GET_VARA_UINT nc_get_vara_uint
 # define NCO_GET_VARS_UINT nc_get_vars_uint
 # define NCO_GET_VARM_UINT nc_get_varm_uint
 # define NCO_PUT_ATT_UINT nc_put_att_uint
+# define NCO_PUT_VAR_UINT nc_put_var_uint
 # define NCO_PUT_VAR1_UINT nc_put_var1_uint
 # define NCO_PUT_VARA_UINT nc_put_vara_uint
 # define NCO_PUT_VARS_UINT nc_put_vars_uint
@@ -385,11 +408,13 @@ typedef long long nco_int64; /* [typ] NC_INT64 */
 # define NCO_INT64_SNG "long long"
 # define NCO_INT64_IO_SFX longlong
 # define NCO_GET_ATT_INT64 nc_get_att_longlong
+# define NCO_GET_VAR_INT64 nc_get_var_longlong
 # define NCO_GET_VAR1_INT64 nc_get_var1_longlong
 # define NCO_GET_VARA_INT64 nc_get_vara_longlong
 # define NCO_GET_VARS_INT64 nc_get_vars_longlong
 # define NCO_GET_VARM_INT64 nc_get_varm_longlong
 # define NCO_PUT_ATT_INT64 nc_put_att_longlong
+# define NCO_PUT_VAR_INT64 nc_put_var_longlong
 # define NCO_PUT_VAR1_INT64 nc_put_var1_longlong
 # define NCO_PUT_VARA_INT64 nc_put_vara_longlong
 # define NCO_PUT_VARS_INT64 nc_put_vars_longlong
@@ -410,11 +435,13 @@ typedef unsigned long long nco_uint64; /* [typ] NC_UINT64 */
 # define NCO_UINT64_SNG "unsigned long long"
 # define NCO_UINT64_IO_SFX ulonglong
 # define NCO_GET_ATT_UINT64 nc_get_att_ulonglong
+# define NCO_GET_VAR_UINT64 nc_get_var_ulonglong
 # define NCO_GET_VAR1_UINT64 nc_get_var1_ulonglong
 # define NCO_GET_VARA_UINT64 nc_get_vara_ulonglong
 # define NCO_GET_VARS_UINT64 nc_get_vars_ulonglong
 # define NCO_GET_VARM_UINT64 nc_get_varm_ulonglong
 # define NCO_PUT_ATT_UINT64 nc_put_att_ulonglong
+# define NCO_PUT_VAR_UINT64 nc_put_var_ulonglong
 # define NCO_PUT_VAR1_UINT64 nc_put_var1_ulonglong
 # define NCO_PUT_VARA_UINT64 nc_put_vara_ulonglong
 # define NCO_PUT_VARS_UINT64 nc_put_vars_ulonglong
@@ -436,12 +463,14 @@ typedef char * nco_string; /* [typ] NC_STRING */
 # define NCO_STRING_SNG "char *"
 # define NCO_STRING_IO_SFX string
 # define NCO_GET_ATT_STRING nc_get_att_string
+# define NCO_GET_VAR_STRING nc_get_var_string
 # define NCO_GET_VAR1_STRING nc_get_var1_string
 # define NCO_GET_VARA_STRING nc_get_vara_string
 # define NCO_GET_VARS_STRING nc_get_vars_string
 # define NCO_GET_VARM_STRING nc_get_varm_string
 /* nc_put_att_string() is unique---it uses strlen() to determine argument length */
 # define NCO_PUT_ATT_STRING(a,b,c,d,e,f) nc_put_att_string(a,b,c,e,f)
+# define NCO_PUT_VAR_STRING nc_put_var_string
 # define NCO_PUT_VAR1_STRING nc_put_var1_string
 # define NCO_PUT_VARA_STRING nc_put_vara_string
 # define NCO_PUT_VARS_STRING nc_put_vars_string
diff --git a/src/nco/nco_var_lst.c b/src/nco/nco_var_lst.c
index 52ef4d7..39dcc54 100644
--- a/src/nco/nco_var_lst.c
+++ b/src/nco/nco_var_lst.c
@@ -1135,7 +1135,9 @@ nco_var_lst_dvd_trv                          /* [fnc] Divide input lists into ou
      20130112: As of today set is_crd_var true in nco_var_fll() when either of these conditions is true 
      so no longer need to specify these conditions separately. 
      20150519: Add nco_is_spc_in_clm_att() to this list
+     20160420: Add nco_is_spc_in_grd_att() to this list
      Keep this old code here as a reminder that is_crd_var also incorporates these conditions
+     is_spc_in_grd_att=nco_is_spc_in_grd_att(var[idx]->nc_id,var[idx]->id);
      is_spc_in_clm_att=nco_is_spc_in_clm_att(var[idx]->nc_id,var[idx]->id);
      is_spc_in_crd_att=nco_is_spc_in_crd_att(var[idx]->nc_id,var[idx]->id);
      is_spc_in_bnd_att=nco_is_spc_in_bnd_att(var[idx]->nc_id,var[idx]->id); */
diff --git a/src/nco/nco_var_utl.c b/src/nco/nco_var_utl.c
index b8b75e6..abfbbb0 100644
--- a/src/nco/nco_var_utl.c
+++ b/src/nco/nco_var_utl.c
@@ -1095,7 +1095,7 @@ var_dfl_set /* [fnc] Set defaults for each member of variable structure */
   var->undefined=False; /* [flg] Used by ncap parser */
   var->is_fix_var=True; /* Is this a fixed (non-processed) variable? */
   var->dfl_lvl=NCO_DFL_LVL_UNDEFINED; /* [enm] Deflate level */
-  var->shuffle=NC_NOSHUFFLE; /* [flg] Turn on shuffle filter */
+  var->shuffle=NC_NOSHUFFLE; /* [flg] Turn-on shuffle filter */
   /* Members related to packing */
   var->has_scl_fct=False; /* [flg] Valid scale_factor attribute exists */
   var->has_add_fst=False; /* [flg] Valid add_offset attribute exists */
@@ -1226,8 +1226,8 @@ nco_var_dfn /* [fnc] Define variables and write their attributes to output file
       if(fl_fmt == NC_FORMAT_NETCDF4 || fl_fmt == NC_FORMAT_NETCDF4_CLASSIC){
         /* Deflation */
         if(dmn_nbr > 0){
-          int shuffle; /* [flg] Turn on shuffle filter */
-          int deflate; /* [flg] Turn on deflate filter */
+          int shuffle; /* [flg] Turn-on shuffle filter */
+          int deflate; /* [flg] Turn-on deflate filter */
           int dfl_lvl_in; /* [enm] Deflate level [0..9] */
           int var_in_id;
           /* Uncertain that output name always exists in input file */
@@ -1236,7 +1236,7 @@ nco_var_dfn /* [fnc] Define variables and write their attributes to output file
             /* When output name is in input file, inquire input deflation level */
             rcd=nco_inq_var_deflate(in_id,var_in_id,&shuffle,&deflate,&dfl_lvl_in);
             /* Copy original deflation settings */
-            if(deflate || shuffle) (void)nco_def_var_deflate(out_id,var[idx]->id,deflate,shuffle,dfl_lvl_in);
+            if(deflate || shuffle) (void)nco_def_var_deflate(out_id,var[idx]->id,shuffle,deflate,dfl_lvl_in);
           }else{
 	    /* Shuffle never, to my knowledge, increases filesize, so shuffle by default when manually deflating */
 	    shuffle=NC_SHUFFLE;
@@ -1463,7 +1463,7 @@ nco_is_spc_in_bnd_att /* [fnc] Variable is listed in a "bounds" attribute */
  const int var_trg_id) /* I [id] Variable ID */
 {
   /* Purpose: Is variable specified in a "bounds" attribute?
-     Typical variables that appear in a "bounds" attribute include "lat_bnds", "lon_bnds", etc.
+     Typical variables that appear in a "bounds" attribute include "lat_bnds", "lon_bnds", "time_bnds", etc.
      Such variables may be "multi-dimensional coordinates" that should
      undergo special treatment by arithmetic operators.
      Routine based on nco_is_spc_in_crd_att() */
@@ -1537,7 +1537,7 @@ nco_is_spc_in_clm_att /* [fnc] Variable is listed in a "climatology" attribute *
  const int var_trg_id) /* I [id] Variable ID */
 {
   /* Purpose: Is variable specified in a "climatology" attribute?
-     Typical variables that appear in a "climatology" attribute include "lat_bnds", "lon_bnds", etc.
+     Typical variables that appear in a "climatology" attribute include "climatology_bounds"
      Such variables may be "multi-dimensional coordinates" that should
      undergo special treatment by arithmetic operators.
      Routine based on nco_is_spc_in_crd_att() */
@@ -1605,6 +1605,80 @@ nco_is_spc_in_clm_att /* [fnc] Variable is listed in a "climatology" attribute *
   return IS_SPC_IN_CLM_ATT; /* [flg] Variable is listed in a "climatology" attribute  */
 } /* end nco_is_spc_in_clm_att() */
 
+nco_bool /* [flg] Variable is listed in a "grid_mapping" attribute */
+nco_is_spc_in_grd_att /* [fnc] Variable is listed in a "grid_mapping" attribute */
+(const int nc_id, /* I [id] netCDF file ID */
+ const int var_trg_id) /* I [id] Variable ID */
+{
+  /* Purpose: Is variable specified in a "grid_mapping" attribute?
+     Typical variables that appear in a "grid_mapping" attribute include "albers_conical_equal_area"
+     Such variables may be "multi-dimensional coordinates" that should
+     undergo special treatment by arithmetic operators.
+     Routine based on nco_is_spc_in_crd_att() */
+  nco_bool IS_SPC_IN_GRD_ATT=False; /* [flg] Variable is listed in a "grid_mapping" attribute  */
+
+  const char dlm_sng[]=" "; /* [sng] Delimiter string */
+  const char fnc_nm[]="nco_is_spc_in_grd_att()"; /* [sng] Function name */
+  char **grd_lst; /* [sng] 1D array of list elements */
+  char *att_val;
+  char att_nm[NC_MAX_NAME];
+  char var_nm[NC_MAX_NAME];
+  char var_trg_nm[NC_MAX_NAME];
+  int idx_att;
+  int idx_grd;
+  int idx_var;
+  int nbr_att;
+  int nbr_grd; /* [nbr] Number of coordinates specified in "grid_mapping" attribute */
+  int nbr_var; /* [nbr] Number of variables in file */
+  int rcd=NC_NOERR; /* [rcd] Return code */
+  int var_id; /* [id] Variable ID */
+  long att_sz;
+  nc_type att_typ;
+
+  /* May need variable name for later comparison to "grid_mapping" attribute */
+  rcd+=nco_inq_varname(nc_id,var_trg_id,var_trg_nm);
+  rcd+=nco_inq_nvars(nc_id,&nbr_var);
+
+  for(idx_var=0;idx_var<nbr_var;idx_var++){
+    /* This assumption, praise the Lord, is valid in netCDF2, netCDF3, and netCDF4 */
+    var_id=idx_var;
+
+    /* Find number of attributes */
+    rcd+=nco_inq_varnatts(nc_id,var_id,&nbr_att);
+    for(idx_att=0;idx_att<nbr_att;idx_att++){
+      rcd+=nco_inq_attname(nc_id,var_id,idx_att,att_nm);
+      /* Is attribute part of CF convention? */
+      if(!strcmp(att_nm,"grid_mapping")){
+        /* Yes, get list of specified attributes */
+        rcd+=nco_inq_att(nc_id,var_id,att_nm,&att_typ,&att_sz);
+        if(att_typ != NC_CHAR){
+          rcd=nco_inq_varname(nc_id,var_id,var_nm);
+          (void)fprintf(stderr,"%s: WARNING the \"%s\" attribute for variable %s is type %s, not %s. This violates the CF convention for specifying additional attributes. Therefore %s will skip this attribute.\n",nco_prg_nm_get(),att_nm,var_nm,nco_typ_sng(att_typ),nco_typ_sng(NC_CHAR),fnc_nm);
+          return IS_SPC_IN_GRD_ATT;
+        } /* end if */
+        att_val=(char *)nco_malloc((att_sz+1L)*sizeof(char));
+        if(att_sz > 0) rcd=nco_get_att(nc_id,var_id,att_nm,(void *)att_val,NC_CHAR);	  
+        /* NUL-terminate attribute */
+        att_val[att_sz]='\0';
+        /* Split list into separate coordinate names
+	   Use nco_lst_prs_sgl_2D() not nco_lst_prs_2D() to avert TODO nco944 */
+        grd_lst=nco_lst_prs_sgl_2D(att_val,dlm_sng,&nbr_grd);
+        /* ...for each coordinate in "grid_mapping" attribute... */
+        for(idx_grd=0;idx_grd<nbr_grd;idx_grd++){
+          /* Does variable match name specified in coordinate list? */
+          if(!strcmp(var_trg_nm,grd_lst[idx_grd])) break;
+        } /* end loop over coordinates in list */
+        if(idx_grd!=nbr_grd) IS_SPC_IN_GRD_ATT=True;
+        /* Free allocated memory */
+        att_val=(char *)nco_free(att_val);
+        grd_lst=nco_sng_lst_free(grd_lst,nbr_grd);
+      } /* !coordinates */
+    } /* end loop over attributes */
+  } /* end loop over idx_var */
+
+  return IS_SPC_IN_GRD_ATT; /* [flg] Variable is listed in a "grid_mapping" attribute  */
+} /* end nco_is_spc_in_grd_att() */
+
 void
 nco_var_mtd_refresh /* [fnc] Update variable metadata (dmn_nbr, ID, mss_val, type) */
 (const int nc_id, /* I [id] netCDF input-file ID */
@@ -1651,7 +1725,7 @@ nco_var_mtd_refresh /* [fnc] Update variable metadata (dmn_nbr, ID, mss_val, typ
      Hence there is no reason to track current storage properties in var_sct
      However, if that ever changes, here are hooks to do so */
   if(False && var->nbr_dim > 0){
-    int deflate; /* [flg] Turn on deflate filter */
+    int deflate; /* [flg] Turn-on deflate filter */
     int srg_typ; /* [enm] Storage type */
     rcd+=nco_inq_var_deflate(var->nc_id,var->id,&var->shuffle,&deflate,&var->dfl_lvl);
     rcd+=nco_inq_var_chunking(var->nc_id,var->id,&srg_typ,var->cnk_sz);
@@ -1842,11 +1916,12 @@ nco_var_fll /* [fnc] Allocate variable structure and fill with metadata */
     var->sz*=var->cnt[idx];
   } /* end loop over dim */
   
-  /* 20130112: Variables associated with "bounds", "climatology", and "coordinates" attributes should,
+  /* 20130112: Variables associated with "bounds", "climatology", "coordinates", and "grid_mapping" attributes should,
      in most cases, be treated as coordinates */
   if(nco_is_spc_in_bnd_att(var->nc_id,var->id)) var->is_crd_var=True;
   if(nco_is_spc_in_clm_att(var->nc_id,var->id)) var->is_crd_var=True;
   if(nco_is_spc_in_crd_att(var->nc_id,var->id)) var->is_crd_var=True;
+  if(nco_is_spc_in_grd_att(var->nc_id,var->id)) var->is_crd_var=True;
   
   /* Portions of variable structure depend on packing properties, e.g., typ_upk
      nco_pck_dsk_inq() fills in these portions harmlessly */
@@ -1854,7 +1929,7 @@ nco_var_fll /* [fnc] Allocate variable structure and fill with metadata */
   
   /* Set deflate and chunking to defaults */  
   var->dfl_lvl=NCO_DFL_LVL_UNDEFINED; /* [enm] Deflate level */
-  var->shuffle=NC_NOSHUFFLE; /* [flg] Turn on shuffle filter */
+  var->shuffle=NC_NOSHUFFLE; /* [flg] Turn-on shuffle filter */
   
   for(idx=0;idx<var->nbr_dim;idx++) var->cnk_sz[idx]=(size_t)0L;
   
diff --git a/src/nco/nco_var_utl.h b/src/nco/nco_var_utl.h
index 2adb3d3..ce84d21 100644
--- a/src/nco/nco_var_utl.h
+++ b/src/nco/nco_var_utl.h
@@ -31,7 +31,7 @@
 /* Personal headers */
 #include "nco.h" /* netCDF Operator (NCO) definitions */
 #include "nco_att_utl.h" /* Attribute utilities */
-#include "nco_bnr.h" /* Binary write utilities */
+#include "nco_bnr.h" /* Binary file utilities */
 #include "nco_ctl.h" /* Program flow control functions */
 #include "nco_dmn_utl.h" /* Dimension utilities */
 #include "nco_grp_trv.h" /* Group traversal */
@@ -134,6 +134,11 @@ extern "C" {
   (const int nc_id, /* I [id] netCDF file ID */
    const int var_trg_id); /* I [id] Variable ID */
   
+  nco_bool /* [flg] Variable is listed in a "grid_mapping" attribute */
+  nco_is_spc_in_grd_att /* [fnc] Variable is listed in a "grid_mapping" attribute */
+  (const int nc_id, /* I [id] netCDF file ID */
+   const int var_trg_id); /* I [id] Variable ID */
+
   void
   nco_var_mtd_refresh /* [fnc] Update variable metadata (dmn_nbr, ID, mss_val, type) */
   (const int nc_id, /* I [id] netCDF input-file ID */
diff --git a/src/nco/ncpdq.c b/src/nco/ncpdq.c
index 77a4ff5..bfb61a2 100644
--- a/src/nco/ncpdq.c
+++ b/src/nco/ncpdq.c
@@ -130,9 +130,7 @@ main(int argc,char **argv)
   ddra_info_sct ddra_info={.flg_ddra=False};
 #endif /* !__cplusplus */
 
-  dmn_sct **dim=NULL_CEWI;
-  dmn_sct **dmn_out;
-  dmn_sct **dmn_rdr=NULL; /* [sct] Dimension structures to be re-ordered */
+  dmn_sct **dmn_rdr_trv=NULL; /* [sct] Dimension structures to be re-ordered (from global table) */
 
   extern char *optarg;
   extern int optind;
@@ -153,6 +151,7 @@ main(int argc,char **argv)
   int cnk_plc=nco_cnk_plc_nil; /* [enm] Chunking policy */
   int dfl_lvl=NCO_DFL_LVL_UNDEFINED; /* [enm] Deflate level */
   int dmn_rdr_nbr=0; /* [nbr] Number of dimension to re-order */
+  int dmn_rdr_nbr_trv=0; /* [nbr] Number of dimension to re-order (from global table) */
   int dmn_rdr_nbr_in=0; /* [nbr] Original number of dimension to re-order */
   int fl_idx=int_CEWI;
   int fl_nbr=0;
@@ -166,7 +165,6 @@ main(int argc,char **argv)
   int lmt_nbr=0; /* Option d. NB: lmt_nbr gets incremented */
   int md_open; /* [enm] Mode flag for nc_open() call */
   int nbr_dmn_fl;
-  int nbr_dmn_xtr;
   int nbr_var_fix; /* nbr_var_fix gets incremented */
   int nbr_var_fl;
   int nbr_var_prc; /* nbr_var_prc gets incremented */
@@ -281,6 +279,7 @@ main(int argc,char **argv)
     {"ppc",required_argument,0,0}, /* [nbr] Precision-preserving compression, i.e., number of total or decimal significant digits */
     {"precision_preserving_compression",required_argument,0,0}, /* [nbr] Precision-preserving compression, i.e., number of total or decimal significant digits */
     {"quantize",required_argument,0,0}, /* [nbr] Precision-preserving compression, i.e., number of total or decimal significant digits */
+    {"upk",required_argument,0,0}, /* [enm] Unpacking convention to utilize */
     /* Long options with short counterparts */
     {"3",no_argument,0,'3'},
     {"4",no_argument,0,'4'},
@@ -327,7 +326,6 @@ main(int argc,char **argv)
     {"threads",required_argument,0,'t'},
     {"omp_num_threads",required_argument,0,'t'},
     {"unpack",no_argument,0,'U'},
-    {"upk",no_argument,0,'U'},
     {"variable",required_argument,0,'v'},
     {"auxiliary",required_argument,0,'X'},
     {"exclude",no_argument,0,'x'},
@@ -407,7 +405,7 @@ main(int argc,char **argv)
         gaa_arg[gaa_nbr++]=(char *)strdup(optarg);
       } /* endif gaa */
       if(!strcmp(opt_crr,"hdf4")) nco_fmt_xtn=nco_fmt_xtn_hdf4; /* [enm] Treat file as HDF4 */
-      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
+      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF_MOD10; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
       if(!strcmp(opt_crr,"hdr_pad") || !strcmp(opt_crr,"header_pad")){
         hdr_pad=strtoul(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
         if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtoul",sng_cnv_rcd);
@@ -422,6 +420,10 @@ main(int argc,char **argv)
       if(!strcmp(opt_crr,"ram_all") || !strcmp(opt_crr,"open_ram") || !strcmp(opt_crr,"diskless_all")) RAM_OPEN=True; /* [flg] Create file in RAM */
       if(!strcmp(opt_crr,"unn") || !strcmp(opt_crr,"union")) GRP_VAR_UNN=True;
       if(!strcmp(opt_crr,"nsx") || !strcmp(opt_crr,"intersection")) GRP_VAR_UNN=False;
+      if(!strcmp(opt_crr,"upk")){ /* [enm] Unpacking convention to utilize */
+        nco_upk_cnv=(int)strtol(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
+        if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtol",sng_cnv_rcd);
+      } /* endif "hdr_pad" */
       if(!strcmp(opt_crr,"vrs") || !strcmp(opt_crr,"version")){
         (void)nco_vrs_prn(CVS_Id,CVS_Revision);
         nco_exit(EXIT_SUCCESS);
@@ -605,13 +607,13 @@ main(int argc,char **argv)
     /* Is dimension to be reversed? i.e., does string begin with minus-sign '-'? */
     for(idx_rdr=0;idx_rdr<dmn_rdr_nbr_in;idx_rdr++){
       if(dmn_rdr_lst_in[idx_rdr][0] == '-'){
-	dmn_rvr_rdr[idx_rdr]=True;
+        dmn_rvr_rdr[idx_rdr]=True;
         /* Strip-out '-': Copy string to new memory one past negative sign to avoid losing byte */
         optarg_lcl=dmn_rdr_lst_in[idx_rdr];
         dmn_rdr_lst_in[idx_rdr]=(char *)strdup(optarg_lcl+1L);
         optarg_lcl=(char *)nco_free(optarg_lcl);
       }else{
-	dmn_rvr_rdr[idx_rdr]=False;
+        dmn_rvr_rdr[idx_rdr]=False;
       } /* !'-' */
     } /* !idx_rdr */
   } /* !dmn_rdr_nbr_in */
@@ -619,23 +621,8 @@ main(int argc,char **argv)
   /* Get number of variables, dimensions, and global attributes in file, file format */
   (void)trv_tbl_inq((int *)NULL,(int *)NULL,(int *)NULL,&nbr_dmn_fl,(int *)NULL,(int *)NULL,(int *)NULL,(int *)NULL,&nbr_var_fl,trv_tbl);
 
-  /* Allocate array of dimensions associated with variables to be extracted with maximum possible size */
-  dim=(dmn_sct **)nco_malloc(nbr_dmn_fl*sizeof(dmn_sct *));
-
-  /* Find dimensions associated with variables to be extracted */
-  (void)nco_dmn_lst_ass_var_trv(in_id,trv_tbl,&nbr_dmn_xtr,&dim);
-
-  dim=(dmn_sct **)nco_realloc(dim,nbr_dmn_xtr*sizeof(dmn_sct *));
-
-  /* Duplicate input dimension structures for output dimension structures */
-  dmn_out=(dmn_sct **)nco_malloc(nbr_dmn_xtr*sizeof(dmn_sct *));
-  for(idx=0;idx<nbr_dmn_xtr;idx++){
-    dmn_out[idx]=nco_dmn_dpl(dim[idx]);
-    (void)nco_dmn_xrf(dim[idx],dmn_out[idx]);
-  } /* end loop over extracted dimensions */
-
   /* Create list of dimensions to average(ncwa)/re-order(ncpdq) */
-  if(IS_REORDER) (void)nco_dmn_avg_mk(in_id,dmn_rdr_lst_in,dmn_rdr_nbr_in,flg_dmn_prc_usr_spc,False,trv_tbl,&dmn_rdr,&dmn_rdr_nbr);
+  if(IS_REORDER) (void)nco_dmn_avg_mk(in_id,dmn_rdr_lst_in,dmn_rdr_nbr_in,flg_dmn_prc_usr_spc,False,trv_tbl,&dmn_rdr_trv,&dmn_rdr_nbr_trv);
 
   /* Fill-in variable structure list for all extracted variables */
   var=nco_fll_var_trv(in_id,&xtr_nbr,trv_tbl);
@@ -655,7 +642,7 @@ main(int argc,char **argv)
   CNV_CCM_CCSM_CF=nco_cnv_ccm_ccsm_cf_inq(in_id);
 
   /* Divide variable lists into lists of fixed variables and variables to be processed */
-  (void)nco_var_lst_dvd(var,var_out,xtr_nbr,CNV_CCM_CCSM_CF,True,nco_pck_map,nco_pck_plc,dmn_rdr,dmn_rdr_nbr,&var_fix,&var_fix_out,&nbr_var_fix,&var_prc,&var_prc_out,&nbr_var_prc,trv_tbl);
+  (void)nco_var_lst_dvd(var,var_out,xtr_nbr,CNV_CCM_CCSM_CF,True,nco_pck_map,nco_pck_plc,dmn_rdr_trv,dmn_rdr_nbr_trv,&var_fix,&var_fix_out,&nbr_var_fix,&var_prc,&var_prc_out,&nbr_var_prc,trv_tbl);
 
   /* Store processed and fixed variables info into GTT */
   (void)nco_var_prc_fix_trv(nbr_var_prc,var_prc,nbr_var_fix,var_fix,trv_tbl);
@@ -672,13 +659,47 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Initialize chunking from user-specified inputs */
   if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) rcd+=nco_cnk_ini(in_id,fl_out,cnk_arg,cnk_nbr,cnk_map,cnk_plc,cnk_min_byt,cnk_sz_byt,cnk_sz_scl,&cnk);
 
-  /* Determine and set new dimensionality in metadata of each re-ordered variable */
-  if(IS_REORDER) (void)nco_var_dmn_rdr_mtd_trv(trv_tbl,nbr_var_prc,var_prc,var_prc_out,nbr_var_fix,var_fix,dmn_rdr,dmn_rdr_nbr,dmn_rvr_rdr);
+  if(IS_REORDER){
+
+    dmn_sct **dmn_rdr=NULL; /* [sct] Dimension structures to be re-ordered */
+
+    /* "dmn_rdr" is only used for input to function nco_var_dmn_rdr_mtd(), that compares dimensions by short name;
+       this is because the input list of -a are dimension short names; group support is obtained combining with -g option;
+       on input it contains a list of dimension short names (in "dmn_rdr"), that together with input array "dmn_rvr_rdr"
+       of flags that determine if dimension at index dmn_rvr_rdr[index] is to be reversed; use cases:
+       in_grp_8.nc contains the dimensions /g1/lat, /g1/lon, /g2/lat, /g2/lon
+       ncpdq -O -v lat,lon -a -lat,-lon -g g1,g2 ~/nco/data/in_grp_8.nc out1.nc
+       "dmn_rdr" contains names ["lat"], ["lon"],  striped of '-' (minus) sign and dmn_rvr_rdr contains [True],[True ]
+       output is reversed /g1/lat, /g1/lon, /g2/lat, /g2/lon
+       ncpdq -O -v lat,lon -a lat,-lon -g g1,g2 ~/nco/data/in_grp_8.nc out1.nc
+       "dmn_rdr" contains names ["lat"], ["lon"], and dmn_rvr_rdr contains [False],[True ] 
+       output is reversed /g1/lon, /g2/lon */
+
+    /* Form list of re-ordering dimensions from extracted input dimensions */
+    dmn_rdr=(dmn_sct **)nco_malloc(dmn_rdr_nbr*sizeof(dmn_sct *));
+
+    /* Initialize re-ordering dimensions; initialize only short name */
+    for(idx_rdr=0;idx_rdr<dmn_rdr_nbr_in;idx_rdr++){
+      dmn_rdr[idx_rdr]=(dmn_sct *)nco_malloc(sizeof(dmn_sct));
+      dmn_rdr[idx_rdr]->nm=(char *)strdup(dmn_rdr_lst_in[idx_rdr]);
+      dmn_rdr[idx_rdr]->nm_fll=NULL;
+      dmn_rdr[idx_rdr]->id=-1;
+    }
+
+    /* Determine and set new dimensionality in metadata of each re-ordered variable */
+    (void)nco_var_dmn_rdr_mtd_trv(trv_tbl,nbr_var_prc,var_prc,var_prc_out,nbr_var_fix,var_fix,dmn_rdr,dmn_rdr_nbr,dmn_rvr_rdr);
+
+    for(idx_rdr=0; idx_rdr<dmn_rdr_nbr_in; idx_rdr++){
+      dmn_rdr[idx_rdr]->nm=(char *)nco_free(dmn_rdr[idx_rdr]->nm);
+      dmn_rdr[idx_rdr]=(dmn_sct *)nco_free(dmn_rdr[idx_rdr]);
+    }
+    dmn_rdr=(dmn_sct **)nco_free(dmn_rdr);
+  } /* IS_REORDER */
 
   /* Alter metadata for variables that will be packed */
   if(nco_pck_plc != nco_pck_plc_nil){
@@ -710,7 +731,7 @@ main(int argc,char **argv)
   if(HISTORY_APPEND) (void)nco_vrs_att_cat(out_id);
   if(thr_nbr > 0 && HISTORY_APPEND) (void)nco_thr_att_cat(out_id,thr_nbr);
 
-  /* Turn off default filling behavior to enhance efficiency */
+  /* Turn-off default filling behavior to enhance efficiency */
   nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 
   /* Take output file out of define mode */
@@ -813,10 +834,10 @@ main(int argc,char **argv)
       } /* endif nco_pck_plc != nco_pck_plc_nil */
 
       if(var_trv->ppc != NC_MAX_INT){
-	if(var_trv->flg_nsd) (void)nco_ppc_bitmask(var_trv->ppc,var_prc_out[idx]->type,var_prc_out[idx]->sz,var_prc_out[idx]->has_mss_val,var_prc_out[idx]->mss_val,var_prc_out[idx]->val); else (void)nco_ppc_around(var_trv->ppc,var_prc_out[idx]->type,var_prc_out[idx]->sz,var_prc_out[idx]->has_mss_val,var_prc_out[idx]->mss_val,var_prc_out[idx]->val);
+        if(var_trv->flg_nsd) (void)nco_ppc_bitmask(var_trv->ppc, var_prc_out[idx]->type, var_prc_out[idx]->sz, var_prc_out[idx]->has_mss_val, var_prc_out[idx]->mss_val, var_prc_out[idx]->val); else (void)nco_ppc_around(var_trv->ppc, var_prc_out[idx]->type, var_prc_out[idx]->sz, var_prc_out[idx]->has_mss_val, var_prc_out[idx]->mss_val, var_prc_out[idx]->val);
       } /* endif ppc */
       if(nco_is_xcp(var_trv->nm)) nco_xcp_prc(var_trv->nm,var_prc_out[idx]->type,var_prc_out[idx]->sz,(char *)var_prc_out[idx]->val.vp);
-	
+
 #ifdef _OPENMP
 #pragma omp critical
 #endif /* _OPENMP */
@@ -868,22 +889,22 @@ main(int argc,char **argv)
         /* nco_var_dfn() pre-defined dummy packing attributes in output file only for "packable" input variables */
         if(nco_pck_plc_typ_get(nco_pck_map,var_prc[idx]->typ_upk,(nc_type *)NULL)){
           /* Verify input variable was newly packed by this operator
-	     Writing pre-existing (non-re-packed) attributes here would fail because
-	     nco_pck_dsk_inq() never fills in var->scl_fct.vp and var->add_fst.vp
-	     Logic is same as in nco_var_dfn() (except var_prc[] instead of var[])
-	     If operator newly packed this particular variable... */
+            Writing pre-existing (non-re-packed) attributes here would fail because
+            nco_pck_dsk_inq() never fills in var->scl_fct.vp and var->add_fst.vp
+            Logic is same as in nco_var_dfn() (except var_prc[] instead of var[])
+            If operator newly packed this particular variable... */
           if(
-	     /* ...either because operator newly packs all variables... */
-	     (nco_pck_plc == nco_pck_plc_all_new_att) ||
-	     /* ...or because operator newly packs un-packed variables like this one... */
-	     (nco_pck_plc == nco_pck_plc_all_xst_att && !var_prc[idx]->pck_ram) ||
-	     /* ...or because operator re-packs packed variables like this one... */
-	     (nco_pck_plc == nco_pck_plc_xst_new_att && var_prc[idx]->pck_ram)
-	     ){
-	    /* Replace dummy packing attributes with final values, or delete them */
-	    if(nco_dbg_lvl >= nco_dbg_io) (void)fprintf(stderr,"%s: main() replacing dummy packing attribute values for variable %s\n",nco_prg_nm,var_prc[idx]->nm);
-	    (void)nco_aed_prc(grp_out_id,aed_lst_add_fst[idx].id,aed_lst_add_fst[idx]);
-	    (void)nco_aed_prc(grp_out_id,aed_lst_scl_fct[idx].id,aed_lst_scl_fct[idx]);
+            /* ...either because operator newly packs all variables... */
+            (nco_pck_plc == nco_pck_plc_all_new_att) ||
+            /* ...or because operator newly packs un-packed variables like this one... */
+            (nco_pck_plc == nco_pck_plc_all_xst_att && !var_prc[idx]->pck_ram) ||
+            /* ...or because operator re-packs packed variables like this one... */
+            (nco_pck_plc == nco_pck_plc_xst_new_att && var_prc[idx]->pck_ram)
+            ){
+            /* Replace dummy packing attributes with final values, or delete them */
+            if(nco_dbg_lvl >= nco_dbg_io) (void)fprintf(stderr,"%s: main() replacing dummy packing attribute values for variable %s\n",nco_prg_nm,var_prc[idx]->nm);
+            (void)nco_aed_prc(grp_out_id,aed_lst_add_fst[idx].id,aed_lst_add_fst[idx]);
+            (void)nco_aed_prc(grp_out_id,aed_lst_scl_fct[idx].id,aed_lst_scl_fct[idx]);
           } /* endif variable is newly packed by this operator */
         } /* !nco_pck_plc_alw */
       } /* end loop over var_prc */
@@ -911,7 +932,12 @@ main(int argc,char **argv)
       if(dmn_rdr_nbr_in > 0) dmn_rdr_lst_in=nco_sng_lst_free(dmn_rdr_lst_in,dmn_rdr_nbr_in);
       dmn_rvr_rdr=(nco_bool *)nco_free(dmn_rvr_rdr);
       /* Free dimension list pointers */
-      dmn_rdr=(dmn_sct **)nco_free(dmn_rdr);
+      for(idx_rdr=0; idx_rdr<dmn_rdr_nbr_trv; idx_rdr++){
+        dmn_rdr_trv[idx_rdr]->nm=(char *)nco_free(dmn_rdr_trv[idx_rdr]->nm);
+        dmn_rdr_trv[idx_rdr]->nm_fll=(char *)nco_free(dmn_rdr_trv[idx_rdr]->nm_fll);
+        dmn_rdr_trv[idx_rdr]=(dmn_sct *)nco_free(dmn_rdr_trv[idx_rdr]);
+      }
+      dmn_rdr_trv=(dmn_sct **)nco_free(dmn_rdr_trv);
       /* Dimension structures in dmn_rdr are owned by dmn and dmn_out, free'd later */
     } /* endif dmn_rdr_nbr > 0 */
     if(nco_pck_plc != nco_pck_plc_nil){
@@ -919,8 +945,8 @@ main(int argc,char **argv)
       if(nco_pck_map_sng) nco_pck_map_sng=(char *)nco_free(nco_pck_map_sng);
       if(nco_pck_plc != nco_pck_plc_upk){
         /* No need for loop over var_prc variables to free attribute values
-	   Variable structures and attribute edit lists share same attribute values
-	   Free them only once, and do it in nco_var_free() */
+         Variable structures and attribute edit lists share same attribute values
+         Free them only once, and do it in nco_var_free() */
         aed_lst_add_fst=(aed_sct *)nco_free(aed_lst_add_fst);
         aed_lst_scl_fct=(aed_sct *)nco_free(aed_lst_scl_fct);
       } /* nco_pck_plc == nco_pck_plc_upk */
@@ -949,10 +975,6 @@ main(int argc,char **argv)
     /* Free chunking information */
     for(idx=0;idx<cnk_nbr;idx++) cnk_arg[idx]=(char *)nco_free(cnk_arg[idx]);
     if(cnk_nbr > 0) cnk.cnk_dmn=(cnk_dmn_sct **)nco_cnk_lst_free(cnk.cnk_dmn,cnk_nbr);
-    /* Free dimension lists */
-    if(nbr_dmn_xtr > 0) dim=nco_dmn_lst_free(dim,nbr_dmn_xtr);
-    if(nbr_dmn_xtr > 0) dmn_out=nco_dmn_lst_free(dmn_out,nbr_dmn_xtr);
-    /* Free variable lists */
     if(xtr_nbr > 0) var=nco_var_lst_free(var,xtr_nbr);
     if(xtr_nbr > 0) var_out=nco_var_lst_free(var_out,xtr_nbr);
     var_prc=(var_sct **)nco_free(var_prc);
diff --git a/src/nco/ncra.c b/src/nco/ncra.c
index db7442e..73eb523 100644
--- a/src/nco/ncra.c
+++ b/src/nco/ncra.c
@@ -150,6 +150,8 @@ main(int argc,char **argv)
   const char * const CVS_Revision="$Revision$";
   const char * const opt_sht_lst="3467ACcD:d:FG:g:HhL:l:Nn:Oo:p:P:rRt:v:w:X:xY:y:-:";
 
+  clm_bnd_sct *cb=NULL;
+  
   cnk_sct cnk; /* [sct] Chunking structure */
 
 #if defined(__cplusplus) || defined(PGI_CC)
@@ -260,6 +262,8 @@ main(int argc,char **argv)
   nco_bool RM_RMT_FL_PST_PRC=True; /* Option R */
   nco_bool WRT_TMP_FL=True; /* [flg] Write output to temporary file */
   nco_bool flg_cll_mth=True; /* [flg] Add/modify cell_methods attributes */
+  nco_bool flg_cb=False; /* [flg] Climatology bounds */
+  nco_bool flg_c2b=False; /* [flg] Climatology bounds-to-time bounds */
   nco_bool flg_cln=True; /* [flg] Clean memory prior to exit */
   nco_bool flg_skp1; /* [flg] Current record is not dimension of this variable */
   nco_bool flg_skp2; /* [flg] Current record is not dimension of this variable */
@@ -299,7 +303,6 @@ main(int argc,char **argv)
   var_sct *wgt_avg=NULL; /* [sct] Copy of wgt_out created to mimic var_prc_out processing 
 			    Holds running total and tally of weight
 			    Acts as op2 for wgt_out averaging just before var_prc[nbr_var_prc-1] */
-
 #ifdef ENABLE_MPI
   /* Declare all MPI-specific variables here */
   MPI_Comm mpi_cmm=MPI_COMM_WORLD; /* [prc] Communicator */
@@ -312,6 +315,10 @@ main(int argc,char **argv)
     {"cll_mth",no_argument,0,0}, /* [flg] Add/modify cell_methods attributes */
     {"cell_methods",no_argument,0,0}, /* [flg] Add/modify cell_methods attributes */
     {"no_cll_mth",no_argument,0,0}, /* [flg] Do not add/modify cell_methods attributes */
+    {"clm_bnd",no_argument,0,0}, /* [sct] Climatology bounds */
+    {"cb",no_argument,0,0}, /* [sct] Climatology bounds */
+    {"clm2bnd",no_argument,0,0}, /* [sct] Climatology bounds-to-time bounds */
+    {"c2b",no_argument,0,0}, /* [sct] Climatology bounds-to-time bounds */
     {"cln",no_argument,0,0}, /* [flg] Clean memory prior to exit */
     {"clean",no_argument,0,0}, /* [flg] Clean memory prior to exit */
     {"mmr_cln",no_argument,0,0}, /* [flg] Clean memory prior to exit */
@@ -500,6 +507,8 @@ main(int argc,char **argv)
       if(!strcmp(opt_crr,"no_cll_mth") || !strcmp(opt_crr,"no_cell_methods")) flg_cll_mth=False; /* [flg] Add/modify cell_methods attributes */
       if(!strcmp(opt_crr,"cln") || !strcmp(opt_crr,"mmr_cln") || !strcmp(opt_crr,"clean")) flg_cln=True; /* [flg] Clean memory prior to exit */
       if(!strcmp(opt_crr,"drt") || !strcmp(opt_crr,"mmr_drt") || !strcmp(opt_crr,"dirty")) flg_cln=False; /* [flg] Clean memory prior to exit */
+      if(!strcmp(opt_crr,"clm_bnd") || !strcmp(opt_crr,"cb")) flg_cb=True; /* [sct] Climatology bounds */
+      if(!strcmp(opt_crr,"clm2bnd") || !strcmp(opt_crr,"c2b")) flg_c2b=flg_cb=True; /* [sct] Climatology bounds-to-time bounds */
       if(!strcmp(opt_crr,"fl_fmt") || !strcmp(opt_crr,"file_format")) rcd=nco_create_mode_prs(optarg,&fl_out_fmt);
       if(!strcmp(opt_crr,"dbl") || !strcmp(opt_crr,"rth_dbl")) nco_rth_cnv=nco_rth_flt_dbl; /* [flg] Arithmetic convention: promote float to double */
       if(!strcmp(opt_crr,"flt") || !strcmp(opt_crr,"rth_flt")) nco_rth_cnv=nco_rth_flt_flt; /* [flg] Arithmetic convention: keep single-precision */
@@ -508,7 +517,7 @@ main(int argc,char **argv)
         gaa_arg[gaa_nbr++]=(char *)strdup(optarg);
       } /* endif gaa */
       if(!strcmp(opt_crr,"hdf4")) nco_fmt_xtn=nco_fmt_xtn_hdf4; /* [enm] Treat file as HDF4 */
-      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
+      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF_MOD10; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
       if(!strcmp(opt_crr,"hdr_pad") || !strcmp(opt_crr,"header_pad")){
         hdr_pad=strtoul(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
         if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtoul",sng_cnv_rcd);
@@ -802,7 +811,7 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Initialize chunking from user-specified inputs */
   if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) rcd+=nco_cnk_ini(in_id,fl_out,cnk_arg,cnk_nbr,cnk_map,cnk_plc,cnk_min_byt,cnk_sz_byt,cnk_sz_scl,&cnk);
@@ -823,26 +832,236 @@ main(int argc,char **argv)
   /* Add input file list global attribute */
   if(FL_LST_IN_APPEND && HISTORY_APPEND && FL_LST_IN_FROM_STDIN) (void)nco_fl_lst_att_cat(out_id,fl_lst_in,fl_nbr);
 
-  /* Turn off default filling behavior to enhance efficiency */
+  /* Turn-off default filling behavior to enhance efficiency */
   (void)nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 
+  /* Add climatology_bounds attribute to output file (before cell_methods) */
+  if(flg_cb && nco_prg_id == ncra){
+    char bnd_sng[]="bounds"; /* CF-standard time bounds attribute name */
+    char clm_sng[]="climatology"; /* CF-standard climatology bounds attribute name */
+    char cln_sng[]="calendar"; /* CF-standard calendar attribute name */
+    char unt_sng[]="units"; /* NUG-standard units attribute name */
+    long att_sz;
+    nc_type att_typ;
+
+    cb=(clm_bnd_sct *)nco_malloc(sizeof(clm_bnd_sct));
+    cb->bnd2clm=False; /* [flg] Convert time bounds to climatology bounds */
+    cb->clm2bnd=False; /* [flg] Convert climatology bounds to time bounds */
+    cb->clm2clm=False; /* [flg] Convert climatology bounds to climatology bounds */
+    cb->clm_bnd_id_in=NC_MIN_INT; /* [id] Climatology bounds ID */
+    cb->clm_bnd_id_out=NC_MIN_INT; /* [id] Climatology bounds ID */
+    cb->clm_bnd_in=False; /* [flg] Climatology bounds appear in input */
+    cb->clm_bnd_nm=NULL; /* [sng] Climatology bounds name */
+    cb->dmn_srt_srt[0]=0L;cb->dmn_srt_srt[1]=0L;
+    cb->dmn_srt_end[0]=0L;cb->dmn_srt_end[1]=1L;
+    cb->tm_bnd_id_in=NC_MIN_INT; /* [id] Time bounds ID */
+    cb->tm_bnd_in=False; /* [flg] Time bounds appear in input */
+    cb->tm_bnd_nm=NULL; /* [sng] Time bounds name */
+    cb->tm_crd_id_in=NC_MIN_INT; /* [id] Time coordinate ID */
+    cb->tm_crd_nm=NULL; /* [sng] Time coordinate name */
+    cb->type=NC_NAT; /* [enm] Time coordinate type */
+    cb->val[0]=NC_MIN_DOUBLE;
+    cb->val[1]=NC_MIN_DOUBLE;
+
+    if((rcd=nco_inq_varid_flg(in_id,"time",&cb->tm_crd_id_in)) == NC_NOERR) cb->tm_crd_nm=strdup("time");
+    else if((rcd=nco_inq_varid_flg(in_id,"Time",&cb->tm_crd_id_in)) == NC_NOERR) cb->tm_crd_nm=strdup("Time");
+    if(cb->tm_crd_id_in != NC_MIN_INT){
+      rcd=nco_inq_vartype(in_id,cb->tm_crd_id_in,&cb->type);
+
+      rcd=nco_inq_att_flg(in_id,cb->tm_crd_id_in,clm_sng,&att_typ,&att_sz);
+      if(rcd == NC_NOERR && att_typ == NC_CHAR){
+	cb->clm_bnd_nm=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+	rcd+=nco_get_att(in_id,cb->tm_crd_id_in,clm_sng,cb->clm_bnd_nm,att_typ);
+	/* NUL-terminate attribute before using strstr() */
+	cb->clm_bnd_nm[att_sz]='\0';
+	cb->clm_bnd_in=True;
+      }else{
+	cb->clm_bnd_nm=strdup("climatology_bounds");
+	rcd=NC_NOERR;
+      }	/* !rcd && att_typ */
+
+      rcd=nco_inq_att_flg(in_id,cb->tm_crd_id_in,bnd_sng,&att_typ,&att_sz);
+      if(rcd == NC_NOERR && att_typ == NC_CHAR){
+	cb->tm_bnd_nm=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+	rcd+=nco_get_att(in_id,cb->tm_crd_id_in,bnd_sng,cb->tm_bnd_nm,att_typ);
+	/* NUL-terminate attribute before using strstr() */
+	cb->tm_bnd_nm[att_sz]='\0';
+	cb->tm_bnd_in=True;
+      }else{
+	cb->tm_bnd_nm=strdup("time_bnds");
+	rcd=NC_NOERR;
+      } /* !rcd && att_typ */
+
+      /* Input file must have either (but not both) time bounds or climatology bounds */
+      if(cb->tm_bnd_in && cb->clm_bnd_in){
+	(void)fprintf(stderr,"%s: WARNING Climatology bounds invoked on time coordinate with both time bounds attribute \"%s\" and climatology bounds attribute \"%s\". Results would be ambiguous. Turning-off climatology bounds mode.\n",nco_prg_nm_get(),bnd_sng,clm_sng);
+	flg_cb=False;
+	goto skp_cb;
+      } /* !(cb->tm_bnd_in && cb->clm_bnd_in) */
+      if(!cb->tm_bnd_in && !cb->clm_bnd_in){
+	(void)fprintf(stderr,"%s: WARNING Climatology bounds invoked on time coordinate with neither time bounds attribute \"%s\" nor climatology bounds attribute \"%s\". No way to obtain bounding time values. Turning-off climatology bounds mode.\n",nco_prg_nm_get(),bnd_sng,clm_sng);
+	flg_cb=False;
+	goto skp_cb;
+      } /* !cb->tm_bnd_in && !cb->clm_bnd_in */
+
+    }else{ /* !tm_crd_id_in */
+      if(nco_dbg_lvl >= nco_dbg_std) (void)fprintf(stderr,"%s: WARNING Climatology bounds invoked on dataset with unknown time coordinate. Turning-off climatology bounds mode.\n",nco_prg_nm_get());
+      flg_cb=False;
+      goto skp_cb; 
+    } /* !tm_crd_in */
+
+    if(flg_c2b && cb->clm_bnd_in) cb->clm2bnd=True;
+    if(cb->clm_bnd_in) cb->clm2clm=True;
+    if(cb->tm_bnd_in) cb->bnd2clm=True;
+    
+    if(cb->tm_bnd_in){
+      rcd=nco_inq_varid_flg(in_id,cb->tm_bnd_nm,&cb->tm_bnd_id_in); 
+      if(cb->tm_bnd_id_in == NC_MIN_INT){
+	if(nco_dbg_lvl >= nco_dbg_std) (void)fprintf(stderr,"%s: WARNING Climatology bounds invoked on dataset with missing time bounds variable \"%s\". Turning-off climatology bounds mode.\n",nco_prg_nm_get(),cb->tm_bnd_nm);
+	flg_cb=False;
+	rcd=NC_NOERR;
+	goto skp_cb; 
+      } /* !tm_bnd_id_in */
+    } /* !tm_bnd_in */
+
+    if(cb->clm_bnd_in){
+      rcd=nco_inq_varid_flg(in_id,cb->clm_bnd_nm,&cb->clm_bnd_id_in); 
+      if(cb->clm_bnd_id_in == NC_MIN_INT){
+	if(nco_dbg_lvl >= nco_dbg_std) (void)fprintf(stderr,"%s: WARNING Climatology bounds invoked on dataset with missing climatology bounds variable \"%s\". Turning-off climatology bounds mode.\n",nco_prg_nm_get(),cb->tm_bnd_nm);
+	flg_cb=False;
+	rcd=NC_NOERR;
+	goto skp_cb; 
+      } /* !tm_bnd_id_in */
+    } /* !clm_bnd_in */
+
+    rcd=nco_inq_varid_flg(out_id,cb->tm_crd_nm,&cb->tm_crd_id_out); 
+    if(rcd != NC_NOERR){
+      if(nco_dbg_lvl >= nco_dbg_std) (void)fprintf(stderr,"%s: ERROR Climatology bounds did not find time coordinate in output file\n",nco_prg_nm_get());
+      nco_exit(EXIT_FAILURE);
+    } /* !tm_crd_id_out */
+
+    if(cb->bnd2clm){
+      rcd=nco_inq_varid_flg(out_id,cb->tm_bnd_nm,&cb->tm_bnd_id_out); 
+      if(rcd != NC_NOERR){
+	if(nco_dbg_lvl >= nco_dbg_std) (void)fprintf(stderr,"%s: ERROR Time bounds variable %s was not copied to output file\n",nco_prg_nm_get(),cb->tm_bnd_nm);
+	nco_exit(EXIT_FAILURE);
+      } /* !tm_bnd_id_out */
+      /* Write climatology bounds to time bounds then rename */
+      cb->clm_bnd_id_out=cb->tm_bnd_id_out;
+    } /* !bnd2clm */
+    
+    if(cb->clm2clm || cb->clm2bnd){
+      rcd=nco_inq_varid_flg(out_id,cb->clm_bnd_nm,&cb->clm_bnd_id_out); 
+      if(rcd != NC_NOERR){
+	if(nco_dbg_lvl >= nco_dbg_std) (void)fprintf(stderr,"%s: ERROR Climatology bounds variable %s was not copied to output file\n",nco_prg_nm_get(),cb->clm_bnd_nm);
+	nco_exit(EXIT_FAILURE);
+      } /* !clm_bnd_id_out */
+      /* Write time bounds to climatology bounds then rename */
+      if(cb->clm2bnd) cb->tm_bnd_id_out=cb->clm_bnd_id_out;
+    } /* !clm2clm */
+
+    if(cb->bnd2clm || cb->clm2bnd){
+      aed_sct aed_mtd;
+      char *att_nm;
+      char *att_val;
+
+      /* Add new bounds attribute */
+      att_nm = cb->bnd2clm ? strdup(clm_sng) : strdup(bnd_sng);
+      att_val= cb->bnd2clm ? strdup(cb->clm_bnd_nm) : strdup(cb->tm_bnd_nm);
+      aed_mtd.att_nm=att_nm;
+      aed_mtd.var_nm=cb->tm_crd_nm;
+      aed_mtd.id=cb->tm_crd_id_out;
+      aed_mtd.sz=strlen(att_val);
+      aed_mtd.type=NC_CHAR;
+      aed_mtd.val.cp=att_val;
+      aed_mtd.mode=aed_create;
+      (void)nco_aed_prc(out_id,cb->tm_crd_id_out,aed_mtd);
+      if(att_nm) att_nm=(char *)nco_free(att_nm);
+      if(att_val) att_val=(char *)nco_free(att_val);
+      
+      /* Delete old bounds attribute */
+      att_nm= cb->bnd2clm ? strdup(bnd_sng) : strdup(clm_sng);
+      aed_mtd.att_nm=att_nm;
+      aed_mtd.var_nm=cb->tm_crd_nm;
+      aed_mtd.id=cb->tm_crd_id_out;
+      aed_mtd.mode=aed_delete;
+      (void)nco_aed_prc(out_id,cb->tm_crd_id_out,aed_mtd);
+      if(att_nm) att_nm=(char *)nco_free(att_nm);
+
+      /* Copy units attribute from coordinate to new bounds if necessary */
+      if(cb->tm_bnd_in) rcd=nco_inq_att_flg(out_id,cb->tm_bnd_id_out,unt_sng,&att_typ,&att_sz);
+      if(cb->clm_bnd_in) rcd=nco_inq_att_flg(out_id,cb->clm_bnd_id_out,unt_sng,&att_typ,&att_sz);
+      if(rcd != NC_NOERR && att_typ == NC_CHAR){
+	rcd=nco_inq_att_flg(out_id,cb->tm_crd_id_out,unt_sng,&att_typ,&att_sz);
+	if(rcd == NC_NOERR && att_typ == NC_CHAR){
+	  cb->unt_val=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+	  rcd+=nco_get_att(out_id,cb->tm_crd_id_out,unt_sng,cb->unt_val,att_typ);
+	  /* NUL-terminate attribute before using strstr() */
+	  cb->unt_val[att_sz]='\0';
+	  
+	  /* Add units attribute */
+	  att_nm=strdup(unt_sng);
+	  att_val=cb->unt_val;
+	  aed_mtd.att_nm=att_nm;
+	  aed_mtd.var_nm=cb->bnd2clm ? cb->tm_bnd_nm : cb->clm_bnd_nm;
+	  aed_mtd.id=cb->bnd2clm ? cb->tm_bnd_id_out : cb->clm_bnd_id_out;
+	  aed_mtd.sz=strlen(att_val);
+	  aed_mtd.type=NC_CHAR;
+	  aed_mtd.val.cp=att_val;
+	  aed_mtd.mode=aed_create;
+	  if(cb->bnd2clm) (void)nco_aed_prc(out_id,cb->tm_bnd_id_out,aed_mtd); else (void)nco_aed_prc(out_id,cb->clm_bnd_id_out,aed_mtd);
+	  if(att_nm) att_nm=(char *)nco_free(att_nm);
+	  if(att_val) att_val=cb->unt_val=(char *)nco_free(att_val);
+	} /* !rcd && att_typ */
+	rcd=NC_NOERR;
+      } /* !rcd && att_typ */
+
+      /* Copy calendar attribute from coordinate to new bounds if necessary */
+      if(cb->tm_bnd_in) rcd=nco_inq_att_flg(out_id,cb->tm_bnd_id_out,cln_sng,&att_typ,&att_sz);
+      if(cb->clm_bnd_in) rcd=nco_inq_att_flg(out_id,cb->clm_bnd_id_out,cln_sng,&att_typ,&att_sz);
+      if(rcd != NC_NOERR && att_typ == NC_CHAR){
+	rcd=nco_inq_att_flg(out_id,cb->tm_crd_id_out,cln_sng,&att_typ,&att_sz);
+	if(rcd == NC_NOERR && att_typ == NC_CHAR){
+	  cb->cln_val=(char *)nco_malloc((att_sz+1L)*nco_typ_lng(att_typ));
+	  rcd+=nco_get_att(out_id,cb->tm_crd_id_out,cln_sng,cb->cln_val,att_typ);
+	  /* NUL-terminate attribute before using strstr() */
+	  cb->cln_val[att_sz]='\0';
+	  
+	  /* Add calendar attribute */
+	  att_nm=strdup(cln_sng);
+	  att_val=cb->cln_val;
+	  aed_mtd.att_nm=att_nm;
+	  aed_mtd.var_nm=cb->bnd2clm ? cb->tm_bnd_nm : cb->clm_bnd_nm;
+	  aed_mtd.id=cb->bnd2clm ? cb->tm_bnd_id_out : cb->clm_bnd_id_out;
+	  aed_mtd.sz=strlen(att_val);
+	  aed_mtd.type=NC_CHAR;
+	  aed_mtd.val.cp=att_val;
+	  aed_mtd.mode=aed_create;
+	  if(cb->bnd2clm) (void)nco_aed_prc(out_id,cb->tm_bnd_id_out,aed_mtd); else (void)nco_aed_prc(out_id,cb->clm_bnd_id_out,aed_mtd);
+	  if(att_nm) att_nm=(char *)nco_free(att_nm);
+	  if(att_val) att_val=cb->cln_val=(char *)nco_free(att_val);
+	} /* !rcd && att_typ */
+	rcd=NC_NOERR;
+      } /* !rcd && att_typ */
+      
+    } /* !bnd2clm !clm2bnd */
+  } /* !flg_cb */
+  
+  /* goto skp_cb */
+ skp_cb: 
+  /* free() any abandoned cb structure now or it will be inadvertently used in nco_cnv_cf_cll_mth_add() */
+  if(!flg_cb)
+    if(cb) cb=(clm_bnd_sct *)nco_free(cb);
+
   /* Add cell_methods attributes (before exiting define mode) */
   if(nco_prg_id == ncra){
     dmn_sct **dmn=NULL_CEWI;
     int nbr_dmn=nbr_rec;
-    /* Allocate */
     dmn=(dmn_sct **)nco_malloc(nbr_dmn*sizeof(dmn_sct *));
     /* Make dimension array from limit records array */
     (void)nco_dmn_lmt(lmt_rec,nbr_dmn,&dmn);
     /* Add cell_methods attributes (pass as dimension argument a records-only array) */
-    if(flg_cll_mth){
-      if(nco_dbg_lvl_get() >= nco_dbg_dev){
-        (void)fprintf(stdout,"%s: DEBUG dimension list to nco_cnv_cf_cll_mth_add()\n",nco_prg_nm_get());
-        for(idx=0;idx<nbr_dmn;idx++) (void)fprintf(stdout,"%s: DEBUG %s\n",nco_prg_nm_get(),dmn[idx]->nm);
-        for(idx=0;idx<nbr_var_prc;idx++) (void)fprintf(stdout,"%s: DEBUG %s\n",nco_prg_nm_get(),var_prc_out[idx]->nm_fll);
-      } /* endif dbg */
-      rcd+=nco_cnv_cf_cll_mth_add(out_id,var_prc_out,nbr_var_prc,dmn,nbr_dmn,nco_op_typ,gpe,trv_tbl); 
-    } /* !flg_cll_mth */
+    if(flg_cll_mth) rcd+=nco_cnv_cf_cll_mth_add(out_id,var_prc_out,nbr_var_prc,dmn,nbr_dmn,nco_op_typ,gpe,cb,trv_tbl); 
     if(nbr_dmn > 0) dmn=nco_dmn_lst_free(dmn,nbr_dmn);
   } /* !ncra */
 
@@ -1269,6 +1488,18 @@ main(int argc,char **argv)
 
       } /* end idx_rec loop over different record variables to process */
 
+      if(flg_cb && nco_prg_id == ncra){
+	/* Obtain climatology bounds from input file */
+	int var_id_in;
+	double val_dbl;
+	var_id_in= cb->tm_bnd_in ? cb->tm_bnd_id_in : cb->clm_bnd_id_in;
+	rcd=nco_get_var1(in_id,var_id_in,cb->dmn_srt_srt,&val_dbl,(nc_type)NC_DOUBLE);
+	if(fl_idx == 0) cb->val[0]=val_dbl;
+	if(val_dbl < cb->val[0]) cb->val[0]=val_dbl;
+	rcd=nco_get_var1(in_id,var_id_in,cb->dmn_srt_end,&val_dbl,(nc_type)NC_DOUBLE);
+	if(val_dbl > cb->val[1]) cb->val[1]=val_dbl;
+      } /* !flg_cb */
+
       /* End ncra, ncrcat section */
     }else if(nco_prg_id == ncfe){ /* ncfe */
 
@@ -1523,6 +1754,22 @@ main(int argc,char **argv)
     } /* end loop over idx */
   } /* endif ncra || nces */
 
+  if(flg_cb && nco_prg_id == ncra) rcd=nco_put_var(out_id,cb->clm_bnd_id_out,cb->val,(nc_type)NC_DOUBLE);
+
+  if(flg_cb && (cb->bnd2clm || cb->clm2bnd)){
+    /* Rename time bounds as climatology bounds, or visa-versa
+       Otherwise wrong bounds will remain orphaned in output file
+       Also, this ensures same dimensions are used
+       Rename at end of procedure so that traversal table does not get out-of-sync
+       Avoiding renaming would mean creating the new and deleting the old bounds variable 
+       That would entail significant modifications to traversal table logic
+       Renaming seems simpler and less error prone */
+    rcd+=nco_redef(out_id);
+    if(cb->bnd2clm) rcd+=nco_rename_var(out_id,cb->tm_bnd_id_out,cb->clm_bnd_nm);
+    if(cb->clm2bnd) rcd+=nco_rename_var(out_id,cb->clm_bnd_id_out,cb->tm_bnd_nm);
+    rcd+=nco_enddef(out_id);
+  } /* !flg_cb */
+
   /* Close output file and move it from temporary to permanent location */
   (void)nco_fl_out_cls(fl_out,fl_out_tmp,out_id);
 
@@ -1569,6 +1816,12 @@ main(int argc,char **argv)
     if(wgt) wgt=(var_sct *)nco_var_free(wgt);
     if(wgt_out) wgt_out=(var_sct *)nco_var_free(wgt_out);
     if(wgt_avg) wgt_avg=(var_sct *)nco_var_free(wgt_avg);
+    if(cb){
+      if(cb->tm_bnd_nm) cb->tm_bnd_nm=(char *)nco_free(cb->tm_bnd_nm);
+      if(cb->tm_crd_nm) cb->tm_crd_nm=(char *)nco_free(cb->tm_crd_nm);
+      if(cb->clm_bnd_nm) cb->clm_bnd_nm=(char *)nco_free(cb->clm_bnd_nm);
+      if(cb) cb=(clm_bnd_sct *)nco_free(cb);
+    } /* !cb */
 
     (void)trv_tbl_free(trv_tbl);
     for(idx=0;idx<lmt_nbr;idx++) flg_dne[idx].dim_nm=(char *)nco_free(flg_dne[idx].dim_nm);
diff --git a/src/nco/ncwa.c b/src/nco/ncwa.c
index ba993db..44c4465 100644
--- a/src/nco/ncwa.c
+++ b/src/nco/ncwa.c
@@ -446,7 +446,7 @@ main(int argc,char **argv)
         gaa_arg[gaa_nbr++]=(char *)strdup(optarg);
       } /* endif gaa */
       if(!strcmp(opt_crr,"hdf4")) nco_fmt_xtn=nco_fmt_xtn_hdf4; /* [enm] Treat file as HDF4 */
-      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
+      if(!strcmp(opt_crr,"hdf_upk") || !strcmp(opt_crr,"hdf_unpack")) nco_upk_cnv=nco_upk_HDF_MOD10; /* [flg] HDF unpack convention: unpacked=scale_factor*(packed-add_offset) */
       if(!strcmp(opt_crr,"hdr_pad") || !strcmp(opt_crr,"header_pad")){
         hdr_pad=strtoul(optarg,&sng_cnv_rcd,NCO_SNG_CNV_BASE10);
         if(*sng_cnv_rcd) nco_sng_cnv_err(optarg,"strtoul",sng_cnv_rcd);
@@ -756,7 +756,7 @@ main(int argc,char **argv)
   (void)nco_fl_fmt_vet(fl_out_fmt,cnk_nbr,dfl_lvl);
 
   /* Open output file */
-  fl_out_tmp=nco_fl_out_open(fl_out,FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
+  fl_out_tmp=nco_fl_out_open(fl_out,&FORCE_APPEND,FORCE_OVERWRITE,fl_out_fmt,&bfr_sz_hnt,RAM_CREATE,RAM_OPEN,WRT_TMP_FL,&out_id);
 
   /* Initialize chunking from user-specified inputs */
   if(fl_out_fmt == NC_FORMAT_NETCDF4 || fl_out_fmt == NC_FORMAT_NETCDF4_CLASSIC) rcd+=nco_cnk_ini(in_id,fl_out,cnk_arg,cnk_nbr,cnk_map,cnk_plc,cnk_min_byt,cnk_sz_byt,cnk_sz_scl,&cnk);
@@ -806,11 +806,11 @@ main(int argc,char **argv)
     } /* end for */
   } /* end if */
 
-  /* Turn off default filling behavior to enhance efficiency */
+  /* Turn-off default filling behavior to enhance efficiency */
   nco_set_fill(out_id,NC_NOFILL,&fll_md_old);
 
   /* Add cell_methods attributes (before exiting define mode) */
-  if(flg_cll_mth) rcd+=nco_cnv_cf_cll_mth_add(out_id,var_prc_out,nbr_var_prc,dmn_avg,dmn_avg_nbr,nco_op_typ,gpe,trv_tbl);
+  if(flg_cll_mth) rcd+=nco_cnv_cf_cll_mth_add(out_id,var_prc_out,nbr_var_prc,dmn_avg,dmn_avg_nbr,nco_op_typ,gpe,(clm_bnd_sct *)NULL,trv_tbl);
 
   /* Take output file out of define mode */
   if(hdr_pad == 0UL){
diff --git a/src/nco_c++/Makefile.am b/src/nco_c++/Makefile.am
index c3f6008..03d0ea0 100644
--- a/src/nco_c++/Makefile.am
+++ b/src/nco_c++/Makefile.am
@@ -16,7 +16,7 @@ libnco_c___la_SOURCES = nco_att.cc nco_dmn.cc nco_fl.cc nco_hgh.cc nco_utl.cc nc
 
 libnco_c___la_CPPFLAGS = -DABORT_ON_ERROR
 
-libnco_c___la_LDFLAGS = -release @VERSION@
+libnco_c___la_LDFLAGS = -release @NCO_VERSION@
 
 tst_SOURCES = tst.cc
 
diff --git a/src/nco_c++/Makefile.in b/src/nco_c++/Makefile.in
index 0b34a3a..0388071 100644
--- a/src/nco_c++/Makefile.in
+++ b/src/nco_c++/Makefile.in
@@ -549,7 +549,7 @@ lib_LTLIBRARIES = libnco_c++.la
 include_HEADERS = libnco_c++.hh nco_dmn.hh nco_hgh.hh nco_var.hh nco_att.hh nco_fl.hh nco_utl.hh
 libnco_c___la_SOURCES = nco_att.cc nco_dmn.cc nco_fl.cc nco_hgh.cc nco_utl.cc nco_var.cc
 libnco_c___la_CPPFLAGS = -DABORT_ON_ERROR
-libnco_c___la_LDFLAGS = -release @VERSION@
+libnco_c___la_LDFLAGS = -release @NCO_VERSION@
 tst_SOURCES = tst.cc
 tst_LDADD = -lnco_c++
 TESTPROGRAMS = tst
diff --git a/src/nco_c++/Makefile.old b/src/nco_c++/Makefile.old
index c122b11..b87d24c 100644
--- a/src/nco_c++/Makefile.old
+++ b/src/nco_c++/Makefile.old
@@ -240,7 +240,7 @@ else
 endif # endif PRC
 
 # NB: CPP_TKN is recursively expanded variable, define only when components are ready
-CPP_TKN = ${USR_TKN} -D${PVM_ARCH} -DNO_NETCDF_2 -DVERSION='${VRS_SNG}' -DHOSTNAME='${HOST}' -DUSER='${USER}' -DNCO_ABORT_ON_ERROR
+CPP_TKN = ${USR_TKN} -D${PVM_ARCH} -DNO_NETCDF_2 -DNCO_VERSION='${VRS_SNG}' -DHOSTNAME='${HOST}' -DUSER='${USER}' -DNCO_ABORT_ON_ERROR
 
 ifeq (${SZ},Y)
 # 20150515: -lsz needed (at least by icc) on rhea
diff --git a/src/nco_c++/tst.cc b/src/nco_c++/tst.cc
index eaaacc9..4ab258d 100644
--- a/src/nco_c++/tst.cc
+++ b/src/nco_c++/tst.cc
@@ -67,7 +67,7 @@ int main(int argc,char **argv)
 #define TKN2SNG(x) XTKN2SNG(x)
   const std::string date_cpp(__DATE__); // [sng] Date from C pre-processor
   const std::string time_cpp(__TIME__); // [sng] Time from C pre-processor
-  const std::string vrs_cpp(TKN2SNG(VERSION)); // [sng] Version from C pre-processor
+  const std::string vrs_cpp(TKN2SNG(NCO_VERSION)); // [sng] Version from C pre-processor
   const std::string hst_cpp(TKN2SNG(HOSTNAME)); // [sng] Hostname from C pre-processor
   const std::string usr_cpp(TKN2SNG(USER)); // [sng] Hostname from C pre-processor
   if(vrs_cvs == "Unknown") std::cerr << prg_nm << " version " << vrs_cpp << " built " << date_cpp << " on " << hst_cpp << " by " << usr_cpp << std::endl;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/nco.git



More information about the Pkg-grass-devel mailing list