diff --git a/ChangeLog b/ChangeLog
index 5f89a5a62ad56453e31c49bf4c1d0e98d62c2d77..6fb088f77a108f1959fafefcb62f25fed1ea6a32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2017-07-27  Uwe Schulzweida
+
+        * using CGRIBEX library version 1.8.1
+	* Version 1.9.0 released
+
+2017-07-18  Uwe Schulzweida
+
+	* cdfDefVarMissval: behavior of _FillValue handling has been changed in netCDF4 (bug fix)
+
+2017-07-12  Uwe Schulzweida
+
+        * grib1(cgribex): added support for GRIB1 records without GridDecriptionSection
+
+2017-07-06  Uwe Schulzweida
+
+	* removed leading space from time units (bug fix)
+
+2017-07-01  Uwe Schulzweida
+
+	* Added function tableInqEntry().
+	* removed:  tableInqParNamePtr(), tableInqParNamePtr(), tableInqParUnitsPtr().
+
+2017-06-21  Uwe Schulzweida
+
+	* find_leadtime: check number of dimensions [Bug #7779]
+
+2017-06-06  Uwe Schulzweida
+
+	* Changed boolean ints to stdbool
+
 2017-05-16  Uwe Schulzweida
 
 	* Version 1.8.2 released
diff --git a/Makefile.in b/Makefile.in
index a13b31c9e04bb199185fac7414016db99e6f26d4..93e11e7bf8686a2773cbb0abf5a66f5bed45b5bd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -253,6 +253,8 @@ DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
+ECCODES_INCLUDE = @ECCODES_INCLUDE@
+ECCODES_LIBS = @ECCODES_LIBS@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
diff --git a/app/Makefile.in b/app/Makefile.in
index c5c9cad22abadfcc8cce6c5c413d78effd645dc9..f3c05a51e4d93f38a4e432572eda6af6dfc7ffca 100644
--- a/app/Makefile.in
+++ b/app/Makefile.in
@@ -226,6 +226,8 @@ DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
+ECCODES_INCLUDE = @ECCODES_INCLUDE@
+ECCODES_LIBS = @ECCODES_LIBS@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
diff --git a/app/createtable.c b/app/createtable.c
index 29377bf1e17f1ff3bc0b746ef3e3019abf71c8d6..c781b927e6bc9448513472c49136e761d3b002d2 100644
--- a/app/createtable.c
+++ b/app/createtable.c
@@ -22,13 +22,13 @@ static void usage(void)
         "   -version      display version number\n", stderr);
 }
 
+
 int main(int argc, char *argv[])
 {
   int c;
   char  *cstring;
   char *ifile = NULL, *ofile = NULL;
   int debug = 0;
-  int tableID;
 
 
   Progname = argv[0];
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
   /*
   if ( debug ) cdiDebug(debug);
   */
-  tableID = tableRead(ifile);
+  int tableID = tableRead(ifile);
   if ( CDI_Debug )
     Message("write parameter table %d to %s", tableID, ofile);
   FILE *ptfp = (ofile[0] == '-' && ofile[1] == '\0')?stdout:fopen(ofile, "w");
diff --git a/app/printinfo.h b/app/printinfo.h
index e0fe4b4a96de5b7b6f5677ac7647fd838d56544a..01b9b8d5dc0deb1726ee535a6eb4d8a93a9d6f86 100644
--- a/app/printinfo.h
+++ b/app/printinfo.h
@@ -1,11 +1,17 @@
 // This file is used in CDI and CDO !!!
 
 #if defined (HAVE_CONFIG_H)
-#  include "../src/config.h"
+#include "../src/config.h"
 #endif
 
 #include <stdio.h>
 
+#ifdef CDO
+#define  streamInqFiletype        pstreamInqFiletype
+#define  streamInqByteorder       pstreamInqByteorder
+#define  streamInqTimestep        pstreamInqTimestep
+#endif
+
 #define DATE_FORMAT "%5.4d-%2.2d-%2.2d"
 #define TIME_FORMAT "%2.2d:%2.2d:%2.2d"
 
@@ -199,9 +205,9 @@ void print_xyvals2D(int gridID, int dig)
       gridInqXunits(gridID, xunits);
       gridInqYunits(gridID, yunits);
 
-      int gridsize = gridInqSize(gridID);
-      double *xvals2D = (double*) malloc((size_t)gridsize*sizeof(double));
-      double *yvals2D = (double*) malloc((size_t)gridsize*sizeof(double));
+      size_t gridsize = gridInqSize(gridID);
+      double *xvals2D = (double*) malloc(gridsize*sizeof(double));
+      double *yvals2D = (double*) malloc(gridsize*sizeof(double));
 
       gridInqXvals(gridID, xvals2D);
       gridInqYvals(gridID, yvals2D);
@@ -210,7 +216,7 @@ void print_xyvals2D(int gridID, int dig)
       double xlast  = xvals2D[0];
       double yfirst = yvals2D[0];
       double ylast  = yvals2D[0];
-      for ( int i = 1; i < gridsize; i++ )
+      for ( size_t i = 1; i < gridsize; i++ )
         {
           if ( xvals2D[i] < xfirst ) xfirst = xvals2D[i];
           if ( xvals2D[i] > xlast  ) xlast  = xvals2D[i];
@@ -245,16 +251,16 @@ void print_xyvals2D(int gridID, int dig)
             }
         }
 
-      fprintf(stdout, "%33s : %.*g to %.*g", xname, dig, xfirst, dig, xlast);
-      if ( IS_NOT_EQUAL(xinc, 0) )
-        fprintf(stdout, " by %.*g", dig, xinc);
+      fprintf(stdout, "%33s : %.*g", xname, dig, xfirst);
+      if ( gridsize > 1 ) fprintf(stdout, " to %.*g", dig, xlast);
+      if ( IS_NOT_EQUAL(xinc, 0) ) fprintf(stdout, " by %.*g", dig, xinc);
       fprintf(stdout, " %s", xunits);
       if ( gridIsCircular(gridID) ) fprintf(stdout, "  circular");
       fprintf(stdout, "\n");
-      fprintf(stdout, "%33s : %.*g to %.*g", yname, dig, yfirst, dig, ylast);
-      if ( IS_NOT_EQUAL(yinc, 0) )
-        fprintf(stdout, " by %.*g", dig, yinc);
-      fprintf(stdout, " %s", xunits);
+      fprintf(stdout, "%33s : %.*g", yname, dig, yfirst);
+      if ( gridsize > 1 ) fprintf(stdout, " to %.*g", dig, ylast);
+      if ( IS_NOT_EQUAL(yinc, 0) ) fprintf(stdout, " by %.*g", dig, yinc);
+      fprintf(stdout, " %s", yunits);
       fprintf(stdout, "\n");
 
       free(xvals2D);
@@ -271,10 +277,10 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
     fprintf(stderr, "Internal problem (%s): sub grid not equal GRID_PROJECTION!\n", __func__);
 
   int trunc    = gridInqTrunc(gridID);
-  int gridsize = gridInqSize(gridID);
-  int xsize    = gridInqXsize(gridID);
-  int ysize    = gridInqYsize(gridID);
-  int xysize   = xsize*ysize;
+  size_t gridsize = gridInqSize(gridID);
+  size_t xsize    = gridInqXsize(gridID);
+  size_t ysize    = gridInqYsize(gridID);
+  size_t xysize   = xsize*ysize;
 
   // int prec     = gridInqPrec(gridID);
   // int dig = (prec == CDI_DATATYPE_FLT64) ? 15 : 7;
@@ -298,6 +304,7 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
   if ( gridtype == GRID_LONLAT     ||
        gridtype == GRID_PROJECTION ||
        gridtype == GRID_GENERIC    ||
+       gridtype == GRID_CHARXY    ||
        gridtype == GRID_GAUSSIAN   ||
        gridtype == GRID_GAUSSIAN_REDUCED )
     {
@@ -306,11 +313,11 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
 #ifdef CDO
           set_text_color(stdout, RESET, GREEN);
 #endif
-          fprintf(stdout, "points=%d", gridsize);
+          fprintf(stdout, "points=%zu", gridsize);
           if ( gridtype == GRID_GAUSSIAN_REDUCED )
-            fprintf(stdout, "  nlat=%d", ysize);
+            fprintf(stdout, "  nlat=%zu", ysize);
           else if ( xysize )
-            fprintf(stdout, " (%dx%d)", xsize, ysize);
+            fprintf(stdout, " (%zux%zu)", xsize, ysize);
 
           if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED )
             fprintf(stdout, "  np=%d", gridInqNP(gridID));
@@ -354,7 +361,7 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
 #ifdef CDO
       set_text_color(stdout, RESET, GREEN);
 #endif
-      fprintf(stdout, "points=%d  nsp=%d  truncation=%d", gridsize, gridsize/2, trunc);
+      fprintf(stdout, "points=%zu  nsp=%zu  truncation=%d", gridsize, gridsize/2, trunc);
       if ( gridInqComplexPacking(gridID) ) fprintf(stdout, "  complexPacking");
       my_reset_text_color(stdout);
       fprintf(stdout, "\n");
@@ -364,7 +371,7 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
 #ifdef CDO
       set_text_color(stdout, RESET, GREEN);
 #endif
-      fprintf(stdout, "points=%d  nfc=%d  truncation=%d\n", gridsize, gridsize/2, trunc);
+      fprintf(stdout, "points=%zu  nfc=%zu  truncation=%d\n", gridsize, gridsize/2, trunc);
       my_reset_text_color(stdout);
     }
   else if ( gridtype == GRID_GME )
@@ -374,7 +381,7 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
 #ifdef CDO
       set_text_color(stdout, RESET, GREEN);
 #endif
-      fprintf(stdout, "points=%d  nd=%d  ni=%d\n", gridsize, nd, ni);
+      fprintf(stdout, "points=%zu  nd=%d  ni=%d\n", gridsize, nd, ni);
       my_reset_text_color(stdout);
     }
   else if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED )
@@ -383,9 +390,9 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
       set_text_color(stdout, RESET, GREEN);
 #endif
       if ( gridtype == GRID_CURVILINEAR )
-        fprintf(stdout, "points=%d (%dx%d)", gridsize, xsize, ysize);
+        fprintf(stdout, "points=%zu (%zux%zu)", gridsize, xsize, ysize);
       else
-        fprintf(stdout, "points=%d", gridsize);
+        fprintf(stdout, "points=%zu", gridsize);
 
       if ( gridtype == GRID_UNSTRUCTURED && gridInqNvertex(gridID) > 0 )
         fprintf(stdout, "  nvertex=%d", gridInqNvertex(gridID));
@@ -416,9 +423,9 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
       set_text_color(stdout, RESET, GREEN);
 #endif
       if ( ysize == 0 )
-        fprintf(stdout, "points=%d\n", gridsize);
+        fprintf(stdout, "points=%zu\n", gridsize);
       else
-        fprintf(stdout, "points=%d (%dx%d)\n", gridsize, xsize, ysize);
+        fprintf(stdout, "points=%zu (%zux%zu)\n", gridsize, xsize, ysize);
       my_reset_text_color(stdout);
     }
 
diff --git a/cdi.settings.in b/cdi.settings.in
index b4d2c67ecaa278c9c0da04d0629bc728491e0ec9..d456b4685b4b0ca55cb587231d798d83ec2164bd 100644
--- a/cdi.settings.in
+++ b/cdi.settings.in
@@ -48,6 +48,10 @@
         "lib"      : "@GRIB_API_LIBS@",
         "include"  : "@GRIB_API_INCLUDE@"
       }
+      "eccodes" : {
+        "lib"      : "@ECCODES_LIBS@",
+        "include"  : "@ECCODES_INCLUDE@"
+      }
     }
   },
   "features" : {
diff --git a/config/default b/config/default
index 3b3a495abaa45e950f18ea8f85badadd5f5c5497..50ea718d02fda05b840410757d5ea124cdb990d0 100755
--- a/config/default
+++ b/config/default
@@ -24,8 +24,8 @@ case "${HOSTNAME}" in
                     --enable-iso-c-interface \
                     --enable-swig \
                     --enable-python \
-                    --with-grib_api=$HOME/local/gribapi-1.12.3 \
-                    --with-netcdf=$HOME/local \
+                    --with-eccodes=$HOME/local/eccodes-2.3.0 \
+                    --with-netcdf=$HOME/local/netcdf-4.4.1.1 \
                     --with-szlib=$HOME/local \
 	            CC=icc CFLAGS="-g -D_REENTRANT -Wall -Wwrite-strings -O3 -march=native -fp-model source"
 	;;
@@ -35,9 +35,10 @@ case "${HOSTNAME}" in
                     --enable-iso-c-interface \
                     --enable-swig \
                     --enable-python \
-                    --with-grib_api=$HOME/local/grib_api-1.13.1 \
-                    --with-netcdf=$HOME/local/netcdf-c-4.3.3.1-threadsafe \
+                    --with-eccodes=$HOME/local/eccodes-2.3.0 \
+                    --with-netcdf=$HOME/local/netcdf-4.4.1.1 \
                     --with-szlib=$HOME/local \
+                    LDFLAGS="-Wl,-rpath,$HOME/local/eccodes-2.3.0/lib" \
 	            CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -Wwrite-strings -W -Wfloat-equal -pedantic -O3 -march=native"
 	;;
     cinglung*|feilung*|wanglung*)
diff --git a/configure b/configure
index 3b6c032eea31600e5ee8353544cf3478a19661f4..44a7d8ee66f52fbbffeffcb2650241f8c83d79ef 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.68 for cdi 1.8.2.
+# Generated by GNU Autoconf 2.68 for cdi 1.9.0.
 #
 # Report bugs to <http://mpimet.mpg.de/cdi>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='cdi'
 PACKAGE_TARNAME='cdi'
-PACKAGE_VERSION='1.8.2'
-PACKAGE_STRING='cdi 1.8.2'
+PACKAGE_VERSION='1.9.0'
+PACKAGE_STRING='cdi 1.9.0'
 PACKAGE_BUGREPORT='http://mpimet.mpg.de/cdi'
 PACKAGE_URL=''
 
@@ -690,6 +690,8 @@ HAVE_LIBGRIB_API_FALSE
 HAVE_LIBGRIB_API_TRUE
 GRIB_API_LIBS
 GRIB_API_INCLUDE
+ECCODES_LIBS
+ECCODES_INCLUDE
 NETCDF_LIBS
 NETCDF_INCLUDE
 NETCDF_ROOT
@@ -860,6 +862,7 @@ enable_largefile
 with_threads
 with_szlib
 with_netcdf
+with_eccodes
 with_grib_api
 enable_grib
 enable_cgribex
@@ -1463,7 +1466,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 cdi 1.8.2 to adapt to many kinds of systems.
+\`configure' configures cdi 1.9.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1533,7 +1536,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of cdi 1.8.2:";;
+     short | recursive ) echo "Configuration of cdi 1.9.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1590,10 +1593,14 @@ Optional Packages:
                           NETCDF4 compression
   --with-netcdf=<yes|no|directory> (default=no)
                           location of NetCDF library (lib and include subdirs)
+  --with-eccodes=<yes|no|directory>
+                          library for grib2 encoding/decoding; if a directory
+                          is given, it will be used as a value for
+                          --with-eccodes-root
   --with-grib_api=<yes|no|directory>
-                          library for grib2 compression; if a directory is
-                          given, it will be used as a value for
-                          --with-jasper-root
+                          library for grib2 encoding/decoding; if a directory
+                          is given, it will be used as a value for
+                          --with-grib_api-root
   --with-mpi-root         set directory to search for MPI headers and library
   --with-mpi-include      specifically set directory to search for MPI
                           headers, [default=$with_mpi_root/include]
@@ -1728,7 +1735,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-cdi configure 1.8.2
+cdi configure 1.9.0
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2573,7 +2580,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 cdi $as_me 1.8.2, which was
+It was created by cdi $as_me 1.9.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -3525,7 +3532,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='cdi'
- VERSION='1.8.2'
+ VERSION='1.9.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -23442,7 +23449,7 @@ Usage: $0 [OPTIONS]
 Report bugs to <bug-libtool@gnu.org>."
 
 lt_cl_version="\
-cdi config.lt 1.8.2
+cdi config.lt 1.9.0
 configured by $0, generated by GNU Autoconf 2.68.
 
 Copyright (C) 2011 Free Software Foundation, Inc.
@@ -27576,6 +27583,187 @@ fi
 
 
 
+#  ----------------------------------------------------------------------
+#  Compile application with ECCODES library (for GRIB2 support)
+ECCODES_INCLUDE=''
+ECCODES_LIBS=''
+
+# Check whether --with-eccodes was given.
+if test "${with_eccodes+set}" = set; then :
+  withval=$with_eccodes; case "$with_eccodes" in #(
+  no) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ECCODES library" >&5
+$as_echo_n "checking for ECCODES library... " >&6; }
+                           { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
+$as_echo "suppressed" >&6; } ;; #(
+  yes) :
+    for ac_header in grib_api.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "grib_api.h" "ac_cv_header_grib_api_h" "$ac_includes_default"
+if test "x$ac_cv_header_grib_api_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GRIB_API_H 1
+_ACEOF
+
+fi
+
+done
+
+                            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing grib_get_message" >&5
+$as_echo_n "checking for library containing grib_get_message... " >&6; }
+if ${ac_cv_search_grib_get_message+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char grib_get_message ();
+int
+main ()
+{
+return grib_get_message ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' eccodes; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_grib_get_message=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_grib_get_message+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_grib_get_message+:} false; then :
+
+else
+  ac_cv_search_grib_get_message=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_grib_get_message" >&5
+$as_echo "$ac_cv_search_grib_get_message" >&6; }
+ac_res=$ac_cv_search_grib_get_message
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+$as_echo "#define HAVE_LIBGRIB_API 1" >>confdefs.h
+
+else
+  as_fn_error $? "Could not link to eccodes library" "$LINENO" 5
+fi
+ ;; #(
+  *) :
+    ECCODES_ROOT=$with_eccodes
+                          if test -d "$ECCODES_ROOT"; then :
+  LDFLAGS="-L$ECCODES_ROOT/lib $LDFLAGS"
+                                 CPPFLAGS="-I$ECCODES_ROOT/include $CPPFLAGS"
+                                 for ac_header in grib_api.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "grib_api.h" "ac_cv_header_grib_api_h" "$ac_includes_default"
+if test "x$ac_cv_header_grib_api_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GRIB_API_H 1
+_ACEOF
+
+fi
+
+done
+
+                                 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing grib_get_message" >&5
+$as_echo_n "checking for library containing grib_get_message... " >&6; }
+if ${ac_cv_search_grib_get_message+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char grib_get_message ();
+int
+main ()
+{
+return grib_get_message ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' eccodes; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_grib_get_message=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_grib_get_message+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_grib_get_message+:} false; then :
+
+else
+  ac_cv_search_grib_get_message=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_grib_get_message" >&5
+$as_echo "$ac_cv_search_grib_get_message" >&6; }
+ac_res=$ac_cv_search_grib_get_message
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+$as_echo "#define HAVE_LIBGRIB_API 1" >>confdefs.h
+
+else
+  as_fn_error $? "Could not link to eccodes library" "$LINENO" 5
+fi
+
+                                 ECCODES_LIBS=" -L$ECCODES_ROOT/lib -leccodes"
+                                 ECCODES_INCLUDE=" -I$ECCODES_ROOT/include"
+else
+  as_fn_error $? "$ECCODES_ROOT is not a directory! ECCODES suppressed" "$LINENO" 5
+fi ;; #(
+  *) :
+     ;;
+esac
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the ECCODES library" >&5
+$as_echo_n "checking for the ECCODES library... " >&6; }
+             { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
+$as_echo "suppressed" >&6; }
+fi
+
+
+
+# AM_CONDITIONAL([HAVE_LIBGRIB_API],[test "x$with_eccodes" != 'x' -a "x$with_eccodes" != 'xno' ])
 #  ----------------------------------------------------------------------
 #  Compile application with GRIB_API library (for GRIB2 support)
 GRIB_API_INCLUDE=''
@@ -27756,7 +27944,7 @@ fi
 
 
 
- if test "x$with_grib_api" != 'x' -a "x$with_grib_api" != 'xno' ; then
+ if test \( "x$with_grib_api" != 'x' -a "x$with_grib_api" != 'xno' \) -o \( "x$with_eccodes" != 'x' -a "x$with_eccodes" != 'xno' \) ; then
   HAVE_LIBGRIB_API_TRUE=
   HAVE_LIBGRIB_API_FALSE='#'
 else
@@ -30620,7 +30808,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 cdi $as_me 1.8.2, which was
+This file was extended by cdi $as_me 1.9.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -30686,7 +30874,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="\\
-cdi config.status 1.8.2
+cdi config.status 1.9.0
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 4b1ad308859344189d9a1bc717d2e38dfaadadf1..9d52c3c181d36445e9f4ecbdd2895959437528d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
 #  autoconf 2.68
 #  libtool  2.4.2
 
-AC_INIT([cdi], [1.8.2], [http://mpimet.mpg.de/cdi])
+AC_INIT([cdi], [1.9.0], [http://mpimet.mpg.de/cdi])
 
 AC_DEFINE_UNQUOTED(CDI, ["$PACKAGE_VERSION"], [CDI version])
 
diff --git a/doc/tex/bib.tex b/doc/tex/bib.tex
index e536863c346f1b4d4c1ca47e9734eaefc7bca927..ca61769f8a00c3663144d58b9da84a42ef66eb03 100644
--- a/doc/tex/bib.tex
+++ b/doc/tex/bib.tex
@@ -1,5 +1,12 @@
 \begin{thebibliography}{xx}
 
+\bibitem[ecCodes]{ecCodes} \ \\
+  \href{https://software.ecmwf.int/wiki/display/ECC/ecCodes+Home}
+       {API for GRIB decoding/encoding},
+  from the European Centre for Medium-Range Weather Forecasts
+  (\href{http://www.ecmwf.int}{ECMWF})
+
+
 \bibitem[ECHAM]{ECHAM} \ \\
   \href{http://www.mpimet.mpg.de/wissenschaft/publikationen/reports.html}
        {The atmospheric general circulation model ECHAM5},
@@ -15,13 +22,6 @@
   (\href{http://www.wmo.ch}{WMO})
 
 
-\bibitem[GRIBAPI]{GRIBAPI} \ \\
-  \href{http://www.ecmwf.int/products/data/software/grib_api.html}
-       {GRIB API decoding/encoding},
-  from the European Centre for Medium-Range Weather Forecasts
-  (\href{http://www.ecmwf.int}{ECMWF})
-
-
 \bibitem[HDF5]{HDF5} \ \\
   \href{http://hdf.ncsa.uiuc.edu/HDF5/}
        {HDF version 5},
diff --git a/doc/tex/c_quick_ref.tex b/doc/tex/c_quick_ref.tex
index 1cedc77297cce942ba5427211751da4517d6393a..fce98ce70d4d06d62c41fc9939db4aef6c720c77 100644
--- a/doc/tex/c_quick_ref.tex
+++ b/doc/tex/c_quick_ref.tex
@@ -813,15 +813,6 @@ read table of parameters from file in tabular format.
 write table of parameters to file in tabular format.
 
 
-\section*{\tt \htmlref{tableWriteC}{tableWriteC}}
-
-\begin{verbatim}
-    void tableWriteC (const char *filename, int tableID);
-\end{verbatim}
-
-write table of parameters to file in C language format.
-
-
 \section*{\tt \htmlref{taxisCreate}{taxisCreate}}
 
 \begin{verbatim}
@@ -1444,6 +1435,15 @@ Destroy a vertical Z-axis.
 Duplicate a Z-axis.
 
 
+\section*{\tt \htmlref{zaxisInqCLen}{zaxisInqCLen}}
+
+\begin{verbatim}
+    int zaxisInqCLen (int zaxisID);
+\end{verbatim}
+
+Get maximal string length of character Z-axis.
+
+
 \section*{\tt \htmlref{zaxisInqLevel}{zaxisInqLevel}}
 
 \begin{verbatim}
diff --git a/doc/tex/cdi_cman.tex b/doc/tex/cdi_cman.tex
index 17e152db5425fe36e202d22289f04bfb64164947..2e52b46f756a6fdf831c721c5ebea831f004e263 100644
--- a/doc/tex/cdi_cman.tex
+++ b/doc/tex/cdi_cman.tex
@@ -135,7 +135,7 @@
 \end{picture}
 
 \begin{flushright}
-{\large\bfseries Climate Data Interface \\ Version 1.8.1 \\ April 2017}
+{\large\bfseries Climate Data Interface \\ Version 1.9.0 \\ August 2017}
 \end{flushright}
 
 \vfill
diff --git a/doc/tex/cdi_fman.tex b/doc/tex/cdi_fman.tex
index c5727d83cf8d312451d64c66061550b8460f7c10..42bd0fd9d719fb06b2ae24af878443c19f1a8874 100644
--- a/doc/tex/cdi_fman.tex
+++ b/doc/tex/cdi_fman.tex
@@ -132,7 +132,7 @@
 \end{picture}
 
 \begin{flushright}
-{\large\bfseries Climate Data Interface \\ Version 1.8.1 \\ April 2017}
+{\large\bfseries Climate Data Interface \\ Version 1.9.0 \\ August 2017}
 \end{flushright}
 
 \vfill
diff --git a/doc/tex/dataset.tex b/doc/tex/dataset.tex
index f7996bc9284a98abb3f9dcb2a7ebdaee2c96af1f..c26ecb75b069195f052052dc675cab99df5cbb23 100644
--- a/doc/tex/dataset.tex
+++ b/doc/tex/dataset.tex
@@ -18,7 +18,7 @@ with one of the following predefined file format types:
 \end{minipage}
 \vspace*{3mm}
 
-\texttt{CDI\_FILETYPE\_GRB2} is only available if the {\CDI} library was compiled with GRIB\_API support and all NetCDF file types are only available if the {\CDI} library was compiled with NetCDF support!
+\texttt{CDI\_FILETYPE\_GRB2} is only available if the {\CDI} library was compiled with ecCodes support and all NetCDF file types are only available if the {\CDI} library was compiled with NetCDF support!
 
 To set the byte order of a binary dataset with the file format
 type \texttt{CDI\_FILETYPE\_SRV}, \texttt{CDI\_FILETYPE\_EXT} or \texttt{CDI\_FILETYPE\_IEG} use one of the
diff --git a/doc/tex/f_quick_ref.tex b/doc/tex/f_quick_ref.tex
index 78386764101325a7a2c3183c7d2891395f2beb03..a3f2c6754b7a97c1ed32579d60c2b190dd9a266e 100644
--- a/doc/tex/f_quick_ref.tex
+++ b/doc/tex/f_quick_ref.tex
@@ -818,15 +818,6 @@ read table of parameters from file in tabular format.
 write table of parameters to file in tabular format.
 
 
-\section*{\tt \htmlref{tableWriteC}{tableWriteC}}
-
-\begin{verbatim}
-    SUBROUTINE tableWriteC (CHARACTER*(*) filename, INTEGER tableID)
-\end{verbatim}
-
-write table of parameters to file in C language format.
-
-
 \section*{\tt \htmlref{taxisCreate}{taxisCreate}}
 
 \begin{verbatim}
@@ -1462,6 +1453,15 @@ Destroy a vertical Z-axis.
 Duplicate a Z-axis.
 
 
+\section*{\tt \htmlref{zaxisInqCLen}{zaxisInqCLen}}
+
+\begin{verbatim}
+    INTEGER FUNCTION zaxisInqCLen (INTEGER zaxisID)
+\end{verbatim}
+
+Get maximal string length of character Z-axis.
+
+
 \section*{\tt \htmlref{zaxisInqLevel}{zaxisInqLevel}}
 
 \begin{verbatim}
diff --git a/doc/tex/formats.tex b/doc/tex/formats.tex
index 854f1159254c7912ffd831add972008588ea03d3..0576de2503096ee4c1b9595af346ca48cc5156ee 100644
--- a/doc/tex/formats.tex
+++ b/doc/tex/formats.tex
@@ -88,13 +88,13 @@ The configure option \texttt{--disable-cgribex} will disable the encoding/decodi
 
 \subsection{GRIB edition 2}
 
-GRIB2 is available in {\CDI} via the ECMWF GRIB\_API \cite{GRIBAPI}.
-GRIB\_API is an external library and not part of {\CDI}. To use GRIB2 with
-{\CDI} the GRIB\_API library must be installed before the configuration
-of the {\CDI} library. Use the configure option \texttt{--with-grib\_api} to
+GRIB2 is available in {\CDI} via the ECMWF ecCodes \cite{ecCodes} library.
+ecCodes is an external library and not part of {\CDI}. To use GRIB2 with
+{\CDI} the ecCodes library must be installed before the configuration
+of the {\CDI} library. Use the configure option \texttt{--with-eccodes} to
 enable GRIB2 support. 
 
-The GRIB\_API library is also used to encode/decode GRIB1 records if the support for the CGRIBEX library is disabled.
+The ecCodes library is also used to encode/decode GRIB1 records if the support for the CGRIBEX library is disabled.
 This feature is not tested regulary and the status is experimental!
 
 \section{NetCDF}
diff --git a/doc/tex/install.tex b/doc/tex/install.tex
index 0420aa6a084e3bc9c0c0a77fcd7196d06181dbca..e2274ddc6ee290891314d7442a7e79103b26b94f 100644
--- a/doc/tex/install.tex
+++ b/doc/tex/install.tex
@@ -15,9 +15,9 @@ To take full advantage of {\CDI}'s features the following additional libraries s
       (\texttt{http://www.unidata.ucar.edu/packages/netcdf})
       version 3 or higher.
       This is needed to read/write NetCDF files with {\CDI}. 
-\item The ECMWF \href{http://www.ecmwf.int/products/data/software/grib_api.html}{GRIB\_API}
-      (\texttt{http://www.ecmwf.int/products/data/software/grib\_api.html})
-      version 1.9.5 or higher.
+\item ECMWF \href{https://software.ecmwf.int/wiki/display/ECC/ecCodes+Home}{ecCodes} library
+      (\texttt{https://software.ecmwf.int/wiki/display/ECC/ecCodes+Home})
+      version 2.3.0 or higher.
       This library is needed to encode/decode GRIB2 records with {\CDI}. 
 \end{itemize}
 
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 76603af1bf6332f0aa5fdceaea5d9667cb29dcc1..9be7838096a92359bde2742b67264a08e0d63633 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -285,6 +285,8 @@ DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
+ECCODES_INCLUDE = @ECCODES_INCLUDE@
+ECCODES_LIBS = @ECCODES_LIBS@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
diff --git a/examples/pio/Makefile.in b/examples/pio/Makefile.in
index cb52b1185ced6ffe3ab55706c56aceaa06ce8c66..ebd9c3fa67d85b31b03986a28eafcc5d32d6732a 100644
--- a/examples/pio/Makefile.in
+++ b/examples/pio/Makefile.in
@@ -268,6 +268,8 @@ DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
+ECCODES_INCLUDE = @ECCODES_INCLUDE@
+ECCODES_LIBS = @ECCODES_LIBS@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
diff --git a/interfaces/Makefile.in b/interfaces/Makefile.in
index f52e8ec08018d34b4311f6d94410d55eded8810a..38722a614299a7944d3f785e9f0d539d7fb2114b 100644
--- a/interfaces/Makefile.in
+++ b/interfaces/Makefile.in
@@ -252,6 +252,8 @@ DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
+ECCODES_INCLUDE = @ECCODES_INCLUDE@
+ECCODES_LIBS = @ECCODES_LIBS@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
diff --git a/m4/acx_options.m4 b/m4/acx_options.m4
index 997cb0dfe47d4ca3be01d3d634924ae8d4817ff9..ee2555782c0ebe0a6fb62506164746ae4f1c698b 100644
--- a/m4/acx_options.m4
+++ b/m4/acx_options.m4
@@ -155,12 +155,44 @@ AC_SUBST([NETCDF_ROOT])
 AC_SUBST([NETCDF_INCLUDE])
 AC_SUBST([NETCDF_LIBS])
 #  ----------------------------------------------------------------------
+#  Compile application with ECCODES library (for GRIB2 support)
+ECCODES_INCLUDE=''
+ECCODES_LIBS=''
+AC_ARG_WITH([eccodes],
+            [AS_HELP_STRING([--with-eccodes=<yes|no|directory>],
+                            [library for grib2 encoding/decoding; if a directory is given, it will be used as a value for --with-eccodes-root])],
+            [AS_CASE(["$with_eccodes"],
+                     [no],[AC_MSG_CHECKING([for ECCODES library])
+                           AC_MSG_RESULT([suppressed])],
+                     [yes],[AC_CHECK_HEADERS([grib_api.h])
+                            AC_SEARCH_LIBS([grib_get_message],
+                                           [eccodes],
+                                           [AC_DEFINE([HAVE_LIBGRIB_API],[1],[ECCODES library is present if defined to 1])],
+                                           [AC_MSG_ERROR([Could not link to eccodes library])])],
+                     [*],[ECCODES_ROOT=$with_eccodes
+                          AS_IF([test -d "$ECCODES_ROOT"],
+                                [LDFLAGS="-L$ECCODES_ROOT/lib $LDFLAGS"
+                                 CPPFLAGS="-I$ECCODES_ROOT/include $CPPFLAGS"
+                                 AC_CHECK_HEADERS([grib_api.h])
+                                 AC_SEARCH_LIBS([grib_get_message],
+                                                [eccodes],
+                                                [AC_DEFINE([HAVE_LIBGRIB_API],[1],[ECCODES library is present if defined to 1])],
+                                                [AC_MSG_ERROR([Could not link to eccodes library])])
+                                 ECCODES_LIBS=" -L$ECCODES_ROOT/lib -leccodes"
+                                 ECCODES_INCLUDE=" -I$ECCODES_ROOT/include"],
+                                [AC_MSG_ERROR([$ECCODES_ROOT is not a directory! ECCODES suppressed])])])],
+            [AC_MSG_CHECKING([for the ECCODES library])
+             AC_MSG_RESULT([suppressed])])
+AC_SUBST([ECCODES_INCLUDE])
+AC_SUBST([ECCODES_LIBS])
+# AM_CONDITIONAL([HAVE_LIBGRIB_API],[test "x$with_eccodes" != 'x' -a "x$with_eccodes" != 'xno' ])
+#  ----------------------------------------------------------------------
 #  Compile application with GRIB_API library (for GRIB2 support)
 GRIB_API_INCLUDE=''
 GRIB_API_LIBS=''
 AC_ARG_WITH([grib_api],
             [AS_HELP_STRING([--with-grib_api=<yes|no|directory>],
-                            [library for grib2 compression; if a directory is given, it will be used as a value for --with-jasper-root])],
+                            [library for grib2 encoding/decoding; if a directory is given, it will be used as a value for --with-grib_api-root])],
             [AS_CASE(["$with_grib_api"],
                      [no],[AC_MSG_CHECKING([for GRIB_API library])
                            AC_MSG_RESULT([suppressed])],
@@ -185,7 +217,7 @@ AC_ARG_WITH([grib_api],
              AC_MSG_RESULT([suppressed])])
 AC_SUBST([GRIB_API_INCLUDE])
 AC_SUBST([GRIB_API_LIBS])
-AM_CONDITIONAL([HAVE_LIBGRIB_API],[test "x$with_grib_api" != 'x' -a "x$with_grib_api" != 'xno' ])
+AM_CONDITIONAL([HAVE_LIBGRIB_API],[test \( "x$with_grib_api" != 'x' -a "x$with_grib_api" != 'xno' \) -o \( "x$with_eccodes" != 'x' -a "x$with_eccodes" != 'xno' \) ])
 #  ----------------------------------------------------------------------
 #  Enable GRIB support
 AC_MSG_CHECKING([for GRIB support])
diff --git a/src/Makefile.am b/src/Makefile.am
index e3b8f1370692bdc7fbda378b3f60aea6cb736b9c..a286427af200177808835270bd7d12b70ffc8e33 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -138,7 +138,7 @@ libcdi_la_USE_FC_extra_sources = \
 	cfortran.h       \
 	cdiFortran.c
 
-# these only contain code iff grib_api is available
+# these only contain code if grib_api is available
 libcdi_la_HAVE_LIBGRIB_API_extra_sources = \
 	gribapi_utilities.c stream_gribapi.c
 
diff --git a/src/Makefile.in b/src/Makefile.in
index 5d24144402a9990aceaca0be9a91c2b11ed9f489..5d2ae72c5f1559a6b94f6ed9e07cff719ad9ae74 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -339,6 +339,8 @@ DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
+ECCODES_INCLUDE = @ECCODES_INCLUDE@
+ECCODES_LIBS = @ECCODES_LIBS@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
@@ -541,7 +543,7 @@ libcdi_la_USE_FC_extra_sources = \
 	cdiFortran.c
 
 
-# these only contain code iff grib_api is available
+# these only contain code if grib_api is available
 libcdi_la_HAVE_LIBGRIB_API_extra_sources = \
 	gribapi_utilities.c stream_gribapi.c
 
@@ -945,8 +947,8 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
-@ENABLE_CDI_LIB_FALSE@install-exec-local:
 @ENABLE_CDI_LIB_FALSE@uninstall-local:
+@ENABLE_CDI_LIB_FALSE@install-exec-local:
 clean: clean-am
 
 clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
diff --git a/src/cdf.c b/src/cdf.c
index b7ed6c37bfbeea110360822fb4fded3ec6ea4433..4d55129783ec7b5759dda946d89098eeb4610fc5 100644
--- a/src/cdf.c
+++ b/src/cdf.c
@@ -163,15 +163,15 @@ int cdfOpen(const char *filename, const char *mode)
 int cdfOpen64(const char *filename, const char *mode)
 {
   int fileID = -1;
-  int open_file = TRUE;
   int filetype = CDI_FILETYPE_NC2;
+  bool open_file = true;
 
   if ( CDF_Debug )
     Message("Open %s with mode %c", filename, *mode);
 
 #if  defined  (HAVE_LIBNETCDF)
 #if  ! defined  (NC_64BIT_OFFSET)
-  open_file = FALSE;
+  open_file = false;
 #endif
 #endif
 
@@ -194,13 +194,13 @@ int cdfOpen64(const char *filename, const char *mode)
 int cdf4Open(const char *filename, const char *mode, int *filetype)
 {
   int fileID = -1;
-  int open_file = FALSE;
+  bool open_file = false;
 
   if ( CDF_Debug )
     Message("Open %s with mode %c", filename, *mode);
 
 #if  defined  (HAVE_NETCDF4)
-  open_file = TRUE;
+  open_file = true;
 #endif
 
   if ( open_file )
diff --git a/src/cdf_int.c b/src/cdf_int.c
index cfc3574a1816b045ae5f140a5fc98e276e1c9f52..04c146c4b0394d0119f6ff0b4d3dc1324c797c4e 100644
--- a/src/cdf_int.c
+++ b/src/cdf_int.c
@@ -76,12 +76,12 @@ void cdf_create(const char *path, int cmode, int *ncidp)
 int cdf_open(const char *path, int omode, int *ncidp)
 {
   int status = 0;
-  int dapfile = FALSE;
+  bool dapfile = false;
   struct stat filestat;
   size_t chunksizehint = 0;
 
 #if  defined  (HAVE_LIBNC_DAP)
-  if ( strncmp(path, "http:", 5) == 0 || strncmp(path, "https:", 6) == 0 ) dapfile = TRUE;
+  if ( strncmp(path, "http:", 5) == 0 || strncmp(path, "https:", 6) == 0 ) dapfile = true;
 #endif
 
   if ( dapfile )
@@ -395,6 +395,52 @@ void cdf_put_var_float(int ncid, int varid, const float *fp)
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
 
+static
+const char *cdf_var_type(nc_type xtype)
+{
+  const char *ctype = "unknown";
+
+  if      ( xtype == NC_BYTE   )  ctype = "NC_BYTE";
+  else if ( xtype == NC_CHAR   )  ctype = "NC_CHAR";
+  else if ( xtype == NC_SHORT  )  ctype = "NC_SHORT";
+  else if ( xtype == NC_INT    )  ctype = "NC_INT";
+  else if ( xtype == NC_FLOAT  )  ctype = "NC_FLOAT";
+  else if ( xtype == NC_DOUBLE )  ctype = "NC_DOUBLE";
+#if  defined  (HAVE_NETCDF4)
+  else if ( xtype == NC_UBYTE  )  ctype = "NC_UBYTE";
+  else if ( xtype == NC_LONG   )  ctype = "NC_LONG";
+  else if ( xtype == NC_USHORT )  ctype = "NC_USHORT";
+  else if ( xtype == NC_UINT   )  ctype = "NC_UINT";
+  else if ( xtype == NC_INT64  )  ctype = "NC_INT64";
+  else if ( xtype == NC_UINT64 )  ctype = "NC_UINT64";
+#endif
+
+  return ctype;
+}
+
+static
+void minmaxval(size_t nvals, const double *array, double *minval, double *maxval)
+{
+  *minval = array[0];
+  *maxval = array[0];
+  for ( size_t i = 1; i < nvals; ++i )
+    {
+      if      ( array[i] > *maxval ) *maxval = array[i];
+      else if ( array[i] < *minval ) *minval = array[i];
+    }
+}
+
+static
+void minmaxvalf(size_t nvals, const float *array, double *minval, double *maxval)
+{
+  *minval = array[0];
+  *maxval = array[0];
+  for ( size_t i = 1; i < nvals; ++i )
+    {
+      if      ( array[i] > *maxval ) *maxval = array[i];
+      else if ( array[i] < *minval ) *minval = array[i];
+    }
+}
 
 void cdf_put_vara_double(int ncid, int varid, const size_t start[],
                          const size_t count[], const double *dp)
@@ -402,13 +448,19 @@ void cdf_put_vara_double(int ncid, int varid, const size_t start[],
   int status = nc_put_vara_double(ncid, varid, start, count, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d val0 = %f", ncid, varid, *dp);
-
-  if ( status != NC_NOERR )
     {
       char name[256];
       nc_inq_varname(ncid, varid, name);
-      Message("varname = %s", name);
+      nc_type xtype;
+      nc_inq_vartype(ncid, varid, &xtype);
+      int ndims;
+      nc_inq_varndims(ncid, varid, &ndims);
+      double minval = 0, maxval = 0;
+      size_t nvals = 1;
+      for ( int i = 0; i < ndims; ++i ) nvals *= count[i];
+      minmaxval(nvals, dp, &minval, &maxval);
+      // Message("ncid = %d varid = %d val0 = %f", ncid, varid, *dp);
+      Message("name=%s  type=%s  minval=%f  maxval=%f", name, cdf_var_type(xtype), minval, maxval);
     }
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
@@ -421,7 +473,20 @@ void  cdf_put_vara_float(int ncid, int varid, const size_t start[],
   int status = nc_put_vara_float(ncid, varid, start, count, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d val0 = %f", ncid, varid, *fp);
+    {
+      char name[256];
+      nc_inq_varname(ncid, varid, name);
+      nc_type xtype;
+      nc_inq_vartype(ncid, varid, &xtype);
+      int ndims;
+      nc_inq_varndims(ncid, varid, &ndims);
+      double minval = 0, maxval = 0;
+      size_t nvals = 1;
+      for ( int i = 0; i < ndims; ++i ) nvals *= count[i];
+      minmaxvalf(nvals, fp, &minval, &maxval);
+      // Message("ncid = %d varid = %d val0 = %f", ncid, varid, *dp);
+      Message("name=%s  type=%s  minval=%f  maxval=%f", name, cdf_var_type(xtype), minval, maxval);
+    }
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
diff --git a/src/cdf_read.c b/src/cdf_read.c
index a81ccb75723838a1be5899f69f79afc22ccb4fbc..50747db00605a47942cdd58d71ba221b22cb4481 100644
--- a/src/cdf_read.c
+++ b/src/cdf_read.c
@@ -14,6 +14,7 @@
 #include "cdf.h"
 #include "cdf_int.h"
 #include "vlist.h"
+#include "vlist_var.h"
 
 
 static
diff --git a/src/cdf_util.c b/src/cdf_util.c
index 9f7ace1cebc317bd439e9b4067705869c9331abd..6a3c1c681a1e60d2295dba4ffa7ca54933879a51 100644
--- a/src/cdf_util.c
+++ b/src/cdf_util.c
@@ -13,6 +13,7 @@ void str_tolower(char *str)
       str[i] = (char)tolower((int)str[i]);
 }
 
+
 bool str_is_equal(const char *vstr, const char *cstr)
 {
   bool is_equal = false;
@@ -27,6 +28,8 @@ int get_timeunit(size_t len, const char *ptu)
 {
   int timeunit = -1;
 
+  while ( isspace(*ptu) && len ) { ptu++; len--; }
+
   if ( len > 2 )
     {
       if      ( str_is_equal(ptu, "sec") )            timeunit = TUNIT_SECOND;
@@ -37,8 +40,7 @@ int get_timeunit(size_t len, const char *ptu)
       else if ( str_is_equal(ptu, "calendar_month") ) timeunit = TUNIT_MONTH;
       else if ( str_is_equal(ptu, "year") )           timeunit = TUNIT_YEAR;
     }
-  else if ( len == 1 && ptu[0] == 's' )
-    timeunit = TUNIT_SECOND;
+  else if ( len == 1 && ptu[0] == 's' )  timeunit = TUNIT_SECOND;
 
   return timeunit;
 }
@@ -46,6 +48,8 @@ int get_timeunit(size_t len, const char *ptu)
 
 bool is_time_units(const char *timeunits)
 {
+  while ( isspace(*timeunits) ) timeunits++; 
+
   bool status = str_is_equal(timeunits, "sec")
              || str_is_equal(timeunits, "minute")
              || str_is_equal(timeunits, "hour")
diff --git a/src/cdf_write.c b/src/cdf_write.c
index a3a3b9857a9e6a2cf04772423eff0224366fc02f..f2f5eef12660b9b89e0f51c1978dbdabb1dc1894 100644
--- a/src/cdf_write.c
+++ b/src/cdf_write.c
@@ -11,6 +11,7 @@
 #include "cdf.h"
 #include "cdf_int.h"
 #include "vlist.h"
+#include "vlist_var.h"
 
 
 void cdfDefVarDeflate(int ncid, int ncvarid, int deflate_level)
@@ -93,7 +94,12 @@ void cdfDefVarMissval(stream_t *streamptr, int varID, int dtype, int lcheck)
 
       if ( xtype == NC_BYTE && missval > 127 && missval < 256 ) xtype = NC_INT;
 
-      cdf_put_att_double(fileID, ncvarid, "_FillValue", (nc_type) xtype, 1, &missval);
+      if ( lcheck == 0 ||
+           streamptr->ncmode != 2 ||
+           streamptr->filetype == CDI_FILETYPE_NC ||
+           streamptr->filetype == CDI_FILETYPE_NC2 )
+        cdf_put_att_double(fileID, ncvarid, "_FillValue", (nc_type) xtype, 1, &missval);
+
       cdf_put_att_double(fileID, ncvarid, "missing_value", (nc_type) xtype, 1, &missval);
 
       if ( lcheck && streamptr->ncmode == 2 ) cdf_enddef(fileID);
@@ -318,7 +324,6 @@ int cdfDefVar(stream_t *streamptr, int varID)
   int ncvarid = -1;
   int xid = CDI_UNDEFID, yid = CDI_UNDEFID;
   size_t xsize = 0, ysize = 0;
-  char varname[CDI_MAX_NAME];
   int dims[4];
   size_t chunks[4] = {0,0,0,0};
   int ndims = 0;
@@ -427,17 +432,19 @@ int cdfDefVar(stream_t *streamptr, int varID)
   if ( CDI_Debug )
     fprintf(stderr, "chunktype %d  chunks %d %d %d %d\n", chunktype, (int)chunks[0], (int)chunks[1], (int)chunks[2], (int)chunks[3]);
 
-  int tableID  = vlistInqVarTable(vlistID, varID);
-
-  const char *name     = vlistInqVarNamePtr(vlistID, varID);
-  const char *longname = vlistInqVarLongnamePtr(vlistID, varID);
-  const char *stdname  = vlistInqVarStdnamePtr(vlistID, varID);
-  const char *units    = vlistInqVarUnitsPtr(vlistID, varID);
+  char varname[CDI_MAX_NAME];
+  char name[CDI_MAX_NAME]; name[0] = 0;
+  char longname[CDI_MAX_NAME]; longname[0] = 0;
+  char stdname[CDI_MAX_NAME]; stdname[0] = 0;
+  char units[CDI_MAX_NAME]; units[0] = 0;
+  if ( vlistInqVarNamePtr(vlistID, varID) ) vlistInqVarName(vlistID, varID, name);
+  vlistInqVarLongname(vlistID, varID, longname);
+  vlistInqVarStdname(vlistID, varID, stdname);
+  vlistInqVarUnits(vlistID, varID, units);
 
-  if ( name     == NULL )     name = tableInqParNamePtr(tableID, code);
-  if ( longname == NULL ) longname = tableInqParLongnamePtr(tableID, code);
-  if ( units    == NULL )    units = tableInqParUnitsPtr(tableID, code);
-  if ( name )
+  int tableID  = vlistInqVarTable(vlistID, varID);
+  if ( !name[0] ) tableInqEntry(tableID, code, -1, name, longname, units);
+  if ( name[0] )
     {
       sprintf(varname, "%s", name);
 
@@ -464,7 +471,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
             Warning("Changed multiple entry of variable name '%s' to '%s'!", name, varname);
         }
 
-      name = varname;
+      strcpy(name, varname);
     }
   else
     {
@@ -493,7 +500,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
           if ( iz >= CDI_MAX_NAME ) break;
         }
 
-      name = varname;
+      strcpy(name, varname);
       code = 0;
       pdis = 255;
     }
@@ -530,14 +537,9 @@ int cdfDefVar(stream_t *streamptr, int varID)
         }
     }
 
-  if ( stdname && *stdname )
-    cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(stdname), stdname);
-
-  if ( longname && *longname )
-    cdf_put_att_text(fileID, ncvarid, "long_name", strlen(longname), longname);
-
-  if ( units && *units )
-    cdf_put_att_text(fileID, ncvarid, "units", strlen(units), units);
+  if ( *stdname )  cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(stdname), stdname);
+  if ( *longname ) cdf_put_att_text(fileID, ncvarid, "long_name", strlen(longname), longname);
+  if ( *units )    cdf_put_att_text(fileID, ncvarid, "units", strlen(units), units);
 
   if ( code > 0 && pdis == 255 )
     cdf_put_att_int(fileID, ncvarid, "code", NC_INT, 1, &code);
@@ -558,7 +560,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
 
   char coordinates[CDI_MAX_NAME]; coordinates[0] = 0;
 
-  if ( zaxis_is_scalar )
+  if ( zaxis_is_scalar || zaxisInqType(zaxisID) == ZAXIS_CHAR )
     {
       int nczvarID = streamptr->nczvarID[zaxisindex];
       if ( nczvarID != CDI_UNDEFID )
diff --git a/src/cdi.h b/src/cdi.h
index 22c54eb66f21ad9200b39881ea0a94cf2d63a0ed..1308607e5d8caab270d1ed6b810e400e80d4446b 100644
--- a/src/cdi.h
+++ b/src/cdi.h
@@ -36,11 +36,13 @@ extern "C" {
 #define  CDI_EEOF                  -1   // The end of file was encountered
 #define  CDI_ESYSTEM              -10   // Operating system error
 #define  CDI_EINVAL               -20   // Invalid argument
-#define  CDI_EUFTYPE              -21   // Unsupported file type
-#define  CDI_ELIBNAVAIL           -22   // xxx library not available
-#define  CDI_EUFSTRUCT            -23   // Unsupported file structure
-#define  CDI_EUNC4                -24   // Unsupported NetCDF4 structure
-#define  CDI_EDIMSIZE             -25   // Invalid dimension size
+#define  CDI_EISDIR               -21   // Is a directory
+#define  CDI_EISEMPTY             -22   // Is empty
+#define  CDI_EUFTYPE              -23   // Unsupported file type
+#define  CDI_ELIBNAVAIL           -24   // xxx library not available
+#define  CDI_EUFSTRUCT            -25   // Unsupported file structure
+#define  CDI_EUNC4                -26   // Unsupported NetCDF4 structure
+#define  CDI_EDIMSIZE             -27   // Invalid dimension size
 #define  CDI_ELIMIT               -99   // Internal limits exceeded
 
 /* File types */
@@ -697,11 +699,6 @@ double  vlistInqVarDblKey(int vlistID, int varID, const char *name);
 /* vlistInqVarIntKey: raw access to GRIB meta-data */
 int     vlistInqVarIntKey(int vlistID, int varID, const char *name);
 
-/* needed only for CDO operator after */
-const char *vlistInqVarNamePtr(int vlistID, int varID);
-const char *vlistInqVarLongnamePtr(int vlistID, int varID);
-const char *vlistInqVarUnitsPtr(int vlistID, int varID);
-
 /* CDI attributes */
 
 /*      cdiInqNatts: Get number of attributes assigned to this variable */
@@ -1011,11 +1008,17 @@ void    zaxisPrint(int zaxisID);
 void    zaxisDefLevels(int zaxisID, const double levels[]);
 
 /*      zaxisDefCvals: Define area types of a Z-axis */
-void    zaxisDefCvals(int zaxisID, const char *cvals[]);
+void    zaxisDefCvals(int zaxisID, const char *cvals[], size_t clength);
 
 /*      zaxisInqLevels: Get all levels of a Z-axis */
 int     zaxisInqLevels(int zaxisID, double levels[]);
 
+/*      zaxisInqCLen: Get maximal string length of character Z-axis */
+int     zaxisInqCLen(int zaxisID);
+
+/*      zaxisInqCVals: Get all string values of a character Z-axis */
+int     zaxisInqCVals(int zaxisID, char ***clevels);
+
 /*      zaxisDefLevel: Define one level of a Z-axis */
 void    zaxisDefLevel(int zaxisID, int levelID, double levels);
 
@@ -1199,8 +1202,6 @@ const char *modelInqNamePtr(int modelID);
 
 /* Table routines */
 
-/*      tableWriteC: write table of parameters to file in C language format */
-void    tableWriteC(const char *filename, int tableID);
 /*      tableFWriteC: write table of parameters to FILE* in C language format */
 void    tableFWriteC(FILE *ptfp, int tableID);
 /*      tableWrite: write table of parameters to file in tabular format */
@@ -1210,7 +1211,6 @@ int     tableRead(const char *tablefile);
 int     tableDef(int modelID, int tablenum, const char *tablename);
 
 const char *tableInqNamePtr(int tableID);
-void    tableDefEntry(int tableID, int code, const char *name, const char *longname, const char *units);
 
 int     tableInq(int modelID, int tablenum, const char *tablename);
 int     tableInqNumber(void);
@@ -1218,17 +1218,7 @@ int     tableInqNumber(void);
 int     tableInqNum(int tableID);
 int     tableInqModel(int tableID);
 
-void    tableInqPar(int tableID, int code, char *name, char *longname, char *units);
-
-int     tableInqParCode(int tableID, char *name, int *code);
-int     tableInqParName(int tableID, int code, char *name);
-int     tableInqParLongname(int tableID, int code, char *longname);
-int     tableInqParUnits(int tableID, int code, char *units);
-
-/* needed only for CDO operator after */
-const char *tableInqParNamePtr(int tableID, int parID);
-const char *tableInqParLongnamePtr(int tableID, int parID);
-const char *tableInqParUnitsPtr(int tableID, int parID);
+void    tableInqEntry(int tableID, int id, int ltype, char *name, char *longname, char *units);
 
 /* History routines */
 
diff --git a/src/cdi.inc b/src/cdi.inc
index 43f9758e15198ca6e7ee10fd8d59871f2d2b5d3c..b1e558302098a22ef14e45cee1024d3b8335eae0 100644
--- a/src/cdi.inc
+++ b/src/cdi.inc
@@ -1,10 +1,10 @@
 ! This file was automatically generated, don't edit!
 !
-! Fortran interface for CDI library version 1.8.1
+! Fortran interface for CDI library version 1.9.0
 !
 ! Author:
 ! -------
-! Uwe Schulzweida, MPI-MET, Hamburg,   May 2017
+! Uwe Schulzweida, MPI-MET, Hamburg,   July 2017
 !
 
       INTEGER    CDI_MAX_NAME
@@ -39,16 +39,20 @@
       PARAMETER (CDI_ESYSTEM            = -10)
       INTEGER    CDI_EINVAL
       PARAMETER (CDI_EINVAL             = -20)
+      INTEGER    CDI_EISDIR
+      PARAMETER (CDI_EISDIR             = -21)
+      INTEGER    CDI_EISEMPTY
+      PARAMETER (CDI_EISEMPTY           = -22)
       INTEGER    CDI_EUFTYPE
-      PARAMETER (CDI_EUFTYPE            = -21)
+      PARAMETER (CDI_EUFTYPE            = -23)
       INTEGER    CDI_ELIBNAVAIL
-      PARAMETER (CDI_ELIBNAVAIL         = -22)
+      PARAMETER (CDI_ELIBNAVAIL         = -24)
       INTEGER    CDI_EUFSTRUCT
-      PARAMETER (CDI_EUFSTRUCT          = -23)
+      PARAMETER (CDI_EUFSTRUCT          = -25)
       INTEGER    CDI_EUNC4
-      PARAMETER (CDI_EUNC4              = -24)
+      PARAMETER (CDI_EUNC4              = -26)
       INTEGER    CDI_EDIMSIZE
-      PARAMETER (CDI_EDIMSIZE           = -25)
+      PARAMETER (CDI_EDIMSIZE           = -27)
       INTEGER    CDI_ELIMIT
       PARAMETER (CDI_ELIMIT             = -99)
 !
@@ -1371,24 +1375,6 @@
 !                                     CHARACTER*(*)   name)
       EXTERNAL        vlistInqVarIntKey
 
-!
-!  needed only for CDO operator after
-!
-      CHARACTER(80)   vlistInqVarNamePtr
-!                                    (INTEGER         vlistID,
-!                                     INTEGER         varID)
-      EXTERNAL        vlistInqVarNamePtr
-
-      CHARACTER(80)   vlistInqVarLongnamePtr
-!                                    (INTEGER         vlistID,
-!                                     INTEGER         varID)
-      EXTERNAL        vlistInqVarLongnamePtr
-
-      CHARACTER(80)   vlistInqVarUnitsPtr
-!                                    (INTEGER         vlistID,
-!                                     INTEGER         varID)
-      EXTERNAL        vlistInqVarUnitsPtr
-
 !
 !  CDI attributes
 !
@@ -2021,6 +2007,10 @@
 !                                     DOUBLEPRECISION levels(*))
       EXTERNAL        zaxisInqLevels
 
+      INTEGER         zaxisInqCLen
+!                                    (INTEGER         zaxisID)
+      EXTERNAL        zaxisInqCLen
+
 !                     zaxisDefLevel
 !                                    (INTEGER         zaxisID,
 !                                     INTEGER         levelID,
@@ -2434,11 +2424,6 @@
 !
 !  Table routines
 !
-!                     tableWriteC
-!                                    (CHARACTER*(*)   filename,
-!                                     INTEGER         tableID)
-      EXTERNAL        tableWriteC
-
 !                     tableWrite
 !                                    (CHARACTER*(*)   filename,
 !                                     INTEGER         tableID)
@@ -2458,14 +2443,6 @@
 !                                    (INTEGER         tableID)
       EXTERNAL        tableInqNamePtr
 
-!                     tableDefEntry
-!                                    (INTEGER         tableID,
-!                                     INTEGER         code,
-!                                     CHARACTER*(*)   name,
-!                                     CHARACTER*(*)   longname,
-!                                     CHARACTER*(*)   units)
-      EXTERNAL        tableDefEntry
-
       INTEGER         tableInq
 !                                    (INTEGER         modelID,
 !                                     INTEGER         tablenum,
@@ -2483,55 +2460,14 @@
 !                                    (INTEGER         tableID)
       EXTERNAL        tableInqModel
 
-!                     tableInqPar
+!                     tableInqEntry
 !                                    (INTEGER         tableID,
-!                                     INTEGER         code,
+!                                     INTEGER         id,
+!                                     INTEGER         ltype,
 !                                     CHARACTER*(*)   name,
 !                                     CHARACTER*(*)   longname,
 !                                     CHARACTER*(*)   units)
-      EXTERNAL        tableInqPar
-
-      INTEGER         tableInqParCode
-!                                    (INTEGER         tableID,
-!                                     CHARACTER*(*)   name,
-!                                     INTEGER         code)
-      EXTERNAL        tableInqParCode
-
-      INTEGER         tableInqParName
-!                                    (INTEGER         tableID,
-!                                     INTEGER         code,
-!                                     CHARACTER*(*)   name)
-      EXTERNAL        tableInqParName
-
-      INTEGER         tableInqParLongname
-!                                    (INTEGER         tableID,
-!                                     INTEGER         code,
-!                                     CHARACTER*(*)   longname)
-      EXTERNAL        tableInqParLongname
-
-      INTEGER         tableInqParUnits
-!                                    (INTEGER         tableID,
-!                                     INTEGER         code,
-!                                     CHARACTER*(*)   units)
-      EXTERNAL        tableInqParUnits
-
-!
-!  needed only for CDO operator after
-!
-      CHARACTER(80)   tableInqParNamePtr
-!                                    (INTEGER         tableID,
-!                                     INTEGER         parID)
-      EXTERNAL        tableInqParNamePtr
-
-      CHARACTER(80)   tableInqParLongnamePtr
-!                                    (INTEGER         tableID,
-!                                     INTEGER         parID)
-      EXTERNAL        tableInqParLongnamePtr
-
-      CHARACTER(80)   tableInqParUnitsPtr
-!                                    (INTEGER         tableID,
-!                                     INTEGER         parID)
-      EXTERNAL        tableInqParUnitsPtr
+      EXTERNAL        tableInqEntry
 
 !
 !  History routines
diff --git a/src/cdiFortran.c b/src/cdiFortran.c
index 0308b0f1edff9a5d25e665142fe3d113941d782c..70de7f198e5dca87e6035962f3602520b04df3f5 100644
--- a/src/cdiFortran.c
+++ b/src/cdiFortran.c
@@ -10,6 +10,9 @@
 
 #if defined (HAVE_CF_INTERFACE)
 
+#include <limits.h>
+#include <assert.h>
+
 #if ! defined (__CFORTRAN_LOADED)
 #  if defined __clang__
 #    pragma GCC diagnostic push
@@ -26,6 +29,13 @@
 #  pragma GCC diagnostic ignored "-Wmissing-prototypes"
 #endif
 
+static
+int size_t_c2f(size_t value_size_t)
+{
+  assert(value_size_t < INT_MAX);
+  return (int) value_size_t;
+}
+
 
 /*  Byte order  */
 
@@ -293,12 +303,6 @@ FCALLSCFUN3 (INT, vlistHasVarKey, VLISTHASVARKEY, vlisthasvarkey, INT, INT, STRI
 FCALLSCFUN3 (DOUBLE, vlistInqVarDblKey, VLISTINQVARDBLKEY, vlistinqvardblkey, INT, INT, STRING)
 FCALLSCFUN3 (INT, vlistInqVarIntKey, VLISTINQVARINTKEY, vlistinqvarintkey, INT, INT, STRING)
 
-/*  needed only for CDO operator after  */
-
-FCALLSCFUN2 (STRING, vlistInqVarNamePtr, VLISTINQVARNAMEPTR, vlistinqvarnameptr, INT, INT)
-FCALLSCFUN2 (STRING, vlistInqVarLongnamePtr, VLISTINQVARLONGNAMEPTR, vlistinqvarlongnameptr, INT, INT)
-FCALLSCFUN2 (STRING, vlistInqVarUnitsPtr, VLISTINQVARUNITSPTR, vlistinqvarunitsptr, INT, INT)
-
 /*  CDI attributes  */
 
 FCALLSCFUN3 (INT, cdiInqNatts, CDIINQNATTS, cdiinqnatts, INT, INT, PINT)
@@ -432,6 +436,7 @@ FCALLSCFUN1 (INT, zaxisDuplicate, ZAXISDUPLICATE, zaxisduplicate, INT)
 FCALLSCSUB1 (zaxisPrint, ZAXISPRINT, zaxisprint, INT)
 FCALLSCSUB2 (zaxisDefLevels, ZAXISDEFLEVELS, zaxisdeflevels, INT, DOUBLEV)
 FCALLSCFUN2 (INT, zaxisInqLevels, ZAXISINQLEVELS, zaxisinqlevels, INT, DOUBLEV)
+FCALLSCFUN1 (INT, zaxisInqCLen, ZAXISINQCLEN, zaxisinqclen, INT)
 FCALLSCSUB3 (zaxisDefLevel, ZAXISDEFLEVEL, zaxisdeflevel, INT, INT, DOUBLE)
 FCALLSCFUN2 (DOUBLE, zaxisInqLevel, ZAXISINQLEVEL, zaxisinqlevel, INT, INT)
 FCALLSCSUB2 (zaxisDefNlevRef, ZAXISDEFNLEVREF, zaxisdefnlevref, INT, INT)
@@ -528,27 +533,15 @@ FCALLSCFUN1 (STRING, modelInqNamePtr, MODELINQNAMEPTR, modelinqnameptr, INT)
 
 /*  Table routines  */
 
-FCALLSCSUB2 (tableWriteC, TABLEWRITEC, tablewritec, STRING, INT)
 FCALLSCSUB2 (tableWrite, TABLEWRITE, tablewrite, STRING, INT)
 FCALLSCFUN1 (INT, tableRead, TABLEREAD, tableread, STRING)
 FCALLSCFUN3 (INT, tableDef, TABLEDEF, tabledef, INT, INT, STRING)
 FCALLSCFUN1 (STRING, tableInqNamePtr, TABLEINQNAMEPTR, tableinqnameptr, INT)
-FCALLSCSUB5 (tableDefEntry, TABLEDEFENTRY, tabledefentry, INT, INT, STRING, STRING, STRING)
 FCALLSCFUN3 (INT, tableInq, TABLEINQ, tableinq, INT, INT, STRING)
 FCALLSCFUN0 (INT, tableInqNumber, TABLEINQNUMBER, tableinqnumber)
 FCALLSCFUN1 (INT, tableInqNum, TABLEINQNUM, tableinqnum, INT)
 FCALLSCFUN1 (INT, tableInqModel, TABLEINQMODEL, tableinqmodel, INT)
-FCALLSCSUB5 (tableInqPar, TABLEINQPAR, tableinqpar, INT, INT, PSTRING, PSTRING, PSTRING)
-FCALLSCFUN3 (INT, tableInqParCode, TABLEINQPARCODE, tableinqparcode, INT, PSTRING, PINT)
-FCALLSCFUN3 (INT, tableInqParName, TABLEINQPARNAME, tableinqparname, INT, INT, PSTRING)
-FCALLSCFUN3 (INT, tableInqParLongname, TABLEINQPARLONGNAME, tableinqparlongname, INT, INT, PSTRING)
-FCALLSCFUN3 (INT, tableInqParUnits, TABLEINQPARUNITS, tableinqparunits, INT, INT, PSTRING)
-
-/*  needed only for CDO operator after  */
-
-FCALLSCFUN2 (STRING, tableInqParNamePtr, TABLEINQPARNAMEPTR, tableinqparnameptr, INT, INT)
-FCALLSCFUN2 (STRING, tableInqParLongnamePtr, TABLEINQPARLONGNAMEPTR, tableinqparlongnameptr, INT, INT)
-FCALLSCFUN2 (STRING, tableInqParUnitsPtr, TABLEINQPARUNITSPTR, tableinqparunitsptr, INT, INT)
+FCALLSCSUB6 (tableInqEntry, TABLEINQENTRY, tableinqentry, INT, INT, INT, PSTRING, PSTRING, PSTRING)
 
 /*  History routines  */
 
diff --git a/src/cdi_error.c b/src/cdi_error.c
index 786e1ba628f0dab56b08518e4ba7702c5013940a..7ddd652f98e7eafc70a1f50684540584e2855360 100644
--- a/src/cdi_error.c
+++ b/src/cdi_error.c
@@ -1,5 +1,5 @@
 #if defined (HAVE_CONFIG_H)
-#  include "config.h"
+#include "config.h"
 #endif
 
 #include <stdio.h>
@@ -10,6 +10,8 @@
 const char *cdiStringError(int cdiErrno)
 {
   static const char UnknownError[] = "Unknown Error";
+  static const char _EISDIR[]      = "Is a directory";
+  static const char _EISEMPTY[]    = "File is empty";
   static const char _EUFTYPE[]     = "Unsupported file type";
   static const char _ELIBNAVAIL[]  = "Unsupported file type (library support not compiled in)";
   static const char _EUFSTRUCT[]   = "Unsupported file structure";
@@ -24,6 +26,8 @@ const char *cdiStringError(int cdiErrno)
       if ( cp == NULL ) break;
       return cp;
     }
+  case CDI_EISDIR:     return _EISDIR;
+  case CDI_EISEMPTY:   return _EISEMPTY;
   case CDI_EUFTYPE:    return _EUFTYPE;
   case CDI_ELIBNAVAIL: return _ELIBNAVAIL;
   case CDI_EUFSTRUCT:  return _EUFSTRUCT;
diff --git a/src/cdi_int.c b/src/cdi_int.c
index 0bc2ee398453010a922888836980d599dcd75f1f..ac2cbbdf1e25943446a98c20ff3167a1db3f01ab 100644
--- a/src/cdi_int.c
+++ b/src/cdi_int.c
@@ -32,9 +32,9 @@ int cdiNcChunksizehint = CDI_UNDEFID;
 int cdiChunkType       = CDI_CHUNK_GRID;
 int cdiSplitLtype105   = CDI_UNDEFID;
 
-int cdiIgnoreAttCoordinates = FALSE;
-int cdiCoordinatesLonLat    = FALSE;
-int cdiIgnoreValidRange     = FALSE;
+bool cdiIgnoreAttCoordinates = false;
+bool cdiCoordinatesLonLat    = false;
+bool cdiIgnoreValidRange     = false;
 int cdiSkipRecords          = 0;
 int cdiConvention           = CDI_CONVENTION_ECHAM;
 int cdiInventoryMode        = 1;
@@ -314,13 +314,13 @@ void cdiSetChunk(const char *chunkAlgo)
 
 void cdiInitialize(void)
 {
-  static int Init_CDI = FALSE;
-  char *envstr;
-  long value;
+  static bool Init_CDI = false;
 
   if ( ! Init_CDI )
     {
-      Init_CDI = TRUE;
+      Init_CDI = true;
+      char *envstr;
+      long value;
 
 #if  defined  (HAVE_LIBCGRIBEX)
       gribFixZSE(1);   // 1: Fix ZeroShiftError of simple packed spherical harmonics
@@ -370,13 +370,13 @@ void cdiInitialize(void)
       if ( envstr ) cdiSplitLtype105 = atoi(envstr);
 
       envstr = getenv("IGNORE_ATT_COORDINATES");
-      if ( envstr ) cdiIgnoreAttCoordinates = atoi(envstr);
+      if ( envstr ) cdiIgnoreAttCoordinates = atoi(envstr) > 0;
 
       envstr = getenv("CDI_COORDINATES_LONLAT");
-      if ( envstr ) cdiCoordinatesLonLat = atoi(envstr);
+      if ( envstr ) cdiCoordinatesLonLat = atoi(envstr) > 0;
 
       envstr = getenv("IGNORE_VALID_RANGE");
-      if ( envstr ) cdiIgnoreValidRange = atoi(envstr);
+      if ( envstr ) cdiIgnoreValidRange = atoi(envstr) > 0;
 
       envstr = getenv("CDI_SKIP_RECORDS");
       if ( envstr )
diff --git a/src/cdi_int.h b/src/cdi_int.h
index 3b77c5dace86f5c9702931f6d8de2e0584ac1f1a..b6874861b3edc4f0761a886ee193f1d22c5f8d6e 100644
--- a/src/cdi_int.h
+++ b/src/cdi_int.h
@@ -160,9 +160,9 @@ typedef struct
     // (181; 105, 0, timeRangeIndicator=0) .. instantanous rain
     // (181; 105, 0, timeRangeIndicator=4) .. accumulated rain  .. both can be in the same grib file
 #endif // HIRLAM_EXTENSIONS
-  short     used;
   short     varID;
   short     levelID;
+  short     used;
   char      varname[32]; /* needed for grib decoding with GRIB_API */
   var_tile_t tiles;      /* tile-related meta-data, currently for GRIB-API only. */
 }
@@ -178,7 +178,7 @@ typedef struct {
                          /* tsID>0 number of non constant records */
   int       nallrecs;    /* number of all records                 */
   int       curRecID;    /* current record ID                     */
-  long      next;
+  bool      next;
   off_t     position;    /* timestep file position                */
   taxis_t   taxis;
 }
@@ -297,7 +297,7 @@ typedef enum {
 typedef struct
 {
   char*                  keyword;        /* keyword string */
-  int                    update;
+  bool                   update;
   key_val_pair_datatype  data_type;      /* data type of this key/value pair */
   double                 dbl_val;        /* double value (data_type == t_double) */
   int                    int_val;        /* integer value (data_type == t_int) */
@@ -333,9 +333,9 @@ extern int cdiDataUnreduced;
 extern int cdiSortName;
 extern int cdiSortParam;
 extern int cdiHaveMissval;
-extern int cdiIgnoreAttCoordinates;
-extern int cdiCoordinatesLonLat;
-extern int cdiIgnoreValidRange;
+extern bool cdiIgnoreAttCoordinates;
+extern bool cdiCoordinatesLonLat;
+extern bool cdiIgnoreValidRange;
 extern int cdiSkipRecords;
 extern int cdiConvention;
 extern int cdiInventoryMode;
diff --git a/src/cgribex.h b/src/cgribex.h
index 7b4d589a1aff6624ff49934beecf690eada2abe2..013e91faa943875cb169cc41aa8ac791724ca6cb 100644
--- a/src/cgribex.h
+++ b/src/cgribex.h
@@ -1,7 +1,8 @@
-#ifndef _CGRIBEX_H
-#define _CGRIBEX_H
+#ifndef CGRIBEX_H
+#define CGRIBEX_H
 
 #include <stdio.h>
+#include <stdbool.h>
 #include <sys/types.h>
 
 #define  GRIB_MISSVAL  -9.E33
@@ -206,7 +207,7 @@ void  gribSetCalendar(int calendar);
 void  gribDateTime(int *isec1, int *date, int *time);
 int   gribRefDate(int *isec1);
 int   gribRefTime(int *isec1);
-int   gribTimeIsFC(int *isec1);
+bool  gribTimeIsFC(int *isec1);
 
 void  gribPrintSec0(int *isec0);
 void  gribPrintSec1(int *isec0, int *isec1);
@@ -254,5 +255,5 @@ double calculate_pfactor_double(const double* spectralField, long fieldTruncatio
 }
 #endif
 
-#endif  /* _CGRIBEX_H */ 
+#endif  /* CGRIBEX_H */ 
 
diff --git a/src/cgribexlib.c b/src/cgribexlib.c
index bd84f03597e83906ced96655ea30f17f73eb35cd..31c37c6ba05ef3bb7c9304ce9f9540fdbc5b98f5 100644
--- a/src/cgribexlib.c
+++ b/src/cgribexlib.c
@@ -1,7 +1,7 @@
 
-/* Automatically generated by m214003 at 2016-12-20, do not edit */
+/* Automatically generated by m214003 at 2017-07-12, do not edit */
 
-/* CGRIBEXLIB_VERSION="1.7.6" */
+/* CGRIBEXLIB_VERSION="1.8.1" */
 
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__)
 #pragma GCC diagnostic push
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <sys/types.h>
 #include <inttypes.h>
 
@@ -31,8 +32,8 @@
 #include "calendar.h"
 #include "timebase.h"
 
-#ifndef _TEMPLATES_H
-#define _TEMPLATES_H
+#ifndef CGRIBEX_TEMPLATES_H
+#define CGRIBEX_TEMPLATES_H
 
 #define CAT(X,Y)      X##_##Y
 #define TEMPLATE(X,Y) CAT(X,Y)
@@ -42,32 +43,26 @@
 #define GRIB_INT_H
 
 #if defined (HAVE_CONFIG_H)
-#  include "config.h"
+#include "config.h"
 #endif
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <math.h>
 #include <float.h>
 
 
-#if ! defined   (_CGRIBEX_H)
+#if ! defined   (CGRIBEX_H)
 #  include "cgribex.h"
 #endif
 #if ! defined   (ERROR_H)
 #  include "error.h"
 #endif
-#if ! defined   (_DTYPES_H)
+#if ! defined   (DTYPES_H)
 #  include "dtypes.h"
 #endif
 
-#if ! defined   (FALSE)
-#  define  FALSE  0
-#endif
-
-#if ! defined   (TRUE)
-#  define  TRUE  1
-#endif
 
 #if ! defined   (UCHAR)
 #  define  UCHAR  unsigned char
@@ -223,8 +218,8 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
 #endif
 
 #endif  /* GRIB_INT_H */
-#ifndef _GRIBDECODE_H
-#define _GRIBDECODE_H
+#ifndef GRIBDECODE_H
+#define GRIBDECODE_H
 
 #define  UNDEFINED          9.999e20
 
@@ -363,9 +358,9 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
 #define  GRIB2_SECLEN(section)   (GET_UINT4(section[0], section[1], section[2], section[3]))
 #define  GRIB2_SECNUM(section)   (GET_UINT1(section[4]))
 
-#endif  /* _GRIBDECODE_H */
-#ifndef _GRIB_ENCODE_H
-#define _GRIB_ENCODE_H
+#endif  /* GRIBDECODE_H */
+#ifndef CGRIBEX_GRIB_ENCODE_H
+#define CGRIBEX_GRIB_ENCODE_H
 
 #include <limits.h>
 
@@ -402,7 +397,7 @@ enum {
   Put3Byte(mantissa);            \
 }
 
-#endif  /* _GRIB_ENCODE_H */
+#endif  /* CGRIBEX_GRIB_ENCODE_H */
 #ifndef CODEC_COMMON_H
 #define CODEC_COMMON_H
 #define gribSwapByteOrder_uint16(ui16)  ((uint16_t)((ui16<<8) | (ui16>>8)))
@@ -1173,6 +1168,7 @@ xlc_r -g -O3 -qhot -q64 -qarch=auto -qtune=auto -qreport -DTEST_ENCODE encode_ar
 #endif
 
 #include <stdint.h>
+#include <math.h>
 
 #ifndef DISABLE_SIMD
 #if   defined(__GNUC__) && (__GNUC__ >= 4)
@@ -1942,7 +1938,6 @@ LABEL900:
 
   return (pval);
 } /* decfp2 */
-#include <stdio.h>
 #include <stdint.h>
 #include <string.h>
 #include <stdarg.h>
@@ -1951,14 +1946,11 @@ LABEL900:
 
 int gribRefDate(int *isec1)
 {
-  int date, ryear, rmonth, rday;
-  int century;
-
-  century = ISEC1_Century;
+  int century = ISEC1_Century;
   if ( century < 0 ) century = -century;
   century -= 1;
 
-  ryear   = ISEC1_Year;
+  int ryear   = ISEC1_Year;
 
   /* if ( century != 0 ) */
     {
@@ -1977,50 +1969,44 @@ int gribRefDate(int *isec1)
 	ryear = 1;
     }
 
-  rmonth  = ISEC1_Month;
-  rday    = ISEC1_Day;
+  int rmonth  = ISEC1_Month;
+  int rday    = ISEC1_Day;
 
-  date = cdiEncodeDate(ryear, rmonth, rday);
+  int date = cdiEncodeDate(ryear, rmonth, rday);
 
-  return (date) ;
+  return date ;
 }
 
 
 int gribRefTime(int *isec1)
 {
-  int time, rhour, rminute;
-
-  rhour   = ISEC1_Hour;
-  rminute = ISEC1_Minute;
+  int rhour   = ISEC1_Hour;
+  int rminute = ISEC1_Minute;
 
-  time = cdiEncodeTime(rhour, rminute, 0);
+  int time = cdiEncodeTime(rhour, rminute, 0);
 
-  return (time) ;
+  return time;
 }
 
 
-int gribTimeIsFC(int *isec1)
+bool gribTimeIsFC(int *isec1)
 {
-  int isFC = FALSE;
-  int time_period;
+  bool isFC = false;
 
-  if ( ISEC1_TimeRange == 10 )
-    time_period = (ISEC1_TimePeriod1<<8) + ISEC1_TimePeriod2;
-  else
-    time_period = ISEC1_TimePeriod1;
+  int time_period =  (ISEC1_TimeRange == 10) ? (ISEC1_TimePeriod1<<8) + ISEC1_TimePeriod2 : ISEC1_TimePeriod1;
 
   if ( time_period > 0 && ISEC1_Day > 0 )
     {
-      if ( ISEC1_TimeRange == 0 || ISEC1_TimeRange == 10 ) isFC = TRUE;
+      if ( ISEC1_TimeRange == 0 || ISEC1_TimeRange == 10 ) isFC = true;
     }
 
-  return (isFC);
+  return isFC;
 }
 
 
 void gribDateTime(int *isec1, int *date, int *time)
 {
-  static int lprint = TRUE;
+  static bool lprint = true;
   int julday, secofday;
   int64_t addsec = 0;
   int64_t time_period = 0;
@@ -2092,7 +2078,7 @@ void gribDateTime(int *isec1, int *date, int *time)
 	  if ( lprint )
 	    {
 	      gprintf(__func__, "Time unit %d unsupported", ISEC1_TimeUnit);
-	      lprint = FALSE;
+	      lprint = false;
 	    }
 	  break;
 	}
@@ -4169,7 +4155,6 @@ int gribrec_len(unsigned b1, unsigned b2, unsigned b3)
   return gribsize;
 }
 
-#include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 
@@ -4268,7 +4253,7 @@ C     ----------------------------------------------------------------
   */
   char *envString;
   char *env_stream;
-  static int lfirst = TRUE;
+  static bool lfirst = true;
   extern int CGRIBEX_Const;
 
   if ( ! lfirst ) return;
@@ -4410,7 +4395,7 @@ C     ----------------------------------------------------------------
   /*
     Mark common area values set by user.
   */
-  lfirst = FALSE;
+  lfirst = false;
   /*
     Exhaustive use of all possible second-order packing methods
     for HOPER='K'. Set to off.
@@ -5042,7 +5027,7 @@ int correct_bdslen(int bdslen, long recsize, long gribpos)
     the (default) rounding for GRIB products is 120 bytes.
   */
   if ( recsize > JP23SET ) bdslen = (int)(recsize - gribpos - bdslen);
-  return (bdslen);
+  return bdslen;
 }
 
 
@@ -5067,7 +5052,7 @@ int grib1Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **p
     {
       fprintf(stderr, "Wrong GRIB indicator section: found >%c%c%c%c<\n",
 	      section[0], section[1], section[2], section[3]);
-      return (-1);
+      return -1;
     }
 
   recsize = gribrec_len(section[4], section[5], section[6]);
@@ -5123,7 +5108,7 @@ int grib1Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **p
   if ( gribbufsize < gribsize )
     {
       fprintf(stderr, "Length of GRIB message is inconsistent (grib_buffer_size=%ld < grib_record_size=%ld)!\n", gribbufsize, gribsize);
-      return (1);
+      return 1;
     }
 
   /* end section - "7777" in ascii */
@@ -5131,10 +5116,10 @@ int grib1Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **p
     {
       fprintf(stderr, "Missing GRIB end section: found >%c%c%c%c<\n",
 	      bufpointer[0], bufpointer[1], bufpointer[2], bufpointer[3]);
-      return (-2);
+      return -2;
     }
 
-  return (0);
+  return 0;
 }
 
 
@@ -5167,14 +5152,14 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
     {
       fprintf(stderr, "wrong indicator section >%c%c%c%c<\n",
 	      section[0], section[1], section[2], section[3]);
-      return (-1);
+      return -1;
     }
 
   gribversion = GRIB_EDITION(section);
   if ( gribversion != 2 )
     {
       fprintf(stderr, "wrong GRIB version %d\n", gribversion);
-      return (-1);      
+      return -1;      
     }
 
   gribsize = 0;
@@ -5191,7 +5176,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
   if ( sec_num != 1 )
     {
       fprintf(stderr, "Unexpected section1 number %d\n", sec_num);
-      return (-1);
+      return -1;
     }
 
   *idsp = section;
@@ -5225,7 +5210,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
   else
     {
       fprintf(stderr, "Unexpected section3 number %d\n", sec_num);
-      return (-1);
+      return -1;
     }
 
   grib_len += sec_len;
@@ -5239,7 +5224,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
   if ( sec_num != 4 )
     {
       fprintf(stderr, "Unexpected section4 number %d\n", sec_num);
-      return (-1);
+      return -1;
     }
 
   *pdsp = section;
@@ -5255,7 +5240,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
   if ( sec_num != 5 )
     {
       fprintf(stderr, "Unexpected section5 number %d\n", sec_num);
-      return (-1);
+      return -1;
     }
 
   *drsp = section;
@@ -5271,7 +5256,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
   if ( sec_num != 6 )
     {
       fprintf(stderr, "Unexpected section6 number %d\n", sec_num);
-      return (-1);
+      return -1;
     }
 
   *bmsp = section;
@@ -5287,7 +5272,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
   if ( sec_num != 7 )
     {
       fprintf(stderr, "Unexpected section7 number %d\n", sec_num);
-      return (-1);
+      return -1;
     }
 
   *bdsp = section;
@@ -5318,10 +5303,10 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
     {
       fprintf(stderr, "Missing end section >%2x %2x %2x %2x<\n",
 	      section[0], section[1], section[2], section[3]);
-      return (-2);
+      return -2;
     }
 
-  return (0);
+  return 0;
 }
 
 
@@ -5342,7 +5327,7 @@ int grib_info_for_grads(off_t recpos, long recsize, unsigned char *gribbuffer,
     {
       fprintf(stderr, "wrong indicator section >%c%c%c%c<\n",
 	      section[0], section[1], section[2], section[3]);
-      return (-1);
+      return -1;
     }
 
   gribversion = GRIB_EDITION(section);
@@ -5395,7 +5380,7 @@ int grib_info_for_grads(off_t recpos, long recsize, unsigned char *gribbuffer,
   if ( gribsize > recsize )
     {
       fprintf(stderr, "GRIB buffer size %ld too small! Min size = %ld\n", recsize, gribsize);
-      return (1);
+      return 1;
     }
 
   /* end section - "7777" in ascii */
@@ -5423,7 +5408,7 @@ int grib_info_for_grads(off_t recpos, long recsize, unsigned char *gribbuffer,
   printf("intnum %d %d %d\n", intnum[0], intnum[1], intnum[2]);
   printf("fltnum %g %g %g\n", fltnum[0], fltnum[1], fltnum[2]);
   */
-  return (0);
+  return 0;
 }
 
 
@@ -5939,7 +5924,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
   int bds_head = 11;
   int bds_ext = 0, bds_ubits;
   int datstart = 0;
-  /* int llarge = FALSE; */
+  // bool llarge = false;
 
   long gribrecsize;
   nerr = grib1Sections(gbuf, gbufsize, &pds, &gds, &bms, &bds, &gribrecsize);
@@ -5956,7 +5941,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
     }
 
   /* recLen = gribrec_len(gbuf[4], gbuf[5], gbuf[6]); */
-  /* if ( recLen > JP23SET ) llarge = TRUE; */
+  /* if ( recLen > JP23SET ) llarge = true; */
 
   bds_len   = BDS_Len;
   bds_nbits = BDS_NumBits;
@@ -6048,7 +6033,6 @@ void gribRepair1(int nrec, long recsize, unsigned char *gribbuffer)
 #include <string.h>
 
 #if defined (HAVE_CONFIG_H)
-#  include "config.h"
 #endif
 
 #if  defined (HAVE_LIBSZ)
@@ -6388,7 +6372,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
   size_t destLen, sourceLen;
   enum { bds_head = 11 };
   int bds_ext = 0;
-  int llarge = FALSE;
+  bool llarge = false;
 
   UNUSED(dbufsize);
 
@@ -6409,7 +6393,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
   int bds_zstart = 14;
 
   int recLen = gribrec_len(bds[bds_zstart], bds[bds_zstart+1], bds[bds_zstart+2]);
-  if ( recLen > JP23SET ) llarge = TRUE;
+  if ( recLen > JP23SET ) llarge = true;
 
   int bds_zoffset = 12;
   if ( llarge ) bds_zoffset += 2;
@@ -8466,18 +8450,16 @@ int gribVersion(unsigned char *is, size_t buffersize)
   if ( buffersize < 8 )
     Error("Buffer too small (current size %d)!", (int) buffersize);
 
-  return (GRIB_EDITION(is));
+  return GRIB_EDITION(is);
 }
 
 static 
 double GET_Real(unsigned char *grib)
 {
-  int iexp, imant;
+  int iexp  = GET_UINT1(grib[0]);
+  int imant = GET_UINT3(grib[1], grib[2], grib[3]);
 
-  iexp  = GET_UINT1(grib[0]);
-  imant = GET_UINT3(grib[1], grib[2], grib[3]);
-
-  return (decfp2(iexp, imant));
+  return decfp2(iexp, imant);
 }
 
 static 
@@ -8485,7 +8467,7 @@ int decodeIS(unsigned char *is, int *isec0, int *iret)
 {
   int isLen = 0;
   int grib1offset;
-  int lgrib = FALSE, lbudg = FALSE, ltide = FALSE;
+  bool lgrib = false, lbudg = false, ltide = false;
 
   /*
     Octets 1 - 4 : The letters G R I B.
@@ -8497,22 +8479,22 @@ int decodeIS(unsigned char *is, int *isec0, int *iret)
   /*
     Check that 'GRIB' is found where expected.
   */
-  if ( GRIB_START(is) ) lgrib = TRUE;
+  if ( GRIB_START(is) ) lgrib = true;
   /*
     ECMWF pseudo-grib data uses 'BUDG' and 'TIDE'.
   */
-  if ( BUDG_START(is) ) lbudg = TRUE;
-  if ( TIDE_START(is) ) ltide = TRUE;
+  if ( BUDG_START(is) ) lbudg = true;
+  if ( TIDE_START(is) ) ltide = true;
   /*
     Data is not GRIB or pseudo-grib.
   */
-  if ( lgrib == FALSE && lbudg == FALSE && ltide == FALSE )
+  if ( lgrib == false && lbudg == false && ltide == false )
     {
       *iret = 305;
       gprintf(__func__, "Input data is not GRIB or pseudo-grib.");
       gprintf(__func__, "Return code = %d", *iret);
     }
-  if ( lbudg == TRUE || ltide == TRUE )
+  if ( lbudg || ltide )
     {
       *iret = 305;
       gprintf(__func__, "Pseudo-grib data unsupported.");
@@ -8537,7 +8519,7 @@ int decodeIS(unsigned char *is, int *isec0, int *iret)
 
   isLen = 4 + grib1offset;
 
-  return (isLen);
+  return isLen;
 }
 
 static 
@@ -8739,7 +8721,7 @@ int decodePDS(unsigned char *pds, int *isec0, int *isec1)
 	}
     }
 
-  return (pdsLen);
+  return pdsLen;
 }
 
 
@@ -9232,7 +9214,7 @@ static
 int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2, int *numGridVals)
 {
   /* int imisng = 0; */
-  int  ReducedGrid = FALSE, VertCoorTab = FALSE;
+  bool  ReducedGrid = false, VertCoorTab = false;
 #if defined (VECTORCODE)
   unsigned char *igrib;
   GRIBPACK *lgrib = NULL;
@@ -9252,17 +9234,17 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
     { /* Either vct or reduced grid */
       if ( GDS_NV != 0 )
 	{ /* we have vct */
-	  VertCoorTab = TRUE;
+	  VertCoorTab = true;
 	  int ipl =  4*GDS_NV + ipvpl - 1;
 	  if ( ipl < gdsLen )
 	    {
-	      ReducedGrid = TRUE;
+	      ReducedGrid = true;
 	    }
 	}
       else
 	{
-	  VertCoorTab = FALSE;
-	  ReducedGrid = TRUE;
+	  VertCoorTab = false;
+	  ReducedGrid = true;
 	}
       /*	  ReducedGrid = (gdsLen - 32 - 4*GDS_NV); */
     }
@@ -9279,7 +9261,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
       if ( jlenl == GDS_NumLat )
 	{
 	  *numGridVals = 0;
-	  ISEC2_Reduced = TRUE;
+	  ISEC2_Reduced = true;
 	  for ( int i = 0; i < jlenl; i++ )
 	    {
 	      ISEC2_RowLon(i) = GET_UINT2(gds[locnl+2*i], gds[locnl+2*i+1]);
@@ -9288,7 +9270,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	}
       else
 	{
-	  ReducedGrid = FALSE;
+	  ReducedGrid = false;
 	}
     }
 
@@ -9332,18 +9314,14 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	    ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN_STR ||
 	    ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN_ROTSTR )
     {
-      /*
-      iret = decodeGDS_GG(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_GG(gds, gdspos, isec0, isec2, imisng);
     }
   else if ( ISEC2_GridType == GRIB1_GTYPE_LATLON     ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_STR ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_ROTSTR )
     {
-      /*
-      iret = decodeGDS_LL(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_LL(gds, gdspos, isec0, isec2, imisng);
     }
   else if ( ISEC2_GridType == GRIB1_GTYPE_LCC )
     {
@@ -9376,9 +9354,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
       isec2[ 8] = 0;
       isec2[ 9] = 0;
       isec2[10] = 0;
-      /*
-      iret = decodeGDS_SH(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_SH(gds, gdspos, isec0, isec2, imisng);
     }
   else if ( ISEC2_GridType == GRIB1_GTYPE_GME )
     {
@@ -9392,16 +9368,19 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
       ISEC2_GME_LonMPL = GDS_GME_LonMPL;
       ISEC2_GME_BFlag  = GDS_GME_BFlag;
       *numGridVals  = (ISEC2_GME_NI+1)*(ISEC2_GME_NI+1)*10;
-      /*
-      iret = decodeGDS_TR(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_TR(gds, gdspos, isec0, isec2, imisng);
     }
   else
     {
+      static bool lwarn = true;
       ISEC2_NumLon = GDS_NumLon;
       ISEC2_NumLat = GDS_NumLat;
       *numGridVals  = ISEC2_NumLon*ISEC2_NumLat;
-      Message("Gridtype %d unsupported", ISEC2_GridType);
+      if ( lwarn )
+        {
+          lwarn = false;
+          Message("GRIB gridtype %d unsupported", ISEC2_GridType);
+        }
     }
 
   /*    vertical coordinate parameters for hybrid levels.     */
@@ -9412,7 +9391,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
   isec2[17] = 0;
   isec2[18] = 0;
 
-  if ( VertCoorTab == TRUE )
+  if ( VertCoorTab )
     {
       int locnv;
       if ( ISEC0_GRIB_Version  == 0 )
@@ -9464,7 +9443,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
 			  T *fsec4, int fsec4len, int dfunc, int bdsLenIn, int numGridVals, int llarge, int *iret)
 {
   unsigned char *igrib;
-  int lspherc = FALSE, lcomplex = FALSE;
+  bool lspherc = false, lcomplex = false;
   int lcompress;
   int jup, kup, mup;
   int locnd;
@@ -9505,7 +9484,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
   /* 0------- grid point           */
   /* 1------- spherical harmonics  */
 
-  lspherc = bds_flag >> 7;
+  lspherc = (bds_flag >> 7)&1;
 
   if ( lspherc ) isec4[2] = 128;
   else           isec4[2] = 0;
@@ -9750,15 +9729,15 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 {
   UCHAR *is = NULL, *pds = NULL, *gds = NULL, *bms = NULL, *bds = NULL;
   int isLen = 0, pdsLen = 0, gdsLen = 0, bmsLen = 0, bdsLen = 0, esLen = 0;
-  int gdsIncluded = FALSE;
-  int bmsIncluded = FALSE;
+  bool gdsIncluded = false;
+  bool bmsIncluded = false;
   int bitmapSize = 0;
   int imaskSize = 0;
-  int ldebug = FALSE;
-  int llarge = FALSE, l_iorj = FALSE;
-  int lsect2 = FALSE, lsect3 = FALSE;
+  bool ldebug = false;
+  bool llarge = false, l_iorj = false;
+  bool lsect2 = false, lsect3 = false;
   int numGridVals = 0;
-  static int lmissvalinfo = 1;
+  static bool lmissvalinfo = 1;
 
   UNUSED(kleng);
 
@@ -9766,7 +9745,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 
   grsdef();
 
-  ISEC2_Reduced = FALSE;
+  ISEC2_Reduced = false;
 
   /*
     ----------------------------------------------------------------
@@ -9774,7 +9753,6 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     ----------------------------------------------------------------
   */
   is = (unsigned char *) &kgrib[0];
-
   isLen = decodeIS(is, isec0, iret);
 
   /*
@@ -9787,7 +9765,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     {
       if ( ldebug )
 	gprintf(__func__, "Special case, negative length multiplied by -120");
-      llarge = TRUE;
+      llarge = true;
       ISEC0_GRIB_Len *= (-120);
     }
   /*
@@ -9881,7 +9859,6 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     ----------------------------------------------------------------
   */ 
   pds = is + isLen;
-
   pdsLen = decodePDS(pds, isec0, isec1);
 
   /*
@@ -9894,7 +9871,6 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( gdsIncluded )
     {
       gds = is + isLen + pdsLen;
-
       gdsLen = TEMPLATE(decodeGDS,T)(gds, isec0, isec2, fsec2, &numGridVals);
     }
 
@@ -9909,8 +9885,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( bmsIncluded )
     {
       bms = is + isLen + pdsLen + gdsLen;
-
       bmsLen = BMS_Len;
+
       imaskSize = (bmsLen - 6)<<3;
       bitmapSize = imaskSize - BMS_UnusedBits;
       /*
@@ -9924,9 +9900,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     ----------------------------------------------------------------
   */
   bds = is + isLen + pdsLen + gdsLen + bmsLen;
-
   bdsLen = ISEC0_GRIB_Len - (isLen + pdsLen + gdsLen + bmsLen);
-
   bdsLen = TEMPLATE(decodeBDS,T)(ISEC1_DecScaleFactor, bds, isec2, isec4, 
 				 fsec4, fsec4len, dfunc, bdsLen, numGridVals, llarge, iret);
 
@@ -9939,7 +9913,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       if ( dfunc != 'L' && dfunc != 'J' )
 	if ( DBL_IS_NAN(FSEC3_MissVal) && lmissvalinfo )
 	  {
-	    lmissvalinfo = 0;
+	    lmissvalinfo = false;
 	    FSEC3_MissVal = (T)GRIB_MISSVAL;
 	    Message("Missing value = NaN is unsupported, set to %g!", GRIB_MISSVAL);
 	  }
@@ -10148,7 +10122,7 @@ static
 int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2, int *numGridVals)
 {
   /* int imisng = 0; */
-  int  ReducedGrid = FALSE, VertCoorTab = FALSE;
+  bool  ReducedGrid = false, VertCoorTab = false;
 #if defined (VECTORCODE)
   unsigned char *igrib;
   GRIBPACK *lgrib = NULL;
@@ -10168,17 +10142,17 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
     { /* Either vct or reduced grid */
       if ( GDS_NV != 0 )
 	{ /* we have vct */
-	  VertCoorTab = TRUE;
+	  VertCoorTab = true;
 	  int ipl =  4*GDS_NV + ipvpl - 1;
 	  if ( ipl < gdsLen )
 	    {
-	      ReducedGrid = TRUE;
+	      ReducedGrid = true;
 	    }
 	}
       else
 	{
-	  VertCoorTab = FALSE;
-	  ReducedGrid = TRUE;
+	  VertCoorTab = false;
+	  ReducedGrid = true;
 	}
       /*	  ReducedGrid = (gdsLen - 32 - 4*GDS_NV); */
     }
@@ -10195,7 +10169,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
       if ( jlenl == GDS_NumLat )
 	{
 	  *numGridVals = 0;
-	  ISEC2_Reduced = TRUE;
+	  ISEC2_Reduced = true;
 	  for ( int i = 0; i < jlenl; i++ )
 	    {
 	      ISEC2_RowLon(i) = GET_UINT2(gds[locnl+2*i], gds[locnl+2*i+1]);
@@ -10204,7 +10178,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	}
       else
 	{
-	  ReducedGrid = FALSE;
+	  ReducedGrid = false;
 	}
     }
 
@@ -10248,18 +10222,14 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	    ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN_STR ||
 	    ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN_ROTSTR )
     {
-      /*
-      iret = decodeGDS_GG(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_GG(gds, gdspos, isec0, isec2, imisng);
     }
   else if ( ISEC2_GridType == GRIB1_GTYPE_LATLON     ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_STR ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_ROTSTR )
     {
-      /*
-      iret = decodeGDS_LL(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_LL(gds, gdspos, isec0, isec2, imisng);
     }
   else if ( ISEC2_GridType == GRIB1_GTYPE_LCC )
     {
@@ -10292,9 +10262,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
       isec2[ 8] = 0;
       isec2[ 9] = 0;
       isec2[10] = 0;
-      /*
-      iret = decodeGDS_SH(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_SH(gds, gdspos, isec0, isec2, imisng);
     }
   else if ( ISEC2_GridType == GRIB1_GTYPE_GME )
     {
@@ -10308,16 +10276,19 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
       ISEC2_GME_LonMPL = GDS_GME_LonMPL;
       ISEC2_GME_BFlag  = GDS_GME_BFlag;
       *numGridVals  = (ISEC2_GME_NI+1)*(ISEC2_GME_NI+1)*10;
-      /*
-      iret = decodeGDS_TR(gds, gdspos, isec0, isec2, imisng);
-      */
+      // iret = decodeGDS_TR(gds, gdspos, isec0, isec2, imisng);
     }
   else
     {
+      static bool lwarn = true;
       ISEC2_NumLon = GDS_NumLon;
       ISEC2_NumLat = GDS_NumLat;
       *numGridVals  = ISEC2_NumLon*ISEC2_NumLat;
-      Message("Gridtype %d unsupported", ISEC2_GridType);
+      if ( lwarn )
+        {
+          lwarn = false;
+          Message("GRIB gridtype %d unsupported", ISEC2_GridType);
+        }
     }
 
   /*    vertical coordinate parameters for hybrid levels.     */
@@ -10328,7 +10299,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
   isec2[17] = 0;
   isec2[18] = 0;
 
-  if ( VertCoorTab == TRUE )
+  if ( VertCoorTab )
     {
       int locnv;
       if ( ISEC0_GRIB_Version  == 0 )
@@ -10380,7 +10351,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
 			  T *fsec4, int fsec4len, int dfunc, int bdsLenIn, int numGridVals, int llarge, int *iret)
 {
   unsigned char *igrib;
-  int lspherc = FALSE, lcomplex = FALSE;
+  bool lspherc = false, lcomplex = false;
   int lcompress;
   int jup, kup, mup;
   int locnd;
@@ -10421,7 +10392,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
   /* 0------- grid point           */
   /* 1------- spherical harmonics  */
 
-  lspherc = bds_flag >> 7;
+  lspherc = (bds_flag >> 7)&1;
 
   if ( lspherc ) isec4[2] = 128;
   else           isec4[2] = 0;
@@ -10666,15 +10637,15 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 {
   UCHAR *is = NULL, *pds = NULL, *gds = NULL, *bms = NULL, *bds = NULL;
   int isLen = 0, pdsLen = 0, gdsLen = 0, bmsLen = 0, bdsLen = 0, esLen = 0;
-  int gdsIncluded = FALSE;
-  int bmsIncluded = FALSE;
+  bool gdsIncluded = false;
+  bool bmsIncluded = false;
   int bitmapSize = 0;
   int imaskSize = 0;
-  int ldebug = FALSE;
-  int llarge = FALSE, l_iorj = FALSE;
-  int lsect2 = FALSE, lsect3 = FALSE;
+  bool ldebug = false;
+  bool llarge = false, l_iorj = false;
+  bool lsect2 = false, lsect3 = false;
   int numGridVals = 0;
-  static int lmissvalinfo = 1;
+  static bool lmissvalinfo = 1;
 
   UNUSED(kleng);
 
@@ -10682,7 +10653,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 
   grsdef();
 
-  ISEC2_Reduced = FALSE;
+  ISEC2_Reduced = false;
 
   /*
     ----------------------------------------------------------------
@@ -10690,7 +10661,6 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     ----------------------------------------------------------------
   */
   is = (unsigned char *) &kgrib[0];
-
   isLen = decodeIS(is, isec0, iret);
 
   /*
@@ -10703,7 +10673,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     {
       if ( ldebug )
 	gprintf(__func__, "Special case, negative length multiplied by -120");
-      llarge = TRUE;
+      llarge = true;
       ISEC0_GRIB_Len *= (-120);
     }
   /*
@@ -10797,7 +10767,6 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     ----------------------------------------------------------------
   */ 
   pds = is + isLen;
-
   pdsLen = decodePDS(pds, isec0, isec1);
 
   /*
@@ -10810,7 +10779,6 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( gdsIncluded )
     {
       gds = is + isLen + pdsLen;
-
       gdsLen = TEMPLATE(decodeGDS,T)(gds, isec0, isec2, fsec2, &numGridVals);
     }
 
@@ -10825,8 +10793,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( bmsIncluded )
     {
       bms = is + isLen + pdsLen + gdsLen;
-
       bmsLen = BMS_Len;
+
       imaskSize = (bmsLen - 6)<<3;
       bitmapSize = imaskSize - BMS_UnusedBits;
       /*
@@ -10840,9 +10808,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
     ----------------------------------------------------------------
   */
   bds = is + isLen + pdsLen + gdsLen + bmsLen;
-
   bdsLen = ISEC0_GRIB_Len - (isLen + pdsLen + gdsLen + bmsLen);
-
   bdsLen = TEMPLATE(decodeBDS,T)(ISEC1_DecScaleFactor, bds, isec2, isec4, 
 				 fsec4, fsec4len, dfunc, bdsLen, numGridVals, llarge, iret);
 
@@ -10855,7 +10821,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       if ( dfunc != 'L' && dfunc != 'J' )
 	if ( DBL_IS_NAN(FSEC3_MissVal) && lmissvalinfo )
 	  {
-	    lmissvalinfo = 0;
+	    lmissvalinfo = false;
 	    FSEC3_MissVal = (T)GRIB_MISSVAL;
 	    Message("Missing value = NaN is unsupported, set to %g!", GRIB_MISSVAL);
 	  }
@@ -11402,6 +11368,9 @@ void encodePDS(GRIBPACK *lpds, long pdsLen, int *isec1)
 #ifdef T
 
 
+#define round_float roundf
+#define round_double round
+
 static
 void TEMPLATE(encode_array_common,T)(int numBits, size_t packStart, size_t datasize, GRIBPACK *lGrib,
 				     const T *data, T zref, T factor, size_t *gz)
@@ -11419,6 +11388,7 @@ void TEMPLATE(encode_array_common,T)(int numBits, size_t packStart, size_t datas
   for ( i = packStart; i < datasize; i++ )
     {
       /* note float -> unsigned int .. truncate */
+      // ival = (unsigned int)(TEMPLATE(round,T)((data[i] - zref) * factor));
       ival = (unsigned int) ((data[i] - zref) * factor + (T)0.5);
       /*
 	if ( ival > max_nbpv_pow2 ) ival = max_nbpv_pow2;
@@ -11464,6 +11434,7 @@ void TEMPLATE(encode_array_2byte,T)(size_t datasize, GRIBPACK *restrict lGrib,
     {
       for ( size_t i = 0; i < datasize; i++ )
         {
+          // sgrib[i] = (uint16_t)(TEMPLATE(round,T)((data[i] - zref) * factor));
           sgrib[i] = (uint16_t) ((data[i] - zref) * factor + (T)0.5);
         }
     }
@@ -11472,6 +11443,7 @@ void TEMPLATE(encode_array_2byte,T)(size_t datasize, GRIBPACK *restrict lGrib,
       uint16_t ui16;
       for ( size_t i = 0; i < datasize; i++ )
         {
+          // ui16 = (uint16_t)(TEMPLATE(round,T)((data[i] - zref) * factor));
           ui16 = (uint16_t) ((data[i] - zref) * factor + (T)0.5);
           sgrib[i] = gribSwapByteOrder_uint16(ui16);
         }
@@ -11499,6 +11471,7 @@ void TEMPLATE(encode_array_2byte,T)(size_t datasize, GRIBPACK *restrict lGrib,
 #endif
   for ( i = 0; i < datasize; i++ )
     {
+      // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
       tmp = ((data[i] - zref) * factor + (T)0.5);
       ui16 = (uint16_t) tmp;
       lGrib[z  ] = ui16 >>  8;
@@ -11542,6 +11515,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
 #endif
       for ( i = 0; i < datasize; i++ )
 	{
+	  // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
 	  tmp = ((data[i] - zref) * factor + (T)0.5);
 	  lGrib[z  ] = (GRIBPACK)tmp;
           z++;
@@ -11605,6 +11579,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
 #endif
       for ( i = 0; i < datasize; i++ )
 	{
+	  // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
 	  tmp = ((data[i] - zref) * factor + (T)0.5);
           ui32 = (uint32_t) tmp;
           lGrib[z  ] =  (GRIBPACK)(ui32 >> 16);
@@ -11634,6 +11609,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
 #endif
       for ( i = 0; i < datasize; i++ )
 	{
+	  // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
 	  tmp = ((data[i] - zref) * factor + (T)0.5);
           ui32 = (uint32_t) tmp;
           lGrib[z  ] =  (GRIBPACK)(ui32 >> 24);
@@ -11671,17 +11647,17 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
   U_BYTEORDER;
   size_t i, j, z = *gz;
 #ifdef _ARCH_PWR6
-#define __UNROLL_DEPTH_2 8
+  enum { CGRIBEX__UNROLL_DEPTH_2 = 8 };
 #else
-#define __UNROLL_DEPTH_2 128
+  enum { CGRIBEX__UNROLL_DEPTH_2 = 128 };
 #endif
   size_t residual;
   size_t ofs;
-  T dval[__UNROLL_DEPTH_2];
+  T dval[CGRIBEX__UNROLL_DEPTH_2];
 
   data += packStart;
   datasize -= packStart;
-  residual =  datasize % __UNROLL_DEPTH_2;
+  residual =  datasize % CGRIBEX__UNROLL_DEPTH_2;
   ofs = datasize - residual;
 
   // reducing FP operations to single FMA is slowing down on pwr6 ...
@@ -11692,13 +11668,14 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
       hpmStart(2, "pack 8 bit unrolled");
 #endif
       unsigned char *cgrib = (unsigned char *) (lGrib + z);
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
 	{
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
 #ifdef _ARCH_PWR6
 	      *cgrib++ =  (unsigned long) dval[j];
@@ -11706,10 +11683,11 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	      *cgrib++ =  (unsigned char) dval[j];
 #endif
 	    }
-	  z += __UNROLL_DEPTH_2;
+	  z += CGRIBEX__UNROLL_DEPTH_2;
 	}
       for (j = 0; j < residual; j++) 
 	{
+	  // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       for (j = 0; j < residual; j++) 
@@ -11738,15 +11716,16 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 #endif
       uint16_t *sgrib = (uint16_t *) (lGrib+z);
 
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
 	{
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
 	  if ( IS_BIGENDIAN() )
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
 #ifdef _ARCH_PWR6
 		  *sgrib++ = (unsigned long) dval[j];
@@ -11754,20 +11733,21 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 		  *sgrib++ = (uint16_t) dval[j];
 #endif
 		}
-	      z += 2*__UNROLL_DEPTH_2;
+	      z += 2*CGRIBEX__UNROLL_DEPTH_2;
 	    }
 	  else
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
 		  ival = (uint16_t) dval[j];
                   *sgrib++ = gribSwapByteOrder_uint16(ival);
 		}
-	      z += 2*__UNROLL_DEPTH_2;
+	      z += 2*CGRIBEX__UNROLL_DEPTH_2;
 	    }
 	}
       for (j = 0; j < residual; j++) 
 	{
+	  // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       if ( IS_BIGENDIAN() )
@@ -11806,13 +11786,14 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 #else
       uint32_t ival;
 #endif
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
 	{
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
 #ifdef _ARCH_PWR6
 	      ival = (unsigned long) dval[j];
@@ -11827,6 +11808,7 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	}
       for (j = 0; j < residual; j++) 
 	{
+	  // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       for (j = 0; j < residual; j++) 
@@ -11852,15 +11834,16 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
       uint32_t ival;
 #endif
       unsigned int *igrib = (unsigned int *) (lGrib + z);
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
  {
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
 	  if ( IS_BIGENDIAN() )
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
 #ifdef _ARCH_PWR6
 		  *igrib = (unsigned long) dval[j];
@@ -11873,7 +11856,7 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	    }
 	  else
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
                   ival = (uint32_t) dval[j];
 		  lGrib[z  ] =  (GRIBPACK)(ival >> 24);
@@ -11886,6 +11869,7 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	}
       for (j = 0; j < residual; j++) 
 	{
+          // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       if ( IS_BIGENDIAN() )
@@ -11930,7 +11914,6 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
     }
 
   *gz = z;
-#undef __UNROLL_DEPTH_2
 }
 
 #endif /* T */
@@ -11948,6 +11931,9 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 #ifdef T
 
 
+#define round_float roundf
+#define round_double round
+
 static
 void TEMPLATE(encode_array_common,T)(int numBits, size_t packStart, size_t datasize, GRIBPACK *lGrib,
 				     const T *data, T zref, T factor, size_t *gz)
@@ -11965,6 +11951,7 @@ void TEMPLATE(encode_array_common,T)(int numBits, size_t packStart, size_t datas
   for ( i = packStart; i < datasize; i++ )
     {
       /* note float -> unsigned int .. truncate */
+      // ival = (unsigned int)(TEMPLATE(round,T)((data[i] - zref) * factor));
       ival = (unsigned int) ((data[i] - zref) * factor + (T)0.5);
       /*
 	if ( ival > max_nbpv_pow2 ) ival = max_nbpv_pow2;
@@ -12010,6 +11997,7 @@ void TEMPLATE(encode_array_2byte,T)(size_t datasize, GRIBPACK *restrict lGrib,
     {
       for ( size_t i = 0; i < datasize; i++ )
         {
+          // sgrib[i] = (uint16_t)(TEMPLATE(round,T)((data[i] - zref) * factor));
           sgrib[i] = (uint16_t) ((data[i] - zref) * factor + (T)0.5);
         }
     }
@@ -12018,6 +12006,7 @@ void TEMPLATE(encode_array_2byte,T)(size_t datasize, GRIBPACK *restrict lGrib,
       uint16_t ui16;
       for ( size_t i = 0; i < datasize; i++ )
         {
+          // ui16 = (uint16_t)(TEMPLATE(round,T)((data[i] - zref) * factor));
           ui16 = (uint16_t) ((data[i] - zref) * factor + (T)0.5);
           sgrib[i] = gribSwapByteOrder_uint16(ui16);
         }
@@ -12045,6 +12034,7 @@ void TEMPLATE(encode_array_2byte,T)(size_t datasize, GRIBPACK *restrict lGrib,
 #endif
   for ( i = 0; i < datasize; i++ )
     {
+      // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
       tmp = ((data[i] - zref) * factor + (T)0.5);
       ui16 = (uint16_t) tmp;
       lGrib[z  ] = ui16 >>  8;
@@ -12088,6 +12078,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
 #endif
       for ( i = 0; i < datasize; i++ )
 	{
+	  // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
 	  tmp = ((data[i] - zref) * factor + (T)0.5);
 	  lGrib[z  ] = (GRIBPACK)tmp;
           z++;
@@ -12151,6 +12142,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
 #endif
       for ( i = 0; i < datasize; i++ )
 	{
+	  // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
 	  tmp = ((data[i] - zref) * factor + (T)0.5);
           ui32 = (uint32_t) tmp;
           lGrib[z  ] =  (GRIBPACK)(ui32 >> 16);
@@ -12180,6 +12172,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
 #endif
       for ( i = 0; i < datasize; i++ )
 	{
+	  // tmp = TEMPLATE(round,T)((data[i] - zref) * factor);
 	  tmp = ((data[i] - zref) * factor + (T)0.5);
           ui32 = (uint32_t) tmp;
           lGrib[z  ] =  (GRIBPACK)(ui32 >> 24);
@@ -12217,17 +12210,17 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
   U_BYTEORDER;
   size_t i, j, z = *gz;
 #ifdef _ARCH_PWR6
-#define __UNROLL_DEPTH_2 8
+  enum { CGRIBEX__UNROLL_DEPTH_2 = 8 };
 #else
-#define __UNROLL_DEPTH_2 128
+  enum { CGRIBEX__UNROLL_DEPTH_2 = 128 };
 #endif
   size_t residual;
   size_t ofs;
-  T dval[__UNROLL_DEPTH_2];
+  T dval[CGRIBEX__UNROLL_DEPTH_2];
 
   data += packStart;
   datasize -= packStart;
-  residual =  datasize % __UNROLL_DEPTH_2;
+  residual =  datasize % CGRIBEX__UNROLL_DEPTH_2;
   ofs = datasize - residual;
 
   // reducing FP operations to single FMA is slowing down on pwr6 ...
@@ -12238,13 +12231,14 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
       hpmStart(2, "pack 8 bit unrolled");
 #endif
       unsigned char *cgrib = (unsigned char *) (lGrib + z);
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
 	{
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
 #ifdef _ARCH_PWR6
 	      *cgrib++ =  (unsigned long) dval[j];
@@ -12252,10 +12246,11 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	      *cgrib++ =  (unsigned char) dval[j];
 #endif
 	    }
-	  z += __UNROLL_DEPTH_2;
+	  z += CGRIBEX__UNROLL_DEPTH_2;
 	}
       for (j = 0; j < residual; j++) 
 	{
+	  // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       for (j = 0; j < residual; j++) 
@@ -12284,15 +12279,16 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 #endif
       uint16_t *sgrib = (uint16_t *) (lGrib+z);
 
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
 	{
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
 	  if ( IS_BIGENDIAN() )
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
 #ifdef _ARCH_PWR6
 		  *sgrib++ = (unsigned long) dval[j];
@@ -12300,20 +12296,21 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 		  *sgrib++ = (uint16_t) dval[j];
 #endif
 		}
-	      z += 2*__UNROLL_DEPTH_2;
+	      z += 2*CGRIBEX__UNROLL_DEPTH_2;
 	    }
 	  else
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
 		  ival = (uint16_t) dval[j];
                   *sgrib++ = gribSwapByteOrder_uint16(ival);
 		}
-	      z += 2*__UNROLL_DEPTH_2;
+	      z += 2*CGRIBEX__UNROLL_DEPTH_2;
 	    }
 	}
       for (j = 0; j < residual; j++) 
 	{
+	  // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       if ( IS_BIGENDIAN() )
@@ -12352,13 +12349,14 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 #else
       uint32_t ival;
 #endif
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
 	{
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
 #ifdef _ARCH_PWR6
 	      ival = (unsigned long) dval[j];
@@ -12373,6 +12371,7 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	}
       for (j = 0; j < residual; j++) 
 	{
+	  // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       for (j = 0; j < residual; j++) 
@@ -12398,15 +12397,16 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
       uint32_t ival;
 #endif
       unsigned int *igrib = (unsigned int *) (lGrib + z);
-      for ( i = 0; i < datasize - residual; i += __UNROLL_DEPTH_2 ) 
+      for ( i = 0; i < datasize - residual; i += CGRIBEX__UNROLL_DEPTH_2 )
  {
-	  for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	  for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 	    {
+	      // dval[j] = TEMPLATE(round,T)((data[i+j] - zref) * factor);
 	      dval[j] = ((data[i+j] - zref) * factor + (T)0.5);
 	    }
 	  if ( IS_BIGENDIAN() )
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
 #ifdef _ARCH_PWR6
 		  *igrib = (unsigned long) dval[j];
@@ -12419,7 +12419,7 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	    }
 	  else
 	    {
-	      for (j = 0; j < __UNROLL_DEPTH_2; j++) 
+	      for (j = 0; j < CGRIBEX__UNROLL_DEPTH_2; j++)
 		{
                   ival = (uint32_t) dval[j];
 		  lGrib[z  ] =  (GRIBPACK)(ival >> 24);
@@ -12432,6 +12432,7 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
 	}
       for (j = 0; j < residual; j++) 
 	{
+          // dval[j] = TEMPLATE(round,T)((data[ofs+j] - zref) * factor);
 	  dval[j] = ((data[ofs+j] - zref) * factor + (T)0.5);
 	}
       if ( IS_BIGENDIAN() )
@@ -12476,7 +12477,6 @@ void TEMPLATE(encode_array_unrolled,T)(int numBits, size_t packStart, size_t dat
     }
 
   *gz = z;
-#undef __UNROLL_DEPTH_2
 }
 
 #endif /* T */
@@ -12500,11 +12500,9 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 {
   long z = *gribLen;
   int exponent, mantissa;
-  long i;
   int ival;
   int pvoffset = 0xFF;
   int gdslen = 32;
-  unsigned lonIncr, latIncr;
 
   if ( ISEC2_GridType == GRIB1_GTYPE_LCC ) gdslen += 10;
 
@@ -12566,12 +12564,7 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 	    ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN  ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT )
     {
-      int numlon;
-      if ( ISEC2_Reduced )
-	numlon = 0xFFFF;
-      else
-	numlon = ISEC2_NumLon;
-
+      int numlon = ISEC2_Reduced ? 0xFFFF : ISEC2_NumLon;
       Put2Byte(numlon);                /*  6- 7 Number of Longitudes     */
 
       Put2Byte(ISEC2_NumLat);          /*  8- 9 Number of Latitudes      */
@@ -12580,16 +12573,8 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
       Put1Byte(ISEC2_ResFlag);         /* 16    Resolution flag          */
       Put3Int(ISEC2_LastLat);
       Put3Int(ISEC2_LastLon);
-      if ( ISEC2_ResFlag == 0 )
-	{
-	  lonIncr = 0xFFFF;
-	  latIncr = 0xFFFF;
-	}
-      else
-	{
-	  lonIncr = (unsigned)ISEC2_LonIncr;
-	  latIncr = (unsigned)ISEC2_LatIncr;
-	}
+      unsigned lonIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LonIncr;
+      unsigned latIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LatIncr;
       Put2Byte(lonIncr);               /* 23-24 i - direction increment  */
       if ( ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN )
 	Put2Byte(ISEC2_NumPar);        /* 25-26 Latitudes Pole->Equator  */
@@ -12614,13 +12599,13 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 #if defined (SX)
 #pragma vdir novector     /* vectorization gives wrong results on NEC */
 #endif
-  for ( i = 0; i < ISEC2_NumVCP; ++i )
+  for ( long i = 0; i < ISEC2_NumVCP; ++i )
     {
       Put1Real((double)(fsec2[10+i]));
     }
 
   if ( ISEC2_Reduced )
-    for ( i = 0; i < ISEC2_NumLat; i++ ) Put2Byte(ISEC2_RowLon(i));
+    for ( long i = 0; i < ISEC2_NumLat; i++ ) Put2Byte(ISEC2_RowLon(i));
 
   *gribLen = z;
 }
@@ -12629,32 +12614,23 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 static
 void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4, T *data, long *datasize)
 {
-  GRIBPACK *bitmap;
-  long bitmapSize;
-  long imaskSize;
-  long i;
-  long bmsLen, bmsUnusedBits;
-  long fsec4size;
   long z = *gribLen;
-#if defined (VECTORCODE)
-  unsigned int *imask;
-#endif
-  static int lmissvalinfo = 1;
-  /*  unsigned int c, imask; */
+  static bool lmissvalinfo = true;
+  //  unsigned int c, imask;
 
   if ( DBL_IS_NAN(FSEC3_MissVal) && lmissvalinfo)
     {
-      lmissvalinfo = 0;
+      lmissvalinfo = false;
       Message("Missing value = NaN is unsupported!");
     }
 
-  bitmapSize = ISEC4_NumValues;
-  imaskSize = ((bitmapSize+7)>>3)<<3;
-  bitmap = &lGrib[z+6];
-  fsec4size = 0;
+  long bitmapSize = ISEC4_NumValues;
+  long imaskSize = ((bitmapSize+7)>>3)<<3;
+  GRIBPACK *bitmap = &lGrib[z+6];
+  long fsec4size = 0;
 
 #if defined (VECTORCODE)
-  imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
+  unsigned int *imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
   memset(imask, 0, imaskSize*sizeof(int));
 
 #if defined (CRAY)
@@ -12666,7 +12642,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 #ifdef __uxpch__
 #pragma loop novrec
 #endif
-  for ( i = 0; i < bitmapSize; i++ )
+  for ( long i = 0; i < bitmapSize; i++ )
     {
       if ( IS_NOT_EQUAL(data[i], FSEC3_MissVal) )
 	{
@@ -12684,7 +12660,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 #ifdef __uxpch__
 #pragma loop novrec
 #endif
-  for ( i = 0; i < imaskSize/8; i++ )
+  for ( long i = 0; i < imaskSize/8; i++ )
     {
       bitmap[i] = (imask[i*8+0] << 7) | (imask[i*8+1] << 6) |
 	          (imask[i*8+2] << 5) | (imask[i*8+3] << 4) |
@@ -12694,9 +12670,9 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 
   Free(imask);
 #else
-  for ( i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
+  for ( long i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
 
-  for ( i = 0; i < bitmapSize; i++ )
+  for ( long i = 0; i < bitmapSize; i++ )
     {
       if ( IS_NOT_EQUAL(data[i], FSEC3_MissVal) )
 	{
@@ -12706,8 +12682,8 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
     }
 #endif
 
-  bmsLen = imaskSize/8 + 6;
-  bmsUnusedBits = imaskSize - bitmapSize;
+  long bmsLen = imaskSize/8 + 6;
+  long bmsUnusedBits = imaskSize - bitmapSize;
 
   Put3Byte(bmsLen);   /*  0- 2 Length of Block 3 Byte 0 */
   Put1Byte(bmsUnusedBits);
@@ -12736,7 +12712,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
   int bds_ext = 0;
   /* ibits = BitsPerInt; */
   int exponent, mantissa;
-  int lspherc = FALSE;
+  bool lspherc = false;
   int isubset = 0, itemp = 0, itrunc = 0;
   T factor = 1, fmin, fmax;
   const double jpepsln = 1.0e-12; /* -----> tolerance used to check equality     */
@@ -12751,10 +12727,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
       lspherc =  ( isec2[0] == 50 || isec2[0] == 60 ||
                    isec2[0] == 70 || isec2[0] == 80 );
 
-      if ( lspherc )
-	isec4[2] = 128;
-      else
-	isec4[2] = 0;
+      isec4[2] = lspherc ? 128 : 0;
     }
   else
     {
@@ -12765,8 +12738,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
 
   /* Complex packing supported for spherical harmonics. */
 
-  int lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
-                 ( lspherc && isec2 && ( isec2[5] == 2 ) );
+  bool lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
+                  ( lspherc && isec2 && ( isec2[5] == 2 ) );
 
   /* Check input specification is consistent */
 
@@ -12977,7 +12950,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
 
   *gribLen = (long)z;
 
-  return (0);
+  return 0;
 }
 
 
@@ -12985,54 +12958,49 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 			     T *fsec3, int *isec4, T *fsec4, int klenp, int *kgrib,
 			     int kleng, int *kword, int efunc, int *kret)
 {
-  long gribLen = 0; /* Counter of GRIB length for output */
-  long isLen, pdsLen;
-  GRIBPACK *lpds;
-  unsigned char *CGrib;
+  long gribLen = 0; // Counter of GRIB length for output
   long fsec4size = 0;
-  int bmsIncluded;
-  GRIBPACK *lGrib;
-  long datstart, datsize, bdsstart;
-  int status = 0;
+  long datstart, datsize;
 
   UNUSED(isec3);
   UNUSED(efunc);
 
   grsdef();
 
-  CGrib = (unsigned char *) kgrib;
+  unsigned char *CGrib = (unsigned char *) kgrib;
 
-  bmsIncluded = ISEC1_Sec2Or3Flag & 64;
+  bool gdsIncluded = ISEC1_Sec2Or3Flag & 128;
+  bool bmsIncluded = ISEC1_Sec2Or3Flag & 64;
 
-  /* set max header len */
+  // set max header len
   size_t len = 16384;
 
-  /* add data len */
+  // add data len
   size_t numBytes = (size_t)((ISEC4_NumBits+7)>>3);
 
   len += numBytes*(size_t)klenp;
 
-  /* add bitmap len */
+  // add bitmap len
   if ( bmsIncluded ) len += (size_t)((klenp+7)>>3);
 
 #if defined (VECTORCODE)
-  lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
+  GRIBPACK *lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
   if ( lGrib == NULL ) SysError("No Memory!");
 #else
-  lGrib = CGrib;
+  GRIBPACK *lGrib = CGrib;
 #endif
 
-  isLen = 8;
+  long isLen = 8;
   encodeIS(lGrib, &gribLen);
-  lpds = &lGrib[isLen];
-  pdsLen = getPdsLen(isec1);
+  GRIBPACK *lpds = &lGrib[isLen];
+  long pdsLen = getPdsLen(isec1);
 
   encodePDS(lpds, pdsLen,  isec1);
   gribLen += pdsLen;
   /*
   if ( ( isec4[3] == 64 ) && ( isec2[5] == 2 ) )
     {
-      static int lwarn_cplx = TRUE;
+      static bool lwarn_cplx = true;
 
       if ( lwarn_cplx )
 	Message("Complex packing of spectral data unsupported, using simple packing!");
@@ -13040,10 +13008,10 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       isec2[5] = 1;
       isec4[3] = 0;
 
-      lwarn_cplx = FALSE;
+      lwarn_cplx = false;
     }
   */
-  TEMPLATE(encodeGDS,T)(lGrib, &gribLen, isec2, fsec2);
+  if ( gdsIncluded ) TEMPLATE(encodeGDS,T)(lGrib, &gribLen, isec2, fsec2);
   /*
     ----------------------------------------------------------------
     BMS Bit-Map Section Section (Section 3)
@@ -13058,9 +13026,9 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       fsec4size = ISEC4_NumValues;
     }
 
-  bdsstart = gribLen;
-  status = TEMPLATE(encodeBDS,T)(lGrib, &gribLen, ISEC1_DecScaleFactor, isec2,
-				 isec4, fsec4size, fsec4, &datstart, &datsize, ISEC1_Parameter);
+  long bdsstart = gribLen;
+  int status = TEMPLATE(encodeBDS,T)(lGrib, &gribLen, ISEC1_DecScaleFactor, isec2,
+                                     isec4, fsec4size, fsec4, &datstart, &datsize, ISEC1_Parameter);
   if ( status )
     {
       *kret = status;
@@ -13109,11 +13077,9 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 {
   long z = *gribLen;
   int exponent, mantissa;
-  long i;
   int ival;
   int pvoffset = 0xFF;
   int gdslen = 32;
-  unsigned lonIncr, latIncr;
 
   if ( ISEC2_GridType == GRIB1_GTYPE_LCC ) gdslen += 10;
 
@@ -13175,12 +13141,7 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 	    ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN  ||
 	    ISEC2_GridType == GRIB1_GTYPE_LATLON_ROT )
     {
-      int numlon;
-      if ( ISEC2_Reduced )
-	numlon = 0xFFFF;
-      else
-	numlon = ISEC2_NumLon;
-
+      int numlon = ISEC2_Reduced ? 0xFFFF : ISEC2_NumLon;
       Put2Byte(numlon);                /*  6- 7 Number of Longitudes     */
 
       Put2Byte(ISEC2_NumLat);          /*  8- 9 Number of Latitudes      */
@@ -13189,16 +13150,8 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
       Put1Byte(ISEC2_ResFlag);         /* 16    Resolution flag          */
       Put3Int(ISEC2_LastLat);
       Put3Int(ISEC2_LastLon);
-      if ( ISEC2_ResFlag == 0 )
-	{
-	  lonIncr = 0xFFFF;
-	  latIncr = 0xFFFF;
-	}
-      else
-	{
-	  lonIncr = (unsigned)ISEC2_LonIncr;
-	  latIncr = (unsigned)ISEC2_LatIncr;
-	}
+      unsigned lonIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LonIncr;
+      unsigned latIncr = (ISEC2_ResFlag == 0) ? 0xFFFF : (unsigned)ISEC2_LatIncr;
       Put2Byte(lonIncr);               /* 23-24 i - direction increment  */
       if ( ISEC2_GridType == GRIB1_GTYPE_GAUSSIAN )
 	Put2Byte(ISEC2_NumPar);        /* 25-26 Latitudes Pole->Equator  */
@@ -13223,13 +13176,13 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 #if defined (SX)
 #pragma vdir novector     /* vectorization gives wrong results on NEC */
 #endif
-  for ( i = 0; i < ISEC2_NumVCP; ++i )
+  for ( long i = 0; i < ISEC2_NumVCP; ++i )
     {
       Put1Real((double)(fsec2[10+i]));
     }
 
   if ( ISEC2_Reduced )
-    for ( i = 0; i < ISEC2_NumLat; i++ ) Put2Byte(ISEC2_RowLon(i));
+    for ( long i = 0; i < ISEC2_NumLat; i++ ) Put2Byte(ISEC2_RowLon(i));
 
   *gribLen = z;
 }
@@ -13238,32 +13191,23 @@ void TEMPLATE(encodeGDS,T)(GRIBPACK *lGrib, long *gribLen, int *isec2, T *fsec2)
 static
 void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4, T *data, long *datasize)
 {
-  GRIBPACK *bitmap;
-  long bitmapSize;
-  long imaskSize;
-  long i;
-  long bmsLen, bmsUnusedBits;
-  long fsec4size;
   long z = *gribLen;
-#if defined (VECTORCODE)
-  unsigned int *imask;
-#endif
-  static int lmissvalinfo = 1;
-  /*  unsigned int c, imask; */
+  static bool lmissvalinfo = true;
+  //  unsigned int c, imask;
 
   if ( DBL_IS_NAN(FSEC3_MissVal) && lmissvalinfo)
     {
-      lmissvalinfo = 0;
+      lmissvalinfo = false;
       Message("Missing value = NaN is unsupported!");
     }
 
-  bitmapSize = ISEC4_NumValues;
-  imaskSize = ((bitmapSize+7)>>3)<<3;
-  bitmap = &lGrib[z+6];
-  fsec4size = 0;
+  long bitmapSize = ISEC4_NumValues;
+  long imaskSize = ((bitmapSize+7)>>3)<<3;
+  GRIBPACK *bitmap = &lGrib[z+6];
+  long fsec4size = 0;
 
 #if defined (VECTORCODE)
-  imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
+  unsigned int *imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
   memset(imask, 0, imaskSize*sizeof(int));
 
 #if defined (CRAY)
@@ -13275,7 +13219,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 #ifdef __uxpch__
 #pragma loop novrec
 #endif
-  for ( i = 0; i < bitmapSize; i++ )
+  for ( long i = 0; i < bitmapSize; i++ )
     {
       if ( IS_NOT_EQUAL(data[i], FSEC3_MissVal) )
 	{
@@ -13293,7 +13237,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 #ifdef __uxpch__
 #pragma loop novrec
 #endif
-  for ( i = 0; i < imaskSize/8; i++ )
+  for ( long i = 0; i < imaskSize/8; i++ )
     {
       bitmap[i] = (imask[i*8+0] << 7) | (imask[i*8+1] << 6) |
 	          (imask[i*8+2] << 5) | (imask[i*8+3] << 4) |
@@ -13303,9 +13247,9 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 
   Free(imask);
 #else
-  for ( i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
+  for ( long i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
 
-  for ( i = 0; i < bitmapSize; i++ )
+  for ( long i = 0; i < bitmapSize; i++ )
     {
       if ( IS_NOT_EQUAL(data[i], FSEC3_MissVal) )
 	{
@@ -13315,8 +13259,8 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
     }
 #endif
 
-  bmsLen = imaskSize/8 + 6;
-  bmsUnusedBits = imaskSize - bitmapSize;
+  long bmsLen = imaskSize/8 + 6;
+  long bmsUnusedBits = imaskSize - bitmapSize;
 
   Put3Byte(bmsLen);   /*  0- 2 Length of Block 3 Byte 0 */
   Put1Byte(bmsUnusedBits);
@@ -13345,7 +13289,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
   int bds_ext = 0;
   /* ibits = BitsPerInt; */
   int exponent, mantissa;
-  int lspherc = FALSE;
+  bool lspherc = false;
   int isubset = 0, itemp = 0, itrunc = 0;
   T factor = 1, fmin, fmax;
   const double jpepsln = 1.0e-12; /* -----> tolerance used to check equality     */
@@ -13360,10 +13304,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
       lspherc =  ( isec2[0] == 50 || isec2[0] == 60 ||
                    isec2[0] == 70 || isec2[0] == 80 );
 
-      if ( lspherc )
-	isec4[2] = 128;
-      else
-	isec4[2] = 0;
+      isec4[2] = lspherc ? 128 : 0;
     }
   else
     {
@@ -13374,8 +13315,8 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
 
   /* Complex packing supported for spherical harmonics. */
 
-  int lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
-                 ( lspherc && isec2 && ( isec2[5] == 2 ) );
+  bool lcomplex = ( lspherc && ( isec4[3] == 64 ) ) ||
+                  ( lspherc && isec2 && ( isec2[5] == 2 ) );
 
   /* Check input specification is consistent */
 
@@ -13586,7 +13527,7 @@ int TEMPLATE(encodeBDS,T)(GRIBPACK *lGrib, long *gribLen, int decscale, int *ise
 
   *gribLen = (long)z;
 
-  return (0);
+  return 0;
 }
 
 
@@ -13594,54 +13535,49 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 			     T *fsec3, int *isec4, T *fsec4, int klenp, int *kgrib,
 			     int kleng, int *kword, int efunc, int *kret)
 {
-  long gribLen = 0; /* Counter of GRIB length for output */
-  long isLen, pdsLen;
-  GRIBPACK *lpds;
-  unsigned char *CGrib;
+  long gribLen = 0; // Counter of GRIB length for output
   long fsec4size = 0;
-  int bmsIncluded;
-  GRIBPACK *lGrib;
-  long datstart, datsize, bdsstart;
-  int status = 0;
+  long datstart, datsize;
 
   UNUSED(isec3);
   UNUSED(efunc);
 
   grsdef();
 
-  CGrib = (unsigned char *) kgrib;
+  unsigned char *CGrib = (unsigned char *) kgrib;
 
-  bmsIncluded = ISEC1_Sec2Or3Flag & 64;
+  bool gdsIncluded = ISEC1_Sec2Or3Flag & 128;
+  bool bmsIncluded = ISEC1_Sec2Or3Flag & 64;
 
-  /* set max header len */
+  // set max header len
   size_t len = 16384;
 
-  /* add data len */
+  // add data len
   size_t numBytes = (size_t)((ISEC4_NumBits+7)>>3);
 
   len += numBytes*(size_t)klenp;
 
-  /* add bitmap len */
+  // add bitmap len
   if ( bmsIncluded ) len += (size_t)((klenp+7)>>3);
 
 #if defined (VECTORCODE)
-  lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
+  GRIBPACK *lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
   if ( lGrib == NULL ) SysError("No Memory!");
 #else
-  lGrib = CGrib;
+  GRIBPACK *lGrib = CGrib;
 #endif
 
-  isLen = 8;
+  long isLen = 8;
   encodeIS(lGrib, &gribLen);
-  lpds = &lGrib[isLen];
-  pdsLen = getPdsLen(isec1);
+  GRIBPACK *lpds = &lGrib[isLen];
+  long pdsLen = getPdsLen(isec1);
 
   encodePDS(lpds, pdsLen,  isec1);
   gribLen += pdsLen;
   /*
   if ( ( isec4[3] == 64 ) && ( isec2[5] == 2 ) )
     {
-      static int lwarn_cplx = TRUE;
+      static bool lwarn_cplx = true;
 
       if ( lwarn_cplx )
 	Message("Complex packing of spectral data unsupported, using simple packing!");
@@ -13649,10 +13585,10 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       isec2[5] = 1;
       isec4[3] = 0;
 
-      lwarn_cplx = FALSE;
+      lwarn_cplx = false;
     }
   */
-  TEMPLATE(encodeGDS,T)(lGrib, &gribLen, isec2, fsec2);
+  if ( gdsIncluded ) TEMPLATE(encodeGDS,T)(lGrib, &gribLen, isec2, fsec2);
   /*
     ----------------------------------------------------------------
     BMS Bit-Map Section Section (Section 3)
@@ -13667,9 +13603,9 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       fsec4size = ISEC4_NumValues;
     }
 
-  bdsstart = gribLen;
-  status = TEMPLATE(encodeBDS,T)(lGrib, &gribLen, ISEC1_DecScaleFactor, isec2,
-				 isec4, fsec4size, fsec4, &datstart, &datsize, ISEC1_Parameter);
+  long bdsstart = gribLen;
+  int status = TEMPLATE(encodeBDS,T)(lGrib, &gribLen, ISEC1_DecScaleFactor, isec2,
+                                     isec4, fsec4size, fsec4, &datstart, &datsize, ISEC1_Parameter);
   if ( status )
     {
       *kret = status;
@@ -13711,7 +13647,7 @@ void encode_dummy(void)
   (void) encode_array_unrolled_double(0, 0, 0, NULL, NULL, 0, 0, NULL);
   (void) encode_array_unrolled_float(0, 0, 0, NULL, NULL, 0, 0, NULL);
 }
-static const char grb_libvers[] = "1.7.6" " of ""Dec 20 2016"" ""19:55:24";
+static const char grb_libvers[] = "1.8.1" " of ""Jul 12 2017"" ""18:11:37";
 const char *
 cgribexLibraryVersion(void)
 {
diff --git a/src/gribapi.c b/src/gribapi.c
index 0a9aeb4ffc46eb316fc61389fbccd0f28637aa6f..b2e312911ad0411d2d402ff9f1010c36561167f4 100644
--- a/src/gribapi.c
+++ b/src/gribapi.c
@@ -15,7 +15,7 @@
 
 static char gribapi_libvers[64] = "";
 #if  defined  (HAVE_LIBGRIB_API)
-static int gribapi_libvers_init;
+static bool gribapi_libvers_init;
 #endif
 
 
@@ -43,7 +43,7 @@ const char *gribapiLibraryVersionString(void)
       gribapiLibraryVersion(&major_version, &minor_version, &revision_version);
 
       sprintf(gribapi_libvers, "%d.%d.%d", major_version, minor_version, revision_version);
-      gribapi_libvers_init = 1;
+      gribapi_libvers_init = true;
     }
 #endif
 
@@ -76,7 +76,7 @@ void gribContainersNew(stream_t * streamptr)
           for ( int levelID = 0; levelID < nlevs; ++levelID )
             {
               gribContainers[varID][levelID].gribHandle = gribHandleNew(editionNumber);
-              gribContainers[varID][levelID].init = FALSE;
+              gribContainers[varID][levelID].init = false;
             }
 	}
 
@@ -88,7 +88,7 @@ void gribContainersNew(stream_t * streamptr)
       for ( int varID = 0; varID < nvars; ++varID )
         {
           gribContainers[varID].gribHandle = gribHandleNew(editionNumber);
-          gribContainers[varID].init = FALSE;
+          gribContainers[varID].init = false;
 	}
 
       streamptr->gribContainers = (void *) gribContainers;
diff --git a/src/gribapi.h b/src/gribapi.h
index 57d0780efc476373b95d2afd429d6449b7594af2..1666b2be399644bffeefc1f19f04893a0ad02208 100644
--- a/src/gribapi.h
+++ b/src/gribapi.h
@@ -110,7 +110,7 @@ static inline void gribHandleDelete(void *gh)
 #endif
 
 typedef struct {
-  int init;
+  bool init;
   void *gribHandle;
 }
 gribContainer_t;
diff --git a/src/gribapi_utilities.c b/src/gribapi_utilities.c
index b333723d877c3570009b0c296c639e6ce98b9018..5e88cd98805e52262c073ba3d7443b0d2c57da8c 100644
--- a/src/gribapi_utilities.c
+++ b/src/gribapi_utilities.c
@@ -427,7 +427,7 @@ int gribapiGetTsteptype(grib_handle *gh)
                 {
                   if (CDI_Debug)
                       Warning("timeRangeIND = %d;  stepType= %s; tsteptype=%d unsupported timeRangeIND at the moment, set to instant!", timeRangeIND, stepType, tsteptype);
-                  lprint = FALSE;
+                  lprint = false;
                 }
                 break;
           }
diff --git a/src/grid.c b/src/grid.c
index 82b77d1bf147d6bcd4053a19c92e54e695e95e19..f4acd57e3a45ffaea5be76d191311c411dc07770 100644
--- a/src/grid.c
+++ b/src/grid.c
@@ -2056,14 +2056,21 @@ void grid_check_cyclic(grid_t *gridptr)
     {
       if ( xvals && xsize > 1 )
         {
-          double xinc = xvals[1] - xvals[0];
-          if ( IS_EQUAL(xinc, 0) )
-            xinc = (xvals[xsize-1] - xvals[0])/(double)(xsize-1);
+          double xval1 = xvals[0];
+          double xval2 = xvals[1];
+          double xvaln = xvals[xsize-1];
+          if ( xval2 < xval1 ) xval2 += 360;
+          if ( xvaln < xval1 ) xvaln += 360;
 
-          double x0 = 2*xvals[xsize-1]-xvals[xsize-2]-360;
+          if ( IS_NOT_EQUAL(xval1, xvaln) )
+            {
+              double xinc = xval2 - xval1;
+              if ( IS_EQUAL(xinc, 0) ) xinc = (xvaln - xval1)/(xsize-1);
+
+              double x0 = xvaln + xinc - 360;
 
-          if ( IS_NOT_EQUAL(xvals[0], xvals[xsize-1]) )
-            if ( fabs(x0 - xvals[0]) < 0.01*xinc ) gridptr->isCyclic = 1;
+              if ( fabs(x0 - xval1) < 0.01*xinc ) gridptr->isCyclic = 1;
+            }
         }
     }
   else if ( gridptr->type == GRID_CURVILINEAR )
diff --git a/src/make_fint.c b/src/make_fint.c
index a31677430da67265f259b624d0c7fb4e2613194b..3272331e9a1a610e0ce5708112c8bef7d1661d7b 100644
--- a/src/make_fint.c
+++ b/src/make_fint.c
@@ -15,7 +15,7 @@
 #endif
 
 //#include "config.h"
-#define VERSION "1.8.1"
+#define VERSION "1.9.0"
 typedef struct
 {
   size_t naline;
@@ -86,8 +86,8 @@ static void doctotxt(FILE *fp, Docu *doc, size_t ndoc)
     }
 }
 
-enum cftype {ISVOID, ISCONSTSTRING, ISINT, ISREAL, ISDOUBLE, ISMPI_COMM,
-             ISXT_IDXLIST, ISCHOICE, ISINTP, ISFLOATV, ISFLOATVV,
+enum cftype {ISVOID, ISCONSTSTRING, ISINT, ISREAL, ISDOUBLE, ISSIZET, ISMPI_COMM,
+             ISXT_IDXLIST, ISCHOICE, ISINTP, ISSIZETP, ISFLOATV, ISFLOATVV,
              ISDOUBLEV, ISDOUBLEVV, ISINTV, ISINTVV, ISINTVVV, ISREALP,
              ISDOUBLEP, ISCBUF, ISUUID, ISUCHAR, ISSTRING, ISSTRINGP,
              VOIDFUNCVOID,
@@ -107,8 +107,14 @@ typedef int (*cfPrologueEmitter)(FILE *outfp, size_t argNum);
 static int cfMPICommConvert(FILE *outfp, const char *argName,
                             size_t argNameLen, enum conversionType part);
 
+static int cfSizetConvert(FILE *outfp, const char *argName,
+                          size_t argNameLen, enum conversionType part);
+
+static int cfSizetpConvert(FILE *outfp, const char *argName,
+                           size_t argNameLen, enum conversionType part);
+
 static int cfXtIdxlistConvert(FILE *outfp, const char *argName,
-                            size_t argNameLen, enum conversionType part);
+                              size_t argNameLen, enum conversionType part);
 
 static int cfVoidFuncPrologue(FILE *outfp, size_t argNum);
 
@@ -156,6 +162,9 @@ static struct symbol funArgSym[]
         "^"WS"*(const"WS"+)?float"WS"+"SYMRE"?"WS"*[,\\)]", 2, 0, 0 },
       { "DOUBLEPRECISION", "DOUBLE",  "%sdouble %.*s",
         "^"WS"*(const"WS"+)?double"WS"+"SYMRE"?"WS"*[,\\)]", 2, 0, 0 },
+      { "INTEGER",         "INT",     "%ssize_t %.*s",
+        "^"WS"*(const"WS"+)?size_t("WS"+"SYMRE")?"WS"*[,\\)]", 3, 1, 0,
+        cfSizetConvert, "%sint %.*s" },
       { "INTEGER",         "INT", "%sMPI_Comm %.*s",
         "^"WS"*MPI_Comm"WS"+"SYMRE"?"WS"*[,\\)]", 1, 1, 0,
         cfMPICommConvert, "%sint %.*s" },
@@ -166,6 +175,9 @@ static struct symbol funArgSym[]
         "^"WS"*const"WS"+void"WS"*\\*"WS"*"SYMRE"?"WS"*[,\\)]", 1, 0, 0 },
       { "INTEGER",         "PINT",    "%sint *%.*s",
         "^"WS"*(const"WS"+)?int"WS"+\\*"SYMRE"?"WS"*[,\\)]", 2, 0, 0 },
+      { "INTEGER",         "PINT",    "%ssize_t *%.*s",
+        "^"WS"*(const"WS"+)?size_t"WS"+\\*"SYMRE"?"WS"*[,\\)]", 2, 1, 0,
+        cfSizetpConvert, "%sint *%.*s"},
       { "REAL",            "FLOATV",  "%sfloat %.*s[]",
         "^"WS"*(const"WS"+)?float("WS"+"SYMRE")?"WS"*"ARRAY_BOUND
         "[,\\)]", 3, 0, 0 },
@@ -221,6 +233,8 @@ static struct symbol funRet[] = {
     "(const"WS"+)?double"WS"+"SYMRE WS"*\\(", 2, 0, 0 },
   { "INTEGER",         "INT",     "%sMPI_Comm %.*s",
     "MPI_Comm"WS"+"SYMRE WS"*\\(", 1, 0, 0, cfMPICommConvert, "%sint %.*s" },
+  { "INTEGER",         "INT",    "%ssize_t %.*s",
+    "(const"WS"+)?size_t"WS"+"SYMRE WS"*\\(", 2, 1, 0, cfSizetConvert, "%sint %.*s" },
 };
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
 #pragma GCC diagnostic pop
@@ -403,6 +417,9 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint,
             "\n", cppHeaderSentinelMacro, fbasename);
   }
   fputs("#if defined (HAVE_CF_INTERFACE)\n"
+        "\n"
+        "#include <limits.h>\n"
+        "#include <assert.h>\n"
         "\n"
         "#if ! defined (__CFORTRAN_LOADED)\n"
         "#  if defined __clang__\n"
@@ -421,6 +438,14 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint,
         "#endif\n"
         "\n", fpint);
 
+  fputs("static\n"
+        "int size_t_c2f(size_t value_size_t)\n"
+        "{\n"
+        "  assert(value_size_t < INT_MAX);\n"
+        "  return (int) value_size_t;\n"
+        "}\n"
+        "\n", fpint);
+
   ssize_t lineLen;
   while ((lineLen = getline(&line, &lineBufSize, fpin)) >= 0)
     {
@@ -673,6 +698,15 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint,
                           line + funcargname[i].rm_so, arrayDimsC);
                 }
               fputs(")\n{\n", fpint);
+              for (size_t i = 0; i < funcargc; i++ )
+                {
+                  if (funArgSym[funcargtype[i]].convert && funcargtype[i] == ISSIZETP)
+                    {
+                      // create temporary size_t variable
+                      fprintf(fpint, "  size_t %.*s_size_t;\n",
+                              (int)(funcargname[i].rm_eo - funcargname[i].rm_so), line + funcargname[i].rm_so);
+                    }
+                }
               if (functype != ISVOID)
                 {
                   fputs("  ", fpint);
@@ -700,6 +734,18 @@ static void fortran_interface(char *fname, char *fnameinc, char *fnameint,
                             line + funcargname[i].rm_so);
                 }
               fputs(");\n", fpint);
+              for (size_t i = 0; i < funcargc; i++ )
+                {
+                  if (funArgSym[funcargtype[i]].convert && funcargtype[i] == ISSIZETP)
+                    {
+                      fprintf(fpint, "  assert(%.*s_size_t < INT_MAX);\n",
+                              (int)(funcargname[i].rm_eo - funcargname[i].rm_so), line + funcargname[i].rm_so);
+                      // copy temporary size_t variable
+                      fprintf(fpint, "  *%.*s = %.*s_size_t;\n",
+                              (int)(funcargname[i].rm_eo - funcargname[i].rm_so), line + funcargname[i].rm_so,
+                              (int)(funcargname[i].rm_eo - funcargname[i].rm_so), line + funcargname[i].rm_so);
+                    }
+                }
               if (functype != ISVOID)
                 {
                   fputs("  return ", fpint);
@@ -1194,6 +1240,41 @@ reCompile(regex_t *restrict RE, const char *restrict REstring,
   return errcode;
 }
 
+/* emit conversion code for size_t argument */
+static int cfSizetConvert(FILE *outfp, const char *argName,
+                            size_t argNameLen, enum conversionType part)
+{
+  int retval = 0;
+  switch (part)
+    {
+    case CONV_ARG:
+      retval = fprintf(outfp, "(size_t)%.*s", (int)argNameLen, argName);
+      break;
+    case CONV_RET:
+      retval = fprintf(outfp, "size_t_c2f(%.*s)", (int)argNameLen, argName);
+      break;
+    }
+  return retval;
+}
+
+/* emit conversion code for size_t* argument */
+static int cfSizetpConvert(FILE *outfp, const char *argName,
+                           size_t argNameLen, enum conversionType part)
+{
+  int retval = 0;
+  switch (part)
+    {
+    case CONV_ARG:
+      retval = fprintf(outfp, "&%.*s_size_t", (int)argNameLen, argName);
+      break;
+    case CONV_RET:
+      abort();
+
+      break;
+    }
+  return retval;
+}
+
 /* emit conversion code for MPI_Comm argument */
 static int cfMPICommConvert(FILE *outfp, const char *argName,
                             size_t argNameLen, enum conversionType part)
@@ -1202,8 +1283,7 @@ static int cfMPICommConvert(FILE *outfp, const char *argName,
   switch (part)
     {
     case CONV_ARG:
-      retval
-        = fprintf(outfp, "MPI_Comm_f2c(%.*s)", (int)argNameLen, argName);
+      retval = fprintf(outfp, "MPI_Comm_f2c(%.*s)", (int)argNameLen, argName);
       break;
     case CONV_RET:
       retval = fprintf(outfp, "MPI_Comm_c2f(%.*s)", (int)argNameLen, argName);
@@ -1220,8 +1300,7 @@ static int cfXtIdxlistConvert(FILE *outfp, const char *argName,
   switch (part)
     {
     case CONV_ARG:
-      retval
-        = fprintf(outfp, "(*(Xt_idxlist *)%.*s)", (int)argNameLen, argName);
+      retval = fprintf(outfp, "(*(Xt_idxlist *)%.*s)", (int)argNameLen, argName);
       break;
     case CONV_RET:
       abort();
diff --git a/src/stream.c b/src/stream.c
index 49e84111aabba0b0c84dd65957781b84935311de..28fbef08a132a9d26fb8f2b81d3e4dcc4a0ef857 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -6,6 +6,7 @@
 #define _XOPEN_SOURCE 600
 #endif
 
+#include <sys/stat.h> // struct stat
 #include <ctype.h>
 
 #include "binary.h"
@@ -78,7 +79,6 @@ int cdiGetFiletype(const char *filename, int *byteorder)
   int swap = 0;
   int version;
   long recpos;
-  char buffer[8];
 
   int fileID = fileOpen(filename, "r");
 
@@ -90,7 +90,18 @@ int cdiGetFiletype(const char *filename, int *byteorder)
 	return CDI_ESYSTEM;
     }
 
-  if ( fileRead(fileID, buffer, 8) != 8 ) return CDI_EUFTYPE;
+  char buffer[8];
+  if ( fileRead(fileID, buffer, 8) != 8 )
+    {
+      struct stat buf;
+      if ( stat(filename, &buf) == 0 )
+        {
+          if ( buf.st_size == 0 ) return CDI_EISEMPTY;
+          if ( buf.st_mode&S_IFDIR ) return CDI_EISDIR;
+        }
+
+      return CDI_EUFTYPE;
+    }
 
   fileRewind(fileID);
 
@@ -123,28 +134,21 @@ int cdiGetFiletype(const char *filename, int *byteorder)
       filetype = CDI_FILETYPE_NC4;
       if ( CDI_Debug ) Message("found HDF file = %s", filename);
     }
-#if  defined  (HAVE_LIBSERVICE)
   else if ( srvCheckFiletype(fileID, &swap) )
     {
       filetype = CDI_FILETYPE_SRV;
       if ( CDI_Debug ) Message("found SRV file = %s", filename);
     }
-#endif
-#if  defined  (HAVE_LIBEXTRA)
   else if ( extCheckFiletype(fileID, &swap) )
     {
       filetype = CDI_FILETYPE_EXT;
       if ( CDI_Debug ) Message("found EXT file = %s", filename);
     }
-#endif
-#if  defined  (HAVE_LIBIEG)
   else if ( iegCheckFiletype(fileID, &swap) )
     {
       filetype = CDI_FILETYPE_IEG;
       if ( CDI_Debug ) Message("found IEG file = %s", filename);
     }
-#endif
-#if  defined  (HAVE_LIBCGRIBEX)
   else if ( gribCheckSeek(fileID, &recpos, &version) == 0 )
     {
       if ( version <= 1 )
@@ -158,7 +162,6 @@ int cdiGetFiletype(const char *filename, int *byteorder)
 	  if ( CDI_Debug ) Message("found seeked GRIB2 file = %s", filename);
 	}
     }
-#endif
 
   fileClose(fileID);
 
@@ -976,8 +979,16 @@ void cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDelet
           cdfClose(fileID);
           if (streamptr->ntsteps == 0)
             {
-              Free(streamptr->tsteps[0].records);
-              Free(streamptr->tsteps[0].recIDs);
+              if ( streamptr->tsteps[0].records )
+                {
+                  Free(streamptr->tsteps[0].records);
+                  streamptr->tsteps[0].records = NULL;
+                }
+              if ( streamptr->tsteps[0].recIDs )
+                {
+                  Free(streamptr->tsteps[0].recIDs);
+                  streamptr->tsteps[0].recIDs = NULL;
+                }
             }
           break;
         }
diff --git a/src/stream_cdf_i.c b/src/stream_cdf_i.c
index 8e28e92280a7f7fb0e7e9c5eea0c31ae73758d1a..dc738c94e184cfbf217c58d104bdd560ee40b51c 100644
--- a/src/stream_cdf_i.c
+++ b/src/stream_cdf_i.c
@@ -199,6 +199,8 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
   int rdate = -1, rtime = -1;
 
   size_t len = strlen(timeunits);
+  while ( isspace(*timeunits) && len ) { timeunits++; len--; }
+
   char *restrict tu = (char *)Malloc((len+1) * sizeof(char));
 
   for ( size_t i = 0; i < len; i++ ) tu[i] = (char)tolower((int)timeunits[i]);
@@ -1329,7 +1331,7 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
                   if ( status == NC_NOERR )
                     {
                       cdf_set_var(ncvars, dimvarid, FALSE);
-                      if ( cdiIgnoreAttCoordinates == false )
+                      if ( !cdiIgnoreAttCoordinates )
                         {
                           ncvars[ncvarid].coordvarids[i] = dimvarid;
                           ncvars[ncvarid].ncoordvars++;
@@ -1372,7 +1374,7 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
                   if ( status == NC_NOERR )
                     {
                       cdf_set_var(ncvars, dimvarid, FALSE);
-                      //  if ( cdiIgnoreAttCoordinates == FALSE )
+                      //  if ( !cdiIgnoreAttCoordinates )
                         {
                           ncvars[ncvarid].auxvarids[i] = dimvarid;
                           ncvars[ncvarid].nauxvars++;
@@ -1430,9 +1432,8 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
             {
               if ( ncvars[ncvarid].lvalidrange == false )
                 {
-                  extern int cdiIgnoreValidRange;
                   bool lignore = xtypeIsFloat(atttype) != xtypeIsFloat(xtype);
-                  if ( cdiIgnoreValidRange == FALSE && lignore == false )
+                  if ( !cdiIgnoreValidRange && lignore == false )
                     {
                       cdfGetAttDouble(ncid, ncvarid, attname, 2, ncvars[ncvarid].validrange);
                       ncvars[ncvarid].lvalidrange = true;
@@ -1450,9 +1451,8 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
             {
               if ( ncvars[ncvarid].lvalidrange == false )
                 {
-                  extern int cdiIgnoreValidRange;
                   bool lignore = xtypeIsFloat(atttype) != xtypeIsFloat(xtype);
-                  if ( cdiIgnoreValidRange == FALSE && lignore == false )
+                  if ( !cdiIgnoreValidRange && lignore == false )
                     {
                       cdfGetAttDouble(ncid, ncvarid, attname, 1, &(ncvars[ncvarid].validrange)[0]);
                       ncvars[ncvarid].lvalidrange = true;
@@ -1467,9 +1467,8 @@ void cdf_scan_var_attr(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimi
             {
               if ( ncvars[ncvarid].lvalidrange == false )
                 {
-                  extern int cdiIgnoreValidRange;
                   bool lignore = xtypeIsFloat(atttype) != xtypeIsFloat(xtype);
-                  if ( cdiIgnoreValidRange == FALSE && lignore == false )
+                  if ( !cdiIgnoreValidRange && lignore == false )
                     {
                       cdfGetAttDouble(ncid, ncvarid, attname, 1, &(ncvars[ncvarid].validrange)[1]);
                       ncvars[ncvarid].lvalidrange = true;
@@ -2821,7 +2820,7 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
 	  bool with_bounds = false;
 	  int zdimid = CDI_UNDEFID;
 	  int zvarid = CDI_UNDEFID;
-	  int zsize = 1;
+	  size_t zsize = 1;
           int psvarid = -1;
           int p0varid = -1;
 
@@ -2845,14 +2844,15 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
                 {
                   // zvarid = ncdims[zdimid].ncvarid;
                   zvarid = (ncvar->zvarid != CDI_UNDEFID) ? ncvar->zvarid : ncdims[zdimid].ncvarid;
-                  zsize  = (int)ncdims[zdimid].len;
+                  zsize  = ncdims[zdimid].len;
                 }
             }
 
-	  if ( CDI_Debug ) Message("nlevs = %d", zsize);
+	  if ( CDI_Debug ) Message("nlevs = %zu", zsize);
 
 	  double *zvar = NULL;
           char **zcvals = NULL;
+          size_t zclength = 0;
 
 	  int zaxisType = CDI_UNDEFID;
 	  if ( zvarid != CDI_UNDEFID ) zaxisType = ncvars[zvarid].zaxistype;
@@ -2880,8 +2880,8 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
                   if ( ncvars[zvarid].ndims == 2 )
                     {
                       zprec = CDI_DATATYPE_UINT8;
-                      size_t strlength = ncdims[ncvars[zvarid].dimids[1]].len;
-                      cdf_load_cvals(zsize*strlength, zvarid, ncvar, &zcvals, zsize);
+                      zclength = ncdims[ncvars[zvarid].dimids[1]].len;
+                      cdf_load_cvals(zsize*zclength, zvarid, ncvar, &zcvals, zsize);
                     }
                 }
 
@@ -2896,7 +2896,7 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
 
               if ( zaxisType != ZAXIS_CHAR )
                 {
-                  zvar = (double*) Malloc((size_t)zsize*sizeof(double));
+                  zvar = (double*) Malloc(zsize*sizeof(double));
                   cdf_get_var_double(ncvars[zvarid].ncid, zvarid, zvar);
                 }
 
@@ -2905,16 +2905,16 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
 		  int nbdims = ncvars[ncvars[zvarid].bounds].ndims;
 		  if ( nbdims == 2 || is_scalar )
 		    {
-		      int nlevel  = is_scalar ? 1 : (int)ncdims[ncvars[ncvars[zvarid].bounds].dimids[0]].len;
+		      size_t nlevel  = is_scalar ? 1 : (int)ncdims[ncvars[ncvars[zvarid].bounds].dimids[0]].len;
 		      int nvertex = (int)ncdims[ncvars[ncvars[zvarid].bounds].dimids[1-is_scalar]].len;
 		      if ( nlevel == zsize && nvertex == 2 )
 			{
 			  with_bounds = true;
-			  lbounds = (double *) Malloc(4 * (size_t)nlevel*sizeof(double));
+			  lbounds = (double *) Malloc(4 * nlevel*sizeof(double));
 			  ubounds = lbounds + nlevel;
 			  double *restrict zbounds = lbounds + 2 * nlevel;
 			  cdf_get_var_double(ncvars[zvarid].ncid, ncvars[zvarid].bounds, zbounds);
-			  for ( int i = 0; i < nlevel; ++i )
+			  for ( size_t i = 0; i < nlevel; ++i )
 			    {
 			      lbounds[i] = zbounds[i*2];
 			      ubounds[i] = zbounds[i*2+1];
@@ -2946,7 +2946,7 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
               return CDI_EDIMSIZE;
             }
 
-      	  ncvar->zaxisID = varDefZaxis(vlistID, zaxisType, (int) zsize, zvar, (const char **)zcvals, with_bounds, lbounds, ubounds,
+      	  ncvar->zaxisID = varDefZaxis(vlistID, zaxisType, (int) zsize, zvar, (const char **)zcvals, zclength, with_bounds, lbounds, ubounds,
                                        (int)vctsize, vct, pname, plongname, punits, zprec, 1, 0);
 
           int zaxisID = ncvar->zaxisID;
@@ -2979,6 +2979,12 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
             cdiZaxisDefKeyStr(zaxisID, CDI_KEY_VDIMNAME, strlen(ncdims[vdimid].name)+1, ncdims[vdimid].name);
           */
 	  if ( zvar    ) Free(zvar);
+	  if ( zcvals  )
+            {
+              for ( size_t i = 0; i < zsize; i++ )
+                Free(zcvals[i]);
+              Free(zcvals);
+            }
 	  if ( lbounds ) Free(lbounds);
 
           if ( zvarid != CDI_UNDEFID )
@@ -3223,30 +3229,31 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
     {
       if ( vlistInqVarCode(vlistID, varID) == -varID-1 )
 	{
-	  const char *pname = vlistInqVarNamePtr(vlistID, varID);
-	  size_t len = strlen(pname);
-	  if ( len > 3 && isdigit((int) pname[3]) )
+          char name[CDI_MAX_NAME]; name[0] = 0;
+	  vlistInqVarName(vlistID, varID, name);
+	  size_t len = strlen(name);
+	  if ( len > 3 && isdigit((int) name[3]) )
 	    {
-	      if ( str_is_equal(pname, "var") )
+	      if ( str_is_equal(name, "var") )
 		{
-		  vlistDefVarCode(vlistID, varID, atoi(pname+3));
+		  vlistDefVarCode(vlistID, varID, atoi(name+3));
                   // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
-	  else if ( len > 4 && isdigit((int) pname[4]) )
+	  else if ( len > 4 && isdigit((int) name[4]) )
 	    {
-	      if ( str_is_equal(pname, "code") )
+	      if ( str_is_equal(name, "code") )
 		{
-		  vlistDefVarCode(vlistID, varID, atoi(pname+4));
+		  vlistDefVarCode(vlistID, varID, atoi(name+4));
 		  // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
-	  else if ( len > 5 && isdigit((int) pname[5]) )
+	  else if ( len > 5 && isdigit((int) name[5]) )
 	    {
-	      if ( str_is_equal(pname, "param") )
+	      if ( str_is_equal(name, "param") )
 		{
 		  int pnum = -1, pcat = 255, pdis = 255;
-		  sscanf(pname+5, "%d.%d.%d", &pnum, &pcat, &pdis);
+		  sscanf(name+5, "%d.%d.%d", &pnum, &pcat, &pdis);
 		  vlistDefVarParam(vlistID, varID, cdiEncodeParam(pnum, pcat, pdis));
                   // vlistDestroyVarName(vlistID, varID);
 		}
@@ -3262,7 +3269,11 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
       int code = vlistInqVarCode(vlistID, varID);
       if ( cdiDefaultTableID != CDI_UNDEFID )
 	{
-	  if ( tableInqParNamePtr(cdiDefaultTableID, code) )
+          char name[CDI_MAX_NAME]; name[0] = 0;
+          char longname[CDI_MAX_NAME]; longname[0] = 0;
+          char units[CDI_MAX_NAME]; units[0] = 0;
+          tableInqEntry(cdiDefaultTableID, code, -1, name, longname, units);
+	  if ( name[0] )
 	    {
 	      vlistDestroyVarName(vlistID, varID);
 	      vlistDestroyVarLongname(vlistID, varID);
@@ -3270,11 +3281,9 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
 
 	      if ( varTableID != CDI_UNDEFID )
 		{
-		  vlistDefVarName(vlistID, varID, tableInqParNamePtr(cdiDefaultTableID, code));
-		  if ( tableInqParLongnamePtr(cdiDefaultTableID, code) )
-		    vlistDefVarLongname(vlistID, varID, tableInqParLongnamePtr(cdiDefaultTableID, code));
-		  if ( tableInqParUnitsPtr(cdiDefaultTableID, code) )
-		    vlistDefVarUnits(vlistID, varID, tableInqParUnitsPtr(cdiDefaultTableID, code));
+		  vlistDefVarName(vlistID, varID, name);
+		  if ( longname[0] ) vlistDefVarLongname(vlistID, varID, longname);
+		  if ( units[0] ) vlistDefVarUnits(vlistID, varID, units);
 		}
 	      else
 		{
@@ -3407,11 +3416,12 @@ int find_leadtime(int nvars, ncvar_t *ncvars)
 
   for ( int ncvarid = 0; ncvarid < nvars; ncvarid++ )
     {
-      if ( ncvars[ncvarid].stdname[0] && strcmp(ncvars[ncvarid].stdname, "forecast_period") == 0 )
-        {
-          leadtime_id = ncvarid;
-          break;
-        }
+      if ( ncvars[ncvarid].ndims == 1 )
+        if ( ncvars[ncvarid].stdname[0] && strcmp(ncvars[ncvarid].stdname, "forecast_period") == 0 )
+          {
+            leadtime_id = ncvarid;
+            break;
+          }
     }
 
   return leadtime_id;
diff --git a/src/stream_cdf_o.c b/src/stream_cdf_o.c
index 04c11add4a59392b9734833a6c9efcd1bd8f9134..9e5527eb3809ab098d3b996860171f16cb2c242b 100644
--- a/src/stream_cdf_o.c
+++ b/src/stream_cdf_o.c
@@ -547,7 +547,7 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
             }
           if ( pbounds )
             {
-              size_t nvertex = 2;
+              size_t nvertex = gridInqNvertex(gridID);
               if ( nc_inq_dimid(fileID, bndsName, &nvdimID) != NC_NOERR )
                 cdf_def_dim(fileID, bndsName, nvertex, &nvdimID);
             }
@@ -1414,6 +1414,67 @@ void cdfDefZaxisUUID(stream_t *streamptr, int zaxisID)
     }
 }
 
+static
+void cdfDefZaxisChar(stream_t *streamptr, int zaxisID, char *axisname, int *dimID, size_t dimlen, int zaxisindex)
+{
+  int fileID  = streamptr->fileID;
+  int ncvarID = CDI_UNDEFID;
+  if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
+
+  /* Check StrlenID */
+  char strlen[7] = "strlen\0";
+  size_t clen = (size_t) zaxisInqCLen(zaxisID);
+  if ( clen == 0 )
+    Error("Maximal string length value is 0.\nA given character axis requires a dimension to save the maximal string length.");
+  int strlenID = CDI_UNDEFID;
+  strlenID = checkDimName(fileID, clen, strlen);
+
+  if ( strlenID == CDI_UNDEFID ) cdf_def_dim(fileID, strlen, clen, &strlenID);
+
+  /* Check 'areatype'dimID */
+  char dimname[CDI_MAX_NAME+3]; dimname[0] = 0;
+  cdiZaxisInqKeyStr(zaxisID, CDI_KEY_DIMNAME, CDI_MAX_NAME, dimname);
+  *dimID = checkDimName(fileID, dimlen, dimname);
+  if ( !(dimlen > 0) )
+    Error("No strings delivered for a character axis.");
+  if ( dimname[0] == 0 ) { memcpy(dimname, "area_type", 10); dimname[10] = 0; }
+
+  if ( *dimID == CDI_UNDEFID ) cdf_def_dim(fileID, dimname, dimlen, dimID);
+
+  int dimIDs[2];
+  dimIDs[0] = *dimID;
+  dimIDs[1] = strlenID;
+
+  /* Get Stringvalues */
+  char **cvals = zaxisInqCValsPtr(zaxisID);
+
+  if ( cvals )
+    {
+      /* Define variable and its attributes */
+      cdf_def_var(fileID, axisname, NC_CHAR, 2, dimIDs, &ncvarID);
+
+      cdfPutGridStdAtts(fileID, ncvarID, zaxisID, 'Z', &gridInqsZ);
+      cdf_put_att_text(fileID, ncvarID, "axis", 1, "Z");
+      cdfDefineAttributes(zaxisID, CDI_GLOBAL, fileID, ncvarID);
+
+      streamptr->nczvarID[zaxisindex] = ncvarID;
+      cdf_enddef(fileID);
+
+      /* Write Stringvalues */
+      size_t start[2], count[2];
+      start[1] = 0;
+      count[0] = 1;
+      count[1] = clen;
+      for ( size_t i = 0; i < dimlen; i++ )
+        {
+          start[0] = i;
+          nc_put_vara_text(fileID, ncvarID, start, count, cvals[i]);
+        }
+    }
+
+  streamptr->ncmode = 2;
+}
+
 static
 void cdfDefZaxis(stream_t *streamptr, int zaxisID)
 {
@@ -1487,6 +1548,8 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
           cdfDefineAttributes(zaxisID, CDI_GLOBAL, fileID, ncvarid);
           if ( natts > 0 && streamptr->ncmode == 2 ) cdf_enddef(fileID);
         }
+      else if ( type == ZAXIS_CHAR )
+        cdfDefZaxisChar(streamptr, zaxisID, axisname, &dimID, dimlen, zaxisindex);
       else
         {
           dimID = checkDimName(fileID, dimlen, dimname);
@@ -1581,7 +1644,7 @@ void cdf_def_mapping(stream_t *streamptr, int gridID)
       cdiGridInqKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, gmapvarname);
 
       int fileID = streamptr->fileID;
-      cdf_redef(fileID);
+      if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
 
       int ncvarid;
       int ncerrcode = nc_def_var(fileID, gmapvarname, (nc_type) NC_INT, 0, NULL, &ncvarid);
@@ -1843,8 +1906,7 @@ void cdfDefGrid(stream_t *streamptr, int gridID, int gridindex)
         }
       else
         {
-          int ndims = !( gridtype == GRID_LONLAT && size == 1
-                         && gridInqHasDims(gridID) == FALSE );
+          int ndims = !(gridtype == GRID_LONLAT && size == 1 && !gridInqHasDims(gridID));
 
           if ( gridInqXsize(gridID) > 0 ) cdfDefXaxis(streamptr, gridID, gridindex, ndims);
           if ( gridInqYsize(gridID) > 0 ) cdfDefYaxis(streamptr, gridID, gridindex, ndims);
diff --git a/src/stream_cgribex.c b/src/stream_cgribex.c
index c1166cc42e5ca99e0111ead5b1135fce9a969cd8..3fd9cb2374433683fc1e8a998ca68ee952e9310e 100644
--- a/src/stream_cgribex.c
+++ b/src/stream_cgribex.c
@@ -517,10 +517,13 @@ void cgribexDecodeHeader(int *isec0, int *isec1, int *isec2, double *fsec2,
   int ipunp = 0, iword = 0;
 
   memset(isec1, 0, 256*sizeof(int));
+  memset(isec2, 0, 32*sizeof(int));
 
   gribExDP(isec0, isec1, isec2, fsec2, isec3, fsec3, isec4, fsec4,
 	   ipunp, (int *) gribbuffer, recsize, &iword, "J", iret);
 
+  if ( !(ISEC1_Sec2Or3Flag & 128) ) isec2[0] = -1; // default generic grid
+
   *lmv = 0;
 
   if ( ISEC1_CenterID == 215 && (isec1[34] != 0 && isec1[34] != 255) )
@@ -577,7 +580,7 @@ cgribexScanTsFixNtsteps(stream_t *streamptr, off_t recpos)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 }
@@ -652,7 +655,7 @@ int cgribexScanTimestep1(stream_t *streamptr)
     }
 
   unsigned nrecs = 0;
-  while ( TRUE )
+  while ( true )
     {
       recsize = gribGetSize(fileID);
       recpos  = fileGetPos(fileID);
@@ -871,7 +874,7 @@ int cgribexScanTimestep2(stream_t * streamptr)
 
   int nrecs_scanned = nrecords;
   int rindex = 0;
-  while ( TRUE )
+  while ( true )
     {
       if ( rindex > nrecords ) break;
 
@@ -976,7 +979,7 @@ int cgribexScanTimestep2(stream_t * streamptr)
 	    }
 	  else
 	    {
-	      streamptr->tsteps[tsID].records[recID].used = TRUE;
+	      streamptr->tsteps[tsID].records[recID].used = true;
 	      streamptr->tsteps[tsID].recIDs[rindex] = recID;
 	    }
 	}
@@ -991,7 +994,7 @@ int cgribexScanTimestep2(stream_t * streamptr)
 	    }
 	  else
 	    {
-	      streamptr->tsteps[tsID].records[recID].used = TRUE;
+	      streamptr->tsteps[tsID].records[recID].used = true;
 	      streamptr->tsteps[tsID].recIDs[rindex] = recID;
 	    }
 	}
@@ -1114,7 +1117,7 @@ int cgribexScanTimestep(stream_t * streamptr)
 
       nrecs_scanned = streamptr->tsteps[0].nallrecs + streamptr->tsteps[1].nrecs*(tsID-1);
       rindex = 0;
-      while ( TRUE )
+      while ( true )
 	{
 	  if ( rindex > nrecs ) break;
 
@@ -1227,7 +1230,7 @@ int cgribexScanTimestep(stream_t * streamptr)
 
 	  if ( cdiInventoryMode == 1 )
 	    {
-	      streamptr->tsteps[tsID].records[recID].used = TRUE;
+	      streamptr->tsteps[tsID].records[recID].used = true;
 	      streamptr->tsteps[tsID].recIDs[rindex] = recID;
 	    }
 	  else
@@ -1246,7 +1249,7 @@ int cgribexScanTimestep(stream_t * streamptr)
 		}
 	      else
 		{
-		  streamptr->tsteps[tsID].records[recID].used = TRUE;
+		  streamptr->tsteps[tsID].records[recID].used = true;
 		  streamptr->tsteps[tsID].recIDs[rindex] = recID;
 		}
 	    }
@@ -1291,7 +1294,7 @@ int cgribexScanTimestep(stream_t * streamptr)
 	  if ( tsID != streamptr->rtsteps )
 	    Error("Internal error. tsID = %d", tsID);
 
-	  streamptr->tsteps[tsID-1].next   = 1;
+	  streamptr->tsteps[tsID-1].next   = true;
 	  streamptr->tsteps[tsID].position = recpos;
 	}
 
@@ -1341,10 +1344,7 @@ int cgribexDecode(int memtype, void *gribbuffer, int gribsize, void *data, long
     gribExDP(isec0, isec1, isec2, fsec2, isec3, fsec3, isec4, (double*) data,
              (int) datasize, (int*) gribbuffer, gribsize, &iword, hoper, &iret);
 
-  if ( ISEC1_Sec2Or3Flag & 64 )
-    *nmiss = ISEC4_NumValues - ISEC4_NumNonMissValues;
-  else
-    *nmiss = 0;
+  *nmiss = (ISEC1_Sec2Or3Flag & 64) ? ISEC4_NumValues - ISEC4_NumNonMissValues : 0;
 
   if ( ISEC1_CenterID == 215 && (isec1[34] != 0 && isec1[34] != 255) )
     {
@@ -1672,7 +1672,7 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
         }
     }
 
-  ISEC2_Reduced  = FALSE;
+  ISEC2_Reduced  = false;
   ISEC2_ScanFlag = 0;
 
   switch (gridtype)
@@ -1697,7 +1697,7 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
 
 	if ( gridtype == GRID_GAUSSIAN_REDUCED )
 	  {
-	    ISEC2_Reduced = TRUE;
+	    ISEC2_Reduced = true;
 	    nlon = 0;
 	    gridInqRowlon(gridID, ISEC2_RowLonPtr);
 	  }
@@ -1855,10 +1855,15 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
 	ISEC2_GME_BFlag  = 0;
 	break;
       }
+    case GRID_GENERIC:
+      {
+        ISEC1_Sec2Or3Flag = 0;
+	break;
+      }
     default:
       {
-	Warning("The CGRIBEX library can not store fields on the used grid!");
-	Error("Unsupported grid type: %s", gridNamePtr(gridtype));
+        ISEC1_Sec2Or3Flag = 0;
+	Warning("CGRIBEX library doesn't support %s grids, grid information will be lost!", gridNamePtr(gridtype));
 	break;
       }
     }
diff --git a/src/stream_ext.c b/src/stream_ext.c
index ca94ac668c27f67e4c9cd36c25b2efcf74c31a4e..4d5a83e85fb866d446e5260561c36c9d5118ca2a 100644
--- a/src/stream_ext.c
+++ b/src/stream_ext.c
@@ -236,7 +236,7 @@ void extScanTimestep1(stream_t *streamptr)
   int fileID = streamptr->fileID;
 
   int nrecs = 0;
-  while ( TRUE )
+  while ( true )
     {
       recpos = fileGetPos(fileID);
       int status = extRead(fileID, extp);
@@ -320,7 +320,7 @@ void extScanTimestep1(stream_t *streamptr)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -421,7 +421,7 @@ int extScanTimestep2(stream_t *streamptr)
 		}
 	      else
 		{
-		  streamptr->tsteps[tsID].records[recID].used = TRUE;
+		  streamptr->tsteps[tsID].records[recID].used = true;
 		  streamptr->tsteps[tsID].recIDs[rindex] = recID;
 		}
 	      break;
@@ -478,7 +478,7 @@ int extScanTimestep2(stream_t *streamptr)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -599,7 +599,7 @@ long extScanTimestep(stream_t *streamptr)
 	  if ( tsID != streamptr->rtsteps )
 	    Error("Internal error. tsID = %d", tsID);
 
-	  streamptr->tsteps[tsID-1].next   = 1;
+	  streamptr->tsteps[tsID-1].next   = true;
 	  streamptr->tsteps[tsID].position = recpos;
 	}
 
diff --git a/src/stream_gribapi.c b/src/stream_gribapi.c
index dc09b5a26c8ffbf1b4cb3c2b8f7b9acf2cb23da6..156bb91048c5fb879667a37c41e33fa503588189 100644
--- a/src/stream_gribapi.c
+++ b/src/stream_gribapi.c
@@ -207,7 +207,7 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
 	}
 
       {
-	static int lprint = TRUE;
+	static bool lprint = true;
 	extern int grib_calendar;
 	int ryear, rmonth, rday, rhour, rminute, rsecond;
 	int julday, secofday;
@@ -235,7 +235,7 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
                 if ( lprint )
                   {
                     Warning("Time unit %d unsupported", timeUnits);
-                    lprint = FALSE;
+                    lprint = false;
                   }
                 break;
               }
@@ -819,8 +819,8 @@ int gribapiScanTimestep1(stream_t * streamptr)
   size_t buffersize = 0;
   DateTime datetime0 = { .date = 10101, .time = 0 };
   int nrecs_scanned = 0;        //Only used for debug output.
-  int warn_time = TRUE;
-  // int warn_numavg = TRUE;
+  bool warn_time = true;
+  // bool warn_numavg = true;
   int rdate = 0, rtime = 0, tunit = 0, fcast = 0;
   grib_handle *gh = NULL;
 
@@ -835,7 +835,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
   int fileID = streamptr->fileID;
 
   unsigned nrecs = 0;
-  while ( TRUE )
+  while ( true )
     {
       int level1 = 0, level2 = 0;
       size_t recsize = gribGetSize(fileID);
@@ -905,7 +905,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
           else if ( result == CHECKTIME_INCONSISTENT && warn_time )
             {
               gribWarning("Inconsistent verification time!", nrecs_scanned, tsID+1, varname, param, level1, level2);
-              warn_time = FALSE;
+              warn_time = false;
             }
           assert(result == CHECKTIME_OK || result == CHECKTIME_INCONSISTENT);
         }
@@ -916,7 +916,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
             {
               Message("Change numavg from %d to %d not allowed!",
                       taxis->numavg, ISEC1_AvgNum);
-              warn_numavg = FALSE;
+              warn_numavg = false;
             }
           else
             {
@@ -994,7 +994,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
       if ( tsID != streamptr->rtsteps )
         Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -1021,7 +1021,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
   DateTime datetime0 = { LONG_MIN, LONG_MIN };
   // int gridID;
   int recID;
-  //  int warn_numavg = TRUE;
+  //  bool warn_numavg = true;
   grib_handle *gh = NULL;
 
   streamptr->curTsID = 1;
@@ -1057,7 +1057,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
 
   int nrecs_scanned = nrecords; //Only used for debug output
   int rindex = 0;
-  while ( TRUE )
+  while ( true )
     {
       if ( rindex > nrecords ) break;
 
@@ -1122,7 +1122,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
 	  if (  taxis->numavg && warn_numavg &&
 		(taxis->numavg != ISEC1_AvgNum) )
 	    {
-	      warn_numavg = FALSE;
+	      warn_numavg = false;
 	    }
 	  else
 	    {
@@ -1158,7 +1158,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
 	    }
 	}
 
-      streamptr->tsteps[tsID].records[recID].used = TRUE;
+      streamptr->tsteps[tsID].records[recID].used = true;
       streamptr->tsteps[tsID].recIDs[rindex] = recID;
 
       if ( CDI_Debug )
@@ -1225,7 +1225,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -1239,7 +1239,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
 int gribapiScanTimestep(stream_t * streamptr)
 {
   int vrecID, recID;
-  //int warn_numavg = TRUE;
+  //bool warn_numavg = true;
   int nrecs = 0;
   int vlistID = streamptr->vlistID;
 
@@ -1278,7 +1278,7 @@ int gribapiScanTimestep(stream_t * streamptr)
       DateTime datetime0 = { LONG_MIN, LONG_MIN };
       grib_handle *gh = NULL;
       char varname[256];
-      while ( TRUE )
+      while ( true )
 	{
 	  if ( rindex > nrecs ) break;
 
@@ -1350,7 +1350,7 @@ int gribapiScanTimestep(stream_t * streamptr)
 	      if (  taxis->numavg && warn_numavg &&
 		   (taxis->numavg != ISEC1_AvgNum) )
 		{
-		  warn_numavg = FALSE;
+		  warn_numavg = false;
 		}
 	      else
 		{
@@ -1396,7 +1396,7 @@ int gribapiScanTimestep(stream_t * streamptr)
 		}
 	    }
 
-          streamptr->tsteps[tsID].records[recID].used = TRUE;
+          streamptr->tsteps[tsID].records[recID].used = true;
           streamptr->tsteps[tsID].recIDs[rindex] = recID;
 
 	  if ( CDI_Debug )
@@ -1446,7 +1446,7 @@ int gribapiScanTimestep(stream_t * streamptr)
 	  if ( tsID != streamptr->rtsteps )
 	    Error("Internal error. tsID = %d", tsID);
 
-	  streamptr->tsteps[tsID-1].next   = 1;
+	  streamptr->tsteps[tsID-1].next   = true;
 	  streamptr->tsteps[tsID].position = recpos;
 	}
 
@@ -3112,7 +3112,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
           {
             //DR: Fix for multi-level fields (otherwise only the 1st level is correct)
             if ( zaxisInqSize(zaxisID)==(levelID+1) )
-              vlistptr->vars[varID].opt_grib_kvpair[i].update = FALSE;
+              vlistptr->vars[varID].opt_grib_kvpair[i].update = false;
 
             if (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_double)
               {
@@ -3161,7 +3161,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
   gribHandleDelete(gh);
 #endif
 
-  gc->init = TRUE;
+  gc->init = true;
 
   return recsize;
 }
diff --git a/src/stream_ieg.c b/src/stream_ieg.c
index 13a53affad4152aa73fb05306bf7362d2ef78725..8527ac8cbedd489dab054b74b5e9288e5b3fafe7 100644
--- a/src/stream_ieg.c
+++ b/src/stream_ieg.c
@@ -743,7 +743,7 @@ void iegScanTimestep1(stream_t *streamptr)
   int fileID = streamptr->fileID;
 
   int nrecs = 0;
-  while ( TRUE )
+  while ( true )
     {
       recpos = fileGetPos(fileID);
       int status = iegRead(fileID, iegp);
@@ -835,7 +835,7 @@ void iegScanTimestep1(stream_t *streamptr)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -938,7 +938,7 @@ int iegScanTimestep2(stream_t *streamptr)
 		}
 	      else
 		{
-		  streamptr->tsteps[tsID].records[recID].used = TRUE;
+		  streamptr->tsteps[tsID].records[recID].used = true;
 		  streamptr->tsteps[tsID].recIDs[rindex] = recID;
 		}
 	      break;
@@ -997,7 +997,7 @@ int iegScanTimestep2(stream_t *streamptr)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -1125,7 +1125,7 @@ long iegScanTimestep(stream_t *streamptr)
 	  if ( tsID != streamptr->rtsteps )
 	    Error("Internal error. tsID = %d", tsID);
 
-	  streamptr->tsteps[tsID-1].next   = 1;
+	  streamptr->tsteps[tsID-1].next   = true;
 	  streamptr->tsteps[tsID].position = recpos;
 	}
 
diff --git a/src/stream_record.c b/src/stream_record.c
index c41d54ac9a08de6874e34b3a9909d40a957697ce..f6d44a2c8ee3b3fd025767d2356fe8caff889fbf 100644
--- a/src/stream_record.c
+++ b/src/stream_record.c
@@ -24,7 +24,7 @@ void recordInitEntry(record_t *record)
   record->size     = 0;
   record->param    = 0;
   record->ilevel   = CDI_UNDEFID;
-  record->used     = FALSE;
+  record->used     = false;
   record->varID    = CDI_UNDEFID;
   record->levelID  = CDI_UNDEFID;
   memset(record->varname, 0, sizeof(record->varname));
@@ -366,7 +366,7 @@ void cdi_create_records(stream_t *streamptr, int tsID)
                 {
                   destTstep->records[recID].position = CDI_UNDEFID;
                   destTstep->records[recID].size     = 0;
-                  destTstep->records[recID].used     = FALSE;
+                  destTstep->records[recID].used     = false;
                 }
             }
 	}
diff --git a/src/stream_srv.c b/src/stream_srv.c
index 3bce61f7c2dc45974a20e78eac3317a362cabcfe..f4d28fa0deacd8ebeb239f897c8651e913b4ecb8 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -241,7 +241,7 @@ void srvScanTimestep1(stream_t *streamptr)
   int fileID = streamptr->fileID;
 
   int nrecs = 0;
-  while ( TRUE )
+  while ( true )
     {
       int header[8];
       recpos = fileGetPos(fileID);
@@ -324,7 +324,7 @@ void srvScanTimestep1(stream_t *streamptr)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -420,7 +420,7 @@ int srvScanTimestep2(stream_t *streamptr)
 		}
 	      else
 		{
-		  streamptr->tsteps[tsID].records[recID].used = TRUE;
+		  streamptr->tsteps[tsID].records[recID].used = true;
 		  streamptr->tsteps[tsID].recIDs[rindex] = recID;
 		}
 	      break;
@@ -477,7 +477,7 @@ int srvScanTimestep2(stream_t *streamptr)
       if ( tsID != streamptr->rtsteps )
 	Error("Internal error. tsID = %d", tsID);
 
-      streamptr->tsteps[tsID-1].next   = TRUE;
+      streamptr->tsteps[tsID-1].next   = true;
       streamptr->tsteps[tsID].position = recpos;
     }
 
@@ -595,7 +595,7 @@ long srvScanTimestep(stream_t *streamptr)
 	  if ( tsID != streamptr->rtsteps )
 	    Error("Internal error. tsID = %d", tsID);
 
-	  streamptr->tsteps[tsID-1].next   = 1;
+	  streamptr->tsteps[tsID-1].next   = true;
 	  streamptr->tsteps[tsID].position = recpos;
 	}
 
diff --git a/src/table.c b/src/table.c
index 05c62e3aa49eda9a725e8f756e1716ae3f259e68..a6ac127ee4a3d1236016c771d6d6042090e728ba 100644
--- a/src/table.c
+++ b/src/table.c
@@ -22,16 +22,16 @@
 
 typedef struct
 {
-  int    used;
+  bool   used;
   int    npars;
-  PAR   *pars;
   int    modelID;
   int    number;
   char  *name;
+  param_type *pars;
 }
-PARTAB;
+paramtab_type;
 
-static PARTAB parTable[MAX_TABLE];
+static paramtab_type parTable[MAX_TABLE];
 static int  parTableSize = MAX_TABLE;
 static int  parTableNum  = 0;
 static int  ParTableInit = 0;
@@ -41,16 +41,16 @@ static char *tablePath = NULL;
 static void tableDefModelID(int tableID, int modelID);
 static void tableDefNum(int tableID, int tablenum);
 
-
-void tableDefEntry(int tableID, int id, const char *name,
+static
+void tableDefEntry(int tableID, int id, int ltype, const char *name,
 		   const char *longname, const char *units)
 {
-  int item;
-
   if ( tableID >= 0 && tableID < MAX_TABLE && parTable[tableID].used) { } else
     Error("Invalid table ID %d", tableID);
-  item = parTable[tableID].npars++;
+
+  int item = parTable[tableID].npars++;
   parTable[tableID].pars[item].id       = id;
+  parTable[tableID].pars[item].ltype    = ltype;
   parTable[tableID].pars[item].dupflags = 0;
   parTable[tableID].pars[item].name     = NULL;
   parTable[tableID].pars[item].longname = NULL;
@@ -73,11 +73,9 @@ void tableDefEntry(int tableID, int id, const char *name,
     }
 }
 
-static void tableLink(int tableID, const PAR *pars, int npars)
+static void tableLink(int tableID, const param_type *pars, int npars)
 {
-  int item;
-
-  for ( item = 0; item < npars; item++ )
+  for ( int item = 0; item < npars; item++ )
     {
       parTable[tableID].pars[item].id       = pars[item].id;
       parTable[tableID].pars[item].dupflags = 0;
@@ -91,7 +89,7 @@ static void tableLink(int tableID, const PAR *pars, int npars)
 
 static void parTableInitEntry(int tableID)
 {
-  parTable[tableID].used    = 0;
+  parTable[tableID].used    = false;
   parTable[tableID].pars    = NULL;
   parTable[tableID].npars   = 0;
   parTable[tableID].modelID = CDI_UNDEFID;
@@ -101,9 +99,7 @@ static void parTableInitEntry(int tableID)
 
 static void tableGetPath(void)
 {
-  char *path;
-
-  path = getenv("TABLEPATH");
+  char *path = getenv("TABLEPATH");
 
   if ( path ) tablePath = strdupx(path);
   /*
@@ -165,10 +161,10 @@ static int tableNewEntry()
   if ( tableID == parTableSize )
     Error("no more entries!");
 
-  parTable[tableID].used = 1;
+  parTable[tableID].used = true;
   parTableNum++;
 
-  return (tableID);
+  return tableID;
 }
 
 static int
@@ -189,9 +185,9 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
       name[len] = 0;
     }
   else
-    return (0);
+    return 0;
 
-  if ( pline[0] == 0 ) return (0);
+  if ( pline[0] == 0 ) return 0;
 
   /* Format 1 : code name add mult longname [units] */
   /* FIXME: successful parse isn't verified */
@@ -228,7 +224,7 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
 	  pstart++;
 	  while ( isspace((int) *pstart) ) pstart++;
 	  pend = strchr(pstart, ']');
-	  if ( ! pend ) return (0);
+	  if ( ! pend ) return 0;
 	  pend--;
 	  while ( isspace((int) *pend) ) pend--;
 	  len = (size_t)(pend - pstart + 1);
@@ -240,7 +236,7 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
 	}
     }
 
-  return (0);
+  return 0;
 }
 
 static int
@@ -266,7 +262,7 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
               memcpy(name, pline, len);
               name[len] = 0;
             }
-          return (0);
+          return 0;
         }
       else
         {
@@ -314,24 +310,22 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
       units[len] = 0;
     }
 
-  return (0);
+  return 0;
 }
 
+
 int tableRead(const char *tablefile)
 {
   char line[1024], *pline;
   int lnr = 0;
-  int id;
   char name[256], longname[256], units[256];
-  int tableID = CDI_UNDEFID;
   int err;
-  char *tablename;
-  FILE *tablefp;
+  int tableID = CDI_UNDEFID;
 
-  tablefp = fopen(tablefile, "r");
-  if ( tablefp == NULL ) return (tableID);
+  FILE *tablefp = fopen(tablefile, "r");
+  if ( tablefp == NULL ) return tableID;
 
-  tablename = (char* )strrchr(tablefile, '/');
+  char *tablename = (char* )strrchr(tablefile, '/');
   if ( tablename == 0 ) tablename = (char *) tablefile;
   else                  tablename++;
 
@@ -342,7 +336,8 @@ int tableRead(const char *tablefile)
       size_t len = strlen(line);
       if ( line[len-1] == '\n' ) line[len-1] = '\0';
       lnr++;
-      id       = CDI_UNDEFID;
+      int id      = CDI_UNDEFID;
+      int ltype   = CDI_UNDEFID;
       name[0]     = 0;
       longname[0] = 0;
       units[0]    = 0;
@@ -360,6 +355,21 @@ int tableRead(const char *tablefile)
 
       while ( isdigit((int) *pline) ) pline++;
 
+      if ( *pline == ';' || *pline == ':' )
+        {
+          pline++;
+          ltype = atoi(pline);
+          while ( isdigit((int) *pline) ) pline++;
+
+          if ( *pline == ';' || *pline == ':' )
+            {
+              pline++;
+              while ( isdigit((int) *pline) ) pline++;
+            }
+        }
+
+      while ( isdigit((int) *pline) ) pline++;
+
       if ( strchr(pline, '|') )
 	err = decodeForm2(pline, name, longname, units);
       else
@@ -369,12 +379,13 @@ int tableRead(const char *tablefile)
 
       if ( name[0] == 0 ) sprintf(name, "var%d", id);
 
-      tableDefEntry(tableID, id, name, longname, units);
+      tableDefEntry(tableID, id, ltype, name, longname, units);
     }
 
-  return (tableID);
+  return tableID;
 }
 
+
 static int tableFromEnv(int modelID, int tablenum)
 {
   char tablename[256] = {'\0'};
@@ -421,7 +432,8 @@ static int tableFromEnv(int modelID, int tablenum)
     }
   /* printf("tableID = %d %s\n", tableID, tablefile); */
   Free(tablefile);
-  return (tableID);
+
+  return tableID;
 }
 
 int tableInq(int modelID, int tablenum, const char *tablename)
@@ -501,7 +513,7 @@ int tableInq(int modelID, int tablenum, const char *tablename)
 	  Message("tableID = %d tablename = %s", tableID, tablename);
     }
 
-  return (tableID);
+  return tableID;
 }
 
 int tableDef(int modelID, int tablenum, const char *tablename)
@@ -522,22 +534,25 @@ int tableDef(int modelID, int tablenum, const char *tablename)
       if ( tablename )
 	parTable[tableID].name = strdupx(tablename);
 
-      parTable[tableID].pars = (PAR *) Malloc(MAX_PARS * sizeof(PAR));
+      parTable[tableID].pars = (param_type *) Malloc(MAX_PARS * sizeof(param_type));
     }
 
-  return (tableID);
+  return tableID;
 }
 
-static void tableDefModelID(int tableID, int modelID)
+static
+void tableDefModelID(int tableID, int modelID)
 {
   parTable[tableID].modelID = modelID;
 }
 
-static void tableDefNum(int tableID, int tablenum)
+static
+void tableDefNum(int tableID, int tablenum)
 {
   parTable[tableID].number  = tablenum;
 }
 
+
 int tableInqNum(int tableID)
 {
   int number = 0;
@@ -545,9 +560,10 @@ int tableInqNum(int tableID)
   if ( tableID >= 0 && tableID < MAX_TABLE )
     number = parTable[tableID].number;
 
-  return (number);
+  return number;
 }
 
+
 int tableInqModel(int tableID)
 {
   int modelID = -1;
@@ -555,9 +571,10 @@ int tableInqModel(int tableID)
   if ( tableID >= 0 && tableID < MAX_TABLE )
     modelID = parTable[tableID].modelID;
 
-  return (modelID);
+  return modelID;
 }
 
+
 static void partabCheckID(int item)
 {
   if ( item < 0 || item >= parTableSize )
@@ -567,6 +584,7 @@ static void partabCheckID(int item)
     Error("item %d name undefined!", item);
 }
 
+
 const char *tableInqNamePtr(int tableID)
 {
   const char *tablename = NULL;
@@ -580,15 +598,14 @@ const char *tableInqNamePtr(int tableID)
     if ( parTable[tableID].name )
       tablename = parTable[tableID].name;
 
-  return (tablename);
+  return tablename;
 }
 
+
 void tableWrite(const char *ptfile, int tableID)
 {
-  int item, npars;
   size_t maxname = 4, maxlname = 10, maxunits = 2;
-  FILE *ptfp;
-  int tablenum, modelID, instID = CDI_UNDEFID;
+  int instID = CDI_UNDEFID;
   int center = 0, subcenter = 0;
   const char *instnameptr = NULL, *modelnameptr = NULL;
 
@@ -603,11 +620,11 @@ void tableWrite(const char *ptfile, int tableID)
 
   partabCheckID(tableID);
 
-  ptfp = fopen(ptfile, "w");
+  FILE *ptfp = fopen(ptfile, "w");
 
-  npars = parTable[tableID].npars;
+  int npars = parTable[tableID].npars;
 
-  for ( item = 0; item < npars; item++)
+  for ( int item = 0; item < npars; item++)
     {
       if ( parTable[tableID].pars[item].name )
 	{
@@ -628,8 +645,8 @@ void tableWrite(const char *ptfile, int tableID)
 	}
     }
 
-  tablenum = tableInqNum(tableID);
-  modelID = parTable[tableID].modelID;
+  int tablenum = tableInqNum(tableID);
+  int modelID = parTable[tableID].modelID;
   if ( modelID != CDI_UNDEFID )
     {
       modelnameptr = modelInqNamePtr(modelID);
@@ -668,8 +685,8 @@ void tableWrite(const char *ptfile, int tableID)
 	  (int)maxname,  "name",
 	  (int)maxlname, "title",
 	  (int)maxunits, "units");
-	  
-  for ( item = 0; item < npars; item++)
+
+  for ( int item = 0; item < npars; item++)
     {
       const char *name = parTable[tableID].pars[item].name,
         *longname = parTable[tableID].pars[item].longname,
@@ -688,21 +705,9 @@ void tableWrite(const char *ptfile, int tableID)
 }
 
 
-void tableWriteC(const char *filename, int tableID)
-{
-  FILE *ptfp = fopen(filename, "w");
-  if (!ptfp)
-    Error("failed to open file \"%s\"!", filename);
-  if ( CDI_Debug )
-    Message("write parameter table %d to %s", tableID, filename);
-  tableFWriteC(ptfp, tableID);
-  fclose(ptfp);
-}
-
 void tableFWriteC(FILE *ptfp, int tableID)
 {
   const char chelp[] = "";
-  int item, npars;
   size_t maxname = 0, maxlname = 0, maxunits = 0;
   char tablename[256];
 
@@ -715,9 +720,9 @@ void tableFWriteC(FILE *ptfp, int tableID)
 
   partabCheckID(tableID);
 
-  npars = parTable[tableID].npars;
+  int npars = parTable[tableID].npars;
 
-  for ( item = 0; item < npars; item++)
+  for ( int item = 0; item < npars; item++)
     {
       if ( parTable[tableID].pars[item].name )
 	{
@@ -745,16 +750,16 @@ void tableFWriteC(FILE *ptfp, int tableID)
     for (size_t i = 0; i < len; i++ )
       if ( tablename[i] == '.' ) tablename[i] = '_';
   }
-  fprintf(ptfp, "static const PAR %s[] = {\n", tablename);
+  fprintf(ptfp, "static const param_type %s[] = {\n", tablename);
 
-  for ( item = 0; item < npars; item++ )
+  for ( int item = 0; item < npars; item++ )
     {
       size_t len = strlen(parTable[tableID].pars[item].name),
         llen = parTable[tableID].pars[item].longname
         ? strlen(parTable[tableID].pars[item].longname) : 0,
         ulen = parTable[tableID].pars[item].units
         ? strlen(parTable[tableID].pars[item].units) : 0;
-      fprintf(ptfp, "  {%4d, 0, \"%s\", %-*s%c%s%s, %-*s%c%s%s %-*s},\n",
+      fprintf(ptfp, "  {%4d, -1, 0, \"%s\", %-*s%c%s%s, %-*s%c%s%s %-*s},\n",
 	      parTable[tableID].pars[item].id,
 	      parTable[tableID].pars[item].name, (int)(maxname-len), chelp,
               llen?'"':' ',
@@ -771,200 +776,62 @@ void tableFWriteC(FILE *ptfp, int tableID)
 }
 
 
-int tableInqParCode(int tableID, char *varname, int *code)
-{
-  int err = 1;
-
-  if ( tableID != CDI_UNDEFID && varname != NULL )
-    {
-      int npars = parTable[tableID].npars;
-      for ( int item = 0; item < npars; item++ )
-	{
-	  if ( parTable[tableID].pars[item].name
-               && strcmp(parTable[tableID].pars[item].name, varname) == 0 )
-            {
-              *code = parTable[tableID].pars[item].id;
-              err = 0;
-              break;
-            }
-	}
-    }
-
-  return (err);
-}
-
-
-int tableInqParName(int tableID, int code, char *varname)
-{
-  int err = 1;
-
-  if ( tableID >= 0 && tableID < MAX_TABLE )
-    {
-      int npars = parTable[tableID].npars;
-      for ( int item = 0; item < npars; item++ )
-	{
-	  if ( parTable[tableID].pars[item].id == code )
-	    {
-	      if ( parTable[tableID].pars[item].name )
-		strcpy(varname, parTable[tableID].pars[item].name);     //FIXME: This may overrun the supplied buffer!
-              err = 0;
-	      break;
-	    }
-	}
-    }
-  else if ( tableID == CDI_UNDEFID )
-    { }
-  else
-    Error("Invalid table ID %d", tableID);
-
-  return (err);
-}
-
-
-const char *tableInqParNamePtr(int tableID, int code)
-{
-  const char *name = NULL;
-
-  if ( tableID != CDI_UNDEFID )
-    {
-      int npars = parTable[tableID].npars;
-      for ( int item = 0; item < npars; item++ )
-	{
-	  if ( parTable[tableID].pars[item].id == code )
-	    {
-	      name = parTable[tableID].pars[item].name;
-	      break;
-	    }
-	}
-    }
-
-  return (name);
-}
-
-
-const char *tableInqParLongnamePtr(int tableID, int code)
-{
-  const char *longname = NULL;
-
-  if ( tableID != CDI_UNDEFID )
-    {
-      int npars = parTable[tableID].npars;
-      for ( int item = 0; item < npars; item++ )
-	{
-	  if ( parTable[tableID].pars[item].id == code )
-	    {
-	      longname = parTable[tableID].pars[item].longname;
-	      break;
-	    }
-	}
-    }
-
-  return (longname);
-}
-
-
-const char *tableInqParUnitsPtr(int tableID, int code)
-{
-  const char *units = NULL;
-
-  if ( tableID != CDI_UNDEFID )
-    {
-      int npars = parTable[tableID].npars;
-      for ( int item = 0; item < npars; item++ )
-	{
-	  if ( parTable[tableID].pars[item].id == code )
-	    {
-	      units = parTable[tableID].pars[item].units;
-	      break;
-	    }
-	}
-    }
-
-  return (units);
-}
-
-
-int tableInqParLongname(int tableID, int code, char *longname)
+void tableInqEntry(int tableID, int id, int ltype, char *name, char *longname, char *units)
 {
   if ( ((tableID >= 0) & (tableID < MAX_TABLE)) | (tableID == CDI_UNDEFID) ) { } else
     Error("Invalid table ID %d", tableID);
 
-  int err = 1;
-
   if ( tableID != CDI_UNDEFID )
     {
       int npars = parTable[tableID].npars;
       for ( int item = 0; item < npars; item++ )
 	{
-	  if ( parTable[tableID].pars[item].id == code )
+	  if ( parTable[tableID].pars[item].id == id &&
+               (parTable[tableID].pars[item].ltype == -1 || ltype == -1 ||
+                parTable[tableID].pars[item].ltype == ltype) )
 	    {
-	      if ( parTable[tableID].pars[item].longname )
+	      if ( name && parTable[tableID].pars[item].name )
+		strcpy(name, parTable[tableID].pars[item].name);
+	      if ( longname && parTable[tableID].pars[item].longname )
 		strcpy(longname, parTable[tableID].pars[item].longname);
-              err = 0;
+	      if ( units && parTable[tableID].pars[item].units )
+		strcpy(units, parTable[tableID].pars[item].units);
+
 	      break;
 	    }
 	}
     }
-
-  return (err);
 }
 
 
-int tableInqParUnits(int tableID, int code, char *units)
+int tableInqParCode(int tableID, char *varname, int *code)
 {
-
-  if ( ((tableID >= 0) & (tableID < MAX_TABLE)) | (tableID == CDI_UNDEFID) ) { } else
-    Error("Invalid table ID %d", tableID);
-
   int err = 1;
 
-  if ( tableID != CDI_UNDEFID )
+  if ( tableID != CDI_UNDEFID && varname != NULL )
     {
       int npars = parTable[tableID].npars;
       for ( int item = 0; item < npars; item++ )
 	{
-	  if ( parTable[tableID].pars[item].id == code )
-	    {
-	      if ( parTable[tableID].pars[item].units )
-		strcpy(units, parTable[tableID].pars[item].units);
+	  if ( parTable[tableID].pars[item].name
+               && strcmp(parTable[tableID].pars[item].name, varname) == 0 )
+            {
+              *code = parTable[tableID].pars[item].id;
               err = 0;
-	      break;
-	    }
+              break;
+            }
 	}
     }
 
-  return (err);
+  return err;
 }
 
 
-void tableInqPar(int tableID, int code, char *name, char *longname, char *units)
-{
-
-  if ( ((tableID >= 0) & (tableID < MAX_TABLE)) | (tableID == CDI_UNDEFID) ) { } else
-    Error("Invalid table ID %d", tableID);
-
-  int npars = parTable[tableID].npars;
-
-  for ( int item = 0; item < npars; item++ )
-    {
-      if ( parTable[tableID].pars[item].id == code )
-	{
-	  if ( parTable[tableID].pars[item].name )
-	    strcpy(name, parTable[tableID].pars[item].name);
-	  if ( parTable[tableID].pars[item].longname )
-	    strcpy(longname, parTable[tableID].pars[item].longname);
-	  if ( parTable[tableID].pars[item].units )
-	    strcpy(units, parTable[tableID].pars[item].units);
-	  break;
-	}
-    }
-}
-
 int tableInqNumber(void)
 {
   if ( ! ParTableInit ) parTableInit();
 
-  return (parTableNum);
+  return parTableNum;
 }
 /*
  * Local Variables:
diff --git a/src/table.h b/src/table.h
index 0c624f8458c13d9716e018182745b9d8f4c23fbc..bc4c2e40f4d69e3313fde6d3164132ff3a84e84b 100644
--- a/src/table.h
+++ b/src/table.h
@@ -1,1427 +1,1413 @@
 /* Automatically generated, do not edit! */
-#ifndef _TABLE_H
-#define _TABLE_H
-
-static const PAR echam4[] = {
-  {   4, 0, "precip",      "total precipitation",                      "m/s"      },
-  {  34, 0, "low_cld",     "low cloud",                                 NULL      },
-  {  35, 0, "mid_cld",     "mid cloud",                                 NULL      },
-  {  36, 0, "hih_cld",     "high cloud",                                NULL      },
-  { 129, 0, "geosp",       "surface geopotential (orography)",         "m^2/s^2"  },
-  { 130, 0, "t",           "temperature",                              "K"        },
-  { 131, 0, "u",           "u-velocity",                               "m/s"      },
-  { 132, 0, "v",           "v-velocity",                               "m/s"      },
-  { 133, 0, "sq",          "specific humidity",                        "kg/kg"    },
-  { 134, 0, "aps",         "Surface pressure",                         "Pa"       },
-  { 135, 0, "omega",       "vertical velocity",                        "Pa/s"     },
-  { 138, 0, "svo",         "vorticity",                                "1/s"      },
-  { 139, 0, "ts",          "surface temperature",                      "K"        },
-  { 140, 0, "ws",          "soil wetness",                             "m"        },
-  { 141, 0, "sn",          "snow depth",                               "m"        },
-  { 142, 0, "aprl",        "large scale precipitation",                "m/s"      },
-  { 143, 0, "aprc",        "convective  precipitation",                "m/s"      },
-  { 144, 0, "aprs",        "snow fall",                                "m/s"      },
-  { 145, 0, "vdis",        "boundary layer dissipation",               "W/m^2"    },
-  { 146, 0, "ahfs",        "surface sensible heat flux",               "W/m^2"    },
-  { 147, 0, "ahfl",        "surface latent heat flux",                 "W/m^2"    },
-  { 148, 0, "stream",      "streamfunction",                           "m^2/s"    },
-  { 149, 0, "velopot",     "velocity potential",                       "m^2/s"    },
-  { 151, 0, "slp",         "mean sea level pressure",                  "Pa"       },
-  { 152, 0, "lsp",         "log surface pressure",                      NULL      },
-  { 153, 0, "sx",          "liquid water content",                     "kg/kg"    },
-  { 155, 0, "sd",          "divergence",                               "1/s"      },
-  { 156, 0, "geopoth",     "geopotential height",                      "m"        },
-  { 157, 0, "rhumidity",   "relative humidity",                        "fraction" },
-  { 158, 0, "var158",      "tendency of surface pressure",             "Pa/s"     },
-  { 159, 0, "ustar3",      "ustar3",                                   "m^3/s^3"  },
-  { 160, 0, "runoff",      "surface runoff",                           "m/s"      },
-  { 161, 0, "alwc",        "liquid water content",                     "kg/kg"    },
-  { 162, 0, "aclc",        "cloud cover",                              "fraction" },
-  { 163, 0, "aclcv",       "total cloud cover",                        "fraction" },
-  { 164, 0, "aclcov",      "total cloud cover",                        "fraction" },
-  { 165, 0, "u10",         "10m u-velocity",                           "m/s"      },
-  { 166, 0, "v10",         "10m v-velocity",                           "m/s"      },
-  { 167, 0, "temp2",       "2m temperature",                           "K"        },
-  { 168, 0, "dew2",        "2m dew point temperature",                 "K"        },
-  { 169, 0, "tsurf",       "surface temperature",                      "K"        },
-  { 170, 0, "td",          "deep soil temperature",                    "K"        },
-  { 171, 0, "wind10",      "10m windspeed",                            "m/s"      },
-  { 172, 0, "slm",         "land sea mask",                            "fraction" },
-  { 173, 0, "az0",         "surface roughness length",                 "m"        },
-  { 174, 0, "alb",         "surface background albedo",                "fraction" },
-  { 175, 0, "albedo",      "surface albedo",                           "fraction" },
-  { 176, 0, "srads",       "net surface solar radiation",              "W/m^2"    },
-  { 177, 0, "trads",       "net surface thermal radiation",            "W/m^2"    },
-  { 178, 0, "srad0",       "net top solar radiation",                  "W/m^2"    },
-  { 179, 0, "trad0",       "top thermal radiation (OLR)",              "W/m^2"    },
-  { 180, 0, "ustr",        "surface u-stress",                         "Pa"       },
-  { 181, 0, "vstr",        "surface v-stress",                         "Pa"       },
-  { 182, 0, "evap",        "surface evaporation",                      "m/s"      },
-  { 183, 0, "tdcl",        "soil temperature",                         "K"        },
-  { 185, 0, "srafs",       "net surf. solar radiation   (clear sky)",  "W/m^2"    },
-  { 186, 0, "trafs",       "net surf. thermal radiation (clear sky)",  "W/m^2"    },
-  { 187, 0, "sraf0",       "net top solar radiation     (clear sky)",  "W/m^2"    },
-  { 188, 0, "traf0",       "net top thermal radiation   (clear sky)",  "W/m^2"    },
-  { 189, 0, "sclfs",       "surface solar cloud forcing",              "W/m^2"    },
-  { 190, 0, "tclfs",       "surface thermal cloud forcing",            "W/m^2"    },
-  { 191, 0, "sclf0",       "top solar cloud forcing",                  "W/m^2"    },
-  { 192, 0, "tclf0",       "top thermal cloud forcing",                "W/m^2"    },
-  { 193, 0, "wl",          "skin reservoir content",                   "m"        },
-  { 194, 0, "wlm1",        "skin reservoir content of plants",         "m"        },
-  { 195, 0, "ustrgw",      "u-gravity wave stress",                    "Pa"       },
-  { 196, 0, "vstrgw",      "v-gravity wave stress",                    "Pa"       },
-  { 197, 0, "vdisgw",      "gravity wave dissipation",                 "W/m^2"    },
-  { 198, 0, "vgrat",       "vegetation ratio",                         "fraction" },
-  { 199, 0, "varor",       "orographic variance",                      "m^2"      },
-  { 200, 0, "vlt",         "leaf area index",                           NULL      },
-  { 201, 0, "t2max",       "maximum 2m-temperature",                   "K"        },
-  { 202, 0, "t2min",       "minimum 2m-temperature",                   "K"        },
-  { 203, 0, "srad0u",      "top solar radiation upward",               "W/m^2"    },
-  { 204, 0, "sradsu",      "surface solar radiation upward",           "W/m^2"    },
-  { 205, 0, "tradsu",      "surface thermal radiation upward",         "W/m^2"    },
-  { 206, 0, "tsn",         "snow temperature",                         "K"        },
-  { 207, 0, "td3",         "soil temperature 3",                       "K"        },
-  { 208, 0, "td4",         "soil temperature 4",                       "K"        },
-  { 209, 0, "td5",         "soil temperature 5",                       "K"        },
-  { 210, 0, "seaice",      "sea ice cover",                            "fraction" },
-  { 211, 0, "siced",       "sea ice depth",                            "m"        },
-  { 212, 0, "forest",      "vegetation type",                          "fraction" },
-  { 213, 0, "teff",        "(effective) sea-ice skin temperature",     "K"        },
-  { 214, 0, "tsmax",       "maximum surface temperature",              "K"        },
-  { 215, 0, "tsmin",       "minimum surface temperature",              "K"        },
-  { 216, 0, "wimax",       "maximum 10m-wind speed",                   "m/s"      },
-  { 217, 0, "topmax",      "maximum height of convective cloud tops",  "Pa"       },
-  { 218, 0, "snmel",       "snow melt",                                "m/s"      },
-  { 219, 0, "runtoc",      "surface runoff into ocean",                 NULL      },
-  { 220, 0, "tslin",       "land: residual surface heat budget",       "W/m^2"    },
-  { 221, 0, "dsnac",       "snow depth change",                        "m/s"      },
-  { 222, 0, "alwcac",      "liquid water content",                     "kg/kg"    },
-  { 223, 0, "aclcac",      "cloud cover",                              "fraction" },
-  { 224, 0, "tke",         "turbulent kinetic energy",                  NULL      },
-  { 225, 0, "tkem1",       "turbulent kinetic energy (t-1)",            NULL      },
-  { 226, 0, "fao",         "FAO data set (soil data flags)",            NULL      },
-  { 227, 0, "rgcgn",       "heat capacity of soil",                     NULL      },
-  { 228, 0, "sodif",       "soil diffusivity",                          NULL      },
-  { 229, 0, "wsmx",        "field capacity of soil",                   "m"        },
-  { 230, 0, "qvi",         "vertically integrated specific humidity",  "kg/m^2"   },
-  { 231, 0, "alwcvi",      "vertically integrated liquid water cont.", "kg/m^2"   },
-  { 232, 0, "glac",        "glacier mask",                             "fraction" },
-  { 233, 0, "runlnd",      "surface runoff not running into ocean",     NULL      },
-  { 259, 0, "windspeed",   "windspeed (sqrt(u^2+v^2))",                 NULL      },
-  { 260, 0, "precip",      "total precipitation",                      "m/s"      },
-  { 261, 0, "net_top",     "total top radiation",                       NULL      },
-  { 262, 0, "net_bot",     "total surface radiation",                   NULL      },
-  { 263, 0, "net_heat",    "net surface heat flux",                     NULL      },
-  { 264, 0, "net_water",   "total surface water",                       NULL      },
-  { 268, 0, "sw_atm",       NULL,                                       NULL      },
-  { 269, 0, "lw_atm",       NULL,                                       NULL      },
-  { 270, 0, "net_atm",      NULL,                                       NULL      },
-  { 271, 0, "surf_runoff", "surface runoff",                            NULL      },
-  { 275, 0, "fresh_water",  NULL,                                       NULL      },
+#ifndef TABLE_H
+#define TABLE_H
+
+static const param_type echam4[] = {
+  {   4, -1, 0, "precip",      "total precipitation",                      "m/s"      },
+  {  34, -1, 0, "low_cld",     "low cloud",                                 NULL      },
+  {  35, -1, 0, "mid_cld",     "mid cloud",                                 NULL      },
+  {  36, -1, 0, "hih_cld",     "high cloud",                                NULL      },
+  { 129, -1, 0, "geosp",       "surface geopotential (orography)",         "m^2/s^2"  },
+  { 130, -1, 0, "t",           "temperature",                              "K"        },
+  { 131, -1, 0, "u",           "u-velocity",                               "m/s"      },
+  { 132, -1, 0, "v",           "v-velocity",                               "m/s"      },
+  { 133, -1, 0, "sq",          "specific humidity",                        "kg/kg"    },
+  { 134, -1, 0, "aps",         "Surface pressure",                         "Pa"       },
+  { 135, -1, 0, "omega",       "vertical velocity",                        "Pa/s"     },
+  { 138, -1, 0, "svo",         "vorticity",                                "1/s"      },
+  { 139, -1, 0, "ts",          "surface temperature",                      "K"        },
+  { 140, -1, 0, "ws",          "soil wetness",                             "m"        },
+  { 141, -1, 0, "sn",          "snow depth",                               "m"        },
+  { 142, -1, 0, "aprl",        "large scale precipitation",                "m/s"      },
+  { 143, -1, 0, "aprc",        "convective  precipitation",                "m/s"      },
+  { 144, -1, 0, "aprs",        "snow fall",                                "m/s"      },
+  { 145, -1, 0, "vdis",        "boundary layer dissipation",               "W/m^2"    },
+  { 146, -1, 0, "ahfs",        "surface sensible heat flux",               "W/m^2"    },
+  { 147, -1, 0, "ahfl",        "surface latent heat flux",                 "W/m^2"    },
+  { 148, -1, 0, "stream",      "streamfunction",                           "m^2/s"    },
+  { 149, -1, 0, "velopot",     "velocity potential",                       "m^2/s"    },
+  { 151, -1, 0, "slp",         "mean sea level pressure",                  "Pa"       },
+  { 152, -1, 0, "lsp",         "log surface pressure",                      NULL      },
+  { 153, -1, 0, "sx",          "liquid water content",                     "kg/kg"    },
+  { 155, -1, 0, "sd",          "divergence",                               "1/s"      },
+  { 156, -1, 0, "geopoth",     "geopotential height",                      "m"        },
+  { 157, -1, 0, "rhumidity",   "relative humidity",                        "fraction" },
+  { 158, -1, 0, "var158",      "tendency of surface pressure",             "Pa/s"     },
+  { 159, -1, 0, "ustar3",      "ustar3",                                   "m^3/s^3"  },
+  { 160, -1, 0, "runoff",      "surface runoff",                           "m/s"      },
+  { 161, -1, 0, "alwc",        "liquid water content",                     "kg/kg"    },
+  { 162, -1, 0, "aclc",        "cloud cover",                              "fraction" },
+  { 163, -1, 0, "aclcv",       "total cloud cover",                        "fraction" },
+  { 164, -1, 0, "aclcov",      "total cloud cover",                        "fraction" },
+  { 165, -1, 0, "u10",         "10m u-velocity",                           "m/s"      },
+  { 166, -1, 0, "v10",         "10m v-velocity",                           "m/s"      },
+  { 167, -1, 0, "temp2",       "2m temperature",                           "K"        },
+  { 168, -1, 0, "dew2",        "2m dew point temperature",                 "K"        },
+  { 169, -1, 0, "tsurf",       "surface temperature",                      "K"        },
+  { 170, -1, 0, "td",          "deep soil temperature",                    "K"        },
+  { 171, -1, 0, "wind10",      "10m windspeed",                            "m/s"      },
+  { 172, -1, 0, "slm",         "land sea mask",                            "fraction" },
+  { 173, -1, 0, "az0",         "surface roughness length",                 "m"        },
+  { 174, -1, 0, "alb",         "surface background albedo",                "fraction" },
+  { 175, -1, 0, "albedo",      "surface albedo",                           "fraction" },
+  { 176, -1, 0, "srads",       "net surface solar radiation",              "W/m^2"    },
+  { 177, -1, 0, "trads",       "net surface thermal radiation",            "W/m^2"    },
+  { 178, -1, 0, "srad0",       "net top solar radiation",                  "W/m^2"    },
+  { 179, -1, 0, "trad0",       "top thermal radiation (OLR)",              "W/m^2"    },
+  { 180, -1, 0, "ustr",        "surface u-stress",                         "Pa"       },
+  { 181, -1, 0, "vstr",        "surface v-stress",                         "Pa"       },
+  { 182, -1, 0, "evap",        "surface evaporation",                      "m/s"      },
+  { 183, -1, 0, "tdcl",        "soil temperature",                         "K"        },
+  { 185, -1, 0, "srafs",       "net surf. solar radiation   (clear sky)",  "W/m^2"    },
+  { 186, -1, 0, "trafs",       "net surf. thermal radiation (clear sky)",  "W/m^2"    },
+  { 187, -1, 0, "sraf0",       "net top solar radiation     (clear sky)",  "W/m^2"    },
+  { 188, -1, 0, "traf0",       "net top thermal radiation   (clear sky)",  "W/m^2"    },
+  { 189, -1, 0, "sclfs",       "surface solar cloud forcing",              "W/m^2"    },
+  { 190, -1, 0, "tclfs",       "surface thermal cloud forcing",            "W/m^2"    },
+  { 191, -1, 0, "sclf0",       "top solar cloud forcing",                  "W/m^2"    },
+  { 192, -1, 0, "tclf0",       "top thermal cloud forcing",                "W/m^2"    },
+  { 193, -1, 0, "wl",          "skin reservoir content",                   "m"        },
+  { 194, -1, 0, "wlm1",        "skin reservoir content of plants",         "m"        },
+  { 195, -1, 0, "ustrgw",      "u-gravity wave stress",                    "Pa"       },
+  { 196, -1, 0, "vstrgw",      "v-gravity wave stress",                    "Pa"       },
+  { 197, -1, 0, "vdisgw",      "gravity wave dissipation",                 "W/m^2"    },
+  { 198, -1, 0, "vgrat",       "vegetation ratio",                         "fraction" },
+  { 199, -1, 0, "varor",       "orographic variance",                      "m^2"      },
+  { 200, -1, 0, "vlt",         "leaf area index",                           NULL      },
+  { 201, -1, 0, "t2max",       "maximum 2m-temperature",                   "K"        },
+  { 202, -1, 0, "t2min",       "minimum 2m-temperature",                   "K"        },
+  { 203, -1, 0, "srad0u",      "top solar radiation upward",               "W/m^2"    },
+  { 204, -1, 0, "sradsu",      "surface solar radiation upward",           "W/m^2"    },
+  { 205, -1, 0, "tradsu",      "surface thermal radiation upward",         "W/m^2"    },
+  { 206, -1, 0, "tsn",         "snow temperature",                         "K"        },
+  { 207, -1, 0, "td3",         "soil temperature 3",                       "K"        },
+  { 208, -1, 0, "td4",         "soil temperature 4",                       "K"        },
+  { 209, -1, 0, "td5",         "soil temperature 5",                       "K"        },
+  { 210, -1, 0, "seaice",      "sea ice cover",                            "fraction" },
+  { 211, -1, 0, "siced",       "sea ice depth",                            "m"        },
+  { 212, -1, 0, "forest",      "vegetation type",                          "fraction" },
+  { 213, -1, 0, "teff",        "(effective) sea-ice skin temperature",     "K"        },
+  { 214, -1, 0, "tsmax",       "maximum surface temperature",              "K"        },
+  { 215, -1, 0, "tsmin",       "minimum surface temperature",              "K"        },
+  { 216, -1, 0, "wimax",       "maximum 10m-wind speed",                   "m/s"      },
+  { 217, -1, 0, "topmax",      "maximum height of convective cloud tops",  "Pa"       },
+  { 218, -1, 0, "snmel",       "snow melt",                                "m/s"      },
+  { 219, -1, 0, "runtoc",      "surface runoff into ocean",                 NULL      },
+  { 220, -1, 0, "tslin",       "land: residual surface heat budget",       "W/m^2"    },
+  { 221, -1, 0, "dsnac",       "snow depth change",                        "m/s"      },
+  { 222, -1, 0, "alwcac",      "liquid water content",                     "kg/kg"    },
+  { 223, -1, 0, "aclcac",      "cloud cover",                              "fraction" },
+  { 224, -1, 0, "tke",         "turbulent kinetic energy",                  NULL      },
+  { 225, -1, 0, "tkem1",       "turbulent kinetic energy (t-1)",            NULL      },
+  { 226, -1, 0, "fao",         "FAO data set (soil data flags)",            NULL      },
+  { 227, -1, 0, "rgcgn",       "heat capacity of soil",                     NULL      },
+  { 228, -1, 0, "sodif",       "soil diffusivity",                          NULL      },
+  { 229, -1, 0, "wsmx",        "field capacity of soil",                   "m"        },
+  { 230, -1, 0, "qvi",         "vertically integrated specific humidity",  "kg/m^2"   },
+  { 231, -1, 0, "alwcvi",      "vertically integrated liquid water cont.", "kg/m^2"   },
+  { 232, -1, 0, "glac",        "glacier mask",                             "fraction" },
+  { 233, -1, 0, "runlnd",      "surface runoff not running into ocean",     NULL      },
+  { 259, -1, 0, "windspeed",   "windspeed (sqrt(u^2+v^2))",                 NULL      },
+  { 260, -1, 0, "precip",      "total precipitation",                      "m/s"      },
+  { 261, -1, 0, "net_top",     "total top radiation",                       NULL      },
+  { 262, -1, 0, "net_bot",     "total surface radiation",                   NULL      },
+  { 263, -1, 0, "net_heat",    "net surface heat flux",                     NULL      },
+  { 264, -1, 0, "net_water",   "total surface water",                       NULL      },
+  { 268, -1, 0, "sw_atm",       NULL,                                       NULL      },
+  { 269, -1, 0, "lw_atm",       NULL,                                       NULL      },
+  { 270, -1, 0, "net_atm",      NULL,                                       NULL      },
+  { 271, -1, 0, "surf_runoff", "surface runoff",                            NULL      },
+  { 275, -1, 0, "fresh_water",  NULL,                                       NULL      },
 };
 
-static const PAR echam5[] = {
-  {   4, 0, "precip",     "total precipitation",                       "kg/m^2s" },
-  {  79, 0, "swnirac",    "net surface NIR flux acc.",                 "W/m^2"   },
-  {  80, 0, "swdifnirac", "fraction of diffuse NIR acc.",              "W/m^2"   },
-  {  81, 0, "swvisac",    "net surface visible flux acc.",             "W/m^2"   },
-  {  82, 0, "swdifvisac", "fraction of diffuse visible acc.",          "W/m^2"   },
-  {  83, 0, "ocu",        "ocean eastw. velocity (coupled mode)",      "m/s"     },
-  {  84, 0, "ocv",        "ocean northw. velocity (coupled mode)",     "m/s"     },
-  {  85, 0, "tradl",      "net LW radiation 200mb",                    "W/m^2"   },
-  {  86, 0, "sradl",      "net SW radiation 200mb",                    "W/m^2"   },
-  {  87, 0, "trafl",      "net LW radiation 200mb (clear sky)",        "W/m^2"   },
-  {  88, 0, "srafl",      "net SW radiation 200mb (clear sky)",        "W/m^2"   },
-  {  89, 0, "amlcorac",   "mixed layer flux correction",               "W/m^2"   },
-  {  90, 0, "amlheatac",  "mixed layer heat content",                  "J/m^2"   },
-  {  91, 0, "trfliac",    "net LW radiation over ice",                 "W/m^2"   },
-  {  92, 0, "trflwac",    "net LW radiation over water",               "W/m^2"   },
-  {  93, 0, "trfllac",    "net LW radiation over land",                "W/m^2"   },
-  {  94, 0, "sofliac",    "net SW radiation over ice",                 "W/m^2"   },
-  {  95, 0, "soflwac",    "net SW radiation over water",               "W/m^2"   },
-  {  96, 0, "sofllac",    "net SW radiation over land",                "W/m^2"   },
-  {  97, 0, "friac",      "ice cover (fraction of grid box)",           NULL     },
-  { 102, 0, "tsi",        "surface temperature of ice",                "K"       },
-  { 103, 0, "tsw",        "surface temperature of water",              "K"       },
-  { 104, 0, "ustri",      "zonal      wind stress over ice",           "Pa"      },
-  { 105, 0, "vstri",      "meridional wind stress over ice",           "Pa"      },
-  { 106, 0, "ustrw",      "zonal      wind stress over water",         "Pa"      },
-  { 107, 0, "vstrw",      "meridional wind stress over water",         "Pa"      },
-  { 108, 0, "ustrl",      "zonal      wind stress over land",          "Pa"      },
-  { 109, 0, "vstrl",      "meridional wind stress over land",          "Pa"      },
-  { 110, 0, "ahfliac",    "latent heat flux over ice",                 "W/m^2"   },
-  { 111, 0, "ahflwac",    "latent heat flux over water",               "W/m^2"   },
-  { 112, 0, "ahfllac",    "latent heat flux over land",                "W/m^2"   },
-  { 113, 0, "evapiac",    "evaporation over ice",                      "kg/m^2s" },
-  { 114, 0, "evapwac",    "evaporation over water",                    "kg/m^2s" },
-  { 115, 0, "evaplac",    "evaporation over land",                     "kg/m^2s" },
-  { 116, 0, "az0i",       "roughness length over ice",                 "m"       },
-  { 117, 0, "az0w",       "roughness length over water",               "m"       },
-  { 118, 0, "az0l",       "roughness length over land",                "m"       },
-  { 119, 0, "ahfsiac",    "sensible heat flux over ice",               "W/m^2"   },
-  { 120, 0, "ahfswac",    "sensible heat flux over water",             "W/m^2"   },
-  { 121, 0, "ahfslac",    "sensible heat flux over land",              "W/m^2"   },
-  { 122, 0, "alsoi",      "albedo of ice",                              NULL     },
-  { 123, 0, "alsow",      "albedo of water",                            NULL     },
-  { 124, 0, "alsol",      "albedo of land",                             NULL     },
-  { 125, 0, "ahfice",     "conductive heat flux through ice",          "W/m^2"   },
-  { 126, 0, "qres",       "residual heat flux for melting sea ice",    "W/m^2"   },
-  { 127, 0, "alake",      "lake fraction",                              NULL     },
-  { 128, 0, "rintop",     "low level inversion",                        NULL     },
-  { 129, 0, "geosp",      "surface geopotential (orography)",          "m^2/s^2" },
-  { 130, 0, "t",          "temperature",                               "K"       },
-  { 131, 0, "u",          "u-velocity",                                "m/s"     },
-  { 132, 0, "v",          "v-velocity",                                "m/s"     },
-  { 133, 0, "q",          "specific humidity",                         "kg/kg"   },
-  { 134, 0, "aps",        "surface pressure",                          "Pa"      },
-  { 135, 0, "omega",      "vertical velocity",                         "Pa/s"    },
-  { 136, 0, "acdnc",      "cloud droplet number concentration",        "1/m^3"   },
-  { 137, 0, "apmeb",      "(P-E) error",                               "kg/m^2s" },
-  { 138, 0, "svo",        "vorticity",                                 "1/s"     },
-  { 139, 0, "tslm1",      "surface temperature of land",               "K"       },
-  { 140, 0, "ws",         "soil wetness",                              "m"       },
-  { 141, 0, "sn",         "water equivalent snow depth",               "m"       },
-  { 142, 0, "aprl",       "large scale precipitation",                 "kg/m^2s" },
-  { 143, 0, "aprc",       "convective  precipitation",                 "kg/m^2s" },
-  { 144, 0, "aprs",       "snow fall",                                 "kg/m^2s" },
-  { 145, 0, "vdis",       "boundary layer dissipation",                "W/m^2"   },
-  { 146, 0, "ahfs",       "sensible heat flux",                        "W/m^2"   },
-  { 147, 0, "ahfl",       "latent heat flux",                          "W/m^2"   },
-  { 148, 0, "stream",     "streamfunction",                            "m^2/s"   },
-  { 149, 0, "velopot",    "velocity potential",                        "m^2/s"   },
-  { 150, 0, "xivi",       "vertically integrated cloud ice",           "kg/m^2"  },
-  { 151, 0, "slp",        "mean sea level pressure",                   "Pa"      },
-  { 152, 0, "lsp",        "log surface pressure",                       NULL     },
-  { 153, 0, "xl",         "cloud water",                               "kg/kg"   },
-  { 154, 0, "xi",         "cloud ice",                                 "kg/kg"   },
-  { 155, 0, "sd",         "divergence",                                "1/s"     },
-  { 156, 0, "geopoth",    "geopotential height",                       "m"       },
-  { 157, 0, "rhumidity",  "relative humidity",                          NULL     },
-  { 159, 0, "wind10w",    "10m windspeed over water",                  "m/s"     },
-  { 160, 0, "runoff",     "surface runoff and drainage",               "kg/m^2s" },
-  { 161, 0, "drain",      "drainage",                                  "kg/m^2s" },
-  { 162, 0, "aclc",       "cloud cover",                                NULL     },
-  { 164, 0, "aclcov",     "total cloud cover",                          NULL     },
-  { 165, 0, "u10",        "10m u-velocity",                            "m/s"     },
-  { 166, 0, "v10",        "10m v-velocity",                            "m/s"     },
-  { 167, 0, "temp2",      "2m temperature",                            "K"       },
-  { 168, 0, "dew2",       "2m dew point temperature",                  "K"       },
-  { 169, 0, "tsurf",      "surface temperature",                       "K"       },
-  { 170, 0, "xvar",       "variance of total water amount",            "kg/kg"   },
-  { 171, 0, "wind10",     "10m windspeed",                             "m/s"     },
-  { 172, 0, "slm",        "land sea mask (1. = land, 0. = sea/lakes)",  NULL     },
-  { 173, 0, "az0",        "roughness length",                          "m"       },
-  { 174, 0, "alb",        "surface background albedo",                  NULL     },
-  { 175, 0, "albedo",     "surface albedo",                             NULL     },
-  { 176, 0, "srads",      "net surface SW radiation",                  "W/m^2"   },
-  { 177, 0, "trads",      "net surface LW radiation",                  "W/m^2"   },
-  { 178, 0, "srad0",      "net top SW radiation",                      "W/m^2"   },
-  { 179, 0, "trad0",      "net top LW radiation (-OLR)",               "W/m^2"   },
-  { 180, 0, "ustr",       "u-stress",                                  "Pa"      },
-  { 181, 0, "vstr",       "v-stress",                                  "Pa"      },
-  { 182, 0, "evap",       "evaporation",                               "kg/m^2s" },
-  { 183, 0, "xskew",      "skewness of total water amount qv+qi+ql",    NULL     },
-  { 184, 0, "srad0d",     "top incoming SW radiation",                 "W/m^2"   },
-  { 185, 0, "srafs",      "net surface SW radiation (clear sky)",      "W/m^2"   },
-  { 186, 0, "trafs",      "net surface LW radiation (clear sky)",      "W/m^2"   },
-  { 187, 0, "sraf0",      "net top SW radiation   (clear sky)",        "W/m^2"   },
-  { 188, 0, "traf0",      "net top LW radiation   (clear sky)",        "W/m^2"   },
-  { 189, 0, "sclfs",      "net surface SW cloud forcing (176-185)",    "W/m^2"   },
-  { 190, 0, "tclfs",      "net surface LW cloud forcing (177-186)",    "W/m^2"   },
-  { 191, 0, "sclf0",      "net SW top cloud forcing (178-187)",        "W/m^2"   },
-  { 192, 0, "tclf0",      "net LW top cloud forcing (179-188)",        "W/m^2"   },
-  { 193, 0, "wl",         "skin reservoir content",                    "m"       },
-  { 194, 0, "slf",        "fractional land cover",                      NULL     },
-  { 195, 0, "ustrgw",     "u-gravity wave stress",                     "Pa"      },
-  { 196, 0, "vstrgw",     "v-gravity wave stress",                     "Pa"      },
-  { 197, 0, "vdisgw",     "gravity wave dissipation",                  "W/m^2"   },
-  { 198, 0, "vgrat",      "vegetation ratio",                           NULL     },
-  { 199, 0, "orostd",     "orographic standard deviation",             "m"       },
-  { 200, 0, "vlt",        "leaf area index",                            NULL     },
-  { 201, 0, "t2max",      "maximum 2m-temperature",                    "K"       },
-  { 202, 0, "t2min",      "minimum 2m-temperature",                    "K"       },
-  { 203, 0, "srad0u",     "top SW radiation upward",                   "W/m^2"   },
-  { 204, 0, "sradsu",     "surface SW radiation upward",               "W/m^2"   },
-  { 205, 0, "tradsu",     "surface LW radiation upward",               "W/m^2"   },
-  { 206, 0, "grndflux",   "surface ground heat flux",                   NULL     },
-  { 207, 0, "tsoil",      "deep soil temperatures (5 layers)",         "K"       },
-  { 208, 0, "ahfcon",     "conductive heat flux through ice",          "W/m^2"   },
-  { 209, 0, "ahfres",     "res. heat flux for melting ice",            "W/m^2"   },
-  { 210, 0, "seaice",     "ice cover (fraction of ice+water)",          NULL     },
-  { 211, 0, "siced",      "ice thickness",                             "m"       },
-  { 212, 0, "forest",     "forest fraction",                            NULL     },
-  { 213, 0, "gld",        "glacier thickness",                         "m"       },
-  { 214, 0, "sni",        "water equivalent of snow on ice",           "m"       },
-  { 215, 0, "rogl",       "glacier runoff",                            "kg/m^2s" },
-  { 216, 0, "wimax",      "maximum 10m-wind speed",                    "m/s"     },
-  { 217, 0, "topmax",     "maximum height of convective cloud tops",   "Pa"      },
-  { 218, 0, "snmel",      "snow melt",                                 "kg/m^2s" },
-  { 219, 0, "runtoc",     "surface runoff into ocean",                 "kg/m^2s" },
-  { 220, 0, "runlnd",     "surface runoff not running into ocean",     "kg/m^2s" },
-  { 221, 0, "apmegl",     "P-E over land ice",                         "kg/m^2s" },
-  { 222, 0, "snacl",      "snow accumulation over land",               "kg/m^2s" },
-  { 223, 0, "aclcac",     "cloud cover",                                NULL     },
-  { 224, 0, "tke",        "turbulent kinetic energy",                  "m^2/s^2" },
-  { 225, 0, "tkem1",      "turbulent kinetic energy (t-1)",            "m^2/s^2" },
-  { 226, 0, "fao",        "FAO data set (soil data flags) 0...5",       NULL     },
-  { 227, 0, "rgcgn",      "heat capacity of soil",                      NULL     },
-  { 228, 0, "sodif",      "soil diffusivity",                          "m^2/s"   },
-  { 229, 0, "wsmx",       "field capacity of soil",                    "m"       },
-  { 230, 0, "qvi",        "vertically integrated water vapor",         "kg/m^2"  },
-  { 231, 0, "xlvi",       "vertically integrated cloud water",         "kg/m^2"  },
-  { 232, 0, "glac",       "fraction of land covered by glaciers",       NULL     },
-  { 233, 0, "snc",        "snow depth at the canopy",                  "m"       },
-  { 234, 0, "rtype",      "type of convection",                        "0...3"   },
-  { 235, 0, "abso4",      "anthropogenic sulfur burden",               "kg/m^2"  },
-  { 236, 0, "ao3",        "ipcc ozone",                                "kg/m^2"  },
-  { 237, 0, "tropo",      "WMO defined tropopause height",             "Pa"      },
-  { 259, 0, "windspeed",  "windspeed (sqrt(u^2+v^2))",                 "m/s"     },
-  { 260, 0, "precip",     "total precipitation  (142+143)",            "kg/m^2s" },
-  { 261, 0, "net_top",    "total top radiation  (178+179)",            "W/m^2"   },
-  { 262, 0, "net_bot",    "total surface radiation (176+177)",         "W/m^2"   },
-  { 272, 0, "mastrfu",    "mass stream function",                      "kg/s"    },
+static const param_type echam5[] = {
+  {   4, -1, 0, "precip",     "total precipitation",                       "kg/m^2s" },
+  {  79, -1, 0, "swnirac",    "net surface NIR flux acc.",                 "W/m^2"   },
+  {  80, -1, 0, "swdifnirac", "fraction of diffuse NIR acc.",              "W/m^2"   },
+  {  81, -1, 0, "swvisac",    "net surface visible flux acc.",             "W/m^2"   },
+  {  82, -1, 0, "swdifvisac", "fraction of diffuse visible acc.",          "W/m^2"   },
+  {  83, -1, 0, "ocu",        "ocean eastw. velocity (coupled mode)",      "m/s"     },
+  {  84, -1, 0, "ocv",        "ocean northw. velocity (coupled mode)",     "m/s"     },
+  {  85, -1, 0, "tradl",      "net LW radiation 200mb",                    "W/m^2"   },
+  {  86, -1, 0, "sradl",      "net SW radiation 200mb",                    "W/m^2"   },
+  {  87, -1, 0, "trafl",      "net LW radiation 200mb (clear sky)",        "W/m^2"   },
+  {  88, -1, 0, "srafl",      "net SW radiation 200mb (clear sky)",        "W/m^2"   },
+  {  89, -1, 0, "amlcorac",   "mixed layer flux correction",               "W/m^2"   },
+  {  90, -1, 0, "amlheatac",  "mixed layer heat content",                  "J/m^2"   },
+  {  91, -1, 0, "trfliac",    "net LW radiation over ice",                 "W/m^2"   },
+  {  92, -1, 0, "trflwac",    "net LW radiation over water",               "W/m^2"   },
+  {  93, -1, 0, "trfllac",    "net LW radiation over land",                "W/m^2"   },
+  {  94, -1, 0, "sofliac",    "net SW radiation over ice",                 "W/m^2"   },
+  {  95, -1, 0, "soflwac",    "net SW radiation over water",               "W/m^2"   },
+  {  96, -1, 0, "sofllac",    "net SW radiation over land",                "W/m^2"   },
+  {  97, -1, 0, "friac",      "ice cover (fraction of grid box)",           NULL     },
+  { 102, -1, 0, "tsi",        "surface temperature of ice",                "K"       },
+  { 103, -1, 0, "tsw",        "surface temperature of water",              "K"       },
+  { 104, -1, 0, "ustri",      "zonal      wind stress over ice",           "Pa"      },
+  { 105, -1, 0, "vstri",      "meridional wind stress over ice",           "Pa"      },
+  { 106, -1, 0, "ustrw",      "zonal      wind stress over water",         "Pa"      },
+  { 107, -1, 0, "vstrw",      "meridional wind stress over water",         "Pa"      },
+  { 108, -1, 0, "ustrl",      "zonal      wind stress over land",          "Pa"      },
+  { 109, -1, 0, "vstrl",      "meridional wind stress over land",          "Pa"      },
+  { 110, -1, 0, "ahfliac",    "latent heat flux over ice",                 "W/m^2"   },
+  { 111, -1, 0, "ahflwac",    "latent heat flux over water",               "W/m^2"   },
+  { 112, -1, 0, "ahfllac",    "latent heat flux over land",                "W/m^2"   },
+  { 113, -1, 0, "evapiac",    "evaporation over ice",                      "kg/m^2s" },
+  { 114, -1, 0, "evapwac",    "evaporation over water",                    "kg/m^2s" },
+  { 115, -1, 0, "evaplac",    "evaporation over land",                     "kg/m^2s" },
+  { 116, -1, 0, "az0i",       "roughness length over ice",                 "m"       },
+  { 117, -1, 0, "az0w",       "roughness length over water",               "m"       },
+  { 118, -1, 0, "az0l",       "roughness length over land",                "m"       },
+  { 119, -1, 0, "ahfsiac",    "sensible heat flux over ice",               "W/m^2"   },
+  { 120, -1, 0, "ahfswac",    "sensible heat flux over water",             "W/m^2"   },
+  { 121, -1, 0, "ahfslac",    "sensible heat flux over land",              "W/m^2"   },
+  { 122, -1, 0, "alsoi",      "albedo of ice",                              NULL     },
+  { 123, -1, 0, "alsow",      "albedo of water",                            NULL     },
+  { 124, -1, 0, "alsol",      "albedo of land",                             NULL     },
+  { 125, -1, 0, "ahfice",     "conductive heat flux through ice",          "W/m^2"   },
+  { 126, -1, 0, "qres",       "residual heat flux for melting sea ice",    "W/m^2"   },
+  { 127, -1, 0, "alake",      "lake fraction",                              NULL     },
+  { 128, -1, 0, "rintop",     "low level inversion",                        NULL     },
+  { 129, -1, 0, "geosp",      "surface geopotential (orography)",          "m^2/s^2" },
+  { 130, -1, 0, "t",          "temperature",                               "K"       },
+  { 131, -1, 0, "u",          "u-velocity",                                "m/s"     },
+  { 132, -1, 0, "v",          "v-velocity",                                "m/s"     },
+  { 133, -1, 0, "q",          "specific humidity",                         "kg/kg"   },
+  { 134, -1, 0, "aps",        "surface pressure",                          "Pa"      },
+  { 135, -1, 0, "omega",      "vertical velocity",                         "Pa/s"    },
+  { 136, -1, 0, "acdnc",      "cloud droplet number concentration",        "1/m^3"   },
+  { 137, -1, 0, "apmeb",      "(P-E) error",                               "kg/m^2s" },
+  { 138, -1, 0, "svo",        "vorticity",                                 "1/s"     },
+  { 139, -1, 0, "tslm1",      "surface temperature of land",               "K"       },
+  { 140, -1, 0, "ws",         "soil wetness",                              "m"       },
+  { 141, -1, 0, "sn",         "water equivalent snow depth",               "m"       },
+  { 142, -1, 0, "aprl",       "large scale precipitation",                 "kg/m^2s" },
+  { 143, -1, 0, "aprc",       "convective  precipitation",                 "kg/m^2s" },
+  { 144, -1, 0, "aprs",       "snow fall",                                 "kg/m^2s" },
+  { 145, -1, 0, "vdis",       "boundary layer dissipation",                "W/m^2"   },
+  { 146, -1, 0, "ahfs",       "sensible heat flux",                        "W/m^2"   },
+  { 147, -1, 0, "ahfl",       "latent heat flux",                          "W/m^2"   },
+  { 148, -1, 0, "stream",     "streamfunction",                            "m^2/s"   },
+  { 149, -1, 0, "velopot",    "velocity potential",                        "m^2/s"   },
+  { 150, -1, 0, "xivi",       "vertically integrated cloud ice",           "kg/m^2"  },
+  { 151, -1, 0, "slp",        "mean sea level pressure",                   "Pa"      },
+  { 152, -1, 0, "lsp",        "log surface pressure",                       NULL     },
+  { 153, -1, 0, "xl",         "cloud water",                               "kg/kg"   },
+  { 154, -1, 0, "xi",         "cloud ice",                                 "kg/kg"   },
+  { 155, -1, 0, "sd",         "divergence",                                "1/s"     },
+  { 156, -1, 0, "geopoth",    "geopotential height",                       "m"       },
+  { 157, -1, 0, "rhumidity",  "relative humidity",                          NULL     },
+  { 159, -1, 0, "wind10w",    "10m windspeed over water",                  "m/s"     },
+  { 160, -1, 0, "runoff",     "surface runoff and drainage",               "kg/m^2s" },
+  { 161, -1, 0, "drain",      "drainage",                                  "kg/m^2s" },
+  { 162, -1, 0, "aclc",       "cloud cover",                                NULL     },
+  { 164, -1, 0, "aclcov",     "total cloud cover",                          NULL     },
+  { 165, -1, 0, "u10",        "10m u-velocity",                            "m/s"     },
+  { 166, -1, 0, "v10",        "10m v-velocity",                            "m/s"     },
+  { 167, -1, 0, "temp2",      "2m temperature",                            "K"       },
+  { 168, -1, 0, "dew2",       "2m dew point temperature",                  "K"       },
+  { 169, -1, 0, "tsurf",      "surface temperature",                       "K"       },
+  { 170, -1, 0, "xvar",       "variance of total water amount",            "kg/kg"   },
+  { 171, -1, 0, "wind10",     "10m windspeed",                             "m/s"     },
+  { 172, -1, 0, "slm",        "land sea mask (1. = land, 0. = sea/lakes)",  NULL     },
+  { 173, -1, 0, "az0",        "roughness length",                          "m"       },
+  { 174, -1, 0, "alb",        "surface background albedo",                  NULL     },
+  { 175, -1, 0, "albedo",     "surface albedo",                             NULL     },
+  { 176, -1, 0, "srads",      "net surface SW radiation",                  "W/m^2"   },
+  { 177, -1, 0, "trads",      "net surface LW radiation",                  "W/m^2"   },
+  { 178, -1, 0, "srad0",      "net top SW radiation",                      "W/m^2"   },
+  { 179, -1, 0, "trad0",      "net top LW radiation (-OLR)",               "W/m^2"   },
+  { 180, -1, 0, "ustr",       "u-stress",                                  "Pa"      },
+  { 181, -1, 0, "vstr",       "v-stress",                                  "Pa"      },
+  { 182, -1, 0, "evap",       "evaporation",                               "kg/m^2s" },
+  { 183, -1, 0, "xskew",      "skewness of total water amount qv+qi+ql",    NULL     },
+  { 184, -1, 0, "srad0d",     "top incoming SW radiation",                 "W/m^2"   },
+  { 185, -1, 0, "srafs",      "net surface SW radiation (clear sky)",      "W/m^2"   },
+  { 186, -1, 0, "trafs",      "net surface LW radiation (clear sky)",      "W/m^2"   },
+  { 187, -1, 0, "sraf0",      "net top SW radiation   (clear sky)",        "W/m^2"   },
+  { 188, -1, 0, "traf0",      "net top LW radiation   (clear sky)",        "W/m^2"   },
+  { 189, -1, 0, "sclfs",      "net surface SW cloud forcing (176-185)",    "W/m^2"   },
+  { 190, -1, 0, "tclfs",      "net surface LW cloud forcing (177-186)",    "W/m^2"   },
+  { 191, -1, 0, "sclf0",      "net SW top cloud forcing (178-187)",        "W/m^2"   },
+  { 192, -1, 0, "tclf0",      "net LW top cloud forcing (179-188)",        "W/m^2"   },
+  { 193, -1, 0, "wl",         "skin reservoir content",                    "m"       },
+  { 194, -1, 0, "slf",        "fractional land cover",                      NULL     },
+  { 195, -1, 0, "ustrgw",     "u-gravity wave stress",                     "Pa"      },
+  { 196, -1, 0, "vstrgw",     "v-gravity wave stress",                     "Pa"      },
+  { 197, -1, 0, "vdisgw",     "gravity wave dissipation",                  "W/m^2"   },
+  { 198, -1, 0, "vgrat",      "vegetation ratio",                           NULL     },
+  { 199, -1, 0, "orostd",     "orographic standard deviation",             "m"       },
+  { 200, -1, 0, "vlt",        "leaf area index",                            NULL     },
+  { 201, -1, 0, "t2max",      "maximum 2m-temperature",                    "K"       },
+  { 202, -1, 0, "t2min",      "minimum 2m-temperature",                    "K"       },
+  { 203, -1, 0, "srad0u",     "top SW radiation upward",                   "W/m^2"   },
+  { 204, -1, 0, "sradsu",     "surface SW radiation upward",               "W/m^2"   },
+  { 205, -1, 0, "tradsu",     "surface LW radiation upward",               "W/m^2"   },
+  { 206, -1, 0, "grndflux",   "surface ground heat flux",                   NULL     },
+  { 207, -1, 0, "tsoil",      "deep soil temperatures (5 layers)",         "K"       },
+  { 208, -1, 0, "ahfcon",     "conductive heat flux through ice",          "W/m^2"   },
+  { 209, -1, 0, "ahfres",     "res. heat flux for melting ice",            "W/m^2"   },
+  { 210, -1, 0, "seaice",     "ice cover (fraction of ice+water)",          NULL     },
+  { 211, -1, 0, "siced",      "ice thickness",                             "m"       },
+  { 212, -1, 0, "forest",     "forest fraction",                            NULL     },
+  { 213, -1, 0, "gld",        "glacier thickness",                         "m"       },
+  { 214, -1, 0, "sni",        "water equivalent of snow on ice",           "m"       },
+  { 215, -1, 0, "rogl",       "glacier runoff",                            "kg/m^2s" },
+  { 216, -1, 0, "wimax",      "maximum 10m-wind speed",                    "m/s"     },
+  { 217, -1, 0, "topmax",     "maximum height of convective cloud tops",   "Pa"      },
+  { 218, -1, 0, "snmel",      "snow melt",                                 "kg/m^2s" },
+  { 219, -1, 0, "runtoc",     "surface runoff into ocean",                 "kg/m^2s" },
+  { 220, -1, 0, "runlnd",     "surface runoff not running into ocean",     "kg/m^2s" },
+  { 221, -1, 0, "apmegl",     "P-E over land ice",                         "kg/m^2s" },
+  { 222, -1, 0, "snacl",      "snow accumulation over land",               "kg/m^2s" },
+  { 223, -1, 0, "aclcac",     "cloud cover",                                NULL     },
+  { 224, -1, 0, "tke",        "turbulent kinetic energy",                  "m^2/s^2" },
+  { 225, -1, 0, "tkem1",      "turbulent kinetic energy (t-1)",            "m^2/s^2" },
+  { 226, -1, 0, "fao",        "FAO data set (soil data flags) 0...5",       NULL     },
+  { 227, -1, 0, "rgcgn",      "heat capacity of soil",                      NULL     },
+  { 228, -1, 0, "sodif",      "soil diffusivity",                          "m^2/s"   },
+  { 229, -1, 0, "wsmx",       "field capacity of soil",                    "m"       },
+  { 230, -1, 0, "qvi",        "vertically integrated water vapor",         "kg/m^2"  },
+  { 231, -1, 0, "xlvi",       "vertically integrated cloud water",         "kg/m^2"  },
+  { 232, -1, 0, "glac",       "fraction of land covered by glaciers",       NULL     },
+  { 233, -1, 0, "snc",        "snow depth at the canopy",                  "m"       },
+  { 234, -1, 0, "rtype",      "type of convection",                        "0...3"   },
+  { 235, -1, 0, "abso4",      "anthropogenic sulfur burden",               "kg/m^2"  },
+  { 236, -1, 0, "ao3",        "ipcc ozone",                                "kg/m^2"  },
+  { 237, -1, 0, "tropo",      "WMO defined tropopause height",             "Pa"      },
+  { 259, -1, 0, "windspeed",  "windspeed (sqrt(u^2+v^2))",                 "m/s"     },
+  { 260, -1, 0, "precip",     "total precipitation  (142+143)",            "kg/m^2s" },
+  { 261, -1, 0, "net_top",    "total top radiation  (178+179)",            "W/m^2"   },
+  { 262, -1, 0, "net_bot",    "total surface radiation (176+177)",         "W/m^2"   },
+  { 272, -1, 0, "mastrfu",    "mass stream function",                      "kg/s"    },
 };
 
-static const PAR echam6[] = {
-  {   4, 0, "precip",         "total precipitation",                       "kg m-2 s-1" },
-  {  34, 0, "low_cld",        "low cloud",                                  NULL        },
-  {  35, 0, "mid_cld",        "mid cloud",                                  NULL        },
-  {  36, 0, "hih_cld",        "high cloud",                                 NULL        },
-  {  68, 0, "fage",           "aging factor of snow on ice",                NULL        },
-  {  69, 0, "snifrac",        "fraction of ice covered with snow",          NULL        },
-  {  70, 0, "barefrac",       "bare ice fraction",                          NULL        },
-  {  71, 0, "alsom",          "albedo of melt ponds",                       NULL        },
-  {  72, 0, "alsobs",         "albedo of bare ice and snow",                NULL        },
-  {  73, 0, "sicepdw",        "melt pond depth on sea-ice",                "m"          },
-  {  74, 0, "sicepdi",        "ice thickness on melt pond",                "m"          },
-  {  75, 0, "tsicepdi",       "ice temperature on frozen melt pond",       "K"          },
-  {  76, 0, "sicepres",       "residual heat flux",                        "W m-2"      },
-  {  77, 0, "ameltdepth",     "total melt pond depth",                     "m"          },
-  {  78, 0, "ameltfrac",      "fractional area of melt ponds on sea-ice",   NULL        },
-  {  79, 0, "albedo_vis_dir", "surface albedo visible range direct",        NULL        },
-  {  80, 0, "albedo_nir_dir", "surface albedo NIR range direct",            NULL        },
-  {  81, 0, "albedo_vis_dif", "surface albedo visible range diffuse",       NULL        },
-  {  82, 0, "albedo_nir_dif", "surface albedo NIR range diffuse",           NULL        },
-  {  83, 0, "ocu",            "ocean eastw. velocity (coupled mode)",      "m/s"        },
-  {  84, 0, "ocv",            "ocean northw. velocity (coupled mode)",     "m/s"        },
-  {  85, 0, "tradl",          "thermal radiation 200mb",                   "W m-2"      },
-  {  86, 0, "sradl",          "solar radiation 200mb",                     "W m-2"      },
-  {  87, 0, "trafl",          "thermal radiation 200mb (clear sky)",       "W m-2"      },
-  {  88, 0, "srafl",          "solar radiation 200mb (clear sky)",         "W m-2"      },
-  {  89, 0, "amlcorac",       "mixed layer flux correction",               "W m-2"      },
-  {  90, 0, "amlheatac",      "mixed layer heat content",                  "J m-2"      },
-  {  91, 0, "trfliac",        "LW flux over ice",                          "W m-2"      },
-  {  92, 0, "trflwac",        "LW flux over water",                        "W m-2"      },
-  {  93, 0, "trfllac",        "LW flux over land",                         "W m-2"      },
-  {  94, 0, "sofliac",        "SW flux over ice",                          "W m-2"      },
-  {  95, 0, "soflwac",        "SW flux over water",                        "W m-2"      },
-  {  96, 0, "sofllac",        "SW flux over land",                         "W m-2"      },
-  {  97, 0, "friac",          "ice cover (fraction of grid box)",           NULL        },
-  { 102, 0, "tsi",            "surface temperature of ice",                "K"          },
-  { 103, 0, "tsw",            "surface temperature of water",              "K"          },
-  { 104, 0, "ustri",          "zonal      wind stress over ice",           "Pa"         },
-  { 105, 0, "vstri",          "meridional wind stress over ice",           "Pa"         },
-  { 106, 0, "ustrw",          "zonal      wind stress over water",         "Pa"         },
-  { 107, 0, "vstrw",          "meridional wind stress over water",         "Pa"         },
-  { 108, 0, "ustrl",          "zonal      wind stress over land",          "Pa"         },
-  { 109, 0, "vstrl",          "meridional wind stress over land",          "Pa"         },
-  { 110, 0, "ahfliac",        "latent heat flux over ice",                 "W m-2"      },
-  { 111, 0, "ahflwac",        "latent heat flux over water",               "W m-2"      },
-  { 112, 0, "ahfllac",        "latent heat flux over land",                "W m-2"      },
-  { 113, 0, "evapiac",        "evaporation over ice",                      "kg m-2 s-1" },
-  { 114, 0, "evapwac",        "evaporation over water",                    "kg m-2 s-1" },
-  { 115, 0, "evaplac",        "evaporation over land",                     "kg m-2 s-1" },
-  { 116, 0, "az0i",           "roughness length over ice",                 "m"          },
-  { 117, 0, "az0w",           "roughness length over water",               "m"          },
-  { 118, 0, "az0l",           "roughness length over land",                "m"          },
-  { 119, 0, "ahfsiac",        "sensible heat flux over ice",               "W m-2"      },
-  { 120, 0, "ahfswac",        "sensible heat flux over water",             "W m-2"      },
-  { 121, 0, "ahfslac",        "sensible heat flux over land",              "W m-2"      },
-  { 122, 0, "alsoi",          "albedo of ice",                              NULL        },
-  { 123, 0, "alsow",          "albedo of water",                            NULL        },
-  { 124, 0, "alsol",          "albedo of land",                             NULL        },
-  { 125, 0, "ahfice",         "conductive heat flux",                      "W m-2"      },
-  { 126, 0, "qres",           "residual heat flux for melting sea ice",    "W m-2"      },
-  { 127, 0, "alake",          "lake fraction of grid box",                 "fraction"   },
-  { 128, 0, "rintop",         "low level inversion",                        NULL        },
-  { 129, 0, "geosp",          "surface geopotential (orography)",          "m^2/s^2"    },
-  { 130, 0, "t",              "temperature",                               "K"          },
-  { 131, 0, "u",              "u-velocity",                                "m/s"        },
-  { 132, 0, "v",              "v-velocity",                                "m/s"        },
-  { 133, 0, "q",              "specific humidity",                         "kg/kg"      },
-  { 134, 0, "aps",            "surface pressure",                          "Pa"         },
-  { 135, 0, "omega",          "vertical velocity",                         "Pa/s"       },
-  { 136, 0, "acdnc",          "cloud droplet number concentration",        "1 m-3"      },
-  { 137, 0, "apmeb",          "vert. integr. tendencies of water",         "kg m-2 s-1" },
-  { 138, 0, "svo",            "vorticity",                                 "1/s"        },
-  { 139, 0, "tslm1",          "surface temperature of land",               "K"          },
-  { 140, 0, "ws",             "soil wetness",                              "m"          },
-  { 141, 0, "sn",             "snow depth",                                "m"          },
-  { 142, 0, "aprl",           "large scale precipitation",                 "kg m-2 s-1" },
-  { 143, 0, "aprc",           "convective  precipitation",                 "kg m-2 s-1" },
-  { 144, 0, "aprs",           "snow fall",                                 "kg m-2 s-1" },
-  { 145, 0, "vdis",           "boundary layer dissipation",                "W m-2"      },
-  { 146, 0, "ahfs",           "sensible heat flux",                        "W m-2"      },
-  { 147, 0, "ahfl",           "latent heat flux",                          "W m-2"      },
-  { 148, 0, "stream",         "streamfunction",                            "m^2/s"      },
-  { 149, 0, "velopot",        "velocity potential",                        "m^2/s"      },
-  { 150, 0, "xivi",           "vertically integrated cloud ice",           "kg m-2"     },
-  { 151, 0, "slp",            "mean sea level pressure",                   "Pa"         },
-  { 152, 0, "lsp",            "log surface pressure",                       NULL        },
-  { 153, 0, "xl",             "cloud water",                               "kg/kg"      },
-  { 154, 0, "xi",             "cloud ice",                                 "kg/kg"      },
-  { 155, 0, "sd",             "divergence",                                "1/s"        },
-  { 156, 0, "geopoth",        "geopotential height",                       "m"          },
-  { 157, 0, "rhumidity",      "relative humidity",                         "fraction"   },
-  { 158, 0, "var158",         "tendency of surface pressure",              "Pa/s"       },
-  { 159, 0, "wind10w",        "10m windspeed over water",                  "m/s"        },
-  { 160, 0, "runoff",         "surface runoff and drainage",               "kg m-2 s-1" },
-  { 161, 0, "drain",          "drainage",                                  "kg m-2 s-1" },
-  { 162, 0, "aclc",           "cloud cover",                                NULL        },
-  { 163, 0, "aclcv",          "total cloud cover",                          NULL        },
-  { 164, 0, "aclcov",         "total cloud cover (mean)",                   NULL        },
-  { 165, 0, "u10",            "10m u-velocity",                            "m/s"        },
-  { 166, 0, "v10",            "10m v-velocity",                            "m/s"        },
-  { 167, 0, "temp2",          "2m temperature",                            "K"          },
-  { 168, 0, "dew2",           "2m dew point temperature",                  "K"          },
-  { 169, 0, "tsurf",          "surface temperature",                       "K"          },
-  { 170, 0, "xvar",           "variance of total water amount qv+qi+ql",   "kg/kg"      },
-  { 171, 0, "wind10",         "10m windspeed",                             "m/s"        },
-  { 172, 0, "slm",            "land sea mask (1. = land, 0. = sea/lakes)",  NULL        },
-  { 173, 0, "az0",            "roughness length",                          "m"          },
-  { 174, 0, "alb",            "surface background albedo",                  NULL        },
-  { 175, 0, "albedo",         "surface albedo",                             NULL        },
-  { 176, 0, "srads",          "net surface solar radiation",               "W m-2"      },
-  { 177, 0, "trads",          "net surface thermal radiation",             "W m-2"      },
-  { 178, 0, "srad0",          "net top solar radiation",                   "W m-2"      },
-  { 179, 0, "trad0",          "top thermal radiation (OLR)",               "W m-2"      },
-  { 180, 0, "ustr",           "u-stress",                                  "Pa"         },
-  { 181, 0, "vstr",           "v-stress",                                  "Pa"         },
-  { 182, 0, "evap",           "evaporation",                               "kg m-2 s-1" },
-  { 183, 0, "xskew",          "skewness of total water amount qv+qi+ql",    NULL        },
-  { 184, 0, "srad0d",         "top incoming solar radiation",              "W m-2"      },
-  { 185, 0, "srafs",          "net surf. solar radiation   (clear sky)",   "W m-2"      },
-  { 186, 0, "trafs",          "net surf. thermal radiation (clear sky)",   "W m-2"      },
-  { 187, 0, "sraf0",          "net top solar radiation     (clear sky)",   "W m-2"      },
-  { 188, 0, "traf0",          "net top thermal radiation   (clear sky)",   "W m-2"      },
-  { 189, 0, "sclfs",          "surface solar cloud forcing",               "W m-2"      },
-  { 190, 0, "tclfs",          "surface thermal cloud forcing",             "W m-2"      },
-  { 191, 0, "sclf0",          "SW top cloud forcing (178-187)",            "W m-2"      },
-  { 192, 0, "tclf0",          "LW top cloud forcing (179-188)",            "W m-2"      },
-  { 193, 0, "wl",             "skin reservoir content",                    "m"          },
-  { 194, 0, "slf",            "sea land fraction",                          NULL        },
-  { 195, 0, "ustrgw",         "u-gravity wave stress",                     "Pa"         },
-  { 196, 0, "vstrgw",         "v-gravity wave stress",                     "Pa"         },
-  { 197, 0, "vdisgw",         "gravity wave dissipation",                  "W m-2"      },
-  { 198, 0, "vgrat",          "vegetation ratio",                           NULL        },
-  { 199, 0, "orostd",         "orographic standard deviation",             "m"          },
-  { 200, 0, "vlt",            "leaf area index",                            NULL        },
-  { 201, 0, "t2max",          "maximum 2m-temperature",                    "K"          },
-  { 202, 0, "t2min",          "minimum 2m-temperature",                    "K"          },
-  { 203, 0, "srad0u",         "top solar radiation upward",                "W m-2"      },
-  { 204, 0, "sradsu",         "surface solar radiation upward",            "W m-2"      },
-  { 205, 0, "tradsu",         "surface thermal radiation upward",          "W m-2"      },
-  { 206, 0, "grndflux",       "surface ground heat flux",                   NULL        },
-  { 207, 0, "tsoil",          "deep soil temperatures (5 layers)",         "K"          },
-  { 208, 0, "ahfcon",         "conductive heat flux through ice",          "W m-2"      },
-  { 209, 0, "ahfres",         "melting of ice",                            "W m-2"      },
-  { 210, 0, "seaice",         "ice cover (fraction of 1-SLM)",              NULL        },
-  { 211, 0, "siced",          "ice depth",                                 "m"          },
-  { 212, 0, "forest",         "forest fraction",                            NULL        },
-  { 213, 0, "gld",            "glacier depth",                             "m"          },
-  { 214, 0, "sni",            "water equivalent of snow on ice",           "m"          },
-  { 215, 0, "rogl",           "glacier runoff",                            "kg m-2 s-1" },
-  { 216, 0, "wimax",          "maximum 10m-wind speed",                    "m/s"        },
-  { 217, 0, "topmax",         "maximum height of convective cloud tops",   "Pa"         },
-  { 218, 0, "snmel",          "snow melt",                                 "kg m-2 s-1" },
-  { 219, 0, "runtoc",         "surface runoff into ocean",                 "kg m-2 s-1" },
-  { 220, 0, "runlnd",         "surface runoff not running into ocean",     "kg m-2 s-1" },
-  { 221, 0, "apmegl",         "P-E over land ice",                         "kg m-2 s-1" },
-  { 222, 0, "snacl",          "snow accumulation over land",               "kg m-2 s-1" },
-  { 223, 0, "aclcac",         "cloud cover",                                NULL        },
-  { 224, 0, "tke",            "turbulent kinetic energy",                  "m^2/s^2"    },
-  { 225, 0, "tkem1",          "turbulent kinetic energy (t-1)",            "m^2/s^2"    },
-  { 226, 0, "fao",            "FAO data set (soil data flags)",            "0...5"      },
-  { 227, 0, "rgcgn",          "heat capacity of soil",                      NULL        },
-  { 228, 0, "sodif",          "diffusivity of soil and land ice",          "m^2/s"      },
-  { 229, 0, "wsmx",           "field capacity of soil",                    "m"          },
-  { 230, 0, "qvi",            "vertically integrated water vapor",         "kg m-2"     },
-  { 231, 0, "xlvi",           "vertically integrated cloud water",         "kg m-2"     },
-  { 232, 0, "glac",           "fraction of land covered by glaciers",       NULL        },
-  { 233, 0, "snc",            "snow depth at the canopy",                  "m"          },
-  { 234, 0, "rtype",          "type of convection",                        "0...3"      },
-  { 235, 0, "abso4",          "antropogenic sulfur burden",                "kg m-2"     },
-  { 236, 0, "ao3",            "ipcc ozone",                                "kg m-2"     },
-  { 237, 0, "tropo",          "WMO defined tropopause height",             "Pa"         },
-  { 259, 0, "windspeed",      "windspeed (sqrt(u^2+v^2))",                 "m/s"        },
-  { 260, 0, "precip",         "total precipitation  (142+143)",            "kg m-2 s-1" },
-  { 261, 0, "net_top",        "total top radiation  (178+179)",            "W m-2"      },
-  { 262, 0, "net_bot",        "total surface radiation (176+177)",         "W m-2"      },
-  { 272, 0, "mastfru",        "mass stream function",                      "kg/s"       },
+static const param_type echam6[] = {
+  {   4, -1, 0, "precip",         "total precipitation",                       "kg m-2 s-1" },
+  {  34, -1, 0, "low_cld",        "low cloud",                                  NULL        },
+  {  35, -1, 0, "mid_cld",        "mid cloud",                                  NULL        },
+  {  36, -1, 0, "hih_cld",        "high cloud",                                 NULL        },
+  {  68, -1, 0, "fage",           "aging factor of snow on ice",                NULL        },
+  {  69, -1, 0, "snifrac",        "fraction of ice covered with snow",          NULL        },
+  {  70, -1, 0, "barefrac",       "bare ice fraction",                          NULL        },
+  {  71, -1, 0, "alsom",          "albedo of melt ponds",                       NULL        },
+  {  72, -1, 0, "alsobs",         "albedo of bare ice and snow",                NULL        },
+  {  73, -1, 0, "sicepdw",        "melt pond depth on sea-ice",                "m"          },
+  {  74, -1, 0, "sicepdi",        "ice thickness on melt pond",                "m"          },
+  {  75, -1, 0, "tsicepdi",       "ice temperature on frozen melt pond",       "K"          },
+  {  76, -1, 0, "sicepres",       "residual heat flux",                        "W m-2"      },
+  {  77, -1, 0, "ameltdepth",     "total melt pond depth",                     "m"          },
+  {  78, -1, 0, "ameltfrac",      "fractional area of melt ponds on sea-ice",   NULL        },
+  {  79, -1, 0, "albedo_vis_dir", "surface albedo visible range direct",        NULL        },
+  {  80, -1, 0, "albedo_nir_dir", "surface albedo NIR range direct",            NULL        },
+  {  81, -1, 0, "albedo_vis_dif", "surface albedo visible range diffuse",       NULL        },
+  {  82, -1, 0, "albedo_nir_dif", "surface albedo NIR range diffuse",           NULL        },
+  {  83, -1, 0, "ocu",            "ocean eastw. velocity (coupled mode)",      "m/s"        },
+  {  84, -1, 0, "ocv",            "ocean northw. velocity (coupled mode)",     "m/s"        },
+  {  85, -1, 0, "tradl",          "thermal radiation 200mb",                   "W m-2"      },
+  {  86, -1, 0, "sradl",          "solar radiation 200mb",                     "W m-2"      },
+  {  87, -1, 0, "trafl",          "thermal radiation 200mb (clear sky)",       "W m-2"      },
+  {  88, -1, 0, "srafl",          "solar radiation 200mb (clear sky)",         "W m-2"      },
+  {  89, -1, 0, "amlcorac",       "mixed layer flux correction",               "W m-2"      },
+  {  90, -1, 0, "amlheatac",      "mixed layer heat content",                  "J m-2"      },
+  {  91, -1, 0, "trfliac",        "LW flux over ice",                          "W m-2"      },
+  {  92, -1, 0, "trflwac",        "LW flux over water",                        "W m-2"      },
+  {  93, -1, 0, "trfllac",        "LW flux over land",                         "W m-2"      },
+  {  94, -1, 0, "sofliac",        "SW flux over ice",                          "W m-2"      },
+  {  95, -1, 0, "soflwac",        "SW flux over water",                        "W m-2"      },
+  {  96, -1, 0, "sofllac",        "SW flux over land",                         "W m-2"      },
+  {  97, -1, 0, "friac",          "ice cover (fraction of grid box)",           NULL        },
+  { 102, -1, 0, "tsi",            "surface temperature of ice",                "K"          },
+  { 103, -1, 0, "tsw",            "surface temperature of water",              "K"          },
+  { 104, -1, 0, "ustri",          "zonal      wind stress over ice",           "Pa"         },
+  { 105, -1, 0, "vstri",          "meridional wind stress over ice",           "Pa"         },
+  { 106, -1, 0, "ustrw",          "zonal      wind stress over water",         "Pa"         },
+  { 107, -1, 0, "vstrw",          "meridional wind stress over water",         "Pa"         },
+  { 108, -1, 0, "ustrl",          "zonal      wind stress over land",          "Pa"         },
+  { 109, -1, 0, "vstrl",          "meridional wind stress over land",          "Pa"         },
+  { 110, -1, 0, "ahfliac",        "latent heat flux over ice",                 "W m-2"      },
+  { 111, -1, 0, "ahflwac",        "latent heat flux over water",               "W m-2"      },
+  { 112, -1, 0, "ahfllac",        "latent heat flux over land",                "W m-2"      },
+  { 113, -1, 0, "evapiac",        "evaporation over ice",                      "kg m-2 s-1" },
+  { 114, -1, 0, "evapwac",        "evaporation over water",                    "kg m-2 s-1" },
+  { 115, -1, 0, "evaplac",        "evaporation over land",                     "kg m-2 s-1" },
+  { 116, -1, 0, "az0i",           "roughness length over ice",                 "m"          },
+  { 117, -1, 0, "az0w",           "roughness length over water",               "m"          },
+  { 118, -1, 0, "az0l",           "roughness length over land",                "m"          },
+  { 119, -1, 0, "ahfsiac",        "sensible heat flux over ice",               "W m-2"      },
+  { 120, -1, 0, "ahfswac",        "sensible heat flux over water",             "W m-2"      },
+  { 121, -1, 0, "ahfslac",        "sensible heat flux over land",              "W m-2"      },
+  { 122, -1, 0, "alsoi",          "albedo of ice",                              NULL        },
+  { 123, -1, 0, "alsow",          "albedo of water",                            NULL        },
+  { 124, -1, 0, "alsol",          "albedo of land",                             NULL        },
+  { 125, -1, 0, "ahfice",         "conductive heat flux",                      "W m-2"      },
+  { 126, -1, 0, "qres",           "residual heat flux for melting sea ice",    "W m-2"      },
+  { 127, -1, 0, "alake",          "lake fraction of grid box",                 "fraction"   },
+  { 128, -1, 0, "rintop",         "low level inversion",                        NULL        },
+  { 129, -1, 0, "geosp",          "surface geopotential (orography)",          "m^2/s^2"    },
+  { 130, -1, 0, "t",              "temperature",                               "K"          },
+  { 131, -1, 0, "u",              "u-velocity",                                "m/s"        },
+  { 132, -1, 0, "v",              "v-velocity",                                "m/s"        },
+  { 133, -1, 0, "q",              "specific humidity",                         "kg/kg"      },
+  { 134, -1, 0, "aps",            "surface pressure",                          "Pa"         },
+  { 135, -1, 0, "omega",          "vertical velocity",                         "Pa/s"       },
+  { 136, -1, 0, "acdnc",          "cloud droplet number concentration",        "1 m-3"      },
+  { 137, -1, 0, "apmeb",          "vert. integr. tendencies of water",         "kg m-2 s-1" },
+  { 138, -1, 0, "svo",            "vorticity",                                 "1/s"        },
+  { 139, -1, 0, "tslm1",          "surface temperature of land",               "K"          },
+  { 140, -1, 0, "ws",             "soil wetness",                              "m"          },
+  { 141, -1, 0, "sn",             "snow depth",                                "m"          },
+  { 142, -1, 0, "aprl",           "large scale precipitation",                 "kg m-2 s-1" },
+  { 143, -1, 0, "aprc",           "convective  precipitation",                 "kg m-2 s-1" },
+  { 144, -1, 0, "aprs",           "snow fall",                                 "kg m-2 s-1" },
+  { 145, -1, 0, "vdis",           "boundary layer dissipation",                "W m-2"      },
+  { 146, -1, 0, "ahfs",           "sensible heat flux",                        "W m-2"      },
+  { 147, -1, 0, "ahfl",           "latent heat flux",                          "W m-2"      },
+  { 148, -1, 0, "stream",         "streamfunction",                            "m^2/s"      },
+  { 149, -1, 0, "velopot",        "velocity potential",                        "m^2/s"      },
+  { 150, -1, 0, "xivi",           "vertically integrated cloud ice",           "kg m-2"     },
+  { 151, -1, 0, "slp",            "mean sea level pressure",                   "Pa"         },
+  { 152, -1, 0, "lsp",            "log surface pressure",                       NULL        },
+  { 153, -1, 0, "xl",             "cloud water",                               "kg/kg"      },
+  { 154, -1, 0, "xi",             "cloud ice",                                 "kg/kg"      },
+  { 155, -1, 0, "sd",             "divergence",                                "1/s"        },
+  { 156, -1, 0, "geopoth",        "geopotential height",                       "m"          },
+  { 157, -1, 0, "rhumidity",      "relative humidity",                         "fraction"   },
+  { 158, -1, 0, "var158",         "tendency of surface pressure",              "Pa/s"       },
+  { 159, -1, 0, "wind10w",        "10m windspeed over water",                  "m/s"        },
+  { 160, -1, 0, "runoff",         "surface runoff and drainage",               "kg m-2 s-1" },
+  { 161, -1, 0, "drain",          "drainage",                                  "kg m-2 s-1" },
+  { 162, -1, 0, "aclc",           "cloud cover",                                NULL        },
+  { 163, -1, 0, "aclcv",          "total cloud cover",                          NULL        },
+  { 164, -1, 0, "aclcov",         "total cloud cover (mean)",                   NULL        },
+  { 165, -1, 0, "u10",            "10m u-velocity",                            "m/s"        },
+  { 166, -1, 0, "v10",            "10m v-velocity",                            "m/s"        },
+  { 167, -1, 0, "temp2",          "2m temperature",                            "K"          },
+  { 168, -1, 0, "dew2",           "2m dew point temperature",                  "K"          },
+  { 169, -1, 0, "tsurf",          "surface temperature",                       "K"          },
+  { 170, -1, 0, "xvar",           "variance of total water amount qv+qi+ql",   "kg/kg"      },
+  { 171, -1, 0, "wind10",         "10m windspeed",                             "m/s"        },
+  { 172, -1, 0, "slm",            "land sea mask (1. = land, 0. = sea/lakes)",  NULL        },
+  { 173, -1, 0, "az0",            "roughness length",                          "m"          },
+  { 174, -1, 0, "alb",            "surface background albedo",                  NULL        },
+  { 175, -1, 0, "albedo",         "surface albedo",                             NULL        },
+  { 176, -1, 0, "srads",          "net surface solar radiation",               "W m-2"      },
+  { 177, -1, 0, "trads",          "net surface thermal radiation",             "W m-2"      },
+  { 178, -1, 0, "srad0",          "net top solar radiation",                   "W m-2"      },
+  { 179, -1, 0, "trad0",          "top thermal radiation (OLR)",               "W m-2"      },
+  { 180, -1, 0, "ustr",           "u-stress",                                  "Pa"         },
+  { 181, -1, 0, "vstr",           "v-stress",                                  "Pa"         },
+  { 182, -1, 0, "evap",           "evaporation",                               "kg m-2 s-1" },
+  { 183, -1, 0, "xskew",          "skewness of total water amount qv+qi+ql",    NULL        },
+  { 184, -1, 0, "srad0d",         "top incoming solar radiation",              "W m-2"      },
+  { 185, -1, 0, "srafs",          "net surf. solar radiation   (clear sky)",   "W m-2"      },
+  { 186, -1, 0, "trafs",          "net surf. thermal radiation (clear sky)",   "W m-2"      },
+  { 187, -1, 0, "sraf0",          "net top solar radiation     (clear sky)",   "W m-2"      },
+  { 188, -1, 0, "traf0",          "net top thermal radiation   (clear sky)",   "W m-2"      },
+  { 189, -1, 0, "sclfs",          "surface solar cloud forcing",               "W m-2"      },
+  { 190, -1, 0, "tclfs",          "surface thermal cloud forcing",             "W m-2"      },
+  { 191, -1, 0, "sclf0",          "SW top cloud forcing (178-187)",            "W m-2"      },
+  { 192, -1, 0, "tclf0",          "LW top cloud forcing (179-188)",            "W m-2"      },
+  { 193, -1, 0, "wl",             "skin reservoir content",                    "m"          },
+  { 194, -1, 0, "slf",            "sea land fraction",                          NULL        },
+  { 195, -1, 0, "ustrgw",         "u-gravity wave stress",                     "Pa"         },
+  { 196, -1, 0, "vstrgw",         "v-gravity wave stress",                     "Pa"         },
+  { 197, -1, 0, "vdisgw",         "gravity wave dissipation",                  "W m-2"      },
+  { 198, -1, 0, "vgrat",          "vegetation ratio",                           NULL        },
+  { 199, -1, 0, "orostd",         "orographic standard deviation",             "m"          },
+  { 200, -1, 0, "vlt",            "leaf area index",                            NULL        },
+  { 201, -1, 0, "t2max",          "maximum 2m-temperature",                    "K"          },
+  { 202, -1, 0, "t2min",          "minimum 2m-temperature",                    "K"          },
+  { 203, -1, 0, "srad0u",         "top solar radiation upward",                "W m-2"      },
+  { 204, -1, 0, "sradsu",         "surface solar radiation upward",            "W m-2"      },
+  { 205, -1, 0, "tradsu",         "surface thermal radiation upward",          "W m-2"      },
+  { 206, -1, 0, "grndflux",       "surface ground heat flux",                   NULL        },
+  { 207, -1, 0, "tsoil",          "deep soil temperatures (5 layers)",         "K"          },
+  { 208, -1, 0, "ahfcon",         "conductive heat flux through ice",          "W m-2"      },
+  { 209, -1, 0, "ahfres",         "melting of ice",                            "W m-2"      },
+  { 210, -1, 0, "seaice",         "ice cover (fraction of 1-SLM)",              NULL        },
+  { 211, -1, 0, "siced",          "ice depth",                                 "m"          },
+  { 212, -1, 0, "forest",         "forest fraction",                            NULL        },
+  { 213, -1, 0, "gld",            "glacier depth",                             "m"          },
+  { 214, -1, 0, "sni",            "water equivalent of snow on ice",           "m"          },
+  { 215, -1, 0, "rogl",           "glacier runoff",                            "kg m-2 s-1" },
+  { 216, -1, 0, "wimax",          "maximum 10m-wind speed",                    "m/s"        },
+  { 217, -1, 0, "topmax",         "maximum height of convective cloud tops",   "Pa"         },
+  { 218, -1, 0, "snmel",          "snow melt",                                 "kg m-2 s-1" },
+  { 219, -1, 0, "runtoc",         "surface runoff into ocean",                 "kg m-2 s-1" },
+  { 220, -1, 0, "runlnd",         "surface runoff not running into ocean",     "kg m-2 s-1" },
+  { 221, -1, 0, "apmegl",         "P-E over land ice",                         "kg m-2 s-1" },
+  { 222, -1, 0, "snacl",          "snow accumulation over land",               "kg m-2 s-1" },
+  { 223, -1, 0, "aclcac",         "cloud cover",                                NULL        },
+  { 224, -1, 0, "tke",            "turbulent kinetic energy",                  "m^2/s^2"    },
+  { 225, -1, 0, "tkem1",          "turbulent kinetic energy (t-1)",            "m^2/s^2"    },
+  { 226, -1, 0, "fao",            "FAO data set (soil data flags)",            "0...5"      },
+  { 227, -1, 0, "rgcgn",          "heat capacity of soil",                      NULL        },
+  { 228, -1, 0, "sodif",          "diffusivity of soil and land ice",          "m^2/s"      },
+  { 229, -1, 0, "wsmx",           "field capacity of soil",                    "m"          },
+  { 230, -1, 0, "qvi",            "vertically integrated water vapor",         "kg m-2"     },
+  { 231, -1, 0, "xlvi",           "vertically integrated cloud water",         "kg m-2"     },
+  { 232, -1, 0, "glac",           "fraction of land covered by glaciers",       NULL        },
+  { 233, -1, 0, "snc",            "snow depth at the canopy",                  "m"          },
+  { 234, -1, 0, "rtype",          "type of convection",                        "0...3"      },
+  { 235, -1, 0, "abso4",          "antropogenic sulfur burden",                "kg m-2"     },
+  { 236, -1, 0, "ao3",            "ipcc ozone",                                "kg m-2"     },
+  { 237, -1, 0, "tropo",          "WMO defined tropopause height",             "Pa"         },
+  { 259, -1, 0, "windspeed",      "windspeed (sqrt(u^2+v^2))",                 "m/s"        },
+  { 260, -1, 0, "precip",         "total precipitation  (142+143)",            "kg m-2 s-1" },
+  { 261, -1, 0, "net_top",        "total top radiation  (178+179)",            "W m-2"      },
+  { 262, -1, 0, "net_bot",        "total surface radiation (176+177)",         "W m-2"      },
+  { 272, -1, 0, "mastfru",        "mass stream function",                      "kg/s"       },
 };
 
-static const PAR mpiom1[] = {
-  {   2, 0, "THO",      "temperature",                     "C"        },
-  {   5, 0, "SAO",      "salinity",                        "psu"      },
-  {   3, 0, "UKO",      "zon. velocity",                   "m/s"      },
-  {   4, 0, "VKE",      "mer. velocity",                   "m/s"      },
-  { 303, 0, "UKOMFL",   "zon. velocity (divergence free)", "m/s"      },
-  { 304, 0, "VKEMFL",   "mer. velocity (divergence free)", "m/s"      },
-  {   7, 0, "WO",       "ver. velocity",                   "m/s"      },
-  {   8, 0, "RHO",      "insitu density",                  "kg/m**3"  },
-  {   6, 0, "PO",       "pressure",                        "Pa"       },
-  {  67, 0, "EMINPO",   "freshwaterflux by restoring",     "m/s"      },
-  {  70, 0, "FLUM",     "total heatflux",                  "W/m**2"   },
-  {  79, 0, "PEM",      "total freshwaterflux",            "m/s"      },
-  {  13, 0, "SICTHO",   "ice thickness",                   "m"        },
-  {  15, 0, "SICOMO",   "ice compactness",                 "frac."    },
-  {  35, 0, "SICUO",    "zon. ice velocity",               "m/s"      },
-  {  36, 0, "SICVE",    "mer. ice velocity",               "m/s"      },
-  {  92, 0, "TAFO",     "surface air temperature",         "C"        },
-  { 164, 0, "FCLOU",    "cloud cover",                      NULL      },
-  {  52, 0, "TXO",      "surface u-stress",                "Pa/1025." },
-  {  53, 0, "TYE",      "surface v-stress",                "Pa/1025." },
-  { 260, 0, "FPREC",    "prescr. precipitation",           "m/s"      },
-  {  80, 0, "FSWR",     "downward shortwave rad.",         "W/m**2"   },
-  {  81, 0, "FTDEW",    "dewpoint temperature",            "K"        },
-  { 171, 0, "FU10",     "10m windspeed",                   "m/s"      },
-  { 141, 0, "SICSNO",   "snow thickness",                  "m"        },
-  { 176, 0, "QSWO",     "heat flux shortwave",             "W/m**2"   },
-  { 177, 0, "QLWO",     "heat flux longwave",              "W/m**2"   },
-  { 147, 0, "QLAO",     "heat flux latent",                "W/m**2"   },
-  { 146, 0, "QSEO",     "heat flux sensible",              "W/m**2"   },
-  {  65, 0, "PRECO",    "net freshwater flux + runoff",    "m/s"      },
-  {   1, 0, "ZO",       "sealevel",                        "m"        },
-  {  82, 0, "Z1O",      "sealevel change",                 "m"        },
-  {  69, 0, "KCONDEP",  "depth of convection",             "level"    },
-  {  27, 0, "PSIUWE",   "hor. bar. streamfunction",        "Sv"       },
-  {  83, 0, "AMLD",     "mixed layer depth",               "m"        },
-  { 172, 0, "WETO",     "landseamask (pressure points)",    NULL      },
-  { 507, 0, "AMSUE",    "landseamask (vector points v)",    NULL      },
-  { 508, 0, "AMSUO",    "landseamask (vector points u)",    NULL      },
-  {  84, 0, "DEPTO",    "depth at pressure points",        "m"        },
-  { 484, 0, "DEUTO",    "depth at vector points (u)",      "m"        },
-  { 584, 0, "DEUTE",    "depth at vector points (v)",      "m"        },
-  { 184, 0, "DDUO",     "level thickness (vector u )",     "m"        },
-  { 284, 0, "DDUE",     "level thickness (vector v )",     "m"        },
-  { 384, 0, "DDPO",     "level thickness (pressure )",     "m"        },
-  {  85, 0, "DLXP",     "grid distance x",                 "m"        },
-  {  86, 0, "DLYP",     "grid distance y",                 "m"        },
-  { 185, 0, "DLXU",     "grid distance x  (vector u)",     "m"        },
-  { 186, 0, "DLYU",     "grid distance y  (vector u)",     "m"        },
-  { 285, 0, "DLXV",     "grid distance x  (vector v)",     "m"        },
-  { 286, 0, "DLYV",     "grid distance y  (vector v)",     "m"        },
-  {  54, 0, "GILA",     "latitude in radiants",            "rad"      },
-  {  55, 0, "GIPH",     "longitude in radiants",           "rad"      },
-  { 354, 0, "ALAT",     "latitude in degrees (pressure)",  "deg"      },
-  { 355, 0, "ALON",     "longitude in degrees (pressure)", "deg"      },
-  { 154, 0, "ALATU",    "latitude in degrees (vector u)",  "deg"      },
-  { 155, 0, "ALONU",    "longitude in degrees (vector u)", "deg"      },
-  { 254, 0, "ALATV",    "latitude in degrees (vector v)",  "deg"      },
-  { 255, 0, "ALONV",    "longitude in degrees (vector v)", "deg"      },
-  { 110, 0, "AVO",      "vertical impuls diffusion",       "m**2/s"   },
-  { 111, 0, "DVO",      "vertical T,S diffusion",          "m**2/s"   },
-  { 142, 0, "SICTRU",   "seaice transport x",              "m**2/s"   },
-  { 143, 0, "SICTRV",   "seaice transport y",              "m**2/s"   },
-  { 612, 0, "WTMIX",    "wind mixing",                     "m**2/s"   },
-  { 183, 0, "zmld",     "mixed layer depth (SJ)",          "m"        },
-  { 207, 0, "WGO",      "GM vertical velocity",            "m/s"      },
-  { 305, 0, "rivrun",   "RiverRunoff",                     "m/s"      },
-  { 158, 0, "TMCDO",    "mon. mean depth of convection",   "level"    },
-  { 247, 0, "DQSWO",    "heatflux sw over water",          "W/m**2"   },
-  { 248, 0, "DQLWO",    "heatflux lw over water",          "W/m**2"   },
-  { 249, 0, "DQSEO",    "heatflux se over water",          "W/m**2"   },
-  { 250, 0, "DQLAO",    "heatflux la over water",          "W/m**2"   },
-  { 251, 0, "DQTHO",    "heatflux net over water",         "W/m**2"   },
-  { 252, 0, "DQSWI",    "heatflux sw over seaice",         "W/m**2"   },
-  { 253, 0, "DQLWI",    "heatflux lw over seaice",         "W/m**2"   },
-  { 254, 0, "DQSEI",    "heatflux se over seaice",         "W/m**2"   },
-  { 255, 0, "DQLAI",    "heatflux la over seaice",         "W/m**2"   },
-  { 256, 0, "DQTHI",    "heatflux net over seaice",        "W/m**2"   },
-  { 257, 0, "DTICEO",   "Equi. temp over seaice",          "K"        },
-  { 270, 0, "AOFLNHWO", "oasis net heat flux water",       "W/m**2"   },
-  { 271, 0, "AOFLSHWO", "oasis downward short wave",       "W/m**2"   },
-  { 272, 0, "AOFLRHIO", "oasis residual heat flux ice",    "W/m**2"   },
-  { 273, 0, "AOFLCHIO", "oasis conduct. heat flux ice",    "W/m**2"   },
-  { 274, 0, "AOFLFRWO", "oasis fluid fresh water flux",    "m/s"      },
-  { 275, 0, "AOFLFRIO", "oasis solid fresh water flux",    "m/s"      },
-  { 276, 0, "AOFLTXWO", "oasis wind stress water x",       "Pa/102"   },
-  { 277, 0, "AOFLTYWO", "oasis wind stress water y",       "Pa/102"   },
-  { 278, 0, "AOFLTXIO", "oasis wind stress ice x",         "Pa/102"   },
-  { 279, 0, "AOFLTYIO", "oasis wind stress ice x",         "Pa/102"   },
-  { 280, 0, "AOFLWSVO", "oasis wind speed",                "m/s"      },
+static const param_type mpiom1[] = {
+  {   2, -1, 0, "THO",      "temperature",                     "C"        },
+  {   5, -1, 0, "SAO",      "salinity",                        "psu"      },
+  {   3, -1, 0, "UKO",      "zon. velocity",                   "m/s"      },
+  {   4, -1, 0, "VKE",      "mer. velocity",                   "m/s"      },
+  { 303, -1, 0, "UKOMFL",   "zon. velocity (divergence free)", "m/s"      },
+  { 304, -1, 0, "VKEMFL",   "mer. velocity (divergence free)", "m/s"      },
+  {   7, -1, 0, "WO",       "ver. velocity",                   "m/s"      },
+  {   8, -1, 0, "RHO",      "insitu density",                  "kg/m**3"  },
+  {   6, -1, 0, "PO",       "pressure",                        "Pa"       },
+  {  67, -1, 0, "EMINPO",   "freshwaterflux by restoring",     "m/s"      },
+  {  70, -1, 0, "FLUM",     "total heatflux",                  "W/m**2"   },
+  {  79, -1, 0, "PEM",      "total freshwaterflux",            "m/s"      },
+  {  13, -1, 0, "SICTHO",   "ice thickness",                   "m"        },
+  {  15, -1, 0, "SICOMO",   "ice compactness",                 "frac."    },
+  {  35, -1, 0, "SICUO",    "zon. ice velocity",               "m/s"      },
+  {  36, -1, 0, "SICVE",    "mer. ice velocity",               "m/s"      },
+  {  92, -1, 0, "TAFO",     "surface air temperature",         "C"        },
+  { 164, -1, 0, "FCLOU",    "cloud cover",                      NULL      },
+  {  52, -1, 0, "TXO",      "surface u-stress",                "Pa/1025." },
+  {  53, -1, 0, "TYE",      "surface v-stress",                "Pa/1025." },
+  { 260, -1, 0, "FPREC",    "prescr. precipitation",           "m/s"      },
+  {  80, -1, 0, "FSWR",     "downward shortwave rad.",         "W/m**2"   },
+  {  81, -1, 0, "FTDEW",    "dewpoint temperature",            "K"        },
+  { 171, -1, 0, "FU10",     "10m windspeed",                   "m/s"      },
+  { 141, -1, 0, "SICSNO",   "snow thickness",                  "m"        },
+  { 176, -1, 0, "QSWO",     "heat flux shortwave",             "W/m**2"   },
+  { 177, -1, 0, "QLWO",     "heat flux longwave",              "W/m**2"   },
+  { 147, -1, 0, "QLAO",     "heat flux latent",                "W/m**2"   },
+  { 146, -1, 0, "QSEO",     "heat flux sensible",              "W/m**2"   },
+  {  65, -1, 0, "PRECO",    "net freshwater flux + runoff",    "m/s"      },
+  {   1, -1, 0, "ZO",       "sealevel",                        "m"        },
+  {  82, -1, 0, "Z1O",      "sealevel change",                 "m"        },
+  {  69, -1, 0, "KCONDEP",  "depth of convection",             "level"    },
+  {  27, -1, 0, "PSIUWE",   "hor. bar. streamfunction",        "Sv"       },
+  {  83, -1, 0, "AMLD",     "mixed layer depth",               "m"        },
+  { 172, -1, 0, "WETO",     "landseamask (pressure points)",    NULL      },
+  { 507, -1, 0, "AMSUE",    "landseamask (vector points v)",    NULL      },
+  { 508, -1, 0, "AMSUO",    "landseamask (vector points u)",    NULL      },
+  {  84, -1, 0, "DEPTO",    "depth at pressure points",        "m"        },
+  { 484, -1, 0, "DEUTO",    "depth at vector points (u)",      "m"        },
+  { 584, -1, 0, "DEUTE",    "depth at vector points (v)",      "m"        },
+  { 184, -1, 0, "DDUO",     "level thickness (vector u )",     "m"        },
+  { 284, -1, 0, "DDUE",     "level thickness (vector v )",     "m"        },
+  { 384, -1, 0, "DDPO",     "level thickness (pressure )",     "m"        },
+  {  85, -1, 0, "DLXP",     "grid distance x",                 "m"        },
+  {  86, -1, 0, "DLYP",     "grid distance y",                 "m"        },
+  { 185, -1, 0, "DLXU",     "grid distance x  (vector u)",     "m"        },
+  { 186, -1, 0, "DLYU",     "grid distance y  (vector u)",     "m"        },
+  { 285, -1, 0, "DLXV",     "grid distance x  (vector v)",     "m"        },
+  { 286, -1, 0, "DLYV",     "grid distance y  (vector v)",     "m"        },
+  {  54, -1, 0, "GILA",     "latitude in radiants",            "rad"      },
+  {  55, -1, 0, "GIPH",     "longitude in radiants",           "rad"      },
+  { 354, -1, 0, "ALAT",     "latitude in degrees (pressure)",  "deg"      },
+  { 355, -1, 0, "ALON",     "longitude in degrees (pressure)", "deg"      },
+  { 154, -1, 0, "ALATU",    "latitude in degrees (vector u)",  "deg"      },
+  { 155, -1, 0, "ALONU",    "longitude in degrees (vector u)", "deg"      },
+  { 254, -1, 0, "ALATV",    "latitude in degrees (vector v)",  "deg"      },
+  { 255, -1, 0, "ALONV",    "longitude in degrees (vector v)", "deg"      },
+  { 110, -1, 0, "AVO",      "vertical impuls diffusion",       "m**2/s"   },
+  { 111, -1, 0, "DVO",      "vertical T,S diffusion",          "m**2/s"   },
+  { 142, -1, 0, "SICTRU",   "seaice transport x",              "m**2/s"   },
+  { 143, -1, 0, "SICTRV",   "seaice transport y",              "m**2/s"   },
+  { 612, -1, 0, "WTMIX",    "wind mixing",                     "m**2/s"   },
+  { 183, -1, 0, "zmld",     "mixed layer depth (SJ)",          "m"        },
+  { 207, -1, 0, "WGO",      "GM vertical velocity",            "m/s"      },
+  { 305, -1, 0, "rivrun",   "RiverRunoff",                     "m/s"      },
+  { 158, -1, 0, "TMCDO",    "mon. mean depth of convection",   "level"    },
+  { 247, -1, 0, "DQSWO",    "heatflux sw over water",          "W/m**2"   },
+  { 248, -1, 0, "DQLWO",    "heatflux lw over water",          "W/m**2"   },
+  { 249, -1, 0, "DQSEO",    "heatflux se over water",          "W/m**2"   },
+  { 250, -1, 0, "DQLAO",    "heatflux la over water",          "W/m**2"   },
+  { 251, -1, 0, "DQTHO",    "heatflux net over water",         "W/m**2"   },
+  { 252, -1, 0, "DQSWI",    "heatflux sw over seaice",         "W/m**2"   },
+  { 253, -1, 0, "DQLWI",    "heatflux lw over seaice",         "W/m**2"   },
+  { 254, -1, 0, "DQSEI",    "heatflux se over seaice",         "W/m**2"   },
+  { 255, -1, 0, "DQLAI",    "heatflux la over seaice",         "W/m**2"   },
+  { 256, -1, 0, "DQTHI",    "heatflux net over seaice",        "W/m**2"   },
+  { 257, -1, 0, "DTICEO",   "Equi. temp over seaice",          "K"        },
+  { 270, -1, 0, "AOFLNHWO", "oasis net heat flux water",       "W/m**2"   },
+  { 271, -1, 0, "AOFLSHWO", "oasis downward short wave",       "W/m**2"   },
+  { 272, -1, 0, "AOFLRHIO", "oasis residual heat flux ice",    "W/m**2"   },
+  { 273, -1, 0, "AOFLCHIO", "oasis conduct. heat flux ice",    "W/m**2"   },
+  { 274, -1, 0, "AOFLFRWO", "oasis fluid fresh water flux",    "m/s"      },
+  { 275, -1, 0, "AOFLFRIO", "oasis solid fresh water flux",    "m/s"      },
+  { 276, -1, 0, "AOFLTXWO", "oasis wind stress water x",       "Pa/102"   },
+  { 277, -1, 0, "AOFLTYWO", "oasis wind stress water y",       "Pa/102"   },
+  { 278, -1, 0, "AOFLTXIO", "oasis wind stress ice x",         "Pa/102"   },
+  { 279, -1, 0, "AOFLTYIO", "oasis wind stress ice x",         "Pa/102"   },
+  { 280, -1, 0, "AOFLWSVO", "oasis wind speed",                "m/s"      },
 };
 
-static const PAR ecmwf[] = {
-  {   1, 0, "STRF",     "Stream function",                                            "m**2 s**-1"            },
-  {   2, 0, "VPOT",     "Velocity potential",                                         "m**2 s**-1"            },
-  {   3, 0, "PT",       "Potential temperature",                                      "K"                     },
-  {   4, 0, "EQPT",     "Equivalent potential temperature",                           "K"                     },
-  {   5, 0, "SEPT",     "Saturated equivalent potential temperature",                 "K"                     },
-  {  11, 0, "UDVW",     "U component of divergent wind",                              "m s**-1"               },
-  {  12, 0, "VDVW",     "V component of divergent wind",                              "m s**-1"               },
-  {  13, 0, "URTW",     "U component of rotational wind",                             "m s**-1"               },
-  {  14, 0, "VRTW",     "V component of rotational wind",                             "m s**-1"               },
-  {  21, 0, "UCTP",     "Unbalanced component of temperature",                        "K"                     },
-  {  22, 0, "UCLN",     "Unbalanced component of logarithm of surface pressure",       NULL                   },
-  {  23, 0, "UCDV",     "Unbalanced component of divergence",                         "s**-1"                 },
-  {  26, 0, "CL",       "Lake cover",                                                  NULL                   },
-  {  27, 0, "CVL",      "Low vegetation cover",                                        NULL                   },
-  {  28, 0, "CVH",      "High vegetation cover",                                       NULL                   },
-  {  29, 0, "TVL",      "Type of low vegetation",                                      NULL                   },
-  {  30, 0, "TVH",      "Type of high vegetation",                                     NULL                   },
-  {  31, 0, "CI",       "Sea-ice cover",                                               NULL                   },
-  {  32, 0, "ASN",      "Snow albedo",                                                 NULL                   },
-  {  33, 0, "RSN",      "Snow density kg",                                            "m**-3"                 },
-  {  34, 0, "SSTK",     "Sea surface temperature",                                    "K"                     },
-  {  35, 0, "ISTL1",    "Ice surface temperature layer 1",                            "K"                     },
-  {  36, 0, "ISTL2",    "Ice surface temperature layer 2",                            "K"                     },
-  {  37, 0, "ISTL3",    "Ice surface temperature layer 3",                            "K"                     },
-  {  38, 0, "ISTL4",    "Ice surface temperature layer 4",                            "K"                     },
-  {  39, 0, "SWVL1",    "Volumetric soil water layer 1",                              "m**3 m**-3"            },
-  {  40, 0, "SWVL2",    "Volumetric soil water layer 2",                              "m**3 m**-3"            },
-  {  41, 0, "SWVL3",    "Volumetric soil water layer 3",                              "m**3 m**-3"            },
-  {  42, 0, "SWVL4",    "Volumetric soil water layer 4",                              "m**3 m**-3"            },
-  {  43, 0, "SLT",      "Soil type",                                                   NULL                   },
-  {  44, 0, "ES",       "Snow evaporation m of water",                                 NULL                   },
-  {  45, 0, "SMLT",     "Snowmelt m of water",                                         NULL                   },
-  {  46, 0, "SDUR",     "Solar duration",                                             "s"                     },
-  {  47, 0, "DSRP",     "Direct solar radiation",                                     "w m**-2"               },
-  {  48, 0, "MAGSS",    "Magnitude of surface stress",                                "N m**-2 s"             },
-  {  49, 0, "WG10",     "Wind gust at 10 metres",                                     "m s**-1"               },
-  {  50, 0, "LSPF",     "Large-scale precipitation fraction",                         "s"                     },
-  {  51, 0, "MX2T24",   "Maximum 2 metre temperature",                                "K"                     },
-  {  52, 0, "MN2T24",   "Minimum 2 metre temperature",                                "K"                     },
-  {  53, 0, "MONT",     "Montgomery potential",                                       "m**2 s**-2"            },
-  {  54, 0, "PRES",     "Pressure",                                                   "Pa"                    },
-  {  55, 0, "MEAN2T24", "Mean 2 metre temperature past 24 hours",                     "K"                     },
-  {  56, 0, "MEAN2D24", "Mean 2 metre dewpoint temperature past 24 hours",            "K"                     },
-  {  60, 0, "PV",       "Potential vorticity",                                        "K m**2 kg**-1 s**-1"   },
-  { 127, 0, "AT",       "Atmospheric tide",                                            NULL                   },
-  { 128, 0, "BV",       "Budget values",                                               NULL                   },
-  { 129, 0, "Z",        "Geopotential",                                               "m**2 s**-2"            },
-  { 130, 0, "T",        "Temperature",                                                "K"                     },
-  { 131, 0, "U",        "U velocity",                                                 "m s**-1"               },
-  { 132, 0, "V",        "V velocity",                                                 "m s**-1"               },
-  { 133, 0, "Q",        "Specific humidity",                                          "kg kg**-1"             },
-  { 134, 0, "SP",       "Surface pressure",                                           "Pa"                    },
-  { 135, 0, "W",        "Vertical velocity",                                          "Pa s**-1"              },
-  { 136, 0, "TCW",      "Total column water",                                         "kg m**-2"              },
-  { 137, 0, "TCWV",     "Total column water vapour",                                  "kg m**-2"              },
-  { 138, 0, "VO",       "Vorticity (relative)",                                       "s**-1"                 },
-  { 139, 0, "STL1",     "Soil temperature level 1",                                   "K"                     },
-  { 140, 0, "SWL1",     "Soil wetness level 1 m of water",                             NULL                   },
-  { 141, 0, "SD",       "Snow depth         1 m of water equivalent",                  NULL                   },
-  { 142, 0, "LSP",      "Stratiform precipitation (Large scale precipitation)",       "m"                     },
-  { 143, 0, "CP",       "Convective precipitation",                                   "m"                     },
-  { 144, 0, "SF",       "Snowfall (convective + stratiform)",                         "m"                     },
-  { 145, 0, "BLD",      "Boundary layer dissipation",                                 "W m**-2 s"             },
-  { 146, 0, "SSHF",     "Surface sensible heat flux",                                 "W m**-2 s"             },
-  { 147, 0, "SLHF",     "Surface latent heat flux",                                   "W m**-2 s"             },
-  { 148, 0, "CHNK",     "Charnock",                                                    NULL                   },
-  { 149, 0, "SNR",      "Surface net radiation",                                      "W m**-2 s"             },
-  { 150, 0, "TNR",      "Top net radiation",                                           NULL                   },
-  { 151, 0, "MSL",      "Mean sea-level pressure",                                    "Pa"                    },
-  { 152, 0, "LNSP",     "Logarithm of surface pressure",                               NULL                   },
-  { 153, 0, "SWHR",     "Short-wave heating rate",                                    "K"                     },
-  { 154, 0, "LWHR",     "Long-wave heating rate",                                     "K"                     },
-  { 155, 0, "D",        "Divergence",                                                 "s**-1"                 },
-  { 156, 0, "GH",       "Height m Geopotential height",                                NULL                   },
-  { 157, 0, "R",        "Relative humidity",                                          "%"                     },
-  { 158, 0, "TSP",      "Tendency of surface pressure",                               "Pa s**-1"              },
-  { 159, 0, "BLH",      "Boundary layer height",                                      "m"                     },
-  { 160, 0, "SDOR",     "Standard deviation of orography",                             NULL                   },
-  { 161, 0, "ISOR",     "Anisotropy of sub-gridscale orography",                       NULL                   },
-  { 162, 0, "ANOR",     "Angle of sub-gridscale orography",                           "rad"                   },
-  { 163, 0, "SLOR",     "Slope of sub-gridscale orography",                            NULL                   },
-  { 164, 0, "TCC",      "Total cloud cover",                                           NULL                   },
-  { 165, 0, "U10M",     "10 metre U wind component",                                  "m s**-1"               },
-  { 166, 0, "V10M",     "10 metre V wind component",                                  "m s**-1"               },
-  { 167, 0, "T2M",      "2 metre temperature",                                        "K"                     },
-  { 168, 0, "D2M",      "2 metre dewpoint temperature",                               "K"                     },
-  { 169, 0, "SSRD",     "Surface solar radiation downwards",                          "W m**-2 s"             },
-  { 170, 0, "STL2",     "Soil temperature level 2",                                   "K"                     },
-  { 171, 0, "SWL2",     "Soil wetness level 2",                                       "m of water"            },
-  { 172, 0, "LSM",      "Land/sea mask",                                               NULL                   },
-  { 173, 0, "SR",       "Surface roughness",                                          "m"                     },
-  { 174, 0, "AL",       "Albedo",                                                      NULL                   },
-  { 175, 0, "STRD",     "Surface thermal radiation downwards",                        "W m**-2 s"             },
-  { 176, 0, "SSR",      "Surface solar radiation",                                    "W m**-2 s"             },
-  { 177, 0, "STR",      "Surface thermal radiation",                                  "W m**-2 s"             },
-  { 178, 0, "TSR",      "Top solar radiation",                                        "W m**-2 s"             },
-  { 179, 0, "TTR",      "Top thermal radiation",                                      "W m**-2 s"             },
-  { 180, 0, "EWSS",     "East/West surface stress",                                   "N m**-2 s"             },
-  { 181, 0, "NSSS",     "North/South surface stress",                                 "N m**-2 s"             },
-  { 182, 0, "E",        "Evaporation",                                                "m of water"            },
-  { 183, 0, "STL3",     "Soil temperature level 3",                                   "K"                     },
-  { 184, 0, "SWL3",     "Soil wetness level 3",                                       "m of water"            },
-  { 185, 0, "CCC",      "Convective cloud cover",                                      NULL                   },
-  { 186, 0, "LCC",      "Low cloud cover",                                             NULL                   },
-  { 187, 0, "MCC",      "Medium cloud cover",                                          NULL                   },
-  { 188, 0, "HCC",      "High cloud cover",                                            NULL                   },
-  { 189, 0, "SUND",     "Sunshine duration",                                          "s"                     },
-  { 190, 0, "EWOV",     "EW component of subgrid orographic variance",                "m**2"                  },
-  { 191, 0, "NSOV",     "NS component of subgrid orographic variance",                "m**2"                  },
-  { 192, 0, "NWOV",     "NWSE component of subgrid orographic variance",              "m**2"                  },
-  { 193, 0, "NEOV",     "NESW component of subgrid orographic variance",              "m**2"                  },
-  { 194, 0, "BTMP",     "Brightness temperature",                                     "K"                     },
-  { 195, 0, "LGWS",     "Lat. component of gravity wave stress",                      "N m**-2 s"             },
-  { 196, 0, "MGWS",     "Meridional component of gravity wave stress",                "N m**-2 s"             },
-  { 197, 0, "GWD",      "Gravity wave dissipation",                                   "W m**-2 s"             },
-  { 198, 0, "SRC",      "Skin reservoir content",                                     "m of water"            },
-  { 199, 0, "VEG",      "Vegetation fraction",                                         NULL                   },
-  { 200, 0, "VSO",      "Variance of sub-gridscale orography",                        "m**2"                  },
-  { 201, 0, "MX2T",     "Maximum 2 metre temperature since previous post-processing", "K"                     },
-  { 202, 0, "MN2T",     "Minimum 2 metre temperature since previous post-processing", "K"                     },
-  { 203, 0, "O3",       "Ozone mass mixing ratio",                                    "kg kg**-1"             },
-  { 204, 0, "PAW",      "Precipiation analysis weights",                               NULL                   },
-  { 205, 0, "RO",       "Runoff",                                                     "m"                     },
-  { 206, 0, "TCO3",     "Total column ozone",                                         "kg m**-2"              },
-  { 207, 0, "WS10",     "10 meter windspeed",                                         "m s**-1"               },
-  { 208, 0, "TSRC",     "Top net solar radiation, clear sky",                         "W m**-2"               },
-  { 209, 0, "TTRC",     "Top net thermal radiation, clear sky",                       "W m**-2"               },
-  { 210, 0, "SSRC",     "Surface net solar radiation, clear sky",                     "W m**-2"               },
-  { 211, 0, "STRC",     "Surface net thermal radiation, clear sky",                   "W m**-2"               },
-  { 212, 0, "SI",       "Solar insolation",                                           "W m**-2"               },
-  { 214, 0, "DHR",      "Diabatic heating by radiation",                              "K"                     },
-  { 215, 0, "DHVD",     "Diabatic heating by vertical diffusion",                     "K"                     },
-  { 216, 0, "DHCC",     "Diabatic heating by cumulus convection",                     "K"                     },
-  { 217, 0, "DHLC",     "Diabatic heating large-scale condensation",                  "K"                     },
-  { 218, 0, "VDZW",     "Vertical diffusion of zonal wind",                           "m s**-1"               },
-  { 219, 0, "VDMW",     "Vertical diffusion of meridional wind",                      "m s**-1"               },
-  { 220, 0, "EWGD",     "EW gravity wave drag tendency",                              "m s**-1"               },
-  { 221, 0, "NSGD",     "NS gravity wave drag tendency",                              "m s**-1"               },
-  { 222, 0, "CTZW",     "Convective tendency of zonal wind",                          "m s**-1"               },
-  { 223, 0, "CTMW",     "Convective tendency of meridional wind",                     "m s**-1"               },
-  { 224, 0, "VDH",      "Vertical diffusion of humidity",                             "kg kg**-1"             },
-  { 225, 0, "HTCC",     "Humidity tendency by cumulus convection",                    "kg kg**-1"             },
-  { 226, 0, "HTLC",     "Humidity tendency large-scale condensation",                 "kg kg**-1"             },
-  { 227, 0, "CRNH",     "Change from removing negative humidity",                     "kg kg**-1"             },
-  { 228, 0, "TP",       "Total precipitation",                                        "m"                     },
-  { 229, 0, "IEWS",     "Instantaneous X surface stress",                             "N m**-2"               },
-  { 230, 0, "INSS",     "Instantaneous Y surface stress",                             "N m**-2"               },
-  { 231, 0, "ISHF",     "Instantaneous surface heat flux",                            "W m**-2"               },
-  { 232, 0, "IE",       "Instantaneous moisture flux",                                "kg m**-2 s"            },
-  { 233, 0, "ASQ",      "Apparent surface humidity",                                  "kg kg**-1"             },
-  { 234, 0, "LSRH",     "Logarithm of surface roughness length for heat",              NULL                   },
-  { 235, 0, "SKT",      "Skin temperature",                                           "K"                     },
-  { 236, 0, "STL4",     "Soil temperature level 4",                                   "K"                     },
-  { 237, 0, "SWL4",     "Soil wetness level 4",                                       "m"                     },
-  { 238, 0, "TSN",      "Temperature of snow layer",                                  "K"                     },
-  { 239, 0, "CSF",      "Convective snowfall",                                        "m of water equivalent" },
-  { 240, 0, "LSF",      "Large-scale snowfall",                                       "m of water equivalent" },
-  { 241, 0, "ACF",      "Accumulated cloud fraction tendency",                         NULL                   },
-  { 242, 0, "ALW",      "Accumulated liquid water tendency",                           NULL                   },
-  { 243, 0, "FAL",      "Forecast albedo",                                             NULL                   },
-  { 244, 0, "FSR",      "Forecast surface roughness",                                 "m"                     },
-  { 245, 0, "FLSR",     "Forecast log of surface roughness for heat",                  NULL                   },
-  { 246, 0, "CLWC",     "Cloud liquid water content",                                 "kg kg**-1"             },
-  { 247, 0, "CIWC",     "Cloud ice water content",                                    "kg kg**-1"             },
-  { 248, 0, "CC",       "Cloud cover",                                                 NULL                   },
-  { 249, 0, "AIW",      "Accumulated ice water tendency",                              NULL                   },
-  { 250, 0, "ICE",      "Ice age",                                                     NULL                   },
-  { 251, 0, "ATTE",     "Adiabatic tendency of temperature",                          "K"                     },
-  { 252, 0, "ATHE",     "Adiabatic tendency of humidity",                             "kg kg**-1"             },
-  { 253, 0, "ATZE",     "Adiabatic tendency of zonal wind",                           "m s**-1"               },
-  { 254, 0, "ATMW",     "Adiabatic tendency of meridional wind",                      "m s**-1"               },
+static const param_type ecmwf[] = {
+  {   1, -1, 0, "STRF",     "Stream function",                                            "m**2 s**-1"            },
+  {   2, -1, 0, "VPOT",     "Velocity potential",                                         "m**2 s**-1"            },
+  {   3, -1, 0, "PT",       "Potential temperature",                                      "K"                     },
+  {   4, -1, 0, "EQPT",     "Equivalent potential temperature",                           "K"                     },
+  {   5, -1, 0, "SEPT",     "Saturated equivalent potential temperature",                 "K"                     },
+  {  11, -1, 0, "UDVW",     "U component of divergent wind",                              "m s**-1"               },
+  {  12, -1, 0, "VDVW",     "V component of divergent wind",                              "m s**-1"               },
+  {  13, -1, 0, "URTW",     "U component of rotational wind",                             "m s**-1"               },
+  {  14, -1, 0, "VRTW",     "V component of rotational wind",                             "m s**-1"               },
+  {  21, -1, 0, "UCTP",     "Unbalanced component of temperature",                        "K"                     },
+  {  22, -1, 0, "UCLN",     "Unbalanced component of logarithm of surface pressure",       NULL                   },
+  {  23, -1, 0, "UCDV",     "Unbalanced component of divergence",                         "s**-1"                 },
+  {  26, -1, 0, "CL",       "Lake cover",                                                  NULL                   },
+  {  27, -1, 0, "CVL",      "Low vegetation cover",                                        NULL                   },
+  {  28, -1, 0, "CVH",      "High vegetation cover",                                       NULL                   },
+  {  29, -1, 0, "TVL",      "Type of low vegetation",                                      NULL                   },
+  {  30, -1, 0, "TVH",      "Type of high vegetation",                                     NULL                   },
+  {  31, -1, 0, "CI",       "Sea-ice cover",                                               NULL                   },
+  {  32, -1, 0, "ASN",      "Snow albedo",                                                 NULL                   },
+  {  33, -1, 0, "RSN",      "Snow density kg",                                            "m**-3"                 },
+  {  34, -1, 0, "SSTK",     "Sea surface temperature",                                    "K"                     },
+  {  35, -1, 0, "ISTL1",    "Ice surface temperature layer 1",                            "K"                     },
+  {  36, -1, 0, "ISTL2",    "Ice surface temperature layer 2",                            "K"                     },
+  {  37, -1, 0, "ISTL3",    "Ice surface temperature layer 3",                            "K"                     },
+  {  38, -1, 0, "ISTL4",    "Ice surface temperature layer 4",                            "K"                     },
+  {  39, -1, 0, "SWVL1",    "Volumetric soil water layer 1",                              "m**3 m**-3"            },
+  {  40, -1, 0, "SWVL2",    "Volumetric soil water layer 2",                              "m**3 m**-3"            },
+  {  41, -1, 0, "SWVL3",    "Volumetric soil water layer 3",                              "m**3 m**-3"            },
+  {  42, -1, 0, "SWVL4",    "Volumetric soil water layer 4",                              "m**3 m**-3"            },
+  {  43, -1, 0, "SLT",      "Soil type",                                                   NULL                   },
+  {  44, -1, 0, "ES",       "Snow evaporation m of water",                                 NULL                   },
+  {  45, -1, 0, "SMLT",     "Snowmelt m of water",                                         NULL                   },
+  {  46, -1, 0, "SDUR",     "Solar duration",                                             "s"                     },
+  {  47, -1, 0, "DSRP",     "Direct solar radiation",                                     "w m**-2"               },
+  {  48, -1, 0, "MAGSS",    "Magnitude of surface stress",                                "N m**-2 s"             },
+  {  49, -1, 0, "WG10",     "Wind gust at 10 metres",                                     "m s**-1"               },
+  {  50, -1, 0, "LSPF",     "Large-scale precipitation fraction",                         "s"                     },
+  {  51, -1, 0, "MX2T24",   "Maximum 2 metre temperature",                                "K"                     },
+  {  52, -1, 0, "MN2T24",   "Minimum 2 metre temperature",                                "K"                     },
+  {  53, -1, 0, "MONT",     "Montgomery potential",                                       "m**2 s**-2"            },
+  {  54, -1, 0, "PRES",     "Pressure",                                                   "Pa"                    },
+  {  55, -1, 0, "MEAN2T24", "Mean 2 metre temperature past 24 hours",                     "K"                     },
+  {  56, -1, 0, "MEAN2D24", "Mean 2 metre dewpoint temperature past 24 hours",            "K"                     },
+  {  60, -1, 0, "PV",       "Potential vorticity",                                        "K m**2 kg**-1 s**-1"   },
+  { 127, -1, 0, "AT",       "Atmospheric tide",                                            NULL                   },
+  { 128, -1, 0, "BV",       "Budget values",                                               NULL                   },
+  { 129, -1, 0, "Z",        "Geopotential",                                               "m**2 s**-2"            },
+  { 130, -1, 0, "T",        "Temperature",                                                "K"                     },
+  { 131, -1, 0, "U",        "U velocity",                                                 "m s**-1"               },
+  { 132, -1, 0, "V",        "V velocity",                                                 "m s**-1"               },
+  { 133, -1, 0, "Q",        "Specific humidity",                                          "kg kg**-1"             },
+  { 134, -1, 0, "SP",       "Surface pressure",                                           "Pa"                    },
+  { 135, -1, 0, "W",        "Vertical velocity",                                          "Pa s**-1"              },
+  { 136, -1, 0, "TCW",      "Total column water",                                         "kg m**-2"              },
+  { 137, -1, 0, "TCWV",     "Total column water vapour",                                  "kg m**-2"              },
+  { 138, -1, 0, "VO",       "Vorticity (relative)",                                       "s**-1"                 },
+  { 139, -1, 0, "STL1",     "Soil temperature level 1",                                   "K"                     },
+  { 140, -1, 0, "SWL1",     "Soil wetness level 1 m of water",                             NULL                   },
+  { 141, -1, 0, "SD",       "Snow depth         1 m of water equivalent",                  NULL                   },
+  { 142, -1, 0, "LSP",      "Stratiform precipitation (Large scale precipitation)",       "m"                     },
+  { 143, -1, 0, "CP",       "Convective precipitation",                                   "m"                     },
+  { 144, -1, 0, "SF",       "Snowfall (convective + stratiform)",                         "m"                     },
+  { 145, -1, 0, "BLD",      "Boundary layer dissipation",                                 "W m**-2 s"             },
+  { 146, -1, 0, "SSHF",     "Surface sensible heat flux",                                 "W m**-2 s"             },
+  { 147, -1, 0, "SLHF",     "Surface latent heat flux",                                   "W m**-2 s"             },
+  { 148, -1, 0, "CHNK",     "Charnock",                                                    NULL                   },
+  { 149, -1, 0, "SNR",      "Surface net radiation",                                      "W m**-2 s"             },
+  { 150, -1, 0, "TNR",      "Top net radiation",                                           NULL                   },
+  { 151, -1, 0, "MSL",      "Mean sea-level pressure",                                    "Pa"                    },
+  { 152, -1, 0, "LNSP",     "Logarithm of surface pressure",                               NULL                   },
+  { 153, -1, 0, "SWHR",     "Short-wave heating rate",                                    "K"                     },
+  { 154, -1, 0, "LWHR",     "Long-wave heating rate",                                     "K"                     },
+  { 155, -1, 0, "D",        "Divergence",                                                 "s**-1"                 },
+  { 156, -1, 0, "GH",       "Height m Geopotential height",                                NULL                   },
+  { 157, -1, 0, "R",        "Relative humidity",                                          "%"                     },
+  { 158, -1, 0, "TSP",      "Tendency of surface pressure",                               "Pa s**-1"              },
+  { 159, -1, 0, "BLH",      "Boundary layer height",                                      "m"                     },
+  { 160, -1, 0, "SDOR",     "Standard deviation of orography",                             NULL                   },
+  { 161, -1, 0, "ISOR",     "Anisotropy of sub-gridscale orography",                       NULL                   },
+  { 162, -1, 0, "ANOR",     "Angle of sub-gridscale orography",                           "rad"                   },
+  { 163, -1, 0, "SLOR",     "Slope of sub-gridscale orography",                            NULL                   },
+  { 164, -1, 0, "TCC",      "Total cloud cover",                                           NULL                   },
+  { 165, -1, 0, "U10M",     "10 metre U wind component",                                  "m s**-1"               },
+  { 166, -1, 0, "V10M",     "10 metre V wind component",                                  "m s**-1"               },
+  { 167, -1, 0, "T2M",      "2 metre temperature",                                        "K"                     },
+  { 168, -1, 0, "D2M",      "2 metre dewpoint temperature",                               "K"                     },
+  { 169, -1, 0, "SSRD",     "Surface solar radiation downwards",                          "W m**-2 s"             },
+  { 170, -1, 0, "STL2",     "Soil temperature level 2",                                   "K"                     },
+  { 171, -1, 0, "SWL2",     "Soil wetness level 2",                                       "m of water"            },
+  { 172, -1, 0, "LSM",      "Land/sea mask",                                               NULL                   },
+  { 173, -1, 0, "SR",       "Surface roughness",                                          "m"                     },
+  { 174, -1, 0, "AL",       "Albedo",                                                      NULL                   },
+  { 175, -1, 0, "STRD",     "Surface thermal radiation downwards",                        "W m**-2 s"             },
+  { 176, -1, 0, "SSR",      "Surface solar radiation",                                    "W m**-2 s"             },
+  { 177, -1, 0, "STR",      "Surface thermal radiation",                                  "W m**-2 s"             },
+  { 178, -1, 0, "TSR",      "Top solar radiation",                                        "W m**-2 s"             },
+  { 179, -1, 0, "TTR",      "Top thermal radiation",                                      "W m**-2 s"             },
+  { 180, -1, 0, "EWSS",     "East/West surface stress",                                   "N m**-2 s"             },
+  { 181, -1, 0, "NSSS",     "North/South surface stress",                                 "N m**-2 s"             },
+  { 182, -1, 0, "E",        "Evaporation",                                                "m of water"            },
+  { 183, -1, 0, "STL3",     "Soil temperature level 3",                                   "K"                     },
+  { 184, -1, 0, "SWL3",     "Soil wetness level 3",                                       "m of water"            },
+  { 185, -1, 0, "CCC",      "Convective cloud cover",                                      NULL                   },
+  { 186, -1, 0, "LCC",      "Low cloud cover",                                             NULL                   },
+  { 187, -1, 0, "MCC",      "Medium cloud cover",                                          NULL                   },
+  { 188, -1, 0, "HCC",      "High cloud cover",                                            NULL                   },
+  { 189, -1, 0, "SUND",     "Sunshine duration",                                          "s"                     },
+  { 190, -1, 0, "EWOV",     "EW component of subgrid orographic variance",                "m**2"                  },
+  { 191, -1, 0, "NSOV",     "NS component of subgrid orographic variance",                "m**2"                  },
+  { 192, -1, 0, "NWOV",     "NWSE component of subgrid orographic variance",              "m**2"                  },
+  { 193, -1, 0, "NEOV",     "NESW component of subgrid orographic variance",              "m**2"                  },
+  { 194, -1, 0, "BTMP",     "Brightness temperature",                                     "K"                     },
+  { 195, -1, 0, "LGWS",     "Lat. component of gravity wave stress",                      "N m**-2 s"             },
+  { 196, -1, 0, "MGWS",     "Meridional component of gravity wave stress",                "N m**-2 s"             },
+  { 197, -1, 0, "GWD",      "Gravity wave dissipation",                                   "W m**-2 s"             },
+  { 198, -1, 0, "SRC",      "Skin reservoir content",                                     "m of water"            },
+  { 199, -1, 0, "VEG",      "Vegetation fraction",                                         NULL                   },
+  { 200, -1, 0, "VSO",      "Variance of sub-gridscale orography",                        "m**2"                  },
+  { 201, -1, 0, "MX2T",     "Maximum 2 metre temperature since previous post-processing", "K"                     },
+  { 202, -1, 0, "MN2T",     "Minimum 2 metre temperature since previous post-processing", "K"                     },
+  { 203, -1, 0, "O3",       "Ozone mass mixing ratio",                                    "kg kg**-1"             },
+  { 204, -1, 0, "PAW",      "Precipiation analysis weights",                               NULL                   },
+  { 205, -1, 0, "RO",       "Runoff",                                                     "m"                     },
+  { 206, -1, 0, "TCO3",     "Total column ozone",                                         "kg m**-2"              },
+  { 207, -1, 0, "WS10",     "10 meter windspeed",                                         "m s**-1"               },
+  { 208, -1, 0, "TSRC",     "Top net solar radiation, clear sky",                         "W m**-2"               },
+  { 209, -1, 0, "TTRC",     "Top net thermal radiation, clear sky",                       "W m**-2"               },
+  { 210, -1, 0, "SSRC",     "Surface net solar radiation, clear sky",                     "W m**-2"               },
+  { 211, -1, 0, "STRC",     "Surface net thermal radiation, clear sky",                   "W m**-2"               },
+  { 212, -1, 0, "SI",       "Solar insolation",                                           "W m**-2"               },
+  { 214, -1, 0, "DHR",      "Diabatic heating by radiation",                              "K"                     },
+  { 215, -1, 0, "DHVD",     "Diabatic heating by vertical diffusion",                     "K"                     },
+  { 216, -1, 0, "DHCC",     "Diabatic heating by cumulus convection",                     "K"                     },
+  { 217, -1, 0, "DHLC",     "Diabatic heating large-scale condensation",                  "K"                     },
+  { 218, -1, 0, "VDZW",     "Vertical diffusion of zonal wind",                           "m s**-1"               },
+  { 219, -1, 0, "VDMW",     "Vertical diffusion of meridional wind",                      "m s**-1"               },
+  { 220, -1, 0, "EWGD",     "EW gravity wave drag tendency",                              "m s**-1"               },
+  { 221, -1, 0, "NSGD",     "NS gravity wave drag tendency",                              "m s**-1"               },
+  { 222, -1, 0, "CTZW",     "Convective tendency of zonal wind",                          "m s**-1"               },
+  { 223, -1, 0, "CTMW",     "Convective tendency of meridional wind",                     "m s**-1"               },
+  { 224, -1, 0, "VDH",      "Vertical diffusion of humidity",                             "kg kg**-1"             },
+  { 225, -1, 0, "HTCC",     "Humidity tendency by cumulus convection",                    "kg kg**-1"             },
+  { 226, -1, 0, "HTLC",     "Humidity tendency large-scale condensation",                 "kg kg**-1"             },
+  { 227, -1, 0, "CRNH",     "Change from removing negative humidity",                     "kg kg**-1"             },
+  { 228, -1, 0, "TP",       "Total precipitation",                                        "m"                     },
+  { 229, -1, 0, "IEWS",     "Instantaneous X surface stress",                             "N m**-2"               },
+  { 230, -1, 0, "INSS",     "Instantaneous Y surface stress",                             "N m**-2"               },
+  { 231, -1, 0, "ISHF",     "Instantaneous surface heat flux",                            "W m**-2"               },
+  { 232, -1, 0, "IE",       "Instantaneous moisture flux",                                "kg m**-2 s"            },
+  { 233, -1, 0, "ASQ",      "Apparent surface humidity",                                  "kg kg**-1"             },
+  { 234, -1, 0, "LSRH",     "Logarithm of surface roughness length for heat",              NULL                   },
+  { 235, -1, 0, "SKT",      "Skin temperature",                                           "K"                     },
+  { 236, -1, 0, "STL4",     "Soil temperature level 4",                                   "K"                     },
+  { 237, -1, 0, "SWL4",     "Soil wetness level 4",                                       "m"                     },
+  { 238, -1, 0, "TSN",      "Temperature of snow layer",                                  "K"                     },
+  { 239, -1, 0, "CSF",      "Convective snowfall",                                        "m of water equivalent" },
+  { 240, -1, 0, "LSF",      "Large-scale snowfall",                                       "m of water equivalent" },
+  { 241, -1, 0, "ACF",      "Accumulated cloud fraction tendency",                         NULL                   },
+  { 242, -1, 0, "ALW",      "Accumulated liquid water tendency",                           NULL                   },
+  { 243, -1, 0, "FAL",      "Forecast albedo",                                             NULL                   },
+  { 244, -1, 0, "FSR",      "Forecast surface roughness",                                 "m"                     },
+  { 245, -1, 0, "FLSR",     "Forecast log of surface roughness for heat",                  NULL                   },
+  { 246, -1, 0, "CLWC",     "Cloud liquid water content",                                 "kg kg**-1"             },
+  { 247, -1, 0, "CIWC",     "Cloud ice water content",                                    "kg kg**-1"             },
+  { 248, -1, 0, "CC",       "Cloud cover",                                                 NULL                   },
+  { 249, -1, 0, "AIW",      "Accumulated ice water tendency",                              NULL                   },
+  { 250, -1, 0, "ICE",      "Ice age",                                                     NULL                   },
+  { 251, -1, 0, "ATTE",     "Adiabatic tendency of temperature",                          "K"                     },
+  { 252, -1, 0, "ATHE",     "Adiabatic tendency of humidity",                             "kg kg**-1"             },
+  { 253, -1, 0, "ATZE",     "Adiabatic tendency of zonal wind",                           "m s**-1"               },
+  { 254, -1, 0, "ATMW",     "Adiabatic tendency of meridional wind",                      "m s**-1"               },
 };
 
-static const PAR remo[] = {
-  {  14, 0, "FTKVM",     "turbulent transfer coefficient of momentum in the atmosphere",   NULL           },
-  {  15, 0, "FTKVH",     "turbulent transfer coefficient of heat in the atmosphere",       NULL           },
-  {  38, 0, "U10ER",     "10m u-velocity",                                                "m/s"           },
-  {  39, 0, "V10ER",     "10m v-velocity",                                                "m/s"           },
-  {  40, 0, "CAPE",      "convetive available potential energy",                           NULL           },
-  {  41, 0, "GHPBL",     "height of the planetary boudary layer",                         "gpm"           },
-  {  42, 0, "BETA",      "BETA",                                                           NULL           },
-  {  43, 0, "WMINLOK",   "WMINLOK",                                                        NULL           },
-  {  44, 0, "WMAXLOK",   "WMAXLOK",                                                        NULL           },
-  {  45, 0, "VBM10M",    "maximum of the expected gust velocity near the surface",        "m/s"           },
-  {  46, 0, "BFLHS",     "surface sensible heat flux",                                    "W/m**2"        },
-  {  47, 0, "BFLQDS",    "surface latent heat flux",                                      "W/m**2"        },
-  {  48, 0, "TMCM",      "turbulent transfer coefficient of momentum at the surface",      NULL           },
-  {  49, 0, "TRSOL",     "TRSOL",                                                          NULL           },
-  {  50, 0, "TMCH",      "turbulent transfer coefficient of heat at the surface",          NULL           },
-  {  51, 0, "EMTEF",     "EMTEF",                                                          NULL           },
-  {  52, 0, "TRSOF",     "TRSOF",                                                          NULL           },
-  {  53, 0, "DRAIN",     "drainage",                                                      "mm"            },
-  {  54, 0, "TSL",       "surface temperature (land)",                                    "K"             },
-  {  55, 0, "TSW",       "surface temperature (water)",                                   "K"             },
-  {  56, 0, "TSI",       "surface temperature (ice)",                                     "K"             },
-  {  57, 0, "USTRL",     "surface u-stress (land)",                                       "Pa"            },
-  {  58, 0, "USTRW",     "surface u-stress (water)",                                      "Pa"            },
-  {  59, 0, "USTRI",     "surface u-stress (ice)",                                        "Pa"            },
-  {  60, 0, "VSTRL",     "surface v-stress (land)",                                       "Pa"            },
-  {  61, 0, "VSTRW",     "surface v-stress (water)",                                      "Pa"            },
-  {  62, 0, "VSTRI",     "surface v-stress (ice)",                                        "Pa"            },
-  {  63, 0, "EVAPL",     "surface evaporation (land)",                                    "mm"            },
-  {  64, 0, "EVAPW",     "surface evaporation (water)",                                   "mm"            },
-  {  65, 0, "EVAPI",     "surface evaporation (ice)",                                     "mm"            },
-  {  66, 0, "AHFLL",     "surface latent heat flux (land)",                               "W/m**2"        },
-  {  67, 0, "AHFLW",     "surface latent heat flux (water)",                              "W/m**2"        },
-  {  68, 0, "AHFLI",     "surface latent heat flux (ice)",                                "W/m**2"        },
-  {  69, 0, "AHFSL",     "surface sensible heat flux (land)",                             "W/m**2"        },
-  {  70, 0, "AHFSW",     "surface sensible heat flux (water)",                            "W/m**2"        },
-  {  71, 0, "AHFSI",     "surface sensible heat flux (ice)",                              "W/m**2"        },
-  {  72, 0, "AZ0L",      "surface roughness length (land)",                               "m"             },
-  {  73, 0, "AZ0W",      "surface roughness length (water)",                              "m"             },
-  {  74, 0, "AZ0I",      "surface roughness length (ice)",                                "m"             },
-  {  75, 0, "ALSOL",     "surface albedo (land)",                                         "fract."        },
-  {  76, 0, "ALSOW",     "surface albedo (water)",                                        "fract."        },
-  {  77, 0, "ALSOI",     "surface albedo (ice)",                                          "fract."        },
-  {  81, 0, "TMCHL",     "turbulent transfer coefficient of heat at the surface (land)",   NULL           },
-  {  82, 0, "TMCHW",     "turbulent transfer coefficient of heat at the surface (water)",  NULL           },
-  {  83, 0, "TMCHI",     "turbulent transfer coefficient of heat at the surface (ice)",    NULL           },
-  {  84, 0, "QDBL",      "specific humidity surface (land)",                              "kg/kg"         },
-  {  85, 0, "QDBW",      "specific humidity surface (water)",                             "kg/kg"         },
-  {  86, 0, "QDBI",      "specific humidity surface (ice)",                               "kg/kg"         },
-  {  87, 0, "BFLHSL",    "surface sensible heat flux (land)",                             "W/m**2"        },
-  {  88, 0, "BFLHSW",    "surface sensible heat flux (water)",                            "W/m**2"        },
-  {  89, 0, "BFLHSI",    "surface sensible heat flux (ice)",                              "W/m**2"        },
-  {  90, 0, "BFLQDSL",   "surface latent heat flux (land)",                               "W/m**2"        },
-  {  91, 0, "BFLQDSW",   "surface latent heat flux (water)",                              "W/m**2"        },
-  {  92, 0, "BFLQDSI",   "surface latent heat flux (ice)",                                "W/m**2"        },
-  {  93, 0, "AHFICE",    "sea-ice: conductive heat",                                      "W/m"           },
-  {  94, 0, "QRES",      "residual heat flux for melting sea ice",                        "W/m**2"        },
-  {  95, 0, "SRFL",      "SRFL",                                                           NULL           },
-  {  96, 0, "QDBOXS",    "horizontal transport of water vapour",                          "kg/m**2"       },
-  {  97, 0, "QWBOXS",    "horizontal transport of cloud water",                           "kg/m**2"       },
-  {  98, 0, "EKBOXS",    "horizontal transport of kinetic energy",                        "(3600*J)/m**2" },
-  {  99, 0, "FHBOXS",    "horizontal transport of sensible heat",                         "(3600*J)/m**2" },
-  { 100, 0, "FIBOXS",    "horizontal transport of potential energy",                      "(3600*J)/m**2" },
-  { 101, 0, "TLAMBDA",   "heat conductivity of dry soil",                                 "W/(K*m)"       },
-  { 103, 0, "DLAMBDA",   "parameter for increasing the heat conductivity of the soil",     NULL           },
-  { 104, 0, "PORVOL",    "pore volume",                                                    NULL           },
-  { 105, 0, "FCAP",      "field capacity of soil",                                         NULL           },
-  { 106, 0, "WI3",       "fraction of frozen soil",                                        NULL           },
-  { 107, 0, "WI4",       "fraction of frozen soil",                                        NULL           },
-  { 108, 0, "WI5",       "fraction of frozen soil",                                        NULL           },
-  { 109, 0, "WI",        "fraction of frozen soil",                                        NULL           },
-  { 110, 0, "WICL",      "fraction of frozen soil",                                        NULL           },
-  { 112, 0, "QDB",       "specific humidity surface",                                     "kg/kg"         },
-  { 129, 0, "FIB",       "surface geopotential (orography)",                              "m"             },
-  { 130, 0, "T",         "temperature",                                                   "K"             },
-  { 131, 0, "U",         "u-velocity",                                                    "m/s"           },
-  { 132, 0, "V",         "v-velocity",                                                    "m/s"           },
-  { 133, 0, "QD",        "specific humidity",                                             "kg/kg"         },
-  { 134, 0, "PS",        "Surface pressure",                                              "Pa"            },
-  { 135, 0, "VERVEL",    "Vertical velocity",                                             "Pa/s"          },
-  { 138, 0, "SVO",       "vorticity",                                                     "1/s"           },
-  { 139, 0, "TS",        "surface temperature",                                           "K"             },
-  { 140, 0, "WS",        "soil wetness",                                                  "m"             },
-  { 141, 0, "SN",        "snow depth",                                                    "m"             },
-  { 142, 0, "APRL",      "large scale precipitation",                                     "mm"            },
-  { 143, 0, "APRC",      "convective  precipitation",                                     "mm"            },
-  { 144, 0, "APRS",      "snow fall",                                                     "mm"            },
-  { 145, 0, "VDIS",      "boundary layer dissipation",                                    "W/m**2"        },
-  { 146, 0, "AHFS",      "surface sensible heat flux",                                    "W/m**2"        },
-  { 147, 0, "AHFL",      "surface latent heat flux",                                      "W/m**2"        },
-  { 148, 0, "STREAM",    "streamfunction",                                                "m**2/s"        },
-  { 149, 0, "VELOPOT",   "velocity potential",                                            "m**2/s"        },
-  { 151, 0, "PSRED",     "mean sea level pressure",                                       "Pa"            },
-  { 152, 0, "LSP",       "log surface pressure",                                           NULL           },
-  { 153, 0, "QW",        "liquid water content",                                          "kg/kg"         },
-  { 155, 0, "SD",        "divergence",                                                    "1/s"           },
-  { 156, 0, "FI",        "geopotential height",                                           "gpm"           },
-  { 159, 0, "USTAR3",    "ustar**3",                                                      "m**3/s**3"     },
-  { 160, 0, "RUNOFF",    "surface runoff",                                                "mm"            },
-  { 162, 0, "ACLC",      "cloud cover",                                                   "fract."        },
-  { 163, 0, "ACLCV",     "total cloud cover",                                             "fract."        },
-  { 164, 0, "ACLCOV",    "total cloud cover",                                             "fract."        },
-  { 165, 0, "U10",       "10m u-velocity",                                                "m/s"           },
-  { 166, 0, "V10",       "10m v-velocity",                                                "m/s"           },
-  { 167, 0, "TEMP2",     "2m temperature",                                                "K"             },
-  { 168, 0, "DEW2",      "2m dew point temperature",                                      "K"             },
-  { 169, 0, "TSURF",     "surface temperature (land)",                                    "K"             },
-  { 170, 0, "TD",        "deep soil temperature",                                         "K"             },
-  { 171, 0, "WIND10",    "10m windspeed",                                                 "m/s"           },
-  { 172, 0, "BLA",       "land sea mask",                                                 "fract."        },
-  { 173, 0, "AZ0",       "surface roughness length",                                      "m"             },
-  { 174, 0, "ALB",       "surface background albedo",                                     "fract."        },
-  { 175, 0, "ALBEDO",    "surface albedo",                                                "fract."        },
-  { 176, 0, "SRADS",     "net surface solar radiation",                                   "W/m**2"        },
-  { 177, 0, "TRADS",     "net surface thermal radiation",                                 "W/m**2"        },
-  { 178, 0, "SRAD0",     "net top solar radiation",                                       "W/m**2"        },
-  { 179, 0, "TRAD0",     "top thermal radiation (OLR)",                                   "W/m**2"        },
-  { 180, 0, "USTR",      "surface u-stress",                                              "Pa"            },
-  { 181, 0, "VSTR",      "surface v-stress",                                              "Pa"            },
-  { 182, 0, "EVAP",      "surface evaporation",                                           "mm"            },
-  { 183, 0, "TDCL",      "soil temperature",                                              "K"             },
-  { 185, 0, "SRAFS",     "net surf. solar radiation   (clear sky)",                       "W/m**2"        },
-  { 186, 0, "TRAFS",     "net surf. thermal radiation (clear sky)",                       "W/m**2"        },
-  { 187, 0, "SRAF0",     "net top solar radiation     (clear sky)",                       "W/m**2"        },
-  { 188, 0, "TRAF0",     "net top thermal radiation   (clear sky)",                       "W/m**2"        },
-  { 189, 0, "SCLFS",     "surface solar cloud forcing",                                   "W/m**2"        },
-  { 190, 0, "TCLFS",     "surface thermal cloud forcing",                                 "W/m**2"        },
-  { 191, 0, "SCLF0",     "top solar cloud forcing",                                       "W/m**2"        },
-  { 192, 0, "TCLF0",     "top thermal cloud forcing",                                     "W/m**2"        },
-  { 194, 0, "WL",        "skin reservoir content",                                        "m"             },
-  { 195, 0, "USTRGW",    "u-gravity wave stress",                                         "Pa"            },
-  { 196, 0, "VSTRGW",    "v-gravity wave stress",                                         "Pa"            },
-  { 197, 0, "VDISGW",    "gravity wave dissipation",                                      "W/m**2"        },
-  { 198, 0, "VGRAT",     "vegetation ratio",                                               NULL           },
-  { 199, 0, "VAROR",     "orographic variance (for surface runoff)",                       NULL           },
-  { 200, 0, "VLT",       "leaf area index",                                                NULL           },
-  { 201, 0, "T2MAX",     "maximum 2m-temperature",                                        "K"             },
-  { 202, 0, "T2MIN",     "minimum 2m-temperature",                                        "K"             },
-  { 203, 0, "SRAD0U",    "top solar radiation upward",                                    "W/m**2"        },
-  { 204, 0, "SRADSU",    "surface solar radiation upward",                                "W/m**2"        },
-  { 205, 0, "TRADSU",    "surface thermal radiation upward",                              "W/m**2"        },
-  { 206, 0, "TSN",       "snow temperature",                                              "K"             },
-  { 207, 0, "TD3",       "soil temperature",                                              "K"             },
-  { 208, 0, "TD4",       "soil temperature",                                              "K"             },
-  { 209, 0, "TD5",       "soil temperature",                                              "K"             },
-  { 210, 0, "SEAICE",    "sea ice cover",                                                 "fract."        },
-  { 211, 0, "SICED",     "sea ice depth",                                                 "m"             },
-  { 212, 0, "FOREST",    "vegetation type",                                                NULL           },
-  { 213, 0, "TEFF",      "(effective) sea-ice skin temperature",                          "K"             },
-  { 214, 0, "TSMAX",     "maximum surface temperature",                                   "K"             },
-  { 215, 0, "TSMIN",     "minimum surface temperature",                                   "K"             },
-  { 216, 0, "WIMAX",     "maximum 10m-wind speed",                                        "m/s"           },
-  { 217, 0, "TOPMAX",    "maximum height of convective cloud tops",                       "Pa"            },
-  { 218, 0, "SNMEL",     "snow melt",                                                     "mm"            },
-  { 220, 0, "TSLIN",     "land: residual surface heat budget",                            "W/m**2"        },
-  { 221, 0, "DSNAC",     "snow depth change",                                             "mm"            },
-  { 222, 0, "EMTER",     "EMTER",                                                          NULL           },
-  { 223, 0, "ACLCAC",    "cloud cover",                                                   "fract."        },
-  { 224, 0, "TKE",       "turbulent kinetic energy",                                       NULL           },
-  { 226, 0, "FAO",       "FAO data set (soil data flags)",                                 NULL           },
-  { 227, 0, "RGCGN",     "heat capacity of soil",                                          NULL           },
-  { 229, 0, "WSMX",      "field capacity of soil",                                         NULL           },
-  { 230, 0, "QVI",       "vertically integrated specific humidity",                       "kg/m**2"       },
-  { 231, 0, "ALWCVI",    "vertically integrated liquid water cont.",                      "kg/m**2"       },
-  { 232, 0, "GLAC",      "glacier mask",                                                   NULL           },
-  { 253, 0, "PHI",       "latitude in real coordinates",                                  "degrees_north" },
-  { 254, 0, "RLA",       "longitude in real coordinates",                                 "degrees_east"  },
-  { 259, 0, "WINDSPEED", "windspeed (sqrt(u**2+v**2))",                                    NULL           },
-  { 260, 0, "PRECIP",    "total precipitation",                                            NULL           },
+static const param_type remo[] = {
+  {  14, -1, 0, "FTKVM",     "turbulent transfer coefficient of momentum in the atmosphere",   NULL           },
+  {  15, -1, 0, "FTKVH",     "turbulent transfer coefficient of heat in the atmosphere",       NULL           },
+  {  38, -1, 0, "U10ER",     "10m u-velocity",                                                "m/s"           },
+  {  39, -1, 0, "V10ER",     "10m v-velocity",                                                "m/s"           },
+  {  40, -1, 0, "CAPE",      "convetive available potential energy",                           NULL           },
+  {  41, -1, 0, "GHPBL",     "height of the planetary boudary layer",                         "gpm"           },
+  {  42, -1, 0, "BETA",      "BETA",                                                           NULL           },
+  {  43, -1, 0, "WMINLOK",   "WMINLOK",                                                        NULL           },
+  {  44, -1, 0, "WMAXLOK",   "WMAXLOK",                                                        NULL           },
+  {  45, -1, 0, "VBM10M",    "maximum of the expected gust velocity near the surface",        "m/s"           },
+  {  46, -1, 0, "BFLHS",     "surface sensible heat flux",                                    "W/m**2"        },
+  {  47, -1, 0, "BFLQDS",    "surface latent heat flux",                                      "W/m**2"        },
+  {  48, -1, 0, "TMCM",      "turbulent transfer coefficient of momentum at the surface",      NULL           },
+  {  49, -1, 0, "TRSOL",     "TRSOL",                                                          NULL           },
+  {  50, -1, 0, "TMCH",      "turbulent transfer coefficient of heat at the surface",          NULL           },
+  {  51, -1, 0, "EMTEF",     "EMTEF",                                                          NULL           },
+  {  52, -1, 0, "TRSOF",     "TRSOF",                                                          NULL           },
+  {  53, -1, 0, "DRAIN",     "drainage",                                                      "mm"            },
+  {  54, -1, 0, "TSL",       "surface temperature (land)",                                    "K"             },
+  {  55, -1, 0, "TSW",       "surface temperature (water)",                                   "K"             },
+  {  56, -1, 0, "TSI",       "surface temperature (ice)",                                     "K"             },
+  {  57, -1, 0, "USTRL",     "surface u-stress (land)",                                       "Pa"            },
+  {  58, -1, 0, "USTRW",     "surface u-stress (water)",                                      "Pa"            },
+  {  59, -1, 0, "USTRI",     "surface u-stress (ice)",                                        "Pa"            },
+  {  60, -1, 0, "VSTRL",     "surface v-stress (land)",                                       "Pa"            },
+  {  61, -1, 0, "VSTRW",     "surface v-stress (water)",                                      "Pa"            },
+  {  62, -1, 0, "VSTRI",     "surface v-stress (ice)",                                        "Pa"            },
+  {  63, -1, 0, "EVAPL",     "surface evaporation (land)",                                    "mm"            },
+  {  64, -1, 0, "EVAPW",     "surface evaporation (water)",                                   "mm"            },
+  {  65, -1, 0, "EVAPI",     "surface evaporation (ice)",                                     "mm"            },
+  {  66, -1, 0, "AHFLL",     "surface latent heat flux (land)",                               "W/m**2"        },
+  {  67, -1, 0, "AHFLW",     "surface latent heat flux (water)",                              "W/m**2"        },
+  {  68, -1, 0, "AHFLI",     "surface latent heat flux (ice)",                                "W/m**2"        },
+  {  69, -1, 0, "AHFSL",     "surface sensible heat flux (land)",                             "W/m**2"        },
+  {  70, -1, 0, "AHFSW",     "surface sensible heat flux (water)",                            "W/m**2"        },
+  {  71, -1, 0, "AHFSI",     "surface sensible heat flux (ice)",                              "W/m**2"        },
+  {  72, -1, 0, "AZ0L",      "surface roughness length (land)",                               "m"             },
+  {  73, -1, 0, "AZ0W",      "surface roughness length (water)",                              "m"             },
+  {  74, -1, 0, "AZ0I",      "surface roughness length (ice)",                                "m"             },
+  {  75, -1, 0, "ALSOL",     "surface albedo (land)",                                         "fract."        },
+  {  76, -1, 0, "ALSOW",     "surface albedo (water)",                                        "fract."        },
+  {  77, -1, 0, "ALSOI",     "surface albedo (ice)",                                          "fract."        },
+  {  81, -1, 0, "TMCHL",     "turbulent transfer coefficient of heat at the surface (land)",   NULL           },
+  {  82, -1, 0, "TMCHW",     "turbulent transfer coefficient of heat at the surface (water)",  NULL           },
+  {  83, -1, 0, "TMCHI",     "turbulent transfer coefficient of heat at the surface (ice)",    NULL           },
+  {  84, -1, 0, "QDBL",      "specific humidity surface (land)",                              "kg/kg"         },
+  {  85, -1, 0, "QDBW",      "specific humidity surface (water)",                             "kg/kg"         },
+  {  86, -1, 0, "QDBI",      "specific humidity surface (ice)",                               "kg/kg"         },
+  {  87, -1, 0, "BFLHSL",    "surface sensible heat flux (land)",                             "W/m**2"        },
+  {  88, -1, 0, "BFLHSW",    "surface sensible heat flux (water)",                            "W/m**2"        },
+  {  89, -1, 0, "BFLHSI",    "surface sensible heat flux (ice)",                              "W/m**2"        },
+  {  90, -1, 0, "BFLQDSL",   "surface latent heat flux (land)",                               "W/m**2"        },
+  {  91, -1, 0, "BFLQDSW",   "surface latent heat flux (water)",                              "W/m**2"        },
+  {  92, -1, 0, "BFLQDSI",   "surface latent heat flux (ice)",                                "W/m**2"        },
+  {  93, -1, 0, "AHFICE",    "sea-ice: conductive heat",                                      "W/m"           },
+  {  94, -1, 0, "QRES",      "residual heat flux for melting sea ice",                        "W/m**2"        },
+  {  95, -1, 0, "SRFL",      "SRFL",                                                           NULL           },
+  {  96, -1, 0, "QDBOXS",    "horizontal transport of water vapour",                          "kg/m**2"       },
+  {  97, -1, 0, "QWBOXS",    "horizontal transport of cloud water",                           "kg/m**2"       },
+  {  98, -1, 0, "EKBOXS",    "horizontal transport of kinetic energy",                        "(3600*J)/m**2" },
+  {  99, -1, 0, "FHBOXS",    "horizontal transport of sensible heat",                         "(3600*J)/m**2" },
+  { 100, -1, 0, "FIBOXS",    "horizontal transport of potential energy",                      "(3600*J)/m**2" },
+  { 101, -1, 0, "TLAMBDA",   "heat conductivity of dry soil",                                 "W/(K*m)"       },
+  { 103, -1, 0, "DLAMBDA",   "parameter for increasing the heat conductivity of the soil",     NULL           },
+  { 104, -1, 0, "PORVOL",    "pore volume",                                                    NULL           },
+  { 105, -1, 0, "FCAP",      "field capacity of soil",                                         NULL           },
+  { 106, -1, 0, "WI3",       "fraction of frozen soil",                                        NULL           },
+  { 107, -1, 0, "WI4",       "fraction of frozen soil",                                        NULL           },
+  { 108, -1, 0, "WI5",       "fraction of frozen soil",                                        NULL           },
+  { 109, -1, 0, "WI",        "fraction of frozen soil",                                        NULL           },
+  { 110, -1, 0, "WICL",      "fraction of frozen soil",                                        NULL           },
+  { 112, -1, 0, "QDB",       "specific humidity surface",                                     "kg/kg"         },
+  { 129, -1, 0, "FIB",       "surface geopotential (orography)",                              "m"             },
+  { 130, -1, 0, "T",         "temperature",                                                   "K"             },
+  { 131, -1, 0, "U",         "u-velocity",                                                    "m/s"           },
+  { 132, -1, 0, "V",         "v-velocity",                                                    "m/s"           },
+  { 133, -1, 0, "QD",        "specific humidity",                                             "kg/kg"         },
+  { 134, -1, 0, "PS",        "Surface pressure",                                              "Pa"            },
+  { 135, -1, 0, "VERVEL",    "Vertical velocity",                                             "Pa/s"          },
+  { 138, -1, 0, "SVO",       "vorticity",                                                     "1/s"           },
+  { 139, -1, 0, "TS",        "surface temperature",                                           "K"             },
+  { 140, -1, 0, "WS",        "soil wetness",                                                  "m"             },
+  { 141, -1, 0, "SN",        "snow depth",                                                    "m"             },
+  { 142, -1, 0, "APRL",      "large scale precipitation",                                     "mm"            },
+  { 143, -1, 0, "APRC",      "convective  precipitation",                                     "mm"            },
+  { 144, -1, 0, "APRS",      "snow fall",                                                     "mm"            },
+  { 145, -1, 0, "VDIS",      "boundary layer dissipation",                                    "W/m**2"        },
+  { 146, -1, 0, "AHFS",      "surface sensible heat flux",                                    "W/m**2"        },
+  { 147, -1, 0, "AHFL",      "surface latent heat flux",                                      "W/m**2"        },
+  { 148, -1, 0, "STREAM",    "streamfunction",                                                "m**2/s"        },
+  { 149, -1, 0, "VELOPOT",   "velocity potential",                                            "m**2/s"        },
+  { 151, -1, 0, "PSRED",     "mean sea level pressure",                                       "Pa"            },
+  { 152, -1, 0, "LSP",       "log surface pressure",                                           NULL           },
+  { 153, -1, 0, "QW",        "liquid water content",                                          "kg/kg"         },
+  { 155, -1, 0, "SD",        "divergence",                                                    "1/s"           },
+  { 156, -1, 0, "FI",        "geopotential height",                                           "gpm"           },
+  { 159, -1, 0, "USTAR3",    "ustar**3",                                                      "m**3/s**3"     },
+  { 160, -1, 0, "RUNOFF",    "surface runoff",                                                "mm"            },
+  { 162, -1, 0, "ACLC",      "cloud cover",                                                   "fract."        },
+  { 163, -1, 0, "ACLCV",     "total cloud cover",                                             "fract."        },
+  { 164, -1, 0, "ACLCOV",    "total cloud cover",                                             "fract."        },
+  { 165, -1, 0, "U10",       "10m u-velocity",                                                "m/s"           },
+  { 166, -1, 0, "V10",       "10m v-velocity",                                                "m/s"           },
+  { 167, -1, 0, "TEMP2",     "2m temperature",                                                "K"             },
+  { 168, -1, 0, "DEW2",      "2m dew point temperature",                                      "K"             },
+  { 169, -1, 0, "TSURF",     "surface temperature (land)",                                    "K"             },
+  { 170, -1, 0, "TD",        "deep soil temperature",                                         "K"             },
+  { 171, -1, 0, "WIND10",    "10m windspeed",                                                 "m/s"           },
+  { 172, -1, 0, "BLA",       "land sea mask",                                                 "fract."        },
+  { 173, -1, 0, "AZ0",       "surface roughness length",                                      "m"             },
+  { 174, -1, 0, "ALB",       "surface background albedo",                                     "fract."        },
+  { 175, -1, 0, "ALBEDO",    "surface albedo",                                                "fract."        },
+  { 176, -1, 0, "SRADS",     "net surface solar radiation",                                   "W/m**2"        },
+  { 177, -1, 0, "TRADS",     "net surface thermal radiation",                                 "W/m**2"        },
+  { 178, -1, 0, "SRAD0",     "net top solar radiation",                                       "W/m**2"        },
+  { 179, -1, 0, "TRAD0",     "top thermal radiation (OLR)",                                   "W/m**2"        },
+  { 180, -1, 0, "USTR",      "surface u-stress",                                              "Pa"            },
+  { 181, -1, 0, "VSTR",      "surface v-stress",                                              "Pa"            },
+  { 182, -1, 0, "EVAP",      "surface evaporation",                                           "mm"            },
+  { 183, -1, 0, "TDCL",      "soil temperature",                                              "K"             },
+  { 185, -1, 0, "SRAFS",     "net surf. solar radiation   (clear sky)",                       "W/m**2"        },
+  { 186, -1, 0, "TRAFS",     "net surf. thermal radiation (clear sky)",                       "W/m**2"        },
+  { 187, -1, 0, "SRAF0",     "net top solar radiation     (clear sky)",                       "W/m**2"        },
+  { 188, -1, 0, "TRAF0",     "net top thermal radiation   (clear sky)",                       "W/m**2"        },
+  { 189, -1, 0, "SCLFS",     "surface solar cloud forcing",                                   "W/m**2"        },
+  { 190, -1, 0, "TCLFS",     "surface thermal cloud forcing",                                 "W/m**2"        },
+  { 191, -1, 0, "SCLF0",     "top solar cloud forcing",                                       "W/m**2"        },
+  { 192, -1, 0, "TCLF0",     "top thermal cloud forcing",                                     "W/m**2"        },
+  { 194, -1, 0, "WL",        "skin reservoir content",                                        "m"             },
+  { 195, -1, 0, "USTRGW",    "u-gravity wave stress",                                         "Pa"            },
+  { 196, -1, 0, "VSTRGW",    "v-gravity wave stress",                                         "Pa"            },
+  { 197, -1, 0, "VDISGW",    "gravity wave dissipation",                                      "W/m**2"        },
+  { 198, -1, 0, "VGRAT",     "vegetation ratio",                                               NULL           },
+  { 199, -1, 0, "VAROR",     "orographic variance (for surface runoff)",                       NULL           },
+  { 200, -1, 0, "VLT",       "leaf area index",                                                NULL           },
+  { 201, -1, 0, "T2MAX",     "maximum 2m-temperature",                                        "K"             },
+  { 202, -1, 0, "T2MIN",     "minimum 2m-temperature",                                        "K"             },
+  { 203, -1, 0, "SRAD0U",    "top solar radiation upward",                                    "W/m**2"        },
+  { 204, -1, 0, "SRADSU",    "surface solar radiation upward",                                "W/m**2"        },
+  { 205, -1, 0, "TRADSU",    "surface thermal radiation upward",                              "W/m**2"        },
+  { 206, -1, 0, "TSN",       "snow temperature",                                              "K"             },
+  { 207, -1, 0, "TD3",       "soil temperature",                                              "K"             },
+  { 208, -1, 0, "TD4",       "soil temperature",                                              "K"             },
+  { 209, -1, 0, "TD5",       "soil temperature",                                              "K"             },
+  { 210, -1, 0, "SEAICE",    "sea ice cover",                                                 "fract."        },
+  { 211, -1, 0, "SICED",     "sea ice depth",                                                 "m"             },
+  { 212, -1, 0, "FOREST",    "vegetation type",                                                NULL           },
+  { 213, -1, 0, "TEFF",      "(effective) sea-ice skin temperature",                          "K"             },
+  { 214, -1, 0, "TSMAX",     "maximum surface temperature",                                   "K"             },
+  { 215, -1, 0, "TSMIN",     "minimum surface temperature",                                   "K"             },
+  { 216, -1, 0, "WIMAX",     "maximum 10m-wind speed",                                        "m/s"           },
+  { 217, -1, 0, "TOPMAX",    "maximum height of convective cloud tops",                       "Pa"            },
+  { 218, -1, 0, "SNMEL",     "snow melt",                                                     "mm"            },
+  { 220, -1, 0, "TSLIN",     "land: residual surface heat budget",                            "W/m**2"        },
+  { 221, -1, 0, "DSNAC",     "snow depth change",                                             "mm"            },
+  { 222, -1, 0, "EMTER",     "EMTER",                                                          NULL           },
+  { 223, -1, 0, "ACLCAC",    "cloud cover",                                                   "fract."        },
+  { 224, -1, 0, "TKE",       "turbulent kinetic energy",                                       NULL           },
+  { 226, -1, 0, "FAO",       "FAO data set (soil data flags)",                                 NULL           },
+  { 227, -1, 0, "RGCGN",     "heat capacity of soil",                                          NULL           },
+  { 229, -1, 0, "WSMX",      "field capacity of soil",                                         NULL           },
+  { 230, -1, 0, "QVI",       "vertically integrated specific humidity",                       "kg/m**2"       },
+  { 231, -1, 0, "ALWCVI",    "vertically integrated liquid water cont.",                      "kg/m**2"       },
+  { 232, -1, 0, "GLAC",      "glacier mask",                                                   NULL           },
+  { 253, -1, 0, "PHI",       "latitude in real coordinates",                                  "degrees_north" },
+  { 254, -1, 0, "RLA",       "longitude in real coordinates",                                 "degrees_east"  },
+  { 259, -1, 0, "WINDSPEED", "windspeed (sqrt(u**2+v**2))",                                    NULL           },
+  { 260, -1, 0, "PRECIP",    "total precipitation",                                            NULL           },
 };
 
-static const PAR cosmo002[] = {
-  {   1, 0, "P",         "pressure",                                          "Pa"         },
-  {   2, 0, "PMSL",      "mean sea level pressure",                           "Pa"         },
-  {   3, 0, "DPSDT",     "surface pressure change",                           "Pa s-1"     },
-  {   6, 0, "FI",        "geopotential",                                      "m2 s-2"     },
-  {   8, 0, "HH",        "height",                                            "m"          },
-  {  10, 0, "TO3",       "vertical integrated ozone content",                 "Dobson"     },
-  {  11, 0, "T",         "temperature",                                       "K"          },
-  {  15, 0, "TMAX",      "2m maximum temperature",                            "K"          },
-  {  16, 0, "TMIN",      "2m minimum temperature",                            "K"          },
-  {  17, 0, "TD",        "2m dew point temperature",                          "K"          },
-  {  31, 0, "DD",        "undefined",                                         "undefined"  },
-  {  32, 0, "FF",        "undefined",                                         "undefined"  },
-  {  33, 0, "U",         "U-component of wind",                               "m s-1"      },
-  {  34, 0, "V",         "V-component of wind",                               "m s-1"      },
-  {  39, 0, "OMEGA",     "omega",                                             "Pa s-1"     },
-  {  40, 0, "W",         "vertical wind velocity",                            "m s-1"      },
-  {  51, 0, "QV",        "specific humidity",                                 "kg kg-1"    },
-  {  52, 0, "RELHUM",    "relative humidity",                                 "%"          },
-  {  54, 0, "TQV",       "precipitable water",                                "kg m-2"     },
-  {  57, 0, "AEVAP",     "surface evaporation",                               "kg m-2"     },
-  {  58, 0, "TQI",       "vertical integrated cloud ice",                     "kg m-2"     },
-  {  59, 0, "TOT_PR",    "total precipitation rate",                          "kg m-2 s-1" },
-  {  61, 0, "TOT_PREC",  "total precipitation amount",                        "kg m-2"     },
-  {  65, 0, "W_SNOW",    "surface snow amount",                               "m"          },
-  {  66, 0, "H_SNOW",    "thickness of snow",                                 "m"          },
-  {  71, 0, "CLCT",      "total cloud cover",                                 "1"          },
-  {  72, 0, "CLC_CON",   "convective cloud area fraction",                    "1"          },
-  {  73, 0, "CLCL",      "low cloud cover",                                   "1"          },
-  {  74, 0, "CLCM",      "medium cloud cover",                                "1"          },
-  {  75, 0, "CLCH",      "high cloud cover",                                  "1"          },
-  {  76, 0, "TQC",       "vertical integrated cloud water",                   "kg m-2"     },
-  {  78, 0, "SNOW_CON",  "convective snowfall",                               "kg m-2"     },
-  {  79, 0, "SNOW_GSP",  "large scale snowfall",                              "kg m-2"     },
-  {  81, 0, "FR_LAND",   "land-sea fraction",                                 "1"          },
-  {  83, 0, "Z0",        "surface roughness length",                          "m"          },
-  {  84, 0, "ALB_RAD",   "surface albedo",                                    "1"          },
-  {  85, 0, "TSOIL",     "soil surface temperature",                          "K"          },
-  {  86, 0, "WSOIL",     "water content of 1. soil layer",                    "m"          },
-  {  87, 0, "PLCOV",     "vegetation area fraction",                          "1"          },
-  {  90, 0, "RUNOFF",    "subsurface runoff",                                 "kg m-2"     },
-  {  91, 0, "FR_ICE",    "sea ice area fraction",                             "1"          },
-  {  92, 0, "H_ICE",     "sea ice thickness",                                 "m"          },
-  { 111, 0, "ASOB",      "averaged surface net downward shortwave radiation", "W m-2"      },
-  { 112, 0, "ATHB",      "averaged surface net downward longwave radiation",  "W m-2"      },
-  { 113, 0, "ASOB",      "averaged TOA net downward shortwave radiation",     "W m-2"      },
-  { 114, 0, "ATHB",      "averaged TOA outgoing longwave radiation",          "W m-2"      },
-  { 115, 0, "ASWDIR",    "direct downward sw radiation at the surface",       "W m-2"      },
-  { 116, 0, "ASWDIFD",   "diffuse downward sw radiation at the surface",      "W m-2"      },
-  { 117, 0, "ASWDIFU",   "diffuse upwnward sw radiation at the surface",      "W m-2"      },
-  { 118, 0, "ALWD",      "downward lw radiation at the surface",              "W m-2"      },
-  { 119, 0, "ALWU",      "upward lw radiation at the surface",                "W m-2"      },
-  { 121, 0, "ALHFL",     "averaged surface latent heat flux",                 "W m-2"      },
-  { 122, 0, "ASHFL",     "averaged surface sensible heat flux",               "W m-2"      },
-  { 124, 0, "AUMFL",     "averaged eastward stress",                          "Pa"         },
-  { 125, 0, "AVMFL",     "averaged northward stress",                         "Pa"         },
-  { 128, 0, "SUNSH",     "undefined",                                         "undefined"  },
-  { 129, 0, "SUNSH2",    "undefined",                                         "undefined"  },
-  { 130, 0, "SUN_SUM",   "undefined",                                         "undefined"  },
-  { 131, 0, "SUN_SUM2",  "undefined",                                         "undefined"  },
-  { 133, 0, "FCOR",      "undefined",                                         "undefined"  },
-  { 134, 0, "SKYVIEW",   "sky-view factor",                                   "1"          },
-  { 137, 0, "SWDIR_COR", "topo correction of direct solar radiarion",         "1"          },
+static const param_type cosmo002[] = {
+  {   1, -1, 0, "P",         "pressure",                                          "Pa"         },
+  {   2, -1, 0, "PMSL",      "mean sea level pressure",                           "Pa"         },
+  {   3, -1, 0, "DPSDT",     "surface pressure change",                           "Pa s-1"     },
+  {   6, -1, 0, "FI",        "geopotential",                                      "m2 s-2"     },
+  {   8, -1, 0, "HH",        "height",                                            "m"          },
+  {  10, -1, 0, "TO3",       "vertical integrated ozone content",                 "Dobson"     },
+  {  11, -1, 0, "T",         "temperature",                                       "K"          },
+  {  15, -1, 0, "TMAX",      "2m maximum temperature",                            "K"          },
+  {  16, -1, 0, "TMIN",      "2m minimum temperature",                            "K"          },
+  {  17, -1, 0, "TD",        "2m dew point temperature",                          "K"          },
+  {  31, -1, 0, "DD",        "undefined",                                         "undefined"  },
+  {  32, -1, 0, "FF",        "undefined",                                         "undefined"  },
+  {  33, -1, 0, "U",         "U-component of wind",                               "m s-1"      },
+  {  34, -1, 0, "V",         "V-component of wind",                               "m s-1"      },
+  {  39, -1, 0, "OMEGA",     "omega",                                             "Pa s-1"     },
+  {  40, -1, 0, "W",         "vertical wind velocity",                            "m s-1"      },
+  {  51, -1, 0, "QV",        "specific humidity",                                 "kg kg-1"    },
+  {  52, -1, 0, "RELHUM",    "relative humidity",                                 "%"          },
+  {  54, -1, 0, "TQV",       "precipitable water",                                "kg m-2"     },
+  {  57, -1, 0, "AEVAP",     "surface evaporation",                               "kg m-2"     },
+  {  58, -1, 0, "TQI",       "vertical integrated cloud ice",                     "kg m-2"     },
+  {  59, -1, 0, "TOT_PR",    "total precipitation rate",                          "kg m-2 s-1" },
+  {  61, -1, 0, "TOT_PREC",  "total precipitation amount",                        "kg m-2"     },
+  {  65, -1, 0, "W_SNOW",    "surface snow amount",                               "m"          },
+  {  66, -1, 0, "H_SNOW",    "thickness of snow",                                 "m"          },
+  {  71, -1, 0, "CLCT",      "total cloud cover",                                 "1"          },
+  {  72, -1, 0, "CLC_CON",   "convective cloud area fraction",                    "1"          },
+  {  73, -1, 0, "CLCL",      "low cloud cover",                                   "1"          },
+  {  74, -1, 0, "CLCM",      "medium cloud cover",                                "1"          },
+  {  75, -1, 0, "CLCH",      "high cloud cover",                                  "1"          },
+  {  76, -1, 0, "TQC",       "vertical integrated cloud water",                   "kg m-2"     },
+  {  78, -1, 0, "SNOW_CON",  "convective snowfall",                               "kg m-2"     },
+  {  79, -1, 0, "SNOW_GSP",  "large scale snowfall",                              "kg m-2"     },
+  {  81, -1, 0, "FR_LAND",   "land-sea fraction",                                 "1"          },
+  {  83, -1, 0, "Z0",        "surface roughness length",                          "m"          },
+  {  84, -1, 0, "ALB_RAD",   "surface albedo",                                    "1"          },
+  {  85, -1, 0, "TSOIL",     "soil surface temperature",                          "K"          },
+  {  86, -1, 0, "WSOIL",     "water content of 1. soil layer",                    "m"          },
+  {  87, -1, 0, "PLCOV",     "vegetation area fraction",                          "1"          },
+  {  90, -1, 0, "RUNOFF",    "subsurface runoff",                                 "kg m-2"     },
+  {  91, -1, 0, "FR_ICE",    "sea ice area fraction",                             "1"          },
+  {  92, -1, 0, "H_ICE",     "sea ice thickness",                                 "m"          },
+  { 111, -1, 0, "ASOB",      "averaged surface net downward shortwave radiation", "W m-2"      },
+  { 112, -1, 0, "ATHB",      "averaged surface net downward longwave radiation",  "W m-2"      },
+  { 113, -1, 0, "ASOB",      "averaged TOA net downward shortwave radiation",     "W m-2"      },
+  { 114, -1, 0, "ATHB",      "averaged TOA outgoing longwave radiation",          "W m-2"      },
+  { 115, -1, 0, "ASWDIR",    "direct downward sw radiation at the surface",       "W m-2"      },
+  { 116, -1, 0, "ASWDIFD",   "diffuse downward sw radiation at the surface",      "W m-2"      },
+  { 117, -1, 0, "ASWDIFU",   "diffuse upwnward sw radiation at the surface",      "W m-2"      },
+  { 118, -1, 0, "ALWD",      "downward lw radiation at the surface",              "W m-2"      },
+  { 119, -1, 0, "ALWU",      "upward lw radiation at the surface",                "W m-2"      },
+  { 121, -1, 0, "ALHFL",     "averaged surface latent heat flux",                 "W m-2"      },
+  { 122, -1, 0, "ASHFL",     "averaged surface sensible heat flux",               "W m-2"      },
+  { 124, -1, 0, "AUMFL",     "averaged eastward stress",                          "Pa"         },
+  { 125, -1, 0, "AVMFL",     "averaged northward stress",                         "Pa"         },
+  { 128, -1, 0, "SUNSH",     "undefined",                                         "undefined"  },
+  { 129, -1, 0, "SUNSH2",    "undefined",                                         "undefined"  },
+  { 130, -1, 0, "SUN_SUM",   "undefined",                                         "undefined"  },
+  { 131, -1, 0, "SUN_SUM2",  "undefined",                                         "undefined"  },
+  { 133, -1, 0, "FCOR",      "undefined",                                         "undefined"  },
+  { 134, -1, 0, "SKYVIEW",   "sky-view factor",                                   "1"          },
+  { 137, -1, 0, "SWDIR_COR", "topo correction of direct solar radiarion",         "1"          },
 };
 
-static const PAR cosmo201[] = {
-  {   5, 0, "APAB",      "&",                                                         "W m-2"      },
-  {  13, 0, "SOHR_RAD",  "&",                                                         "K s-1"      },
-  {  14, 0, "THHR_RAD",  "&",                                                         "K s-1"      },
-  {  20, 0, "DURSUN",    "duration of sunshine",                                      "s"          },
-  {  29, 0, "CLC",       "cloud area fraction",                                       "1"          },
-  {  30, 0, "CLC_SGS",   "grid scale cloud area fraction",                            "1"          },
-  {  31, 0, "QC",        "specific cloud liquid water content",                       "kg kg-1"    },
-  {  33, 0, "QI",        "specific cloud ice content",                                "kg kg-1"    },
-  {  35, 0, "QR",        "specific rain content",                                     "kg kg-1"    },
-  {  36, 0, "QS",        "specific snow content",                                     "kg kg-1"    },
-  {  37, 0, "TQR",       "total rain water content vertically integrated",            "kg m-2"     },
-  {  38, 0, "TQS",       "total snow content vertically integrated",                  "kg m-2"     },
-  {  39, 0, "QG",        "specific graupel content",                                  "kg kg-1"    },
-  {  40, 0, "TQG",       "total graupel content vertically integrated",               "kg m-2"     },
-  {  41, 0, "TWATER",    "cloud condensed water content",                             "kg m-2"     },
-  {  42, 0, "TDIV_HUM",  "atmosphere water divergence",                               "kg m-2"     },
-  {  43, 0, "QC_RAD",    "sub scale specific cloud liquid water content",             "kg kg-1"    },
-  {  44, 0, "QI_RAD",    "sub scale specific cloud ice content",                      "kg kg-1"    },
-  {  61, 0, "CLW_CON",   "convective cloud liquid water",                             "1"          },
-  {  68, 0, "HBAS_CON",  "height of convective cloud base",                           "m"          },
-  {  69, 0, "HTOP_CON",  "height of convective cloud top",                            "m"          },
-  {  70, 0, "HBAS_CONI", "height of convective cloud base",                           "m"          },
-  {  71, 0, "HTOP_CONI", "height of convective cloud top",                            "m"          },
-  {  72, 0, "BAS_CON",   "index of convective cloud base",                            "1"          },
-  {  73, 0, "TOP_CON",   "index of convective cloud top",                             "1"          },
-  {  74, 0, "DT_CON",    "convective tendency of temperature",                        "K s-1"      },
-  {  75, 0, "DQV_CON",   "convective tendency of specific humidity",                  "s-1"        },
-  {  78, 0, "DU_CON",    "convective tendency of u-wind component",                   "m s-2"      },
-  {  79, 0, "DV_CON",    "convective tendency of v-wind component",                   "m s-2"      },
-  {  82, 0, "HTOP_DC",   "height of dry convection top",                              "m"          },
-  {  84, 0, "HZEROCL",   "height of freezing level",                                  "m"          },
-  {  85, 0, "SNOWLMT",   "height of the snow fall limit in m above sea level",        "m"          },
-  {  86, 0, "HCBAS",     "height of cloud base",                                      "m"          },
-  {  87, 0, "HCTOP",     "height of cloud top",                                       "m"          },
-  {  91, 0, "C_T_LK",    "&",                                                         "1"          },
-  {  92, 0, "GAMSO_LK",  "&",                                                         "m-1"        },
-  {  93, 0, "DP_BS_LK",  "&",                                                         "m"          },
-  {  94, 0, "H_B1_LK",   "&",                                                         "m"          },
-  {  95, 0, "H_ML_LK",   "&",                                                         "m"          },
-  {  96, 0, "DEPTH_LK",  "lake depth",                                                "m"          },
-  {  97, 0, "FETCH_LK",  "wind fetch over lake",                                      "m"          },
-  {  99, 0, "QRS",       "precipitation water (water loading)",                       "1"          },
-  { 100, 0, "PRR_GSP",   "mass flux density of large scale rainfall",                 "kg m-2 s-1" },
-  { 101, 0, "PRS_GSP",   "mass flux density of large scale snowfall",                 "kg m-2 s-1" },
-  { 102, 0, "RAIN_GSP",  "large scale rainfall",                                      "kg m-2"     },
-  { 111, 0, "PRR_CON",   "mass flux density of convective rainfall",                  "kg m-2 s-1" },
-  { 112, 0, "PRS_CON",   "mass flux density of convective snowfall",                  "kg m-2 s-1" },
-  { 113, 0, "RAIN_CON",  "convective rainfall",                                       "kg m-2"     },
-  { 129, 0, "FRESHSNW",  "freshness of snow",                                         "undefined"  },
-  { 131, 0, "PRG_GSP",   "mass flux density of large scale graupel",                  "kg m-2 s-1" },
-  { 132, 0, "GRAU_GSP",  "large scale graupel",                                       "kg m-2"     },
-  { 133, 0, "RHO_SNOW",  "density of snow",                                           "kg m-3"     },
-  { 139, 0, "PP",        "deviation from reference pressure",                         "Pa"         },
-  { 140, 0, "RCLD",      "standard deviation of saturation deficit",                  "undefined"  },
-  { 143, 0, "CAPE_MU",   "cape of most unstable parcel",                              "J kg-1"     },
-  { 144, 0, "CIN_MU",    "convective inhibition of most unstable parcel",             "J kg-1"     },
-  { 145, 0, "CAPE_ML",   "cape of mean surface layer parcel",                         "J kg-1"     },
-  { 146, 0, "CIN_ML",    "convective inhibition of mean surface layer parcel",        "J kg-1"     },
-  { 147, 0, "TKE_CON",   "convective turbulent kinetic energy",                       "undefined"  },
-  { 148, 0, "TKETENS",   "tendency of turbulent kinetic energy",                      "undefined"  },
-  { 152, 0, "TKE",       "turbulent kinetic energy",                                  "m2 s-2"     },
-  { 153, 0, "TKVM",      "diffusion coefficient of momentum",                         "m2 s-1"     },
-  { 154, 0, "TKVH",      "diffusion coefficient of heat",                             "m2 s-1"     },
-  { 170, 0, "TCM",       "drag coefficient of momentum",                              "1"          },
-  { 171, 0, "TCH",       "drag coefficient of heat",                                  "1"          },
-  { 187, 0, "VMAX",      "maximum turbulent wind gust in 10m",                        "m s-1"      },
-  { 190, 0, "TSOIL",     "&",                                                         "K"          },
-  { 191, 0, "TSOIL",     "&",                                                         "K"          },
-  { 192, 0, "TSOIL",     "&",                                                         "K"          },
-  { 193, 0, "TSOIL",     "mixed layer temperature",                                   "K"          },
-  { 194, 0, "TSOIL",     "mean temperature of water column",                          "K"          },
-  { 197, 0, "TSOIL",     "soil temperature",                                          "K"          },
-  { 198, 0, "W_SO",      "soil water content",                                        "m"          },
-  { 199, 0, "W_SO_ICE",  "soil frozen water content",                                 "m"          },
-  { 200, 0, "W_I",       "canopy water amount",                                       "m"          },
-  { 203, 0, "TSOIL",     "snow surface temperature",                                  "K"          },
-  { 215, 0, "TSOIL",     "temperature of ice upper surface",                          "K"          },
-  { 230, 0, "dBZ",       "unattenuated radar reflectivity in Rayleigh approximation", "1"          },
-  { 240, 0, "MFLX_CON",  "convective mass flux density",                              "kg m-2 s-1" },
-  { 241, 0, "CAPE_CON",  "&",                                                         "J kg-1"     },
-  { 243, 0, "QCVG_CON",  "&",                                                         "s-1"        },
+static const param_type cosmo201[] = {
+  {   5, -1, 0, "APAB",      "&",                                                         "W m-2"      },
+  {  13, -1, 0, "SOHR_RAD",  "&",                                                         "K s-1"      },
+  {  14, -1, 0, "THHR_RAD",  "&",                                                         "K s-1"      },
+  {  20, -1, 0, "DURSUN",    "duration of sunshine",                                      "s"          },
+  {  29, -1, 0, "CLC",       "cloud area fraction",                                       "1"          },
+  {  30, -1, 0, "CLC_SGS",   "grid scale cloud area fraction",                            "1"          },
+  {  31, -1, 0, "QC",        "specific cloud liquid water content",                       "kg kg-1"    },
+  {  33, -1, 0, "QI",        "specific cloud ice content",                                "kg kg-1"    },
+  {  35, -1, 0, "QR",        "specific rain content",                                     "kg kg-1"    },
+  {  36, -1, 0, "QS",        "specific snow content",                                     "kg kg-1"    },
+  {  37, -1, 0, "TQR",       "total rain water content vertically integrated",            "kg m-2"     },
+  {  38, -1, 0, "TQS",       "total snow content vertically integrated",                  "kg m-2"     },
+  {  39, -1, 0, "QG",        "specific graupel content",                                  "kg kg-1"    },
+  {  40, -1, 0, "TQG",       "total graupel content vertically integrated",               "kg m-2"     },
+  {  41, -1, 0, "TWATER",    "cloud condensed water content",                             "kg m-2"     },
+  {  42, -1, 0, "TDIV_HUM",  "atmosphere water divergence",                               "kg m-2"     },
+  {  43, -1, 0, "QC_RAD",    "sub scale specific cloud liquid water content",             "kg kg-1"    },
+  {  44, -1, 0, "QI_RAD",    "sub scale specific cloud ice content",                      "kg kg-1"    },
+  {  61, -1, 0, "CLW_CON",   "convective cloud liquid water",                             "1"          },
+  {  68, -1, 0, "HBAS_CON",  "height of convective cloud base",                           "m"          },
+  {  69, -1, 0, "HTOP_CON",  "height of convective cloud top",                            "m"          },
+  {  70, -1, 0, "HBAS_CONI", "height of convective cloud base",                           "m"          },
+  {  71, -1, 0, "HTOP_CONI", "height of convective cloud top",                            "m"          },
+  {  72, -1, 0, "BAS_CON",   "index of convective cloud base",                            "1"          },
+  {  73, -1, 0, "TOP_CON",   "index of convective cloud top",                             "1"          },
+  {  74, -1, 0, "DT_CON",    "convective tendency of temperature",                        "K s-1"      },
+  {  75, -1, 0, "DQV_CON",   "convective tendency of specific humidity",                  "s-1"        },
+  {  78, -1, 0, "DU_CON",    "convective tendency of u-wind component",                   "m s-2"      },
+  {  79, -1, 0, "DV_CON",    "convective tendency of v-wind component",                   "m s-2"      },
+  {  82, -1, 0, "HTOP_DC",   "height of dry convection top",                              "m"          },
+  {  84, -1, 0, "HZEROCL",   "height of freezing level",                                  "m"          },
+  {  85, -1, 0, "SNOWLMT",   "height of the snow fall limit in m above sea level",        "m"          },
+  {  86, -1, 0, "HCBAS",     "height of cloud base",                                      "m"          },
+  {  87, -1, 0, "HCTOP",     "height of cloud top",                                       "m"          },
+  {  91, -1, 0, "C_T_LK",    "&",                                                         "1"          },
+  {  92, -1, 0, "GAMSO_LK",  "&",                                                         "m-1"        },
+  {  93, -1, 0, "DP_BS_LK",  "&",                                                         "m"          },
+  {  94, -1, 0, "H_B1_LK",   "&",                                                         "m"          },
+  {  95, -1, 0, "H_ML_LK",   "&",                                                         "m"          },
+  {  96, -1, 0, "DEPTH_LK",  "lake depth",                                                "m"          },
+  {  97, -1, 0, "FETCH_LK",  "wind fetch over lake",                                      "m"          },
+  {  99, -1, 0, "QRS",       "precipitation water (water loading)",                       "1"          },
+  { 100, -1, 0, "PRR_GSP",   "mass flux density of large scale rainfall",                 "kg m-2 s-1" },
+  { 101, -1, 0, "PRS_GSP",   "mass flux density of large scale snowfall",                 "kg m-2 s-1" },
+  { 102, -1, 0, "RAIN_GSP",  "large scale rainfall",                                      "kg m-2"     },
+  { 111, -1, 0, "PRR_CON",   "mass flux density of convective rainfall",                  "kg m-2 s-1" },
+  { 112, -1, 0, "PRS_CON",   "mass flux density of convective snowfall",                  "kg m-2 s-1" },
+  { 113, -1, 0, "RAIN_CON",  "convective rainfall",                                       "kg m-2"     },
+  { 129, -1, 0, "FRESHSNW",  "freshness of snow",                                         "undefined"  },
+  { 131, -1, 0, "PRG_GSP",   "mass flux density of large scale graupel",                  "kg m-2 s-1" },
+  { 132, -1, 0, "GRAU_GSP",  "large scale graupel",                                       "kg m-2"     },
+  { 133, -1, 0, "RHO_SNOW",  "density of snow",                                           "kg m-3"     },
+  { 139, -1, 0, "PP",        "deviation from reference pressure",                         "Pa"         },
+  { 140, -1, 0, "RCLD",      "standard deviation of saturation deficit",                  "undefined"  },
+  { 143, -1, 0, "CAPE_MU",   "cape of most unstable parcel",                              "J kg-1"     },
+  { 144, -1, 0, "CIN_MU",    "convective inhibition of most unstable parcel",             "J kg-1"     },
+  { 145, -1, 0, "CAPE_ML",   "cape of mean surface layer parcel",                         "J kg-1"     },
+  { 146, -1, 0, "CIN_ML",    "convective inhibition of mean surface layer parcel",        "J kg-1"     },
+  { 147, -1, 0, "TKE_CON",   "convective turbulent kinetic energy",                       "undefined"  },
+  { 148, -1, 0, "TKETENS",   "tendency of turbulent kinetic energy",                      "undefined"  },
+  { 152, -1, 0, "TKE",       "turbulent kinetic energy",                                  "m2 s-2"     },
+  { 153, -1, 0, "TKVM",      "diffusion coefficient of momentum",                         "m2 s-1"     },
+  { 154, -1, 0, "TKVH",      "diffusion coefficient of heat",                             "m2 s-1"     },
+  { 170, -1, 0, "TCM",       "drag coefficient of momentum",                              "1"          },
+  { 171, -1, 0, "TCH",       "drag coefficient of heat",                                  "1"          },
+  { 187, -1, 0, "VMAX",      "maximum turbulent wind gust in 10m",                        "m s-1"      },
+  { 190, -1, 0, "TSOIL",     "&",                                                         "K"          },
+  { 191, -1, 0, "TSOIL",     "&",                                                         "K"          },
+  { 192, -1, 0, "TSOIL",     "&",                                                         "K"          },
+  { 193, -1, 0, "TSOIL",     "mixed layer temperature",                                   "K"          },
+  { 194, -1, 0, "TSOIL",     "mean temperature of water column",                          "K"          },
+  { 197, -1, 0, "TSOIL",     "soil temperature",                                          "K"          },
+  { 198, -1, 0, "W_SO",      "soil water content",                                        "m"          },
+  { 199, -1, 0, "W_SO_ICE",  "soil frozen water content",                                 "m"          },
+  { 200, -1, 0, "W_I",       "canopy water amount",                                       "m"          },
+  { 203, -1, 0, "TSOIL",     "snow surface temperature",                                  "K"          },
+  { 215, -1, 0, "TSOIL",     "temperature of ice upper surface",                          "K"          },
+  { 230, -1, 0, "dBZ",       "unattenuated radar reflectivity in Rayleigh approximation", "1"          },
+  { 240, -1, 0, "MFLX_CON",  "convective mass flux density",                              "kg m-2 s-1" },
+  { 241, -1, 0, "CAPE_CON",  "&",                                                         "J kg-1"     },
+  { 243, -1, 0, "QCVG_CON",  "&",                                                         "s-1"        },
 };
 
-static const PAR cosmo202[] = {
-  {  46, 0, "SSO_STDH",  "standard deviation of subgrid scale height",                "m"         },
-  {  47, 0, "SSO_GAMMA", "anisotropy of topography",                                  "-"         },
-  {  48, 0, "SSO_THETA", "angle between principal axis of orography and global east", "-"         },
-  {  49, 0, "SSO_SIGMA", "mean slope of subgrid scale orography",                     "-"         },
-  {  55, 0, "FR_LAKE",   "fraction of inland lake water",                             "1"         },
-  {  57, 0, "SOILTYP",   "soil type",                                                 "1"         },
-  {  61, 0, "LAI",       "leaf area index",                                           "1"         },
-  {  62, 0, "ROOTDP",    "root depth",                                                "m"         },
-  {  64, 0, "HMO3",      "air pressure at ozone maximum",                             "Pa"        },
-  {  65, 0, "VIO3",      "vertical integrated ozone amount",                          "Pa"        },
-  {  67, 0, "PLCOV_MX",  "vegetation area fraction maximum",                          "1"         },
-  {  68, 0, "PLCOV_MN",  "vegetation area fraction minimum",                          "1"         },
-  {  69, 0, "LAI_MX",    "leaf area index maximum",                                   "1"         },
-  {  70, 0, "LAI_MN",    "leaf area index minimum",                                   "1"         },
-  {  75, 0, "FOR_E",     "ground fraction covered by evergreen forest",               "-"         },
-  {  76, 0, "FOR_D",     "ground fraction covered by deciduous forest",               "-"         },
-  { 104, 0, "DQVDT",     "tendency of water vapor",                                   "s-1"       },
-  { 105, 0, "QVSFLX",    "surface flux of water vapour",                              "s-1m-2"    },
-  { 113, 0, "FC",        "coriolis parameter",                                        "s-1"       },
-  { 114, 0, "RLAT",      "latitude",                                                  "radian"    },
-  { 115, 0, "RLON",      "longitude",                                                 "radian"    },
-  { 121, 0, "ZTD",       "integrated total atmospheric refractivity",                 "undefined" },
-  { 122, 0, "ZWD",       "integrated wet atmospheric refractivity",                   "undefined" },
-  { 123, 0, "ZHD",       "integrated dry atmospheric refractivity",                   "undefined" },
-  { 180, 0, "O3",        "ozone mass mixing ratio",                                   "kg kg-1"   },
-  { 200, 0, "I131a",     "undefined",                                                 "undefined" },
-  { 201, 0, "I131a_DD",  "undefined",                                                 "undefined" },
-  { 202, 0, "I131a_WD",  "undefined",                                                 "undefined" },
-  { 203, 0, "Cs137",     "undefined",                                                 "undefined" },
-  { 204, 0, "Cs137_DD",  "undefined",                                                 "undefined" },
-  { 205, 0, "Cs137_WD",  "undefined",                                                 "undefined" },
-  { 206, 0, "Te132",     "undefined",                                                 "undefined" },
-  { 207, 0, "Te132_DD",  "undefined",                                                 "undefined" },
-  { 208, 0, "Te132_WD",  "undefined",                                                 "undefined" },
-  { 209, 0, "Zr95",      "undefined",                                                 "undefined" },
-  { 210, 0, "Zr95_DD",   "undefined",                                                 "undefined" },
-  { 211, 0, "Zr95_WD",   "undefined",                                                 "undefined" },
-  { 212, 0, "Kr85",      "undefined",                                                 "undefined" },
-  { 213, 0, "Kr85_DD",   "undefined",                                                 "undefined" },
-  { 214, 0, "Kr85_WD",   "undefined",                                                 "undefined" },
-  { 215, 0, "TRACER",    "undefined",                                                 "undefined" },
-  { 216, 0, "TRACER_DD", "undefined",                                                 "undefined" },
-  { 217, 0, "TRACER_WD", "undefined",                                                 "undefined" },
-  { 218, 0, "Xe133",     "undefined",                                                 "undefined" },
-  { 219, 0, "Xe133_DD",  "undefined",                                                 "undefined" },
-  { 220, 0, "Xe133_WD",  "undefined",                                                 "undefined" },
-  { 221, 0, "I131g",     "undefined",                                                 "undefined" },
-  { 222, 0, "I131g_DD",  "undefined",                                                 "undefined" },
-  { 223, 0, "I131g_WD",  "undefined",                                                 "undefined" },
-  { 224, 0, "I131o",     "undefined",                                                 "undefined" },
-  { 225, 0, "I131o_DD",  "undefined",                                                 "undefined" },
-  { 226, 0, "I131o_WD",  "undefined",                                                 "undefined" },
-  { 227, 0, "Ba140",     "undefined",                                                 "undefined" },
-  { 228, 0, "Ba140_DD",  "undefined",                                                 "undefined" },
-  { 229, 0, "Ba140_WD",  "undefined",                                                 "undefined" },
-  { 230, 0, "Sr90",      "undefined",                                                 "undefined" },
-  { 231, 0, "Sr90_DD",   "undefined",                                                 "undefined" },
-  { 232, 0, "Sr90_WD",   "undefined",                                                 "undefined" },
-  { 233, 0, "Ru103",     "undefined",                                                 "undefined" },
-  { 234, 0, "Ru103_DD",  "undefined",                                                 "undefined" },
-  { 235, 0, "Ru103_WD",  "undefined",                                                 "undefined" },
+static const param_type cosmo202[] = {
+  {  46, -1, 0, "SSO_STDH",  "standard deviation of subgrid scale height",                "m"         },
+  {  47, -1, 0, "SSO_GAMMA", "anisotropy of topography",                                  "-"         },
+  {  48, -1, 0, "SSO_THETA", "angle between principal axis of orography and global east", "-"         },
+  {  49, -1, 0, "SSO_SIGMA", "mean slope of subgrid scale orography",                     "-"         },
+  {  55, -1, 0, "FR_LAKE",   "fraction of inland lake water",                             "1"         },
+  {  57, -1, 0, "SOILTYP",   "soil type",                                                 "1"         },
+  {  61, -1, 0, "LAI",       "leaf area index",                                           "1"         },
+  {  62, -1, 0, "ROOTDP",    "root depth",                                                "m"         },
+  {  64, -1, 0, "HMO3",      "air pressure at ozone maximum",                             "Pa"        },
+  {  65, -1, 0, "VIO3",      "vertical integrated ozone amount",                          "Pa"        },
+  {  67, -1, 0, "PLCOV_MX",  "vegetation area fraction maximum",                          "1"         },
+  {  68, -1, 0, "PLCOV_MN",  "vegetation area fraction minimum",                          "1"         },
+  {  69, -1, 0, "LAI_MX",    "leaf area index maximum",                                   "1"         },
+  {  70, -1, 0, "LAI_MN",    "leaf area index minimum",                                   "1"         },
+  {  75, -1, 0, "FOR_E",     "ground fraction covered by evergreen forest",               "-"         },
+  {  76, -1, 0, "FOR_D",     "ground fraction covered by deciduous forest",               "-"         },
+  { 104, -1, 0, "DQVDT",     "tendency of water vapor",                                   "s-1"       },
+  { 105, -1, 0, "QVSFLX",    "surface flux of water vapour",                              "s-1m-2"    },
+  { 113, -1, 0, "FC",        "coriolis parameter",                                        "s-1"       },
+  { 114, -1, 0, "RLAT",      "latitude",                                                  "radian"    },
+  { 115, -1, 0, "RLON",      "longitude",                                                 "radian"    },
+  { 121, -1, 0, "ZTD",       "integrated total atmospheric refractivity",                 "undefined" },
+  { 122, -1, 0, "ZWD",       "integrated wet atmospheric refractivity",                   "undefined" },
+  { 123, -1, 0, "ZHD",       "integrated dry atmospheric refractivity",                   "undefined" },
+  { 180, -1, 0, "O3",        "ozone mass mixing ratio",                                   "kg kg-1"   },
+  { 200, -1, 0, "I131a",     "undefined",                                                 "undefined" },
+  { 201, -1, 0, "I131a_DD",  "undefined",                                                 "undefined" },
+  { 202, -1, 0, "I131a_WD",  "undefined",                                                 "undefined" },
+  { 203, -1, 0, "Cs137",     "undefined",                                                 "undefined" },
+  { 204, -1, 0, "Cs137_DD",  "undefined",                                                 "undefined" },
+  { 205, -1, 0, "Cs137_WD",  "undefined",                                                 "undefined" },
+  { 206, -1, 0, "Te132",     "undefined",                                                 "undefined" },
+  { 207, -1, 0, "Te132_DD",  "undefined",                                                 "undefined" },
+  { 208, -1, 0, "Te132_WD",  "undefined",                                                 "undefined" },
+  { 209, -1, 0, "Zr95",      "undefined",                                                 "undefined" },
+  { 210, -1, 0, "Zr95_DD",   "undefined",                                                 "undefined" },
+  { 211, -1, 0, "Zr95_WD",   "undefined",                                                 "undefined" },
+  { 212, -1, 0, "Kr85",      "undefined",                                                 "undefined" },
+  { 213, -1, 0, "Kr85_DD",   "undefined",                                                 "undefined" },
+  { 214, -1, 0, "Kr85_WD",   "undefined",                                                 "undefined" },
+  { 215, -1, 0, "TRACER",    "undefined",                                                 "undefined" },
+  { 216, -1, 0, "TRACER_DD", "undefined",                                                 "undefined" },
+  { 217, -1, 0, "TRACER_WD", "undefined",                                                 "undefined" },
+  { 218, -1, 0, "Xe133",     "undefined",                                                 "undefined" },
+  { 219, -1, 0, "Xe133_DD",  "undefined",                                                 "undefined" },
+  { 220, -1, 0, "Xe133_WD",  "undefined",                                                 "undefined" },
+  { 221, -1, 0, "I131g",     "undefined",                                                 "undefined" },
+  { 222, -1, 0, "I131g_DD",  "undefined",                                                 "undefined" },
+  { 223, -1, 0, "I131g_WD",  "undefined",                                                 "undefined" },
+  { 224, -1, 0, "I131o",     "undefined",                                                 "undefined" },
+  { 225, -1, 0, "I131o_DD",  "undefined",                                                 "undefined" },
+  { 226, -1, 0, "I131o_WD",  "undefined",                                                 "undefined" },
+  { 227, -1, 0, "Ba140",     "undefined",                                                 "undefined" },
+  { 228, -1, 0, "Ba140_DD",  "undefined",                                                 "undefined" },
+  { 229, -1, 0, "Ba140_WD",  "undefined",                                                 "undefined" },
+  { 230, -1, 0, "Sr90",      "undefined",                                                 "undefined" },
+  { 231, -1, 0, "Sr90_DD",   "undefined",                                                 "undefined" },
+  { 232, -1, 0, "Sr90_WD",   "undefined",                                                 "undefined" },
+  { 233, -1, 0, "Ru103",     "undefined",                                                 "undefined" },
+  { 234, -1, 0, "Ru103_DD",  "undefined",                                                 "undefined" },
+  { 235, -1, 0, "Ru103_WD",  "undefined",                                                 "undefined" },
 };
 
-static const PAR cosmo203[] = {
-  { 135, 0, "LCL_ML",   "undefined",                  "undefined" },
-  { 136, 0, "LFC_ML",   "undefined",                  "undefined" },
-  { 137, 0, "CAPE_3KM", "undefined",                  "undefined" },
-  { 138, 0, "SWISS00",  "swiss00 index",              "1"         },
-  { 139, 0, "SWISS12",  "swiss12 index",              "1"         },
-  { 147, 0, "SLI",      "surface lifted index",       "K"         },
-  { 149, 0, "SI",       "showalter index",            "K"         },
-  { 155, 0, "BRN",      "undefined",                  "undefined" },
-  { 156, 0, "HPBL",     "undefined",                  "undefined" },
-  { 203, 0, "CLDEPTH",  "normalized cloud depth",     "1"         },
-  { 204, 0, "CLCT_MOD", "modified_total_cloud_cover", "1"         },
+static const param_type cosmo203[] = {
+  { 135, -1, 0, "LCL_ML",   "undefined",                  "undefined" },
+  { 136, -1, 0, "LFC_ML",   "undefined",                  "undefined" },
+  { 137, -1, 0, "CAPE_3KM", "undefined",                  "undefined" },
+  { 138, -1, 0, "SWISS00",  "swiss00 index",              "1"         },
+  { 139, -1, 0, "SWISS12",  "swiss12 index",              "1"         },
+  { 147, -1, 0, "SLI",      "surface lifted index",       "K"         },
+  { 149, -1, 0, "SI",       "showalter index",            "K"         },
+  { 155, -1, 0, "BRN",      "undefined",                  "undefined" },
+  { 156, -1, 0, "HPBL",     "undefined",                  "undefined" },
+  { 203, -1, 0, "CLDEPTH",  "normalized cloud depth",     "1"         },
+  { 204, -1, 0, "CLCT_MOD", "modified_total_cloud_cover", "1"         },
 };
 
-static const PAR cosmo205[] = {
-  {   1, 0, "SYNME5", "synthetic satellite images Meteosat5", "-" },
-  {   2, 0, "SYNME6", "synthetic satellite images Meteosat6", "-" },
-  {   3, 0, "SYNME7", "synthetic satellite images Meteosat7", "-" },
-  {   4, 0, "SYNMSG", "synthetic satellite images MSG",       "-" },
+static const param_type cosmo205[] = {
+  {   1, -1, 0, "SYNME5", "synthetic satellite images Meteosat5", "-" },
+  {   2, -1, 0, "SYNME6", "synthetic satellite images Meteosat6", "-" },
+  {   3, -1, 0, "SYNME7", "synthetic satellite images Meteosat7", "-" },
+  {   4, -1, 0, "SYNMSG", "synthetic satellite images MSG",       "-" },
 };
 
-static const PAR cosmo250[] = {
-  {   1, 0, "QNH",       "sea level air pressure",                                         "hPa"                                },
-  {  11, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
-  {  12, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
-  {  13, 0, "D_T_2M_K",  "kalman correction to 2m temperature",                            "K"                                  },
-  {  14, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
-  {  15, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
-  {  16, 0, "RH_ICE",    "relative humidity over ice",                                     "%"                                  },
-  {  17, 0, "TD",        "dew point temperature",                                          "K"                                  },
-  {  18, 0, "D_TD",      "dew point depression",                                           "K"                                  },
-  {  19, 0, "THETAE",    "equivalent potential temperature",                               "K"                                  },
-  {  20, 0, "TD_2M_K",   "2m dew point temperature",                                       "K"                                  },
-  {  21, 0, "D_TD_2M_K", "kalman correction to 2m dew point temperature",                  "K"                                  },
-  {  22, 0, "TD_2M_OLD", "2m dew point temperature",                                       "K"                                  },
-  {  23, 0, "TD_2M_BUZ", "2m dew point temperature",                                       "K"                                  },
-  {  24, 0, "HI",        "heat index",                                                     "Fahrenheit"                         },
-  {  25, 0, "DURSUN_M",  "maximum duration of sunshine",                                   "s"                                  },
-  {  26, 0, "DURSUN_R",  "relative duration of sunshine",                                  "%"                                  },
-  {  52, 0, "RH_2M_K",   "2m relative humidity",                                           "%"                                  },
-  {  53, 0, "D_RH_2M_K", "kalman correction to 2m relative humidity",                      "%"                                  },
-  {  58, 0, "CLI_RATIO", "cloud ice ratio (Qi/Qc+Qi)",                                     "%"                                  },
-  {  61, 0, "TOT_SNOW",  "total precipitation in snow",                                    "kg/m**2"                            },
-  {  62, 0, "TOT_RAIN",  "total precipitation in rain",                                    "kg/m**2"                            },
-  {  63, 0, "TOT_CON",   "total convective precipitation",                                 "kg/m**2"                            },
-  {  64, 0, "TOT_GSP",   "total large scale precipitation",                                "kg/m**2"                            },
-  {  65, 0, "SNOW_%",    "percentage of precipitation in snow",                            "%"                                  },
-  {  66, 0, "CONV_%",    "percentage of convective precipitation",                         "%"                                  },
-  {  67, 0, "VORTP_ABS", "absolute",                                                       "VORTP_ABS 67 -1 absolute vorticity" },
-  {  68, 0, "VORTP_REL", "relative",                                                       "VORTP_REL 68 -1 relative vorticity" },
-  {  70, 0, "PDIFF_CON", "pressure difference between cloud base and cloud top",           "Pa"                                 },
-  {  71, 0, "TTOP_CON",  "temperature at cloud top",                                       "K"                                  },
-  {  80, 0, "GEM",       "emissivity of the ground",                                       "%"                                  },
-  {  82, 0, "Z0LOC",     "local surface roughness length",                                 "m"                                  },
-  { 110, 0, "LUM",       "luminosity",                                                     "klux"                               },
-  { 111, 0, "GLOB",      "global shortwave radiation at surface",                          "W/m**2"                             },
-  { 112, 0, "LW_IN_TG",  "incoming longwave radiation at surface",                         "W/m**2"                             },
-  { 113, 0, "LW_IN_TS",  "incoming longwave radiation at surface",                         "W/m**2"                             },
-  { 114, 0, "LW_IN_T2M", "incoming longwave radiation at surface",                         "W/m**2"                             },
-  { 115, 0, "SWISS_WE",  "Swiss",                                                          "SWISS_WE 115 1 Swiss coordinates"   },
-  { 116, 0, "SWISS_SN",  "Swiss",                                                          "SWISS_SN 116 1 Swiss coordinates"   },
-  { 150, 0, "KOINDEX",   "KO index",                                                       "K"                                  },
-  { 151, 0, "TTINDEX",   "total-totals index",                                             "K"                                  },
-  { 152, 0, "DCI",       "deep convection index",                                          "K"                                  },
-  { 153, 0, "SWEAT",     "severe weather thread index",                                    "undefined"                          },
-  { 154, 0, "ADEDO2",    "adedokun 2 index",                                               "K"                                  },
-  { 160, 0, "C_TSTORM",  "thunderstorm index using AdaBoost classifier",                   "undefined"                          },
-  { 161, 0, "CN_TSTORM", "thunderstorm probabilty using AdaBoost classifier",              "%"                                  },
-  { 200, 0, "WSHEARL",   "wind shear between surface and 3 km asl",                        "1/s"                                },
-  { 201, 0, "WSHEARM",   "wind shear between surface and 6 km asl",                        "1/s"                                },
-  { 202, 0, "WSHEARU",   "wind shear between 3 km (or surface) and 6 km asl",              "1/s"                                },
-  { 211, 0, "VWIN",      "maximum OLD turbulent wind gust in 10m",                         "m s-1"                              },
-  { 212, 0, "VW10M_20",  "maximum 10m wind speed",                                         "m s-1"                              },
-  { 213, 0, "VW10M_25",  "duration of VWIN_10M above 25 knots",                            "s"                                  },
-  { 214, 0, "VW10M_30",  "duration of VWIN_10M above 30 knots",                            "s"                                  },
-  { 215, 0, "VW10M_35",  "duration of VWIN_10M above 35 knots",                            "s"                                  },
-  { 216, 0, "VW10M_40",  "duration of VWIN_10M above 40 knots",                            "s"                                  },
-  { 217, 0, "VW10M_45",  "duration of VWIN_10M above 45 knots",                            "s"                                  },
-  { 218, 0, "VW10M_50",  "duration of VWIN_10M above 50 knots",                            "s"                                  },
-  { 219, 0, "VOLD",      "maximum turbulent wind gust in 10m",                             "m s-1"                              },
-  { 220, 0, "VJPS",      "maximum turbulent wind gust in 10m",                             "m s-1"                              },
-  { 221, 0, "VBRA",      "maximum Brasseur turbulent wind gust in 10m",                    "m s-1"                              },
-  { 222, 0, "VB10M_20",  "duration of VBRA_10M above 20 knots",                            "s"                                  },
-  { 223, 0, "VB10M_25",  "duration of VBRA_10M above 25 knots",                            "s"                                  },
-  { 224, 0, "VB10M_30",  "duration of VBRA_10M above 30 knots",                            "s"                                  },
-  { 225, 0, "VB10M_35",  "duration of VBRA_10M above 35 knots",                            "s"                                  },
-  { 226, 0, "VB10M_40",  "duration of VBRA_10M above 40 knots",                            "s"                                  },
-  { 227, 0, "VB10M_45",  "duration of VBRA_10M above 45 knots",                            "s"                                  },
-  { 228, 0, "VB10M_50",  "duration of VBRA_10M above 50 knots",                            "s"                                  },
-  { 231, 0, "VCON",      "maximum convective wind gust in 10m",                            "m s-1"                              },
-  { 232, 0, "VC10M_20",  "duration of VCON_10M above 20 knots",                            "s"                                  },
-  { 233, 0, "VC10M_25",  "duration of VCON_10M above 25 knots",                            "s"                                  },
-  { 234, 0, "VC10M_30",  "duration of VCON_10M above 30 knots",                            "s"                                  },
-  { 235, 0, "VC10M_35",  "duration of VCON_10M above 35 knots",                            "s"                                  },
-  { 236, 0, "VC10M_40",  "duration of VCON_10M above 40 knots",                            "s"                                  },
-  { 237, 0, "VC10M_45",  "duration of VCON_10M above 45 knots",                            "s"                                  },
-  { 238, 0, "VC10M_50",  "duration of VCON_10M above 50 knots",                            "s"                                  },
-  { 241, 0, "FMAX",      "maximum wind speed at k=ke",                                     "m s-1"                              },
-  { 242, 0, "USTARMAX",  "maximal u*=SQRT(Drag_coef)*fmax_10m",                            "m s-1"                              },
-  { 243, 0, "GLOB_DIF",  "global diffuse shortwave radiation at the surface",              "W/m**2"                             },
-  { 244, 0, "GLOB_DIR",  "global direct (beam) shortwave radiation at the surface",        "W/m**2"                             },
-  { 245, 0, "GLOB_vE",   "global shortwave radiation on a vertical surface facing east",   "W/m**2"                             },
-  { 246, 0, "GLOB_vS",   "global shortwave radiation on a vertical surface facing south",  "W/m**2"                             },
-  { 247, 0, "GLOB_vW",   "global shortwave radiation on a vertical surface facing west",   "W/m**2"                             },
-  { 248, 0, "GLOB_vN",   "global shortwave radiation on a vertical surface facing north",  "W/m**2"                             },
-  { 249, 0, "LW_TG_vS",  "incoming longwave radiation on a vertical surface facing south", "W/m**2"                             },
-  { 250, 0, "ENTH",      "enthalpy",                                                       "kJ/kg"                              },
-  { 251, 0, "ENTH",      "enthalpy",                                                       "kJ/kg"                              },
-  { 252, 0, "MIXRAT",    "mixing ratio",                                                   "g/kg"                               },
-  { 253, 0, "MIXRAT",    "mixing ratio",                                                   "g/kg"                               },
-  { 254, 0, "TW",        "wet bulb temperature",                                           "degC"                               },
-  { 255, 0, "TW",        "wet bulb temperature",                                           "degC"                               },
+static const param_type cosmo250[] = {
+  {   1, -1, 0, "QNH",       "sea level air pressure",                                         "hPa"                                },
+  {  11, -1, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
+  {  12, -1, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
+  {  13, -1, 0, "D_T_2M_K",  "kalman correction to 2m temperature",                            "K"                                  },
+  {  14, -1, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
+  {  15, -1, 0, "TSOIL",     "2m temperature",                                                 "K"                                  },
+  {  16, -1, 0, "RH_ICE",    "relative humidity over ice",                                     "%"                                  },
+  {  17, -1, 0, "TD",        "dew point temperature",                                          "K"                                  },
+  {  18, -1, 0, "D_TD",      "dew point depression",                                           "K"                                  },
+  {  19, -1, 0, "THETAE",    "equivalent potential temperature",                               "K"                                  },
+  {  20, -1, 0, "TD_2M_K",   "2m dew point temperature",                                       "K"                                  },
+  {  21, -1, 0, "D_TD_2M_K", "kalman correction to 2m dew point temperature",                  "K"                                  },
+  {  22, -1, 0, "TD_2M_OLD", "2m dew point temperature",                                       "K"                                  },
+  {  23, -1, 0, "TD_2M_BUZ", "2m dew point temperature",                                       "K"                                  },
+  {  24, -1, 0, "HI",        "heat index",                                                     "Fahrenheit"                         },
+  {  25, -1, 0, "DURSUN_M",  "maximum duration of sunshine",                                   "s"                                  },
+  {  26, -1, 0, "DURSUN_R",  "relative duration of sunshine",                                  "%"                                  },
+  {  52, -1, 0, "RH_2M_K",   "2m relative humidity",                                           "%"                                  },
+  {  53, -1, 0, "D_RH_2M_K", "kalman correction to 2m relative humidity",                      "%"                                  },
+  {  58, -1, 0, "CLI_RATIO", "cloud ice ratio (Qi/Qc+Qi)",                                     "%"                                  },
+  {  61, -1, 0, "TOT_SNOW",  "total precipitation in snow",                                    "kg/m**2"                            },
+  {  62, -1, 0, "TOT_RAIN",  "total precipitation in rain",                                    "kg/m**2"                            },
+  {  63, -1, 0, "TOT_CON",   "total convective precipitation",                                 "kg/m**2"                            },
+  {  64, -1, 0, "TOT_GSP",   "total large scale precipitation",                                "kg/m**2"                            },
+  {  65, -1, 0, "SNOW_%",    "percentage of precipitation in snow",                            "%"                                  },
+  {  66, -1, 0, "CONV_%",    "percentage of convective precipitation",                         "%"                                  },
+  {  67, -1, 0, "VORTP_ABS", "absolute",                                                       "VORTP_ABS 67 -1 absolute vorticity" },
+  {  68, -1, 0, "VORTP_REL", "relative",                                                       "VORTP_REL 68 -1 relative vorticity" },
+  {  70, -1, 0, "PDIFF_CON", "pressure difference between cloud base and cloud top",           "Pa"                                 },
+  {  71, -1, 0, "TTOP_CON",  "temperature at cloud top",                                       "K"                                  },
+  {  80, -1, 0, "GEM",       "emissivity of the ground",                                       "%"                                  },
+  {  82, -1, 0, "Z0LOC",     "local surface roughness length",                                 "m"                                  },
+  { 110, -1, 0, "LUM",       "luminosity",                                                     "klux"                               },
+  { 111, -1, 0, "GLOB",      "global shortwave radiation at surface",                          "W/m**2"                             },
+  { 112, -1, 0, "LW_IN_TG",  "incoming longwave radiation at surface",                         "W/m**2"                             },
+  { 113, -1, 0, "LW_IN_TS",  "incoming longwave radiation at surface",                         "W/m**2"                             },
+  { 114, -1, 0, "LW_IN_T2M", "incoming longwave radiation at surface",                         "W/m**2"                             },
+  { 115, -1, 0, "SWISS_WE",  "Swiss",                                                          "SWISS_WE 115 1 Swiss coordinates"   },
+  { 116, -1, 0, "SWISS_SN",  "Swiss",                                                          "SWISS_SN 116 1 Swiss coordinates"   },
+  { 150, -1, 0, "KOINDEX",   "KO index",                                                       "K"                                  },
+  { 151, -1, 0, "TTINDEX",   "total-totals index",                                             "K"                                  },
+  { 152, -1, 0, "DCI",       "deep convection index",                                          "K"                                  },
+  { 153, -1, 0, "SWEAT",     "severe weather thread index",                                    "undefined"                          },
+  { 154, -1, 0, "ADEDO2",    "adedokun 2 index",                                               "K"                                  },
+  { 160, -1, 0, "C_TSTORM",  "thunderstorm index using AdaBoost classifier",                   "undefined"                          },
+  { 161, -1, 0, "CN_TSTORM", "thunderstorm probabilty using AdaBoost classifier",              "%"                                  },
+  { 200, -1, 0, "WSHEARL",   "wind shear between surface and 3 km asl",                        "1/s"                                },
+  { 201, -1, 0, "WSHEARM",   "wind shear between surface and 6 km asl",                        "1/s"                                },
+  { 202, -1, 0, "WSHEARU",   "wind shear between 3 km (or surface) and 6 km asl",              "1/s"                                },
+  { 211, -1, 0, "VWIN",      "maximum OLD turbulent wind gust in 10m",                         "m s-1"                              },
+  { 212, -1, 0, "VW10M_20",  "maximum 10m wind speed",                                         "m s-1"                              },
+  { 213, -1, 0, "VW10M_25",  "duration of VWIN_10M above 25 knots",                            "s"                                  },
+  { 214, -1, 0, "VW10M_30",  "duration of VWIN_10M above 30 knots",                            "s"                                  },
+  { 215, -1, 0, "VW10M_35",  "duration of VWIN_10M above 35 knots",                            "s"                                  },
+  { 216, -1, 0, "VW10M_40",  "duration of VWIN_10M above 40 knots",                            "s"                                  },
+  { 217, -1, 0, "VW10M_45",  "duration of VWIN_10M above 45 knots",                            "s"                                  },
+  { 218, -1, 0, "VW10M_50",  "duration of VWIN_10M above 50 knots",                            "s"                                  },
+  { 219, -1, 0, "VOLD",      "maximum turbulent wind gust in 10m",                             "m s-1"                              },
+  { 220, -1, 0, "VJPS",      "maximum turbulent wind gust in 10m",                             "m s-1"                              },
+  { 221, -1, 0, "VBRA",      "maximum Brasseur turbulent wind gust in 10m",                    "m s-1"                              },
+  { 222, -1, 0, "VB10M_20",  "duration of VBRA_10M above 20 knots",                            "s"                                  },
+  { 223, -1, 0, "VB10M_25",  "duration of VBRA_10M above 25 knots",                            "s"                                  },
+  { 224, -1, 0, "VB10M_30",  "duration of VBRA_10M above 30 knots",                            "s"                                  },
+  { 225, -1, 0, "VB10M_35",  "duration of VBRA_10M above 35 knots",                            "s"                                  },
+  { 226, -1, 0, "VB10M_40",  "duration of VBRA_10M above 40 knots",                            "s"                                  },
+  { 227, -1, 0, "VB10M_45",  "duration of VBRA_10M above 45 knots",                            "s"                                  },
+  { 228, -1, 0, "VB10M_50",  "duration of VBRA_10M above 50 knots",                            "s"                                  },
+  { 231, -1, 0, "VCON",      "maximum convective wind gust in 10m",                            "m s-1"                              },
+  { 232, -1, 0, "VC10M_20",  "duration of VCON_10M above 20 knots",                            "s"                                  },
+  { 233, -1, 0, "VC10M_25",  "duration of VCON_10M above 25 knots",                            "s"                                  },
+  { 234, -1, 0, "VC10M_30",  "duration of VCON_10M above 30 knots",                            "s"                                  },
+  { 235, -1, 0, "VC10M_35",  "duration of VCON_10M above 35 knots",                            "s"                                  },
+  { 236, -1, 0, "VC10M_40",  "duration of VCON_10M above 40 knots",                            "s"                                  },
+  { 237, -1, 0, "VC10M_45",  "duration of VCON_10M above 45 knots",                            "s"                                  },
+  { 238, -1, 0, "VC10M_50",  "duration of VCON_10M above 50 knots",                            "s"                                  },
+  { 241, -1, 0, "FMAX",      "maximum wind speed at k=ke",                                     "m s-1"                              },
+  { 242, -1, 0, "USTARMAX",  "maximal u*=SQRT(Drag_coef)*fmax_10m",                            "m s-1"                              },
+  { 243, -1, 0, "GLOB_DIF",  "global diffuse shortwave radiation at the surface",              "W/m**2"                             },
+  { 244, -1, 0, "GLOB_DIR",  "global direct (beam) shortwave radiation at the surface",        "W/m**2"                             },
+  { 245, -1, 0, "GLOB_vE",   "global shortwave radiation on a vertical surface facing east",   "W/m**2"                             },
+  { 246, -1, 0, "GLOB_vS",   "global shortwave radiation on a vertical surface facing south",  "W/m**2"                             },
+  { 247, -1, 0, "GLOB_vW",   "global shortwave radiation on a vertical surface facing west",   "W/m**2"                             },
+  { 248, -1, 0, "GLOB_vN",   "global shortwave radiation on a vertical surface facing north",  "W/m**2"                             },
+  { 249, -1, 0, "LW_TG_vS",  "incoming longwave radiation on a vertical surface facing south", "W/m**2"                             },
+  { 250, -1, 0, "ENTH",      "enthalpy",                                                       "kJ/kg"                              },
+  { 251, -1, 0, "ENTH",      "enthalpy",                                                       "kJ/kg"                              },
+  { 252, -1, 0, "MIXRAT",    "mixing ratio",                                                   "g/kg"                               },
+  { 253, -1, 0, "MIXRAT",    "mixing ratio",                                                   "g/kg"                               },
+  { 254, -1, 0, "TW",        "wet bulb temperature",                                           "degC"                               },
+  { 255, -1, 0, "TW",        "wet bulb temperature",                                           "degC"                               },
 };
 
 
 static
 void tableDefault(void)
 {
-  int tableID, instID, modelID;
-
-
-  /*
-   *  define table : echam4
-   */
-
-  instID  = institutInq(98, 255, "MPIMET", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(98, 255, "MPIMET", NULL);
-
-  modelID = modelInq(instID, 0, "ECHAM4");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "ECHAM4");
-
-  tableID = tableDef(modelID, 128, "echam4");
-
-  tableLink(tableID, echam4, sizeof(echam4) / sizeof(PAR));
-
-  /*
-   *  define table : echam5
-   */
-
-  instID  = institutInq(0, 0, "MPIMET", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MPIMET", NULL);
-
-  modelID = modelInq(instID, 0, "ECHAM5");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "ECHAM5");
-
-  tableID = tableDef(modelID, 128, "echam5");
-
-  tableLink(tableID, echam5, sizeof(echam5) / sizeof(PAR));
-
-  /*
-   *  define table : echam6
-   */
-
-  instID  = institutInq(0, 0, "MPIMET", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MPIMET", NULL);
 
-  modelID = modelInq(instID, 0, "ECHAM6");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "ECHAM6");
+  // define table : echam4
+  {
+    int instID  = institutInq(98, 255, "MPIMET", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(98, 255, "MPIMET", NULL);
 
-  tableID = tableDef(modelID, 128, "echam6");
+    int modelID = modelInq(instID, 0, "ECHAM4");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "ECHAM4");
 
-  tableLink(tableID, echam6, sizeof(echam6) / sizeof(PAR));
+    int tableID = tableDef(modelID, 128, "echam4");
 
-  /*
-   *  define table : mpiom1
-   */
+    tableLink(tableID, echam4, sizeof(echam4) / sizeof(param_type));
+  }
 
-  instID  = institutInq(0, 0, "MPIMET", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MPIMET", NULL);
+  // define table : echam5
+  {
+    int instID  = institutInq(0, 0, "MPIMET", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MPIMET", NULL);
 
-  modelID = modelInq(instID, 0, "MPIOM1");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "MPIOM1");
+    int modelID = modelInq(instID, 0, "ECHAM5");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "ECHAM5");
 
-  tableID = tableDef(modelID, 128, "mpiom1");
+    int tableID = tableDef(modelID, 128, "echam5");
 
-  tableLink(tableID, mpiom1, sizeof(mpiom1) / sizeof(PAR));
+    tableLink(tableID, echam5, sizeof(echam5) / sizeof(param_type));
+  }
 
-  /*
-   *  define table : ecmwf
-   */
+  // define table : echam6
+  {
+    int instID  = institutInq(0, 0, "MPIMET", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MPIMET", NULL);
 
-  instID  = institutInq(0, 0, "ECMWF", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "ECMWF", NULL);
+    int modelID = modelInq(instID, 0, "ECHAM6");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "ECHAM6");
 
-  modelID = modelInq(instID, 0, "");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "");
+    int tableID = tableDef(modelID, 128, "echam6");
 
-  tableID = tableDef(modelID, 128, "ecmwf");
+    tableLink(tableID, echam6, sizeof(echam6) / sizeof(param_type));
+  }
 
-  tableLink(tableID, ecmwf, sizeof(ecmwf) / sizeof(PAR));
+  // define table : mpiom1
+  {
+    int instID  = institutInq(0, 0, "MPIMET", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MPIMET", NULL);
 
-  /*
-   *  define table : remo
-   */
+    int modelID = modelInq(instID, 0, "MPIOM1");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "MPIOM1");
 
-  instID  = institutInq(0, 0, "MPIMET", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MPIMET", NULL);
+    int tableID = tableDef(modelID, 128, "mpiom1");
 
-  modelID = modelInq(instID, 0, "REMO");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "REMO");
+    tableLink(tableID, mpiom1, sizeof(mpiom1) / sizeof(param_type));
+  }
 
-  tableID = tableDef(modelID, 128, "remo");
+  // define table : ecmwf
+  {
+    int instID  = institutInq(0, 0, "ECMWF", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "ECMWF", NULL);
 
-  tableLink(tableID, remo, sizeof(remo) / sizeof(PAR));
+    int modelID = modelInq(instID, 0, "");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "");
 
-  /*
-   *  define table : cosmo002
-   */
+    int tableID = tableDef(modelID, 128, "ecmwf");
 
-  instID  = institutInq(0, 0, "MCH", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MCH", NULL);
+    tableLink(tableID, ecmwf, sizeof(ecmwf) / sizeof(param_type));
+  }
 
-  modelID = modelInq(instID, 0, "COSMO");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "COSMO");
+  // define table : remo
+  {
+    int instID  = institutInq(0, 0, "MPIMET", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MPIMET", NULL);
 
-  tableID = tableDef(modelID, 002, "cosmo002");
+    int modelID = modelInq(instID, 0, "REMO");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "REMO");
 
-  tableLink(tableID, cosmo002, sizeof(cosmo002) / sizeof(PAR));
+    int tableID = tableDef(modelID, 128, "remo");
 
-  /*
-   *  define table : cosmo201
-   */
+    tableLink(tableID, remo, sizeof(remo) / sizeof(param_type));
+  }
 
-  instID  = institutInq(0, 0, "MCH", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MCH", NULL);
+  // define table : cosmo002
+  {
+    int instID  = institutInq(0, 0, "MCH", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MCH", NULL);
 
-  modelID = modelInq(instID, 0, "COSMO");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "COSMO");
+    int modelID = modelInq(instID, 0, "COSMO");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "COSMO");
 
-  tableID = tableDef(modelID, 201, "cosmo201");
+    int tableID = tableDef(modelID, 002, "cosmo002");
 
-  tableLink(tableID, cosmo201, sizeof(cosmo201) / sizeof(PAR));
+    tableLink(tableID, cosmo002, sizeof(cosmo002) / sizeof(param_type));
+  }
 
-  /*
-   *  define table : cosmo202
-   */
+  // define table : cosmo201
+  {
+    int instID  = institutInq(0, 0, "MCH", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MCH", NULL);
 
-  instID  = institutInq(0, 0, "MCH", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MCH", NULL);
+    int modelID = modelInq(instID, 0, "COSMO");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "COSMO");
 
-  modelID = modelInq(instID, 0, "COSMO");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "COSMO");
+    int tableID = tableDef(modelID, 201, "cosmo201");
 
-  tableID = tableDef(modelID, 202, "cosmo202");
+    tableLink(tableID, cosmo201, sizeof(cosmo201) / sizeof(param_type));
+  }
 
-  tableLink(tableID, cosmo202, sizeof(cosmo202) / sizeof(PAR));
+  // define table : cosmo202
+  {
+    int instID  = institutInq(0, 0, "MCH", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MCH", NULL);
 
-  /*
-   *  define table : cosmo203
-   */
+    int modelID = modelInq(instID, 0, "COSMO");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "COSMO");
 
-  instID  = institutInq(0, 0, "MCH", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MCH", NULL);
+    int tableID = tableDef(modelID, 202, "cosmo202");
 
-  modelID = modelInq(instID, 0, "COSMO");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "COSMO");
+    tableLink(tableID, cosmo202, sizeof(cosmo202) / sizeof(param_type));
+  }
 
-  tableID = tableDef(modelID, 203, "cosmo203");
+  // define table : cosmo203
+  {
+    int instID  = institutInq(0, 0, "MCH", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MCH", NULL);
 
-  tableLink(tableID, cosmo203, sizeof(cosmo203) / sizeof(PAR));
+    int modelID = modelInq(instID, 0, "COSMO");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "COSMO");
 
-  /*
-   *  define table : cosmo205
-   */
+    int tableID = tableDef(modelID, 203, "cosmo203");
 
-  instID  = institutInq(0, 0, "MCH", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MCH", NULL);
+    tableLink(tableID, cosmo203, sizeof(cosmo203) / sizeof(param_type));
+  }
 
-  modelID = modelInq(instID, 0, "COSMO");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "COSMO");
+  // define table : cosmo205
+  {
+    int instID  = institutInq(0, 0, "MCH", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MCH", NULL);
 
-  tableID = tableDef(modelID, 205, "cosmo205");
+    int modelID = modelInq(instID, 0, "COSMO");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "COSMO");
 
-  tableLink(tableID, cosmo205, sizeof(cosmo205) / sizeof(PAR));
+    int tableID = tableDef(modelID, 205, "cosmo205");
 
-  /*
-   *  define table : cosmo250
-   */
+    tableLink(tableID, cosmo205, sizeof(cosmo205) / sizeof(param_type));
+  }
 
-  instID  = institutInq(0, 0, "MCH", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(0, 0, "MCH", NULL);
+  // define table : cosmo250
+  {
+    int instID  = institutInq(0, 0, "MCH", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(0, 0, "MCH", NULL);
 
-  modelID = modelInq(instID, 0, "COSMO");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "COSMO");
+    int modelID = modelInq(instID, 0, "COSMO");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "COSMO");
 
-  tableID = tableDef(modelID, 250, "cosmo250");
+    int tableID = tableDef(modelID, 250, "cosmo250");
 
-  tableLink(tableID, cosmo250, sizeof(cosmo250) / sizeof(PAR));
+    tableLink(tableID, cosmo250, sizeof(cosmo250) / sizeof(param_type));
+  }
 }
 
-#endif  /* _TABLE_H */
+#endif  /* TABLE_H */
diff --git a/src/tablepar.h b/src/tablepar.h
index 0223f6beba9ce0bb50ca717db1b462033b8615ae..160d669899d748888cbcb4027ed40bbc89a107b2 100644
--- a/src/tablepar.h
+++ b/src/tablepar.h
@@ -1,5 +1,5 @@
-#ifndef _TABLEPAR_H
-#define _TABLEPAR_H
+#ifndef TABLEPAR_H
+#define TABLEPAR_H
 
 enum {
   TABLE_DUP_NAME = 1 << 0,
@@ -9,18 +9,21 @@ enum {
 
 typedef struct
 {
-  int   id;	     /* Parameter number (GRIB) */
-  int dupflags;      /* keep track of which attributes got strdup'ed */
-  const char *name;	     /* Parameter name */
-  const char *longname;    /* Parameter long name */
-  const char *units;	     /* Parameter units */
+  int id;	        // Parameter number (GRIB)
+  int ltype;	        // Level type (GRIB)
+  int dupflags;         // keep track of which attributes got strdup'ed
+  const char *name;	// Parameter name
+  const char *longname; // Parameter long name
+  const char *units;	// Parameter units
 }
-PAR;
+param_type;
 
 
-static void tableLink(int tableID, const PAR *pars, int npars);
+static void tableLink(int tableID, const param_type *pars, int npars);
 int tableDef(int modelID, int tablegribID, const char *tablename);
 
+int tableInqParCode(int tableID, char *name, int *code);
+
 #endif
 /*
  * Local Variables:
diff --git a/src/tsteps.c b/src/tsteps.c
index 92273ec54d72807969053e5db111899fe737401e..c1c4fc66cdd97c33b43fe7b566575a74bae53eb2 100644
--- a/src/tsteps.c
+++ b/src/tsteps.c
@@ -53,7 +53,7 @@ int tstepsNewEntry(stream_t *streamptr)
 
   tstepsInitEntry(streamptr, tsID);
 
-  streamptr->tsteps[tsID].taxis.used = TRUE;
+  streamptr->tsteps[tsID].taxis.used = true;
 
   return (int)tsID;
 }
@@ -61,24 +61,20 @@ int tstepsNewEntry(stream_t *streamptr)
 
 void cdiCreateTimesteps(stream_t *streamptr)
 {
-  long ntsteps;
-  long tsID;
-
   if ( streamptr->ntsteps < 0 || streamptr->tstepsTableSize > 0 )
     return;
 
-  if ( streamptr->ntsteps == 0 ) ntsteps = 1;    /* <<<<<-------- */
-  else ntsteps = streamptr->ntsteps;
+  long ntsteps = (streamptr->ntsteps == 0) ? 1 : streamptr->ntsteps;
 
   streamptr->tsteps = (tsteps_t *) Malloc((size_t)ntsteps*sizeof(tsteps_t));
 
   streamptr->tstepsTableSize = (int)ntsteps;
   streamptr->tstepsNextID    = (int)ntsteps;
 
-  for ( tsID = 0; tsID < ntsteps; tsID++ )
+  for ( long tsID = 0; tsID < ntsteps; tsID++ )
     {
       tstepsInitEntry(streamptr, (size_t)tsID);
-      streamptr->tsteps[tsID].taxis.used = TRUE;
+      streamptr->tsteps[tsID].taxis.used = true;
     }
 }
 /*
diff --git a/src/varscan.c b/src/varscan.c
index c39850896e39207209180fde828eddddf280f25c..56d5e06e77189c5535ea8110caf2db64187ce5d8 100644
--- a/src/varscan.c
+++ b/src/varscan.c
@@ -578,7 +578,6 @@ int cmp_varname(const void *s1, const void *s2)
 
 void cdi_generate_vars(stream_t *streamptr)
 {
-  char name[CDI_MAX_NAME], longname[CDI_MAX_NAME], units[CDI_MAX_NAME];
   int vlistID = streamptr->vlistID;
 
   int *varids = (int *) Malloc(varTableUsed*sizeof(int));
@@ -734,7 +733,7 @@ void cdi_generate_vars(stream_t *streamptr)
 
       const char **cvals = NULL;
       const char *unitptr = cdiUnitNamePtr(vartable[varid].level_unit);
-      int zaxisID = varDefZaxis(vlistID, zaxistype, (int)nlevels, dlevels, cvals, lbounds, dlevels1, dlevels2,
+      int zaxisID = varDefZaxis(vlistID, zaxistype, (int)nlevels, dlevels, cvals, 0, lbounds, dlevels1, dlevels2,
                                 (int)Vctsize, Vct, NULL, NULL, unitptr, 0, 0, ltype1);
 
       if ( CDI_cmor_mode && nlevels == 1 && zaxistype != ZAXIS_HYBRID ) zaxisDefScalar(zaxisID);
@@ -794,7 +793,7 @@ void cdi_generate_vars(stream_t *streamptr)
 	  if ( vartable[varid].opt_grib_kvpair[i].keyword )
 	    vlistptr->vars[varID].opt_grib_kvpair[idx].keyword =
 	      strdupx(vartable[varid].opt_grib_kvpair[i].keyword);
-          vlistptr->vars[varID].opt_grib_kvpair[i].update = TRUE;
+          vlistptr->vars[varID].opt_grib_kvpair[i].update = true;
         }
       /* note: if the key is not defined, we do not throw an error! */
 
@@ -802,23 +801,18 @@ void cdi_generate_vars(stream_t *streamptr)
 	{
 	  int pdis, pcat, pnum;
 	  cdiDecodeParam(param, &pnum, &pcat, &pdis);
-	  if ( tableInqParNamePtr(cdiDefaultTableID, pnum) )
+          char name[CDI_MAX_NAME]; name[0] = 0;
+          char longname[CDI_MAX_NAME]; longname[0] = 0;
+          char units[CDI_MAX_NAME]; units[0] = 0;
+          tableInqEntry(cdiDefaultTableID, pnum, -1, name, longname, units);
+	  if ( name[0] )
 	    {
 	      if ( tableID != CDI_UNDEFID )
 		{
-		  strcpy(name, tableInqParNamePtr(cdiDefaultTableID, pnum));
 		  vlistDefVarName(vlistID, varID, name);
-		  if ( tableInqParLongnamePtr(cdiDefaultTableID, pnum) )
-		    {
-		      strcpy(longname, tableInqParLongnamePtr(cdiDefaultTableID, pnum));
-		      vlistDefVarLongname(vlistID, varID, longname);
-		    }
-		  if ( tableInqParUnitsPtr(cdiDefaultTableID, pnum) )
-		    {
-		      strcpy(units, tableInqParUnitsPtr(cdiDefaultTableID, pnum));
-		      vlistDefVarUnits(vlistID, varID, units);
-		    }
-		}
+                  if ( longname[0] ) vlistDefVarLongname(vlistID, varID, longname);
+                  if ( units[0] ) vlistDefVarUnits(vlistID, varID, units);
+                }
 	      else
 		tableID = cdiDefaultTableID;
 	    }
@@ -955,8 +949,7 @@ varDefZAxisSearch(int id, void *res, void *data)
 }
 
 
-int varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, const char **cvals, bool lbounds,
-		const double *levels1, const double *levels2, int vctsize, const double *vct, char *name,
+int varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, const char **cvals, size_t clength, bool lbounds,        const double *levels1, const double *levels2, int vctsize, const double *vct, char *name,
 		const char *longname, const char *units, int prec, int mode, int ltype1)
 {
   /*
@@ -1018,7 +1011,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, c
 	      zaxisDefUbounds(zaxisID, levels2);
 	    }
 
-          if ( cvals ) zaxisDefCvals(zaxisID, cvals);
+          if ( cvals != NULL && nlevels != 0 && clength != 0 ) zaxisDefCvals(zaxisID, cvals, clength);
 
 	  if ( (zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF) && vctsize > 0 )
             zaxisDefVct(zaxisID, vctsize, vct);
@@ -1141,7 +1134,7 @@ void resize_vartable_opt_grib_entries(vartable_t *var, int nentries)
       for (i=var->opt_grib_kvpair_size; i<new_size; i++) {
         tmp[i].int_val =     0;
         tmp[i].dbl_val =     0;
-        tmp[i].update  = FALSE;
+        tmp[i].update  = false;
         tmp[i].keyword =  NULL;
       } // for
       var->opt_grib_kvpair_size = new_size;
diff --git a/src/varscan.h b/src/varscan.h
index f837ca1aff021f8f428bb47ce79a3892e9930b83..68cfbdabf4a90b27e2dd7ad557f0f331579e3add 100644
--- a/src/varscan.h
+++ b/src/varscan.h
@@ -15,7 +15,7 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
 void varDefVCT(size_t vctsize, double *vctptr);
 void varDefZAxisReference(int nlev, int nvgrid, unsigned char uuid[CDI_UUID_SIZE]);
 
-int  varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, const char **cvals, bool lbounds,
+int  varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, const char **cvals, size_t clength, bool lbounds,
 		 const double *levels1, const double *levels2, int vctsize, const double *vct, char *name,
 		 const char *longname, const char *units, int prec, int mode, int ltype);
 
diff --git a/src/vlist.c b/src/vlist.c
index 672108793e245f983d10fd15ac5455e25d5e4fb7..b1302d4d30b5c7909905e4b981864dd7bdedde3e 100644
--- a/src/vlist.c
+++ b/src/vlist.c
@@ -37,7 +37,7 @@ static pthread_once_t  _vlist_init_thread = PTHREAD_ONCE_INIT;
 
 #else
 
-static int vlistIsInitialized = 0;
+static bool vlistIsInitialized = false;
 
 #  define VLIST_INIT()               \
   if ( !vlistIsInitialized ) vlist_initialize()
@@ -146,7 +146,7 @@ void vlist_initialize(void)
   char *env = getenv("VLIST_DEBUG");
   if ( env ) VLIST_Debug = atoi(env);
 #ifndef HAVE_LIBPTHREAD
-  vlistIsInitialized = TRUE;
+  vlistIsInitialized = true;
 #endif
 }
 
@@ -311,7 +311,7 @@ void var_copy_entries(var_t *var2, var_t *var1)
     if ( var1->opt_grib_kvpair[i].keyword != NULL ) {
       var2->opt_grib_kvpair[i]         = var1->opt_grib_kvpair[i];
       var2->opt_grib_kvpair[i].keyword = strdupx(var1->opt_grib_kvpair[i].keyword);
-      var2->opt_grib_kvpair[i].update  = TRUE;
+      var2->opt_grib_kvpair[i].update  = true;
       if ( CDI_Debug )  Message("done.");
     }
     else {
@@ -405,12 +405,12 @@ void vlistClearFlag(int vlistID)
 
   for ( int varID = 0; varID < vlistptr->nvars; varID++ )
     {
-      vlistptr->vars[varID].flag = FALSE;
+      vlistptr->vars[varID].flag = false;
       if ( vlistptr->vars[varID].levinfo )
         {
           int nlevs = zaxisInqSize(vlistptr->vars[varID].zaxisID);
           for ( int levID = 0; levID < nlevs; levID++ )
-            vlistptr->vars[varID].levinfo[levID].flag = FALSE;
+            vlistptr->vars[varID].levinfo[levID].flag = false;
         }
     }
 }
@@ -443,7 +443,8 @@ vgzZAxisSearch(int id, void *res, void *data)
 
 static
 int vlist_generate_zaxis(int vlistID, int zaxistype, int nlevels, const double *levels,
-                         const double *lbounds, const double *ubounds, int vctsize, const double *vct)
+                         const double *lbounds, const double *ubounds, int vctsize, const double *vct,
+                         const char **cvals, size_t clen)
 {
   int zaxisID = CDI_UNDEFID;
   bool zaxisdefined = false;
@@ -485,6 +486,10 @@ int vlist_generate_zaxis(int vlistID, int zaxistype, int nlevels, const double *
 	{
 	  zaxisID = zaxisCreate(zaxistype, nlevels);
 	  zaxisDefLevels(zaxisID, levels);
+
+          if ( zaxistype == ZAXIS_CHAR )
+            zaxisDefCvals(zaxisID, cvals, clen);
+
 	  if ( has_bounds )
 	    {
 	      zaxisDefLbounds(zaxisID, lbounds);
@@ -537,7 +542,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
       vlistptr2->nzaxis = 0;
 
       for ( int varID = 0; varID < nvars; varID++ )
-        nvars2 += (vars1[varID].flag != 0);
+        nvars2 += vars1[varID].flag;
 
       vlistptr2->nvars = nvars2;
       vlistptr2->varsAllocated = nvars2;
@@ -552,7 +557,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
       for ( int varID = 0; varID < nvars; varID++ )
 	if ( vars1[varID].flag )
 	  {
-	    vlistptr2->vars[varID2].flag = FALSE;
+	    vlistptr2->vars[varID2].flag = false;
 	    int zaxisID   = vlistptr1->vars[varID].zaxisID;
 	    int gridID    = vlistptr1->vars[varID].gridID;
 	    int subtypeID = vlistptr1->vars[varID].subtypeID;
@@ -573,7 +578,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 	    int nlevs2 = 0;
             if ( vars1[varID].levinfo )
               for ( int levID = 0; levID < nlevs; levID++ )
-                nlevs2 += (vars1[varID].levinfo[levID].flag != 0);
+                nlevs2 += vars1[varID].levinfo[levID].flag;
 
 	    vars2[varID2].levinfo = (levinfo_t *) Malloc((size_t)nlevs2 * sizeof(levinfo_t));
 
@@ -581,6 +586,8 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 	      {
 		int nvct = 0;
                 double *levels = NULL;
+                char **cvals1 = NULL, **cvals2 = NULL;
+                size_t clen2 = 0;
 		double *lbounds = NULL, *ubounds = NULL;
 		const double *vct = NULL;
                 char ctemp[CDI_MAX_NAME];
@@ -598,6 +605,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                       vars1[varID].levinfo[levID].mlevelID = levID2;
                     }
 
+
                 if ( zaxisInqLevels(zaxisID, NULL) )
                   {
                     levels = (double *) Malloc((size_t)nlevs2 * sizeof (double));
@@ -605,9 +613,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                     levID2 = 0;
                     for ( int levID = 0; levID < nlevs; ++levID )
                       if ( vars1[varID].levinfo[levID].flag )
-                        {
-                          levels[levID2++] = zaxisInqLevel(zaxisID, levID);
-                        }
+                        levels[levID2++] = zaxisInqLevel(zaxisID, levID);
                   }
 
                 if ( zaxisType == ZAXIS_HYBRID )
@@ -616,6 +622,31 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                     vct  = zaxisInqVctPtr(zaxisID);
                   }
 
+                if ( zaxisType == ZAXIS_CHAR )
+                  {
+                    cvals1 = zaxisInqCValsPtr(zaxisID);
+                    size_t clen1 = (size_t)zaxisInqCLen(zaxisID);
+                    for ( int levID = 0; levID < nlevs; ++levID )
+                      if ( vars1[varID].levinfo[levID].flag )
+                          {
+                            size_t testlen = clen1;
+                            while ( cvals1[levID][testlen] == ' ' )
+                              testlen--;
+                            if ( clen2 < testlen )
+                              clen2 = testlen;
+                          }
+                    cvals2 = (char **) Malloc((size_t)nlevs2 * sizeof (char *));
+                    levID2 = 0;
+
+                    for ( int levID = 0; levID < nlevs; ++levID )
+                      if ( vars1[varID].levinfo[levID].flag )
+                        {
+                          cvals2[levID2] = Malloc((size_t)(clen2) * sizeof (char));
+                          memcpy(cvals2[levID2], cvals1[levID], clen2*sizeof(char));
+                          levID2++;
+                        }
+                  }
+
                 if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
                   {
                     lbounds = (double *) Malloc(2 * (size_t)nlevs2 * sizeof (double));
@@ -639,9 +670,15 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                     Free(lbounds1);
                   }
 
-		int zaxisID2 = vlist_generate_zaxis(vlistID2, zaxisType, nlevs2, levels, lbounds, ubounds, nvct, vct);
+		int zaxisID2 = vlist_generate_zaxis(vlistID2, zaxisType, nlevs2, levels, lbounds, ubounds, nvct, vct, (const char **)cvals2, clen2);
 		if ( levels )  Free(levels);
                 if ( lbounds ) Free(lbounds);
+                if ( cvals2 )
+                  {
+                    for ( int levID = 0; levID < nlevs2; ++levID )
+                      Free(cvals2[levID]);
+                    Free(cvals2);
+                  }
 
                 zaxisInqName(zaxisID, ctemp);
                 zaxisDefName(zaxisID2, ctemp);
@@ -650,6 +687,14 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                 zaxisInqUnits(zaxisID, ctemp);
                 zaxisDefUnits(zaxisID2, ctemp);
 
+                if ( zaxisType == ZAXIS_CHAR )
+                  {
+                    char dimname[CDI_MAX_NAME+3]; dimname[0] = 0;
+                    cdiZaxisInqKeyStr(zaxisID, CDI_KEY_DIMNAME, CDI_MAX_NAME, dimname);
+                    if ( dimname[0] == 0 ) { memcpy(dimname, "area_type", 10); dimname[10] = 0; }
+                    cdiZaxisDefKeyStr(zaxisID2, CDI_KEY_DIMNAME, CDI_MAX_NAME, dimname);
+                  }
+
                 if ( zaxisType == ZAXIS_GENERIC ) zaxisDefLtype(zaxisID2, zaxisInqLtype(zaxisID));
 
 		zaxisID = zaxisID2;
@@ -658,7 +703,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 
 	    for ( int levID = 0; levID < nlevs2; levID++ )
 	      {
-		vars2[varID2].levinfo[levID].flag  = FALSE;
+		vars2[varID2].levinfo[levID].flag  = false;
 		vars2[varID2].levinfo[levID].index = -1;
 	      }
 
@@ -1451,17 +1496,17 @@ int vlistSubtypeIndex(int vlistID, int subtypeID)
 
 int vlistHasTime(int vlistID)
 {
-  int hastime = FALSE;
+  bool hastime = false;
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
   for ( int varID = 0; varID <  vlistptr->nvars; varID++ )
     if ( vlistptr->vars[varID].tsteptype != TSTEP_CONSTANT )
       {
-        hastime = TRUE;
+        hastime = true;
         break;
       }
 
-  return hastime;
+  return (int)hastime;
 }
 
 enum {
@@ -1572,7 +1617,7 @@ void resize_opt_grib_entries(var_t *var, int nentries)
       for (i=var->opt_grib_kvpair_size; i<new_size; i++) {
         tmp[i].int_val =     0;
         tmp[i].dbl_val =     0;
-        tmp[i].update  = FALSE;
+        tmp[i].update  = false;
         tmp[i].keyword =  NULL;
       } // for
       var->opt_grib_kvpair_size = new_size;
diff --git a/src/vlist.h b/src/vlist.h
index bcba36065c4ef918deab00832b9c794612752a7c..c2eea4c756e3a05505d75cb1a93794c9902a5d4f 100644
--- a/src/vlist.h
+++ b/src/vlist.h
@@ -22,7 +22,7 @@
 
 typedef struct
 {
-  int      flag;
+  bool     flag;
   int      index;
   int      mlevelID;
   int      flevelID;
@@ -48,7 +48,7 @@ ensinfo_t;
 typedef struct
 {
   bool        isUsed;
-  int         flag;
+  bool        flag;
   int         mvarID;
   int         fvarID;
   int         param;
@@ -65,8 +65,8 @@ typedef struct
   int         productDefinitionTemplate;
   int         chunktype;
   int         xyz;
-  int         missvalused; /* TRUE if missval is defined */
-  int         lvalidrange;
+  bool        missvalused; /* true if missval is defined */
+  bool        lvalidrange;
   char       *name;
   char       *longname;
   char       *stdname;
@@ -122,7 +122,6 @@ vlist_t *vlist_to_pointer(int vlistID);
 void cdiVlistMakeInternal(int vlistID);
 void cdiVlistMakeImmutable(int vlistID);
 void vlistCheckVarID(const char *caller, int vlistID, int varID);
-const char *vlistInqVarStdnamePtr(int vlistID, int varID);
 void     vlistDestroyVarName(int vlistID, int varID);
 void     vlistDestroyVarLongname(int vlistID, int varID);
 void     vlistDestroyVarStdname(int vlistID, int varID);
diff --git a/src/vlist_var.c b/src/vlist_var.c
index 9b5b78e24e08e51c375a37d571f53a62f3061f1b..eb753ac33e50debaa6fe56306c7627842b107412 100644
--- a/src/vlist_var.c
+++ b/src/vlist_var.c
@@ -11,6 +11,7 @@
 #include "vlist_var.h"
 #include "resource_handle.h"
 #include "cdi_att.h"
+#include "tablepar.h"
 #include "namespace.h"
 #include "serialize.h"
 #include "error.h"
@@ -44,7 +45,7 @@ void vlistvarInitEntry(int vlistID, int varID)
   vlistptr->vars[varID].instID        = CDI_UNDEFID;
   vlistptr->vars[varID].modelID       = CDI_UNDEFID;
   vlistptr->vars[varID].tableID       = CDI_UNDEFID;
-  vlistptr->vars[varID].missvalused   = FALSE;
+  vlistptr->vars[varID].missvalused   = false;
   vlistptr->vars[varID].missval       = cdiDefaultMissval;
   vlistptr->vars[varID].addoffset     = 0.0;
   vlistptr->vars[varID].scalefactor   = 1.0;
@@ -58,7 +59,7 @@ void vlistvarInitEntry(int vlistID, int varID)
   vlistptr->vars[varID].complevel     = 1;
   vlistptr->vars[varID].atts.nalloc   = MAX_ATTRIBUTES;
   vlistptr->vars[varID].atts.nelems   = 0;
-  vlistptr->vars[varID].lvalidrange   = 0;
+  vlistptr->vars[varID].lvalidrange   = false;
   vlistptr->vars[varID].validrange[0] = VALIDMISS;
   vlistptr->vars[varID].validrange[1] = VALIDMISS;
   vlistptr->vars[varID].ensdata       = NULL;
@@ -438,36 +439,6 @@ const char *vlistInqVarNamePtr(int vlistID, int varID)
   return vlistptr->vars[varID].name;
 }
 
-
-const char *vlistInqVarLongnamePtr(int vlistID, int varID)
-{
-  vlist_t *vlistptr = vlist_to_pointer(vlistID);
-
-  vlistCheckVarID(__func__, vlistID, varID);
-
-  return vlistptr->vars[varID].longname;
-}
-
-
-const char *vlistInqVarStdnamePtr(int vlistID, int varID)
-{
-  vlist_t *vlistptr = vlist_to_pointer(vlistID);
-
-  vlistCheckVarID(__func__, vlistID, varID);
-
-  return vlistptr->vars[varID].stdname;
-}
-
-
-const char *vlistInqVarUnitsPtr(int vlistID, int varID)
-{
-  vlist_t *vlistptr = vlist_to_pointer(vlistID);
-
-  vlistCheckVarID(__func__, vlistID, varID);
-
-  return vlistptr->vars[varID].units;
-}
-
 /*
 @Function  vlistInqVarName
 @Title     Get the name of a Variable
@@ -504,8 +475,9 @@ void vlistInqVarName(int vlistID, int varID, char *name)
 	{
 	  int code = pnum;
 	  int tableID = vlistptr->vars[varID].tableID;
-	  if ( tableInqParName(tableID, code, name) != 0 )
-	    sprintf(name, "var%d", code);
+          name[0] = 0;
+          tableInqEntry(tableID, code, -1, name, NULL, NULL);
+	  if ( !name[0] ) sprintf(name, "var%d", code);
 	}
       else
 	{
@@ -541,24 +513,29 @@ char* vlistCopyVarName(int vlistId, int varId)
   vlistCheckVarID(__func__, vlistId, varId);
 
   //If a name is set in the variable description, use that.
-  const char* name = vlistptr->vars[varId].name;
-  if(name) return strdup(name);
+  {
+    const char* name = vlistptr->vars[varId].name;
+    if (name) return strdup(name);
+  }
 
   //Otherwise we check if we should use the table of parameter descriptions.
   int param = vlistptr->vars[varId].param;
   int discipline, category, number;
   cdiDecodeParam(param, &number, &category, &discipline);
   char *result = NULL;
-  if(discipline == 255)
+  if (discipline == 255)
     {
       int tableId = vlistptr->vars[varId].tableID;
-      if(( name = tableInqParNamePtr(tableId, number) ))
+      char name[CDI_MAX_NAME]; name[0] = 0;
+      tableInqEntry(tableId, number, -1, name, NULL, NULL);
+      if ( name[0] )
         result = strdup(name);
-      {
-        //No luck, fall back to outputting a name of the format "var<num>".
-        result = (char *) Malloc(3 + 3 * sizeof (int) * CHAR_BIT / 8 + 2);
-        sprintf(result, "var%d", number);
-      }
+      else
+        {
+          //No luck, fall back to outputting a name of the format "var<num>".
+          result = (char *) Malloc(3 + 3 * sizeof (int) * CHAR_BIT / 8 + 2);
+          sprintf(result, "var%d", number);
+        }
     }
   else
     {
@@ -607,8 +584,7 @@ void vlistInqVarLongname(int vlistID, int varID, char *longname)
 	{
 	  int code = pnum;
           int tableID = vlistptr->vars[varID].tableID;
-	  if ( tableInqParLongname(tableID, code, longname) != 0 )
-	    longname[0] = '\0';
+          tableInqEntry(tableID, code, -1, NULL, longname, NULL);
 	}
     }
   else
@@ -692,8 +668,7 @@ void vlistInqVarUnits(int vlistID, int varID, char *units)
 	{
 	  int code = pnum;
 	  int tableID = vlistptr->vars[varID].tableID;
-	  if ( tableInqParUnits(tableID, code, units) != 0 )
-	    units[0] = '\0';
+          tableInqEntry(tableID, code, -1, NULL, NULL, units);
 	}
     }
   else
@@ -807,7 +782,7 @@ void vlistDefVarDatatype(int vlistID, int varID, int datatype)
     {
       vlistptr->vars[varID].datatype = datatype;
 
-      if ( vlistptr->vars[varID].missvalused == FALSE )
+      if ( !vlistptr->vars[varID].missvalused )
         switch (datatype)
           {
           case CDI_DATATYPE_INT8:   vlistptr->vars[varID].missval = -SCHAR_MAX; break;
@@ -1067,7 +1042,7 @@ void vlistDefVarMissval(int vlistID, int varID, double missval)
   vlistCheckVarID(__func__, vlistID, varID);
 
   vlistptr->vars[varID].missval = missval;
-  vlistptr->vars[varID].missvalused = TRUE;
+  vlistptr->vars[varID].missvalused = true;
 }
 
 /*
@@ -1152,7 +1127,7 @@ int vlistInqVarValidrange(int vlistID, int varID, double *validrange)
       validrange[1] = vlistptr->vars[varID].validrange[1];
     }
 
-  return vlistptr->vars[varID].lvalidrange;
+  return (int)vlistptr->vars[varID].lvalidrange;
 }
 
 
@@ -1164,7 +1139,7 @@ void vlistDefVarValidrange(int vlistID, int varID, const double *validrange)
 
   vlistptr->vars[varID].validrange[0] = validrange[0];
   vlistptr->vars[varID].validrange[1] = validrange[1];
-  vlistptr->vars[varID].lvalidrange = TRUE;
+  vlistptr->vars[varID].lvalidrange = true;
   reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
 }
 
@@ -1381,7 +1356,7 @@ void vlistDestroyVarUnits(int vlistID, int varID)
 int vlistInqVarMissvalUsed(int vlistID, int varID)
 {
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
-  return vlistptr->vars[varID].missvalused;
+  return (int)vlistptr->vars[varID].missvalused;
 }
 
 
@@ -1792,7 +1767,7 @@ void vlistDefVarIntKey(int vlistID, int varID, const char *name, int value)
   if ( idx < vlistptr->vars[varID].opt_grib_nentries )
     {
       vlistptr->vars[varID].opt_grib_kvpair[idx].int_val = value;
-      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = true;
     }
   else
     {
@@ -1801,7 +1776,7 @@ void vlistDefVarIntKey(int vlistID, int varID, const char *name, int value)
       idx = vlistptr->vars[varID].opt_grib_nentries -1;
       vlistptr->vars[varID].opt_grib_kvpair[idx].data_type   = t_int;
       vlistptr->vars[varID].opt_grib_kvpair[idx].int_val     = value;
-      vlistptr->vars[varID].opt_grib_kvpair[idx].update      = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update      = true;
       if ( name )
         vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
       else
@@ -1855,7 +1830,7 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
   if ( idx < vlistptr->vars[varID].opt_grib_nentries )
     {
       vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val = value;
-      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = true;
     }
   else
     {
@@ -1864,7 +1839,7 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
       idx = vlistptr->vars[varID].opt_grib_nentries - 1;
       vlistptr->vars[varID].opt_grib_kvpair[idx].data_type = t_double;
       vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val   = value;
-      vlistptr->vars[varID].opt_grib_kvpair[idx].update    = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update    = true;
       if ( name )
         vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
       else
@@ -2116,7 +2091,7 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
   tempbuf[12] = var->tableID;
   tempbuf[13] = var->timave;
   tempbuf[14] = var->timaccu;
-  tempbuf[15] = var->missvalused;
+  tempbuf[15] = (int)var->missvalused;
   tempbuf[16] = var->comptype;
   tempbuf[17] = var->complevel;
   int nlevs = var->levinfo ? zaxisInqSize(var->zaxisID) : 0;
diff --git a/src/vlist_var.h b/src/vlist_var.h
index baba96a805c8ec72c2be67777d4de0b67509b60a..0c2493efc9a1b6cdb47a2a35718fe109b5395301 100644
--- a/src/vlist_var.h
+++ b/src/vlist_var.h
@@ -20,6 +20,8 @@ int  vlistInqVarIOrank    ( int, int );
 
 void cdiVlistCreateVarLevInfo(vlist_t *vlistptr, int varID);
 
+const char *vlistInqVarNamePtr(int vlistID, int varID);
+
 #endif
 /*
  * Local Variables:
diff --git a/src/zaxis.c b/src/zaxis.c
index fab24c56011dee78d6477c76523ff0e2118b137f..9d28e0c161246a051b5d004f3e89ffd4f55c8450 100644
--- a/src/zaxis.c
+++ b/src/zaxis.c
@@ -129,6 +129,7 @@ void zaxis_init(zaxis_t *zaxisptr)
   zaxisptr->p0value.defined = false;
   zaxisptr->vals          = NULL;
   zaxisptr->cvals         = NULL;
+  zaxisptr->clength       = 0;
   zaxisptr->ubounds       = NULL;
   zaxisptr->lbounds       = NULL;
   zaxisptr->weights       = NULL;
@@ -273,7 +274,12 @@ void zaxisDestroyKernel( zaxis_t * zaxisptr )
   int id = zaxisptr->self;
 
   if ( zaxisptr->vals )    Free( zaxisptr->vals );
-  if ( zaxisptr->cvals )   Free( zaxisptr->cvals );
+  if ( zaxisptr->cvals )
+    {
+      for ( int i=0; i<zaxisptr->size; i++)
+        Free(zaxisptr->cvals[i]);
+      Free( zaxisptr->cvals );
+    }
   if ( zaxisptr->lbounds ) Free( zaxisptr->lbounds );
   if ( zaxisptr->ubounds ) Free( zaxisptr->ubounds );
   if ( zaxisptr->weights ) Free( zaxisptr->weights );
@@ -777,20 +783,21 @@ void zaxisDefLevels(int zaxisID, const double *levels)
 }
 
 
-void zaxisDefCvals(int zaxisID, const char **cvals)
+void zaxisDefCvals(int zaxisID, const char **cvals, size_t clen)
 {
   zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
   size_t size = (size_t)zaxisptr->size;
 
-  if ( cvals )
+  if ( cvals && clen )
     {
-      if ( zaxisptr->cvals != NULL )
-        zaxisptr->cvals = NULL;
+      zaxisptr->clength = clen;
       zaxisptr->cvals = (char**) Malloc(size*sizeof(char *));
 
       for ( size_t ilev = 0; ilev < size; ++ilev )
-        zaxisptr->cvals[ilev] = strdup(cvals[ilev]);
-
+        {
+          zaxisptr->cvals[ilev] = Malloc(clen*sizeof(char));
+          memcpy(zaxisptr->cvals[ilev],cvals[ilev], clen*sizeof(char));
+        }
       reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
     }
 }
@@ -988,6 +995,15 @@ const double *zaxisInqLevelsPtr(int zaxisID)
   return zaxisptr->vals;
 }
 
+
+char **zaxisInqCValsPtr(int zaxisID)
+{
+  char **cvals = NULL;
+  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
+  cvals = zaxisptr->cvals;
+  return cvals;
+}
+
 /*
 @Function  zaxisInqLevels
 @Title     Get all levels of a Z-axis
@@ -1022,6 +1038,40 @@ int zaxisInqLevels(int zaxisID, double *levels)
   return size;
 }
 
+int zaxisInqCLen(int zaxisID)
+{
+  int size = 0;
+  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
+
+  if ( zaxisptr->cvals && zaxisptr->clength)
+    size = zaxisptr->clength;
+  return size;
+}
+
+int zaxisInqCVals(int zaxisID, char ***clevels)
+{
+  int size = 0;
+  size_t clen = 0;
+  zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
+
+  if ( zaxisptr->cvals )
+    {
+      size = zaxisptr->size;
+      clen = zaxisptr->clength;
+      if ( size && clen )
+        {
+          (*clevels) = Malloc(size*sizeof(char*));
+          for ( int i = 0; i < size; i++ )
+            {
+              (*clevels)[i] = Malloc(clen*sizeof(char));
+              memcpy((*clevels)[i], zaxisptr->cvals[i], clen*sizeof(char));
+            }
+          }
+    }
+
+  return size;
+}
+
 
 int zaxisInqLbounds(int zaxisID, double *lbounds)
 {
diff --git a/src/zaxis.h b/src/zaxis.h
index 04cfa0ba39b8a79ee36dca683b597bac78902162..60ccad55eab3df666f9f758b53fe6527ff706e13 100644
--- a/src/zaxis.h
+++ b/src/zaxis.h
@@ -21,6 +21,7 @@ typedef struct {
   zkey_double_t p0value;
   double  *vals;
   char   **cvals;
+  int      clength;
   double  *lbounds;
   double  *ubounds;
   double  *weights;
@@ -63,6 +64,7 @@ const resOps *getZaxisOps(void);
 const char *zaxisInqNamePtr(int zaxisID);
 
 const double *zaxisInqLevelsPtr(int zaxisID);
+char **zaxisInqCValsPtr(int zaxisID);
 
 void zaxisResize(int zaxisID, int size);
 
diff --git a/tables/gen_tableheaderfile.in b/tables/gen_tableheaderfile.in
index 54b3f8c182f42379f0c39bcd49d38ada78a75eba..2f1147cad81a2451af317f1751dce360298c5c58 100755
--- a/tables/gen_tableheaderfile.in
+++ b/tables/gen_tableheaderfile.in
@@ -31,8 +31,8 @@ unset PTFILE[item]
 #
 cat >&4 <<EOF
 /* Automatically generated, do not edit! */
-#ifndef _TABLE_H
-#define _TABLE_H
+#ifndef TABLE_H
+#define TABLE_H
 
 EOF
 #
@@ -47,8 +47,6 @@ cat >&4 <<EOF
 static
 void tableDefault(void)
 {
-  int tableID, instID, modelID;
-
 EOF
 #
 settabvar() {
@@ -78,21 +76,20 @@ TABLENAME=`echo ${TFBASENAME} | sed -e "s/\./_/g" `
 #
 cat >&4 <<EOF
 
-  /*
-   *  define table : ${TFBASENAME}
-   */
-
-  instID  = institutInq(${TABLE_CE}, ${TABLE_SU}, "${TABLE_IN}", NULL);
-  if ( instID == -1 )
-    instID  = institutDef(${TABLE_CE}, ${TABLE_SU}, "${TABLE_IN}", NULL);
+  // define table : ${TFBASENAME}
+  {
+    int instID  = institutInq(${TABLE_CE}, ${TABLE_SU}, "${TABLE_IN}", NULL);
+    if ( instID == -1 )
+      instID  = institutDef(${TABLE_CE}, ${TABLE_SU}, "${TABLE_IN}", NULL);
 
-  modelID = modelInq(instID, 0, "${TABLE_MO}");
-  if ( modelID == -1 )
-    modelID = modelDef(instID, 0, "${TABLE_MO}");
+    int modelID = modelInq(instID, 0, "${TABLE_MO}");
+    if ( modelID == -1 )
+      modelID = modelDef(instID, 0, "${TABLE_MO}");
 
-  tableID = tableDef(modelID, ${TABLE_ID}, "${TABLE_NA}");
+    int tableID = tableDef(modelID, ${TABLE_ID}, "${TABLE_NA}");
 
-  tableLink(tableID, ${TABLENAME}, sizeof(${TABLENAME}) / sizeof(PAR));
+    tableLink(tableID, ${TABLENAME}, sizeof(${TABLENAME}) / sizeof(param_type));
+  }
 EOF
 #
 done
@@ -100,7 +97,7 @@ done
 cat >&4 <<EOF
 }
 
-#endif  /* _TABLE_H */
+#endif  /* TABLE_H */
 EOF
 #
 rm -f ptfile
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 2341351f0fa9f01a1b163d61c0af486da70a1a02..4f0df77b7f2ca635333469a76e9f9a899864aad6 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -350,6 +350,8 @@ DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 DSYMUTIL = @DSYMUTIL@
 DUMPBIN = @DUMPBIN@
+ECCODES_INCLUDE = @ECCODES_INCLUDE@
+ECCODES_LIBS = @ECCODES_LIBS@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
diff --git a/tests/test_table.c b/tests/test_table.c
index 1bbd1204a66de81e03c61ed01fd70ecb09251776..274ae162500c8be36025a96278d289759c4f7cda 100644
--- a/tests/test_table.c
+++ b/tests/test_table.c
@@ -5,6 +5,7 @@
 
 int main()
 {
-  assert(tableInqParName(-1, -1, NULL) != 0);
+  tableInqEntry(-1, -1, -1, NULL, NULL, NULL);
+  //assert(tableInqEntry(-1, -1, -1, NULL, NULL, NULL) != 0);
   return EXIT_SUCCESS;
 }