[grads] 01/11: new upstream 2.1.1.b0

Alastair McKinstry mckinstry at moszumanska.debian.org
Wed Jul 19 06:14:00 UTC 2017


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

mckinstry pushed a commit to tag 3%2.1.1.b0-1
in repository grads.

commit 458ff7f279a0ee9b677e4c05a9138ae3703a73aa
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Thu Jul 6 09:30:07 2017 +0100

    new upstream 2.1.1.b0
---
 configure                    | 171 ++-------
 configure.ac                 |  41 ++-
 doc/descriptorfile.html      |  18 +-
 doc/expressions.html         |  92 ++++-
 doc/filledbarbs.png          | Bin 0 -> 7705 bytes
 doc/gradcomdqdefine.html     |  50 +++
 doc/gradcomdsetbarbopts.html |  32 ++
 doc/gradcomdsetsdfwrite.html |  10 +-
 doc/gradfuncif.html          |  56 +++
 doc/pdef.html                | 770 ++++++++++++++++++++++++++++++++++++++-
 doc/script.html              |  45 ++-
 doc/udp.html                 | 105 ++++++
 src/Makefile.in              |   2 +-
 src/VERSION                  |   2 +-
 src/bufrstn.c                |   2 +-
 src/dodstn.c                 |   4 +-
 src/gaddes.c                 |  79 ++--
 src/gaexpr.c                 | 151 ++++++--
 src/gafunc.c                 | 754 ++++++++++++++++++++++----------------
 src/gagx.c                   | 321 +++++++++--------
 src/gaio.c                   | 250 ++++++-------
 src/gasdf.c                  | 106 +++---
 src/gauser.c                 | 837 +++++++++++++++++++++++++------------------
 src/gautil.c                 |  24 +-
 src/grads.c                  | 505 +++++++++++++-------------
 src/grads.h                  |  39 +-
 src/gscrpt.c                 |  79 ++++
 src/gxprint.c                |   1 -
 src/gxprintGD.c              |   1 -
 29 files changed, 3063 insertions(+), 1484 deletions(-)

diff --git a/configure b/configure
index 038ef32..231f307 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.59 for GrADS 2.1.0.
+# Generated by GNU Autoconf 2.59 for GrADS 2.1.1.b0.
 #
 # Report bugs to <jadams21 at gmu.edu>.
 #
@@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='GrADS'
 PACKAGE_TARNAME='grads'
-PACKAGE_VERSION='2.1.0'
-PACKAGE_STRING='GrADS 2.1.0'
+PACKAGE_VERSION='2.1.1.b0'
+PACKAGE_STRING='GrADS 2.1.1.b0'
 PACKAGE_BUGREPORT='jadams21 at gmu.edu'
 
 ac_default_prefix=`pwd`
@@ -812,7 +812,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 GrADS 2.1.0 to adapt to many kinds of systems.
+\`configure' configures GrADS 2.1.1.b0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -882,7 +882,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of GrADS 2.1.0:";;
+     short | recursive ) echo "Configuration of GrADS 2.1.1.b0:";;
    esac
   cat <<\_ACEOF
 
@@ -1045,7 +1045,7 @@ fi
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-GrADS configure 2.1.0
+GrADS configure 2.1.1.b0
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1059,7 +1059,7 @@ cat >&5 <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by GrADS $as_me 2.1.0, which was
+It was created by GrADS $as_me 2.1.1.b0, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1711,7 +1711,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='grads'
- VERSION='2.1.0'
+ VERSION='2.1.1.b0'
 
 
 # Some tools Automake needs.
@@ -15827,66 +15827,7 @@ fi
   LDFLAGS="-L${ga_supplib_dir}/lib "
   LIBS="$LIBS "
 
-      echo "$as_me:$LINENO: checking for main in -lsz" >&5
-echo $ECHO_N "checking for main in -lsz... $ECHO_C" >&6
-if test "${ac_cv_lib_sz_main+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsz  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-
-int
-main ()
-{
-main ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_sz_main=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_sz_main=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_sz_main" >&5
-echo "${ECHO_T}$ac_cv_lib_sz_main" >&6
-if test $ac_cv_lib_sz_main = yes; then
-   if test "${ac_cv_header_mfhdf_h+set}" = set; then
+      if test "${ac_cv_header_mfhdf_h+set}" = set; then
   echo "$as_me:$LINENO: checking for mfhdf.h" >&5
 echo $ECHO_N "checking for mfhdf.h... $ECHO_C" >&6
 if test "${ac_cv_header_mfhdf_h+set}" = set; then
@@ -16153,7 +16094,7 @@ if test $ac_cv_lib_mfhdf_main = yes; then
 
   ga_lib_prefix='$(supp_lib_dir)/lib'
   ga_lib_suffix='.a'
-  for ga_lib_name in mfhdf df udunits sz jpeg z ; do
+  for ga_lib_name in mfhdf df udunits jpeg z ; do
       hdf_libs="$hdf_libs ${ga_lib_prefix}${ga_lib_name}${ga_lib_suffix}"
   done
 
@@ -16168,9 +16109,6 @@ fi
 
 
 
-fi
-
-
   # Use to undo temporary changes to -I and -L paths
   CPPFLAGS=$ga_saved_cppflags
   LDFLAGS=$ga_saved_ldflags
@@ -18435,66 +18373,7 @@ fi
   LDFLAGS="-L${ga_supplib_dir}/lib "
   LIBS="$LIBS "
 
-      echo "$as_me:$LINENO: checking for main in -lsz" >&5
-echo $ECHO_N "checking for main in -lsz... $ECHO_C" >&6
-if test "${ac_cv_lib_sz_main+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsz  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-
-int
-main ()
-{
-main ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_sz_main=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_sz_main=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_sz_main" >&5
-echo "${ECHO_T}$ac_cv_lib_sz_main" >&6
-if test $ac_cv_lib_sz_main = yes; then
-   if test "${ac_cv_header_hdf5_h+set}" = set; then
+      if test "${ac_cv_header_hdf5_h+set}" = set; then
   echo "$as_me:$LINENO: checking for hdf5.h" >&5
 echo $ECHO_N "checking for hdf5.h... $ECHO_C" >&6
 if test "${ac_cv_header_hdf5_h+set}" = set; then
@@ -18702,7 +18581,7 @@ if test $ac_cv_lib_hdf5_main = yes; then
 
   ga_lib_prefix='$(supp_lib_dir)/lib'
   ga_lib_suffix='.a'
-  for ga_lib_name in hdf5 sz z ; do
+  for ga_lib_name in hdf5 z ; do
       hdf5_libs="$hdf5_libs ${ga_lib_prefix}${ga_lib_name}${ga_lib_suffix}"
   done
 
@@ -18714,9 +18593,6 @@ fi
 
 
 
-fi
-
-
   # Use to undo temporary changes to -I and -L paths
   CPPFLAGS=$ga_saved_cppflags
   LDFLAGS=$ga_saved_ldflags
@@ -20189,7 +20065,7 @@ if test $ac_cv_lib_curl_main = yes; then
 
   ga_lib_prefix='$(supp_lib_dir)/lib'
   ga_lib_suffix='.a'
-  for ga_lib_name in udunits netcdf hdf5_hl hdf5 z sz curl ; do
+  for ga_lib_name in udunits netcdf hdf5_hl hdf5 z curl ; do
       nc_libs="$nc_libs ${ga_lib_prefix}${ga_lib_name}${ga_lib_suffix}"
   done
 
@@ -20216,6 +20092,7 @@ fi
 
 
         NC_CONFIG=${ga_supplib_dir}/bin/nc-config
+        CURL_CONFIG=${ga_supplib_dir}/bin/curl-config
       fi
     fi
     #  if we haven't got what we need, look outside supplibs for netcdf-4
@@ -21163,7 +21040,8 @@ fi
   fi
 
 
-       NC_CONFIG="`pkg-config --variable=prefix netcdf`/bin/nc-config"
+        NC_CONFIG="`pkg-config --variable=prefix netcdf`/bin/nc-config"
+        CURL_CONFIG="`pkg-config --variable=prefix libcurl`/bin/curl-config"
     fi
     if test $use_nc4 != "yes" ; then
 
@@ -21198,6 +21076,13 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
       fi
+      # find out if curl is https-enabled
+      https=`$CURL_CONFIG  --protocols | grep HTTPS`
+      if test $https = "HTTPS" ; then
+        nc_extra_libs="-lssl"
+      fi
+      # merge nc_libs and extras
+      nc_libs="$nc_libs $nc_extra_libs"
     fi
   fi
 
@@ -23209,7 +23094,7 @@ echo
 # Some non-configuration-dependent GrADS macros
 
 cat >>confdefs.h <<\_ACEOF
-#define GRADS_VERSION "2.1.0"
+#define GRADS_VERSION "2.1.1.b0"
 _ACEOF
 
 
@@ -23312,7 +23197,7 @@ build_info="Built `date` for ${host}"
 
    echo \
 "  +=========================================================================+"
-   echo "   GrADS "2.1.0 ":" $build_info
+   echo "   GrADS "2.1.1.b0 ":" $build_info
    echo \
 "  +=========================================================================+"
    echo
@@ -23409,7 +23294,7 @@ fi
    echo "  +-------------------------------+"
 
 echo "configure: creating src/VERSION"
-echo 2.1.0 > src/VERSION
+echo 2.1.1.b0 > src/VERSION
 
 echo "configure: creating src/buildinfo.h"
 mkdir -p src
@@ -23842,7 +23727,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by GrADS $as_me 2.1.0, which was
+This file was extended by GrADS $as_me 2.1.1.b0, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -23902,7 +23787,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-GrADS config.status 2.1.0
+GrADS config.status 2.1.1.b0
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
diff --git a/configure.ac b/configure.ac
index 577f893..1ce741e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ dnl  See acinclude.m4 for definitions of the GA_xxx macros
 
 # The version number
 # below is the "master" version that will appear in all code, etc.
-AC_INIT(GrADS, [2.1.0], [jadams21 at gmu.edu])
+AC_INIT(GrADS, [2.1.1.b0], [jadams21 at gmu.edu])
 
 # Require autoconf 2.52 (comes with Mac OS X 10.2) or newer
 AC_PREREQ(2.52) 
@@ -693,14 +693,12 @@ else
     fi
     if test "$have_zlib" = "yes" -a "$have_udunits" = "yes" -a "$have_jpeg" = "yes" ; then
       GA_SET_FLAGS([hdf])
-      AC_CHECK_LIB([sz], [main],
-      [ AC_CHECK_HEADER([mfhdf.h],
-        [ AC_CHECK_LIB([df], [main], 
-          [ AC_CHECK_LIB([mfhdf], [main],
-            [ use_hdf=yes 
-              GA_SET_INCLUDE_VAR([hdf_inc], [hdf udunits])
-              GA_SET_LIB_VAR([hdf_libs], [mfhdf df udunits sz jpeg z])
-            ])
+      AC_CHECK_HEADER([mfhdf.h],
+      [ AC_CHECK_LIB([df], [main], 
+        [ AC_CHECK_LIB([mfhdf], [main],
+          [ use_hdf=yes 
+            GA_SET_INCLUDE_VAR([hdf_inc], [hdf udunits])
+            GA_SET_LIB_VAR([hdf_libs], [mfhdf df udunits jpeg z])
           ])
         ])
       ])
@@ -755,13 +753,11 @@ else
     fi
     if test "$have_zlib" = "yes" -a "$have_jpeg" = "yes" ; then
       GA_SET_FLAGS([hdf5])
-      AC_CHECK_LIB([sz], [main],
-      [ AC_CHECK_HEADER([hdf5.h],
-        [ AC_CHECK_LIB([hdf5], [main], 
-          [ use_hdf5=yes 
-            GA_SET_INCLUDE_VAR([hdf5_inc], [hdf5])
-            GA_SET_LIB_VAR([hdf5_libs], [hdf5 sz z])
-          ])
+      AC_CHECK_HEADER([hdf5.h],
+      [ AC_CHECK_LIB([hdf5], [main], 
+        [ use_hdf5=yes 
+          GA_SET_INCLUDE_VAR([hdf5_inc], [hdf5])
+          GA_SET_LIB_VAR([hdf5_libs], [hdf5 z])
         ])
       ])
       GA_UNSET_FLAGS
@@ -811,7 +807,7 @@ else
             [ AC_CHECK_LIB(curl,main,
               [ use_nc4="yes"
                 GA_SET_INCLUDE_VAR(nc_inc, [udunits netcdf])
-                GA_SET_LIB_VAR(nc_libs, [udunits netcdf hdf5_hl hdf5 z sz curl])
+                GA_SET_LIB_VAR(nc_libs, [udunits netcdf hdf5_hl hdf5 z curl])
               ])
             ])
           ])
@@ -821,6 +817,7 @@ else
  	AC_SUBST(nc_inc)
         AC_SUBST(nc_libs)
         NC_CONFIG=${ga_supplib_dir}/bin/nc-config
+        CURL_CONFIG=${ga_supplib_dir}/bin/curl-config
       fi
     fi
     #  if we haven't got what we need, look outside supplibs for netcdf-4
@@ -834,7 +831,8 @@ else
           ],,
           [])
         ])
-       NC_CONFIG="`pkg-config --variable=prefix netcdf`/bin/nc-config"
+        NC_CONFIG="`pkg-config --variable=prefix netcdf`/bin/nc-config"
+        CURL_CONFIG="`pkg-config --variable=prefix libcurl`/bin/curl-config"
     fi
     if test $use_nc4 != "yes" ; then
       AC_DEFINE(USENETCDF, 0, [Enable netcdf])
@@ -849,6 +847,13 @@ else
       if test $use_dap = "yes" ; then
         AC_DEFINE(USEDAP, 1, [Enable OPeNDAP for grids])
       fi
+      # find out if curl is https-enabled
+      https=`$CURL_CONFIG  --protocols | grep HTTPS`
+      if test $https = "HTTPS" ; then
+        nc_extra_libs="-lssl"
+      fi
+      # merge nc_libs and extras
+      nc_libs="$nc_libs $nc_extra_libs"
     fi
   fi
 
diff --git a/doc/descriptorfile.html b/doc/descriptorfile.html
index e5654e1..c9615dc 100644
--- a/doc/descriptorfile.html
+++ b/doc/descriptorfile.html
@@ -35,6 +35,7 @@ body {
   <a href="#unpack">UNPACK</a> <br>
   <a href="#FILEHEADER">FILEHEADER</a><br>
   <a href="#XYHEADER">XYHEADER</a><br>
+  <a href="#XYTRAILER">XYTRAILER</a><br>
   <a href="#THEADER">THEADER</a><br>
   <a href="#THEADER">HEADERBYTES</a><br>
   <a href="#TRAILERBYTES">TRAILERBYTES</a><br>
@@ -324,18 +325,31 @@ href="cmd/query.html">query</a> command and it will appear in the directory list
 	 each time block of binary data. This entry is only valid for GrADS gridded data sets. See the section on <a href="aboutgriddeddata.html#structure">structure of a gridded binary data file</a> for more information.</td>
   </tr>
   <tr> 
-    <td bgcolor="#CCCCCC"> <a name="XYHEADER"> <b>XYHEADER</b> <i>length</i></a>    </td>
+  <td bgcolor="#CCCCCC"> <a name="XYHEADER"> <b>XYHEADER</b> <i>length</i></a>    </td>
     <td width="74" align="right" valign="top" bgcolor="#CCCCCC"><a href="#TOP" class="item9">back 
       to top</a></td>
   </tr>
   <tr> 
     <td colspan="2">This optional entry tells GrADS that the data file has a header 
-      record of length bytes preceding each horizontal grid (XY block) of binary 
+      record of <em>length</em> bytes preceding each horizontal grid (XY block) of binary 
       data. This entry is only valid for GrADS gridded 
       data sets. See the section on <a
 href="aboutgriddeddata.html#structure">structure of a gridded binary data file</a> 
       for more information.</td>
   </tr>
+      <tr>
+    <td bgcolor="#CCCCCC"> <a name="XYTRAILER"> <b>XYTRAILER</b> <i>length</i></a>    </td>
+    <td width="74" align="right" valign="top" bgcolor="#CCCCCC"><a href="#TOP" class="item9">back 
+      to top</a></td>
+  </tr>
+  <tr> 
+    <td colspan="2">(<span class="red">GrADS version 2.1.1.b0+</span>) This optional entry tells GrADS that the data file has a trailer 
+      record of <em>length</em> bytes following each horizontal grid (XY block) of binary 
+      data. This entry is only valid for GrADS gridded 
+      data sets. See the section on <a
+href="aboutgriddeddata.html#structure">structure of a gridded binary data file</a> 
+      for more information. </td>
+  </tr>
   <tr> 
     <td bgcolor="#CCCCCC"><strong><a name="XVAR"></a>XVAR</strong> <em>x,y</em></td>
     <td align="right" valign="top" bgcolor="#CCCCCC"><a href="#TOP" class="item9">back 
diff --git a/doc/expressions.html b/doc/expressions.html
index ef6ca37..b5ef856 100644
--- a/doc/expressions.html
+++ b/doc/expressions.html
@@ -1 +1,91 @@
-<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.--><style type="text/css">
<!--
body {
	background-color: #e0f0ff;
}
.style1 {color: #990000}
-->
</style>

<h1>Expressions</h1>

A GrADS expression consists of operators, operands, and
parentheses.  Parentheses are used to
control the order of operation.
<p>

Operators are:


<ul>
<code>+</code>    Addition <br>
<code>-</code>    Subtraction <br>
<code>*</code>    Multiplication <br>
<code>/</code>    Division</ul><p>

Operands are:


<dd><code><a href="variable.html">variable specifications</a>, <a href="functions.html">functions</a>, and constants</code>.
  <p>

Operations between two variables are done on equivalent grid points in each grid. 
Missing data values in either grid give a result of a missing
data value at that grid point.  Dividing by zero gives a result
of a missing data value at that grid point.<p>

Operations cannot be done between grids that have different
scaling in their varying dimensions -- i.e., grids that have
different rules for converting the varying dimensions from grid
space to world coordinate space.  This can only be encountered
when you are attempting operations between grids from different
files that have different scaling rules.
<p>

If one grid has more varying dimensions than the other, the grid
with fewer varying dimensions     is 'expanded' and the operation
is performed.
<p>Expression evaluation in GrADS is recursive, so that multiple expressions may be nested together. 
<p>(<span class="style1">GrADS version 2.0.a7+</span>) Variable specifications can include a dimension expression to set time as an <a href="offt.html">offset</a> from the variable's initial time. 

<p>

Some examples of expressions:

<ul>
<code>slp/100                     </code>(Convert sea level pressure units from hPa to mb)<br>
<code>z-z(t-1)                    </code>(Height change over one time step)<br>
<code>z-z(offt=0)                 </code>(Height change since initial time)<br>
<code>t(lev=500)-t(lev=850)       </code>(Temp difference between 500
and 850mb)<br>
<code>ave(z,t=1,t=5)              </code>(Average of z over first 5 times in file) <br>
<code>sum(prec(offt+0),t=1,t=4)   </code>(Accumulated precipitation -- sum of 2nd through 5th time steps in file) <br>
<code>z-ave(z,lon=0,lon=360,-b)   </code>(Remove zonal mean)<br>
<code>tloop(aave(p,global))       </code>(Time series of globally averaged precip)</ul>
\ No newline at end of file
+<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.--><style type="text/css">
+<!--
+body {
+	background-color: #e0f0ff;
+}
+.style1 {color: #990000}
+-->
+</style>
+
+<h1>Expressions</h1>
+
+A GrADS expression consists of operators, operands, and
+parentheses.  Parentheses are used to
+control the order of operation -- this is especially important when using the logical operators. 
+<p>
+
+Operators are:
+<ul>
+<code>+   </code>Addition <br>
+<code>-   </code>Subtraction <br>
+<code>*   </code>Multiplication <br>
+<code>/   </code>Division <br>
+</ul>
+
+Logical Operators (introduced in <span class="style1">Version 2.1.1.b0</span> for GRIDDED data only):
+<ul>
+<code>=    </code>Equal ( <code>== </code> is also acceptable)<br>
+<code>!=   </code>Not Equal<br>
+<code>>    </code>Greater than<br>
+<code>>=   </code>Greater than or equal <br>
+<code><    </code>Less than <br>
+<code><=   </code>Less than or equal<br>
+<code>&    </code>And  (<code> && </code> is also acceptable)<br>
+<code>|    </code>Or  ( <code>|| </code> is also acceptable)<br>
+
+</ul>
+
+
+
+<p>
+
+Operands are:
+
+
+<dd><code><a href="variable.html">variable specifications</a>, <a href="functions.html">functions</a>, and constants</code>.</dd>
+<h3>Usage Notes</h3>
+Operations between two variables are done on equivalent grid points in each grid. 
+Missing data values in either grid give a result of a missing
+data value at that grid point.  Dividing by zero gives a result
+of a missing data value at that grid point.<p>
+
+Operations cannot be done between grids that have different
+scaling in their varying dimensions -- i.e., grids that have
+different rules for converting the varying dimensions from grid
+space to world coordinate space.  This can only be encountered
+when you are attempting operations between grids from different
+files that have different scaling rules.
+<p>
+
+If one grid has more varying dimensions than the other, the grid
+with fewer varying dimensions     is 'expanded' and the operation
+is performed.
+<p>Expression evaluation in GrADS is recursive, so that multiple expressions may be nested together. 
+<p>(<span class="style1">GrADS version 2.0.a7+</span>) Variable specifications can include a dimension expression to set time as an <a href="offt.html">offset</a> from the variable's initial time. 
+
+<p>(<span class="style1">GrADS version 2.1.1.b0+</span>) The result of a logical operation is boolean -- an answer to a yes/no question. If the expression is true the result is 1, if the expression is false the answer is  -1 (instead of zero).  
+This is slightly different from the usual convention, but it is implemented this way in GrADS to make it easier to use logical operators with the <code><a href="gradfuncmaskout.html">maskout()</a></code> function. An <code><a href="gradfuncif.html">if()</a></code> function has also been implemented to  use  logical operators in expressions of the form if-then-else. Note: the logical operators have not yet been implemented for station data. <br />
+<h3>Examples</h3>
+
+<ul>
+<code>slp/100                     </code>(Convert sea level pressure units from hPa to mb)<br>
+<code>z-z(t-1)                    </code>(Height change over one time step)<br>
+<code>z-z(offt=0)                 </code>(Height change since initial time)<br>
+<code>t(lev=500)-t(lev=850)       </code>(Temp difference between 500
+and 850mb)<br>
+<code>ave(z,t=1,t=5)              </code>(Average of z over first 5 times in file) <br>
+<code>sum(prec(offt+0),t=1,t=4)   </code>(Accumulated precipitation -- sum of 2nd through 5th time steps in file) <br>
+<code>z-ave(z,lon=0,lon=360,-b)   </code>(Remove zonal mean)<br>
+<code>tloop(aave(p,global))       </code>(Time series of globally averaged precip)<br />
+<br />
+</ul>
+<h3>Examples Using Logical Operators</h3>
+<ul>
+<code>tsfc>=0                                                </code>(Surface temperatures greater than or equal to zero)<br />
+<code>maskout(tsfc,tsfc>=0)                                  </code>(Set all negative surface temperatures to be undefined)<br />
+<code>(tsfc>30)|(tsfc<-30)                                   </code>(Surface temperature extremes)<br />
+<code>(lat>=-5)&(lat<=5)&(lon>=190)&(lon<=240)               </code>(Lat/Lon bounding box -- Nino3.4)<br />
+<code>maskout(tsfc,(lat>=-5)&(lat<=5)&(lon>=190)&(lon<=240)) </code>(Surface temperature only defined within the Lat/Lon box)<br /><br />
+
+</ul>
+ 
\ No newline at end of file
diff --git a/doc/filledbarbs.png b/doc/filledbarbs.png
new file mode 100644
index 0000000..4fe4bc1
Binary files /dev/null and b/doc/filledbarbs.png differ
diff --git a/doc/gradcomdqdefine.html b/doc/gradcomdqdefine.html
new file mode 100644
index 0000000..23441a8
--- /dev/null
+++ b/doc/gradcomdqdefine.html
@@ -0,0 +1,50 @@
+<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->
+
+<html>
+<head>
+<title>GrADS Command: q define</title>
+<link href="/assets/NewIGES.css" rel="stylesheet" type="text/css">
+<style type="text/css">
+<!--
+.style2 {color: #990000}
+.style3 {color: #009933}
+body {
+        background-color: #e0f0ff;
+}
+.red {
+        color: #900;
+}
+.italic {
+        font-style: italic;
+}
+-->
+</style>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+</head>
+<body bgcolor="e0f0ff" text="#000000">
+
+<h2><b>q define</b></h2>
+<p><code>q define <i>varname</i></code>
+<p>This command returns information about a defined variable, <code><i>varname</i></code>. The <code>'q define'</code> command without the variable name will return a list of defined variables. When a variable name is added, the printout includes the type, the sizes of each dimension, axis definitions for each dimension, the calendar, and whether the variable has been <a href="gradcomdmodify.html"><code>'modified'</code></a>. 
+<h3>Usage Notes</h3>
+<p>This command is  available in GrADS <span class="red">version 2.1.1.b0</span>.</p>
+<h3>Example</h3>
+<code>
+<p>ga->define ps=ps<br>
+  Define memory allocation size = 8311688 bytes<br>
+  ga-> q define ps<br>
+  Gridded Defined Variable: ps <br>
+Xsize = 1441  Ysize = 721  Zsize = 1  Tsize = 1  Esize = 1<br>
+XDEF 1441 linear 0 0.25<br>
+YDEF 721 linear -90 0.25<br>
+ZDEF 1 levels 1000<br>
+TDEF 1 linear 12Z02FEB2017 180mn<br>
+Calendar: Gregorian q ens<br>
+</p>
+</code>
+<h3> </h3>
+
+
+</body>
+</html>
+
diff --git a/doc/gradcomdsetbarbopts.html b/doc/gradcomdsetbarbopts.html
new file mode 100644
index 0000000..47363ea
--- /dev/null
+++ b/doc/gradcomdsetbarbopts.html
@@ -0,0 +1,32 @@
+<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->
+<style type="text/css">
+body {
+	background-color: #e0f0ff;
+}
+.red {	color: #900;
+}
+</style>
+
+
+<H2><B>set barbopts</B></H2>
+<P>
+This command controls the appearance of the pennant flags on wind barbs. 
+ 
+It is available starting with <span class="red">GrADS version 2.1.1b0</span>.
+<h3>Syntax
+</h3>
+<P><code>set barbopts <i>opts</i></code>
+<ul>
+<code>outline</code>     do <i>not</i> fill
+in
+the pennant <br>
+<code>filled</code>       fill in the pennant
+</ul>
+<H3>Usage Notes</H3>
+<P>If you are using a transparent color to draw filled barbs, you may notice a faint outline around the pennant flags; you can avoid this using 
+<a href="colorcontrol.html#transparent">color masking</a>. 
+<H3>Examples</H3>
+<P>Results that look like the image below may be accomplished by drawing filled barbs underneath outlined barbs. <br />
+<img src="filledbarbs.png" width="145" height="100" alt="filled barbs" border="1"/><br />
+  <br />
+  
diff --git a/doc/gradcomdsetsdfwrite.html b/doc/gradcomdsetsdfwrite.html
index 4e79841..f9109c3 100644
--- a/doc/gradcomdsetsdfwrite.html
+++ b/doc/gradcomdsetsdfwrite.html
@@ -25,6 +25,7 @@
     <code>-3dt     </code>forces the output data file to have at least 3 coordinate dimensions (lon, lat,  and time)<br>
     <code>-3dz     </code>forces the output data file to have at least 3 coordinate dimensions (lon, lat, and lev)<br>
     <code>-4d      </code>forces the output data file to have at least 4 coordinate dimensions (lon, lat, lev, and time)<br>
+    <code>-4e      </code>forces the output data file to have at least 4 coordinate dimensions (lon, lat, time, and ens)<br>
     <code>-5d      </code>forces the output data file to have 5 coordinate dimensions (lon, lat, lev, time, and ens)<br>
     <code>-rt      </code>sets the T axis as the record (unlimited) dimension<br>
     <code>-re      </code>sets the E axis as the record (unlimited) dimension<br>
@@ -43,12 +44,13 @@
 <p>
 <h3>Usage Notes</h3>
 <p>
-This command is  available in GrADS <span class="style1">v2.0.a3+</span>. 
+This command is  available in version <span class="style1">v2.0.a3+</span>. 
 <br>
-The <code>-4d</code> and <code>-5d</code> options are available in GrADS <span class="style1">v2.0.a5+</span>. 
+The <code>-4d</code> and <code>-5d</code> options are available in version <span class="style1">v2.0.a5+</span>. 
 <br>
-The <code>-flt</code>, <code>-dbl</code>, <code>-nc3</code>,<code>-nc4</code>, <code>-chunk</code>, and <code>-zip</code> options are available in GrADS <span class="style1">2.0.a8+</span>.<br>
-The <code>-3dz,</code><code>-3dt,-rt</code> and <code>-re</code> options are available in GrADS <span class="style1">2.1.a2+</span>.
+The <code>-flt</code>, <code>-dbl</code>, <code>-nc3</code>,<code>-nc4</code>, <code>-chunk</code>, and <code>-zip</code> options are available in version <span class="style1">2.0.a8+</span>.<br>
+The <code>-3dz,</code><code>-3dt,-rt</code> and <code>-re</code> options are available in version <span class="style1">2.1.a2+</span>.<br>
+The -4de option is available in version <span class="style1">2.1.1.b0</span>.
 <p>The options set with this command "stick" until the <a href="http://iges.org/grads/gadoc/gradcomdreset.html"><code>reset</code></a>, <a href="http://iges.org/grads/gadoc/gradcomdreinit.html"><code>reinit</code></a>, or <a href="http://iges.org/grads/gadoc/gradcomdclear.html"><code>clear sdfwrite</code></a> commands are invoked -- they are not altered when <a href="gradcomdsdfwrite.html"><code>sdfwrite</code></a> is invoked; however, there have been some changes related to  which optio [...]
 <ul>
   <li>(<span class="style1">2.0.a3</span>) Originally, all options were designed to "stick" until  a  <a href="http://iges.org/grads/gadoc/gradcomdclear.html"><code>clear sdfwrite</code></a> command was invoked.</li>
diff --git a/doc/gradfuncif.html b/doc/gradfuncif.html
new file mode 100644
index 0000000..6d01691
--- /dev/null
+++ b/doc/gradfuncif.html
@@ -0,0 +1,56 @@
+<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->
+
+<html>
+<title>GrADS Function: if</title>
+<style type="text/css">
+.red {
+	color: #900;
+}
+body {
+	background-color: #e0f0ff;
+}
+</style>
+<body text="#000000">
+
+<H2><b>if()</b></H2>
+<p>
+  This function performs an if/then/else expression evaluation. 
+It is available starting with <span class="red">GrADS version 2.1.1.b0</span>.
+<h3>Syntax</h3>
+<p>
+<code>if (<i>logical_expr, then_expr, else_expr</i>)</code>
+
+<p>
+where:
+<ul>
+  <p><code><i>logical_expr</i>   </code>- any valid  logical expression that has a boolean (yes/no) result<br>
+    <code><i>then_expr</i>      </code>- the result expression if <code><i>logical_expr</i></code> is true<br>
+    <code><i>else_expr   </i>   </code>-  the result expression if <code><i>logical_expr</i></code> is false<br>
+</ul>
+  <p>All the arguments must be expressions for gridded data -- the logical operators and the if() function have not yet been implemented for station data. <br>
+</p>
+<H3>Usage Notes</H3>
+<ol>
+<li>The <code><i>logical_expr</i></code> should include one or more of the logical operators:<code> =, !=, >, >=, <, <=, |, &</code><br>
+  <br>
+The result of a logical operation is boolean -- an answer to a yes/no question. If the expression is true the result is 1, and if the expression is false the answer is  -1. The <code>if()</code> function will evaluate <code><i>logical_expr</i></code> and wherever the result is  >0 it will place the value of <code><i>then_expr</i></code>, and wherever the result is <0 it will place the value of <code><i>else_expr</i></code>.<br>
+<br>
+<li>The arguments<code><i>then_expr</i></code> and <code><i>else_expr</i></code> may be any GrADS expression, including a constant. If you want <code><i>then_expr</i></code> or <code><i>else_expr</i></code> to be undefined, then use  <code><a href="gradfuncmaskout.html">maskout()</a></code> instead of the <code><a href="gradfuncif.html">if()</a></code> function.
+</ol>
+
+<h3>Examples</h3>
+<p>Here is a script sample to find the minimum and maximum 2-meter temperature at each grid point over a 12-month period:<dd><code>
+  'define tmin = const(t2m,1e9)'<br>
+  'define tmax = const(t2m,-1e9)'<br>
+  t = 1<br>
+  while (t <= 12) <br>
+  'set t 't<br>
+  'define tmin = if(t2m<tmin,t2m,tmin)'<br>
+  'define tmax = if(t2m>tmax,t2m,tmax)'<br>
+  t = t + 1<br>
+endwhile
+</code>
+</dd>
+</p>
+</body>
+</html>
\ No newline at end of file
diff --git a/doc/pdef.html b/doc/pdef.html
index a4e06ba..bac48ea 100644
--- a/doc/pdef.html
+++ b/doc/pdef.html
@@ -1 +1,769 @@
-<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PDEF - Displayng Pre-Projected Data in GrADS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="GrADS.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #990000}
-->
</style>
</head>

<body bgcolor="e0f0ff">
<p class="banner18">Use PDEF For Displaying Pre-Projected Data With GrADS</p>
<p class="plaintext"><a href="#about">Display pre-projected data with PDEF</a><br>
  <a href="#syntax">PDEF Syntax</a><br>
  <a href="#interp">How grid interpolation works</a><br>
  <a href="#rotation">How wind rotation works</a><br>
  <a href="#bilin">PDEF BILIN option</a><br>
  <a href="#file">PDEF GENERAL option</a><br>
  <a href="#file">PDEF FILE option</a></p>
<table width="650" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><p class="plaintext"><a name="about" class="item12bold">Display Pre-Projected 
        Data with PDEF</a></p>
      <p class="plaintext">Gridded data that are mapped onto a particular map 
        projection are called 'pre-projected.' An example of pre-projected data 
        is the output from a weather forecast model that is mapped onto a north 
        polar stereographic grid. </p>
      <p class="plaintext">In order to display pre-projected data on a map in 
        GrADS, the descriptor file must contain a PDEF entry. A descriptor file 
        that contains a PDEF record describes two different grids. The first grid 
        is described by the PDEF record itself and is the "native" grid 
        for the pre-projected data in the file. The second 
        grid described in the desctiptor file is a rectilinear lat/lon grid, which 
        is defined by the XDEF and YDEF records. The PDEF record describes the 
        size of the native grid, and then describes how to convert from i/j of the native grid to the lat/lon values of the rectilinear grid described by XDEF and YDEF. The information in the PDEF entry describes the 
        projection of the grid along with the projection constants or providing 
        the mapping to the native grid in a supplementary data file. The rectilinear grid is used 
        by GrADS internally and can be any size or resolution -- it is completely 
        independent of the pre-projected or native grid. GrADS uses the information 
        about the two grids to interpolate from the PDEF-described native grid 
        to the XDEF/ YDEF-described rectilinear grid. All displays and analyses 
        are done using the interpolated data on the rectilinear grid. The virtue 
        of this approach is that all built in GrADS analytic functions (e.g., 
        <a
href="/grads/gadoc/gradfuncaave.html">aave</a>, <a href="/grads/gadoc/gradfunchcurl.html">hcurl</a>...) 
        will work even though the data were not originally on a lon/lat grid. 
        The downside is that you are looking at interpolated data. </p>
      <p class="plaintext">It is possible to view the pre-projected data on its 
        native grid. To do this, you omit the PDEF entry from the descriptor file, 
        and use the XDEF and YDEF entries to describe the shape of the native 
        grid. In this case, your displays must be drawn in i/j space without a 
        map projection (<a href="/grads/gadoc/gradcomdsetmpdraw.html">set mpdraw</a> 
        off). </p>
      <p class="plaintext">When you do a <a
href="/grads/gadoc/gradcomddisplay.html">display</a> of a pre-projected vector 
        field, you must know whether the original vector components are defined 
        relative to the data grid or relative to the Earth. If the data are grid-relative, 
        they must be rotated to Earth-relative coordinates in order for the interpolation 
        to work properly. See the "Notes" under each particular projection 
        type for further information.</p>
      <p class="item12bold"><a name="syntax"></a>PDEF Syntax</p>
      <ul>
        <table width="600" border="0" cellpadding="0" cellspacing="4" class="plaintext">
          <tr bgcolor="#CCCCCC"> 
            <td colspan="3"> <strong>PDEF <em>isize jsize</em> NPS<em> ipole jpole 
              lonref gridinc</em><br>
              PDEF <em>isize jsize</em> SPS<em> ipole jpole lonref gridinc</em></strong></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td width="50" align="right">Example:</td>
            <td colspan="2">PDEF 53 45 nps 27 49 -105 190.5</td>
          </tr>
          <tr bgcolor="b8c8d7"> 
            <td align="right" valign="top">Args: </td>
            <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr class="plaintext"> 
                  <td width="60" valign="top"><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>ipole</em></td>
                  <td>the i coordinate of the pole referenced from the lower left 
                    corner, assumed to be at (1,1)</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>jpole</em></td>
                  <td>the j coordinate of the pole referenced from the lower left 
                    corner, assumed to be at (1,1)</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>lonref</em></td>
                  <td>reference longitude</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>gridinc</em></td>
                  <td>distance between gripoints in km</td>
                </tr>
              </table></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Notes: </td>
            <td colspan="2">Polar stereographic projections (N and S) are defined 
              as at NCEP. Wind rotation has also been added so that vector data 
              will be properly displayed. </td>
          </tr>
          <tr> 
            <td> </td>
            <td colspan="2"> </td>
          </tr>
          <tr bgcolor="#CCCCCC"> 
            <td colspan="3"><strong>PDEF <em>isize jsize</em> LCCR <em>latref 
              lonref iref jref Struelat Ntruelat slon dx dy<br>
              </em>PDEF <em>isize jsize</em> LCC <em>latref lonref iref jref Struelat 
              Ntruelat slon dx dy</em><em> </em></strong></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right">Example:</td>
            <td colspan="2">PDEF 103 69 lccr 30 -88 51.5 34.5 20 40 -88 90000 
              90000</td>
          </tr>
          <tr bgcolor="b8c8d7"> 
            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
            <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr class="plaintext"> 
                  <td width="60" valign="top"><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>latref</em></td>
                  <td>reference latitude</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>lonref</em></td>
                  <td>reference longitude (in degrees, E is positive, W is negative)                  </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>iref</em></td>
                  <td>i of ref point </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>jref</em></td>
                  <td>j of ref point </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>Struelat</em></td>
                  <td>S true lat </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>Ntruelat</em></td>
                  <td>N true lat </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>slon</em></td>
                  <td>standard longitude</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>dx</em></td>
                  <td>grid X increment in meters</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>dy</em></td>
                  <td>grid Y increment in meters</td>
                </tr>
              </table></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top" bgcolor="ccdceb">Notes: </td>
            <td colspan="2">Starting with version 1.9b4, the LCCR option supplements 
              the use of PDEF with data on the Lambert Conformal projection. With 
              LCCR, wind rotation has been implemented for data files with grid-relative 
              winds instead of Earth-relative winds. Use LCC if your vector components 
              are already Earth-relative. </td>
          </tr>
          <tr> 
            <td> </td>
            <td width="9%"> </td>
            <td width="82%"> </td>
          </tr>
          <tr bgcolor="#CCCCCC"> 
            <td colspan="3"><strong>PDEF <em>isize jsize </em>ETA.U<em> lonref 
              latref dlon dlat</em></strong></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right">Example:</td>
            <td colspan="2">PDEF 181 136 eta.u -97.0 41.0 0.38888888 0.37</td>
          </tr>
          <tr> 
            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
            <td colspan="2" bgcolor="b8c8d7"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr class="plaintext"> 
                  <td width="60" valign="top"><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">lonref</td>
                  <td>reference longitude (in degrees, E is positive, W is negative)                  </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">latref</td>
                  <td>reference latitude</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">dlon</td>
                  <td>grid longitude increment in degrees</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">dlat</td>
                  <td>grid latitude increment in degrees</td>
                </tr>
              </table></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Notes: </td>
            <td colspan="2">The eta model native grid is awkward to work with 
              because the variables are on staggered <i>and</i> non-rectangular 
              grids. NCEP created "unstaggered" eta model fields, in which the 
              variables are placed on a common rectangular grid. Wind rotation 
              has also been added so that vector data will be properly displayed.            </td>
          </tr>
          <tr> 
            <td> </td>
            <td> </td>
            <td> </td>
          </tr>
          <tr bgcolor="#CCCCCC"> 
            <td colspan="3"><strong>PDEF <em>isize jsize</em> PSE <em>slat slon 
              ipole jpole dx dy sign</em></strong></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Example:</td>
            <td colspan="2"> </td>
          </tr>
          <tr bgcolor="b8c8d7"> 
            <td align="right" valign="top">Args: </td>
            <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr class="plaintext"> 
                  <td width="60" valign="top"><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top"><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">slat</td>
                  <td>absolute value of the standard latitude </td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">slon</td>
                  <td>absolute value of the standard longitude</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">ipole</td>
                  <td>the i coordinate of the pole referenced from the lower left 
                    corner, assumed to be at (0,0)</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">jpole</td>
                  <td>the j coordinate of the pole referenced from the lower left 
                    corner, assumed to be at (0,0)</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">dx</td>
                  <td>grid X increment in km</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">dy</td>
                  <td>grid Y increment in km</td>
                </tr>
                <tr class="plaintext"> 
                  <td valign="top">sign</td>
                  <td>1 for NH; -1 for SH</td>
                </tr>
              </table></td>
          </tr>
          <tr> 
            <td align="right" valign="top" bgcolor="ccdceb">Notes: </td>
            <td colspan="2" bgcolor="ccdceb">The polar stereo projection used 
              by the original NMC models is not very precise because it assumes 
              the earth is round (eccentricity = 0). While this approximation 
              was reasonable for coarse resolution NWP models, it is inadequate 
              to work with higher resolution data such as SSM/I. <i>Wind rotation 
              has not been implemented!!! Use only for scalar fields.</i></td>
          </tr>
          <tr> 
            <td> </td>
            <td> </td>
            <td> </td>
          </tr>
          <tr bgcolor="#CCCCCC"> 
            <td colspan="3"><strong>PDEF <em>isize jsize</em> OPS <em> latref 
              lonref xoff yoff iref jref dx dy </em></strong></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right">Example:</td>
            <td colspan="2">PDEF 26 16 ops 40.0 -100.0 90000.0 90000.0 14.0 9.0 
              180000.0 180000.0 </td>
          </tr>
          <tr bgcolor="b8c8d7"> 
            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
            <td colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
                <tr class="plaintext"> 
                  <td width="60"><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td>latref</td>
                  <td>reference latitude</td>
                </tr>
                <tr class="plaintext"> 
                  <td>lonref</td>
                  <td>reference longitude (in degrees, E is positive, W is negative)                  </td>
                </tr>
                <tr class="plaintext"> 
                  <td>xoff</td>
                  <td>lonref offset in meters</td>
                </tr>
                <tr class="plaintext"> 
                  <td>yoff</td>
                  <td>latref offset in meters</td>
                </tr>
                <tr class="plaintext"> 
                  <td>iref</td>
                  <td>the i coordinate of the reference point</td>
                </tr>
                <tr class="plaintext"> 
                  <td>jref</td>
                  <td>the j coordinate of the reference point</td>
                </tr>
                <tr class="plaintext"> 
                  <td>dx</td>
                  <td>grid X increment in km</td>
                </tr>
                <tr class="plaintext"> 
                  <td>dy</td>
                  <td>grid Y increment in km</td>
                </tr>
                <tr class="plaintext"> 
                  <td>dy</td>
                  <td>grid Y increment in km</td>
                </tr>
              </table></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Notes: </td>
            <td colspan="2">The CSU RAMS model uses an oblique polar stereo projection. 
              <i>Wind rotation has not been implemented!!! Use only for scalar 
              fields.</i></td>
          </tr>
          <tr bgcolor="ccdceb">
            <td align="right" valign="top" bgcolor="#FFFFFF"> </td>
            <td colspan="2" bgcolor="#FFFFFF"> </td>
          </tr>
          <tr bgcolor="#CCCCCC">
            <td colspan="3"><strong>PDEF <em>isize jsize</em> ROTLL<em> lonpol latpol dlon dlat lonll latll <br>
            </em>PDEF <em>isize jsize</em> ROTLLR<em> lonpol latpol dlon dlat lonll latll </em></strong></td>
          </tr>
          <tr bgcolor="#CCCCCC"></tr>
          <tr bgcolor="ccdceb">
            <td align="right">Example:</td>
            <td colspan="2">PDEF 500 330 rotllr -170.0  43.0   0.02   0.02  -5.5 -3.8</td>
          </tr>
          <tr bgcolor="b8c8d7">
            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
            <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
                <tr class="plaintext">
                  <td width="60"><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr class="plaintext">
                  <td><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr class="plaintext">
                  <td>lonpol</td>
                  <td>Longitude of the rotated pole in degrees</td>
                </tr>
                <tr class="plaintext">
                  <td>latpol</td>
                  <td>Latitude of the rotated pole in degrees</td>
                </tr>
                <tr class="plaintext">
                  <td>dlon</td>
                  <td>grid spacing in longitudinal direction of the rotated grid in degrees</td>
                </tr>
                <tr class="plaintext">
                  <td>dlat</td>
                  <td>grid spacing in latitudinal direction of the rotated grid in degrees</td>
                </tr>
                <tr class="plaintext">
                  <td>lonll</td>
                  <td>longitude of the lower left corner, given in rotated space in degree</td>
                </tr>
                <tr class="plaintext">
                  <td>latll</td>
                  <td>latitude of the lower left corner, given in rotated space in degree</td>
                </tr>

            </table></td>
          </tr>
          <tr bgcolor="ccdceb">
            <td align="right" valign="top">Notes: </td>
            <td colspan="2" bgcolor="ccdceb"><p>(<font color="#990000">GrADS version 2.0</font>) The rotated lat/lon grid projection is described in the  <a href="http://www.cosmo-model.org/public/documentation.htm">COSMO documentation</a>, Part 1, chapter 3.3. The lower left corner, i.e. the first element in the data array, has to be the southwest corner.  It is  not possible to use a mirrored grid by setting dlon or dlat to a negative value.</p>            </td>
          </tr>
          
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top" bgcolor="#FFFFFF"> </td>
            <td colspan="2" bgcolor="#FFFFFF"> </td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td colspan="3" align="left" valign="top" bgcolor="#CCCCCC"> <p><strong>PDEF<em> 
                isize jsi</em>ze BILIN <em>format byteorder fname</em></strong></p></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Example:</td>
            <td colspan="2">PDEF 100 100 BILIN sequential binary-big ^mygrid.interp.values            </td>
          </tr>
          <tr bgcolor="b8c8d7"> 
            <td align="right" valign="top" bgcolor="b8c8d7">Args:</td>
            <td colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
                <tr class="plaintext"> 
                  <td width="60"><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr class="plaintext"> 
                  <td><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr> 
                  <td><em>format</em></td>
                  <td>Must be either STREAM (direct access) or SEQENTIAL (fortran 
                    formatted)</td>
                </tr>
                <tr> 
                  <td valign="top"><em>byteorder</em></td>
                  <td>If set to BINARY, byte odering is assumed to be same as 
                    local machine<br>
                    If set to BINARY-BIG, byte ordering is assumed to be big-endian<br>
                    If set to BINARY-LITTLE, byte ordering is assumed to be little-endian</td>
                </tr>
                <tr> 
                  <td valign="top"><em>fname</em></td>
                  <td>The name of the supplementary file </td>
                </tr>
              </table></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Notes:</td>
            <td colspan="2">The supplementary file contains three lat-lon floating-point 
              grids: i values, j values, and wind rotation values. The native grid  is assumed to have a corner (i,j) value of (1,1). The size of 
              these grids must match the XDEF and YDEF entries in the descriptor 
              file. </td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top" bgcolor="#FFFFFF"> </td>
            <td colspan="2" bgcolor="#FFFFFF"> </td>
          </tr>
          <tr align="left" bgcolor="#CCCCCC">
            <td colspan="3" valign="top"><strong>PDEF<em> isize jsize</em> GENERAL <em>num 
              format byteorder fname</em></strong></td>
          </tr>
          <tr bgcolor="ccdceb">
            <td align="right" valign="top">Example:</td>
            <td colspan="2">PDEF 182 149  general 4 sequential binary-big ^mygrid.interp.values<br>
              PDEF 15238 1 general 1 stream binary ^gtd.filepdef</td>
          </tr>
          <tr bgcolor="b8c8d7">
            <td align="right" valign="top">Args:</td>
            <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
                <tr>
                  <td><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr>
                  <td><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                <tr>
                  <td width="60"><em>num</em></td>
                  <td>number of sets of interpolation grids supplied</td>
                </tr>
                <tr>
                  <td><em>format</em></td>
                  <td>Must be either STREAM (direct access) or SEQENTIAL (fortran 
                    formatted)</td>
                </tr>
                <tr>
                  <td valign="top"><em>byteorder</em></td>
                  <td>If set to BINARY, byte odering is assumed to be same as 
                    local machine<br>
                    If set to BINARY-BIG, byte ordering is assumed to be big-endian<br>
                    If set to BINARY-LITTLE, byte ordering is assumed to be little-endian</td>
                </tr>
                <tr>
                  <td valign="top"><em>fname</em></td>
                  <td>The name of the supplementary file; it may be mixed case. </td>
                </tr>
            </table></td>
          </tr>
          <tr bgcolor="ccdceb">
            <td align="right" valign="top" bgcolor="ccdceb">Notes:</td>
            <td colspan="2" bgcolor="ccdceb"><p>(<span class="style1">GrADS version 2.0.a3 and later</span>) The syntax and behavior of PDEF GENERAL is exactly like PDEF FILE, except that the convention for the native grid offset values in the pdef file is the same for all data formats. The offsets should be 1-based; the first grid point is assumed to have (i,j) values of (1,1), and  valid offset values are > 0 and <= <em>isize</em>*<em>jsize</em> .</p>
              <p>Native grid offset values of -999 indicate not to use 
        an input point for that portion of the calculation (thus you can apply 
        less than the "<em>num</em>" number of interpolation points for some 
        of the points). </p>
              <p>See additional notes in the paragraphs below.</p></td>
          </tr>
          <tr align="left" bgcolor="#CCCCCC">
            <td colspan="3" valign="top" bgcolor="#FFFFFF"> </td>
          </tr>
          
          <tr align="left" bgcolor="#CCCCCC"> 
            <td colspan="3" valign="top"><strong>PDEF<em> isize jsize</em> FILE <em>num 
              format byteorder fname</em></strong></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Example:</td>
            <td colspan="2">PDEF 182 149 file 4 sequential binary-big ^mygrid.interp.values<br>
              PDEF 15238 1 file 1 stream binary ^gtd.filepdef</td>
          </tr>
          <tr bgcolor="b8c8d7"> 
            <td align="right" valign="top">Args:</td>
            <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
                <tr>
                  <td><em>isize</em></td>
                  <td>The size of the native grid in the x direction </td>
                </tr>
                <tr>
                  <td><em>jsize</em></td>
                  <td>The size of the native grid in the y direction </td>
                </tr>
                
                <tr> 
                  <td width="60"><em>num</em></td>
                  <td>number of sets of interpolation grids supplied</td>
                </tr>
                <tr> 
                  <td><em>format</em></td>
                  <td>Must be either STREAM (direct access) or SEQENTIAL (fortran 
                    formatted)</td>
                </tr>
                <tr> 
                  <td valign="top"><em>byteorder</em></td>
                  <td>If set to BINARY, byte odering is assumed to be same as 
                    local machine<br>
                    If set to BINARY-BIG, byte ordering is assumed to be big-endian<br>
                    If set to BINARY-LITTLE, byte ordering is assumed to be little-endian</td>
                </tr>
                <tr> 
                  <td valign="top"><em>fname</em></td>
                  <td>The name of the supplementary file; it may be mixed case.                  </td>
                </tr>
              </table></td>
          </tr>
          <tr bgcolor="ccdceb"> 
            <td align="right" valign="top">Notes:</td>
            <td colspan="2" bgcolor="ccdceb"><p>For GrADS v2.0.a2 and earlier, <em>jsize</em> was fixed to be 1, and <em>isize</em> was the size of the native grid expressed as a vector (i.e., all gridpoints in the x-y grid). This mode for describing the native grid will continue to work with v2.0.a3+, but only if the native grid is in GRIB or binary format. For NetCDF and HDF formats, the <em>isize</em> and <em>jsize</em> args must match the X and Y dimensions of the native grid. </p>
            <p><span class="style1">WARNING: The use of PDEF FILE may be incorrect!</span> A long-standing bug and incomplete documentation has led to different conventions for the native grid offset values in the pdef file for GRIB and non-GRIB data formats. For GRIB (1&2), the offsets must be 0-based; the first grid point is assumed to have (i,j) values of (0,0). For all other data types, the offsets must be 1-based; the first grid point is assumed to have (i,j) values of (1,1). Thus:<br>
                   for GRIB format: valid offset values are >= 0 and < <em>isize</em>*<em>jsize</em><br>
                   for other formats: valid offset values are > 0 and <= <em>isize</em>*<em>jsize</em><br>
              To maintain backward compatibility, the bug will remain in GrADS as a feature, but the use of PDEF FILE has been deprecated as of version 2.0.a3 and a warning message will be displayed when a data set is opened that uses PDEF FILE. Note that if you use <a href="http://www.cpc.ncep.noaa.gov/products/wesley/grib2ctl.html">grib2ctl</a> or <a href="http://www.cpc.ncep.noaa.gov/products/wesley/g2ctl.html">g2ctl </a>to generate your pdef file, the offsets are correct. </p>
            <p>Native grid offset values of -999 indicate not to use 
        an input point for that portion of the calculation (thus you can apply 
        less than the "<em>num</em>" number of interpolation points for some 
        of the points). </p>
            <p>See additional notes in the paragraphs below.</p></td>
          </tr>
        </table>
      </ul>
      <p class="item16"> <span class="item12bold"><strong><a name="interp"></a>How 
        PDEF Grid Interpolation Works</strong></span><br>
        <span class="plaintext">To illustrate how the data is interpolated from 
        the native grid to the rectilinear grid, let's consider an example. Here 
        are a set of relevant records from a descriptor file: <br>
        PDEF 100 100 nps ...<br>
        XDEF 181 linear -180 1<br>
        YDEF 90 linear 0 1<br>
        These three entries describe data on a native 100x100 North Polar stereographic 
        projection and a rectilinear lat/lon grid that is 181 by 90 and has an 
        interval of 1 degree in both lat and lon. Consider one point within the 
        rectilinear grid, the point -90,40. GrADS calls an internal routine to 
        calculate the i and j values in the native grid that correspond to this 
        lat/lon point. Let's say we get i,j values of 31.24 and 67.88. To do the 
        interpolation to the lat/lon point -90,40, GrADS uses the data values 
        from the following four native grid points: 31,67 - 31,68 - 32,67 - 32,68. 
        Bi-linear interpolation is used within this grid box to get down to the 
        position 31.24,67.88. The interpolation is linear within the i,j grid. 
        When a descriptor file is opened that contains a PDEF record, GrADS calculates 
        the i/j values in the native grid that correspond to the lat/lon pair 
        for each gridpoint in the rectilinear grid. </span></p>
      <p class="item16"> <span class="item12bold"><strong><a name="rotation"></a>How 
        PDEF Wind Rotation Works</strong></span><br>
        <span class="plaintext">There is a third value calculated for every lat/lon 
        point, and that is the wind rotation value. With some "pre-projected" 
        or native grids, the winds are given relative to the i/j space and not 
        the lat/lon space. To insure correct interpolation, the winds must be 
        rotated to lat/lon space. This is done by determining a rotation amount 
        for each lat/lon point. When u or v wind components are displayed, the 
        values are not just interpolated but also rotated. </span></p>
      <p class="plaintext">To do the wind rotation properly, GrADS requires both 
        the u and v components. Even if you are just displaying u, GrADS has to 
        retrieve (internally) both the u and v component in order to do the rotation 
        calculation. GrADS determines how to match u and v variables by checking 
        the<em> units</em> field of the variable record in the descriptor file. 
        The u variable must have a <em>units</em> value of 33, and the v variable 
        must have a <em>units</em> value of 34. (This is the GRIB convention). 
        If there are more than one u/v pairs, secondary <em>units</em> values 
        are used. For example: 
      <ul>
        <table width="600" border="0" cellpadding="0" cellspacing="0" class="plaintext">
          <tr> 
            <td width="30">u</td>
            <td width="15" align="right">18</td>
            <td width="50" align="center"> <p>33,100</p></td>
            <td > U-Wind Components on Pressure Levels</td>
          </tr>
          <tr> 
            <td>v</td>
            <td align="right">18</td>
            <td align="center">34,100</td>
            <td> V-Wind Components on Pressure Levels</td>
          </tr>
          <tr> 
            <td>u10</td>
            <td align="right">0</td>
            <td align="center"> 33,105</td>
            <td>10 Meter U Wind</td>
          </tr>
          <tr> 
            <td>v10</td>
            <td align="right">0</td>
            <td align="center">34,105</td>
            <td>10 Meter V Wind</td>
          </tr>
        </table>
      </ul>
      <p class="plaintext">might be some variable records in the descriptor file. 
        If wind rotation is called for, u and v would be paired, and u10 and v10 
        would be paired (since the secondary values would be checked, ie, the 
        105,100 values). </p>
      <p class="item16"><span class="item12bold"><strong><a name="bilin"></a>The 
        PDEF BILIN Option</strong></span><br>
        <span class="plaintext">When a descriptor file is opened that contains 
        a PDEF record, we have explained that GrADS internally generates three 
        grids, each one the size of the rectilinear lat/lon grid. The first two 
        grids contain the i and j values (respectively) from the native grid that 
        correspond to each grid point in the rectilinear grid; the third grid 
        contains wind rotation values. But this only works for a small set of 
        well-defined native grids. GrADS will generate these three internal grids 
        automatically for polar stereographic, lamber conformal, and some eta 
        grids. If the native grid for your data is not one of the predefined projections, 
        it is still possible for GrADS to handle the data. All you have to do 
        is supply these three grids to GrADS with a supplementary data file and 
        use the bilin option in your PDEF record. </span></p>
      <p class="plaintext">The supplementary file will contains three lat-lon 
        floating-point grids sized according to the XDEF and YDEF records in the 
        descriptor file.The three grids contain: i values, j values, and wind 
        rotation values. A value of -999 in the i-value grid indicates not to 
        interpolate to that lat-lon point (will end up missing on output) and 
        a value of -999 in the wind-rotation grid indicates not to do wind rotation 
        for that point. If the wind-rotation grid is all -999 values, no rotation 
        is ever done and a flag is set not to even attempt rotation.</p>
      <p class="item16"><span class="item12bold"><strong><a name="file"></a>The 
        PDEF GENERAL Option (and the PDEF FILE option)</strong></span><br>
        <span class="plaintext">All of the PDEF examples discussed so far involve 
        the same method for grid interpolation: a grid point value in the rectilinear 
        grid is calculated by finding the four neighboring grid points in the 
        native grid and averaging them, with weights applied bi-linearly according 
        to their proximity to the to rectilinear grid point. The PDEF GENERAL option 
        and the PDEF FILE option generalize this method so that an arbitrary number of native grid point 
        values and their weights are averaged to generate the interpolated rectilinear 
        grid point values. The index values for the native grid values that are 
        to be used and their weights are specified by the user in a supplementary 
        data file (<em>fname</em>). The  FILE and GENERAL options are identical except for one detail: they have different conventions for the native grid offset values in the supplementary file (see the "Notes" in the syntax tables above for specifics). <br>
        </span></p>
      <p class="plaintext">The <em>num</em> argument in the PDEF FILE entry specifies 
        the number of native grid points that will be used to calcuate each interpolated 
        rectilinear grid point value. For each <em>num, </em>the supplementary 
        data file will contain two grids -- both will be the size of the rectilinear 
        grid (as defined by XDEF and YDEF). The first grid contains the index 
        or offset values that point to the native grid value that will be used 
        in the interpolation; the second grid contains the weights for those native 
        grid values. The first grid contains integer values, the second grid contains 
        floating-point values. Finally, the supplementary data file must also 
        contain one grid of floating-point wind rotation values. Thus if <em>num</em> 
        equals 1, there will be 3 grids in <em>fname</em>. If <em>num</em> equals 
        3, there will be 7 grids in <em>fname</em> (3 sets of 2 grids plus the 
        wind rotation grid). </p>
      <p class="plaintext">To do the grid interpolation, GrADS will first read 
        the data in the native grid (vector) along with the values in the supplementary 
        grids. To calculate the interpolated value for a particular lat-lon point, 
        GrADS will get <em>num</em> native grid point values, multiply each by 
        their weight, sum over all the weighted native grid points, and divide 
        by the sum of the weights. </p>
      <p class="plaintextbold">An Example: </p>
      <p class="plaintext">The original data are set up as a vector of land points 
        only, taken from a 1-degree lat/lon grid. There are 15238 land points 
        in the native grid (vector). We use the PDEF FILE option to repopulate 
        a rectilinear lat/lon grid with the land values, leaving the ocean grid 
        points as missing. In this case, ther eis no interpolation done. The PDEF 
        option is used simply to convert a vector of land points into a 2D grid 
        with ocean points missing. The descriptor file looks like this: 
      <ul>
        <span class="plaintext"> DSET ^gswp_vegetation_parameters.nc<br>
        DTYPE netcdf <br>
        TITLE Monthly Vegetation parameters at 1x1 degree<br>
        UNDEF 1.e+20<br>
        PDEF 15238 1 file 1 stream binary ^gswp.filepdef<br>
        XDEF 360 linear -179.5 1<br>
        YDEF 150 linear -59.5 1<br>
        ZDEF 1 linear 1 1<br>
        TDEF 204 linear 00Z01jan1982 1mo<br>
        VARS 1<br>
        NDVI=>ndvi 0 t,x Monthly vegetation index<br>
        ENDVARS</span> 
      </ul>
      <p class="plaintext">The supplementary file gtd.filepdef contains three 
        grids -- the first contains the index values that associate each location 
        in the lat/lon grid with it's point in the vector. All of the ocean points 
        will have a missing value of -999. The second grid will contain the weights, 
        which will be 1 for land points, 0 for ocean points. The third grid will 
        contain all missing values since wind rotation is not a issue in this 
        example. Here is a descriptor file for the supplementary data file (a 
        useful strategy for making sure you've got everything written out correctly):</p>
      <ul>
        <p class="plaintext">DSET ^gswp.filepdef<br>
          TITLE PDEF file for GSWP Vegetation Parameters<br>
          UNDEF -999<br>
          XDEF 360 linear -179.5 1<br>
          YDEF 150 linear -59.5 1<br>
          ZDEF 1 linear 1 1 <br>
          TDEF 1 linear 00z01jul1982 3hr<br>
          VARS 3<br>
          i 0 -1,40,4 Index Values<br>
          w 0 99 Weights<br>
          r 0 99 Wind Rotation Values<br>
          ENDVARS</p>
        <p></p>
        <p> </p>
      </ul>

</td>
  </tr>
</table>
<p class="plaintext"> </p>
</body>
</html>
\ No newline at end of file
+<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>PDEF - Displayng Pre-Projected Data in GrADS</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link href="GrADS.css" rel="stylesheet" type="text/css">
+<style type="text/css">
+<!--
+.style1 {color: #990000}
+-->
+</style>
+</head>
+
+<body bgcolor="e0f0ff">
+<p class="banner18">Use PDEF For Displaying Pre-Projected Data With GrADS</p>
+<p class="plaintext"><a href="#about">Display pre-projected data with PDEF</a><br>
+  <a href="#syntax">PDEF Syntax</a><br>
+  <a href="#interp">How grid interpolation works</a><br>
+  <a href="#rotation">How wind rotation works</a><br>
+  <a href="#bilin">PDEF BILIN option</a><br>
+  <a href="#file">PDEF GENERAL option</a><br>
+  <a href="#file">PDEF FILE option</a></p>
+<table width="650" border="0" cellspacing="0" cellpadding="0">
+  <tr>
+    <td><p class="plaintext"><a name="about" class="item12bold">Display Pre-Projected 
+        Data with PDEF</a></p>
+      <p class="plaintext">Gridded data that are mapped onto a particular map 
+        projection are called 'pre-projected.' An example of pre-projected data 
+        is the output from a weather forecast model that is mapped onto a north 
+        polar stereographic grid. </p>
+      <p class="plaintext">In order to display pre-projected data on a map in 
+        GrADS, the descriptor file must contain a PDEF entry. A descriptor file 
+        that contains a PDEF record describes two different grids. The first grid 
+        is described by the PDEF record itself and is the "native" grid 
+        for the pre-projected data in the file. The second 
+        grid described in the desctiptor file is a rectilinear lat/lon grid, which 
+        is defined by the XDEF and YDEF records. The PDEF record describes the 
+        size of the native grid, and then describes how to convert from i/j of the native grid to the lat/lon values of the rectilinear grid described by XDEF and YDEF. The information in the PDEF entry describes the 
+        projection of the grid along with the projection constants or providing 
+        the mapping to the native grid in a supplementary data file. The rectilinear grid is used 
+        by GrADS internally and can be any size or resolution -- it is completely 
+        independent of the pre-projected or native grid. GrADS uses the information 
+        about the two grids to interpolate from the PDEF-described native grid 
+        to the XDEF/ YDEF-described rectilinear grid. All displays and analyses 
+        are done using the interpolated data on the rectilinear grid. The virtue 
+        of this approach is that all built in GrADS analytic functions (e.g., 
+        <a
+href="/grads/gadoc/gradfuncaave.html">aave</a>, <a href="/grads/gadoc/gradfunchcurl.html">hcurl</a>...) 
+        will work even though the data were not originally on a lon/lat grid. 
+        The downside is that you are looking at interpolated data. </p>
+      <p class="plaintext">It is possible to view the pre-projected data on its 
+        native grid. To do this, you omit the PDEF entry from the descriptor file, 
+        and use the XDEF and YDEF entries to describe the shape of the native 
+        grid. In this case, your displays must be drawn in i/j space without a 
+        map projection (<a href="/grads/gadoc/gradcomdsetmpdraw.html">set mpdraw</a> 
+        off). </p>
+      <p class="plaintext">When you do a <a
+href="/grads/gadoc/gradcomddisplay.html">display</a> of a pre-projected vector 
+        field, you must know whether the original vector components are defined 
+        relative to the data grid or relative to the Earth. If the data are grid-relative, 
+        they must be rotated to Earth-relative coordinates in order for the interpolation 
+        to work properly. See the "Notes" under each particular projection 
+        type for further information.</p>
+      <p class="item12bold"><a name="syntax"></a>PDEF Syntax</p>
+      <ul>
+        <table width="600" border="0" cellpadding="0" cellspacing="4" class="plaintext">
+          <tr bgcolor="#CCCCCC"> 
+            <td colspan="3"> <strong>PDEF <em>isize jsize</em> NPS<em> ipole jpole 
+              lonref gridinc</em><br>
+              PDEF <em>isize jsize</em> SPS<em> ipole jpole lonref gridinc</em></strong></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td width="50" align="right">Example:</td>
+            <td colspan="2">PDEF 53 45 nps 27 49 -105 190.5</td>
+          </tr>
+          <tr bgcolor="b8c8d7"> 
+            <td align="right" valign="top">Args: </td>
+            <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                <tr class="plaintext"> 
+                  <td width="60" valign="top"><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>ipole</em></td>
+                  <td>the i coordinate of the pole referenced from the lower left 
+                    corner, assumed to be at (1,1)</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>jpole</em></td>
+                  <td>the j coordinate of the pole referenced from the lower left 
+                    corner, assumed to be at (1,1)</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>lonref</em></td>
+                  <td>reference longitude</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>gridinc</em></td>
+                  <td>distance between gripoints in km</td>
+                </tr>
+              </table></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Notes: </td>
+            <td colspan="2">Polar stereographic projections (N and S) are defined 
+              as at NCEP. Wind rotation has also been added so that vector data 
+              will be properly displayed. </td>
+          </tr>
+          <tr> 
+            <td> </td>
+            <td colspan="2"> </td>
+          </tr>
+          <tr bgcolor="#CCCCCC"> 
+            <td colspan="3"><strong>PDEF <em>isize jsize</em> LCCR <em>latref 
+              lonref iref jref Struelat Ntruelat slon dx dy<br>
+              </em>PDEF <em>isize jsize</em> LCC <em>latref lonref iref jref Struelat 
+              Ntruelat slon dx dy</em><em> </em></strong></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right">Example:</td>
+            <td colspan="2">PDEF 103 69 lccr 30 -88 51.5 34.5 20 40 -88 90000 
+              90000</td>
+          </tr>
+          <tr bgcolor="b8c8d7"> 
+            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
+            <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                <tr class="plaintext"> 
+                  <td width="60" valign="top"><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>latref</em></td>
+                  <td>reference latitude</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>lonref</em></td>
+                  <td>reference longitude (in degrees, E is positive, W is negative)                  </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>iref</em></td>
+                  <td>i of ref point </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>jref</em></td>
+                  <td>j of ref point </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>Struelat</em></td>
+                  <td>S true lat </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>Ntruelat</em></td>
+                  <td>N true lat </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>slon</em></td>
+                  <td>standard longitude</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>dx</em></td>
+                  <td>grid X increment in meters</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>dy</em></td>
+                  <td>grid Y increment in meters</td>
+                </tr>
+              </table></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top" bgcolor="ccdceb">Notes: </td>
+            <td colspan="2">Starting with version 1.9b4, the LCCR option supplements 
+              the use of PDEF with data on the Lambert Conformal projection. With 
+              LCCR, wind rotation has been implemented for data files with grid-relative 
+              winds instead of Earth-relative winds. Use LCC if your vector components 
+              are already Earth-relative. </td>
+          </tr>
+          <tr> 
+            <td> </td>
+            <td width="9%"> </td>
+            <td width="82%"> </td>
+          </tr>
+          <tr bgcolor="#CCCCCC"> 
+            <td colspan="3"><strong>PDEF <em>isize jsize </em>ETA.U<em> lonref 
+              latref dlon dlat</em></strong></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right">Example:</td>
+            <td colspan="2">PDEF 181 136 eta.u -97.0 41.0 0.38888888 0.37</td>
+          </tr>
+          <tr> 
+            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
+            <td colspan="2" bgcolor="b8c8d7"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                <tr class="plaintext"> 
+                  <td width="60" valign="top"><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">lonref</td>
+                  <td>reference longitude (in degrees, E is positive, W is negative)                  </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">latref</td>
+                  <td>reference latitude</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">dlon</td>
+                  <td>grid longitude increment in degrees</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">dlat</td>
+                  <td>grid latitude increment in degrees</td>
+                </tr>
+              </table></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Notes: </td>
+            <td colspan="2">The eta model native grid is awkward to work with 
+              because the variables are on staggered <i>and</i> non-rectangular 
+              grids. NCEP created "unstaggered" eta model fields, in which the 
+              variables are placed on a common rectangular grid. Wind rotation 
+              has also been added so that vector data will be properly displayed.            </td>
+          </tr>
+          <tr> 
+            <td> </td>
+            <td> </td>
+            <td> </td>
+          </tr>
+          <tr bgcolor="#CCCCCC"> 
+            <td colspan="3"><strong>PDEF <em>isize jsize</em> PSE <em>slat slon 
+              ipole jpole dx dy sign</em></strong></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Example:</td>
+            <td colspan="2"> </td>
+          </tr>
+          <tr bgcolor="b8c8d7"> 
+            <td align="right" valign="top">Args: </td>
+            <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
+                <tr class="plaintext"> 
+                  <td width="60" valign="top"><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top"><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">slat</td>
+                  <td>absolute value of the standard latitude </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">slon</td>
+                  <td>absolute value of the standard longitude</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">ipole</td>
+                  <td>the i coordinate of the pole referenced from the lower left 
+                    corner, assumed to be at (0,0)</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">jpole</td>
+                  <td>the j coordinate of the pole referenced from the lower left 
+                    corner, assumed to be at (0,0)</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">dx</td>
+                  <td>grid X increment in km</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">dy</td>
+                  <td>grid Y increment in km</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td valign="top">sign</td>
+                  <td>1 for NH; -1 for SH</td>
+                </tr>
+              </table></td>
+          </tr>
+          <tr> 
+            <td align="right" valign="top" bgcolor="ccdceb">Notes: </td>
+            <td colspan="2" bgcolor="ccdceb">The polar stereo projection used 
+              by the original NMC models is not very precise because it assumes 
+              the earth is round (eccentricity = 0). While this approximation 
+              was reasonable for coarse resolution NWP models, it is inadequate 
+              to work with higher resolution data such as SSM/I. <i>Wind rotation 
+              has not been implemented!!! Use only for scalar fields.</i></td>
+          </tr>
+          <tr> 
+            <td> </td>
+            <td> </td>
+            <td> </td>
+          </tr>
+          <tr bgcolor="#CCCCCC"> 
+            <td colspan="3"><strong>PDEF <em>isize jsize</em> OPS <em> latref 
+              lonref xoff yoff iref jref dx dy </em></strong></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right">Example:</td>
+            <td colspan="2">PDEF 26 16 ops 40.0 -100.0 90000.0 90000.0 14.0 9.0 
+              180000.0 180000.0 </td>
+          </tr>
+          <tr bgcolor="b8c8d7"> 
+            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
+            <td colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
+                <tr class="plaintext"> 
+                  <td width="60"><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>latref</td>
+                  <td>reference latitude</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>lonref</td>
+                  <td>reference longitude (in degrees, E is positive, W is negative)                  </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>xoff</td>
+                  <td>lonref offset in meters</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>yoff</td>
+                  <td>latref offset in meters</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>iref</td>
+                  <td>the i coordinate of the reference point</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>jref</td>
+                  <td>the j coordinate of the reference point</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>dx</td>
+                  <td>grid X increment in km</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>dy</td>
+                  <td>grid Y increment in km</td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td>dy</td>
+                  <td>grid Y increment in km</td>
+                </tr>
+              </table></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Notes: </td>
+            <td colspan="2">The CSU RAMS model uses an oblique polar stereo projection. 
+              <i>Wind rotation has not been implemented!!! Use only for scalar 
+              fields.</i></td>
+          </tr>
+          <tr bgcolor="ccdceb">
+            <td align="right" valign="top" bgcolor="#FFFFFF"> </td>
+            <td colspan="2" bgcolor="#FFFFFF"> </td>
+          </tr>
+          <tr bgcolor="#CCCCCC">
+            <td colspan="3"><strong>PDEF <em>isize jsize</em> ROTLL<em> lonpol latpol dlon dlat lonll latll <br>
+            </em>PDEF <em>isize jsize</em> ROTLLR<em> lonpol latpol dlon dlat lonll latll </em></strong></td>
+          </tr>
+          <tr bgcolor="#CCCCCC"></tr>
+          <tr bgcolor="ccdceb">
+            <td align="right">Example:</td>
+            <td colspan="2">PDEF 500 330 rotllr -170.0  43.0   0.02   0.02  -5.5 -3.8</td>
+          </tr>
+          <tr bgcolor="b8c8d7">
+            <td align="right" valign="top" bgcolor="b8c8d7">Args: </td>
+            <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
+                <tr class="plaintext">
+                  <td width="60"><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr class="plaintext">
+                  <td><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr class="plaintext">
+                  <td>lonpol</td>
+                  <td>Longitude of the rotated pole in degrees</td>
+                </tr>
+                <tr class="plaintext">
+                  <td>latpol</td>
+                  <td>Latitude of the rotated pole in degrees</td>
+                </tr>
+                <tr class="plaintext">
+                  <td>dlon</td>
+                  <td>grid spacing in longitudinal direction of the rotated grid in degrees</td>
+                </tr>
+                <tr class="plaintext">
+                  <td>dlat</td>
+                  <td>grid spacing in latitudinal direction of the rotated grid in degrees</td>
+                </tr>
+                <tr class="plaintext">
+                  <td>lonll</td>
+                  <td>longitude of the lower left corner, given in rotated space in degree</td>
+                </tr>
+                <tr class="plaintext">
+                  <td>latll</td>
+                  <td>latitude of the lower left corner, given in rotated space in degree</td>
+                </tr>
+
+            </table></td>
+          </tr>
+          <tr bgcolor="ccdceb">
+            <td align="right" valign="top">Notes: </td>
+            <td colspan="2" bgcolor="ccdceb"><p>(<font color="#990000">GrADS version 2.0</font>) The rotated lat/lon grid projection is described in the  <a href="http://www.cosmo-model.org/content/model/documentation/core/cosmo_userguide_5.04.pdf" target="_blank">COSMO documentation</a>, Chapter 3.3. The lower left corner, i.e. the first element in the data array, has to be the southwest corner.  It is  not possible to use a mirrored grid by setting dlon or dlat to a negative value.</p> [...]
+          </tr>
+          
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top" bgcolor="#FFFFFF"> </td>
+            <td colspan="2" bgcolor="#FFFFFF"> </td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td colspan="3" align="left" valign="top" bgcolor="#CCCCCC"> <p><strong>PDEF<em> 
+                isize jsi</em>ze BILIN <em>format byteorder fname</em></strong></p></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Example:</td>
+            <td colspan="2">PDEF 100 100 BILIN sequential binary-big ^mygrid.interp.values            </td>
+          </tr>
+          <tr bgcolor="b8c8d7"> 
+            <td align="right" valign="top" bgcolor="b8c8d7">Args:</td>
+            <td colspan="2"> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
+                <tr class="plaintext"> 
+                  <td width="60"><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr class="plaintext"> 
+                  <td><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr> 
+                  <td><em>format</em></td>
+                  <td>Must be either STREAM (direct access) or SEQENTIAL (fortran 
+                    formatted)</td>
+                </tr>
+                <tr> 
+                  <td valign="top"><em>byteorder</em></td>
+                  <td>If set to BINARY, byte odering is assumed to be same as 
+                    local machine<br>
+                    If set to BINARY-BIG, byte ordering is assumed to be big-endian<br>
+                    If set to BINARY-LITTLE, byte ordering is assumed to be little-endian</td>
+                </tr>
+                <tr> 
+                  <td valign="top"><em>fname</em></td>
+                  <td>The name of the supplementary file </td>
+                </tr>
+              </table></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Notes:</td>
+            <td colspan="2">The supplementary file contains three lat-lon floating-point 
+              grids: i values, j values, and wind rotation values. The native grid  is assumed to have a corner (i,j) value of (1,1). The size of 
+              these grids must match the XDEF and YDEF entries in the descriptor 
+              file. </td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top" bgcolor="#FFFFFF"> </td>
+            <td colspan="2" bgcolor="#FFFFFF"> </td>
+          </tr>
+          <tr align="left" bgcolor="#CCCCCC">
+            <td colspan="3" valign="top"><strong>PDEF<em> isize jsize</em> GENERAL <em>num 
+              format byteorder fname</em></strong></td>
+          </tr>
+          <tr bgcolor="ccdceb">
+            <td align="right" valign="top">Example:</td>
+            <td colspan="2">PDEF 182 149  general 4 sequential binary-big ^mygrid.interp.values<br>
+              PDEF 15238 1 general 1 stream binary ^gtd.filepdef</td>
+          </tr>
+          <tr bgcolor="b8c8d7">
+            <td align="right" valign="top">Args:</td>
+            <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
+                <tr>
+                  <td><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr>
+                  <td><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                <tr>
+                  <td width="60"><em>num</em></td>
+                  <td>number of sets of interpolation grids supplied</td>
+                </tr>
+                <tr>
+                  <td><em>format</em></td>
+                  <td>Must be either STREAM (direct access) or SEQENTIAL (fortran 
+                    formatted)</td>
+                </tr>
+                <tr>
+                  <td valign="top"><em>byteorder</em></td>
+                  <td>If set to BINARY, byte odering is assumed to be same as 
+                    local machine<br>
+                    If set to BINARY-BIG, byte ordering is assumed to be big-endian<br>
+                    If set to BINARY-LITTLE, byte ordering is assumed to be little-endian</td>
+                </tr>
+                <tr>
+                  <td valign="top"><em>fname</em></td>
+                  <td>The name of the supplementary file; it may be mixed case. </td>
+                </tr>
+            </table></td>
+          </tr>
+          <tr bgcolor="ccdceb">
+            <td align="right" valign="top" bgcolor="ccdceb">Notes:</td>
+            <td colspan="2" bgcolor="ccdceb"><p>(<span class="style1">GrADS version 2.0.a3 and later</span>) The syntax and behavior of PDEF GENERAL is exactly like PDEF FILE, except that the convention for the native grid offset values in the pdef file is the same for all data formats. The offsets should be 1-based; the first grid point is assumed to have (i,j) values of (1,1), and  valid offset values are > 0 and <= <em>isize</em>*<em>jsize</em> .</p>
+              <p>Native grid offset values of -999 indicate not to use 
+        an input point for that portion of the calculation (thus you can apply 
+        less than the "<em>num</em>" number of interpolation points for some 
+        of the points). </p>
+              <p>See additional notes in the paragraphs below.</p></td>
+          </tr>
+          <tr align="left" bgcolor="#CCCCCC">
+            <td colspan="3" valign="top" bgcolor="#FFFFFF"> </td>
+          </tr>
+          
+          <tr align="left" bgcolor="#CCCCCC"> 
+            <td colspan="3" valign="top"><strong>PDEF<em> isize jsize</em> FILE <em>num 
+              format byteorder fname</em></strong></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Example:</td>
+            <td colspan="2">PDEF 182 149 file 4 sequential binary-big ^mygrid.interp.values<br>
+              PDEF 15238 1 file 1 stream binary ^gtd.filepdef</td>
+          </tr>
+          <tr bgcolor="b8c8d7"> 
+            <td align="right" valign="top">Args:</td>
+            <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="plaintext">
+                <tr>
+                  <td><em>isize</em></td>
+                  <td>The size of the native grid in the x direction </td>
+                </tr>
+                <tr>
+                  <td><em>jsize</em></td>
+                  <td>The size of the native grid in the y direction </td>
+                </tr>
+                
+                <tr> 
+                  <td width="60"><em>num</em></td>
+                  <td>number of sets of interpolation grids supplied</td>
+                </tr>
+                <tr> 
+                  <td><em>format</em></td>
+                  <td>Must be either STREAM (direct access) or SEQENTIAL (fortran 
+                    formatted)</td>
+                </tr>
+                <tr> 
+                  <td valign="top"><em>byteorder</em></td>
+                  <td>If set to BINARY, byte odering is assumed to be same as 
+                    local machine<br>
+                    If set to BINARY-BIG, byte ordering is assumed to be big-endian<br>
+                    If set to BINARY-LITTLE, byte ordering is assumed to be little-endian</td>
+                </tr>
+                <tr> 
+                  <td valign="top"><em>fname</em></td>
+                  <td>The name of the supplementary file; it may be mixed case.                  </td>
+                </tr>
+              </table></td>
+          </tr>
+          <tr bgcolor="ccdceb"> 
+            <td align="right" valign="top">Notes:</td>
+            <td colspan="2" bgcolor="ccdceb"><p>For GrADS v2.0.a2 and earlier, <em>jsize</em> was fixed to be 1, and <em>isize</em> was the size of the native grid expressed as a vector (i.e., all gridpoints in the x-y grid). This mode for describing the native grid will continue to work with v2.0.a3+, but only if the native grid is in GRIB or binary format. For NetCDF and HDF formats, the <em>isize</em> and <em>jsize</em> args must match the X and Y dimensions of the native grid. </p>
+            <p><span class="style1">WARNING: The use of PDEF FILE may be incorrect!</span> A long-standing bug and incomplete documentation has led to different conventions for the native grid offset values in the pdef file for GRIB and non-GRIB data formats. For GRIB (1&2), the offsets must be 0-based; the first grid point is assumed to have (i,j) values of (0,0). For all other data types, the offsets must be 1-based; the first grid point is assumed to have (i,j) values of (1,1). Thus:<br>
+                   for GRIB format: valid offset values are >= 0 and < <em>isize</em>*<em>jsize</em><br>
+                   for other formats: valid offset values are > 0 and <= <em>isize</em>*<em>jsize</em><br>
+              To maintain backward compatibility, the bug will remain in GrADS as a feature, but the use of PDEF FILE has been deprecated as of version 2.0.a3 and a warning message will be displayed when a data set is opened that uses PDEF FILE. Note that if you use <a href="http://www.cpc.ncep.noaa.gov/products/wesley/grib2ctl.html">grib2ctl</a> or <a href="http://www.cpc.ncep.noaa.gov/products/wesley/g2ctl.html">g2ctl </a>to generate your pdef file, the offsets are correct. </p>
+            <p>Native grid offset values of -999 indicate not to use 
+        an input point for that portion of the calculation (thus you can apply 
+        less than the "<em>num</em>" number of interpolation points for some 
+        of the points). </p>
+            <p>See additional notes in the paragraphs below.</p></td>
+          </tr>
+        </table>
+      </ul>
+      <p class="item16"> <span class="item12bold"><strong><a name="interp"></a>How 
+        PDEF Grid Interpolation Works</strong></span><br>
+        <span class="plaintext">To illustrate how the data is interpolated from 
+        the native grid to the rectilinear grid, let's consider an example. Here 
+        are a set of relevant records from a descriptor file: <br>
+        PDEF 100 100 nps ...<br>
+        XDEF 181 linear -180 1<br>
+        YDEF 90 linear 0 1<br>
+        These three entries describe data on a native 100x100 North Polar stereographic 
+        projection and a rectilinear lat/lon grid that is 181 by 90 and has an 
+        interval of 1 degree in both lat and lon. Consider one point within the 
+        rectilinear grid, the point -90,40. GrADS calls an internal routine to 
+        calculate the i and j values in the native grid that correspond to this 
+        lat/lon point. Let's say we get i,j values of 31.24 and 67.88. To do the 
+        interpolation to the lat/lon point -90,40, GrADS uses the data values 
+        from the following four native grid points: 31,67 - 31,68 - 32,67 - 32,68. 
+        Bi-linear interpolation is used within this grid box to get down to the 
+        position 31.24,67.88. The interpolation is linear within the i,j grid. 
+        When a descriptor file is opened that contains a PDEF record, GrADS calculates 
+        the i/j values in the native grid that correspond to the lat/lon pair 
+        for each gridpoint in the rectilinear grid. </span></p>
+      <p class="item16"> <span class="item12bold"><strong><a name="rotation"></a>How 
+        PDEF Wind Rotation Works</strong></span><br>
+        <span class="plaintext">There is a third value calculated for every lat/lon 
+        point, and that is the wind rotation value. With some "pre-projected" 
+        or native grids, the winds are given relative to the i/j space and not 
+        the lat/lon space. To insure correct interpolation, the winds must be 
+        rotated to lat/lon space. This is done by determining a rotation amount 
+        for each lat/lon point. When u or v wind components are displayed, the 
+        values are not just interpolated but also rotated. </span></p>
+      <p class="plaintext">To do the wind rotation properly, GrADS requires both 
+        the u and v components. Even if you are just displaying u, GrADS has to 
+        retrieve (internally) both the u and v component in order to do the rotation 
+        calculation. GrADS determines how to match u and v variables by checking 
+        the<em> units</em> field of the variable record in the descriptor file. 
+        The u variable must have a <em>units</em> value of 33, and the v variable 
+        must have a <em>units</em> value of 34. (This is the GRIB convention). 
+        If there are more than one u/v pairs, secondary <em>units</em> values 
+        are used. For example: 
+      <ul>
+        <table width="600" border="0" cellpadding="0" cellspacing="0" class="plaintext">
+          <tr> 
+            <td width="30">u</td>
+            <td width="15" align="right">18</td>
+            <td width="50" align="center"> <p>33,100</p></td>
+            <td > U-Wind Components on Pressure Levels</td>
+          </tr>
+          <tr> 
+            <td>v</td>
+            <td align="right">18</td>
+            <td align="center">34,100</td>
+            <td> V-Wind Components on Pressure Levels</td>
+          </tr>
+          <tr> 
+            <td>u10</td>
+            <td align="right">0</td>
+            <td align="center"> 33,105</td>
+            <td>10 Meter U Wind</td>
+          </tr>
+          <tr> 
+            <td>v10</td>
+            <td align="right">0</td>
+            <td align="center">34,105</td>
+            <td>10 Meter V Wind</td>
+          </tr>
+        </table>
+      </ul>
+      <p class="plaintext">might be some variable records in the descriptor file. 
+        If wind rotation is called for, u and v would be paired, and u10 and v10 
+        would be paired (since the secondary values would be checked, ie, the 
+        105,100 values). </p>
+      <p class="item16"><span class="item12bold"><strong><a name="bilin"></a>The 
+        PDEF BILIN Option</strong></span><br>
+        <span class="plaintext">When a descriptor file is opened that contains 
+        a PDEF record, we have explained that GrADS internally generates three 
+        grids, each one the size of the rectilinear lat/lon grid. The first two 
+        grids contain the i and j values (respectively) from the native grid that 
+        correspond to each grid point in the rectilinear grid; the third grid 
+        contains wind rotation values. But this only works for a small set of 
+        well-defined native grids. GrADS will generate these three internal grids 
+        automatically for polar stereographic, lamber conformal, and some eta 
+        grids. If the native grid for your data is not one of the predefined projections, 
+        it is still possible for GrADS to handle the data. All you have to do 
+        is supply these three grids to GrADS with a supplementary data file and 
+        use the bilin option in your PDEF record. </span></p>
+      <p class="plaintext">The supplementary file will contains three lat-lon 
+        floating-point grids sized according to the XDEF and YDEF records in the 
+        descriptor file.The three grids contain: i values, j values, and wind 
+        rotation values. A value of -999 in the i-value grid indicates not to 
+        interpolate to that lat-lon point (will end up missing on output) and 
+        a value of -999 in the wind-rotation grid indicates not to do wind rotation 
+        for that point. If the wind-rotation grid is all -999 values, no rotation 
+        is ever done and a flag is set not to even attempt rotation.</p>
+      <p class="item16"><span class="item12bold"><strong><a name="file"></a>The 
+        PDEF GENERAL Option (and the PDEF FILE option)</strong></span><br>
+        <span class="plaintext">All of the PDEF examples discussed so far involve 
+        the same method for grid interpolation: a grid point value in the rectilinear 
+        grid is calculated by finding the four neighboring grid points in the 
+        native grid and averaging them, with weights applied bi-linearly according 
+        to their proximity to the to rectilinear grid point. The PDEF GENERAL option 
+        and the PDEF FILE option generalize this method so that an arbitrary number of native grid point 
+        values and their weights are averaged to generate the interpolated rectilinear 
+        grid point values. The index values for the native grid values that are 
+        to be used and their weights are specified by the user in a supplementary 
+        data file (<em>fname</em>). The  FILE and GENERAL options are identical except for one detail: they have different conventions for the native grid offset values in the supplementary file (see the "Notes" in the syntax tables above for specifics). <br>
+        </span></p>
+      <p class="plaintext">The <em>num</em> argument in the PDEF FILE entry specifies 
+        the number of native grid points that will be used to calcuate each interpolated 
+        rectilinear grid point value. For each <em>num, </em>the supplementary 
+        data file will contain two grids -- both will be the size of the rectilinear 
+        grid (as defined by XDEF and YDEF). The first grid contains the index 
+        or offset values that point to the native grid value that will be used 
+        in the interpolation; the second grid contains the weights for those native 
+        grid values. The first grid contains integer values, the second grid contains 
+        floating-point values. Finally, the supplementary data file must also 
+        contain one grid of floating-point wind rotation values. Thus if <em>num</em> 
+        equals 1, there will be 3 grids in <em>fname</em>. If <em>num</em> equals 
+        3, there will be 7 grids in <em>fname</em> (3 sets of 2 grids plus the 
+        wind rotation grid). </p>
+      <p class="plaintext">To do the grid interpolation, GrADS will first read 
+        the data in the native grid (vector) along with the values in the supplementary 
+        grids. To calculate the interpolated value for a particular lat-lon point, 
+        GrADS will get <em>num</em> native grid point values, multiply each by 
+        their weight, sum over all the weighted native grid points, and divide 
+        by the sum of the weights. </p>
+      <p class="plaintextbold">An Example: </p>
+      <p class="plaintext">The original data are set up as a vector of land points 
+        only, taken from a 1-degree lat/lon grid. There are 15238 land points 
+        in the native grid (vector). We use the PDEF FILE option to repopulate 
+        a rectilinear lat/lon grid with the land values, leaving the ocean grid 
+        points as missing. In this case, ther eis no interpolation done. The PDEF 
+        option is used simply to convert a vector of land points into a 2D grid 
+        with ocean points missing. The descriptor file looks like this: 
+      <ul>
+        <span class="plaintext"> DSET ^gswp_vegetation_parameters.nc<br>
+        DTYPE netcdf <br>
+        TITLE Monthly Vegetation parameters at 1x1 degree<br>
+        UNDEF 1.e+20<br>
+        PDEF 15238 1 file 1 stream binary ^gswp.filepdef<br>
+        XDEF 360 linear -179.5 1<br>
+        YDEF 150 linear -59.5 1<br>
+        ZDEF 1 linear 1 1<br>
+        TDEF 204 linear 00Z01jan1982 1mo<br>
+        VARS 1<br>
+        NDVI=>ndvi 0 t,x Monthly vegetation index<br>
+        ENDVARS</span> 
+      </ul>
+      <p class="plaintext">The supplementary file gtd.filepdef contains three 
+        grids -- the first contains the index values that associate each location 
+        in the lat/lon grid with it's point in the vector. All of the ocean points 
+        will have a missing value of -999. The second grid will contain the weights, 
+        which will be 1 for land points, 0 for ocean points. The third grid will 
+        contain all missing values since wind rotation is not a issue in this 
+        example. Here is a descriptor file for the supplementary data file (a 
+        useful strategy for making sure you've got everything written out correctly):</p>
+      <ul>
+        <p class="plaintext">DSET ^gswp.filepdef<br>
+          TITLE PDEF file for GSWP Vegetation Parameters<br>
+          UNDEF -999<br>
+          XDEF 360 linear -179.5 1<br>
+          YDEF 150 linear -59.5 1<br>
+          ZDEF 1 linear 1 1 <br>
+          TDEF 1 linear 00z01jul1982 3hr<br>
+          VARS 3<br>
+          i 0 -1,40,4 Index Values<br>
+          w 0 99 Weights<br>
+          r 0 99 Wind Rotation Values<br>
+          ENDVARS</p>
+        <p></p>
+        <p> </p>
+      </ul>
+
+</td>
+  </tr>
+</table>
+<p class="plaintext"> </p>
+</body>
+</html>
diff --git a/doc/script.html b/doc/script.html
index a0f83ff..be851dc 100644
--- a/doc/script.html
+++ b/doc/script.html
@@ -24,7 +24,7 @@
       <a href="#functions">Functions</a><br>
       <a href="#intrinsic">Intrinsic Functions</a><br>
 <a href="#commands">Commands that complement the scripting language</a><br>
-<a href="#widgets">Widgets</a> (N.B. The widgets have been temporarily disabled for <span class="red">version 2.1.a1</span>) <br>
+<a href="#widgets">Widgets</a> (N.B. The widgets have been temporarily disabled as of <span class="red">version 2.1.a1</span>) <br>
 <a href="library.html">Script Library</a><br>
 <a href="reference_card_scl.pdf">Scripting Language Reference Card</a>
 <font size=-1>
@@ -773,7 +773,7 @@ Repeated calls must be made to read consecutive records. The result is
 a string containing two lines: the first line is the return code, the 
 2nd line is the record read from the file. The record may be a maximum 
 of 80 characters. Use the <code>sublin</code> function to separate the
-result. Return codes are:<br>
+result. Return codes are:
 
 <ul>
 <code>0 - </code>ok <br>
@@ -781,6 +781,7 @@ result. Return codes are:<br>
 <code>2 - </code>end of file <br>
 <code>8 - </code>file open for write <br>
 <code>9 - </code>I/O error<br>
+<br>
 </ul>
 
 Files are opened when the first call to read is made for a 
@@ -796,7 +797,7 @@ This functions writes records to output file <code>filename</code>.
 On the first call to write for a particular file, the file is opened
 in write mode.  This will destroy an existing file!  If you use the
 optional append flag, the file will be opened in append mode, and all
-writes will be appended to the end of the file.  Return codes are:<br>
+writes will be appended to the end of the file.  Return codes are:
 <ul>
 <code>0</code> - ok <br>
 <code>1</code> - open error <br>
@@ -805,15 +806,41 @@ writes will be appended to the end of the file.  Return codes are:<br>
 <p>
 <b><code>close (<i>name</i>)</code></b>
 <br>
-
 This function closes the named file.  This must be done if you wish to
 read from a file you have been writing to.  This can also be used to
-rewind a file.  Return codes are:<br>
+rewind a file.  Return codes are:
 <ul>
 <code>0</code> - ok <br>
-<code>1</code> - file not open</ul><p>
+<code>1</code> - file not open</ul>
+<p><b><code>sys (<i>command</i>)</code></b><br>
+  This function was added in <span class="red">version 2.1.1.b0. </span> It  submits the specified command to the shell and returns the resulting text stream that gets sent to standard output (stdout). The  command is passed to /bin/sh. There is no way to check if the command succeeded; the return code is not captured, and an empty result could mean that the command has no output or that the command failed. Any error notifications or text streams sent to standard error (stderr) will appe [...]
+<p>Consider the following script test_sys.gs: 
+<ul><code>
+  cmd1="ls ./foo"<br>
+  cmd2="ls ./foo 2>&1"<br>
+  cmd3='echo Hello, world!'<br>
+  res1=sys(cmd1); say 'cmd1 returned ->'res1'<-'<br>
+  res2=sys(cmd2); say 'cmd2 returned ->'res2'<-'<br>
+  res3=sys(cmd3); say 'cmd3 returned ->'res3'<-'<br>
+  <br>
+</code></ul>
+The session in the GrADS command window when running test_sys.gs looks like this:<br>
+<br>
+<ul>
+<code>
+  ga-> test_sys<br>    
+ls: ./foo: No such file or directory<br>
+cmd1 returned -><-<br>
+cmd2 returned ->ls: ./foo: No such file or directory<br>
+<-<br>
+cmd3 returned ->Hello, world!<br>
+<-<br>
+ga-> <br>
+</code></ul>
+</p>
 </ul>
 
+
 <h2><a name="commands"><u>Commands that complement the scripting language</u></a></h2>
 <p>
 There are some GrADS commands that, although not designed
@@ -835,6 +862,10 @@ options that are most useful for script applications follows.
 Lists all defined variables
 
 <p>
+<b><code><a href="gradcomdquery.html">q</a> define <i>varname</i></code></b> --
+(Added in <span class="red">version 2.1.1b0</span>) Lists information about a specific defined variable: grid dimensions, coordinate axis definitions, calendar type, and whether it has been modified to be a climatological variable. 
+
+<p>
 <b><code><a href="gradcomdquery.html">q</a> defval <i>ival
 jval</i></code></b> -- Gives defined grid value at <i>ival, jval</i>
 <p>
@@ -844,7 +875,7 @@ can be used in conjunction with <code><a
 href="gradcomdsetdefval.html">set defval</a></code>. For example, the
 code shown below queries the value of sst at gridpoint(i,j), then
 tests to see if the value is less than -1.6, and if it is, sets the
-sst to a bad value.<p>
+sst to a bad value.
 <ul>
 <code>
 'q defval sst 'i' 'j <br>
diff --git a/doc/udp.html b/doc/udp.html
new file mode 100644
index 0000000..ebd8ac0
--- /dev/null
+++ b/doc/udp.html
@@ -0,0 +1,105 @@
+<!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->
+
+<html>
+<head>
+<title>GrADS User Defined Plug-ins</title>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<link href="GrADS.css" rel="stylesheet" type="text/css">
+<style type="text/css">
+.red {
+	color: #C00;
+}
+body {
+	background-color: #e0f0ff;
+}
+</style>
+</head>
+<body text="#000000">
+
+<h2>User Defined Plug-ins (UDPs)</h2>
+<p>
+
+<a href="#overview">Overview </a><br>
+<a href="#how">How to set up and use User Defined Plug-ins</a><br>
+<a href="#compile">How to compile User Defined Plug-ins</a><br>
+<a href="#table">The User Defined Plug-in Table</a><br>
+<a href="#gaudpt">The environment variable GAUDPT</a><br>
+<a href="#example1">Example: Add a number to a variable</a><br><br>
+<hr>
+  
+<a name="overview"><h3>Overview</h3></a>
+<p>User Defined Plug-ins were introduced in <span class="red">version 2.1.1.b0</span> and are intended to replace the old <a href="udf.html">User Defined Functions</a>, which were disabled when version 2.0 was introduced. The function arguments and data grids are no longer passed between GrADS and the user's program through data files written out to disk. With plug-ins, the user's code is dynamically loaded into GrADS when invoked by the user, and the data is operated on while still sitt [...]
+
+<a name="how">
+<h3>How to set up and use User Defined Plug-ins:</h3></a>
+<ol>
+<li>Compile your plug-in functions  as shared object files. (Scroll down for <a href="#compile">additional documention</a>.)
+<li>Update a stand-alone text file called the User Defined Plug-in Table (UDPT) that  provides all the necessary information GrADS needs to know about 
+  the plug-ins. 
+(Scroll down for <a href="#table">additional documention.</a>)
+<li>Set the environment variable GAUDPT  to provide the full name (including the path) of the UDPT file. 
+<li>When GrADS is first started up, it will parse the UDPT file so it knows all the plug-in function names and where to find them. The plug-ins  will be loaded dynamically by GrADS only when the function is called by the user. <br>
+<li>When a plug-in function is invoked in an <a href="expressions.html">expression</a>, GrADS passes all the function arguments as-is to the plug-in.  The arguments to a plug-in generally contain one or more GrADS expressions plus any additional numbers or strings that might be needed. The plug-in should contain the necessary code to parse and check the arguments, evaluate the expressions(s), perform the calculations, print out any desired diagnostic information, and return the result ba [...]
+<li>Note: User defined plug-ins do <em>NOT</em> have precedence over GrADS intrinsic
+functions, thus a UDP cannot be set up to replace
+a GrADS function. This behavior is different from the old user defined functions. 
+
+</ol>
+
+<a name="compile"><h3>How to compile User Defined Plug-ins:</h3></a>
+<p> User Defined Plug-ins are compiled as dynamic libraries or shared object files and are loaded by GrADS using the dlopen(), dlsym(), and dlclose() functions. Compiling these dynamic object files is a two-step process that requires a slightly different syntax than what is normally used to compile a stand-alone executable. Consider an example plug-in program called addthis.c:
+<p>Compile the 
+  plug-in source code (<code><a href="addthis.c">addthis.c</a></code>) and create the object file.
+<ol>
+<li>
+  <pre>  gcc -fPIC -Wall -g -c addthis.c </pre>
+<p>Note that this program requies the inclusion of <code>grads.h</code>, which is part of the GrADS source code. Use the environment variable CFLAGS to specify the directory where <code>grads.h</code> resides (e.g. $HOME/grads/src/grads.h):</p>
+<pre>  setenv CFLAGS -I$HOME/grads/src
+  gcc -fPIC -Wall -g -c addthis.c $CFLAGS</pre>
+<p>If you get an error message that the compiler cannot find additional include files such as <code>shapefil.h</code>, then try adding the supplibs include directory where the file is located to the <code>CFLAGS</code> environment variable, or use the -D option to disable the USESHP macro:</p>
+<pre>  gcc -fPIC -Wall -g -c addthis.c $CFLAGS -DUSESHP=0</pre>
+</li>
+
+<li>Once you have compiled the program and successfully created the object file <code>addthis.o</code>, you must create the dynamic library/shared object file that will be loaded  by GrADS. More  ```` than one object file can be packaged in a dynamic library/shared object file. The synatx for this step is different for Linux systems and for Mac OS X:
+  <p>
+  For Linux:
+  <pre>  gcc -fPIC -g -shared -rdynamic addthis.o -o addthis.so </pre>
+  <p>For Mac OS X:
+  <pre>  libtool -dynamic -flat_namespace -undefined suppress addthis.o -o addthis.dylib </pre>
+</li>
+</ol>
+
+<a name="table">
+<h3>The User Defined Plug-in Table</h3></a>
+<p>
+The user defined function table (UDFT) is a simple text file that
+contains information about each user defined plug-in function. There is one record (line) in the file for each plug-in, and the file may contain
+multiple records for any number of plug-ins. 
+Each plug-in record contains three blank delimited fields:
+<ul>
+<p>Field 1: The type of the plug-in, which is either <code>function</code> or <code>defop</code>. (N.B.: The <code>defop</code> type will be for operations on previously defined variables, and hasn't yet been implemented.) For now, the only working option for this field is <code>function</code>.
+<p>Field 2: The name of the function, which must meet the following criteria: it must start with a letter, be less than 16 characters long, and consist of letters or numbers or underscore. All letters must be lower case.</p>
+<p>
+  Field 3: The  file name (including the full path) of the shared object file (a dynamic library) that contains the function's
+  executable routine.  GrADS will use the 'dlopen' command to load the library file, and the 'dlsym' command to point to the named function.  
+  The man pages for dlopen and dlsym have more information about how these routines work. 
+</p>
+</ul>
+<p>An example of a record for our example plug-in <code>addthis.c</code> might look like this:
+<pre>   function addthis /home/username/grads/udp/addthis.so</pre>
+
+
+<a name="gaudpt">
+<h3>The environment variable GAUDPT</h3></a>
+<p>GrADS will look for user defined plug-in function definitions in two places: the file name pointed to by the 
+  environment variable GAUDPT, and a file named "udpt" in the directory named by the GADDIR environment variable.  An example of setting the GAUDPT environment
+  variable is:
+  
+<pre>    setenv GAUDPT $HOME/grads/udpt</pre>
+
+<a name="example1">
+<h3>Example: Add a number to a variable</h3>
+</a>
+<p><a href="addthis.c"><code><b>addthis.c</b></code></a> is a sample user defined plug-in function for use with GrADS that does a very basic task: it adds a number to all the non-missing values in a GrADS expression, which may be for gridded or station data. Additional information may be found in the comments of the source code.</p>
+</body>
+</html>
diff --git a/src/Makefile.in b/src/Makefile.in
index 4d8a914..32184d5 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -52,7 +52,7 @@ bin_PROGRAMS = grads$(EXEEXT) xgrads$(EXEEXT) gribmap$(EXEEXT) \
 EXTRA_PROGRAMS = grib2scan$(EXEEXT)
 subdir = src
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(srcdir)/config.h.in ChangeLog
+	$(srcdir)/Makefile.in $(srcdir)/config.h.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/Xaw.m4 \
 	$(top_srcdir)/m4/ga_lib_readline.m4 $(top_srcdir)/m4/gd.m4 \
diff --git a/src/VERSION b/src/VERSION
index 7ec1d6d..3ffd695 100644
--- a/src/VERSION
+++ b/src/VERSION
@@ -1 +1 @@
-2.1.0
+2.1.1.b0
diff --git a/src/bufrstn.c b/src/bufrstn.c
index dd83154..715e41a 100644
--- a/src/bufrstn.c
+++ b/src/bufrstn.c
@@ -315,7 +315,7 @@ gaint getbufr (struct gastn *stn) {
 		      rpt->lon = hlon;
 		      rpt->lev = hlev;
 		      rpt->tim = htim;
-                      rpt->umask = 1;
+                      rpt->umask = 1;  
 		      rpt->val = bval->val;
 		      for (k=0; k<8; k++) *(rpt->stid+k) = *(rfhdr.stid+k);
 		      stn->rnum++;
diff --git a/src/dodstn.c b/src/dodstn.c
index c282fba..7ae8c18 100644
--- a/src/dodstn.c
+++ b/src/dodstn.c
@@ -345,7 +345,7 @@ gaint dappfi (char *url, struct gafile *pfi) {
   else if (isepic(handle)) {
     trngid = gadap_d_attrindex(handle,nvars,"time_range");
     trngstr = gadap_d_attrstr(handle,nvars,trngid);
-    tmin = strtod(trngstr,&trngstr);
+    tmin = strtod(trngstr,(char**)&trngstr);
     tmax = strtod(trngstr,NULL);
     dt1 = epict2dt(tmax);
     dt1 = epict2dt(tmin);
@@ -520,7 +520,7 @@ gaint dapget(struct gastn *stn) {
 	if (stid2[j] == '\0') break;
 	stid[j] = stid2[j];
       }
-      if (stid2) free(stid2);
+      if (stid2) free((char*)stid2);
       gadap_r_valdbl(r_handle, i, 0, rptinfo[3], 0, &time); 
     }
 
diff --git a/src/gaddes.c b/src/gaddes.c
index db6aed7..bbbdad6 100644
--- a/src/gaddes.c
+++ b/src/gaddes.c
@@ -20,7 +20,7 @@
 #include "grads.h"
 
 extern struct gamfcmn mfcmn;
-static char pout[256];
+static char pout[1256];
 static FILE *pdfi;       /* File descriptor for pdef file */
 FILE *descr;             /* File descriptor pointer */
 
@@ -181,6 +181,19 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	}
       }
 
+    } else if (cmpwrd("xytrailer",rec)) {
+      if ( (ch=nxtwrd(rec))==NULL ) {
+        gaprnt (1,"Description file warning: Missing xy grid trailer length\n");
+      } else {
+        ch = longprs(ch,&(pfi->xytrlr));
+        if (ch==NULL) {
+	  gaprnt (1,"xy grid trailer length invalid\n");
+	  pfi->xytrlr = 0;
+        } else {
+	  pfi->xytrlr = pfi->xytrlr/4;
+	}
+      }
+
     } else if (cmpwrd("unpack",rec)) {
       if ( (ch=nxtwrd(mrec))==NULL ) {
         gaprnt (1,"Descriptor File Warning: Missing attribute names in unpack record\n");
@@ -824,7 +837,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	/* open the pdef file */
         pdfi = fopen(pdefnm,"rb");
         if (pdfi==NULL) {
-          snprintf(pout,255, "  Error opening pdef file:  %s\n",pdefnm);
+          snprintf(pout,1255, "  Error opening pdef file:  %s\n",pdefnm);
           gaprnt (0,pout);
           goto errm;
         }
@@ -845,7 +858,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       if ( (ch = nxtwrd(rec)) == NULL) goto err1;
       if ( (pos = intprs(ch,&(pfi->dnum[0])))==NULL) goto err1;
       if (pfi->dnum[0]<1) {
-	snprintf(pout,255,"Warning: Invalid XDEF syntax in %s -- Changing size of X axis from %d to 1 \n",
+	snprintf(pout,1255,"Warning: Invalid XDEF syntax in %s -- Changing size of X axis from %d to 1 \n",
 		pfi->dnam,pfi->dnum[0]);
         gaprnt (1,pout);
 	pfi->dnum[0] = 1;
@@ -874,7 +887,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       if ( (ch = nxtwrd(rec)) == NULL) goto err1;
       if ( (pos = intprs(ch,&(pfi->dnum[1])))==NULL) goto err1;
       if (pfi->dnum[1]<1) {
-	snprintf(pout,255,"Warning: Invalid YDEF syntax in %s -- Changing size of Y axis from %d to 1 \n",
+	snprintf(pout,1255,"Warning: Invalid YDEF syntax in %s -- Changing size of Y axis from %d to 1 \n",
 		pfi->dnam,pfi->dnum[1]);
         gaprnt (1,pout);
 	pfi->dnum[1] = 1;
@@ -951,7 +964,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       if ( (ch = nxtwrd(rec)) == NULL) goto err1;
       if ( (pos = intprs(ch,&(pfi->dnum[2])))==NULL) goto err1;
       if (pfi->dnum[2]<1) {
-	snprintf(pout,255,"Warning: Invalid ZDEF syntax in %s -- Changing size of Z axis from %d to 1 \n",
+	snprintf(pout,1255,"Warning: Invalid ZDEF syntax in %s -- Changing size of Z axis from %d to 1 \n",
 		pfi->dnam,pfi->dnum[2]);
         gaprnt (1,pout);
 	pfi->dnum[2] = 1;
@@ -974,7 +987,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       if ( (ch = nxtwrd(rec)) == NULL) goto err1;
       if ( (pos = intprs(ch,&(pfi->dnum[3])))==NULL) goto err1;
       if (pfi->dnum[3]<1) {
-	snprintf(pout,255,"Warning: Invalid TDEF syntax in %s -- Changing size of T axis from %d to 1 \n",
+	snprintf(pout,1255,"Warning: Invalid TDEF syntax in %s -- Changing size of T axis from %d to 1 \n",
 		pfi->dnam,pfi->dnum[3]);
         gaprnt (1,pout);
 	pfi->dnum[3] = 1;
@@ -1015,7 +1028,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       if ((ch = nxtwrd(mrec)) == NULL) goto err1;
       if ((pos = intprs(ch,&(pfi->dnum[4])))==NULL) goto err1;
       if (pfi->dnum[4]<1) {
-	snprintf(pout,255,"Warning: Invalid EDEF syntax in %s -- Changing size of E axis from %d to 1 \n",
+	snprintf(pout,1255,"Warning: Invalid EDEF syntax in %s -- Changing size of E axis from %d to 1 \n",
 		pfi->dnam,pfi->dnum[4]);
         gaprnt (1,pout);
 	pfi->dnum[4] = 1;
@@ -1110,7 +1123,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	  }
 	  if (cmpwrd("endedef",rec)) {
 	    gaprnt (0,"Open Error:  Unexpected ENDEDEF record\n");
-	    snprintf(pout,255, "Was expecting %i records.  Found %i.\n", pfi->dnum[4], j);
+	    snprintf(pout,1255, "Was expecting %i records.  Found %i.\n", pfi->dnum[4], j);
 	    gaprnt (2,pout);
 	    goto err9;
 	  }
@@ -1176,7 +1189,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	      if ((ddfattr(mrec,pfi)) == -1) goto retrn;
 	    }
 	  } else {
-	    snprintf(pout,255,"Open Error:  Looking for \"ENDEDEF\", found \"%s\" instead.\n",mrec);
+	    snprintf(pout,1255,"Open Error:  Looking for \"ENDEDEF\", found \"%s\" instead.\n",mrec);
 	    gaprnt (0,pout);
 	    goto err9;
 	  }
@@ -1240,7 +1253,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	/* get the complete variable declaration */
         if (fgets(rec,512,descr)==NULL) {
           gaprnt (0,"Open Error:  Unexpected EOF reading variables\n");
-          snprintf(pout,255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
+          snprintf(pout,1255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
           gaprnt (2,pout);
           goto retrn;
         }
@@ -1277,7 +1290,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 
         if (cmpwrd("endvars",rec)) {
           gaprnt (0,"Open Error:  Unexpected ENDVARS record\n");
-          snprintf(pout,255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
+          snprintf(pout,1255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
           gaprnt (2,pout);
           goto err9;
         }
@@ -1412,7 +1425,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	  }
 	}
         else {
-	  snprintf(pout,255,"Open Error:  Looking for \"endvars\", found \"%s\" instead.\n",rec);
+	  snprintf(pout,1255,"Open Error:  Looking for \"endvars\", found \"%s\" instead.\n",rec);
 	  gaprnt (0,pout);
 	  goto err9;
 	}
@@ -1452,7 +1465,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
   err=0;
   for (i=0; i<7; i++) {
     if (flgs[i]) {
-      snprintf(pout,255,"Open Error:  missing %s record \n",errs[i]);
+      snprintf(pout,1255,"Open Error:  missing %s record \n",errs[i]);
       gaprnt (0,pout);
       err=1;
     }
@@ -1517,7 +1530,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       ens->gt = t2gr(pfi->abvals[3],&(ens->tinit));
       /* make sure time axis spans all ensemble members */
       if (ens->gt - 1 + ens->length > pfi->dnum[3]) {
-	snprintf(pout,255,"Open Error:  ensemble %d (%s) extends beyond the time axis limits\n",j,ens->name);
+	snprintf(pout,1255,"Open Error:  ensemble %d (%s) extends beyond the time axis limits\n",j,ens->name);
 	gaprnt(0,pout);
 	goto retrn;
       }
@@ -1541,7 +1554,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
   if (pfi->idxflg && mflag) {
     mfile = fopen (pfi->mnam, "rb");
     if (mfile==NULL) {
-      snprintf(pout,255,"Open Error:  Can't open Station/Index map file %s \n",pfi->mnam);
+      snprintf(pout,1255,"Open Error:  Can't open Station/Index map file %s \n",pfi->mnam);
       gaprnt (0,pout); goto retrn;
     }
     if (mflag==2) goto skipread;
@@ -1605,7 +1618,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	    for (i=0; i<pindx->hinum; i++) {
 	      rc = fread(urec,sizeof(unsigned char),4,mfile);
 	      if (rc!=4) { 
-		snprintf(pout,255,"Error reading integer %d from header of GRIB1 index file\n",i); 
+		snprintf(pout,1255,"Error reading integer %d from header of GRIB1 index file\n",i); 
 		gaprnt(0,pout); goto retrn; 
 	      }
 	      idum = gagby(urec,0,4);
@@ -1627,7 +1640,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	    for (i=0; i<pindx->intnum; i++) {
 	      rc = fread(urec,sizeof(unsigned char),4,mfile);
 	      if (rc!=4) { 
-		snprintf(pout,255,"Error reading integer %d from GRIB1 index file\n",i); 
+		snprintf(pout,1255,"Error reading integer %d from GRIB1 index file\n",i); 
 		gaprnt(0,pout); goto retrn; 
 	      }
 	      idum = gagby(urec,0,4);
@@ -1641,7 +1654,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	    for (i=0; i<pindx->fltnum; i++) {
 	      rc = fread(urec,sizeof(unsigned char),4,mfile);
 	      if (rc!=4) { 
-		snprintf(pout,255,"Error reading float %d from GRIB1 index file\n",i); 
+		snprintf(pout,1255,"Error reading float %d from GRIB1 index file\n",i); 
 		gaprnt(0,pout); goto retrn; 
 	      }
 	      fdum = ibm2flt(urec);
@@ -1776,7 +1789,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	    if ((g2indx->g2intpnt = (gaint *)galloc(sz,"g2intpnt"))==NULL) goto err8;
 	    rc = fread(g2indx->g2intpnt,sizeof(gaint),g2indx->g2intnum,mfile);
 	    if (rc!=g2indx->g2intnum) {
-	      snprintf(pout,255,"Error reading int array from GRIB2 index file, rc=%d\n",rc);
+	      snprintf(pout,1255,"Error reading int array from GRIB2 index file, rc=%d\n",rc);
 	      gaprnt(0,pout); goto retrn;
 	    }
 	    if (swpflg) gabswp(g2indx->g2intpnt,g2indx->g2intnum);
@@ -1786,7 +1799,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	      if ((g2indx->g2bigpnt = (off_t *)galloc(sz,"g2bigpnt"))==NULL) goto err8;
 	      rc = fread(g2indx->g2bigpnt,sizeof(off_t),g2indx->g2intnum,mfile);
 	      if (rc!=g2indx->g2intnum) {
-	        snprintf(pout,255,"Error reading off_t array from GRIB2 index file, rc=%d\n",rc);
+	        snprintf(pout,1255,"Error reading off_t array from GRIB2 index file, rc=%d\n",rc);
 	        gaprnt(0,pout); goto retrn;
 	      }
 	      if (swpflg) gabswp8(g2indx->g2bigpnt,g2indx->g2intnum);
@@ -1794,7 +1807,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	  }
 	}
 	else {     
-	  snprintf(pout,255,"Unknown GRIB2 index version number: %d\n",g2indx->version);
+	  snprintf(pout,1255,"Unknown GRIB2 index version number: %d\n",g2indx->version);
 	  gaprnt(0,pout); goto retrn;
 	}
 	/* everything parsed OK, so hang the pindx off the gafile structure */
@@ -1927,7 +1940,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	      }
 	    }
 	    else {
-	      snprintf(pout,255,"Warning: VECTORPAIRS variables %s,%s were not found \n",var1,var2);
+	      snprintf(pout,1255,"Warning: VECTORPAIRS variables %s,%s were not found \n",var1,var2);
 	      gaprnt(1,pout);
 	    }
 	    break;
@@ -2027,9 +2040,9 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       err=1;
     } else if (mcnt != pfi->dnum[3]) {
       gaprnt (0,"Open Error: Inconsistent time count\n");
-      snprintf(pout,255,"  Count in station map file = %i\n",mcnt);
+      snprintf(pout,1255,"  Count in station map file = %i\n",mcnt);
       gaprnt (0,pout);
-      snprintf(pout,255,"  Count in descriptor file = %i\n",pfi->dnum[3]);
+      snprintf(pout,1255,"  Count in descriptor file = %i\n",pfi->dnum[3]);
       gaprnt (0,pout);
       err=1;
     }
@@ -2065,7 +2078,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
   if (pfi->type==1) {
     pfi->gsiz = pfi->dnum[0] * pfi->dnum[1];
     if (pfi->ppflag) pfi->gsiz = pfi->ppisiz * pfi->ppjsiz;
-    /* add the XY header to gsiz */
+    /* add the XY header/trailer to gsiz */
     if (pfi->xyhdr) {
       if (pvar->dfrm == 1) {
 	pfi->xyhdr = pfi->xyhdr*4/1;          
@@ -2075,6 +2088,15 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       } 
       pfi->gsiz = pfi->gsiz + pfi->xyhdr;
     }
+    if (pfi->xytrlr) {
+      if (pvar->dfrm == 1) {
+	pfi->xytrlr = pfi->xytrlr*4/1;          
+      } 
+      else if (pvar->dfrm ==  2 || pvar->dfrm == -2 ) {
+	pfi->xytrlr = pfi->xytrlr*4/2;
+      } 
+      pfi->gsiz = pfi->gsiz + pfi->xytrlr;
+    }
 
     /* adjust the size of hdrb and trlb for non-float data */
     if (pvar->dfrm == 1) {
@@ -2286,7 +2308,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
       /* get filename for initial time of current ensemble member  */
       ch = gafndt(pfi->name,&tdefe,&tdefe,pfi->abvals[3],pfi->pchsub1,pfi->ens1,ens->gt,e,&flag);   
       if (ch==NULL) {
-	snprintf(pout,255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,ens->gt);
+	snprintf(pout,1255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,ens->gt);
 	gaprnt(0,pout);
 	goto err8;
       }
@@ -2327,7 +2349,7 @@ gaint gaddes (char *name, struct gafile *pfi, gaint mflag) {
 	gr2t(pfi->grvals[3],(gadouble)t,&tdef);
 	pos = gafndt(pfi->name,&tdef,&tdefe,pfi->abvals[3],pfi->pchsub1,pfi->ens1,t,e,&flag);  
 	if (pos==NULL) {
-	  snprintf(pout,255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,t);
+	  snprintf(pout,1255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,t);
 	  gaprnt(0,pout);
 	  goto err8;
 	}
@@ -2782,7 +2804,7 @@ struct gaattr *parseattr (char *ch) {
     }
   } 
   else {
-    snprintf(pout,255,"Error: attribute data type not handled: nctype = %d \n",nctype);
+    snprintf(pout,1255,"Error: attribute data type not handled: nctype = %d \n",nctype);
     gaprnt(0,pout);
     goto err;
   }
@@ -2837,6 +2859,7 @@ size_t sz;
   pfi->h5id = -999;      /* No hdf5 file open */
   pfi->fhdr = 0;         /* Assume no file header */
   pfi->xyhdr=0;          /* Assume no xyheader */
+  pfi->xytrlr=0;         /* Assume no xytrailer */
   pfi->fseq = -999;      /* No sequence number assigned */
   pfi->dhandle = -999;   /* Assume not a gadods stn data set */
   pfi->packflg = 0;      /* Assume data are not packed */
diff --git a/src/gaexpr.c b/src/gaexpr.c
index eac2336..fdae2e3 100644
--- a/src/gaexpr.c
+++ b/src/gaexpr.c
@@ -14,7 +14,7 @@
 #include <math.h>
 #include "grads.h"
 
-static char pout[256];     /* Build error msgs here */
+static char pout[1256];     /* Build error msgs here */
 static gaint pass=0;  /* Internal pass number */
 
 /* Debugging routine to print the current stack */
@@ -174,6 +174,44 @@ gaint size;
         state=1;
       }
 
+      /* logical operator */
+
+      else if ( (*pos=='=')||(*pos=='!')||(*pos=='<')||(*pos=='>')
+                       ||(*pos=='|')||(*pos=='&') ) {
+        if (*(pos+1)=='=') {
+          curr++;
+          stack[curr].type=1;
+          if ( (*pos=='=')&&(*(pos+1)=='=') ) stack[curr].obj.op=20;
+          if ( (*pos=='<')&&(*(pos+1)=='=') ) stack[curr].obj.op=23;
+          if ( (*pos=='>')&&(*(pos+1)=='=') ) stack[curr].obj.op=24;
+          if ( (*pos=='!')&&(*(pos+1)=='=') ) stack[curr].obj.op=25;
+          pos+=2;
+          state=1;
+        } else if ((*pos=='|')&&(*(pos+1)=='|')) {
+          curr++;
+          stack[curr].type=1;
+	  stack[curr].obj.op=26; 
+          pos+=2;
+          state=1;
+        } else if ((*pos=='&')&&(*(pos+1)=='&')) {
+          curr++;
+          stack[curr].type=1;
+	  stack[curr].obj.op=27; 
+          pos+=2;
+          state=1;
+        } else {
+          curr++;
+          stack[curr].type=1;
+          if (*pos=='=') stack[curr].obj.op=20;
+          if (*pos=='<') stack[curr].obj.op=21;
+          if (*pos=='>') stack[curr].obj.op=22;
+          if (*pos=='|') stack[curr].obj.op=26;
+          if (*pos=='&') stack[curr].obj.op=27;
+          pos++;
+          state=1;
+        }
+      }
+
       else {
         gaprnt (0,"Syntax Error:  Expected operator or ')'\n");
         cont=0; err=1;
@@ -210,7 +248,7 @@ gaint size;
   if (err) {
     if (pass==1) {
       i = 1 + pos - expr;
-      snprintf(pout,255,"  Error ocurred at column %i\n",i);
+      snprintf(pout,1255,"  Error ocurred at column %i\n",i);
       gaprnt (0,pout);
     }
 
@@ -480,7 +518,70 @@ char *uval1,*uval2;
           if (*val2<0.0) *uval2 = 0;
           else *val2 = *val1;
         }
+      } else if (op==14) {   /* for if function.  pairs with op 15 */
+        if (swap) {
+          if (*val2<0.0) *val2 = 0.0;
+          else *val2 = *val1;
+        } else {
+          if (*val1<0.0) *val2 = 0.0;
+        }
+      } else if (op==15) { 
+        if (swap) {
+          if (*val2<0.0) *val2 = *val1;
+          else *val2 = 0.0;
+        } else {
+          if (!(*val1<0.0)) *val2 = 0.0;
+        }
+      } else if (op>=21 && op<=24 ) {
+        if (swap) {
+          if (op==21) {
+            if (*val2 < *val1) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+          if (op==22) {
+            if (*val2 > *val1) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+          if (op==23) {
+            if (*val2 <= *val1) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+          if (op==24) {
+            if (*val2 >= *val1) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+        } else {
+          if (op==21) {
+            if (*val1 < *val2) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+          if (op==22) {
+            if (*val1 > *val2) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+          if (op==23) {
+            if (*val1 <= *val2) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+          if (op==24) {
+            if (*val1 >= *val2) *val2 = 1.0;
+            else *val2 = -1.0;
+          }
+        }
+      } else if (op==20) {
+        if (*val1 == *val2) *val2 = 1.0;
+        else *val2 = -1.0;
+      } else if (op==25) {
+        if (*val1 != *val2) *val2 = 1.0;
+        else *val2 = -1.0;
+      } else if (op==26) {
+        if ( (*val1<0.0)&&(*val2<0.0) ) *val2 = -1.0;
+        else *val2 = 1.0;
+      } else if (op==27) {
+        if ( (*val1>=0.0)&&(*val2>=0.0) ) *val2 = 1.0;
+        else *val2 = -1.0;
       }
+
       else {
         gaprnt (0,"Internal logic check 17: invalid oper value\n");
         return (NULL);
@@ -504,16 +605,16 @@ char *uval1,*uval2;
   err1:
     gaprnt (0,"Operation error:  Incompatable grids \n");
     gaprnt (1,"   Varying dimensions are different\n");
-    snprintf(pout,255,"  1st grid dims = %i %i   2nd = %i %i \n",
+    snprintf(pout,1255,"  1st grid dims = %i %i   2nd = %i %i \n",
             pgr1->idim, pgr2->idim, pgr1->jdim, pgr2->jdim);
     gaprnt (2,pout);
     return (NULL);
 
   err2:
     gaprnt (0,"Operation error:  Incompatable grids \n");
-    snprintf(pout,255,"  Dimension = %i\n",i);
+    snprintf(pout,1255,"  Dimension = %i\n",i);
     gaprnt (2, pout);
-    snprintf(pout,255,"  1st grid range = %i %i   2nd = %i %i \n",
+    snprintf(pout,1255,"  1st grid range = %i %i   2nd = %i %i \n",
             pgr1->dimmin[i],pgr1->dimmax[i],
             pgr2->dimmin[i],pgr2->dimmax[i]);
     gaprnt (2,pout);
@@ -769,7 +870,7 @@ size_t sz;
     ch++;
     pos = intprs(ch,&fnum);
     if (pos==NULL || fnum<1) {
-      snprintf(pout,255,"Syntax error: Bad file number for variable %s \n",name);
+      snprintf(pout,1255,"Syntax error: Bad file number for variable %s \n",name);
       gaprnt (0,pout);
       return (NULL);
     }
@@ -801,7 +902,7 @@ size_t sz;
       for (i=1; i<fnum && pfi!=NULL; i++) pfi = pfi->pforw;
       if (pfi==NULL) {
         gaprnt (0,"Data Request Error:  File number out of range \n");
-        snprintf(pout,255,"  Variable = %s \n",vnam);
+        snprintf(pout,1255,"  Variable = %s \n",vnam);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -818,10 +919,10 @@ size_t sz;
       if (cmpwrd(name,"lat")) {vfake.offset = 1; snprintf(vfake.abbrv,5,"lat");}
       if (cmpwrd(name,"lev")) {vfake.offset = 2; snprintf(vfake.abbrv,5,"lev");}
       if (pfi->type==2 || pfi->type==3) {
-        snprintf(pout,255,"Data Request Error:  Predefined variable %s\n", vnam);
+        snprintf(pout,1255,"Data Request Error:  Predefined variable %s\n", vnam);
         gaprnt (0,pout);
         gaprnt (0,"   is only defined for grid type files\n");
-        snprintf(pout,255,"   File %i is a station file\n",fnum);
+        snprintf(pout,1255,"   File %i is a station file\n",fnum);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -835,7 +936,7 @@ size_t sz;
       if (i>=pfi->vnum) {
         if (dotflg) {
           gaprnt (0,"Data Request Error:  Invalid variable name \n");
-          snprintf(pout,255,"  Variable '%s' not found in file %i\n",vnam,fnum);
+          snprintf(pout,1255,"  Variable '%s' not found in file %i\n",vnam,fnum);
           gaprnt (0,pout);
           return (NULL);
         } else {
@@ -883,9 +984,9 @@ size_t sz;
       dmax[i] = ceil(dmax[i]-0.0001);
       if (dmax[i]<=dmin[i]) {
         gaprnt (0,"Data Request Error: Invalid grid coordinates\n");
-        snprintf(pout,255,"  Varying dimension %i decreases: %g to %g\n",i,dmin[i],dmax[i]);
+        snprintf(pout,1255,"  Varying dimension %i decreases: %g to %g\n",i,dmin[i],dmax[i]);
         gaprnt (0,pout);
-        snprintf(pout,255,"  Error ocurred getting variable '%s'\n",vnam);
+        snprintf(pout,1255,"  Error ocurred getting variable '%s'\n",vnam);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -899,14 +1000,14 @@ size_t sz;
     while (*ch!=')') {
       pos = dimprs(ch, pst, pfi, &dim, &d1, 1, &rc);
       if (pos==NULL) {
-        snprintf(pout,255,"  Variable name = %s\n",vnam);
+        snprintf(pout,1255,"  Variable name = %s\n",vnam);
         gaprnt (0,pout);
         return (NULL);
       }
       if (id[dim]) {
         gaprnt (0,"Syntax Error: Invalid dimension expression\n");
         gaprnt (0,"  Same dimension specified multiple times ");
-        snprintf(pout,255,"for variable = %s\n",vnam);
+        snprintf(pout,1255,"for variable = %s\n",vnam);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -914,7 +1015,7 @@ size_t sz;
       if ( dim==pst->idim || dim==pst->jdim) {
         gaprnt (0,"Data Request Error: Invalid dimension expression\n");
         gaprnt (0,"  Attempt to set or modify varying dimension\n");
-        snprintf(pout,255,"  Variable = %s, Dimension = %i \n",vnam,dim);
+        snprintf(pout,1255,"  Variable = %s, Dimension = %i \n",vnam,dim);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -972,7 +1073,7 @@ size_t sz;
       gaprnt (0,"Data Request Error: Invalid grid coordinates\n");
       gaprnt (0,"  World coordinates convert to non-integer");
       gaprnt (0,"  grid coordinates\n");
-      snprintf(pout,255,"    Variable = %s  Dimension = %i \n",vnam,i);
+      snprintf(pout,1255,"    Variable = %s  Dimension = %i \n",vnam,i);
       gaprnt (0,pout);
       return (NULL);
     }
@@ -1054,13 +1155,13 @@ size_t sz;
   /* Get grid */
   rc = gaggrd (pgr);
   if (rc>0) {
-    snprintf(pout,255,"Data Request Error:  Error for variable '%s'\n", vnam);
+    snprintf(pout,1255,"Data Request Error:  Error for variable '%s'\n", vnam);
     gaprnt (0,pout);
     gagfre(pgr);
     return (NULL);
   }
   if (rc<0) {
-    snprintf(pout,255,"  Warning issued for variable = %s\n",vnam);
+    snprintf(pout,1255,"  Warning issued for variable = %s\n",vnam);
     gaprnt (2,pout);
   }
 
@@ -1089,7 +1190,7 @@ size_t sz;
       pgr2->pvar = pvar2;
       rc = gaggrd (pgr2);
       if (rc>0) {
-        snprintf(pout,255,"Data Request Error:  Error for variable '%s'\n", vnam);
+        snprintf(pout,1255,"Data Request Error:  Error for variable '%s'\n", vnam);
         gaprnt (0,pout);
         gagfre(pgr);
         gagfre(pgr2);
@@ -1327,14 +1428,14 @@ size_t sz;
         pos = dimprs(ch, pst, pfi, &dim, &d, 0, &rc);
       }
       if (pos==NULL) {
-        snprintf(pout,255,"  Variable name = %s\n",vnam);
+        snprintf(pout,1255,"  Variable name = %s\n",vnam);
         gaprnt (0,pout);
         return (NULL);
       }
       if (dim<6 && id[dim]>1) {
         gaprnt (0,"Syntax Error: Invalid dimension expression\n");
         gaprnt (0,"  Same dimension specified more than twice ");
-        snprintf(pout,255,"for variable = %s\n",vnam);
+        snprintf(pout,1255,"for variable = %s\n",vnam);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -1342,7 +1443,7 @@ size_t sz;
            ( dim>3 && (pst->idim==0 || pst->idim==1 || pst->jdim==1))) {
         gaprnt (0,"Data Request Error: Invalid dimension expression\n");
         gaprnt (0,"  Attempt to set or modify varying dimension\n");
-        snprintf(pout,255,"  Variable = %s, Dimension = %i \n",vnam,dim);
+        snprintf(pout,1255,"  Variable = %s, Dimension = %i \n",vnam,dim);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -1366,9 +1467,9 @@ size_t sz;
   for (i=0; i<4; i++) {
     if ((i!=2 && dmin[i]>dmax[i]) || (i==2 && dmax[i]>dmin[i])) {
       gaprnt (0,"Data Request Error: Invalid grid coordinates\n");
-      snprintf(pout,255,"  Varying dimension %i decreases: %g to %g \n",i,dmin[i],dmax[i]);
+      snprintf(pout,1255,"  Varying dimension %i decreases: %g to %g \n",i,dmin[i],dmax[i]);
       gaprnt (0,pout);
-      snprintf(pout,255,"  Error ocurred getting variable '%s'\n",vnam);
+      snprintf(pout,1255,"  Error ocurred getting variable '%s'\n",vnam);
       gaprnt (0,pout);
       return (NULL);
     }
@@ -1416,7 +1517,7 @@ size_t sz;
   rc = gagstn (stn);
 
   if (rc) {
-    snprintf(pout,255,"Data Request Error:  Variable is '%s'\n",vnam);
+    snprintf(pout,1255,"Data Request Error:  Variable is '%s'\n",vnam);
     gaprnt (0,pout);
     gree(stn,"f171");
     return (NULL);
diff --git a/src/gafunc.c b/src/gafunc.c
index df4fe62..25609a6 100644
--- a/src/gafunc.c
+++ b/src/gafunc.c
@@ -16,6 +16,7 @@
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <dlfcn.h>
 #include <string.h>
 #include "grads.h"
 
@@ -23,15 +24,16 @@
 #include "gaudx.h"
 #endif
 
-/* expose Mike Fiorino's global struct to these routines for warning level setting */
-extern struct gamfcmn mfcmn;
 
-static struct gaufb *ufba;  /* Anchor for user function defs */
-char *gxgnam(char *);       /* This is also in gx.h */
+extern struct gamfcmn mfcmn;   /* for global warning level settings */
+static struct gaufb *ufba;     /* Anchor for user function defs */
+static struct gaupb *upba;     /* Anchor for user defined plug-in */
+static char pout[1256];         /* Build error msgs here */
+char *gxgnam(char *);          /* This is also in gx.h */
+gaint ffudpi (struct gafunc *, struct gastat *, struct gaupb *);
 
 /* Function routine names.  Add a new function by putting the
    prototype here and adding to the if tests below.  */
-
 gaint ffsqrt   (struct gafunc *, struct gastat *);
 gaint ffsin    (struct gafunc *, struct gastat *);
 gaint ffcos    (struct gafunc *, struct gastat *);
@@ -42,6 +44,7 @@ gaint ffexp    (struct gafunc *, struct gastat *);
 gaint fflog    (struct gafunc *, struct gastat *);
 gaint fflog10  (struct gafunc *, struct gastat *);
 gaint ffabs    (struct gafunc *, struct gastat *);
+gaint ffif     (struct gafunc *, struct gastat *);
 gaint ffpow    (struct gafunc *, struct gastat *);
 gaint ffmag    (struct gafunc *, struct gastat *);
 gaint ffatan   (struct gafunc *, struct gastat *);
@@ -102,108 +105,110 @@ gaint ave      (struct gafunc *, struct gastat *, gaint);
 gaint scorr    (struct gafunc *, struct gastat *, gaint); 
 gaint tvrh2q   (gadouble, gadouble, gadouble, gadouble *, gadouble *);
 gaint fndarg   (char *, gaint *);
-void cosadj  (struct gagrid *);
-char doaave (struct gagrid *, gadouble, gadouble, gadouble, gadouble, gaint, gadouble *);
-gaint mnmx (struct gafunc *, struct gastat *, int);
+void cosadj    (struct gagrid *);
+char doaave    (struct gagrid *, gadouble, gadouble, gadouble, gadouble, gaint, gadouble *);
+gaint mnmx     (struct gafunc *, struct gastat *, int);
 
-static char pout[256];   /* Build error msgs here */
 
+/* Handles function calls from gaexpr.c  */
 char *rtnprs (char *ch, char *name, struct gastat *pst) {
 struct gafunc *pfc;
 struct gastat *pst2;
-struct gaufb *ufb;
+struct gaupb *upb=NULL;
 char *pos;
 gaint pdeep,rc;
 size_t sz;
-gaint (*fpntr)(struct gafunc *, struct gastat *)=NULL;
-
-  /* Find this function name and get the function pointer. */
-
-  ufb = ufba;
-  while (ufb) {
-    if (cmpwrd(ufb->name,name)) break;
-    ufb = ufb->ufb;
-  }
-
-  if (ufb==NULL) {
-    fpntr = NULL;
-    if (cmpwrd("sqrt",name)) fpntr = ffsqrt;
-    if (cmpwrd("sin",name)) fpntr = ffsin;
-    if (cmpwrd("cos",name)) fpntr = ffcos;
-    if (cmpwrd("tan",name)) fpntr = fftan;
-    if (cmpwrd("asin",name)) fpntr = ffasin;
-    if (cmpwrd("acos",name)) fpntr = ffacos;
-    if (cmpwrd("exp",name)) fpntr = ffexp;
-    if (cmpwrd("log",name)) fpntr = fflog;
-    if (cmpwrd("log10",name)) fpntr = fflog10;
-    if (cmpwrd("abs",name)) fpntr = ffabs;
-    if (cmpwrd("pow",name)) fpntr = ffpow;
-    if (cmpwrd("ave",name)) fpntr = ffave;
-    if (cmpwrd("mag",name)) fpntr = ffmag;
-    if (cmpwrd("atan2",name)) fpntr = ffatan;
-    if (cmpwrd("hdivg",name)) fpntr = ffhdiv;
-    if (cmpwrd("hcurl",name)) fpntr = ffhcrl;
-    if (cmpwrd("vint",name)) fpntr = ffvint;
-    if (cmpwrd("tloop",name)) fpntr = fftlp;
-    if (cmpwrd("eloop",name)) fpntr = ffelp;
-    if (cmpwrd("aave",name)) fpntr = ffaav;
-    if (cmpwrd("scorr",name)) fpntr = ffscor;
-    if (cmpwrd("tcorr",name)) fpntr = fftcor;
-    if (cmpwrd("tmave",name)) fpntr = fftmav;
-    if (cmpwrd("maskout",name)) fpntr = ffmask;
-    if (cmpwrd("gr2stn",name)) fpntr = ffg2s;
-    if (cmpwrd("tvrh2q",name)) fpntr = fftv2q;
-    if (cmpwrd("tvrh2t",name)) fpntr = fftv2t;
-    if (cmpwrd("gint",name)) fpntr = ffgint;
-    if (cmpwrd("oacres",name)) fpntr = ffoacr;
-    if (cmpwrd("oabin",name)) fpntr = ffoabn;
-    if (cmpwrd("smth9",name)) fpntr = ffsmth;
-    if (cmpwrd("stnave",name)) fpntr = ffsave;
-    if (cmpwrd("stnmin",name)) fpntr = ffsmin;
-    if (cmpwrd("stnmax",name)) fpntr = ffsmax;
-    if (cmpwrd("skip",name)) fpntr = ffskip;
-    if (cmpwrd("const",name)) fpntr = ffcnst;
-    if (cmpwrd("cdiff",name)) fpntr = ffcdif;
-    if (cmpwrd("mean",name)) fpntr = ffmn;    
-    if (cmpwrd("amean",name)) fpntr = ffamn;  
-    if (cmpwrd("sum",name)) fpntr = ffsum;    
-    if (cmpwrd("sumg",name)) fpntr = ffsumg;  
-    if (cmpwrd("asum",name)) fpntr = ffasum;  
-    if (cmpwrd("asumg",name)) fpntr = ffasumg; 
-    if (cmpwrd("atot",name)) fpntr = ffatot; 
-    if (cmpwrd("grarea",name)) fpntr = ffgrarea; 
-    if (cmpwrd("coll2gr",name)) fpntr = ffclgr;
-    if (cmpwrd("min",name)) fpntr = ffmin;
-    if (cmpwrd("max",name)) fpntr = ffmax;
-    if (cmpwrd("minloc",name)) fpntr = ffminl;
-    if (cmpwrd("maxloc",name)) fpntr = ffmaxl;
-    if (cmpwrd("fndlvl",name)) fpntr = ffflvl;
-    if (cmpwrd("sregr",name)) fpntr = ffsreg;  
-    if (cmpwrd("tregr",name)) fpntr = fftreg;  
-    if (cmpwrd("s2g1d",name)) fpntr = ffs2g1d;
-    if (cmpwrd("lterp",name)) fpntr = fflterp;
-    if (cmpwrd("amin",name)) fpntr = ffamin;    
-    if (cmpwrd("amax",name)) fpntr = ffamax;    
-    if (cmpwrd("aminlocx",name)) fpntr = ffaminlocx;    
-    if (cmpwrd("aminlocy",name)) fpntr = ffaminlocy;    
-    if (cmpwrd("amaxlocx",name)) fpntr = ffamaxlocx;    
-    if (cmpwrd("amaxlocy",name)) fpntr = ffamaxlocy;    
+gaint (*fpntr)(struct gafunc *, struct gastat *);
+
+  /* Find the function name and get the function pointer. */
+  fpntr=NULL;
+
+  /* start with the list of built-in functions */
+  if (cmpwrd("sqrt",name)) fpntr = ffsqrt;
+  if (cmpwrd("sin",name)) fpntr = ffsin;
+  if (cmpwrd("cos",name)) fpntr = ffcos;
+  if (cmpwrd("tan",name)) fpntr = fftan;
+  if (cmpwrd("asin",name)) fpntr = ffasin;
+  if (cmpwrd("acos",name)) fpntr = ffacos;
+  if (cmpwrd("exp",name)) fpntr = ffexp;
+  if (cmpwrd("log",name)) fpntr = fflog;
+  if (cmpwrd("log10",name)) fpntr = fflog10;
+  if (cmpwrd("abs",name)) fpntr = ffabs;
+  if (cmpwrd("if",name)) fpntr = ffif;
+  if (cmpwrd("pow",name)) fpntr = ffpow;
+  if (cmpwrd("ave",name)) fpntr = ffave;
+  if (cmpwrd("mag",name)) fpntr = ffmag;
+  if (cmpwrd("atan2",name)) fpntr = ffatan;
+  if (cmpwrd("hdivg",name)) fpntr = ffhdiv;
+  if (cmpwrd("hcurl",name)) fpntr = ffhcrl;
+  if (cmpwrd("vint",name)) fpntr = ffvint;
+  if (cmpwrd("tloop",name)) fpntr = fftlp;
+  if (cmpwrd("eloop",name)) fpntr = ffelp;
+  if (cmpwrd("aave",name)) fpntr = ffaav;
+  if (cmpwrd("scorr",name)) fpntr = ffscor;
+  if (cmpwrd("tcorr",name)) fpntr = fftcor;
+  if (cmpwrd("tmave",name)) fpntr = fftmav;
+  if (cmpwrd("maskout",name)) fpntr = ffmask;
+  if (cmpwrd("gr2stn",name)) fpntr = ffg2s;
+  if (cmpwrd("tvrh2q",name)) fpntr = fftv2q;
+  if (cmpwrd("tvrh2t",name)) fpntr = fftv2t;
+  if (cmpwrd("gint",name)) fpntr = ffgint;
+  if (cmpwrd("oacres",name)) fpntr = ffoacr;
+  if (cmpwrd("oabin",name)) fpntr = ffoabn;
+  if (cmpwrd("smth9",name)) fpntr = ffsmth;
+  if (cmpwrd("stnave",name)) fpntr = ffsave;
+  if (cmpwrd("stnmin",name)) fpntr = ffsmin;
+  if (cmpwrd("stnmax",name)) fpntr = ffsmax;
+  if (cmpwrd("skip",name)) fpntr = ffskip;
+  if (cmpwrd("const",name)) fpntr = ffcnst;
+  if (cmpwrd("cdiff",name)) fpntr = ffcdif;
+  if (cmpwrd("mean",name)) fpntr = ffmn;    
+  if (cmpwrd("amean",name)) fpntr = ffamn;  
+  if (cmpwrd("sum",name)) fpntr = ffsum;    
+  if (cmpwrd("sumg",name)) fpntr = ffsumg;  
+  if (cmpwrd("asum",name)) fpntr = ffasum;  
+  if (cmpwrd("asumg",name)) fpntr = ffasumg; 
+  if (cmpwrd("atot",name)) fpntr = ffatot; 
+  if (cmpwrd("grarea",name)) fpntr = ffgrarea; 
+  if (cmpwrd("coll2gr",name)) fpntr = ffclgr;
+  if (cmpwrd("min",name)) fpntr = ffmin;
+  if (cmpwrd("max",name)) fpntr = ffmax;
+  if (cmpwrd("minloc",name)) fpntr = ffminl;
+  if (cmpwrd("maxloc",name)) fpntr = ffmaxl;
+  if (cmpwrd("fndlvl",name)) fpntr = ffflvl;
+  if (cmpwrd("sregr",name)) fpntr = ffsreg;  
+  if (cmpwrd("tregr",name)) fpntr = fftreg;  
+  if (cmpwrd("s2g1d",name)) fpntr = ffs2g1d;
+  if (cmpwrd("lterp",name)) fpntr = fflterp;
+  if (cmpwrd("amin",name)) fpntr = ffamin;    
+  if (cmpwrd("amax",name)) fpntr = ffamax;    
+  if (cmpwrd("aminlocx",name)) fpntr = ffaminlocx;    
+  if (cmpwrd("aminlocy",name)) fpntr = ffaminlocy;    
+  if (cmpwrd("amaxlocx",name)) fpntr = ffamaxlocx;    
+  if (cmpwrd("amaxlocy",name)) fpntr = ffamaxlocy;    
 
 #ifdef OPENGRADS
-    /* OpenGrADS User Defined Extensions */
-    if (fpntr==NULL) *(void **) &fpntr = (void *) gaudf(name); 
+  /* OpenGrADS User Defined Extensions */
+  if (fpntr==NULL) *(void **) &fpntr = (void *) gaudf(name); 
 #endif
 
-    if (fpntr==NULL) {                       /* Didn't find it....      */
-      gaprnt (0,"Syntax Error:  Invalid Operand \n");
-      snprintf(pout,255,"  '%s' not a variable or function name\n",name);
-      gaprnt (0,pout);
-      return (NULL);
+  /* check the list of plug-ins */
+  if (fpntr==NULL) {
+    upb = upba;
+    while (upb) {
+      if (cmpwrd(upb->name,name)) break;
+      upb = upb->upb;
     }
   }
 
-  /* Allocate storage for gastat and gafunc structures                */
+  if (upb==NULL && fpntr==NULL) {           /* Didn't find it....      */
+    gaprnt (0,"Syntax Error:  Invalid Operand \n");
+    snprintf(pout,1255,"  '%s' not a variable or function name\n",name);
+    gaprnt (0,pout);
+    return (NULL);
+  }
 
+  /* Allocate storage for gastat and gafunc structures                */
   sz = sizeof(struct gafunc);
   pfc = (struct gafunc *)galloc(sz,"funccall");
   sz = sizeof(struct gastat);
@@ -212,7 +217,6 @@ gaint (*fpntr)(struct gafunc *, struct gastat *)=NULL;
   *pst2 = *pst;                            /* Provide copy of gastat  */
 
   /* Parse the argument list                                          */
-
   pfc->argnum = 0;                         /* Initial arg count       */
   if (*ch=='(') {                          /* If no leading paren..   */
     ch++;                                  /* Past the '('            */
@@ -246,15 +250,16 @@ gaint (*fpntr)(struct gafunc *, struct gastat *)=NULL;
 
   /* Everything is all set.  Call the function routine.               */
 
-  rc = (*fpntr)(pfc, pst2);           /* Call the function       */
+  if (upb) rc = ffudpi(pfc,pst2,upb);      /* Call the plug-in        */
+  else rc = (*fpntr)(pfc, pst2);           /* Call the function       */
 
   if (rc==-1) {
-    snprintf(pout,255,"Error in %s : Arg was stn data type\n",name);
+    snprintf(pout,1255,"Error in %s : Arg was stn data type\n",name);
     gaprnt (0,pout);
   }
 
   if (rc) {                                /* If an error occurred... */
-    snprintf(pout,255,"Operation Error:  Error from %s function\n",name);
+    snprintf(pout,1255,"Operation Error:  Error from %s function\n",name);
     gaprnt (0,pout);
     goto err;
   }
@@ -328,7 +333,7 @@ char *valu;
     }
   }
   if (ecnt>0) {
-    snprintf(pout,255,"Warning from SQRT:  Data has %i values < zero \n",ecnt);
+    snprintf(pout,1255,"Warning from SQRT:  Data has %i values < zero \n",ecnt);
     gaprnt (1,pout);
     gaprnt (1,"                    These were set to the undefined value \n");
   }
@@ -665,7 +670,7 @@ char *valu;
     }
   }
   if (ecnt>0) {
-    snprintf(pout,255,"Warning from LOG:  Data has %i values <= zero \n",ecnt);
+    snprintf(pout,1255,"Warning from LOG:  Data has %i values <= zero \n",ecnt);
     gaprnt (1,pout);
     gaprnt (1,"                   These were set to the undefined value \n");
   }
@@ -719,7 +724,7 @@ char *valu;
     }
   }
   if (ecnt>0) {
-    snprintf(pout,255,"Warning from LOG10:  Data has %i values <= zero \n",ecnt);
+    snprintf(pout,1255,"Warning from LOG10:  Data has %i values <= zero \n",ecnt);
     gaprnt (1,pout);
     gaprnt (1,"                     These were set to the undefined value \n");
   }
@@ -727,6 +732,119 @@ char *valu;
   return (0);
 }
 
+/* Implement the IF function.  Three expressions for the operation.
+   The first arg is assumed to be the result of a logical expression. */
+
+gaint ffif (struct gafunc *pfc, struct gastat *pst) {
+struct gastat pst2,pst3;
+struct gagrid *mypgr,*pgr1,*pgrres1,*pgrres2,*pgrres3;
+gaint rc,i,savaloc;
+
+  if (pfc->argnum!=3) { 
+    gaprnt (0,"Error from IF:  Too many or too few args \n");
+    gaprnt (0,"                Three arguments expected \n");
+    return (1);
+  }
+
+  pst2 = *pst;
+  pst3 = *pst;
+
+  rc = gaexpr(pfc->argpnt[0],pst);
+  if (rc) {
+    return (rc);
+  }
+
+  rc = gaexpr(pfc->argpnt[1],&pst2);
+  if (rc) {
+    gafree (pst);
+    return (rc);
+  }
+
+  rc = gaexpr(pfc->argpnt[2],&pst3);
+  if (rc) {
+    gafree (pst);
+    gafree (&pst2);
+    return (rc);
+  }
+
+  if (pst->type!=1 || pst2.type!=1 || pst3.type!=1) {
+    gaprnt (0,"Error from IF:  Arguments must be grids \n");
+    goto err1;
+  }
+
+  /* We need a copy of the result of the logical expression (arg 1) 
+     since we need to use that result twice, and gagrop 
+     may put its result grid there for our first 
+     step.  We will re-use the scaling info, but we have to be 
+     careful with the alocf issue. */
+
+  mypgr = galloc(sizeof(struct gagrid),"ffif3");
+  if (mypgr==NULL) goto err1;
+
+  pgr1 = pst->result.pgr; 
+  savaloc = pgr1->alocf;   /* preserve original alocf value */
+  *mypgr = *pgr1;
+  mypgr->alocf = 0;
+  pgr1->alocf = 0;   /* don't let scaling info get freed until we are ready */
+
+  if (mypgr->idim != -1 && mypgr->jdim != -1) {
+    mypgr->grid = galloc(sizeof(gadouble)*mypgr->isiz*mypgr->jsiz,"ffif1");
+    if (mypgr->grid==NULL) goto err1;
+    mypgr->umask = galloc(sizeof(char)*mypgr->isiz*mypgr->jsiz,"ffif2");
+    if (mypgr->umask==NULL) {
+      gree (mypgr->grid,"ffif1");
+      goto err1;
+    }
+    for (i=0; i<mypgr->isiz*mypgr->jsiz; i++) {
+      *(mypgr->grid+i) = *(pgr1->grid+i);
+      *(mypgr->umask+i) = *(pgr1->umask+i);
+    }
+  }
+
+  /* Don't let gagrop free anything  */
+
+  rc = 0;
+  pgrres1=NULL; pgrres2=NULL; pgrres3=NULL;
+
+  pgrres1 = gagrop(pgr1, pst2.result.pgr, 14, 0);
+  if (pgrres1==NULL) rc = 1;
+  if (rc==0) pgrres2 = gagrop(mypgr, pst3.result.pgr, 15, 0);
+  if (pgrres2==NULL) rc = 1;
+  if (rc==0) pgrres3 = gagrop(pgrres2, pgrres1, 2, 0);
+  if (pgrres3==NULL) rc = 1; 
+
+  /* We don't really know what original pgr ended up being our final result.
+     We sure don't want to free that one! We'll do something kloodgy 
+     and compare pointers.  On error, pgrres3 ends up NULL, so everything
+     will get free'd  */
+
+  /* printf ("xxxx %p %p %p %p %p\n",pgrres3,pst->result.pgr,
+                   pst2.result.pgr,pst3.result.pgr,mypgr);
+  printf ("xxxx before gafree pst\n",rc); */
+
+  if (pgrres3 == mypgr) mypgr->alocf = savaloc; /* propagate alocf... */ 
+  else pgr1->alocf = savaloc;      /*  or restore it */
+
+  if (pgrres3 != pst->result.pgr) gafree(pst);
+  if (pgrres3 != pst2.result.pgr) gafree(&pst2);
+  if (pgrres3 != pst3.result.pgr) gafree(&pst3);
+  if (pgrres3 != mypgr) gagfre(mypgr);
+
+  if (rc==0) {
+    pst->type = 1;
+    pst->result.pgr = pgrres3;
+  }
+
+  return (rc);
+
+  err1:
+    gafree(pst);
+    gafree(&pst2);
+    gafree(&pst3);
+    return(1);
+}
+
+
 gaint ffpow (struct gafunc *pfc, struct gastat *pst) {
 struct gastat pst2;
 gaint rc;
@@ -1737,7 +1855,7 @@ char *ch,*fnam,resu;
   /* Check for valid number of args       */
   if (pfc->argnum==2 && !strncmp(pfc->argpnt[1],"global",1)) gflag=1;
   if (pfc->argnum!=5 && !gflag) {
-    snprintf(pout,255,"Error from %s:  Too many or too few args\n",fnam);
+    snprintf(pout,1255,"Error from %s:  Too many or too few args\n",fnam);
     gaprnt(0,pout);
     gaprnt (0,"                  5 arguments expected \n");
     return (1);
@@ -1745,7 +1863,7 @@ char *ch,*fnam,resu;
 
   /* Check environment.  Z or T or E can't vary.  */
   if (pst->idim>1 || pst->jdim>1) {
-    snprintf(pout,255,"Error from %s  Invalid environment.  ",fnam);
+    snprintf(pout,1255,"Error from %s  Invalid environment.  ",fnam);
     gaprnt(0,pout);
     gaprnt (0,"Z, T, or E can't vary.\n");
     return (1);
@@ -1813,7 +1931,7 @@ char *ch,*fnam,resu;
   return (0);
 
 err1:
-  snprintf(pout,255,"Error from %s:  Invalid dimension expression \n",fnam);
+  snprintf(pout,1255,"Error from %s:  Invalid dimension expression \n",fnam);
   gaprnt(0,pout);
   return (1);
 }
@@ -1872,7 +1990,7 @@ gaint mnmx (struct gafunc *pfc, struct gastat *pst, int sel) {
   /* Check for valid number of args       */
   if (pfc->argnum==2 && !strncmp(pfc->argpnt[1],"global",1)) gflag=1;
   if (pfc->argnum!=5 && !gflag) {
-    snprintf(pout,255,"Error from %s:  Too many or too few args\n",fnam);
+    snprintf(pout,1255,"Error from %s:  Too many or too few args\n",fnam);
     gaprnt(0,pout);
     gaprnt (0,"                  5 arguments expected \n");
     return (1);
@@ -1880,7 +1998,7 @@ gaint mnmx (struct gafunc *pfc, struct gastat *pst, int sel) {
 
   /* Check environment.  Z or T or E can't vary.  */
   if (pst->idim>1 || pst->jdim>1) {
-    snprintf(pout,255,"Error from %s  Invalid environment.  ",fnam);
+    snprintf(pout,1255,"Error from %s  Invalid environment.  ",fnam);
     gaprnt(0,pout);
     gaprnt (0,"Z, T, or E can't vary.\n");
     return (1);
@@ -1978,7 +2096,7 @@ gaint mnmx (struct gafunc *pfc, struct gastat *pst, int sel) {
   return (0);
 
 err1:
-  snprintf(pout,255,"Error from %s:  Invalid dimension expression \n",fnam);
+  snprintf(pout,1255,"Error from %s:  Invalid dimension expression \n",fnam);
   gaprnt(0,pout);
   return (1);
 }
@@ -2368,7 +2486,7 @@ size_t sz;
   fnam = tmnam[sel-1];
   /* Check for valid number of args       */
   if (pfc->argnum!=4) {
-    snprintf(pout,255,"Error from %s:  Too many or too few args\n",fnam);
+    snprintf(pout,1255,"Error from %s:  Too many or too few args\n",fnam);
     gaprnt (0,pout);
     gaprnt (0,"                   4 arguments expected \n");
     return (1);
@@ -2378,11 +2496,11 @@ size_t sz;
   pfi = pst->pfid;
   ch = dimprs (pfc->argpnt[2], pst, pfi, &dim, &t1, 1, &wflag);
   if (ch==NULL || dim!=3 || wflag==2) {
-    snprintf(pout,255,"Error from %s:  1st dimension expr invalid\n",fnam);
+    snprintf(pout,1255,"Error from %s:  1st dimension expr invalid\n",fnam);
     gaprnt (0,pout);
     if (dim!=3) gaprnt (0,"  expr does not describe time dimension\n");
     if (wflag==2) {
-      snprintf(pout,255,"  offt expression not supported as an arg to %s\n",fnam);
+      snprintf(pout,1255,"  offt expression not supported as an arg to %s\n",fnam);
       gaprnt (0,pout);
     }
     return (1);
@@ -2391,12 +2509,12 @@ size_t sz;
   /* Now parse the 2nd dimension expression.  */
   ch = dimprs (pfc->argpnt[3], pst, pfi, &dim, &t2, 1, &wflag);
   if (ch==NULL || dim!=3 || t2<t1 || wflag==2) {
-    snprintf(pout,255,"Error from %s:  2nd dimension expr invalid\n",fnam);
+    snprintf(pout,1255,"Error from %s:  2nd dimension expr invalid\n",fnam);
     gaprnt (0,pout);
     if (dim!=3) gaprnt (0,"  expr does not describe time dimension\n");
     if (t2<t1)  gaprnt (0,"  end time is earlier than start time\n");
     if (wflag==2) {
-      snprintf(pout,255,"  offt expression not supported as an arg to %s\n",fnam);
+      snprintf(pout,1255,"  offt expression not supported as an arg to %s\n",fnam);
       gaprnt (0,pout);
     }
     return (1);
@@ -2406,7 +2524,7 @@ size_t sz;
   if (pst->jdim==dim) pst->jdim = -1;
   d1 =  ceil(t1-0.001);          /* Loop limits are integers    */
   d2 = floor(t2+0.001);          /* No weighting  */
-  snprintf(pout,255,"%s:  dim = %i, start = %i, end = %i\n", fnam, dim, d1, d2);
+  snprintf(pout,1255,"%s:  dim = %i, start = %i, end = %i\n", fnam, dim, d1, d2);
   gaprnt (2,pout);
 
   rc = 0;
@@ -2422,7 +2540,7 @@ size_t sz;
     }
     pgr = pst->result.pgr;
     if (pgr->idim != -1 || pgr->isiz!=1 || pgr->jsiz!=1) {
-      snprintf(pout,255,"Error from %s:  1st arg must be 0-D\n",fnam);
+      snprintf(pout,1255,"Error from %s:  1st arg must be 0-D\n",fnam);
       gaprnt (0,pout);
       gafree (pst);
       goto err2;
@@ -2646,19 +2764,19 @@ size_t sz;
   return (0);
 
 err1:
-  snprintf(pout,255,"Error from %s:  Memory allocation error\n",fnam);
+  snprintf(pout,1255,"Error from %s:  Memory allocation error\n",fnam);
   gaprnt (0,pout);
   if (mn1) gree(mn1,"f411");
   if (mn1u) gree(mn1u,"f412");
   return (1);
 err2:
-  snprintf(pout,255,"Error from %s:  Error getting grids\n",fnam);
+  snprintf(pout,1255,"Error from %s:  Error getting grids\n",fnam);
   gaprnt (0,pout);
   if (mn1) gree(mn1,"f413");
   if (mn1u) gree(mn1u,"f414");
   return (1);
 err3:
-  snprintf(pout,255,"Error from %s:  Args must be grid data\n",fnam);
+  snprintf(pout,1255,"Error from %s:  Args must be grid data\n",fnam);
   gaprnt (0,pout);
   if (mn1) gree(mn1,"f415");
   if (mn1u) gree(mn1u,"416");
@@ -2735,7 +2853,7 @@ char *ch,*fnam,*sumu,*cntu,*valu;
 
   /* Check for valid number of args */
   if (pfc->argnum<3 || pfc->argnum>5) {
-    snprintf(pout,255,"Error from %s:  Too many or too few args \n",fnam);
+    snprintf(pout,1255,"Error from %s:  Too many or too few args \n",fnam);
     gaprnt(0,pout);
     gaprnt (0,"                 3 to 5 arguments expected \n");
     return (1);
@@ -2745,10 +2863,10 @@ char *ch,*fnam,*sumu,*cntu,*valu;
   pfi = pst->pfid;
   ch = dimprs (pfc->argpnt[1], pst, pfi, &dim, &gr1, 1, &wflag);
   if (ch==NULL || wflag==2) {
-    snprintf(pout,255,"Error from %s:  1st dimension expression invalid\n",fnam);
+    snprintf(pout,1255,"Error from %s:  1st dimension expression invalid\n",fnam);
     gaprnt(0,pout);
     if (wflag==2) {
-      snprintf(pout,255,"  offt expression not supported as an arg to %s\n",fnam);
+      snprintf(pout,1255,"  offt expression not supported as an arg to %s\n",fnam);
       gaprnt (0,pout);
     }
     return (1);
@@ -2757,12 +2875,12 @@ char *ch,*fnam,*sumu,*cntu,*valu;
   /* Parse the 2nd dimension expression */
   ch = dimprs (pfc->argpnt[2], pst, pfi, &dim2, &gr2, 1, &wflag);
   if (ch==NULL || dim2!=dim || gr2<gr1 || wflag==2) {
-    snprintf(pout,255,"Error from %s:  2nd dimension expression invalid\n",fnam);
+    snprintf(pout,1255,"Error from %s:  2nd dimension expression invalid\n",fnam);
     gaprnt(0,pout);
     if (dim2!=dim) gaprnt (0,"  start and end points have different dimensions\n");
     if (gr2<gr1)   gaprnt (0,"  end grid point is less than start grid point \n");
     if (wflag==2) {
-      snprintf(pout,255,"  offt expression not supported as an arg to %s\n",fnam);
+      snprintf(pout,1255,"  offt expression not supported as an arg to %s\n",fnam);
       gaprnt (0,pout);
     }
     return (1);
@@ -2776,14 +2894,14 @@ char *ch,*fnam,*sumu,*cntu,*valu;
     if (*(pfc->argpnt[3]) == '-') {    /* Option flags? */
       if (*(pfc->argpnt[3]+1) == 'b') bndflg = 1;
       else {
-        snprintf(pout,255,"Error from %s: Invalid option flags\n",fnam);
+        snprintf(pout,1255,"Error from %s: Invalid option flags\n",fnam);
         gaprnt(0,pout);
         return(1);
       }
     } else {                           
       /* Must be time increment */
       if (dim!=3) {
-        snprintf(pout,255,"Error from %s: Invalid usage of increment value\n",fnam);
+        snprintf(pout,1255,"Error from %s: Invalid usage of increment value\n",fnam);
         gaprnt(0,pout);
         gaprnt (0,"                Can only be used with time averaging\n");
         return (1);
@@ -2816,7 +2934,7 @@ char *ch,*fnam,*sumu,*cntu,*valu;
     if (*(pfc->argpnt[4]) == '-' &&
         *(pfc->argpnt[4]+1) == 'b') bndflg = 1;
     else {
-      snprintf(pout,255,"Error from %s: Invalid option flags\n",fnam);
+      snprintf(pout,1255,"Error from %s: Invalid option flags\n",fnam);
       gaprnt(0,pout);
       return(1);
     }
@@ -2844,9 +2962,9 @@ char *ch,*fnam,*sumu,*cntu,*valu;
 
   if(mfcmn.warnflg > 0) {
     if (sel == 1) {
-      snprintf(pout,255,"Averaging.  dim = %i, start = %i, end = %i\n", dim, d1, d2);
+      snprintf(pout,1255,"Averaging.  dim = %i, start = %i, end = %i\n", dim, d1, d2);
     } else {
-      snprintf(pout,255,"%sing.  dim = %i, start = %i, end = %i\n", fnam, dim, d1, d2);
+      snprintf(pout,1255,"%sing.  dim = %i, start = %i, end = %i\n", fnam, dim, d1, d2);
     }
     gaprnt (2,pout);
   }
@@ -3227,7 +3345,7 @@ char *ch,*fnam,*sumu,*cntu,*valu;
     if (rc==-1) gafree (pst);
     gagfre(pgr1);
     gagfre(pgr2);
-    snprintf(pout,255,"Error from %s:  Error getting grids \n",fnam);
+    snprintf(pout,1255,"Error from %s:  Error getting grids \n",fnam);
     gaprnt(0,pout);
     return (rc);
   } else {
@@ -3239,12 +3357,12 @@ char *ch,*fnam,*sumu,*cntu,*valu;
       for (i=0; i<siz; i++) {
         if (*sumu!=0) {
           if (sel < 3 && *cnt==0.0) {
-            snprintf(pout,255,"Error from %s:  Internal logic check 100\n",fnam);
+            snprintf(pout,1255,"Error from %s:  Internal logic check 100\n",fnam);
             gaprnt(0,pout);
             return (1);
           }
           if (sel > 6 && *cntu==0) {
-            snprintf(pout,255,"Error from %s:  Internal logic check 101\n",fnam);
+            snprintf(pout,1255,"Error from %s:  Internal logic check 101\n",fnam);
             gaprnt(0,pout);
             return (1);
           }
@@ -3268,7 +3386,7 @@ char *ch,*fnam,*sumu,*cntu,*valu;
   return (0);
 
 err3:
-  snprintf(pout,255,"Error from %s: Invalid time increment argument\n",fnam);
+  snprintf(pout,1255,"Error from %s: Invalid time increment argument\n",fnam);
   gaprnt(0,pout);
   return (1);
 }
@@ -3333,7 +3451,7 @@ char *ch,*sumu,*valu;
   d2 = floor(gr2+0.001);
 
   if(mfcmn.warnflg > 0) {
-    snprintf(pout,255,"Integrating.  dim = %i, start = %i, end = %i\n", dim, d1, d2);
+    snprintf(pout,1255,"Integrating.  dim = %i, start = %i, end = %i\n", dim, d1, d2);
     gaprnt (2,pout);
   }
 
@@ -3872,7 +3990,7 @@ char *tvu, *rhu;
     }
   } else {
     p = pst->dmin[2];
-    snprintf(pout,255," Using fixed pressure level %g mb\n",p);
+    snprintf(pout,1255," Using fixed pressure level %g mb\n",p);
     if (tflag) {
       gaprnt (2,"Notice from TVRH2T:");
     } else {
@@ -3910,7 +4028,7 @@ char *tvu, *rhu;
   }
 
   if (errcnt) {
-    snprintf(pout,255," Convergence failed for %i grid points\n",errcnt);
+    snprintf(pout,1255," Convergence failed for %i grid points\n",errcnt);
     if (tflag) {
       gaprnt (1,"Warning from TVRH2T:");
     } else {
@@ -5065,7 +5183,7 @@ gaint ffclgr (struct gafunc *pfc, struct gastat *pst) {
   clct0 = *(pst->pclct+clnm);
   clct = clct0;
   if (clct==NULL) {
-     snprintf(pout,255,"Error from COLL2GR:  Collection %i empty\n",clnm);
+     snprintf(pout,1255,"Error from COLL2GR:  Collection %i empty\n",clnm);
      gaprnt (0,pout);
      return (1);
   }
@@ -6004,7 +6122,7 @@ size_t sz;
   gr2t (pfi->grvals[3],d2,&tend);
   gat2ch (&tstrt,5,chs,20);
   gat2ch (&tend,5,che,20);
-  snprintf(pout,255,"Stn Averaging.  Dim = %i, Start = %s, End = %s Incr(mos,mns) = %i %i\n", 
+  snprintf(pout,1255,"Stn Averaging.  Dim = %i, Start = %s, End = %s Incr(mos,mns) = %i %i\n", 
 	   dim, chs, che, mos, mns);
   gaprnt (2,pout);
 
@@ -6139,7 +6257,7 @@ err:
   gasfre(stnr);
   return(1);
 err3:
-  snprintf(pout,255,"Error from STNAVE: Invalid time increment argument\n");
+  snprintf(pout,1255,"Error from STNAVE: Invalid time increment argument\n");
   gaprnt(0,pout);
   return (1);
 }
@@ -6375,14 +6493,14 @@ size_t sz;
 
   /* Check for X, Y varying environment */
   if (pst->idim!=0 || pst->jdim!=1) {
-    snprintf(pout,255,"Error from %s:  X, Y varying environment required\n",fnam);
+    snprintf(pout,1255,"Error from %s:  X, Y varying environment required\n",fnam);
     gaprnt (0,pout);
     return(1);
   }
 
   /* Check for valid number of args */
   if (pfc->argnum<3 || pfc->argnum>4) {
-    snprintf(pout,255,"Error from %s:  Too many or too few args \n",fnam);
+    snprintf(pout,1255,"Error from %s:  Too many or too few args \n",fnam);
     gaprnt (0,pout);
     gaprnt (0,"                    3 or 4 arguments expected \n");
     return (1);
@@ -6392,10 +6510,10 @@ size_t sz;
   pfi = pst->pfid;
   ch = dimprs (pfc->argpnt[1], pst, pfi, &dim, &gr1, 1, &wflag);
   if (ch==NULL || dim!=3 || wflag==2) {
-    snprintf(pout,255,"Error from %s:  1st dimension expression invalid\n",fnam);
+    snprintf(pout,1255,"Error from %s:  1st dimension expression invalid\n",fnam);
     gaprnt (0,pout);
     if (wflag==2) {
-      snprintf(pout,255,"  offt expression not supported as an arg to %s\n",fnam);
+      snprintf(pout,1255,"  offt expression not supported as an arg to %s\n",fnam);
       gaprnt (0,pout);
     }
     return (1);
@@ -6404,10 +6522,10 @@ size_t sz;
   /* Now parse the 2nd dimension expression. */
   ch = dimprs (pfc->argpnt[2], pst, pfi, &dim2, &gr2, 1, &wflag);
   if (ch==NULL || dim2!=dim || wflag==2) {
-    snprintf(pout,255,"Error from %s:  2nd dimension expression invalid\n",fnam);
+    snprintf(pout,1255,"Error from %s:  2nd dimension expression invalid\n",fnam);
     gaprnt (0,pout);
     if (wflag==2) {
-      snprintf(pout,255,"  offt expression not supported as an arg to %s\n",fnam);
+      snprintf(pout,1255,"  offt expression not supported as an arg to %s\n",fnam);
       gaprnt (0,pout);
     }
     return (1);
@@ -6505,7 +6623,7 @@ size_t sz;
   return(0);
 
 err:
-  snprintf(pout,255,"Error from %s:  Unable to evaluate expression\n",fnam);
+  snprintf(pout,1255,"Error from %s:  Unable to evaluate expression\n",fnam);
   gaprnt (0,pout);
   gafree(pst);
   gasfre(stnr);
@@ -6713,185 +6831,173 @@ size_t sz;
   return (0);
 }
 
-/* Routine to read the user function definition file, and build
-   the appropriate link list of function definition blocks.
-   The file name is pointed to by the GAFDEF environment variable;
-   if unset then no user functions will be set up */
+/* Routine to read the user function definition file. Cruft. */
 
 void gafdef (void) {
-/* struct gaufb *ufb, *oufb=NULL; */
-/* char *cname; */
-/* FILE *cfile; */
-/* char rec[260],*ch; */
-/* gaint i,j,pass; */
-
   ufba = NULL;
   return; 
+}
 
-  /* remainder of subroutine commented out pending implementation of DLLs */
+/* Routine to read the user defined plug-in table
+   and build link list of plug-in definition blocks.
+   The table file name is pointed to by the GAUDPT environment variable 
+   and/or a file called "udpt" in the GADDIR directory */
+
+void gaudpdef (void) {
+struct gaupb *upb, *oupb=NULL;
+char *cname;
+FILE *cfile;
+char *ch,ptype[16],rec[500];
+gaint i,sz,pass,line,err;
+
+  upba = NULL;
+
+  /* Make two passes.  
+     First read user specified plug-in table (in GAUDPT), 
+     then read system plug-in table (in GADDIR) */
+
+  pass = 0;
+  while (pass<2) {
+    if (pass==0) {
+      /* check if user has set the GAUDPT environment variable */
+      cname = getenv("GAUDPT");
+      if (cname==NULL) {
+        pass++;
+        continue;
+      }
+      cfile = fopen(cname,"r");
+      if (cfile==NULL) {
+        gaprnt(0,"Error opening User Defined Plug-in Table\n");
+        snprintf(pout,1255,"  File name is: %s\n",cname);
+        gaprnt (0,pout);
+        pass++;
+	gree(cname,"f300");
+        continue;
+      }
+    }
+    /* check for a file called "udpt" in the GADDIR directory */
+     else {
+      cname = gxgnam("udpt");
+      cfile = fopen(cname,"r");
+      if (cfile==NULL) {
+	gree(cname,"f301");
+	break;
+      }
+    }
 
+    /* Read the file. */
+    line=0;
+    while (1) {
 
-/*   /\* Make two passes.  First read user function table, then read */
-/*      system function table *\/ */
+      /* Read a record from the file */
+      ch = fgets(rec,500,cfile);
+      if (ch==NULL) break;
+      ch = rec;
+      line++;
+      err=0;
+      if (*ch=='*' || *ch=='#') continue;            /* Check if this is a comment field */
 
-/*   pass = 0; */
-/*   while (pass<2) { */
-/*     if (pass==0) { */
-/*       cname = getenv("GAUDFT"); */
-/*       if (cname==NULL) { */
-/*         pass++; */
-/*         continue; */
-/*       } */
-/*       cfile = fopen(cname,"r"); */
-/*       if (cfile==NULL) { */
-/*         gaprnt(0,"Error opening user function definition table\n"); */
-/*         snprintf(pout,255,"  File name is: %s\n",cname); */
-/*         gaprnt (0,pout); */
-/*         pass++; */
-/* 	gree(cname,"f300"); */
-/*         continue; */
-/*       } */
-/*     } else { */
-/*       cname = gxgnam("udft"); */
-/*       cfile = fopen(cname,"r"); */
-/*       if (cfile==NULL) { */
-/* 	gree(cname,"f301"); */
-/* 	break; */
-/*       } */
-/*     } */
-
-/*     /\* Read the file. *\/ */
-
-/*     while (1) { */
-/*       ufb = (struct gaufb *)malloc(sizeof(struct gaufb)); */
-/*       if (ufb==NULL) goto memerr; */
-
-/*       /\* Read First record (name and arg types) *\/ */
-
-/*       ch = fgets(rec,256,cfile); */
-/*       if (ch==NULL) break; */
-/*       ch = rec; */
-/*       lowcas(ch); */
-/*       while (*ch==' ') ch++; */
-/*       i = 0; */
-/*       while (*ch!=' ' && *ch!='\0' && *ch!='\n') { */
-/*         if (i<15) { */
-/*           ufb->name[i] = *ch; */
-/*           i++; */
-/*         } */
-/*         ch++; */
-/*       } */
-/*       ufb->name[i] = '\0'; */
-/*       if (*ch!=' ') goto fmterr; */
-/*       while (*ch==' ') ch++; */
-/*       if (intprs(ch,&(ufb->alo))==NULL) goto fmterr; */
-/*       if ( (ch = nxtwrd(ch))==NULL) goto fmterr; */
-/*       if (intprs(ch,&(ufb->ahi))==NULL) goto fmterr; */
-/*       i = 0; */
-/*       while (i<ufb->ahi) { */
-/*         if ( (ch = nxtwrd(ch))==NULL) goto fmterr; */
-/*         if (cmpwrd("expr",ch)) ufb->atype[i]=1; */
-/*         else if (cmpwrd("value",ch)) ufb->atype[i]=2; */
-/*         else if (cmpwrd("char",ch)) ufb->atype[i]=3; */
-/*         else goto fmterr; */
-/*         i++; */
-/*       } */
-
-/*       /\* Read 2nd record -- options *\/ */
-
-/*       ch = fgets(rec,256,cfile); */
-/*       if (ch==NULL) goto rderr; */
-/*       ch = rec; */
-/*       lowcas(ch); */
-/*       while (*ch==' ') ch++; */
-/*       if (*ch=='\n' || *ch=='\0') goto fmterr; */
-/*       while (1) { */
-/*         if (cmpwrd("direct",ch)) ufb->sflg=0; */
-/*         else if (cmpwrd("sequential",ch)) ufb->sflg=1; */
-/*         else goto fmterr; */
-/*         if ( (ch = nxtwrd(ch))==NULL) break; */
-/*       } */
+      /* allocate memory */
+      upb = (struct gaupb *)malloc(sizeof(struct gaupb));
+      if (upb==NULL) goto memerr;
+      while (*ch==' ') ch++;                                 /* move past leading blanks */
+
+      /* parse the plug-in type keyword*/
+      i = 0;
+      while (*ch!=' ' && *ch!='\0' && *ch!='\n') {
+        if (i<15) {
+          ptype[i] = *ch;
+          i++;
+        }
+        ch++;
+      }
+      ptype[i] = '\0';
+      lowcas(ptype);                               
+      upb->type=0;
+      if (!strncmp(ptype,"function",8)) upb->type=1; 
+      if (!strncmp(ptype,"defop",5))    upb->type=2; 
+      if (upb->type==0) { err=1; goto fmterr; }
+      while (*ch==' ') ch++;                          /* move past any in-between blanks */
+
+      /* parse the function name, must be 15 characters or less */
+      upb->name[0] = '\0';
+      i = 0;
+      while (*ch!=' ' && *ch!='\0' && *ch!='\n') {
+        if (i<15) {
+          upb->name[i] = *ch;
+          i++;
+        }
+        ch++;
+      }
+      upb->name[i] = '\0';
+      lowcas(upb->name);              /* gaexpr requires function names to be lower case */
+      if (i==0) { err=2; goto fmterr; }
+      while (*ch==' ') ch++;                          /* move past any in-between blanks */
+
+      /* parse the shared object filename */
+      upb->fname = NULL;
+      sz = 0;
+      while (*(ch+sz)!=' '&&*(ch+sz)!='\n'&&*(ch+sz)!='\0') sz++;   /* no spaces allowed */
+      if (sz==0) { err=3; goto fmterr; }
+
+
+    fmterr:
+      if (err) {
+	snprintf(pout,1255,"\nWarning: Format error in line %d of user defined plug-in table: %s\n",line,cname);
+	gaprnt (0,pout);
+	if (err==1) gaprnt(0,"  Type must be either 'function' or 'defop'\n\n"); 
+	if (err==2) gaprnt(0,"  Plug-in name and shared object file name are missing\n\n"); 
+	if (err==3) gaprnt(0,"  Shared object file name is missing\n\n"); 
+	if (upb!=NULL) free(upb);
+        continue;
+      }
+    
+      upb->fname = (char *)malloc(sz+2);
+      if (upb->fname==NULL) { free(upb); goto memerr; }
+      for (i=0; i<sz; i++) {
+ 	upb->fname[i] = *ch;
+        ch++;
+      }
+      upb->fname[sz] = '\0';
 
-/*       /\* Read 3rd record -- file name of executable *\/ */
+      /* set the function pointer to NULL */
+      upb->pfunc = NULL;
 
-/*       ch = fgets(rec,256,cfile); */
-/*       if (ch==NULL) goto rderr; */
-/*       i = 0; */
-/*       while (rec[i]!='\n' && rec[i]!='\0') i++; */
-/*       ufb->fname = (char *)malloc(i+1); */
-/*       if (ufb->fname==NULL) { */
-/*         free(ufb); */
-/*         goto memerr; */
-/*       } */
-/*       for (j=0; j<i; j++) *(ufb->fname+j) = rec[j]; */
-/*       *(ufb->fname+i) = '\0'; */
-
-/*       /\* Read 4th record -- file name of data transfer to user *\/ */
-
-/*       ch = fgets(rec,256,cfile); */
-/*       if (ch==NULL) goto rderr; */
-/*       i = 0; */
-/*       while (rec[i]!='\n' && rec[i]!='\0') i++; */
-/*       ufb->oname = (char *)malloc(i+1); */
-/*       if (ufb->oname==NULL) { */
-/*         free(ufb); */
-/*         goto memerr; */
-/*       } */
-/*       for (j=0; j<i; j++) *(ufb->oname+j) = rec[j]; */
-/*       *(ufb->oname+i) = '\0'; */
-
-/*       /\* Read 5th record -- file name for data transfer from user *\/ */
-
-/*       ch = fgets(rec,256,cfile); */
-/*       if (ch==NULL) goto rderr; */
-/*       i = 0; */
-/*       while (rec[i]!='\n' && rec[i]!='\0') i++; */
-/*       ufb->iname = (char *)malloc(i+1); */
-/*       if (ufb->iname==NULL) { */
-/*         free(ufb); */
-/*         goto memerr; */
-/*       } */
-/*       for (j=0; j<i; j++) *(ufb->iname+j) = rec[j]; */
-/*       *(ufb->iname+i) = '\0'; */
+      /* Chain this up */
+      upb->upb = NULL;
 
-/*       /\* Chain this ufb *\/ */
+      if (upba==NULL) upba = upb;
+      else oupb->upb = upb;
+      oupb = upb;
+    }
 
-/*       ufb->ufb = NULL; */
+    fclose (cfile);
+    if (pass>0 && cname!=NULL) gree(cname,"f306");
+    pass++;
+  }
+  return;
 
-/*       if (ufba==NULL) ufba = ufb; */
-/*       else oufb->ufb = ufb; */
-/*       oufb = ufb; */
-/*     } */
+memerr:
+  gaprnt(0,"Memory allocation error when parsing user defined plug-in table\n");
+  return;
 
-/*     fclose (cfile); */
-/*     if (pass>0 && cname!=NULL) gree(cname,"f306"); */
-/*     pass++; */
-/*   } */
-/*   return; */
-
-/* memerr: */
-/*   gaprnt(0,"Memory allocation error: user defined functions\n"); */
-/*   return; */
-
-/* fmterr: */
-/*   gaprnt(0,"Format error in user defined function table:\n"); */
-/*   snprintf(pout,255,"  Processing function name: %s\n",ufb->name); */
-/*   gaprnt (0,pout); */
-/*   free(ufb); */
-/*   goto wname; */
-
-/* rderr: */
-/*   gaprnt(0,"Read error on user defined function table:\n"); */
-/*   free(ufb); */
-/*   goto wname; */
-
-/* wname: */
-/*   snprintf(pout,255,"  File name is: %s\n",cname); */
-/*   gaprnt (0,pout); */
-/*   if (cname!=NULL) gree(cname,"f309"); */
-/*   return; */
 }
 
+/* Prints the contents of the chain of upb structures */
+void gaqupb (void) {
+struct gaupb *upb;
+  upb = upba;
+  while (upb) {
+    if (upb->type) {
+      if (upb->type==1)
+        sprintf (pout,"function: %s  Exec: %s\n",upb->name, upb->fname);
+      if (upb->type==2)
+        sprintf (pout,"defop: %s  Exec: %s\n",upb->name, upb->fname);
+      gaprnt (2,pout);
+    }
+    upb = upb->upb;
+  }
+}
 
 gaint ffflvl (struct gafunc *pfc, struct gastat *pst) {
 struct gagrid *pgr1, *pgr2, *pgrv;
@@ -7255,3 +7361,43 @@ size_t sz;
   return (0);
 }
 
+gaint ffudpi (struct gafunc *pfc, struct gastat *pst2, struct gaupb *upb) {
+struct gaudpinfo *pudpinfo;
+void *handle;
+char *error;
+gaint rc;
+gaint (*pfunc)(struct gafunc *, struct gastat *, struct gaudpinfo *);
+
+  /* set up the pointer to gaexpr */
+  pudpinfo = malloc(sizeof(struct gaudpinfo)); 
+  pudpinfo->exprptr = gaexpr;
+  pudpinfo->version = UDPVERS; 
+
+  /* load the shared object file and get the function pointer */
+  if (upb->pfunc == NULL) {
+    handle = dlopen(upb->fname,RTLD_LAZY);
+    if (handle==NULL) {
+      snprintf (pout,1255,"Error: dlopen failed to get a handle on %s \n",upb->fname);
+      gaprnt (0,pout);
+      return (1);
+    }
+    dlerror();
+    pfunc = dlsym(handle,upb->name);
+    if ((error=dlerror()) != NULL) {
+      snprintf (pout,1255,"Error: dlsym failed to load %s \n%s \n",upb->name,error);
+      gaprnt (0,pout);
+      return (1);
+    }
+    /* save the function pointer */
+    upb->pfunc = pfunc;
+  }
+  else {
+    pfunc = upb->pfunc;
+  }
+
+  /* call the function */
+  rc = (*pfunc)(pfc,pst2,pudpinfo);
+  
+  free (pudpinfo);
+  return (rc);
+}
diff --git a/src/gagx.c b/src/gagx.c
index 3b8e95f..6067213 100644
--- a/src/gagx.c
+++ b/src/gagx.c
@@ -37,7 +37,7 @@
 #endif
 
 void gatmlb (struct gacmn *);    /* time label*/
-static char pout[256];           /* Build error msgs here */
+static char pout[1256];           /* Build error msgs here */
 static struct mapprj mpj;        /* Common map projection structure */
 static gadouble wxymin,wxymax;   /* wx symbol limits */
 #if USESHP==1
@@ -123,9 +123,9 @@ gaint proj;
 	}
 	else {
 	  if (pgr->umin==1)
-	    snprintf(pout,255,"Result value = %g \n",pgr->rmin);
+	    snprintf(pout,1255,"Result value = %g \n",pgr->rmin);
 	  else
-	    snprintf(pout,255,"Result value = %g \n",pcm->undef);
+	    snprintf(pout,1255,"Result value = %g \n",pcm->undef);
 	  gaprnt (2,pout);
 	}
       }
@@ -206,11 +206,11 @@ void gawgdsval(FILE* outfile, gafloat *val) {
 }
 
 void gawgdstime(FILE* outfile, gadouble *val) {
-  snprintf(pout,255, "pre-byteswapped time: %g", *val); gaprnt(0, pout);
+  snprintf(pout,1255, "pre-byteswapped time: %g", *val); gaprnt(0, pout);
   if (BYTEORDER != 1) {  /* always write big endian for the GDS */
     ganbswp((char*)val, sizeof(gadouble));
   }
-  snprintf(pout,255, "byteswapped time: %g", *val); gaprnt(0, pout);
+  snprintf(pout,1255, "byteswapped time: %g", *val); gaprnt(0, pout);
   fwrite(val, sizeof(gadouble), 1, outfile);
 }
 
@@ -309,22 +309,22 @@ void gaoutgds (struct gacmn *pcm) {
     gaprnt(0, ">>\t");
 
     if (sendstnid) {
-      snprintf(pout,255, "stnid: %.8s  ", ref->stid); gaprnt(0, pout);
+      snprintf(pout,1255, "stnid: %.8s  ", ref->stid); gaprnt(0, pout);
       fwrite(stnidlen, sizeof(char), 4, outfile);
       fwrite(&(ref->stid), sizeof(char), 8, outfile);
     }
     if (sendlon) {
-      snprintf(pout,255, "lon: %f  ", ref->lon); gaprnt(0, pout);
+      snprintf(pout,1255, "lon: %f  ", ref->lon); gaprnt(0, pout);
       outFloat = ref->lon;
       gawgdsval(outfile, &outFloat);
     } 
     if (sendlat) {
-      snprintf(pout,255, "lat: %f  ", ref->lat); gaprnt(0, pout);
+      snprintf(pout,1255, "lat: %f  ", ref->lat); gaprnt(0, pout);
       outFloat = ref->lat;
       gawgdsval(outfile, &outFloat);
     }
     if (sendtime) {
-      snprintf(pout,255, "time: %f  ", coardstime); gaprnt(0, pout);
+      snprintf(pout,1255, "time: %f  ", coardstime); gaprnt(0, pout);
       gawgdstime(outfile, &coardstime);
     }
     gaprnt(0, "\n\t");
@@ -342,7 +342,7 @@ void gaoutgds (struct gacmn *pcm) {
 	goto cleanup;
       }
       if (sendind) {
-	snprintf(pout,255, "[%s: %f]  ", 
+	snprintf(pout,1255, "[%s: %f]  ", 
 		pcm->result[i].stn->pvar->abbrv, currpt[i]->val); 
 	gaprnt(0, pout);
 	outFloat = currpt[i]->val;
@@ -365,7 +365,7 @@ void gaoutgds (struct gacmn *pcm) {
 	fwrite(startrec, sizeof(char), 4, outfile);
 	
 	if (sendlev) {
-	  snprintf(pout,255, "lev: %f  ", levelref->lev); gaprnt(0, pout);
+	  snprintf(pout,1255, "lev: %f  ", levelref->lev); gaprnt(0, pout);
 	  outFloat = levelref->lev;
 	  gawgdsval(outfile, &outFloat);
 	}
@@ -382,7 +382,7 @@ void gaoutgds (struct gacmn *pcm) {
 	    goto cleanup;
 	  }
 	  if (senddep) {
-	    snprintf(pout,255, "[%s: %f]  ", pcm->result[i].stn->pvar->abbrv, 
+	    snprintf(pout,1255, "[%s: %f]  ", pcm->result[i].stn->pvar->abbrv, 
 		    currpt[i]->val); gaprnt(0, pout);
 	    outFloat = currpt[i]->val;
 	    gawgdsval(outfile, &outFloat);
@@ -403,7 +403,7 @@ void gaoutgds (struct gacmn *pcm) {
   /*    gaprnt(0, "EOS\n"); */
   /*    fwrite(endrec, sizeof(char), 4, outfile); */
 
-  snprintf(pout,255, "WRITEGDS: %d reports x %d vars written as %d records\n",
+  snprintf(pout,1255, "WRITEGDS: %d reports x %d vars written as %d records\n",
 	  pcm->result[0].stn->rnum, numvars, numreps); gaprnt(0, pout);
 
 cleanup:
@@ -426,7 +426,7 @@ char *gru;
     /* Data type grid */
     pgr = pcm->result[0].pgr;
     siz = pgr->isiz*pgr->jsiz;
-    snprintf(pout,255,"Printing Grid -- %i Values -- Undef = %g\n", siz, pcm->undef);
+    snprintf(pout,1255,"Printing Grid -- %i Values -- Undef = %g\n", siz, pcm->undef);
     gaprnt(2,pout);
     gr  = pgr->grid;
     gru = pgr->umask;
@@ -437,10 +437,10 @@ char *gru;
           pout[0]='U'; pout[1]='n'; pout[2]='d'; pout[3]='e'; pout[4]='f'; pout[5]='\0';
         } 
 	else if (*gru==0) {
-          snprintf(pout,255,pcm->prstr,pcm->undef);
+          snprintf(pout,1255,pcm->prstr,pcm->undef);
 	}
 	else {
-          snprintf(pout,255,pcm->prstr,*gr);
+          snprintf(pout,1255,pcm->prstr,*gr);
         }
 	/* pad with blanks? */
         if (pcm->prbnum>0) {
@@ -456,9 +456,9 @@ char *gru;
       } 
       else {
         if (*gru==0) 
-          snprintf(pout,255,"%g ",pcm->undef);
+          snprintf(pout,1255,"%g ",pcm->undef);
 	else 
-	  snprintf(pout,255,"%g ",*gr);
+	  snprintf(pout,1255,"%g ",*gr);
         gaprnt (2,pout);
       }
       lnum++;
@@ -473,11 +473,11 @@ char *gru;
   else {                           
     /* Data type station */
     stn = pcm->result[0].stn;
-    snprintf(pout,255,"Printing Stations -- %i Reports -- Undef = %g\n", stn->rnum, pcm->undef);
+    snprintf(pout,1255,"Printing Stations -- %i Reports -- Undef = %g\n", stn->rnum, pcm->undef);
     gaprnt(2,pout);
     rpt = stn->rpt;
     while (rpt) {
-	snprintf(pout,255,"%c%c%c%c%c%c%c%c %-9.4g %-9.4g %-9.4g \n",
+	snprintf(pout,1255,"%c%c%c%c%c%c%c%c %-9.4g %-9.4g %-9.4g \n",
 	   rpt->stid[0], rpt->stid[1], rpt->stid[2], rpt->stid[3],
            rpt->stid[4], rpt->stid[5], rpt->stid[6], rpt->stid[7],
            rpt->lon,rpt->lat,rpt->lev);
@@ -487,16 +487,16 @@ char *gru;
           pout[0]='U'; pout[1]='n'; pout[2]='d'; pout[3]='e'; pout[4]='f'; pout[5]='\0';
         } 
 	else if (rpt->umask==0) {
-          snprintf(pout,255,pcm->prstr,pcm->undef);
+          snprintf(pout,1255,pcm->prstr,pcm->undef);
 	}
 	else {
-          snprintf(pout,255,pcm->prstr,rpt->val);
+          snprintf(pout,1255,pcm->prstr,rpt->val);
         }
       } else {
         if (rpt->umask==0) 
-          snprintf(pout,255,"%g ",pcm->undef);
+          snprintf(pout,1255,"%g ",pcm->undef);
 	else 
-	  snprintf(pout,255,"%g ",rpt->val);
+	  snprintf(pout,1255,"%g ",rpt->val);
       }
       gaprnt(2,pout);
       gaprnt(2,"\n");
@@ -524,10 +524,10 @@ char lab[20];
   if (pcm->type[0] == 1) {          
     pgr = pcm->result[0].pgr;
     gaprnt(2,"Data Type = grid\n");
-    snprintf(pout,255,"Dimensions = %i %i\n", pgr->idim, pgr->jdim);
+    snprintf(pout,1255,"Dimensions = %i %i\n", pgr->idim, pgr->jdim);
     gaprnt(2,pout);
     if (pgr->idim>-1) {
-      snprintf(pout,255,"I Dimension = %i to %i", pgr->dimmin[pgr->idim], pgr->dimmax[pgr->idim]);
+      snprintf(pout,1255,"I Dimension = %i to %i", pgr->dimmin[pgr->idim], pgr->dimmax[pgr->idim]);
       gaprnt(2,pout);
       /* Linear scaling info */
       if (pgr->idim>-1 && pgr->ilinr==1) {     
@@ -539,14 +539,14 @@ char lab[20];
           else 
 	    gat2ch (&dtim,5,lab,20);
           if (*(pgr->ivals+5)!=0) {
-            snprintf(pout,255," %s %gmo\n",lab,*(pgr->ivals+5));
+            snprintf(pout,1255," %s %gmo\n",lab,*(pgr->ivals+5));
           } else {
-            snprintf(pout,255," %s %gmn\n",lab,*(pgr->ivals+6));
+            snprintf(pout,1255," %s %gmn\n",lab,*(pgr->ivals+6));
           }
           gaprnt (2,pout);
         } else {
           conv = pgr->igrab;
-          snprintf(pout,255," %g %g\n",conv(pgr->ivals,pgr->dimmin[pgr->idim]),*(pgr->ivals));
+          snprintf(pout,1255," %g %g\n",conv(pgr->ivals,pgr->dimmin[pgr->idim]),*(pgr->ivals));
           gaprnt (2,pout);
         }
       }
@@ -555,7 +555,7 @@ char lab[20];
         gaprnt(2," Levels");
         conv = pgr->igrab;
         for (i=pgr->dimmin[pgr->idim]; i<=pgr->dimmax[pgr->idim]; i++) {
-          snprintf(pout,255," %g",conv(pgr->ivals,i));
+          snprintf(pout,1255," %g",conv(pgr->ivals,i));
           gaprnt (2,pout);
         }
         gaprnt (2,"\n");
@@ -564,7 +564,7 @@ char lab[20];
       gaprnt(2,"I Dimension = -999 to -999\n");
     }
     if (pgr->jdim>-1) {
-      snprintf(pout,255,"J Dimension = %i to %i",pgr->dimmin[pgr->jdim],pgr->dimmax[pgr->jdim]);
+      snprintf(pout,1255,"J Dimension = %i to %i",pgr->dimmin[pgr->jdim],pgr->dimmax[pgr->jdim]);
       gaprnt(2,pout);
       /* Linear scaling info */
       if (pgr->jdim>-1 && pgr->jlinr==1) {     
@@ -576,14 +576,14 @@ char lab[20];
           else 
 	    gat2ch (&dtim,5,lab,20);
           if (*(pgr->jvals+5)!=0) {
-            snprintf(pout,255," %s %gmo\n",lab,*(pgr->jvals+5));
+            snprintf(pout,1255," %s %gmo\n",lab,*(pgr->jvals+5));
           } else {
-            snprintf(pout,255," %s %gmn\n",lab,*(pgr->jvals+6));
+            snprintf(pout,1255," %s %gmn\n",lab,*(pgr->jvals+6));
           }
           gaprnt (2,pout);
         } else {
           conv = pgr->jgrab;
-          snprintf(pout,255," %g %g\n",conv(pgr->jvals,pgr->dimmin[pgr->jdim]),*(pgr->jvals));
+          snprintf(pout,1255," %g %g\n",conv(pgr->jvals,pgr->dimmin[pgr->jdim]),*(pgr->jvals));
           gaprnt (2,pout);
         }
       }
@@ -592,7 +592,7 @@ char lab[20];
         gaprnt(2," Levels");
         conv = pgr->jgrab;
         for (i=pgr->dimmin[pgr->jdim]; i<=pgr->dimmax[pgr->jdim]; i++) {
-          snprintf(pout,255," %g",conv(pgr->jvals,i));
+          snprintf(pout,1255," %g",conv(pgr->jvals,i));
           gaprnt (2,pout);
         }
         gaprnt (2,"\n");
@@ -601,9 +601,9 @@ char lab[20];
       gaprnt(2,"J Dimension = -999 to -999\n");
     }
     siz = pgr->isiz*pgr->jsiz;
-    snprintf(pout,255,"Sizes = %i %i %i\n",pgr->isiz,pgr->jsiz,siz);
+    snprintf(pout,1255,"Sizes = %i %i %i\n",pgr->isiz,pgr->jsiz,siz);
     gaprnt(2,pout);
-    snprintf(pout,255,"Undef value = %g\n",pcm->undef);
+    snprintf(pout,1255,"Undef value = %g\n",pcm->undef);
     gaprnt(2,pout);
     ucnt = 0;  gcnt = 0; sum=0; sumsqr=0; 
     gr = pgr->grid;
@@ -617,11 +617,11 @@ char lab[20];
 	gcnt++;
       }
     }
-    snprintf(pout,255,"Undef count = %i  Valid count = %i\n",ucnt,gcnt);
+    snprintf(pout,1255,"Undef count = %i  Valid count = %i\n",ucnt,gcnt);
     gaprnt(2,pout);
     if (pgr->idim>-1) {
       gamnmx (pgr);
-      snprintf(pout,255,"Min, Max = %g %g\n",pgr->rmin,pgr->rmax);
+      snprintf(pout,1255,"Min, Max = %g %g\n",pgr->rmin,pgr->rmax);
       gaprnt(2,pout);
       cint = 0.0;
       gacsel (pgr->rmin,pgr->rmax,&cint,&cmin,&cmax);
@@ -635,51 +635,51 @@ char lab[20];
         cmax = pgr->rmax+5.0;
         cint = 1.0;
       }
-      snprintf(pout,255,"Cmin, cmax, cint = %g %g %g\n",cmin,cmax,cint);
+      snprintf(pout,1255,"Cmin, cmax, cint = %g %g %g\n",cmin,cmax,cint);
       gaprnt(2,pout);
       gcntm1=gcnt-1;
       if(gcntm1<=0) gcntm1=1;
       gcnto=gcnt;
       if(gcnt<=0) gcnt=1;
-      snprintf(pout,255,"Stats[sum,sumsqr,root(sumsqr),n]:     %g %g %g %d\n",
+      snprintf(pout,1255,"Stats[sum,sumsqr,root(sumsqr),n]:     %g %g %g %d\n",
 	       sum,sumsqr,sqrt(sumsqr),gcnto);
       gaprnt(2,pout);
-      snprintf(pout,255,"Stats[(sum,sumsqr,root(sumsqr))/n]:     %g %g %g\n",
+      snprintf(pout,1255,"Stats[(sum,sumsqr,root(sumsqr))/n]:     %g %g %g\n",
 	       sum/gcnt,sumsqr/gcnt,sqrt(sumsqr/gcnt));
       gaprnt(2,pout);
-      snprintf(pout,255,"Stats[(sum,sumsqr,root(sumsqr))/(n-1)]: %g %g %g\n",
+      snprintf(pout,1255,"Stats[(sum,sumsqr,root(sumsqr))/(n-1)]: %g %g %g\n",
 	       sum/gcntm1,sumsqr/gcntm1,sqrt(sumsqr/gcntm1));
       gaprnt(2,pout);
       dum=(sumsqr/gcnt)-((sum/gcnt)*(sum/gcnt));
       if(dum>0){
-	snprintf(pout,255,"Stats[(sigma,var)(n)]:     %g %g\n",sqrt(dum),dum);
+	snprintf(pout,1255,"Stats[(sigma,var)(n)]:     %g %g\n",sqrt(dum),dum);
       } else {
-	snprintf(pout,255,"Stats[(sigma,var)(n)]:     %g %g\n",0.0,0.0);
+	snprintf(pout,1255,"Stats[(sigma,var)(n)]:     %g %g\n",0.0,0.0);
       }
       gaprnt(2,pout);
       dum=dum*(gcnt/gcntm1);
       if(dum>0) {
-	snprintf(pout,255,"Stats[(sigma,var)(n-1)]:   %g %g\n",sqrt(dum),dum);
+	snprintf(pout,1255,"Stats[(sigma,var)(n-1)]:   %g %g\n",sqrt(dum),dum);
       } else {
-	snprintf(pout,255,"Stats[(sigma,var)(n-1)]:   %g %g\n",0.0,0.0);
+	snprintf(pout,1255,"Stats[(sigma,var)(n-1)]:   %g %g\n",0.0,0.0);
       }
       gaprnt(2,pout);
     } else {
-      snprintf(pout,255,"Min, Max = %g %g\n",pgr->rmin,pgr->rmin);
+      snprintf(pout,1255,"Min, Max = %g %g\n",pgr->rmin,pgr->rmin);
       gaprnt(2,pout);
     }
 
   } else {                           /* Data type station */
     gaprnt(2,"Data Type = station\n");
     stn = pcm->result[0].stn;
-    snprintf(pout,255,"Dimensions = %i %i\n",stn->idim,stn->jdim);
+    snprintf(pout,1255,"Dimensions = %i %i\n",stn->idim,stn->jdim);
     gaprnt(2,pout);
     if (stn->idim>-1) {
       if (stn->idim!=3) {
-        snprintf(pout,255,"I Dimension = %g to %g\n",stn->dmin[stn->idim],stn->dmax[stn->idim]);
+        snprintf(pout,1255,"I Dimension = %g to %g\n",stn->dmin[stn->idim],stn->dmax[stn->idim]);
         gaprnt(2,pout);
       } else {
-        snprintf(pout,255,"I Dimension = %i to %i\n",stn->tmin, stn->tmax);
+        snprintf(pout,1255,"I Dimension = %i to %i\n",stn->tmin, stn->tmax);
         gaprnt(2,pout);
       }
     } else {
@@ -687,18 +687,18 @@ char lab[20];
     }
     if (stn->jdim>-1) {
       if (stn->jdim!=3) {
-        snprintf(pout,255,"J Dimension = %g to %g\n",stn->dmin[stn->jdim],stn->dmax[stn->jdim]);
+        snprintf(pout,1255,"J Dimension = %g to %g\n",stn->dmin[stn->jdim],stn->dmax[stn->jdim]);
         gaprnt(2,pout);
       } else {
-        snprintf(pout,255,"J Dimension = %i to %i\n",stn->tmin, stn->tmax);
+        snprintf(pout,1255,"J Dimension = %i to %i\n",stn->tmin, stn->tmax);
         gaprnt(2,pout);
       }
     } else {
       gaprnt(2,"J Dimension = -999 to -999\n");
     }
-    snprintf(pout,255,"Stn count = %i\n",stn->rnum);
+    snprintf(pout,1255,"Stn count = %i\n",stn->rnum);
     gaprnt(2,pout);
-    snprintf(pout,255,"Undef value = %g\n",pcm->undef);
+    snprintf(pout,1255,"Undef value = %g\n",pcm->undef);
     gaprnt(2,pout);
     ucnt = 0;  gcnt = 0; sum=0; sumsqr=0;  
     rmin = 9e33;
@@ -724,9 +724,9 @@ char lab[20];
       rmax = pcm->undef;
     }
 
-    snprintf(pout,255,"Undef count = %i  Valid count = %i \n",ucnt,gcnt);
+    snprintf(pout,1255,"Undef count = %i  Valid count = %i \n",ucnt,gcnt);
     gaprnt(2,pout);
-    snprintf(pout,255,"Min, Max = %g %g\n",rmin,rmax);
+    snprintf(pout,1255,"Min, Max = %g %g\n",rmin,rmax);
     gaprnt(2,pout);
     cint = 0.0;
 
@@ -740,50 +740,50 @@ char lab[20];
       cmax = rmax+5.0;
       cint = 1.0;
     }
-    snprintf(pout,255,"Cmin, cmax, cint = %g %g %g\n",cmin,cmax,cint);
+    snprintf(pout,1255,"Cmin, cmax, cint = %g %g %g\n",cmin,cmax,cint);
     gaprnt(2,pout);
 
     gcntm1 = gcnt-1;
     if(gcntm1 <= 0) gcntm1=1;
     gcnto = gcnt;
     if(gcnt <= 0) gcnt=1;
-    snprintf(pout,255,"Stats[sum,sumsqr,root(sumsqr),n]:     %g %g %g %d\n",
+    snprintf(pout,1255,"Stats[sum,sumsqr,root(sumsqr),n]:     %g %g %g %d\n",
 	     sum,sumsqr,sqrt(sumsqr),gcnto);
     gaprnt(2,pout);
-    snprintf(pout,255,"Stats[(sum,sumsqr,root(sumsqr))/n)]:     %g %g %g\n",
+    snprintf(pout,1255,"Stats[(sum,sumsqr,root(sumsqr))/n)]:     %g %g %g\n",
 	     sum/gcnt,sumsqr/gcnt,sqrt(sumsqr/gcnt));
     gaprnt(2,pout);
-    snprintf(pout,255,"Stats[(sum,sumsqr,root(sumsqr))/(n-1))]: %g %g %g\n",
+    snprintf(pout,1255,"Stats[(sum,sumsqr,root(sumsqr))/(n-1))]: %g %g %g\n",
 	     sum/gcntm1,sumsqr/gcntm1,sqrt(sumsqr/gcntm1));
     gaprnt(2,pout);
     dum=(sumsqr/gcnt)-((sum/gcnt)*(sum/gcnt));
     if(dum>0){
-      snprintf(pout,255,"Stats[(sigma,var)(n)]:     %g %g\n",sqrt(dum),dum);
+      snprintf(pout,1255,"Stats[(sigma,var)(n)]:     %g %g\n",sqrt(dum),dum);
     } else {
-      snprintf(pout,255,"Stats[(sigma,var)(n)]:     %g %g\n",0.0,0.0);
+      snprintf(pout,1255,"Stats[(sigma,var)(n)]:     %g %g\n",0.0,0.0);
     }
     gaprnt(2,pout);
     dum=dum*(gcnt/gcntm1);
     if(dum>0) {
-      snprintf(pout,255,"Stats[(sigma,var)(n-1)]:   %g %g\n",sqrt(dum),dum);
+      snprintf(pout,1255,"Stats[(sigma,var)(n-1)]:   %g %g\n",sqrt(dum),dum);
     } else {
-      snprintf(pout,255,"Stats[(sigma,var)(n-1)]:   %g %g\n",0.0,0.0);
+      snprintf(pout,1255,"Stats[(sigma,var)(n-1)]:   %g %g\n",0.0,0.0);
     }
     gaprnt(2,pout);
 
     if(pcm->stnprintflg) {
-      snprintf(pout,255,"Printing station values:  #obs = %d\n",gcnt);
+      snprintf(pout,1255,"Printing station values:  #obs = %d\n",gcnt);
       gaprnt(2,pout);
       gcnt=0;
       ucnt=0;
       rpt = stn->rpt;
-      snprintf(pout,255,"OB    ID       LON      LAT      LEV      VAL\n");
+      snprintf(pout,1255,"OB    ID       LON      LAT      LEV      VAL\n");
       gaprnt(2,pout);
       while (rpt) {
 	if (rpt->umask==0) ucnt++;
 	else {
 	  gcnt++;
-	  snprintf(pout,255,"%-5i %.8s %-8.6g %-8.6g %-8.6g %-8.6g\n",
+	  snprintf(pout,1255,"%-5i %.8s %-8.6g %-8.6g %-8.6g %-8.6g\n",
 		   gcnt,rpt->stid,rpt->lon,rpt->lat,rpt->lev,rpt->val);
 	  gaprnt(2,pout);
 	}
@@ -830,7 +830,7 @@ gadouble x,y,r,d,xpos,ypos,rlon;
   }
   if (srpt) {
     srpt->stid[7] = '\0';
-    snprintf(pout,255,"%s %g %g %g\n",srpt->stid,srpt->lon,srpt->lat,r);
+    snprintf(pout,1255,"%s %g %g %g\n",srpt->stid,srpt->lon,srpt->lat,r);
     gaprnt(2,pout);
   } else gaprnt (2,"No stations found\n");
   gagsav (21,pcm,NULL);
@@ -1061,7 +1061,7 @@ char lab[20];
                 else if (pcm->hemflg == 0) hemflg = 0;
                 else if (rpt->lat<0.0) hemflg = 1;
                 gabarb (x, y, pcm->digsiz*3.5, pcm->digsiz*2.0,
-                     pcm->digsiz*0.25, dir, spd, hemflg);
+			pcm->digsiz*0.25, dir, spd, hemflg, pcm->barbolin);
                 gxmark (2,x,y,pcm->digsiz*0.5);
               } else {
                 if (vscal>0.0) {
@@ -1175,9 +1175,9 @@ char lab[20];
     radius.  Direction is direction wind blowing towards.  */
 
 void gabarb (gadouble x, gadouble y, gadouble plen, gadouble blen, gadouble rad,
-      gadouble dir, gadouble spd, gaint hemflg) {
+	     gadouble dir, gadouble spd, gaint hemflg, gaint fillflg) {
 gadouble bgap,padd,var,a70,cosd70,sind70;
-gadouble xp1,yp1,xp2,yp2,xp3,yp3;
+gadouble xp1,yp1,xp2,yp2,xp3,yp3,xy[10];
 gaint flag,flg2;
 
   dir = dir + pi;   /* Want direction wind blowing from */
@@ -1230,9 +1230,18 @@ gaint flag,flg2;
     yp2 = yp1 + blen*sind70;
     xp3 = x + (plen-bgap*1.45)*cos(dir);
     yp3 = y + (plen-bgap*1.45)*sin(dir);
+    /* draw the pennant outline */
     gxplot (xp1,yp1,3);
     gxplot (xp2,yp2,2);
     gxplot (xp3,yp3,2);
+    if (fillflg) {
+      /* fill in the pennant flag */
+      xy[0] = xp1; xy[1] = yp1;
+      xy[2] = xp2; xy[3] = yp2;
+      xy[4] = xp3; xy[5] = yp3;
+      xy[6] = xp1; xy[7] = yp1;
+      gxfill(xy,4);
+    } 
     plen = plen - bgap*1.6;
     var-=50.0;
     flg2 = 1;
@@ -1584,7 +1593,7 @@ char ch[20],len;
     if (plen>pcm->digsiz*6.0) plen = orad;
     wrad = orad;
   }
-  gabarb (x, y, plen, pcm->digsiz*2.5, wrad, dir, spd, hemflg);
+  gabarb (x, y, plen, pcm->digsiz*2.5, wrad, dir, spd, hemflg, pcm->barbolin);
   return(0);
 }
 
@@ -1806,7 +1815,7 @@ gaint ipen,im,i,hemflg,bcol;
         else if (pcm->hemflg == 0) hemflg = 0;
         else if (rpt->lat<0.0) hemflg = 1;
         gabarb (x, pcm->ysiz1, pcm->digsiz*3.5, pcm->digsiz*2.0,
-                  pcm->digsiz*0.25, dir, hypot(rpt->val,rpt2->val), hemflg);
+		pcm->digsiz*0.25, dir, hypot(rpt->val,rpt2->val), hemflg, pcm->barbolin);
       }
       rpt = rpt->rpt;
       rpt2 = rpt2->rpt;
@@ -2941,7 +2950,7 @@ char *gru,*gr2u=NULL,*gr3u=NULL;
               else dir = atan2(*gr3,*gr2);
               if (pcm->gout1a==2) {
                 gabarb (x, y, pcm->digsiz*3.5, pcm->digsiz*2.0,
-                   pcm->digsiz*0.25, dir, hypot(*gr2,*gr3), hemflg);
+			pcm->digsiz*0.25, dir, hypot(*gr2,*gr3), hemflg, pcm->barbolin);
               } else {
                 if (vscal>0.0) {
                   gaarrw (x, y, dir, pcm->arrsiz*hypot(*gr2,*gr3)/vscal, pcm->ahdsiz);
@@ -3215,7 +3224,7 @@ char *umask,*vmask,*cmask=NULL;
         else dir = atan2(*v,*u);
         if (brbflg) {
           gabarb (x, y, pcm->digsiz*3.5, pcm->digsiz*2.0,
-                  pcm->digsiz*0.25, dir+adj, hypot(*u,*v), hemflg);
+                  pcm->digsiz*0.25, dir+adj, hypot(*u,*v), hemflg, pcm->barbolin);
         } else {
           if (vscal>0.0) {
             gaarrw (x, y, dir+adj, pcm->arrsiz*hypot(*u,*v)/vscal, pcm->ahdsiz);
@@ -3235,7 +3244,7 @@ char *umask,*vmask,*cmask=NULL;
     gxcolr (pcm->anncol);
     gxwide (pcm->annthk-2);
     gaarrw (pcm->xsiz2-2.0,pcm->ysiz1-0.5,0.0,pcm->arrsiz, pcm->ahdsiz);
-    snprintf(pout,255,"%g",vscal);
+    snprintf(pout,1255,"%g",vscal);
     len = strlen(pout);
     x = pcm->xsiz2 - 2.0 + (pcm->arrsiz/2.0) - 0.5*0.13*(gadouble)len;
     gxchpl (pout,len,x,pcm->ysiz1-0.7,0.13,0.13,0.0);
@@ -3357,7 +3366,7 @@ char *r1mask, *r2mask, *cmask=NULL;
       cmax2 = cmax2 + 2.0*cint2;
     }
   }
-  snprintf(pout,255,"%g %g %g %g \n",cmin1,cmax1,cmin2,cmax2);
+  snprintf(pout,1255,"%g %g %g %g \n",cmin1,cmax1,cmin2,cmax2);
   gaprnt(2,pout);
   gxscal (pcm->xsiz1,pcm->xsiz2,pcm->ysiz1,pcm->ysiz2,
           cmin1,cmax1,cmin2,cmax2);
@@ -3631,7 +3640,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
       goto cleanup;
     }
     if (dequal(stn->smin,stn->smax,1e-12)==0) {
-      snprintf(pout,255,"Warning from gashpwrt: all reports have the same value = %g\n",stn->smin);
+      snprintf(pout,1255,"Warning from gashpwrt: all reports have the same value = %g\n",stn->smin);
       gaprnt(2,pout);
     }
     /* Do map level scaling (copied from gasmrk) */
@@ -3673,7 +3682,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
   /* Set up the list of data base fields. */
 
   /* Allocate a new field, the GrADS version, set it as the anchor in the local chain */
-  snprintf(pout,255,"GrADS-"GRADS_VERSION"");
+  snprintf(pout,1255,"GrADS-"GRADS_VERSION"");
   len = strlen(pout);
   fld = newdbfld("CREATED_BY", FTString, len, 0, 0, pout);
   if (fld==NULL) {
@@ -3846,7 +3855,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
 	    rc = SHPWriteObject (sfid,-1,shp);
 	    SHPDestroyObject (shp);
 	    if (rc!=shpid) {
-	      snprintf(pout,255,"Error in gashpwrt: SHPWriteObject returned %d, shpid=%d\n",rc,shpid);
+	      snprintf(pout,1255,"Error in gashpwrt: SHPWriteObject returned %d, shpid=%d\n",rc,shpid);
 	      gaprnt (0,pout);
 	      error = 1; goto cleanup;
 	    }
@@ -3880,7 +3889,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
 	  gx++;
 	}
       }
-      snprintf(pout,255,"%d grid point values written to shapefile %s\n",shpid,fnroot);
+      snprintf(pout,1255,"%d grid point values written to shapefile %s\n",shpid,fnroot);
       gaprnt(2,pout);
     }
     else {
@@ -3906,7 +3915,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
 	    rc = SHPWriteObject (sfid,-1,shp);
 	    SHPDestroyObject (shp);
 	    if (rc!=shpid) {
-	      snprintf(pout,255,"Error in gashpwrt: SHPWriteObject returned %d, shpid=%d\n",rc,shpid);
+	      snprintf(pout,1255,"Error in gashpwrt: SHPWriteObject returned %d, shpid=%d\n",rc,shpid);
 	      gaprnt (0,pout);
 	      error = 1; goto cleanup;
 	    }
@@ -3942,7 +3951,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
 	}
 	rpt = rpt->rpt;
       }
-      snprintf(pout,255,"%d station reports written to shapefile %s\n",shpid,fnroot);
+      snprintf(pout,1255,"%d station reports written to shapefile %s\n",shpid,fnroot);
       gaprnt(2,pout);
     }
 
@@ -3958,7 +3967,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
     /* call routine in gxcntr.c to write out contour line vertices and values */
     rc = gxshplin(sfid,dbfid,dbanch);
     if (rc>0) {
-      snprintf(pout,255,"%d contours written to shapefile %s\n",rc,fnroot);
+      snprintf(pout,1255,"%d contours written to shapefile %s\n",rc,fnroot);
       gaprnt(2,pout);
     }
     else if (rc==-1) {
@@ -3983,7 +3992,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
     /* call routine in gxshad2.c to write out polygon vertices and values */
     rc = s2shpwrt(sfid,dbfid,dbanch);
     if (rc>0) {
-      snprintf(pout,255,"%d polygons written to shapefile %s\n",rc,fnroot);
+      snprintf(pout,1255,"%d polygons written to shapefile %s\n",rc,fnroot);
       gaprnt(2,pout);
     }
     else if (rc==-1) {
@@ -4002,7 +4011,7 @@ struct dbfld *fld=NULL,*newfld=NULL,*nextfld;
   }
   sprintf(prjname,"%s.prj",fnroot);
   fp = fopen(prjname,"w");
-  snprintf(pout,255,"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]\n");
+  snprintf(pout,1255,"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]\n");
   if ((fwrite(pout,1,strlen(pout),fp))!=strlen(pout)) {
     gaprnt(0,"Error in gashpwrt when writing to .prj file \n");
     error = 1; goto cleanup; 
@@ -4139,9 +4148,9 @@ void gakml (struct gacmn *pcm) {
     kmlfp = fopen ("grads.kml","wb");
   if (kmlfp==NULL) {
     if (pcm->kmlname)
-      snprintf(pout,255,"Error: fopen failed for KML text output file %s\n",pcm->kmlname);
+      snprintf(pout,1255,"Error: fopen failed for KML text output file %s\n",pcm->kmlname);
     else
-      snprintf(pout,255,"Error: fopen failed for KML text output file grads.kml\n");
+      snprintf(pout,1255,"Error: fopen failed for KML text output file grads.kml\n");
     gaprnt(0,pout);
     goto cleanup;
   }
@@ -4164,18 +4173,18 @@ void gakml (struct gacmn *pcm) {
 
 
   /* write out KML headers */
-  snprintf(pout,255,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+  snprintf(pout,1255,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
   if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-  snprintf(pout,255,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
+  snprintf(pout,1255,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
   if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-  snprintf(pout,255,"  <Document id=\"Created by GrADS-"GRADS_VERSION"\">\n");
+  snprintf(pout,1255,"  <Document id=\"Created by GrADS-"GRADS_VERSION"\">\n");
   if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
 
   /* Contours */
   if (pcm->kmlflg==2) {
     /* write out the contour colors as a set of Style tags with LineStyle */
     for (i=0; i<pcm->cntrcnt; i++) {
-      snprintf(pout,255,"    <Style id=\"%d\">\n      <LineStyle>\n",pcm->cntrcols[i]);
+      snprintf(pout,1255,"    <Style id=\"%d\">\n      <LineStyle>\n",pcm->cntrcols[i]);
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
       /* get rgb values for this color */
       gxdbqcol(pcm->cntrcols[i], &dbq);
@@ -4183,20 +4192,20 @@ void gakml (struct gacmn *pcm) {
       g = dbq.green;
       b = dbq.blue;
       a = dbq.alpha;
-      snprintf(pout,255,"        <color>%02x%02x%02x%02x</color>\n",a,b,g,r);
+      snprintf(pout,1255,"        <color>%02x%02x%02x%02x</color>\n",a,b,g,r);
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"        <width>%d</width>\n",pcm->cthick);
+      snprintf(pout,1255,"        <width>%d</width>\n",pcm->cthick);
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"      </LineStyle>\n    </Style>\n");
+      snprintf(pout,1255,"      </LineStyle>\n    </Style>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
     }
     /* write out the locations of the contour vertices */
     rc = gxclvert(kmlfp);
     if (rc>0) {
       if (pcm->kmlname)
-	snprintf(pout,255,"%d contours written to KML file %s\n",rc,pcm->kmlname);
+	snprintf(pout,1255,"%d contours written to KML file %s\n",rc,pcm->kmlname);
       else
-	snprintf(pout,255,"%d contours written to KML file grads.kml\n",rc);
+	snprintf(pout,1255,"%d contours written to KML file grads.kml\n",rc);
       gaprnt(2,pout);
     }
     else err=1;
@@ -4205,9 +4214,9 @@ void gakml (struct gacmn *pcm) {
   else {
     /* write out the polygon colors as a set of Style tags with LineStyle and PolyStyle */
     for (i=0; i<pcm->shdcnt; i++) {
-      snprintf(pout,255,"    <Style id=\"%d\">\n",pcm->shdcls[i]);
+      snprintf(pout,1255,"    <Style id=\"%d\">\n",pcm->shdcls[i]);
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"      <LineStyle>\n");
+      snprintf(pout,1255,"      <LineStyle>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
       /* get rgb values for this color */
       gxdbqcol(pcm->shdcls[i], &dbq);
@@ -4215,21 +4224,21 @@ void gakml (struct gacmn *pcm) {
       g = dbq.green;
       b = dbq.blue;
       a = dbq.alpha;
-      snprintf(pout,255,"        <color>%02x%02x%02x%02x</color>\n",a,b,g,r);
+      snprintf(pout,1255,"        <color>%02x%02x%02x%02x</color>\n",a,b,g,r);
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"        <width>0</width>\n");
+      snprintf(pout,1255,"        <width>0</width>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"      </LineStyle>\n");
+      snprintf(pout,1255,"      </LineStyle>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"      <PolyStyle>\n");
+      snprintf(pout,1255,"      <PolyStyle>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"        <color>%02x%02x%02x%02x</color>\n",a,b,g,r);
+      snprintf(pout,1255,"        <color>%02x%02x%02x%02x</color>\n",a,b,g,r);
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"        <fill>1</fill>\n");
+      snprintf(pout,1255,"        <fill>1</fill>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"      </PolyStyle>\n");
+      snprintf(pout,1255,"      </PolyStyle>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
-      snprintf(pout,255,"    </Style>\n");
+      snprintf(pout,1255,"    </Style>\n");
       if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
     }
 
@@ -4238,9 +4247,9 @@ void gakml (struct gacmn *pcm) {
     rc = s2polyvert(kmlfp);
     if (rc>0) {
       if (pcm->kmlname)
-	snprintf(pout,255,"%d polygons written to KML file %s\n",rc,pcm->kmlname);
+	snprintf(pout,1255,"%d polygons written to KML file %s\n",rc,pcm->kmlname);
       else
-	snprintf(pout,255,"%d polygons written to KML file grads.kml\n",rc);
+	snprintf(pout,1255,"%d polygons written to KML file grads.kml\n",rc);
       gaprnt(2,pout);
     }
     else err=1;
@@ -4248,7 +4257,7 @@ void gakml (struct gacmn *pcm) {
   }
 
   /* write out footers */
-  snprintf(pout,255,"  </Document>\n</kml>\n");
+  snprintf(pout,1255,"  </Document>\n</kml>\n");
   if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
   /* set the last graphic code */
   gagsav (24,pcm,NULL);
@@ -4342,18 +4351,18 @@ void gagtif (struct gacmn *pcm, gaint kmlflg) {
      tif = XTIFFOpen("grads.tif", "w");
    if (tif==NULL) {
      if (pcm->tifname)
-       snprintf(pout,255,"Error: XTiffOpen failed for KML image output file %s\n",pcm->tifname);
+       snprintf(pout,1255,"Error: XTiffOpen failed for KML image output file %s\n",pcm->tifname);
      else
-       snprintf(pout,255,"Error: XTiffOpen failed for KML image output file grads.tif\n");
+       snprintf(pout,1255,"Error: XTiffOpen failed for KML image output file grads.tif\n");
      gaprnt (0,pout);
      goto cleanup;
    }
    gtif = GTIFNew(tif);
    if (gtif==NULL) {
      if (pcm->tifname)
-       snprintf(pout,255,"Error: GTIFNew failed for KML image output file %s\n",pcm->tifname);
+       snprintf(pout,1255,"Error: GTIFNew failed for KML image output file %s\n",pcm->tifname);
      else
-       snprintf(pout,255,"Error: GTIFNew failed for KML image output file grads.tif\n");
+       snprintf(pout,1255,"Error: GTIFNew failed for KML image output file grads.tif\n");
      gaprnt (0,pout);
      goto cleanup;
    }
@@ -4366,18 +4375,18 @@ void gagtif (struct gacmn *pcm, gaint kmlflg) {
      tif = XTIFFOpen("gradsgeo.tif", "w");
    if (tif==NULL) {
      if (pcm->gtifname)
-       snprintf(pout,255,"Error: XTiffOpen failed for GeoTIFF output file %s\n",pcm->gtifname);
+       snprintf(pout,1255,"Error: XTiffOpen failed for GeoTIFF output file %s\n",pcm->gtifname);
      else
-       snprintf(pout,255,"Error: XTiffOpen failed for GeoTIFF output file gradsgeo.tif\n");
+       snprintf(pout,1255,"Error: XTiffOpen failed for GeoTIFF output file gradsgeo.tif\n");
      gaprnt (0,pout);
      goto cleanup;
    }
    gtif = GTIFNew(tif);
    if (gtif==NULL) {
      if (pcm->gtifname)
-       snprintf(pout,255,"Error: GTIFNew failed for GeoTIFF output file %s\n",pcm->gtifname);
+       snprintf(pout,1255,"Error: GTIFNew failed for GeoTIFF output file %s\n",pcm->gtifname);
      else
-       snprintf(pout,255,"Error: GTIFNew failed for GeoTIFF output file gradsgeo.tif\n");
+       snprintf(pout,1255,"Error: GTIFNew failed for GeoTIFF output file gradsgeo.tif\n");
      gaprnt (0,pout);
      goto cleanup;
    }
@@ -4460,7 +4469,7 @@ void gagtif (struct gacmn *pcm, gaint kmlflg) {
      gaprnt(0,"Error: TIFFSetField failed for smaxsamplevalue\n"); goto cleanup;
    }
  }
- snprintf(pout,255,"GrADS version "GRADS_VERSION" ");
+ snprintf(pout,1255,"GrADS version "GRADS_VERSION" ");
  if (TIFFSetField(tif, TIFFTAG_SOFTWARE, pout)!=1) { 
    gaprnt(0,"Error: TIFFSetField failed for software\n"); goto cleanup; 
  }
@@ -4617,7 +4626,7 @@ void gagtif (struct gacmn *pcm, gaint kmlflg) {
        rc = TIFFWriteScanline(tif, dbuf0+i, j, 0);
    }
    if (rc!=1) {
-     snprintf(pout,255,"Error: TIFFWriteScanline failed at row %d\n",j);
+     snprintf(pout,1255,"Error: TIFFWriteScanline failed at row %d\n",j);
      gaprnt(0,pout); goto cleanup; 
    }
  }
@@ -4625,22 +4634,22 @@ void gagtif (struct gacmn *pcm, gaint kmlflg) {
  if (kmlflg) {
    gagsav (24,pcm,NULL);
    if (pcm->tifname)
-     snprintf(pout,255,"Created TIFF image file %s\n",pcm->tifname);
+     snprintf(pout,1255,"Created TIFF image file %s\n",pcm->tifname);
    else
-     snprintf(pout,255,"Created TIFF image file grads.tif\n");
+     snprintf(pout,1255,"Created TIFF image file grads.tif\n");
    gaprnt (2,pout);
    if (pcm->kmlname)
-     snprintf(pout,255,"  and complementary KML file %s\n",pcm->kmlname);
+     snprintf(pout,1255,"  and complementary KML file %s\n",pcm->kmlname);
    else
-     snprintf(pout,255,"  and complementary KML file grads.kml\n");
+     snprintf(pout,1255,"  and complementary KML file grads.kml\n");
    gaprnt (2,pout);
  }
  else {
    gagsav (23,pcm,NULL);
    if (pcm->gtifname)
-     snprintf(pout,255,"Created GeoTIFF file %s\n",pcm->gtifname);
+     snprintf(pout,1255,"Created GeoTIFF file %s\n",pcm->gtifname);
    else
-     snprintf(pout,255,"Created GeoTIFF file gradsgeo.tif\n");
+     snprintf(pout,1255,"Created GeoTIFF file gradsgeo.tif\n");
    gaprnt (2,pout);
  }
  cleanup:
@@ -4728,9 +4737,9 @@ gaint write_kml(struct gacmn *pcm, gadouble *tpts) {
    kmlfp = fopen ("grads.kml","wb");
  if (kmlfp==NULL) {
    if (pcm->kmlname)
-     snprintf(pout,255,"Error: fopen failed for KML text output file %s\n",pcm->kmlname);
+     snprintf(pout,1255,"Error: fopen failed for KML text output file %s\n",pcm->kmlname);
    else
-     snprintf(pout,255,"Error: fopen failed for KML text output file grads.kml\n");
+     snprintf(pout,1255,"Error: fopen failed for KML text output file grads.kml\n");
    gaprnt(0,pout);
    return(1);
  }
@@ -4738,46 +4747,46 @@ gaint write_kml(struct gacmn *pcm, gadouble *tpts) {
 
  /* write out the KML text */
  err=0;
- snprintf(pout,255,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ snprintf(pout,1255,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
+ snprintf(pout,1255,"<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"  <GroundOverlay>\n");
+ snprintf(pout,1255,"  <GroundOverlay>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"    <name>%s</name>\n",pgr->pvar->varnm);
+ snprintf(pout,1255,"    <name>%s</name>\n",pgr->pvar->varnm);
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"    <Icon>\n");
+ snprintf(pout,1255,"    <Icon>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
  if (pcm->tifname)
-   snprintf(pout,255,"      <href>%s</href>\n",pcm->tifname);
+   snprintf(pout,1255,"      <href>%s</href>\n",pcm->tifname);
  else
-   snprintf(pout,255,"      <href>grads.tif</href>\n");
+   snprintf(pout,1255,"      <href>grads.tif</href>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"    </Icon>\n");
+ snprintf(pout,1255,"    </Icon>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"    <LatLonBox>\n");
+ snprintf(pout,1255,"    <LatLonBox>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
  if ((tpts[0+3]==tpts[6+3]) && (tpts[12+3]==tpts[18+3])) {
    if (tpts[0+3]<tpts[12+3])
-     snprintf(pout,255,"      <west>%10.5g</west>\n      <east>%10.5g</east>\n",tpts[0+3],tpts[12+3]);
+     snprintf(pout,1255,"      <west>%10.5g</west>\n      <east>%10.5g</east>\n",tpts[0+3],tpts[12+3]);
    else
-     snprintf(pout,255,"      <west>%10.5g</west>\n      <east>%10.5g</east>\n",tpts[12+3],tpts[0+3]);
+     snprintf(pout,1255,"      <west>%10.5g</west>\n      <east>%10.5g</east>\n",tpts[12+3],tpts[0+3]);
    if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
  }
  if ((tpts[0+4]==tpts[12+4]) && (tpts[6+4]==tpts[18+4])) {
    if (tpts[0+4]<tpts[12+4])
-     snprintf(pout,255,"      <south>%10.5g</south>\n      <north>%10.5g</north>\n",tpts[0+4],tpts[6+4]);
+     snprintf(pout,1255,"      <south>%10.5g</south>\n      <north>%10.5g</north>\n",tpts[0+4],tpts[6+4]);
    else
-     snprintf(pout,255,"      <south>%10.5g</south>\n      <north>%10.5g</north>\n",tpts[6+4],tpts[0+4]);
+     snprintf(pout,1255,"      <south>%10.5g</south>\n      <north>%10.5g</north>\n",tpts[6+4],tpts[0+4]);
    if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
  }
- snprintf(pout,255,"      <rotation>0.0</rotation>\n");
+ snprintf(pout,1255,"      <rotation>0.0</rotation>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"    </LatLonBox>\n");
+ snprintf(pout,1255,"    </LatLonBox>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"  </GroundOverlay>\n");
+ snprintf(pout,1255,"  </GroundOverlay>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
- snprintf(pout,255,"</kml>\n");
+ snprintf(pout,1255,"</kml>\n");
  if ((fwrite(pout,sizeof(char),strlen(pout),kmlfp))!=strlen(pout)) {err=1; goto cleanup;}
 
  cleanup:
@@ -4826,13 +4835,13 @@ gadouble *gr;
     if (pcm->fwappend) {
       strcpy(fmode,"ab");
       if (fexists) {
-	snprintf(pout,255,"Appending data to file %s.\n",pcm->fwname);
+	snprintf(pout,1255,"Appending data to file %s.\n",pcm->fwname);
 	gaprnt (2,pout);
       }
     } else {
       strcpy(fmode,"wb");
       if (fexists) {
-	snprintf(pout,255,"Replacing file %s.\n",pcm->fwname);
+	snprintf(pout,1255,"Replacing file %s.\n",pcm->fwname);
 	gaprnt (2,pout);
       }
     }
@@ -4941,7 +4950,7 @@ gadouble *gr;
       write = fwrite (fval+goff, sizeof(gafloat), xsiz, pcm->ffile);
       ret = ferror(pcm->ffile);
       if (ret || (write != xsiz)) {
-        snprintf(pout,255,"Error writing data for fwrite: %s\n", strerror(errno) ); 
+        snprintf(pout,1255,"Error writing data for fwrite: %s\n", strerror(errno) ); 
         gaprnt(0, pout);
       }
       written = written + write;
@@ -4954,7 +4963,7 @@ gadouble *gr;
     written = fwrite (fval, sizeof(gafloat), size, pcm->ffile);
     ret = ferror(pcm->ffile);
     if (ret || (written != size)) {
-      snprintf(pout,255,"Error writing data for fwrite: %s\n", strerror(errno) ); 
+      snprintf(pout,1255,"Error writing data for fwrite: %s\n", strerror(errno) ); 
       gaprnt(0, pout);
     }
     if (pcm->fwsqflg) fwrite(&rdw,sizeof(gaint),1,pcm->ffile);
@@ -4962,11 +4971,11 @@ gadouble *gr;
 
   if (pcm->ffile != stdout) {
     if (pcm->fwname) {
-      snprintf(pout,255,"Wrote %ld of %i elements to ", written, exsz);
+      snprintf(pout,1255,"Wrote %ld of %i elements to ", written, exsz);
       gaprnt (2,pout);
       gaprnt (2,pcm->fwname);
     } else {
-      snprintf(pout,255,"Wrote %ld of %i elements to grads.fwrite", written, exsz);
+      snprintf(pout,1255,"Wrote %ld of %i elements to grads.fwrite", written, exsz);
       gaprnt (2,pout);
     }
   
@@ -5209,11 +5218,11 @@ size_t sz;
         gaplot (pcm);
         pcm->gout2a = isav;
         pcm->fgcnt = 0;
-        snprintf(pout,255,"Constant field.  Value = %g\n",pgr->rmin);
+        snprintf(pout,1255,"Constant field.  Value = %g\n",pgr->rmin);
         gaprnt (1,pout);
       } else {
 	/* just print the message */
-        snprintf(pout,255,"Constant field.  Value = %g\n",pgr->rmin);
+        snprintf(pout,1255,"Constant field.  Value = %g\n",pgr->rmin);
         gaprnt (1,pout);
       }
       return 1;
@@ -5307,12 +5316,12 @@ size_t sz;
   if (pcm->cflag) {
     gaprnt (2,"Contouring at clevs = ");
     for (i=0; i<pcm->cflag; i++) {
-      snprintf(pout,255," %g",pcm->clevs[i]);
+      snprintf(pout,1255," %g",pcm->clevs[i]);
       gaprnt (2,pout);
     }
     gaprnt (2,"\n");
   } else {
-    snprintf(pout,255,"Contouring: %g to %g interval %g \n",cmin,cmax,cint);
+    snprintf(pout,1255,"Contouring: %g to %g interval %g \n",cmin,cmax,cint);
     gaprnt (2,pout);
   }
 
diff --git a/src/gaio.c b/src/gaio.c
index 91e9812..7d321e2 100644
--- a/src/gaio.c
+++ b/src/gaio.c
@@ -45,7 +45,7 @@ static struct gaindx *pindx;
 static struct gaindxb *pindxb;
 static gaint timerr;
 static gaint msgflg=1;
-static char pout[256]; 
+static char pout[1256]; 
 
 /* For STNDALN, routines included are gaopfn, gaopnc, and gaophdf */
 #ifndef STNDALN
@@ -143,7 +143,7 @@ gaint gaggrd (struct gagrid *pgrid) {
   if (pgr->idim < -1 || pgr->idim > 4 ||
       pgr->jdim < -1 || pgr->jdim > 4 ||
       (pgr->idim == -1 && pgr->jdim!=-1)) {
-    snprintf(pout,255,"Internal logic check 16:  %i %i  \n", pgr->idim, pgr->jdim);
+    snprintf(pout,1255,"Internal logic check 16:  %i %i  \n", pgr->idim, pgr->jdim);
     gaprnt (0,pout);
     return (16);
   }
@@ -255,7 +255,7 @@ gaint gaggrd (struct gagrid *pgrid) {
       rc = h5openvar(pfi->h5id,vname,&dsid,&vid);
       if (rc) {
 	pvr->h5vid = -888;
-	snprintf(pout,255,"Error: Variable %s not in HDF5 file\n",vname);
+	snprintf(pout,1255,"Error: Variable %s not in HDF5 file\n",vname);
 	gaprnt(0,pout);
 	return (rc); 
       }
@@ -351,10 +351,10 @@ nodatmsg:
   if(mfcmn.warnflg>0) {
     gaprnt (1,"Data Request Warning:  Request is completely outside file limits\n");
     gaprnt (2,"  Entire grid contents are set to missing data \n");
-    snprintf(pout,255,"  Grid limits of file:     X = 1 %i  Y = 1 %i  Z = 1 %i  T = 1 %i  E = 1 %i \n",
+    snprintf(pout,1255,"  Grid limits of file:     X = 1 %i  Y = 1 %i  Z = 1 %i  T = 1 %i  E = 1 %i \n",
 	     pfi->dnum[0],pfi->dnum[1],pfi->dnum[2],pfi->dnum[3],pfi->dnum[4]);
     gaprnt (2,pout);
-    snprintf(pout,255,"  Grid limits of request:  X = %i %i  Y = %i %i  Z = %i %i  T = %i %i  E = %i %i \n",
+    snprintf(pout,1255,"  Grid limits of request:  X = %i %i  Y = %i %i  Z = %i %i  T = %i %i  E = %i %i \n",
 	     pgr->dimmin[0],pgr->dimmax[0],
 	     pgr->dimmin[1],pgr->dimmax[1],
 	     pgr->dimmin[2],pgr->dimmax[2],
@@ -497,7 +497,7 @@ gaint y,z,t,e;
 	rc = h5openvar(pfi->h5id,vname,&dsid,&vid);
 	if (rc) {
 	  pvr->h5vid = -888;
-	  snprintf(pout,255,"Error: Variable %s not in HDF5 file\n",vname);
+	  snprintf(pout,1255,"Error: Variable %s not in HDF5 file\n",vname);
 	  gaprnt(0,pout);
 	  return (rc); 
 	}
@@ -645,11 +645,11 @@ size_t sz;
   rc = fseeko(pfi->infile, ffpos, 0);
   if (rc!=0) {
     gaprnt (0,"Low Level I/O Error:  Seek error on data file \n");
-    snprintf(pout,255,"  Data file name = %s \n",pfi->name);
+    snprintf(pout,1255,"  Data file name = %s \n",pfi->name);
     gaprnt (0,pout);
-    snprintf(pout,255,"%d rc=%d fpos=%ld pfi->fhdr=%ld\n",__LINE__,rc,(long)fpos,pfi->fhdr);
+    snprintf(pout,1255,"%d rc=%d fpos=%ld pfi->fhdr=%ld\n",__LINE__,rc,(long)fpos,pfi->fhdr);
     gaprnt (0,pout);
-    snprintf(pout,255,"  Error occurred when seeking to byte %ld \n",(long)ffpos);
+    snprintf(pout,1255,"  Error occurred when seeking to byte %ld \n",(long)ffpos);
     gaprnt (0,pout);
     return (1);
   }
@@ -752,9 +752,9 @@ size_t sz;
 
 readerr:
   gaprnt (0,"Low Level I/O Error:  Read error on data file \n");
-  snprintf(pout,255,"  Data file name = %s \n",pfi->name);
+  snprintf(pout,1255,"  Data file name = %s \n",pfi->name);
   gaprnt (0,pout);
-  snprintf(pout,255,"  Error reading %ld bytes at location %ld \n",sz,(long)ffpos);
+  snprintf(pout,1255,"  Error reading %ld bytes at location %ld \n",sz,(long)ffpos);
   gaprnt (0,pout);
   return (1);
 
@@ -958,7 +958,7 @@ size_t sz;
             if (rtot>nsiz) {
               gaprnt (0,"Low Level I/O Error:  Sequential read error\n");
               gaprnt (0,"  Record size exceeds report size\n");
-              snprintf(pout,255,"  Data file name = %s \n",pfi->name);
+              snprintf(pout,1255,"  Data file name = %s \n",pfi->name);
               gaprnt (0,pout);
               goto err;
             }
@@ -1015,7 +1015,7 @@ size_t sz;
           if (rtot>sizf) {
             gaprnt (0,"Low Level I/O Error:  Sequential read error\n");
             gaprnt (0,"  Record size exceeds report size\n");
-            snprintf(pout,255,"  Data file name = %s \n",pfi->name);
+            snprintf(pout,1255,"  Data file name = %s \n",pfi->name);
             gaprnt (0,pout);
             goto err;
           }
@@ -1179,11 +1179,11 @@ gaint rc;
   rc = fseeko(pfi->infile, fpos, 0);
   if (rc!=0) {
     gaprnt (0,"Low Level I/O Error:  Seek error on data file \n");
-    snprintf(pout,255,"  Data file name = %s \n",pfi->name);
+    snprintf(pout,1255,"  Data file name = %s \n",pfi->name);
     gaprnt (0,pout);
-    snprintf(pout,255,"%d  rc=%d pos=%ld pfi->fhdr =%ld \n",__LINE__,rc,(long)fpos,pfi->fhdr);
+    snprintf(pout,1255,"%d  rc=%d pos=%ld pfi->fhdr =%ld \n",__LINE__,rc,(long)fpos,pfi->fhdr);
     gaprnt (0,pout);
-    snprintf(pout,255,"  Error occurred when seeking to byte %ld \n",(long)fpos);
+    snprintf(pout,1255,"  Error occurred when seeking to byte %ld \n",(long)fpos);
     gaprnt (0,pout);
     return (1);
   }
@@ -1199,9 +1199,9 @@ gaint rc;
   rc = fread (val, siz, 1, pfi->infile);
   if (rc<1) {
     gaprnt (0,"Low Level I/O Error:  Read error on data file \n");
-    snprintf(pout,255,"  Data file name = %s \n",pfi->name);
+    snprintf(pout,1255,"  Data file name = %s \n",pfi->name);
     gaprnt (0,pout);
-    snprintf(pout,255,"  Error reading %i bytes at location %ld \n", siz, (long)fpos);
+    snprintf(pout,1255,"  Error reading %i bytes at location %ld \n", siz, (long)fpos);
     gaprnt (0,pout);
     return (1);
   }
@@ -1562,7 +1562,7 @@ gaint g2off,ng2elems=2;
   irec = (e-1)*pfi->dnum[3]*pfi->trecs + (t-1)*pfi->trecs + pvr->recoff + z - 1;
   if (pfi->g2indx->bigflg==0) irec = irec * ng2elems;
   if (irec > pfi->g2indx->g2intnum) {
-    snprintf(pout,255,"GRIB2 I/O error: irec=%d is greater than g2intnum=%d\n",irec,pfi->g2indx->g2intnum);
+    snprintf(pout,1255,"GRIB2 I/O error: irec=%d is greater than g2intnum=%d\n",irec,pfi->g2indx->g2intnum);
     gaprnt(0,pout);
     return(1);
   }
@@ -1576,7 +1576,7 @@ gaint g2off,ng2elems=2;
     ifld = *(pfi->g2indx->g2intpnt+irec+1);
   }
   if (debug==2) {
-    snprintf(pout,255,"gairow debug: seek,ifld = %ld %ld\n",(long)seek,(long)ifld);
+    snprintf(pout,1255,"gairow debug: seek,ifld = %ld %ld\n",(long)seek,(long)ifld);
     gaprnt(0,pout);
   }
 
@@ -1696,7 +1696,7 @@ gaint diag=0;
     if (diag) printf("Sec1   %d\n",gagby(s1,0,4));
     roff += gagby(s1,0,4);     
   } else {
-    snprintf(pout,255,"GRIB2 I/O Error: reading header, section 1 expected, found %i\n",i);
+    snprintf(pout,1255,"GRIB2 I/O Error: reading header, section 1 expected, found %i\n",i);
     gaprnt (0,pout);
     goto g2err;
   }
@@ -1722,7 +1722,7 @@ gaint diag=0;
       roff += gagby(s3,0,4);  
     } 
     else if (field==1) {
-      snprintf(pout,255,"GRIB2 I/O Error: reading header, section 3 expected, found %i\n",i);
+      snprintf(pout,1255,"GRIB2 I/O Error: reading header, section 3 expected, found %i\n",i);
       gaprnt (0,pout);
       goto g2err;
     } 
@@ -1738,7 +1738,7 @@ gaint diag=0;
       roff += gagby(s4,0,4);
     }
     else if (field==1) {
-      snprintf(pout,255,"GRIB2 I/O Error: reading header, section 4 expected, found %i\n",i);
+      snprintf(pout,1255,"GRIB2 I/O Error: reading header, section 4 expected, found %i\n",i);
       gaprnt (0,pout);
       goto g2err;
     }
@@ -1754,7 +1754,7 @@ gaint diag=0;
       roff += gagby(s5,0,4);
     }
     else if (field==1) {
-      snprintf(pout,255,"GRIB2 I/O Error: reading header, section 5 expected, found %i\n",i);
+      snprintf(pout,1255,"GRIB2 I/O Error: reading header, section 5 expected, found %i\n",i);
       gaprnt (0,pout);
       goto g2err;
     }
@@ -1782,7 +1782,7 @@ gaint diag=0;
       roff += gagby(s7,0,4);
     }
     else if (field==1) {
-      snprintf(pout,255,"GRIB2 I/O Error: reading header, section 7 expected, found %i\n",i);
+      snprintf(pout,1255,"GRIB2 I/O Error: reading header, section 7 expected, found %i\n",i);
       gaprnt(0,pout);
       goto g2err;
     }
@@ -1809,7 +1809,7 @@ gaint diag=0;
     case 90: soct = 63; break;
     case 204: soct = 71; break; 
     default: 
-      snprintf(pout,255,"g2read error: Grid Definition Template %d not handled\n",gdt);
+      snprintf(pout,1255,"g2read error: Grid Definition Template %d not handled\n",gdt);
       gaprnt (0,pout);
       goto g2err;
   };
@@ -1826,7 +1826,7 @@ gaint diag=0;
   expand=1;
   ierr=g2_getfld(cgrib,ifld,unpack,expand,&gfld);
   if (ierr) {
-    snprintf(pout,255,"GRIB2 I/O Error: g2_getfld failed, ierr=%d\n",ierr);
+    snprintf(pout,1255,"GRIB2 I/O Error: g2_getfld failed, ierr=%d\n",ierr);
     gaprnt (0,pout);
     goto g2err;
   }
@@ -1868,7 +1868,7 @@ gaint diag=0;
 
   /* create the undef mask */
   if (gfld->ibmap!=0 && gfld->ibmap!=254 && gfld->ibmap!=255) {
-    snprintf(pout,255,"GRIB2 I/O Error: Predefined bitmap applies (ibmap=%ld) \n",gfld->ibmap);
+    snprintf(pout,1255,"GRIB2 I/O Error: Predefined bitmap applies (ibmap=%ld) \n",gfld->ibmap);
     gaprnt (0,pout);
     goto g2err1;
   }
@@ -2150,7 +2150,7 @@ size_t sz;
       rc = fseeko(pfi->infile, fpos, 0);
       rc = fread(cache,sizeof(char),siz,pfi->infile);
       if (rc==0) {
-        snprintf(pout,255,"GRIB I/O Error reading %i bytes at %ld\n",siz,(long)fpos);
+        snprintf(pout,1255,"GRIB I/O Error reading %i bytes at %ld\n",siz,(long)fpos);
         gaprnt (0,pout);
         gaprnt (0,"  File name is: ");
         if (pfi->tempname) gaprnt(0,pfi->tempname);
@@ -2167,7 +2167,7 @@ size_t sz;
     rc = fseeko(pfi->infile, fpos+cstrt, 0);
     rc = fread (pfi->pbuf, sizeof(char), clen, pfi->infile);
     if (rc==0) {
-      snprintf(pout,255,"GRIB I/O Error reading %i bytes at %ld\n",clen,(long)fpos+cstrt);
+      snprintf(pout,1255,"GRIB I/O Error reading %i bytes at %ld\n",clen,(long)fpos+cstrt);
       gaprnt (0,pout);
       gaprnt (0,"  File name is: ");
       if (pfi->tempname) gaprnt(0,pfi->tempname);
@@ -2390,10 +2390,10 @@ gaint gancsetup (void) {
     if (error) {
       pvr->ncvid = -888;  /* set flag so we won't try this variable ever again */
       if (pvr->longnm[0] != '\0') {
-	snprintf(pout,255,"Error: Variable %s not in netcdf file\n",pvr->longnm);
+	snprintf(pout,1255,"Error: Variable %s not in netcdf file\n",pvr->longnm);
      }
       else {
-	snprintf(pout,255,"Error: Variable %s not in netcdf file\n",pvr->abbrv);
+	snprintf(pout,1255,"Error: Variable %s not in netcdf file\n",pvr->abbrv);
       }
       gaprnt (0,pout);
       ncopts = oldncopts ;
@@ -2406,7 +2406,7 @@ gaint gancsetup (void) {
     if (pfi->undefattrflg) {
       /* get the primary undef value */
       if (nc_get_att_double(pfi->ncid, pvr->ncvid, pfi->undefattr, &val) != NC_NOERR) {
-	snprintf(pout,255,"Warning: value for primary undef attribute \"%s\" not found\n",pfi->undefattr);
+	snprintf(pout,1255,"Warning: value for primary undef attribute \"%s\" not found\n",pfi->undefattr);
 	gaprnt(1,pout);
         pvr->undef = pfi->undef;
       }
@@ -2416,7 +2416,7 @@ gaint gancsetup (void) {
       /* get the secondary undef value */
       if (pfi->undefattrflg==2) {
         if (nc_get_att_double(pfi->ncid, pvr->ncvid, pfi->undefattr2, &val) != NC_NOERR) {
-	  snprintf(pout,255,"Warning: value for secondary undef attribute \"%s\" not found\n",pfi->undefattr2);
+	  snprintf(pout,1255,"Warning: value for secondary undef attribute \"%s\" not found\n",pfi->undefattr2);
   	  gaprnt(1,pout);
           pvr->undef2 = pfi->undef;
         }
@@ -2473,14 +2473,14 @@ gaint gancsetup (void) {
 		gaprnt(1,"*** WARNING! ***\n");
 		gaprnt(1,"*** The I/O for this variable will be extremely slow \n");
 		gaprnt(1,"*** because the chunks are too big to fit in the cache \n");
-		snprintf(pout,255,"*** chunk size = %ld bytes  (",(long)(nelems*size));
+		snprintf(pout,1255,"*** chunk size = %ld bytes  (",(long)(nelems*size));
 		gaprnt(1,pout);
 		for (i=ndims-1; i>=0; i--) { 
-		  snprintf(pout,255,"%ld * ",(long)chsize[i]); gaprnt(1,pout); 
+		  snprintf(pout,1255,"%ld * ",(long)chsize[i]); gaprnt(1,pout); 
 		}
-		snprintf(pout,255,"%ld bytes)\n",(long)size);
+		snprintf(pout,1255,"%ld bytes)\n",(long)size);
 		gaprnt(1,pout);
-		snprintf(pout,255,"*** cache size = %ld bytes \n",pfi->cachesize);
+		snprintf(pout,1255,"*** cache size = %ld bytes \n",pfi->cachesize);
 		gaprnt(1,pout);
 		gaprnt(1,"*** There are two ways to control the cache size: \n");
 		gaprnt(1,"*** add a CACHESIZE entry to the descriptor file \n");
@@ -2701,7 +2701,7 @@ gaint oldncopts ;         /* to save and restore setting for automatic error han
   grtmp = (gadouble *)galloc(sz,"grtmp");
   if (grtmp==NULL) {
     gaprnt (0,"gancgrid error: unable to allocate memory for grtmp grid storage \n");
-    snprintf(pout,255,"  grid size = xlen * ylen * zlen * tlen * elen = %d * %d * %d * %d * %d\n",
+    snprintf(pout,1255,"  grid size = xlen * ylen * zlen * tlen * elen = %d * %d * %d * %d * %d\n",
 	    xlen,ylen,zlen,tlen,elen);
     gaprnt (0,pout);
     rtrn=1; goto cleanup;
@@ -2710,7 +2710,7 @@ gaint oldncopts ;         /* to save and restore setting for automatic error han
   grutmp = (char *)galloc(sz,"grutmp");
   if (grutmp==NULL) {
     gaprnt (0,"gancgrid error: unable to allocate memory for grutmp grid storage \n");
-    snprintf(pout,255,"  grid size = xlen * ylen * zlen * tlen * elen = %d * %d * %d * %d * %d\n",
+    snprintf(pout,1255,"  grid size = xlen * ylen * zlen * tlen * elen = %d * %d * %d * %d * %d\n",
 	    xlen,ylen,zlen,tlen,elen);
     gaprnt (0,pout);
     rtrn=1; goto cleanup;
@@ -2801,7 +2801,7 @@ gaint oldncopts ;         /* to save and restore setting for automatic error han
       grtmp2 = (gadouble *)galloc(sz,"grtmp2");
       if (grtmp2==NULL) {
 	gaprnt (0,"gancgrid error: unable to allocate memory for grtmp2 grid storage \n");
-	snprintf(pout,255,"  grid size = xlen * ylen * zlen * tlen * elen = %d * %d * %d * %d * %d\n",
+	snprintf(pout,1255,"  grid size = xlen * ylen * zlen * tlen * elen = %d * %d * %d * %d * %d\n",
 		xlen,ylen,zlen,tlen,elen);
 	gaprnt (0,pout);
 	rtrn=1; goto cleanup;
@@ -2814,7 +2814,7 @@ gaint oldncopts ;         /* to save and restore setting for automatic error han
     /* Do the I/O into temporary grid grtmp2 */
     rc = nc_get_vara_double(pfi->ncid, pvr->ncvid, start, count, grtmp2);
     if (rc != NC_NOERR) {
-      snprintf(pout,255,"gancgrid error: nc_get_vara_double failed; %s\n",nc_strerror(rc));
+      snprintf(pout,1255,"gancgrid error: nc_get_vara_double failed; %s\n",nc_strerror(rc));
       gaprnt(0,pout);
       rtrn=1; goto cleanup;
     }
@@ -2834,7 +2834,7 @@ gaint oldncopts ;         /* to save and restore setting for automatic error han
     /* Do the I/O and put data directly into grtmp */
     rc = nc_get_vara_double(pfi->ncid, pvr->ncvid, start, count, grtmp);
     if (rc != NC_NOERR) {
-      snprintf(pout,255,"gancgrid error: nc_get_vara_double failed; %s\n",nc_strerror(rc));
+      snprintf(pout,1255,"gancgrid error: nc_get_vara_double failed; %s\n",nc_strerror(rc));
       gaprnt(0,pout);
       rtrn=1; goto cleanup;
     }
@@ -2995,7 +2995,7 @@ gaint gancrow (gaint x, gaint y, gaint z, gaint t, gaint e, gaint len, gadouble
   /* Now we are ready to do the I/O  */
   rc = nc_get_vara_double(pfi->ncid, pvr->ncvid, start, count, gr);
   if (rc != NC_NOERR) {
-    snprintf(pout,255,"NetCDF Error (gancrow, nc_get_vara_double): %s\n",nc_strerror(rc));
+    snprintf(pout,1255,"NetCDF Error (gancrow, nc_get_vara_double): %s\n",nc_strerror(rc));
     gaprnt(0,pout);
     ncopts = oldncopts ;
     return (1);
@@ -3077,10 +3077,10 @@ size_t sz;
     if (v_id==FAIL) {
       pvr->sdvid = -888;
       if (pvr->longnm[0] != '\0') {
-	snprintf(pout,255,"Error: Variable %s not in HDF-SDS file\n",pvr->longnm);
+	snprintf(pout,1255,"Error: Variable %s not in HDF-SDS file\n",pvr->longnm);
       }
       else {
-	snprintf(pout,255,"Error: Variable %s not in HDF-SDS file\n",pvr->abbrv);
+	snprintf(pout,1255,"Error: Variable %s not in HDF-SDS file\n",pvr->abbrv);
       }
       gaprnt(0,pout);
       return (1);
@@ -3095,17 +3095,17 @@ size_t sz;
       sds_id = SDselect(sd_id,v_id);
       if (sds_id==FAIL) {
 	if (pvr->longnm[0] != '\0') {
-	  snprintf(pout,255,"Error: SDselect failed for %s \n",pvr->longnm);
+	  snprintf(pout,1255,"Error: SDselect failed for %s \n",pvr->longnm);
 	}
 	else {
-	  snprintf(pout,255,"Error: SDselect failed for %s \n",pvr->abbrv);
+	  snprintf(pout,1255,"Error: SDselect failed for %s \n",pvr->abbrv);
 	}
 	gaprnt(0,pout);
 	return (1);
       }
       /* Retrieve the primary HDF undef attribute value */
       if (hdfattr(sds_id, pfi->undefattr, &val) != 0) {
-	snprintf(pout,255,"Warning: value for primary undef attribute \"%s\" not found\n",pfi->undefattr);
+	snprintf(pout,1255,"Warning: value for primary undef attribute \"%s\" not found\n",pfi->undefattr);
 	gaprnt(1,pout);
 	pvr->undef = pfi->undef;
       }
@@ -3115,7 +3115,7 @@ size_t sz;
       /* Retrieve the secondary HDF undef attribute value */
       if (pfi->undefattrflg==2) {
         if (hdfattr(sds_id, pfi->undefattr2, &val) != 0) {
-	  snprintf(pout,255,"Warning: value for secondary undef attribute \"%s\" not found\n",pfi->undefattr2);
+	  snprintf(pout,1255,"Warning: value for secondary undef attribute \"%s\" not found\n",pfi->undefattr2);
   	  gaprnt(1,pout);
 	  pvr->undef2 = pfi->undef;
         }
@@ -3141,10 +3141,10 @@ size_t sz;
       sds_id = SDselect(sd_id,v_id);
       if (sds_id==FAIL) {
 	if (pvr->longnm[0] != '\0') {
-	  snprintf(pout,255,"Error: SDselect failed for %s \n",pvr->longnm);
+	  snprintf(pout,1255,"Error: SDselect failed for %s \n",pvr->longnm);
 	}
 	else {
-	  snprintf(pout,255,"Error: SDselect failed for %s \n",pvr->abbrv);
+	  snprintf(pout,1255,"Error: SDselect failed for %s \n",pvr->abbrv);
 	}
 	gaprnt(0,pout);
 	return (1);
@@ -3152,7 +3152,7 @@ size_t sz;
       /* Retrieve the scale factor attribute value */
       if (pfi->packflg == 1 || pfi->packflg == 2) {
 	if (hdfattr(sds_id, pfi->scattr, &pvr->scale) != 0) {
-	  snprintf(pout,255,"Warning: Could not retrieve \"%s\" -- setting to 1.0\n",pfi->scattr);
+	  snprintf(pout,1255,"Warning: Could not retrieve \"%s\" -- setting to 1.0\n",pfi->scattr);
 	  gaprnt(1,pout);
 	  pvr->scale = 1.0;
 	}
@@ -3160,7 +3160,7 @@ size_t sz;
       /* Retrieve the add offset attribute value if required */
       if (pfi->packflg == 2 || pfi->packflg == 3) {
 	if (hdfattr(sds_id, pfi->ofattr, &pvr->add) != 0) {
-	  snprintf(pout,255,"Warning: Could not retrieve \"%s\" -- setting to 0.0\n",pfi->ofattr);
+	  snprintf(pout,1255,"Warning: Could not retrieve \"%s\" -- setting to 0.0\n",pfi->ofattr);
 	  gaprnt(1,pout);
 	  pvr->add = 0.0;
 	}
@@ -3174,10 +3174,10 @@ size_t sz;
 
   if (sds_id==FAIL) {
     if (pvr->longnm[0] != '\0') {
-      snprintf(pout,255,"Error: SDselect failed for %s \n",pvr->longnm);
+      snprintf(pout,1255,"Error: SDselect failed for %s \n",pvr->longnm);
     }
     else {
-      snprintf(pout,255,"Error: SDselect failed for %s \n",pvr->abbrv);
+      snprintf(pout,1255,"Error: SDselect failed for %s \n",pvr->abbrv);
     }
     gaprnt(0,pout);
     return (1);
@@ -3369,7 +3369,7 @@ size_t sz;
       break;
 
     default:
-      snprintf(pout,255,"HDF-SDS Error: Data type %d not handled\n", data_dtype);
+      snprintf(pout,1255,"HDF-SDS Error: Data type %d not handled\n", data_dtype);
       gaprnt(0,pout);
       return(1);
   };
@@ -3439,7 +3439,7 @@ gaint h5setup(void) {
   /* Retrieve the HDF5 undef attribute value */
   if (pfi->undefattrflg) {
     if (h5attr(vid, vname, pfi->undefattr, &val) != 0) {
-      snprintf(pout,255,"h5setup warning: Could not retrieve undef attribute \"%s\" -- using %g instead\n",
+      snprintf(pout,1255,"h5setup warning: Could not retrieve undef attribute \"%s\" -- using %g instead\n",
 	      pfi->undefattr,pfi->undef);
       gaprnt(1,pout);
       pvr->undef = pfi->undef;
@@ -3462,7 +3462,7 @@ gaint h5setup(void) {
     /* Retrieve the scale factor attribute value */
     if (pfi->packflg == 1 || pfi->packflg == 2) {
       if (h5attr(vid, vname, pfi->scattr, &val) != 0) {
-	snprintf(pout,255,"Warning: Could not retrieve \"%s\" -- setting to 1.0\n",pfi->scattr);
+	snprintf(pout,1255,"Warning: Could not retrieve \"%s\" -- setting to 1.0\n",pfi->scattr);
 	gaprnt(1,pout);
       }
       else { 
@@ -3472,7 +3472,7 @@ gaint h5setup(void) {
     /* Retrieve the add offset attribute value if required */
     if (pfi->packflg == 2 || pfi->packflg == 3) {
       if (h5attr(vid, vname, pfi->ofattr, &val) != 0) {
-	snprintf(pout,255,"Warning: Could not retrieve \"%s\" -- setting to 0.0\n",pfi->ofattr);
+	snprintf(pout,1255,"Warning: Could not retrieve \"%s\" -- setting to 0.0\n",pfi->ofattr);
 	gaprnt(1,pout);
       }
       else {
@@ -3495,14 +3495,14 @@ gaint h5setup(void) {
                 gaprnt(1,"*** WARNING! ***\n");
                 gaprnt(1,"*** The I/O for this variable will be extremely slow \n");
                 gaprnt(1,"*** because the chunks are too big to fit in the cache \n");
-                snprintf(pout,255,"*** chunk size = %ld bytes  (",(long)(nelems*size));
+                snprintf(pout,1255,"*** chunk size = %ld bytes  (",(long)(nelems*size));
                 gaprnt(1,pout);
                 for (i=ndims-1; i>=0; i--) { 
-                	snprintf(pout,255,"%ld * ",(long)chsize[i]); gaprnt(1,pout); 
+                	snprintf(pout,1255,"%ld * ",(long)chsize[i]); gaprnt(1,pout); 
                 }
-                snprintf(pout,255,"%ld bytes)\n",(long)size);
+                snprintf(pout,1255,"%ld bytes)\n",(long)size);
                 gaprnt(1,pout);
-                snprintf(pout,255,"*** cache size = %ld bytes \n",pfi->cachesize);
+                snprintf(pout,1255,"*** cache size = %ld bytes \n",pfi->cachesize);
                 gaprnt(1,pout);
                 gaprnt(1,"*** There are two ways to control the cache size: \n");
                 gaprnt(1,"*** add a CACHESIZE entry to the descriptor file \n");
@@ -3541,7 +3541,7 @@ gaint h5openvar (gaint h5id, char *vname, hid_t *dataspace, hid_t *h5varflg) {
   fid = (hid_t)h5id;
   vid = H5Dopen2 (fid, vname, plid);
   if (vid<0) {
-    snprintf(pout,255,"Error: H5Dopen2 failed for variable %s \n",vname);
+    snprintf(pout,1255,"Error: H5Dopen2 failed for variable %s \n",vname);
     gaprnt(0,pout);
     return (1); 
   }
@@ -3569,7 +3569,7 @@ gaint h5closevar (hid_t dsid, hid_t vid) {
   /* release variable dataspace */
   if (dsid > (hid_t)0) {
     if ((H5Sclose(dsid))<0) {
-      snprintf(pout,255,"H5Sclose failed to close dataspace %d\n",(gaint)dsid);
+      snprintf(pout,1255,"H5Sclose failed to close dataspace %d\n",(gaint)dsid);
       gaprnt(1,pout);
       return (1);
     }
@@ -3577,7 +3577,7 @@ gaint h5closevar (hid_t dsid, hid_t vid) {
   /* close variable */
   if (vid > (hid_t)0) {
     if ((H5Dclose(vid))<0) {
-      snprintf(pout,255,"H5Dclose failed to close varid %d\n",(gaint)vid);
+      snprintf(pout,1255,"H5Dclose failed to close varid %d\n",(gaint)vid);
       gaprnt(1,pout);
       return (1);
     }
@@ -3689,7 +3689,7 @@ gafloat *fval;
       } 
     }
     else {
-      snprintf(pout,255,"H5T_FLOAT of size %d not handled\n",(int)datasize);
+      snprintf(pout,1255,"H5T_FLOAT of size %d not handled\n",(int)datasize);
       gaprnt(0,pout);
       return (1);
     }
@@ -3832,13 +3832,13 @@ gafloat *fval;
       }
     }
     else {
-      snprintf(pout,255,"H5T_INTEGER of size %d not handled\n",(int)datasize);
+      snprintf(pout,1255,"H5T_INTEGER of size %d not handled\n",(int)datasize);
       gaprnt(2,pout);
       return (1);
     }
   }
   else {
-    snprintf(pout,255,"HDF5 Error: Data class %d not handled\n", dataclass);
+    snprintf(pout,1255,"HDF5 Error: Data class %d not handled\n", dataclass);
     gaprnt(0,pout);
     return(1);
   }
@@ -3907,7 +3907,7 @@ gadouble dval;
 
   /* get the attribute id */
   if ((aid = H5Aopen_by_name(vid, vname, aname, H5P_DEFAULT, H5P_DEFAULT))<0) {
-    snprintf(pout,255,"HDF5 attribute named \"%s\" does not exist\n",aname);
+    snprintf(pout,1255,"HDF5 attribute named \"%s\" does not exist\n",aname);
     gaprnt(2,pout);
     return(1);
   } 
@@ -4037,7 +4037,7 @@ size_t sz;
   /* Get the attribute index number from its name */
   attr_index = SDfindattr(sds_id, attr_name);
   if (attr_index == -1) {
-    snprintf(pout,255,"Warning: HDF attribute named \"%s\" does not exist\n",attr_name);
+    snprintf(pout,1255,"Warning: HDF attribute named \"%s\" does not exist\n",attr_name);
     gaprnt(1,pout);
     return(1);
   } 
@@ -4049,7 +4049,7 @@ size_t sz;
   } 
   else {
     if (attr_count != 1) {
-      snprintf(pout,255,"Warning: HDF attribute named \"%s\" has more than one value\n",attr_name);
+      snprintf(pout,1255,"Warning: HDF attribute named \"%s\" has more than one value\n",attr_name);
       gaprnt(1,pout);
       return(1);
     }
@@ -4162,7 +4162,7 @@ size_t sz;
 	break;
 	
       default:
-	snprintf(pout,255,"Warning: HDF Attribute \"%s\" is not a numeric data type (%d)\n", 
+	snprintf(pout,1255,"Warning: HDF Attribute \"%s\" is not a numeric data type (%d)\n", 
 		attr_name, attr_dtype);
 	gaprnt(1,pout);
 	return(1);
@@ -4209,7 +4209,7 @@ size_t sz,asize;
   if (!error) {
     if (hdrflg) {
       if (n_atts > 0) {
-	snprintf(pout,255,"Native Attributes for File %i : %s \n",fnum,ftit);
+	snprintf(pout,1255,"Native Attributes for File %i : %s \n",fnum,ftit);
 	gaprnt(2,pout);
       }
     }
@@ -4223,13 +4223,13 @@ size_t sz,asize;
 
     /* Get current attribute's name */
     if (nc_inq_attname(ncid, varid, aindx, attr_name) == -1) {
-      snprintf(pout,255,"nc_inq_attname failed for variable %s, attribute number %d\n", abbrv, aindx);
+      snprintf(pout,1255,"nc_inq_attname failed for variable %s, attribute number %d\n", abbrv, aindx);
       gaprnt(2,pout);
     }
     else {
       /* Get current attribute's data type and length */
       if (nc_inq_att(ncid, varid, attr_name, &attr_dtype, &asize) == -1) {
-	snprintf(pout,255,"nc_inq_att failed for variable %s, attribute number %d\n", abbrv, aindx);
+	snprintf(pout,1255,"nc_inq_att failed for variable %s, attribute number %d\n", abbrv, aindx);
 	gaprnt(2,pout);
       }
       else {
@@ -4249,7 +4249,7 @@ size_t sz,asize;
 		gaprnt(2,attr_name); 
 		gaprnt(2," ");
 		for (i=0; i<asize; i++) {
-		  snprintf(pout,255,"%d ", (gaint)(battr_val[i])); 
+		  snprintf(pout,1255,"%d ", (gaint)(battr_val[i])); 
 		  gaprnt(2,pout);
 		}
 		gaprnt(2,"\n");
@@ -4284,7 +4284,7 @@ size_t sz,asize;
 		gaprnt(2,attr_name); 
 		gaprnt(2," ");
 		for (i=0; i<asize; i++) {
-		  snprintf(pout,255,"%d", (gaint)(sattr_val[i])); 
+		  snprintf(pout,1255,"%d", (gaint)(sattr_val[i])); 
 		  gaprnt(2,pout);
 		  if (i<asize-1) gaprnt(2,",");
 		}
@@ -4304,7 +4304,7 @@ size_t sz,asize;
 		gaprnt(2,attr_name); 
 		gaprnt(2," ");
 		for (i=0; i<asize; i++) {
-		  snprintf(pout,255,"%ld", iattr_val[i]); 
+		  snprintf(pout,1255,"%ld", iattr_val[i]); 
 		  gaprnt(2,pout);
 		  if (i<asize-1) gaprnt(2,",");
 		}
@@ -4324,7 +4324,7 @@ size_t sz,asize;
 		gaprnt(2,attr_name); 
 		gaprnt(2," ");
 		for (i=0; i<asize; i++) {
-		  snprintf(pout,255,"%g", fattr_val[i]);
+		  snprintf(pout,1255,"%g", fattr_val[i]);
 		  gaprnt(2,pout);
 		  if (i<asize-1) gaprnt(2,",");
 		}
@@ -4344,7 +4344,7 @@ size_t sz,asize;
 		gaprnt(2,attr_name); 
 		gaprnt(2," ");
 		for (i=0; i<asize; i++) {
-		  snprintf(pout,255,"%g", dattr_val[i]); 
+		  snprintf(pout,1255,"%g", dattr_val[i]); 
 		  gaprnt(2,pout);
 		  if (i<asize-1) gaprnt(2,",");
 		}
@@ -4353,7 +4353,7 @@ size_t sz,asize;
 	      gree(dattr_val,"f144");
 	      break;
 	    default:
-	      snprintf(pout,255,"Failed to retrieve attribute %d of type %d \n", aindx, attr_dtype);
+	      snprintf(pout,1255,"Failed to retrieve attribute %d of type %d \n", aindx, attr_dtype);
 	      gaprnt(2,pout);
 	    };
 	} /* end of if statement for asize >0 */
@@ -4407,7 +4407,7 @@ size_t sz;
   if (!error) {
     if (hdrflg) {
       if (n_atts > 0) {
-	snprintf(pout,255,"Native Attributes for File %i : %s \n",fnum,ftit);
+	snprintf(pout,1255,"Native Attributes for File %i : %s \n",fnum,ftit);
 	gaprnt(2,pout);
       }
     }
@@ -4421,7 +4421,7 @@ size_t sz;
 	 
     /* Get info about the current attribute and then print out Name, Type, and Value */
     if (SDattrinfo(sds_id, attr_index, attr_name, &attr_dtype, &attr_count) == -1) {
-      snprintf(pout,255,"SDattrinfo failed for variable %s, attribute number %d\n", abbrv, attr_index);
+      snprintf(pout,1255,"SDattrinfo failed for variable %s, attribute number %d\n", abbrv, attr_index);
       gaprnt(2,pout);
     }
     else {
@@ -4435,7 +4435,7 @@ size_t sz;
 	  }
 	  else {
 	    cattr_val[attr_count]='\0';
-	    snprintf(pout,255,"%s String %s ",abbrv,attr_name); 
+	    snprintf(pout,1255,"%s String %s ",abbrv,attr_name); 
 	    gaprnt(2,pout);
 	    prntwrap(abbrv, attr_name, cattr_val);
 	  }
@@ -4469,7 +4469,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%d ", (gaint)(icattr_val[i])); 
+	      snprintf(pout,1255,"%d ", (gaint)(icattr_val[i])); 
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4488,7 +4488,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%u ", (gauint)(uicattr_val[i])); 
+	      snprintf(pout,1255,"%u ", (gauint)(uicattr_val[i])); 
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4507,7 +4507,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%d ", (gaint)(sattr_val[i])); 
+	      snprintf(pout,1255,"%d ", (gaint)(sattr_val[i])); 
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4526,7 +4526,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%u ", (gauint)(usattr_val[i])); 
+	      snprintf(pout,1255,"%u ", (gauint)(usattr_val[i])); 
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4545,7 +4545,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%d ", iattr_val[i]); 
+	      snprintf(pout,1255,"%d ", iattr_val[i]); 
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4564,7 +4564,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%u ", uiattr_val[i]); 
+	      snprintf(pout,1255,"%u ", uiattr_val[i]); 
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4583,7 +4583,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%g ", fattr_val[i]);
+	      snprintf(pout,1255,"%g ", fattr_val[i]);
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4602,7 +4602,7 @@ size_t sz;
 	    gaprnt(2,attr_name); 
 	    gaprnt(2," ");
 	    for (i=0; i<attr_count; i++) {
-	      snprintf(pout,255,"%g ", dattr_val[i]); 
+	      snprintf(pout,1255,"%g ", dattr_val[i]); 
 	      gaprnt(2,pout);
 	    }
 	    gaprnt(2,"\n");
@@ -4610,7 +4610,7 @@ size_t sz;
 	  gree(dattr_val,"f154");
 	  break;
 	default:
-	  snprintf(pout,255,"Failed to retrieve attribute %d of type %d \n", attr_index, attr_dtype);
+	  snprintf(pout,1255,"Failed to retrieve attribute %d of type %d \n", attr_index, attr_dtype);
 	  gaprnt(2,pout);
 	};
     }  /* end of if-else statment following call to SDattrinfo */
@@ -4657,7 +4657,7 @@ gadouble *dval=NULL;
   n_atts = (gaint)oinfo.num_attrs;
   if (hdrflg) {
     if (n_atts > 0) {
-      snprintf(pout,255,"Native Attributes for File %i : %s \n",fnum,ftit);
+      snprintf(pout,1255,"Native Attributes for File %i : %s \n",fnum,ftit);
       gaprnt(2,pout);
     }
   }
@@ -4682,7 +4682,7 @@ gadouble *dval=NULL;
     if (!err) aclass = H5Tget_class(atype); if (aclass<0) err=1;
     if (!err) asize  = H5Tget_size(atype); if (asize<0) err=1;
     if (err) {
-      snprintf(pout,255,"Unable to retrieve required info for attribute number %d for variable %s \n",aindex,abbrv);
+      snprintf(pout,1255,"Unable to retrieve required info for attribute number %d for variable %s \n",aindex,abbrv);
       gaprnt(2,pout);
       continue; /* move on to the next attribute */
     }
@@ -4694,9 +4694,9 @@ gadouble *dval=NULL;
 	  sz = rank*sizeof(gafloat);
 	  if ((fval = (gafloat*)galloc(sz,"fval"))!=NULL) {
 	    if ((rc = H5Aread(aid,H5T_NATIVE_FLOAT,fval))>=0) {
-	      snprintf(pout,255,"%s Float32 %s ",abbrv,aname); gaprnt(2,pout);
+	      snprintf(pout,1255,"%s Float32 %s ",abbrv,aname); gaprnt(2,pout);
 	      for (i=0; i<rank; i++) {
-		snprintf(pout,255,"%g ", fval[i]); gaprnt(2,pout);
+		snprintf(pout,1255,"%g ", fval[i]); gaprnt(2,pout);
 	      }
 	      gaprnt(2,"\n");
 	    }
@@ -4708,9 +4708,9 @@ gadouble *dval=NULL;
 	  sz = rank*sizeof(gadouble);
 	  if ((dval = (gadouble*)galloc(sz,"dval"))!=NULL) {
 	    if ((rc = H5Aread(aid,H5T_NATIVE_DOUBLE,dval))>=0) {
-	      snprintf(pout,255,"%s Float64 %s ",abbrv,aname); gaprnt(2,pout);
+	      snprintf(pout,1255,"%s Float64 %s ",abbrv,aname); gaprnt(2,pout);
 	      for (i=0; i<rank; i++) {
-		snprintf(pout,255,"%g ", dval[i]); gaprnt(2,pout);
+		snprintf(pout,1255,"%g ", dval[i]); gaprnt(2,pout);
 	      }
 	      gaprnt(2,"\n");
 	    }
@@ -4727,9 +4727,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(unsigned char);
 	      if ((ucval = (unsigned char*)galloc(sz,"ucval"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_UCHAR,(void*)ucval))>=0) {
-		  snprintf(pout,255,"%s Byte %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s Byte %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%u ", (gaint)ucval[i]); 
+		    snprintf(pout,1255,"%u ", (gaint)ucval[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4741,9 +4741,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(char);
 	      if ((cval = (char*)galloc(sz,"cval"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_CHAR,(void*)cval))>=0) {
-		  snprintf(pout,255,"%s Byte %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s Byte %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%d ", (gaint)cval[i]); 
+		    snprintf(pout,1255,"%d ", (gaint)cval[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4758,9 +4758,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(unsigned short);
 	      if ((usval = (unsigned short*)galloc(sz,"usval"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_USHORT,(void*)usval))>=0) {
-		  snprintf(pout,255,"%s UInt16 %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s UInt16 %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%u ", (gaint)usval[i]); 
+		    snprintf(pout,1255,"%u ", (gaint)usval[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4772,9 +4772,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(short);
 	      if ((sval = (short*)galloc(sz,"sval"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_SHORT,(void*)sval))>=0) {
-		  snprintf(pout,255,"%s Int16 %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s Int16 %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%d ", (gaint)sval[i]); 
+		    snprintf(pout,1255,"%d ", (gaint)sval[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4789,9 +4789,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(gauint);
 	      if ((uival = (gauint*)galloc(sz,"uival"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_UINT,(void*)uival))>=0) {
-		  snprintf(pout,255,"%s UInt32 %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s UInt32 %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%u ", uival[i]); 
+		    snprintf(pout,1255,"%u ", uival[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4803,9 +4803,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(gaint);
 	      if ((ival = (gaint*)galloc(sz,"ival"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_INT,(void*)ival))>=0) {
-		  snprintf(pout,255,"%s Int32 %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s Int32 %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%d ", ival[i]); 
+		    snprintf(pout,1255,"%d ", ival[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4820,9 +4820,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(unsigned long);
 	      if ((ulval = (unsigned long*)galloc(sz,"ulval"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_ULONG,(void*)ulval))>=0) {
-		  snprintf(pout,255,"%s UInt32 %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s UInt32 %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%lu ", ulval[i]); 
+		    snprintf(pout,1255,"%lu ", ulval[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4834,9 +4834,9 @@ gadouble *dval=NULL;
 	      sz = rank*sizeof(long);
 	      if ((lval = (long*)galloc(sz,"lval"))!=NULL) {
 		if ((rc = H5Aread(aid,H5T_NATIVE_LONG,(void*)lval))>=0) {
-		  snprintf(pout,255,"%s Int32 %s ",abbrv,aname); gaprnt(2,pout);
+		  snprintf(pout,1255,"%s Int32 %s ",abbrv,aname); gaprnt(2,pout);
 		  for (i=0; i<rank; i++) {
-		    snprintf(pout,255,"%ld ", lval[i]); 
+		    snprintf(pout,1255,"%ld ", lval[i]); 
 		    gaprnt(2,pout);
 		  }
 		  gaprnt(2,"\n");
@@ -4846,7 +4846,7 @@ gadouble *dval=NULL;
 	    }
 	  }
 	  else {
-	    snprintf(pout,255,"HDF5 class H5T_INTEGER of size %d not handled\n",(gaint)asize);
+	    snprintf(pout,1255,"HDF5 class H5T_INTEGER of size %d not handled\n",(gaint)asize);
 	    gaprnt(2,pout);
 	  }
 	}
@@ -4856,7 +4856,7 @@ gadouble *dval=NULL;
 	  if ((string = (char*)malloc((stosize+1)*sizeof(char)))!=NULL) {
 	    if ((rc = H5Aread(aid,atype,(void*)string))>=0) {
 	      string[stosize]='\0';
-	      snprintf(pout,255,"%s String %s ",abbrv,aname);
+	      snprintf(pout,1255,"%s String %s ",abbrv,aname);
 	      gaprnt(2,pout);
 	      prntwrap(abbrv,aname,string);
 	    }
@@ -4885,7 +4885,7 @@ void prntwrap(char *vname, char *aname, char *str ) {
       *pos = '\0';         /* swap null for carriage return */
       gaprnt(2,line);
       /* add varname, attr_type, and attr_name after carriage return */
-      snprintf(pout,255," \n%s String %s ",vname,aname); 
+      snprintf(pout,1255," \n%s String %s ",vname,aname); 
       gaprnt(2,pout);
       *pos = '\n';         /* put the carriage return back in */
       line = pos+1;
@@ -5040,9 +5040,9 @@ char *filename;
   rc = nc_open(filename, NC_NOWRITE, &i);
   if (rc != NC_NOERR) {
     if (eflag) {
-      snprintf(pout,255,"Error: nc_open failed to open file %s\n",filename);
+      snprintf(pout,1255,"Error: nc_open failed to open file %s\n",filename);
       gaprnt(0,pout);
-      snprintf(pout,255,"%s\n",nc_strerror(rc));
+      snprintf(pout,1255,"%s\n",nc_strerror(rc));
       gaprnt(0,pout);
     }
     return (1);
@@ -5070,7 +5070,7 @@ gaint gaophdf (struct gafile *pfil, gaint tflag, gaint eflag) {
   /* open the file, set the file id in the gafile structure */
   if ((sd_id = SDstart(filename, DFACC_READ))==FAIL) {
     if (eflag) {
-      snprintf(pout,255,"gaophdf error: SDstart failed to open hdf-sds file %s\n",filename);
+      snprintf(pout,1255,"gaophdf error: SDstart failed to open hdf-sds file %s\n",filename);
       gaprnt(0,pout);
     }
     return (1);
@@ -5113,7 +5113,7 @@ gaint gaoph5 (struct gafile *pfil, gaint tflag, gaint eflag) {
   }
   else {
     if (eflag) {
-      snprintf(pout,255,"Error: Unable to open HDF5 file %s \n",filename);
+      snprintf(pout,1255,"Error: Unable to open HDF5 file %s \n",filename);
       gaprnt(0,pout);
     }
     return (1);
@@ -5133,7 +5133,7 @@ gaint gaclosenc (struct gafile *pfi) {
     rc = nc_close(pfi->ncid);
     if (rc != NC_NOERR) {
       gaprnt(0,"Error: nc_close failed\n");
-      snprintf(pout,255,"%s\n",nc_strerror(rc));
+      snprintf(pout,1255,"%s\n",nc_strerror(rc));
       gaprnt(0,pout);
       return (1);
     }
diff --git a/src/gasdf.c b/src/gasdf.c
index 49af15f..37443da 100644
--- a/src/gasdf.c
+++ b/src/gasdf.c
@@ -43,7 +43,7 @@ extern struct gamfcmn mfcmn ;
 extern FILE *descr ;
 
 char *gxgnam(char *) ;     /* This is also in gx.h */
-static char pout[256];    /* Build error msgs here */
+static char pout[1256];    /* Build error msgs here */
 gaint utISinit = 0 ;
 
 
@@ -108,7 +108,7 @@ gaint gasdfopen (char *args, struct gacmn *pcm) {
     pcm->pfid = pcm->pfi1; 
     pcm->dfnum = 1;
   }
-  snprintf(pout,255,"SDF file %s is open as file %i\n",pfi->name,pcm->fnum);
+  snprintf(pout,1255,"SDF file %s is open as file %i\n",pfi->name,pcm->fnum);
   gaprnt (2,pout);
 
   /* If first file open, set up some default dimension ranges for the user */
@@ -117,10 +117,10 @@ gaint gasdfopen (char *args, struct gacmn *pcm) {
       gacmd ("set lon 0 360",pcm,0);
     }
     else {
-      snprintf(pout,255,"set x 1 %i",pfi->dnum[0]);
+      snprintf(pout,1255,"set x 1 %i",pfi->dnum[0]);
       gacmd (pout,pcm,0);
     }
-    snprintf(pout,255,"set y 1 %i",pfi->dnum[1]);
+    snprintf(pout,1255,"set y 1 %i",pfi->dnum[1]);
     gacmd (pout,pcm,0);
     gacmd ("set z 1",pcm,0);
     gacmd ("set t 1",pcm,0);
@@ -204,7 +204,7 @@ gaint gaxdfopen (char *args, struct gacmn *pcm) {
   /* get remaining required metadata */
   rc = gadsdf(pfi, parms) ;
   if (rc==Failure) {
-    snprintf(pout,255, "SDF Descriptor file %s was not successfully opened & parsed.\n", pfi->dnam) ;
+    snprintf(pout,1255, "SDF Descriptor file %s was not successfully opened & parsed.\n", pfi->dnam) ;
     gaprnt(0, pout) ;
     frepfi (pfi, 0) ;
     freeparms(&parms);
@@ -225,7 +225,7 @@ gaint gaxdfopen (char *args, struct gacmn *pcm) {
     return Failure;
   } 
   else {
-    snprintf(pout,255, "SDF file %s is open as file %i\n", pfi->name, pcm->fnum);
+    snprintf(pout,1255, "SDF file %s is open as file %i\n", pfi->name, pcm->fnum);
     gaprnt(2, pout);
   }
 
@@ -235,10 +235,10 @@ gaint gaxdfopen (char *args, struct gacmn *pcm) {
       gacmd ("set lon 0 360",pcm,0);
     }
     else {
-      snprintf(pout,255,"set x 1 %i",pfi->dnum[0]);
+      snprintf(pout,1255,"set x 1 %i",pfi->dnum[0]);
       gacmd (pout,pcm,0);
     }
-    snprintf(pout,255,"set y 1 %i",pfi->dnum[1]);
+    snprintf(pout,1255,"set y 1 %i",pfi->dnum[1]);
     gacmd (pout,pcm,0);
     gacmd ("set z 1",pcm,0);
     gacmd ("set t 1",pcm,0);
@@ -428,7 +428,7 @@ utUnit timeunit ;
       /* find the axis named in the descriptor file */
       Xcoord = find_var(pfi, parms.xdimname) ;
       if (!Xcoord) {
-	snprintf(pout,255, "gadsdf: Can't find variable %s for X coordinate.\n",parms.xdimname);
+	snprintf(pout,1255, "gadsdf: Can't find variable %s for X coordinate.\n",parms.xdimname);
 	gaprnt(0,pout);
 	return Failure ;
       }
@@ -452,7 +452,7 @@ utUnit timeunit ;
   if (parms.isxdf && (!parms.xsrch)) {
     xdimid = find_dim(pfi, parms.xdimname) ;
     if (xdimid == -1) {
-      snprintf(pout,255, "gadsdf: Lon dimension %s is not an SDF dimension.\n",parms.xdimname);
+      snprintf(pout,1255, "gadsdf: Lon dimension %s is not an SDF dimension.\n",parms.xdimname);
       gaprnt(0,pout);
       return Failure;
     }
@@ -481,7 +481,7 @@ utUnit timeunit ;
       /* find the axis named in the descriptor file */
       Ycoord = find_var(pfi, parms.ydimname) ;
       if (!Ycoord) {
-	snprintf(pout,255, "gadsdf: Can't find variable %s for Y coordinate.\n",parms.ydimname);
+	snprintf(pout,1255, "gadsdf: Can't find variable %s for Y coordinate.\n",parms.ydimname);
 	gaprnt(0,pout);
 	return Failure ;
       }
@@ -523,7 +523,7 @@ utUnit timeunit ;
   if (parms.isxdf && (!parms.ysrch)) {
     ydimid = find_dim(pfi, parms.ydimname) ;
     if (ydimid == -1) {
-      snprintf(pout,255,"gadsdf: Lat dimension %s is not an SDF dimension.\n",parms.ydimname);
+      snprintf(pout,1255,"gadsdf: Lat dimension %s is not an SDF dimension.\n",parms.ydimname);
       gaprnt(0,pout);
       return Failure;
     }
@@ -546,7 +546,7 @@ utUnit timeunit ;
       /* find the axis named in the descriptor file */
       Zcoord = find_var(pfi, parms.zdimname) ;
       if (!Zcoord) {
-	snprintf(pout,255,"gadsdf: Can't find variable %s for Z coordinate.\n",parms.zdimname);
+	snprintf(pout,1255,"gadsdf: Can't find variable %s for Z coordinate.\n",parms.zdimname);
 	gaprnt(0,pout);
 	return Failure ;
       }
@@ -621,7 +621,7 @@ utUnit timeunit ;
   if (parms.isxdf && (!parms.zsrch)) {
     zdimid = find_dim(pfi, parms.zdimname) ;
     if (zdimid == -1) {
-      snprintf(pout,255, "gadsdf: Lev dimension %s is not an SDF dimension.\n",parms.zdimname);
+      snprintf(pout,1255, "gadsdf: Lev dimension %s is not an SDF dimension.\n",parms.zdimname);
       gaprnt(0,pout);
       return Failure;
     }
@@ -643,7 +643,7 @@ utUnit timeunit ;
       /* find the axis named in the descriptor file */
       Tcoord = find_var(pfi, parms.tdimname) ;
       if (!Tcoord) {
-	snprintf(pout,255, "gadsdf: Can't find variable %s for T coordinate.\n",parms.tdimname);
+	snprintf(pout,1255, "gadsdf: Can't find variable %s for T coordinate.\n",parms.tdimname);
 	gaprnt(0,pout);
 	return Failure ;
       }
@@ -982,7 +982,7 @@ utUnit timeunit ;
 		    tvals[6] = 0.0 ;
 		  } 
 		  else {
-		    gaprnt(0,"gadsdf: Time increment too large for 'seconds since' time units attribute\n");
+		    gaprnt(0,"gadsdf: Time increment is too large for 'seconds since' time units attribute\n");
 		    goto err2;
 		  }
 		}
@@ -1017,7 +1017,7 @@ utUnit timeunit ;
     if (parms.tdimname != NULL) {
       tdimid = find_dim(pfi, parms.tdimname) ;
       if (tdimid == -1) {
-	snprintf(pout,255, "gadsdf: Time dimension %s is not an SDF dimension.\n",parms.tdimname);
+	snprintf(pout,1255, "gadsdf: Time dimension %s is not an SDF dimension.\n",parms.tdimname);
 	gaprnt(0,pout);
 	return Failure;
       }
@@ -1042,7 +1042,7 @@ utUnit timeunit ;
       /* find the axis named in the descriptor file */
       Ecoord = find_var(pfi, parms.edimname) ;
       if (!Ecoord) {
-	snprintf(pout,255,"gadsdf: Can't find variable %s for Ensemble coordinate.\n",parms.edimname);
+	snprintf(pout,1255,"gadsdf: Can't find variable %s for Ensemble coordinate.\n",parms.edimname);
 	gaprnt(0,pout);
 	return Failure ;
       }
@@ -1206,7 +1206,7 @@ utUnit timeunit ;
   if (parms.isxdf && (!parms.esrch)) {
     edimid = find_dim(pfi, parms.edimname) ;
     if (edimid == -1) {
-      snprintf(pout,255,"gadsdf: Ensemble dimension %s is not an SDF dimension.\n",parms.edimname);
+      snprintf(pout,1255,"gadsdf: Ensemble dimension %s is not an SDF dimension.\n",parms.edimname);
       gaprnt(0,pout);
       return Failure;
     }
@@ -1252,7 +1252,7 @@ utUnit timeunit ;
       /* get filename for initial time of current ensemble member  */
       ch = gafndt(pfi->name,&tdefe,&tdefe,pfi->abvals[3],pfi->pchsub1,pfi->ens1,ens->gt,e,&flag);   
       if (ch==NULL) {
-	snprintf(pout,255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,ens->gt);
+	snprintf(pout,1255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,ens->gt);
 	gaprnt(0,pout);
 	goto err2;
       }
@@ -1263,7 +1263,7 @@ utUnit timeunit ;
 	gr2t(pfi->grvals[3],(gadouble)t,&tdef);
 	pos = gafndt(pfi->name,&tdef,&tdefe,pfi->abvals[3],pfi->pchsub1,pfi->ens1,t,e,&flag);  
 	if (pos==NULL) {
-	  snprintf(pout,255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,t);
+	  snprintf(pout,1255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,t);
 	  gaprnt(0,pout);
 	  goto err2;
 	}
@@ -1633,7 +1633,7 @@ uint32 *uidata=NULL;
       break;
       
     default:
-      snprintf(pout,255,"HDF coordinate axis data type %d not handled\n",dtype);
+      snprintf(pout,1255,"HDF coordinate axis data type %d not handled\n",dtype);
       gaprnt(0,pout);
       goto err1;
     };
@@ -2267,7 +2267,7 @@ char dimname[H4_MAX_NC_NAME+1];
       sds_id = SDselect(pfi->sdid, i);
       status = SDgetinfo(sds_id, sdsname, &rank, dim_sizes, &dtype, &natts);
       if (status == -1) {
-	snprintf(pout,255,"read_metadata: SDgetinfo failed for sds_id=%d\n",sds_id);
+	snprintf(pout,1255,"read_metadata: SDgetinfo failed for sds_id=%d\n",sds_id);
 	gaprnt(0,pout);
 	goto err3;
       }
@@ -2276,7 +2276,7 @@ char dimname[H4_MAX_NC_NAME+1];
 	dim_id = SDgetdimid(sds_id,0);                                  
 	status = SDdiminfo(dim_id, dimname, &dimsize, &dtype, &ndatts); 
 	if (status == -1) {
-	  snprintf(pout,255,"read_metadata: SDdiminfo failed for sds_id=%d, dimid=%d\n",sds_id,dim_id);
+	  snprintf(pout,1255,"read_metadata: SDdiminfo failed for sds_id=%d, dimid=%d\n",sds_id,dim_id);
 	  gaprnt(0,pout);
 	  goto err3;
 	}
@@ -2385,19 +2385,19 @@ char dimname[H4_MAX_NC_NAME+1];
       /* get info about the current data set */
       sds_id = SDselect(pfi->sdid, i);
       if (sds_id==FAIL) {
-	snprintf(pout,255,"read_metadata: SDselect failed for varid %d\n",i);
+	snprintf(pout,1255,"read_metadata: SDselect failed for varid %d\n",i);
 	gaprnt(0,pout);
 	goto err3;
       }
       status = SDgetinfo(sds_id, name, &(pvar->nvardims), dim_sizes, &dtype, &natts);
       if (status == -1) {
-	snprintf(pout,255,"read_metadata: SDgetinfo failed for varid %d\n",i);
+	snprintf(pout,1255,"read_metadata: SDgetinfo failed for varid %d\n",i);
 	gaprnt(0,pout);
 	goto err3;
       }
       status = SDnametoindex(pfi->sdid, name);
       if (status == -1) {
-	snprintf(pout,255,"read_metadata: SDnametoindex failed for varid %d\n",i);
+	snprintf(pout,1255,"read_metadata: SDnametoindex failed for varid %d\n",i);
 	gaprnt(0,pout);
 	goto err3;
       }
@@ -2412,7 +2412,7 @@ char dimname[H4_MAX_NC_NAME+1];
     if (pfi->ncflg==1) {
       status = nc_inq_var(pfi->ncid, i, name, NULL, &(pvar->nvardims), pvar->vardimids, &natts);
       if (status != NC_NOERR) {
-	snprintf(pout,255,"read_metadata: nc_inq_var failed to retrieve variable info for varid %d\n",i);
+	snprintf(pout,1255,"read_metadata: nc_inq_var failed to retrieve variable info for varid %d\n",i);
 	gaprnt(0,pout);
 	handle_error(status);
 	goto err3;
@@ -2629,7 +2629,7 @@ size_t sz;
       return(Failure);
     }
     if (SDattrinfo(sds_id, i, attname, &attr_dtype, &attr_count) == -1) {
-      snprintf(pout,255,"SDattrinfo failed for variable %s, attribute number %d\n", varname, i);
+      snprintf(pout,1255,"SDattrinfo failed for variable %s, attribute number %d\n", varname, i);
       gaprnt(2,pout);
     }
     else {
@@ -2751,7 +2751,7 @@ size_t sz;
 	    }
 	    break;
 	  default:
-	    snprintf(pout,255,"Failed to retrieve attribute %d of type %d \n", i, attr_dtype);
+	    snprintf(pout,1255,"Failed to retrieve attribute %d of type %d \n", i, attr_dtype);
 	    gaprnt(2,pout);
 	  };
 	
@@ -2759,7 +2759,7 @@ size_t sz;
 	  /* Successfully extracted the attribute, so add a link to the list */
 	  sz = sizeof(struct gaattr);
 	  if ((newattrib = (struct gaattr *) galloc(sz,"newathdf")) == NULL) {
-	    snprintf(pout,255,"read_hdfatts error: memory allocation failed when adding attribute number %d\n",i);
+	    snprintf(pout,1255,"read_hdfatts error: memory allocation failed when adding attribute number %d\n",i);
 	    gaprnt(2,pout);
 	    if (cval)   { gree(cval,"f145");   cval=NULL;   }
 	    if (ucval)  { gree(ucval,"f146");  ucval=NULL;  }
@@ -2894,7 +2894,7 @@ nc_type type;
     status = nc_inq_attname(cdfid, varid, i, attname);
     if (status != NC_NOERR) { 
       handle_error(status); 
-      snprintf(pout,255,"read_ncatts: ncattname failed for varid %d attribute number %d\n",varid,i);
+      snprintf(pout,1255,"read_ncatts: ncattname failed for varid %d attribute number %d\n",varid,i);
       gaprnt(2,pout);
     }
     else {
@@ -2903,7 +2903,7 @@ nc_type type;
       status = nc_inq_att(cdfid, varid, attname, &type, &attlen);
       if (status != NC_NOERR) { 
 	handle_error(status); 
-	snprintf(pout,255,"read_ncatts: nc_inq_att failed for varid %d attribute number %d\n",varid,i);
+	snprintf(pout,1255,"read_ncatts: nc_inq_att failed for varid %d attribute number %d\n",varid,i);
 	gaprnt(2,pout);
       }
       else {
@@ -2920,7 +2920,7 @@ nc_type type;
 		gree(bval,"f22"); 
 		bval = NULL;
 		handle_error(status); 
-		snprintf(pout,255,"read_ncatts: failed to get %s attribute %d type BYTE\n",varname,i);
+		snprintf(pout,1255,"read_ncatts: failed to get %s attribute %d type BYTE\n",varname,i);
 		gaprnt(2,pout);
 	      }
 	      else { 
@@ -2936,7 +2936,7 @@ nc_type type;
 		gree(cval,"f24");
 		cval = NULL;
 		handle_error(status); 
-		snprintf(pout,255,"read_ncatts: failed to get %s attribute %d type CHAR\n",varname,i);
+		snprintf(pout,1255,"read_ncatts: failed to get %s attribute %d type CHAR\n",varname,i);
 		gaprnt(2,pout);
 	      }
 	      else { 
@@ -2952,7 +2952,7 @@ nc_type type;
 		gree(sval,"f26");
 		sval=NULL;
 		handle_error(status); 
-		snprintf(pout,255,"read_ncatts: failed to get %s attribute %d type SHORT\n",varname,i);
+		snprintf(pout,1255,"read_ncatts: failed to get %s attribute %d type SHORT\n",varname,i);
 		gaprnt(2,pout);
 	      }
 	      else { 
@@ -2967,7 +2967,7 @@ nc_type type;
 		gree(ival,"f28");
 		ival = NULL;
 		handle_error(status); 
-		snprintf(pout,255,"read_ncatts: failed to get %s attribute %d type LONG\n",varname,i);
+		snprintf(pout,1255,"read_ncatts: failed to get %s attribute %d type LONG\n",varname,i);
 		gaprnt(2,pout);
 	      }
 	      else { 
@@ -2982,7 +2982,7 @@ nc_type type;
 		gree(fval,"f30");
 		fval = NULL;
 		handle_error(status); 
-		snprintf(pout,255,"read_ncatts: failed to get %s attribute %d type FLOAT\n",varname,i);
+		snprintf(pout,1255,"read_ncatts: failed to get %s attribute %d type FLOAT\n",varname,i);
 		gaprnt(2,pout);
 	      }
 	      else { 
@@ -2997,7 +2997,7 @@ nc_type type;
 		gree(dval,"f32");
 		dval = NULL;
 		handle_error(status); 
-		snprintf(pout,255,"read_ncatts: failed to get %s attribute %d type DOUBLE\n",varname,i);
+		snprintf(pout,1255,"read_ncatts: failed to get %s attribute %d type DOUBLE\n",varname,i);
 		gaprnt(2,pout);
 	      }
 	      else { 
@@ -3005,7 +3005,7 @@ nc_type type;
 	      }
             break;
 	    default:
-	      snprintf(pout,255,"read_ncatts: %s attribute %d type %d not supported\n",varname,i,type);
+	      snprintf(pout,1255,"read_ncatts: %s attribute %d type %d not supported\n",varname,i,type);
 	      gaprnt(2,pout);
 	    };
 	  
@@ -3013,7 +3013,7 @@ nc_type type;
 	    /* Successfully extracted the attribute, so add a link to the list */
 	    sz = sizeof(struct gaattr);
 	    if ((newattrib = (struct gaattr *) galloc(sz,"newattr")) == NULL) {
-	      snprintf(pout,255,"read_ncatts: memory allocation failed when adding attribute number %d\n",i);
+	      snprintf(pout,1255,"read_ncatts: memory allocation failed when adding attribute number %d\n",i);
 	      gaprnt(2,pout);
 	      if (bval) { gree(bval,"f33"); bval = NULL; }
 	      if (cval) { gree(cval,"f34"); cval = NULL; }
@@ -3123,7 +3123,7 @@ gaint read_one_dimension (struct gafile *pfi, struct gavar *coord,
       *data = ddata;
       break;
     default:
-      snprintf(pout,255,"SDF coordinate axis data type %d not handled\n",dtype);
+      snprintf(pout,1255,"SDF coordinate axis data type %d not handled\n",dtype);
       gaprnt(0,pout);
       return Failure;
     };
@@ -3218,7 +3218,7 @@ gaint decode_delta_t (char *delta_t_str, gaint *year, gaint *month, gaint *day,
 /* Handle return codes */
 void handle_error(gaint status) {
 #if USENETCDF==1
-  snprintf(pout,255," %s\n",nc_strerror(status));
+  snprintf(pout,1255," %s\n",nc_strerror(status));
   gaprnt(0,pout);
 #endif
 }
@@ -3467,7 +3467,7 @@ size_t sz;
       else {
         if ((pos = intprs(ch,&(pfi->dnum[0])))==NULL) goto err1;
 	if (pfi->dnum[0]<1) {
-	  snprintf(pout,255,"Warning: Invalid XDEF syntax in %s -- Changing size of X axis from %d to 1 \n",
+	  snprintf(pout,1255,"Warning: Invalid XDEF syntax in %s -- Changing size of X axis from %d to 1 \n",
 		  pfi->dnam,pfi->dnum[0]);
 	  gaprnt (1,pout);
 	  pfi->dnum[0] = 1;
@@ -3513,7 +3513,7 @@ size_t sz;
       else {
         if ((pos = intprs(ch,&(pfi->dnum[1])))==NULL) goto err1 ;
 	if (pfi->dnum[1]<1) {
-	  snprintf(pout,255,"Warning: Invalid YDEF syntax in %s -- Changing size of Y axis from %d to 1 \n",
+	  snprintf(pout,1255,"Warning: Invalid YDEF syntax in %s -- Changing size of Y axis from %d to 1 \n",
 		  pfi->dnam,pfi->dnum[1]);
 	  gaprnt (1,pout);
 	  pfi->dnum[1] = 1;
@@ -3596,7 +3596,7 @@ size_t sz;
       else {
         if ((pos = intprs(ch,&(pfi->dnum[2])))==NULL) goto err1 ;
 	if (pfi->dnum[2]<1) {
-	  snprintf(pout,255,"Warning: Invalid ZDEF syntax in %s -- Changing size of Z axis from %d to 1 \n",
+	  snprintf(pout,1255,"Warning: Invalid ZDEF syntax in %s -- Changing size of Z axis from %d to 1 \n",
 		  pfi->dnam,pfi->dnum[2]);
 	  gaprnt (1,pout);
 	  pfi->dnum[2] = 1;
@@ -3665,7 +3665,7 @@ size_t sz;
  	  }
 	}
 	else if (pfi->dnum[3]<1) {
-	  snprintf(pout,255,"Warning: Invalid TDEF syntax in %s -- Changing size of T axis from %d to 1 \n",
+	  snprintf(pout,1255,"Warning: Invalid TDEF syntax in %s -- Changing size of T axis from %d to 1 \n",
 		  pfi->dnam,pfi->dnum[3]);
 	  gaprnt (1,pout);
 	  pfi->dnum[3] = 1;
@@ -3721,7 +3721,7 @@ size_t sz;
       if ((ch = nxtwrd(ch)) != NULL) {
 	if ((pos = intprs(ch,&(pfi->dnum[EINDEX]))) == NULL) goto err1;
 	if (pfi->dnum[EINDEX]<1) {
-	  snprintf(pout,255,"Warning: Invalid EDEF syntax in %s -- Changing size of E axis from %d to 1 \n",
+	  snprintf(pout,1255,"Warning: Invalid EDEF syntax in %s -- Changing size of E axis from %d to 1 \n",
 		  pfi->dnam,pfi->dnum[EINDEX]);
 	  gaprnt (1,pout);
 	  pfi->dnum[EINDEX] = 1;
@@ -3791,7 +3791,7 @@ size_t sz;
       while (i<pfi->vnum) {
         if (fgets(rec,512,descr)==NULL) {
           gaprnt (0,"gadxdf error: Unexpected EOF reading variables\n");
-          snprintf(pout,255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
+          snprintf(pout,1255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
           gaprnt (2,pout);
           goto retrn;
         }
@@ -3823,7 +3823,7 @@ size_t sz;
 	}
         if (cmpwrd("endvars",rec)) {
           gaprnt (0,"gadxdf error: Unexpected ENDVARS record\n");
-          snprintf(pout,255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
+          snprintf(pout,1255, "Was expecting %i records.  Found %i.\n", pfi->vnum, i);
           gaprnt (2,pout);
           goto err9;
         }
@@ -3847,7 +3847,7 @@ size_t sz;
 	  if ((ddfattr(mrec,pfi)) == -1) goto retrn;
 	}
         else {
-	  snprintf(pout,255,"gadxdf error: Looking for \"endvars\", found \"%s\" instead.\n",rec);
+	  snprintf(pout,1255,"gadxdf error: Looking for \"endvars\", found \"%s\" instead.\n",rec);
 	  gaprnt (0,pout);
 	  goto err9;
 	}
@@ -3970,7 +3970,7 @@ size_t sz;
       /* get filename for initial time of current ensemble member  */
       ch = gafndt(pfi->name,&tdefe,&tdefe,pfi->abvals[3],pfi->pchsub1,pfi->ens1,ens->gt,e,&flag);   
       if (ch==NULL) {
-	snprintf(pout,255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,ens->gt);
+	snprintf(pout,1255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,ens->gt);
 	gaprnt(0,pout);
 	goto err2;
       }
@@ -3989,7 +3989,7 @@ size_t sz;
 	gr2t(pfi->grvals[3],(gadouble)t,&tdef);
 	pos = gafndt(pfi->name,&tdef,&tdefe,pfi->abvals[3],pfi->pchsub1,pfi->ens1,t,e,&flag);  
 	if (pos==NULL) {
-	  snprintf(pout,255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,t);
+	  snprintf(pout,1255,"Open Error: couldn't determine data file name for e=%d t=%d\n",e,t);
 	  gaprnt(0,pout);
 	  goto err2;
 	}
diff --git a/src/gauser.c b/src/gauser.c
index dea4498..7df98d8 100644
--- a/src/gauser.c
+++ b/src/gauser.c
@@ -48,7 +48,7 @@ char *gatxtl(char *str, int level);
 extern struct gamfcmn mfcmn;
 static char *cdims[7] = {"None","Lon","Lat","Lev","Time","Ens","Val"};
 static char *ccdims[6] = {"Xdim","Ydim","Zdim","Tdim","Edim","Val"}; 
-static char pout[256];   /* Build error msgs here */
+static char pout[1256];   /* Build error msgs here */
 static struct gacmn *savpcm;
 
 /*  Variables to handle message buffering for the script language */
@@ -282,23 +282,23 @@ FILE *pdefid=NULL;
       pfi = pcm->pfi1;
       if (pfi->type==2 || pfi->wrap) gacmd ("set lon 0 360",pcm,0);
       else {
-        snprintf(pout,255,"set x 1 %i",pfi->dnum[0]);
+        snprintf(pout,1255,"set x 1 %i",pfi->dnum[0]);
         gacmd (pout,pcm,0);
       }
       if (pfi->type==2) {
         gacmd ("set lat -90 90",pcm,0);
         gacmd ("set lev 500",pcm,0);
       } else {
-        snprintf(pout,255,"set y 1 %i",pfi->dnum[1]);
+        snprintf(pout,1255,"set y 1 %i",pfi->dnum[1]);
         gacmd (pout,pcm,0);
 
 	/* set z to max if x or y = 1 */
 	if(pfi->type==1 && pfi->dnum[2] > 1
 	   && ( (pfi->dnum[0] == 1) || (pfi->dnum[1] == 1) ) ) {
 	  if(pfi->dnum[2] <= 1) {
-	    snprintf(pout,255,"set z 1");
+	    snprintf(pout,1255,"set z 1");
 	  } else {
-	    snprintf(pout,255,"set z 1 %i",pfi->dnum[2]);
+	    snprintf(pout,1255,"set z 1 %i",pfi->dnum[2]);
 	  }
 	  gacmd (pout,pcm,0);
 	} else {
@@ -408,7 +408,7 @@ FILE *pdefid=NULL;
       for (i=0; i<fnum-2 && pfi; i++) pfi = pfi->pforw;  /* move to end of chain */
       pfi->pforw = NULL;                                 /* set last link to null */
     }
-    snprintf(pout,255,"File %i has been closed\n",fnum);
+    snprintf(pout,1255,"File %i has been closed\n",fnum);
     gaprnt (2,pout);
     goto retrn;
   }
@@ -565,18 +565,18 @@ FILE *pdefid=NULL;
   }
   else if (cmpwrd("gxprint",cmd) || cmpwrd("printim",cmd)) {
     /* check for output file name */
-    if ((ch=nxtwrd(com)) == NULL) {
+    if ((ch=nxtwrd(com)) == NULL) {   
       gaprnt (0,"GXPRINT error:  missing output file name\n");
       retcod = 1;
       goto retrn;
     }
-    /* check for irregularities in output file name */
+    /* copy output file name into cc */
     getwrd (cc,ch,256);
-    if ((cmd=nxtwrd(cmd)) == NULL) {
-      gaprnt (0,"GXPRINT error:  logic error 64\n");
-      retcod = 1;
-      goto retrn;
-    }
+
+    /* advance past the output file name in mixed and lower case versions of the command */
+    com=nxtwrd(com);
+    cmd=nxtwrd(cmd);
+
     /* initialize */
     xin = -999;
     yin = -999;
@@ -586,8 +586,9 @@ FILE *pdefid=NULL;
     fgImage[0] = '\0';
     tcolor = -1;
     border = -1.0;
+
     /* parse the user-provided options */
-    while ((cmd=nxtwrd(cmd)) != NULL) {
+    while ( (cmd=nxtwrd(cmd))!=NULL && (com=nxtwrd(com))!=NULL) {
       /* set backgroud/foreground colors */
       if      (cmpwrd("black",cmd))  bwin = 0;
       else if (cmpwrd("white",cmd))  bwin = 1;
@@ -603,9 +604,11 @@ FILE *pdefid=NULL;
       else if (cmpwrd("jpeg",cmd)) fmtflg = 7;
       /* get background image filename */
       else if (cmpwrd("-b",cmd)) {
-        if ((cmd=nxtwrd(cmd)) != NULL) {
-          if (strlen(cmd) < 256){
-            getwrd(bgImage,cmd, 255);
+        com=nxtwrd(com);
+        if((cmd=nxtwrd(cmd)) != NULL) {
+	  /* use mixed case version for bgImage */
+          if (strlen(com) < 256){
+            getwrd(bgImage,com,255);
           }
         } else {
           gaprnt(1,"GXPRINT warning: Background image file name not provided\n");
@@ -614,9 +617,11 @@ FILE *pdefid=NULL;
       }
       /* get foreground image filename */
       else if (cmpwrd("-f",cmd)) {
+        com=nxtwrd(com);
         if((cmd=nxtwrd(cmd)) != NULL) {
-          if(strlen(cmd) < 256){
-            getwrd(fgImage,cmd, 255);
+	  /* use mixed case version for fgImage */
+          if (strlen(com) < 256){
+            getwrd(fgImage,com, 255);
           }
 	} else {
           gaprnt(1,"GXPRINT warning: Foreground image file name not provided\n");
@@ -626,6 +631,7 @@ FILE *pdefid=NULL;
       /* set transparent color number */
       else if (cmpwrd("-t",cmd)) {
 	/* set transparent color number */
+        com=nxtwrd(com);
         if((cmd=nxtwrd(cmd)) != NULL) {
 	  if(sscanf(cmd, "%i", &tcolor) != 1) {    /* get a color number  */
 	     gaprnt(1,"GXPRINT warning: Invalid transparent color number\n");
@@ -651,6 +657,7 @@ FILE *pdefid=NULL;
       }
       /* set width of border around the edge of the plot */
       else if (cmpwrd("-e",cmd)) {
+        com=nxtwrd(com);
         if((cmd=nxtwrd(cmd)) != NULL) {
 	  if (getdbl(cmd,&border) == NULL) {   
 	     gaprnt(1,"GXPRINT warning: Invalid edge width \n");
@@ -694,7 +701,7 @@ FILE *pdefid=NULL;
     /* Image size specs are incompatible with non-image formats */
     if (fmtflg==1 || fmtflg==2 || fmtflg==3 || fmtflg==4) {
       if (xin>0 || yin>0) {
-	snprintf(pout,255,"GXPRINT Warning: Image size specifications are incompatible with the %s format and will be ignored\n",
+	snprintf(pout,1255,"GXPRINT Warning: Image size specifications are incompatible with the %s format and will be ignored\n",
 		 formats[fmtflg-1]);
 	gaprnt (1,pout);
 	xin = -999;
@@ -705,7 +712,7 @@ FILE *pdefid=NULL;
     /* fgImage and bgImage options are incompatible with non-image formats */
     if (fmtflg==1 || fmtflg==2 || fmtflg==3 || fmtflg==4) {
       if (*bgImage || *fgImage) {
-	snprintf(pout,255,"GXPRINT Warning: Background/Foreground images are incompatible with the %s format and will be ignored\n",
+	snprintf(pout,1255,"GXPRINT Warning: Background/Foreground images are incompatible with the %s format and will be ignored\n",
 		 formats[fmtflg-1]);
 	gaprnt (1,pout);
 	bgImage[0]='\0';
@@ -735,9 +742,9 @@ FILE *pdefid=NULL;
     if (rc) retcod = 1;
     else {
       retcod = 0;
-      snprintf(pout,255,"Created %s file %s",formats[fmtflg-1], cc); gaprnt(2,pout); 
-      if (*bgImage) { snprintf(pout,255," ; bgImage = %s",bgImage); gaprnt(2,pout); }
-      if (*fgImage) { snprintf(pout,255," ; fgImage = %s",fgImage); gaprnt(2,pout); }
+      snprintf(pout,1255,"Created %s file %s",formats[fmtflg-1], cc); gaprnt(2,pout); 
+      if (*bgImage) { snprintf(pout,1255," ; bgImage = %s",bgImage); gaprnt(2,pout); }
+      if (*fgImage) { snprintf(pout,1255," ; fgImage = %s",fgImage); gaprnt(2,pout); }
       gaprnt(2,"\n");
     }
     goto retrn;
@@ -887,15 +894,15 @@ FILE *pdefid=NULL;
     rc = fwrite(rvals, sizeof(gafloat), size, pdefid); if (rc!=size) {retcod=1; goto retrn;}
 
     fclose(pdefid);
-    snprintf(pout,255,"pdef %d %d bilin stream binary-",pcm->pfid->ppisiz,pcm->pfid->ppjsiz);
+    snprintf(pout,1255,"pdef %d %d bilin stream binary-",pcm->pfid->ppisiz,pcm->pfid->ppjsiz);
     gaprnt(2,pout);
 #if BYTEORDER==1
-    snprintf(pout,255,"big");
+    snprintf(pout,1255,"big");
 #else
-    snprintf(pout,255,"little");
+    snprintf(pout,1255,"little");
 #endif
     gaprnt(2,pout);
-    snprintf(pout,255," ^%s\n",pdefname);
+    snprintf(pout,1255," ^%s\n",pdefname);
     gaprnt(2,pout);
 
     if (ival!=NULL) gree(ival,"f194a");
@@ -1599,7 +1606,7 @@ char shparg[4096];
       }
       /* The only type that should get trapped here is a MultiPatch (value 31) */
       else {
-	snprintf(pout,255,"Warning: shape type %d is not supported \n",shp->nSHPType);
+	snprintf(pout,1255,"Warning: shape type %d is not supported \n",shp->nSHPType);
 	gaprnt(2,pout);
       }
       
@@ -1981,7 +1988,7 @@ gaint rc, savflg, ret;
   efile = fopen(ename,"r");
   if (efile==NULL) {
     gaprnt (0,"EXEC error:  Can't open file\n");
-    snprintf(pout,255,"  File name is: %s\n",ename);
+    snprintf(pout,1255,"  File name is: %s\n",ename);
     gaprnt (0,pout);
     ret = 1;
     goto retrn;
@@ -2046,13 +2053,13 @@ gaint rc, savflg, ret;
     gaprnt (0,cout);
     rc = gacmd(cout,pcm,1);
     if (rc) {
-      snprintf(pout,255,"EXEC error:  error in %s.  EXEC stopped.\n",ename);
+      snprintf(pout,1255,"EXEC error:  error in %s.  EXEC stopped.\n",ename);
       gaprnt (0,pout);
       ret = rc;
       goto retrn;
     }
   }
-  snprintf(pout,255,"EOF EXECuting %s \n",ename);
+  snprintf(pout,1255,"EOF EXECuting %s \n",ename);
   gaprnt (0,pout);
   ret = 0;
 
@@ -2105,7 +2112,7 @@ gaint i;
     }
     gree(pfi,"f163");
     gree(pdf,"f164");
-    snprintf(pout,255,"%s UNDEFINEd and storage released\n",name);
+    snprintf(pout,1255,"%s UNDEFINEd and storage released\n",name);
     gaprnt (2,pout);
   }
   return (0);
@@ -2191,7 +2198,7 @@ char *gru;
       gru = pfi->ubuf;
       gru = gru + (grj*pfi->dnum[0]+gri);
       if (*gru == 1) {
-	snprintf(pout,255,"DEFVAL is %g\n",*gr);
+	snprintf(pout,1255,"DEFVAL is %g\n",*gr);
 	gaprnt (2,pout);
       }
       else {
@@ -2239,7 +2246,7 @@ char name[20];
   pdf = pcm->pdf1;
   while (pdf!=NULL && !cmpwrd(name,pdf->abbrv)) pdf = pdf->pforw;
   if (pdf==NULL) {
-    snprintf(pout,255,"MODIFY Error: Defined grid %s not found\n",name);
+    snprintf(pout,1255,"MODIFY Error: Defined grid %s not found\n",name);
     gaprnt (0,pout);
     return (1);
   }
@@ -2599,7 +2606,7 @@ char name[20];
     pfiv->rbuf = (gadouble *)galloc(sz,"defnrbuf");
     if (pfiv->rbuf==NULL) {
       gaprnt (0,"Define Error:  Unable to allocate data memory\n");
-      snprintf(pout,255,"  Size of request was %ld grid elements\n",siz);
+      snprintf(pout,1255,"  Size of request was %ld grid elements\n",siz);
       gaprnt (0,pout);
       goto retrn;
     }
@@ -2607,7 +2614,7 @@ char name[20];
     pfiv->ubuf = (char *)galloc(sz,"defnubuf");
     if (pfiv->ubuf==NULL) {
       gaprnt (0,"Define Error:  Unable to allocate memory for undef mask\n");
-      snprintf(pout,255,"  Size of request was %ld grid elements\n",siz);
+      snprintf(pout,1255,"  Size of request was %ld grid elements\n",siz);
       gaprnt (0,pout);
       goto retrn;
     }
@@ -2683,7 +2690,7 @@ char name[20];
   }
 
   siz = siz * sizeof(gadouble);
-  snprintf(pout,255,"Define memory allocation size = %ld bytes\n",siz);
+  snprintf(pout,1255,"Define memory allocation size = %ld bytes\n",siz);
   gaprnt (2,pout);
 
   /* Now we will chain our new object to the chain of define blocks
@@ -2843,6 +2850,7 @@ gadouble minvals[4], maxvals[4];
     gaprnt (2,"  q shpopts  Returns settings for drawing and writing shapefiles\n");
     gaprnt (2,"  q string   Returns width of a string\n");
     gaprnt (2,"  q time     Returns info about time settings\n");
+    gaprnt (2,"  q udpt     Returns list of user defined plug-ins\n");
     gaprnt (2,"  q undef    Returns output undef value \n");
     gaprnt (2,"  q xinfo    Returns characteristics of graphics display window\n");
     gaprnt (2,"  q xy2w     Converst XY screen to world coordinates\n");
@@ -2859,32 +2867,32 @@ gadouble minvals[4], maxvals[4];
     glook();
   }
   else if (cmpwrd(arg,"bcol")) {
-    snprintf(pout,255,"Background color is %d\n",gxdbkq());
+    snprintf(pout,1255,"Background color is %d\n",gxdbkq());
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"lcol")) {
-    snprintf(pout,255,"Current line color is %d\n",gxqclr());
+    snprintf(pout,1255,"Current line color is %d\n",gxqclr());
     gaprnt(2,pout);
-    snprintf(pout,255,"pcm->lincol is %d\n",pcm->lincol);
+    snprintf(pout,1255,"pcm->lincol is %d\n",pcm->lincol);
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"undef")) {
-    snprintf(pout,255,"Output undef value is set to %12f\n",pcm->undef);
+    snprintf(pout,1255,"Output undef value is set to %12f\n",pcm->undef);
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"dbuff")) {
-    if (pcm->dbflg) snprintf(pout,255,"double buffering is on\n");
-    else snprintf(pout,255,"double buffering is off\n");
+    if (pcm->dbflg) snprintf(pout,1255,"double buffering is on\n");
+    else snprintf(pout,1255,"double buffering is off\n");
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"calendar")) {
-    if (mfcmn.cal365==-999) snprintf(pout,255,"calendar mode not yet set\n");
-    else if (mfcmn.cal365==1) snprintf(pout,255,"365-day calendar in effect\n");
-    else snprintf(pout,255,"standard calendar in effect\n");
+    if (mfcmn.cal365==-999) snprintf(pout,1255,"calendar mode not yet set\n");
+    else if (mfcmn.cal365==1) snprintf(pout,1255,"365-day calendar in effect\n");
+    else snprintf(pout,1255,"standard calendar in effect\n");
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"cachesf")) {
-    snprintf(pout,255,"Global cache scale factor is %g\n",qcachesf());
+    snprintf(pout,1255,"Global cache scale factor is %g\n",qcachesf());
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"cache")) {
@@ -2906,13 +2914,13 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY CACHE Error: file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY CACHE Error: file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
       }
     }
-    snprintf(pout,255,"File %i cache size in bytes: %ld \n",fnum,pfi->cachesize);
+    snprintf(pout,1255,"File %i cache size in bytes: %ld \n",fnum,pfi->cachesize);
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"dialog")) {
@@ -2996,7 +3004,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY ENS argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY ENS argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -3004,7 +3012,7 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY ENS Error: file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY ENS Error: file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
@@ -3014,14 +3022,14 @@ gadouble minvals[4], maxvals[4];
     i=0;
     while (i<pfi->dnum[4]) {
       gat2ch(&(ens->tinit),4,lab,20);
-      snprintf(pout,255,"Ensemble %d named %s has %d timesteps and begins at %s (t=%d) ",
+      snprintf(pout,1255,"Ensemble %d named %s has %d timesteps and begins at %s (t=%d) ",
 	     i+1, ens->name, ens->length, lab, ens->gt );
       gaprnt(2,pout);
       if (ens->grbcode[0]>-900) {
 	if (ens->grbcode[1]>-900) 
-	  snprintf(pout,255,"grbcode=%d,%d",ens->grbcode[0],ens->grbcode[1]);
+	  snprintf(pout,1255,"grbcode=%d,%d",ens->grbcode[0],ens->grbcode[1]);
 	else
-	  snprintf(pout,255,"grbcode=%d",ens->grbcode[0]);
+	  snprintf(pout,1255,"grbcode=%d",ens->grbcode[0]);
 	gaprnt(2,pout);
       }
       gaprnt(2,"\n");
@@ -3047,7 +3055,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY ENS_NAME argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY ENS_NAME argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -3055,7 +3063,7 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY ENS_NAME Error: file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY ENS_NAME Error: file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
@@ -3065,7 +3073,7 @@ gadouble minvals[4], maxvals[4];
     i=0;
     gaprnt(2,"ens String grads_name ");
     while (i<pfi->dnum[4]) {
-      snprintf(pout,255,"%s",ens->name);
+      snprintf(pout,1255,"%s",ens->name);
       gaprnt(2,pout);
       if (i<pfi->dnum[4]-1) gaprnt(2,",");
       i++; ens++;
@@ -3090,7 +3098,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY ENS_LENGTH argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY ENS_LENGTH argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -3098,7 +3106,7 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY ENS_LENGTH Error: file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY ENS_LENGTH Error: file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
@@ -3108,7 +3116,7 @@ gadouble minvals[4], maxvals[4];
     i=0;
     gaprnt(2,"ens String grads_length ");
     while (i<pfi->dnum[4]) {
-      snprintf(pout,255,"%d",ens->length);
+      snprintf(pout,1255,"%d",ens->length);
       gaprnt(2,pout);
       if (i<pfi->dnum[4]-1) gaprnt(2,",");
       i++; ens++;
@@ -3133,7 +3141,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY ENS_TINIT argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY ENS_TINIT argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -3141,7 +3149,7 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY ENS_TINIT Error: file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY ENS_TINIT Error: file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
@@ -3151,7 +3159,7 @@ gadouble minvals[4], maxvals[4];
     i=0;
     gaprnt(2,"ens String grads_tinit ");
     while (i<pfi->dnum[4]) {
-      snprintf(pout,255,"%d",ens->gt);
+      snprintf(pout,1255,"%d",ens->gt);
       gaprnt(2,pout);
       if (i<pfi->dnum[4]-1) gaprnt(2,",");
       i++; ens++;
@@ -3175,7 +3183,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY VARS argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY VARS argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -3183,7 +3191,7 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY VARS Error: file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY VARS Error: file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
@@ -3217,41 +3225,41 @@ gadouble minvals[4], maxvals[4];
   }
   else if (cmpwrd(arg,"shpopts"))  {
 #if USESHP==1
-    snprintf(pout,255,"Settings for drawing shapefiles:\n polygon fill color: %i \n",pcm->fillpoly);
+    snprintf(pout,1255,"Settings for drawing shapefiles:\n polygon fill color: %i \n",pcm->fillpoly);
     gaprnt (2,pout);
-    snprintf(pout,255," mark type: %i \n",pcm->marktype);
+    snprintf(pout,1255," mark type: %i \n",pcm->marktype);
     gaprnt (2,pout);
-    snprintf(pout,255," mark size: %g \n",pcm->marksize);
+    snprintf(pout,1255," mark size: %g \n",pcm->marksize);
     gaprnt (2,pout);
-    snprintf(pout,255,"Settings for writing shapefiles:\n");
+    snprintf(pout,1255,"Settings for writing shapefiles:\n");
     gaprnt (2,pout);
     if (pcm->shpfname)
-      snprintf(pout,255," output filename root: %s\n",pcm->shpfname);
+      snprintf(pout,1255," output filename root: %s\n",pcm->shpfname);
     else 
-      snprintf(pout,255," output filename root: grads\n");
+      snprintf(pout,1255," output filename root: grads\n");
     gaprnt (2,pout);
     if (pcm->shptype==1) gaprnt(2," output type: point\n");
     if (pcm->shptype==2) gaprnt(2," output type: line\n");
-    snprintf(pout,255," format string: \%%%d.%df\n",pcm->dblen,pcm->dbprec);
+    snprintf(pout,1255," format string: \%%%d.%df\n",pcm->dblen,pcm->dbprec);
     gaprnt(2,pout);
     /* print the user-provided fields that are linked off of gacmn  */
     if (pcm->dbfld) { 
       gaprnt(2," attributes:\n");
       fld = pcm->dbfld;  
       while (fld) {
-	snprintf(pout,255,"  %s: ",fld->name);
+	snprintf(pout,1255,"  %s: ",fld->name);
 	gaprnt(2,pout);
 	if (fld->type == FTInteger) {
 	  intprs(fld->value,&ival);
-	  snprintf(pout,255,"%d \n",ival); 
+	  snprintf(pout,1255,"%d \n",ival); 
 	} 
 	else if (fld->type == FTDouble) {
 	  getdbl(fld->value,&dval);
           snprintf(lab,20,"\%%-%d.%df\n",pcm->dblen,pcm->dbprec);
-	  snprintf(pout,255,lab,dval); 
+	  snprintf(pout,1255,lab,dval); 
 	} 
 	else {
-	  snprintf(pout,255,"%s\n",(char*)fld->value); 
+	  snprintf(pout,1255,"%s\n",(char*)fld->value); 
 	}
 	gaprnt(2,pout);
 	fld = fld->next;
@@ -3271,19 +3279,19 @@ gadouble minvals[4], maxvals[4];
       shpid = gaopshp(shparg);
       if (shpid) {
 	SHPGetInfo (shpid, &shpcnt, &shptype, minvals, maxvals);
-	snprintf(pout,255,"Shapefile Type=%s #Shapes=%d XBounds=%g:%g YBounds=%g:%g\n", 
+	snprintf(pout,1255,"Shapefile Type=%s #Shapes=%d XBounds=%g:%g YBounds=%g:%g\n", 
 		SHPTypeName(shptype),shpcnt,minvals[0],maxvals[0],minvals[1],maxvals[1]);
 	gaprnt(2,pout);
 	for (i=0; i<shpcnt; i++) {
 	  shp = NULL;
 	  if ((shp = SHPReadObject (shpid,i))!=NULL) { 
-	    snprintf(pout,255,"%d:  %s  parts=%d  vertices=%d  ",
+	    snprintf(pout,1255,"%d:  %s  parts=%d  vertices=%d  ",
 		    shp->nShapeId,SHPTypeName(shp->nSHPType),shp->nParts,shp->nVertices);
 	    gaprnt(2,pout);
-	    snprintf(pout,255,"XBounds=%g:%g  ",shp->dfXMin,shp->dfXMax); gaprnt(2,pout);
-	    snprintf(pout,255,"YBounds=%g:%g  ",shp->dfYMin,shp->dfYMax); gaprnt(2,pout);
-	    snprintf(pout,255,"ZBounds=%g:%g  ",shp->dfZMin,shp->dfZMax); gaprnt(2,pout);
-	    snprintf(pout,255,"MBounds=%g:%g \n",shp->dfMMin,shp->dfMMax); gaprnt(2,pout);
+	    snprintf(pout,1255,"XBounds=%g:%g  ",shp->dfXMin,shp->dfXMax); gaprnt(2,pout);
+	    snprintf(pout,1255,"YBounds=%g:%g  ",shp->dfYMin,shp->dfYMax); gaprnt(2,pout);
+	    snprintf(pout,1255,"ZBounds=%g:%g  ",shp->dfZMin,shp->dfZMax); gaprnt(2,pout);
+	    snprintf(pout,1255,"MBounds=%g:%g \n",shp->dfMMin,shp->dfMMax); gaprnt(2,pout);
 	    SHPDestroyObject (shp);
 	  }
 	}
@@ -3305,7 +3313,7 @@ gadouble minvals[4], maxvals[4];
       if (dbfid) {
 	fcnt = DBFGetFieldCount (dbfid);
 	rcnt = DBFGetRecordCount (dbfid);
-	snprintf(pout,255,"RECORD#,");
+	snprintf(pout,1255,"RECORD#,");
 	gaprnt(2,pout);
 	fld = NULL;
 	if ((fld = (struct dbfld *)galloc(fcnt*sizeof(struct dbfld),"dbfld"))==NULL) {
@@ -3317,7 +3325,7 @@ gadouble minvals[4], maxvals[4];
 	  /* print out the attribute names */
 	  while (i<fcnt) {
 	    fld->type = DBFGetFieldInfo (dbfid, i, fld->name, &fld->len, &fld->prec);
-	    snprintf(pout,255,"%s",fld->name);
+	    snprintf(pout,1255,"%s",fld->name);
 	    gaprnt(2,pout);
 	    if (i<fcnt-1) gaprnt(2,",");
 	    i++; fld++;
@@ -3326,14 +3334,14 @@ gadouble minvals[4], maxvals[4];
 	  gree(fld1,"aa1");
 	  /* print out the attribute values for each record */
 	  for (i=0; i<rcnt; i++) {
-	    snprintf(pout,255,"%d,",i);
+	    snprintf(pout,1255,"%d,",i);
 	    gaprnt(2,pout);
 	    for (j=0; j<fcnt; j++) {
 	      if (DBFIsAttributeNULL(dbfid,i,j)) {
 		gaprnt(2,"(NULL)");
 	      }
 	      else {
-		snprintf(pout,255,"%s",DBFReadStringAttribute(dbfid,i,j));
+		snprintf(pout,1255,"%s",DBFReadStringAttribute(dbfid,i,j));
 		gaprnt(2,pout);
 	      }
 	      if (j<fcnt-1) gaprnt(2,",");
@@ -3356,7 +3364,7 @@ gadouble minvals[4], maxvals[4];
       while (*(arg+i)!='\0' && *(arg+i)!='\n') i++;
       v = 0.2;
       gxchln (ccc+(arg-cmd),i,pcm->strhsz,&v);
-      snprintf(pout,255,"String Width = %g\n",v);
+      snprintf(pout,1255,"String Width = %g\n",v);
       gaprnt (2,pout);
     }
   }
@@ -3378,7 +3386,7 @@ gadouble minvals[4], maxvals[4];
     } else {
       gaprnt (2,"; machine byte order is big_endian\n");
     }
-    snprintf(pout,255,"Fwrite output undef value is set to %12f\n",pcm->undef);
+    snprintf(pout,1255,"Fwrite output undef value is set to %12f\n",pcm->undef);
     gaprnt(2,pout);
   }
   else if (cmpwrd(arg,"sdfwrite")) {
@@ -3396,20 +3404,20 @@ gadouble minvals[4], maxvals[4];
     gaprnt(2,"\n");
     if (pcm->sdfchunk || pcm->sdfzip) {
       gaprnt(2,"SDFWrite output chunk dimensions: ");
-      if (pcm->xchunk) snprintf(pout,255,"%d ",pcm->xchunk);
-      else snprintf(pout,255,"Xsize ");
+      if (pcm->xchunk) snprintf(pout,1255,"%d ",pcm->xchunk);
+      else snprintf(pout,1255,"Xsize ");
       gaprnt(2,pout);
-      if (pcm->ychunk) snprintf(pout,255,"%d ",pcm->ychunk);
-      else snprintf(pout,255,"Ysize ");
+      if (pcm->ychunk) snprintf(pout,1255,"%d ",pcm->ychunk);
+      else snprintf(pout,1255,"Ysize ");
       gaprnt(2,pout);
-      snprintf(pout,255,"%d ",pcm->zchunk ? pcm->zchunk : 1 );
+      snprintf(pout,1255,"%d ",pcm->zchunk ? pcm->zchunk : 1 );
       gaprnt(2,pout);
-      snprintf(pout,255,"%d ",pcm->tchunk ? pcm->echunk : 1 );
+      snprintf(pout,1255,"%d ",pcm->tchunk ? pcm->echunk : 1 );
       gaprnt(2,pout);
-      snprintf(pout,255,"%d\n",pcm->echunk ? pcm->echunk : 1 );
+      snprintf(pout,1255,"%d\n",pcm->echunk ? pcm->echunk : 1 );
       gaprnt(2,pout);
     }
-    snprintf(pout,255,"SDFwrite output undef value is set to %12f\n",pcm->undef);
+    snprintf(pout,1255,"SDFwrite output undef value is set to %12f\n",pcm->undef);
     gaprnt(2,pout);
     /* information about dimensions */
     if (pcm->sdfwpad==0)
@@ -3421,6 +3429,8 @@ gadouble minvals[4], maxvals[4];
     if (pcm->sdfwpad==3) 
       gaprnt (2,"SDFwrite file will have 4 dimensions: lon, lat, lev, and time\n");
     if (pcm->sdfwpad==4)
+      gaprnt (2,"SDFwrite file will have 4 dimensions: lon, lat, time, and ens\n");
+    if (pcm->sdfwpad==5)
       gaprnt (2,"SDFwrite file will have 5 dimensions: lon, lat, lev, time, and ens\n");
     /* including the record dimension */
     if (pcm->sdfrecdim==1) 
@@ -3438,12 +3448,12 @@ gadouble minvals[4], maxvals[4];
       while (attr) {
 	/* print strings */
 	if (attr->nctype <= 2) {
-	  snprintf(pout,255,"  %s %s %s %s\n",
+	  snprintf(pout,1255,"  %s %s %s %s\n",
 		  attr->varname,attr->type,attr->name,(char*)attr->value);
 	    gaprnt(2,pout);
 	} 
 	else {
-	  snprintf(pout,255,"  %s %s %s ",attr->varname,attr->type,attr->name);
+	  snprintf(pout,1255,"  %s %s %s ",attr->varname,attr->type,attr->name);
 	  gaprnt(2,pout);
 	  if      (attr->nctype == 3) sptr = (short*)attr->value;
 	  else if (attr->nctype == 4) lptr = (long*)attr->value;
@@ -3452,28 +3462,28 @@ gadouble minvals[4], maxvals[4];
 	  for (i=0; i<attr->len; i++) {
 	    /* print numbers */
 	    if (attr->nctype == 3) {
-	      snprintf(pout,255,"%i",(gaint)*(sptr));
+	      snprintf(pout,1255,"%i",(gaint)*(sptr));
 	      gaprnt(2,pout);
 	      sptr++;
 	    } else if (attr->nctype == 4) {
-	      snprintf(pout,255,"%li",*(lptr));
+	      snprintf(pout,1255,"%li",*(lptr));
 	      gaprnt(2,pout);
 	      lptr++;
 	    } else if (attr->nctype == 5) {
-	      snprintf(pout,255,"%f",*(fptr));
+	      snprintf(pout,1255,"%f",*(fptr));
 	      gaprnt(2,pout);
 	      fptr++;
 	    } else { 
-	      snprintf(pout,255,"%g",*(dptr));
+	      snprintf(pout,1255,"%g",*(dptr));
 	      gaprnt(2,pout);
 	      dptr++;
 	    }
 	    if (i != attr->len-1) {
-	      snprintf(pout,255,",");
+	      snprintf(pout,1255,",");
 	      gaprnt(2,pout);
 	    }
 	  }
-	  snprintf(pout,255,"\n");
+	  snprintf(pout,1255,"\n");
 	  gaprnt(2,pout);
 	}
 	attr=attr->next;
@@ -3492,7 +3502,7 @@ gadouble minvals[4], maxvals[4];
       return (1);
     }
     pfi = pcm->pfid;
-    snprintf(pout,255,"Default file number is: %i \n",pcm->dfnum);
+    snprintf(pout,1255,"Default file number is: %i \n",pcm->dfnum);
     gaprnt (2,pout);
     /* Longitude */
     if (pfi->type==2) {
@@ -3504,9 +3514,9 @@ gadouble minvals[4], maxvals[4];
       v2 = conv(pfi->abvals[0],pcm->dmax[0]);
     }
     if (pcm->dmin[0]==pcm->dmax[0]) {
-      snprintf(pout,255,"X is fixed     Lon = %g  X = %g\n",pcm->dmin[0],v1);
+      snprintf(pout,1255,"X is fixed     Lon = %g  X = %g\n",pcm->dmin[0],v1);
     } else {
-      snprintf(pout,255,"X is varying   Lon = %g to %g   X = %g to %g\n",
+      snprintf(pout,1255,"X is varying   Lon = %g to %g   X = %g to %g\n",
            pcm->dmin[0],pcm->dmax[0],v1,v2);
     }
     gaprnt (2,pout);
@@ -3520,9 +3530,9 @@ gadouble minvals[4], maxvals[4];
       v2 = conv(pfi->abvals[1],pcm->dmax[1]);
     }
     if (pcm->dmin[1]==pcm->dmax[1]) {
-      snprintf(pout,255,"Y is fixed     Lat = %g  Y = %g\n",pcm->dmin[1],v1);
+      snprintf(pout,1255,"Y is fixed     Lat = %g  Y = %g\n",pcm->dmin[1],v1);
     } else {
-      snprintf(pout,255,"Y is varying   Lat = %g to %g   Y = %g to %g\n",
+      snprintf(pout,1255,"Y is varying   Lat = %g to %g   Y = %g to %g\n",
            pcm->dmin[1],pcm->dmax[1],v1,v2);
     }
     gaprnt (2,pout);
@@ -3536,9 +3546,9 @@ gadouble minvals[4], maxvals[4];
       v2 = conv(pfi->abvals[2],pcm->dmax[2]);
     }
     if (pcm->dmin[2]==pcm->dmax[2]) {
-      snprintf(pout,255,"Z is fixed     Lev = %g  Z = %g\n",pcm->dmin[2],v1);
+      snprintf(pout,1255,"Z is fixed     Lev = %g  Z = %g\n",pcm->dmin[2],v1);
     } else {
-      snprintf(pout,255,"Z is varying   Lev = %g to %g   Z = %g to %g\n",
+      snprintf(pout,1255,"Z is varying   Lev = %g to %g   Z = %g to %g\n",
            pcm->dmin[2],pcm->dmax[2],v1,v2);
     }
     gaprnt (2,pout);
@@ -3550,9 +3560,9 @@ gadouble minvals[4], maxvals[4];
     if (pcm->tmax.mn==0) gat2ch(&(pcm->tmax),4,lab2,20);
     else gat2ch (&(pcm->tmax),5,lab2,20);
     if (v1==v2) {
-      snprintf(pout,255,"T is fixed     Time = %s  T = %g\n",lab,v1);
+      snprintf(pout,1255,"T is fixed     Time = %s  T = %g\n",lab,v1);
     } else {
-      snprintf(pout,255,"T is varying   Time = %s to %s  T = %g to %g\n",
+      snprintf(pout,1255,"T is varying   Time = %s to %s  T = %g to %g\n",
                   lab,lab2,v1,v2);
     }
     gaprnt (2,pout);
@@ -3561,11 +3571,11 @@ gadouble minvals[4], maxvals[4];
     v2=pcm->dmax[4];
     if (v1==v2) {
       name = e2ens(pfi,v1);
-      snprintf(pout,255,"E is fixed     Ens = %s  E = %g\n",name,v1);
+      snprintf(pout,1255,"E is fixed     Ens = %s  E = %g\n",name,v1);
     } else {
       name = e2ens(pfi,v1);
       name2 = e2ens(pfi,v2);
-      snprintf(pout,255,"E is varying   Ens = %s to %s  E = %g to %g\n",name,name2,v1,v2);
+      snprintf(pout,1255,"E is varying   Ens = %s to %s  E = %g to %g\n",name,name2,v1,v2);
     }
     gaprnt (2,pout);
   }
@@ -3598,18 +3608,18 @@ gadouble minvals[4], maxvals[4];
       conv = pcm->yab2gr;
       y = lat;
       if (conv && pcm->ydim!=3) y = conv(pcm->yabval, lat);
-      snprintf(pout,255,"%s = %g  %s = %g\n", ccdims[pcm->xdim], x, ccdims[pcm->ydim], y);
+      snprintf(pout,1255,"%s = %g  %s = %g\n", ccdims[pcm->xdim], x, ccdims[pcm->ydim], y);
       gaprnt(2,pout);
     } else {
       gxconv (lon,lat,&x,&y,2);
-      snprintf(pout,255,"X = %g  Y = %g\n",x,y);
+      snprintf(pout,1255,"X = %g  Y = %g\n",x,y);
       gaprnt(2,pout);
     }
     return (0);
     errw:
-    if (flag) snprintf(pout,255,"Query Error: Syntax is QUERY W2GR %s %s\n",
+    if (flag) snprintf(pout,1255,"Query Error: Syntax is QUERY W2GR %s %s\n",
              cdims[pcm->xdim+1],cdims[pcm->ydim+1]);
-    else snprintf(pout,255,"Query Error: Syntax is QUERY W2XY %s %s\n",
+    else snprintf(pout,1255,"Query Error: Syntax is QUERY W2XY %s %s\n",
              cdims[pcm->xdim+1],cdims[pcm->ydim+1]);
     gaprnt (0,pout);
     return (1);
@@ -3636,30 +3646,30 @@ gadouble minvals[4], maxvals[4];
       if (pcm->xdim==3) {
         gr2t (pcm->xgrval, lon, &dtim);
         gat2ch (&dtim, 5, lab, 20);
-        snprintf(pout,255,"%s = %s  %s = %g\n",cdims[pcm->xdim+1],lab,
+        snprintf(pout,1255,"%s = %s  %s = %g\n",cdims[pcm->xdim+1],lab,
                     cdims[pcm->ydim+1],lat);
         gaprnt(2,pout);
       } else if (pcm->ydim==3) {
         gr2t (pcm->ygrval, lat, &dtim);
         gat2ch (&dtim, 5, lab, 20);
-        snprintf(pout,255,"%s = %g  %s = %s\n",cdims[pcm->xdim+1],lon,
+        snprintf(pout,1255,"%s = %g  %s = %s\n",cdims[pcm->xdim+1],lon,
                     cdims[pcm->ydim+1],lab);
         gaprnt(2,pout);
       } else {
-        snprintf(pout,255,"%s = %g  %s = %g\n",cdims[pcm->xdim+1],lon,
+        snprintf(pout,1255,"%s = %g  %s = %g\n",cdims[pcm->xdim+1],lon,
                     cdims[pcm->ydim+1],lat);
         gaprnt(2,pout);
       }
     } else {
       gxconv (lon,lat,&x,&y,2);
-      snprintf(pout,255,"X = %g  Y = %g\n",x,y);
+      snprintf(pout,1255,"X = %g  Y = %g\n",x,y);
       gaprnt(2,pout);
     }
     return (0);
     errgr:
-    if (flag) snprintf(pout,255,"Query Error: Syntax is QUERY GR2W %s %s\n",
+    if (flag) snprintf(pout,1255,"Query Error: Syntax is QUERY GR2W %s %s\n",
              ccdims[pcm->xdim],ccdims[pcm->ydim]);
-    else snprintf(pout,255,"Query Error: Syntax is QUERY GR2XY %s %s\n",
+    else snprintf(pout,1255,"Query Error: Syntax is QUERY GR2XY %s %s\n",
              ccdims[pcm->xdim],ccdims[pcm->ydim]);
     gaprnt (0,pout);
     return (1);
@@ -3671,7 +3681,7 @@ gadouble minvals[4], maxvals[4];
     if ((arg = nxtwrd (arg)) == NULL) goto errpp;
     if (getdbl(arg,&y) == NULL ) goto errpp;
     gxppvp (x, y, &x, &y);
-    snprintf(pout,255,"X = %g  Y = %g\n",x,y);
+    snprintf(pout,1255,"X = %g  Y = %g\n",x,y);
     gaprnt(2,pout);
     return (0);
     errpp:
@@ -3701,21 +3711,21 @@ gadouble minvals[4], maxvals[4];
         if (lat>-999.0) {
           if (conv && pcm->ydim!=3) y = conv(pcm->yabval, lat);
         }
-        snprintf(pout,255,"%s = %g  %s = %g\n",ccdims[pcm->xdim],x,ccdims[pcm->ydim],y);
+        snprintf(pout,1255,"%s = %g  %s = %g\n",ccdims[pcm->xdim],x,ccdims[pcm->ydim],y);
         gaprnt(2,pout);
       } else {
         if (pcm->xdim==3) {
           gr2t (pcm->xgrval, lon, &dtim);
           gat2ch (&dtim, 5, lab, 20);
-          snprintf(pout,255,"%s = %s  %s = %g\n",cdims[pcm->xdim+1],lab,cdims[pcm->ydim+1],lat);
+          snprintf(pout,1255,"%s = %s  %s = %g\n",cdims[pcm->xdim+1],lab,cdims[pcm->ydim+1],lat);
           gaprnt(2,pout);
         } else if (pcm->ydim==3) {
           gr2t (pcm->ygrval, lat, &dtim);
           gat2ch (&dtim, 5, lab, 20);
-          snprintf(pout,255,"%s = %g  %s = %s\n",cdims[pcm->xdim+1],lon,cdims[pcm->ydim+1],lab);
+          snprintf(pout,1255,"%s = %g  %s = %s\n",cdims[pcm->xdim+1],lon,cdims[pcm->ydim+1],lab);
           gaprnt(2,pout);
         } else {
-          snprintf(pout,255,"%s = %g  %s = %g\n",cdims[pcm->xdim+1],lon,cdims[pcm->ydim+1],lat);
+          snprintf(pout,1255,"%s = %g  %s = %g\n",cdims[pcm->xdim+1],lon,cdims[pcm->ydim+1],lat);
           gaprnt(2,pout);
         }
       }
@@ -3733,7 +3743,7 @@ gadouble minvals[4], maxvals[4];
     if ((arg = nxtwrd (arg)) == NULL) goto errll;
     if (getdbl(arg,&lat) == NULL ) goto errll;
     gxconv (lon,lat,&x,&y,2);
-    snprintf(pout,255,"%g %g\n",x,y);
+    snprintf(pout,1255,"%g %g\n",x,y);
     gaprnt (2,pout);
     return (0);
     errll:
@@ -3747,7 +3757,13 @@ gadouble minvals[4], maxvals[4];
   }
 
   else if (cmpwrd(arg,"udft")) {
-    gaprnt(2,"Warning: User Defined Functions have been disabled in this version of GrADS\n");
+    gaprnt(2,"Warning: User Defined Functions have been replaced by User Defined Plug-ins.\n");
+    gaprnt(2,"         Please read documentation at http://cola.gmu.edu/grads/gadoc/udp.html\n");
+    return (0);
+  }
+
+  else if (cmpwrd(arg,"udpt")) {
+    gaqupb();
     return (0);
   }
 
@@ -3768,7 +3784,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY CTLINFO argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY CTLINFO argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -3776,33 +3792,33 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY CTLINFO Error:  file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY CTLINFO Error:  file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
       }
     }
 
-    snprintf(pout,255,"dset %s\n",pfi->name);
+    snprintf(pout,1255,"dset %s\n",pfi->name);
     gaprnt (2,pout);
-    snprintf(pout,255,"title %s\n",pfi->title);
+    snprintf(pout,1255,"title %s\n",pfi->title);
     gaprnt (2,pout);
-    snprintf(pout,255,"undef %g\n",pfi->undef);
+    snprintf(pout,1255,"undef %g\n",pfi->undef);
     gaprnt (2,pout);
 
     if (pfi->ncflg==1) gaprnt(2,"dtype netcdf\n");
     if (pfi->ncflg==2) gaprnt(2,"dtype hdfsds\n");
     if (pfi->type==2) {
       gaprnt (2,"dtype station\n");
-      snprintf(pout,255,"  Tsize = %i\n",pfi->dnum[3]);
+      snprintf(pout,1255,"  Tsize = %i\n",pfi->dnum[3]);
       gaprnt(2,pout);
     } 
     else {
-      snprintf(pout,255,"xdef %i",pfi->dnum[0]);
+      snprintf(pout,1255,"xdef %i",pfi->dnum[0]);
       gaprnt(2,pout);
       if (pfi->linear[0]) {
         conv = pfi->gr2ab[0];
-        snprintf(pout,255," linear %g %g\n",conv(pfi->grvals[0],1.0),*(pfi->grvals[0]));
+        snprintf(pout,1255," linear %g %g\n",conv(pfi->grvals[0],1.0),*(pfi->grvals[0]));
         gaprnt (2,pout);
       } 
       else {
@@ -3810,7 +3826,7 @@ gadouble minvals[4], maxvals[4];
         conv = pfi->gr2ab[0];
         cnt = 3;
         for (i=1; i<=pfi->dnum[0]; i++) {
-          snprintf(pout,255," %g",conv(pfi->grvals[0],(gadouble)i));
+          snprintf(pout,1255," %g",conv(pfi->grvals[0],(gadouble)i));
           gaprnt (2,pout);
           cnt++;
           if (cnt>10 && i!=pfi->dnum[0]) {
@@ -3820,18 +3836,18 @@ gadouble minvals[4], maxvals[4];
         gaprnt (2,"\n");
       }
 
-      snprintf(pout,255,"ydef %i",pfi->dnum[1]);
+      snprintf(pout,1255,"ydef %i",pfi->dnum[1]);
       gaprnt(2,pout);
       if (pfi->linear[1]) {
         conv = pfi->gr2ab[1];
-        snprintf(pout,255," linear %g %g\n",conv(pfi->grvals[1],1.0),*(pfi->grvals[1]));
+        snprintf(pout,1255," linear %g %g\n",conv(pfi->grvals[1],1.0),*(pfi->grvals[1]));
         gaprnt (2,pout);
       } else {
         gaprnt(2," levels");
         conv = pfi->gr2ab[1];
         cnt = 3;
         for (i=1; i<=pfi->dnum[1]; i++) {
-          snprintf(pout,255," %g",conv(pfi->grvals[1],(gadouble)i));
+          snprintf(pout,1255," %g",conv(pfi->grvals[1],(gadouble)i));
           gaprnt (2,pout);
           cnt++;
           if (cnt>10 && i!=pfi->dnum[1]) {
@@ -3841,18 +3857,18 @@ gadouble minvals[4], maxvals[4];
         gaprnt (2,"\n");
       }
 
-      snprintf(pout,255,"zdef %i",pfi->dnum[2]);
+      snprintf(pout,1255,"zdef %i",pfi->dnum[2]);
       gaprnt(2,pout);
       if (pfi->linear[2]) {
         conv = pfi->gr2ab[2];
-        snprintf(pout,255," linear %g %g\n",conv(pfi->grvals[2],1.0),*(pfi->grvals[2]));
+        snprintf(pout,1255," linear %g %g\n",conv(pfi->grvals[2],1.0),*(pfi->grvals[2]));
         gaprnt (2,pout);
       } else {
         gaprnt(2," levels");
         conv = pfi->gr2ab[2];
         cnt = 3;
         for (i=1; i<=pfi->dnum[2]; i++) {
-          snprintf(pout,255," %g",conv(pfi->grvals[2],(gadouble)i));
+          snprintf(pout,1255," %g",conv(pfi->grvals[2],(gadouble)i));
           gaprnt (2,pout);
           cnt++;
           if (cnt>10 && i!=pfi->dnum[2]) {
@@ -3866,9 +3882,9 @@ gadouble minvals[4], maxvals[4];
       if (dtim.mn==0) gat2ch (&dtim,4,lab,20);
       else gat2ch (&dtim,5,lab,20);
       if (*(pfi->grvals[3]+5)!=0) {
-        snprintf(pout,255,"tdef %i linear %s %gmo\n",pfi->dnum[3],lab,*(pfi->grvals[3]+5));
+        snprintf(pout,1255,"tdef %i linear %s %gmo\n",pfi->dnum[3],lab,*(pfi->grvals[3]+5));
       } else {
-        snprintf(pout,255,"tdef %i linear %s %gmn\n",pfi->dnum[3],lab,*(pfi->grvals[3]+6));
+        snprintf(pout,1255,"tdef %i linear %s %gmn\n",pfi->dnum[3],lab,*(pfi->grvals[3]+6));
       }
       gaprnt (2,pout);
 
@@ -3876,26 +3892,26 @@ gadouble minvals[4], maxvals[4];
       if (pfi->dnum[4]>1) {
 	if (pfi->ens1) {
 	  /* write out a multi-line EDEF entry with all metadata */
-	  snprintf(pout,255,"edef %i \n",pfi->dnum[4]);
+	  snprintf(pout,1255,"edef %i \n",pfi->dnum[4]);
 	  gaprnt(2,pout);
 	  for (i=0; i<pfi->dnum[4]; i++) {
 	    gat2ch(&(pfi->ens1[i].tinit),4,lab,20);
-	    snprintf(pout,255,"%s %d %s\n", pfi->ens1[i].name, pfi->ens1[i].length, lab);
+	    snprintf(pout,1255,"%s %d %s\n", pfi->ens1[i].name, pfi->ens1[i].length, lab);
 	    gaprnt(2,pout);
 	  }
 	  gaprnt(2,"endedef\n");
 	}
       }
 	
-      snprintf(pout,255,"vars %i\n",pfi->vnum);
+      snprintf(pout,1255,"vars %i\n",pfi->vnum);
       gaprnt (2,pout);
       pvar = pfi->pvar1;
       for (i=0;i<pfi->vnum;i++) {
 	/* print out the variable name and the number of levels */
 	if (pvar->longnm[0] != '\0')
-	  snprintf(pout,255,"%s=>%s  %i  ",pvar->longnm,pvar->abbrv,pvar->levels);
+	  snprintf(pout,1255,"%s=>%s  %i  ",pvar->longnm,pvar->abbrv,pvar->levels);
 	else
-	  snprintf(pout,255,"%s  %i  ",pvar->abbrv,pvar->levels);
+	  snprintf(pout,1255,"%s  %i  ",pvar->abbrv,pvar->levels);
 	gaprnt(2,pout);
 	/* print out the values in the units field */
 	for (j=0; j<5; j++) {
@@ -3906,14 +3922,14 @@ gadouble minvals[4], maxvals[4];
 	    else if (pvar->units[j] == -103) gaprnt(2,"t");
 	    else if (pvar->units[j] == -104) gaprnt(2,"e");
 	    else {
-	      snprintf(pout,255,"%g",pvar->units[j]);
+	      snprintf(pout,1255,"%g",pvar->units[j]);
 	      gaprnt(2,pout);
 	    }
 	    if (pvar->units[j+1] != -999) gaprnt(2,",");    /* add a comma if we've got more */
 	  }
 	}
 	/* print out the description */
-	snprintf(pout,255,"  %s\n",pvar->varnm);
+	snprintf(pout,1255,"  %s\n",pvar->varnm);
         gaprnt(2,pout);
         pvar++;
       }
@@ -3937,7 +3953,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY FILE argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY FILE argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -3945,17 +3961,17 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY FILE Error:  file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY FILE Error:  file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
       }
     }
-    snprintf(pout,255,"File %i : %s\n",fnum,pfi->title);
+    snprintf(pout,1255,"File %i : %s\n",fnum,pfi->title);
     gaprnt (2,pout);
-    snprintf(pout,255,"  Descriptor: %s\n",pfi->dnam);
+    snprintf(pout,1255,"  Descriptor: %s\n",pfi->dnam);
     gaprnt (2,pout);
-    snprintf(pout,255,"  Binary: %s\n",pfi->name);
+    snprintf(pout,1255,"  Binary: %s\n",pfi->name);
     gaprnt (2,pout);
     if (pfi->type==2) {
       if (pfi->bufrflg) {
@@ -3963,21 +3979,21 @@ gadouble minvals[4], maxvals[4];
       } else {
 	gaprnt (2,"  Type = Station Data\n");
       }
-      snprintf(pout,255,"  Tsize = %i\n",pfi->dnum[3]);
+      snprintf(pout,1255,"  Tsize = %i\n",pfi->dnum[3]);
       gaprnt(2,pout);
     } else {
       gaprnt (2,"  Type = Gridded\n");
-      snprintf(pout,255,"  Xsize = %i  Ysize = %i  Zsize = %i  Tsize = %i  Esize = %i\n",
+      snprintf(pout,1255,"  Xsize = %i  Ysize = %i  Zsize = %i  Tsize = %i  Esize = %i\n",
          pfi->dnum[0],pfi->dnum[1],pfi->dnum[2],pfi->dnum[3],pfi->dnum[4]);
       gaprnt(2,pout);
     }
-    snprintf(pout,255,"  Number of Variables = %i\n",pfi->vnum);
+    snprintf(pout,1255,"  Number of Variables = %i\n",pfi->vnum);
     gaprnt (2,pout);
 
     pvar = pfi->pvar1;
     for (i=0;i<pfi->vnum;i++) {
       /* print out the variable name and the number of levels */
-      snprintf(pout,255,"     %s  %i  ",pvar->abbrv,pvar->levels);
+      snprintf(pout,1255,"     %s  %i  ",pvar->abbrv,pvar->levels);
       gaprnt(2,pout);
       /* print out the values in the units field */
       for (j=0; j<5; j++) {
@@ -3988,47 +4004,47 @@ gadouble minvals[4], maxvals[4];
 	  else if (pvar->units[j] == -103) gaprnt(2,"t");
 	  else if (pvar->units[j] == -104) gaprnt(2,"e");
 	  else {
-	    snprintf(pout,255,"%g",pvar->units[j]);
+	    snprintf(pout,1255,"%g",pvar->units[j]);
 	    gaprnt(2,pout);
 	  }
 	  if (pvar->units[j+1] != -999) gaprnt(2,",");    /* add a comma if we've got more */
 	}
       }
       /* print out the description */
-      snprintf(pout,255,"  %s\n",pvar->varnm);
+      snprintf(pout,1255,"  %s\n",pvar->varnm);
       gaprnt(2,pout);
       pvar++;
     }
   }
 
   else if (cmpwrd(arg,"gxout")) {
-    snprintf(pout,255,"General = %s\n",gxout0D[pcm->gout1]);
+    snprintf(pout,1255,"General = %s\n",gxout0D[pcm->gout1]);
     gaprnt(2,pout);
-    snprintf(pout,255,"1D Graphic, 1 expr = %s\n",gxout1D[pcm->gout1]);
+    snprintf(pout,1255,"1D Graphic, 1 expr = %s\n",gxout1D[pcm->gout1]);
     gaprnt(2,pout);
-    snprintf(pout,255,"1D Graphic, 2 expr = %s\n",gxout1Da[pcm->gout1a]);
+    snprintf(pout,1255,"1D Graphic, 2 expr = %s\n",gxout1Da[pcm->gout1a]);
     gaprnt(2,pout);
-    snprintf(pout,255,"2D Graphic, 1 expr = %s\n",gxout2Da[pcm->gout2a]);
+    snprintf(pout,1255,"2D Graphic, 1 expr = %s\n",gxout2Da[pcm->gout2a]);
     gaprnt(2,pout);
-    snprintf(pout,255,"2D Graphic, 2 expr = %s\n",gxout2Db[pcm->gout2b]);
+    snprintf(pout,1255,"2D Graphic, 2 expr = %s\n",gxout2Db[pcm->gout2b]);
     gaprnt(2,pout);
-    snprintf(pout,255,"Station data = %s\n",gxoutStn[pcm->goutstn]);
+    snprintf(pout,1255,"Station data = %s\n",gxoutStn[pcm->goutstn]);
     gaprnt(2,pout);
   }
 
   else if (cmpwrd(arg,"gxinfo")) {
-    snprintf(pout,255,"Last Graphic = %s\n",gxnms[pcm->lastgx]);
+    snprintf(pout,1255,"Last Graphic = %s\n",gxnms[pcm->lastgx]);
     gaprnt(2,pout);
-    snprintf(pout,255,"Page Size = %g by %g\n",pcm->xsiz,pcm->ysiz);
+    snprintf(pout,1255,"Page Size = %g by %g\n",pcm->xsiz,pcm->ysiz);
     gaprnt(2,pout);
-    snprintf(pout,255,"X Limits = %g to %g\n",pcm->xsiz1,pcm->xsiz2);
+    snprintf(pout,1255,"X Limits = %g to %g\n",pcm->xsiz1,pcm->xsiz2);
     gaprnt(2,pout);
-    snprintf(pout,255,"Y Limits = %g to %g\n",pcm->ysiz1,pcm->ysiz2);
+    snprintf(pout,1255,"Y Limits = %g to %g\n",pcm->ysiz1,pcm->ysiz2);
     gaprnt(2,pout);
-    snprintf(pout,255,"Xaxis = %s  Yaxis = %s\n",cdims[pcm->xdim+1],
+    snprintf(pout,1255,"Xaxis = %s  Yaxis = %s\n",cdims[pcm->xdim+1],
                   cdims[pcm->ydim+1]);
     gaprnt(2,pout);
-    snprintf(pout,255,"Mproj = %d\n",pcm->mproj);
+    snprintf(pout,1255,"Mproj = %d\n",pcm->mproj);
     gaprnt(2,pout);
   }
 
@@ -4037,17 +4053,17 @@ gadouble minvals[4], maxvals[4];
       gaprnt(2,"Batch Mode\n");
     } else {
       if (win_data (&xinf) ) {
-        snprintf(pout,255,"Window ID = %d\n",xinf.winid);
+        snprintf(pout,1255,"Window ID = %d\n",xinf.winid);
         gaprnt(2,pout);
-        snprintf(pout,255,"Window X = %d\n",xinf.winx);
+        snprintf(pout,1255,"Window X = %d\n",xinf.winx);
         gaprnt(2,pout);
-        snprintf(pout,255,"Window Y = %d\n",xinf.winy);
+        snprintf(pout,1255,"Window Y = %d\n",xinf.winy);
         gaprnt(2,pout);
-        snprintf(pout,255,"Window Width = %d\n",xinf.winw);
+        snprintf(pout,1255,"Window Width = %d\n",xinf.winw);
         gaprnt(2,pout);
-        snprintf(pout,255,"Window Height = %d\n",xinf.winh);
+        snprintf(pout,1255,"Window Height = %d\n",xinf.winh);
         gaprnt(2,pout);
-        snprintf(pout,255,"Window Border = %d\n",xinf.winb);
+        snprintf(pout,1255,"Window Border = %d\n",xinf.winb);
         gaprnt(2,pout);
       } else {
         gaprnt(2,"Error\n");
@@ -4059,15 +4075,15 @@ gadouble minvals[4], maxvals[4];
     if (pcm->shdcnt<1) {
       gaprnt(2,"None\n");
     } else {
-      snprintf(pout,255,"Number of levels = %i\n",pcm->shdcnt);
+      snprintf(pout,1255,"Number of levels = %i\n",pcm->shdcnt);
       gaprnt(2,pout);
       for (i=0; i<pcm->shdcnt; i++) {
         if (i==0) 
-	  snprintf(pout,255,"%i <= %g\n",pcm->shdcls[i],pcm->shdlvs[1]);
+	  snprintf(pout,1255,"%i <= %g\n",pcm->shdcls[i],pcm->shdlvs[1]);
         else if (i==pcm->shdcnt-1) 
-	  snprintf(pout,255,"%i %g >\n",pcm->shdcls[i],pcm->shdlvs[i]);
+	  snprintf(pout,1255,"%i %g >\n",pcm->shdcls[i],pcm->shdlvs[i]);
         else 
-	  snprintf(pout,255,"%i %g %g\n",pcm->shdcls[i],pcm->shdlvs[i],pcm->shdlvs[i+1]);
+	  snprintf(pout,1255,"%i %g %g\n",pcm->shdcls[i],pcm->shdlvs[i],pcm->shdlvs[i+1]);
         gaprnt(2,pout);
       }
     }
@@ -4077,20 +4093,20 @@ gadouble minvals[4], maxvals[4];
     if (pcm->cntrcnt < 1) {
       gaprnt(2,"None\n");
     } else {
-      snprintf(pout,255,"Number of levels = %i\n",pcm->cntrcnt);
+      snprintf(pout,1255,"Number of levels = %i\n",pcm->cntrcnt);
       gaprnt(2,pout);
       for (i=0; i<pcm->cntrcnt; i++) {
-        snprintf(pout,255,"%i %g\n",pcm->cntrcols[i],pcm->cntrlevs[i]);
+        snprintf(pout,1255,"%i %g\n",pcm->cntrcols[i],pcm->cntrlevs[i]);
         gaprnt(2,pout);
       }
     }
   }
 
   else if (cmpwrd(arg,"fgvals")) {
-    snprintf(pout,255,"Number of fgvals = %d\n",pcm->fgcnt);
+    snprintf(pout,1255,"Number of fgvals = %d\n",pcm->fgcnt);
     gaprnt(2,pout);
     for (i=0; i<pcm->fgcnt; i++) {
-      snprintf(pout,255,"%d %d\n",pcm->fgcols[i],pcm->fgvals[i]);
+      snprintf(pout,1255,"%d %d\n",pcm->fgcols[i],pcm->fgvals[i]);
       gaprnt(2,pout);
     }
   }
@@ -4104,9 +4120,9 @@ gadouble minvals[4], maxvals[4];
     else gat2ch (&(pcm->tmin),5,lab,20);
     if (pcm->tmax.mn==0) gat2ch(&(pcm->tmax),4,lab2,20);
     else gat2ch (&(pcm->tmax),5,lab2,20);
-    snprintf(pout,255,"Time = %s to %s",lab,lab2);
+    snprintf(pout,1255,"Time = %s to %s",lab,lab2);
     gaprnt (2,pout);
-    snprintf(pout,255,"  %s to %s\n",dweek[dayweek(&(pcm->tmin))],dweek[dayweek(&(pcm->tmax))]);
+    snprintf(pout,1255,"  %s to %s\n",dweek[dayweek(&(pcm->tmin))],dweek[dayweek(&(pcm->tmax))]);
     gaprnt (2,pout);
   }
 
@@ -4117,16 +4133,16 @@ gadouble minvals[4], maxvals[4];
     }
     gxdbtn (i, &x, &y, &i, &etype, info, rinfo);
     if (etype<1) {
-      snprintf(pout,255,"Position = %g %g %i %i\n",
+      snprintf(pout,1255,"Position = %g %g %i %i\n",
 	       x,y,i,etype);
     } else if (etype==1) {
-      snprintf(pout,255,"Position = %g %g %i %i %i %i\n",
+      snprintf(pout,1255,"Position = %g %g %i %i %i %i\n",
 	       x,y,i,etype,*info,*(info+1));
     } else if (etype==2) {
-      snprintf(pout,255,"Position = %g %g %i %i %i %g %g\n",
+      snprintf(pout,1255,"Position = %g %g %i %i %i %g %g\n",
 	       x,y,i,etype,*info,*rinfo,*(rinfo+1));
     } else if (etype==3) {
-      snprintf(pout,255,"Position = %g %g %i %i %i %i %i %i %i %i %i %i\n",
+      snprintf(pout,1255,"Position = %g %g %i %i %i %i %i %i %i %i %i %i\n",
          x,y,i,etype,*info,*(info+1),*(info+2),*(info+3),*(info+4),*(info+5),*(info+6),*(info+7));
     }
     gaprnt (2,pout);
@@ -4136,14 +4152,145 @@ gadouble minvals[4], maxvals[4];
     if (pcm->pdf1==NULL) {
       gaprnt (1,"No Defined Variables\n");
       return(0);
-    } else {
+    } 
+    if ((arg = nxtwrd (arg)) == NULL) {
+      /* no variable name specified, just list all defined varnames */
       pdf = pcm->pdf1;
       while (pdf) {
         pfi = pdf->pfi;
-        snprintf(pout,255,"%s %g\n",pdf->abbrv,*(pfi->rbuf));
+        snprintf(pout,1255,"%s %g\n",pdf->abbrv,*(pfi->rbuf));
 	gaprnt(2,pout);
         pdf = pdf->pforw;
       }
+    } else {
+      /* parse the user-provided variable name */
+      i = 0;
+      while (*arg!=' '&&*arg!='\0'&&*arg!='\n'&&i<19) {
+	lab[i] = *arg;
+	arg++;
+	i++;
+      }
+      lab[i] = '\0';
+      /* see if it matches any defined variables */
+      pdf = pcm->pdf1;
+      while (pdf) {
+        if (!strcmp(pdf->abbrv, lab)) {       
+          pfi = pdf->pfi;
+	  /* print relevant information about the defined variable */
+          if (pfi->type==4) {
+            snprintf (pout,1255,"Gridded Defined Variable: %s \n",pdf->abbrv); 
+	    gaprnt (2,pout);
+          } else {
+	    /* one day there may be more than one type of defined variable */
+            gaprnt (0,"Logic error when querying a defined variable\n");
+            return(0);
+	  }
+
+	  /* print stuff about the grid */
+          snprintf(pout,1255," Xsize = %i  Ysize = %i  Zsize = %i  Tsize = %i  Esize = %i\n",
+		   pfi->dnum[0],pfi->dnum[1],pfi->dnum[2],pfi->dnum[3],pfi->dnum[4]);
+          gaprnt(2,pout);
+	  
+	  snprintf(pout,1255,"  XDEF %i",pfi->dnum[0]);
+	  gaprnt(2,pout);
+	  if (pfi->linear[0]) {
+	    conv = pfi->gr2ab[0];
+	    v1=(gadouble)(1+pfi->dimoff[0]);
+	    snprintf(pout,1255," linear %g %g\n",conv(pfi->grvals[0],v1),*(pfi->grvals[0]));
+	    gaprnt (2,pout);
+	  } 
+	  else {
+	    gaprnt(2," levels");
+	    conv = pfi->gr2ab[0];
+	    cnt = 3;
+	    for (i=1; i<=pfi->dnum[0]; i++) {
+	      v1=(gadouble)(i+pfi->dimoff[0]);
+	      snprintf(pout,1255,"   %g",conv(pfi->grvals[0],v1));
+	      gaprnt (2,pout);
+	      cnt++;
+	      if (cnt>10 && i!=pfi->dnum[0]) {
+		gaprnt (2,"\n"); cnt = 1;
+	      }
+	    }
+	    gaprnt (2,"\n");
+	  }
+	  snprintf(pout,1255,"  YDEF %i",pfi->dnum[1]);
+	  gaprnt(2,pout);
+	  if (pfi->linear[1]) {
+	    conv = pfi->gr2ab[1];
+	    v1=(gadouble)(1+pfi->dimoff[1]);
+	    snprintf(pout,1255," linear %g %g\n",conv(pfi->grvals[1],v1),*(pfi->grvals[1]));
+	    gaprnt (2,pout);
+	  } else {
+	    gaprnt(2," levels");
+	    conv = pfi->gr2ab[1];
+	    cnt = 3;
+	    for (i=1; i<=pfi->dnum[1]; i++) {
+	      v1=(gadouble)(i+pfi->dimoff[1]);
+	      snprintf(pout,1255," %g",conv(pfi->grvals[1],v1));
+	      gaprnt (2,pout);
+	      cnt++;
+	      if (cnt>10 && i!=pfi->dnum[1]) {
+		gaprnt (2,"\n   "); cnt = 1;
+	      }
+	    }
+	    gaprnt (2,"\n");
+	  }
+	  
+	  snprintf(pout,1255,"  ZDEF %i",pfi->dnum[2]);
+	  gaprnt(2,pout);
+	  if (pfi->linear[2]) {
+	    conv = pfi->gr2ab[2];
+	    v1=(gadouble)(1+pfi->dimoff[2]);
+	    snprintf(pout,1255," linear %g %g\n",conv(pfi->grvals[2],v1),*(pfi->grvals[2]));
+	    gaprnt (2,pout);
+	  } else {
+	    gaprnt(2," levels");
+	    conv = pfi->gr2ab[2];
+	    cnt = 3;
+	    for (i=1; i<=pfi->dnum[2]; i++) {
+	      v1=(gadouble)(i+pfi->dimoff[2]);
+	      snprintf(pout,1255," %g",conv(pfi->grvals[2],v1));
+	      gaprnt (2,pout);
+	      cnt++;
+	      if (cnt>10 && i!=pfi->dnum[2]) {
+		gaprnt (2,"\n   "); cnt = 1;
+	      }
+	    }
+	    gaprnt (2,"\n");
+	  }
+	  
+          v1=(gadouble)(1+pfi->dimoff[3]);
+	  gr2t (pfi->grvals[3],v1,&dtim);
+	  if (dtim.mn==0) gat2ch (&dtim,4,lab,20);
+	  else gat2ch (&dtim,5,lab,20);
+	  if (*(pfi->grvals[3]+5)!=0) {
+	    snprintf(pout,1255,"  TDEF %i linear %s %gmo\n",pfi->dnum[3],lab,*(pfi->grvals[3]+5));
+	  } else {
+	    snprintf(pout,1255,"  TDEF %i linear %s %gmn\n",pfi->dnum[3],lab,*(pfi->grvals[3]+6));
+	  }
+	  gaprnt (2,pout);
+	  
+	  /* only mention EDEF if esize > 1 */
+	  if (pfi->dnum[4]>1) {
+	    snprintf(pout,1255,"  EDEF %i linear 1 1\n",pfi->dnum[4]);
+	    gaprnt(2,pout);
+            gaprnt(2,"    * Note: Defined grids always have an abstract E axis. \n");
+            gaprnt(2,"    * All members span the same time axis and should be   \n");
+            gaprnt(2,"    * referenced by their index value, not their names.   \n");
+	  }
+
+	  /* What kind of calendar does it have ? */
+          if (pfi->calendar==1) gaprnt(2," Calendar: 365-Day \n");
+	  else gaprnt(2," Calendar: Gregorian \n");
+
+	  /* Has it been modified? */
+	  if (pfi->climo==1) gaprnt(2," Climatology: Seasonal \n");
+	  if (pfi->climo==2) gaprnt(2," Climatology: Diurnal \n");
+
+	}
+	pdf = pdf->pforw;
+      }
     }
     return(0);
   }
@@ -4155,11 +4302,11 @@ gadouble minvals[4], maxvals[4];
     } else {
       j = 1;
       while (pfi!=NULL) {
-        snprintf(pout,255,"File %i : %s\n",j,pfi->title);
+        snprintf(pout,1255,"File %i : %s\n",j,pfi->title);
         gaprnt (2,pout);
-        snprintf(pout,255,"  Descriptor: %s\n",pfi->dnam);
+        snprintf(pout,1255,"  Descriptor: %s\n",pfi->dnam);
         gaprnt (2,pout);
-        snprintf(pout,255,"  Binary: %s\n",pfi->name);
+        snprintf(pout,1255,"  Binary: %s\n",pfi->name);
         gaprnt (2,pout);
         pfi = pfi->pforw;
         j++;
@@ -4184,7 +4331,7 @@ gadouble minvals[4], maxvals[4];
           i++;
         }
         lab[i] = '\0';
-        snprintf(pout,255,"Invalid QUERY ATTR argument: %s \n",lab);
+        snprintf(pout,1255,"Invalid QUERY ATTR argument: %s \n",lab);
         gaprnt (0,pout);
         return (1);
       }
@@ -4192,7 +4339,7 @@ gadouble minvals[4], maxvals[4];
       for (i=0; i<fnum-1; i++) {
         pfi = pfi->pforw;
         if (pfi==NULL) {
-          snprintf(pout,255,"QUERY ATTR Error: file %i not open\n",fnum);
+          snprintf(pout,1255,"QUERY ATTR Error: file %i not open\n",fnum);
           gaprnt (0,pout);
           return(1);
         }
@@ -4220,7 +4367,7 @@ gadouble minvals[4], maxvals[4];
     } 
     if (hdrflgd) {
       /* Always include the following text, even if there are no descriptor attributes */
-      snprintf(pout,255,"No Descriptor Attributes for File %i : %s \n\n",fnum,pfi->title);
+      snprintf(pout,1255,"No Descriptor Attributes for File %i : %s \n\n",fnum,pfi->title);
       gaprnt(2,pout);
     }
 
@@ -4414,7 +4561,7 @@ gadouble minvals[4], maxvals[4];
     }
     
     if (hdrflg) {
-      snprintf(pout,255,"No Native Attributes for File %i : %s \n",fnum,pfi->title);
+      snprintf(pout,1255,"No Native Attributes for File %i : %s \n",fnum,pfi->title);
       gaprnt(2,pout);
     }
     
@@ -4428,7 +4575,7 @@ gadouble minvals[4], maxvals[4];
       i++;
     }
     lab[i] = '\0';
-    snprintf(pout,255,"Invalid QUERY argument: %s \n",lab);
+    snprintf(pout,1255,"Invalid QUERY argument: %s \n",lab);
     gaprnt(0,pout);
   }
   return (0);
@@ -4505,7 +4652,7 @@ size_t sz;
   /* Chain up what we have collected */
 
   sz = sizeof(struct gaclct);
-  snprintf(pout,255,"%dclct%d",clnm,pcm->clctnm[clnm]);
+  snprintf(pout,1255,"%dclct%d",clnm,pcm->clctnm[clnm]);
   clct = (struct gaclct *)galloc(sz,pout);
   if (clct==NULL) {
     gaprnt (0,"Memory allocation error in collect\n");
@@ -4805,7 +4952,7 @@ char *ch=NULL,*ch2=NULL,*strng,*pat,*cmd1;
 char ename1[16],ename2[16];
 size_t sz;
 char *tileimg=NULL;
-static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
+static char *kwds[130] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
 			  "CINT","CSTYLE","CCOLOR","LOOPDIM",
 			  "LOOPING","LOOPINCR","DFILE","VRANGE",
 			  "CSMOOTH","GRID","CMARK","XAXIS","YAXIS",
@@ -4830,7 +4977,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
 			  "E","ENS","SDFWRITE","SDFATTR","GEOTIFF","KML",
 			  "UNDEF","CHUNKSIZE","CACHESF","SHPOPTS",
 			  "SHP","SHPATTR","LOG1D","STRMOPTS","TILE",
-			  "HERSHEY","LWID","ANTIALIAS"};
+			  "HERSHEY","LWID","ANTIALIAS","BARBOPTS"};
 
   strng = NULL;
   kwrd=-1;
@@ -4881,6 +5028,13 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if (cmpwrd("filled",cmd)) pcm->barolin = 0;
     return(0);
   }
+  else if (cmpwrd("barbopts",cmd)) {
+    kwrd=129;
+    if ((cmd = nxtwrd (cmd)) == NULL) goto err;
+    if (cmpwrd("outline",cmd)) pcm->barbolin = 0;
+    if (cmpwrd("filled",cmd)) pcm->barbolin = 1;
+    return(0);
+  }
   else if (cmpwrd("barbase",cmd)) {
     kwrd = 47;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
@@ -4979,7 +5133,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     else goto err;
   }
   else if (cmpwrd("antialias",cmd)) {
-    kwrd = 126;
+    kwrd = 128;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (cmpwrd("off",cmd)) {
       pcm->aaflg = 0;   /* set flag in gacmn */
@@ -5036,7 +5190,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       pcm->ysiz = pcm->pxsize * (yhi-ylo)/(xhi-xlo);
     }
     gxvpag (pcm->xsiz, pcm->ysiz, xlo, xhi, ylo, yhi);
-    snprintf(pout,255,"Virtual page size = %g %g \n",pcm->xsiz,pcm->ysiz);
+    snprintf(pout,1255,"Virtual page size = %g %g \n",pcm->xsiz,pcm->ysiz);
     gaprnt (2,pout);
     gacln(pcm,1);
   }
@@ -5156,7 +5310,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     kwrd = 68;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&(pcm->ahdsiz)) == NULL ) goto err;
-    snprintf(pout,255,"Arrowhead = %g \n",pcm->ahdsiz);
+    snprintf(pout,1255,"Arrowhead = %g \n",pcm->ahdsiz);
     gaprnt (2,pout);
   }
   else if (cmpwrd("cint",cmd)) {
@@ -5168,7 +5322,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     }
     else {
       pcm->cint = val1;
-      snprintf(pout,255,"cint = %g \n",pcm->cint);
+      snprintf(pout,1255,"cint = %g \n",pcm->cint);
       gaprnt (2,pout);
     }
   }
@@ -5176,14 +5330,14 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     kwrd = 77;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&(pcm->xlint)) == NULL ) goto err;
-    snprintf(pout,255,"xlint = %g \n",pcm->xlint);
+    snprintf(pout,1255,"xlint = %g \n",pcm->xlint);
     gaprnt (2,pout);
   }
   else if (cmpwrd("ylint",cmd)) {
     kwrd = 78;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&(pcm->ylint)) == NULL ) goto err;
-    snprintf(pout,255,"ylint = %g \n",pcm->ylint);
+    snprintf(pout,1255,"ylint = %g \n",pcm->ylint);
     gaprnt (2,pout);
   }
   else if (cmpwrd("xsize",cmd)) {
@@ -5234,7 +5388,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (i1>254) goto err; 
     }
     pcm->cflag = i1;
-    snprintf(pout,255,"Number of clevs = %i \n",i1);
+    snprintf(pout,1255,"Number of clevs = %i \n",i1);
     gaprnt (2,pout);
     for (i=1; i<pcm->cflag; i++) {
       if (pcm->clevs[i] <= pcm->clevs[i-1]) {
@@ -5252,7 +5406,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (i1>49) goto err;
     }
     pcm->xlflg = i1;
-    snprintf(pout,255,"Number of xlevs = %i \n",i1);
+    snprintf(pout,1255,"Number of xlevs = %i \n",i1);
     gaprnt (2,pout);
   }
   else if (cmpwrd("ylevs",cmd)) {
@@ -5264,7 +5418,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (i1>49) goto err;
     }
     pcm->ylflg = i1;
-    snprintf(pout,255,"Number of ylevs = %i \n",i1);
+    snprintf(pout,1255,"Number of ylevs = %i \n",i1);
     gaprnt (2,pout);
   }
   else if (cmpwrd("rbcols",cmd)) {
@@ -5279,7 +5433,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     pcm->rbflg = i1;
     if (i1==0) gaprnt(2,"Rainbow colors set to auto\n");
     else {
-      snprintf(pout,255,"Number of rainbow colors = %i\n",i1);
+      snprintf(pout,1255,"Number of rainbow colors = %i\n",i1);
       gaprnt (2,pout);
     }
   }
@@ -5302,7 +5456,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (i1>255) goto err; 
     }
     pcm->ccflg = i1;
-    snprintf(pout,255,"Number of ccols = %i\n",i1);
+    snprintf(pout,1255,"Number of ccols = %i\n",i1);
     gaprnt (2,pout);
     if (pcm->cflag==0) {
       gaprnt (2,"ccols won't take effect unless clevs are set.\n");
@@ -5312,21 +5466,21 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     kwrd = 25;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&(pcm->cmin)) == NULL ) goto err;
-    snprintf(pout,255,"cmin = %g \n",pcm->cmin);
+    snprintf(pout,1255,"cmin = %g \n",pcm->cmin);
     gaprnt (2,pout);
   }
   else if (cmpwrd("cmax",cmd)) {
     kwrd = 26;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&(pcm->cmax)) == NULL ) goto err;
-    snprintf(pout,255,"cmax = %g \n",pcm->cmax);
+    snprintf(pout,1255,"cmax = %g \n",pcm->cmax);
     gaprnt (2,pout);
   }
   else if (cmpwrd("cmark",cmd)) {
     kwrd = 18;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (intprs(cmd,&(pcm->cmark)) == NULL ) goto err;
-    snprintf(pout,255,"cmark = %i \n",pcm->cmark);
+    snprintf(pout,1255,"cmark = %i \n",pcm->cmark);
     gaprnt (2,pout);
   }
   else if (cmpwrd("mproj",cmd)) {
@@ -5400,9 +5554,9 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if (wgds->fname) gree(wgds->fname,"f224");
     wgds->fname = ch;
     if (wgds->opts) {
-      snprintf(pout,255,"WRITEGDS file name = %s  Opts = %s\n",ch,wgds->opts);
+      snprintf(pout,1255,"WRITEGDS file name = %s  Opts = %s\n",ch,wgds->opts);
     } else {
-      snprintf(pout,255,"WRITEGDS file name = %s\n",ch);
+      snprintf(pout,1255,"WRITEGDS file name = %s\n",ch);
     }
     gaprnt (2,pout);
   }
@@ -5446,12 +5600,12 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if (pcm->shpfname) gree(pcm->shpfname,"f225e");
     pcm->shpfname = ch;
 
-    snprintf(pout,255,"Shapefile output file name root: %s\n",pcm->shpfname);
+    snprintf(pout,1255,"Shapefile output file name root: %s\n",pcm->shpfname);
     gaprnt (2,pout);
     if (pcm->shptype==1) gaprnt(2,"Shapefile output type: point\n");
     if (pcm->shptype==2) gaprnt(2,"Shapefile output type: line\n");
     if (pcm->shptype==3) gaprnt(2,"Shapefile output type: polygon\n");
-    snprintf(pout,255,"Shapefile format string is \%%%d.%df\n",pcm->dblen,pcm->dbprec);
+    snprintf(pout,1255,"Shapefile format string is \%%%d.%df\n",pcm->dblen,pcm->dbprec);
     gaprnt(2,pout);
 #else
     gaprnt(0,"Error: This version of GrADS does not support shapefile output\n");
@@ -5528,15 +5682,15 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (pcm->tifname) gree(pcm->tifname,"f225c");
       pcm->tifname = ch2;
       gaprnt (2,"KML output file names: \n");
-      snprintf(pout,255,"%s (TIFF image) \n",pcm->tifname);
+      snprintf(pout,1255,"%s (TIFF image) \n",pcm->tifname);
       gaprnt (2,pout);
-      snprintf(pout,255,"%s (KML text file) \n",pcm->kmlname);
+      snprintf(pout,1255,"%s (KML text file) \n",pcm->kmlname);
       gaprnt (2,pout);
       gaprnt (2,"KML output type: image\n");
     }
     else {
       gaprnt(2,"KML output file name: \n");
-      snprintf(pout,255,"%s (KML text file)\n",pcm->kmlname);
+      snprintf(pout,1255,"%s (KML text file)\n",pcm->kmlname);
       gaprnt (2,pout);
       if (pcm->kmlflg==2)
 	gaprnt (2,"KML output type: contour lines\n");
@@ -5582,7 +5736,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     /* reset geotiff filename */
     if (pcm->gtifname) gree(pcm->gtifname,"f225b");
     pcm->gtifname = ch;
-    snprintf(pout,255,"GeoTIFF file name = %s\n",pcm->gtifname);
+    snprintf(pout,1255,"GeoTIFF file name = %s\n",pcm->gtifname);
     gaprnt (2,pout);
     if (pcm->gtifflg==1) gaprnt(2,"GeoTIFF format is float  \n");
     if (pcm->gtifflg==2) gaprnt(2,"GeoTIFF format is double \n");
@@ -5629,7 +5783,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       *(ch+i1) = '\0';
       if (pcm->fwname) gree(pcm->fwname,"f225");
       pcm->fwname = ch;
-      snprintf(pout,255,"FWrite file name = %s\n",ch);
+      snprintf(pout,1255,"FWrite file name = %s\n",ch);
       gaprnt (2,pout);
       if (pcm->fwenflg == 0) {
         gaprnt (2,"FWwrite byte order is little_endian; format is ");
@@ -5653,7 +5807,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     pcm->sdfwpad = 0;   
     pcm->sdfrecdim = 0;
     /* parse any arguments to 'set sdfwrite' command */
-    while (cmpwrd("-4d",cmd)  || cmpwrd("-5d",cmd) || 
+    while (cmpwrd("-4d",cmd)  || cmpwrd("-4de",cmd) || cmpwrd("-5d",cmd) || 
 	   cmpwrd("-3dz",cmd) || cmpwrd("-3dt",cmd) ||
 	   cmpwrd("-flt",cmd) || cmpwrd("-dbl",cmd) ||
 	   cmpwrd("-nc3",cmd) || cmpwrd("-nc4",cmd) ||
@@ -5662,7 +5816,8 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (cmpwrd("-3dz",cmd))   pcm->sdfwpad = 1;   
       if (cmpwrd("-3dt",cmd))   pcm->sdfwpad = 2;   
       if (cmpwrd("-4d",cmd))    pcm->sdfwpad = 3;   
-      if (cmpwrd("-5d",cmd))    pcm->sdfwpad = 4;
+      if (cmpwrd("-4de",cmd))   pcm->sdfwpad = 4;   
+      if (cmpwrd("-5d",cmd))    pcm->sdfwpad = 5;
       if (cmpwrd("-dbl",cmd))   pcm->sdfprec = 8;
       if (cmpwrd("-flt",cmd))   pcm->sdfprec = 4;
       if (cmpwrd("-nc3",cmd))   pcm->sdfwtype = 1;
@@ -5689,7 +5844,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     /* release previously set sdfwrite filename */
     if (pcm->sdfwname) gree(pcm->sdfwname,"f225a");
     pcm->sdfwname = ch;
-    snprintf(pout,255,"SDFWrite file name = %s\n",ch);
+    snprintf(pout,1255,"SDFWrite file name = %s\n",ch);
     gaprnt (2,pout);
     gaprnt (2,"SDFWrite will replace an existing file\n");
     if (pcm->sdfwpad==0)
@@ -5701,6 +5856,8 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if (pcm->sdfwpad==3) 
       gaprnt (2,"SDFwrite file will have 4 dimensions: lon, lat, lev, and time\n");
     if (pcm->sdfwpad==4)
+      gaprnt (2,"SDFwrite file will have 4 dimensions: lon, lat, time, and ens\n");
+    if (pcm->sdfwpad==5)
       gaprnt (2,"SDFwrite file will have 5 dimensions: lon, lat, lev, time, and ens\n");
 #if HAVENETCDF4 != 1
     /* reset flags if we dont' have netcdf-4 */
@@ -5812,7 +5969,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&val1) == NULL) goto err;
     pcm->cachesf = val1;
-    snprintf(pout,255,"Global cache scale factor is %g\n",pcm->cachesf);
+    snprintf(pout,1255,"Global cache scale factor is %g\n",pcm->cachesf);
     gaprnt(2,pout);
   }
   else if (cmpwrd("imprun",cmd)) {
@@ -5837,7 +5994,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (pcm->impflg) gree(pcm->impnam,"f227");
       pcm->impflg = 1;
       pcm->impnam = ch;
-      snprintf(pout,255,"Imprun file name = %s\n",ch);
+      snprintf(pout,1255,"Imprun file name = %s\n",ch);
       gaprnt (2,pout);
     }
   }
@@ -5929,7 +6086,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       for (i1=itt2; i1<itt; i1++) *(ch+i1-itt2) = *(cmd+i1);
       *(ch+i1-itt2) = '\0';
       pcm->mpdset[xx] = ch;
-      snprintf(pout,255,"MPDSET file name = %s\n",ch);
+      snprintf(pout,1255,"MPDSET file name = %s\n",ch);
       gaprnt (2,pout);
       while (*(cmd+itt)==' ') itt++;
       if (*(cmd+itt)=='\n'||*(cmd+itt)=='\0') break;
@@ -6171,7 +6328,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       }
     }
     if (pcm->grflag) {
-      snprintf(pout,255,"grid is on, style %i color %i thickness %d\n",pcm->grstyl,pcm->grcolr,pcm->grthck);
+      snprintf(pout,1255,"grid is on, style %i color %i thickness %d\n",pcm->grstyl,pcm->grcolr,pcm->grthck);
       gaprnt (2,pout);
     } else {
       gaprnt (2,"grid is off\n");
@@ -6206,9 +6363,9 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     pcm->clcol = itt;
     pcm->clthck = itt1;
     pcm->clsiz = val1;
-    snprintf(pout,255,"SET CLOPTS values:  Color = %i Thickness = %i", pcm->clcol, pcm->clthck);
+    snprintf(pout,1255,"SET CLOPTS values:  Color = %i Thickness = %i", pcm->clcol, pcm->clthck);
     gaprnt (2,pout);
-    snprintf(pout,255," Size = %g\n",pcm->clsiz);
+    snprintf(pout,1255," Size = %g\n",pcm->clsiz);
     gaprnt (2,pout);
   }
   else if (cmpwrd("shpopts",cmd)) {
@@ -6230,11 +6387,11 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
         }
       }
     }
-    snprintf(pout,255,"SET SHPOPTS values:  polygon fill color = %i  ",pcm->fillpoly);
+    snprintf(pout,1255,"SET SHPOPTS values:  polygon fill color = %i  ",pcm->fillpoly);
     gaprnt (2,pout);
-    snprintf(pout,255,"mark type = %i  ",pcm->marktype);
+    snprintf(pout,1255,"mark type = %i  ",pcm->marktype);
     gaprnt (2,pout);
-    snprintf(pout,255,"mark size = %g \n",pcm->marksize);
+    snprintf(pout,1255,"mark size = %g \n",pcm->marksize);
     gaprnt (2,pout);
   }
   else if (cmpwrd("wxopt",cmd)) {
@@ -6268,7 +6425,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if (intprs(cmd,&itt1) == NULL ) goto err;
     pcm->lfc1 = itt;
     pcm->lfc2 = itt1;
-    snprintf(pout,255,"LineFill Colors: Above = %i  Below = %i\n",
+    snprintf(pout,1255,"LineFill Colors: Above = %i  Below = %i\n",
       pcm->lfc1, pcm->lfc2);
     gaprnt (2,pout);
   }
@@ -6341,12 +6498,12 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       }
      }
     }
-    snprintf(pout,255,"SET BUTTON values:  Fc, Bc, Oc, Oc2 = %i %i %i %i ",
+    snprintf(pout,1255,"SET BUTTON values:  Fc, Bc, Oc, Oc2 = %i %i %i %i ",
       pcm->btnfc,pcm->btnbc,pcm->btnoc,pcm->btnoc2);
     gaprnt (2,pout);
-    snprintf(pout,255,"Toggle Fc, Bc, Oc, Oc2 = %i %i %i %i ",
+    snprintf(pout,1255,"Toggle Fc, Bc, Oc, Oc2 = %i %i %i %i ",
       pcm->btnftc,pcm->btnbtc,pcm->btnotc,pcm->btnotc2);
-    snprintf(pout,255,"Thick = %i\n",pcm->btnthk);
+    snprintf(pout,1255,"Thick = %i\n",pcm->btnthk);
     gaprnt (2,pout);
   }
   else if (cmpwrd("dialog",cmd)) {
@@ -6373,16 +6530,16 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       }
      }
     }
-    snprintf(pout,255,"SET DIALOG values:  Pc, Fc, Bc, Oc = %i %i %i %i ",
+    snprintf(pout,1255,"SET DIALOG values:  Pc, Fc, Bc, Oc = %i %i %i %i ",
       pcm->dlgpc,pcm->dlgfc,pcm->dlgbc,pcm->dlgoc);
     gaprnt (2,pout);
     if (pcm->dlgnu) {
-      snprintf(pout,255,"Thick = %i ",pcm->dlgth);
+      snprintf(pout,1255,"Thick = %i ",pcm->dlgth);
       gaprnt (2,pout);
-      snprintf(pout,255,"Args = numeric\n ");
+      snprintf(pout,1255,"Args = numeric\n ");
       gaprnt (2,pout);
     } else {
-      snprintf(pout,255,"Thick = %i\n",pcm->dlgth);
+      snprintf(pout,1255,"Thick = %i\n",pcm->dlgth);
       gaprnt (2,pout);
     }
   }
@@ -6396,9 +6553,9 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (cmpwrd("t",cmd)||cmpwrd("top",cmd)) pcm->xlside = 1;
     }
     if (pcm->xlside)
-      snprintf(pout,255,"SET XLPOS values:  Offset = %g  Side = Top\n",pcm->xlpos);
+      snprintf(pout,1255,"SET XLPOS values:  Offset = %g  Side = Top\n",pcm->xlpos);
     else
-      snprintf(pout,255,"SET XLPOS values:  Offset = %g  Side = Bottom\n",pcm->xlpos);
+      snprintf(pout,1255,"SET XLPOS values:  Offset = %g  Side = Bottom\n",pcm->xlpos);
     gaprnt (2,pout);
   }
   else if (cmpwrd("ylpos",cmd)) {
@@ -6411,7 +6568,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (cmpwrd("r",cmd)||cmpwrd("right",cmd)) pcm->ylside = 1;
       if (cmpwrd("l",cmd)||cmpwrd("left",cmd)) pcm->ylside = 0;
     }
-    snprintf(pout,255,"SET YLPOS values:  Offset = %g  Side = ",tt);
+    snprintf(pout,1255,"SET YLPOS values:  Offset = %g  Side = ",tt);
     gaprnt (2,pout);
     if (pcm->ylside) gaprnt(2,"Right\n");
     else gaprnt(2,"Left\n");
@@ -6434,7 +6591,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     pcm->xlcol  = itt;
     pcm->xlthck = itt1;
     pcm->xlsiz  = val1;
-    snprintf(pout,255,"SET XLOPTS values:  Color = %i  Thickness = %i  Size = %g \n",
+    snprintf(pout,1255,"SET XLOPTS values:  Color = %i  Thickness = %i  Size = %g \n",
 	     pcm->xlcol, pcm->xlthck, pcm->xlsiz);
     gaprnt (2,pout);
   }
@@ -6456,7 +6613,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     pcm->ylcol  = itt;
     pcm->ylthck = itt1;
     pcm->ylsiz  = val1;
-    snprintf(pout,255,"SET YLOPTS values:  Color = %i  Thickness = %i   Size = %g \n",
+    snprintf(pout,1255,"SET YLOPTS values:  Color = %i  Thickness = %i   Size = %g \n",
 	     pcm->ylcol, pcm->ylthck, pcm->ylsiz);
     gaprnt (2,pout);
   }
@@ -6474,7 +6631,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
         pcm->annthk = itt;
       }
     }
-    snprintf(pout,255,"SET ANNOT values:  Color = %i  Thickness = %i\n",
+    snprintf(pout,1255,"SET ANNOT values:  Color = %i  Thickness = %i\n",
 	     pcm->anncol, pcm->annthk);
     gaprnt (2,pout);
   }
@@ -6497,7 +6654,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
         }
       }
     }
-    snprintf(pout,255,"SET LINE values:  color = %i  style = %i  thickness = %i\n",
+    snprintf(pout,1255,"SET LINE values:  color = %i  style = %i  thickness = %i\n",
 	     pcm->lincol, pcm->linstl, pcm->linthk);
     gaprnt (2,pout);
   }
@@ -6527,7 +6684,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if (pcm->mapcol < 0 ) {
       gaprnt (2,"SET MAP values:  auto\n");
     } else {
-      snprintf(pout,255,"SET MAP values:  color = %i  style = %i  thickness = %i\n",
+      snprintf(pout,1255,"SET MAP values:  color = %i  style = %i  thickness = %i\n",
 	       pcm->mapcol, pcm->mapstl, pcm->mapthk);
       gaprnt (2,pout);
     }
@@ -6560,10 +6717,10 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
         }
       }
     }
-    snprintf(pout,255,"SET STRING values:  color = %i  just = %s",
+    snprintf(pout,1255,"SET STRING values:  color = %i  just = %s",
       pcm->strcol, justs[pcm->strjst]);
     gaprnt (2,pout);
-    snprintf(pout,255,"  thickness = %i  rotation = %g\n",
+    snprintf(pout,1255,"  thickness = %i  rotation = %g\n",
       pcm->strthk, pcm->strrot);
     gaprnt (2,pout);
   }
@@ -6579,7 +6736,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       } else {pcm->strvsz = val1; i1 = 0;}
     }
     if (i1) pcm->strvsz = pcm->strhsz;
-    snprintf(pout,255,"SET STRSIZ values:  hsize = %g  vsize = %g\n",
+    snprintf(pout,1255,"SET STRSIZ values:  hsize = %g  vsize = %g\n",
       pcm->strhsz, pcm->strvsz);
     gaprnt (2,pout);
   }
@@ -6595,7 +6752,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (getdbl(cmd,&v1) == NULL) goto err;
       else pcm->axint = v1;
     }
-    snprintf(pout,255,"xaxis labels range %g %g incr %g \n",pcm->axmin,pcm->axmax,pcm->axint);
+    snprintf(pout,1255,"xaxis labels range %g %g incr %g \n",pcm->axmin,pcm->axmax,pcm->axint);
     gaprnt (2,pout);
   }
   else if (cmpwrd("yaxis",cmd)) {
@@ -6610,7 +6767,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (getdbl(cmd,&v1) == NULL) goto err;
       else pcm->ayint = v1;
     }
-    snprintf(pout,255,"yaxis labels range %g %g incr %g \n",pcm->aymin,pcm->aymax,pcm->ayint);
+    snprintf(pout,1255,"yaxis labels range %g %g incr %g \n",pcm->aymin,pcm->aymax,pcm->ayint);
     gaprnt (2,pout);
   }
   else if (cmpwrd("misswarn",cmd)) {
@@ -6624,7 +6781,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     for (i1=0; i1<id-1; i1++) {
       pfi = pfi->pforw;
       if (pfi==NULL) {
-        snprintf(pout,255,"SET MISSWARN error:  file %i not open\n",id);
+        snprintf(pout,1255,"SET MISSWARN error:  file %i not open\n",id);
         gaprnt (0,pout);
         return(1);
       }
@@ -6654,11 +6811,11 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
 	  }
 	}
 	if (pfi==NULL) {
-	  snprintf(pout,255,"Warning: SET UNDEF FILE -- file %d not open, output undef value is unchanged.\n",id);
+	  snprintf(pout,1255,"Warning: SET UNDEF FILE -- file %d not open, output undef value is unchanged.\n",id);
 	  gaprnt (2,pout);
 	} else {
 	  pcm->undef = pfi->undef;
-	  snprintf(pout,255,"Output undef value copied from file %d : %s \n",id,pfi->dnam);
+	  snprintf(pout,1255,"Output undef value copied from file %d : %s \n",id,pfi->dnam);
 	  gaprnt (2,pout);
 	}
       }
@@ -6673,11 +6830,11 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
 	}
       }
       if (pfi==NULL) {
-	snprintf(pout,255,"Warning: SET UNDEF DFILE -- default file %i not open, output undef value is unchanged\n",id);
+	snprintf(pout,1255,"Warning: SET UNDEF DFILE -- default file %i not open, output undef value is unchanged\n",id);
 	gaprnt (2,pout);
       } else {
 	pcm->undef = pfi->undef;
-	snprintf(pout,255,"Output undef value copied from default file %d : %s \n",id,pfi->dnam);
+	snprintf(pout,1255,"Output undef value copied from default file %d : %s \n",id,pfi->dnam);
 	gaprnt (2,pout);
       }
     }
@@ -6689,7 +6846,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
 	pcm->undef = v1;
       }
     }
-    snprintf(pout,255,"Output undef value is set to %12f \n",pcm->undef);
+    snprintf(pout,1255,"Output undef value is set to %12f \n",pcm->undef);
     gaprnt (2,pout);
   }
   else if (cmpwrd("dfile",cmd)) {
@@ -6701,12 +6858,12 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     for (i1=0; i1<id-1; i1++) {
       pfi = pfi->pforw;
       if (pfi==NULL) {
-        snprintf(pout,255,"SET DFILE error:  file %i not open\n",id);
+        snprintf(pout,1255,"SET DFILE error:  file %i not open\n",id);
         gaprnt (0,pout);
         return(1);
       }
     }
-    snprintf(pout,255,"Default file set to: %s \n",pfi->name);
+    snprintf(pout,1255,"Default file set to: %s \n",pfi->name);
     gaprnt (2,pout);
     pcm->pfid = pfi;
     pcm->dfnum = id;
@@ -6715,7 +6872,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     kwrd = 58;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (intprs(cmd,&itt) == NULL ) goto err;
-    snprintf(pout,255,"background = %i \n",itt);
+    snprintf(pout,1255,"background = %i \n",itt);
     gaprnt (2,pout);
     gxdbck(itt);        
   }
@@ -6723,7 +6880,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     kwrd = 49;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (intprs(cmd,&(pcm->cthick)) == NULL ) goto err;
-    snprintf(pout,255,"cthick = %i \n",pcm->cthick);
+    snprintf(pout,1255,"cthick = %i \n",pcm->cthick);
     gaprnt (2,pout);
   }
   else if (cmpwrd("cstyle",cmd)) {
@@ -6731,9 +6888,9 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (intprs(cmd,&(pcm->cstyle)) == NULL ) goto err;
     if(pcm->cstyle==0) {
-      snprintf(pout,255,"WARNING: cstyle=0; no lines will be plotted; try using 1 instead\n");
+      snprintf(pout,1255,"WARNING: cstyle=0; no lines will be plotted; try using 1 instead\n");
     } else {
-      snprintf(pout,255,"cstyle = %i \n",pcm->cstyle);
+      snprintf(pout,1255,"cstyle = %i \n",pcm->cstyle);
     }
     gaprnt (2,pout);
   }
@@ -6741,7 +6898,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     kwrd = 24;
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&(pcm->digsiz)) == NULL ) goto err;
-    snprintf(pout,255,"digsiz = %g \n",pcm->digsiz);
+    snprintf(pout,1255,"digsiz = %g \n",pcm->digsiz);
     gaprnt (2,pout);
   }
   else if (cmpwrd("dignum",cmd)) {
@@ -6752,7 +6909,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       gaprnt (0,"Invalid dignum value:  must be 0 to 8\n");
     } else {
       pcm->dignum = itt;
-      snprintf(pout,255,"dignum = %i \n",pcm->dignum);
+      snprintf(pout,1255,"dignum = %i \n",pcm->dignum);
       gaprnt (2,pout);
     }
   }
@@ -6766,7 +6923,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if ((cmd = nxtwrd (cmd)) == NULL) goto err;
       if (getdbl(cmd,&(pcm->rmax)) == NULL ) goto err;
       pcm->aflag = -1;
-      snprintf(pout,255, "1-D axis limits set: %g to %g \n", pcm->rmin, pcm->rmax);
+      snprintf(pout,1255, "1-D axis limits set: %g to %g \n", pcm->rmin, pcm->rmax);
       gaprnt (2,pout);
     }
   }
@@ -6778,7 +6935,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (getdbl(cmd,&(pcm->rmax2)) == NULL ) goto err;
     pcm->aflag2 = -1;
-    snprintf(pout,255, "Scatter Y axis limits set: %g to %g \n", pcm->rmin2, pcm->rmax2);
+    snprintf(pout,1255, "Scatter Y axis limits set: %g to %g \n", pcm->rmin2, pcm->rmax2);
     gaprnt (2,pout);
   }
   else if (cmpwrd("strmden",cmd) || cmpwrd("strmopts",cmd)) {
@@ -6812,7 +6969,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       gaprnt (2,"ccolor = reverse rainbow \n");
     } else {
       if (intprs(cmd,&(pcm->ccolor)) == NULL ) goto err;
-      snprintf(pout,255,"ccolor = %i \n",pcm->ccolor);
+      snprintf(pout,1255,"ccolor = %i \n",pcm->ccolor);
       gaprnt (2,pout);
     }
   }
@@ -6924,7 +7081,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     pcm->vdim[4] = num-1;
     pcm->dmin[4] = enum1+1;  
     pcm->dmax[4] = enum2+1;
-    snprintf(pout,255,"E set to %g %g \n", pcm->dmin[4], pcm->dmax[4]);
+    snprintf(pout,1255,"E set to %g %g \n", pcm->dmin[4], pcm->dmax[4]);
     gaprnt (2,pout);    
   }
   else if (cmpwrd("e",cmd)) {
@@ -6951,7 +7108,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     pcm->vdim[4] = num-1;
     pcm->dmin[4] = v1;  
     pcm->dmax[4] = v2;
-    snprintf(pout,255,"E set to %g %g \n", pcm->dmin[4], pcm->dmax[4]);
+    snprintf(pout,1255,"E set to %g %g \n", pcm->dmin[4], pcm->dmax[4]);
     gaprnt (2,pout);
   }
   else if (cmpwrd("x",cmd) || cmpwrd("y",cmd) ||
@@ -7006,10 +7163,10 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       if (num==1) pcm->tmax = pcm->tmin;
       else gr2t(vals,v2,&(pcm->tmax));
       gaprnt (2,"Time values set: ");
-      snprintf(pout,255,"%i:%i:%i:%i ",pcm->tmin.yr,pcm->tmin.mo,
+      snprintf(pout,1255,"%i:%i:%i:%i ",pcm->tmin.yr,pcm->tmin.mo,
         pcm->tmin.dy,pcm->tmin.hr);
       gaprnt (2,pout);
-      snprintf(pout,255,"%i:%i:%i:%i \n",pcm->tmax.yr,pcm->tmax.mo,
+      snprintf(pout,1255,"%i:%i:%i:%i \n",pcm->tmax.yr,pcm->tmax.mo,
         pcm->tmax.dy,pcm->tmax.hr);
       gaprnt (2,pout);
     } else {
@@ -7028,7 +7185,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
         else 
 	  pcm->dmax[kwrd] = v2;
       }
-      snprintf(pout,255,"%s set to %g %g \n",kwds[kwrd+4], pcm->dmin[kwrd], pcm->dmax[kwrd]);
+      snprintf(pout,1255,"%s set to %g %g \n",kwds[kwrd+4], pcm->dmin[kwrd], pcm->dmax[kwrd]);
       gaprnt (2,pout);
     }
   }
@@ -7059,7 +7216,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       pcm->dmin[id] = conv(vals,v1);
       pcm->dmax[id] = pcm->dmin[id];
     }
-    snprintf(pout,255,"%s set to %g %g \n",kwds[id+4],pcm->dmin[id],pcm->dmax[id]);
+    snprintf(pout,1255,"%s set to %g %g \n",kwds[id+4],pcm->dmin[id],pcm->dmax[id]);
     gaprnt (2,pout);
   }
   else if (cmpwrd("time",cmd)) {
@@ -7086,10 +7243,10 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
       pcm->tmax = pcm->tmin;
     }
     gaprnt (2,"Time values set: ");
-    snprintf(pout,255,"%i:%i:%i:%i ",pcm->tmin.yr,pcm->tmin.mo,
+    snprintf(pout,1255,"%i:%i:%i:%i ",pcm->tmin.yr,pcm->tmin.mo,
       pcm->tmin.dy,pcm->tmin.hr);
     gaprnt (2,pout);
-    snprintf(pout,255,"%i:%i:%i:%i \n",pcm->tmax.yr,pcm->tmax.mo,
+    snprintf(pout,1255,"%i:%i:%i:%i \n",pcm->tmax.yr,pcm->tmax.mo,
       pcm->tmax.dy,pcm->tmax.hr);
     gaprnt (2,pout);
   }
@@ -7106,14 +7263,14 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (intprs(cmd,itmp) == NULL ) goto err;  /* tile number */
     if (*(itmp+0)<0 || *(itmp+0)>=COLORMAX) {
-      snprintf (pout,255,"Tile number must be between 0 and %d\n",COLORMAX-1); 
+      snprintf (pout,1255,"Tile number must be between 0 and %d\n",COLORMAX-1); 
       gaprnt (0,pout);
       goto err;
     } 
     if ((cmd = nxtwrd (cmd)) == NULL) goto err;
     if (intprs(cmd,itmp+1) == NULL ) goto err;  /* tile type */
     if (*(itmp+1)<0 || *(itmp+1)>8) {
-      snprintf (pout,255,"Tile type must be between 0 and 8\n"); 
+      snprintf (pout,1255,"Tile type must be between 0 and 8\n"); 
       gaprnt (0,pout);
       goto err;
     } 
@@ -7221,11 +7378,11 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
     else goto err;
 
     if (cmpwrd("line",pat) )
-      snprintf(pout,255,"SET FILL values: %s %d %d\n",pat,pcm->ptden,pcm->ptang);
+      snprintf(pout,1255,"SET FILL values: %s %d %d\n",pat,pcm->ptden,pcm->ptang);
     else if (cmpwrd("dot",pat) )
-      snprintf(pout,255,"SET FILL values: %s %d\n",pat,pcm->ptden);
+      snprintf(pout,1255,"SET FILL values: %s %d\n",pat,pcm->ptden);
     else
-      snprintf(pout,255,"SET FILL values: %s\n",pat);
+      snprintf(pout,1255,"SET FILL values: %s\n",pat);
     gaprnt (2,pout);
     gree(pat,"f234");
   }
@@ -7241,7 +7398,7 @@ static char *kwds[129] = {"X","Y","Z","T","LON","LAT","LEV","TIME",
 
 err:
   gaprnt (0,"SET error:  Missing or invalid arguments ");
-  snprintf(pout,255,"for %s option\n",kwds[kwrd]);
+  snprintf(pout,1255,"for %s option\n",kwds[kwrd]);
   gaprnt (0,pout);
   return (1);
 
@@ -7370,27 +7527,27 @@ gaint rc;
   pcm->fnum++;
 
   if (pcm->fnum==1) {pcm->pfid = pcm->pfi1; pcm->dfnum = 1;}
-  snprintf(pout,255,"Data file %s is open as file %i\n",pfi->name,pcm->fnum);
+  snprintf(pout,1255,"Data file %s is open as file %i\n",pfi->name,pcm->fnum);
   gaprnt (2,pout);
 
   /* If first file open, set up some default dimension ranges for the user */
   if (pcm->fnum==1) {
     if (pfi->type==2 || pfi->wrap ) gacmd ("set lon 0 360",pcm,0);
     else {
-      snprintf(pout,255,"set x 1 %i",pfi->dnum[0]);
+      snprintf(pout,1255,"set x 1 %i",pfi->dnum[0]);
       gacmd (pout,pcm,0);
     }
     if (pfi->type==2) {
       gacmd ("set lat -90 90",pcm,0);
       gacmd ("set lev 500",pcm,0);
     } else {
-      snprintf(pout,255,"set y 1 %i",pfi->dnum[1]);
+      snprintf(pout,1255,"set y 1 %i",pfi->dnum[1]);
       gacmd (pout,pcm,0);
       
       /* set z to max if x or y = 1 */
       if ((pfi->type==1 && pfi->dnum[2] >= 1)
 	  && ((pfi->dnum[0] == 1) || (pfi->dnum[1] == 1))) {
-	snprintf(pout,255,"set z 1 %i",pfi->dnum[2]);
+	snprintf(pout,1255,"set z 1 %i",pfi->dnum[2]);
 	gacmd (pout,pcm,0);
       } else {
 	gacmd ("set z 1",pcm,0);
@@ -7401,13 +7558,13 @@ gaint rc;
   }
 
   if (pfi->ppflag) {
-    snprintf(pout,255,"Notice: Implied interpolation for file %s\n",name);
+    snprintf(pout,1255,"Notice: Implied interpolation for file %s\n",name);
     gaprnt (1,pout);
     gaprnt (1," Interpolation will be performed on any data ");
     gaprnt (1,"displayed from this file\n");
 
     if (pfi->ppflag==8 && pfi->pdefgnrl==0) {
-      snprintf(pout,255,"WARNING: The use of PDEF FILE in %s \n",pfi->dnam);
+      snprintf(pout,1255,"WARNING: The use of PDEF FILE in %s \n",pfi->dnam);
       gaprnt (1,pout);
       gaprnt (1," may be incorrect. Please make sure you are using it properly.\n");
       gaprnt (1," Updated documentation is at http://cola.gmu.edu/grads/gadoc/pdef.html\n");
@@ -7456,7 +7613,7 @@ size_t sz;
   if (pcm->vdim[0]) {                    /* X is varying */
     if (pcm->dmin[0]>pcm->dmax[0]) {
       gaprnt (0,"Operation error:  Invalid dimension environment\n");
-      snprintf(pout,255,"  Min longitude > max longitude: %g %g \n",
+      snprintf(pout,1255,"  Min longitude > max longitude: %g %g \n",
 	       pcm->dmin[0],pcm->dmax[0]);
       gaprnt (0,pout);
       goto err;
@@ -7469,7 +7626,7 @@ size_t sz;
   if (pcm->vdim[1]) {                    /* Y is varying */
     if (pcm->dmin[1]>pcm->dmax[1]) {
       gaprnt (0,"Operation error:  Invalid dimension environment\n");
-      snprintf(pout,255,"  Min latitude > max latitude: %g %g \n",
+      snprintf(pout,1255,"  Min latitude > max latitude: %g %g \n",
 	       pcm->dmin[1],pcm->dmax[1]);
       gaprnt (0, pout);
       goto err;
@@ -7580,18 +7737,18 @@ gaint prntgaattr (struct gafile *pfi, char *name, gaint hdrflg, gaint fnum) {
       if (strcmp(attr->varname,name)==0) {
 	if (attr->fromddf == 1) {   /* only print those that were in a descriptor file */
 	  if (hdrflg) {
-	    snprintf(pout,255,"Descriptor Attributes for File %i : %s \n",fnum,pfi->title);
+	    snprintf(pout,1255,"Descriptor Attributes for File %i : %s \n",fnum,pfi->title);
 	    gaprnt(2,pout);
 	    hdrflg=0;
 	  }
 	  /* print strings */
 	  if (attr->nctype <= 2) {
-	    snprintf(pout,255,"%s %s %s %s\n",
+	    snprintf(pout,1255,"%s %s %s %s\n",
 		    attr->varname,attr->type,attr->name,(char*)attr->value);
 	    gaprnt(2,pout);
 	  } 
 	  else {
-	    snprintf(pout,255,"%s %s %s ",attr->varname,attr->type,attr->name);
+	    snprintf(pout,1255,"%s %s %s ",attr->varname,attr->type,attr->name);
 	    gaprnt(2,pout);
 	    if      (attr->nctype == 3) sptr = (short*)attr->value;
 	    else if (attr->nctype == 4) lptr = (long*)attr->value;
@@ -7600,28 +7757,28 @@ gaint prntgaattr (struct gafile *pfi, char *name, gaint hdrflg, gaint fnum) {
 	    for (i=0; i<attr->len; i++) {
 	      /* print numbers */
 	      if (attr->nctype == 3) {
-		snprintf(pout,255,"%i",(gaint)*(sptr));
+		snprintf(pout,1255,"%i",(gaint)*(sptr));
 		gaprnt(2,pout);
 		sptr++;
 	      } else if (attr->nctype == 4) {
-		snprintf(pout,255,"%li",*(lptr));
+		snprintf(pout,1255,"%li",*(lptr));
 		gaprnt(2,pout);
 		lptr++;
 	      } else if (attr->nctype == 5) {
-		snprintf(pout,255,"%f",*(fptr));
+		snprintf(pout,1255,"%f",*(fptr));
 		gaprnt(2,pout);
 		fptr++;
 	      } else { 
-		snprintf(pout,255,"%g",*(dptr));
+		snprintf(pout,1255,"%g",*(dptr));
 		gaprnt(2,pout);
 		dptr++;
 	      }
 	      if (i != attr->len-1) {
-		snprintf(pout,255,",");
+		snprintf(pout,1255,",");
 		gaprnt(2,pout);
 	      }
 	    }
-	    snprintf(pout,255,"\n");
+	    snprintf(pout,1255,"\n");
 	    gaprnt(2,pout);
 	  }
 	}
@@ -7760,10 +7917,10 @@ gaint gahistory(char*cmd, char *com, struct gacmn *pcm) {
       retcod = gacmd(his_cmd[i-1]->line,pcm,1);
       if (retcod) {
 	++nerror;
-	snprintf(pout,255,"  Repeat:  Error in command [%d] \"%s\".\n",i,his_cmd[i-1]->line);
+	snprintf(pout,1255,"  Repeat:  Error in command [%d] \"%s\".\n",i,his_cmd[i-1]->line);
 	gaprnt (0,pout);
 	if (nerror>50) {
-	  snprintf(pout,255,"  Repeat:  Too many errors (>50 ). Repeat stopped.\n");
+	  snprintf(pout,1255,"  Repeat:  Too many errors (>50 ). Repeat stopped.\n");
 	  gaprnt (0,pout);
 	  retcod = 1;
 	  return (retcod);
@@ -7785,7 +7942,7 @@ gaint sdfwatt (struct gacmn *pcm, gaint varid, char *varname, char *attname, cha
   if (attname != NULL) {
     rc = nc_put_att_text(pcm->ncwid, varid, attname, strlen(attval), attval);
     if (rc) {
-      snprintf(pout,255,"sdfwatt error from nc_put_att_text (%s %s): \n ",
+      snprintf(pout,1255,"sdfwatt error from nc_put_att_text (%s %s): \n ",
 	       varname, attname); 
       gaprnt (0,pout);
       handle_error(rc);
@@ -7802,7 +7959,7 @@ gaint sdfwatt (struct gacmn *pcm, gaint varid, char *varname, char *attname, cha
 	  rc = nc_put_att_text (pcm->ncwid, varid, attr->name, 
 				attr->len, (char*)attr->value);
 	  if (rc) {
-	    snprintf(pout,255,"sdfwatt error from nc_put_att_text (%s %s): \n ",
+	    snprintf(pout,1255,"sdfwatt error from nc_put_att_text (%s %s): \n ",
 		     attr->varname, attr->name); 
 	    gaprnt(0,pout);
 	    handle_error(rc);
@@ -7812,7 +7969,7 @@ gaint sdfwatt (struct gacmn *pcm, gaint varid, char *varname, char *attname, cha
 	  rc = nc_put_att_short (pcm->ncwid, varid, attr->name, 
 				 attr->nctype, attr->len, (short*)attr->value);
 	  if (rc) {
-	    snprintf(pout,255,"sdfwatt error from nc_put_att_short (%s %s): \n ",
+	    snprintf(pout,1255,"sdfwatt error from nc_put_att_short (%s %s): \n ",
 		     attr->varname, attr->name); 
 	    gaprnt(0,pout);
 	    handle_error(rc);
@@ -7822,7 +7979,7 @@ gaint sdfwatt (struct gacmn *pcm, gaint varid, char *varname, char *attname, cha
 	  rc = nc_put_att_long (pcm->ncwid, varid, attr->name, 
 				attr->nctype, attr->len, (long*)attr->value);
 	  if (rc) {
-	    snprintf(pout,255,"sdfwatt error from nc_put_att_long (%s %s): \n ",
+	    snprintf(pout,1255,"sdfwatt error from nc_put_att_long (%s %s): \n ",
 		     attr->varname, attr->name); 
 	    gaprnt(0,pout);
 	    handle_error(rc);
@@ -7832,7 +7989,7 @@ gaint sdfwatt (struct gacmn *pcm, gaint varid, char *varname, char *attname, cha
 	  rc = nc_put_att_float (pcm->ncwid, varid, attr->name, 
 				 attr->nctype, attr->len, (gafloat*)attr->value);
 	  if (rc) {
-	    snprintf(pout,255,"sdfwatt error from nc_put_att_float (%s %s): \n ",
+	    snprintf(pout,1255,"sdfwatt error from nc_put_att_float (%s %s): \n ",
 		     attr->varname, attr->name); 
 	    gaprnt(0,pout);
 	    handle_error(rc);
@@ -7842,7 +7999,7 @@ gaint sdfwatt (struct gacmn *pcm, gaint varid, char *varname, char *attname, cha
 	  rc = nc_put_att_double (pcm->ncwid, varid, attr->name, 
 				  attr->nctype, attr->len, (gadouble*)attr->value);
 	  if (rc) {
-	    snprintf(pout,255,"sdfwatt error from nc_put_att_double (%s %s): \n ",
+	    snprintf(pout,1255,"sdfwatt error from nc_put_att_double (%s %s): \n ",
 		     attr->varname, attr->name); 
 	    gaprnt(0,pout);
 	    handle_error(rc);
@@ -7911,7 +8068,7 @@ size_t start, count;
  }
 
  if (rc) {
-   snprintf(pout,255,"sdfwdim error from nc_put_var_double (dim=%d): \n ",dim);
+   snprintf(pout,1255,"sdfwdim error from nc_put_var_double (dim=%d): \n ",dim);
    gaprnt(0,pout);
    handle_error(rc);
    return (1);
@@ -7934,7 +8091,7 @@ size_t chunksize;
  else
    rc = nc_def_dim(fileid, dimname, dimsize, dimid);
  if (rc) {
-   snprintf(pout,255,"sdfdefdim error from nc_def_dim (%s): \n ",dimname);
+   snprintf(pout,1255,"sdfdefdim error from nc_def_dim (%s): \n ",dimname);
    gaprnt (0,pout);
    handle_error(rc); 
    return (1);
@@ -7942,7 +8099,7 @@ size_t chunksize;
  /* define the coordinate variable */
  rc = nc_def_var(fileid, dimname, NC_DOUBLE, 1, dimid, varid);
  if (rc) {
-   snprintf(pout,255,"sdfdefdim error from nc_def_var (%s): \n ",dimname);
+   snprintf(pout,1255,"sdfdefdim error from nc_def_var (%s): \n ",dimname);
    gaprnt (0,pout);
    handle_error(rc); 
    return (1);
@@ -7954,7 +8111,7 @@ size_t chunksize;
    chunksize = (size_t)dimsize;
    rc = nc_def_var_chunking (fileid, *dimid, NC_CHUNKED, &chunksize);
    if (rc) {
-     snprintf(pout,255,"sdfdefdim error from nc_def_var_chunking (%s): \n ",dimname);
+     snprintf(pout,1255,"sdfdefdim error from nc_def_var_chunking (%s): \n ",dimname);
      gaprnt(0,pout);
      handle_error(rc);
      return (1);
@@ -8004,7 +8161,7 @@ char *filename={"grads.sdfwrite.nc"};
   pdf = pcm->pdf1;
   while (pdf!=NULL && !cmpwrd(name,pdf->abbrv)) pdf = pdf->pforw;
   if (pdf==NULL) {
-    snprintf(pout,255,"ncwrite error: defined grid %s not found\n",name);
+    snprintf(pout,1255,"ncwrite error: defined grid %s not found\n",name);
     gaprnt (0,pout);
     goto err;
   }
@@ -8035,9 +8192,9 @@ char *filename={"grads.sdfwrite.nc"};
   if (pcm->sdfwpad) {
     padX = 1;
     padY = 1;
-    if (pcm->sdfwpad==1 || pcm->sdfwpad>=3) padZ = 1;
+    if (pcm->sdfwpad==1 || pcm->sdfwpad==3 || pcm->sdfwpad==5) padZ = 1;
     if (pcm->sdfwpad>=2) padT = 1;
-    if (pcm->sdfwpad==4) padE = 1;
+    if (pcm->sdfwpad>=4) padE = 1;
   }
 
   /* X is varying or user wants to pad the output with non-varying dims */
@@ -8170,7 +8327,7 @@ char *filename={"grads.sdfwrite.nc"};
     rc = nc_def_var(pcm->ncwid, name, NC_FLOAT, nvdims, dimids, &varid);
   }
   if (rc) {
-    snprintf(pout,255,"ncwrite error from nc_def_var (%s): \n ",name);
+    snprintf(pout,1255,"ncwrite error from nc_def_var (%s): \n ",name);
     gaprnt(0,pout);
     handle_error(rc);
     goto err;
@@ -8191,7 +8348,7 @@ char *filename={"grads.sdfwrite.nc"};
     /* define variable as chunked */
     rc = nc_def_var_chunking (pcm->ncwid, varid, NC_CHUNKED, chunksize);
     if (rc) {
-      snprintf(pout,255,"ncwrite error from nc_def_var_chunking (%s): \n ",name);
+      snprintf(pout,1255,"ncwrite error from nc_def_var_chunking (%s): \n ",name);
       gaprnt(0,pout);
       handle_error(rc);
       goto err;
@@ -8201,7 +8358,7 @@ char *filename={"grads.sdfwrite.nc"};
     /* compression settings: shuffle on, deflate level 1 */
     rc = nc_def_var_deflate (pcm->ncwid, varid, 1, 1, 1); 
     if (rc) {
-      snprintf(pout,255,"ncwrite error from nc_def_var_deflate (%s): \n ",name);
+      snprintf(pout,1255,"ncwrite error from nc_def_var_deflate (%s): \n ",name);
       gaprnt(0,pout);
       handle_error(rc);
       goto err;
@@ -8221,7 +8378,7 @@ char *filename={"grads.sdfwrite.nc"};
     rc = nc_put_att_float(pcm->ncwid, varid, "_FillValue", NC_FLOAT, 1, &flundef);
   }
   if (rc) {
-    snprintf(pout,255,"ncwrite error from nc_put_att (%s): \n ",name);
+    snprintf(pout,1255,"ncwrite error from nc_put_att (%s): \n ",name);
     gaprnt(0,pout);
     handle_error(rc);
     goto err;
@@ -8297,9 +8454,9 @@ char *filename={"grads.sdfwrite.nc"};
   if (chunksize) gree(chunksize,"f335");
   rc = nc_close(pcm->ncwid);
   if (pcm->sdfwname) 
-    snprintf(pout,255,"Wrote variable %s to %s\n",name,pcm->sdfwname);
+    snprintf(pout,1255,"Wrote variable %s to %s\n",name,pcm->sdfwname);
   else 
-    snprintf(pout,255,"Wrote variable %s to grads.sdfwrite.nc\n",name);
+    snprintf(pout,1255,"Wrote variable %s to grads.sdfwrite.nc\n",name);
   gaprnt(2,pout);
 
   return 0;
@@ -8392,7 +8549,7 @@ SHPHandle gaopshp(char *shparg) {
   if ((id=SHPOpen(gxgnam(shparg),"rb"))!=NULL) return(id);
  
   /* give up */
-  snprintf(pout,255,"Error: Unable to open shapefile \"%s\" \n",shparg);
+  snprintf(pout,1255,"Error: Unable to open shapefile \"%s\" \n",shparg);
   gaprnt(0,pout);
   return (NULL); 
 }
@@ -8453,7 +8610,7 @@ DBFHandle gaopdbf(char *shparg) {
   if ((id=DBFOpen(gxgnam(shparg),"rb"))!=NULL) return(id);
  
   /* give up */
-  snprintf(pout,255,"Error: Unable to open shapefile \"%s\" \n",shparg);
+  snprintf(pout,1255,"Error: Unable to open shapefile \"%s\" \n",shparg);
   gaprnt(0,pout);
   return (NULL); 
 }
diff --git a/src/gautil.c b/src/gautil.c
index 48d023d..605eb9a 100644
--- a/src/gautil.c
+++ b/src/gautil.c
@@ -46,7 +46,7 @@
 
 struct gamfcmn mfcmn;
 
-static char pout[256];   /* Build Error msgs here */
+static char pout[1256];   /* Build Error msgs here */
 
 char *gatxtl(char *str, gaint color);
 
@@ -433,7 +433,7 @@ char monam[5];
     if (*ch == ':' || tolower(*ch) == 'z') {
       if (val>23) {
         gaprnt (0,"Syntax Error:  Invalid Date/Time value.\n");
-        snprintf(pout,255,"  Hour = %i -- greater than 23\n",val);
+        snprintf(pout,1255,"  Hour = %i -- greater than 23\n",val);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -444,7 +444,7 @@ char monam[5];
           ch = intprs (ch,&val);
           if (val>59) {
             gaprnt (0,"Syntax Error:  Invalid Date/Time value.\n");
-            snprintf(pout,255,"  Minute = %i -- greater than 59\n",val);
+            snprintf(pout,1255,"  Minute = %i -- greater than 59\n",val);
             gaprnt (0,pout);
             return (NULL);
           }
@@ -521,7 +521,7 @@ char monam[5];
   if (dtim->mo==2 && qleap(dtim->yr)) i = 29;
   if (dtim->dy > i) {
     gaprnt (0,"Syntax Error:  Invalid Date/Time value.\n");
-    snprintf(pout,255,"  Day = %i -- greater than %i \n",dtim->dy,i);
+    snprintf(pout,1255,"  Day = %i -- greater than %i \n",dtim->dy,i);
     gaprnt (0,pout);
     return (NULL);
   }
@@ -564,7 +564,7 @@ char id[3];
     else if (cmpwrd("mn",id)) dtim->mn = val;
     else {
       gaprnt (0,"Syntax Error:  Invalid Date/Time offset.\n");
-      snprintf(pout,255,"  Expecting yr/mo/dy/hr/mn, found %s\n",id);
+      snprintf(pout,1255,"  Expecting yr/mo/dy/hr/mn, found %s\n",id);
       gaprnt (0,pout);
       return (NULL);
     }
@@ -840,7 +840,7 @@ char name[15],ename[20];
   name[i] = '\0';
   if (i>4) {
     gaprnt (0,"Syntax Error:  Invalid dimension expression \n");
-    snprintf(pout,255,"  Expecting x/y/z/t/offt/e/lon/lat/lev/time/ens, found %s\n",name);
+    snprintf(pout,1255,"  Expecting x/y/z/t/offt/e/lon/lat/lev/time/ens, found %s\n",name);
     gaprnt (0,pout);
     return (NULL);
   }
@@ -851,7 +851,7 @@ char name[15],ename[20];
   else if (*ch == '-') op = 2;
   else {
     gaprnt (0,"Syntax Error:  Invalid dimension expression\n");
-    snprintf(pout,255,"  Expecting +/-/= operator, found %c\n",*ch);
+    snprintf(pout,1255,"  Expecting +/-/= operator, found %c\n",*ch);
     gaprnt (0,pout);
     return (NULL);
   }
@@ -908,7 +908,7 @@ char name[15],ename[20];
   else if (type==0 && cmpwrd("r",name)) *dim = 10;
   else {
     gaprnt (0,"Syntax Error:  Invalid dimension expression\n");
-    snprintf(pout,255,"  Expecting x/y/z/t/offt/e/lat/lon/lev/time/ens, found %s\n",name);
+    snprintf(pout,1255,"  Expecting x/y/z/t/offt/e/lat/lon/lev/time/ens, found %s\n",name);
     gaprnt (0,pout);
     return (NULL);
   }
@@ -931,7 +931,7 @@ char name[15],ename[20];
       if (*dim==pst->idim || *dim==pst->jdim) {
 	gaprnt (0,"Syntax Error:  Invalid dimension expression\n");
 	gaprnt (0,"  Cannot use an offset value with a varying dimension\n");
-	snprintf(pout,255,"  Varying dimension = %i \n",*dim);
+	snprintf(pout,1255,"  Varying dimension = %i \n",*dim);
 	gaprnt (0,pout);
 	return (NULL);
       }
@@ -971,7 +971,7 @@ char name[15],ename[20];
       if (*dim==pst->idim || *dim==pst->jdim) {
         gaprnt (0,"Syntax Error:  Invalid dimension expression\n");
         gaprnt (0,"  Cannot use an offset value with a varying dimension\n");
-        snprintf(pout,255,"  Varying dimension = %i \n",*dim);
+        snprintf(pout,1255,"  Varying dimension = %i \n",*dim);
         gaprnt (0,pout);
         return (NULL);
       }
@@ -1003,7 +1003,7 @@ char name[15],ename[20];
       }
       if (enum1<0) {
 	gaprnt (0,"Syntax Error:  Invalid dimension expression\n");
-	snprintf(pout,255,"  Ensemble name \"%s\" not found\n",ename);
+	snprintf(pout,1255,"  Ensemble name \"%s\" not found\n",ename);
 	gaprnt (0,pout);
 	return (NULL);
       }
@@ -2307,7 +2307,7 @@ size_t sz;
  sz = sizeof(gadouble)*num;
  vvv = (gadouble *)galloc(sz,"cpscal");
  if (vvv==NULL) {
-   snprintf(pout,255,"cpscal memory allocation error; dim=%d lin=%d num=%d\n",dim,lin,num);
+   snprintf(pout,1255,"cpscal memory allocation error; dim=%d lin=%d num=%d\n",dim,lin,num);
    gaprnt(0,pout);
    return (NULL);
  }
diff --git a/src/grads.c b/src/grads.c
index d1130a4..b6c1b5e 100644
--- a/src/grads.c
+++ b/src/grads.c
@@ -65,296 +65,300 @@ struct gacmn gcmn;
 static struct gawgds wgds;   
 extern struct gamfcmn mfcmn;
 
+/* * * * * * * * * * * * * * * * *
+ * Here's where it all begins... *
+ * * * * * * * * * * * * * * * * */
 #ifdef OPENGRADS
 int Main (int argc, char *argv[])  {
 #else
 int main (int argc, char *argv[])  {
 #endif
 
-void command_line_help(void) ;
-void gxdgeo (char *);
-void gxend (void);
-void gatxti(gaint on, gaint cs);
-char *gatxtl(char *str,gaint level);
-
-char cmd[1024];
-gaint rc,i,j,land,port,cmdflg,hstflg,gflag,xwideflg,killflg,ratioflg;
-gaint metabuff,size=0,g2size=0;
-gaint txtcs=-2;
-gaint ipcflg = 0; /* for IPC friendly interaction via pipes */
-char *icmd,*arg,*rc1;
-void gasigcpu() ;
-gaint wrhstflg=0; 
-gadouble aspratio;
-char *logfile,*userhome=NULL;
-
-/*--- common block sets before gainit ---*/
-gcmn.batflg = 0;
-land = 0;
-port = 0;
-cmdflg = 0;
-metabuff = 0;
-hstflg = 1; 
-gflag = 0;
-xwideflg = 0;
-icmd = NULL;
-arg = NULL;
-rc1 = NULL;
-killflg = 0;
-ratioflg = 0;
-aspratio = -999.9;
-
+  void command_line_help(void) ;
+  void gxdgeo (char *);
+  void gxend (void);
+  void gatxti(gaint on, gaint cs);
+  char *gatxtl(char *str,gaint level);
+  
+  char cmd[1024];
+  gaint rc,i,j,land,port,cmdflg,hstflg,gflag,xwideflg,killflg,ratioflg;
+  gaint metabuff,size=0,g2size=0;
+  gaint txtcs=-2;
+  gaint ipcflg = 0; /* for IPC friendly interaction via pipes */
+  char *icmd,*arg,*rc1;
+  void gasigcpu() ;
+  gaint wrhstflg=0; 
+  gadouble aspratio;
+  char *logfile,*userhome=NULL;
+  
+  /*--- common block sets before gainit ---*/
+  gcmn.batflg = 0;
+  land = 0;
+  port = 0;
+  cmdflg = 0;
+  metabuff = 0;
+  hstflg = 1; 
+  gflag = 0;
+  xwideflg = 0;
+  icmd = NULL;
+  arg = NULL;
+  rc1 = NULL;
+  killflg = 0;
+  ratioflg = 0;
+  aspratio = -999.9;
+  
 #if READLINE == 1
 #ifdef __GO32__  /* MSDOS case */ 
-logfile= (char *) malloc(22);
-logfile= "c:\windows\grads.log";
+  logfile= (char *) malloc(22);
+  logfile= "c:\windows\grads.log";
 #else  /* Unix */
-userhome=getenv("HOME");
-if (userhome==NULL) {
-  logfile=NULL;
-}
-else {
-  logfile= (char *) malloc(strlen(userhome)+12);
-  if(logfile==NULL) {
-    printf("Memory allocation error for logfile name.\n");
+  userhome=getenv("HOME");
+  if (userhome==NULL) {
+    logfile=NULL;
   }
   else {
-    strcpy(logfile,userhome);
-    strcat(logfile,"/.grads.log");
+    logfile= (char *) malloc(strlen(userhome)+12);
+    if(logfile==NULL) {
+      printf("Memory allocation error for logfile name.\n");
+    }
+    else {
+      strcpy(logfile,userhome);
+      strcat(logfile,"/.grads.log");
+    }
   }
-}
 #endif /* __GO32__ */
 #endif /* READLINE == 1 */
-
-if (argc>1) {
-  for (i=1; i<argc; i++) {
-    if (*(argv[i])=='-' &&
-	*(argv[i]+1)=='h' && *(argv[i]+2)=='e' && *(argv[i]+3)=='l' && *(argv[i]+4)=='p') {
-      command_line_help();     /* answer a cry for help */
-      return(0);
-    } else if (cmdflg==1) {    /* next arg is the command to execute */
-      icmd = argv[i];
-      cmdflg = 0;
-    } else if (metabuff) {     /* next arg is the metafile buffer size */
-      arg = argv[i];
-      rc1 = intprs(arg,&size);
-      if (rc1!=NULL) metabuff = 0;
-    } else if ((txtcs==-1) && (*argv[i]!='-')) {  /* next arg is optional colorization scheme */
-      txtcs = (gaint) strtol(argv[i], (char **)NULL, 10);
-      if (txtcs>2) {
-        printf("Valid colorization schemes are 0, 1, or 2. Colorization option %d ignored. \n",txtcs);
-        txtcs = -2;
-      }
-    } else if (ratioflg) {    /* next arg is aspect ratio */
+  
+  if (argc>1) {
+    for (i=1; i<argc; i++) {
+      if (*(argv[i])=='-' &&
+	  *(argv[i]+1)=='h' && *(argv[i]+2)=='e' && *(argv[i]+3)=='l' && *(argv[i]+4)=='p') {
+	command_line_help();     /* user needs help */
+	return(0);
+      } else if (cmdflg==1) {    /* next arg is the command to execute */
+	icmd = argv[i];
+	cmdflg = 0;
+      } else if (metabuff) {     /* next arg is the metafile buffer size */
+	arg = argv[i];
+	rc1 = intprs(arg,&size);
+	if (rc1!=NULL) metabuff = 0;
+      } else if ((txtcs==-1) && (*argv[i]!='-')) {  /* next arg is optional colorization scheme */
+	txtcs = (gaint) strtol(argv[i], (char **)NULL, 10);
+	if (txtcs>2) {
+	  printf("Valid colorization schemes are 0, 1, or 2. Colorization option %d ignored. \n",txtcs);
+	  txtcs = -2;
+	}
+      } else if (ratioflg) {    /* next arg is aspect ratio */
         aspratio = atof(argv[i]);
         ratioflg = 0;
-    } else if (gflag) {        /* next arg is the geometry string */
-      gxdgeo(argv[i]);
-      gflag=0;
-    } else if (wrhstflg && *(argv[i])!='-') {   /* next arg is optional log file name */
+      } else if (gflag) {        /* next arg is the geometry string */
+	gxdgeo(argv[i]);
+	gflag=0;
+      } else if (wrhstflg && *(argv[i])!='-') {   /* next arg is optional log file name */
         logfile=argv[i];
-    } else if (*(argv[i])=='-') {
-      j = 1;
-      while (*(argv[i]+j)) {
-	if      (*(argv[i]+j)=='a') ratioflg = 1;    /* aspect ratio to follow */
-	else if (*(argv[i]+j)=='b') gcmn.batflg = 1; /* batch mode */
-	else if (*(argv[i]+j)=='c') cmdflg = 1;      /* command to follow */
-	else if (*(argv[i]+j)=='C') txtcs = -1;      /* text color scheme */
-	else if (*(argv[i]+j)=='E') hstflg = 0;      /* disable command line editing */
-	else if (*(argv[i]+j)=='g') gflag = 1;       /* geometry specification to follow */
-	else if (*(argv[i]+j)=='H') wrhstflg = 1;    /* write history to log file */
-	else if (*(argv[i]+j)=='l') land = 1;        /* landscape mode */
-	else if (*(argv[i]+j)=='m') metabuff = 1;    /* metafile buffer size to follow */
-	else if (*(argv[i]+j)=='p') port = 1;        /* portrait mode */
-	else if (*(argv[i]+j)=='W') xwideflg = 1;    /* use software to control wide lines (undocumented) */
-	else if (*(argv[i]+j)=='u') {                /* unbuffer output: needed for IPC via pipes */
-	  hstflg = 0;                                /* no need for readline in IPC mode */
-	  ipcflg = 1;
-	  setvbuf(stdin,  (char *) NULL,  _IONBF, 0 );
-	  setvbuf(stdout, (char *) NULL,  _IONBF, 0 );
-	  setvbuf(stderr, (char *) NULL,  _IONBF, 0 );
+      } else if (*(argv[i])=='-') {
+	j = 1;
+	while (*(argv[i]+j)) {
+	  if      (*(argv[i]+j)=='a') ratioflg = 1;    /* aspect ratio to follow */
+	  else if (*(argv[i]+j)=='b') gcmn.batflg = 1; /* batch mode */
+	  else if (*(argv[i]+j)=='c') cmdflg = 1;      /* command to follow */
+	  else if (*(argv[i]+j)=='C') txtcs = -1;      /* text color scheme */
+	  else if (*(argv[i]+j)=='E') hstflg = 0;      /* disable command line editing */
+	  else if (*(argv[i]+j)=='g') gflag = 1;       /* geometry specification to follow */
+	  else if (*(argv[i]+j)=='H') wrhstflg = 1;    /* write history to log file */
+	  else if (*(argv[i]+j)=='l') land = 1;        /* landscape mode */
+	  else if (*(argv[i]+j)=='m') metabuff = 1;    /* metafile buffer size to follow */
+	  else if (*(argv[i]+j)=='p') port = 1;        /* portrait mode */
+	  else if (*(argv[i]+j)=='W') xwideflg = 1;    /* use software to control wide lines (undocumented) */
+	  else if (*(argv[i]+j)=='u') {                /* unbuffer output: needed for IPC via pipes */
+	    hstflg = 0;                                /* no need for readline in IPC mode */
+	    ipcflg = 1;
+	    setvbuf(stdin,  (char *) NULL,  _IONBF, 0 );
+	    setvbuf(stdout, (char *) NULL,  _IONBF, 0 );
+	    setvbuf(stderr, (char *) NULL,  _IONBF, 0 );
+	  }
+	  else if (*(argv[i]+j)=='x') killflg = 1;     /* quit after finishing (usually used with -c) */
+	  else printf ("Unknown command line option: %c\n",*(argv[i]+j));
+	  j++;
 	}
-	else if (*(argv[i]+j)=='x') killflg = 1;     /* quit after finishing (usually used with -c) */
-	else printf ("Unknown command line option: %c\n",*(argv[i]+j));
-	j++;
-      }
-    } else printf ("Unknown command line keyword: %s\n",argv[i]);
+      } else printf ("Unknown command line keyword: %s\n",argv[i]);
+    }
   }
-}
-
-if (txtcs > -2) gatxti(1,txtcs); /* turn on text colorizing */
-
-if (ratioflg==1) printf ("Note: -a option was specified, but no aspect ratio was provided\n");
-if (cmdflg==1)   printf ("Note: -c option was specified, but no command was provided\n");
-if (gflag==1)    printf ("Note: -g option was specified, but no geometry specification was provided\n");
-if (metabuff==1) printf ("Note: -m option was specified, but no metafile buffer size was provided\n");
-
-if (ipcflg) printf("\n<IPC>" );  /* delimit splash screen */
-
-printf ("\nGrid Analysis and Display System (GrADS) Version %s\n",gatxtl(GRADS_VERSION,0));
-printf ("Copyright (C) 1988-2016 by George Mason University\n");
-printf ("GrADS comes with ABSOLUTELY NO WARRANTY\n");
-printf ("See file COPYRIGHT for more information\n\n");
-
-gacfg(0);
-
+  
+  if (txtcs > -2) gatxti(1,txtcs); /* turn on text colorizing */
+  
+  if (ratioflg==1) printf ("Note: -a option was specified, but no aspect ratio was provided\n");
+  if (cmdflg==1)   printf ("Note: -c option was specified, but no command was provided\n");
+  if (gflag==1)    printf ("Note: -g option was specified, but no geometry specification was provided\n");
+  if (metabuff==1) printf ("Note: -m option was specified, but no metafile buffer size was provided\n");
+  
+  if (ipcflg) printf("\n<IPC>" );  /* delimit splash screen */
+  
+  printf ("\nGrid Analysis and Display System (GrADS) Version %s\n",gatxtl(GRADS_VERSION,0));
+  printf ("Copyright (C) 1988-2017 by George Mason University\n");
+  printf ("GrADS comes with ABSOLUTELY NO WARRANTY\n");
+  printf ("See file COPYRIGHT for more information\n\n");
+  
+  gacfg(0);
+  
 #ifdef OPENGRADS
-<gaudi(&gcmn); /* Initialize OpenGrADS User Defined Extensions */
+  gaudi(&gcmn); /* Initialize OpenGrADS User Defined Extensions */
 #endif
-
-
-if (!land && !port && aspratio<-990) {
-  nxtcmd (cmd,"Landscape mode? ('n' for portrait): ");
-  if (cmd[0]=='n') port = 1;
-}
-if (port) {
-  gcmn.xsiz = 8.5;
-  gcmn.ysiz = 11.0;
-} else {
-  gcmn.xsiz = 11.0;
-  gcmn.ysiz = 8.5;
-}
-if (aspratio>-990) { /* user has specified aspect ratio */
-  if (aspratio>0.2 && aspratio < 5.0) {   /* range is limited here. */
-    if (aspratio < 1.0) {
-      gcmn.xsiz = 11.0*aspratio;
-      gcmn.ysiz = 11.0;
-    } else {
-      gcmn.ysiz = 11.0/aspratio;
-      gcmn.xsiz = 11.0;
+  
+  
+  if (!land && !port && aspratio<-990) {
+    nxtcmd (cmd,"Landscape mode? ('n' for portrait): ");
+    if (cmd[0]=='n') port = 1;
+  }
+  if (port) {
+    gcmn.xsiz = 8.5;
+    gcmn.ysiz = 11.0;
+  } else {
+    gcmn.xsiz = 11.0;
+    gcmn.ysiz = 8.5;
+  }
+  if (aspratio>-990) { /* user has specified aspect ratio */
+    if (aspratio>0.2 && aspratio < 5.0) {   /* range is limited here. */
+      if (aspratio < 1.0) {
+	gcmn.xsiz = 11.0*aspratio;
+	gcmn.ysiz = 11.0;
+      } else {
+	gcmn.ysiz = 11.0/aspratio;
+	gcmn.xsiz = 11.0;
+      }
+    }
+    else {
+      gaprnt(1,"Warning: Aspect ratio must be between 0.2 and 5.0 -- defaulting to landscape mode\n");
     }
   }
-  else {
-    gaprnt(1,"Warning: Aspect ratio must be between 0.2 and 5.0 -- defaulting to landscape mode\n");
+  
+  if(xwideflg) gxwdln();
+  
+  gainit();
+  mfcmn.cal365=-999;
+  mfcmn.warnflg=2;
+  mfcmn.winx=-999;      /* Window x  */         
+  mfcmn.winy=-999;      /* Window y */     
+  mfcmn.winw=0;         /* Window width */ 
+  mfcmn.winh=0;         /* Window height */ 
+  mfcmn.winb=0;         /* Window border width */
+  gcmn.pfi1 = NULL;                     /* No data sets open      */
+  gcmn.pfid = NULL;
+  gcmn.fnum = 0;
+  gcmn.dfnum = 0;
+  gcmn.undef = -9.99e8;         /* default undef value */
+  gcmn.fseq = 10; 
+  gcmn.pdf1 = NULL;
+  gcmn.sdfwname = NULL;
+  gcmn.sdfwtype = 1;
+  gcmn.sdfwpad = 0;
+  gcmn.sdfrecdim = 0;
+  gcmn.sdfchunk = 0;
+  gcmn.sdfzip = 0;
+  gcmn.sdfprec = 8;
+  gcmn.ncwid = -999;
+  gcmn.xchunk = 0;
+  gcmn.ychunk = 0;
+  gcmn.zchunk = 0;
+  gcmn.tchunk = 0;
+  gcmn.echunk = 0;
+  gcmn.attr = NULL;
+  gcmn.ffile = NULL;
+  gcmn.sfile = NULL;
+  gcmn.fwname = NULL;
+  gcmn.gtifname = NULL;    /* for GeoTIFF output */
+  gcmn.tifname = NULL;     /* for KML output */
+  gcmn.kmlname = NULL;     /* for KML output */
+  gcmn.kmlflg = 1;         /* default KML output is an image file */
+  gcmn.shpfname = NULL;    /* for shapefile output */
+  gcmn.shptype = 2;        /* default shape type is line */
+  gcmn.fwenflg = BYTEORDER;
+  gcmn.fwsqflg = 0;        /* default is stream */
+  gcmn.fwexflg = 0;        /* default is not exact -- old bad way */
+  gcmn.gtifflg = 1;        /* default geotiff output format is float */
+  if (size) gcmn.hbufsz = size;
+  if (g2size) gcmn.g2bufsz = g2size;
+  gcmn.cachesf = 1.0;      /* global scale factor for netcdf4/hdf5 cache */
+  gcmn.fillpoly = -1;      /* default is to not fill shapefile polygons */
+  gcmn.marktype = 3;       /* default is to draw points as closed circe */
+  gcmn.marksize = 0.05;    /* default mark size */
+  for (i=0; i<32; i++) {
+    gcmn.clct[i] = NULL;  /* initialize collection pointers */
+    gcmn.clctnm[i] = 0;
   }
-}
-
-if(xwideflg) gxwdln();
-
-gainit();
-mfcmn.cal365=-999;
-mfcmn.warnflg=2;
-mfcmn.winx=-999;      /* Window x  */         
-mfcmn.winy=-999;      /* Window y */     
-mfcmn.winw=0;         /* Window width */ 
-mfcmn.winh=0;         /* Window height */ 
-mfcmn.winb=0;         /* Window border width */
-gcmn.pfi1 = NULL;                     /* No data sets open      */
-gcmn.pfid = NULL;
-gcmn.fnum = 0;
-gcmn.dfnum = 0;
-gcmn.undef = -9.99e8;         /* default undef value */
-gcmn.fseq = 10; 
-gcmn.pdf1 = NULL;
-gcmn.sdfwname = NULL;
-gcmn.sdfwtype = 1;
-gcmn.sdfwpad = 0;
-gcmn.sdfrecdim = 0;
-gcmn.sdfchunk = 0;
-gcmn.sdfzip = 0;
-gcmn.sdfprec = 8;
-gcmn.ncwid = -999;
-gcmn.xchunk = 0;
-gcmn.ychunk = 0;
-gcmn.zchunk = 0;
-gcmn.tchunk = 0;
-gcmn.echunk = 0;
-gcmn.attr = NULL;
-gcmn.ffile = NULL;
-gcmn.sfile = NULL;
-gcmn.fwname = NULL;
-gcmn.gtifname = NULL;    /* for GeoTIFF output */
-gcmn.tifname = NULL;     /* for KML output */
-gcmn.kmlname = NULL;     /* for KML output */
-gcmn.kmlflg = 1;         /* default KML output is an image file */
-gcmn.shpfname = NULL;    /* for shapefile output */
-gcmn.shptype = 2;        /* default shape type is line */
-gcmn.fwenflg = BYTEORDER;
-gcmn.fwsqflg = 0;        /* default is stream */
-gcmn.fwexflg = 0;        /* default is not exact -- old bad way */
-gcmn.gtifflg = 1;        /* default geotiff output format is float */
-if (size) gcmn.hbufsz = size;
-if (g2size) gcmn.g2bufsz = g2size;
-gcmn.cachesf = 1.0;      /* global scale factor for netcdf4/hdf5 cache */
-gcmn.fillpoly = -1;      /* default is to not fill shapefile polygons */
-gcmn.marktype = 3;       /* default is to draw points as closed circe */
-gcmn.marksize = 0.05;    /* default mark size */
-for (i=0; i<32; i++) {
-  gcmn.clct[i] = NULL;  /* initialize collection pointers */
-  gcmn.clctnm[i] = 0;
-}
-
-
-gafdef();
-
-gagx(&gcmn);
-
+  
+  
+  gafdef();    /* read user defined function table (for versions < 2.0) */
+  gaudpdef();  /* read user defined plug-in table */
+  
+  gagx(&gcmn);
+  
 #if !defined(__CYGWIN32__) && !defined(__GO32__)
   signal(CPULIMSIG, gasigcpu) ;  /* CPU time limit signal; just exit   -hoop */
 #endif
-
+  
 #if READLINE == 1
-if (wrhstflg && logfile != NULL) {
-  printf("Command line history in %s\n",logfile);
-  history_truncate_file(logfile,256); 
-  read_history(logfile); /* read last 256 cmd */
-}
+  if (wrhstflg && logfile != NULL) {
+    printf("Command line history in %s\n",logfile);
+    history_truncate_file(logfile,256); 
+    read_history(logfile); /* read last 256 cmd */
+  }
 #endif
-
-if (icmd) rc = gacmd(icmd,&gcmn,0);
-else      rc = 0;
-signal(2,gasig);  /* Trap cntrl c */
-
+  
+  if (icmd) rc = gacmd(icmd,&gcmn,0);
+  else      rc = 0;
+  signal(2,gasig);  /* Trap cntrl c */
+  
 #if USEGUI == 1
-if (!ipcflg) 
-  gagui_main (argc, argv);   /*ams Initializes GAGUI, and if the environment
-                               variable GAGUI is set it starts a GUI
-                               script. Otherwise, it just returns. ams*/
+  if (!ipcflg) 
+    gagui_main (argc, argv);   /*ams Initializes GAGUI, and if the environment
+				 variable GAGUI is set it starts a GUI
+				 script. Otherwise, it just returns. ams*/
 #endif
-if (ipcflg) printf("\n<RC> %d </RC>\n</IPC>\n",rc);
-
-/* Main command line loop */
-while (rc>-1) {
-
-  if (killflg) return(99);
-
+  if (ipcflg) printf("\n<RC> %d </RC>\n</IPC>\n",rc);
+  
+  /* Main command line loop */
+  while (rc>-1) {
+    
+    if (killflg) return(99);
+    
 #if READLINE == 1
 #if defined(MM_NEW_PROMPT) 
-  char prompt[13];
-  if (hstflg) {
-    snprintf(prompt,12,"ga[%d]> ",history_length+1);
-    rc=nxrdln(&cmd[0],prompt);
-  }
+    char prompt[13];
+    if (hstflg) {
+      snprintf(prompt,12,"ga[%d]> ",history_length+1);
+      rc=nxrdln(&cmd[0],prompt);
+    }
 #else
-  if (hstflg) rc=nxrdln(&cmd[0],"ga-> ");
+    if (hstflg) rc=nxrdln(&cmd[0],"ga-> ");
 #endif
-  else rc=nxtcmd(&cmd[0],"ga> ");
+    else rc=nxtcmd(&cmd[0],"ga> ");
 #else
-  rc=nxtcmd(&cmd[0],"ga> ");
+    rc=nxtcmd(&cmd[0],"ga> ");
 #endif
-  
-  if (rc < 0) {
-    strcpy(cmd,"quit");   /* on EOF, just quit */
-    printf("[EOF]\n");
+    
+    if (rc < 0) {
+      strcpy(cmd,"quit");   /* on EOF, just quit */
+      printf("[EOF]\n");
+    }
+    
+    if (ipcflg) printf("\n<IPC> %s", cmd );  /* echo command in IPC mode */
+    
+    gcmn.sig = 0;
+    rc = gacmd(cmd,&gcmn,0);
+    
+    if (ipcflg) printf("\n<RC> %d </RC>\n</IPC>\n",rc);
   }
-
-  if (ipcflg) printf("\n<IPC> %s", cmd );  /* echo command in IPC mode */
-
-  gcmn.sig = 0;
-  rc = gacmd(cmd,&gcmn,0);
-
-  if (ipcflg) printf("\n<RC> %d </RC>\n</IPC>\n",rc);
-}
-
-/* All done */
-gxend();
-
+  
+  /* All done */
+  gxend();
+  
 #if READLINE == 1
- if (wrhstflg) write_command_log(logfile);
+  if (wrhstflg) write_command_log(logfile);
 #endif
-
-exit(0);
-
+  
+  exit(0);
+  
 }
 
 /* query the global cache scale factor */
@@ -474,6 +478,7 @@ gaint i;
   gcmn.timelabflg = 1;
   gcmn.stnprintflg = 0;
   gcmn.fgcnt = 0;
+  gcmn.barbolin = 0;
   gcmn.barflg = 0;
   gcmn.bargap = 0;
   gcmn.barolin = 0;
diff --git a/src/grads.h b/src/grads.h
index 850d187..b70a229 100644
--- a/src/grads.h
+++ b/src/grads.h
@@ -11,9 +11,11 @@
 #include "shapefil.h"
 #endif
 #if USEHDF5==1
-#include <hdf5.h>
+#include "hdf5.h"
 #endif
 
+#define UDPVERS 1
+
 /* Handling of missing data values. After the data I/O is done, 
    grid values are tested to see if they are within a small range 
    (+-value/EPSILON) of the missing value. If true, then the undef 
@@ -226,6 +228,7 @@ struct gacmn {
   gaint wxcols[5];             /* wx symbol colors */
   gaint wxopt;                 /* wx options */
   gaint tser;                  /* station time series type */
+  gaint barbolin;              /* Wind barb pennant outline flag */
   gaint bargap;                /* Bar Gap in percent  */
   gaint barolin;               /* Bar outline flag */
   gadouble barbase;            /* Bar Base Value      */
@@ -438,7 +441,7 @@ struct gastat {
   struct gaindx *pindx;        /* Index Strucure if indexed file */
   struct gaindxb *pindxb;      /* Index Strucure if off_t offsets are being used */
 #if GRIB2
-  struct gag2indx *g2indx;     /* Index Strucure if GRIB2 file */
+  struct gag2indx *g2indx;     /* Index Strucure for grib2 index file */
 #endif
   gaint tmplat;                /* File name templating:
                                    3==templating on E and T 
@@ -463,6 +466,7 @@ struct gastat {
   char *undefattr;             /* undef attribute name */
   char *undefattr2;            /* secondary undef attribute name */
   long xyhdr;                  /* Number of bytes to ignore at head of xy grids*/
+  long xytrlr;                 /* Number of bytes to ignore at end of xy grids*/
   gaint calendar;              /* Support for 365-day calendars */
   gaint pa2mb;                 /* convert pressure values in descriptor file from Pa -> mb */
   gaint bufrflg;               /* 1==dtype bufr */
@@ -724,6 +728,21 @@ struct gaufb {
   char *iname;                 /* File name for data transfer from user */
 };
 
+/* Structure that contains a pointer to gaexpr (for user defined plug-ins) */
+struct gaudpinfo {
+  gaint version;               /* for keeping track of compatibility */
+  gaint (*exprptr)(char *, struct gastat *);
+};
+
+/* Structure that describes a user defined plug-in */
+struct gaupb {
+  struct gaupb *upb;           /* Forward pointer                      */
+  char name[16];               /* Function name                        */
+  char *fname;                 /* Name of user executable              */
+  gaint type;                  /* 1==function, 2==defop                */
+  gaint (*pfunc)(struct gafunc *, struct gastat *, struct gaudpinfo *);  /* Function pointer */
+};
+
 /* Structure that describes a defined grid */
 struct gadefn {
   struct gadefn *pforw;        /* Linked list pointer                  */
@@ -926,14 +945,19 @@ char *stnvar (char *, char *, struct gafile *, struct gavar *,
               struct gastat *);
 
 /* Functions in GAFUNC:
-    rtnprs: Parse and execute a function call
-    gafopr: Perform opration for two-op function call
-    gafdef: Read user function definition table
-                                                                     */
+    rtnprs:   Parse and execute a function call
+    gafopr:   Perform opration for two-op function call
+    gafdef:   Read user function definition table
+    gaudpdef: Read user function definition table
+    gaqupb:   Prints the contents of the chain of upb structures  */
+
+                                                                 
 
 char *rtnprs (char *, char *, struct gastat *) ;
 gaint gafopr (struct gastat *, struct gastat *, gaint );
 void gafdef (void);
+void gaudpdef (void);
+void gaqupb (void);
 
 /* Functions in GAIO:
     gaggrd: Get a grid from a data file
@@ -1083,7 +1107,7 @@ void gafstn (struct gacmn *);
 void gapstn (struct gacmn *);
 void gawsym (struct gacmn *);
 void gasmrk (struct gacmn *);
-void gabarb (gadouble, gadouble, gadouble, gadouble, gadouble, gadouble, gadouble, gaint);
+void gabarb (gadouble, gadouble, gadouble, gadouble, gadouble, gadouble, gadouble, gaint, gaint);
 void gapmdl (struct gacmn *);
 gaint gasmdl (struct gacmn *, struct garpt *, gadouble *, char *);
 gadouble wndexit (gadouble, gadouble, gadouble, gadouble, gadouble, gadouble *,
@@ -1133,7 +1157,6 @@ gaint gashdc (struct gacmn *, gadouble);
     lev2gr: Discrete level scaling routine
     intprs: Parse an integer expression
     longprs: Parse an long integer expression kk 020624 --- 
-    valprs: Parse a floating number expression
     dimprs: Parse a dimension expression
     lowcas: Convert a string to lower case
     uppcas: Convert a string to upper case
diff --git a/src/gscrpt.c b/src/gscrpt.c
index 597a364..983cc5e 100644
--- a/src/gscrpt.c
+++ b/src/gscrpt.c
@@ -1916,6 +1916,7 @@ gaint len, rc, i, cflg, pcnt;
   else if (cmpwrd(name,"read")) rc = gsfrd(pcmn);
   else if (cmpwrd(name,"write")) rc = gsfwt(pcmn);
   else if (cmpwrd(name,"close")) rc = gsfcl(pcmn);
+  else if (cmpwrd(name,"sys")) rc = gsfsys(pcmn);
   else if (cmpwrd(name,"gsfallow")) rc = gsfallw(pcmn);
   else if (cmpwrd(name,"gsfpath")) rc = gsfpath(pcmn);
   else if (cmpwrd(name,"math_log")) rc = gsfmath(pcmn,1);
@@ -2279,6 +2280,84 @@ gaint dflg,eflg,len;
 
 /*  Intrinsic functions.  */
 
+/* Sys function. Expects one arg, the command to execute.
+   Uses popen to execute the command and read the stdout from it.  
+   Note that popen has limitations. */
+
+gaint gsfsys (struct gscmn *pcmn) {
+FILE *pipe;
+struct gsvar *pvar;
+char *cmd,*res,*buf;
+gadouble v;
+gaint ret,len,siz,incr,pos,ntype;
+
+  pcmn->rres = NULL;
+
+  pvar = pcmn->farg;
+  if (pvar==NULL) {
+    printf ("Error from script function: sys:  1st argument missing\n");
+    ret = 1;
+    goto retrn;
+  }
+  cmd = pvar->strng;
+
+  incr = 1000;
+  pvar = pvar->forw;
+  if (pvar!=NULL) {
+    gsnum (pvar->strng, &ntype, &ret, &v);
+    if (ntype!=1 || ret<5000) {
+      printf ("Warning from script function: sys: 2nd arg invalid, ignored\n");
+    } else incr = ret;
+  }
+
+  /* Call popen to execute the command. */
+
+  pipe = popen(cmd, "r");
+  if (pipe==NULL) {
+    printf ("Error from script function: sys:  popen error\n");
+    ret = 1;
+    goto retrn;
+  }
+
+  /* Allocate storage for the result and read the result */
+
+  siz = incr;
+  res = NULL;
+  pos = 0;
+  while (1) {
+    buf = (char *)realloc(res,siz+10);
+    if (buf==NULL) {
+      printf ("Error from script function: sys:  Memory allocation error\n");
+      printf ("Error from script function: sys:  Attempted size %i\n",siz);
+      free (res);
+      pclose(pipe);
+      ret = 1;
+      goto retrn;
+    }
+    res = buf;
+    len = fread(res+pos,sizeof(char),incr,pipe); 
+    pos += len;
+    if (len<incr) break;
+    if (siz>10000 && incr<5000) incr=5000;
+    if (siz>100000 && incr<10000) incr=10000;
+    if (siz>1000000 && incr<100000) incr=100000;
+    siz += incr;
+  }
+  *(res+pos) = '\0';
+  pclose(pipe);
+
+  ret = 0;
+  pcmn->rres = res;
+
+  /* Release arg storage and return */
+
+retrn:
+
+  gsfrev (pcmn->farg);
+  pcmn->farg = NULL;
+  return (ret);
+}
+
 /* Substring function.  Expects three args:  string, start, length */
 
 gaint gsfsub (struct gscmn *pcmn) {
diff --git a/src/gxprint.c b/src/gxprint.c
index bdd18c5..ed94d7d 100644
--- a/src/gxprint.c
+++ b/src/gxprint.c
@@ -12,7 +12,6 @@
 
 
 /* local variables */
-static char pout[256];           
 static gadouble xsize,ysize;   
 static gaint rc=0;
 
diff --git a/src/gxprintGD.c b/src/gxprintGD.c
index 4b4d29b..e847248 100644
--- a/src/gxprintGD.c
+++ b/src/gxprintGD.c
@@ -11,7 +11,6 @@
 #include "gx.h"
 
 /* local variables */
-static char pout[256];           
 static gadouble xrsize,yrsize;   
 static gaint rc=0;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/grads.git



More information about the debian-science-commits mailing list