Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/cmake/BuildDakotaCustom.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/cmake/BuildDakotaCustom.cmake	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/cmake/BuildDakotaCustom.cmake	(revision 28162)
@@ -0,0 +1,95 @@
+##############################################################################
+#
+# Template CMake Configuration File.
+#
+##############################################################################
+# The following CMake variables represent the minimum set of variables
+# that are required to allow Dakota to
+#   * find all prerequisite third party libraries (TPLs)
+#   * configure compiler and MPI options
+#   * set Dakota install path
+#
+# Instructions:
+# 1. Read Dakota/INSTALL - Source Quick Start to use this template file.
+#
+# 2. Uncomment CMake variables below ONLY for values you need to change for
+#    your platform. Edit variables as needed.
+#
+#    For example, if you are using a custom install of Boost, installed in
+#    /home/me/usr/boost, uncomment both CMake Boost variables  and edit
+#    paths:
+#       set(BOOST_ROOT
+#           "/home/me/usr/boost"
+#           CACHE PATH "Use non-standard Boost install" FORCE)
+#       set( Boost_NO_SYSTEM_PATHS TRUE
+#            CACHE BOOL "Supress search paths other than BOOST_ROOT" FORCE)
+#
+#    Save file and exit.
+#
+# 6. Run CMake with script file. At terminal window, type:
+#      $ cmake -C BuildCustom.cmake $DAK_SRC
+#
+#    If you have not followed instructions in INSTALL -Source Quick Start,
+#    you will need to replace BuildCustom.cmake with the actual filename of
+#    this file and $DAK_SRC with the actual path to Dakota source.
+#
+##############################################################################
+
+##############################################################################
+# Set BLAS, LAPACK library paths ONLY if in non-standard locations
+##############################################################################
+set( BLAS_LIBS
+      "$ENV{BLAS_LIBS}"
+      CACHE FILEPATH "Use non-standard BLAS library path" FORCE )
+set( LAPACK_LIBS
+      "$ENV{LAPACK_LIBS}"
+      CACHE FILEPATH "Use non-standard BLAS library path" FORCE )
+
+##############################################################################
+# Set additional compiler options
+# Uncomment and replace <flag> with actual compiler flag, e.g. -xxe4.2
+##############################################################################
+set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}"
+     CACHE STRING "C Flags my platform" )
+set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}"
+     CACHE STRING "CXX Flags for my platform" )
+set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}"
+     CACHE STRING "Fortran Flags for my platform" )
+
+##############################################################################
+# Set MPI options
+# Recommended practice is to set DAKOTA_HAVE_MPI and set MPI_CXX_COMPILER
+# to a compiler wrapper.
+##############################################################################
+set( DAKOTA_HAVE_MPI ON
+     CACHE BOOL "Build with MPI enabled" FORCE)
+set( MPI_INCLUDE_PATH "$ENV{MPI_HOME}/include"
+     CACHE FILEPATH "Use MPI headers" FORCE)
+set( MPI_LIBRARY "-L$ENV{MPI_HOME}/lib -lmpich"
+     CACHE FILEPATH "Use MPI library" FORCE)
+
+##############################################################################
+# Set Boost path if CMake cannot find your installed version of Boost or
+# if you have a custom Boost install location.
+##############################################################################
+set(BOOST_ROOT
+    $ENV{BOOST_ROOT}
+    CACHE PATH "Use non-standard Boost install" FORCE)
+set( Boost_NO_SYSTEM_PATHS TRUE
+     CACHE BOOL "Supress search paths other than BOOST_ROOT" FORCE)
+
+##############################################################################
+# Set Trilinos path if you want have a custom Trilinos install location. If
+# not set, the Trilinos package, teuchos, will be build during the Dakota
+# build.
+##############################################################################
+#set( Trilinos_DIR
+#      "path/to/Trilinos/install"
+#      CACHE PATH "Path to installed Trilinos" FORCE )
+
+##############################################################################
+# Customize DAKOTA
+##############################################################################
+set( CMAKE_INSTALL_PREFIX
+     $ENV{DAK_INSTALL}
+     CACHE PATH "Path to Dakota installation" )
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/cmake/DakotaDev.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/cmake/DakotaDev.cmake	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/cmake/DakotaDev.cmake	(revision 28162)
@@ -0,0 +1,18 @@
+# CMake options for DAKOTA developer builds
+
+# Developer options
+#set(DAKOTA_HAVE_MPI TRUE CACHE BOOL "Enable MPI in DAKOTA?")
+set(ENABLE_DAKOTA_DOCS FALSE CACHE BOOL "Enable DAKOTA documentation build")
+set(ENABLE_SPEC_MAINT FALSE CACHE BOOL
+  "Enable DAKOTA specification maintenance mode?")
+set(PECOS_ENABLE_TESTS FALSE CACHE BOOL "Enable Pecos-specific tests?")
+
+# Not included from Mike's configs, but may help some
+
+# Disable optional X graphics
+#-DHAVE_X_GRAPHICS:BOOL=FALSE
+set(HAVE_X_GRAPHICS OFF CACHE BOOL "Disable dependency on X libraries" FORCE)
+
+# CMake 2.8.6 has problems with RHEL6/Boost -- the following is a workaround
+#-DBoost_NO_BOOST_CMAKE=ON
+#set(Boost_NO_BOOST_CMAKE ON CACHE BOOL "Obtain desired behavior on RHEL6" FORCE)
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/cmake/BuildDakotaCustom.cmake
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/cmake/BuildDakotaCustom.cmake	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/cmake/BuildDakotaCustom.cmake	(revision 28162)
@@ -0,0 +1,95 @@
+##############################################################################
+#
+# Template CMake Configuration File.
+#
+##############################################################################
+# The following CMake variables represent the minimum set of variables
+# that are required to allow Dakota to
+#   * find all prerequisite third party libraries (TPLs)
+#   * configure compiler and MPI options
+#   * set Dakota install path
+#
+# Instructions:
+# 1. Read Dakota/INSTALL - Source Quick Start to use this template file.
+#
+# 2. Uncomment CMake variables below ONLY for values you need to change for
+#    your platform. Edit variables as needed.
+#
+#    For example, if you are using a custom install of Boost, installed in
+#    /home/me/usr/boost, uncomment both CMake Boost variables  and edit
+#    paths:
+#       set(BOOST_ROOT
+#           "/home/me/usr/boost"
+#           CACHE PATH "Use non-standard Boost install" FORCE)
+#       set( Boost_NO_SYSTEM_PATHS TRUE
+#            CACHE BOOL "Supress search paths other than BOOST_ROOT" FORCE)
+#
+#    Save file and exit.
+#
+# 6. Run CMake with script file. At terminal window, type:
+#      $ cmake -C BuildCustom.cmake $DAK_SRC
+#
+#    If you have not followed instructions in INSTALL -Source Quick Start,
+#    you will need to replace BuildCustom.cmake with the actual filename of
+#    this file and $DAK_SRC with the actual path to Dakota source.
+#
+##############################################################################
+
+##############################################################################
+# Set BLAS, LAPACK library paths ONLY if in non-standard locations
+##############################################################################
+set( BLAS_LIBS
+      "$ENV{BLAS_LIBS}"
+      CACHE FILEPATH "Use non-standard BLAS library path" FORCE )
+set( LAPACK_LIBS
+      "$ENV{LAPACK_LIBS}"
+      CACHE FILEPATH "Use non-standard BLAS library path" FORCE )
+
+##############################################################################
+# Set additional compiler options
+# Uncomment and replace <flag> with actual compiler flag, e.g. -xxe4.2
+##############################################################################
+set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}"
+     CACHE STRING "C Flags my platform" )
+set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}"
+     CACHE STRING "CXX Flags for my platform" )
+set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}"
+     CACHE STRING "Fortran Flags for my platform" )
+
+##############################################################################
+# Set MPI options
+# Recommended practice is to set DAKOTA_HAVE_MPI and set MPI_CXX_COMPILER
+# to a compiler wrapper.
+##############################################################################
+set( DAKOTA_HAVE_MPI ON
+     CACHE BOOL "Build with MPI enabled" FORCE)
+set( MPI_INCLUDE_PATH "$ENV{MPI_HOME}/include"
+     CACHE FILEPATH "Use MPI headers" FORCE)
+set( MPI_LIBRARY "$ENV{MPI_HOME}/lib/libmpi.a"
+     CACHE FILEPATH "Use MPI library" FORCE)
+
+##############################################################################
+# Set Boost path if CMake cannot find your installed version of Boost or
+# if you have a custom Boost install location.
+##############################################################################
+set(BOOST_ROOT
+    $ENV{BOOST_ROOT}
+    CACHE PATH "Use non-standard Boost install" FORCE)
+set( Boost_NO_SYSTEM_PATHS TRUE
+     CACHE BOOL "Supress search paths other than BOOST_ROOT" FORCE)
+
+##############################################################################
+# Set Trilinos path if you want have a custom Trilinos install location. If
+# not set, the Trilinos package, teuchos, will be build during the Dakota
+# build.
+##############################################################################
+#set( Trilinos_DIR
+#      "path/to/Trilinos/install"
+#      CACHE PATH "Path to installed Trilinos" FORCE )
+
+##############################################################################
+# Customize DAKOTA
+##############################################################################
+set( CMAKE_INSTALL_PREFIX
+     $ENV{DAK_INSTALL}
+     CACHE PATH "Path to Dakota installation" )
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/include/xtndispatch.h
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/include/xtndispatch.h	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/include/xtndispatch.h	(revision 28162)
@@ -0,0 +1,147 @@
+/*  This code was computer generated */
+
+/*
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+/* Fix for C99 */
+extern int ipow(int a, int b); /* primes.c */
+
+if(  q== ipow(2,2)  )xtn = xtn2t2;
+if(  q== ipow(2,3)  )xtn = xtn2t3;
+if(  q== ipow(2,4)  )xtn = xtn2t4;
+if(  q== ipow(2,5)  )xtn = xtn2t5;
+if(  q== ipow(2,6)  )xtn = xtn2t6;
+if(  q== ipow(2,7)  )xtn = xtn2t7;
+if(  q== ipow(2,8)  )xtn = xtn2t8;
+if(  q== ipow(2,9)  )xtn = xtn2t9;
+if(  q== ipow(2,10)  )xtn = xtn2t10;
+if(  q== ipow(2,11)  )xtn = xtn2t11;
+if(  q== ipow(2,12)  )xtn = xtn2t12;
+if(  q== ipow(2,13)  )xtn = xtn2t13;
+if(  q== ipow(2,14)  )xtn = xtn2t14;
+if(  q== ipow(2,15)  )xtn = xtn2t15;
+if(  q== ipow(2,16)  )xtn = xtn2t16;
+if(  q== ipow(2,17)  )xtn = xtn2t17;
+if(  q== ipow(2,18)  )xtn = xtn2t18;
+if(  q== ipow(2,19)  )xtn = xtn2t19;
+if(  q== ipow(2,20)  )xtn = xtn2t20;
+if(  q== ipow(2,21)  )xtn = xtn2t21;
+if(  q== ipow(2,22)  )xtn = xtn2t22;
+if(  q== ipow(2,23)  )xtn = xtn2t23;
+if(  q== ipow(2,24)  )xtn = xtn2t24;
+if(  q== ipow(2,25)  )xtn = xtn2t25;
+if(  q== ipow(2,26)  )xtn = xtn2t26;
+if(  q== ipow(2,27)  )xtn = xtn2t27;
+if(  q== ipow(2,28)  )xtn = xtn2t28;
+if(  q== ipow(2,29)  )xtn = xtn2t29;
+if(  q== ipow(3,2)  )xtn = xtn3t2;
+if(  q== ipow(3,3)  )xtn = xtn3t3;
+if(  q== ipow(3,4)  )xtn = xtn3t4;
+if(  q== ipow(3,5)  )xtn = xtn3t5;
+if(  q== ipow(3,6)  )xtn = xtn3t6;
+if(  q== ipow(3,7)  )xtn = xtn3t7;
+if(  q== ipow(3,8)  )xtn = xtn3t8;
+if(  q== ipow(3,9)  )xtn = xtn3t9;
+if(  q== ipow(3,10)  )xtn = xtn3t10;
+if(  q== ipow(3,11)  )xtn = xtn3t11;
+if(  q== ipow(3,12)  )xtn = xtn3t12;
+if(  q== ipow(3,13)  )xtn = xtn3t13;
+if(  q== ipow(3,14)  )xtn = xtn3t14;
+if(  q== ipow(3,15)  )xtn = xtn3t15;
+if(  q== ipow(3,16)  )xtn = xtn3t16;
+if(  q== ipow(3,17)  )xtn = xtn3t17;
+if(  q== ipow(3,18)  )xtn = xtn3t18;
+if(  q== ipow(5,2)  )xtn = xtn5t2;
+if(  q== ipow(5,3)  )xtn = xtn5t3;
+if(  q== ipow(5,4)  )xtn = xtn5t4;
+if(  q== ipow(5,5)  )xtn = xtn5t5;
+if(  q== ipow(5,6)  )xtn = xtn5t6;
+if(  q== ipow(5,7)  )xtn = xtn5t7;
+if(  q== ipow(5,8)  )xtn = xtn5t8;
+if(  q== ipow(5,9)  )xtn = xtn5t9;
+if(  q== ipow(5,10)  )xtn = xtn5t10;
+if(  q== ipow(5,11)  )xtn = xtn5t11;
+if(  q== ipow(5,12)  )xtn = xtn5t12;
+if(  q== ipow(7,2)  )xtn = xtn7t2;
+if(  q== ipow(7,3)  )xtn = xtn7t3;
+if(  q== ipow(7,4)  )xtn = xtn7t4;
+if(  q== ipow(7,5)  )xtn = xtn7t5;
+if(  q== ipow(7,6)  )xtn = xtn7t6;
+if(  q== ipow(7,7)  )xtn = xtn7t7;
+if(  q== ipow(7,8)  )xtn = xtn7t8;
+if(  q== ipow(7,9)  )xtn = xtn7t9;
+if(  q== ipow(7,10)  )xtn = xtn7t10;
+if(  q== ipow(11,2)  )xtn = xtn11t2;
+if(  q== ipow(11,3)  )xtn = xtn11t3;
+if(  q== ipow(11,4)  )xtn = xtn11t4;
+if(  q== ipow(11,5)  )xtn = xtn11t5;
+if(  q== ipow(11,6)  )xtn = xtn11t6;
+if(  q== ipow(11,7)  )xtn = xtn11t7;
+if(  q== ipow(11,8)  )xtn = xtn11t8;
+if(  q== ipow(13,2)  )xtn = xtn13t2;
+if(  q== ipow(13,3)  )xtn = xtn13t3;
+if(  q== ipow(13,4)  )xtn = xtn13t4;
+if(  q== ipow(13,5)  )xtn = xtn13t5;
+if(  q== ipow(13,6)  )xtn = xtn13t6;
+if(  q== ipow(13,7)  )xtn = xtn13t7;
+if(  q== ipow(13,8)  )xtn = xtn13t8;
+if(  q== ipow(17,2)  )xtn = xtn17t2;
+if(  q== ipow(17,3)  )xtn = xtn17t3;
+if(  q== ipow(17,4)  )xtn = xtn17t4;
+if(  q== ipow(17,5)  )xtn = xtn17t5;
+if(  q== ipow(17,6)  )xtn = xtn17t6;
+if(  q== ipow(17,7)  )xtn = xtn17t7;
+if(  q== ipow(19,2)  )xtn = xtn19t2;
+if(  q== ipow(19,3)  )xtn = xtn19t3;
+if(  q== ipow(19,4)  )xtn = xtn19t4;
+if(  q== ipow(19,5)  )xtn = xtn19t5;
+if(  q== ipow(19,6)  )xtn = xtn19t6;
+if(  q== ipow(19,7)  )xtn = xtn19t7;
+if(  q== ipow(23,2)  )xtn = xtn23t2;
+if(  q== ipow(23,3)  )xtn = xtn23t3;
+if(  q== ipow(23,4)  )xtn = xtn23t4;
+if(  q== ipow(23,5)  )xtn = xtn23t5;
+if(  q== ipow(23,6)  )xtn = xtn23t6;
+if(  q== ipow(29,2)  )xtn = xtn29t2;
+if(  q== ipow(29,3)  )xtn = xtn29t3;
+if(  q== ipow(29,4)  )xtn = xtn29t4;
+if(  q== ipow(29,5)  )xtn = xtn29t5;
+if(  q== ipow(29,6)  )xtn = xtn29t6;
+if(  q== ipow(31,2)  )xtn = xtn31t2;
+if(  q== ipow(31,3)  )xtn = xtn31t3;
+if(  q== ipow(31,4)  )xtn = xtn31t4;
+if(  q== ipow(31,5)  )xtn = xtn31t5;
+if(  q== ipow(31,6)  )xtn = xtn31t6;
+if(  q== ipow(37,2)  )xtn = xtn37t2;
+if(  q== ipow(37,3)  )xtn = xtn37t3;
+if(  q== ipow(37,4)  )xtn = xtn37t4;
+if(  q== ipow(37,5)  )xtn = xtn37t5;
+if(  q== ipow(41,2)  )xtn = xtn41t2;
+if(  q== ipow(41,3)  )xtn = xtn41t3;
+if(  q== ipow(41,4)  )xtn = xtn41t4;
+if(  q== ipow(41,5)  )xtn = xtn41t5;
+if(  q== ipow(43,2)  )xtn = xtn43t2;
+if(  q== ipow(43,3)  )xtn = xtn43t3;
+if(  q== ipow(43,4)  )xtn = xtn43t4;
+if(  q== ipow(43,5)  )xtn = xtn43t5;
+if(  q== ipow(47,2)  )xtn = xtn47t2;
+if(  q== ipow(47,3)  )xtn = xtn47t3;
+if(  q== ipow(47,4)  )xtn = xtn47t4;
+if(  q== ipow(47,5)  )xtn = xtn47t5;
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/boselink.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/boselink.c	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/boselink.c	(revision 28162)
@@ -0,0 +1,150 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+#include <math.h>
+#include <stdio.h>
+#include "galois.h"
+
+/* Fix for C99*/
+extern int bose(struct GF *gf, int **A, int ncol); /* construct.c */
+extern int bush(struct GF *gf, int **A, int str, int ncol); /* construct.c */
+extern void GF_free(struct GF *gf); /* galois.c */
+extern int GF_getfield(int q, struct GF *gf); /* gfields.c */
+
+int bose_link( int n, int ninputs, int str, int ***AA )
+{
+   int    i, nsym, nsamples, **A; 
+   double dtemp, dpower;
+   struct GF gf;
+
+   if ( n <= 0 ) return -1;
+
+   /* only one method for strength of 3 */
+
+   if ( str == 3 )
+   {
+      dtemp = (double) n;
+      dtemp = pow(dtemp, 0.333333334);
+      nsym  = (int) dtemp;
+      if( ninputs > (nsym+1) ){
+         fprintf(stderr,"Only q+1 = %d cols given in Bush design.\n",nsym+1);
+         fprintf(stderr,"Columns requested was %d.\n",ninputs);
+	 return -1;
+      }
+      if(  !GF_getfield(nsym, &gf)  ) {
+         fprintf(stderr,"Could not construct the Galois field needed\n");
+         fprintf(stderr,"for the strength 3 Bush design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      nsamples = nsym * nsym * nsym;
+      A = imatrix( 0, nsamples, 0, ninputs-1  );
+      if(  !A  )
+      {
+         fprintf(stderr,"Could not allocate array for Bush design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      if(  ! bush( &gf, A, 3, ninputs )  )
+      {
+         fprintf(stderr,"Unable to construct the strength 3 ");
+         fprintf(stderr,"Bush design nsym=%d, ninputs=%d.\n", nsym,ninputs);
+	 GF_free( &gf );
+	 return -1;
+      }
+      else
+      {
+         (*AA) = A;
+         return nsamples;
+      }
+   }
+
+   /* only one method for strength greater than 3 */
+
+   if ( str > 3 )
+   {
+      dtemp = (double) n;
+      dpower = 1.0 / (double) str + 0.00000001;
+      dtemp = pow(dtemp, dpower);
+      nsym  = (int) dtemp;
+      if( ninputs > (nsym+1) ){
+         fprintf(stderr,"Only q+1 = %d cols given in Bush design.\n",nsym+1);
+         fprintf(stderr,"Columns requested was %d.\n",ninputs);
+	 return -1;
+      }
+      nsamples = nsym;
+      for ( i = 1; i < str; i++ ) nsamples = nsamples * nsym;
+      if(  !GF_getfield(nsym, &gf)  ){
+         fprintf(stderr,"Could not construct the Galois field needed\n");
+         fprintf(stderr,"for the strength %d Bush design\n",str);
+         fprintf(stderr,"on %d levels.\n", nsym);
+	 GF_free( &gf );
+	 return -1;
+      }
+      A = imatrix( 0, nsamples-1, 0, ninputs-1  );
+      if(  !A  )
+      {
+         fprintf(stderr,"Could not allocate array for Bush design.\n");
+	 GF_free( &gf );
+	 return -1;
+      } 
+      if(  ! bush( &gf, A, str, ninputs )  )
+      {
+         fprintf(stderr,"Unable to construct the strength %d \n", str);
+         fprintf(stderr,"Bush design nsym=%d, ninputs=%d.\n", nsym,ninputs);
+	 GF_free( &gf );
+	 return -1;
+      }
+      else
+      {
+         (*AA) = A;
+	 GF_free( &gf );
+         return nsamples;
+      }
+   }
+
+   /* for the cases when strength = 2 */
+
+   if ( str == 2 )
+   {
+      dtemp = (double) n;
+      dtemp = pow(dtemp, 0.500001);
+      nsym  = (int) dtemp;
+
+      if ( ninputs > ( nsym + 1 ) ) 
+      {
+         fprintf(stderr,"Number of samples too small to construct OA.\n");
+         fprintf(stderr,"Need at least %d. \n", (ninputs-1)*(ninputs-1));
+         return -1;
+      } 
+      if(  !GF_getfield( nsym, &gf)  )
+      {
+         fprintf(stderr,"Could not construct Galois field needed\n");
+         fprintf(stderr,"for Bose design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      nsamples = nsym * nsym;
+      A = imatrix( 0, nsamples-1, 0, ninputs-1  );
+      if(  !A  )
+      {
+         fprintf(stderr,"Could not allocate array for Bose design.\n");
+	 GF_free( &gf );
+	 return -1;
+      }
+      if(  ! bose( &gf, A, ninputs )  )
+      {
+         fprintf(stderr,"Unable to construct Bose design q=%d,",nsym);
+         fprintf(stderr," ninputs=%d.\n", ninputs);
+	 GF_free( &gf );
+	 return -1;
+      }
+      else
+      {
+         (*AA) = A;
+	 GF_free( &gf );
+         return nsamples;
+      }
+   }
+}
+
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/construct.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/construct.c	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/construct.c	(revision 28162)
@@ -0,0 +1,410 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/*
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+/*  Constructions for designs using Galois fields */
+
+#include <math.h>
+#include <stdio.h>
+
+#include "galois.h"
+
+/* Fix for C99 */
+extern int ipow(int a, int b); /* primes.c */
+extern int isprime(int p); /* primes.c */
+extern void free_ivector(int *v, int nl, int nh); /* memory.c */
+extern void free_imatrix(int **m, int nrl, int nrh, int ncl, int nch); /* memory.c */
+extern int akodd(struct GF *gf, int *kay, int *b, int *c, int *k); /* akconst.c */
+extern int akeven(struct GF *gf, int *kay, int *b, int *c, int *k); /* akconst.c */
+
+/*  Glossary:
+
+    bose:            OA( q^2, q+1, q, 2  )
+                     R.C. Bose (1938) Sankhya Vol 3 pp 323-338
+    bosecheck:       test input to bose
+
+    bosebush:        OA( 2q^2, 2q+1, q, 2 ), only implemented for q=2^n
+    bosebushcheck:   test input to bosebush
+
+    polyeval:        evaluate a polynomial with coefficients, argument
+                     and result in a Galois field
+
+*/
+
+
+bosecheck( q,ncol )
+int q, ncol;
+{
+if(  ncol > q+1  ){
+  fprintf(stderr,"Bose's design must have ncol <= q+1.\n");
+  fprintf(stderr,"Had q=%d and ncol=%d.\n",q,ncol);
+  return 0;
+}
+if(  ncol <= 0  ){
+  fprintf(stderr,"Nonpositive number of columns requested for Bose's design\n");
+  return 0;
+}
+return 1;
+}
+
+
+bose( gf, A, ncol )
+struct GF *gf;
+int    **A, ncol;
+{
+int i,j, icol,  q=gf->q, irow;
+
+if(  !bosecheck(q,ncol)  )return 0;
+
+irow = 0;
+for(  i=0; i<q; i++  )
+for(  j=0; j<q; j++  ){
+  icol=0;
+  A[ irow ][ icol++ ] = i;
+  if(  ncol > 1 )A[ irow  ][ icol++ ] = j;
+  for(  icol=2; icol<ncol; icol++ )
+    A[ irow ][ icol ] = gf->plus[j][gf->times[i][icol-1]];
+  irow++;
+}
+
+
+return 1;
+}
+
+itopoly( n,q,d,coef )
+int  n,q,d,*coef;
+{
+int i;
+
+for(  i=0; i<=d; i++  ){
+  coef[i] = n % q;
+  n = n/q;
+}
+}
+
+
+polyeval( gf, d, poly, arg, value )
+/*  find  value = poly(arg) where poly is a polynomial of degree d  
+    and all the arithmetic takes place in the given Galois field.*/
+
+struct GF *gf;
+int    d, *poly, arg, *value;
+{
+int   i,ans;
+
+ans = 0;
+for(  i= d; i>=0; i--  )  /* Horner's rule */
+  ans = gf->plus[  gf->times[ans][arg]  ][  poly[i] ];
+
+*value = ans;
+}
+
+bushcheck(q,str,ncol)
+int q,str,ncol;
+{
+if(  ncol > q+1  ){
+  fprintf(stderr,"Bush designs require ncol <= q+1.\n");
+  fprintf(stderr,"Cannot have q = %d and ncol = %d.\n",q,ncol);
+  return 0;
+}
+if(  str > ncol  ){
+  fprintf(stderr,"It doesn't make sense to have an array of strength\n");
+  fprintf(stderr,"%d with only %d columns.\n",str,ncol);
+  return 0;
+}
+if(  str >= q+1  ){
+  fprintf(stderr,"Bush's (1952) theorem has a condition t<q where t\n");
+  fprintf(stderr,"is the strength of the array and q is the number of symbols.\n");
+  fprintf(stderr,"Here we have t = %d and q = %d.  The array may still\n",str,q);
+  fprintf(stderr,"be useful, but a full factorial would have at least as\n");
+  fprintf(stderr,"many columns.\n");
+  return 1;
+}
+
+return 1;
+}
+
+
+bush( gf, A, str, ncol  )
+struct GF *gf;
+int       **A, str, ncol;
+{
+int   *coef;
+int   q, i,j;
+
+q = gf->q;
+if(  !bushcheck(q,str,ncol)  )return 0;
+
+coef = ivector( 0,str-1  );  
+if( !coef  ){ /* Very unlikely */
+  fprintf(stderr,"Could not allocate memory for Bush design.\n");
+  return 0;
+}
+
+for(  i=0; i<ipow(q,str); i++  ){
+  itopoly( i,q,str-1,coef );
+  A[i][0] = coef[str-1];  
+  for(  j=0; j<ncol-1; j++  )
+    polyeval( gf, str-1, coef, j, &A[i][1+j] );
+}
+free_ivector( coef,0,str-1  );  
+return 1;
+}
+
+
+addelkempcheck( q,p,ncol )
+int  q,p,ncol;
+{
+
+if(  p==2 && q>4 ){
+  fprintf(stderr,"This Addelman-Kempthorne OA(2q^2,ncol,q,2) is only\n");
+  fprintf(stderr,"available for odd prime powers q and for even prime\n");
+  fprintf(stderr,"powers q<=4.  q=%d is not available, but a Bose Bush\n",q);
+  fprintf(stderr,"construction exists for that design.\n");
+  return 0;
+}
+
+if(  ncol > 2*q+1  ){
+  fprintf(stderr,"The Addelman-Kempthorne construction needs ncol <= 2q+1.\n");
+  fprintf(stderr,"Can't have ncol = %d with q = %d,\n",ncol,q);
+  return 0;
+}
+
+if(  ncol == 2*q+1  ){
+  fprintf(stderr,"\nWarning: The Addelman-Kempthorne construction with ncol = 2q+1\n");
+  fprintf(stderr,"has a defect.  While it is still an OA(2q^2,2q+1,q,2),\n");
+  fprintf(stderr,"there exist some pairs of rows that agree in three columns.\n");
+  fprintf(stderr,"The final column in the array is involved in all of these\n");
+  fprintf(stderr,"triple coincidences.\n\n\n");
+}
+return 1;
+}
+
+
+addelkemp( gf, A, ncol )
+/* Implement Addelman and Kempthorne's 1961 A.M.S. method with n=2 */
+struct GF *gf;
+int    ncol, **A;
+{
+int i,j,m,p,q;
+int kay,*b,*c,*k;  /* A&K notation */
+int row, col, square, ksquare, temp;
+
+p=gf->p, q=gf->q;
+
+if(  !addelkempcheck( q,p,ncol )  )return 0;
+
+b = ivector( 0,q-1 );
+c = ivector( 0,q-1 );
+k = ivector( 0,q-1 );
+
+for(  i=0; i<q; i++  ){           /* First q*q rows */
+  square = gf->times[i][i];
+  for(  j=0; j<q; j++  ){
+    row = i*q+j;
+    col = 0;
+    if( col<ncol  )A[row][col++]=j;
+    for(  m=1; m<q && col<ncol; m++  )
+      A[row][col++] = gf->plus[i][gf->times[m][j]];
+    for(  m=0; m<q && col<ncol; m++  ){
+      temp = gf->plus[j][gf->times[m][i]];
+      A[row][col++] = gf->plus[temp][square]; /* Rgt cols */
+    }
+    if( col<ncol  )A[row][col++]=i;
+  }
+}
+
+if(  p !=2  )                    /* Constants kay,b,c,k for odd p */
+  akodd(  gf,&kay,b,c,k );
+else                             /* Constants kay,b,c,k for even p */
+  akeven( gf,&kay,b,c,k );
+
+for(  i=0; i<q; i++  ){           /* Second q*q rows */
+  square = gf->times[i][i];
+  ksquare = gf->times[kay][square];
+  for(  j=0; j<q; j++  ){
+    row = q*q+i*q+j;
+    col = 0;
+    if( col<ncol  )A[row][col++]=j;
+    for(  m=1; m<q && col<ncol; m++,col++  )
+      A[row][col] = gf->plus[A[row-q*q][col]][b[m]];
+    if( col<ncol  )A[row][col++] = gf->plus[ksquare][j]; /* q+1 */
+    for(  m=1; m<q && col<ncol; m++  ){
+      temp = gf->times[i][k[m]];
+      temp = gf->plus[ksquare][temp];
+      temp = gf->plus[j][temp];
+      A[row][col++] = gf->plus[temp][c[m]];
+    }
+    if( col<ncol  )A[row][col++]=i;
+  }
+}
+
+/*for(  i=0; i<2*q*q; i++  )
+for(  j=0; j<ncol; j++  )
+  printf("%3d%s",A[i][j],j==(ncol-1)?"\n":" ");
+*/
+
+return 1;
+}
+
+
+bosebushcheck( q,p,ncol  )
+int  q,p,ncol;
+{
+
+if(  p!=2  ){
+  fprintf(stderr,"This version of Bose and Bush needs q=2^n for some n.\n");
+  return 0;
+}
+
+if(  ncol > 2*q+1  ){
+  fprintf(stderr,"The Bose-Bush construction needs ncol <= 2q+1.\n");
+  fprintf(stderr,"Can't have ncol = %d with q = %d,\n",ncol,q);
+  return 0;
+}
+
+if(  ncol == 2*q+1  ){
+  fprintf(stderr,"\nWarning: The Bose-Bush construction with ncol = 2q+1\n");
+  fprintf(stderr,"has a defect.  While it is still an OA(2q^2,2q+1,q,2),\n");
+  fprintf(stderr,"there exist some pairs of rows that agree in three columns.\n\n\n");
+}
+return 1;
+}
+
+bosebush( gf, B, ncol )
+/* Implement Bose and Bush's 1952 A.M.S. method with p=2, u=1 */
+struct GF *gf;
+int **B;
+{
+int p,q,s,irow;
+int i,j,k,mul;
+int **A;
+
+p=gf->p,   /* GF(q) used to generate design with q/2 levels */
+q=gf->q;
+s=q/2;     /* number of levels in design */
+
+if(  !bosebushcheck( s,p,ncol )  )
+  return 0;
+
+A = imatrix(0,s-1,0,q-1);
+if(  !A  ){
+  fprintf(stderr,"Unable to allocate scratch space for Bose-Bush array.\n");
+  return 0;
+}
+
+irow = 0;
+for(  i=0; i<q; i++  ){
+  for(  j=0; j<q; j++  ){
+    mul = gf->times[i][j];
+    mul = mul % s;
+    for( k=0; k<s; k++  )
+/*      A[k][j] = gf->plus[mul][k];*/
+      A[k][j] = gf->plus[mul][k];
+  }
+  for(  k=0; k<s; k++  ){
+    for( j=0; j<ncol && j<2*s+1; j++ )
+      B[irow][j] = A[k][j];
+    if(  ncol==2*s+1  )
+      B[irow][ncol-1] = i%s;
+    irow++;
+  }
+}
+free_imatrix(A,0,s-1,0,q-1);
+return 1;
+}
+  
+  
+bosebushlcheck( s,p,lam,ncol  )
+int  s,p,lam,ncol;
+{
+
+if(  !isprime(p)  ){
+  fprintf(stderr,"Bose Bush routine given a nonprime.\n");
+  return 0;
+}
+
+if(  ncol > lam*s+1  ){
+  fprintf(stderr,"The Bose-Bush construction needs ncol <= lambda*q+1.\n");
+  fprintf(stderr,"Can't have ncol = %d with lam = %d and q = %d,\n",ncol,lam,s);
+  return 0;
+}
+
+if(  ncol == lam*s+1  ){
+  fprintf(stderr,"\nWarning: The Bose-Bush construction with ncol = lambda*q+1\n");
+  fprintf(stderr,"has a defect.  While it is still an OA(lambda*q^2,lambda*q+1,q,2),\n");
+  fprintf(stderr,"it may have worse coincidence properties than\n");
+  fprintf(stderr,"OA(lambda*q^2,lambda*q+1,q,2).\n");
+}
+return 1;
+}
+
+bosebushl( gf, lam, B, ncol )
+/* Implement Bose and Bush's 1952 A.M.S. method with given lambda */
+struct GF *gf;
+int **B, lam;
+{
+int p,q,s,irow;
+int i,j,k,mul;
+int **A;
+
+p=gf->p,   /* GF(q) used to generate design with q/lam levels */
+q=gf->q;
+s=q/lam;     /* number of levels in design */
+
+if(  !bosebushlcheck( s,p,lam,ncol )  )
+  return 0;
+
+A = imatrix(0,s-1,0,q-1);
+if(  !A  ){
+  fprintf(stderr,"Unable to allocate scratch space for Bose-Bush array.\n");
+  return 0;
+}
+
+irow = 0;
+for(  i=0; i<q; i++  ){
+  for(  j=0; j<q; j++  ){
+    mul = gf->times[i][j];
+    mul = mul % s;
+    for( k=0; k<s; k++  )
+/*      A[k][j] = gf->plus[mul][k];*/
+      A[k][j] = gf->plus[mul][k];
+  }
+  for(  k=0; k<s; k++  ){
+    for( j=0; j<ncol && j<lam*s+1; j++ )
+      B[irow][j] = A[k][j];
+    if(  ncol==lam*s+1  )
+      B[irow][ncol-1] = i%s;
+    irow++;
+  }
+}
+
+
+
+
+
+free_imatrix(A,0,s-1,0,q-1);
+return 1;
+}
+  
+  
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/galois.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/galois.c	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/galois.c	(revision 28162)
@@ -0,0 +1,264 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/**
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+/*     Manipulation of generic Galois fields.  See gfields.c
+   for construction of specific Galois fields.  */
+
+#include <math.h>
+#include <stdio.h>
+
+#include "galois.h"
+
+/* Fix for C99 */
+extern void free_ivector(int v, int nl, int nh); /* memory.c */
+extern void free_imatrix(int m, int nrl, int nrh, int ncl, int nch); /* memory.c */
+
+/*  Glossary:
+
+       GF_poly_sum       Addition in polynomial representation
+       GF_poly_prod      Multiplication in polynomial representation
+       GF_poly2int       Convert polynomial to integer in 0..q-1
+       GF_ready          Prepare (+,*,^-1) lookup tables
+       GF_print          Print Galois field
+       GF_free           Free storage
+
+*/
+
+
+/*---------------------------------------------------------------*/
+
+GF_poly_sum( p,n,p1,p2,sum )
+int  n,p,*p1,*p2,*sum;
+{
+int i;
+
+for(  i=0; i<n; i++  )
+  sum[i] = (p1[i]+p2[i]) % p;
+}
+
+/*---------------------------------------------------------------*/
+
+GF_poly_prod( p,n,xton,p1,p2,prod )
+/*
+  Set prod = p1*p2 with coefficients modulo p, and x^n replaced
+by polynomial xton.
+*/
+int  n,p,*xton,*p1,*p2,*prod;
+{
+int i,j, *longprod;
+
+longprod = ivector(0,2*n-2);
+
+for(  i=0; i<2*n-1; i++  )
+  longprod[i] = 0;
+for(  i=0; i<n; i++  )
+for(  j=0; j<n; j++  )
+  longprod[i+j] += p1[i]*p2[j];
+for(  i=2*n-2; i>n-1; i--  )
+for(  j=0; j<n; j++  )
+  longprod[i-n+j] += xton[j]*longprod[i];
+for(  i=0; i<n; i++  )
+  prod[i] = longprod[i] % p;
+
+free_ivector(longprod,0,2*n-2);
+}
+
+/*---------------------------------------------------------------*/
+
+int GF_poly2int( p,n,poly )
+
+int n,p,*poly;
+{
+int ans, i;
+
+ans = 0;
+for(  i=n-1; i>0; i--  )
+  ans = (ans+poly[i])*p;
+ans += poly[0];
+
+return ans;
+}
+
+/*---------------------------------------------------------------*/
+
+#define GFPUNT {fprintf(stderr,"Unable to allocate space for Galois field on %d elements.\n",q);return 0;}
+
+GF_ready( gf,p,n,xton )
+/* 
+   Make ready the Galois Field
+*/
+struct GF *gf;
+int  n,p,*xton;
+{
+int i,j,q,click,*poly;
+
+poly = ivector(0,n-1);
+
+gf->n = n;
+gf->p = p;
+q = 1;
+for(  i=0; i<n; i++  )
+  q *= p;
+gf->q = q;
+gf->xton = ivector(0,n-1);        if(  !gf->xton  )GFPUNT;
+for(  i=0; i<n; i++  )
+  gf->xton[i] = xton[i];
+gf->plus = imatrix(0,q-1,0,q-1);  if(  !gf->plus  )GFPUNT;
+gf->times= imatrix(0,q-1,0,q-1);  if(  !gf->times )GFPUNT;
+gf->inv  = ivector(0,q-1);        if(  !gf->inv   )GFPUNT;
+gf->neg  = ivector(0,q-1);        if(  !gf->neg   )GFPUNT;
+gf->root = ivector(0,q-1);        if(  !gf->root  )GFPUNT;
+gf->poly = imatrix(0,q-1,0,n-1);  if(  !gf->poly  )GFPUNT;
+
+for(  i=0; i<n; i++  )
+  gf->poly[0][i] = 0;
+
+for( i=1; i<q; i++  ){
+  for( click=0; gf->poly[i-1][click]==(p-1); click++  )
+    gf->poly[i][click] = 0;
+  gf->poly[i][click] = gf->poly[i-1][click]+1;
+  for(  j=click+1; j<n; j++  )
+    gf->poly[i][j] = gf->poly[i-1][j];
+}
+
+for(  i=0; i<q; i++  )
+for(  j=0; j<q; j++  ){
+  GF_poly_sum( p,n,gf->poly[i],gf->poly[j],poly );
+  gf->plus[i][j] = GF_poly2int( p,n,poly );
+  GF_poly_prod( p,n,xton,gf->poly[i],gf->poly[j],poly );
+  gf->times[i][j] = GF_poly2int( p,n,poly );
+}
+
+for(  i=0; i<q; i++  ){
+  gf->inv[i] = -1;
+  for(  j=0; j<q;  j++  )
+    if(  gf->times[i][j]==1  )
+      gf->inv[i] = j;
+  if(  i>0 && gf->inv[i] <= 0  ){
+    fprintf(stderr,"There is something wrong with the Galois field\n");
+    fprintf(stderr,"used for q=%d.  Element %d has no reciprocal.\n",q,i);
+    return 0;
+  }
+}
+
+for(  i=0; i<q; i++  ){
+  gf->neg[i] = -1;
+  for(  j=0; j<q;  j++  )
+    if(  gf->plus[i][j]==0  )
+      gf->neg[i] = j;
+  if(  i>0 && gf->neg[i] <= 0  ){
+    fprintf(stderr,"There is something wrong with the Galois field\n");
+    fprintf(stderr,"used for q=%d.  Element %d has no negative.\n",q,i);
+    return 0;
+  }
+}
+
+for(  i=0; i<q; i++  ){
+  gf->root[i] = -1;
+  for(  j=0; j<q;  j++  )
+    if(  gf->times[j][j]==i  )
+      gf->root[i] = j;
+}
+
+/*printf("%d %d %d\n",q,p,n);*/
+
+/* Added by J Cramp 07.02.04 to fix memory leak. */
+free_ivector(poly,0,n-1);
+
+return 1;
+}
+
+/*---------------------------------------------------------------*/
+
+GF_print( gf )
+
+struct GF *gf;
+{
+int i,j,n,p,q;
+
+n=gf->n, p=gf->p, q=gf->q;
+
+if( q>999 )fprintf(stderr,"Warning q=%d will overflow print field.\n",q);
+
+printf("\nFor GF(%d) p=%d n=%d\n",q,p,n);
+printf("x**n = (");
+for( i=0; i<n-1; i++  )
+  printf("%d,",gf->xton[i]);
+printf("%d)\n",gf->xton[n-1]);
+printf("\n\nGF(%d) Polynomial coefficients:\n",q);
+for(  i=0; i<q; i++  ){
+  printf("  %3d  ",i);
+  for(  j=0; j<n; j++  )
+    printf("%3d ",gf->poly[i][j]);
+  printf("\n");
+}
+printf("\n\nGF(%d) Addition Table\n",q);
+for(  i=0; i<q; i++  ){
+  printf("  ");
+  for(  j=0; j<q; j++  )
+    printf(" %3d",gf->plus[i][j]);
+  printf("\n");
+}
+printf("\n\nGF(%d) Multiplication table\n",q);
+for(  i=0; i<q; i++  ){
+  printf("  ");
+  for(  j=0; j<q; j++  )
+    printf(" %3d",gf->times[i][j]);
+  printf("\n");
+}
+printf("\n\nGF(%d) Reciprocals\n",q);
+for(  i=1; i<q; i++  )
+  printf(" %3d %3d\n",i,gf->inv[i]);
+
+printf("\n\nGF(%d) Negatives\n",q);
+for(  i=0; i<q; i++  )
+  printf(" %3d %3d\n",i,gf->neg[i]);
+
+printf("\n\nGF(%d) Square roots\n",q);
+for(  i=0; i<q; i++  )
+  printf(" %3d %3d\n",i,gf->root[i]);
+}
+
+/*---------------------------------------------------------------*/
+
+GF_free( gf )
+/* 
+   Deallocate the Galois Field
+*/
+struct GF *gf;
+{
+/*int q,p,n;
+q = gf->q, p=gf->p, n=gf->n;*/
+
+int q,n;
+q = gf->q, n=gf->n; /* Shuts lint up */
+
+free_imatrix(gf->poly,0,q-1,0,n-1);
+free_ivector(gf->root,0,q-1);
+free_ivector(gf->neg,0,q-1);
+free_ivector(gf->inv,0,q-1);
+free_imatrix(gf->times,0,q-1,0,q-1);
+free_imatrix(gf->plus,0,q-1,0,q-1);
+free_ivector(gf->xton,0,n-1);
+}
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/gfields.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/gfields.c	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/gfields.c	(revision 28162)
@@ -0,0 +1,120 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/*
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+/*     Construction of specific Galois fields.  See galois.c 
+    for manipulation of generic Galois fields.
+
+       To add a new Galois field GF(q)=GF(p^n) it is necessary 
+    to find the polynomial representation of x^n, and use it to
+    include another *xtn--- vector like those used below.
+
+*/
+
+#include <math.h>
+#include <stdio.h>
+
+#include "galois.h"
+
+/* Fix for C99 */
+extern int isprime(int p); /* primes.c */
+extern void primepow(int q, int *p, int *n, int *isit); /* primes.c */
+extern int GF_ready(struct GF *gf, int p, int n, int *xton); /* galois.c */
+
+/*  Glossary:
+
+       xtn2t2              Polynomial representation of x^2 in gf2t2
+       xtn2t3              Polynomial representation of x^3 in gf2t3
+       . . .               Polynomial representation of p^n in gfptn
+       xtn13t2             Polynomial representation of x^2 in gf13t2
+
+       GF_set_fields       Initialize polynomial representations
+       GF_fields_are_set   Indicates initialization done
+       GF_getfield         Construct and return GF(q) if possible
+*/
+
+#include "xtndeclare.h"
+int *xtnpt1;
+
+int GF_fields_are_set = 0;
+
+GF_set_fields()
+{
+/* Brute force set up of defining vectors, from Carmichael */
+
+/* Declare x-to-the-power-n vectors, for GFs p-to-the-n */
+
+if(   GF_fields_are_set   )
+  fprintf(stderr,"Warning: Fields being re-initialized.  Possible memory waste.\n");
+
+
+#include "xtnset.h"
+
+xtnpt1 = ivector(0,0);
+xtnpt1[0] = 0; 
+GF_fields_are_set = 1;
+}
+
+
+GF_getfield( q, gf )
+int q;
+struct GF *gf;
+{
+int *xtn;
+int p,n,ispp;
+
+if(  !GF_fields_are_set  )
+  GF_set_fields();
+
+if(  q<1  ){      /* Impossible argument */
+  fprintf(stderr,"Field must have positive number of elements.\n");
+  return 0; }
+if(  q==1 ){      /* Pointless  argument */
+  fprintf(stderr,"Field with 1 element was requested.\n");
+  return 0; }
+
+primepow( q,&p,&n,&ispp  );
+if(  !ispp  ){
+  fprintf(stderr,"q=%d is not a prime power.\n",q);
+  return 0; }
+
+xtn = NULL;
+
+#include "xtndispatch.h"
+
+if(  isprime(q)  )xtn = xtnpt1;  /* Could have tested p=q, or n=1 */
+
+if(  xtn   ){
+  if(  GF_ready( gf,p,n,xtn )  )
+    return 1;
+  else{
+    fprintf(stderr,"Construction failed for GF(%d).\n",q);
+    return 0;
+  }
+}
+else {
+  fprintf(stderr,"GF(%d) = GF(%d^%d) is not included in this program.\n",q,p,n);
+  fprintf(stderr,"To add it, consider modifying gfields.c.\n");
+  return 0;
+}
+}
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/oa.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/oa.c	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/DDACE/src/Bose/oa.c	(revision 28162)
@@ -0,0 +1,664 @@
+#if defined(HAVE_CONFIG_H) && !defined(DISABLE_DAKOTA_CONFIG_H)
+  #include "ddace_config.h"
+#endif
+/**
+
+  These programs construct and manipulate orthogonal 
+arrays.  They were prepared by
+
+    Art Owen
+    Department of Statistics
+    Sequoia Hall
+    Stanford CA 94305
+
+  They may be freely used and shared.  This code comes
+with no warranty of any kind.  Use it at your own
+risk.
+
+  I thank the Semiconductor Research Corporation and
+the National Science Foundation for supporting this
+work.
+
+*/
+
+
+#include <stdio.h>
+/* for exit: */
+#include <stdlib.h>
+
+#include "oa.h"
+  
+int  **imatrix(), *ivector();
+
+/* Fix for C99 */
+extern int grow_imatrix_byrows(int ***imat, int oldrowsize, int newrowsize, int colsize); /* memory.c */
+extern void free_ivector(int *v, int nl, int nh); /* memory.c */
+extern int ipow(int a, int b); /* primes.c */
+
+/**
+
+   Glossary:
+
+    OA_put            write OA to standard output
+    OA_fput           write OA to stream
+    OA_get            get OA from standard input
+    OA_fget           get OA from stream
+
+    OA_parsein        read arguments q,nrow,ncol to OA "filter programs"
+    OA_strworkcheck   warn about large work loads in strength checking programs
+
+*/
+
+
+/*  OUTPUT    OUTPUT    OUTPUT    OUTPUT    OUTPUT    OUTPUT    OUTPUT  */
+
+OA_fput( stream,A,n,k,q )
+FILE *stream;
+int **A, n, k, q;
+{
+int   i,j;
+char* format;
+
+format = "%d%s";
+if(  q < 1000  )format = "%3d%s";
+if(  q < 100   )format = "%2d%s";
+if(  q < 10    )format = "%1d%s";
+if(  q < 0     )format = "%d%s";
+
+for(  i=0; i<n; i++  )
+for(  j=0; j<k; j++  )
+  fprintf(stream,format,A[i][j],(j==k-1)?"\n":" ");
+}
+
+OA_put( A,n,k,q )
+int **A, n, k, q;
+{
+OA_fput( stdout,A,n,k,q );
+}
+
+/*  INPUT    INPUT    INPUT    INPUT    INPUT    INPUT    INPUT    INPUT  */
+
+OA_fget( stream,A,n,k,q,eof_assert )
+FILE *stream;
+int **A, n, k, q, eof_assert;
+{
+int   i,j;
+for( i=0; i<n; i++ )
+for( j=0; j<k; j++ )
+  if( fscanf(stream,"%d",&A[i][j]) == EOF  ){
+    fprintf(stderr,"Unexpected end of input encountered.  Wanted to read\n");
+    fprintf(stderr,"%d rows of %d cols.  Failed trying for row %d, col %d.\n",
+      n,k,i,j);
+    return 0;
+  }else if(  A[i][j] >= q ){
+    fprintf(stderr,"Invalid array element %d.  All elements should be\n",
+      A[i][j]);
+    fprintf(stderr,"strictly less than q = %d.\n",q);
+    return 0;
+  }else if(  A[i][j] <0   ){
+    fprintf(stderr,"Invalid array element %d, should be >= 0.\n",A[i][j]);
+    return 0;
+  }
+
+if(  eof_assert  &&  fscanf(stream,"%d",&eof_assert) != EOF  ){
+    fprintf(stderr,"Input has more integers than expected.\n");
+    fprintf(stderr,"Perhaps the number of rows and/or columns is incorrect.\n");
+    return 0;
+  }
+return 1;
+}
+
+OA_get( A,n,k,q, eof_assert )
+int **A, n, k, q, eof_assert;
+{
+return OA_fget( stdin,A,n,k,q,eof_assert );
+}
+
+/*  READ    READ    READ    READ    READ    READ    READ    READ    READ  */
+
+/*  Read array and determine dimensions.   Inspired by approach
+taken in Xgobi.  */
+
+#define MAXK 5000
+#define ROWINC 1000
+int line0[ MAXK ];
+
+OA_fread( stream,A,n,k,q )
+FILE *stream;
+int ***A, *n, *k, *q;
+{
+int   i, j;
+char  c;
+
+*k = 0;
+
+while( (c = getc(stream)) != '\n'  ){
+  if(  c=='\t' || c==' '  )
+    ;
+  else{
+    ungetc(c,stream);
+    if(  *k >= MAXK  ){
+      fprintf(stderr,"Error: Input appears to have more than %d columns.\n",*k);
+      fprintf(stderr,"If such large input is desired, increase MAXK in oa.c\n");
+      fprintf(stderr,"and re-install the software.\n");
+      return 0;
+    }
+    if(  fscanf(stream,"%d",&line0[(*k)++]) <= 0  ){
+      fprintf(stderr,"Error: no newline character found.  Could be empty\n");
+      fprintf(stderr,"input or matrix all on one line.\n");
+      return 0;
+    }
+  }
+}
+
+*A = imatrix( 0,ROWINC-1, 0,*k-1 );
+if(  !(*A)  ){
+  fprintf(stderr,"Unable to allocate memory to read the array.\n");
+  return 0;
+}
+
+*n = 0;
+for(  j=0; j<*k; j++  )
+  A[0][*n][j] = line0[j];
+
+while( 1 ){
+  (*n)++;
+  if(  (*n % ROWINC)==0  )
+    if(  !grow_imatrix_byrows( A, (*n), (*n)+ROWINC, *k )  ){
+      fprintf(stderr,"Unable to allocate extra memory for row %d of the array.\n"
+	      ,*n);
+      return 0;
+    }
+
+  if(  fscanf(stream,"%d",&(A[0][*n][0])) == EOF  )
+    break;
+
+  for(  j=1; j<*k; j++  )
+    if( fscanf(stream,"%d",&(A[0][*n][j])) == EOF  ){
+      fprintf(stderr,"Unexpected end of input encountered.  Row %d only has\n",*n);
+      fprintf(stderr,"%d elements of %d expected.\n",j,*k);
+      return 0;
+    }
+}
+*q = 0;                   /* Assume that q = max(A)+1  */
+
+for(  i=0; i<*n; i++  )
+for(  j=0; j<*k; j++  )
+  if(  A[0][i][j] > *q  )
+    *q = A[0][i][j];
+*q = *q +1;
+
+return 1;
+}
+
+OA_read( A,n,k,q )
+int ***A, *n, *k, *q;
+{
+return OA_fread( stdin,A,n,k,q );
+}
+
+/*  PARSE    PARSE    PARSE    PARSE    PARSE    PARSE    PARSE    PARSE  */
+
+OA_parsein( argc,argv, q,nrow,ncol, A )
+int  argc;
+char *argv[];
+int *q, *nrow, *ncol, ***A;
+{
+if(  argc<=1  ){
+  if(  !OA_read( A,nrow,ncol,q )  ){
+    fprintf(stderr,"Fatal error while reading the array.\n");
+    exit(1);
+  }
+}
+else if( argc==2  ){
+  sscanf(argv[1],"%d",q);
+  scanf("%d %d",nrow,ncol);
+}else if( argc==3  ){
+  sscanf(argv[1],"%d",q);
+  sscanf(argv[2],"%d",nrow);
+  scanf("%d",ncol);
+}else{
+  sscanf(argv[1],"%d",q);
+  sscanf(argv[2],"%d",nrow);
+  sscanf(argv[3],"%d",ncol);
+}
+
+if(  *q<1  ){
+  fprintf(stderr,"Array has only %d symbol(s).  At least one\n",*q);
+  fprintf(stderr,"symbol is necessary in an orthogonal array.\n");
+  exit(1);
+}
+
+if(  *ncol<1  ){
+  fprintf(stderr,"Array has only %d column(s).  At least one\n",*ncol);
+  fprintf(stderr,"column is necessary in an orthogonal array.\n");
+  exit(1);
+}
+
+if(  *nrow<1  ){
+  fprintf(stderr,"Array has only %d rows.  At least one\n",*nrow);
+  fprintf(stderr,"row is necessary in an orthogonal array.\n");
+  exit(1);
+}
+
+
+if(  argc >1  ){
+  *A = imatrix( 0,*nrow-1,0,*ncol-1 );
+  if(  !(*A)  ){
+    fprintf(stderr,"The array is too large (%d by %d) to fit in memory.\n",nrow,ncol);
+    exit(1);
+  }
+  
+  if(  !OA_get( *A,*nrow,*ncol,*q, 1 )  ){/* Read 'em all */
+    fprintf(stderr,"Read error getting the orthogonal array.\n");
+    exit(1);
+  }
+}
+}
+
+
+/*  WORK    WORK    WORK    WORK    WORK    WORK    WORK    WORK    WORK  */
+
+OA_strworkcheck( work,str )
+double work;
+int    str;
+{
+if(  work > BIGWORK  ){
+  fprintf(stderr,"If the array has strength %d, %g comparisons will\n",
+	  str, work);
+  fprintf(stderr,"be required to prove it.  This might take a long time.\n");
+  fprintf(stderr,"This warning is triggered when more than %d comparisons\n",
+	  BIGWORK);
+  fprintf(stderr,"are required.  To avoid this warning increase BIGWORK in\n");
+  fprintf(stderr,"oa.h.  Intermediate results will be printed.\n\n");
+  fflush(stderr);
+}else if(  work > MEDWORK  ){
+  fprintf(stderr,"Since more than %d comparisons may be required to\n",MEDWORK);
+  fprintf(stderr,"to check whether the array has strength %d, intermediate\n",
+	  str);
+  fprintf(stderr,"results will be printed.  To avoid this warning increase\n");
+  fprintf(stderr,"MEDWORK in oa.h\n\n");
+  fflush(stderr);
+}
+}
+
+
+/*  STRENGTH    STRENGTH    STRENGTH    STRENGTH    STRENGTH  */
+
+/* Check strength 0 */
+OA_str0( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1;
+
+for(  j1=0; j1<ncol; j1++  )
+for(  i=0; i<nrow; i++  )
+  if(  A[i][j1] < 0  || A[i][j1] >= q  ){
+    if(  verbose >= 2  ){
+      printf("Array is not even of strength 0, that is there are elements\n");
+      // BMA 20141204; added q-1 as argument to silence compiler warning
+      //printf("other than integers 0 through %d inclusive in it.\n");
+      printf("other than integers 0 through %d inclusive in it.\n", (q-1));
+      printf("The first exception is A[%d][%d] = %d.\n",i,j1,A[i][j1]);
+    }
+    return 0;
+  }
+if(  verbose >=2  )
+  printf("The array has strength (at least) 0.\n");
+return 1;
+}
+
+
+/* Check strength 1 */
+OA_str1( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int     i, j1, q1;
+int     lambda, count;
+double  work;
+
+if(  nrow%q  ){
+  if(  verbose >= 2  ){
+    printf("The array cannot have strength 1, because the number\n");
+    printf("of rows %d is not a multiple of q = %d.\n",nrow,q);
+  }
+  return 0;
+}
+
+lambda = nrow/q;
+work = nrow * ncol * q * 1.0;
+OA_strworkcheck( work,1 );
+for(  j1=0; j1<ncol; j1++  ){
+  for(  q1=0; q1<q; q1++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1);
+    if(  count != lambda   ){
+      if(  verbose >= 2  ){
+	printf("Array is not of strength 1.  The first violation arises for\n");
+	printf("the number of times A[,%d] = %d.\n",
+	       j1, q1);
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+  }
+if(  work > MEDWORK && verbose > 0  )
+  fprintf(stderr,"No violation of strength 1 involves column %d.\n",j1);
+}
+if(  verbose >=2  )
+  printf("The array has strength (at least) 1.\n");
+return 1;
+}
+
+/* Check strength 2  */
+OA_str2( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1,j2, q1,q2;
+int  lambda, count;
+double  work;
+
+if(  ncol<2  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least two\n",ncol);
+    fprintf(stderr,"columns are necessary for strength 2 to make sense.\n");
+  }
+  return 0;
+}
+if(  nrow % (q*q)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength 2, because the number\n");
+    fprintf(stderr,"of rows %d is not a multiple of q^2 = %d^2 = %d.\n",nrow,q,q*q);
+  }
+  return 0;
+}
+
+lambda = nrow/(q*q);
+work = nrow*ncol*(ncol-1.0)*q*q/2.0;
+OA_strworkcheck( work,2 );
+
+for(  j1=0;    j1<ncol; j1++  ){
+for(  j2=j1+1; j2<ncol; j2++  ){
+  for(  q1=0; q1<q; q1++  )
+  for(  q2=0; q2<q; q2++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1)&&(A[i][j2]==q2);
+    if(  count != lambda   ){
+      if(  verbose >= 2 ){
+	printf("Array is not of strength 2.  The first violation arises for\n");
+	printf("the number of times (A[,%d],A[,%d]) = (%d,%d).\n",
+	       j1,j2, q1,q2 );
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+  }
+}
+if(  work > MEDWORK && verbose > 0 )
+  fprintf(stderr,"No violation of strength 2 involves column %d.\n",j1);
+}
+
+if(  verbose >=2  )
+  printf("The array has strength (at least) 2.\n");
+return 1;
+}
+
+
+
+/* Check strength 3  */
+OA_str3( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1,j2,j3, q1,q2,q3;
+int  lambda, count;
+double  work;
+
+if(  ncol<3  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least three\n",ncol);
+    fprintf(stderr,"columns are necessary for strength 3 to make sense.\n");
+  }
+  return 0;
+}
+if(  nrow % (q*q*q)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength 3, because the number\n");
+    fprintf(stderr,"of rows %d is not a multiple of q^3 = %d^3 = %d.\n",nrow,q,q*q*q);
+  }
+  return 0;
+}
+
+lambda = nrow/(q*q*q);
+work = nrow*ncol*(ncol-1.0)*(ncol-2.0)*q*q*q/6.0;
+OA_strworkcheck( work,3 );
+
+for(  j1=0;    j1<ncol; j1++  ){
+for(  j2=j1+1; j2<ncol; j2++  )
+for(  j3=j2+1; j3<ncol; j3++  ){
+  for(  q1=0; q1<q; q1++  )
+  for(  q2=0; q2<q; q2++  )
+  for(  q3=0; q3<q; q3++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1)&&(A[i][j2]==q2)&&(A[i][j3]==q3);
+    if(  count != lambda   ){
+      if(  verbose >= 2 ){
+	printf("Array is not of strength 3.  The first violation arises for\n");
+	printf("the number of times (A[,%d],A[,%d],A[,%d]) = (%d,%d,%d).\n",
+	       j1,j2,j3,  q1,q2,q3 );
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+  }
+}
+if(  work > MEDWORK && verbose > 0 )
+  fprintf(stderr,"No violation of strength 3 involves column %d.\n",j1);
+}
+if(  verbose >=2  )
+  printf("The array has strength (at least) 3.\n");
+return 1;
+}
+
+
+/* Check strength 4  */
+OA_str4( q,nrow,ncol,A,verbose   )
+int      q,nrow,ncol,**A, verbose;
+{
+int  i, j1,j2,j3,j4, q1,q2,q3,q4;
+int  lambda, count;
+double  work;
+
+if(  ncol<4  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least four\n",ncol);
+    fprintf(stderr,"columns are necessary for strength 4 to make sense.\n");
+  }
+  return 0;
+}
+if(  nrow % (q*q*q*q)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength 4, because the number\n");
+    fprintf(stderr,"of rows %d is not a multiple of q^4 = %d^4 = %d.\n",nrow,q,q*q*q*q);
+  }
+  return 0;
+}
+
+lambda = nrow/(q*q*q*q);
+work = nrow*ncol*(ncol-1.0)*(ncol-2.0)*(ncol-3.0)*q*q*q*q/24.0;
+OA_strworkcheck( work,4 );
+
+for(  j1=0;    j1<ncol; j1++  ){
+for(  j2=j1+1; j2<ncol; j2++  )
+for(  j3=j2+1; j3<ncol; j3++  )
+for(  j4=j3+1; j4<ncol; j4++  ){
+  for(  q1=0; q1<q; q1++  )
+  for(  q2=0; q2<q; q2++  )
+  for(  q3=0; q3<q; q3++  )
+  for(  q4=0; q4<q; q4++  ){
+    count = 0;
+    for( i=0; i<nrow; i++  )
+      count += (A[i][j1]==q1)&&(A[i][j2]==q2)&&(A[i][j3]==q3)&&(A[i][j4]==q4);
+    if(  count != lambda  ){
+      if(  verbose >= 2  ){
+	printf("Array is not of strength 4.  The first violation arises for\n");
+	printf("the number of times (A[,%d],A[,%d],A[,%d],A[,%d]) = (%d,%d,%d,%d).\n",
+	       j1,j2,j3,j4, q1,q2,q3,q4 );
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+    }
+  }
+}
+if(  work > MEDWORK && verbose > 0 )
+  fprintf(stderr,"No violation of strength 4 involves column %d.\n",j1);
+
+if(  verbose >=2  )
+  printf("The array has strength (at least) 4.\n");
+return 1;
+}
+
+
+/* Check strength t  */
+OA_strt( q,nrow,ncol,A,t,verbose   )
+int      q,nrow,ncol,**A,t,verbose;
+{
+int  row, i, ic, iq, *clist, *qlist, ctuples, qtuples;
+int  lambda, count, match;
+double  work;
+
+if(  t<0  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Don't know how to verify strength %d.  It doesn't\n",t);
+    fprintf(stderr,"make sense.\n");
+  }
+  return 0;
+}
+if(  ncol<t  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"Array has only %d column(s).  At least %d\n",ncol,t);
+    fprintf(stderr,"columns are necessary for strength %d to make sense.\n",t);
+  }
+  return 0;
+}
+if(  t==0  )
+  return OA_str0( q,nrow,ncol,A,verbose );
+if(  nrow % ipow(q,t)  ){
+  if(  verbose > 0 ){
+    fprintf(stderr,"The array cannot have strength %d, because the number\n",t);
+    fprintf(stderr,"of rows %d is not a multiple of q^%d = %d^%d = %d.\n",
+	    nrow,t,q,t,ipow(q,t));
+  }
+  return 0;
+}
+
+lambda = nrow/ipow(q,t);
+work   = nrow*ipow(q,t);
+ctuples = 1;
+
+clist = ivector( 0,t-1 );
+qlist = ivector( 0,t-1 );
+
+for(  i=0; i<t; i++  ){
+  work *= (ncol-i)/(i+1.0);
+  ctuples *= ncol-i;
+  qlist[i] = 0;
+  clist[i] = i;
+}
+for(  i=0; i<t; i++  )
+  ctuples /= (i+1);
+qtuples = ipow(q,t);
+
+OA_strworkcheck( work,t );
+
+for(  ic=0; ic<ctuples; ic++  ){   /* Loop over ordered tuples of columns */
+/*  for( i=0; i<t; i++  )
+    printf("%s %d%s",(i==0)?"Col":"",clist[i],(i==t-1)?"\n":" ");*/
+
+  for(  iq=0; iq<qtuples;   iq++  ){ /* Loop over unordered tuples of symbols */
+/*    for( i=0; i<t; i++  )
+      printf("  %s %d%s",(i==0)?"Sym":"",qlist[i],(i==t-1)?"\n":" ");*/
+    count = 0;
+    for( row=0; row<nrow; row++  ){
+      match = 1;
+      for(  i=0; i<t && match; i++  )
+	match *= A[row][clist[i]] == qlist[i];
+      count += match;
+    }
+    if(  count != lambda  ){
+      if(  verbose >= 2  ){
+	printf("Array is not of strength %d.  The first violation arises for\n",t);
+	printf("the number of times (");
+	for(  i=0; i<t; i++  )
+	  printf("A[,%d]%s",clist[i],(i==t-1)?")":",");
+	printf(" = (");
+	for(  i=0; i<t; i++  )
+	  printf("%d%s",qlist[i],(i==t-1)?").\n":",");
+	printf("This happened in %d rows, it should have happened in %d rows.\n",
+	       count, lambda);
+      }
+      return 0;
+    }
+    for( i=t-1; i>=0; i--  ){
+      qlist[i] = (qlist[i]+1) % q;
+      if(  qlist[i]  )break;
+    }
+  }
+
+  for( i= t-1; i>=0; i--  ){
+    clist[i] = (clist[i]+1) % (ncol+i-t+1);
+    if(  clist[i]  )break;
+  }
+
+  if(  work > MEDWORK && verbose > 0 && (t==1||t>1 && clist[1]==0)  )
+    fprintf(stderr,"No violation of strength %d involves column %d.\n",
+	    t,(clist[0]+ncol-1)%ncol);
+
+  for( i=1; i< t; i++  )
+    if(  clist[i] <= clist[i-1]  )
+      clist[i] = clist[i-1]+1;
+}
+
+if(  verbose >=2  )
+  printf("The array has strength (at least) %d.\n",t);
+
+/* Added by J Cramp on 07.02.04 to
+ * fix memory leak problems. */
+free_ivector(clist,0,t-1);
+free_ivector(qlist,0,t-1);
+
+return 1;
+}
+
+void OA_strength( q,nrow,ncol,A,str,verbose )
+int  q,nrow,ncol,**A,*str, verbose;
+/*
+     Calculate and return the strength of the array A.
+
+verbose = 0   =>   No printed output
+verbose = 1   =>   Only stderr output
+verbose = 2   =>   Output to both stdout and stderr
+
+*/
+{
+*str = -1;
+
+if(  OA_str0( q,nrow,ncol,A,verbose)   )
+  *str = 0;
+else
+  return;
+if(  OA_str1( q,nrow,ncol,A,verbose)   )
+  *str = 1;
+else
+  return;
+while( OA_strt( q,nrow,ncol,A,*str+1,verbose )  )
+  (*str)++;
+return;
+}
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/nidr/nidr-scanner.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/nidr/nidr-scanner.c	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/nidr/nidr-scanner.c	(revision 28162)
@@ -0,0 +1,2063 @@
+/* A lexical scanner generated by flex*/
+
+/* Scanner skeleton version:
+ * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define nidrconst const
+#else
+#define nidrconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN nidr_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((nidr_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE nidrrestart( nidrin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct nidr_buffer_state *YY_BUFFER_STATE;
+
+extern int nidrleng;
+extern FILE *nidrin, *nidrout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ * 	if ( condition_holds )
+ *		nidrless( 5 );
+ *	else
+ *		do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the nidrless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define nidrless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up nidrtext. */ \
+		*nidr_cp = nidr_hold_char; \
+		YY_RESTORE_YY_MORE_OFFSET \
+		nidr_c_buf_p = nidr_cp = nidr_bp + n - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up nidrtext again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) nidrunput( c, nidrtext_ptr )
+
+/* Some routines like nidr_flex_realloc() are emitted as static but are
+   not called by all lexers. This generates warnings in some compilers,
+   notably GCC. Arrange to suppress these. */
+#ifdef __GNUC__
+#define YY_MAY_BE_UNUSED __attribute__((unused))
+#else
+#define YY_MAY_BE_UNUSED
+#endif
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int nidr_size_t;
+
+
+struct nidr_buffer_state
+	{
+	FILE *nidr_input_file;
+
+	char *nidr_ch_buf;		/* input buffer */
+	char *nidr_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	nidr_size_t nidr_buf_size;
+
+	/* Number of characters read into nidr_ch_buf, not including EOB
+	 * characters.
+	 */
+	int nidr_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int nidr_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int nidr_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int nidr_at_bol;
+
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int nidr_fill_buffer;
+
+	int nidr_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via nidrrestart()), so that the user can continue scanning by
+	 * just pointing nidrin at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+	};
+
+static YY_BUFFER_STATE nidr_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER nidr_current_buffer
+
+
+/* nidr_hold_char holds the character lost when nidrtext is formed. */
+static char nidr_hold_char;
+
+static int nidr_n_chars;		/* number of characters read into nidr_ch_buf */
+
+
+int nidrleng;
+
+/* Points to current character in buffer. */
+static char *nidr_c_buf_p = (char *) 0;
+static int nidr_init = 1;		/* whether we need to initialize */
+static int nidr_start = 0;	/* start state number */
+
+/* Flag which is used to allow nidrwrap()'s to do buffer switches
+ * instead of setting up a fresh nidrin.  A bit of a hack ...
+ */
+static int nidr_did_buffer_switch_on_eof;
+
+void nidrrestart YY_PROTO(( FILE *input_file ));
+
+void nidr_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void nidr_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE nidr_create_buffer YY_PROTO(( FILE *file, int size ));
+void nidr_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void nidr_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void nidr_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER nidr_flush_buffer( nidr_current_buffer )
+
+YY_BUFFER_STATE nidr_scan_buffer YY_PROTO(( char *base, nidr_size_t size ));
+YY_BUFFER_STATE nidr_scan_string YY_PROTO(( nidrconst char *nidr_str ));
+YY_BUFFER_STATE nidr_scan_bytes YY_PROTO(( nidrconst char *bytes, int len ));
+
+static void *nidr_flex_alloc YY_PROTO(( nidr_size_t ));
+static void *nidr_flex_realloc YY_PROTO(( void *, nidr_size_t )) YY_MAY_BE_UNUSED;
+static void nidr_flex_free YY_PROTO(( void * ));
+
+#define nidr_new_buffer nidr_create_buffer
+
+#define nidr_set_interactive(is_interactive) \
+	{ \
+	if ( ! nidr_current_buffer ) \
+		nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE ); \
+	nidr_current_buffer->nidr_is_interactive = is_interactive; \
+	}
+
+#define nidr_set_bol(at_bol) \
+	{ \
+	if ( ! nidr_current_buffer ) \
+		nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE ); \
+	nidr_current_buffer->nidr_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (nidr_current_buffer->nidr_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *nidrin = (FILE *) 0, *nidrout = (FILE *) 0;
+typedef int nidr_state_type;
+extern char *nidrtext;
+#define nidrtext_ptr nidrtext
+
+static nidr_state_type nidr_get_previous_state YY_PROTO(( void ));
+static nidr_state_type nidr_try_NUL_trans YY_PROTO(( nidr_state_type current_state ));
+static int nidr_get_next_buffer YY_PROTO(( void ));
+static void nidr_fatal_error YY_PROTO(( nidrconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up nidrtext.
+ */
+#define YY_DO_BEFORE_ACTION \
+	nidrtext_ptr = nidr_bp; \
+	nidrtext_ptr -= nidr_more_len; \
+	nidrleng = (int) (nidr_cp - nidrtext_ptr); \
+	nidr_hold_char = *nidr_cp; \
+	*nidr_cp = '\0'; \
+	nidr_c_buf_p = nidr_cp;
+
+#define YY_NUM_RULES 27
+#define YY_END_OF_BUFFER 28
+static nidrconst short int nidr_accept[125] =
+    {   0,
+        0,    0,    0,    0,   21,   21,   18,   18,   28,    6,
+        5,    2,   25,    4,    3,    3,    6,   16,   12,    2,
+       15,   25,   13,   26,   16,    8,   16,    9,   14,    7,
+       11,   11,   11,   16,   21,   21,   22,   22,   21,   21,
+       18,   18,   19,   18,   19,   18,    5,   25,    0,   25,
+       25,    4,   24,    3,    3,    0,   23,   12,    8,    7,
+        0,    9,    0,    0,   10,    9,    9,    9,    7,   11,
+       11,   11,   21,   21,   21,   21,   20,   21,   21,   21,
+       18,   18,   18,   18,   18,   18,   17,   18,   24,    3,
+        0,    0,   10,   10,    9,   10,    9,    9,   10,   10,
+
+       10,   21,   18,    1,   10,   10,   10,   10,   10,    9,
+       10,   11,    0,   10,   10,   11,    0,   11,    0,   11,
+        0,   10,   10,    0
+    } ;
+
+static nidrconst int nidr_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    2,    1,    4,    5,    1,    1,    1,    6,    1,
+        1,    7,    8,    9,   10,   11,    1,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,    7,   13,    1,
+       14,    1,    1,   15,   16,   17,   17,   17,   18,   19,
+       17,   17,   20,   17,   17,   17,   17,   21,   17,   17,
+       17,   17,   17,   22,   17,   17,   17,   23,   24,   17,
+        1,   25,    1,    1,   26,    1,   16,   17,   17,   17,
+
+       18,   19,   17,   17,   20,   17,   17,   17,   17,   21,
+       17,   17,   17,   17,   17,   22,   17,   17,   17,   23,
+       24,   17,    1,    1,    1,   15,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static nidrconst int nidr_meta[27] =
+    {   0,
+        1,    1,    2,    3,    1,    4,    1,    5,    1,    6,
+        6,    6,    1,    1,    7,    6,    6,    6,    6,    6,
+        6,    6,    6,    6,    1,    6
+    } ;
+
+static nidrconst short int nidr_base[137] =
+    {   0,
+        0,    0,   26,    0,   51,   75,   99,  123,  263,  264,
+       56,  264,   57,  264,    0,  239,   57,  264,  147,  264,
+      264,  236,  264,  264,  162,  264,  248,   53,  264,  257,
+        0,  237,  241,   64,    0,   67,  264,  252,   59,   71,
+        0,   81,  264,   62,  249,   86,   88,  229,   92,  228,
+       86,  227,  249,    0,  230,   94,  264,    0,  264,  247,
+      236,   96,  226,  230,   91,  233,   98,  107,  242,    0,
+      224,  212,    0,  116,  108,  120,  264,  126,  226,  129,
+        0,  132,  114,  133,  121,  224,  264,  140,  217,  191,
+      193,  178,  169,  150,  168,  126,  155,  167,  166,  157,
+
+        0,  174,  173,    0,  151,  264,  158,  157,  156,  147,
+      143,  133,  132,  138,  135,  125,  120,   76,   63,   51,
+       33,    0,  264,  264,  183,  190,  197,  199,  202,  203,
+      210,  217,  224,  231,  234,  236
+    } ;
+
+static nidrconst short int nidr_def[137] =
+    {   0,
+      124,    1,  124,    3,  125,  125,  126,  126,  124,  124,
+      124,  124,  127,  124,  128,  128,  124,  124,  124,  124,
+      124,  127,  124,  124,  124,  124,  124,  129,  124,  124,
+      130,  130,  130,  124,  131,  131,  124,  124,  132,  131,
+      133,  133,  124,  134,  124,  133,  124,  127,  124,  127,
+      127,  127,  124,  128,  128,  124,  124,   19,  124,  124,
+      124,  129,  124,  124,  135,  129,  136,  129,  124,  130,
+      130,  130,  131,  131,  132,  131,  124,  132,  131,  131,
+      133,  133,  134,  133,  134,  133,  124,  133,  124,  128,
+      124,  124,  135,  135,  136,  135,  136,  129,  135,  130,
+
+      130,  131,  133,  128,  124,  124,  135,  135,  135,  136,
+      135,  130,  124,  135,  135,  130,  124,  130,  124,  130,
+      124,  130,  124,    0,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124
+    } ;
+
+static nidrconst short int nidr_nxt[291] =
+    {   0,
+       10,   11,   12,   10,   13,   10,   10,   10,   10,   10,
+       10,   10,   14,   10,   10,   15,   15,   16,   15,   15,
+       15,   15,   15,   15,   17,   10,   18,   19,   20,   21,
+       22,   23,   24,   25,   26,   25,   27,   28,   29,   30,
+       18,   31,   31,   31,   31,   32,   33,   31,   31,   31,
+       34,   18,   36,   37,   38,   39,  123,   47,   56,   57,
+       48,   51,   50,   67,   62,   56,   57,   50,   74,   52,
+       68,   75,   80,   57,  122,   40,   36,   37,   38,   39,
+       49,   53,   82,   79,  121,   83,   86,   88,   57,   47,
+       51,   76,   48,   56,   57,   56,   57,  120,   52,   40,
+
+       42,   43,   65,   44,   45,   84,   67,   62,   94,   96,
+       53,   50,   49,   68,   98,   97,   98,   74,   99,   50,
+       75,   80,   57,   46,   42,   43,   50,   44,   45,   50,
+       80,   57,   79,   82,   88,   57,   83,   96,   86,  119,
+       76,   88,   57,  109,  118,   86,  115,   46,   58,  115,
+       79,   48,  117,  116,  111,   59,   84,  107,  111,  107,
+       60,  108,  110,  114,  110,  114,  111,  115,  108,  108,
+      113,   49,   61,   62,  103,  102,  112,   99,   99,  124,
+      124,   63,   64,   35,   35,   35,   35,   35,   35,   35,
+       41,   41,   41,   41,   41,   41,   41,   50,  106,   50,
+
+       50,   50,   50,   50,   54,   54,   66,   66,   70,   70,
+       73,  105,  104,   73,   73,   73,   73,   78,   89,   78,
+       78,   78,   78,   78,   81,  103,   81,  102,   81,   81,
+       81,   85,  101,   85,   85,   85,   85,   85,   93,   93,
+       95,   95,  100,   69,  124,   92,   91,   65,   69,   90,
+       89,   53,   53,   53,   87,   77,   72,   71,   69,   65,
+       53,   55,  124,    9,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124
+    } ;
+
+static nidrconst short int nidr_chk[291] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    5,    5,    5,    5,  121,   11,   17,   17,
+       11,   13,   39,   28,   28,   34,   34,   44,   36,   13,
+       28,   36,   40,   40,  120,    5,    6,    6,    6,    6,
+       11,   13,   42,   39,  119,   42,   44,   46,   46,   47,
+       51,   36,   47,   49,   49,   56,   56,  118,   51,    6,
+
+        7,    7,   65,    7,    7,   42,   62,   62,   65,   67,
+       51,   75,   47,   62,   68,   67,   68,   74,   68,   83,
+       74,   76,   76,    7,    8,    8,   85,    8,    8,   78,
+       80,   80,   75,   82,   84,   84,   82,   96,   83,  117,
+       74,   88,   88,   96,  116,   85,  115,    8,   19,  114,
+       78,   19,  113,  112,  111,   19,   82,   94,  110,   94,
+       19,   94,   97,  109,   97,  109,   97,  109,  108,  107,
+      105,   19,   25,   25,  103,  102,  100,   99,   98,   95,
+       93,   25,   25,  125,  125,  125,  125,  125,  125,  125,
+      126,  126,  126,  126,  126,  126,  126,  127,   92,  127,
+
+      127,  127,  127,  127,  128,  128,  129,  129,  130,  130,
+      131,   91,   90,  131,  131,  131,  131,  132,   89,  132,
+      132,  132,  132,  132,  133,   86,  133,   79,  133,  133,
+      133,  134,   72,  134,  134,  134,  134,  134,  135,  135,
+      136,  136,   71,   69,   66,   64,   63,   61,   60,   55,
+       53,   52,   50,   48,   45,   38,   33,   32,   30,   27,
+       22,   16,    9,  124,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
+      124,  124,  124,  124,  124,  124,  124,  124,  124,  124
+    } ;
+
+static nidr_state_type nidr_last_accepting_state;
+static char *nidr_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+static int nidr_more_flag = 0;
+static int nidr_more_len = 0;
+#define nidrmore() (nidr_more_flag = 1)
+#define YY_MORE_ADJ nidr_more_len
+#define YY_RESTORE_YY_MORE_OFFSET
+char *nidrtext;
+/* #line 1 "nidrscan.l" */
+#define INITIAL 0
+/* #line 2 "nidrscan.l" */
+/*********************************************************************
+Copyright 2008, 2010 Sandia Corporation.  Under the terms of Contract
+DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
+retains certain rights in this software.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+* Neither the name of Sandia Corporation nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#ifndef NIDR_H
+#include "nidr.h"
+#endif
+#ifndef NIDR_PARSER_H
+#include "nidr-parser.h"
+#endif
+#include <stdlib.h>	/* possibly redundant, but necessary for strtod on some systems */
+
+static int my_nidr_input(char*, int);
+extern char *nidr_KWscopy(const char*);
+
+#ifdef IDR_DEBUG
+static void print_token( char*, char*, char* );
+#else
+#define print_token(a,b,c) /*nothing*/
+#endif
+
+
+#define YY_INPUT(buf,result,maxsize) result = my_nidr_input(buf,maxsize)
+
+int	nidrLineNumber = 1;
+
+extern void	nidr_abort(void);
+extern void	(*nidr_comment)(const char*);
+extern KeyWord *(*nidr_identifier)(const char*);
+extern KeyWord *nidr_keyword(const char*);
+extern const char *nidr_keyword_name(void);
+/* Hardwire the now rarely used help text.  It truly is something the
+   application should provide, not NIDR, but had trouble with the
+   declaration/definition w.r.t. MSVS when building DAKOTA source.
+   Ultimately would want to pass it into nidr_parse(...) 
+extern char	nidr_please_refer[];
+*/
+char nidr_please_refer[] = 
+  "Please refer to the input specification reference for this application.";
+extern void	nidr_tolower(char*);
+static void	bad_number(const char*);
+static void	unput_string(char *, int);
+#define DATA 1
+
+#define DQ_STRING 2
+
+#define Q_STRING 3
+
+/* #line 545 "nidr-scanner.c" */
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int nidrwrap YY_PROTO(( void ));
+#else
+extern int nidrwrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void nidrunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef nidrtext_ptr
+static void nidr_flex_strncpy YY_PROTO(( char *, nidrconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int nidr_flex_strlen YY_PROTO(( nidrconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int nidrinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int nidr_start_stack_ptr = 0;
+static int nidr_start_stack_depth = 0;
+static int *nidr_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void nidr_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void nidr_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int nidr_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( nidrtext, nidrleng, 1, nidrout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+	if ( nidr_current_buffer->nidr_is_interactive ) \
+		{ \
+		int c = '*', n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( nidrin )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( nidrin ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else if ( ((result = fread( buf, 1, max_size, nidrin )) == 0) \
+		  && ferror( nidrin ) ) \
+		YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "nidrterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef nidrterminate
+#define nidrterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) nidr_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int nidrlex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after nidrtext and nidrleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+	YY_USER_ACTION
+
+YY_DECL
+	{
+	register nidr_state_type nidr_current_state;
+	register char *nidr_cp = NULL, *nidr_bp = NULL;
+	register int nidr_act;
+
+/* #line 85 "nidrscan.l" */
+
+
+
+	KeyWord	*identifier, *keyword;
+	char *se;
+
+
+/* #line 704 "nidr-scanner.c" */
+
+	if ( nidr_init )
+		{
+		nidr_init = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! nidr_start )
+			nidr_start = 1;	/* first start state */
+
+		if ( ! nidrin )
+			nidrin = stdin;
+
+		if ( ! nidrout )
+			nidrout = stdout;
+
+		if ( ! nidr_current_buffer )
+			nidr_current_buffer =
+				nidr_create_buffer( nidrin, YY_BUF_SIZE );
+
+		nidr_load_buffer_state();
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+		nidr_more_len = 0;
+		if ( nidr_more_flag )
+			{
+			nidr_more_len = nidr_c_buf_p - nidrtext_ptr;
+			nidr_more_flag = 0;
+			}
+		nidr_cp = nidr_c_buf_p;
+
+		/* Support of nidrtext. */
+		*nidr_cp = nidr_hold_char;
+
+		/* nidr_bp points to the position in nidr_ch_buf of the start of
+		 * the current run.
+		 */
+		nidr_bp = nidr_cp;
+
+		nidr_current_state = nidr_start;
+nidr_match:
+		do
+			{
+			register YY_CHAR nidr_c = nidr_ec[YY_SC_TO_UI(*nidr_cp)];
+			if ( nidr_accept[nidr_current_state] )
+				{
+				nidr_last_accepting_state = nidr_current_state;
+				nidr_last_accepting_cpos = nidr_cp;
+				}
+			while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
+				{
+				nidr_current_state = (int) nidr_def[nidr_current_state];
+				if ( nidr_current_state >= 125 )
+					nidr_c = nidr_meta[(unsigned int) nidr_c];
+				}
+			nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
+			++nidr_cp;
+			}
+		while ( nidr_base[nidr_current_state] != 264 );
+
+nidr_find_action:
+		nidr_act = nidr_accept[nidr_current_state];
+		if ( nidr_act == 0 )
+			{ /* have to back up */
+			nidr_cp = nidr_last_accepting_cpos;
+			nidr_current_state = nidr_last_accepting_state;
+			nidr_act = nidr_accept[nidr_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+
+do_action:	/* This label is used only to access EOF actions. */
+
+
+		switch ( nidr_act )
+	{ /* beginning of action switch */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*nidr_cp = nidr_hold_char;
+			nidr_cp = nidr_last_accepting_cpos;
+			nidr_current_state = nidr_last_accepting_state;
+			goto nidr_find_action;
+
+case 1:
+YY_RULE_SETUP
+/* #line 92 "nidrscan.l" */
+{
+			print_token("exit", NULL, "<INITIAL>" );
+			return 0;
+			}
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+/* #line 97 "nidrscan.l" */
+{
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			nidrLineNumber++;
+			}
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+/* #line 103 "nidrscan.l" */
+{
+			nidr_tolower(nidrtext);
+			keyword = nidr_keyword(nidrtext);
+
+			if  (keyword) {
+				print_token( "keyword", (char*) nidrtext, "<INITIAL>" );
+				if (keyword->kind & KWKind_Dynmult)
+					return END;
+				nidrlval.keyword = keyword;
+				BEGIN DATA;
+				return KEY_WORD;
+				}
+			print_token( "error", (char*) nidrtext, "<INITIAL>" );
+			nidrlval.string = nidrtext;
+			return KEYWORDERROR;
+			}
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+/* #line 120 "nidrscan.l" */
+{
+			if (*nidrtext == '#') {
+				if (nidr_comment)
+					nidr_comment(nidrtext);
+				}
+			else {
+				print_token( "end", NULL, "<INITIAL>" );
+				return END;
+				}
+			}
+	YY_BREAK
+case 5:
+YY_RULE_SETUP
+/* #line 131 "nidrscan.l" */
+{ print_token( "whitespace", (char*) nidrtext, "<INITIAL>" ); }
+	YY_BREAK
+case 6:
+YY_RULE_SETUP
+/* #line 133 "nidrscan.l" */
+{
+			print_token( "word", (char*) nidrtext, "<INITIAL>" );
+			nidrlval.string = nidr_KWscopy(nidrtext);
+			return STRING;
+			}
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+/* #line 138 "nidrscan.l" */
+{
+			print_token( "equals", NULL, "<DATA>" );
+			return EQUALS;
+			}
+	YY_BREAK
+case 8:
+YY_RULE_SETUP
+/* #line 142 "nidrscan.l" */
+{
+			print_token( "separator", NULL, "<DATA>" );
+			return SEPARATOR;
+			}
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+/* #line 146 "nidrscan.l" */
+{
+			print_token( "integer", (char*) nidrtext, "<DATA>" );
+			/* The following, old way has trouble with */
+			/* big floating-point numbers written without */
+			/* a decimal point */
+			/* nidrlval.integer = (int) atoi( (char*) nidrtext ); */
+			/* return INTEGER; */
+			nidrlval.real = strtod(nidrtext,&se);
+			if (*se)
+				bad_number(nidrtext);
+			return REAL;
+			}
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+/* #line 158 "nidrscan.l" */
+{
+			print_token( "real", (char*) nidrtext, "<DATA>" );
+			nidrlval.real = strtod(nidrtext,&se);
+			if (*se)
+				bad_number(nidrtext);
+			return REAL;
+			}
+	YY_BREAK
+case 11:
+YY_RULE_SETUP
+/* #line 165 "nidrscan.l" */
+{
+			nidr_tolower(nidrtext);
+			if (nidr_keyword(nidrtext)) {
+				unput_string(nidrtext, nidrleng);
+				BEGIN INITIAL;
+				return END;
+				}
+			identifier = nidr_identifier(nidrtext);
+
+			if (identifier) {
+				print_token( "identifier", (char*) nidrtext, "<DATA>");
+
+				nidrlval.identifier = identifier;
+				return IDENTIFIER;
+				}
+			else {
+				print_token( "word", (char*) nidrtext, "<DATA>" );
+				fprintf(stderr,"\n\tunrecognized identifier '%s'\n", nidrtext);
+				fprintf(stderr,"\tinput line %d, within %s keyword.\n",
+						nidrLineNumber, nidr_keyword_name());
+				fprintf(stderr, "%s\n", nidr_please_refer);
+				nidr_abort();
+				nidrlval.string = nidr_KWscopy(nidrtext);
+				return STRING;
+				}
+			}
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+/* #line 192 "nidrscan.l" */
+{ print_token( "whitespace", (char*) nidrtext, "<DATA>" ); }
+	YY_BREAK
+case 13:
+YY_RULE_SETUP
+/* #line 194 "nidrscan.l" */
+{
+			print_token( "opening quote", NULL, "<DATA>" );
+			BEGIN Q_STRING;
+			}
+	YY_BREAK
+case 14:
+YY_RULE_SETUP
+/* #line 198 "nidrscan.l" */
+{
+			print_token( "end", NULL, "<DATA>" );
+			BEGIN INITIAL;
+			return END;
+			}
+	YY_BREAK
+case 15:
+YY_RULE_SETUP
+/* #line 203 "nidrscan.l" */
+{
+			print_token( "double quote", NULL, "<DATA>" );
+			BEGIN DQ_STRING;
+			}
+	YY_BREAK
+case 16:
+YY_RULE_SETUP
+/* #line 207 "nidrscan.l" */
+{
+			print_token( "word", (char*) nidrtext, "<DATA>" );
+			fprintf(stderr, "Input line %d:  '%s' unexpected.\n",
+				nidrLineNumber, nidrtext);
+			nidr_abort();
+			nidrlval.string = nidr_KWscopy(nidrtext);
+			return STRING;
+			}
+	YY_BREAK
+case 17:
+YY_RULE_SETUP
+/* #line 215 "nidrscan.l" */
+{
+			print_token( "q:repeated quote", NULL, "<Q_STRING>" );
+			nidrtext[--nidrleng] = 0;
+			nidrmore();
+			}
+	YY_BREAK
+case 18:
+YY_RULE_SETUP
+/* #line 220 "nidrscan.l" */
+{
+			nidrmore();
+			print_token( "q:text", (char*) nidrtext, "<Q_STRING>" );
+			}
+	YY_BREAK
+case 19:
+YY_RULE_SETUP
+/* #line 224 "nidrscan.l" */
+{
+			print_token( "closing quote", NULL, "<Q_STRING>" );
+			if (nidrtext[--nidrleng] == '\n')
+				unput('\n');
+			nidrtext[nidrleng] = 0;
+			print_token( "quoted string", (char*) nidrtext, "<Q_STRING>" );
+			nidrlval.qstring = nidr_KWscopy(nidrtext);
+			BEGIN DATA;
+			return QUOTED_STRING;
+			}
+	YY_BREAK
+case 20:
+YY_RULE_SETUP
+/* #line 234 "nidrscan.l" */
+{
+			print_token( "q:repeated double quote", NULL, "<DQ_STRING>" );
+			nidrtext[--nidrleng] = 0;
+			nidrmore();
+			}
+	YY_BREAK
+case 21:
+YY_RULE_SETUP
+/* #line 239 "nidrscan.l" */
+{
+			nidrmore();
+			print_token( "q:text", (char*) nidrtext, "<DQ_STRING>" );
+			}
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
+/* #line 243 "nidrscan.l" */
+{
+			print_token( "closing double quote", NULL, "<DQ_STRING>" );
+			if (nidrtext[--nidrleng] == '\n')
+				unput('\n');
+			nidrtext[nidrleng] = 0;
+			print_token( "quoted string", (char*) nidrtext, "<DQ_STRING>" );
+			nidrlval.qstring = nidr_KWscopy(nidrtext);
+			BEGIN DATA;
+			return QUOTED_STRING;
+			}
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+/* #line 253 "nidrscan.l" */
+{
+			print_token( "newline", NULL, NULL );
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			nidrLineNumber++;
+			}
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+/* #line 259 "nidrscan.l" */
+{
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			print_token( "comment - escaped newline", (char*) nidrtext, "<INITIAL>" );
+			unput( '\\' );
+			}
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+/* #line 265 "nidrscan.l" */
+{
+			if (nidr_comment)
+				nidr_comment(nidrtext);
+			print_token( "comment", (char*) nidrtext, "<INITIAL>" );
+			}
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+/* #line 270 "nidrscan.l" */
+{ return nidrtext[0]; }
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+/* #line 272 "nidrscan.l" */
+ECHO;
+	YY_BREAK
+/* #line 1074 "nidr-scanner.c" */
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(DATA):
+case YY_STATE_EOF(DQ_STRING):
+case YY_STATE_EOF(Q_STRING):
+	nidrterminate();
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int nidr_amount_of_matched_text = (int) (nidr_cp - nidrtext_ptr) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*nidr_cp = nidr_hold_char;
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( nidr_current_buffer->nidr_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed nidrin at a new source and called
+			 * nidrlex().  If so, then we have to assure
+			 * consistency between nidr_current_buffer and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			nidr_n_chars = nidr_current_buffer->nidr_n_chars;
+			nidr_current_buffer->nidr_input_file = nidrin;
+			nidr_current_buffer->nidr_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for nidr_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since nidr_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( nidr_c_buf_p <= &nidr_current_buffer->nidr_ch_buf[nidr_n_chars] )
+			{ /* This was really a NUL. */
+			nidr_state_type nidr_next_state;
+
+			nidr_c_buf_p = nidrtext_ptr + nidr_amount_of_matched_text;
+
+			nidr_current_state = nidr_get_previous_state();
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * nidr_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			nidr_next_state = nidr_try_NUL_trans( nidr_current_state );
+
+			nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
+
+			if ( nidr_next_state )
+				{
+				/* Consume the NUL. */
+				nidr_cp = ++nidr_c_buf_p;
+				nidr_current_state = nidr_next_state;
+				goto nidr_match;
+				}
+
+			else
+				{
+				nidr_cp = nidr_c_buf_p;
+				goto nidr_find_action;
+				}
+			}
+
+		else switch ( nidr_get_next_buffer() )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				nidr_did_buffer_switch_on_eof = 0;
+
+				if ( nidrwrap() )
+					{
+					/* Note: because we've taken care in
+					 * nidr_get_next_buffer() to have set up
+					 * nidrtext, we can now set up
+					 * nidr_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					nidr_c_buf_p = nidrtext_ptr + YY_MORE_ADJ;
+
+					nidr_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! nidr_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				nidr_c_buf_p =
+					nidrtext_ptr + nidr_amount_of_matched_text;
+
+				nidr_current_state = nidr_get_previous_state();
+
+				nidr_cp = nidr_c_buf_p;
+				nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
+				goto nidr_match;
+
+			case EOB_ACT_LAST_MATCH:
+				nidr_c_buf_p =
+				&nidr_current_buffer->nidr_ch_buf[nidr_n_chars];
+
+				nidr_current_state = nidr_get_previous_state();
+
+				nidr_cp = nidr_c_buf_p;
+				nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
+				goto nidr_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of nidrlex */
+
+
+/* nidr_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int nidr_get_next_buffer()
+	{
+	register char *dest = nidr_current_buffer->nidr_ch_buf;
+	register char *source = nidrtext_ptr;
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( nidr_c_buf_p > &nidr_current_buffer->nidr_ch_buf[nidr_n_chars + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( nidr_current_buffer->nidr_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( nidr_c_buf_p - nidrtext_ptr - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) (nidr_c_buf_p - nidrtext_ptr) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( nidr_current_buffer->nidr_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		nidr_current_buffer->nidr_n_chars = nidr_n_chars = 0;
+
+	else
+		{
+		int num_to_read =
+			nidr_current_buffer->nidr_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+			YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = nidr_current_buffer;
+
+			int nidr_c_buf_p_offset =
+				(int) (nidr_c_buf_p - b->nidr_ch_buf);
+
+			if ( b->nidr_is_our_buffer )
+				{
+				int new_size = b->nidr_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->nidr_buf_size += b->nidr_buf_size / 8;
+				else
+					b->nidr_buf_size *= 2;
+
+				b->nidr_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					nidr_flex_realloc( (void *) b->nidr_ch_buf,
+							 b->nidr_buf_size + 2 );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->nidr_ch_buf = 0;
+
+			if ( ! b->nidr_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			nidr_c_buf_p = &b->nidr_ch_buf[nidr_c_buf_p_offset];
+
+			num_to_read = nidr_current_buffer->nidr_buf_size -
+						number_to_move - 1;
+#endif
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&nidr_current_buffer->nidr_ch_buf[number_to_move]),
+			nidr_n_chars, num_to_read );
+
+		nidr_current_buffer->nidr_n_chars = nidr_n_chars;
+		}
+
+	if ( nidr_n_chars == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			nidrrestart( nidrin );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			nidr_current_buffer->nidr_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	nidr_n_chars += number_to_move;
+	nidr_current_buffer->nidr_ch_buf[nidr_n_chars] = YY_END_OF_BUFFER_CHAR;
+	nidr_current_buffer->nidr_ch_buf[nidr_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+	nidrtext_ptr = &nidr_current_buffer->nidr_ch_buf[0];
+
+	return ret_val;
+	}
+
+
+/* nidr_get_previous_state - get the state just before the EOB char was reached */
+
+static nidr_state_type nidr_get_previous_state()
+	{
+	register nidr_state_type nidr_current_state;
+	register char *nidr_cp;
+
+	nidr_current_state = nidr_start;
+
+	for ( nidr_cp = nidrtext_ptr + YY_MORE_ADJ; nidr_cp < nidr_c_buf_p; ++nidr_cp )
+		{
+		register YY_CHAR nidr_c = (*nidr_cp ? nidr_ec[YY_SC_TO_UI(*nidr_cp)] : 1);
+		if ( nidr_accept[nidr_current_state] )
+			{
+			nidr_last_accepting_state = nidr_current_state;
+			nidr_last_accepting_cpos = nidr_cp;
+			}
+		while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
+			{
+			nidr_current_state = (int) nidr_def[nidr_current_state];
+			if ( nidr_current_state >= 125 )
+				nidr_c = nidr_meta[(unsigned int) nidr_c];
+			}
+		nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
+		}
+
+	return nidr_current_state;
+	}
+
+
+/* nidr_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = nidr_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static nidr_state_type nidr_try_NUL_trans( nidr_state_type nidr_current_state )
+#else
+static nidr_state_type nidr_try_NUL_trans( nidr_current_state )
+nidr_state_type nidr_current_state;
+#endif
+	{
+	register int nidr_is_jam;
+	register char *nidr_cp = nidr_c_buf_p;
+
+	register YY_CHAR nidr_c = 1;
+	if ( nidr_accept[nidr_current_state] )
+		{
+		nidr_last_accepting_state = nidr_current_state;
+		nidr_last_accepting_cpos = nidr_cp;
+		}
+	while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
+		{
+		nidr_current_state = (int) nidr_def[nidr_current_state];
+		if ( nidr_current_state >= 125 )
+			nidr_c = nidr_meta[(unsigned int) nidr_c];
+		}
+	nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
+	nidr_is_jam = (nidr_current_state == 124);
+
+	return nidr_is_jam ? 0 : nidr_current_state;
+	}
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void nidrunput( int c, register char *nidr_bp )
+#else
+static void nidrunput( c, nidr_bp )
+int c;
+register char *nidr_bp;
+#endif
+	{
+	register char *nidr_cp = nidr_c_buf_p;
+
+	/* undo effects of setting up nidrtext */
+	*nidr_cp = nidr_hold_char;
+
+	if ( nidr_cp < nidr_current_buffer->nidr_ch_buf + 2 )
+		{ /* need to shift things up to make room */
+		/* +2 for EOB chars. */
+		register int number_to_move = nidr_n_chars + 2;
+		register char *dest = &nidr_current_buffer->nidr_ch_buf[
+					nidr_current_buffer->nidr_buf_size + 2];
+		register char *source =
+				&nidr_current_buffer->nidr_ch_buf[number_to_move];
+
+		while ( source > nidr_current_buffer->nidr_ch_buf )
+			*--dest = *--source;
+
+		nidr_cp += (int) (dest - source);
+		nidr_bp += (int) (dest - source);
+		nidr_current_buffer->nidr_n_chars =
+			nidr_n_chars = nidr_current_buffer->nidr_buf_size;
+
+		if ( nidr_cp < nidr_current_buffer->nidr_ch_buf + 2 )
+			YY_FATAL_ERROR( "flex scanner push-back overflow" );
+		}
+
+	*--nidr_cp = (char) c;
+
+
+	nidrtext_ptr = nidr_bp;
+	nidr_hold_char = *nidr_cp;
+	nidr_c_buf_p = nidr_cp;
+	}
+#endif	/* ifndef YY_NO_UNPUT */
+
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int nidrinput()
+#else
+static int input()
+#endif
+	{
+	int c;
+
+	*nidr_c_buf_p = nidr_hold_char;
+
+	if ( *nidr_c_buf_p == YY_END_OF_BUFFER_CHAR )
+		{
+		/* nidr_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( nidr_c_buf_p < &nidr_current_buffer->nidr_ch_buf[nidr_n_chars] )
+			/* This was really a NUL. */
+			*nidr_c_buf_p = '\0';
+
+		else
+			{ /* need more input */
+			int offset = nidr_c_buf_p - nidrtext_ptr;
+			++nidr_c_buf_p;
+
+			switch ( nidr_get_next_buffer() )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because nidr_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					nidrrestart( nidrin );
+
+					/* fall through */
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( nidrwrap() )
+						return EOF;
+
+					if ( ! nidr_did_buffer_switch_on_eof )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return nidrinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					nidr_c_buf_p = nidrtext_ptr + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) nidr_c_buf_p;	/* cast for 8-bit char's */
+	*nidr_c_buf_p = '\0';	/* preserve nidrtext */
+	nidr_hold_char = *++nidr_c_buf_p;
+
+
+	return c;
+	}
+#endif /* YY_NO_INPUT */
+
+#ifdef YY_USE_PROTOS
+void nidrrestart( FILE *input_file )
+#else
+void nidrrestart( input_file )
+FILE *input_file;
+#endif
+	{
+	if ( ! nidr_current_buffer )
+		nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE );
+
+	nidr_init_buffer( nidr_current_buffer, input_file );
+	nidr_load_buffer_state();
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void nidr_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+	{
+	if ( nidr_current_buffer == new_buffer )
+		return;
+
+	if ( nidr_current_buffer )
+		{
+		/* Flush out information for old buffer. */
+		*nidr_c_buf_p = nidr_hold_char;
+		nidr_current_buffer->nidr_buf_pos = nidr_c_buf_p;
+		nidr_current_buffer->nidr_n_chars = nidr_n_chars;
+		}
+
+	nidr_current_buffer = new_buffer;
+	nidr_load_buffer_state();
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (nidrwrap()) processing, but the only time this flag
+	 * is looked at is after nidrwrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	nidr_did_buffer_switch_on_eof = 1;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_load_buffer_state( void )
+#else
+void nidr_load_buffer_state()
+#endif
+	{
+	nidr_n_chars = nidr_current_buffer->nidr_n_chars;
+	nidrtext_ptr = nidr_c_buf_p = nidr_current_buffer->nidr_buf_pos;
+	nidrin = nidr_current_buffer->nidr_input_file;
+	nidr_hold_char = *nidr_c_buf_p;
+	}
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE nidr_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	b = (YY_BUFFER_STATE) nidr_flex_alloc( sizeof( struct nidr_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_create_buffer()" );
+
+	b->nidr_buf_size = size;
+
+	/* nidr_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->nidr_ch_buf = (char *) nidr_flex_alloc( b->nidr_buf_size + 2 );
+	if ( ! b->nidr_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_create_buffer()" );
+
+	b->nidr_is_our_buffer = 1;
+
+	nidr_init_buffer( b, file );
+
+	return b;
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_delete_buffer( YY_BUFFER_STATE b )
+#else
+void nidr_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+	{
+	if ( ! b )
+		return;
+
+	if ( b == nidr_current_buffer )
+		nidr_current_buffer = (YY_BUFFER_STATE) 0;
+
+	if ( b->nidr_is_our_buffer )
+		nidr_flex_free( (void *) b->nidr_ch_buf );
+
+	nidr_flex_free( (void *) b );
+	}
+
+/* Fix for C99 */
+#ifndef __cplusplus
+extern int isatty(int);
+#endif /* __cplusplus */
+
+#ifdef YY_USE_PROTOS
+void nidr_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void nidr_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+	{
+	nidr_flush_buffer( b );
+
+	b->nidr_input_file = file;
+	b->nidr_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+	b->nidr_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+	b->nidr_is_interactive = 0;
+#else
+	b->nidr_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+	}
+
+
+#ifdef YY_USE_PROTOS
+void nidr_flush_buffer( YY_BUFFER_STATE b )
+#else
+void nidr_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+	{
+	if ( ! b )
+		return;
+
+	b->nidr_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->nidr_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->nidr_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->nidr_buf_pos = &b->nidr_ch_buf[0];
+
+	b->nidr_at_bol = 1;
+	b->nidr_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == nidr_current_buffer )
+		nidr_load_buffer_state();
+	}
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_scan_buffer( char *base, nidr_size_t size )
+#else
+YY_BUFFER_STATE nidr_scan_buffer( base, size )
+char *base;
+nidr_size_t size;
+#endif
+	{
+	YY_BUFFER_STATE b;
+
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) nidr_flex_alloc( sizeof( struct nidr_buffer_state ) );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_scan_buffer()" );
+
+	b->nidr_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->nidr_buf_pos = b->nidr_ch_buf = base;
+	b->nidr_is_our_buffer = 0;
+	b->nidr_input_file = 0;
+	b->nidr_n_chars = b->nidr_buf_size;
+	b->nidr_is_interactive = 0;
+	b->nidr_at_bol = 1;
+	b->nidr_fill_buffer = 0;
+	b->nidr_buffer_status = YY_BUFFER_NEW;
+
+	nidr_switch_to_buffer( b );
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_scan_string( nidrconst char *nidr_str )
+#else
+YY_BUFFER_STATE nidr_scan_string( nidr_str )
+nidrconst char *nidr_str;
+#endif
+	{
+	int len;
+	for ( len = 0; nidr_str[len]; ++len )
+		;
+
+	return nidr_scan_bytes( nidr_str, len );
+	}
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE nidr_scan_bytes( nidrconst char *bytes, int len )
+#else
+YY_BUFFER_STATE nidr_scan_bytes( bytes, len )
+nidrconst char *bytes;
+int len;
+#endif
+	{
+	YY_BUFFER_STATE b;
+	char *buf;
+	nidr_size_t n;
+	int i;
+
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) nidr_flex_alloc( n );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in nidr_scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = nidr_scan_buffer( buf, n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in nidr_scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->nidr_is_our_buffer = 1;
+
+	return b;
+	}
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void nidr_push_state( int new_state )
+#else
+static void nidr_push_state( new_state )
+int new_state;
+#endif
+	{
+	if ( nidr_start_stack_ptr >= nidr_start_stack_depth )
+		{
+		nidr_size_t new_size;
+
+		nidr_start_stack_depth += YY_START_STACK_INCR;
+		new_size = nidr_start_stack_depth * sizeof( int );
+
+		if ( ! nidr_start_stack )
+			nidr_start_stack = (int *) nidr_flex_alloc( new_size );
+
+		else
+			nidr_start_stack = (int *) nidr_flex_realloc(
+					(void *) nidr_start_stack, new_size );
+
+		if ( ! nidr_start_stack )
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
+		}
+
+	nidr_start_stack[nidr_start_stack_ptr++] = YY_START;
+
+	BEGIN(new_state);
+	}
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void nidr_pop_state()
+	{
+	if ( --nidr_start_stack_ptr < 0 )
+		YY_FATAL_ERROR( "start-condition stack underflow" );
+
+	BEGIN(nidr_start_stack[nidr_start_stack_ptr]);
+	}
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int nidr_top_state()
+	{
+	return nidr_start_stack[nidr_start_stack_ptr - 1];
+	}
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void nidr_fatal_error( nidrconst char msg[] )
+#else
+static void nidr_fatal_error( msg )
+char msg[];
+#endif
+	{
+	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+	}
+
+
+
+/* Redefine nidrless() so it works in section 3 code. */
+
+#undef nidrless
+#define nidrless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up nidrtext. */ \
+		nidrtext[nidrleng] = nidr_hold_char; \
+		nidr_c_buf_p = nidrtext + n; \
+		nidr_hold_char = *nidr_c_buf_p; \
+		*nidr_c_buf_p = '\0'; \
+		nidrleng = n; \
+		} \
+	while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef nidrtext_ptr
+#ifdef YY_USE_PROTOS
+static void nidr_flex_strncpy( char *s1, nidrconst char *s2, int n )
+#else
+static void nidr_flex_strncpy( s1, s2, n )
+char *s1;
+nidrconst char *s2;
+int n;
+#endif
+	{
+	register int i;
+	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+	}
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int nidr_flex_strlen( nidrconst char *s )
+#else
+static int nidr_flex_strlen( s )
+nidrconst char *s;
+#endif
+	{
+	register int n;
+	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+	}
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *nidr_flex_alloc( nidr_size_t size )
+#else
+static void *nidr_flex_alloc( size )
+nidr_size_t size;
+#endif
+	{
+	return (void *) malloc( size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void *nidr_flex_realloc( void *ptr, nidr_size_t size )
+#else
+static void *nidr_flex_realloc( ptr, size )
+void *ptr;
+nidr_size_t size;
+#endif
+	{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+	}
+
+#ifdef YY_USE_PROTOS
+static void nidr_flex_free( void *ptr )
+#else
+static void nidr_flex_free( ptr )
+void *ptr;
+#endif
+	{
+	free( ptr );
+	}
+
+#if YY_MAIN
+int main()
+	{
+	nidrlex();
+	return 0;
+	}
+#endif
+/* #line 272 "nidrscan.l" */
+
+
+ static int nidr_ateof = 0;
+ static const char *nidr_instring = 0;
+
+ void
+bad_number(const char *s)
+{
+	fprintf(stderr, "\n*** Invalid number \"%s\" on input line %d within "
+			"%s keyword.\n", s, nidrLineNumber, nidr_keyword_name());
+	nidr_abort();
+	}
+
+ void
+nidr_set_input_string(const char *s)
+{
+	nidr_instring = s;
+	}
+
+ static int
+my_nidr_input(char *buf, int bmax)
+{
+	int c, n;
+
+	if (nidr_ateof)
+		return 0;
+	n = 0;
+	if (nidr_instring) {
+		while(n < bmax && (c = *nidr_instring)) {
+			++nidr_instring;
+			if (c != '\r')
+				buf[n++] = c;
+			if (c == '\n')
+				break;
+			}
+		}
+	else if (nidr_current_buffer->nidr_is_interactive)
+		while(n < bmax) {
+		if ((c = getc(nidrin)) == EOF)
+			break;
+		if (c != '\r')
+			buf[n++] = c;
+		if (c == '\n')
+			break;
+		}
+	else
+		while(n < bmax) {
+		if ((c = getc(nidrin)) == EOF)
+			break;
+		if (c != '\r')
+			buf[n++] = c;
+		}
+	if (n <= 0) {
+		nidr_ateof = n = 1;
+		if (c == EOF) {
+			fclose(nidrin);
+			nidrin = NULL;
+			}
+		buf[0] = ';';
+		}
+	return n;
+	}
+
+ void
+reset_nidrlex_state(void)
+{
+	BEGIN INITIAL;
+	nidr_abort();
+	}
+
+ void
+unput_string(char *s, int len)
+{
+	while(--len >= 0)
+		unput(s[len]);
+	}
+
+ void
+nidr_reinit(void)
+{
+	nidr_init = 1;
+	nidr_ateof = 0;
+	if (nidr_current_buffer) {
+		free(nidr_current_buffer->nidr_ch_buf);
+		free(nidr_current_buffer);
+		nidr_current_buffer = 0;
+		}
+	}
+
+ int
+nidrwrap(void)
+{ return 1; }
Index: /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/nidr/nidr.c
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/nidr/nidr.c	(revision 28162)
+++ /issm/trunk-jpl/externalpackages/dakota/configs/6.2/static/packages/nidr/nidr.c	(revision 28162)
@@ -0,0 +1,2427 @@
+/*********************************************************************
+Copyright 2008, 2010 Sandia Corporation.  Under the terms of Contract
+DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
+retains certain rights in this software.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+* Neither the name of Sandia Corporation nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+/* nidr.c */
+
+#ifndef NIDR_H	/* for $DAKOTA/src/nidr.c */
+#include "nidr.h"
+#endif
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "avltree.h"
+
+#ifndef NIDR_SQUAWKMAX
+#define NIDR_SQUAWKMAX 10
+#endif
+
+#ifndef NO_NIDR_DYNLIB /*{*/
+typedef KeyWord *(*KW_ADD)(void);
+static KeyWord *kwfind(const char *, KeyWord *, int, int *);
+static KeyWord *toomany(const char *, KeyWord *, int);
+#ifdef _WIN32 /*{{*/
+#include <windows.h>
+#define dlopen(x,y) LoadLibrary(x)
+#define find_dlsym(a,b,c) (a = (KW_ADD)GetProcAddress((HINSTANCE)(b),c))
+#define dlclose(x) FreeLibrary((HMODULE)x)
+#define NO_DLERROR
+#else /*}{*/
+#include <dlfcn.h>
+#include <unistd.h>
+#define find_dlsym(a,b,c) (a = (KW_ADD)dlsym(b,c))
+#undef NO_DLERROR
+#endif /*}}*/
+#endif /*}*/
+
+ extern KeyWord Dakota_Keyword_Top;
+ extern int nidrLineNumber;
+ static KeyWord* Keyword_Top = &Dakota_Keyword_Top;
+ static void *KW_g;
+ void (*nidr_comment)(const char*);
+ static void nidr_keyword_finish(void);
+ static Comment *OutsideComment;
+ static void kw_finish2(void), kw_finish3(void);
+ static void kw_setup1(KeyWord *);
+ static FILE *dumpfile;
+ static KeyWord **ToClear, **ToClear0, **ToClearEnd;
+ static int dumplev, nsquawk, nparse_errors, primary, strict;
+
+ int NIDR_disallow_missing_start = 1;
+
+ enum {n_KWStack0 = 64};
+
+ static KWinfo KWStack0[n_KWStack0];
+
+ static Uint n_KWStack = n_KWStack0;
+
+ static KeyWord *curid, *curkw;
+ static KWinfo	*KWStack = KWStack0,
+		*KWStackBot = KWStack0,
+		*KWStackEnd = KWStack0 + n_KWStack0;
+
+ static Values KWval, KWvalmax;
+ static Real *KWvalbuf;
+ static Uint nKWvalbuf;
+
+ typedef struct Sbuf Sbuf;
+ enum { n_KWsbuf = 8192 };
+ struct Sbuf {
+	char buf[n_KWsbuf];
+	Sbuf *next;
+	};
+
+ typedef struct KWseen KWseen;
+
+ struct
+KWseen {
+	const char *name;
+	KeyWord *kw;
+	KWseen *mnext, *mprev;	/* for identifiers so far unrequited when kw == 0 */
+				/* kw != 0 ==> mprev = first child, and mnext = next sibling */
+	KWseen *parent;
+	KWseen **lcn;		/* &mprev field of last child; lcn == 0 when this */
+				/* keyword was entered into the AVL tree because */
+				/* its parent was seen. */
+	Comment *comment;
+	char **svals;
+	Real *rvals;
+	size_t nvals;
+	};
+
+ static KWseen *KW_cur;
+ NIDR_KWlib *NIDR_Libs;
+
+ void
+nidr_lib_cleanup(void)
+{
+	KeyWord *kw;
+	NIDR_KWlib *L, *L1;
+
+	L1 = NIDR_Libs;
+	NIDR_Libs = 0;
+	while((L = L1)) {
+		if (L->oldtop)
+			Keyword_Top = L->oldtop;
+		if ((kw = L->kw0)) {
+			kw->f.vs = 0;
+			kw->kind &= ~KWKind_Loaded;
+			}
+#ifndef NO_NIDR_DYNLIB /*{{*/
+		dlclose(L->h);
+#else  /*}{*/
+		/* botch("dlclose is NOT SUPPORTED for current configuration"); */
+		fprintf(stderr, "\ndlclose is NOT SUPPORTED for current configuration");
+#endif /*}}*/
+		L1 = L->next;
+		free(L);
+		}
+	}
+
+ static Sbuf KWsbuf0, *KWsbuf = &KWsbuf0;
+ static char *KWsbuf1 = KWsbuf0.buf, *KWsbufe = KWsbuf0.buf + n_KWsbuf;
+ static KWseen *curkws;
+ static const char *valkind[3] = {"integer","numeric","string"};
+
+ int
+nidr_parse_error(void)
+{
+	int n;
+	if ((n = nsquawk - NIDR_SQUAWKMAX) > 0)
+		fprintf(stderr, "\n%d error message%s suppressed.\n",
+			n, "s" + (n == 1));
+	return nsquawk + nparse_errors;
+	}
+
+ void
+nidr_signal_parse_error(void)
+{ ++nparse_errors; }
+
+ void
+nidr_tolower(char *s)
+{
+	for(; *s; ++s)
+		*s = tolower(*s);
+	}
+
+ static void
+botch(const char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	fprintf(stderr, "\nBotch:  ");
+	vfprintf(stderr, fmt, ap);
+	fputs(".\n", stderr);
+	va_end(ap);
+	exit(1);
+	}
+
+ static void
+squawk(const char *fmt, ...)
+{
+	va_list ap;
+	if (++nsquawk <= NIDR_SQUAWKMAX) {
+		fprintf(stderr, "Input line %d: ", nidrLineNumber);
+		va_start(ap, fmt);
+		vfprintf(stderr, fmt, ap);
+		fputs(".\n", stderr);
+		va_end(ap);
+		}
+	}
+
+#ifdef NIDR_MALLOC_DEBUG
+ typedef struct MallocDebug MallocDebug;
+ struct MallocDebug
+{
+	MallocDebug *next, *prev;
+	char *where;
+	int nalloc;
+	};
+
+ static MallocDebug MDtop = {&MDtop, &MDtop, 0, 0};
+ int MallocDebugCount, MallocDebugCount1;
+
+ static void*
+Alloc(const char *where, size_t len)
+{
+	MallocDebug *md = malloc(len + sizeof(MallocDebug));
+	if (!md) {
+		fprintf(stderr, "malloc(%lu) failure in %s\n", (unsigned long)len, where);
+		exit(1);
+		}
+	(md->next = MDtop.next)->prev = md;
+	(md->prev = &MDtop)->next = md;
+	md->where = where;
+	if ((md->nalloc = ++MallocDebugCount) == MallocDebugCount1)
+		printf("Hit %d\n", md->nalloc);
+	return (void*)(md + 1);
+	}
+
+ static void
+MallocDebugFree(void *v)
+{
+	MallocDebug *md = (MallocDebug *)v - 1;
+	md->next->prev = md->prev;
+	md->prev->next = md->next;
+	free(md);
+	}
+#define free MallocDebugFree
+
+#else //!NIDR_MALLOC_DEBUG
+ static void*
+Alloc(const char *where, size_t len)
+{
+	void *rv = malloc(len);
+	if (!rv) {
+		fprintf(stderr, "malloc(%lu) failure in %s\n", (unsigned long)len, where);
+		exit(1);
+		}
+	return rv;
+	}
+#endif //NIDR_MALLOC_DEBUG
+
+ const char *
+nidr_basename(const char *p)
+{
+	const char *b;
+
+#ifdef _WIN32
+	if (p[0] && p[1] == ':')
+		p += 2;
+	else if (p[0] == '\\' && p[1] == '\\')
+		for(p += 2; *p; )
+			switch(*p++) {
+			 case '/':
+			 case '\\':
+				goto break2;
+			}
+ break2:
+#endif
+	b = p;
+	while(*p)
+		switch(*p++) {
+		 case '/':
+#ifdef _WIN32
+		 case '\\':
+#endif
+			b = p;
+		}
+	return b;
+	}
+
+ const char *nidr_exedir;
+ int nidr_exedir_len = -1; /* allow resetting to -1 for debugging */
+
+#ifndef _WIN32
+ static int
+Is_executable(uid_t myuid, gid_t mygid, struct stat *sb)
+{
+	if (sb->st_uid == myuid) {
+		if (sb->st_mode & S_IXUSR)
+			return 1;
+		}
+	else if (sb->st_gid == mygid) {
+		if (sb->st_mode & S_IXGRP)
+			return 1;
+		}
+	else if (sb->st_mode & S_IXOTH)
+		return 1;
+	return 0;
+	}
+#endif
+
+ int
+nidr_save_exedir(const char *argv0, int pathadj)
+{
+	/* pathadj & 1 ==> add exedir to $PATH */
+	/* pathadj & 2 ==> add . to $PATH */
+	/* (in both cases if not already there) */
+
+    /* These conditionals don't seem to work (perhaps expected) for Cygwin 
+	   binaries run from Windows command prompt as the compile-time is 
+	   unix-style, but runtime the path is windows-like.  For now comment
+	   out warning when on Cygwin build */
+#ifdef _WIN32
+#define Pathname "Path"
+#define Sep ';'
+#define Slash '\\'
+#define Executable(x) !stat(x,&sb)
+#else
+#define Pathname "PATH"
+#define Sep ':'
+#define Slash '/'
+#define Executable(x) !stat(x,&sb) && Is_executable(myuid, mygid, &sb)
+#endif
+	char *buf, buf0[4096], *s;
+	const char *av0, *p, *p0, *p1, *p2;
+	int dotseen, finaldot, rc;
+	size_t buflen, L, L1, L2, L3;
+	struct stat sb;
+	static const char dotslash[3] = { '.', Slash, 0 };
+#ifdef _WIN32
+	int c;
+	pathadj &= 1;	/* . is implicitly in $PATH under _WIN32 */
+#else
+	gid_t mygid;
+	uid_t myuid;
+#endif
+	if (nidr_exedir_len != -1) {
+		fprintf(stderr, "\nIgnoring extra call on nidr_save_argv0()\n");
+		return 1;
+		}
+	nidr_exedir_len = 0;
+	if (!(av0 = argv0))
+		return 2;
+	if (!(p = getenv(Pathname))) {
+		fprintf(stderr, "\nnidr_save_exedir: no $%s\n", Pathname);
+		return 3;
+		}
+	dotseen = finaldot = rc = 0;
+	buf = buf0;
+	buflen = sizeof(buf0);
+	p0 = p2 = p;
+	p1 = nidr_basename(av0);
+	if ((L = p1 - av0) > 0) {
+		memcpy(s = (char*)Alloc("nidr_save_argv0", L+1), av0, L);
+		s[L] = 0;
+		nidr_exedir = s;
+		nidr_exedir_len = (int)L;
+#ifdef _WIN32
+		for(L1 = 0; L1 < L; ++L1)
+			if (s[L1] == '/')
+				s[L1] = '\\';
+#endif
+		if (!pathadj)
+			return 0;
+		if (*p == Sep)
+			dotseen = 1;
+		while(*p) {
+			if (*p == Sep && (p[1] == Sep || p[1] == 0)) {
+				dotseen = 1;
+				break;
+				}
+			++p;
+			}
+		if (s[0] == '.' && s[1] == Slash && L == 2) {
+#ifdef _WIN32
+			return 0;
+#else
+			if (!dotseen)
+				goto dot_add;
+#endif
+			}
+		L1 = L - 1;
+		for(p = p0;;) {
+			while(*p == Sep)
+				++p;
+			if (!*p)
+				break;
+			if (!strncmp(p, s, L1)) {
+#ifdef _WIN32
+				return 0;
+#else
+				if (!(pathadj &= ~1) || *p0 == Sep)
+					return 0;
+				for(p = p0;;) {
+					if (*p == Sep || (*p == '.' && p[1] == Sep))
+						return 0;
+					while(*p != Sep) {
+						if (!*p)
+							goto dot_add;
+						++p;
+						}
+					if (!*++p)
+						return 0;
+					}
+#endif
+				}
+			while(*++p != Sep)
+				if (!*p)
+					goto break2;
+			if (!*++p) {
+#ifdef _WIN32
+				finaldot = 1; /* leave at 0 for !_WIN32 */
+#endif
+				break;
+				}
+			}
+ break2:
+		L1 = strlen(Pathname);
+		L2 = strlen(p0);
+		if (!pathadj & 2)
+			dotseen = 1;
+		L3 = L1 + L2 + L + 3;
+		s = (char*)Alloc("nidr_save_argv0", L3);
+		memcpy(s, Pathname, L1);
+		s[L1++] = '=';
+		memcpy(s+L1, p0, L2);
+		L1 += L2;
+		if (!finaldot)
+			s[L1++] = Sep;
+		memcpy(s+L1, nidr_exedir, --L);
+		L1 += L;
+		if (!dotseen)
+			s[L1++] = Sep;
+		s[L1] = 0;	/* omit final slash */
+		putenv(s);
+		return 0;
+		}
+	L = strlen(av0);
+#ifdef _WIN32
+	if (L < 5 || av0[L-4] != '.'
+	|| ((c = av0[L-3]) != 'e' && c != 'E')
+	|| ((c = av0[L-2]) != 'x' && c != 'X')
+	|| ((c = av0[L-1]) != 'e' && c != 'E')) {
+		memcpy(s = (char*)Alloc("nidr_save_argv0", L + 5), av0, L);
+		strcpy(s+L, ".exe");
+		L += 4;
+		av0 = s;
+		}
+	if (Executable(av0)) {
+		/* handle implicit . */
+		dotseen = 1;
+		nidr_exedir = dotslash;
+		}
+	else /* do for loop */
+#else
+
+/* Fix for C99 */
+#ifndef __cplusplus
+extern uid_t geteuid(void);
+extern uid_t getegid(void);
+#endif /* __cplusplus */
+
+	myuid = geteuid();
+	mygid = getegid();
+#endif
+	for(; *p; p = p2) {
+		for(p1 = p;; ++p1) {
+			if (*p1 == Sep) {
+				p2 = p1 + 1;
+				if (!*p2)
+					finaldot = 1;
+				break;
+				}
+			if (!*p1) {
+				p2 = p1;
+				break;
+				}
+			}
+		if (p1 == p || (*p == '.' && p1 == p + 1)) {
+			if (!dotseen) {
+				dotseen = 1;
+				if (Executable(av0)) {
+					nidr_exedir = dotslash;
+					break;
+					}
+				}
+			}
+		else {
+			L1 = p1 - p;
+			L2 = L + L1 + 2;
+			if (L2 > buflen) {
+				if (buf != buf0)
+					free(buf);
+				buf = (char*)Alloc("nidr_save_argv0", L2);
+				buflen = L2;
+				}
+			memcpy(buf, p, L1);
+			buf[L1++] = Slash;
+			strcpy(buf+L1, av0);
+			if (Executable(buf)) {
+				s = (char*)Alloc("nidr_save_argv0", L1+1);
+				memcpy(s, buf, L1);
+				s[L1] = 0;
+				nidr_exedir = s;
+				nidr_exedir_len = (int)L1;
+				pathadj &= ~1;
+				break;
+				}
+			}
+		}
+	if (dotseen)
+		pathadj &= ~2;
+	if (!finaldot && *p2) {
+		while(p2[1])
+			++p2;
+		if (*p2 == Sep)
+			finaldot = 1;
+		}
+	if (finaldot && !dotseen && !nidr_exedir) {
+		dotseen = 1;
+		if (Executable(av0))
+			nidr_exedir = dotslash;
+		}
+	if (nidr_exedir == dotslash)
+		nidr_exedir_len = 2;
+	else {
+		if (pathadj & 2 && !finaldot) {
+#ifndef _WIN32
+ dot_add:
+#endif
+			L = strlen(p0);
+			L1 = strlen(Pathname);
+			L2 = L + L1 + 3;
+			s = (char*)Alloc("nidr_save_argv0", L2);
+			memcpy(s, Pathname, L1);
+			s[L1++] = '=';
+			memcpy(s+L1, p0, L);
+			s[L += L1] = Sep;
+			s[L+1] = 0;
+			putenv(s);
+			}
+		if (!nidr_exedir) {
+/* Suppress warning for Cygwin and Windows, where path isn't resolved correctly above */
+#if !defined(__CYGWIN__) && !defined(_MSC_VER)
+			fprintf(stderr, "\nnidr_save_exedir: could not find \"%s\" in $%s\n",
+				av0, Pathname);
+#endif
+			rc = 4;
+			}
+		}
+	if (buf != buf0)
+		free(buf);
+	return rc;
+	}
+
+ void *
+nidr_dlopen(const char *libname)
+{
+#ifdef NO_NIDR_DYNLIB /*{{*/
+	botch("dlopen for \"%s\" is NOT SUPPORTED", libname);
+	return (void*)libname;
+#else /*}{*/
+	char buf0[4096], *buf;
+	const char *b;
+	size_t buflen, L, L1;
+	void *h;
+
+	b = nidr_basename(libname);
+	if (b > libname)
+		return dlopen(libname, RTLD_NOW);
+	buf = buf0;
+	buflen = sizeof(buf0);
+	L = strlen(libname);
+	if (nidr_exedir) {
+		L1 = L + nidr_exedir_len + 1;
+		if (L1 > buflen) {
+			buf = (char*)Alloc("nidr_dlopen", L1);
+			buflen = L1;
+			}
+		memcpy(buf, nidr_exedir, nidr_exedir_len);
+		strcpy(buf + nidr_exedir_len, libname);
+		if ((h = dlopen(buf, RTLD_NOW)))
+			goto ret;
+		}
+	if (!(h = dlopen(libname, RTLD_NOW))) {
+		L1 = L + 3;
+		if (L1 > buflen) {
+			buf = (char*)Alloc("nidr_dlopen", L1);
+			buflen = L1;
+			}
+		buf[0] = '.';
+		buf[1] = Slash;
+		strcpy(buf+2, libname);
+		if (!(h = dlopen(buf, RTLD_NOW)))
+			h = dlopen(libname, RTLD_NOW); 	/* for dlerror */
+		}
+ ret:
+	if (buf != buf0)
+		free(buf);
+	return h;
+#endif  /*}}*/
+	}
+
+#undef Executable
+#undef Slash
+#undef Sep
+#undef Pathname
+
+
+ struct
+Comment {
+	int k;		/* subscript for comfree */
+	size_t avail;	/* bytes left (from tnext) */
+	char *text;	/* text of comment */
+	char *tnext;	/* null byte at end of comment */
+	Comment *fnext;	/* next free Comment */
+	};
+
+ enum { Comment_kmax = 7 };
+
+ static Comment *comfree[Comment_kmax+1];
+ static size_t Comment_maxlen[Comment_kmax+1];
+
+ static void
+comment_free(Comment *c)
+{
+	int k = c->k;
+
+	if (k > Comment_kmax)
+		free(c);
+	else {
+		c->fnext = comfree[k];
+		comfree[k] = c;
+		}
+	}
+
+ static Comment*
+alloc_comment(int k, size_t L)
+{
+	Comment *c;
+
+	for(; k <= Comment_kmax; ++k) {
+		if (L <= Comment_maxlen[k]) {
+			L = Comment_maxlen[k];
+			if ((c = comfree[k])) {
+				comfree[k] = c->fnext;
+				goto have_c;
+				}
+			break;
+			}
+		}
+	c = (Comment*)Alloc("save_comment", L + sizeof(Comment) + 1);
+	c->k = k;
+	c->text = (char*)(c+1);
+ have_c:
+	c->avail = L;
+	c->tnext = c->text;
+	return c;
+	}
+
+ static void
+save_comment(const char *s)
+{
+	Comment *c, *c1, **cp;
+	size_t L, L1;
+
+	L = strlen(s);
+	cp = curid ? &curid->comment : curkws ? &curkws->comment : &OutsideComment;
+	if ((c = *cp)) {
+		if (c->avail >= L)
+			goto cupdate;
+		L1 = c->tnext - c->text;
+		c1 = alloc_comment(c->k + 1, L + L1);
+		memcpy(c1->text, c->text, L1);
+		c1->tnext = c1->text + L1;
+		c1->avail -= L1;
+		comment_free(c);
+		c = c1;
+		}
+ 	else
+		c = alloc_comment(0, L);
+ cupdate:
+	memcpy(c->tnext, s, L+1);
+	c->tnext += L;
+	c->avail -= L;
+	*cp = c;
+	}
+
+ static void
+comment_setup(void)
+{
+	int i;
+	size_t L;
+	nidr_comment = save_comment;
+	/* "- 1" to allow for terminating '\0' */
+	for(L = 64; L <= sizeof(Comment) - 1; L <<= 1);
+	for(i = 0; i <= Comment_kmax; ++i, L <<= 1)
+		Comment_maxlen[i] = L - sizeof(Comment) - 1;
+	}
+
+ static void
+comment_reset(void)
+{
+	Comment *c, *c1;
+	int i;
+
+	for(i = 0; i <= Comment_kmax; ++i) {
+		c1 = comfree[i];
+		comfree[i] = 0;
+		while((c = c1)) {
+			c1 = c->fnext;
+			free(c);
+			}
+		}
+	nidr_comment = 0;
+	}
+
+ static void
+dumpcomment(Comment **cp)
+{
+	Comment *c = *cp;
+	*cp = 0;
+	fprintf(dumpfile, "%s", c->text);
+	comment_free(c);
+	}
+
+ static void
+dumpname(int hasval, KeyWord *kw)
+{
+	const char *fmt[2] = { "%s", "%s =" };
+	int i;
+	if (OutsideComment)
+		dumpcomment(&OutsideComment);
+	if (primary)
+		kw += kw->paoff;
+	for(i = 0; i < dumplev; ++i)
+		putc(' ', dumpfile);
+	fprintf(dumpfile,fmt[hasval],kw->name);
+	if (!hasval) {
+		if (kw->comment)
+			dumpcomment(&kw->comment);
+		else if (kw != curkw)
+			putc('\n', dumpfile);
+		}
+	}
+
+ static void
+dumpstring(const char *s0)
+{
+	const char *s;
+	int c, n1, n2, q;
+
+	n1 = n2 = 0;
+	for(s = s0;;)
+		switch(*s++) {
+		  case 0: goto break2;
+		  case '\'':
+			++n1;
+			break;
+		  case '"':
+			++n2;
+		  }
+ break2:
+	q = '\'';
+	if (n1 > n2)
+		q = '"';
+	putc(' ', dumpfile);
+	putc(q, dumpfile);
+	s = s0;
+	while((c = *s++)) {
+		if (c == q)
+			putc(q, dumpfile);
+		putc(c, dumpfile);
+		}
+	putc(q, dumpfile);
+	}
+
+ static void
+dumpvals0(KeyWord *kw)
+{
+	Real *r;
+	const char **sp;
+	int i, *ip, indent, j, n;
+
+	ip = 0; /* shut up warning of possible use without initialization */
+	sp = 0; /* ditto */
+	if (!(r = KWval.r) && !(ip = KWval.i) && !(sp = KWval.s))
+		return;
+	n = KWval.n;
+	putc((indent = n > 1) ? '\n' : ' ', dumpfile);
+	for(i = 0;;) {
+		if (indent) {
+			putc('\t', dumpfile);
+			for(j = 0; j < dumplev; ++j)
+				putc(' ', dumpfile);
+			}
+		if (r)
+			fprintf(dumpfile, "%.15g", r[i]);
+		else if (ip)
+			fprintf(dumpfile, "%d", ip[i]);
+		else
+			dumpstring(sp[i]);
+		if (++i >= n)
+			break;
+		indent = 1;
+		putc('\n', dumpfile);
+		}
+	if (kw->comment)
+		dumpcomment(&kw->comment);
+	else
+		putc('\n', dumpfile);
+	}
+
+ static void (*dumpvals)(KeyWord *kw) = dumpvals0;
+
+ static void
+dumpvals1(KeyWord *kw)
+{
+	Real *r;
+	const char **sp;
+	int i, *ip, n;
+
+	ip = 0; /* shut up warning of possible use without initialization */
+	sp = 0; /* ditto */
+	if ((r = KWval.r) || (ip = KWval.i) || (sp = KWval.s)) {
+		n = KWval.n;
+		for(i = 0; i < n; ++i) {
+			if (r)
+				fprintf(dumpfile, " %.15g", r[i]);
+			else if (ip)
+				fprintf(dumpfile, " %d", ip[i]);
+			else
+				dumpstring(sp[i]);
+			}
+		}
+	if (kw->comment)
+		dumpcomment(&kw->comment);
+	else
+		putc('\n', dumpfile);
+	}
+
+ char *
+nidr_KWscopy(const char *s)
+{
+	Sbuf *sb;
+	char *rv;
+
+	size_t L = strlen(s) + 1;
+	if (L >= n_KWsbuf)
+		botch("String too long in KWscopy");
+	if (KWsbufe - KWsbuf1 < L) {
+		if (!KWsbuf->next) {
+			KWsbuf->next = sb = (Sbuf*)Alloc("KWscopy", sizeof(Sbuf));
+			sb->next = 0;
+			}
+		KWsbuf = KWsbuf->next;
+		KWsbuf1 = KWsbuf->buf;
+		KWsbufe = KWsbuf1 + n_KWsbuf;
+		}
+	strcpy(KWsbuf1, s);
+	rv = KWsbuf1;
+	KWsbuf1 += L;
+	return rv;
+	}
+
+ static void
+KWvalbuf_inc(void)
+{
+	Real *r;
+	Uint n;
+
+	n = nKWvalbuf << 1;
+	r = (Real*)Alloc("KWvalbuf", n*sizeof(Real));
+	memcpy(r, KWvalbuf, nKWvalbuf*sizeof(Real));
+	free(KWvalbuf);
+	KWvalbuf = r;
+	nKWvalbuf = n;
+	KWvalmax.n <<= 1;
+	if (KWval.r) {
+		KWval.r = r;
+		KWvalmax.r = r + n;
+		}
+	else if (KWval.i) {
+		KWval.i = (int*) r;
+		KWvalmax.i = (int*)(r + n);
+		}
+	else if (KWval.s) {
+		KWval.s = (const char**)r;
+		KWvalmax.s = (const char**)(r + n);
+		}
+	else
+		botch("Unexpected case in KWvalbuf_inc");
+	}
+
+/* KWval.rstate values...
+ *	value	form seen
+ *	0	v
+ *	1	L:u
+ *	2	L:s:u
+ *	3	n*v
+ *	4	n*L:u
+ *	5	n*L:s:u
+ */
+
+ static void
+finish_rexpand(void)
+{
+	int i, k, n, os;
+	Real sgn, st, u, v, x;
+
+	os = KWval.rstate;
+	KWval.rstate = 0;
+	n = KWval.n;
+	k = 1;
+	if (os >= 3) {
+		KWval.n = n -= os-1;
+		k = KWval.r[n];
+		if (k != KWval.r[n]) {
+			squawk("Noninteger replication factor %.17g", KWval.r[n]);
+			return;
+			}
+		else if (k < 1) {
+			squawk("Nonpositive replication factor %d", k);
+			return;
+			}
+		++n;
+		os -= 3;
+		}
+	else
+		KWval.n = n -= os + 1;
+	v = KWval.r[n++];
+	u = st = 0.;	/* Shut up warning of not being initialized. */
+			/* Both will be assigned before being used. */
+	switch(os) {
+	  case 0:
+		n = KWval.n;
+		for(i = 0; i < k; ++i) {
+			if (n >= KWvalmax.n)
+				KWvalbuf_inc();
+			KWval.r[n++] = v;
+			}
+		KWval.n = n;
+		return;
+	  case 1:
+		st = 1;
+		u = KWval.r[n];
+		break;
+	  case 2:
+		st = KWval.r[n];
+		if (st == 0.) {
+			squawk("Invalid stride == zero.");
+			return;
+			}
+		u = KWval.r[n+1];
+	  }
+	sgn = 1.;
+	if (st < 0.)
+		sgn = -1.;
+	if (sgn*(u - v) < 0.) {
+		squawk("Empty sequence.");
+		return;
+		}
+	n = KWval.n;
+	do {
+		for(i = 0; sgn*(u - (x = v + i*st)) >= 0.; ++i) {
+			if (n >= KWvalmax.n)
+				KWvalbuf_inc();
+			KWval.r[n++] = x;
+			}
+		}
+		while(--k > 0);
+	KWval.n = n;
+	}
+
+ static void
+rexpand(int state)
+{
+	int os;
+
+	os = KWval.rstate;
+	KWval.rstate = 0;
+	switch(state) {
+	  case 1: /* just saw *v */
+		if (os == 0)
+			KWval.rstate = 3;
+		else
+			squawk("Unexpected '*'");
+		break;
+	  case 2: /* just saw :v */
+		if (os == 2 || os == 5)
+			squawk("Unexpected ':'");
+		else
+			KWval.rstate = os + 1;
+		break;
+	  }
+	}
+
+ static void
+nidr_bufr_strict(Real r, int state)
+{
+	int k, n;
+
+	if (KWval.s) {
+		squawk("expected a quoted string, but found a number");
+		return;
+		}
+	if (KWval.rstate && !state)
+		finish_rexpand();
+	if (!KWval.r && !KWval.i) {
+		squawk("No values may be specified for %s", KWStack->kw->name);
+		return;
+		}
+	if ((n = KWval.n) >= KWvalmax.n)
+		KWvalbuf_inc();
+	if (KWval.r)
+		KWval.r[n] = r;
+	else {
+		k = (int)r;
+		if (k != r)
+			squawk("truncating %.17g to %d", r, k);
+		KWval.i[n] = k;
+		}
+	++KWval.n;
+	if (state | KWval.rstate)
+		rexpand(state);
+	}
+
+ static void
+nidr_bufs_strict(const char *s)
+{
+	if (!KWval.s) {
+		if (KWval.r)
+			squawk("Expected a number, but found a quoted string");
+		else
+			squawk("Misplaced quoted string");
+		return;
+		}
+	if (KWval.n >= KWvalmax.n)
+		KWvalbuf_inc();
+	KWval.s[KWval.n++] = s;
+	}
+
+ void
+nidr_reset(void)
+{
+	/* Originally did this in case KWKind_Str of kw_setup(), */
+	/* but this leads to confusion with erroneous input. */
+	if (curkw)
+		nidr_keyword_finish();
+	KWsbuf = &KWsbuf0;
+	KWsbuf1 = KWsbuf0.buf;
+	KWsbufe = KWsbuf0.buf + n_KWsbuf;
+	}
+
+ NIDR_KWlib *
+nidr_lib_record(void *h, const char *libname)
+{
+	NIDR_KWlib *Lib;
+	size_t L;
+
+	L = strlen(libname) + 1;
+	Lib = (NIDR_KWlib*)Alloc("NIDR_lib_record", sizeof(NIDR_KWlib) + L);
+	memset(Lib, 0, sizeof(NIDR_KWlib));
+	memcpy(Lib->libname = (char*)(Lib+1), libname, L);
+	if (!(Lib->next = NIDR_Libs))
+		atexit(nidr_lib_cleanup);
+	NIDR_Libs = Lib;
+	Lib->h = h;
+	return Lib;
+	}
+
+ static KeyWord*
+kw_insert(KeyWord *kw, int *tryagain)
+{
+#ifdef NO_NIDR_DYNLIB /*{{*/
+	botch("Loading library \"%s\" for %s is disallowed",
+		kw->f.vf, kw->name);
+#else /*}{*/
+	KW_ADD kwa;
+	KeyWord *kw0, *kw1, *kw2;
+	NIDR_KWlib *Lib;
+	Uint u1, ui;
+	const char *lname, *s;
+	int newtop, nmatch;
+	void *h;
+
+	if (tryagain)
+		*tryagain = 0;
+	if (kw->kind & KWKind_Loaded)
+		return (KeyWord*)kw->f.vs;
+	h = nidr_dlopen(lname = (const char*)kw->f.vf);
+	if (!h) {
+#ifndef NO_DLERROR
+		if ((s = dlerror()))
+			botch("Cannot open library \"%s\" for %s:\n\t%s",
+				lname, kw->name, s);
+		else
+#endif
+			botch("Cannot open library \"%s\" for %s",
+				lname, kw->name);
+		}
+	if (!find_dlsym(kwa, h, "keyword_add"))
+		botch("dlsym(\"keyword_add\") failed for %s", lname);
+	kw1 = (*kwa)();
+	if (!(s = kw1->name)) {
+		s = "<NULL>";
+		goto namebotch;
+		}
+	newtop = 0;
+	if (strcmp(s, kw->name)) {
+		if (!KW_cur && !strcmp(s,"KeywordTop") && kw1->kind & KWKind_Dynmult)
+			newtop = 1;
+		else if (tryagain && kw1->nkw > 0
+		 && (kw2 = kwfind(kw->name, kw1->kw, kw1->nkw, &nmatch))) {
+			if (nmatch > 1) {
+				toomany(kw->name, kw1, nmatch);
+				botch("Too many matches in library %s", lname);
+				}
+			*tryagain = 1;
+			}
+		else
+ namebotch:
+			botch("Library %s: expected top keyword to be %s but got %s",
+				lname, kw->name, s);
+		}
+	ui = kw->kind  & (KWKind_Mask|KWKind_List);
+	u1 = kw1->kind & (KWKind_Mask|KWKind_List);
+	if (ui != u1)
+		botch("Library %s: expected kind %u for %s, but got %u",
+			lname, ui, s, u1);
+	Lib = nidr_lib_record(h, lname);
+	Lib->kw0 = kw0 = kw;
+	memcpy(&Lib->kw, kw, sizeof(KeyWord));
+	kw = &Lib->kw;
+	kw->kw = kw1->kw;
+	kw->nkw = kw1->nkw;
+	kw->f = kw1->f;
+	kw0->f.vs = (void*)kw;
+	kw0->kind |= KWKind_Loaded;
+	if (newtop) {
+		Lib->oldtop = Keyword_Top;
+		Keyword_Top = kw;
+		kw->kind |= KWKind_Dynmult;
+		}
+#endif	/*}}*/
+	return kw;
+	}
+
+ static void
+kwnext_setup(KeyWord *kw, Uint n)
+{
+	KeyWord *kwe;
+
+	if (kw->kwnext || (n <= 1 && kw->name))
+		return;
+#ifndef NO_NIDR_DYNLIB /*{*/
+	if (kw->kind & KWKind_Extended) {
+		KeyWordx *kx1, *kxe;
+		for(kx1 = (KeyWordx*)kw; !kx1->kw.name; ++kx1)
+			kx1->kw.kwnext = (KeyWord*)(kx1 + 1);
+		for(kxe = kx1 + n - 1; kx1 < kxe; ++kx1)
+			kx1->kw.kwnext = (KeyWord*)(kx1 + 1);
+		return;
+		}
+#endif
+	for(; !kw->name; ++kw)
+		kw->kwnext = kw + 1;
+	for(kwe = kw + n - 1; kw < kwe; ++kw)
+		kw->kwnext = kw + 1;
+	}
+
+ static void
+KWStack_inc(void)
+{
+	KWinfo *kwi;
+	Uint nn;
+	size_t len;
+
+	nn = n_KWStack << 1;
+	kwi = (KWinfo*)Alloc("kw_setup", len = nn*sizeof(KWinfo));
+	memcpy(kwi, KWStackBot, len >> 1);
+	if (KWStackBot != KWStack0)
+		free(KWStackBot);
+	KWStackBot = kwi;
+	KWStackEnd = kwi + nn;
+	KWStack = kwi + n_KWStack;
+	n_KWStack = nn;
+	}
+
+ static KeyWord*
+kw_setup(KeyWord *kw, void *g, const char *name)
+{
+	KWinfo *kwi;
+	KeyWord **alt, *kw1, **req;
+
+	Uint k, nalt, nn, nreq;
+	int *altct, deferred;
+	size_t len;
+
+	deferred = 0;
+	if (kw->kind & KWKind_Dynlib) {
+		if (kw->kw)
+			deferred = 1;
+		else
+			kw = kw_insert(kw, 0);
+		}
+ top:
+	if ((kw1 = kw->kw)) {
+		kwnext_setup(kw1, kw->nkw);
+		if (kw->kind & KWKind_Dynmult)
+			return kw;
+		while(!kw1->name) {
+			if (!(kw1->kind & KWKind_Stacked)) {
+				kw1->kind |= KWKind_Stacked;
+				kw_setup(kw1, g, name);
+				}
+			kw1 = kw1->kwnext;
+			}
+		}
+	if (!curkw) {
+		KWStack = KWStackBot = KWStack0;
+		KWStackEnd = KWStack0 + n_KWStack0;
+		curkw = kw;
+		}
+	else if (++KWStack >= KWStackEnd)
+		KWStack_inc();
+	kwi = KWStack;
+	kwi->name = name;
+	kwi->kw = kw;
+	kwi->kw1 = kw1;
+	nalt = nreq = 0;
+	if (kw1)
+		for(; kw1; kw1 = kw1->kwnext) {
+			if (nalt < kw1->alt)
+				nalt = kw1->alt;
+			if (nreq < kw1->req)
+				nreq = kw1->req;
+			}
+	kwi->nalt = nalt;
+	kwi->nreq = nreq;
+	alt = req = 0;
+	altct = 0;
+	if ((nn = nalt + nreq) > 0) {
+		nn += 2;
+		alt = (KeyWord**)Alloc("kw_setup(alt)",
+				len = nn*sizeof(KeyWord*) + (nalt+1)*sizeof(int));
+		memset(alt, 0, len);
+		req = alt + nalt + 1;
+		altct = (int*)(req + nreq + 1);
+		/* altct[0], alt[0] and req[0] = "don't care" slots */
+		}
+	kwi->alt = alt;
+	kwi->req = req;
+	kwi->altct = altct;
+	if (nreq)
+		for(kw1 = kwi->kw1; kw1; kw1 = kw1->kwnext)
+			req[kw1->req] = kw1;
+	if (nalt)
+		for(kw1 = kwi->kw1; kw1; kw1 = kw1->kwnext)
+			if (kw1->kind & KWKind_primary)
+				++altct[kw1->alt];
+	kwi->g = g;
+	KWval.n = 0;
+	KWval.i = 0;
+	KWval.r = 0;
+	KWval.s = 0;
+	if ((k = kw->kind & KWKind_Mask)) {
+		if (!KWvalmax.r)
+			KWvalbuf = (Real *)Alloc("kw_setup(KWvalbuf)",
+						(nKWvalbuf = 128)*sizeof(Real));
+		switch(k) {
+
+		  case KWKind_Int:
+			KWval.i = (int*)KWvalbuf;
+			KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(int);
+			KWvalmax.i = KWval.i + KWvalmax.n;
+			break;
+
+		  case KWKind_Real:
+			KWval.r = KWvalbuf;
+			KWvalmax.r = KWvalbuf + (KWvalmax.n = nKWvalbuf);
+			break;
+
+		  case KWKind_Str:
+			KWval.s = (const char**)KWvalbuf;
+			KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(char*);
+			KWvalmax.s = KWval.s + KWvalmax.n;
+		  }
+		}
+	if (deferred) {
+		kw = kw_insert(kw, 0);
+		deferred = 0;
+		goto top;
+		}
+	if (!(kwi->needstart = kw->kind & KWKind_Mask)) {
+		if (kw->name) {
+			if (dumpfile)
+				dumpname(0, kw);
+			++dumplev;
+			}
+		if (kw->f.start)
+			(*kw->f.start)(kw->name, 0, &KWStack->g, kw->f.vs);
+		}
+	else if (!kw->f.start && NIDR_disallow_missing_start)
+		botch("No start routine for %s", kw->name);
+	return kw;
+	}
+
+ static KeyWord *
+kwfind(const char *name, KeyWord *keywds, int n, int *nmatch)
+{
+	KeyWord *kn, *kn1;
+	int k, n0, n1, n2, nn;
+	size_t L;
+
+	*nmatch = 0;
+	if (n <= 0)
+		return 0;
+	L = strlen(name);
+	n0 = 0;
+	nn = n;
+#ifndef NO_NIDR_DYNLIB /*{*/
+	if (n > 0 && keywds->kind & KWKind_Extended) {
+	    while(n > 0) {
+		n1 = n >> 1;
+		kn = (KeyWord*)((KeyWordx*)keywds + n1);
+		k = strncmp(name, kn->name, L);
+		if (k < 0)
+			n = n1;
+		else if (k > 0) {
+			n -= ++n1;
+			n0 += n1;
+			keywds = (KeyWord*)((KeyWordx*)kn + 1);
+			}
+		else {
+			/* Found -- check for range of matches. */
+			/* Here we use linear search, as we expect */
+			/* the range to be small. */
+			n = n1 + n0;
+			n2 = n + 1;
+			if (kn->name[L]) {
+				for(kn1 = kn; n2 < nn; ++n2) {
+					kn1 = (KeyWord*)((KeyWordx*)kn1 + 1);
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L])
+						goto found1;
+					}
+				kn1 = kn;
+				while(n > 0) {
+					kn1 = (KeyWord*)((KeyWordx*)kn1 - 1);
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L])
+						goto found1;
+					--n;
+					kn = kn1;
+					}
+				}
+			*nmatch = n2 - n;
+			return kn;
+			}
+		}
+	    }
+	else
+#endif	/*}*/
+	while(n > 0) {
+		n1 = n >> 1;
+		kn = keywds + n1;
+		k = strncmp(name, kn->name, L);
+		if (k < 0)
+			n = n1;
+		else if (k > 0) {
+			n -= ++n1;
+			n0 += n1;
+			keywds = kn + 1;
+			}
+		else {
+			/* Found -- check for range of matches. */
+			/* Here we use linear search, as we expect */
+			/* the range to be small. */
+			n = n1 + n0;
+			n2 = n + 1;
+			if (kn->name[L]) {
+				for(kn1 = kn; n2 < nn; ++n2) {
+					++kn1;
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L])
+						goto found1;
+					}
+				kn1 = kn;
+				while(n > 0) {
+					--kn1;
+					if (strncmp(name, kn1->name, L))
+						break;
+					if (!kn1->name[L]) {
+ found1:
+						*nmatch = 1;
+						return kn1;
+						}
+					--n;
+					kn = kn1;
+					}
+				}
+			*nmatch = n2 - n;
+			return kn;
+			}
+		}
+	return 0;	/* not found */
+	}
+
+ static KeyWord *
+toomany(const char *name, KeyWord *kw, int nmatch)
+{
+	int i;
+	squawk("\"%s\" is ambiguous; possible matches..", name);
+	if (nsquawk <=  NIDR_SQUAWKMAX)
+		for(i = 0; i < nmatch; i++, kw++)
+			fprintf(stderr, "\t%s\n", kw->name);
+	return 0;
+	}
+
+ KeyWord *
+nidr_keyword(const char *name)
+{
+	int nmatch;
+	KeyWord *kw, *kw1;
+
+	kw = kwfind(name, Keyword_Top->kw, Keyword_Top->nkw, &nmatch);
+	if (nmatch > 1)
+		return toomany(name, kw, nmatch);
+	else if (kw) {
+		if (!(kw1 = curkw)) {
+			kw = kw_setup(kw, KW_g, name);
+			if (kw->kind & KWKind_Dynmult)
+				return kw;
+			}
+		if (!strict) {
+			if (kw1)
+				nidr_keyword_finish();
+			kw_setup1(kw);
+			}
+		}
+	return kw;
+	}
+
+ static void
+valcheck(KeyWord *kw)
+{
+	Real *r;
+	int *z;
+	int i, k, n;
+
+	n = KWval.n;
+	switch(k = kw->kind & KWKind_Mask) {
+	  case KWKind_Int:
+		z = KWval.i;
+		if (kw->kind & KWKind_strictLb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] <= kw->Lb) {
+					squawk("%s must be > %.0f", kw->name, kw->Lb);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqLb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] < kw->Lb) {
+					squawk("%s must be >= %.0f", kw->name, kw->Lb);
+					break;
+					}
+				}
+		if (kw->kind & KWKind_strictUb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] >= kw->Ub) {
+					squawk("%s must be < %.0f", kw->name, kw->Ub);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqUb) {
+			for(i = 0; i < n; ++i)
+				if (z[i] > kw->Ub) {
+					squawk("%s must be >= %.0f", kw->name, kw->Ub);
+					break;
+					}
+				}
+		break;
+	  case KWKind_Real:
+		r = KWval.r;
+		if (kw->kind & KWKind_strictLb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] <= kw->Lb) {
+					squawk("%s must be > %g", kw->name, kw->Lb);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqLb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] < kw->Lb) {
+					squawk("%s must be >= %g", kw->name, kw->Lb);
+					break;
+					}
+				}
+		if (kw->kind & KWKind_strictUb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] >= kw->Ub) {
+					squawk("%s must be < %g", kw->name, kw->Ub);
+					break;
+					}
+				}
+		else if (kw->kind & KWKind_caneqUb) {
+			for(i = 0; i < n; ++i)
+				if (r[i] > kw->Ub) {
+					squawk("%s must be >= %g", kw->name, kw->Ub);
+					break;
+					}
+				}
+		break;
+	  default:
+		botch("Bug: unexpected (kw->kind & KWKind_Mask) = %d in valcheck",n);
+	  }
+	}
+
+ static void
+read_lib(const char *libname, KeyWord *kw)
+{
+#ifdef NO_NIDR_DYNLIB /*{{*/
+	botch("LIBNAME is disallowed: cannot read \"%s\"", libname);
+#else /*}{*/
+	KeyWord *kw1;
+	KW_ADD kwa;
+	NIDR_KWlib *Lib;
+	void *h;
+
+	h = nidr_dlopen(libname);
+	if (!h) {
+#ifndef NO_DLERROR
+		const char *s;
+		if ((s = dlerror()))
+			botch("Cannot open library \"%s\":\n\t%s", libname, s);
+		else
+#endif
+			botch("Cannot open library \"%s\"", libname);
+		}
+	if (!find_dlsym(kwa, h, "keyword_add"))
+		botch("dlsym(\"keyword_add\") failed for %s", libname);
+	kw1 = (*kwa)();
+	Lib = nidr_lib_record(h, libname);
+	kw->nkw = kw1->nkw;
+	kw->kw = kw1->kw;
+	kw->f = kw1->f;
+	kw->kind |= KWKind_Loaded;
+#endif	/*}}*/
+	}
+
+ static void
+nidr_id_strict_finish(KWinfo *kwi, KeyWord *kw, const char *name)
+{
+	KeyWord *kw1;
+	int n;
+
+	if (kw->alt) {
+		if ((kw1 = kwi->alt[n = kw->alt])) {
+			if (strcmp(kw1->name, name))
+				squawk("%s and %s are mutually exclusive",
+					kw1->name, name);
+			else
+				squawk("%s was already specified", name);
+			}
+		else
+			kwi->alt[n] = kw;
+		}
+	if (kw->req) {
+		if (kwi->req[n = kw->req])
+			kwi->req[n] = 0;
+		else if (!kw->alt)
+			squawk("%s specified more than once", name);
+		}
+	}
+
+ static KWinfo *
+dispatch_val(KWinfo *kwi)
+{
+	KeyWord *kw = kwi->kw;
+
+	kwi->needstart = 0;
+	if (KWval.n) {
+		if (KWval.rstate)
+			finish_rexpand();
+		if (dumpfile) {
+			dumpname(1, kw);
+			dumpvals(kw);
+			}
+		if (kw->kind & (KWKind_Lb|KWKind_Ub))
+			valcheck(kw);
+		if (kw->f.start)
+			(*kw->f.start)(kw->name, &KWval, &kwi->g, kw->f.vs);
+		else if ((kw->kind & (KWKind_Libname | KWKind_Loaded)) == KWKind_Libname) {
+			read_lib(KWval.s[0], kw);
+			kw = kw_setup(kw, kwi->g, kw->name);
+			if (kw->f.start)
+				(*kw->f.start)(kw->name, &KWval, &kwi->g, kw->f.vs);
+			if (kw == kwi->kw) {
+				*kwi = *KWStack;
+				--KWStack;
+				}
+			else
+				kwi = KWStack;
+			}
+		KWval.n = 0;
+		}
+	else if ((kw->kind & (KWKind_Libname|KWKind_Loaded))
+			  != (KWKind_Libname|KWKind_Loaded))
+		squawk("expected %sone %s value for %s",
+			kw->kind & KWKind_List ? "at least " : "",
+			valkind[(kw->kind & KWKind_Mask)-1], kw->name);
+	++dumplev;
+	return kwi;
+	}
+
+ static void
+oneof(KeyWord *kw, int alt, int n)
+{
+	KeyWord *kw1;
+
+	squawk("One of the following %d entities\nmust be specified for %s..",
+		n, kw->name);
+	for(kw1 = kw->kw; !kw1->name; kw1 = kw1->kwnext);
+	for(; kw1; kw1 = kw1->kwnext)
+		if (kw1->alt == alt && kw1->kind & KWKind_primary)
+			fprintf(stderr, "\t%s\n", kw1->name);
+	}
+
+ static void
+missing_chk(KeyWord *kw1, KWinfo *kwi)
+{
+	KeyWord *kw0, *kw2, **req;
+	Uint a;
+	char seen0[1024], *seen;
+	const char *kwname;
+	int n;
+	size_t nreq;
+
+	/* only issue one error message per missing keyword */
+
+	nreq = 0;
+	for(kw0 = kw1; kw1; kw1 = kw1->kwnext)
+		if (nreq < kw1->req)
+			nreq = kw1->req;
+	seen = seen0;
+	if (++nreq > sizeof(seen0))
+		seen = (char*)Alloc("missing_chk", nreq);
+	memset(seen, 0, nreq);
+	req = kwi->req;
+	for(kw1 = kw0; kw1; kw1 = kw1->kwnext) {
+		if (kw1->req && req[kw1->req] && !seen[kw1->req] && kw1->kind & KWKind_primary) {
+			seen[kw1->req] = 1;
+			a = -1;
+			if (!kw1->alt || (n = kwi->altct[a = kw1->alt]) <= 1) {
+				if (!(kwname = kwi->name))
+					kwname = "<NIDRBUG>";
+				for(kw2 = kw1;;) {
+					if (kw2->alt == a && kw2->kind & KWKind_primary)
+						break;
+					if (!(kw2 = kw2->kwnext))
+						botch("Bug in missing_chk");
+					}
+				squawk("%s must be specified for %s",
+					kw2->name, kwname);
+				}
+			else
+				oneof(kwi->kw, kw1->alt, n);
+			}
+		}
+	if (seen != seen0)
+		free(seen);
+	}
+
+ static void
+finalize(KWinfo *kwi)
+{
+	KeyWord *kw, *kw1, **req;
+
+	kw = kwi->kw;
+	kw->kind &= ~KWKind_Stacked;
+	if (kwi->needstart)
+		kwi = dispatch_val(kwi);
+	if (kw->name)
+		--dumplev;
+	if (kw->f.final)
+		(*kw->f.final)(kw->name, 0, &kwi->g, kw->f.vf);
+	if (kwi->alt) {
+		if (kwi->nreq) {
+			req = kwi->req;
+			for(kw1 = kwi->kw1; kw1; kw1 = kw1->kwnext)
+				if (kw1->req && req[kw1->req]) {
+					missing_chk(kw1, kwi);
+					break;
+					}
+			}
+		free(kwi->alt);
+		}
+	}
+
+ static KeyWord *
+nidr_identifier_strict(const char *name)
+{
+	KWinfo *kwi, *kwi1;
+	KeyWord *kw, *kw1;
+	int nmatch;
+	size_t height;
+
+	if (!curkw)
+		botch("curkw = 0 in nidr_identifier");
+	kwi = KWStack;
+	if (kwi->needstart)
+		kwi = dispatch_val(kwi);
+	for(kwi1 = kwi;;) {
+		kw1 = kwi->kw;
+		if ((kw = kwfind(name, kwi->kw1, kw1->nkw, &nmatch)))
+			break;
+		if (kwi == KWStackBot)
+			return 0;
+		if ((--kwi)->kw->name && !(kwi->kw->kind & KWKind_Loaded))
+			kwi1 = kwi;
+		}
+	if (nmatch > 1)
+		return toomany(name, kw, nmatch);
+	while(KWStack > kwi1)
+		finalize(KWStack--);
+	if ((kw->kind & (KWKind_Libname | KWKind_Loaded)) == KWKind_Libname) {
+		nidr_id_strict_finish(kwi, kw, name);
+		if (!KWvalmax.r)
+			KWvalbuf = (Real *)Alloc("nidr_identifier_strict",
+						(nKWvalbuf = 128)*sizeof(Real));
+		if (++KWStack >= KWStackEnd)
+			KWStack_inc();
+		kwi = KWStack;
+		kwi->kw = kw;
+		kwi->needstart = 1;
+		KWval.s = (const char**)KWvalbuf;
+		KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(char*);
+		KWvalmax.s = KWval.s + KWvalmax.n;
+		}
+	else {
+		height = kwi - KWStackBot;
+		kw = kw_setup(kw, kwi->g, name);
+		kwi = KWStackBot + height; /* in case kw_setup reallocated KWStack */
+		nidr_id_strict_finish(kwi, kw, name);
+		}
+	return kw;
+	}
+
+ static void
+nidr_keyword_finish(void)
+{
+	if (!strict)
+		kw_finish2();
+	for(;;--KWStack) {
+		finalize(KWStack);
+		if (KWStack == KWStackBot)
+			break;
+		}
+	if (!strict)
+		kw_finish3();
+	curid = curkw = 0;
+	}
+
+ const char*
+nidr_keyword_name(void)
+{ return curkw ? curkw->name : "<none>"; }
+
+/* Some of the above assumes strict nesting according to dakota.input.nspec. */
+/* Code here is meant to relax this assumption, allowing more flexibility in */
+/* the order of identifiers within a DAKOTA "keyword". */
+
+ typedef struct KWpair KWpair;
+ typedef struct KWmblk KWmblk;
+
+ struct
+KWmblk {
+	KWmblk *next;
+	size_t len;
+	/* memory of length len immediately follows */
+	};
+
+ struct
+KWpair {
+	KeyWord *kw;
+	KWseen *kws;
+	};
+
+ enum{ KWmblk_gulp = 32000 };
+
+ static AVL_Tree *AVLT, *AVLKWP;
+ static KWseen **KW_p, **KW_pe, KWmissing, *KWs0;
+ static KWmblk *KWmblk0, *KWmblk1;
+ static const char *KWmem0, *KWmem1;
+
+ typedef struct
+AVLCmpInfo {
+	KWseen **found[2];
+	int nfound;
+	int inexact;
+	} AVLCmpInfo;
+
+ static int
+avlcmp(void *v, KWseen **a, KWseen **b)
+{
+	AVLCmpInfo *AI = (AVLCmpInfo*)v;
+	KWseen *ksa, *ksb;
+	const char *s, *t;
+
+	s = (ksa = *a)->name;
+	t = (ksb = *b)->name;
+	for(; *s == *t; ++s, ++t)
+		if (!*s)
+			return 0;
+	if ((!*s && !ksa->kw && ksb->kw)
+	  ||(!*t && !ksb->kw && ksa->kw)) {
+		/* inexact match */
+		if (AI->nfound == 0
+		|| (AI->nfound == 1 && AI->found[0] != b))
+			AI->found[AI->nfound++] = b;
+		return AI->inexact;
+		}
+	return *s - *t;
+	}
+
+ static int
+kwpcmp(void *v, KWpair *a, KWpair *b)
+{
+	if (a->kw == b->kw)
+		return 0;
+	return a->kw > b->kw ? 1 : -1;
+	}
+
+ static void
+KWmeminit(void)
+{
+	KWmblk0 = KWmblk1 = (KWmblk*)Alloc("KWmeminit",
+			sizeof(KWmblk) + KWmblk_gulp);
+	KWmem0 = (char*)(KWmblk0 + 1);
+	KWmem1 = KWmem0 + KWmblk_gulp;
+	KWmblk0->len = KWmblk_gulp;
+	KWmblk0->next = 0;
+	KWmissing.mnext = KWmissing.mprev = &KWmissing;
+	KW_cur = 0;
+	memset(&KWval, 0, sizeof(KWval));
+	KWvalbuf = (Real *)Alloc("kw_setup(KWValbuf)", (nKWvalbuf = 128)*sizeof(Real));
+	ToClear = ToClear0 = (KeyWord**)Alloc("kw_setup(ToClear)", 256*sizeof(KeyWord*));
+	ToClearEnd = ToClear0 + 256;
+	}
+
+ static void
+KWmembump(size_t L)
+{
+	KWmblk *mb, *mb1;
+	size_t L1;
+
+	for(L1 = KWmblk_gulp; L1 < L; L1 <<= 1);
+	if ((mb = mb1 = KWmblk1->next) && L1 <= mb->len)
+		L1 = mb->len;
+	else {
+		KWmblk1->next = mb = (KWmblk*)Alloc("KWmembump", L1 + sizeof(KWmblk));
+		mb->len = L1;
+		mb->next = mb1;
+		}
+	KWmblk1 = mb;
+	KWmem0 = (char*)(mb+1);
+	KWmem1 = KWmem0 + L1;
+	}
+
+ static void *
+KWgetmem(size_t L)	/* for aligned memory */
+{
+	void *rv;
+
+	L = (L + sizeof(Real) - 1) & ~(sizeof(Real) - 1);
+	if (KWmem1 - KWmem0 < L)
+		KWmembump(L);
+	rv = (void*)KWmem0;
+	KWmem0 += L;
+	return rv;
+	}
+
+ static KWseen **
+KWhash(const char *s, KeyWord *kw)
+{
+	AVLCmpInfo AI;
+	KWseen KW0, *KW0p, *kws, **kwsp;
+	char **ps;
+	const char *sa, *sb;
+
+	AI.nfound = 0;
+	AI.inexact = -1;
+	AVL_setv(AVLT, &AI);
+	KW0.name = s;
+	KW0.kw = kw;
+	KW0p = &KW0;
+	curkws = 0;
+	if ((kwsp = (KWseen**)AVL_find((const Element*)&KW0p, AVLT)))
+		return kwsp;
+	if (AI.nfound) {
+		if (AI.nfound == 1) {
+			AI.inexact = 1;
+			AVL_find((const Element*)&KW0p, AVLT);
+			if (AI.nfound == 1) {
+				if (kw && (kw->kind & (KWKind_Libname | KWKind_Loaded))
+						== KWKind_Libname
+				 && (ps = (*AI.found[0])->svals))
+					read_lib(ps[0], kw);
+				return AI.found[0];
+				}
+			}
+		sa = (*AI.found[0])->name;
+		sb = (*AI.found[1])->name;
+		if (kw)
+			squawk("Both '%s' and '%s' match '%s'",
+				sa, sb, s);
+		else
+			squawk("'%s' is ambiguous:\n\tit matches both '%s' and '%s'",
+				s, sa, sb);
+		return AI.found[0];
+		}
+	kws = (KWseen*)KWgetmem(sizeof(KWseen));
+	memset(kws, 0, sizeof(KWseen));
+	if ((kws->kw = kw))
+		s = kw->name;
+	else {
+		curkws = kws;
+		kws->mnext = &KWmissing;
+		KWmissing.mprev = (kws->mprev = KWmissing.mprev)->mnext = kws;
+		s = nidr_KWscopy(s);
+		}
+	kws->name = s;
+	if (KW_p >= KW_pe) {
+		KW_p = (KWseen**)KWgetmem(32*sizeof(KWseen*));
+		KW_pe = KW_p + 32;
+		}
+	*(kwsp = KW_p++) = kws;
+	AVL_insert((const Element*)kwsp, AVLT);
+	return kwsp;
+	}
+
+ static void
+mixed_squawk(void)
+{
+	squawk("values for %s cannot be both strings and numbers",
+		KW_cur->name);
+	}
+
+ static void
+nidr_bufr_relaxed(Real r, int state)
+{
+	int n;
+
+	if (KWval.rstate && !state)
+		finish_rexpand();
+	if (!(n = KWval.n)) {
+		KWval.r = KWvalbuf;
+		KWvalmax.r = KWvalbuf + (KWvalmax.n = nKWvalbuf);
+		}
+	else if (KWval.s) {
+		mixed_squawk();
+		return;
+		}
+	if (n >= KWvalmax.n)
+		KWvalbuf_inc();
+	KWval.r[KWval.n++] = r;
+	if (state | KWval.rstate)
+		rexpand(state);
+	}
+
+ static void
+nidr_bufs_relaxed(const char *s)
+{
+	int n;
+
+	if (!(n = KWval.n)) {
+		KWval.s = (const char**)KWvalbuf;
+		KWvalmax.n = (nKWvalbuf*sizeof(Real))/sizeof(char*);
+		KWvalmax.s = KWval.s + KWvalmax.n;
+		}
+	else if (KWval.r) {
+		mixed_squawk();
+		return;
+		}
+	if (n >= KWvalmax.n)
+		KWvalbuf_inc();
+	KWval.s[KWval.n++] = s;
+	}
+
+ static void kw_setup2(KWseen*);
+
+ static void
+kw_finish1(KWseen *kws)
+{
+	KeyWord *kw;
+	int n;
+	size_t L;
+
+	if (KWval.rstate)
+		finish_rexpand();
+	kws->nvals = n = KWval.n;
+	KWval.n = 0;
+	if (KWval.r) {
+		L = n*sizeof(Real);
+		memcpy(kws->rvals = (Real*)KWgetmem(L), KWval.r, L);
+		KWval.r = 0;
+		}
+	else if (KWval.s) {
+		L = n*sizeof(char*);
+		memcpy(kws->svals = (char**)KWgetmem(L), KWval.s, L);
+		if ((kw = kws->kw) && kw->kind & KWKind_Libname) {
+			read_lib(KWval.s[0], kw);
+			if (kw->kw)
+				kw_setup2(kws);
+			}
+		KWval.s = 0;
+		}
+	}
+
+ static void*
+Alloc1(size_t len)
+{
+	void *rv = malloc(len);
+	if (!rv) {
+		fprintf(stderr, "malloc(%lu) failure in Alloc1\n", (unsigned long)len);
+		exit(1);
+		}
+	return rv;
+	}
+
+ static void
+AVL_Clear(void)
+{
+	while(ToClear > ToClear0)
+		(*--ToClear)->kind &= ~KWKind_Hashed;
+	AVL_Tree_free(&AVLT);
+	if (AVLKWP)
+		AVL_Tree_free(&AVLKWP);
+	}
+
+ static void
+kw_setup1(KeyWord *kw)
+{
+	KWseen *kws, *kws1;
+	KeyWord *kw1;
+
+	if ((kw1 = kw->kw))
+		kwnext_setup(kw1, kw->nkw);
+	if (!KWmblk0)
+		KWmeminit();
+	if (AVLT)
+		AVL_Clear();
+	AVLT = AVL_Tree_alloc(0, (AVL_Elcomp)avlcmp, Alloc1);
+	KW_cur = KWs0 = kws = (KWseen*)KWgetmem(sizeof(KWseen));
+	memset(kws, 0, sizeof(KWseen));
+	kws->name = kw->name;
+	kws->kw = kw;
+	kws->lcn = &kws->mprev;
+	if (kw1) {
+		while(!kw1->name)
+			kw1 = kw1->kwnext;
+		for(; kw1; kw1 = kw1->kwnext) {
+			kws1 = *KWhash(kw1->name, kw1);
+			kws1->parent = kws;
+			}
+		}
+	}
+
+ static KWseen**
+kw_setup3(KWseen **kwtodo1, KWseen *kws, KeyWord *kw)
+{
+	KWseen *kws1, **kwsp;
+
+	for(; kw; kw = kw->kwnext) {
+		kwsp = KWhash(kw->name, kw);
+		kws1 = *kwsp;
+		if (kws1->comment) {
+			kw->comment = kws1->comment;
+			kws1->comment = 0;
+			}
+		if (kws1->parent) {
+			kws1 = (KWseen*)KWgetmem(sizeof(KWseen));
+			memset(kws1, 0, sizeof(KWseen));
+			kws1->kw = kw;
+			kws1->name = kw->name;
+			*kwsp = kws1;
+			}
+		kws1->parent = kws;
+		if (!kws1->kw) {
+			kws1->mprev->mnext = kws1->mnext;
+			kws1->mnext->mprev = kws1->mprev;
+			*kwtodo1 = kws1;
+			kwtodo1 = kws1->lcn = &kws1->mprev;
+			*kws->lcn = kws1;
+			kws->lcn = &kws1->mnext;
+			}
+		kws1->kw = kw;
+		}
+	return kwtodo1;
+	}
+
+ static void
+bumpToClear(void)
+{
+	KeyWord **ntc;
+	size_t L, L1;
+
+	L = ToClearEnd - ToClear0;
+	L1 = L << 1;
+	ntc = (KeyWord**)Alloc("bumpToClear", L1*sizeof(KeyWord*));
+	memcpy(ntc, ToClear0, L*sizeof(KeyWord*));
+	free(ToClear0);
+	ToClear0 = ntc;
+	ToClear  = ntc + L;
+	ToClearEnd = ntc + L1;
+	}
+
+ static void
+kw_setup2(KWseen *kws)
+{
+	KWpair kwp, *pkwp;
+	KWseen *kws1, *kws2, *kws3, *kwtodo, **kwtodo1, **pkws;
+	KeyWord *kw, *kw1;
+
+	kwtodo1 = &kwtodo;
+	for(;;) {
+		kw = kws->kw;
+		if ((kw1 = kw->kw)) {
+			kwnext_setup(kw1, kw->nkw);
+			kws2 = kws;
+			while(!kw1->name) {
+				if (!AVLKWP)
+					AVLKWP = AVL_Tree_alloc(0, (AVL_Elcomp)kwpcmp, Alloc1);
+				if (kw1->kind & KWKind_Hashed) {
+					kwp.kw = kw1->kw;
+					kwp.kws = 0;
+					pkwp = (KWpair*)AVL_find((const Element*)&kwp, AVLKWP);
+					kws2 = pkwp->kws;
+					}
+				else {
+					if (ToClear >= ToClearEnd)
+						bumpToClear();
+					*ToClear++ = kw1;
+					kw1->kind |= KWKind_Hashed;
+					pkwp = (KWpair*)KWgetmem(sizeof(KWpair) + sizeof(KWseen));
+					kws1 = (KWseen*)(pkwp + 1);
+					pkwp->kw = kw1->kw;
+					pkwp->kws = kws1;
+					memset(kws1, 0, sizeof(KWseen));
+					kws1->kw = kw1;
+					kws1->name = kws->name;
+					kws1->lcn = &kws1->mprev;
+					kws1->parent = kws2;
+					*kws2->lcn = 0;
+					for(pkws = &kws2->mprev;
+						(kws3 = *pkws) && !kws3->name;
+						pkws = &kws3->mnext);
+					kws1->mnext = *pkws;
+					if (pkws == kws2->lcn)
+						kws2->lcn = &kws1->mnext;
+					kws2 = *pkws = kws1;
+					kwnext_setup(kw1->kw, kw1->nkw);
+					kwtodo1 = kw_setup3(kwtodo1, kws1, kw1->kw);
+					AVL_insert((const Element*)pkwp, AVLKWP);
+					}
+				kw1 = kw1->kwnext;
+				}
+			if (kw->nkw)
+				kwtodo1 = kw_setup3(kwtodo1, kws2, kw1);
+			}
+		*kwtodo1 = 0;
+		if (!kwtodo)
+			break;
+		kws = kwtodo;
+		kw = kws->kw;
+		if (!(kwtodo = kwtodo->mprev))
+			kwtodo1 = &kwtodo;
+		}
+	}
+
+ static KeyWord *
+nidr_identifier_relaxed(const char *name)
+{
+	KWseen *kws, *kws1;
+	KeyWord *kw;
+	int tryagain;
+
+	kw_finish1(KW_cur);
+ top:
+	KW_cur = kws = *KWhash(name, 0);
+	if ((kw = kws->kw)) {
+		curid = kw;
+		if (kws->lcn)
+			squawk("'%s' already seen", kw->name);
+		else {
+			if (kws->comment) {
+				kw->comment = kws->comment;
+				kws->comment = 0;
+				}
+			kws->lcn = &kws->mprev;
+			kws1 = kws->parent;
+			*kws1->lcn = kws;
+			kws1->lcn = &kws->mnext;
+			if (kw->kw)
+				kw_setup2(kws);
+			if (kw->kind & KWKind_Dynlib) {
+				kw = kw_insert(kw, &tryagain);
+				if (kw->kw) {
+					kws->kw = kw;
+					kw_setup2(kws);
+					}
+				if (tryagain)
+					goto top;
+				}
+			}
+		}
+	return (KeyWord*)kws;	/* just needs to be nonzero; won't be dereferenced */
+	}
+
+ static void
+num_expected(KeyWord *kw, int n)
+{
+	squawk("expected numerical value%s for %s, not quoted strings",
+		"s" + (n == 1), kw->name);
+	}
+
+ static void
+kw_process(KWseen *kws)
+{
+	KWseen *kws1;
+	KeyWord *kw;
+	Real *r;
+	Uint k;
+	int i, n;
+
+	kw = kws->kw;
+	if (kw->name) {
+		if (kws != KWs0 && !nidr_identifier_strict(kw->name))
+			botch("nidr_identifier_strict did not find \"%s\"", kw->name);
+		if ((n = KWval.n = kws->nvals)) {
+			KWval.i = 0;
+			KWval.r = 0;
+			KWval.s = 0;
+			KWval.rstate = 0;
+			switch(k = kw->kind & KWKind_Mask) {
+			  case 0:
+				squawk("No values may be specified for %s", kw->name);
+				break;
+
+			  case KWKind_Int:
+				if (!(r = kws->rvals)) {
+					num_expected(kw,n);
+					break;
+					}
+				KWval.i = (int*)KWvalbuf;
+				for(i = 0; i < n; i++)
+					KWval.i[i] = (int)r[i];
+				break;
+
+			  case KWKind_Real:
+				if (!(r = kws->rvals)) {
+					num_expected(kw,n);
+					break;
+					}
+				KWval.r = r;
+				break;
+
+			  case KWKind_Str:
+				if (!(KWval.s = (const char **)kws->svals))
+					squawk("expected string value%s for %s",
+						"s" + (n == 1), kw->name);
+			  }
+			}
+		}
+	*kws->lcn = 0;
+	for(kws1 = kws->mprev; kws1; kws1 = kws1->mnext)
+		kw_process(kws1);
+	}
+
+ static void
+kw_finish2(void)
+{
+	KWseen *kws, *kwe;
+
+	kw_finish1(KW_cur);
+	kwe = &KWmissing;
+	for(kws = KWmissing.mnext; kws != kwe; kws = kws->mnext) {
+		squawk("unrecognized identifier '%s'", kws->name);
+		}
+	KWmissing.mnext = KWmissing.mprev = &KWmissing;
+	kw_process(KWs0);
+	KWs0 = 0;
+	AVL_Clear();
+	}
+
+ static void
+kw_finish3(void)
+{
+	KWmblk1 = KWmblk0;
+	KWmem0 = (char*)(KWmblk0 + 1);
+	KWmem1 = KWmem0 + KWmblk_gulp;
+	KW_p = KW_pe = 0;
+	}
+
+ void (*nidr_bufr)(Real,int) = nidr_bufr_relaxed;
+ void (*nidr_bufs)(const char*) = nidr_bufs_relaxed;
+ KeyWord *(*nidr_identifier)(const char*) = nidr_identifier_relaxed;
+
+ void
+nidr_set_strict(int n)
+{
+	if ((strict = n)) {
+		nidr_bufr = nidr_bufr_strict;
+		nidr_bufs = nidr_bufs_strict;
+		nidr_identifier = nidr_identifier_strict;
+		}
+	else {
+		nidr_bufr = nidr_bufr_relaxed;
+		nidr_bufs = nidr_bufs_relaxed;
+		nidr_identifier = nidr_identifier_relaxed;
+		}
+	}
+
+ int
+nidr_cleanup(void)
+{
+	KWmblk *mb, *mb1;
+	Sbuf *sb, *sb1;
+
+	if (curkw)
+		nidr_keyword_finish();
+	if (dumpfile) {
+		if (OutsideComment)
+			dumpcomment(&OutsideComment);
+		if (dumpfile != stdout) {
+			fclose(dumpfile);
+			dumpfile = 0;
+			}
+		if (nidr_comment)
+			comment_reset();
+		}
+	if (ToClear0) {
+		free(ToClear0);
+		ToClear = ToClear0 = 0;
+		}
+	if ((mb1 = KWmblk0)) {
+		KWmblk0 = 0;
+		do {
+			mb = mb1;
+			mb1 = mb->next;
+			free(mb);
+			} while(mb1);
+		}
+	if (KWvalbuf) {
+		free(KWvalbuf);
+		KWvalbuf = 0;
+		}
+	if ((sb1 = KWsbuf0.next)) {
+		KWsbuf0.next = 0;
+		do {
+			sb = sb1;
+			sb1 = sb->next;
+			free(sb);
+			} while(sb1);
+		}
+	if (AVLT)
+		AVL_Clear();
+	return nidr_parse_error();
+	}
+
+ void
+nidr_setup(const char *parser, FILE *df)
+{
+	const char *s;
+	int comkeep, oneline;
+
+	if (!(s = parser))
+		return;
+	if (!strncmp(s,"nidr",4))
+		s += 4;
+	if (!strncmp(parser,"strict",6)) {
+		nidr_set_strict(1);
+		s += 6;
+		}
+	comkeep = oneline = 0;
+	if (*s == '-') for(;;) {
+		switch(*++s) {
+		  case '1':
+			++oneline;
+			continue;
+		  case 'p':
+			++primary;
+			continue;
+		  case 'c':
+			++comkeep;
+			continue;
+		  }
+		break;
+		}
+	if (df)
+		dumpfile = df;
+	else if (s[0] == ':' && s[1]) {
+		if (s[1] == '-' && !s[2])
+			dumpfile = df = stdout;
+		else {
+			dumpfile = df = fopen(++s,"w");
+			if (!dumpfile) {
+				fprintf(stderr, "Cannot open \"%s\"\n", s);
+				exit(1);
+				}
+			}
+		}
+	if (df) {
+		if (oneline)
+			dumpvals = dumpvals1;
+		if (comkeep)
+			comment_setup();
+		}
+	}
Index: /issm/trunk-jpl/externalpackages/dakota/install-6.2-linux.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/install-6.2-linux.sh	(revision 28161)
+++ /issm/trunk-jpl/externalpackages/dakota/install-6.2-linux.sh	(revision 28162)
@@ -50,6 +50,6 @@
 
 # Copy customized source and configuration files specific to Linux to 'src' directory
-cp configs/${VER}/linux/cmake/BuildDakotaCustom.cmake ${DAK_SRC}/cmake
-cp configs/${VER}/linux/cmake/DakotaDev.cmake ${DAK_SRC}/cmake
+cp configs/${VER}/cmake/BuildDakotaCustom.cmake ${DAK_SRC}/cmake
+cp configs/${VER}/cmake/DakotaDev.cmake ${DAK_SRC}/cmake
 
 # Disable requirement of Python 2 for TriBITS
Index: /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac-static.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac-static.sh	(revision 28161)
+++ /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac-static.sh	(revision 28162)
@@ -54,6 +54,6 @@
 
 # Copy customized source and configuration files specific to Mac to 'src' directory
-cp configs/${VER}/mac/static/cmake/BuildDakotaCustom.cmake ${DAK_SRC}/cmake
-cp configs/${VER}/mac/cmake/DakotaDev.cmake ${DAK_SRC}/cmake
+cp configs/${VER}/static/cmake/BuildDakotaCustom.cmake ${DAK_SRC}/cmake
+cp configs/${VER}/cmake/DakotaDev.cmake ${DAK_SRC}/cmake
 cp configs/${VER}/mac/cmake/InstallDarwinDylibs.cmake ${DAK_SRC}/cmake
 
Index: /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac.sh
===================================================================
--- /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac.sh	(revision 28161)
+++ /issm/trunk-jpl/externalpackages/dakota/install-6.2-mac.sh	(revision 28162)
@@ -51,6 +51,6 @@
 
 # Copy customized source and configuration files specific to Mac to 'src' directory
-cp configs/${VER}/mac/cmake/BuildDakotaCustom.cmake ${DAK_SRC}/cmake
-cp configs/${VER}/mac/cmake/DakotaDev.cmake ${DAK_SRC}/cmake
+cp configs/${VER}/cmake/BuildDakotaCustom.cmake ${DAK_SRC}/cmake
+cp configs/${VER}/cmake/DakotaDev.cmake ${DAK_SRC}/cmake
 cp configs/${VER}/mac/cmake/InstallDarwinDylibs.cmake ${DAK_SRC}/cmake
 
