[netcdf-libcf] 02/06: Imported Upstream version 1.0~alpha5

Bas Couwenberg sebastic at xs4all.nl
Sat Jan 24 18:08:22 UTC 2015


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

sebastic-guest pushed a commit to branch master
in repository netcdf-libcf.

commit 60f9400eb0cb87da1e1f821d7a2dc072d190fca8
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Jan 17 18:52:32 2015 +0100

    Imported Upstream version 1.0~alpha5
---
 Makefile.am                                        |     9 +-
 Makefile.in                                        |   230 +-
 acinclude.m4                                       |  1204 +-
 aclocal.m4                                         |  6945 ++++++++-
 cfcheck/Makefile.am                                |    54 +-
 cfcheck/Makefile.in                                |   260 +-
 cfcheck/cfcheck.c                                  |     2 +-
 cfcheck/tst_cfcheck.sh                             |     2 +-
 compile                                            |    17 +-
 config.guess                                       |    55 +-
 config.h.in                                        |    40 +-
 config.sub                                         |    54 +-
 configure                                          | 14909 +++++++++----------
 configure.ac                                       |   163 +-
 depcomp                                            |    87 +-
 doc/Makefile.am                                    |     2 +-
 doc/Makefile.in                                    |   206 +-
 doc/defines.texi                                   |     3 +-
 doc/libcf.info                                     |   880 +-
 doc/libcf.pdf                                      |   Bin 152955 -> 185174 bytes
 doc/libcf.ps                                       |  3475 +++--
 doc/libcf.texi                                     |   659 +-
 doc/mdate-sh                                       |    18 +-
 doc/stamp-vti                                      |     8 +-
 doc/texinfo.tex                                    |  3101 +++-
 doc/version.texi                                   |     8 +-
 gridspec/Makefile.am                               |     8 +
 {gridspec_tools_20080702 => gridspec}/Makefile.in  |   160 +-
 gridspec/shared/Makefile.am                        |     6 +
 .../shared/Makefile.in                             |   158 +-
 gridspec/shared/mosaic/Makefile.am                 |    71 +
 .../shared/mosaic/Makefile.in                      |   144 +-
 gridspec/shared/mosaic/constant.h                  |    38 +
 .../shared/mosaic/create_xgrid.c                   |     0
 .../shared/mosaic/create_xgrid.h                   |     0
 .../shared/mosaic/gradient_c2l.c                   |     0
 .../shared/mosaic/gradient_c2l.h                   |     0
 .../shared/mosaic/interp.c                         |     0
 .../shared/mosaic/interp.h                         |     0
 .../shared/mosaic/mosaic_util.c                    |     0
 .../shared/mosaic/mosaic_util.h                    |     0
 .../shared/mosaic/read_mosaic.c                    |    70 +-
 .../shared/mosaic/read_mosaic.h                    |     0
 gridspec/tools/Makefile.am                         |    12 +
 .../tools/Makefile.in                              |   282 +-
 gridspec/tools/fregrid/Makefile.am                 |    66 +
 .../tools/fregrid/Makefile.in                      |   240 +-
 .../tools/fregrid/fregrid.c                        |   298 +-
 gridspec/tools/get_data.sh                         |    27 +
 gridspec/tools/make_coupler_mosaic/Makefile.am     |    67 +
 .../tools/make_coupler_mosaic/Makefile.in          |   229 +-
 .../make_coupler_mosaic/make_coupler_mosaic.c      |   206 +
 gridspec/tools/make_hgrid/Makefile.am              |    75 +
 {cfcheck => gridspec/tools/make_hgrid}/Makefile.in |   314 +-
 .../tools/make_hgrid/make_hgrid.c                  |    28 +-
 gridspec/tools/make_hgrid/run_tests.in             |    36 +
 gridspec/tools/make_mosaic/Makefile.am             |    73 +
 .../tools/make_mosaic}/Makefile.in                 |   257 +-
 gridspec/tools/make_mosaic/make_mosaic.c           |   177 +
 gridspec/tools/make_topog/Makefile.am              |    70 +
 .../tools/make_topog/Makefile.in                   |   367 +-
 .../tools/make_topog/make_topog.c                  |   243 +-
 gridspec/tools/make_topog/run_tests.in             |    21 +
 gridspec/tools/make_vgrid/Makefile.am              |    72 +
 .../tools/make_vgrid/Makefile.in                   |   372 +-
 .../tools/make_vgrid/make_vgrid.c                  |    12 +-
 gridspec/tools/make_vgrid/run_tests.in             |    13 +
 gridspec/tools/shared/Makefile.am                  |    76 +
 .../tools/shared/Makefile.in                       |   163 +-
 .../tools/shared}/bilinear_interp.c                |    16 +-
 .../tools/shared}/bilinear_interp.h                |     0
 .../tools/shared/conserve_interp.c                 |   320 +-
 .../tools/shared}/conserve_interp.h                |     0
 .../tools/shared/create_conformal_cubic_grid.c     |     8 +-
 .../tools/shared}/create_gnomonic_cubic_grid.c     |     1 +
 .../tools/shared}/create_grid_from_file.c          |    53 +-
 .../tools/shared}/create_hgrid.h                   |     8 +-
 .../tools/shared/create_lonlat_grid.c              |     1 +
 .../tools/shared}/create_vgrid.c                   |     0
 .../tools/shared}/create_vgrid.h                   |     0
 .../tools/shared}/fregrid_util.c                   |   510 +-
 .../tools/shared}/fregrid_util.h                   |    16 +-
 gridspec/tools/shared/make_boundary_contact.c      |   483 +
 gridspec/tools/shared/make_boundary_contact.h      |     7 +
 gridspec/tools/shared/make_xgrid_contact.c         |   227 +
 gridspec/tools/shared/make_xgrid_contact.h         |     4 +
 .../tools/shared/mpp.c                             |     2 +-
 .../tools/shared/mpp.h                             |     1 +
 .../tools/shared/mpp_domain.c                      |     0
 .../tools/shared/mpp_domain.h                      |     0
 .../tools/shared/mpp_io.c                          |   246 +-
 .../tools/shared/mpp_io.h                          |    10 +
 gridspec/tools/shared/tool_util.c                  |  3554 +++++
 gridspec/tools/shared/tool_util.h                  |    62 +
 .../tools/shared/topog.c                           |     2 +
 .../make_topog => gridspec/tools/shared}/topog.h   |     0
 gridspec/tools/test.sh                             |    45 +
 gridspec/tools/test_all.sh                         |    47 +
 gridspec_tools_20080702/Makefile.am                |     1 -
 gridspec_tools_20080702/shared/Makefile.am         |     1 -
 gridspec_tools_20080702/shared/mosaic/Makefile.am  |    32 -
 gridspec_tools_20080702/shared/mosaic/constant.h   |     2 -
 gridspec_tools_20080702/tools/Makefile.am          |     2 -
 gridspec_tools_20080702/tools/fregrid/Makefile.am  |    45 -
 .../tools/fregrid/conserve_interp.c                |   689 -
 gridspec_tools_20080702/tools/fregrid/globals.h    |   166 -
 gridspec_tools_20080702/tools/fregrid/gs_fregrid.c |   416 -
 .../tools/make_coupler_mosaic/Makefile.am          |    41 -
 .../make_coupler_mosaic/gs_make_coupler_mosaic.c   |   218 -
 .../make_coupler_mosaic/make_coupler_mosaic.c      |  2005 ---
 .../tools/make_hgrid/Makefile.am                   |    45 -
 .../tools/make_hgrid/create_conformal_cubic_grid.c |   814 -
 .../tools/make_hgrid/create_lonlat_grid.c          |   406 -
 .../tools/make_hgrid/make_hgrid.c                  |   626 -
 .../tools/make_solo_mosaic/Makefile.am             |    43 -
 .../tools/make_solo_mosaic/Makefile.in             |   532 -
 .../tools/make_solo_mosaic/get_contact.c           |   326 -
 .../tools/make_solo_mosaic/get_contact.h           |    13 -
 .../tools/make_solo_mosaic/gs_make_solo_mosaic.c   |   152 -
 .../tools/make_solo_mosaic/make_solo_mosaic.c      |   287 -
 .../tools/make_topog/Makefile.am                   |    41 -
 gridspec_tools_20080702/tools/make_topog/topog.c   |   542 -
 .../tools/make_vgrid/Makefile.am                   |    41 -
 .../tools/make_vgrid/make_vgrid.c                  |   162 -
 .../tools/river_regrid/Makefile.am                 |    41 -
 .../tools/river_regrid/Makefile.in                 |   524 -
 .../tools/river_regrid/gs_river_regrid.c           |   119 -
 .../tools/river_regrid/river_regrid.c              |  1484 --
 gridspec_tools_20080702/tools/shared/Makefile.am   |    39 -
 .../tools/shared/bilinear_interp.c                 |  1131 --
 .../tools/shared/create_gnomonic_cubic_grid.c      |   907 --
 .../tools/shared/create_grid_from_file.c           |   152 -
 .../tools/shared/create_vgrid.c                    |    43 -
 .../tools/shared/fregrid_util.c                    |  1597 --
 gridspec_tools_20080702/tools/shared/get_contact.c |   326 -
 gridspec_tools_20080702/tools/shared/tool_util.c   |  5969 --------
 gridspec_tools_20080702/tools/shared/tool_util.h   |    69 -
 .../tools/shared/transfer_to_mosaic.c              |  1278 --
 .../tools/transfer_to_mosaic_grid/Makefile.am      |    39 -
 .../tools/transfer_to_mosaic_grid/Makefile.in      |   523 -
 .../gs_transfer_to_mosaic.c                        |    73 -
 .../transfer_to_mosaic_grid/transfer_to_mosaic.c   |  1278 --
 install-sh                                         |     5 +-
 missing                                            |    49 +-
 nfconfig.in                                        |     2 +-
 src/Makefile.am                                    |   103 +-
 src/Makefile.in                                    |   391 +-
 src/cdTimeConv.c                                   |     8 +-
 src/cddrs.h                                        |     8 +-
 src/cdms.h                                         |     8 +-
 src/cdmsint.h                                      |     8 +-
 src/cdunif.h                                       |     8 +-
 src/cfcvars.c                                      |    34 +-
 src/cferror.c                                      |     2 +-
 src/cffcvars.f90                                   |   405 +-
 src/cffiles.c                                      |    68 +-
 src/cfsubsets.c                                    |     2 +-
 src/cfvars.c                                       |    55 +-
 src/drscdf.h                                       |     8 +-
 src/libcf.h                                        |   196 +-
 src/libcf_api.f90                                  |   788 +
 src/libcf_int.h                                    |     2 +-
 src/nc_tests.h                                     |     2 +-
 src/nccoord.c                                      |     2 +-
 src/tst_coords.c                                   |     2 +-
 src/tst_cvars.c                                    |     2 +-
 src/tst_example_data.c                             |     2 +-
 src/tst_f03_file.f90                               |   126 +-
 src/tst_files.c                                    |     2 +-
 src/tst_subsets.c                                  |     2 +-
 src/tst_vars.c                                     |     2 +-
 src/tst_vert.c                                     |     2 +-
 172 files changed, 30769 insertions(+), 37230 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f60e0b4..5b8631b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,10 @@
-## This is a automake file, part of Unidata's NetCDF CF Library package.
-# Copyright 2006, see the COPYRIGHT file for more information.
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2006, see the COPYRIGHT file for more
+## information.
 
 # This is the main automake file for the NetCDF CF Library. 
 
-# $Id: Makefile.am,v 1.9 2009/04/12 14:18:13 ed Exp $
+# $Id: Makefile.am,v 1.2 2009/09/08 17:14:51 ed Exp $
 
 # These files get added to the distribution.
 EXTRA_DIST = COPYRIGHT
@@ -22,7 +23,7 @@ endif
 
 # Does the user want to build the gridspec?
 if BUILD_GRIDSPEC
-GRIDSPEC = gridspec_tools_20080702
+GRIDSPEC = gridspec
 endif
 
 SUBDIRS = $(GRIDSPEC) src $(CFCHECK) $(DOC) 
diff --git a/Makefile.in b/Makefile.in
index 9e2bb04..b443dee 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,15 +15,14 @@
 
 @SET_MAKE@
 
-# Copyright 2006, see the COPYRIGHT file for more information.
-
 # This is the main automake file for the NetCDF CF Library. 
 
-# $Id: Makefile.am,v 1.9 2009/04/12 14:18:13 ed Exp $
+# $Id: Makefile.am,v 1.2 2009/09/08 17:14:51 ed Exp $
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -54,6 +54,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -65,18 +66,45 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
 	ps-recursive uninstall-recursive
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir dist dist-all distcheck
 ETAGS = etags
 CTAGS = ctags
-DIST_SUBDIRS = gridspec_tools_20080702 src cfcheck doc
+DIST_SUBDIRS = gridspec src cfcheck doc
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
 am__remove_distdir = \
-  { test ! -d $(distdir) \
-    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
-         && rm -fr $(distdir); }; }
-DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2 $(distdir).tar.Z \
-	$(distdir).zip
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
 distuninstallcheck_listfiles = find . -type f -print
 distcleancheck_listfiles = find . -type f -print
@@ -92,7 +120,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -109,12 +136,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -130,13 +156,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -153,8 +178,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -199,7 +225,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -222,7 +247,7 @@ ACLOCAL_AMFLAGS = -I m4
 @BUILD_DOCS_TRUE at DOC = doc
 
 # Does the user want to build the gridspec?
- at BUILD_GRIDSPEC_TRUE@GRIDSPEC = gridspec_tools_20080702
+ at BUILD_GRIDSPEC_TRUE@GRIDSPEC = gridspec
 SUBDIRS = $(GRIDSPEC) src $(CFCHECK) $(DOC) 
 
 # What needs to go in the binrary dist?
@@ -237,15 +262,15 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
-	      cd $(srcdir) && $(AUTOMAKE) --foreign  \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
 		&& exit 0; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -261,9 +286,10 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENC
 	$(SHELL) ./config.status --recheck
 
 $(top_srcdir)/configure:  $(am__configure_deps)
-	cd $(srcdir) && $(AUTOCONF)
+	$(am__cd) $(srcdir) && $(AUTOCONF)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
-	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
 
 config.h: stamp-h1
 	@if test ! -f $@; then \
@@ -275,7 +301,7 @@ stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status config.h
 $(srcdir)/config.h.in:  $(am__configure_deps) 
-	cd $(top_srcdir) && $(AUTOHEADER)
+	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 	rm -f stamp-h1
 	touch $@
 
@@ -299,7 +325,7 @@ clean-libtool:
 	-rm -rf .libs _libs
 
 distclean-libtool:
-	-rm -f libtool
+	-rm -f libtool config.lt
 
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
@@ -325,7 +351,7 @@ $(RECURSIVE_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done; \
 	if test "$$dot_seen" = "no"; then \
@@ -359,16 +385,16 @@ $(RECURSIVE_CLEAN_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done && test -z "$$fail"
 tags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 	done
 ctags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
 	done
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
@@ -376,14 +402,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in nfconfig.in $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
 	  include_option=--etags-include; \
@@ -395,7 +421,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in nfconfig.in $(TAGS_DEPEND
 	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test ! -f $$subdir/TAGS || \
-	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
 	list='$(SOURCES) $(HEADERS) config.h.in nfconfig.in $(LISP) $(TAGS_FILES)'; \
@@ -404,36 +430,41 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in nfconfig.in $(TAGS_DEPEND
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in nfconfig.in $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS) config.h.in nfconfig.in $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
-	test -d $(distdir) || mkdir $(distdir)
+	test -d "$(distdir)" || mkdir "$(distdir)"
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -449,41 +480,58 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
-	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test -d "$(distdir)/$$subdir" \
 	    || $(MKDIR_P) "$(distdir)/$$subdir" \
 	    || exit 1; \
-	    distdir=`$(am__cd) $(distdir) && pwd`; \
-	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
-	    (cd $$subdir && \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
 	      $(MAKE) $(AM_MAKEFLAGS) \
-	        top_distdir="$$top_distdir" \
-	        distdir="$$distdir/$$subdir" \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
 		am__remove_distdir=: \
 		am__skip_length_check=: \
+		am__skip_mode_fix=: \
 	        distdir) \
 	      || exit 1; \
 	  fi; \
 	done
-	-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+	-test -n "$(am__skip_mode_fix)" \
+	|| find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
 	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
 	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
 	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
-	|| chmod -R a+r $(distdir)
+	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
 	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
 	$(am__remove_distdir)
+
 dist-bzip2: distdir
 	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
 	$(am__remove_distdir)
@@ -491,6 +539,11 @@ dist-bzip2: distdir
 dist-lzma: distdir
 	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
 	$(am__remove_distdir)
+
+dist-xz: distdir
+	tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+	$(am__remove_distdir)
+
 dist-tarZ: distdir
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__remove_distdir)
@@ -498,6 +551,7 @@ dist-tarZ: distdir
 dist-shar: distdir
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__remove_distdir)
+
 dist-zip: distdir
 	-rm -f $(distdir).zip
 	zip -rq $(distdir).zip $(distdir)
@@ -505,10 +559,6 @@ dist-zip: distdir
 
 dist dist-all: distdir
 	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
-	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
-	-rm -f $(distdir).zip
-	zip -rq $(distdir).zip $(distdir)
 	$(am__remove_distdir)
 
 # This target untars the dist file and tries a VPATH configuration.  Then
@@ -522,6 +572,8 @@ distcheck: dist
 	  bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
 	*.tar.lzma*) \
 	  unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+	*.tar.xz*) \
+	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
 	*.tar.Z*) \
 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 	*.shar.gz*) \
@@ -533,9 +585,11 @@ distcheck: dist
 	mkdir $(distdir)/_build
 	mkdir $(distdir)/_inst
 	chmod a-w $(distdir)
+	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
-	  && cd $(distdir)/_build \
+	  && am__cwd=`pwd` \
+	  && $(am__cd) $(distdir)/_build \
 	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
@@ -557,13 +611,15 @@ distcheck: dist
 	  && rm -rf "$$dc_destdir" \
 	  && $(MAKE) $(AM_MAKEFLAGS) dist \
 	  && rm -rf $(DIST_ARCHIVES) \
-	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+	  && cd "$$am__cwd" \
+	  || exit 1
 	$(am__remove_distdir)
 	@(echo "$(distdir) archives ready for distribution: "; \
 	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
 	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
 distuninstallcheck:
-	@cd $(distuninstallcheck_dir) \
+	@$(am__cd) '$(distuninstallcheck_dir)' \
 	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
 	   || { echo "ERROR: files left after uninstall:" ; \
 	        if test -n "$(DESTDIR)"; then \
@@ -605,6 +661,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -625,6 +682,8 @@ dvi-am:
 
 html: html-recursive
 
+html-am:
+
 info: info-recursive
 
 info-am:
@@ -633,18 +692,28 @@ install-data-am:
 
 install-dvi: install-dvi-recursive
 
+install-dvi-am:
+
 install-exec-am:
 
 install-html: install-html-recursive
 
+install-html-am:
+
 install-info: install-info-recursive
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-recursive
 
+install-pdf-am:
+
 install-ps: install-ps-recursive
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-recursive
@@ -667,24 +736,24 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
-	install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+	ctags-recursive install-am install-strip tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
 	all all-am am--refresh check check-am clean clean-generic \
 	clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
-	dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \
-	distclean distclean-generic distclean-hdr distclean-libtool \
-	distclean-tags distcleancheck distdir distuninstallcheck dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-man install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs installdirs-am \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags tags-recursive uninstall uninstall-am
+	dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
+	distcheck distclean distclean-generic distclean-hdr \
+	distclean-libtool distclean-tags distcleancheck distdir \
+	distuninstallcheck dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	installdirs-am maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+	ps ps-am tags tags-recursive uninstall uninstall-am
 
 
 check_install: check install
@@ -699,6 +768,7 @@ ftpbin: install
 	echo "FCFLAGS=$(FCFLAGS) F77FLAGS=$(F77FLAGS) $F90FLAGS=$(F90FLAGS)" >> ${prefix}/README_BINARIES.txt
 	tar cf binary-libcf- at PACKAGE_VERSION@.tar -C ${prefix} ${BINFILES}
 	gzip -f binary-libcf- at PACKAGE_VERSION@.tar
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/acinclude.m4 b/acinclude.m4
index 2d8d3af..417a955 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,1170 +1,38 @@
-dnl $Id: acinclude.m4,v 1.1.1.1 2006/07/15 15:34:55 ed Exp $
-dnl UD macros for netcdf configure
-
-
-dnl Convert a string to all uppercase.
-dnl
-define([uppercase],
-[translit($1, abcdefghijklmnopqrstuvwxyz, ABCDEFGHIJKLMNOPQRSTUVWXYZ)])
-
-dnl
-dnl Check for an m4(1) preprocessor utility.
-dnl
-AC_DEFUN([UD_PROG_M4],
-[
-    case "${M4-unset}" in
-	unset) AC_CHECK_PROGS(M4, m4 gm4, m4) ;;
-	*) AC_CHECK_PROGS(M4, $M4 m4 gm4, m4) ;;
-    esac
-    AC_MSG_CHECKING(m4 flags)
-    case "${M4FLAGS-unset}" in
-	unset) M4FLAGS=-B10000 ;;
-    esac
-    AC_MSG_RESULT($M4FLAGS)
-    AC_SUBST(M4FLAGS)
-])
-
-dnl
-dnl Check for an ar(1) utility.
-dnl
-AC_DEFUN([UD_PROG_AR],
-[
-    case "${AR-unset}" in
-	unset) AC_CHECK_PROGS(AR, ar, ar) ;;
-	*) AC_CHECK_PROGS(AR, $AR ar, ar) ;;
-    esac
-    AC_MSG_CHECKING(ar flags)
-    case "${ARFLAGS-unset}" in
-	unset) ARFLAGS=cru ;;
-    esac
-    AC_MSG_RESULT($ARFLAGS)
-    AC_SUBST(ARFLAGS)
-])
-
-dnl
-dnl Check for an nm(1) utility.
-dnl
-AC_DEFUN([UD_PROG_NM],
-[
-    case "${NM-unset}" in
-	unset) AC_CHECK_PROGS(NM, nm, nm) ;;
-	*) AC_CHECK_PROGS(NM, $NM nm, nm) ;;
-    esac
-    AC_MSG_CHECKING(nm flags)
-    case "${NMFLAGS-unset}" in
-	unset) NMFLAGS= ;;
-    esac
-    AC_MSG_RESULT($NMFLAGS)
-    AC_SUBST(NMFLAGS)
-])
-
-dnl
-dnl Set the top-level source-directory.
-dnl
-AC_DEFUN([UD_SRCDIR],
-[
-    AC_MSG_CHECKING(for top-level source-directory)
-    SRCDIR=`(cd $srcdir && pwd)`
-    AC_MSG_RESULT($SRCDIR)
-    AC_SUBST(SRCDIR)
-])
-
-dnl
-dnl Check for a Standard C compiler.  Prefer a native one over the
-dnl GNU one to reduce the chance that the environment variable LIBS
-dnl will have to be set to reference the GNU C runtime library.
-dnl
-AC_DEFUN([UD_PROG_CC],
-[
-    # Because we must have a C compiler, we treat an unset CC
-    # the same as an empty CC.
-    case "${CC}" in
-	'')
-	    case `uname` in
-		ULTRIX)
-		    # The native ULTRIX C compiler isn't standard.
-		    ccs='gcc cc'
-		    ;;
-		*)
-		    # xlc is before c89 because AIX's sizeof(long long)
-		    # differs between the two.
-		    #
-		    ccs='xlc c89 acc cc gcc'
-		    ;;
-	    esac
-	    for cc in $ccs; do
-		AC_CHECK_PROG(CC, $cc, $cc)
-		case "$CC" in
-		    '') ;;
-		    *)  break
-			;;
-		esac
-	    done
-	    case "${CC}" in
-		'')
-		    AC_MSG_ERROR("Could not find C compiler")
-		    ;;
-	    esac
-	    ;;
-    esac
-    #
-    # On some systems, a discovered compiler nevertheless won't
-    # work (due to licensing, for example); thus, we check the
-    # compiler with a test program.
-    # 
-    AC_MSG_CHECKING(C compiler \"$CC\")
-    AC_TRY_COMPILE(, ,
-	AC_MSG_RESULT(works),
-	AC_MSG_RESULT(failed to compile test program))
-    AC_SUBST(CC)
-    case "$CC" in
-	*gcc*)
-	    GCC=yes		# Expected by autoconf(1) macros
-	    ;;
-    esac
-    case `uname -sr` in
-	'HP-UX A.09'*)
-	    AC_DEFINE([_HPUX_SOURCE], [], [building on HPUX system])
-	    ;;
-    esac
-])
-
-dnl
-dnl Check for a C++ compiler.  Prefer a native one over the
-dnl GNU one to reduce the chance that the environment variable LIBS
-dnl will have to be set to reference the GNU C runtime library.
-dnl
-AC_DEFUN([UD_PROG_CXX],
-[
-    case "${CXX-unset}" in
-	unset)
-	    case `uname` in
-		AIX)
-		    preferred_cxx='xlC'
-		    ;;
-	    esac
-	    possible_cxxs="${preferred_cxx} CC cxx c++ g++ gcc"
-	    ;;
-	'') AC_MSG_WARN("Empty CXX variable")
-	    possible_cxxs=
-	    ;;
-	*)  possible_cxxs=$CXX
-	    ;;
-    esac
-    case "${possible_cxxs}" in
-	'') CXX=
-	    ;;
-	*)  AC_LANG_SAVE()
-	    AC_LANG_CPLUSPLUS()
-	    for cxx in $possible_cxxs; do
-		AC_CHECK_PROG(CXX, $cxx, $cxx)
-		case "$CXX" in
-		    '') ;;
-		    *)  # On some systems, a discovered compiler nevertheless
-                        # won't work (because it's a script to a non-existant
-                        # executable, for example); thus, we check the compiler
-                        # with a test program.  We also test for "iostream" and
-                        # the standard C++ library because we need these to
-                        # work.
-			# 
-			AC_MSG_CHECKING(C++ compiler \"$CXX\")
-			AC_TRY_RUN(
- 			    [
-				#include <iostream>
-				int main() {
-				    std::cout << "";
-				    return 0;
-				}
-			    ],
-			    [
-				AC_MSG_RESULT(works)
-				break
-			    ],
-			    [
-				AC_MSG_WARN($CXX failed on standard C++ test program)
-				CXX=
-				unset ac_cv_prog_CXX
-			    ])
-			;;
-		esac
-	    done
-	    AC_LANG_RESTORE()
-	    case "${CXX}" in
-		'') AC_MSG_WARN("Could not find working C++ compiler")
-		    AC_MSG_WARN(Setting CXX to the empty string)
-		    ;;
-	    esac
-	    ;;
-    esac
-    case "${CXX}" in
-	'') AC_MSG_WARN(The C++ interface will not be built)
-	    ;;
-    esac
-    AC_SUBST(CXX)
-    case `uname` in
-	'HP-UX A.09'*)
-	    AC_DEFINE([_HPUX_SOURCE], [], [building on HPUX system])
-	    ;;
-    esac
-])
-
-
-dnl
-dnl like AC_LONG_DOUBLE, except checks for 'long long'
-dnl
-AC_DEFUN([UD_C_LONG_LONG],
-[AC_MSG_CHECKING(for long long)
-AC_CACHE_VAL(ac_cv_c_long_long,
-[if test "$GCC" = yes; then
-  ac_cv_c_long_long=yes
-else
-AC_TRY_RUN([int main() {
-long long foo = 0;
-exit(sizeof(long long) < sizeof(long)); }],
-ac_cv_c_long_long=yes, ac_cv_c_long_long=no, :)
-fi])dnl
-AC_MSG_RESULT($ac_cv_c_long_long)
-if test $ac_cv_c_long_long = yes; then
-  AC_DEFINE([HAVE_LONG_LONG], [], [have long long type])
-fi
-])
-
-dnl UD_CHECK_SIZEOF(TYPE)
-AC_DEFUN([UD_CHECK_SIZEOF],
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
-dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
-changequote([, ])dnl
-AC_MSG_CHECKING(size of $1)
-AC_CACHE_VAL(AC_CV_NAME,
-[AC_TRY_RUN([#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-main()
-{
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  fprintf(f, "%d\n", sizeof($1));
-  exit(0);
-}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, AC_CV_NAME=0)])dnl
-AC_MSG_RESULT($AC_CV_NAME)
-AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [type size])
-undefine([AC_TYPE_NAME])dnl
-undefine([AC_CV_NAME])dnl
-])
-
-
-dnl 
-dnl UD_CHECK_IEEE
-dnl If the 'double' is not an IEEE double
-dnl or the 'float' is not and IEEE single,
-dnl define NO_IEEE_FLOAT
-dnl
-AC_DEFUN([UD_CHECK_IEEE],
-[
-AC_MSG_CHECKING(for IEEE floating point format)
-AC_TRY_RUN([#ifndef NO_FLOAT_H
-#include <float.h>
-#endif
-
-#define EXIT_NOTIEEE	1
-#define EXIT_MAYBEIEEE	0
-
-int
-main()
-{
-#if	defined(FLT_RADIX)	&& FLT_RADIX != 2
-		return EXIT_NOTIEEE;
-#elif	defined(DBL_MAX_EXP)	&& DBL_MAX_EXP != 1024
-		return EXIT_NOTIEEE;
-#elif	defined(DBL_MANT_DIG)	&& DBL_MANT_DIG != 53
-		return EXIT_NOTIEEE;
-#elif 	defined(FLT_MAX_EXP)	&& !(FLT_MAX_EXP == 1024 || FLT_MAX_EXP == 128)
-		return EXIT_NOTIEEE;
-#elif	defined(FLT_MANT_DIG)	&& !(FLT_MANT_DIG == 53 || FLT_MANT_DIG == 24)
-		return EXIT_NOTIEEE;
-#else
-	/* (assuming eight bit char) */
-	if(sizeof(double) != 8)
-		return EXIT_NOTIEEE;
-	if(!(sizeof(float) == 4 || sizeof(float) == 8))
-		return EXIT_NOTIEEE;
-
-	return EXIT_MAYBEIEEE;
-#endif
-}],ac_cv_c_ieeefloat=yes, ac_cv_c_ieeefloat=no, :)
-AC_MSG_RESULT($ac_cv_c_ieeefloat)
-if test $ac_cv_c_ieeefloat = no; then
-  AC_DEFINE([NO_IEEE_FLOAT], [], [no IEEE float on this platform])
-fi
-])
-
-dnl Check for utility for generating makefile dependencies.
-dnl Should only be used at the UPC.
-dnl
-AC_DEFUN([UD_PROG_CC_MAKEDEPEND],
-[
-    AC_MSG_CHECKING(how to make dependencies)
-    case `uname -s` in
-	IRIX*|OSF1)
-	    CC_MAKEDEPEND='cc -M'
-	    ;;
-	SunOS)
-	    case `uname -r` in
-		4*)
-		    CC_MAKEDEPEND='cc -M'
-		    ;;
-		5*|*)
-		    CC_MAKEDEPEND='cc -xM'
-		    ;;
-	    esac
-	    ;;
-	ULTRIX)
-	    case `uname -m` in
-		RISC)
-		    CC_MAKEDEPEND='cc -M'
-		    ;;
-		VAX)	# Can't handle prototypes in netcdf.h
-		    ;;
-	    esac
-	    ;;
-	AIX)	# Writes to .u files rather than standard out
-	    ;;
-	HP-UX)	# Writes escaped newlines to standard error
-	    ;;
-    esac
-    case "${CC_MAKEDEPEND}" in
-	'')
-	    CC_MAKEDEPEND=false
-	    ;;
-    esac
-    AC_MSG_RESULT($CC_MAKEDEPEND)
-    AC_SUBST(CC_MAKEDEPEND)
-])
-
-
-dnl Check for Fortran-90 compiler.
-dnl
-AC_DEFUN([UD_PROG_F90],
-[
-    case "${F90+set}" in
-	set)
-	    AC_MSG_CHECKING(user-defined Fortran-90 compiler \"$F90\")
-	    cat <<EOF >conftest.f90
-		subroutine foo(bar)
-		integer, intent(in) :: bar
-		end subroutine foo
-EOF
-	    doit='$F90 -c ${F90FLAGS} conftest.f90'
-	    if AC_TRY_EVAL(doit); then
-		AC_MSG_RESULT(works)
-	    else
-		AC_MSG_RESULT(failed to compile test program)
-		unset F90
-	    fi
-	    rm -f conftest.*
-	    ;;
-	*)
-	    case "${FC+set}" in
-		set)
-		    F90=$FC
-		    FFLAGS="${FCFLAGS-}"
-		    F90FLAGS="${F90FLAGS-${FFLAGS-}}"
-		    F90LIBS="${F90LIBS-${FLIBS}}"
-		    cat <<EOF >conftest.f90
-			program foo
-			call bar(1)
-			end program foo
-			subroutine bar(bof)
-			integer, intent(in) :: bof
-			end subroutine bar
-EOF
-		    AC_MSG_CHECKING(\"$F90\" as Fortran-90 compiler)
-		    doit='$F90 -o conftest ${F90FLAGS} conftest.f90 ${F90LIBS}'
-		    if AC_TRY_EVAL(doit); then
-			doit=./conftest
-			if AC_TRY_EVAL(doit); then
-			    AC_MSG_RESULT(works)
-			else
-			    AC_MSG_RESULT(failed to build executable program)
-			    unset F90
-			fi
-		    else
-			AC_MSG_RESULT(failed to build test program)
-			unset F90
-		    fi
-		    rm -f conftest*
-		    ;;
-	    esac
-	    case "${F90-unset}" in
-		unset)
-		    cat <<EOF >conftest.f90
-			program foo
-			call bar(1)
-			end program foo
-			subroutine bar(bof)
-			integer, intent(in) :: bof
-			end subroutine bar
-EOF
-		    for f90 in xlf90 f90 pgf90 g95; do
-			AC_CHECK_PROG(F90, $f90, $f90)
-			case "${F90}" in
-			    '')
-				;;
-			    *)
-				dnl Check for compiler dependant F90FLAGS. Remember not to change
-				dnl F90FLAGS if it is already set.
-AC_MSG_CHECKING(F90 F90FLAGS)
-AC_MSG_RESULT($F90 $F90FLAGS)
-				AC_MSG_CHECKING(if F90 flag needed)
-				case "${F90FLAGS-unset}" in
-				    unset)	
-					case "${F90}" in
-					     *xlf90*) 
-						  F90FLAGS='-qsuffix=f=f90'
-						  ;;
-					     *xlf95*) 
-						  F90FLAGS='-qfree=f90 -qxlf90=noautodealloc:nosignedzero -qsuffix=f=f90'
-						  ;;
-					esac
-				esac
-				AC_MSG_RESULT($F90FLAGS)
-				AC_MSG_CHECKING(Fortran-90 compiler \"$F90\")
-				doit='$F90 -o conftest ${F90FLAGS} conftest.f90 ${F90LIBS}'
-				if AC_TRY_EVAL(doit); then
-				    doit=./conftest
-				    if AC_TRY_EVAL(doit); then
-					AC_MSG_RESULT(works)
-					break;
-				    else
-					AC_MSG_RESULT(
-					    failed to build executable program)
-					unset F90
-					unset ac_cv_prog_F90
-				    fi
-				else
-				    AC_MSG_RESULT(failed to build test program)
-				    unset F90
-				    unset ac_cv_prog_F90
-				fi
-				;;
-			esac
-		    done
-		    rm -f conftest*
-		    case "${F90}" in
-			'') AC_MSG_WARN(
-			    "Could not find working Fortran-90 compiler")
-			    ;;
-		    esac
-		    ;;
-	    esac
-	    ;;
-    esac
-    case "${F90}" in
-	'')
-	    AC_MSG_WARN("The Fortran-90 interface will not be built")
-	    ;;
-    esac
-    AC_SUBST(F90)
-    AC_SUBST(F90FLAGS)
-    AC_SUBST(F90LIBS)
-])
-
-dnl Check for Fortran-77 compiler.
-dnl
-AC_DEFUN([UD_PROG_FC],
-[
-    AC_BEFORE([UD_FORTRAN_TYPES])
-    case "${FC+set}" in
-	set)
-	    case "$FC" in
-		'')
-		    AC_MSG_WARN(Fortran-77 compiler is explicitly null)
-		    ;;
-		*)
-		    AC_MSG_CHECKING(user-defined Fortran-77 compiler \"$FC\")
-		    cat <<EOF >conftest.f
-                        CALL FOO
-                        END
-EOF
-		    doit='$FC -c ${FFLAGS} conftest.f'
-		    if AC_TRY_EVAL(doit); then
-			AC_MSG_RESULT(works)
-		    else
-			AC_MSG_RESULT(failed to compile test program)
-			FC=
-		    fi
-		    rm -f conftest.*
-		    ;;
-	    esac
-	    ;;
-	*)
-	    case "${F90+set}" in
-		set)
-		    FC=$F90
-		    FFLAGS="${FFLAGS-${F90FLAGS--O}}"
-		    FLIBS="${FLIBS-${F90LIBS-}}"
-		    AC_MSG_CHECKING(\"$FC\" as Fortran-77 compiler)
-		    cat <<EOF >conftest.f
-                        CALL FOO
-                        END
-EOF
-		    doit='$FC -c ${FFLAGS} conftest.f'
-		    if AC_TRY_EVAL(doit); then
-			AC_MSG_RESULT(works)
-		    else
-			AC_MSG_RESULT(failed to compile test program)
-			unset FC
-		    fi
-		    rm -f conftest.*
-		    ;;
-	    esac
-	    case "${FC-unset}" in
-		unset)
-		    case `uname -sr` in
-			AIX*)
-			    # xlf90(1) thinks fortran/ftest.F has bad syntax.
-			    forts="xlf f77"
-			    ;;
-			BSD/OS*|FreeBSD*)
-			    forts="f77 fort77 g77"
-			    ;;
-			HP-UX*)
-			    # f77(1) doesn't have the -L option.
-			    forts=fort77
-			    FLIBS=-lU77
-			    ;;
-			IRIX*)
-			    # f90(1) can't link with c89(1)-compiled objects
-			    forts=f77
-			    ;;
-			IRIX64*)
-			    forts='f77 g77 fort77'
-			    ;;
-			Linux*)
-			    forts="pgf90 f77 fort77 g77"
-			    ;;
-			OSF1*)
-			    # The use of f90(1) results in the following for
-			    # an unknown reason (`make' works in the fortran/
-			    # directory):
-			    # f90 -c -I../libsrc ftest.F 
-			    # Last chance handler: pc = 0xa971b8, 
-			    # sp = 0x3fece0, ra = 0xa971b8
-			    # Last chance handler: internal exception: unwinding
-			    forts="f77"
-			    ;;
-			'SunOS 4'*)
-			    forts='f77 g77 fort77'
-			    ;;
-			'SunOS 5'*)
-			    # SunOS's f90(1) has problems passing a C `char'
-			    # as a Fortran `integer*1' => use f77(1)
-			    forts="pgf90 f77"
-			    ;;
-			sn*|UNICOS*|unicos*)
-			    forts="fort77 cf77 f77 g77 f90"
-			    ;;
-			*)
-			    forts="xlf fort77 ghf77 f77 cf77 g77 xlf90 f90"
-			    ;;
-		    esac
-		    for fc in $forts; do
-			AC_CHECK_PROG(FC, $fc, $fc)
-			case "${FC}" in
-			    '')
-				;;
-			    *)
-				#
-				# On some systems, a discovered compiler
-				# nevertheless won't work (due to licensing,
-				# for example); thus, we check the compiler
-				# with a test program.
-				# 
-				cat <<EOF >conftest.f
-				    CALL FOO
-				    END
-EOF
-				doit='$FC -c ${FFLAGS} conftest.f'
-				if AC_TRY_EVAL(doit); then
-				    break
-				else
-				    AC_MSG_RESULT(
-					failed to compile test program)
-				    unset FC
-				    unset ac_cv_prog_FC
-				fi
-				;;
-			esac
-		    done
-		    rm -f conftest.*
-		    case "${FC}" in
-			'') AC_MSG_WARN(
-				"Could not find working Fortran-77 compiler")
-			    ;;
-		    esac
-		    ;;
-	    esac
-	    ;;
-    esac
-    case "${FC}" in
-	'') AC_MSG_WARN("The Fortran-77 interface will not be built")
-	    ;;
-    esac
-    AC_SUBST(FC)
-    AC_SUBST(FFLAGS)
-    AC_SUBST(FLIBS)
-    #
-    # Set the make(1) macro for compiling a .F file.
-    #
-    case "${FPP-}" in
-    '')
-	AC_MSG_CHECKING(for Fortran .F compiler)
-	AC_MSG_RESULT($COMPILE_F)
-	case "${COMPILE_F-unset}" in
-	unset)
-	    case "${FC}" in
-	    '')
-		COMPILE_F=
-		;;
-	    *)
-		AC_MSG_CHECKING(if Fortran-77 compiler handles *.F files)
-		cat >conftest.h <<\EOF
-#define J 1
-EOF
-		cat >conftest.F <<\EOF
-#include "conftest.h"
-#define N 5
-		  real r(J,N)
-		  end
-EOF
-		doit='$FC -o conftest ${FFLAGS} conftest.F ${FLIBS}'
-		if AC_TRY_EVAL(doit); then
-		    COMPILE_F='$(COMPILE.f) $(FPPFLAGS)'
-		    AC_MSG_RESULT(yes)
-		else
-		    COMPILE_F=
-		    AC_MSG_RESULT(no)
-		fi
-		rm -f conftest*
-		;;
-	    esac
-	    ;;
-	esac
-	;;
-    *)
-	unset COMPILE_F
-	;;
-    esac
-    case "${COMPILE_F-}" in
-	'') UD_PROG_FPP;;
-    esac
-    AC_SUBST(COMPILE_F)
-    FPPFLAGS=${FPPFLAGS-}
-    AC_SUBST(FPPFLAGS)
-])
-
-
-dnl Check for Fortran preprocessor.
-dnl
-AC_DEFUN([UD_PROG_FPP],
-[
-    AC_MSG_CHECKING(for Fortran preprocessor)
-    case "$FPP" in
-    '')
-	AC_REQUIRE([AC_PROG_CPP])
-	FPP="$CPP"
-	;;
-    esac
-    AC_MSG_RESULT($FPP)
-    AC_SUBST(FPP)
-])
-
-
-dnl Check for a Fortran type equivalent to a netCDF type.
-dnl
-dnl UD_CHECK_FORTRAN_NCTYPE(forttype, possibs, nctype)
-dnl
-AC_DEFUN([UD_CHECK_FORTRAN_NCTYPE],
-[
-    AC_MSG_CHECKING(for Fortran-equivalent to netCDF \"$3\")
-    for type in $2; do
-	cat >conftest.f <<EOF
-               $type foo
-               end
-EOF
-	doit='$FC -c ${FFLAGS} conftest.f'
-	if AC_TRY_EVAL(doit); then
-	    break;
-	fi
-    done
-    rm -f conftest.f conftest.o
-    AC_DEFINE_UNQUOTED($1, $type, [type definition])
-    AC_MSG_RESULT($type)
-    $1=$type
-])
-
-
-dnl Check for a Fortran type equivalent to a C type.
-dnl
-dnl UD_CHECK_FORTRAN_CTYPE(v3forttype, v2forttype, ctype, min, max)
-dnl
-AC_DEFUN([UD_CHECK_FORTRAN_CTYPE],
-[
-    AC_MSG_CHECKING(for Fortran-equivalent to C \"$3\")
-    cat >conftest.f <<EOF
-        subroutine sub(values, minval, maxval)
-        implicit        none
-        $2              values(5), minval, maxval
-        minval = values(2)
-        maxval = values(4)
-        if (values(2) .ge. values(4)) then
-            minval = values(4)
-            maxval = values(2)
-        endif
-        end
-EOF
-    doit='$FC -c ${FFLAGS} conftest.f'
-    if AC_TRY_EVAL(doit); then
-	mv conftest.o conftestf.o
-	cat >conftest.c <<EOF
-#include <limits.h>
-#include <float.h>
-void main()
-{
-$3		values[[]] = {0, $4, 0, $5, 0};
-$3		minval, maxval;
-void	$FCALLSCSUB($3*, $3*, $3*);
-$FCALLSCSUB(values, &minval, &maxval);
-exit(!(minval == $4 && maxval == $5));
-}
-EOF
-	doit='$CC -o conftest ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} conftest.c conftestf.o ${LIBS}'
-	if AC_TRY_EVAL(doit); then
-	    doit=./conftest
-	    if AC_TRY_EVAL(doit); then
-		AC_MSG_RESULT($2)
-		$1=$2
-		AC_DEFINE_UNQUOTED($1,$2, [take a guess])
-	    else
-		AC_MSG_RESULT(no equivalent type)
-		unset $1
-	    fi
-	else
-	    AC_MSG_ERROR(Could not compile-and-link conftest.c and conftestf.o)
-	fi
-    else
-	AC_MSG_ERROR(Could not compile conftest.f)
-    fi
-    rm -f conftest*
-])
-
-
-dnl Check for a Fortran data type.
-dnl
-dnl UD_CHECK_FORTRAN_TYPE(varname, ftypes)
-dnl
-AC_DEFUN([UD_CHECK_FORTRAN_TYPE],
-[
-    for ftype in $2; do
-	AC_MSG_CHECKING(for Fortran \"$ftype\")
-	cat >conftest.f <<EOF
-      subroutine sub(value)
-      $ftype value
-      end
-EOF
-	doit='$FC -c ${FFLAGS} conftest.f'
-	if AC_TRY_EVAL(doit); then
-	    AC_MSG_RESULT(yes)
-	    $1=$ftype
-	    AC_DEFINE_UNQUOTED($1, $ftype, [type thing])
-	    break
-	else
-	    AC_MSG_RESULT(no)
-	fi
-    done
-    rm -f conftest*
-])
-
-
-dnl Check for the name format of a Fortran-callable C routine.
-dnl
-dnl UD_CHECK_FCALLSCSUB
-AC_DEFUN([UD_CHECK_FCALLSCSUB],
-[
-    AC_REQUIRE([UD_PROG_FC])
-    case "$FC" in
-	'') ;;
-	*)
-	    AC_REQUIRE([UD_PROG_NM])
-	    AC_BEFORE([UD_CHECK_FORTRAN_CTYPE])
-	    AC_BEFORE([UD_CHECK_CTYPE_FORTRAN])
-	    AC_MSG_CHECKING(for C-equivalent to Fortran routine \"SUB\")
-	    cat >conftest.f <<\EOF
-              call sub()
-              end
-EOF
-	    doit='$FC -c ${FFLAGS} conftest.f'
-	    if AC_TRY_EVAL(doit); then
-		FCALLSCSUB=`$NM $NMFLAGS conftest.o | awk '
-		    /SUB_/{print "SUB_";exit}
-		    /SUB/ {print "SUB"; exit}
-		    /sub_/{print "sub_";exit}
-		    /sub/ {print "sub"; exit}'`
-		case "$FCALLSCSUB" in
-		    '') AC_MSG_ERROR(not found)
-			;;
-		    *)  AC_MSG_RESULT($FCALLSCSUB)
-			;;
-		esac
-	    else
-		AC_MSG_ERROR(Could not compile conftest.f)
-	    fi
-	    rm -f conftest*
-	    ;;
-    esac
-])
-
-
-dnl Check for a C type equivalent to a Fortran type.
-dnl
-dnl UD_CHECK_CTYPE_FORTRAN(ftype, ctypes, fmacro_root)
-dnl
-AC_DEFUN([UD_CHECK_CTYPE_FORTRAN],
-[
-    cat >conftestf.f <<EOF
-           $1 values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in $2; do
-	AC_MSG_CHECKING(if Fortran \"$1\" is C \"$ctype\")
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[[4]];
-	    {
-		exit(values[[1]] != -2 || values[[2]] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if AC_TRY_EVAL(doit); then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if AC_TRY_EVAL(doit); then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if AC_TRY_EVAL(doit); then
-		    doit=./conftest
-		    if AC_TRY_EVAL(doit); then
-		        AC_MSG_RESULT(yes)
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
-		        AC_DEFINE_UNQUOTED(NF_$3[]_IS_C_$cname, [1], [fortran to c conversion])
-		        break
-		    else
-		        AC_MSG_RESULT(no)
-		    fi
-	        else
-		    AC_MSG_ERROR(Could not link conftestf.o and conftest.o)
-	        fi
-	    else
-		AC_MSG_ERROR(Could not compile conftestf.f)
-	    fi
-	else
-	    AC_MSG_ERROR(Could not compile conftest.c)
-	fi
-    done
-    rm -f conftest*
-])
-
-
-dnl Get information about Fortran data types.
-dnl
-AC_DEFUN([UD_FORTRAN_TYPES],
-[
-    AC_REQUIRE([UD_PROG_FC])
-    case "$FC" in
-    '')
-	;;
-    *)
-	AC_REQUIRE([UD_CHECK_FCALLSCSUB])
-	UD_CHECK_FORTRAN_TYPE(NF_INT1_T, byte integer*1 "integer(kind(1))")
-	UD_CHECK_FORTRAN_TYPE(NF_INT2_T, integer*2 "integer(kind(2))")
-
-	case "${NF_INT1_T}" in
-	    '') ;;
-	    *)  UD_CHECK_CTYPE_FORTRAN($NF_INT1_T, "signed char", INT1)
-		UD_CHECK_CTYPE_FORTRAN($NF_INT1_T, "short", INT1)
-		UD_CHECK_CTYPE_FORTRAN($NF_INT1_T, "int", INT1)
-		UD_CHECK_CTYPE_FORTRAN($NF_INT1_T, "long", INT1)
-		;;
-	esac
-	case "${NF_INT2_T}" in
-	    '') ;;
-	    *)  UD_CHECK_CTYPE_FORTRAN($NF_INT2_T, short, INT2)
-		UD_CHECK_CTYPE_FORTRAN($NF_INT2_T, int, INT2)
-		UD_CHECK_CTYPE_FORTRAN($NF_INT2_T, long, INT2)
-		;;
-	esac
-	UD_CHECK_CTYPE_FORTRAN(integer, int long, INT)
-	UD_CHECK_CTYPE_FORTRAN(real, float double, REAL)
-	UD_CHECK_CTYPE_FORTRAN(doubleprecision, double float, DOUBLEPRECISION)
-
-	UD_CHECK_FORTRAN_NCTYPE(NCBYTE_T, byte integer*1 integer, byte)
-
-	UD_CHECK_FORTRAN_NCTYPE(NCSHORT_T, integer*2 integer, short)
-dnl	UD_CHECK_FORTRAN_CTYPE(NF_SHORT_T, $NCSHORT_T, short, SHRT_MIN, SHRT_MAX)
-
-dnl	UD_CHECK_FORTRAN_NCTYPE(NCLONG_T, integer*4 integer, long)
-dnl	UD_CHECK_FORTRAN_CTYPE(NF_INT_T, integer, int, INT_MIN, INT_MAX)
-
-dnl	UD_CHECK_FORTRAN_NCTYPE(NCFLOAT_T, real*4 real, float)
-dnl	UD_CHECK_FORTRAN_CTYPE(NF_FLOAT_T, $NCFLOAT_T, float, FLT_MIN, FLT_MAX)
-
-dnl	UD_CHECK_FORTRAN_NCTYPE(NCDOUBLE_T, real*8 doubleprecision real, double)
-dnl	UD_CHECK_FORTRAN_CTYPE(NF_DOUBLE_T, $NCDOUBLE_T, double, DBL_MIN, DBL_MAX)
-	;;
-    esac
-])
-
-
-dnl Setup for making a manual-page database.
-dnl
-AC_DEFUN([UD_MAKEWHATIS],
-[
-    #
-    # NB: We always want to define WHATIS to prevent the
-    # $(MANDIR)/$(WHATIS) make(1) target from being just $(MANDIR)/ and
-    # conflicting with the (directory creation) target with the same name.
-    #
-    WHATIS=whatis
-    case `uname -sr` in
-	BSD/OS*|FreeBSD*)
-	    # Can't generate a user-database -- only /usr/share/man/whatis.db.
-	    MAKEWHATIS_CMD=
-	    ;;
-	'IRIX64 6.5'|'IRIX 6.5')
-	    MAKEWHATIS_CMD='/usr/lib/makewhatis -M $(MANDIR) $(MANDIR)/whatis'
-	    ;;
-	'IRIX 6'*)
-	    # Can't generate a user-database.
-	    MAKEWHATIS_CMD=
-	    ;;
-	HP-UX*)
-	    # Can't generate a user-database -- only /usr/lib/whatis.
-	    MAKEWHATIS_CMD=
-	    ;;
-	'Linux '*)
-	    # /usr/sbin/makewhatis doesn't work
-	    MAKEWHATIS_CMD=
-	    ;;
-	ULTRIX*)
-	    # Can't generate a user-database -- only /usr/lib/whatis.
-	    MAKEWHATIS_CMD=
-	    ;;
-	*)
-	    if test -r /usr/man/windex; then
-		WHATIS=windex
-	    fi
-	    AC_CHECK_PROGS(prog, catman makewhatis /usr/lib/makewhatis)
-	    case "$prog" in
-		*catman*)
-		    MAKEWHATIS_CMD=$prog' -w -M $(MANDIR)'
-		    ;;
-		*makewhatis*)
-		    MAKEWHATIS_CMD=$prog' $(MANDIR)'
-		    ;;
-	    esac
-	    ;;
-    esac
-    AC_SUBST(WHATIS)
-    AC_SUBST(MAKEWHATIS_CMD)
-    AC_MSG_CHECKING(for manual-page index command)
-    AC_MSG_RESULT($MAKEWHATIS_CMD)
-])
-
-
-dnl Check for the math library.
-dnl
-AC_DEFUN([UD_CHECK_LIB_MATH],
-[
-    case "${MATHLIB}" in
-	'')
-	    AC_CHECK_LIB(c, tanh, MATHLIB=,
-		    AC_CHECK_LIB(m, tanh, MATHLIB=-lm, MATHLIB=))
-	    ;;
-	*)
-	    ;;
-    esac 
-   AC_SUBST(MATHLIB)
-])
-
-
-dnl Check for the ftruncate() function and its correct behavior.
-dnl
-AC_DEFUN([UD_CHECK_FTRUNCATE],
-[
-    AC_MSG_CHECKING(for working ftruncate())
-    AC_TRY_RUN(dnl
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-main()
-{
-    char*	path = tmpnam(NULL);
-    int		exitStatus = 1;
-
-    if (path != NULL)
-    {
-	int	fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
-
-	if (fd != -1)
-	{
-	    if (write(fd, "0", 1) == 1)
-	    {
-		off_t	pos = lseek(fd, 0, SEEK_CUR);
-
-		if (pos != (off_t)-1)
-		{
-		    if (ftruncate(fd, 512) != -1)
-		    {
-			if (pos == lseek(fd, 0, SEEK_CUR))
-			{
-			    if (lseek(fd, 0, SEEK_SET) == 0)
-			    {
-				char	buf[[512]];
-
-				if (read(fd, buf, 512) == 512)
-				    exitStatus = 0;
-			    }
-			}
-		    }
-		}
-	    }
-	    close(fd);
-	    unlink(path);
-	}
-    }
-
-    return exitStatus;
-}
-    ,
-	AC_MSG_RESULT(yes)
-	AC_DEFINE([HAVE_FTRUNCATE], [], [have ftruncate])
-    ,
-	AC_MSG_RESULT(no)
-    )
-])
-
-
-dnl Set the binary distribution directory.
-dnl
-AC_DEFUN([UD_FTPBINDIR], [dnl
-    AC_MSG_CHECKING([binary distribution directory])
-    case ${FTPBINDIR-unset} in
-	unset)
-	    system=`(system) 2>/dev/null || echo dummy_system`
-	    FTPBINDIR=${FTPDIR-/home/ftp}/pub/binary/$system
-	    ;;
-    esac
-    AC_SUBST(FTPBINDIR)dnl
-    AC_MSG_RESULT($FTPBINDIR)
-])
-
-
-dnl
-dnl
-dnl
-
-dnl
-dnl These headers won't get C style comments
-dnl
-dnl UD_CONFIG_HEADER(HEADER-TO-CREATE ...)
-AC_DEFUN([UD_CONFIG_HEADER],
-[define(UD_LIST_HEADER, $1)])
-
-
-dnl
-dnl Print which compilers are going to be used, the flags, and their
-dnl locations. This is all to assist in debugging, and help with
-dnl support questions.
-dnl
-AC_DEFUN([UD_DISPLAY_RESULTS],
-[
-AC_MSG_CHECKING(CPPFLAGS)
-AC_MSG_RESULT($CPPFLAGS)
-AC_MSG_CHECKING(CC CFLAGS)
-AC_MSG_RESULT($CC $CFLAGS)
-ud_type_cc=`type $CC`
-AC_MSG_CHECKING(type $CC)
-AC_MSG_RESULT($ud_type_cc)
-
-AC_MSG_CHECKING(CXX)
-if test -n "$CXX"; then
-	AC_MSG_RESULT($CXX)
-	AC_MSG_CHECKING(CXXFLAGS)
-	AC_MSG_RESULT($CXXFLAGS)
-	ud_type_CXX=`type $CXX`
-	AC_MSG_CHECKING(type $CXX)
-	AC_MSG_RESULT($ud_type_CXX)
-else
-	AC_MSG_RESULT(unset)
-fi
-
-AC_MSG_CHECKING(FC)
-if test -n "$FC"; then
-	AC_MSG_RESULT($FC)
-	AC_MSG_CHECKING(FFLAGS)
-	AC_MSG_RESULT($FFLAGS)
-	ud_type_fc=`type $FC`
-	AC_MSG_CHECKING(type $FC)
-	AC_MSG_RESULT($ud_type_fc)
-else
-	AC_MSG_RESULT(unset)
+AC_DEFUN([AX_F90_MODULE_FLAG],[
+AC_CACHE_CHECK([fortran 90 modules inclusion flag],
+ax_cv_f90_modflag,
+[AC_LANG_PUSH(Fortran)
+i=0
+while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do
+  i=`expr $i + 1`
+done
+mkdir tmpdir_$i
+cd tmpdir_$i
+AC_COMPILE_IFELSE([module conftest_module
+   contains
+   subroutine conftest_routine
+   write(*,'(a)') 'gotcha!'
+   end subroutine conftest_routine
+   end module conftest_module
+  ],[],[])
+cd ..
+ax_cv_f90_modflag="not found"
+for ax_flag in "-I" "-M" "-p"; do
+  if test "$ax_cv_f90_modflag" = "not found" ; then
+    ax_save_FCFLAGS="$FCFLAGS"
+    FCFLAGS="$ax_save_FCFLAGS ${ax_flag}tmpdir_$i"
+    AC_COMPILE_IFELSE([program conftest_program
+       use conftest_module
+       call conftest_routine
+       end program conftest_program
+      ],[ax_cv_f90_modflag="$ax_flag"],[])
+    FCFLAGS="$ax_save_FCFLAGS"
+  fi
+done
+rm -fr tmpdir_$i
+if test "$ax_flag" = "not found" ; then
+  AC_MSG_ERROR([unable to find compiler flag for modules inclusion])
 fi
-
-AC_MSG_CHECKING(F90)
-if test -n "$F90"; then
-	AC_MSG_RESULT($F90)
-	AC_MSG_CHECKING(F90FLAGS)
-	AC_MSG_RESULT($F90FLAGS)
-	ud_type_F90=`type $F90`
-	AC_MSG_CHECKING(type $F90)
-	AC_MSG_RESULT($ud_type_F90)
-else
-	AC_MSG_RESULT(unset)
-fi
-
-AC_MSG_CHECKING(AR)
-if test -n "$AR"; then
-	AC_MSG_RESULT($AR)
-	AC_MSG_CHECKING(ARFLAGS)
-	AC_MSG_RESULT($ARFLAGS)
-	ud_type_AR=`type $AR`
-	AC_MSG_CHECKING(type $AR)
-	AC_MSG_RESULT($ud_type_AR)
-else
-	AC_MSG_RESULT(unset)
-fi
-
-AC_MSG_CHECKING(NM)
-if test -n "$NM"; then
-	AC_MSG_RESULT($NM)
-	AC_MSG_CHECKING(NMFLAGS)
-	AC_MSG_RESULT($NMFLAGS)
-#	ud_type_NM=`type $NM`
-#	AC_MSG_CHECKING(type $NM)
-#	AC_MSG_RESULT($ud_type_NM)
-else
-	AC_MSG_RESULT(unset)
-fi
-
-])
-
-
+AC_LANG_POP(Fortran)
+])])
 
diff --git a/aclocal.m4 b/aclocal.m4
index eab4b58..35049b6 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.11 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -13,13 +13,6652 @@
 
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(AC_AUTOCONF_VERSION, [2.62],,
-[m4_warning([this file was generated for autoconf 2.62.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
+[m4_warning([this file was generated for autoconf 2.63.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])
 
-# Copyright (C) 2002, 2003, 2005, 2006, 2007  Free Software Foundation, Inc.
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+
+# serial 52 AC_PROG_LIBTOOL
+
+
+# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+# -----------------------------------------------------------
+# If this macro is not defined by Autoconf, define it here.
+m4_ifdef([AC_PROVIDE_IFELSE],
+         [],
+         [m4_define([AC_PROVIDE_IFELSE],
+	         [m4_ifdef([AC_PROVIDE_$1],
+		           [$2], [$3])])])
+
+
+# AC_PROG_LIBTOOL
+# ---------------
+AC_DEFUN([AC_PROG_LIBTOOL],
+[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+  AC_PROVIDE_IFELSE([AC_PROG_CXX],
+    [AC_LIBTOOL_CXX],
+    [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+  ])])
+dnl And a similar setup for Fortran 77 support
+  AC_PROVIDE_IFELSE([AC_PROG_F77],
+    [AC_LIBTOOL_F77],
+    [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+])])
+
+dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+  AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+    [AC_LIBTOOL_GCJ],
+    [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+      [AC_LIBTOOL_GCJ],
+      [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+	[AC_LIBTOOL_GCJ],
+      [ifdef([AC_PROG_GCJ],
+	     [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([A][M_PROG_GCJ],
+	     [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([LT_AC_PROG_GCJ],
+	     [define([LT_AC_PROG_GCJ],
+		defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+])])# AC_PROG_LIBTOOL
+
+
+# _AC_PROG_LIBTOOL
+# ----------------
+AC_DEFUN([_AC_PROG_LIBTOOL],
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Prevent multiple expansion
+define([AC_PROG_LIBTOOL], [])
+])# _AC_PROG_LIBTOOL
+
+
+# AC_LIBTOOL_SETUP
+# ----------------
+AC_DEFUN([AC_LIBTOOL_SETUP],
+[AC_PREREQ(2.50)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+
+AC_REQUIRE([AC_PROG_LN_S])dnl
+AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+AC_REQUIRE([AC_OBJEXT])dnl
+AC_REQUIRE([AC_EXEEXT])dnl
+dnl
+AC_LIBTOOL_SYS_MAX_CMD_LEN
+AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+AC_LIBTOOL_OBJDIR
+
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+_LT_AC_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
+
+# Same as above, but do not quote variable references.
+[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+AC_CHECK_TOOL(AR, ar, false)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(STRIP, strip, :)
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    AC_PATH_MAGIC
+  fi
+  ;;
+esac
+
+_LT_REQUIRED_DARWIN_CHECKS
+
+AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+enable_win32_dll=yes, enable_win32_dll=no)
+
+AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--disable-libtool-lock],
+	[avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+AC_ARG_WITH([pic],
+    [AC_HELP_STRING([--with-pic],
+	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [pic_mode="$withval"],
+    [pic_mode=default])
+test -z "$pic_mode" && pic_mode=default
+
+# Use C for the default configuration in the libtool script
+tagname=
+AC_LIBTOOL_LANG_C_CONFIG
+_LT_AC_TAGCONFIG
+])# AC_LIBTOOL_SETUP
+
+
+# _LT_AC_SYS_COMPILER
+# -------------------
+AC_DEFUN([_LT_AC_SYS_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_AC_SYS_COMPILER
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+AC_DEFUN([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+AC_DEFUN([_LT_LINKER_BOILERPLATE],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# --------------------------
+# Check for some things on darwin
+AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS],[
+  case $host_os in
+    rhapsody* | darwin*)
+    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+
+    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+      [lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+   # By default we will add the -single_module flag. You can override
+   # by either setting the environment variable LT_MULTI_MODULE
+   # non-empty at configure time, or by adding -multi_module to the
+   # link flags.
+   echo "int foo(void){return 1;}" > conftest.c
+   $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+     -dynamiclib ${wl}-single_module conftest.c
+   if test -f libconftest.dylib; then
+     lt_cv_apple_cc_single_mod=yes
+     rm -rf libconftest.dylib*
+   fi
+   rm conftest.c
+      fi])
+    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+      [lt_cv_ld_exported_symbols_list],
+      [lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+   [lt_cv_ld_exported_symbols_list=yes],
+   [lt_cv_ld_exported_symbols_list=no])
+   LDFLAGS="$save_LDFLAGS"
+    ])
+    case $host_os in
+    rhapsody* | darwin1.[[0123]])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*)
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+   10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+   10.[[012]]*)
+     _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+   10.*)
+     _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms="~$NMEDIT -s \$output_objdir/\${libname}-symbols.expsym \${lib}"
+    fi
+    if test "$DSYMUTIL" != ":"; then
+      _lt_dsymutil="~$DSYMUTIL \$lib || :"
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+])
+
+# _LT_AC_SYS_LIBPATH_AIX
+# ----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_AC_SYS_LIBPATH_AIX
+
+
+# _LT_AC_SHELL_INIT(ARG)
+# ----------------------
+AC_DEFUN([_LT_AC_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+	     [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+	 [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_AC_SHELL_INIT
+
+
+# _LT_AC_PROG_ECHO_BACKSLASH
+# --------------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+[_LT_AC_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+  ;;
+esac
+
+echo=${ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X[$]1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+[$]*
+EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+       echo_test_string=`eval $cmd` &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+    then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+   test "X$echo_testing_string" = "X$echo_test_string"; then
+  :
+else
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    IFS="$lt_save_ifs"
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+	 test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running configure again with it.
+      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+    else
+      # Try using printf.
+      echo='printf %s\n'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+	 echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+	 test "X$echo_testing_string" = "X$echo_test_string"; then
+	# Cool, printf works
+	:
+      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	   test "X$echo_testing_string" = 'X\t' &&
+	   echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+	export CONFIG_SHELL
+	SHELL="$CONFIG_SHELL"
+	export SHELL
+	echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+	   test "X$echo_testing_string" = 'X\t' &&
+	   echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+	   test "X$echo_testing_string" = "X$echo_test_string"; then
+	echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      else
+	# maybe with a smaller string...
+	prev=:
+
+	for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+	  if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+	  then
+	    break
+	  fi
+	  prev="$cmd"
+	done
+
+	if test "$prev" != 'sed 50q "[$]0"'; then
+	  echo_test_string=`eval $prev`
+	  export echo_test_string
+	  exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+	else
+	  # Oops.  We lost completely, so just stick with echo.
+	  echo=echo
+	fi
+      fi
+    fi
+  fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+   ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(ECHO)
+])])# _LT_AC_PROG_ECHO_BACKSLASH
+
+
+# _LT_AC_LOCK
+# -----------
+AC_DEFUN([_LT_AC_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--disable-libtool-lock],
+	[avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+   fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *32-bit*)
+      case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_i386_fbsd"
+          ;;
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      libsuff=64
+      case $host in
+        x86_64-*kfreebsd*-gnu)
+          LD="${LD-ld} -m elf_x86_64_fbsd"
+          ;;
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+sparc*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*) LD="${LD-ld} -m elf64_sparc" ;;
+      *)
+        if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+  ])
+esac
+
+need_locks="$enable_libtool_lock"
+
+])# _LT_AC_LOCK
+
+
+# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+[AC_REQUIRE([LT_AC_PROG_SED])
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+  ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $rm conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$5], , :, [$5])
+else
+    ifelse([$6], , :, [$6])
+fi
+])# AC_LIBTOOL_COMPILER_OPTION
+
+
+# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                          [ACTION-SUCCESS], [ACTION-FAILURE])
+# ------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $rm -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$4], , :, [$4])
+else
+    ifelse([$5], , :, [$5])
+fi
+])# AC_LIBTOOL_LINKER_OPTION
+
+
+# AC_LIBTOOL_SYS_MAX_CMD_LEN
+# --------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+[# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ 	]]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+	       = "XX$teststring") >/dev/null 2>&1 &&
+	      new_result=`expr "X$teststring" : ".*" 2>&1` &&
+	      lt_cv_sys_max_cmd_len=$new_result &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on massive
+      # amounts of additional arguments before passing them to the linker.
+      # It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
+
+# _LT_AC_CHECK_DLFCN
+# ------------------
+AC_DEFUN([_LT_AC_CHECK_DLFCN],
+[AC_CHECK_HEADERS(dlfcn.h)dnl
+])# _LT_AC_CHECK_DLFCN
+
+
+# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ---------------------------------------------------------------------
+AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+    exit (status);
+}]
+EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_dlunknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_AC_TRY_DLOPEN_SELF
+
+
+# AC_LIBTOOL_DLOPEN_SELF
+# ----------------------
+AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+   ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+	  [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+	[AC_CHECK_FUNC([dlopen],
+	      [lt_cv_dlopen="dlopen"],
+	  [AC_CHECK_LIB([dl], [dlopen],
+		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+	    [AC_CHECK_LIB([svld], [dlopen],
+		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+	      [AC_CHECK_LIB([dld], [dld_link],
+		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+	      ])
+	    ])
+	  ])
+	])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+	  lt_cv_dlopen_self, [dnl
+	  _LT_AC_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+    	  lt_cv_dlopen_self_static, [dnl
+	  _LT_AC_TRY_DLOPEN_SELF(
+	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+])# AC_LIBTOOL_DLOPEN_SELF
+
+
+# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+# ---------------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler
+AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+])
+])# AC_LIBTOOL_PROG_CC_C_O
+
+
+# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+# -----------------------------------------
+# Check to see if we can do hard links to lock some files if needed
+AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+[AC_REQUIRE([_LT_AC_LOCK])dnl
+
+hard_links="nottested"
+if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+
+# AC_LIBTOOL_OBJDIR
+# -----------------
+AC_DEFUN([AC_LIBTOOL_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+])# AC_LIBTOOL_OBJDIR
+
+
+# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+# ----------------------------------------------
+# Check hardcoding attributes.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_AC_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+   test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_AC_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_AC_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
+
+
+# AC_LIBTOOL_SYS_LIB_STRIP
+# ------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+[striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         old_striplib="$STRIP -S"
+         AC_MSG_RESULT([yes])
+       else
+  AC_MSG_RESULT([no])
+fi
+       ;;
+   *)
+  AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+])# AC_LIBTOOL_SYS_LIB_STRIP
+
+
+# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+m4_if($1,[],[
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$lt_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    lt_search_path_spec=`echo "$lt_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`echo $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
+    }
+  }
+  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+  sys_lib_search_path_spec=`echo $lt_search_path_spec`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[[4-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  m4_if([$1], [],[
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) 
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+interix[[3-9]]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ 	]*hwcap[ 	]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+    shlibpath_overrides_runpath=no
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    shlibpath_overrides_runpath=yes
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+AC_CACHE_VAL([lt_cv_sys_lib_search_path_spec],
+[lt_cv_sys_lib_search_path_spec="$sys_lib_search_path_spec"])
+sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+AC_CACHE_VAL([lt_cv_sys_lib_dlsearch_path_spec],
+[lt_cv_sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec"])
+sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+
+
+# _LT_AC_TAGCONFIG
+# ----------------
+AC_DEFUN([_LT_AC_TAGCONFIG],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_ARG_WITH([tags],
+    [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+        [include additional configurations @<:@automatic@:>@])],
+    [tagnames="$withval"])
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+  if test ! -f "${ofile}"; then
+    AC_MSG_WARN([output file `$ofile' does not exist])
+  fi
+
+  if test -z "$LTCC"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    if test -z "$LTCC"; then
+      AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+    else
+      AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+    fi
+  fi
+  if test -z "$LTCFLAGS"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
+  fi
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+  for tagname in $tagnames; do
+    IFS="$lt_save_ifs"
+    # Check whether tagname contains only valid characters
+    case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+    "") ;;
+    *)  AC_MSG_ERROR([invalid tag name: $tagname])
+	;;
+    esac
+
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+    then
+      AC_MSG_ERROR([tag name \"$tagname\" already exists])
+    fi
+
+    # Update the list of available tags.
+    if test -n "$tagname"; then
+      echo appending configuration tag \"$tagname\" to $ofile
+
+      case $tagname in
+      CXX)
+	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+	    (test "X$CXX" != "Xg++"))) ; then
+	  AC_LIBTOOL_LANG_CXX_CONFIG
+	else
+	  tagname=""
+	fi
+	;;
+
+      F77)
+	if test -n "$F77" && test "X$F77" != "Xno"; then
+	  AC_LIBTOOL_LANG_F77_CONFIG
+	else
+	  tagname=""
+	fi
+	;;
+
+      GCJ)
+	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+	  AC_LIBTOOL_LANG_GCJ_CONFIG
+	else
+	  tagname=""
+	fi
+	;;
+
+      RC)
+	AC_LIBTOOL_LANG_RC_CONFIG
+	;;
+
+      *)
+	AC_MSG_ERROR([Unsupported tag name: $tagname])
+	;;
+      esac
+
+      # Append the new tag name to the list of available tags.
+      if test -n "$tagname" ; then
+      available_tags="$available_tags $tagname"
+    fi
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  # Now substitute the updated list of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+    mv "${ofile}T" "$ofile"
+    chmod +x "$ofile"
+  else
+    rm -f "${ofile}T"
+    AC_MSG_ERROR([unable to update list of available tagged configurations.])
+  fi
+fi
+])# _LT_AC_TAGCONFIG
+
+
+# AC_LIBTOOL_DLOPEN
+# -----------------
+# enable checks for dlopen support
+AC_DEFUN([AC_LIBTOOL_DLOPEN],
+ [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_DLOPEN
+
+
+# AC_LIBTOOL_WIN32_DLL
+# --------------------
+# declare package support for building win32 DLLs
+AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_WIN32_DLL
+
+
+# AC_ENABLE_SHARED([DEFAULT])
+# ---------------------------
+# implement the --enable-shared flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_SHARED],
+[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([shared],
+    [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+	[build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+])# AC_ENABLE_SHARED
+
+
+# AC_DISABLE_SHARED
+# -----------------
+# set the default shared flag to --disable-shared
+AC_DEFUN([AC_DISABLE_SHARED],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)
+])# AC_DISABLE_SHARED
+
+
+# AC_ENABLE_STATIC([DEFAULT])
+# ---------------------------
+# implement the --enable-static flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_STATIC],
+[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([static],
+    [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+	[build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+])# AC_ENABLE_STATIC
+
+
+# AC_DISABLE_STATIC
+# -----------------
+# set the default static flag to --disable-static
+AC_DEFUN([AC_DISABLE_STATIC],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)
+])# AC_DISABLE_STATIC
+
+
+# AC_ENABLE_FAST_INSTALL([DEFAULT])
+# ---------------------------------
+# implement the --enable-fast-install flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([fast-install],
+    [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+])# AC_ENABLE_FAST_INSTALL
+
+
+# AC_DISABLE_FAST_INSTALL
+# -----------------------
+# set the default to --disable-fast-install
+AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)
+])# AC_DISABLE_FAST_INSTALL
+
+
+# AC_LIBTOOL_PICMODE([MODE])
+# --------------------------
+# implement the --with-pic flag
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+AC_DEFUN([AC_LIBTOOL_PICMODE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+pic_mode=ifelse($#,1,$1,default)
+])# AC_LIBTOOL_PICMODE
+
+
+# AC_PROG_EGREP
+# -------------
+# This is predefined starting with Autoconf 2.54, so this conditional
+# definition can be removed once we require Autoconf 2.54 or later.
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+   [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi])
+ EGREP=$ac_cv_prog_egrep
+ AC_SUBST([EGREP])
+])])
+
+
+# AC_PATH_TOOL_PREFIX
+# -------------------
+# find a file program which can recognize shared library
+AC_DEFUN([AC_PATH_TOOL_PREFIX],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="ifelse([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+])# AC_PATH_TOOL_PREFIX
+
+
+# AC_PATH_MAGIC
+# -------------
+# find a file program which can recognize a shared library
+AC_DEFUN([AC_PATH_MAGIC],
+[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# AC_PATH_MAGIC
+
+
+# AC_PROG_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([AC_PROG_LD],
+[AC_ARG_WITH([gnu-ld],
+    [AC_HELP_STRING([--with-gnu-ld],
+	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])
+AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])# AC_PROG_LD
+
+
+# AC_PROG_LD_GNU
+# --------------
+AC_DEFUN([AC_PROG_LD_GNU],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# AC_PROG_LD_GNU
+
+
+# AC_PROG_LD_RELOAD_FLAG
+# ----------------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+])# AC_PROG_LD_RELOAD_FLAG
+
+
+# AC_DEPLIBS_CHECK_METHOD
+# -----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+[AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  if ( file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[[3-9]]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+nto-qnx*)
+  lt_cv_deplibs_check_method=unknown
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+])# AC_DEPLIBS_CHECK_METHOD
+
+
+# AC_PROG_NM
+# ----------
+# find the pathname to a BSD-compatible name lister
+AC_DEFUN([AC_PROG_NM],
+[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi])
+NM="$lt_cv_path_NM"
+])# AC_PROG_NM
+
+
+# AC_CHECK_LIBM
+# -------------
+# check for math library
+AC_DEFUN([AC_CHECK_LIBM],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+])# AC_CHECK_LIBM
+
+
+# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl convenience library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-convenience to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# it is assumed to be `libltdl'.  LIBLTDL will be prefixed with
+# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+# (note the single quotes!).  If your package is not flat and you're not
+# using automake, define top_builddir and top_srcdir appropriately in
+# the Makefiles.
+AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case $enable_ltdl_convenience in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_CONVENIENCE
+
+
+# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl installable library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-install to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# and an installed libltdl is not found, it is assumed to be `libltdl'.
+# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and top_srcdir
+# appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, lt_dlinit,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    LTDLINCL=
+  fi
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_INSTALLABLE
+
+
+# AC_LIBTOOL_CXX
+# --------------
+# enable support for C++ libraries
+AC_DEFUN([AC_LIBTOOL_CXX],
+[AC_REQUIRE([_LT_AC_LANG_CXX])
+])# AC_LIBTOOL_CXX
+
+
+# _LT_AC_LANG_CXX
+# ---------------
+AC_DEFUN([_LT_AC_LANG_CXX],
+[AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+])# _LT_AC_LANG_CXX
+
+# _LT_AC_PROG_CXXCPP
+# ------------------
+AC_DEFUN([_LT_AC_PROG_CXXCPP],
+[
+AC_REQUIRE([AC_PROG_CXX])
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+fi
+])# _LT_AC_PROG_CXXCPP
+
+# AC_LIBTOOL_F77
+# --------------
+# enable support for Fortran 77 libraries
+AC_DEFUN([AC_LIBTOOL_F77],
+[AC_REQUIRE([_LT_AC_LANG_F77])
+])# AC_LIBTOOL_F77
+
+
+# _LT_AC_LANG_F77
+# ---------------
+AC_DEFUN([_LT_AC_LANG_F77],
+[AC_REQUIRE([AC_PROG_F77])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+])# _LT_AC_LANG_F77
+
+
+# AC_LIBTOOL_GCJ
+# --------------
+# enable support for GCJ libraries
+AC_DEFUN([AC_LIBTOOL_GCJ],
+[AC_REQUIRE([_LT_AC_LANG_GCJ])
+])# AC_LIBTOOL_GCJ
+
+
+# _LT_AC_LANG_GCJ
+# ---------------
+AC_DEFUN([_LT_AC_LANG_GCJ],
+[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+	 [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+	   [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+])# _LT_AC_LANG_GCJ
+
+
+# AC_LIBTOOL_RC
+# -------------
+# enable support for Windows resource files
+AC_DEFUN([AC_LIBTOOL_RC],
+[AC_REQUIRE([LT_AC_PROG_RC])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+])# AC_LIBTOOL_RC
+
+
+# AC_LIBTOOL_LANG_C_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+[lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF
+
+# Report which library types will actually be built
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix[[4-9]]*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+    ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_C_CONFIG
+
+
+# AC_LIBTOOL_LANG_CXX_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+[AC_LANG_PUSH(C++)
+AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Dependencies to place before and after the object being linked:
+_LT_AC_TAGVAR(predep_objects, $1)=
+_LT_AC_TAGVAR(postdep_objects, $1)=
+_LT_AC_TAGVAR(predeps, $1)=
+_LT_AC_TAGVAR(postdeps, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_LD=$LD
+lt_save_GCC=$GCC
+GCC=$GXX
+lt_save_with_gnu_ld=$with_gnu_ld
+lt_save_path_LD=$lt_cv_path_LD
+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+else
+  $as_unset lt_cv_prog_gnu_ld
+fi
+if test -n "${lt_cv_path_LDCXX+set}"; then
+  lt_cv_path_LD=$lt_cv_path_LDCXX
+else
+  $as_unset lt_cv_path_LD
+fi
+test -z "${LDCXX+set}" || LD=$LDCXX
+CC=${CXX-"c++"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# We don't want -fno-exception wen compiling C++ code, so set the
+# no_builtin_flag separately
+if test "$GXX" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+else
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+fi
+
+if test "$GXX" = yes; then
+  # Set up default GNU C++ configuration
+
+  AC_PROG_LD
+
+  # Check if GNU C++ uses GNU ld as the underlying linker, since the
+  # archiving commands below assume that GNU ld is being used.
+  if test "$with_gnu_ld" = yes; then
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+    #     investigate it a little bit more. (MM)
+    wlarc='${wl}'
+
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+	grep 'no-whole-archive' > /dev/null; then
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    with_gnu_ld=no
+    wlarc=
+
+    # A generic and very simple default shared library creation
+    # command for GNU C++ for the case where it uses the native
+    # linker, instead of GNU ld.  If possible, this setting should
+    # overridden to take advantage of the native linker features on
+    # the platform it is being used on.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+  fi
+
+  # Commands to make compiler produce verbose output that lists
+  # what "hidden" libraries, object files and flags are used when
+  # linking a shared library.
+  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+else
+  GXX=no
+  with_gnu_ld=no
+  wlarc=
+fi
+
+# PORTME: fill in a description of your system's C++ link characteristics
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+case $host_os in
+  aix3*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  aix[[4-9]]*)
+    if test "$host_cpu" = ia64; then
+      # On IA64, the linker does run time linking by default, so we don't
+      # have to do anything special.
+      aix_use_runtimelinking=no
+      exp_sym_flag='-Bexport'
+      no_entry_flag=""
+    else
+      aix_use_runtimelinking=no
+
+      # Test if we are trying to use run time linking or normal
+      # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+      # need to do runtime linking.
+      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+	for ld_flag in $LDFLAGS; do
+	  case $ld_flag in
+	  *-brtl*)
+	    aix_use_runtimelinking=yes
+	    break
+	    ;;
+	  esac
+	done
+	;;
+      esac
+
+      exp_sym_flag='-bexport'
+      no_entry_flag='-bnoentry'
+    fi
+
+    # When large executables or shared objects are built, AIX ld can
+    # have problems creating the table of contents.  If linking a library
+    # or program results in "error TOC overflow" add -mminimal-toc to
+    # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+    # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+    _LT_AC_TAGVAR(archive_cmds, $1)=''
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+    if test "$GXX" = yes; then
+      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+      # We only want to do this on AIX 4.2 and lower, the check
+      # below for broken collect2 doesn't work under 4.3+
+	collect2name=`${CC} -print-prog-name=collect2`
+	if test -f "$collect2name" && \
+	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	then
+	  # We have reworked collect2
+	  :
+	else
+	  # We have old collect2
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+	fi
+	;;
+      esac
+      shared_flag='-shared'
+      if test "$aix_use_runtimelinking" = yes; then
+	shared_flag="$shared_flag "'${wl}-G'
+      fi
+    else
+      # not using gcc
+      if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	shared_flag='-G'
+      else
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag='${wl}-G'
+	else
+	  shared_flag='${wl}-bM:SRE'
+	fi
+      fi
+    fi
+
+    # It seems that -bexpall does not export symbols beginning with
+    # underscore (_), so it is better to generate a list of symbols to export.
+    _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+    if test "$aix_use_runtimelinking" = yes; then
+      # Warning - without using the other runtime loading flags (-brtl),
+      # -berok will link without error, but may produce a broken library.
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+      # Determine the default libpath from the value encoded in an empty executable.
+      _LT_AC_SYS_LIBPATH_AIX
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+     else
+      if test "$host_cpu" = ia64; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+      else
+	# Determine the default libpath from the value encoded in an empty executable.
+	_LT_AC_SYS_LIBPATH_AIX
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	# Warning - without using the other run time loading flags,
+	# -berok will link without error, but may produce a broken library.
+	_LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	# Exported symbols can be pulled into shared objects from archives
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+	# This is similar to how AIX traditionally builds its shared libraries.
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+      fi
+    fi
+    ;;
+
+  beos*)
+    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+
+  chorus*)
+    case $cc_basename in
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+
+  cygwin* | mingw* | pw32*)
+    # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+    # as there is no search path for DLLs.
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+    _LT_AC_TAGVAR(always_export_symbols, $1)=no
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+    if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      # If the export-symbols file already is a .def file (1st line
+      # is EXPORTS), use it as is; otherwise, prepend...
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	cp $export_symbols $output_objdir/$soname.def;
+      else
+	echo EXPORTS > $output_objdir/$soname.def;
+	cat $export_symbols >> $output_objdir/$soname.def;
+      fi~
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+  ;;
+      darwin* | rhapsody*)
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+      if test "$GXX" = yes ; then
+      output_verbose_link_cmd='echo'
+      _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+      _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+      if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+      fi
+      else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+      fi
+        ;;
+
+  dgux*)
+    case $cc_basename in
+      ec++*)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      ghcx*)
+	# Green Hills C++ Compiler
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  freebsd[[12]]*)
+    # C++ shared libraries reported to be fairly broken before switch to ELF
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  freebsd-elf*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    ;;
+  freebsd* | dragonfly*)
+    # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+    # conventions
+    _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+    ;;
+  gnu*)
+    ;;
+  hpux9*)
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+				# but as the default
+				# location of the library.
+
+    case $cc_basename in
+    CC*)
+      # FIXME: insert proper C++ library support
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    aCC*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      #
+      # There doesn't appear to be a way to prevent this compiler from
+      # explicitly linking system object files so we need to strip them
+      # from the output so that they don't get included in the library
+      # dependencies.
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      ;;
+    *)
+      if test "$GXX" = yes; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+        # FIXME: insert proper C++ library support
+        _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+    ;;
+  hpux10*|hpux11*)
+    if test $with_gnu_ld = no; then
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+      case $host_cpu in
+      hppa*64*|ia64*) ;;
+      *)
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        ;;
+      esac
+    fi
+    case $host_cpu in
+    hppa*64*|ia64*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+    *)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+					      # but as the default
+					      # location of the library.
+      ;;
+    esac
+
+    case $cc_basename in
+      CC*)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      aCC*)
+	case $host_cpu in
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  ;;
+	esac
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes; then
+	  if test $with_gnu_ld = no; then
+	    case $host_cpu in
+	    hppa*64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    ia64*)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    *)
+	      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      ;;
+	    esac
+	  fi
+	else
+	  # FIXME: insert proper C++ library support
+	  _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+    esac
+    ;;
+  interix[[3-9]]*)
+    _LT_AC_TAGVAR(hardcode_direct, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+    # Instead, shared libraries are loaded at an image base (0x10000000 by
+    # default) and relocated if they conflict, which is a slow very memory
+    # consuming and fragmenting process.  To avoid this, we pick a random,
+    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+    ;;
+  irix5* | irix6*)
+    case $cc_basename in
+      CC*)
+	# SGI C++
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	# Archives containing C++ object files must be created using
+	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	# necessary to make sure instantiated templates are included
+	# in the archive.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	;;
+      *)
+	if test "$GXX" = yes; then
+	  if test "$with_gnu_ld" = no; then
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	  else
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+	  fi
+	fi
+	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+	;;
+    esac
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    ;;
+  linux* | k*bsd*-gnu)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	_LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+	# Archives containing C++ object files must be created using
+	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+	;;
+      icpc*)
+	# Intel C++
+	with_gnu_ld=yes
+	# version 8.0 and above of icpc choke on multiply defined symbols
+	# if we add $predep_objects and $postdep_objects, however 7.1 and
+	# earlier do not add the objects themselves.
+	case `$CC -V 2>&1` in
+	*"Version 7."*)
+  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+  	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  ;;
+	*)  # Version 8.0 or newer
+	  tmp_idyn=
+	  case $host_cpu in
+	    ia64*) tmp_idyn=' -i_dynamic';;
+	  esac
+  	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  ;;
+	esac
+	_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	;;
+      pgCC* | pgcpp*)
+        # Portland Group C++ compiler
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+  	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+        ;;
+      cxx*)
+	# Compaq C++
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+	runpath_var=LD_RUN_PATH
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C++ 5.9
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+
+	  # Not sure whether something based on
+	  # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	  # would be better.
+	  output_verbose_link_cmd='echo'
+
+	  # Archives containing C++ object files must be created using
+	  # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	  # necessary to make sure instantiated templates are included
+	  # in the archive.
+	  _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	  ;;
+	esac
+	;;
+    esac
+    ;;
+  lynxos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  m88k*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  mvs*)
+    case $cc_basename in
+      cxx*)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    fi
+    # Workaround some broken pre-1.5 toolchains
+    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+    ;;
+  openbsd2*)
+    # C++ shared libraries are fairly broken
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  openbsd*)
+    if test -f /usr/libexec/ld.so; then
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      fi
+      output_verbose_link_cmd='echo'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+    ;;
+  osf3*)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	_LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Archives containing C++ object files must be created using
+	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+
+	;;
+      RCC*)
+	# Rational C++ 2.4.1
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      cxx*)
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	  # Commands to make compiler produce verbose output that lists
+	  # what "hidden" libraries, object files and flags are used when
+	  # linking a shared library.
+	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+	else
+	  # FIXME: insert proper C++ library support
+	  _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+    esac
+    ;;
+  osf4* | osf5*)
+    case $cc_basename in
+      KCC*)
+	# Kuck and Associates, Inc. (KAI) C++ Compiler
+
+	# KCC will only create a shared library if the output file
+	# ends with ".so" (or ".sl" for HP-UX), so rename the library
+	# to its proper name (with version) after linking.
+	_LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Archives containing C++ object files must be created using
+	# the KAI C++ compiler.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+	;;
+      RCC*)
+	# Rational C++ 2.4.1
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      cxx*)
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	  echo "-hidden">> $lib.exp~
+	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+	  $rm $lib.exp'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	# Commands to make compiler produce verbose output that lists
+	# what "hidden" libraries, object files and flags are used when
+	# linking a shared library.
+	#
+	# There doesn't appear to be a way to prevent this compiler from
+	# explicitly linking system object files so we need to strip them
+	# from the output so that they don't get included in the library
+	# dependencies.
+	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+	;;
+      *)
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	 _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	  # Commands to make compiler produce verbose output that lists
+	  # what "hidden" libraries, object files and flags are used when
+	  # linking a shared library.
+	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+	else
+	  # FIXME: insert proper C++ library support
+	  _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	fi
+	;;
+    esac
+    ;;
+  psos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  sunos4*)
+    case $cc_basename in
+      CC*)
+	# Sun C++ 4.x
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      lcc*)
+	# Lucid
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  solaris*)
+    case $cc_basename in
+      CC*)
+	# Sun C++ 4.2, 5.x and Centerline C++
+        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+	_LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	case $host_os in
+	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  *)
+	    # The compiler driver will combine and reorder linker options,
+	    # but understands `-z linker_flag'.
+	    # Supported since Solaris 2.6 (maybe 2.5.1?)
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	    ;;
+	esac
+	_LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+	output_verbose_link_cmd='echo'
+
+	# Archives containing C++ object files must be created using
+	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	# necessary to make sure instantiated templates are included
+	# in the archive.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+	;;
+      gcx*)
+	# Green Hills C++ Compiler
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+	# The C++ compiler must be used to create the archive.
+	_LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	;;
+      *)
+	# GNU C++ compiler with Solaris linker
+	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+	  if $CC --version | grep -v '^2\.7' > /dev/null; then
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+	  else
+	    # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	    # platform.
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+	  fi
+
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+	  case $host_os in
+	  solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+	  *)
+	    _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	    ;;
+	  esac
+	fi
+	;;
+    esac
+    ;;
+  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  sysv5* | sco3.2v5* | sco5v6*)
+    # Note: We can NOT use -z defs as we might desire, because we do not
+    # link with -lc, and that would cause any symbols used from libc to
+    # always be unresolved, which means just about no library would
+    # ever link correctly.  If we're not using GNU ld we use -z text
+    # though, which does catch some bad symbols but isn't as heavy-handed
+    # as -z defs.
+    # For security reasons, it is highly recommended that you always
+    # use absolute paths for naming shared libraries, and exclude the
+    # DT_RUNPATH tag from executables and libraries.  But doing so
+    # requires that you compile everything twice, which is a pain.
+    # So that behaviour is only enabled if SCOABSPATH is set to a
+    # non-empty value in the environment.  Most likely only useful for
+    # creating official distributions of packages.
+    # This is a hack until libtool officially supports absolute path
+    # names for shared libraries.
+    _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+    runpath_var='LD_RUN_PATH'
+
+    case $cc_basename in
+      CC*)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+      *)
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	;;
+    esac
+    ;;
+  tandem*)
+    case $cc_basename in
+      NCC*)
+	# NonStop-UX NCC 3.20
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+      *)
+	# FIXME: insert proper C++ library support
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	;;
+    esac
+    ;;
+  vxworks*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  *)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+esac
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$GXX"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_POSTDEP_PREDEP($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+])# AC_LIBTOOL_LANG_CXX_CONFIG
+
+# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+# ------------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+int a;
+void foo (void) { a = 0; }
+EOF
+],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+EOF
+],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+EOF
+],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  # The `*' in the case matches for architectures that use `case' in
+  # $output_verbose_cmd can trigger glob expansion during the loop
+  # eval without this substitution.
+  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+
+  for p in `eval $output_verbose_link_cmd`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" \
+	  || test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+	     _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+	   else
+	     _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+	   _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+	 else
+	   _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+	 fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+	   _LT_AC_TAGVAR(predep_objects, $1)="$p"
+	 else
+	   _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+	 fi
+       else
+	 if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+	   _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+	 else
+	   _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$rm -f confest.$objext
+
+_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+  _LT_AC_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_AC_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+# PORTME: override above test on systems where it is broken
+ifelse([$1],[CXX],
+[case $host_os in
+interix[[3-9]]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  _LT_AC_TAGVAR(predep_objects,$1)=
+  _LT_AC_TAGVAR(postdep_objects,$1)=
+  _LT_AC_TAGVAR(postdeps,$1)=
+  ;;
+
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+    #
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      _LT_AC_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+])
+case " $_LT_AC_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+])# AC_LIBTOOL_POSTDEP_PREDEP
+
+# AC_LIBTOOL_LANG_F77_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+[AC_REQUIRE([AC_PROG_F77])
+AC_LANG_PUSH(Fortran 77)
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="\
+      program t
+      end
+"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+aix[[4-9]]*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+  ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+_LT_AC_TAGVAR(GCC, $1)="$G77"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_F77_CONFIG
+
+
+# AC_LIBTOOL_LANG_GCJ_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_GCJ_CONFIG
+
+
+# AC_LIBTOOL_LANG_RC_CONFIG
+# -------------------------
+# Ensure that the configuration vars for the Windows resource compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_RC_CONFIG
+
+
+# AC_LIBTOOL_CONFIG([TAGNAME])
+# ----------------------------
+# If TAGNAME is not passed, then create an initial libtool script
+# with a default configuration from the untagged config vars.  Otherwise
+# add code to config.status for appending the configuration named by
+# TAGNAME from the matching tagged config vars.
+AC_DEFUN([AC_LIBTOOL_CONFIG],
+[# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    _LT_AC_TAGVAR(compiler, $1) \
+    _LT_AC_TAGVAR(CC, $1) \
+    _LT_AC_TAGVAR(LD, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+    _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+    _LT_AC_TAGVAR(old_archive_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+    _LT_AC_TAGVAR(predep_objects, $1) \
+    _LT_AC_TAGVAR(postdep_objects, $1) \
+    _LT_AC_TAGVAR(predeps, $1) \
+    _LT_AC_TAGVAR(postdeps, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_dirs, $1) \
+    _LT_AC_TAGVAR(archive_cmds, $1) \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(postinstall_cmds, $1) \
+    _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+    _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+    _LT_AC_TAGVAR(no_undefined_flag, $1) \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+    _LT_AC_TAGVAR(hardcode_automatic, $1) \
+    _LT_AC_TAGVAR(module_cmds, $1) \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+    _LT_AC_TAGVAR(fix_srcfile_path, $1) \
+    _LT_AC_TAGVAR(exclude_expsyms, $1) \
+    _LT_AC_TAGVAR(include_expsyms, $1); do
+
+    case $var in
+    _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(module_cmds, $1) | \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\[$]0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
+    ;;
+  esac
+
+ifelse([$1], [],
+  [cfgfile="${ofile}T"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  $rm -f "$cfgfile"
+  AC_MSG_NOTICE([creating $ofile])],
+  [cfgfile="$ofile"])
+
+  cat <<__EOF__ >> "$cfgfile"
+ifelse([$1], [],
+[#! $SHELL
+
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e 1s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG],
+[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_LTCFLAGS
+
+# A language-specific compiler.
+CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
+
+# Is the compiler the GNU C compiler?
+with_gcc=$_LT_AC_TAGVAR(GCC, $1)
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
+
+# The directories searched by this compiler when creating a shared
+# library
+compiler_lib_search_dirs=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_dirs, $1)
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
+
+# Symbols that must always be exported.
+include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
+
+ifelse([$1],[],
+[# ### END LIBTOOL CONFIG],
+[# ### END LIBTOOL TAG CONFIG: $tagname])
+
+__EOF__
+
+ifelse([$1],[], [
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "$cfgfile"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" || \
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+])
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+])# AC_LIBTOOL_CONFIG
+
+
+# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+
+_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
+
+
+# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+# ---------------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([LT_AC_PROG_SED])
+AC_REQUIRE([AC_PROG_NM])
+AC_REQUIRE([AC_OBJEXT])
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+linux* | k*bsd*-gnu)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDGIRSTW]]'
+    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris*)
+  symcode='[[BDRT]]'
+  ;;
+sco3.2v5*)
+  symcode='[[DT]]'
+  ;;
+sysv4.2uw2*)
+  symcode='[[DT]]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[[ABDT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ 	]]\($symcode$symcode*\)[[ 	]][[ 	]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if grep ' nm_test_var$' "$nlist" >/dev/null; then
+	if grep ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+	  cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[[]] =
+{
+EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+	  cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_save_LIBS="$LIBS"
+	  lt_save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS="$lt_save_LIBS"
+	  CFLAGS="$lt_save_CFLAGS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
+
+# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+# ---------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+ ifelse([$1],[CXX],[
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[[4-9]]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	else
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+       darwin*)
+         # PIC is the default on this platform
+         # Common symbols not allowed in MH_DYLIB files
+         case $cc_basename in
+           xlc*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           ;;
+         esac
+       ;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	    ;;
+	  icpc* | ecpc*)
+	    # Intel C++
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler.
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd*)
+	;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+	;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    interix[[3-9]]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	;;
+      esac
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      m4_if([$1], [GCJ], [],
+	[_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc*)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      *)
+        case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+	  _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+	  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    rdos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+	_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+	_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    unicos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_pic_works, $1),
+    [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+  _LT_AC_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+  $lt_tmp_static_flag,
+  [],
+  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+])
+
+
+# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+# ------------------------------------
+# See if the linker supports building shared libraries.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+[AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ifelse([$1],[CXX],[
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix[[4-9]]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+  ;;
+  cygwin* | mingw*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+],[
+  runpath_var=
+  _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+  _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_AC_TAGVAR(archive_cmds, $1)=
+  _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+  _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+  _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+  _LT_AC_TAGVAR(module_cmds, $1)=
+  _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(always_export_symbols, $1)=no
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  _LT_AC_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  _LT_AC_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  _LT_CC_BASENAME([$compiler])
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+  	_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[[3-9]]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+
+      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=no
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    interix[[3-9]]*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
+
+    gnu* | linux* | k*bsd*-gnu)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	tmp_addflag=
+	case $cc_basename,$host_cpu in
+	pgcc*)				# Portland Group C compiler
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	*)
+	  tmp_sharedflag='-shared' ;;
+	esac
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+	if test $supports_anon_versioning = yes; then
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+	  $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	fi
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+	;;
+	*)
+	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+	    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
+	    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
+	  else
+	    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+	  fi
+	;;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	_LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix[[4-9]]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+	  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+	else
+	  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
+
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+	  for ld_flag in $LDFLAGS; do
+  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+  	    aix_use_runtimelinking=yes
+  	    break
+  	  fi
+	  done
+	  ;;
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      _LT_AC_TAGVAR(archive_cmds, $1)=''
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[[012]]|aix4.[[012]].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" && \
+  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
+	  then
+  	  # We have reworked collect2
+  	  :
+	  else
+  	  # We have old collect2
+  	  _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+  	  # It fails to find uninstalled libraries when the uninstalled
+  	  # path is not listed in the libpath.  Setting hardcode_minus_L
+  	  # to unsupported forces relinking
+  	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+  	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  	  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+  	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       _LT_AC_SYS_LIBPATH_AIX
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+	if test "$host_cpu" = ia64; then
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an empty executable.
+	 _LT_AC_SYS_LIBPATH_AIX
+	 _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+	  _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      # see comment about different semantics on the GNU ld section
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    bsdi[[45]]*)
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+      # FIXME: Should let the user specify the lib program.
+      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[[012]])
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[[012]])
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    if test "$GCC" = yes ; then
+    	output_verbose_link_cmd='echo'
+        _LT_AC_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+        _LT_AC_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+        _LT_AC_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $xlcverstring'
+         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $xlcverstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    freebsd1*)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	_LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+	_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+	  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	  ;;
+	*)
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+	  ;;
+	esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	_LT_AC_TAGVAR(hardcode_direct, $1)=yes
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+	     ;;
+	   *)
+	     _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+        fi
+      else
+	_LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    os2*)
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+	_LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+	wlarc=''
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+ 	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+        ;;
+	motorola)
+	  _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	_LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_AC_TAGVAR(archive_cmds, $1) in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+      $rm conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+	pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+        if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+        then
+	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+        else
+	  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+        fi
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+      ;;
+    esac
+  fi
+  ;;
+esac
+])# AC_LIBTOOL_PROG_LD_SHLIBS
+
+
+# _LT_AC_FILE_LTDLL_C
+# -------------------
+# Be careful that the start marker always follows a newline.
+AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# #  ifdef __CYGWIN32__
+# #    define __CYGWIN__ __CYGWIN32__
+# #  endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+#   __hDllInstance_base = hInst;
+#   return TRUE;
+# }
+# /* ltdll.c ends here */
+])# _LT_AC_FILE_LTDLL_C
+
+
+# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+# ---------------------------------
+AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
+
+
+# old names
+AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])
+AC_DEFUN([AM_ENABLE_SHARED],  [AC_ENABLE_SHARED($@)])
+AC_DEFUN([AM_ENABLE_STATIC],  [AC_ENABLE_STATIC($@)])
+AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+AC_DEFUN([AM_PROG_LD],        [AC_PROG_LD])
+AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
+
+# This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])
+
+AC_DEFUN([LT_AC_PROG_GCJ],
+[AC_CHECK_TOOL(GCJ, gcj, no)
+  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+  AC_SUBST(GCJFLAGS)
+])
+
+AC_DEFUN([LT_AC_PROG_RC],
+[AC_CHECK_TOOL(RC, windres, no)
+])
+
+
+# Cheap backport of AS_EXECUTABLE_P and required macros
+# from Autoconf 2.59; we should not use $as_executable_p directly.
+
+# _AS_TEST_PREPARE
+# ----------------
+m4_ifndef([_AS_TEST_PREPARE],
+[m4_defun([_AS_TEST_PREPARE],
+[if test -x / >/dev/null 2>&1; then
+  as_executable_p='test -x'
+else
+  as_executable_p='test -f'
+fi
+])])# _AS_TEST_PREPARE
+
+# AS_EXECUTABLE_P
+# ---------------
+# Check whether a file is executable.
+m4_ifndef([AS_EXECUTABLE_P],
+[m4_defun([AS_EXECUTABLE_P],
+[AS_REQUIRE([_AS_TEST_PREPARE])dnl
+$as_executable_p $1[]dnl
+])])# AS_EXECUTABLE_P
+
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+# LT_AC_PROG_SED
+# --------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+AC_DEFUN([LT_AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if AS_EXECUTABLE_P(["$as_dir/$lt_ac_prog$ac_exec_ext"]); then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -31,10 +6670,10 @@ To do so, use the procedure documented by the package, typically `autoreconf'.])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.10'
+[am__api_version='1.11'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.10.1], [],
+m4_if([$1], [1.11], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -48,12 +6687,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # AM_SET_CURRENT_AUTOMAKE_VERSION
 # -------------------------------
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
-# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.10.1])dnl
+[AM_AUTOMAKE_VERSION([1.11])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
@@ -110,14 +6749,14 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 8
+# serial 9
 
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
@@ -130,6 +6769,7 @@ AC_SUBST([$1_TRUE])dnl
 AC_SUBST([$1_FALSE])dnl
 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
 _AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
 if $2; then
   $1_TRUE=
   $1_FALSE='#'
@@ -143,14 +6783,14 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 9
+# serial 10
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -207,6 +6847,16 @@ AC_CACHE_CHECK([dependency style of $depcc],
   if test "$am_compiler_list" = ""; then
      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
   fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
   for depmode in $am_compiler_list; do
     # Setup a source with many dependencies, because some compilers
     # like to wrap large dependency lists on column 80 (with \), and
@@ -224,7 +6874,17 @@ AC_CACHE_CHECK([dependency style of $depcc],
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
     case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
     nosideeffect)
       # after this tag, mechanisms are not by side-effect, so they'll
       # only be used when explicitly requested
@@ -234,19 +6894,23 @@ AC_CACHE_CHECK([dependency style of $depcc],
 	break
       fi
       ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
     none) break ;;
     esac
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.
     if depmode=$depmode \
-       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       source=sub/conftest.c object=$am__obj \
        depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
          >/dev/null 2>conftest.err &&
        grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
        grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
       # icc doesn't choke on unknown options, it will just issue warnings
       # or remarks (even with -Werror).  So we grep stderr for any message
@@ -303,57 +6967,68 @@ _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-#serial 3
+#serial 5
 
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[for mf in $CONFIG_FILES; do
-  # Strip MF so we end up with the name of the file.
-  mf=`echo "$mf" | sed -e 's/:.*$//'`
-  # Check whether this is an Automake generated Makefile or not.
-  # We used to match only the files named `Makefile.in', but
-  # some people rename them; so instead we look at the file content.
-  # Grep'ing the first line is not enough: some people post-process
-  # each Makefile.in and add a new line on top of each file to say so.
-  # Grep'ing the whole file is not good either: AIX grep has a line
-  # limit of 2048, but all sed's we know have understand at least 4000.
-  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-    dirpart=`AS_DIRNAME("$mf")`
-  else
-    continue
-  fi
-  # Extract the definition of DEPDIR, am__include, and am__quote
-  # from the Makefile without running `make'.
-  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-  test -z "$DEPDIR" && continue
-  am__include=`sed -n 's/^am__include = //p' < "$mf"`
-  test -z "am__include" && continue
-  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-  # When using ansi2knr, U may be empty or an underscore; expand it
-  U=`sed -n 's/^U = //p' < "$mf"`
-  # Find all dependency output files, they are included files with
-  # $(DEPDIR) in their names.  We invoke sed twice because it is the
-  # simplest approach to changing $(DEPDIR) to its actual value in the
-  # expansion.
-  for file in `sed -n "
-    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
-    # Make sure the directory exists.
-    test -f "$dirpart/$file" && continue
-    fdir=`AS_DIRNAME(["$file"])`
-    AS_MKDIR_P([$dirpart/$fdir])
-    # echo "creating $dirpart/$file"
-    echo '# dummy' > "$dirpart/$file"
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
   done
-done
+}
 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 
 
@@ -373,13 +7048,13 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 # Do all the work for Automake.                             -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2008 Free Software Foundation, Inc.
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 13
+# serial 16
 
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
@@ -396,7 +7071,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 # arguments mandatory, and then we can depend on a new Autoconf
 # release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.60])dnl
+[AC_PREREQ([2.62])dnl
 dnl Autoconf wants to disallow AM_ names.  We explicitly allow
 dnl the ones we care about.
 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
@@ -447,8 +7122,8 @@ AM_MISSING_PROG(AUTOCONF, autoconf)
 AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
 AM_MISSING_PROG(AUTOHEADER, autoheader)
 AM_MISSING_PROG(MAKEINFO, makeinfo)
-AM_PROG_INSTALL_SH
-AM_PROG_INSTALL_STRIP
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
 AC_REQUIRE([AM_PROG_MKDIR_P])dnl
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
@@ -456,24 +7131,37 @@ AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
-              [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
-	      		     [_AM_PROG_TAR([v7])])])
+	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+			     [_AM_PROG_TAR([v7])])])
 _AM_IF_OPTION([no-dependencies],,
 [AC_PROVIDE_IFELSE([AC_PROG_CC],
-                  [_AM_DEPENDENCIES(CC)],
-                  [define([AC_PROG_CC],
-                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+		  [_AM_DEPENDENCIES(CC)],
+		  [define([AC_PROG_CC],
+			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_CXX],
-                  [_AM_DEPENDENCIES(CXX)],
-                  [define([AC_PROG_CXX],
-                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+		  [_AM_DEPENDENCIES(CXX)],
+		  [define([AC_PROG_CXX],
+			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
-                  [_AM_DEPENDENCIES(OBJC)],
-                  [define([AC_PROG_OBJC],
-                          defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+		  [_AM_DEPENDENCIES(OBJC)],
+		  [define([AC_PROG_OBJC],
+			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
 ])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
 ])
 
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
 
 # When config.status generates a header, we must update the stamp-h file.
 # This file resides in the same directory as the config header
@@ -496,7 +7184,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -507,7 +7195,14 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
 AC_SUBST(install_sh)])
 
 # Copyright (C) 2003, 2005  Free Software Foundation, Inc.
@@ -533,13 +7228,13 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 3
+# serial 4
 
 # AM_MAKE_INCLUDE()
 # -----------------
@@ -548,7 +7243,7 @@ AC_DEFUN([AM_MAKE_INCLUDE],
 [am_make=${MAKE-make}
 cat > confinc << 'END'
 am__doit:
-	@echo done
+	@echo this is the am__doit target
 .PHONY: am__doit
 END
 # If we don't find an include directive, just comment out the code.
@@ -558,24 +7253,24 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
-   am__include=include
-   am__quote=
-   _am_result=GNU
-fi
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
 # Now try BSD make style include.
 if test "$am__include" = "#"; then
    echo '.include "confinc"' > confmf
-   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
-      am__include=.include
-      am__quote="\""
-      _am_result=BSD
-   fi
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
 fi
 AC_SUBST([am__include])
 AC_SUBST([am__quote])
@@ -583,14 +7278,14 @@ AC_MSG_RESULT([$_am_result])
 rm -f confinc confmf
 ])
 
-# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
+# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
+# serial 6
 
 # AM_PROG_CC_C_O
 # --------------
@@ -602,8 +7297,9 @@ AC_REQUIRE_AUX_FILE([compile])dnl
 # FIXME: we rely on the cache variable name because
 # there is no other way.
 set dummy $CC
-ac_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
-if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
    # Losing compiler, so override with the script.
    # FIXME: It is wrong to rewrite CC.
    # But if we don't then we get into trouble of one sort or another.
@@ -619,14 +7315,14 @@ m4_define([AC_PROG_CC],
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
+# serial 6
 
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
@@ -643,7 +7339,14 @@ AC_SUBST($1)])
 AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 AC_REQUIRE_AUX_FILE([missing])dnl
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
 # Use eval to expand $SHELL
 if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
@@ -681,13 +7384,13 @@ esac
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 3
+# serial 4
 
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
@@ -704,7 +7407,7 @@ AC_DEFUN([_AM_SET_OPTION],
 # ----------------------------------
 # OPTIONS is a space-separated list of Automake options.
 AC_DEFUN([_AM_SET_OPTIONS],
-[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
 
 # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
 # -------------------------------------------
@@ -714,14 +7417,14 @@ AC_DEFUN([_AM_IF_OPTION],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 5
 
 # AM_SANITY_CHECK
 # ---------------
@@ -730,16 +7433,29 @@ AC_DEFUN([AM_SANITY_CHECK],
 # Just in case
 sleep 1
 echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
    if test "$[*]" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftest.file`
+      set X `ls -t "$srcdir/configure" conftest.file`
    fi
    rm -f conftest.file
    if test "$[*]" != "X $srcdir/configure conftest.file" \
@@ -792,18 +7508,25 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006  Free Software Foundation, Inc.
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# serial 2
+
 # _AM_SUBST_NOTMAKE(VARIABLE)
 # ---------------------------
 # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
 # This macro is traced by Automake.
 AC_DEFUN([_AM_SUBST_NOTMAKE])
 
+# AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
 # Check how to create a tarball.                            -*- Autoconf -*-
 
 # Copyright (C) 2004, 2005  Free Software Foundation, Inc.
diff --git a/cfcheck/Makefile.am b/cfcheck/Makefile.am
index 9588892..02591a2 100644
--- a/cfcheck/Makefile.am
+++ b/cfcheck/Makefile.am
@@ -4,35 +4,61 @@
 
 # Ed Hartnett 11/23/06
 
-# $Id: Makefile.am,v 1.3 2007/05/27 06:56:11 ed Exp $
+# $Id: Makefile.am,v 1.2 2009/09/08 17:14:51 ed Exp $
 
 # Find libcf.h here.
 AM_CPPFLAGS = -I${top_srcdir}/src
-
 AM_LDFLAGS = 
+LDADD =
 
-# Link in our libcf library, also netCDF.
-LDADD = ../src/libcf.la -lnetcdf 
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-# If the user specified a root location for NETCDF, use it.
 if USE_NETCDF_DIR
 AM_CPPFLAGS += -I at NETCDFDIR@/include
 AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../libsrc4
+else
+LDADD += ../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
 endif
 
-# If the user specified a root location for HDF5, use it.
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
 if USE_HDF5_DIR
 AM_CPPFLAGS += -I at HDF5DIR@/include
 AM_LDFLAGS += -L at HDF5DIR@/lib
 endif
 
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
 EXTRA_DIST = tst_cfcheck.sh
 
 bin_PROGRAMS = cfcheck
diff --git a/cfcheck/Makefile.in b/cfcheck/Makefile.in
index 69ea17e..48023cc 100644
--- a/cfcheck/Makefile.in
+++ b/cfcheck/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -20,12 +21,13 @@
 
 # Ed Hartnett 11/23/06
 
-# $Id: Makefile.am,v 1.3 2007/05/27 06:56:11 ed Exp $
+# $Id: Makefile.am,v 1.2 2009/09/08 17:14:51 ed Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -40,19 +42,33 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_1 = -lhdf5_hl -lhdf5 -lz
-
-# If the user specified a root location for NETCDF, use it.
- at USE_NETCDF_DIR_TRUE@am__append_2 = -I at NETCDFDIR@/include
- at USE_NETCDF_DIR_TRUE@am__append_3 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_4 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_5 = -L at HDF5DIR@/lib
+ at USE_NETCDF_DIR_TRUE@am__append_1 = -I at NETCDFDIR@/include
+ at USE_NETCDF_DIR_TRUE@am__append_2 = -L at NETCDFDIR@/lib
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
 bin_PROGRAMS = cfcheck$(EXEEXT)
 subdir = cfcheck
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
@@ -66,17 +82,19 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
 am_cfcheck_OBJECTS = cfcheck.$(OBJEXT)
 cfcheck_OBJECTS = $(am_cfcheck_OBJECTS)
 cfcheck_LDADD = $(LDADD)
 am__DEPENDENCIES_1 =
-cfcheck_DEPENDENCIES = ../src/libcf.la $(am__DEPENDENCIES_1)
+cfcheck_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__append_4) \
+	$(am__append_7) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -90,6 +108,8 @@ SOURCES = $(cfcheck_SOURCES)
 DIST_SOURCES = $(cfcheck_SOURCES)
 ETAGS = etags
 CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
@@ -103,7 +123,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -120,12 +139,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -141,13 +159,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -164,8 +181,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -210,7 +228,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -223,11 +240,14 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 
 # Find libcf.h here.
-AM_CPPFLAGS = -I${top_srcdir}/src $(am__append_2) $(am__append_4)
-AM_LDFLAGS = $(am__append_3) $(am__append_5)
-
-# Link in our libcf library, also netCDF.
-LDADD = ../src/libcf.la -lnetcdf $(am__append_1)
+AM_CPPFLAGS = -I${top_srcdir}/src $(am__append_1) $(am__append_5) \
+	$(am__append_8) $(am__append_12) $(am__append_14) \
+	$(am__append_16) $(am__append_18)
+AM_LDFLAGS = $(am__append_2) $(am__append_6) $(am__append_9) \
+	$(am__append_13) $(am__append_15) $(am__append_17) \
+	$(am__append_19)
+LDADD = $(am__append_3) $(am__append_4) $(am__append_7) \
+	$(am__append_10) $(am__append_11)
 EXTRA_DIST = tst_cfcheck.sh
 cfcheck_SOURCES = cfcheck.c
 TESTS = tst_cfcheck.sh
@@ -240,14 +260,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  cfcheck/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  cfcheck/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign cfcheck/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign cfcheck/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -265,34 +285,50 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 
 clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
 cfcheck$(EXEEXT): $(cfcheck_OBJECTS) $(cfcheck_DEPENDENCIES) 
 	@rm -f cfcheck$(EXEEXT)
 	$(LINK) $(cfcheck_OBJECTS) $(cfcheck_LDADD) $(LIBS)
@@ -308,7 +344,7 @@ distclean-compile:
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -316,7 +352,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -324,7 +360,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -340,14 +376,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -355,37 +391,43 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 check-TESTS: $(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[	 ]'; \
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
 	srcdir=$(srcdir); export srcdir; \
 	list=' $(TESTS) '; \
+	$(am__tty_colors); \
 	if test -n "$$list"; then \
 	  for tst in $$list; do \
 	    if test -f ./$$tst; then dir=./; \
@@ -394,49 +436,63 @@ check-TESTS: $(TESTS)
 	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
 	      all=`expr $$all + 1`; \
 	      case " $(XFAIL_TESTS) " in \
-	      *$$ws$$tst$$ws*) \
+	      *[\ \	]$$tst[\ \	]*) \
 		xpass=`expr $$xpass + 1`; \
 		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
+		col=$$red; res=XPASS; \
 	      ;; \
 	      *) \
-		echo "PASS: $$tst"; \
+		col=$$grn; res=PASS; \
 	      ;; \
 	      esac; \
 	    elif test $$? -ne 77; then \
 	      all=`expr $$all + 1`; \
 	      case " $(XFAIL_TESTS) " in \
-	      *$$ws$$tst$$ws*) \
+	      *[\ \	]$$tst[\ \	]*) \
 		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
+		col=$$lgn; res=XFAIL; \
 	      ;; \
 	      *) \
 		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
+		col=$$red; res=FAIL; \
 	      ;; \
 	      esac; \
 	    else \
 	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
+	      col=$$blu; res=SKIP; \
 	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
 	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
 	  if test "$$failed" -eq 0; then \
 	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
+	      banner="$$All$$all $$tests passed"; \
 	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
 	    fi; \
 	  else \
 	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
+	      banner="$$failed of $$all $$tests failed"; \
 	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
 	    fi; \
 	  fi; \
 	  dashes="$$banner"; \
 	  skipped=""; \
 	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
 	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
 	      dashes="$$skipped"; \
 	  fi; \
@@ -447,11 +503,15 @@ check-TESTS: $(TESTS)
 	      dashes="$$report"; \
 	  fi; \
 	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
 	  echo "$$banner"; \
 	  test -z "$$skipped" || echo "$$skipped"; \
 	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
+	  echo "$$dashes$$std"; \
 	  test "$$failed" -eq 0; \
 	else :; fi
 
@@ -471,13 +531,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -510,6 +574,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -530,6 +595,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -538,18 +605,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -572,7 +649,7 @@ ps-am:
 
 uninstall-am: uninstall-binPROGRAMS
 
-.MAKE: install-am install-strip
+.MAKE: check-am install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
 	clean-binPROGRAMS clean-generic clean-libtool ctags distclean \
@@ -588,6 +665,7 @@ uninstall-am: uninstall-binPROGRAMS
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags uninstall uninstall-am uninstall-binPROGRAMS
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/cfcheck/cfcheck.c b/cfcheck/cfcheck.c
index c38f184..7b9fc5b 100644
--- a/cfcheck/cfcheck.c
+++ b/cfcheck/cfcheck.c
@@ -6,7 +6,7 @@
 
    Ed Hartnett, 11/23/06
 
-   $Id: cfcheck.c,v 1.2 2006/11/26 11:45:09 ed Exp $
+   $Id: cfcheck.c,v 1.2 2009/09/08 17:14:51 ed Exp $
 */
 
 #include <config.h>
diff --git a/cfcheck/tst_cfcheck.sh b/cfcheck/tst_cfcheck.sh
index 17981d3..3b2989d 100755
--- a/cfcheck/tst_cfcheck.sh
+++ b/cfcheck/tst_cfcheck.sh
@@ -7,7 +7,7 @@
 
 # Ed Hartnett, 11/23/06
 
-# $Id: tst_cfcheck.sh,v 1.2 2006/11/26 11:45:09 ed Exp $
+# $Id: tst_cfcheck.sh,v 1.2 2009/09/08 17:14:52 ed Exp $
 
 set -e
 echo ""
diff --git a/compile b/compile
index 1b1d232..ec64c62 100755
--- a/compile
+++ b/compile
@@ -1,9 +1,10 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand `-c -o'.
 
-scriptversion=2005-05-14.22
+scriptversion=2009-04-28.21; # UTC
 
-# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009  Free Software
+# Foundation, Inc.
 # Written by Tom Tromey <tromey at cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -17,8 +18,7 @@ scriptversion=2005-05-14.22
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -103,13 +103,13 @@ if test -z "$ofile" || test -z "$cfile"; then
 fi
 
 # Name of file we expect compiler to create.
-cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
 
 # Create the lock directory.
-# Note: use `[/.-]' here to ensure that we don't use the same name
+# Note: use `[/\\:.-]' here to ensure that we don't use the same name
 # that we are using for the .o file.  Also, base the name on the expected
 # object file name, since that is what matters with a parallel build.
-lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
 while true; do
   if mkdir "$lockdir" >/dev/null 2>&1; then
     break
@@ -138,5 +138,6 @@ exit $ret
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/config.guess b/config.guess
index ca2a03c..da83314 100755
--- a/config.guess
+++ b/config.guess
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 #   Free Software Foundation, Inc.
 
-timestamp='2008-01-08'
+timestamp='2009-04-27'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -324,6 +324,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	case `/usr/bin/uname -p` in
 	    sparc) echo sparc-icl-nx7; exit ;;
 	esac ;;
+    s390x:SunOS:*:*)
+	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
     sun4H:SunOS:5.*:*)
 	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
@@ -331,7 +334,20 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	eval $set_cc_for_build
+	SUN_ARCH="i386"
+	# If there is a compiler, see if it is configured for 64-bit objects.
+	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+	# This test works for both compilers.
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		SUN_ARCH="x86_64"
+	    fi
+	fi
+	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     sun4*:SunOS:6*:*)
 	# According to config.sub, this is the proper way to canonicalize
@@ -796,7 +812,7 @@ EOF
 	    x86)
 		echo i586-pc-interix${UNAME_RELEASE}
 		exit ;;
-	    EM64T | authenticamd)
+	    EM64T | authenticamd | genuineintel)
 		echo x86_64-unknown-interix${UNAME_RELEASE}
 		exit ;;
 	    IA64)
@@ -935,6 +951,9 @@ EOF
 	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
 	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
 	exit ;;
+    padre:Linux:*:*)
+	echo sparc-unknown-linux-gnu
+	exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
@@ -985,9 +1004,6 @@ EOF
 	  a.out-i386-linux)
 		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
 		exit ;;
-	  coff-i386)
-		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
-		exit ;;
 	  "")
 		# Either a pre-BFD a.out linker (linux-gnuoldld) or
 		# one that does not give us useful --help.
@@ -1102,8 +1118,11 @@ EOF
     pc:*:*:*)
 	# Left here for compatibility:
         # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i386.
-	echo i386-pc-msdosdjgpp
+        # the processor, so we play safe by assuming i586.
+	# Note: whatever this is, it MUST be the same as what config.sub
+	# prints for the "djgpp" host, or else GDB configury will decide that
+	# this is a cross-build.
+	echo i586-pc-msdosdjgpp
         exit ;;
     Intel:Mach:3*:*)
 	echo i386-pc-mach3
@@ -1141,6 +1160,16 @@ EOF
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
           && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+	OS_REL='.3'
+	test -r /etc/.relid \
+	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
 	echo m68k-unknown-lynxos${UNAME_RELEASE}
 	exit ;;
@@ -1216,6 +1245,9 @@ EOF
     BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
 	echo i586-pc-beos
 	exit ;;
+    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
+	echo i586-pc-haiku
+	exit ;;
     SX-4:SUPER-UX:*:*)
 	echo sx4-nec-superux${UNAME_RELEASE}
 	exit ;;
@@ -1324,6 +1356,9 @@ EOF
     i*86:rdos:*:*)
 	echo ${UNAME_MACHINE}-pc-rdos
 	exit ;;
+    i*86:AROS:*:*)
+	echo ${UNAME_MACHINE}-pc-aros
+	exit ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1484,9 +1519,9 @@ This script, last modified $timestamp, has failed to recognize
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
 and
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be
diff --git a/config.h.in b/config.h.in
index bf5de8a..0ee5ae5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
    systems. This function is required for `alloca.c' support on those systems.
    */
@@ -18,9 +21,6 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
-/* have ftruncate */
-#undef HAVE_FTRUNCATE
-
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -65,21 +65,6 @@
    */
 #undef LT_OBJDIR
 
-/* type definition */
-#undef NCBYTE_T
-
-/* type definition */
-#undef NCSHORT_T
-
-/* type thing */
-#undef NF_INT1_T
-
-/* type thing */
-#undef NF_INT2_T
-
-/* no IEEE float on this platform */
-#undef NO_IEEE_FLOAT
-
 /* Define to 1 if your C compiler doesn't accept -c and -o together. */
 #undef NO_MINUS_C_MINUS_O
 
@@ -122,15 +107,12 @@
 /* The size of `long', as computed by sizeof. */
 #undef SIZEOF_LONG
 
-/* type size */
+/* The size of `off_t', as computed by sizeof. */
 #undef SIZEOF_OFF_T
 
 /* The size of `short', as computed by sizeof. */
 #undef SIZEOF_SHORT
 
-/* type size */
-#undef SIZEOF_SIZE_T
-
 /* If using the C implementation of alloca, define if you know the
    direction of stack growth for your system; otherwise it will be
    automatically deduced at runtime.
@@ -149,11 +131,15 @@
 #undef VERSION
 
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
-   significant byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-#elif ! defined __LITTLE_ENDIAN__
-# undef WORDS_BIGENDIAN
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
 #endif
 
 /* Number of bits in a file offset, on hosts where this is settable. */
diff --git a/config.sub b/config.sub
index 6759825..a39437d 100755
--- a/config.sub
+++ b/config.sub
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 #   Free Software Foundation, Inc.
 
-timestamp='2008-01-16'
+timestamp='2009-04-17'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -122,6 +122,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
   uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@@ -249,13 +250,16 @@ case $basic_machine in
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
+	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | mcore | mep \
+	| maxq | mb | microblaze | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
-	| mips64vr | mips64vrel \
+	| mips64octeon | mips64octeonel \
 	| mips64orion | mips64orionel \
+	| mips64r5900 | mips64r5900el \
+	| mips64vr | mips64vrel \
 	| mips64vr4100 | mips64vr4100el \
 	| mips64vr4300 | mips64vr4300el \
 	| mips64vr5000 | mips64vr5000el \
@@ -268,6 +272,7 @@ case $basic_machine in
 	| mipsisa64sr71k | mipsisa64sr71kel \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
+	| moxie \
 	| mt \
 	| msp430 \
 	| nios | nios2 \
@@ -277,7 +282,7 @@ case $basic_machine in
 	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
 	| pyramid \
 	| score \
-	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@@ -286,7 +291,7 @@ case $basic_machine in
 	| v850 | v850e \
 	| we32k \
 	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
-	| z8k)
+	| z8k | z80)
 		basic_machine=$basic_machine-unknown
 		;;
 	m6811 | m68hc11 | m6812 | m68hc12)
@@ -329,14 +334,17 @@ case $basic_machine in
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
+	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
-	| mips64vr-* | mips64vrel-* \
+	| mips64octeon-* | mips64octeonel-* \
 	| mips64orion-* | mips64orionel-* \
+	| mips64r5900-* | mips64r5900el-* \
+	| mips64vr-* | mips64vrel-* \
 	| mips64vr4100-* | mips64vr4100el-* \
 	| mips64vr4300-* | mips64vr4300el-* \
 	| mips64vr5000-* | mips64vr5000el-* \
@@ -358,20 +366,20 @@ case $basic_machine in
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
 	| pyramid-* \
 	| romp-* | rs6000-* \
-	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
 	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
 	| tahoe-* | thumb-* \
-	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
 	| tron-* \
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
 	| xstormy16-* | xtensa*-* \
 	| ymp-* \
-	| z8k-*)
+	| z8k-* | z80-*)
 		;;
 	# Recognize the basic CPU types without company name, with glob match.
 	xtensa*)
@@ -439,6 +447,10 @@ case $basic_machine in
 		basic_machine=m68k-apollo
 		os=-bsd
 		;;
+	aros)
+		basic_machine=i386-pc
+		os=-aros
+		;;
 	aux)
 		basic_machine=m68k-apple
 		os=-aux
@@ -459,6 +471,10 @@ case $basic_machine in
 		basic_machine=c90-cray
 		os=-unicos
 		;;
+        cegcc)
+		basic_machine=arm-unknown
+		os=-cegcc
+		;;
 	convex-c1)
 		basic_machine=c1-convex
 		os=-bsd
@@ -526,6 +542,10 @@ case $basic_machine in
 		basic_machine=m88k-motorola
 		os=-sysv3
 		;;
+	dicos)
+		basic_machine=i686-pc
+		os=-dicos
+		;;
 	djgpp)
 		basic_machine=i586-pc
 		os=-msdosdjgpp
@@ -1128,6 +1148,10 @@ case $basic_machine in
 		basic_machine=z8k-unknown
 		os=-sim
 		;;
+	z80-*-coff)
+		basic_machine=z80-unknown
+		os=-sim
+		;;
 	none)
 		basic_machine=none-none
 		os=-none
@@ -1166,7 +1190,7 @@ case $basic_machine in
 	we32k)
 		basic_machine=we32k-att
 		;;
-	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
 		basic_machine=sh-unknown
 		;;
 	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
@@ -1238,8 +1262,9 @@ case $os in
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+	      | -kopensolaris* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* \
+	      | -aos* | -aros* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
@@ -1248,7 +1273,7 @@ case $os in
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-	      | -chorusos* | -chorusrdb* \
+	      | -chorusos* | -chorusrdb* | -cegcc* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
@@ -1388,6 +1413,9 @@ case $os in
 	-zvmoe)
 		os=-zvmoe
 		;;
+	-dicos*)
+		os=-dicos
+		;;
 	-none)
 		;;
 	*)
diff --git a/configure b/configure
index c5f9766..4c79ee9 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
 #! /bin/sh
-# From configure.ac Id: configure.ac,v 1.22 2009/04/12 14:18:13 ed Exp .
+# From configure.ac Id: configure.ac,v 1.6 2009/11/16 15:42:12 zhi Exp .
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.62 for libcf 1.0-alpha4.
+# Generated by GNU Autoconf 2.63 for libcf 1.0-alpha5.
 #
 # Report bugs to <support at unidata.ucar.edu>.
 #
@@ -746,8 +746,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='libcf'
 PACKAGE_TARNAME='libcf'
-PACKAGE_VERSION='1.0-alpha4'
-PACKAGE_STRING='libcf 1.0-alpha4'
+PACKAGE_VERSION='1.0-alpha5'
+PACKAGE_STRING='libcf 1.0-alpha5'
 PACKAGE_BUGREPORT='support at unidata.ucar.edu'
 
 ac_unique_file="src/nccoord.c"
@@ -787,176 +787,190 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL
-PATH_SEPARATOR
-PACKAGE_NAME
-PACKAGE_TARNAME
-PACKAGE_VERSION
-PACKAGE_STRING
-PACKAGE_BUGREPORT
-exec_prefix
-prefix
-program_transform_name
-bindir
-sbindir
-libexecdir
-datarootdir
-datadir
-sysconfdir
-sharedstatedir
-localstatedir
-includedir
-oldincludedir
-docdir
-infodir
-htmldir
-dvidir
-pdfdir
-psdir
-libdir
-localedir
-mandir
-DEFS
-ECHO_C
-ECHO_N
-ECHO_T
-LIBS
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+ALLOCA
+CPP
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+lt_ECHO
+RANLIB
+AR
+LN_S
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+EGREP
+GREP
+SED
+LIBTOOL
+OBJDUMP
+DLLTOOL
+AS
+MOD_FLAG
+FCFLAGS_f90
+ac_ct_FC
+FCFLAGS
+FC
+ac_ct_F77
+FFLAGS
+F77
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+NCDUMPDIR
+NETCDFDIR
+USE_NETCDF_DIR_FALSE
+USE_NETCDF_DIR_TRUE
+BUILD_F90_FALSE
+BUILD_F90_TRUE
+USE_SZLIB_DIR_FALSE
+USE_SZLIB_DIR_TRUE
+USE_ZLIB_DIR_FALSE
+USE_ZLIB_DIR_TRUE
+SZLIBDIR
+ZLIBDIR
+USE_HDF4_FALSE
+USE_HDF4_TRUE
+HDF4DIR
+USE_HDF4_DIR_FALSE
+USE_HDF4_DIR_TRUE
+HDF5DIR
+USE_HDF5_DIR_FALSE
+USE_HDF5_DIR_TRUE
+EXTRA_DATA_TESTS_FALSE
+EXTRA_DATA_TESTS_TRUE
+USE_NETCDF4_FALSE
+USE_NETCDF4_TRUE
+BUILD_CFCHECK_FALSE
+BUILD_CFCHECK_TRUE
+BUILD_GRIDSPEC_FILE_TESTS_FALSE
+BUILD_GRIDSPEC_FILE_TESTS_TRUE
+BUILD_GRIDSPEC_FALSE
+BUILD_GRIDSPEC_TRUE
+BUILD_DOCS_FALSE
+BUILD_DOCS_TRUE
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+target_alias
+host_alias
 build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_shared
+enable_docs
+enable_gridspec
+enable_gridspec_file_tests
+enable_cfcheck
+enable_logging
+enable_netcdf_4
+enable_hdf4
+enable_extra_data_tests
+with_hdf5
+with_hdf4
+with_zlib
+with_szlib
+enable_f90
+with_netcdf
+enable_dependency_tracking
+enable_static
+with_pic
+enable_fast_install
+with_gnu_ld
+enable_libtool_lock
+enable_largefile
+'
+      ac_precious_vars='build_alias
 host_alias
 target_alias
-build
-build_cpu
-build_vendor
-build_os
-host
-host_cpu
-host_vendor
-host_os
-INSTALL_PROGRAM
-INSTALL_SCRIPT
-INSTALL_DATA
-am__isrc
-CYGPATH_W
-PACKAGE
-VERSION
-ACLOCAL
-AUTOCONF
-AUTOMAKE
-AUTOHEADER
-MAKEINFO
-install_sh
-STRIP
-INSTALL_STRIP_PROGRAM
-MKDIR_P
-mkdir_p
-AWK
-SET_MAKE
-am__leading_dot
-AMTAR
-am__tar
-am__untar
-BUILD_DOCS_TRUE
-BUILD_DOCS_FALSE
-BUILD_GRIDSPEC_TRUE
-BUILD_GRIDSPEC_FALSE
-BUILD_CFCHECK_TRUE
-BUILD_CFCHECK_FALSE
-USE_NETCDF4_TRUE
-USE_NETCDF4_FALSE
-EXTRA_DATA_TESTS_TRUE
-EXTRA_DATA_TESTS_FALSE
-USE_HDF5_DIR_TRUE
-USE_HDF5_DIR_FALSE
-HDF5DIR
-BUILD_F90_TRUE
-BUILD_F90_FALSE
-USE_NETCDF_DIR_TRUE
-USE_NETCDF_DIR_FALSE
-NETCDFDIR
 CC
 CFLAGS
 LDFLAGS
-CPPFLAGS
-ac_ct_CC
-EXEEXT
-OBJEXT
-DEPDIR
-am__include
-am__quote
-AMDEP_TRUE
-AMDEP_FALSE
-AMDEPBACKSLASH
-CCDEPMODE
-am__fastdepCC_TRUE
-am__fastdepCC_FALSE
-F77
-FFLAGS
-ac_ct_F77
-FC
-FCFLAGS
-ac_ct_FC
-AS
-DLLTOOL
-OBJDUMP
-LIBTOOL
-SED
-GREP
-EGREP
-FGREP
-LD
-DUMPBIN
-ac_ct_DUMPBIN
-NM
-LN_S
-AR
-RANLIB
-lt_ECHO
-DSYMUTIL
-NMEDIT
-LIPO
-OTOOL
-OTOOL64
-CPP
-FLIBS
-FPP
-COMPILE_F
-FPPFLAGS
-NMFLAGS
-MATHLIB
-ALLOCA
-prog
-WHATIS
-MAKEWHATIS_CMD
-LIBOBJS
-LTLIBOBJS'
-ac_subst_files=''
-ac_user_opts='
-enable_option_checking
-enable_shared
-enable_docs
-enable_gridspec
-enable_cfcheck
-enable_logging
-enable_netcdf_4
-enable_extra_data_tests
-with_hdf5
-enable_f90
-with_netcdf
-enable_dependency_tracking
-enable_static
-with_pic
-enable_fast_install
-with_gnu_ld
-enable_libtool_lock
-enable_largefile
-'
-      ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-LIBS
+LIBS
 CPPFLAGS
 F77
 FFLAGS
@@ -1385,9 +1399,9 @@ fi
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
-    fatal) { $as_echo "$as_me: error: Unrecognized options: $ac_unrecognized_opts" >&2
+    fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
    { (exit 1); exit 1; }; } ;;
-    *)     $as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2 ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
 
@@ -1440,7 +1454,7 @@ test "$silent" = yes && exec 6>/dev/null
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  { $as_echo "$as_me: error: Working directory cannot be determined" >&2
+  { $as_echo "$as_me: error: working directory cannot be determined" >&2
    { (exit 1); exit 1; }; }
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
   { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
@@ -1515,7 +1529,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libcf 1.0-alpha4 to adapt to many kinds of systems.
+\`configure' configures libcf 1.0-alpha5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1585,7 +1599,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libcf 1.0-alpha4:";;
+     short | recursive ) echo "Configuration of libcf 1.0-alpha5:";;
    esac
   cat <<\_ACEOF
 
@@ -1597,10 +1611,15 @@ Optional Features:
   --enable-docs           build the libcf documentation (a built version is
                           already included with the distrubution)
   --enable-gridspec       build the gridspec tools
-  --disable-cfcheck       don't build the cfcheck application
+  --enable-gridspec-file-tests
+                          get GRIDSPEC test data from Unidata FTP server and
+                          run extra tests
+  --enable-cfcheck        still in development - not working yet
   --enable-logging        enable logging capability. This debugging features
                           is only of interest to libcf developers.
   --enable-netcdf-4       build with netcdf-4 (HDF5 is required)
+  --enable-hdf4           build netcdf-4 with HDF4 read capability (HDF4, HDF5
+                          and zlib required)
   --enable-extra-data-tests
                           Perform extra tests using CF example files from
                           Unidata web site (example files must be donloaded
@@ -1620,6 +1639,16 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-hdf5=<directory> Specify location of HDF5 library. Configure will
                           expect to find subdirs include and lib.
+  --with-hdf4=<directory> Specify location of HDF4 library. Configure will
+                          expect to find subdirs include and lib.
+  --with-zlib=<directory> Specify location of ZLIB library. ZLIB is required
+                          for netCDF-4. Configure will expect to find subdirs
+                          include and lib.
+  --with-szlib=<directory>
+                          Specify location of SZLIB library. SZLIB is not
+                          required for netCDF-4, but you must specify its
+                          location if HDF5 was built with SZLIB. Configure
+                          will expect to find subdirs include and lib.
   --with-netcdf=<directory>
                           Specify location of netCDF library. Configure will
                           expect to find subdirs include and lib.
@@ -1707,8 +1736,8 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libcf configure 1.0-alpha4
-generated by GNU Autoconf 2.62
+libcf configure 1.0-alpha5
+generated by GNU Autoconf 2.63
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -1721,8 +1750,8 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libcf $as_me 1.0-alpha4, which was
-generated by GNU Autoconf 2.62.  Invocation command line was
+It was created by libcf $as_me 1.0-alpha5, which was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   $ $0 $@
 
@@ -1845,8 +1874,8 @@ _ASBOX
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
@@ -2049,6 +2078,8 @@ $as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
   fi
 done
 if $ac_cache_corrupted; then
+  { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
   { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
   { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
@@ -2089,8 +2120,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-{ $as_echo "$as_me:$LINENO: libcf 1.0-alpha4" >&5
-$as_echo "$as_me: libcf 1.0-alpha4" >&6;}
+{ $as_echo "$as_me:$LINENO: libcf 1.0-alpha5" >&5
+$as_echo "$as_me: libcf 1.0-alpha5" >&6;}
 
 # Find out about the host we're building on.
 ac_aux_dir=
@@ -2216,7 +2247,7 @@ ac_config_headers="$ac_config_headers nfconfig.inc:nfconfig.in"
 
 
 # This call is required by automake.
-am__api_version='1.10'
+am__api_version='1.11'
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -2316,16 +2347,33 @@ $as_echo_n "checking whether build environment is sane... " >&6; }
 # Just in case
 sleep 1
 echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    { { $as_echo "$as_me:$LINENO: error: unsafe absolute working directory name" >&5
+$as_echo "$as_me: error: unsafe absolute working directory name" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \	]*)
+    { { $as_echo "$as_me:$LINENO: error: unsafe srcdir value: \`$srcdir'" >&5
+$as_echo "$as_me: error: unsafe srcdir value: \`$srcdir'" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
    if test "$*" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftest.file`
+      set X `ls -t "$srcdir/configure" conftest.file`
    fi
    rm -f conftest.file
    if test "$*" != "X $srcdir/configure conftest.file" \
@@ -2369,7 +2417,14 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 # expand $ac_aux_dir to an absolute path
 am_aux_dir=`cd $ac_aux_dir && pwd`
 
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
 # Use eval to expand $SHELL
 if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
@@ -2379,6 +2434,115 @@ else
 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
 fi
 
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:$LINENO: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
 { $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
 if test -z "$MKDIR_P"; then
@@ -2533,7 +2697,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libcf'
- VERSION='1.0-alpha4'
+ VERSION='1.0-alpha5'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2561,119 +2725,13 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
 
 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 
-install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
 
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-if test "$cross_compiling" != no; then
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_STRIP+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$STRIP"; then
-  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
+AMTAR=${AMTAR-"${am_missing_run}tar"}
 
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
-  { $as_echo "$as_me:$LINENO: result: $STRIP" >&5
-$as_echo "$STRIP" >&6; }
-else
-  { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
-  ac_ct_STRIP=$STRIP
-  # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_STRIP"; then
-  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_STRIP="strip"
-    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
-  { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-$as_echo "$ac_ct_STRIP" >&6; }
-else
-  { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_STRIP" = x; then
-    STRIP=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
-ac_tool_warned=yes ;;
-esac
-    STRIP=$ac_ct_STRIP
-  fi
-else
-  STRIP="$ac_cv_prog_STRIP"
-fi
-
-fi
-INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
-
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
-# Always define AMTAR for backward compatibility.
-
-AMTAR=${AMTAR-"${am_missing_run}tar"}
-
-am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
 
 
 
@@ -2774,6 +2832,26 @@ else
 fi
 
 
+# Does the user want to fetch test data and run extra gridspec tests?
+{ $as_echo "$as_me:$LINENO: checking whether gridspec test data should be fetched from Unidata FTP site" >&5
+$as_echo_n "checking whether gridspec test data should be fetched from Unidata FTP site... " >&6; }
+# Check whether --enable-gridspec-file-tests was given.
+if test "${enable_gridspec_file_tests+set}" = set; then
+  enableval=$enable_gridspec_file_tests;
+fi
+
+test "x$enable_gridspec_file_tests" = xyes || enable_gridspec_file_tests=no
+{ $as_echo "$as_me:$LINENO: result: $enable_gridspec_file_tests" >&5
+$as_echo "$enable_gridspec_file_tests" >&6; }
+ if test x$enable_gridspec_file_tests = xyes; then
+  BUILD_GRIDSPEC_FILE_TESTS_TRUE=
+  BUILD_GRIDSPEC_FILE_TESTS_FALSE='#'
+else
+  BUILD_GRIDSPEC_FILE_TESTS_TRUE='#'
+  BUILD_GRIDSPEC_FILE_TESTS_FALSE=
+fi
+
+
 # Does the user want to build cfcheck?
 { $as_echo "$as_me:$LINENO: checking whether cfcheck is to be built" >&5
 $as_echo_n "checking whether cfcheck is to be built... " >&6; }
@@ -2782,7 +2860,7 @@ if test "${enable_cfcheck+set}" = set; then
   enableval=$enable_cfcheck;
 fi
 
-test "x$enable_cfcheck" = xno || enable_cfcheck=yes
+test "x$enable_cfcheck" = xyes || enable_cfcheck=no
 { $as_echo "$as_me:$LINENO: result: $enable_cfcheck" >&5
 $as_echo "$enable_cfcheck" >&6; }
  if test x$enable_cfcheck = xyes; then
@@ -2821,7 +2899,13 @@ if test "${enable_netcdf_4+set}" = set; then
   enableval=$enable_netcdf_4;
 fi
 
-test "x$enable_netcdf_4" = xyes || enable_netcdf_4=no
+
+# If hdf5 dir is set, turn on enable-netcdf-4.
+if test "x$with_hdf5" != x; then
+   enable_netcdf_4=yes
+else
+   test "x$enable_netcdf_4" = xyes || enable_netcdf_4=no
+fi
 { $as_echo "$as_me:$LINENO: result: $enable_netcdf_4" >&5
 $as_echo "$enable_netcdf_4" >&6; }
  if test x$enable_netcdf_4 = xyes; then
@@ -2840,7 +2924,14 @@ _ACEOF
 
 fi
 
-# Does the user want to use netcdf-4?
+# Does the user want to turn on HDF4 read ability?
+# Check whether --enable-hdf4 was given.
+if test "${enable_hdf4+set}" = set; then
+  enableval=$enable_hdf4;
+fi
+
+
+# Does the user want extra tests on CF sample files?
 { $as_echo "$as_me:$LINENO: checking whether extra tests on sample data should be performed" >&5
 $as_echo_n "checking whether extra tests on sample data should be performed... " >&6; }
 # Check whether --enable-extra-data-tests was given.
@@ -2869,7 +2960,6 @@ if test "${with_hdf5+set}" = set; then
   withval=$with_hdf5; HDF5DIR=$with_hdf5
 fi
 
-HDF5DIR=${HDF5DIR-.}
 { $as_echo "$as_me:$LINENO: result: $HDF5DIR" >&5
 $as_echo "$HDF5DIR" >&6; }
  if test ! "x$HDF5DIR" = x; then
@@ -2882,6 +2972,84 @@ fi
 
 HDF5DIR=$HDF5DIR
 
+if test ! "x$HDF5DIR" = x; then
+   LDFLAGS="${LDFLAGS} -L$HDF5DIR/lib"
+fi
+
+# Did the user specify a location for the HDF4 library?
+{ $as_echo "$as_me:$LINENO: checking whether a location for the HDF4 library was specified" >&5
+$as_echo_n "checking whether a location for the HDF4 library was specified... " >&6; }
+
+# Check whether --with-hdf4 was given.
+if test "${with_hdf4+set}" = set; then
+  withval=$with_hdf4; HDF4DIR=$with_hdf4
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $HDF4DIR" >&5
+$as_echo "$HDF4DIR" >&6; }
+ if test ! "x$HDF4DIR" = x; then
+  USE_HDF4_DIR_TRUE=
+  USE_HDF4_DIR_FALSE='#'
+else
+  USE_HDF4_DIR_TRUE='#'
+  USE_HDF4_DIR_FALSE=
+fi
+
+HDF4DIR=$HDF4DIR
+
+ if test x$enable_hdf4 = xyes; then
+  USE_HDF4_TRUE=
+  USE_HDF4_FALSE='#'
+else
+  USE_HDF4_TRUE='#'
+  USE_HDF4_FALSE=
+fi
+
+
+# Did the user specify a location for the ZLIB library?
+{ $as_echo "$as_me:$LINENO: checking whether a location for the ZLIB library was specified" >&5
+$as_echo_n "checking whether a location for the ZLIB library was specified... " >&6; }
+
+# Check whether --with-zlib was given.
+if test "${with_zlib+set}" = set; then
+  withval=$with_zlib; ZLIBDIR=$with_zlib
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $ZLIBDIR" >&5
+$as_echo "$ZLIBDIR" >&6; }
+ZLIBDIR=$ZLIBDIR
+
+
+# Did the user specify a location for the SZLIB library?
+{ $as_echo "$as_me:$LINENO: checking whether a location for the SZLIB library was specified" >&5
+$as_echo_n "checking whether a location for the SZLIB library was specified... " >&6; }
+
+# Check whether --with-szlib was given.
+if test "${with_szlib+set}" = set; then
+  withval=$with_szlib; SZLIBDIR=$with_szlib
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $SZLIBDIR" >&5
+$as_echo "$SZLIBDIR" >&6; }
+SZLIBDIR=$SZLIBDIR
+
+
+ if test ! "x$ZLIBDIR" = x; then
+  USE_ZLIB_DIR_TRUE=
+  USE_ZLIB_DIR_FALSE='#'
+else
+  USE_ZLIB_DIR_TRUE='#'
+  USE_ZLIB_DIR_FALSE=
+fi
+
+ if test ! "x$SZLIBDIR" = x; then
+  USE_SZLIB_DIR_TRUE=
+  USE_SZLIB_DIR_FALSE='#'
+else
+  USE_SZLIB_DIR_TRUE='#'
+  USE_SZLIB_DIR_FALSE=
+fi
+
 
 # Do we want to build the fortran API? Check for --disable-f90
 nc_build_f90=yes
@@ -2911,13 +3079,14 @@ $as_echo_n "checking whether a location for the netCDF library was specified...
 
 # Check whether --with-netcdf was given.
 if test "${with_netcdf+set}" = set; then
-  withval=$with_netcdf; NETCDFDIR=$with_netcdf
+  withval=$with_netcdf;
+else
+  with_netcdf=no
 fi
 
-NETCDFDIR=${NETCDFDIR}
-{ $as_echo "$as_me:$LINENO: result: $NETCDFDIR" >&5
-$as_echo "$NETCDFDIR" >&6; }
- if test ! "x$NETCDFDIR" = x; then
+{ $as_echo "$as_me:$LINENO: result: $with_netcdf" >&5
+$as_echo "$with_netcdf" >&6; }
+ if test ! x$with_netcdf = xno; then
   USE_NETCDF_DIR_TRUE=
   USE_NETCDF_DIR_FALSE='#'
 else
@@ -2925,8 +3094,16 @@ else
   USE_NETCDF_DIR_FALSE=
 fi
 
-NETCDFDIR=$NETCDFDIR
+if test ! x$with_netcdf = xno; then
+   NETCDFDIR=$with_netcdf
+
+   NCDUMPDIR=$with_netcdf/bin
+
+   LDFLAGS="${LDFLAGS} -L$NETCDFDIR/lib"
+else
+   NCDUMPDIR=../../../../ncdump
 
+fi
 
 # According to the autoconf mailing list gurus, we must test for
 # compilers unconditionally. That is, we can't skip looking for the
@@ -3033,12 +3210,8 @@ done
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
@@ -3046,11 +3219,13 @@ esac
 fi
 
 
-test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: no acceptable C compiler found in \$PATH
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 
 # Provide some information about the compiler.
 $as_echo "$as_me:$LINENO: checking for C compiler version" >&5
@@ -3180,11 +3355,13 @@ if test -z "$ac_file"; then
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 { { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: C compiler cannot create executables
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
@@ -3212,13 +3389,15 @@ $as_echo "$ac_try_echo") >&5
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
+	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
     fi
   fi
 fi
@@ -3261,11 +3440,13 @@ for ac_file in conftest.exe conftest conftest.*; do
   esac
 done
 else
-  { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 rm -f conftest$ac_cv_exeext
@@ -3319,11 +3500,13 @@ else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
@@ -3678,7 +3861,7 @@ ac_config_commands="$ac_config_commands depfiles"
 am_make=${MAKE-make}
 cat > confinc << 'END'
 am__doit:
-	@echo done
+	@echo this is the am__doit target
 .PHONY: am__doit
 END
 # If we don't find an include directive, just comment out the code.
@@ -3689,24 +3872,24 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
-   am__include=include
-   am__quote=
-   _am_result=GNU
-fi
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
 # Now try BSD make style include.
 if test "$am__include" = "#"; then
    echo '.include "confinc"' > confmf
-   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
-      am__include=.include
-      am__quote="\""
-      _am_result=BSD
-   fi
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
 fi
 
 
@@ -3763,6 +3946,11 @@ else
   if test "$am_compiler_list" = ""; then
      am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
   fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
   for depmode in $am_compiler_list; do
     # Setup a source with many dependencies, because some compilers
     # like to wrap large dependency lists on column 80 (with \), and
@@ -3780,7 +3968,17 @@ else
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
     case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
     nosideeffect)
       # after this tag, mechanisms are not by side-effect, so they'll
       # only be used when explicitly requested
@@ -3790,19 +3988,23 @@ else
 	break
       fi
       ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
     none) break ;;
     esac
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.
     if depmode=$depmode \
-       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       source=sub/conftest.c object=$am__obj \
        depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
          >/dev/null 2>conftest.err &&
        grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
        grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
       # icc doesn't choke on unknown options, it will just issue warnings
       # or remarks (even with -Werror).  So we grep stderr for any message
@@ -3961,8 +4163,9 @@ fi
 # FIXME: we rely on the cache variable name because
 # there is no other way.
 set dummy $CC
-ac_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
-if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
    # Losing compiler, so override with the script.
    # FIXME: It is wrong to rewrite CC.
    # But if we don't then we get into trouble of one sort or another.
@@ -4077,12 +4280,8 @@ done
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     F77=$ac_ct_F77
@@ -4352,12 +4551,8 @@ done
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     FC=$ac_ct_FC
@@ -4522,6 +4717,215 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+if test "x$nc_build_f90" = xyes; then
+   { $as_echo "$as_me:$LINENO: configuring fortran" >&5
+$as_echo "$as_me: configuring fortran" >&6;}
+   # Some f90 compilers change the case of the mod file names. Others
+   # require special flags to be set to deal with .f90 files. Find out
+   # about this compiler.
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
+ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+{ $as_echo "$as_me:$LINENO: checking for Fortran flag to compile .f90 files" >&5
+$as_echo_n "checking for Fortran flag to compile .f90 files... " >&6; }
+if test "${ac_cv_fc_srcext_f90+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=f90
+ac_fcflags_srcext_save=$ac_fcflags_srcext
+ac_fcflags_srcext=
+ac_cv_fc_srcext_f90=unknown
+for ac_flag in none -qsuffix=f=f90 -Tf; do
+  test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
+  cat >conftest.$ac_ext <<_ACEOF
+      program main
+
+      end
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_fc_srcext_f90=$ac_flag; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest.$ac_objext conftest.f90
+ac_fcflags_srcext=$ac_fcflags_srcext_save
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_srcext_f90" >&5
+$as_echo "$ac_cv_fc_srcext_f90" >&6; }
+if test "x$ac_cv_fc_srcext_f90" = xunknown; then
+  { { $as_echo "$as_me:$LINENO: error: Fortran could not compile .f90 files" >&5
+$as_echo "$as_me: error: Fortran could not compile .f90 files" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  ac_fc_srcext=f90
+  if test "x$ac_cv_fc_srcext_f90" = xnone; then
+    ac_fcflags_srcext=""
+    FCFLAGS_f90=""
+  else
+    ac_fcflags_srcext=$ac_cv_fc_srcext_f90
+    FCFLAGS_f90=$ac_cv_fc_srcext_f90
+  fi
+
+
+fi
+ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+   ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:$LINENO: checking fortran 90 modules inclusion flag" >&5
+$as_echo_n "checking fortran 90 modules inclusion flag... " >&6; }
+if test "${ax_cv_f90_modflag+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+i=0
+while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do
+  i=`expr $i + 1`
+done
+mkdir tmpdir_$i
+cd tmpdir_$i
+cat >conftest.$ac_ext <<_ACEOF
+module conftest_module
+   contains
+   subroutine conftest_routine
+   write(*,'(a)') 'gotcha!'
+   end subroutine conftest_routine
+   end module conftest_module
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+cd ..
+ax_cv_f90_modflag="not found"
+for ax_flag in "-I" "-M" "-p"; do
+  if test "$ax_cv_f90_modflag" = "not found" ; then
+    ax_save_FCFLAGS="$FCFLAGS"
+    FCFLAGS="$ax_save_FCFLAGS ${ax_flag}tmpdir_$i"
+    cat >conftest.$ac_ext <<_ACEOF
+program conftest_program
+       use conftest_module
+       call conftest_routine
+       end program conftest_program
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ax_cv_f90_modflag="$ax_flag"
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    FCFLAGS="$ax_save_FCFLAGS"
+  fi
+done
+rm -fr tmpdir_$i
+if test "$ax_flag" = "not found" ; then
+  { { $as_echo "$as_me:$LINENO: error: unable to find compiler flag for modules inclusion" >&5
+$as_echo "$as_me: error: unable to find compiler flag for modules inclusion" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ax_cv_f90_modflag" >&5
+$as_echo "$ax_cv_f90_modflag" >&6; }
+   MOD_FLAG=${ax_cv_f90_modflag}
+
+fi
+
 { $as_echo "$as_me:$LINENO: finding other utilities" >&5
 $as_echo "$as_me: finding other utilities" >&6;}
 
@@ -4709,12 +5113,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     AS=$ac_ct_AS
@@ -4805,12 +5205,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     DLLTOOL=$ac_ct_DLLTOOL
@@ -4901,12 +5297,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     OBJDUMP=$ac_ct_OBJDUMP
@@ -5532,12 +5924,8 @@ done
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     DUMPBIN=$ac_ct_DUMPBIN
@@ -5563,13 +5951,13 @@ if test "${lt_cv_nm_interface+set}" = set; then
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5566: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:5954: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5569: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:5957: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5572: output\"" >&5)
+  (eval echo "\"\$as_me:5960: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6106,12 +6494,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     AR=$ac_ct_AR
@@ -6215,12 +6599,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     STRIP=$ac_ct_STRIP
@@ -6318,12 +6698,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     RANLIB=$ac_ct_RANLIB
@@ -6680,7 +7056,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6683 "configure"' > conftest.$ac_ext
+  echo '#line 7059 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -6956,12 +7332,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     DSYMUTIL=$ac_ct_DSYMUTIL
@@ -7052,12 +7424,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     NMEDIT=$ac_ct_NMEDIT
@@ -7148,12 +7516,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     LIPO=$ac_ct_LIPO
@@ -7244,12 +7608,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     OTOOL=$ac_ct_OTOOL
@@ -7340,12 +7700,8 @@ fi
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     OTOOL64=$ac_ct_OTOOL64
@@ -7726,11 +8082,13 @@ rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then
   :
 else
-  { { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 ac_ext=c
@@ -7979,8 +8337,9 @@ ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -8041,8 +8400,9 @@ ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
@@ -8149,12 +8509,8 @@ done
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     F77=$ac_ct_F77
@@ -8427,12 +8783,8 @@ done
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     FC=$ac_ct_FC
@@ -8603,7 +8955,6 @@ fi
 
 
 
-
 # Set options
 
 
@@ -9072,11 +9423,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9075: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9426: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:9079: \$? = $ac_status" >&5
+   echo "$as_me:9430: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9396,11 +9747,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9399: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9750: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:9403: \$? = $ac_status" >&5
+   echo "$as_me:9754: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -9501,11 +9852,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9504: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9855: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:9508: \$? = $ac_status" >&5
+   echo "$as_me:9859: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -9556,11 +9907,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:9559: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9910: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:9563: \$? = $ac_status" >&5
+   echo "$as_me:9914: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11840,7 +12191,7 @@ LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test $ac_cv_lib_dl_dlopen = yes; then
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then
   lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
 else
 
@@ -11938,7 +12289,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
 $as_echo "$ac_cv_func_shl_load" >&6; }
-if test $ac_cv_func_shl_load = yes; then
+if test "x$ac_cv_func_shl_load" = x""yes; then
   lt_cv_dlopen="shl_load"
 else
   { $as_echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
@@ -12006,7 +12357,7 @@ LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
-if test $ac_cv_lib_dld_shl_load = yes; then
+if test "x$ac_cv_lib_dld_shl_load" = x""yes; then
   lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
 else
   { $as_echo "$as_me:$LINENO: checking for dlopen" >&5
@@ -12094,7 +12445,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
 $as_echo "$ac_cv_func_dlopen" >&6; }
-if test $ac_cv_func_dlopen = yes; then
+if test "x$ac_cv_func_dlopen" = x""yes; then
   lt_cv_dlopen="dlopen"
 else
   { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
@@ -12162,7 +12513,7 @@ LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test $ac_cv_lib_dl_dlopen = yes; then
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then
   lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
 else
   { $as_echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
@@ -12230,7 +12581,7 @@ LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
-if test $ac_cv_lib_svld_dlopen = yes; then
+if test "x$ac_cv_lib_svld_dlopen" = x""yes; then
   lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
 else
   { $as_echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
@@ -12245,1502 +12596,22 @@ cat >conftest.$ac_ext <<_ACEOF
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dld_link ();
-int
-main ()
-{
-return dld_link ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  ac_cv_lib_dld_dld_link=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_lib_dld_dld_link=no
-fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
-$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
-if test $ac_cv_lib_dld_dld_link = yes; then
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-    ;;
-  esac
-
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
-    enable_dlopen=no
-  fi
-
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
-    save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
-    save_LIBS="$LIBS"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
-
-    { $as_echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
-$as_echo_n "checking whether a program can dlopen itself... " >&6; }
-if test "${lt_cv_dlopen_self+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-#line 12351 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
-
-    exit (status);
-}
-_LT_EOF
-  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self=no
-  fi
-fi
-rm -fr conftest*
-
-
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
-$as_echo "$lt_cv_dlopen_self" >&6; }
-
-    if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      { $as_echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
-$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
-if test "${lt_cv_dlopen_self_static+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self_static=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-#line 12451 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
-
-    exit (status);
-}
-_LT_EOF
-  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self_static=no
-  fi
-fi
-rm -fr conftest*
-
-
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
-$as_echo "$lt_cv_dlopen_self_static" >&6; }
-    fi
-
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
-
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
-
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-striplib=
-old_striplib=
-{ $as_echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
-$as_echo_n "checking whether stripping libraries is possible... " >&6; }
-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-  darwin*)
-    if test -n "$STRIP" ; then
-      striplib="$STRIP -x"
-      old_striplib="$STRIP -S"
-      { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-    else
-      { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-    fi
-    ;;
-  *)
-    { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-    ;;
-  esac
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-  # Report which library types will actually be built
-  { $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-$as_echo_n "checking if libtool supports shared libraries... " >&6; }
-  { $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5
-$as_echo "$can_build_shared" >&6; }
-
-  { $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-$as_echo_n "checking whether to build shared libraries... " >&6; }
-  test "$can_build_shared" = "no" && enable_shared=no
-
-  # On AIX, shared libraries and static libraries use the same namespace, and
-  # are all built from PIC.
-  case $host_os in
-  aix3*)
-    test "$enable_shared" = yes && enable_static=no
-    if test -n "$RANLIB"; then
-      archive_cmds="$archive_cmds~\$RANLIB \$lib"
-      postinstall_cmds='$RANLIB $lib'
-    fi
-    ;;
-
-  aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
-    fi
-    ;;
-  esac
-  { $as_echo "$as_me:$LINENO: result: $enable_shared" >&5
-$as_echo "$enable_shared" >&6; }
-
-  { $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-$as_echo_n "checking whether to build static libraries... " >&6; }
-  # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
-  { $as_echo "$as_me:$LINENO: result: $enable_static" >&5
-$as_echo "$enable_static" >&6; }
-
-
-
-
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-
-
-      ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-archive_cmds_need_lc_F77=no
-allow_undefined_flag_F77=
-always_export_symbols_F77=no
-archive_expsym_cmds_F77=
-export_dynamic_flag_spec_F77=
-hardcode_direct_F77=no
-hardcode_direct_absolute_F77=no
-hardcode_libdir_flag_spec_F77=
-hardcode_libdir_flag_spec_ld_F77=
-hardcode_libdir_separator_F77=
-hardcode_minus_L_F77=no
-hardcode_automatic_F77=no
-inherit_rpath_F77=no
-module_cmds_F77=
-module_expsym_cmds_F77=
-link_all_deplibs_F77=unknown
-old_archive_cmds_F77=$old_archive_cmds
-no_undefined_flag_F77=
-whole_archive_flag_spec_F77=
-enable_shared_with_static_runtimes_F77=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-objext_F77=$objext
-
-# No sense in running all these tests if we already determined that
-# the F77 compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="\
-      subroutine t
-      return
-      end
-"
-
-  # Code to be used in simple link tests
-  lt_simple_link_test_code="\
-      program t
-      end
-"
-
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-
-
-
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-  # save warnings/boilerplate of simple test code
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
-
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
-
-
-  # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
-  lt_save_GCC=$GCC
-  CC=${F77-"f77"}
-  compiler=$CC
-  compiler_F77=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-  GCC=$G77
-  if test -n "$compiler"; then
-    { $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-$as_echo_n "checking if libtool supports shared libraries... " >&6; }
-    { $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5
-$as_echo "$can_build_shared" >&6; }
-
-    { $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-$as_echo_n "checking whether to build shared libraries... " >&6; }
-    test "$can_build_shared" = "no" && enable_shared=no
-
-    # On AIX, shared libraries and static libraries use the same namespace, and
-    # are all built from PIC.
-    case $host_os in
-      aix3*)
-        test "$enable_shared" = yes && enable_static=no
-        if test -n "$RANLIB"; then
-          archive_cmds="$archive_cmds~\$RANLIB \$lib"
-          postinstall_cmds='$RANLIB $lib'
-        fi
-        ;;
-      aix[4-9]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
-	fi
-        ;;
-    esac
-    { $as_echo "$as_me:$LINENO: result: $enable_shared" >&5
-$as_echo "$enable_shared" >&6; }
-
-    { $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-$as_echo_n "checking whether to build static libraries... " >&6; }
-    # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
-    { $as_echo "$as_me:$LINENO: result: $enable_static" >&5
-$as_echo "$enable_static" >&6; }
-
-    GCC_F77="$G77"
-    LD_F77="$LD"
-
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    lt_prog_compiler_wl_F77=
-lt_prog_compiler_pic_F77=
-lt_prog_compiler_static_F77=
-
-{ $as_echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
-
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl_F77='-Wl,'
-    lt_prog_compiler_static_F77='-static'
-
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_F77='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            lt_prog_compiler_pic_F77='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
-            lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
-
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-
-    mingw* | cygwin* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
-      ;;
-
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_F77='-fno-common'
-      ;;
-
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_F77='-fPIC'
-	;;
-      esac
-      ;;
-
-    interix[3-9]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared_F77=no
-      enable_shared=no
-      ;;
-
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic_F77='-fPIC -shared'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_F77=-Kconform_pic
-      fi
-      ;;
-
-    *)
-      lt_prog_compiler_pic_F77='-fPIC'
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_F77='-Bstatic'
-      else
-	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-
-    mingw* | cygwin* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_F77='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static_F77='-non_shared'
-      ;;
-
-    linux* | k*bsd*-gnu)
-      case $cc_basename in
-      icc* | ecc* | ifort*)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-KPIC'
-	lt_prog_compiler_static_F77='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-fpic'
-	lt_prog_compiler_static_F77='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl_F77='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static_F77='-non_shared'
-        ;;
-      xl*)
-	# IBM XL C 8.0/Fortran 10.1 on PPC
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-qpic'
-	lt_prog_compiler_static_F77='-qstaticlink'
-	;;
-      *)
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)
-	  # Sun C 5.9
-	  lt_prog_compiler_pic_F77='-KPIC'
-	  lt_prog_compiler_static_F77='-Bstatic'
-	  lt_prog_compiler_wl_F77='-Wl,'
-	  ;;
-	*Sun\ F*)
-	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
-	  lt_prog_compiler_pic_F77='-KPIC'
-	  lt_prog_compiler_static_F77='-Bstatic'
-	  lt_prog_compiler_wl_F77=''
-	  ;;
-	esac
-	;;
-      esac
-      ;;
-
-    newsos6)
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic_F77='-fPIC -shared'
-      ;;
-
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static_F77='-non_shared'
-      ;;
-
-    rdos*)
-      lt_prog_compiler_static_F77='-non_shared'
-      ;;
-
-    solaris*)
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_F77='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_F77='-Wl,';;
-      esac
-      ;;
-
-    sunos4*)
-      lt_prog_compiler_wl_F77='-Qoption ld '
-      lt_prog_compiler_pic_F77='-PIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic_F77='-Kconform_pic'
-	lt_prog_compiler_static_F77='-Bstatic'
-      fi
-      ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    unicos*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
-
-    uts4*)
-      lt_prog_compiler_pic_F77='-pic'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    *)
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
-    esac
-  fi
-
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_F77=
-    ;;
-  *)
-    lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
-    ;;
-esac
-{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
-$as_echo "$lt_prog_compiler_pic_F77" >&6; }
-
-
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_F77"; then
-  { $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
-$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... " >&6; }
-if test "${lt_cv_prog_compiler_pic_works_F77+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_pic_works_F77=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_F77"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13095: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:13099: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_pic_works_F77=yes
-     fi
-   fi
-   $RM conftest*
-
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_F77" >&5
-$as_echo "$lt_cv_prog_compiler_pic_works_F77" >&6; }
-
-if test x"$lt_cv_prog_compiler_pic_works_F77" = xyes; then
-    case $lt_prog_compiler_pic_F77 in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
-     esac
-else
-    lt_prog_compiler_pic_F77=
-     lt_prog_compiler_can_build_shared_F77=no
-fi
-
-fi
-
-
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
-{ $as_echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if test "${lt_cv_prog_compiler_static_works_F77+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_static_works_F77=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler_static_works_F77=yes
-       fi
-     else
-       lt_cv_prog_compiler_static_works_F77=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_F77" >&5
-$as_echo "$lt_cv_prog_compiler_static_works_F77" >&6; }
-
-if test x"$lt_cv_prog_compiler_static_works_F77" = xyes; then
-    :
-else
-    lt_prog_compiler_static_F77=
-fi
-
-
-
-
-    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_c_o_F77=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13194: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:13198: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_F77=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
-
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_F77" >&6; }
-
-
-
-    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_c_o_F77=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13246: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:13250: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_F77=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
-
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_F77" >&6; }
-
-
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  { $as_echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-$as_echo_n "checking if we can lock with hard links... " >&6; }
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { $as_echo "$as_me:$LINENO: result: $hard_links" >&5
-$as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-
-
-
-    { $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
-
-  runpath_var=
-  allow_undefined_flag_F77=
-  always_export_symbols_F77=no
-  archive_cmds_F77=
-  archive_expsym_cmds_F77=
-  compiler_needs_object_F77=no
-  enable_shared_with_static_runtimes_F77=no
-  export_dynamic_flag_spec_F77=
-  export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  hardcode_automatic_F77=no
-  hardcode_direct_F77=no
-  hardcode_direct_absolute_F77=no
-  hardcode_libdir_flag_spec_F77=
-  hardcode_libdir_flag_spec_ld_F77=
-  hardcode_libdir_separator_F77=
-  hardcode_minus_L_F77=no
-  hardcode_shlibpath_var_F77=unsupported
-  inherit_rpath_F77=no
-  link_all_deplibs_F77=unknown
-  module_cmds_F77=
-  module_expsym_cmds_F77=
-  old_archive_from_new_cmds_F77=
-  old_archive_from_expsyms_cmds_F77=
-  thread_safe_flag_spec_F77=
-  whole_archive_flag_spec_F77=
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms_F77=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms_F77='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  # Exclude shared library initialization/finalization symbols.
-  extract_expsyms_cmds=
-
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
-
-  ld_shlibs_F77=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
-
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    else
-      whole_archive_flag_spec_F77=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>&1` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix[3-9]*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs_F77=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-_LT_EOF
-      fi
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds_F77=''
-        ;;
-      m68k)
-            archive_cmds_F77='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec_F77='-L$libdir'
-            hardcode_minus_L_F77=yes
-        ;;
-      esac
-      ;;
-
-    beos*)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag_F77=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # _LT_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      allow_undefined_flag_F77=unsupported
-      always_export_symbols_F77=no
-      enable_shared_with_static_runtimes_F77=yes
-      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
-
-      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
-    interix[3-9]*)
-      hardcode_direct_F77=no
-      hardcode_shlibpath_var_F77=no
-      hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec_F77='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    gnu* | linux* | tpf* | k*bsd*-gnu)
-      tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
-	case $cc_basename in
-	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
-	esac
-      fi
-      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
-      then
-	tmp_addflag=
-	tmp_sharedflag='-shared'
-	case $cc_basename,$host_cpu in
-        pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	xl[cC]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
-	  tmp_sharedflag='-qmkshrobj'
-	  tmp_addflag= ;;
-	esac
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
-	  compiler_needs_object_F77=yes
-	  tmp_sharedflag='-G' ;;
-	*Sun\ F*)			# Sun Fortran 8.3
-	  tmp_sharedflag='-G' ;;
-	esac
-	archive_cmds_F77='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-        if test "x$supports_anon_versioning" = xyes; then
-          archive_expsym_cmds_F77='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-        fi
-
-	case $cc_basename in
-	xlf*)
-	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-	  whole_archive_flag_spec_F77='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec_F77=
-	  hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
-	  archive_cmds_F77='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
-	    archive_expsym_cmds_F77='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
-	  fi
-	  ;;
-	esac
-      else
-        ld_shlibs_F77=no
-      fi
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
-
-    solaris*)
-      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
-	ld_shlibs_F77=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs_F77=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-	;;
-	*)
-	  # For security reasons, it is highly recommended that you always
-	  # use absolute paths for naming shared libraries, and exclude the
-	  # DT_RUNPATH tag from executables and libraries.  But doing so
-	  # requires that you compile everything twice, which is a pain.
-	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-	    archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  else
-	    ld_shlibs_F77=no
-	  fi
-	;;
-      esac
-      ;;
-
-    sunos4*)
-      archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    *)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-    esac
-
-    if test "$ld_shlibs_F77" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_F77=
-      export_dynamic_flag_spec_F77=
-      whole_archive_flag_spec_F77=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag_F77=unsupported
-      always_export_symbols_F77=yes
-      archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L_F77=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct_F77=unsupported
-      fi
-      ;;
-
-    aix[4-9]*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
-
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
-	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-	    aix_use_runtimelinking=yes
-	    break
-	  fi
-	  done
-	  ;;
-	esac
-
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
-
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-      archive_cmds_F77=''
-      hardcode_direct_F77=yes
-      hardcode_direct_absolute_F77=yes
-      hardcode_libdir_separator_F77=':'
-      link_all_deplibs_F77=yes
-      file_list_spec_F77='${wl}-f,'
-
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	  # We have reworked collect2
-	  :
-	  else
-	  # We have old collect2
-	  hardcode_direct_F77=unsupported
-	  # It fails to find uninstalled libraries when the uninstalled
-	  # path is not listed in the libpath.  Setting hardcode_minus_L
-	  # to unsupported forces relinking
-	  hardcode_minus_L_F77=yes
-	  hardcode_libdir_flag_spec_F77='-L$libdir'
-	  hardcode_libdir_separator_F77=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
-
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols_F77=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag_F77='-berok'
-        # Determine the default libpath from the value encoded in an
-        # empty executable.
-        cat >conftest.$ac_ext <<_ACEOF
-      program main
+/* end confdefs.h.  */
 
-      end
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
 if { (ac_try="$ac_link"
@@ -13757,1102 +12628,1467 @@ $as_echo "$ac_try_echo") >&5
   cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && {
-	 test -z "$ac_f77_werror_flag" ||
+	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
 	 $as_test_x conftest$ac_exeext
        }; then
-
-lt_aix_libpath_sed='
-    /Import File Strings/,/^$/ {
-	/^0/ {
-	    s/^0  *\(.*\)$/\1/
-	    p
-	}
-    }'
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then
-  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-fi
+  ac_cv_lib_dld_dld_link=yes
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+	ac_cv_lib_dld_dld_link=no
 fi
 
 rm -rf conftest.dSYM
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = x""yes; then
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
 
-        hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds_F77='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-      else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag_F77="-z nodefs"
-	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an
-	 # empty executable.
-	 cat >conftest.$ac_ext <<_ACEOF
-      program main
 
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line 12702 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+    exit (status);
+}
+_LT_EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { $as_echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line 12802 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
+
+    exit (status);
+}
+_LT_EOF
+  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_f77_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-
-lt_aix_libpath_sed='
-    /Import File Strings/,/^$/ {
-	/^0/ {
-	    s/^0  *\(.*\)$/\1/
-	    p
-	}
-    }'
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then
-  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
 fi
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+rm -fr conftest*
 
 
 fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
 
-	 hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag_F77=' ${wl}-bernotok'
-	  allow_undefined_flag_F77=' ${wl}-berok'
-	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec_F77='$convenience'
-	  archive_cmds_need_lc_F77=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds_F77=''
-        ;;
-      m68k)
-            archive_cmds_F77='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec_F77='-L$libdir'
-            hardcode_minus_L_F77=yes
-        ;;
-      esac
-      ;;
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
 
-    bsdi[45]*)
-      export_dynamic_flag_spec_F77=-rdynamic
-      ;;
 
-    cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      hardcode_libdir_flag_spec_F77=' '
-      allow_undefined_flag_F77=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      old_archive_from_new_cmds_F77='true'
-      # FIXME: Should let the user specify the lib program.
-      old_archive_cmds_F77='lib -OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
-      enable_shared_with_static_runtimes_F77=yes
-      ;;
 
-    darwin* | rhapsody*)
 
 
-  archive_cmds_need_lc_F77=no
-  hardcode_direct_F77=no
-  hardcode_automatic_F77=yes
-  hardcode_shlibpath_var_F77=unsupported
-  whole_archive_flag_spec_F77=''
-  link_all_deplibs_F77=yes
-  allow_undefined_flag_F77="$_lt_dar_allow_undefined"
-  if test "$GCC" = "yes"; then
-    output_verbose_link_cmd=echo
-    archive_cmds_F77="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_F77="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_F77="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_F77="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 
-  else
-  ld_shlibs_F77=no
-  fi
 
-      ;;
 
-    dgux*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    freebsd1*)
-      ld_shlibs_F77=no
-      ;;
 
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_F77=yes
-      hardcode_minus_L_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
-      archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds_F77='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      hardcode_direct_F77=yes
 
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L_F77=yes
-      export_dynamic_flag_spec_F77='${wl}-E'
-      ;;
 
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-	hardcode_libdir_flag_spec_ld_F77='+b $libdir'
-	hardcode_libdir_separator_F77=:
-	hardcode_direct_F77=yes
-	hardcode_direct_absolute_F77=yes
-	export_dynamic_flag_spec_F77='${wl}-E'
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L_F77=yes
-      fi
-      ;;
 
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_F77=:
 
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_direct_F77=no
-	  hardcode_shlibpath_var_F77=no
-	  ;;
-	*)
-	  hardcode_direct_F77=yes
-	  hardcode_direct_absolute_F77=yes
-	  export_dynamic_flag_spec_F77='${wl}-E'
+striplib=
+old_striplib=
+{ $as_echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+    ;;
+  *)
+    { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
 
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L_F77=yes
-	  ;;
-	esac
-      fi
-      ;;
 
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	# Try to use the -exported_symbol ld option, if it does not
-	# work, assume that -exports_file does not work either and
-	# implicitly export all symbols.
-        save_LDFLAGS="$LDFLAGS"
-        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
-        cat >conftest.$ac_ext <<_ACEOF
-int foo(void) {}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_f77_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
 
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
 
-fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-        LDFLAGS="$save_LDFLAGS"
-      else
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
-      fi
-      archive_cmds_need_lc_F77='no'
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      inherit_rpath_F77=yes
-      link_all_deplibs_F77=yes
-      ;;
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    newsos6)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_F77=yes
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    *nto* | *qnx*)
-      ;;
 
-    openbsd*)
-      if test -f /usr/libexec/ld.so; then
-	hardcode_direct_F77=yes
-	hardcode_shlibpath_var_F77=no
-	hardcode_direct_absolute_F77=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	  archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec_F77='${wl}-E'
-	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec_F77='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-	     ;;
-	  esac
-	fi
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
 
-    os2*)
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_minus_L_F77=yes
-      allow_undefined_flag_F77=unsupported
-      archive_cmds_F77='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
+  # Report which library types will actually be built
+  { $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+  { $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
 
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag_F77=' -expect_unresolved \*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      archive_cmds_need_lc_F77='no'
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      ;;
+  { $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+  test "$can_build_shared" = "no" && enable_shared=no
 
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag_F77=' -expect_unresolved \*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
 
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec_F77='-rpath $libdir'
-      fi
-      archive_cmds_need_lc_F77='no'
-      hardcode_libdir_separator_F77=:
-      ;;
+  aix[4-9]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  { $as_echo "$as_me:$LINENO: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
 
-    solaris*)
-      no_undefined_flag_F77=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds_F77='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-      else
-	case `$CC -V 2>&1` in
-	*"Compilers 5.0"*)
-	  wlarc=''
-	  archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
-	  ;;
-	*)
-	  wlarc='${wl}'
-	  archive_cmds_F77='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-	  ;;
-	esac
-      fi
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_shlibpath_var_F77=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
-	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
-	# but is careful enough not to reorder.
-	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-	else
-	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract'
-	fi
-	;;
-      esac
-      link_all_deplibs_F77=yes
-      ;;
+  { $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  { $as_echo "$as_me:$LINENO: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+
+      ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+
+
+archive_cmds_need_lc_F77=no
+allow_undefined_flag_F77=
+always_export_symbols_F77=no
+archive_expsym_cmds_F77=
+export_dynamic_flag_spec_F77=
+hardcode_direct_F77=no
+hardcode_direct_absolute_F77=no
+hardcode_libdir_flag_spec_F77=
+hardcode_libdir_flag_spec_ld_F77=
+hardcode_libdir_separator_F77=
+hardcode_minus_L_F77=no
+hardcode_automatic_F77=no
+inherit_rpath_F77=no
+module_cmds_F77=
+module_expsym_cmds_F77=
+link_all_deplibs_F77=unknown
+old_archive_cmds_F77=$old_archive_cmds
+no_undefined_flag_F77=
+whole_archive_flag_spec_F77=
+enable_shared_with_static_runtimes_F77=no
 
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_direct_F77=yes
-      hardcode_minus_L_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
+# Source file extension for f77 test sources.
+ac_ext=f
 
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_F77=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds_F77='$CC -r -o $output$reload_objs'
-	  hardcode_direct_F77=no
-        ;;
-	motorola)
-	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var_F77=no
-      ;;
+# Object file extension for compiled f77 test sources.
+objext=o
+objext_F77=$objext
 
-    sysv4.3*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var_F77=no
-      export_dynamic_flag_spec_F77='-Bexport'
-      ;;
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var_F77=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs_F77=yes
-      fi
-      ;;
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_F77='${wl}-z,text'
-      archive_cmds_need_lc_F77=no
-      hardcode_shlibpath_var_F77=no
-      runpath_var='LD_RUN_PATH'
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
 
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag_F77='${wl}-z,text'
-      allow_undefined_flag_F77='${wl}-z,nodefs'
-      archive_cmds_need_lc_F77=no
-      hardcode_shlibpath_var_F77=no
-      hardcode_libdir_flag_spec_F77='${wl}-R,$libdir'
-      hardcode_libdir_separator_F77=':'
-      link_all_deplibs_F77=yes
-      export_dynamic_flag_spec_F77='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
 
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
 
-    uts4*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_shlibpath_var_F77=no
-      ;;
 
-    *)
-      ld_shlibs_F77=no
-      ;;
-    esac
 
-    if test x$host_vendor = xsni; then
-      case $host in
-      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec_F77='${wl}-Blargedynsym'
-	;;
-      esac
-    fi
-  fi
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
-{ $as_echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
-$as_echo "$ld_shlibs_F77" >&6; }
-test "$ld_shlibs_F77" = no && can_build_shared=no
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
-with_gnu_ld_F77=$with_gnu_ld
+# Allow CC to be a program name with arguments.
+compiler=$CC
 
 
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
 
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
 
 
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${F77-"f77"}
+  compiler=$CC
+  compiler_F77=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_F77" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_F77=yes
+  GCC=$G77
+  if test -n "$compiler"; then
+    { $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+    { $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_F77 in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      { $as_echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-      $RM conftest*
-      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+    { $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+    test "$can_build_shared" = "no" && enable_shared=no
 
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl_F77
-	pic_flag=$lt_prog_compiler_pic_F77
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag_F77
-        allow_undefined_flag_F77=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds_F77 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc_F77=no
-        else
-	  archive_cmds_need_lc_F77=yes
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
         fi
-        allow_undefined_flag_F77=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $RM conftest*
-      { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
-$as_echo "$archive_cmds_need_lc_F77" >&6; }
-      ;;
-    esac
-  fi
-  ;;
-esac
+        ;;
+      aix[4-9]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    { $as_echo "$as_me:$LINENO: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+    { $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    { $as_echo "$as_me:$LINENO: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
 
+    GCC_F77="$G77"
+    LD_F77="$LD"
 
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    lt_prog_compiler_wl_F77=
+lt_prog_compiler_pic_F77=
+lt_prog_compiler_static_F77=
 
+{ $as_echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
 
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_F77='-Wl,'
+    lt_prog_compiler_static_F77='-static'
 
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
+      fi
+      ;;
 
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_F77='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
 
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
 
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_F77='-fno-common'
+      ;;
 
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_F77='-fPIC'
+	;;
+      esac
+      ;;
 
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
 
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_F77=no
+      enable_shared=no
+      ;;
 
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_F77='-fPIC -shared'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_F77=-Kconform_pic
+      fi
+      ;;
 
+    *)
+      lt_prog_compiler_pic_F77='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_F77='-Bstatic'
+      else
+	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
 
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
+      ;;
 
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_F77='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
+      ;;
 
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
 
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc* | ifort*)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-KPIC'
+	lt_prog_compiler_static_F77='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-fpic'
+	lt_prog_compiler_static_F77='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_F77='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_F77='-non_shared'
+        ;;
+      xl*)
+	# IBM XL C 8.0/Fortran 10.1 on PPC
+	lt_prog_compiler_wl_F77='-Wl,'
+	lt_prog_compiler_pic_F77='-qpic'
+	lt_prog_compiler_static_F77='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic_F77='-KPIC'
+	  lt_prog_compiler_static_F77='-Bstatic'
+	  lt_prog_compiler_wl_F77='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic_F77='-KPIC'
+	  lt_prog_compiler_static_F77='-Bstatic'
+	  lt_prog_compiler_wl_F77=''
+	  ;;
+	esac
+	;;
+      esac
+      ;;
 
+    newsos6)
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
 
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_F77='-fPIC -shared'
+      ;;
 
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
 
+    rdos*)
+      lt_prog_compiler_static_F77='-non_shared'
+      ;;
 
+    solaris*)
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl_F77='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl_F77='-Wl,';;
+      esac
+      ;;
 
+    sunos4*)
+      lt_prog_compiler_wl_F77='-Qoption ld '
+      lt_prog_compiler_pic_F77='-PIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
 
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_F77='-Kconform_pic'
+	lt_prog_compiler_static_F77='-Bstatic'
+      fi
+      ;;
 
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_pic_F77='-KPIC'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
 
+    unicos*)
+      lt_prog_compiler_wl_F77='-Wl,'
+      lt_prog_compiler_can_build_shared_F77=no
+      ;;
 
+    uts4*)
+      lt_prog_compiler_pic_F77='-pic'
+      lt_prog_compiler_static_F77='-Bstatic'
+      ;;
 
+    *)
+      lt_prog_compiler_can_build_shared_F77=no
+      ;;
+    esac
+  fi
 
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_F77=
+    ;;
+  *)
+    lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
+$as_echo "$lt_prog_compiler_pic_F77" >&6; }
 
 
 
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_F77"; then
+  { $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... " >&6; }
+if test "${lt_cv_prog_compiler_pic_works_F77+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works_F77=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_F77"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13446: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:13450: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_F77=yes
+     fi
+   fi
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_F77" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_F77" >&6; }
 
+if test x"$lt_cv_prog_compiler_pic_works_F77" = xyes; then
+    case $lt_prog_compiler_pic_F77 in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
+     esac
+else
+    lt_prog_compiler_pic_F77=
+     lt_prog_compiler_can_build_shared_F77=no
+fi
 
+fi
 
 
 
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
+{ $as_echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test "${lt_cv_prog_compiler_static_works_F77+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works_F77=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_F77=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_F77=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_F77" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_F77" >&6; }
 
+if test x"$lt_cv_prog_compiler_static_works_F77" = xyes; then
+    :
+else
+    lt_prog_compiler_static_F77=
+fi
 
 
 
 
+    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_F77=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13545: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:13549: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_F77=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_F77" >&6; }
 
 
 
+    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_F77=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13597: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:13601: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_F77=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_F77" >&6; }
 
 
 
 
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:$LINENO: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
 
 
 
+    { $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
+  runpath_var=
+  allow_undefined_flag_F77=
+  always_export_symbols_F77=no
+  archive_cmds_F77=
+  archive_expsym_cmds_F77=
+  compiler_needs_object_F77=no
+  enable_shared_with_static_runtimes_F77=no
+  export_dynamic_flag_spec_F77=
+  export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic_F77=no
+  hardcode_direct_F77=no
+  hardcode_direct_absolute_F77=no
+  hardcode_libdir_flag_spec_F77=
+  hardcode_libdir_flag_spec_ld_F77=
+  hardcode_libdir_separator_F77=
+  hardcode_minus_L_F77=no
+  hardcode_shlibpath_var_F77=unsupported
+  inherit_rpath_F77=no
+  link_all_deplibs_F77=unknown
+  module_cmds_F77=
+  module_expsym_cmds_F77=
+  old_archive_from_new_cmds_F77=
+  old_archive_from_expsyms_cmds_F77=
+  thread_safe_flag_spec_F77=
+  whole_archive_flag_spec_F77=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_F77=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_F77='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
 
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
 
-    { $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-$as_echo_n "checking dynamic linker characteristics... " >&6; }
+  ld_shlibs_F77=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
 
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec_F77=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_F77=no
+	cat <<_LT_EOF 1>&2
 
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
+_LT_EOF
+      fi
+      ;;
 
-aix[4-9]*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
-	:
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_F77=''
+        ;;
+      m68k)
+            archive_cmds_F77='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_F77='-L$libdir'
+            hardcode_minus_L_F77=yes
+        ;;
+      esac
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_F77=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
       else
-	can_build_shared=no
+	ld_shlibs_F77=no
       fi
       ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
 
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
-  ;;
+    cygwin* | mingw* | pw32*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=no
+      enable_shared_with_static_runtimes_F77=yes
+      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
 
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
 
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
+    interix[3-9]*)
+      hardcode_direct_F77=no
+      hardcode_shlibpath_var_F77=no
+      hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec_F77='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
 
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+    gnu* | linux* | tpf* | k*bsd*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	xl[cC]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec_F77='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object_F77=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds_F77='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds_F77='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+	case $cc_basename in
+	xlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec_F77='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec_F77=
+	  hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
+	  archive_cmds_F77='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    archive_expsym_cmds_F77='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
       else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+        ld_shlibs_F77=no
       fi
       ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
       ;;
-    esac
-    ;;
 
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_F77=no
+	cat <<_LT_EOF 1>&2
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
 
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs_F77=no
+	cat <<_LT_EOF 1>&2
 
-freebsd1*)
-  dynamic_linker=no
-  ;;
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+	    archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs_F77=no
+	  fi
+	;;
+      esac
       ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
+
+    sunos4*)
+      archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
       ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
+    esac
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    if test "$ld_shlibs_F77" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_F77=
+      export_dynamic_flag_spec_F77=
+      whole_archive_flag_spec_F77=
     fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-interix[3-9]*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_F77=unsupported
+      always_export_symbols_F77=yes
+      archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_F77=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_F77=unsupported
+      fi
+      ;;
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
 	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
+	  export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
 
-# This must be Linux ELF.
-linux* | k*bsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # Some binutils ld are patched to set DT_RUNPATH
-  save_LDFLAGS=$LDFLAGS
-  save_libdir=$libdir
-  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_F77\"; \
-       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_F77\""
-  cat >conftest.$ac_ext <<_ACEOF
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds_F77=''
+      hardcode_direct_F77=yes
+      hardcode_direct_absolute_F77=yes
+      hardcode_libdir_separator_F77=':'
+      link_all_deplibs_F77=yes
+      file_list_spec_F77='${wl}-f,'
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct_F77=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L_F77=yes
+	  hardcode_libdir_flag_spec_F77='-L$libdir'
+	  hardcode_libdir_separator_F77=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_F77=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag_F77='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        cat >conftest.$ac_ext <<_ACEOF
       program main
 
       end
@@ -14878,10 +14114,19 @@ $as_echo "$ac_try_echo") >&5
 	 test "$cross_compiling" = yes ||
 	 $as_test_x conftest$ac_exeext
        }; then
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
-  shlibpath_overrides_runpath=yes
-fi
 
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -14892,583 +14137,690 @@ fi
 rm -rf conftest.dSYM
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
-  LDFLAGS=$save_LDFLAGS
-  libdir=$save_libdir
-
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
+        hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds_F77='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_F77="-z nodefs"
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+      program main
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
 
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
-  ;;
+fi
 
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+	 hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_F77=' ${wl}-bernotok'
+	  allow_undefined_flag_F77=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec_F77='$convenience'
+	  archive_cmds_need_lc_F77=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_F77=''
+        ;;
+      m68k)
+            archive_cmds_F77='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_F77='-L$libdir'
+            hardcode_minus_L_F77=yes
+        ;;
       esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
+      ;;
 
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
+    bsdi[45]*)
+      export_dynamic_flag_spec_F77=-rdynamic
+      ;;
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec_F77=' '
+      allow_undefined_flag_F77=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_from_new_cmds_F77='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_F77='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_F77=yes
+      ;;
 
-rdos*)
-  dynamic_linker=no
-  ;;
+    darwin* | rhapsody*)
 
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
+  archive_cmds_need_lc_F77=no
+  hardcode_direct_F77=no
+  hardcode_automatic_F77=yes
+  hardcode_shlibpath_var_F77=unsupported
+  whole_archive_flag_spec_F77=''
+  link_all_deplibs_F77=yes
+  allow_undefined_flag_F77="$_lt_dar_allow_undefined"
+  if test "$GCC" = "yes"; then
+    output_verbose_link_cmd=echo
+    archive_cmds_F77="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_F77="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_F77="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_F77="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+  else
+  ld_shlibs_F77=no
   fi
-  need_version=yes
-  ;;
 
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
       ;;
-    siemens)
-      need_lib_prefix=no
+
+    dgux*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
       ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+
+    freebsd1*)
+      ld_shlibs_F77=no
       ;;
-  esac
-  ;;
 
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds_F77='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_direct_F77=yes
 
-*)
-  dynamic_linker=no
-  ;;
-esac
-{ $as_echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-$as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_F77=yes
+      export_dynamic_flag_spec_F77='${wl}-E'
+      ;;
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	hardcode_libdir_flag_spec_ld_F77='+b $libdir'
+	hardcode_libdir_separator_F77=:
+	hardcode_direct_F77=yes
+	hardcode_direct_absolute_F77=yes
+	export_dynamic_flag_spec_F77='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L_F77=yes
+      fi
+      ;;
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
-fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
-fi
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_F77=:
 
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct_F77=no
+	  hardcode_shlibpath_var_F77=no
+	  ;;
+	*)
+	  hardcode_direct_F77=yes
+	  hardcode_direct_absolute_F77=yes
+	  export_dynamic_flag_spec_F77='${wl}-E'
 
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_F77=yes
+	  ;;
+	esac
+      fi
+      ;;
 
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        cat >conftest.$ac_ext <<_ACEOF
+int foo(void) {}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
+  archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
 
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
 
+fi
 
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+      else
+	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc_F77='no'
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      inherit_rpath_F77=yes
+      link_all_deplibs_F77=yes
+      ;;
 
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_direct_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
+    newsos6)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_F77=yes
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      hardcode_shlibpath_var_F77=no
+      ;;
 
+    *nto* | *qnx*)
+      ;;
 
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct_F77=yes
+	hardcode_shlibpath_var_F77=no
+	hardcode_direct_absolute_F77=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec_F77='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec_F77='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	ld_shlibs_F77=no
+      fi
+      ;;
 
+    os2*)
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_minus_L_F77=yes
+      allow_undefined_flag_F77=unsupported
+      archive_cmds_F77='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
 
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc_F77='no'
+      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_F77=:
+      ;;
 
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag_F77=' -expect_unresolved \*'
+	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
 
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_F77='-rpath $libdir'
+      fi
+      archive_cmds_need_lc_F77='no'
+      hardcode_libdir_separator_F77=:
+      ;;
 
+    solaris*)
+      no_undefined_flag_F77=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds_F77='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  archive_cmds_F77='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_F77='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      hardcode_libdir_flag_spec_F77='-R$libdir'
+      hardcode_shlibpath_var_F77=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs_F77=yes
+      ;;
 
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_direct_F77=yes
+      hardcode_minus_L_F77=yes
+      hardcode_shlibpath_var_F77=no
+      ;;
 
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_F77='$CC -r -o $output$reload_objs'
+	  hardcode_direct_F77=no
+        ;;
+	motorola)
+	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_F77=no
+      ;;
 
+    sysv4.3*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_F77=no
+      export_dynamic_flag_spec_F77='-Bexport'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_F77=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_F77=yes
+      fi
+      ;;
 
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_F77='${wl}-z,text'
+      archive_cmds_need_lc_F77=no
+      hardcode_shlibpath_var_F77=no
+      runpath_var='LD_RUN_PATH'
 
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
 
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag_F77='${wl}-z,text'
+      allow_undefined_flag_F77='${wl}-z,nodefs'
+      archive_cmds_need_lc_F77=no
+      hardcode_shlibpath_var_F77=no
+      hardcode_libdir_flag_spec_F77='${wl}-R,$libdir'
+      hardcode_libdir_separator_F77=':'
+      link_all_deplibs_F77=yes
+      export_dynamic_flag_spec_F77='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
 
+      if test "$GCC" = yes; then
+	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
 
+    uts4*)
+      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_F77='-L$libdir'
+      hardcode_shlibpath_var_F77=no
+      ;;
 
+    *)
+      ld_shlibs_F77=no
+      ;;
+    esac
 
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec_F77='${wl}-Blargedynsym'
+	;;
+      esac
+    fi
+  fi
 
+{ $as_echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
+$as_echo "$ld_shlibs_F77" >&6; }
+test "$ld_shlibs_F77" = no && can_build_shared=no
 
+with_gnu_ld_F77=$with_gnu_ld
 
 
 
 
 
 
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_F77" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_F77=yes
 
-    { $as_echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
-hardcode_action_F77=
-if test -n "$hardcode_libdir_flag_spec_F77" ||
-   test -n "$runpath_var_F77" ||
-   test "X$hardcode_automatic_F77" = "Xyes" ; then
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_F77 in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-  # We can hardcode non-existent directories.
-  if test "$hardcode_direct_F77" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
-     test "$hardcode_minus_L_F77" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_F77=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_F77=immediate
+      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_F77
+	pic_flag=$lt_prog_compiler_pic_F77
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_F77
+        allow_undefined_flag_F77=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_F77 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_F77=no
+        else
+	  archive_cmds_need_lc_F77=yes
+        fi
+        allow_undefined_flag_F77=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
+$as_echo "$archive_cmds_need_lc_F77" >&6; }
+      ;;
+    esac
   fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_F77=unsupported
-fi
-{ $as_echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
-$as_echo "$hardcode_action_F77" >&6; }
-
-if test "$hardcode_action_F77" = relink ||
-   test "$inherit_rpath_F77" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-
-
-
-
-
+  ;;
+esac
+
+
 
 
-  fi # test -n "$compiler"
 
-  GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-fi # test "$_lt_disable_F77" != yes
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-      ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
-archive_cmds_need_lc_FC=no
-allow_undefined_flag_FC=
-always_export_symbols_FC=no
-archive_expsym_cmds_FC=
-export_dynamic_flag_spec_FC=
-hardcode_direct_FC=no
-hardcode_direct_absolute_FC=no
-hardcode_libdir_flag_spec_FC=
-hardcode_libdir_flag_spec_ld_FC=
-hardcode_libdir_separator_FC=
-hardcode_minus_L_FC=no
-hardcode_automatic_FC=no
-inherit_rpath_FC=no
-module_cmds_FC=
-module_expsym_cmds_FC=
-link_all_deplibs_FC=unknown
-old_archive_cmds_FC=$old_archive_cmds
-no_undefined_flag_FC=
-whole_archive_flag_spec_FC=
-enable_shared_with_static_runtimes_FC=no
 
-# Source file extension for fc test sources.
-ac_ext=${ac_fc_srcext-f}
 
-# Object file extension for compiled fc test sources.
-objext=o
-objext_FC=$objext
 
-# No sense in running all these tests if we already determined that
-# the FC compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="\
-      subroutine t
-      return
-      end
-"
 
-  # Code to be used in simple link tests
-  lt_simple_link_test_code="\
-      program t
-      end
-"
 
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
 
 
 
 
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
 
 
-  # save warnings/boilerplate of simple test code
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
 
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
 
 
-  # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
-  lt_save_GCC=$GCC
-  CC=${FC-"f95"}
-  compiler=$CC
-  GCC=$ac_cv_fc_compiler_gnu
 
-  compiler_FC=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
 
-  if test -n "$compiler"; then
-    { $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-$as_echo_n "checking if libtool supports shared libraries... " >&6; }
-    { $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5
-$as_echo "$can_build_shared" >&6; }
 
-    { $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-$as_echo_n "checking whether to build shared libraries... " >&6; }
-    test "$can_build_shared" = "no" && enable_shared=no
 
-    # On AIX, shared libraries and static libraries use the same namespace, and
-    # are all built from PIC.
-    case $host_os in
-      aix3*)
-        test "$enable_shared" = yes && enable_static=no
-        if test -n "$RANLIB"; then
-          archive_cmds="$archive_cmds~\$RANLIB \$lib"
-          postinstall_cmds='$RANLIB $lib'
-        fi
-        ;;
-      aix[4-9]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
-	fi
-        ;;
-    esac
-    { $as_echo "$as_me:$LINENO: result: $enable_shared" >&5
-$as_echo "$enable_shared" >&6; }
 
-    { $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-$as_echo_n "checking whether to build static libraries... " >&6; }
-    # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
-    { $as_echo "$as_me:$LINENO: result: $enable_static" >&5
-$as_echo "$enable_static" >&6; }
 
-    GCC_FC="$ac_cv_fc_compiler_gnu"
-    LD_FC="$LD"
 
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    # Dependencies to place before and after the object being linked:
-predep_objects_FC=
-postdep_objects_FC=
-predeps_FC=
-postdeps_FC=
-compiler_lib_search_path_FC=
 
-cat > conftest.$ac_ext <<_LT_EOF
-      subroutine foo
-      implicit none
-      integer a
-      a=0
-      return
-      end
-_LT_EOF
 
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  # Parse the compiler output and extract the necessary
-  # objects, libraries and library flags.
 
-  # Sentinel used to keep track of whether or not we are before
-  # the conftest object file.
-  pre_test_object_deps_done=no
 
-  for p in `eval "$output_verbose_link_cmd"`; do
-    case $p in
 
-    -L* | -R* | -l*)
-       # Some compilers place space between "-{L,R}" and the path.
-       # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
-	 prev=$p
-	 continue
-       else
-	 prev=
-       fi
 
-       if test "$pre_test_object_deps_done" = no; then
-	 case $p in
-	 -L* | -R*)
-	   # Internal compiler library paths should come after those
-	   # provided the user.  The postdeps already come after the
-	   # user supplied libs so there is no need to process them.
-	   if test -z "$compiler_lib_search_path_FC"; then
-	     compiler_lib_search_path_FC="${prev}${p}"
-	   else
-	     compiler_lib_search_path_FC="${compiler_lib_search_path_FC} ${prev}${p}"
-	   fi
-	   ;;
-	 # The "-l" case would never come before the object being
-	 # linked, so don't bother handling this case.
-	 esac
-       else
-	 if test -z "$postdeps_FC"; then
-	   postdeps_FC="${prev}${p}"
-	 else
-	   postdeps_FC="${postdeps_FC} ${prev}${p}"
-	 fi
-       fi
-       ;;
 
-    *.$objext)
-       # This assumes that the test object file only shows up
-       # once in the compiler output.
-       if test "$p" = "conftest.$objext"; then
-	 pre_test_object_deps_done=yes
-	 continue
-       fi
 
-       if test "$pre_test_object_deps_done" = no; then
-	 if test -z "$predep_objects_FC"; then
-	   predep_objects_FC="$p"
-	 else
-	   predep_objects_FC="$predep_objects_FC $p"
-	 fi
-       else
-	 if test -z "$postdep_objects_FC"; then
-	   postdep_objects_FC="$p"
-	 else
-	   postdep_objects_FC="$postdep_objects_FC $p"
-	 fi
-       fi
-       ;;
 
-    *) ;; # Ignore the rest.
 
-    esac
-  done
 
-  # Clean up.
-  rm -f a.out a.exe
-else
-  echo "libtool.m4: error: problem compiling FC test program"
-fi
 
-$RM -f confest.$objext
 
-# PORTME: override above test on systems where it is broken
 
 
-case " $postdeps_FC " in
-*" -lc "*) archive_cmds_need_lc_FC=no ;;
-esac
- compiler_lib_search_dirs_FC=
-if test -n "${compiler_lib_search_path_FC}"; then
- compiler_lib_search_dirs_FC=`echo " ${compiler_lib_search_path_FC}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
-fi
 
 
 
@@ -15481,2077 +14833,2276 @@ fi
 
 
 
+    { $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
 
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
 
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
 
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
 
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
 
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
 
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
 
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
 
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
 
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
 
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
 
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
 
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
 
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
 
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
+freebsd1*)
+  dynamic_linker=no
+  ;;
 
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
 
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
 
-    lt_prog_compiler_wl_FC=
-lt_prog_compiler_pic_FC=
-lt_prog_compiler_static_FC=
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
 
-{ $as_echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl_FC='-Wl,'
-    lt_prog_compiler_static_FC='-static'
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
 
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_FC='-Bstatic'
-      fi
-      ;;
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            lt_prog_compiler_pic_FC='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
-            lt_prog_compiler_pic_FC='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_F77\"; \
+       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_F77\""
+  cat >conftest.$ac_ext <<_ACEOF
+      program main
 
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
+  shlibpath_overrides_runpath=yes
+fi
 
-    mingw* | cygwin* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
-      ;;
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_FC='-fno-common'
-      ;;
 
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_FC='-fPIC'
-	;;
-      esac
-      ;;
+fi
 
-    interix[3-9]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
 
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared_FC=no
-      enable_shared=no
-      ;;
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
 
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic_FC='-fPIC -shared'
-      ;;
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_FC=-Kconform_pic
-      fi
-      ;;
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
 
-    *)
-      lt_prog_compiler_pic_FC='-fPIC'
-      ;;
-    esac
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
   else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_FC='-Bstatic'
-      else
-	lt_prog_compiler_static_FC='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-
-    mingw* | cygwin* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
-      ;;
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
 
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_FC='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static_FC='${wl}-a ${wl}archive'
-      ;;
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
 
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static_FC='-non_shared'
-      ;;
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
 
-    linux* | k*bsd*-gnu)
-      case $cc_basename in
-      icc* | ecc* | ifort*)
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='-KPIC'
-	lt_prog_compiler_static_FC='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='-fpic'
-	lt_prog_compiler_static_FC='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl_FC='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static_FC='-non_shared'
-        ;;
-      xl*)
-	# IBM XL C 8.0/Fortran 10.1 on PPC
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='-qpic'
-	lt_prog_compiler_static_FC='-qstaticlink'
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
 	;;
       *)
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)
-	  # Sun C 5.9
-	  lt_prog_compiler_pic_FC='-KPIC'
-	  lt_prog_compiler_static_FC='-Bstatic'
-	  lt_prog_compiler_wl_FC='-Wl,'
-	  ;;
-	*Sun\ F*)
-	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
-	  lt_prog_compiler_pic_FC='-KPIC'
-	  lt_prog_compiler_static_FC='-Bstatic'
-	  lt_prog_compiler_wl_FC=''
-	  ;;
-	esac
+	shlibpath_overrides_runpath=yes
 	;;
       esac
-      ;;
-
-    newsos6)
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
-
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic_FC='-fPIC -shared'
-      ;;
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
 
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static_FC='-non_shared'
-      ;;
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
 
-    rdos*)
-      lt_prog_compiler_static_FC='-non_shared'
-      ;;
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
 
-    solaris*)
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_FC='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_FC='-Wl,';;
-      esac
-      ;;
+rdos*)
+  dynamic_linker=no
+  ;;
 
-    sunos4*)
-      lt_prog_compiler_wl_FC='-Qoption ld '
-      lt_prog_compiler_pic_FC='-PIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
 
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic_FC='-Kconform_pic'
-	lt_prog_compiler_static_FC='-Bstatic'
-      fi
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
       ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
+    siemens)
+      need_lib_prefix=no
       ;;
-
-    unicos*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      lt_prog_compiler_can_build_shared_FC=no
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
       ;;
+  esac
+  ;;
 
-    uts4*)
-      lt_prog_compiler_pic_FC='-pic'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
 
-    *)
-      lt_prog_compiler_can_build_shared_FC=no
-      ;;
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
     esac
   fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
 
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_FC=
-    ;;
-  *)
-    lt_prog_compiler_pic_FC="$lt_prog_compiler_pic_FC"
-    ;;
-esac
-{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_FC" >&5
-$as_echo "$lt_prog_compiler_pic_FC" >&6; }
-
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_FC"; then
-  { $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_FC works" >&5
-$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_FC works... " >&6; }
-if test "${lt_cv_prog_compiler_pic_works_FC+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_pic_works_FC=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_FC"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15791: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:15795: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_pic_works_FC=yes
-     fi
-   fi
-   $RM conftest*
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
 
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_FC" >&5
-$as_echo "$lt_cv_prog_compiler_pic_works_FC" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works_FC" = xyes; then
-    case $lt_prog_compiler_pic_FC in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_FC=" $lt_prog_compiler_pic_FC" ;;
-     esac
-else
-    lt_prog_compiler_pic_FC=
-     lt_prog_compiler_can_build_shared_FC=no
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
 fi
-
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
 fi
 
 
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_FC eval lt_tmp_static_flag=\"$lt_prog_compiler_static_FC\"
-{ $as_echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if test "${lt_cv_prog_compiler_static_works_FC+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_static_works_FC=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler_static_works_FC=yes
-       fi
-     else
-       lt_cv_prog_compiler_static_works_FC=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
 
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_FC" >&5
-$as_echo "$lt_cv_prog_compiler_static_works_FC" >&6; }
 
-if test x"$lt_cv_prog_compiler_static_works_FC" = xyes; then
-    :
-else
-    lt_prog_compiler_static_FC=
-fi
 
 
 
 
-    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if test "${lt_cv_prog_compiler_c_o_FC+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_c_o_FC=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15890: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:15894: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_FC=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
 
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_FC" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
 
 
 
-    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if test "${lt_cv_prog_compiler_c_o_FC+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_c_o_FC=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15942: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:15946: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_FC=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
 
-fi
-{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_FC" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
 
 
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_FC" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  { $as_echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-$as_echo_n "checking if we can lock with hard links... " >&6; }
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { $as_echo "$as_me:$LINENO: result: $hard_links" >&5
-$as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
 
 
 
-    { $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
-  runpath_var=
-  allow_undefined_flag_FC=
-  always_export_symbols_FC=no
-  archive_cmds_FC=
-  archive_expsym_cmds_FC=
-  compiler_needs_object_FC=no
-  enable_shared_with_static_runtimes_FC=no
-  export_dynamic_flag_spec_FC=
-  export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  hardcode_automatic_FC=no
-  hardcode_direct_FC=no
-  hardcode_direct_absolute_FC=no
-  hardcode_libdir_flag_spec_FC=
-  hardcode_libdir_flag_spec_ld_FC=
-  hardcode_libdir_separator_FC=
-  hardcode_minus_L_FC=no
-  hardcode_shlibpath_var_FC=unsupported
-  inherit_rpath_FC=no
-  link_all_deplibs_FC=unknown
-  module_cmds_FC=
-  module_expsym_cmds_FC=
-  old_archive_from_new_cmds_FC=
-  old_archive_from_expsyms_cmds_FC=
-  thread_safe_flag_spec_FC=
-  whole_archive_flag_spec_FC=
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms_FC=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms_FC='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  # Exclude shared library initialization/finalization symbols.
-  extract_expsyms_cmds=
 
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
 
-  ld_shlibs_FC=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec_FC='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec_FC="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    else
-      whole_archive_flag_spec_FC=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>&1` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
 
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix[3-9]*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs_FC=no
-	cat <<_LT_EOF 1>&2
 
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
 
-_LT_EOF
-      fi
-      ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds_FC=''
-        ;;
-      m68k)
-            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec_FC='-L$libdir'
-            hardcode_minus_L_FC=yes
-        ;;
-      esac
-      ;;
 
-    beos*)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag_FC=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds_FC='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
 
-    cygwin* | mingw* | pw32*)
-      # _LT_TAGVAR(hardcode_libdir_flag_spec, FC) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      allow_undefined_flag_FC=unsupported
-      always_export_symbols_FC=no
-      enable_shared_with_static_runtimes_FC=yes
-      export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
 
-      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds_FC='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
 
-    interix[3-9]*)
-      hardcode_direct_FC=no
-      hardcode_shlibpath_var_FC=no
-      hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec_FC='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds_FC='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
 
-    gnu* | linux* | tpf* | k*bsd*-gnu)
-      tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
-	case $cc_basename in
-	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
-	esac
-      fi
-      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
-      then
-	tmp_addflag=
-	tmp_sharedflag='-shared'
-	case $cc_basename,$host_cpu in
-        pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	xl[cC]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
-	  tmp_sharedflag='-qmkshrobj'
-	  tmp_addflag= ;;
-	esac
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec_FC='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
-	  compiler_needs_object_FC=yes
-	  tmp_sharedflag='-G' ;;
-	*Sun\ F*)			# Sun Fortran 8.3
-	  tmp_sharedflag='-G' ;;
-	esac
-	archive_cmds_FC='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    { $as_echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_F77=
+if test -n "$hardcode_libdir_flag_spec_F77" ||
+   test -n "$runpath_var_F77" ||
+   test "X$hardcode_automatic_F77" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_F77" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
+     test "$hardcode_minus_L_F77" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_F77=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_F77=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_F77=unsupported
+fi
+{ $as_echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
+$as_echo "$hardcode_action_F77" >&6; }
+
+if test "$hardcode_action_F77" = relink ||
+   test "$inherit_rpath_F77" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+      ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
-        if test "x$supports_anon_versioning" = xyes; then
-          archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-        fi
 
-	case $cc_basename in
-	xlf*)
-	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-	  whole_archive_flag_spec_FC='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec_FC=
-	  hardcode_libdir_flag_spec_ld_FC='-rpath $libdir'
-	  archive_cmds_FC='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
-	    archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
-	  fi
-	  ;;
-	esac
-      else
-        ld_shlibs_FC=no
-      fi
-      ;;
+archive_cmds_need_lc_FC=no
+allow_undefined_flag_FC=
+always_export_symbols_FC=no
+archive_expsym_cmds_FC=
+export_dynamic_flag_spec_FC=
+hardcode_direct_FC=no
+hardcode_direct_absolute_FC=no
+hardcode_libdir_flag_spec_FC=
+hardcode_libdir_flag_spec_ld_FC=
+hardcode_libdir_separator_FC=
+hardcode_minus_L_FC=no
+hardcode_automatic_FC=no
+inherit_rpath_FC=no
+module_cmds_FC=
+module_expsym_cmds_FC=
+link_all_deplibs_FC=unknown
+old_archive_cmds_FC=$old_archive_cmds
+no_undefined_flag_FC=
+whole_archive_flag_spec_FC=
+enable_shared_with_static_runtimes_FC=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+objext_FC=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds_FC='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
 
-    solaris*)
-      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
-	ld_shlibs_FC=no
-	cat <<_LT_EOF 1>&2
 
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
 
-_LT_EOF
-      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs_FC=no
-	cat <<_LT_EOF 1>&2
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
-_LT_EOF
-	;;
-	*)
-	  # For security reasons, it is highly recommended that you always
-	  # use absolute paths for naming shared libraries, and exclude the
-	  # DT_RUNPATH tag from executables and libraries.  But doing so
-	  # requires that you compile everything twice, which is a pain.
-	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-	    archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  else
-	    ld_shlibs_FC=no
-	  fi
-	;;
-      esac
-      ;;
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
-    sunos4*)
-      archive_cmds_FC='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
+# Allow CC to be a program name with arguments.
+compiler=$CC
 
-    *)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
-    esac
 
-    if test "$ld_shlibs_FC" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_FC=
-      export_dynamic_flag_spec_FC=
-      whole_archive_flag_spec_FC=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag_FC=unsupported
-      always_export_symbols_FC=yes
-      archive_expsym_cmds_FC='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L_FC=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct_FC=unsupported
-      fi
-      ;;
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
 
-    aix[4-9]*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds_FC='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds_FC='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
 
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
-	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-	    aix_use_runtimelinking=yes
-	    break
-	  fi
-	  done
-	  ;;
-	esac
 
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  CC=${FC-"f95"}
+  compiler=$CC
+  GCC=$ac_cv_fc_compiler_gnu
 
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+  compiler_FC=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
 
-      archive_cmds_FC=''
-      hardcode_direct_FC=yes
-      hardcode_direct_absolute_FC=yes
-      hardcode_libdir_separator_FC=':'
-      link_all_deplibs_FC=yes
-      file_list_spec_FC='${wl}-f,'
 
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	  # We have reworked collect2
-	  :
-	  else
-	  # We have old collect2
-	  hardcode_direct_FC=unsupported
-	  # It fails to find uninstalled libraries when the uninstalled
-	  # path is not listed in the libpath.  Setting hardcode_minus_L
-	  # to unsupported forces relinking
-	  hardcode_minus_L_FC=yes
-	  hardcode_libdir_flag_spec_FC='-L$libdir'
-	  hardcode_libdir_separator_FC=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
+  if test -n "$compiler"; then
+    { $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+    { $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+    { $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[4-9]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
 	fi
-      fi
+        ;;
+    esac
+    { $as_echo "$as_me:$LINENO: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
 
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols_FC=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag_FC='-berok'
-        # Determine the default libpath from the value encoded in an
-        # empty executable.
-        cat >conftest.$ac_ext <<_ACEOF
-      program main
+    { $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    { $as_echo "$as_me:$LINENO: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+    GCC_FC="$ac_cv_fc_compiler_gnu"
+    LD_FC="$LD"
 
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    # Dependencies to place before and after the object being linked:
+predep_objects_FC=
+postdep_objects_FC=
+predeps_FC=
+postdeps_FC=
+compiler_lib_search_path_FC=
+
+cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
       end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
+_LT_EOF
+
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_fc_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
+  (exit $ac_status); }; then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
 
-lt_aix_libpath_sed='
-    /Import File Strings/,/^$/ {
-	/^0/ {
-	    s/^0  *\(.*\)$/\1/
-	    p
-	}
-    }'
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then
-  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-fi
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
 
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case $p in
 
-fi
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       else
+	 prev=
+       fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+       if test "$pre_test_object_deps_done" = no; then
+	 case $p in
+	 -L* | -R*)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$compiler_lib_search_path_FC"; then
+	     compiler_lib_search_path_FC="${prev}${p}"
+	   else
+	     compiler_lib_search_path_FC="${compiler_lib_search_path_FC} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$postdeps_FC"; then
+	   postdeps_FC="${prev}${p}"
+	 else
+	   postdeps_FC="${postdeps_FC} ${prev}${p}"
+	 fi
+       fi
+       ;;
 
-        hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds_FC='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-      else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec_FC='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag_FC="-z nodefs"
-	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an
-	 # empty executable.
-	 cat >conftest.$ac_ext <<_ACEOF
-      program main
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
 
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_fc_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$predep_objects_FC"; then
+	   predep_objects_FC="$p"
+	 else
+	   predep_objects_FC="$predep_objects_FC $p"
+	 fi
+       else
+	 if test -z "$postdep_objects_FC"; then
+	   postdep_objects_FC="$p"
+	 else
+	   postdep_objects_FC="$postdep_objects_FC $p"
+	 fi
+       fi
+       ;;
 
-lt_aix_libpath_sed='
-    /Import File Strings/,/^$/ {
-	/^0/ {
-	    s/^0  *\(.*\)$/\1/
-	    p
-	}
-    }'
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then
-  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-fi
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
 else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  echo "libtool.m4: error: problem compiling FC test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
 
 
+case " $postdeps_FC " in
+*" -lc "*) archive_cmds_need_lc_FC=no ;;
+esac
+ compiler_lib_search_dirs_FC=
+if test -n "${compiler_lib_search_path_FC}"; then
+ compiler_lib_search_dirs_FC=`echo " ${compiler_lib_search_path_FC}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
 fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
-	 hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag_FC=' ${wl}-bernotok'
-	  allow_undefined_flag_FC=' ${wl}-berok'
-	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec_FC='$convenience'
-	  archive_cmds_need_lc_FC=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds_FC=''
-        ;;
-      m68k)
-            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec_FC='-L$libdir'
-            hardcode_minus_L_FC=yes
-        ;;
-      esac
-      ;;
 
-    bsdi[45]*)
-      export_dynamic_flag_spec_FC=-rdynamic
-      ;;
 
-    cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      hardcode_libdir_flag_spec_FC=' '
-      allow_undefined_flag_FC=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      archive_cmds_FC='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      old_archive_from_new_cmds_FC='true'
-      # FIXME: Should let the user specify the lib program.
-      old_archive_cmds_FC='lib -OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_FC='`cygpath -w "$srcfile"`'
-      enable_shared_with_static_runtimes_FC=yes
-      ;;
 
-    darwin* | rhapsody*)
 
 
-  archive_cmds_need_lc_FC=no
-  hardcode_direct_FC=no
-  hardcode_automatic_FC=yes
-  hardcode_shlibpath_var_FC=unsupported
-  whole_archive_flag_spec_FC=''
-  link_all_deplibs_FC=yes
-  allow_undefined_flag_FC="$_lt_dar_allow_undefined"
-  if test "$GCC" = "yes"; then
-    output_verbose_link_cmd=echo
-    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 
-  else
-  ld_shlibs_FC=no
-  fi
 
-      ;;
 
-    dgux*)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    freebsd1*)
-      ld_shlibs_FC=no
-      ;;
 
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_FC=yes
-      hardcode_minus_L_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
-      archive_cmds_FC='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds_FC='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
-      hardcode_direct_FC=yes
 
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L_FC=yes
-      export_dynamic_flag_spec_FC='${wl}-E'
-      ;;
 
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds_FC='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_FC='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
-	hardcode_libdir_flag_spec_ld_FC='+b $libdir'
-	hardcode_libdir_separator_FC=:
-	hardcode_direct_FC=yes
-	hardcode_direct_absolute_FC=yes
-	export_dynamic_flag_spec_FC='${wl}-E'
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L_FC=yes
-      fi
-      ;;
 
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_FC='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_FC=:
 
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_direct_FC=no
-	  hardcode_shlibpath_var_FC=no
-	  ;;
-	*)
-	  hardcode_direct_FC=yes
-	  hardcode_direct_absolute_FC=yes
-	  export_dynamic_flag_spec_FC='${wl}-E'
 
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L_FC=yes
-	  ;;
-	esac
-      fi
-      ;;
 
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	# Try to use the -exported_symbol ld option, if it does not
-	# work, assume that -exports_file does not work either and
-	# implicitly export all symbols.
-        save_LDFLAGS="$LDFLAGS"
-        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
-        cat >conftest.$ac_ext <<_ACEOF
-int foo(void) {}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_fc_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
 
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
 
-fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-        LDFLAGS="$save_LDFLAGS"
-      else
-	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
-      fi
-      archive_cmds_need_lc_FC='no'
-      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
-      inherit_rpath_FC=yes
-      link_all_deplibs_FC=yes
-      ;;
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds_FC='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    newsos6)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_FC=yes
-      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    *nto* | *qnx*)
-      ;;
 
-    openbsd*)
-      if test -f /usr/libexec/ld.so; then
-	hardcode_direct_FC=yes
-	hardcode_shlibpath_var_FC=no
-	hardcode_direct_absolute_FC=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	  archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec_FC='${wl}-E'
-	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec_FC='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
-	     ;;
-	  esac
-	fi
-      else
-	ld_shlibs_FC=no
+
+    lt_prog_compiler_wl_FC=
+lt_prog_compiler_pic_FC=
+lt_prog_compiler_static_FC=
+
+{ $as_echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_FC='-Wl,'
+    lt_prog_compiler_static_FC='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_FC='-Bstatic'
       fi
       ;;
 
-    os2*)
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_minus_L_FC=yes
-      allow_undefined_flag_FC=unsupported
-      archive_cmds_FC='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds_FC='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
-
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag_FC=' -expect_unresolved \*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      archive_cmds_need_lc_FC='no'
-      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_FC='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_FC='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
       ;;
 
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag_FC=' -expect_unresolved \*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_FC='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
 
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec_FC='-rpath $libdir'
-      fi
-      archive_cmds_need_lc_FC='no'
-      hardcode_libdir_separator_FC=:
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
       ;;
 
-    solaris*)
-      no_undefined_flag_FC=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds_FC='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-      else
-	case `$CC -V 2>&1` in
-	*"Compilers 5.0"*)
-	  wlarc=''
-	  archive_cmds_FC='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
-	  ;;
-	*)
-	  wlarc='${wl}'
-	  archive_cmds_FC='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-	  ;;
-	esac
-      fi
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_shlibpath_var_FC=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_FC='-fno-common'
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
       *)
-	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
-	# but is careful enough not to reorder.
-	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec_FC='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-	else
-	  whole_archive_flag_spec_FC='-z allextract$convenience -z defaultextract'
-	fi
+	lt_prog_compiler_pic_FC='-fPIC'
 	;;
       esac
-      link_all_deplibs_FC=yes
       ;;
 
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds_FC='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_FC='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_direct_FC=yes
-      hardcode_minus_L_FC=yes
-      hardcode_shlibpath_var_FC=no
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
       ;;
 
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_FC=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds_FC='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds_FC='$CC -r -o $output$reload_objs'
-	  hardcode_direct_FC=no
-        ;;
-	motorola)
-	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_FC=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var_FC=no
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_FC=no
+      enable_shared=no
       ;;
 
-    sysv4.3*)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var_FC=no
-      export_dynamic_flag_spec_FC='-Bexport'
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_FC='-fPIC -shared'
       ;;
 
     sysv4*MP*)
       if test -d /usr/nec; then
-	archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var_FC=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs_FC=yes
+	lt_prog_compiler_pic_FC=-Kconform_pic
       fi
       ;;
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_FC='${wl}-z,text'
-      archive_cmds_need_lc_FC=no
-      hardcode_shlibpath_var_FC=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+    *)
+      lt_prog_compiler_pic_FC='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_FC='-Bstatic'
       else
-	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	lt_prog_compiler_static_FC='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
 
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag_FC='${wl}-z,text'
-      allow_undefined_flag_FC='${wl}-z,nodefs'
-      archive_cmds_need_lc_FC=no
-      hardcode_shlibpath_var_FC=no
-      hardcode_libdir_flag_spec_FC='${wl}-R,$libdir'
-      hardcode_libdir_separator_FC=':'
-      link_all_deplibs_FC=yes
-      export_dynamic_flag_spec_FC='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
+    mingw* | cygwin* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
       ;;
 
-    uts4*)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_shlibpath_var_FC=no
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_FC='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_FC='${wl}-a ${wl}archive'
       ;;
 
-    *)
-      ld_shlibs_FC=no
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_FC='-non_shared'
       ;;
-    esac
 
-    if test x$host_vendor = xsni; then
-      case $host in
-      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec_FC='${wl}-Blargedynsym'
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+      icc* | ecc* | ifort*)
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='-KPIC'
+	lt_prog_compiler_static_FC='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='-fpic'
+	lt_prog_compiler_static_FC='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_FC='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_FC='-non_shared'
+        ;;
+      xl*)
+	# IBM XL C 8.0/Fortran 10.1 on PPC
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='-qpic'
+	lt_prog_compiler_static_FC='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic_FC='-KPIC'
+	  lt_prog_compiler_static_FC='-Bstatic'
+	  lt_prog_compiler_wl_FC='-Wl,'
+	  ;;
+	*Sun\ F*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic_FC='-KPIC'
+	  lt_prog_compiler_static_FC='-Bstatic'
+	  lt_prog_compiler_wl_FC=''
+	  ;;
+	esac
 	;;
       esac
-    fi
-  fi
+      ;;
 
-{ $as_echo "$as_me:$LINENO: result: $ld_shlibs_FC" >&5
-$as_echo "$ld_shlibs_FC" >&6; }
-test "$ld_shlibs_FC" = no && can_build_shared=no
+    newsos6)
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
+
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_FC='-fPIC -shared'
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_FC='-non_shared'
+      ;;
 
-with_gnu_ld_FC=$with_gnu_ld
+    rdos*)
+      lt_prog_compiler_static_FC='-non_shared'
+      ;;
 
+    solaris*)
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+	lt_prog_compiler_wl_FC='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl_FC='-Wl,';;
+      esac
+      ;;
 
+    sunos4*)
+      lt_prog_compiler_wl_FC='-Qoption ld '
+      lt_prog_compiler_pic_FC='-PIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
 
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_FC='-Kconform_pic'
+	lt_prog_compiler_static_FC='-Bstatic'
+      fi
+      ;;
 
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
 
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_FC" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_FC=yes
+    unicos*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      lt_prog_compiler_can_build_shared_FC=no
+      ;;
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_FC in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
+    uts4*)
+      lt_prog_compiler_pic_FC='-pic'
+      lt_prog_compiler_static_FC='-Bstatic'
       ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      { $as_echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-      $RM conftest*
-      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl_FC
-	pic_flag=$lt_prog_compiler_pic_FC
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag_FC
-        allow_undefined_flag_FC=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc_FC=no
-        else
-	  archive_cmds_need_lc_FC=yes
-        fi
-        allow_undefined_flag_FC=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $RM conftest*
-      { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc_FC" >&5
-$as_echo "$archive_cmds_need_lc_FC" >&6; }
+    *)
+      lt_prog_compiler_can_build_shared_FC=no
       ;;
     esac
   fi
-  ;;
-esac
-
 
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_FC=
+    ;;
+  *)
+    lt_prog_compiler_pic_FC="$lt_prog_compiler_pic_FC"
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_FC" >&5
+$as_echo "$lt_prog_compiler_pic_FC" >&6; }
 
 
 
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_FC"; then
+  { $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_FC works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_FC works... " >&6; }
+if test "${lt_cv_prog_compiler_pic_works_FC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works_FC=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_FC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:16142: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:16146: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_FC=yes
+     fi
+   fi
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_FC" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_FC" >&6; }
 
+if test x"$lt_cv_prog_compiler_pic_works_FC" = xyes; then
+    case $lt_prog_compiler_pic_FC in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_FC=" $lt_prog_compiler_pic_FC" ;;
+     esac
+else
+    lt_prog_compiler_pic_FC=
+     lt_prog_compiler_can_build_shared_FC=no
+fi
 
+fi
 
 
 
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_FC eval lt_tmp_static_flag=\"$lt_prog_compiler_static_FC\"
+{ $as_echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if test "${lt_cv_prog_compiler_static_works_FC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works_FC=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_FC=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_FC=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_FC" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_FC" >&6; }
 
+if test x"$lt_cv_prog_compiler_static_works_FC" = xyes; then
+    :
+else
+    lt_prog_compiler_static_FC=
+fi
 
 
 
 
+    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_FC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_FC=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:16241: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:16245: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_FC=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_FC" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
 
 
 
+    { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_FC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_FC=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:16293: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:16297: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_FC=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_FC" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
 
 
 
 
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_FC" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:$LINENO: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
 
 
 
+    { $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
+  runpath_var=
+  allow_undefined_flag_FC=
+  always_export_symbols_FC=no
+  archive_cmds_FC=
+  archive_expsym_cmds_FC=
+  compiler_needs_object_FC=no
+  enable_shared_with_static_runtimes_FC=no
+  export_dynamic_flag_spec_FC=
+  export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic_FC=no
+  hardcode_direct_FC=no
+  hardcode_direct_absolute_FC=no
+  hardcode_libdir_flag_spec_FC=
+  hardcode_libdir_flag_spec_ld_FC=
+  hardcode_libdir_separator_FC=
+  hardcode_minus_L_FC=no
+  hardcode_shlibpath_var_FC=unsupported
+  inherit_rpath_FC=no
+  link_all_deplibs_FC=unknown
+  module_cmds_FC=
+  module_expsym_cmds_FC=
+  old_archive_from_new_cmds_FC=
+  old_archive_from_expsyms_cmds_FC=
+  thread_safe_flag_spec_FC=
+  whole_archive_flag_spec_FC=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_FC=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_FC='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
 
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
 
+  ld_shlibs_FC=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
 
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec_FC='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec_FC="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec_FC=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
 
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_FC=no
+	cat <<_LT_EOF 1>&2
 
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
 
+_LT_EOF
+      fi
+      ;;
 
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_FC=''
+        ;;
+      m68k)
+            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_FC='-L$libdir'
+            hardcode_minus_L_FC=yes
+        ;;
+      esac
+      ;;
 
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_FC=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_FC='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
 
+    cygwin* | mingw* | pw32*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, FC) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      allow_undefined_flag_FC=unsupported
+      always_export_symbols_FC=no
+      enable_shared_with_static_runtimes_FC=yes
+      export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
 
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_FC='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
 
+    interix[3-9]*)
+      hardcode_direct_FC=no
+      hardcode_shlibpath_var_FC=no
+      hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec_FC='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds_FC='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
 
+    gnu* | linux* | tpf* | k*bsd*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	xl[cC]*)			# IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec_FC='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object_FC=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds_FC='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
 
+	case $cc_basename in
+	xlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec_FC='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec_FC=
+	  hardcode_libdir_flag_spec_ld_FC='-rpath $libdir'
+	  archive_cmds_FC='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        ld_shlibs_FC=no
+      fi
+      ;;
 
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_FC='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
 
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_FC=no
+	cat <<_LT_EOF 1>&2
 
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
 
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs_FC=no
+	cat <<_LT_EOF 1>&2
 
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+	    archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs_FC=no
+	  fi
+	;;
+      esac
+      ;;
 
+    sunos4*)
+      archive_cmds_FC='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
+    esac
 
+    if test "$ld_shlibs_FC" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_FC=
+      export_dynamic_flag_spec_FC=
+      whole_archive_flag_spec_FC=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_FC=unsupported
+      always_export_symbols_FC=yes
+      archive_expsym_cmds_FC='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_FC=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_FC=unsupported
+      fi
+      ;;
 
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds_FC='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds_FC='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
 
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
 
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
 
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
+      archive_cmds_FC=''
+      hardcode_direct_FC=yes
+      hardcode_direct_absolute_FC=yes
+      hardcode_libdir_separator_FC=':'
+      link_all_deplibs_FC=yes
+      file_list_spec_FC='${wl}-f,'
 
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct_FC=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L_FC=yes
+	  hardcode_libdir_flag_spec_FC='-L$libdir'
+	  hardcode_libdir_separator_FC=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
 
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_FC=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag_FC='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        cat >conftest.$ac_ext <<_ACEOF
+      program main
 
-    { $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-$as_echo_n "checking dynamic linker characteristics... " >&6; }
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
 
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
 
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
+fi
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
-aix[4-9]*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
-	:
+        hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds_FC='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
       else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_FC='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_FC="-z nodefs"
+	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 cat >conftest.$ac_ext <<_ACEOF
+      program main
 
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
-  ;;
+      end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
 
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
+lt_aix_libpath_sed='
+    /Import File Strings/,/^$/ {
+	/^0/ {
+	    s/^0  *\(.*\)$/\1/
+	    p
+	}
+    }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+  aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
 
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+fi
 
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+	 hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_FC=' ${wl}-bernotok'
+	  allow_undefined_flag_FC=' ${wl}-berok'
+	  # Exported symbols can be pulled into shared objects from archives
+	  whole_archive_flag_spec_FC='$convenience'
+	  archive_cmds_need_lc_FC=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
       fi
       ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_FC=''
+        ;;
+      m68k)
+            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_FC='-L$libdir'
+            hardcode_minus_L_FC=yes
+        ;;
+      esac
       ;;
-    esac
-    ;;
 
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
+    bsdi[45]*)
+      export_dynamic_flag_spec_FC=-rdynamic
+      ;;
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec_FC=' '
+      allow_undefined_flag_FC=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_FC='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_from_new_cmds_FC='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_FC='lib -OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path_FC='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_FC=yes
+      ;;
 
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
+    darwin* | rhapsody*)
 
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
 
-freebsd1*)
-  dynamic_linker=no
-  ;;
+  archive_cmds_need_lc_FC=no
+  hardcode_direct_FC=no
+  hardcode_automatic_FC=yes
+  hardcode_shlibpath_var_FC=unsupported
+  whole_archive_flag_spec_FC=''
+  link_all_deplibs_FC=yes
+  allow_undefined_flag_FC="$_lt_dar_allow_undefined"
+  if test "$GCC" = "yes"; then
+    output_verbose_link_cmd=echo
+    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
   else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
+  ld_shlibs_FC=no
   fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
+
       ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
+
+    dgux*)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_shlibpath_var_FC=no
       ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
 
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
+    freebsd1*)
+      ld_shlibs_FC=no
+      ;;
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-interix[3-9]*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_FC=yes
+      hardcode_minus_L_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds_FC='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds_FC='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      hardcode_direct_FC=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_FC=yes
+      export_dynamic_flag_spec_FC='${wl}-E'
+      ;;
+
+    hpux10*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	archive_cmds_FC='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+	hardcode_libdir_flag_spec_ld_FC='+b $libdir'
+	hardcode_libdir_separator_FC=:
+	hardcode_direct_FC=yes
+	hardcode_direct_absolute_FC=yes
+	export_dynamic_flag_spec_FC='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L_FC=yes
+      fi
+      ;;
+
+    hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_FC='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_FC=:
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct_FC=no
+	  hardcode_shlibpath_var_FC=no
+	  ;;
+	*)
+	  hardcode_direct_FC=yes
+	  hardcode_direct_absolute_FC=yes
+	  export_dynamic_flag_spec_FC='${wl}-E'
 
-# This must be Linux ELF.
-linux* | k*bsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # Some binutils ld are patched to set DT_RUNPATH
-  save_LDFLAGS=$LDFLAGS
-  save_libdir=$libdir
-  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_FC\"; \
-       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_FC\""
-  cat >conftest.$ac_ext <<_ACEOF
-      program main
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_FC=yes
+	  ;;
+	esac
+      fi
+      ;;
 
-      end
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+        save_LDFLAGS="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+        cat >conftest.$ac_ext <<_ACEOF
+int foo(void) {}
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
 if { (ac_try="$ac_link"
@@ -17574,9 +17125,7 @@ $as_echo "$ac_try_echo") >&5
 	 test "$cross_compiling" = yes ||
 	 $as_test_x conftest$ac_exeext
        }; then
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
-  shlibpath_overrides_runpath=yes
-fi
+  archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
 
 else
   $as_echo "$as_me: failed program was:" >&5
@@ -17585,235 +17134,338 @@ sed 's/^/| /' conftest.$ac_ext >&5
 
 fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-  LDFLAGS=$save_LDFLAGS
-  libdir=$save_libdir
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+        LDFLAGS="$save_LDFLAGS"
+      else
+	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc_FC='no'
+      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      inherit_rpath_FC=yes
+      link_all_deplibs_FC=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_FC='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
+
+    newsos6)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_FC=yes
+      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      hardcode_shlibpath_var_FC=no
+      ;;
+
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct_FC=yes
+	hardcode_shlibpath_var_FC=no
+	hardcode_direct_absolute_FC=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec_FC='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec_FC='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_minus_L_FC=yes
+      allow_undefined_flag_FC=unsupported
+      archive_cmds_FC='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds_FC='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag_FC=' -expect_unresolved \*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc_FC='no'
+      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag_FC=' -expect_unresolved \*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_FC='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_FC='-rpath $libdir'
+      fi
+      archive_cmds_need_lc_FC='no'
+      hardcode_libdir_separator_FC=:
+      ;;
+
+    solaris*)
+      no_undefined_flag_FC=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds_FC='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds_FC='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  archive_cmds_FC='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_shlibpath_var_FC=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec_FC='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec_FC='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs_FC=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds_FC='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_direct_FC=yes
+      hardcode_minus_L_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_FC=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_FC='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_FC='$CC -r -o $output$reload_objs'
+	  hardcode_direct_FC=no
+        ;;
+	motorola)
+	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_FC=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_FC=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_FC=no
+      export_dynamic_flag_spec_FC='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_FC=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_FC=yes
+      fi
+      ;;
 
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_FC='${wl}-z,text'
+      archive_cmds_need_lc_FC=no
+      hardcode_shlibpath_var_FC=no
+      runpath_var='LD_RUN_PATH'
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag_FC='${wl}-z,text'
+      allow_undefined_flag_FC='${wl}-z,nodefs'
+      archive_cmds_need_lc_FC=no
+      hardcode_shlibpath_var_FC=no
+      hardcode_libdir_flag_spec_FC='${wl}-R,$libdir'
+      hardcode_libdir_separator_FC=':'
+      link_all_deplibs_FC=yes
+      export_dynamic_flag_spec_FC='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
 
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
+    uts4*)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
-  ;;
+    *)
+      ld_shlibs_FC=no
+      ;;
+    esac
 
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec_FC='${wl}-Blargedynsym'
 	;;
       esac
-  else
-    shlibpath_overrides_runpath=yes
+    fi
   fi
-  ;;
 
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
+{ $as_echo "$as_me:$LINENO: result: $ld_shlibs_FC" >&5
+$as_echo "$ld_shlibs_FC" >&6; }
+test "$ld_shlibs_FC" = no && can_build_shared=no
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
+with_gnu_ld_FC=$with_gnu_ld
 
-rdos*)
-  dynamic_linker=no
-  ;;
 
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
 
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_FC" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_FC=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_FC in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
       ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $RM conftest*
+      echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_FC
+	pic_flag=$lt_prog_compiler_pic_FC
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_FC
+        allow_undefined_flag_FC=
+        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
+  (eval $archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+        then
+	  archive_cmds_need_lc_FC=no
+        else
+	  archive_cmds_need_lc_FC=yes
+        fi
+        allow_undefined_flag_FC=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $RM conftest*
+      { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc_FC" >&5
+$as_echo "$archive_cmds_need_lc_FC" >&6; }
       ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
     esac
   fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
   ;;
 esac
-{ $as_echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-$as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
-fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
-fi
 
 
 
@@ -17850,43 +17502,8 @@ fi
 
 
 
-    { $as_echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
-hardcode_action_FC=
-if test -n "$hardcode_libdir_flag_spec_FC" ||
-   test -n "$runpath_var_FC" ||
-   test "X$hardcode_automatic_FC" = "Xyes" ; then
 
-  # We can hardcode non-existent directories.
-  if test "$hardcode_direct_FC" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, FC)" != no &&
-     test "$hardcode_minus_L_FC" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_FC=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_FC=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_FC=unsupported
-fi
-{ $as_echo "$as_me:$LINENO: result: $hardcode_action_FC" >&5
-$as_echo "$hardcode_action_FC" >&6; }
 
-if test "$hardcode_action_FC" = relink ||
-   test "$inherit_rpath_FC" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
 
 
 
@@ -17894,17 +17511,8 @@ fi
 
 
 
-  fi # test -n "$compiler"
 
-  GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-fi # test "$_lt_disable_FC" != yes
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
@@ -17914,348 +17522,413 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
-        ac_config_commands="$ac_config_commands libtool"
 
 
 
 
-# Only expand once:
 
 
 
-{ $as_echo "$as_me:$LINENO: checking for large file support" >&5
-$as_echo "$as_me: checking for large file support" >&6;}
+    { $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-# Check whether --enable-largefile was given.
-if test "${enable_largefile+set}" = set; then
-  enableval=$enable_largefile;
-fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
 
-if test "$enable_largefile" != no; then
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
 
-  { $as_echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
-$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
-if test "${ac_cv_sys_largefile_CC+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_sys_largefile_CC=no
-     if test "$GCC" != yes; then
-       ac_save_CC=$CC
-       while :; do
-	 # IRIX 6.2 and later do not support large files by default,
-	 # so use the C compiler's -n32 option if that helps.
-	 cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
 
-  ;
-  return 0;
-}
-_ACEOF
-	 rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  break
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
 
+aix[4-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
 
-fi
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
 
-rm -f core conftest.err conftest.$ac_objext
-	 CC="$CC -n32"
-	 rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_sys_largefile_CC=' -n32'; break
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
 
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
 
-fi
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
 
-rm -f core conftest.err conftest.$ac_objext
-	 break
-       done
-       CC=$ac_save_CC
-       rm -f conftest.$ac_ext
-    fi
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
-$as_echo "$ac_cv_sys_largefile_CC" >&6; }
-  if test "$ac_cv_sys_largefile_CC" != no; then
-    CC=$CC$ac_cv_sys_largefile_CC
-  fi
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
 
-  { $as_echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
-$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
-if test "${ac_cv_sys_file_offset_bits+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_sys_file_offset_bits=no; break
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
 
-fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#define _FILE_OFFSET_BITS 64
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_sys_file_offset_bits=64; break
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+freebsd1*)
+  dynamic_linker=no
+  ;;
 
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
 
-fi
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  ac_cv_sys_file_offset_bits=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
-$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
-case $ac_cv_sys_file_offset_bits in #(
-  no | unknown) ;;
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
   *)
-cat >>confdefs.h <<_ACEOF
-#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
-_ACEOF
-;;
-esac
-rm -rf conftest*
-  if test $ac_cv_sys_file_offset_bits = unknown; then
-    { $as_echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
-$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
-if test "${ac_cv_sys_large_files+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_sys_large_files=no; break
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+interix[3-9]*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
 
-fi
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # Some binutils ld are patched to set DT_RUNPATH
+  save_LDFLAGS=$LDFLAGS
+  save_libdir=$libdir
+  eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_FC\"; \
+       LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_FC\""
   cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#define _LARGE_FILES 1
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-		       && LARGE_OFF_T % 2147483647 == 1)
-		      ? 1 : -1];
-int
-main ()
-{
+      program main
 
-  ;
-  return 0;
-}
+      end
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
+	 test -z "$ac_fc_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_sys_large_files=1; break
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
+  shlibpath_overrides_runpath=yes
+fi
+
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -18263,1463 +17936,616 @@ sed 's/^/| /' conftest.$ac_ext >&5
 
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  ac_cv_sys_large_files=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
-$as_echo "$ac_cv_sys_large_files" >&6; }
-case $ac_cv_sys_large_files in #(
-  no | unknown) ;;
-  *)
-cat >>confdefs.h <<_ACEOF
-#define _LARGE_FILES $ac_cv_sys_large_files
-_ACEOF
-;;
-esac
-rm -rf conftest*
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  LDFLAGS=$save_LDFLAGS
+  libdir=$save_libdir
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
-fi
 
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
 
-{ $as_echo "$as_me:$LINENO: displaying some results" >&5
-$as_echo "$as_me: displaying some results" >&6;}
-
-## This next macro just prints some results for debugging
-## support issues.
-
-{ $as_echo "$as_me:$LINENO: checking CPPFLAGS" >&5
-$as_echo_n "checking CPPFLAGS... " >&6; }
-{ $as_echo "$as_me:$LINENO: result: $CPPFLAGS" >&5
-$as_echo "$CPPFLAGS" >&6; }
-{ $as_echo "$as_me:$LINENO: checking CC CFLAGS" >&5
-$as_echo_n "checking CC CFLAGS... " >&6; }
-{ $as_echo "$as_me:$LINENO: result: $CC $CFLAGS" >&5
-$as_echo "$CC $CFLAGS" >&6; }
-ud_type_cc=`type $CC`
-{ $as_echo "$as_me:$LINENO: checking type $CC" >&5
-$as_echo_n "checking type $CC... " >&6; }
-{ $as_echo "$as_me:$LINENO: result: $ud_type_cc" >&5
-$as_echo "$ud_type_cc" >&6; }
-
-{ $as_echo "$as_me:$LINENO: checking CXX" >&5
-$as_echo_n "checking CXX... " >&6; }
-if test -n "$CXX"; then
-	{ $as_echo "$as_me:$LINENO: result: $CXX" >&5
-$as_echo "$CXX" >&6; }
-	{ $as_echo "$as_me:$LINENO: checking CXXFLAGS" >&5
-$as_echo_n "checking CXXFLAGS... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $CXXFLAGS" >&5
-$as_echo "$CXXFLAGS" >&6; }
-	ud_type_CXX=`type $CXX`
-	{ $as_echo "$as_me:$LINENO: checking type $CXX" >&5
-$as_echo_n "checking type $CXX... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $ud_type_CXX" >&5
-$as_echo "$ud_type_CXX" >&6; }
-else
-	{ $as_echo "$as_me:$LINENO: result: unset" >&5
-$as_echo "unset" >&6; }
-fi
-
-{ $as_echo "$as_me:$LINENO: checking FC" >&5
-$as_echo_n "checking FC... " >&6; }
-if test -n "$FC"; then
-	{ $as_echo "$as_me:$LINENO: result: $FC" >&5
-$as_echo "$FC" >&6; }
-	{ $as_echo "$as_me:$LINENO: checking FFLAGS" >&5
-$as_echo_n "checking FFLAGS... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $FFLAGS" >&5
-$as_echo "$FFLAGS" >&6; }
-	ud_type_fc=`type $FC`
-	{ $as_echo "$as_me:$LINENO: checking type $FC" >&5
-$as_echo_n "checking type $FC... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $ud_type_fc" >&5
-$as_echo "$ud_type_fc" >&6; }
-else
-	{ $as_echo "$as_me:$LINENO: result: unset" >&5
-$as_echo "unset" >&6; }
-fi
-
-{ $as_echo "$as_me:$LINENO: checking F90" >&5
-$as_echo_n "checking F90... " >&6; }
-if test -n "$F90"; then
-	{ $as_echo "$as_me:$LINENO: result: $F90" >&5
-$as_echo "$F90" >&6; }
-	{ $as_echo "$as_me:$LINENO: checking F90FLAGS" >&5
-$as_echo_n "checking F90FLAGS... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $F90FLAGS" >&5
-$as_echo "$F90FLAGS" >&6; }
-	ud_type_F90=`type $F90`
-	{ $as_echo "$as_me:$LINENO: checking type $F90" >&5
-$as_echo_n "checking type $F90... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $ud_type_F90" >&5
-$as_echo "$ud_type_F90" >&6; }
-else
-	{ $as_echo "$as_me:$LINENO: result: unset" >&5
-$as_echo "unset" >&6; }
-fi
-
-{ $as_echo "$as_me:$LINENO: checking AR" >&5
-$as_echo_n "checking AR... " >&6; }
-if test -n "$AR"; then
-	{ $as_echo "$as_me:$LINENO: result: $AR" >&5
-$as_echo "$AR" >&6; }
-	{ $as_echo "$as_me:$LINENO: checking ARFLAGS" >&5
-$as_echo_n "checking ARFLAGS... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $ARFLAGS" >&5
-$as_echo "$ARFLAGS" >&6; }
-	ud_type_AR=`type $AR`
-	{ $as_echo "$as_me:$LINENO: checking type $AR" >&5
-$as_echo_n "checking type $AR... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $ud_type_AR" >&5
-$as_echo "$ud_type_AR" >&6; }
-else
-	{ $as_echo "$as_me:$LINENO: result: unset" >&5
-$as_echo "unset" >&6; }
-fi
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
 
-{ $as_echo "$as_me:$LINENO: checking NM" >&5
-$as_echo_n "checking NM... " >&6; }
-if test -n "$NM"; then
-	{ $as_echo "$as_me:$LINENO: result: $NM" >&5
-$as_echo "$NM" >&6; }
-	{ $as_echo "$as_me:$LINENO: checking NMFLAGS" >&5
-$as_echo_n "checking NMFLAGS... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $NMFLAGS" >&5
-$as_echo "$NMFLAGS" >&6; }
-#	ud_type_NM=`type $NM`
-#	AC_MSG_CHECKING(type $NM)
-#	AC_MSG_RESULT($ud_type_NM)
-else
-	{ $as_echo "$as_me:$LINENO: result: unset" >&5
-$as_echo "unset" >&6; }
-fi
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
 
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
 
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
 
-{ $as_echo "$as_me:$LINENO: checking types, headers, and functions" >&5
-$as_echo "$as_me: checking types, headers, and functions" >&6;}
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
 
+rdos*)
+  dynamic_linker=no
+  ;;
 
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
 
-    case "${FC+set}" in
-	set)
-	    case "$FC" in
-		'')
-		    { $as_echo "$as_me:$LINENO: WARNING: Fortran-77 compiler is explicitly null" >&5
-$as_echo "$as_me: WARNING: Fortran-77 compiler is explicitly null" >&2;}
-		    ;;
-		*)
-		    { $as_echo "$as_me:$LINENO: checking user-defined Fortran-77 compiler \"$FC\"" >&5
-$as_echo_n "checking user-defined Fortran-77 compiler \"$FC\"... " >&6; }
-		    cat <<EOF >conftest.f
-                        CALL FOO
-                        END
-EOF
-		    doit='$FC -c ${FFLAGS} conftest.f'
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-			{ $as_echo "$as_me:$LINENO: result: works" >&5
-$as_echo "works" >&6; }
-		    else
-			{ $as_echo "$as_me:$LINENO: result: failed to compile test program" >&5
-$as_echo "failed to compile test program" >&6; }
-			FC=
-		    fi
-		    rm -f conftest.*
-		    ;;
-	    esac
-	    ;;
-	*)
-	    case "${F90+set}" in
-		set)
-		    FC=$F90
-		    FFLAGS="${FFLAGS-${F90FLAGS--O}}"
-		    FLIBS="${FLIBS-${F90LIBS-}}"
-		    { $as_echo "$as_me:$LINENO: checking \"$FC\" as Fortran-77 compiler" >&5
-$as_echo_n "checking \"$FC\" as Fortran-77 compiler... " >&6; }
-		    cat <<EOF >conftest.f
-                        CALL FOO
-                        END
-EOF
-		    doit='$FC -c ${FFLAGS} conftest.f'
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-			{ $as_echo "$as_me:$LINENO: result: works" >&5
-$as_echo "works" >&6; }
-		    else
-			{ $as_echo "$as_me:$LINENO: result: failed to compile test program" >&5
-$as_echo "failed to compile test program" >&6; }
-			unset FC
-		    fi
-		    rm -f conftest.*
-		    ;;
-	    esac
-	    case "${FC-unset}" in
-		unset)
-		    case `uname -sr` in
-			AIX*)
-			    # xlf90(1) thinks fortran/ftest.F has bad syntax.
-			    forts="xlf f77"
-			    ;;
-			BSD/OS*|FreeBSD*)
-			    forts="f77 fort77 g77"
-			    ;;
-			HP-UX*)
-			    # f77(1) doesn't have the -L option.
-			    forts=fort77
-			    FLIBS=-lU77
-			    ;;
-			IRIX*)
-			    # f90(1) can't link with c89(1)-compiled objects
-			    forts=f77
-			    ;;
-			IRIX64*)
-			    forts='f77 g77 fort77'
-			    ;;
-			Linux*)
-			    forts="pgf90 f77 fort77 g77"
-			    ;;
-			OSF1*)
-			    # The use of f90(1) results in the following for
-			    # an unknown reason (`make' works in the fortran/
-			    # directory):
-			    # f90 -c -I../libsrc ftest.F
-			    # Last chance handler: pc = 0xa971b8,
-			    # sp = 0x3fece0, ra = 0xa971b8
-			    # Last chance handler: internal exception: unwinding
-			    forts="f77"
-			    ;;
-			'SunOS 4'*)
-			    forts='f77 g77 fort77'
-			    ;;
-			'SunOS 5'*)
-			    # SunOS's f90(1) has problems passing a C `char'
-			    # as a Fortran `integer*1' => use f77(1)
-			    forts="pgf90 f77"
-			    ;;
-			sn*|UNICOS*|unicos*)
-			    forts="fort77 cf77 f77 g77 f90"
-			    ;;
-			*)
-			    forts="xlf fort77 ghf77 f77 cf77 g77 xlf90 f90"
-			    ;;
-		    esac
-		    for fc in $forts; do
-			# Extract the first word of "$fc", so it can be a program name with args.
-set dummy $fc; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_FC+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$FC"; then
-  ac_cv_prog_FC="$FC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_FC="$fc"
-    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
   fi
-done
-done
-IFS=$as_save_IFS
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
 
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
 fi
-FC=$ac_cv_prog_FC
-if test -n "$FC"; then
-  { $as_echo "$as_me:$LINENO: result: $FC" >&5
-$as_echo "$FC" >&6; }
-else
-  { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
 fi
 
 
-			case "${FC}" in
-			    '')
-				;;
-			    *)
-				#
-				# On some systems, a discovered compiler
-				# nevertheless won't work (due to licensing,
-				# for example); thus, we check the compiler
-				# with a test program.
-				#
-				cat <<EOF >conftest.f
-				    CALL FOO
-				    END
-EOF
-				doit='$FC -c ${FFLAGS} conftest.f'
-				if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-				    break
-				else
-				    { $as_echo "$as_me:$LINENO: result: failed to compile test program" >&5
-$as_echo "failed to compile test program" >&6; }
-				    unset FC
-				    unset ac_cv_prog_FC
-				fi
-				;;
-			esac
-		    done
-		    rm -f conftest.*
-		    case "${FC}" in
-			'') { $as_echo "$as_me:$LINENO: WARNING: \"Could not find working Fortran-77 compiler\"" >&5
-$as_echo "$as_me: WARNING: \"Could not find working Fortran-77 compiler\"" >&2;}
-			    ;;
-		    esac
-		    ;;
-	    esac
-	    ;;
-    esac
-    case "${FC}" in
-	'') { $as_echo "$as_me:$LINENO: WARNING: \"The Fortran-77 interface will not be built\"" >&5
-$as_echo "$as_me: WARNING: \"The Fortran-77 interface will not be built\"" >&2;}
-	    ;;
-    esac
 
 
 
-    #
-    # Set the make(1) macro for compiling a .F file.
-    #
-    case "${FPP-}" in
-    '')
-	{ $as_echo "$as_me:$LINENO: checking for Fortran .F compiler" >&5
-$as_echo_n "checking for Fortran .F compiler... " >&6; }
-	{ $as_echo "$as_me:$LINENO: result: $COMPILE_F" >&5
-$as_echo "$COMPILE_F" >&6; }
-	case "${COMPILE_F-unset}" in
-	unset)
-	    case "${FC}" in
-	    '')
-		COMPILE_F=
-		;;
-	    *)
-		{ $as_echo "$as_me:$LINENO: checking if Fortran-77 compiler handles *.F files" >&5
-$as_echo_n "checking if Fortran-77 compiler handles *.F files... " >&6; }
-		cat >conftest.h <<\EOF
-#define J 1
-EOF
-		cat >conftest.F <<\EOF
-#include "conftest.h"
-#define N 5
-		  real r(J,N)
-		  end
-EOF
-		doit='$FC -o conftest ${FFLAGS} conftest.F ${FLIBS}'
-		if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    COMPILE_F='$(COMPILE.f) $(FPPFLAGS)'
-		    { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		else
-		    COMPILE_F=
-		    { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		fi
-		rm -f conftest*
-		;;
-	    esac
-	    ;;
-	esac
-	;;
-    *)
-	unset COMPILE_F
-	;;
-    esac
-    case "${COMPILE_F-}" in
-	'')
-    { $as_echo "$as_me:$LINENO: checking for Fortran preprocessor" >&5
-$as_echo_n "checking for Fortran preprocessor... " >&6; }
-    case "$FPP" in
-    '')
-
-	FPP="$CPP"
-	;;
-    esac
-    { $as_echo "$as_me:$LINENO: result: $FPP" >&5
-$as_echo "$FPP" >&6; }
 
-;;
-    esac
 
-    FPPFLAGS=${FPPFLAGS-}
 
 
 
-    case "${NM-unset}" in
-	unset) for ac_prog in nm
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_NM+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$NM"; then
-  ac_cv_prog_NM="$NM" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_NM="$ac_prog"
-    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
 
-fi
-fi
-NM=$ac_cv_prog_NM
-if test -n "$NM"; then
-  { $as_echo "$as_me:$LINENO: result: $NM" >&5
-$as_echo "$NM" >&6; }
-else
-  { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-  test -n "$NM" && break
-done
-test -n "$NM" || NM="nm"
- ;;
-	*) for ac_prog in $NM nm
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_NM+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$NM"; then
-  ac_cv_prog_NM="$NM" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_NM="$ac_prog"
-    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
 
-fi
-fi
-NM=$ac_cv_prog_NM
-if test -n "$NM"; then
-  { $as_echo "$as_me:$LINENO: result: $NM" >&5
-$as_echo "$NM" >&6; }
-else
-  { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-  test -n "$NM" && break
-done
-test -n "$NM" || NM="nm"
- ;;
-    esac
-    { $as_echo "$as_me:$LINENO: checking nm flags" >&5
-$as_echo_n "checking nm flags... " >&6; }
-    case "${NMFLAGS-unset}" in
-	unset) NMFLAGS= ;;
-    esac
-    { $as_echo "$as_me:$LINENO: result: $NMFLAGS" >&5
-$as_echo "$NMFLAGS" >&6; }
 
 
 
 
-    case "$FC" in
-	'') ;;
-	*)
 
 
 
-	    { $as_echo "$as_me:$LINENO: checking for C-equivalent to Fortran routine \"SUB\"" >&5
-$as_echo_n "checking for C-equivalent to Fortran routine \"SUB\"... " >&6; }
-	    cat >conftest.f <<\EOF
-              call sub()
-              end
-EOF
-	    doit='$FC -c ${FFLAGS} conftest.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		FCALLSCSUB=`$NM $NMFLAGS conftest.o | awk '
-		    /SUB_/{print "SUB_";exit}
-		    /SUB/ {print "SUB"; exit}
-		    /sub_/{print "sub_";exit}
-		    /sub/ {print "sub"; exit}'`
-		case "$FCALLSCSUB" in
-		    '') { { $as_echo "$as_me:$LINENO: error: not found" >&5
-$as_echo "$as_me: error: not found" >&2;}
-   { (exit 1); exit 1; }; }
-			;;
-		    *)  { $as_echo "$as_me:$LINENO: result: $FCALLSCSUB" >&5
-$as_echo "$FCALLSCSUB" >&6; }
-			;;
-		esac
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftest.f" >&5
-$as_echo "$as_me: error: Could not compile conftest.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	    rm -f conftest*
-	    ;;
-    esac
 
 
 
-    case "$FC" in
-    '')
-	;;
-    *)
 
 
-    for ftype in byte integer*1 "integer(kind(1))"; do
-	{ $as_echo "$as_me:$LINENO: checking for Fortran \"$ftype\"" >&5
-$as_echo_n "checking for Fortran \"$ftype\"... " >&6; }
-	cat >conftest.f <<EOF
-      subroutine sub(value)
-      $ftype value
-      end
-EOF
-	doit='$FC -c ${FFLAGS} conftest.f'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-	    NF_INT1_T=$ftype
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT1_T $ftype
-_ACEOF
 
-	    break
-	else
-	    { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-	fi
-    done
-    rm -f conftest*
 
 
-    for ftype in integer*2 "integer(kind(2))"; do
-	{ $as_echo "$as_me:$LINENO: checking for Fortran \"$ftype\"" >&5
-$as_echo_n "checking for Fortran \"$ftype\"... " >&6; }
-	cat >conftest.f <<EOF
-      subroutine sub(value)
-      $ftype value
-      end
-EOF
-	doit='$FC -c ${FFLAGS} conftest.f'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-	    NF_INT2_T=$ftype
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT2_T $ftype
-_ACEOF
 
-	    break
-	else
-	    { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-	fi
-    done
-    rm -f conftest*
-
-
-	case "${NF_INT1_T}" in
-	    '') ;;
-	    *)
-    cat >conftestf.f <<EOF
-           $NF_INT1_T values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in "signed char"; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT1_IS_C_$cname 1
-_ACEOF
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
-
-
-    cat >conftestf.f <<EOF
-           $NF_INT1_T values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in "short"; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
+    { $as_echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_FC=
+if test -n "$hardcode_libdir_flag_spec_FC" ||
+   test -n "$runpath_var_FC" ||
+   test "X$hardcode_automatic_FC" = "Xyes" ; then
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT1_IS_C_$cname 1
-_ACEOF
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_FC" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, FC)" != no &&
+     test "$hardcode_minus_L_FC" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_FC=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_FC=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_FC=unsupported
+fi
+{ $as_echo "$as_me:$LINENO: result: $hardcode_action_FC" >&5
+$as_echo "$hardcode_action_FC" >&6; }
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
-
-
-    cat >conftestf.f <<EOF
-           $NF_INT1_T values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in "int"; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
+if test "$hardcode_action_FC" = relink ||
+   test "$inherit_rpath_FC" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT1_IS_C_$cname 1
-_ACEOF
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
-
-
-    cat >conftestf.f <<EOF
-           $NF_INT1_T values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in "long"; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"$NF_INT1_T\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT1_IS_C_$cname 1
-_ACEOF
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
 
-		;;
-	esac
-	case "${NF_INT2_T}" in
-	    '') ;;
-	    *)
-    cat >conftestf.f <<EOF
-           $NF_INT2_T values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in short; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT2_IS_C_$cname 1
-_ACEOF
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
-
-
-    cat >conftestf.f <<EOF
-           $NF_INT2_T values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in int; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT2_IS_C_$cname 1
-_ACEOF
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
-
-
-    cat >conftestf.f <<EOF
-           $NF_INT2_T values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in long; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"$NF_INT2_T\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT2_IS_C_$cname 1
-_ACEOF
+        ac_config_commands="$ac_config_commands libtool"
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
 
-		;;
-	esac
 
-    cat >conftestf.f <<EOF
-           integer values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in int long; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"integer\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"integer\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
 
-cat >>confdefs.h <<_ACEOF
-#define NF_INT_IS_C_$cname 1
-_ACEOF
+# Only expand once:
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
-
-
-    cat >conftestf.f <<EOF
-           real values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in float double; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"real\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"real\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
 
-cat >>confdefs.h <<_ACEOF
-#define NF_REAL_IS_C_$cname 1
-_ACEOF
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
-
-
-    cat >conftestf.f <<EOF
-           doubleprecision values(4)
-           data values /-1, -2, -3, -4/
-           call sub(values)
-           end
-EOF
-    for ctype in double float; do
-	{ $as_echo "$as_me:$LINENO: checking if Fortran \"doubleprecision\" is C \"$ctype\"" >&5
-$as_echo_n "checking if Fortran \"doubleprecision\" is C \"$ctype\"... " >&6; }
-	cat >conftest.c <<EOF
-	    void $FCALLSCSUB(values)
-		$ctype values[4];
-	    {
-		exit(values[1] != -2 || values[2] != -3);
-	    }
-EOF
-	doit='$CC -c ${CPPFLAGS} ${CFLAGS} conftest.c'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    doit='$FC ${FFLAGS} -c conftestf.f'
-	    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	        doit='$FC -o conftest ${FFLAGS} ${FLDFLAGS} conftestf.o conftest.o ${FLIBS} ${LIBS}'
-	        if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		    doit=./conftest
-		    if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-		        { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-		        cname=`echo $ctype | tr ' abcdefghijklmnopqrstuvwxyz' \
-			    _ABCDEFGHIJKLMNOPQRSTUVWXYZ`
+{ $as_echo "$as_me:$LINENO: checking for large file support" >&5
+$as_echo "$as_me: checking for large file support" >&6;}
 
-cat >>confdefs.h <<_ACEOF
-#define NF_DOUBLEPRECISION_IS_C_$cname 1
+# Check whether --enable-largefile was given.
+if test "${enable_largefile+set}" = set; then
+  enableval=$enable_largefile;
+fi
+
+if test "$enable_largefile" != no; then
+
+  { $as_echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
+$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
+if test "${ac_cv_sys_largefile_CC+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_sys_largefile_CC=no
+     if test "$GCC" != yes; then
+       ac_save_CC=$CC
+       while :; do
+	 # IRIX 6.2 and later do not support large files by default,
+	 # so use the C compiler's -n32 option if that helps.
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
 _ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
 
-		        break
-		    else
-		        { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-		    fi
-	        else
-		    { { $as_echo "$as_me:$LINENO: error: Could not link conftestf.o and conftest.o" >&5
-$as_echo "$as_me: error: Could not link conftestf.o and conftest.o" >&2;}
-   { (exit 1); exit 1; }; }
-	        fi
-	    else
-		{ { $as_echo "$as_me:$LINENO: error: Could not compile conftestf.f" >&5
-$as_echo "$as_me: error: Could not compile conftestf.f" >&2;}
-   { (exit 1); exit 1; }; }
-	    fi
-	else
-	    { { $as_echo "$as_me:$LINENO: error: Could not compile conftest.c" >&5
-$as_echo "$as_me: error: Could not compile conftest.c" >&2;}
-   { (exit 1); exit 1; }; }
-	fi
-    done
-    rm -f conftest*
+  ;
+  return 0;
+}
+_ACEOF
+	 rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
 
+fi
 
-    { $as_echo "$as_me:$LINENO: checking for Fortran-equivalent to netCDF \"byte\"" >&5
-$as_echo_n "checking for Fortran-equivalent to netCDF \"byte\"... " >&6; }
-    for type in byte integer*1 integer; do
-	cat >conftest.f <<EOF
-               $type foo
-               end
-EOF
-	doit='$FC -c ${FFLAGS} conftest.f'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
+rm -f core conftest.err conftest.$ac_objext
+	 CC="$CC -n32"
+	 rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    break;
-	fi
-    done
-    rm -f conftest.f conftest.o
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_sys_largefile_CC=' -n32'; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-cat >>confdefs.h <<_ACEOF
-#define NCBYTE_T $type
-_ACEOF
 
-    { $as_echo "$as_me:$LINENO: result: $type" >&5
-$as_echo "$type" >&6; }
-    NCBYTE_T=$type
+fi
 
+rm -f core conftest.err conftest.$ac_objext
+	 break
+       done
+       CC=$ac_save_CC
+       rm -f conftest.$ac_ext
+    fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
+$as_echo "$ac_cv_sys_largefile_CC" >&6; }
+  if test "$ac_cv_sys_largefile_CC" != no; then
+    CC=$CC$ac_cv_sys_largefile_CC
+  fi
 
+  { $as_echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
+if test "${ac_cv_sys_file_offset_bits+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  while :; do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
 
-    { $as_echo "$as_me:$LINENO: checking for Fortran-equivalent to netCDF \"short\"" >&5
-$as_echo_n "checking for Fortran-equivalent to netCDF \"short\"... " >&6; }
-    for type in integer*2 integer; do
-	cat >conftest.f <<EOF
-               $type foo
-               end
-EOF
-	doit='$FC -c ${FFLAGS} conftest.f'
-	if { (eval echo "$as_me:$LINENO: \"$doit\"") >&5
-  (eval $doit) 2>&5
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-	    break;
-	fi
-    done
-    rm -f conftest.f conftest.o
-
-cat >>confdefs.h <<_ACEOF
-#define NCSHORT_T $type
-_ACEOF
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_sys_file_offset_bits=no; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-    { $as_echo "$as_me:$LINENO: result: $type" >&5
-$as_echo "$type" >&6; }
-    NCSHORT_T=$type
 
+fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_sys_file_offset_bits=64; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-	;;
-    esac
 
+fi
 
-    case "${MATHLIB}" in
-	'')
-	    { $as_echo "$as_me:$LINENO: checking for tanh in -lc" >&5
-$as_echo_n "checking for tanh in -lc... " >&6; }
-if test "${ac_cv_lib_c_tanh+set}" = set; then
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  ac_cv_sys_file_offset_bits=unknown
+  break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
+$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
+case $ac_cv_sys_file_offset_bits in #(
+  no | unknown) ;;
+  *)
+cat >>confdefs.h <<_ACEOF
+#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
+_ACEOF
+;;
+esac
+rm -rf conftest*
+  if test $ac_cv_sys_file_offset_bits = unknown; then
+    { $as_echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
+$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
+if test "${ac_cv_sys_large_files+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lc  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+  while :; do
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char tanh ();
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
 int
 main ()
 {
-return tanh ();
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -19728,66 +18554,49 @@ $as_echo "$ac_try_echo") >&5
   (exit $ac_status); } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  ac_cv_lib_c_tanh=yes
+       } && test -s conftest.$ac_objext; then
+  ac_cv_sys_large_files=no; break
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_c_tanh=no
-fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_c_tanh" >&5
-$as_echo "$ac_cv_lib_c_tanh" >&6; }
-if test $ac_cv_lib_c_tanh = yes; then
-  MATHLIB=
-else
-  { $as_echo "$as_me:$LINENO: checking for tanh in -lm" >&5
-$as_echo_n "checking for tanh in -lm... " >&6; }
-if test "${ac_cv_lib_m_tanh+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char tanh ();
+#define _LARGE_FILES 1
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
 int
 main ()
 {
-return tanh ();
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -19796,38 +18605,37 @@ $as_echo "$ac_try_echo") >&5
   (exit $ac_status); } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then
-  ac_cv_lib_m_tanh=yes
+       } && test -s conftest.$ac_objext; then
+  ac_cv_sys_large_files=1; break
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_m_tanh=no
-fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_tanh" >&5
-$as_echo "$ac_cv_lib_m_tanh" >&6; }
-if test $ac_cv_lib_m_tanh = yes; then
-  MATHLIB=-lm
-else
-  MATHLIB=
 fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  ac_cv_sys_large_files=unknown
+  break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
+$as_echo "$ac_cv_sys_large_files" >&6; }
+case $ac_cv_sys_large_files in #(
+  no | unknown) ;;
+  *)
+cat >>confdefs.h <<_ACEOF
+#define _LARGE_FILES $ac_cv_sys_large_files
+_ACEOF
+;;
+esac
+rm -rf conftest*
+  fi
 fi
 
-	    ;;
-	*)
-	    ;;
-    esac
 
+{ $as_echo "$as_me:$LINENO: checking types, headers, and functions" >&5
+$as_echo "$as_me: checking types, headers, and functions" >&6;}
 
 if test "${ac_cv_header_stdlib_h+set}" = set; then
   { $as_echo "$as_me:$LINENO: checking for stdlib.h" >&5
@@ -19961,7 +18769,7 @@ fi
 $as_echo "$ac_cv_header_stdlib_h" >&6; }
 
 fi
-if test $ac_cv_header_stdlib_h = yes; then
+if test "x$ac_cv_header_stdlib_h" = x""yes; then
   :
 else
 
@@ -20104,7 +18912,7 @@ fi
 $as_echo "$ac_cv_header_sys_types_h" >&6; }
 
 fi
-if test $ac_cv_header_sys_types_h = yes; then
+if test "x$ac_cv_header_sys_types_h" = x""yes; then
   :
 else
 
@@ -20334,7 +19142,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_func_strerror" >&5
 $as_echo "$ac_cv_func_strerror" >&6; }
-if test $ac_cv_func_strerror = yes; then
+if test "x$ac_cv_func_strerror" = x""yes; then
   :
 else
 
@@ -20429,7 +19237,7 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_func_strlcat" >&5
 $as_echo "$ac_cv_func_strlcat" >&6; }
-if test $ac_cv_func_strlcat = yes; then
+if test "x$ac_cv_func_strlcat" = x""yes; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_STRLCAT 1
@@ -20437,114 +19245,6 @@ _ACEOF
 
 fi
 
-
-    { $as_echo "$as_me:$LINENO: checking for working ftruncate()" >&5
-$as_echo_n "checking for working ftruncate()... " >&6; }
-    if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-main()
-{
-    char*	path = tmpnam(NULL);
-    int		exitStatus = 1;
-
-    if (path != NULL)
-    {
-	int	fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
-
-	if (fd != -1)
-	{
-	    if (write(fd, "0", 1) == 1)
-	    {
-		off_t	pos = lseek(fd, 0, SEEK_CUR);
-
-		if (pos != (off_t)-1)
-		{
-		    if (ftruncate(fd, 512) != -1)
-		    {
-			if (pos == lseek(fd, 0, SEEK_CUR))
-			{
-			    if (lseek(fd, 0, SEEK_SET) == 0)
-			    {
-				char	buf[512];
-
-				if (read(fd, buf, 512) == 512)
-				    exitStatus = 0;
-			    }
-			}
-		    }
-		}
-	    }
-	    close(fd);
-	    unlink(path);
-	}
-    }
-
-    return exitStatus;
-}
-
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  { $as_echo "$as_me:$LINENO: result: yes" >&5
-$as_echo "yes" >&6; }
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_FTRUNCATE /**/
-_ACEOF
-
-
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 { $as_echo "$as_me:$LINENO: checking for working alloca.h" >&5
@@ -20815,39 +19515,229 @@ else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	eval "$as_ac_var=no"
+	eval "$as_ac_var=no"
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval 'as_val=${'$as_ac_var'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define CRAY_STACKSEG_END $ac_func
+_ACEOF
+
+    break
+fi
+
+  done
+fi
+
+{ $as_echo "$as_me:$LINENO: checking stack direction for C alloca" >&5
+$as_echo_n "checking stack direction for C alloca... " >&6; }
+if test "${ac_cv_c_stack_direction+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then
+  ac_cv_c_stack_direction=0
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+find_stack_direction ()
+{
+  static char *addr = 0;
+  auto char dummy;
+  if (addr == 0)
+    {
+      addr = &dummy;
+      return find_stack_direction ();
+    }
+  else
+    return (&dummy > addr) ? 1 : -1;
+}
+
+int
+main ()
+{
+  return find_stack_direction () < 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_stack_direction=1
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_c_stack_direction=-1
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5
+$as_echo "$ac_cv_c_stack_direction" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+_ACEOF
+
+
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for struct stat.st_blksize" >&5
+$as_echo_n "checking for struct stat.st_blksize... " >&6; }
+if test "${ac_cv_member_struct_stat_st_blksize+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static struct stat ac_aggr;
+if (ac_aggr.st_blksize)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_member_struct_stat_st_blksize=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static struct stat ac_aggr;
+if (sizeof ac_aggr.st_blksize)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_member_struct_stat_st_blksize=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_member_struct_stat_st_blksize=no
 fi
 
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-ac_res=`eval 'as_val=${'$as_ac_var'}
-		 $as_echo "$as_val"'`
-	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_var'}
-		 $as_echo "$as_val"'` = yes; then
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_blksize" >&5
+$as_echo "$ac_cv_member_struct_stat_st_blksize" >&6; }
+if test "x$ac_cv_member_struct_stat_st_blksize" = x""yes; then
 
 cat >>confdefs.h <<_ACEOF
-#define CRAY_STACKSEG_END $ac_func
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
 _ACEOF
 
-    break
-fi
 
-  done
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ST_BLKSIZE 1
+_ACEOF
+
 fi
 
-{ $as_echo "$as_me:$LINENO: checking stack direction for C alloca" >&5
-$as_echo_n "checking stack direction for C alloca... " >&6; }
-if test "${ac_cv_c_stack_direction+set}" = set; then
+
+{ $as_echo "$as_me:$LINENO: checking for size_t" >&5
+$as_echo_n "checking for size_t... " >&6; }
+if test "${ac_cv_type_size_t+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  if test "$cross_compiling" = yes; then
-  ac_cv_c_stack_direction=0
-else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_cv_type_size_t=no
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -20855,78 +19745,103 @@ cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
 int
-find_stack_direction ()
-{
-  static char *addr = 0;
-  auto char dummy;
-  if (addr == 0)
-    {
-      addr = &dummy;
-      return find_stack_direction ();
-    }
-  else
-    return (&dummy > addr) ? 1 : -1;
-}
-
-int
 main ()
 {
-  return find_stack_direction () < 0;
+if (sizeof (size_t))
+       return 0;
+  ;
+  return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof ((size_t)))
+	  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_try") 2>&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_c_stack_direction=1
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
 else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-$as_echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-( exit $ac_status )
-ac_cv_c_stack_direction=-1
-fi
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+	ac_cv_type_size_t=yes
 fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5
-$as_echo "$ac_cv_c_stack_direction" >&6; }
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+$as_echo "$ac_cv_type_size_t" >&6; }
+if test "x$ac_cv_type_size_t" = x""yes; then
+  :
+else
 
 cat >>confdefs.h <<_ACEOF
-#define STACK_DIRECTION $ac_cv_c_stack_direction
+#define size_t unsigned int
 _ACEOF
 
-
 fi
 
-{ $as_echo "$as_me:$LINENO: checking for struct stat.st_blksize" >&5
-$as_echo_n "checking for struct stat.st_blksize... " >&6; }
-if test "${ac_cv_member_struct_stat_st_blksize+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking for off_t" >&5
+$as_echo_n "checking for off_t... " >&6; }
+if test "${ac_cv_type_off_t+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_cv_type_off_t=no
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -20936,9 +19851,8 @@ $ac_includes_default
 int
 main ()
 {
-static struct stat ac_aggr;
-if (ac_aggr.st_blksize)
-return 0;
+if (sizeof (off_t))
+       return 0;
   ;
   return 0;
 }
@@ -20961,12 +19875,7 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_stat_st_blksize=yes
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -20976,9 +19885,8 @@ $ac_includes_default
 int
 main ()
 {
-static struct stat ac_aggr;
-if (sizeof ac_aggr.st_blksize)
-return 0;
+if (sizeof ((off_t)))
+	  return 0;
   ;
   return 0;
 }
@@ -21001,130 +19909,146 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_member_struct_stat_st_blksize=yes
+  :
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_member_struct_stat_st_blksize=no
+	ac_cv_type_off_t=yes
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_blksize" >&5
-$as_echo "$ac_cv_member_struct_stat_st_blksize" >&6; }
-if test $ac_cv_member_struct_stat_st_blksize = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
+$as_echo "$ac_cv_type_off_t" >&6; }
+if test "x$ac_cv_type_off_t" = x""yes; then
+  :
+else
 
 cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
-_ACEOF
-
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_ST_BLKSIZE 1
+#define off_t long int
 _ACEOF
 
 fi
 
-
-
-{ $as_echo "$as_me:$LINENO: checking for IEEE floating point format" >&5
-$as_echo_n "checking for IEEE floating point format... " >&6; }
-if test "$cross_compiling" = yes; then
-  :
+{ $as_echo "$as_me:$LINENO: checking for ssize_t" >&5
+$as_echo_n "checking for ssize_t... " >&6; }
+if test "${ac_cv_type_ssize_t+set}" = set; then
+  $as_echo_n "(cached) " >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_cv_type_ssize_t=no
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#ifndef NO_FLOAT_H
-#include <float.h>
-#endif
-
-#define EXIT_NOTIEEE	1
-#define EXIT_MAYBEIEEE	0
-
+$ac_includes_default
 int
-main()
+main ()
 {
-#if	defined(FLT_RADIX)	&& FLT_RADIX != 2
-		return EXIT_NOTIEEE;
-#elif	defined(DBL_MAX_EXP)	&& DBL_MAX_EXP != 1024
-		return EXIT_NOTIEEE;
-#elif	defined(DBL_MANT_DIG)	&& DBL_MANT_DIG != 53
-		return EXIT_NOTIEEE;
-#elif 	defined(FLT_MAX_EXP)	&& !(FLT_MAX_EXP == 1024 || FLT_MAX_EXP == 128)
-		return EXIT_NOTIEEE;
-#elif	defined(FLT_MANT_DIG)	&& !(FLT_MANT_DIG == 53 || FLT_MANT_DIG == 24)
-		return EXIT_NOTIEEE;
-#else
-	/* (assuming eight bit char) */
-	if(sizeof(double) != 8)
-		return EXIT_NOTIEEE;
-	if(!(sizeof(float) == 4 || sizeof(float) == 8))
-		return EXIT_NOTIEEE;
-
-	return EXIT_MAYBEIEEE;
-#endif
+if (sizeof (ssize_t))
+       return 0;
+  ;
+  return 0;
 }
 _ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof ((ssize_t)))
+	  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_try") 2>&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_c_ieeefloat=yes
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_ssize_t=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-$as_echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-( exit $ac_status )
-ac_cv_c_ieeefloat=no
-fi
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
 
+fi
 
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_ieeefloat" >&5
-$as_echo "$ac_cv_c_ieeefloat" >&6; }
-if test $ac_cv_c_ieeefloat = no; then
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5
+$as_echo "$ac_cv_type_ssize_t" >&6; }
+if test "x$ac_cv_type_ssize_t" = x""yes; then
+  :
+else
 
-cat >>confdefs.h <<\_ACEOF
-#define NO_IEEE_FLOAT /**/
+cat >>confdefs.h <<_ACEOF
+#define ssize_t int
 _ACEOF
 
 fi
 
-{ $as_echo "$as_me:$LINENO: checking for size_t" >&5
-$as_echo_n "checking for size_t... " >&6; }
-if test "${ac_cv_type_size_t+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking for ptrdiff_t" >&5
+$as_echo_n "checking for ptrdiff_t... " >&6; }
+if test "${ac_cv_type_ptrdiff_t+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  ac_cv_type_size_t=no
+  ac_cv_type_ptrdiff_t=no
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -21135,7 +20059,7 @@ $ac_includes_default
 int
 main ()
 {
-if (sizeof (size_t))
+if (sizeof (ptrdiff_t))
        return 0;
   ;
   return 0;
@@ -21169,7 +20093,7 @@ $ac_includes_default
 int
 main ()
 {
-if (sizeof ((size_t)))
+if (sizeof ((ptrdiff_t)))
 	  return 0;
   ;
   return 0;
@@ -21198,7 +20122,7 @@ else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_type_size_t=yes
+	ac_cv_type_ptrdiff_t=yes
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
@@ -21211,24 +20135,24 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
-$as_echo "$ac_cv_type_size_t" >&6; }
-if test $ac_cv_type_size_t = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_ptrdiff_t" >&5
+$as_echo "$ac_cv_type_ptrdiff_t" >&6; }
+if test "x$ac_cv_type_ptrdiff_t" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
-#define size_t unsigned int
+#define ptrdiff_t int
 _ACEOF
 
 fi
 
-{ $as_echo "$as_me:$LINENO: checking for off_t" >&5
-$as_echo_n "checking for off_t... " >&6; }
-if test "${ac_cv_type_off_t+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking for uchar" >&5
+$as_echo_n "checking for uchar... " >&6; }
+if test "${ac_cv_type_uchar+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  ac_cv_type_off_t=no
+  ac_cv_type_uchar=no
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -21239,7 +20163,7 @@ $ac_includes_default
 int
 main ()
 {
-if (sizeof (off_t))
+if (sizeof (uchar))
        return 0;
   ;
   return 0;
@@ -21273,7 +20197,7 @@ $ac_includes_default
 int
 main ()
 {
-if (sizeof ((off_t)))
+if (sizeof ((uchar)))
 	  return 0;
   ;
   return 0;
@@ -21302,7 +20226,7 @@ else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_type_off_t=yes
+	ac_cv_type_uchar=yes
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
@@ -21315,25 +20239,25 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
-$as_echo "$ac_cv_type_off_t" >&6; }
-if test $ac_cv_type_off_t = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_uchar" >&5
+$as_echo "$ac_cv_type_uchar" >&6; }
+if test "x$ac_cv_type_uchar" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
-#define off_t long int
+#define uchar unsigned char
 _ACEOF
 
 fi
 
-{ $as_echo "$as_me:$LINENO: checking for ssize_t" >&5
-$as_echo_n "checking for ssize_t... " >&6; }
-if test "${ac_cv_type_ssize_t+set}" = set; then
+
+{ $as_echo "$as_me:$LINENO: checking whether char is unsigned" >&5
+$as_echo_n "checking whether char is unsigned... " >&6; }
+if test "${ac_cv_c_char_unsigned+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-  ac_cv_type_ssize_t=no
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -21343,8 +20267,9 @@ $ac_includes_default
 int
 main ()
 {
-if (sizeof (ssize_t))
-       return 0;
+static int test_array [1 - 2 * !(((char) -1) < 0)];
+test_array [0] = 0
+
   ;
   return 0;
 }
@@ -21367,21 +20292,44 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_cv_c_char_unsigned=no
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_c_char_unsigned=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_char_unsigned" >&5
+$as_echo "$ac_cv_c_char_unsigned" >&6; }
+if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define __CHAR_UNSIGNED__ 1
+_ACEOF
+
+fi
+
+
+ { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
+$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+if test "${ac_cv_c_bigendian+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_bigendian=unknown
+    # See if we're dealing with a universal compiler.
+    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-if (sizeof ((ssize_t)))
-	  return 0;
-  ;
-  return 0;
-}
+#ifndef __APPLE_CC__
+	       not a universal capable compiler
+	     #endif
+	     typedef int dummy;
+
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -21401,15 +20349,13 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  :
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_cv_type_ssize_t=yes
-fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	# Check for potential -arch flags.  It is not universal unless
+	# there are some -arch flags.  Note that *ppc* also matches
+	# ppc64.  This check is also rather less than ideal.
+	case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in  #(
+	  *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;;
+	esac
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -21418,37 +20364,26 @@ sed 's/^/| /' conftest.$ac_ext >&5
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5
-$as_echo "$ac_cv_type_ssize_t" >&6; }
-if test $ac_cv_type_ssize_t = yes; then
-  :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define ssize_t int
-_ACEOF
-
-fi
-
-{ $as_echo "$as_me:$LINENO: checking for ptrdiff_t" >&5
-$as_echo_n "checking for ptrdiff_t... " >&6; }
-if test "${ac_cv_type_ptrdiff_t+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_type_ptrdiff_t=no
-cat >conftest.$ac_ext <<_ACEOF
+    if test $ac_cv_c_bigendian = unknown; then
+      # See if sys/param.h defines the BYTE_ORDER macro.
+      cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
+#include <sys/types.h>
+	     #include <sys/param.h>
+
 int
 main ()
 {
-if (sizeof (ptrdiff_t))
-       return 0;
+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
+		     && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
+		     && LITTLE_ENDIAN)
+	      bogus endian macros
+	     #endif
+
   ;
   return 0;
 }
@@ -21471,18 +20406,23 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  cat >conftest.$ac_ext <<_ACEOF
+  # It does; now see whether it defined to BIG_ENDIAN or not.
+	 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
+#include <sys/types.h>
+		#include <sys/param.h>
+
 int
 main ()
 {
-if (sizeof ((ptrdiff_t)))
-	  return 0;
+#if BYTE_ORDER != BIG_ENDIAN
+		 not big endian
+		#endif
+
   ;
   return 0;
 }
@@ -21505,12 +20445,12 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  :
+  ac_cv_c_bigendian=yes
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_type_ptrdiff_t=yes
+	ac_cv_c_bigendian=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
@@ -21522,37 +20462,24 @@ sed 's/^/| /' conftest.$ac_ext >&5
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_ptrdiff_t" >&5
-$as_echo "$ac_cv_type_ptrdiff_t" >&6; }
-if test $ac_cv_type_ptrdiff_t = yes; then
-  :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define ptrdiff_t int
-_ACEOF
-
-fi
-
-{ $as_echo "$as_me:$LINENO: checking for uchar" >&5
-$as_echo_n "checking for uchar... " >&6; }
-if test "${ac_cv_type_uchar+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_type_uchar=no
-cat >conftest.$ac_ext <<_ACEOF
+    fi
+    if test $ac_cv_c_bigendian = unknown; then
+      # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
+      cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
+#include <limits.h>
+
 int
 main ()
 {
-if (sizeof (uchar))
-       return 0;
+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
+	      bogus endian macros
+	     #endif
+
   ;
   return 0;
 }
@@ -21575,18 +20502,22 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  cat >conftest.$ac_ext <<_ACEOF
+  # It does; now see whether it defined to _BIG_ENDIAN or not.
+	 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
+#include <limits.h>
+
 int
 main ()
 {
-if (sizeof ((uchar)))
-	  return 0;
+#ifndef _BIG_ENDIAN
+		 not big endian
+		#endif
+
   ;
   return 0;
 }
@@ -21609,12 +20540,12 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  :
+  ac_cv_c_bigendian=yes
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_type_uchar=yes
+	ac_cv_c_bigendian=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
@@ -21626,38 +20557,37 @@ sed 's/^/| /' conftest.$ac_ext >&5
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_uchar" >&5
-$as_echo "$ac_cv_type_uchar" >&6; }
-if test $ac_cv_type_uchar = yes; then
-  :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define uchar unsigned char
-_ACEOF
-
-fi
-
-
-{ $as_echo "$as_me:$LINENO: checking whether char is unsigned" >&5
-$as_echo_n "checking whether char is unsigned... " >&6; }
-if test "${ac_cv_c_char_unsigned+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
+    fi
+    if test $ac_cv_c_bigendian = unknown; then
+      # Compile a test program.
+      if test "$cross_compiling" = yes; then
+  # Try to guess by grepping values from an object file.
+	 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
+short int ascii_mm[] =
+		  { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+		short int ascii_ii[] =
+		  { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+		int use_ascii (int i) {
+		  return ascii_mm[i] + ascii_ii[i];
+		}
+		short int ebcdic_ii[] =
+		  { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+		short int ebcdic_mm[] =
+		  { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+		int use_ebcdic (int i) {
+		  return ebcdic_mm[i] + ebcdic_ii[i];
+		}
+		extern int foo;
+
 int
 main ()
 {
-static int test_array [1 - 2 * !(((char) -1) < 0)];
-test_array [0] = 0
-
+return use_ascii (foo) == use_ebcdic (foo);
   ;
   return 0;
 }
@@ -21680,91 +20610,136 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_c_char_unsigned=no
+  if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
+	      ac_cv_c_bigendian=yes
+	    fi
+	    if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+	      if test "$ac_cv_c_bigendian" = unknown; then
+		ac_cv_c_bigendian=no
+	      else
+		# finding both strings is unlikely to happen, but who knows?
+		ac_cv_c_bigendian=unknown
+	      fi
+	    fi
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_c_char_unsigned=yes
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_char_unsigned" >&5
-$as_echo "$ac_cv_c_char_unsigned" >&6; }
-if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
-  cat >>confdefs.h <<\_ACEOF
-#define __CHAR_UNSIGNED__ 1
-_ACEOF
 
 fi
 
-
- { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
-$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
-if test "${ac_cv_c_bigendian+set}" = set; then
-  $as_echo_n "(cached) " >&6
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-  ac_cv_c_bigendian=unknown
-    # See if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined.
-       cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#if ! (defined __BIG_ENDIAN__ || defined __LITTLE_ENDIAN__)
-	       neither is defined;
-	     #endif
-	     typedef int dummy;
+$ac_includes_default
+int
+main ()
+{
 
+	     /* Are we little or big endian?  From Harbison&Steele.  */
+	     union
+	     {
+	       long int l;
+	       char c[sizeof (long int)];
+	     } u;
+	     u.l = 1;
+	     return u.c[sizeof (long int) - 1] == 1;
+
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
 $as_echo "$ac_try_echo") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  ac_cv_c_bigendian=universal
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_bigendian=no
 else
-  $as_echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+( exit $ac_status )
+ac_cv_c_bigendian=yes
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
 
+
+    fi
 fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
+$as_echo "$ac_cv_c_bigendian" >&6; }
+ case $ac_cv_c_bigendian in #(
+   yes)
+     cat >>confdefs.h <<\_ACEOF
+#define WORDS_BIGENDIAN 1
+_ACEOF
+;; #(
+   no)
+      ;; #(
+   universal)
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    if test $ac_cv_c_bigendian = unknown; then
-      # See if sys/param.h defines the BYTE_ORDER macro.
-      cat >conftest.$ac_ext <<_ACEOF
+cat >>confdefs.h <<\_ACEOF
+#define AC_APPLE_UNIVERSAL_BUILD 1
+_ACEOF
+
+     ;; #(
+   *)
+     { { $as_echo "$as_me:$LINENO: error: unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" >&5
+$as_echo "$as_me: error: unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
+   { (exit 1); exit 1; }; } ;;
+ esac
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:$LINENO: checking size of short" >&5
+$as_echo_n "checking size of short... " >&6; }
+if test "${ac_cv_sizeof_short+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <sys/types.h>
-	     #include <sys/param.h>
-
+$ac_includes_default
 int
 main ()
 {
-#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
-		     && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
-		     && LITTLE_ENDIAN)
-	      bogus endian macros
-	     #endif
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= 0)];
+test_array [0] = 0
 
   ;
   return 0;
@@ -21788,22 +20763,20 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  # It does; now see whether it defined to BIG_ENDIAN or not.
-	 cat >conftest.$ac_ext <<_ACEOF
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <sys/types.h>
-		#include <sys/param.h>
-
+$ac_includes_default
 int
 main ()
 {
-#if BYTE_ORDER != BIG_ENDIAN
-		 not big endian
-		#endif
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 0
 
   ;
   return 0;
@@ -21827,40 +20800,37 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_c_bigendian=yes
+  ac_hi=$ac_mid; break
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_c_bigendian=no
+	ac_lo=`expr $ac_mid + 1`
+			if test $ac_lo -le $ac_mid; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			ac_mid=`expr 2 '*' $ac_mid + 1`
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    fi
-    if test $ac_cv_c_bigendian = unknown; then
-      # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
-      cat >conftest.$ac_ext <<_ACEOF
+	cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <limits.h>
-
+$ac_includes_default
 int
 main ()
 {
-#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
-	      bogus endian macros
-	     #endif
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) < 0)];
+test_array [0] = 0
 
   ;
   return 0;
@@ -21884,21 +20854,20 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  # It does; now see whether it defined to _BIG_ENDIAN or not.
-	 cat >conftest.$ac_ext <<_ACEOF
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <limits.h>
-
+$ac_includes_default
 int
 main ()
 {
-#ifndef _BIG_ENDIAN
-		 not big endian
-		#endif
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= $ac_mid)];
+test_array [0] = 0
 
   ;
   return 0;
@@ -21922,54 +20891,48 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  ac_cv_c_bigendian=yes
+  ac_lo=$ac_mid; break
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_c_bigendian=no
+	ac_hi=`expr '(' $ac_mid ')' - 1`
+			if test $ac_mid -le $ac_hi; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			ac_mid=`expr 2 '*' $ac_mid`
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+	ac_lo= ac_hi=
+fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    fi
-    if test $ac_cv_c_bigendian = unknown; then
-      # Compile a test program.
-      if test "$cross_compiling" = yes; then
-  # Try to guess by grepping values from an object file.
-	 cat >conftest.$ac_ext <<_ACEOF
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-short int ascii_mm[] =
-		  { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
-		short int ascii_ii[] =
-		  { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
-		int use_ascii (int i) {
-		  return ascii_mm[i] + ascii_ii[i];
-		}
-		short int ebcdic_ii[] =
-		  { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
-		short int ebcdic_mm[] =
-		  { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
-		int use_ebcdic (int i) {
-		  return ebcdic_mm[i] + ebcdic_ii[i];
-		}
-		extern int foo;
-
+$ac_includes_default
 int
 main ()
 {
-return use_ascii (foo) == use_ebcdic (foo);
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 0
+
   ;
   return 0;
 }
@@ -21992,25 +20955,30 @@ $as_echo "$ac_try_echo") >&5
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest.$ac_objext; then
-  if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
-	      ac_cv_c_bigendian=yes
-	    fi
-	    if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
-	      if test "$ac_cv_c_bigendian" = unknown; then
-		ac_cv_c_bigendian=no
-	      else
-		# finding both strings is unlikely to happen, but who knows?
-		ac_cv_c_bigendian=unknown
-	      fi
-	    fi
+  ac_hi=$ac_mid
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+	ac_lo=`expr '(' $ac_mid ')' + 1`
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_short=$ac_lo;;
+'') if test "$ac_cv_type_short" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short)
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute sizeof (short)
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }; }
+   else
+     ac_cv_sizeof_short=0
+   fi ;;
+esac
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -22019,18 +20987,34 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
+static long int longval () { return (long int) (sizeof (short)); }
+static unsigned long int ulongval () { return (long int) (sizeof (short)); }
+#include <stdio.h>
+#include <stdlib.h>
 int
 main ()
 {
 
-	     /* Are we little or big endian?  From Harbison&Steele.  */
-	     union
-	     {
-	       long int l;
-	       char c[sizeof (long int)];
-	     } u;
-	     u.l = 1;
-	     return u.c[sizeof (long int) - 1] == 1;
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (((long int) (sizeof (short))) < 0)
+    {
+      long int i = longval ();
+      if (i != ((long int) (sizeof (short))))
+	return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ((long int) (sizeof (short))))
+	return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
 
   ;
   return 0;
@@ -22058,49 +21042,47 @@ $as_echo "$ac_try_echo") >&5
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_c_bigendian=no
+  ac_cv_sizeof_short=`cat conftest.val`
 else
   $as_echo "$as_me: program exited with status $ac_status" >&5
 $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-ac_cv_c_bigendian=yes
+if test "$ac_cv_type_short" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short)
+See \`config.log' for more details." >&5
+$as_echo "$as_me: error: cannot compute sizeof (short)
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }; }
+   else
+     ac_cv_sizeof_short=0
+   fi
 fi
 rm -rf conftest.dSYM
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
+rm -f conftest.val
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5
+$as_echo "$ac_cv_sizeof_short" >&6; }
 
 
-    fi
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
-$as_echo "$ac_cv_c_bigendian" >&6; }
- case $ac_cv_c_bigendian in #(
-   yes)
-     cat >>confdefs.h <<\_ACEOF
-#define WORDS_BIGENDIAN 1
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
 _ACEOF
-;; #(
-   no)
-      ;; #(
-   universal)
-      ;; #(
-   *)
-     { { $as_echo "$as_me:$LINENO: error: unknown endianness
- presetting ac_cv_c_bigendian=no (or yes) will help" >&5
-$as_echo "$as_me: error: unknown endianness
- presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
-   { (exit 1); exit 1; }; } ;;
- esac
+
 
 # The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
 # This bug is HP SR number 8606223364.
-{ $as_echo "$as_me:$LINENO: checking size of short" >&5
-$as_echo_n "checking size of short... " >&6; }
-if test "${ac_cv_sizeof_short+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking size of int" >&5
+$as_echo_n "checking size of int... " >&6; }
+if test "${ac_cv_sizeof_int+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then
@@ -22115,7 +21097,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= 0)];
 test_array [0] = 0
 
   ;
@@ -22152,7 +21134,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -22206,7 +21188,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (short))) < 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) < 0)];
 test_array [0] = 0
 
   ;
@@ -22243,7 +21225,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -22307,7 +21289,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -22343,15 +21325,17 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 done
 case $ac_lo in
-?*) ac_cv_sizeof_short=$ac_lo;;
-'') if test "$ac_cv_type_short" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short)
+?*) ac_cv_sizeof_int=$ac_lo;;
+'') if test "$ac_cv_type_int" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (short)
+$as_echo "$as_me: error: cannot compute sizeof (int)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_short=0
+     ac_cv_sizeof_int=0
    fi ;;
 esac
 else
@@ -22362,8 +21346,8 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-static long int longval () { return (long int) (sizeof (short)); }
-static unsigned long int ulongval () { return (long int) (sizeof (short)); }
+static long int longval () { return (long int) (sizeof (int)); }
+static unsigned long int ulongval () { return (long int) (sizeof (int)); }
 #include <stdio.h>
 #include <stdlib.h>
 int
@@ -22373,17 +21357,17 @@ main ()
   FILE *f = fopen ("conftest.val", "w");
   if (! f)
     return 1;
-  if (((long int) (sizeof (short))) < 0)
+  if (((long int) (sizeof (int))) < 0)
     {
       long int i = longval ();
-      if (i != ((long int) (sizeof (short))))
+      if (i != ((long int) (sizeof (int))))
 	return 1;
       fprintf (f, "%ld", i);
     }
   else
     {
       unsigned long int i = ulongval ();
-      if (i != ((long int) (sizeof (short))))
+      if (i != ((long int) (sizeof (int))))
 	return 1;
       fprintf (f, "%lu", i);
     }
@@ -22417,21 +21401,23 @@ $as_echo "$ac_try_echo") >&5
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_sizeof_short=`cat conftest.val`
+  ac_cv_sizeof_int=`cat conftest.val`
 else
   $as_echo "$as_me: program exited with status $ac_status" >&5
 $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-if test "$ac_cv_type_short" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (short)
+if test "$ac_cv_type_int" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (short)
+$as_echo "$as_me: error: cannot compute sizeof (int)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_short=0
+     ac_cv_sizeof_int=0
    fi
 fi
 rm -rf conftest.dSYM
@@ -22439,13 +21425,13 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$a
 fi
 rm -f conftest.val
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5
-$as_echo "$ac_cv_sizeof_short" >&6; }
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5
+$as_echo "$ac_cv_sizeof_int" >&6; }
 
 
 
 cat >>confdefs.h <<_ACEOF
-#define SIZEOF_SHORT $ac_cv_sizeof_short
+#define SIZEOF_INT $ac_cv_sizeof_int
 _ACEOF
 
 
@@ -22453,9 +21439,9 @@ _ACEOF
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
 # This bug is HP SR number 8606223364.
-{ $as_echo "$as_me:$LINENO: checking size of int" >&5
-$as_echo_n "checking size of int... " >&6; }
-if test "${ac_cv_sizeof_int+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking size of long" >&5
+$as_echo_n "checking size of long... " >&6; }
+if test "${ac_cv_sizeof_long+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then
@@ -22470,7 +21456,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= 0)];
 test_array [0] = 0
 
   ;
@@ -22507,7 +21493,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -22561,7 +21547,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (int))) < 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) < 0)];
 test_array [0] = 0
 
   ;
@@ -22598,7 +21584,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -22662,7 +21648,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -22698,15 +21684,17 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 done
 case $ac_lo in
-?*) ac_cv_sizeof_int=$ac_lo;;
-'') if test "$ac_cv_type_int" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int)
+?*) ac_cv_sizeof_long=$ac_lo;;
+'') if test "$ac_cv_type_long" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (int)
+$as_echo "$as_me: error: cannot compute sizeof (long)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_int=0
+     ac_cv_sizeof_long=0
    fi ;;
 esac
 else
@@ -22717,8 +21705,8 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-static long int longval () { return (long int) (sizeof (int)); }
-static unsigned long int ulongval () { return (long int) (sizeof (int)); }
+static long int longval () { return (long int) (sizeof (long)); }
+static unsigned long int ulongval () { return (long int) (sizeof (long)); }
 #include <stdio.h>
 #include <stdlib.h>
 int
@@ -22728,17 +21716,17 @@ main ()
   FILE *f = fopen ("conftest.val", "w");
   if (! f)
     return 1;
-  if (((long int) (sizeof (int))) < 0)
+  if (((long int) (sizeof (long))) < 0)
     {
       long int i = longval ();
-      if (i != ((long int) (sizeof (int))))
+      if (i != ((long int) (sizeof (long))))
 	return 1;
       fprintf (f, "%ld", i);
     }
   else
     {
       unsigned long int i = ulongval ();
-      if (i != ((long int) (sizeof (int))))
+      if (i != ((long int) (sizeof (long))))
 	return 1;
       fprintf (f, "%lu", i);
     }
@@ -22772,21 +21760,23 @@ $as_echo "$ac_try_echo") >&5
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_sizeof_int=`cat conftest.val`
+  ac_cv_sizeof_long=`cat conftest.val`
 else
   $as_echo "$as_me: program exited with status $ac_status" >&5
 $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-if test "$ac_cv_type_int" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (int)
+if test "$ac_cv_type_long" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (int)
+$as_echo "$as_me: error: cannot compute sizeof (long)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_int=0
+     ac_cv_sizeof_long=0
    fi
 fi
 rm -rf conftest.dSYM
@@ -22794,13 +21784,13 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$a
 fi
 rm -f conftest.val
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5
-$as_echo "$ac_cv_sizeof_int" >&6; }
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
 
 
 
 cat >>confdefs.h <<_ACEOF
-#define SIZEOF_INT $ac_cv_sizeof_int
+#define SIZEOF_LONG $ac_cv_sizeof_long
 _ACEOF
 
 
@@ -22808,9 +21798,9 @@ _ACEOF
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
 # This bug is HP SR number 8606223364.
-{ $as_echo "$as_me:$LINENO: checking size of long" >&5
-$as_echo_n "checking size of long... " >&6; }
-if test "${ac_cv_sizeof_long+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking size of float" >&5
+$as_echo_n "checking size of float... " >&6; }
+if test "${ac_cv_sizeof_float+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then
@@ -22825,7 +21815,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= 0)];
 test_array [0] = 0
 
   ;
@@ -22862,7 +21852,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -22916,7 +21906,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (long))) < 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) < 0)];
 test_array [0] = 0
 
   ;
@@ -22953,7 +21943,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23017,7 +22007,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23053,15 +22043,17 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 done
 case $ac_lo in
-?*) ac_cv_sizeof_long=$ac_lo;;
-'') if test "$ac_cv_type_long" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long)
+?*) ac_cv_sizeof_float=$ac_lo;;
+'') if test "$ac_cv_type_float" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (long)
+$as_echo "$as_me: error: cannot compute sizeof (float)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_long=0
+     ac_cv_sizeof_float=0
    fi ;;
 esac
 else
@@ -23072,8 +22064,8 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-static long int longval () { return (long int) (sizeof (long)); }
-static unsigned long int ulongval () { return (long int) (sizeof (long)); }
+static long int longval () { return (long int) (sizeof (float)); }
+static unsigned long int ulongval () { return (long int) (sizeof (float)); }
 #include <stdio.h>
 #include <stdlib.h>
 int
@@ -23083,17 +22075,17 @@ main ()
   FILE *f = fopen ("conftest.val", "w");
   if (! f)
     return 1;
-  if (((long int) (sizeof (long))) < 0)
+  if (((long int) (sizeof (float))) < 0)
     {
       long int i = longval ();
-      if (i != ((long int) (sizeof (long))))
+      if (i != ((long int) (sizeof (float))))
 	return 1;
       fprintf (f, "%ld", i);
     }
   else
     {
       unsigned long int i = ulongval ();
-      if (i != ((long int) (sizeof (long))))
+      if (i != ((long int) (sizeof (float))))
 	return 1;
       fprintf (f, "%lu", i);
     }
@@ -23127,21 +22119,23 @@ $as_echo "$ac_try_echo") >&5
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_sizeof_long=`cat conftest.val`
+  ac_cv_sizeof_float=`cat conftest.val`
 else
   $as_echo "$as_me: program exited with status $ac_status" >&5
 $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-if test "$ac_cv_type_long" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (long)
+if test "$ac_cv_type_float" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (long)
+$as_echo "$as_me: error: cannot compute sizeof (float)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_long=0
+     ac_cv_sizeof_float=0
    fi
 fi
 rm -rf conftest.dSYM
@@ -23149,13 +22143,13 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$a
 fi
 rm -f conftest.val
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5
-$as_echo "$ac_cv_sizeof_long" >&6; }
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5
+$as_echo "$ac_cv_sizeof_float" >&6; }
 
 
 
 cat >>confdefs.h <<_ACEOF
-#define SIZEOF_LONG $ac_cv_sizeof_long
+#define SIZEOF_FLOAT $ac_cv_sizeof_float
 _ACEOF
 
 
@@ -23163,9 +22157,9 @@ _ACEOF
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
 # This bug is HP SR number 8606223364.
-{ $as_echo "$as_me:$LINENO: checking size of float" >&5
-$as_echo_n "checking size of float... " >&6; }
-if test "${ac_cv_sizeof_float+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking size of double" >&5
+$as_echo_n "checking size of double... " >&6; }
+if test "${ac_cv_sizeof_double+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then
@@ -23180,7 +22174,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= 0)];
 test_array [0] = 0
 
   ;
@@ -23217,7 +22211,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23271,7 +22265,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (float))) < 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) < 0)];
 test_array [0] = 0
 
   ;
@@ -23308,7 +22302,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23372,7 +22366,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23408,15 +22402,17 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 done
 case $ac_lo in
-?*) ac_cv_sizeof_float=$ac_lo;;
-'') if test "$ac_cv_type_float" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float)
+?*) ac_cv_sizeof_double=$ac_lo;;
+'') if test "$ac_cv_type_double" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (float)
+$as_echo "$as_me: error: cannot compute sizeof (double)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_float=0
+     ac_cv_sizeof_double=0
    fi ;;
 esac
 else
@@ -23427,8 +22423,8 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-static long int longval () { return (long int) (sizeof (float)); }
-static unsigned long int ulongval () { return (long int) (sizeof (float)); }
+static long int longval () { return (long int) (sizeof (double)); }
+static unsigned long int ulongval () { return (long int) (sizeof (double)); }
 #include <stdio.h>
 #include <stdlib.h>
 int
@@ -23438,17 +22434,17 @@ main ()
   FILE *f = fopen ("conftest.val", "w");
   if (! f)
     return 1;
-  if (((long int) (sizeof (float))) < 0)
+  if (((long int) (sizeof (double))) < 0)
     {
       long int i = longval ();
-      if (i != ((long int) (sizeof (float))))
+      if (i != ((long int) (sizeof (double))))
 	return 1;
       fprintf (f, "%ld", i);
     }
   else
     {
       unsigned long int i = ulongval ();
-      if (i != ((long int) (sizeof (float))))
+      if (i != ((long int) (sizeof (double))))
 	return 1;
       fprintf (f, "%lu", i);
     }
@@ -23482,21 +22478,23 @@ $as_echo "$ac_try_echo") >&5
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_sizeof_float=`cat conftest.val`
+  ac_cv_sizeof_double=`cat conftest.val`
 else
   $as_echo "$as_me: program exited with status $ac_status" >&5
 $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-if test "$ac_cv_type_float" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (float)
+if test "$ac_cv_type_double" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (float)
+$as_echo "$as_me: error: cannot compute sizeof (double)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_float=0
+     ac_cv_sizeof_double=0
    fi
 fi
 rm -rf conftest.dSYM
@@ -23504,13 +22502,13 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$a
 fi
 rm -f conftest.val
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5
-$as_echo "$ac_cv_sizeof_float" >&6; }
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5
+$as_echo "$ac_cv_sizeof_double" >&6; }
 
 
 
 cat >>confdefs.h <<_ACEOF
-#define SIZEOF_FLOAT $ac_cv_sizeof_float
+#define SIZEOF_DOUBLE $ac_cv_sizeof_double
 _ACEOF
 
 
@@ -23518,9 +22516,9 @@ _ACEOF
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
 # This bug is HP SR number 8606223364.
-{ $as_echo "$as_me:$LINENO: checking size of double" >&5
-$as_echo_n "checking size of double... " >&6; }
-if test "${ac_cv_sizeof_double+set}" = set; then
+{ $as_echo "$as_me:$LINENO: checking size of off_t" >&5
+$as_echo_n "checking size of off_t... " >&6; }
+if test "${ac_cv_sizeof_off_t+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   if test "$cross_compiling" = yes; then
@@ -23535,7 +22533,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (off_t))) >= 0)];
 test_array [0] = 0
 
   ;
@@ -23572,7 +22570,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (off_t))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23626,7 +22624,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (double))) < 0)];
+static int test_array [1 - 2 * !(((long int) (sizeof (off_t))) < 0)];
 test_array [0] = 0
 
   ;
@@ -23663,7 +22661,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (off_t))) >= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23727,7 +22725,7 @@ $ac_includes_default
 int
 main ()
 {
-static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)];
+static int test_array [1 - 2 * !(((long int) (sizeof (off_t))) <= $ac_mid)];
 test_array [0] = 0
 
   ;
@@ -23763,15 +22761,17 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 done
 case $ac_lo in
-?*) ac_cv_sizeof_double=$ac_lo;;
-'') if test "$ac_cv_type_double" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double)
+?*) ac_cv_sizeof_off_t=$ac_lo;;
+'') if test "$ac_cv_type_off_t" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (off_t)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (double)
+$as_echo "$as_me: error: cannot compute sizeof (off_t)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_double=0
+     ac_cv_sizeof_off_t=0
    fi ;;
 esac
 else
@@ -23782,8 +22782,8 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-static long int longval () { return (long int) (sizeof (double)); }
-static unsigned long int ulongval () { return (long int) (sizeof (double)); }
+static long int longval () { return (long int) (sizeof (off_t)); }
+static unsigned long int ulongval () { return (long int) (sizeof (off_t)); }
 #include <stdio.h>
 #include <stdlib.h>
 int
@@ -23793,17 +22793,17 @@ main ()
   FILE *f = fopen ("conftest.val", "w");
   if (! f)
     return 1;
-  if (((long int) (sizeof (double))) < 0)
+  if (((long int) (sizeof (off_t))) < 0)
     {
       long int i = longval ();
-      if (i != ((long int) (sizeof (double))))
+      if (i != ((long int) (sizeof (off_t))))
 	return 1;
       fprintf (f, "%ld", i);
     }
   else
     {
       unsigned long int i = ulongval ();
-      if (i != ((long int) (sizeof (double))))
+      if (i != ((long int) (sizeof (off_t))))
 	return 1;
       fprintf (f, "%lu", i);
     }
@@ -23837,21 +22837,23 @@ $as_echo "$ac_try_echo") >&5
   ac_status=$?
   $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_sizeof_double=`cat conftest.val`
+  ac_cv_sizeof_off_t=`cat conftest.val`
 else
   $as_echo "$as_me: program exited with status $ac_status" >&5
 $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-if test "$ac_cv_type_double" = yes; then
-     { { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (double)
+if test "$ac_cv_type_off_t" = yes; then
+     { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute sizeof (off_t)
 See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot compute sizeof (double)
+$as_echo "$as_me: error: cannot compute sizeof (off_t)
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
    else
-     ac_cv_sizeof_double=0
+     ac_cv_sizeof_off_t=0
    fi
 fi
 rm -rf conftest.dSYM
@@ -23859,264 +22861,29 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$a
 fi
 rm -f conftest.val
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5
-$as_echo "$ac_cv_sizeof_double" >&6; }
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_DOUBLE $ac_cv_sizeof_double
-_ACEOF
-
-
-{ $as_echo "$as_me:$LINENO: checking size of off_t" >&5
-$as_echo_n "checking size of off_t... " >&6; }
-if test "${ac_cv_sizeof_off_t+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then
-  ac_cv_sizeof_off_t=0
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-main()
-{
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  fprintf(f, "%d\n", sizeof(off_t));
-  exit(0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_off_t=`cat conftestval`
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_sizeof_off_t=0
-fi
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5
 $as_echo "$ac_cv_sizeof_off_t" >&6; }
 
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_OFF_T $ac_cv_sizeof_off_t
-_ACEOF
-
-
-{ $as_echo "$as_me:$LINENO: checking size of size_t" >&5
-$as_echo_n "checking size of size_t... " >&6; }
-if test "${ac_cv_sizeof_size_t+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then
-  ac_cv_sizeof_size_t=0
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-main()
-{
-  FILE *f=fopen("conftestval", "w");
-  if (!f) exit(1);
-  fprintf(f, "%d\n", sizeof(size_t));
-  exit(0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_size_t=`cat conftestval`
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_sizeof_size_t=0
-fi
-rm -rf conftest.dSYM
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
 
-fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_sizeof_size_t" >&5
-$as_echo "$ac_cv_sizeof_size_t" >&6; }
 
 cat >>confdefs.h <<_ACEOF
-#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t
+#define SIZEOF_OFF_T $ac_cv_sizeof_off_t
 _ACEOF
 
 
+#AC_CHECK_SIZEOF(size_t)
 
-    #
-    # NB: We always want to define WHATIS to prevent the
-    # $(MANDIR)/$(WHATIS) make(1) target from being just $(MANDIR)/ and
-    # conflicting with the (directory creation) target with the same name.
-    #
-    WHATIS=whatis
-    case `uname -sr` in
-	BSD/OS*|FreeBSD*)
-	    # Can't generate a user-database -- only /usr/share/man/whatis.db.
-	    MAKEWHATIS_CMD=
-	    ;;
-	'IRIX64 6.5'|'IRIX 6.5')
-	    MAKEWHATIS_CMD='/usr/lib/makewhatis -M $(MANDIR) $(MANDIR)/whatis'
-	    ;;
-	'IRIX 6'*)
-	    # Can't generate a user-database.
-	    MAKEWHATIS_CMD=
-	    ;;
-	HP-UX*)
-	    # Can't generate a user-database -- only /usr/lib/whatis.
-	    MAKEWHATIS_CMD=
-	    ;;
-	'Linux '*)
-	    # /usr/sbin/makewhatis doesn't work
-	    MAKEWHATIS_CMD=
-	    ;;
-	ULTRIX*)
-	    # Can't generate a user-database -- only /usr/lib/whatis.
-	    MAKEWHATIS_CMD=
-	    ;;
-	*)
-	    if test -r /usr/man/windex; then
-		WHATIS=windex
-	    fi
-	    for ac_prog in catman makewhatis /usr/lib/makewhatis
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_prog+set}" = set; then
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$prog"; then
-  ac_cv_prog_prog="$prog" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_prog="$ac_prog"
-    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-prog=$ac_cv_prog_prog
-if test -n "$prog"; then
-  { $as_echo "$as_me:$LINENO: result: $prog" >&5
-$as_echo "$prog" >&6; }
-else
-  { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$prog" && break
-done
-
-	    case "$prog" in
-		*catman*)
-		    MAKEWHATIS_CMD=$prog' -w -M $(MANDIR)'
-		    ;;
-		*makewhatis*)
-		    MAKEWHATIS_CMD=$prog' $(MANDIR)'
-		    ;;
-	    esac
-	    ;;
-    esac
-
+{ $as_echo "$as_me:$LINENO: generating header files and makefiles" >&5
+$as_echo "$as_me: generating header files and makefiles" >&6;}
 
-    { $as_echo "$as_me:$LINENO: checking for manual-page index command" >&5
-$as_echo_n "checking for manual-page index command... " >&6; }
-    { $as_echo "$as_me:$LINENO: result: $MAKEWHATIS_CMD" >&5
-$as_echo "$MAKEWHATIS_CMD" >&6; }
+ac_config_files="$ac_config_files gridspec/tools/make_hgrid/run_tests"
 
+ac_config_files="$ac_config_files gridspec/tools/make_vgrid/run_tests"
 
-# For nightly build testing, output CC, FC, etc.
-if test x$enable_compiler_recover = xno; then
-   echo "CC=$CC CXX=$CXX FC=$FC F77=$F77" >> comps.txt
-fi
+ac_config_files="$ac_config_files gridspec/tools/make_topog/run_tests"
 
-{ $as_echo "$as_me:$LINENO: generating header files and makefiles" >&5
-$as_echo "$as_me: generating header files and makefiles" >&6;}
 
-ac_config_files="$ac_config_files Makefile doc/Makefile cfcheck/Makefile src/Makefile gridspec_tools_20080702/Makefile gridspec_tools_20080702/shared/Makefile gridspec_tools_20080702/shared/mosaic/Makefile gridspec_tools_20080702/tools/Makefile gridspec_tools_20080702/tools/shared/Makefile gridspec_tools_20080702/tools/make_hgrid/Makefile gridspec_tools_20080702/tools/make_solo_mosaic/Makefile gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile gridspec_tools_20080702/tools/fregri [...]
+ac_config_files="$ac_config_files Makefile doc/Makefile cfcheck/Makefile src/Makefile gridspec/Makefile gridspec/shared/Makefile gridspec/shared/mosaic/Makefile gridspec/tools/Makefile gridspec/tools/shared/Makefile gridspec/tools/make_hgrid/Makefile gridspec/tools/make_mosaic/Makefile gridspec/tools/make_coupler_mosaic/Makefile gridspec/tools/fregrid/Makefile gridspec/tools/make_topog/Makefile gridspec/tools/make_vgrid/Makefile"
 
 
 cat >confcache <<\_ACEOF
@@ -24146,8 +22913,8 @@ _ACEOF
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
@@ -24216,6 +22983,14 @@ LIBOBJS=$ac_libobjs
 LTLIBOBJS=$ac_ltlibobjs
 
 
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
 if test -z "${BUILD_DOCS_TRUE}" && test -z "${BUILD_DOCS_FALSE}"; then
   { { $as_echo "$as_me:$LINENO: error: conditional \"BUILD_DOCS\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -24230,6 +23005,13 @@ $as_echo "$as_me: error: conditional \"BUILD_GRIDSPEC\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${BUILD_GRIDSPEC_FILE_TESTS_TRUE}" && test -z "${BUILD_GRIDSPEC_FILE_TESTS_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"BUILD_GRIDSPEC_FILE_TESTS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"BUILD_GRIDSPEC_FILE_TESTS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${BUILD_CFCHECK_TRUE}" && test -z "${BUILD_CFCHECK_FALSE}"; then
   { { $as_echo "$as_me:$LINENO: error: conditional \"BUILD_CFCHECK\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -24258,6 +23040,34 @@ $as_echo "$as_me: error: conditional \"USE_HDF5_DIR\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${USE_HDF4_DIR_TRUE}" && test -z "${USE_HDF4_DIR_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"USE_HDF4_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"USE_HDF4_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${USE_HDF4_TRUE}" && test -z "${USE_HDF4_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"USE_HDF4\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"USE_HDF4\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${USE_ZLIB_DIR_TRUE}" && test -z "${USE_ZLIB_DIR_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"USE_ZLIB_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"USE_ZLIB_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${USE_SZLIB_DIR_TRUE}" && test -z "${USE_SZLIB_DIR_FALSE}"; then
+  { { $as_echo "$as_me:$LINENO: error: conditional \"USE_SZLIB_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"USE_SZLIB_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${BUILD_F90_TRUE}" && test -z "${BUILD_F90_FALSE}"; then
   { { $as_echo "$as_me:$LINENO: error: conditional \"BUILD_F90\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -24287,6 +23097,7 @@ Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
 
+
 : ${CONFIG_STATUS=./config.status}
 ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
@@ -24608,8 +23419,8 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libcf $as_me 1.0-alpha4, which was
-generated by GNU Autoconf 2.62.  Invocation command line was
+This file was extended by libcf $as_me 1.0-alpha5, which was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -24622,6 +23433,15 @@ on `(hostname || uname -n) 2>/dev/null | sed 1q`
 
 _ACEOF
 
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
 config_files="$ac_config_files"
@@ -24635,16 +23455,17 @@ ac_cs_usage="\
 \`$as_me' instantiates files from templates according to the
 current configuration.
 
-Usage: $0 [OPTIONS] [FILE]...
+Usage: $0 [OPTION]... [FILE]...
 
   -h, --help       print this help, then exit
   -V, --version    print version number and configuration settings, then exit
-  -q, --quiet      do not print progress messages
+  -q, --quiet, --silent
+                   do not print progress messages
   -d, --debug      don't remove temporary files
       --recheck    update $as_me by reconfiguring in the same conditions
-  --file=FILE[:TEMPLATE]
+      --file=FILE[:TEMPLATE]
                    instantiate the configuration file FILE
-  --header=FILE[:TEMPLATE]
+      --header=FILE[:TEMPLATE]
                    instantiate the configuration header FILE
 
 Configuration files:
@@ -24661,8 +23482,8 @@ Report bugs to <bug-autoconf at gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-libcf config.status 1.0-alpha4
-configured by $0, generated by GNU Autoconf 2.62,
+libcf config.status 1.0-alpha5
+configured by $0, generated by GNU Autoconf 2.63,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
 Copyright (C) 2008 Free Software Foundation, Inc.
@@ -25224,23 +24045,24 @@ do
     "nfconfig.inc") CONFIG_HEADERS="$CONFIG_HEADERS nfconfig.inc:nfconfig.in" ;;
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+    "gridspec/tools/make_hgrid/run_tests") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_hgrid/run_tests" ;;
+    "gridspec/tools/make_vgrid/run_tests") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_vgrid/run_tests" ;;
+    "gridspec/tools/make_topog/run_tests") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_topog/run_tests" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
     "cfcheck/Makefile") CONFIG_FILES="$CONFIG_FILES cfcheck/Makefile" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
-    "gridspec_tools_20080702/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/Makefile" ;;
-    "gridspec_tools_20080702/shared/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/shared/Makefile" ;;
-    "gridspec_tools_20080702/shared/mosaic/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/shared/mosaic/Makefile" ;;
-    "gridspec_tools_20080702/tools/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/Makefile" ;;
-    "gridspec_tools_20080702/tools/shared/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/shared/Makefile" ;;
-    "gridspec_tools_20080702/tools/make_hgrid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/make_hgrid/Makefile" ;;
-    "gridspec_tools_20080702/tools/make_solo_mosaic/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/make_solo_mosaic/Makefile" ;;
-    "gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile" ;;
-    "gridspec_tools_20080702/tools/fregrid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/fregrid/Makefile" ;;
-    "gridspec_tools_20080702/tools/make_topog/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/make_topog/Makefile" ;;
-    "gridspec_tools_20080702/tools/make_vgrid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/make_vgrid/Makefile" ;;
-    "gridspec_tools_20080702/tools/river_regrid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/river_regrid/Makefile" ;;
-    "gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile" ;;
+    "gridspec/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/Makefile" ;;
+    "gridspec/shared/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/shared/Makefile" ;;
+    "gridspec/shared/mosaic/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/shared/mosaic/Makefile" ;;
+    "gridspec/tools/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/Makefile" ;;
+    "gridspec/tools/shared/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/shared/Makefile" ;;
+    "gridspec/tools/make_hgrid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_hgrid/Makefile" ;;
+    "gridspec/tools/make_mosaic/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_mosaic/Makefile" ;;
+    "gridspec/tools/make_coupler_mosaic/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_coupler_mosaic/Makefile" ;;
+    "gridspec/tools/fregrid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/fregrid/Makefile" ;;
+    "gridspec/tools/make_topog/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_topog/Makefile" ;;
+    "gridspec/tools/make_vgrid/Makefile") CONFIG_FILES="$CONFIG_FILES gridspec/tools/make_vgrid/Makefile" ;;
 
   *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
 $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -25322,7 +24144,8 @@ for ac_last_try in false false false false false :; do
 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
    { (exit 1); exit 1; }; }
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` = $ac_delim_num; then
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
     break
   elif $ac_last_try; then
     { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -25527,9 +24350,9 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
   }
   split(mac1, mac2, "(") #)
   macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
   if (D_is_set[macro]) {
     # Preserve the white space surrounding the "#".
-    prefix = substr(line, 1, index(line, defundef) - 1)
     print prefix "define", macro P[macro] D[macro]
     next
   } else {
@@ -25537,7 +24360,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
     # in the case of _POSIX_SOURCE, which is predefined and required
     # on some systems where configure will not decide to define it.
     if (defundef == "undef") {
-      print "/*", line, "*/"
+      print "/*", prefix defundef, macro, "*/"
       next
     }
   }
@@ -25561,8 +24384,8 @@ do
   esac
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
-$as_echo "$as_me: error: Invalid tag $ac_tag." >&2;}
+  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
+$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
    { (exit 1); exit 1; }; };;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
@@ -25895,18 +24718,28 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "nfconfig.inc":H) sed '1d;s%^/\* \(.*\) \*/%\1%' nfconfig.inc >conftest.tmp && mv conftest.tmp nfconfig.inc ;;
-    "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
-  # Strip MF so we end up with the name of the file.
-  mf=`echo "$mf" | sed -e 's/:.*$//'`
-  # Check whether this is an Automake generated Makefile or not.
-  # We used to match only the files named `Makefile.in', but
-  # some people rename them; so instead we look at the file content.
-  # Grep'ing the first line is not enough: some people post-process
-  # each Makefile.in and add a new line on top of each file to say so.
-  # Grep'ing the whole file is not good either: AIX grep has a line
-  # limit of 2048, but all sed's we know have understand at least 4000.
-  if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-    dirpart=`$as_dirname -- "$mf" ||
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
 $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$mf" : 'X\(//\)[^/]' \| \
 	 X"$mf" : 'X\(//\)$' \| \
@@ -25929,28 +24762,28 @@ $as_echo X"$mf" |
 	    q
 	  }
 	  s/.*/./; q'`
-  else
-    continue
-  fi
-  # Extract the definition of DEPDIR, am__include, and am__quote
-  # from the Makefile without running `make'.
-  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-  test -z "$DEPDIR" && continue
-  am__include=`sed -n 's/^am__include = //p' < "$mf"`
-  test -z "am__include" && continue
-  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-  # When using ansi2knr, U may be empty or an underscore; expand it
-  U=`sed -n 's/^U = //p' < "$mf"`
-  # Find all dependency output files, they are included files with
-  # $(DEPDIR) in their names.  We invoke sed twice because it is the
-  # simplest approach to changing $(DEPDIR) to its actual value in the
-  # expansion.
-  for file in `sed -n "
-    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
-    # Make sure the directory exists.
-    test -f "$dirpart/$file" && continue
-    fdir=`$as_dirname -- "$file" ||
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
 $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$file" : 'X\(//\)[^/]' \| \
 	 X"$file" : 'X\(//\)$' \| \
@@ -25973,7 +24806,7 @@ $as_echo X"$file" |
 	    q
 	  }
 	  s/.*/./; q'`
-    { as_dir=$dirpart/$fdir
+      { as_dir=$dirpart/$fdir
   case $as_dir in #(
   -*) as_dir=./$as_dir;;
   esac
@@ -26014,10 +24847,11 @@ $as_echo X"$as_dir" |
   } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
 $as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
    { (exit 1); exit 1; }; }; }
-    # echo "creating $dirpart/$file"
-    echo '# dummy' > "$dirpart/$file"
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
   done
-done
+}
  ;;
     "libtool":C)
 
@@ -26980,6 +25814,9 @@ compiler_lib_search_path=$lt_compiler_lib_search_path_FC
 _LT_EOF
 
  ;;
+    "gridspec/tools/make_hgrid/run_tests":F) chmod +x gridspec/tools/make_hgrid/run_tests ;;
+    "gridspec/tools/make_vgrid/run_tests":F) chmod +x gridspec/tools/make_vgrid/run_tests ;;
+    "gridspec/tools/make_topog/run_tests":F) chmod +x gridspec/tools/make_topog/run_tests ;;
 
   esac
 done # for ac_tag
@@ -27017,8 +25854,8 @@ if test "$no_create" != yes; then
   $ac_cs_success || { (exit 1); exit 1; }
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:$LINENO: WARNING: Unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2;}
+  { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
 
diff --git a/configure.ac b/configure.ac
index 39c28ac..0695878 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,20 +5,14 @@
 # 2006, see the COPYRIGHT file for more information.
 
 ## This puts the cvs ID tag in the output configure script.
-AC_REVISION([$Id: configure.ac,v 1.22 2009/04/12 14:18:13 ed Exp $])
+AC_REVISION([$Id: configure.ac,v 1.6 2009/11/16 15:42:12 zhi Exp $])
 
 ## Running autoconf on this file will trigger a warning if 
 ## autoconf is not at least the specified version.
 AC_PREREQ([2.59])
 
-## Tell autoconf to look for auxiliary build tools in this directory.
-#AC_CONFIG_AUX_DIR([config])
-
-## Tell autoconf where to find aclocal.
-#AC_CONFIG_MACRO_DIR([config])
-
 ## Initialize with name, version, and support email address. 
-AC_INIT([libcf], [1.0-alpha4], [support at unidata.ucar.edu])
+AC_INIT([libcf], [1.0-alpha5], [support at unidata.ucar.edu])
 AC_CONFIG_MACRO_DIR([m4])
 
 AC_MSG_NOTICE([libcf AC_PACKAGE_VERSION])
@@ -33,7 +27,7 @@ AC_CONFIG_HEADERS([nfconfig.inc:nfconfig.in],
    [sed '1d;s%^/\* \(.*\) \*/%\1%' nfconfig.inc >conftest.tmp && mv conftest.tmp nfconfig.inc])
 
 # This call is required by automake.
-AM_INIT_AUTOMAKE([foreign no-installinfo dist-bzip2 dist-zip dist-tarZ subdir-objects -Wall])
+AM_INIT_AUTOMAKE([foreign no-installinfo subdir-objects -Wall])
 
 # Check for the existance of this file before proceeding.
 AC_CONFIG_SRCDIR([src/nccoord.c])
@@ -75,12 +69,21 @@ test "x$enable_gridspec" = xyes || enable_gridspec=no
 AC_MSG_RESULT($enable_gridspec)
 AM_CONDITIONAL(BUILD_GRIDSPEC, [test x$enable_gridspec = xyes])
 
+# Does the user want to fetch test data and run extra gridspec tests?
+AC_MSG_CHECKING([whether gridspec test data should be fetched from Unidata FTP site])
+AC_ARG_ENABLE([gridspec-file-tests],
+              [AS_HELP_STRING([--enable-gridspec-file-tests],
+                              [get GRIDSPEC test data from Unidata FTP server and run extra tests])])
+test "x$enable_gridspec_file_tests" = xyes || enable_gridspec_file_tests=no
+AC_MSG_RESULT($enable_gridspec_file_tests)
+AM_CONDITIONAL(BUILD_GRIDSPEC_FILE_TESTS, [test x$enable_gridspec_file_tests = xyes])
+
 # Does the user want to build cfcheck?
 AC_MSG_CHECKING([whether cfcheck is to be built])
 AC_ARG_ENABLE([cfcheck],
-              [AS_HELP_STRING([--disable-cfcheck],
-                              [don't build the cfcheck application])])
-test "x$enable_cfcheck" = xno || enable_cfcheck=yes
+              [AS_HELP_STRING([--enable-cfcheck],
+                              [still in development - not working yet])])
+test "x$enable_cfcheck" = xyes || enable_cfcheck=no
 AC_MSG_RESULT($enable_cfcheck)
 AM_CONDITIONAL(BUILD_CFCHECK, [test x$enable_cfcheck = xyes])
 
@@ -101,14 +104,24 @@ AC_MSG_CHECKING([whether netCDF-4 is to be used])
 AC_ARG_ENABLE([netcdf-4],
               [AS_HELP_STRING([--enable-netcdf-4],
                               [build with netcdf-4 (HDF5 is required)])])
-test "x$enable_netcdf_4" = xyes || enable_netcdf_4=no
+
+# If hdf5 dir is set, turn on enable-netcdf-4.
+if test "x$with_hdf5" != x; then
+   enable_netcdf_4=yes
+else
+   test "x$enable_netcdf_4" = xyes || enable_netcdf_4=no
+fi
 AC_MSG_RESULT($enable_netcdf_4)
 AM_CONDITIONAL(USE_NETCDF4, [test x$enable_netcdf_4 = xyes])
 if test "x$enable_netcdf_4" = xyes; then
    AC_DEFINE([USE_NETCDF4], 1, [if true, use netCDF-4])
 fi
 
-# Does the user want to use netcdf-4?
+# Does the user want to turn on HDF4 read ability?
+AC_ARG_ENABLE([hdf4], [AS_HELP_STRING([--enable-hdf4],
+              [build netcdf-4 with HDF4 read capability (HDF4, HDF5 and zlib required)])])
+
+# Does the user want extra tests on CF sample files?
 AC_MSG_CHECKING([whether extra tests on sample data should be performed])
 AC_ARG_ENABLE([extra-data-tests],
               [AS_HELP_STRING([--enable-extra-data-tests],
@@ -126,10 +139,50 @@ AC_ARG_WITH([hdf5],
                               [Specify location of HDF5 library. Configure will expect \
 			      to find subdirs include and lib.])],
             [HDF5DIR=$with_hdf5])
-HDF5DIR=${HDF5DIR-.}
 AC_MSG_RESULT([$HDF5DIR])
 AM_CONDITIONAL(USE_HDF5_DIR, [test ! "x$HDF5DIR" = x])
 AC_SUBST(HDF5DIR, [$HDF5DIR])
+if test ! "x$HDF5DIR" = x; then
+   LDFLAGS="${LDFLAGS} -L$HDF5DIR/lib"
+fi
+
+# Did the user specify a location for the HDF4 library?
+AC_MSG_CHECKING([whether a location for the HDF4 library was specified])
+AC_ARG_WITH([hdf4],
+              [AS_HELP_STRING([--with-hdf4=<directory>],
+                              [Specify location of HDF4 library. Configure will \
+			      expect to find subdirs include and lib.])],
+            [HDF4DIR=$with_hdf4])
+AC_MSG_RESULT([$HDF4DIR])
+AM_CONDITIONAL(USE_HDF4_DIR, [test ! "x$HDF4DIR" = x])
+AC_SUBST(HDF4DIR, [$HDF4DIR])
+AM_CONDITIONAL(USE_HDF4, [test x$enable_hdf4 = xyes])
+
+# Did the user specify a location for the ZLIB library?
+AC_MSG_CHECKING([whether a location for the ZLIB library was specified])
+AC_ARG_WITH([zlib],
+              [AS_HELP_STRING([--with-zlib=<directory>],
+                              [Specify location of ZLIB library. ZLIB is required \
+			      for netCDF-4. Configure will expect to find subdirs \
+			      include and lib.])],
+            [ZLIBDIR=$with_zlib])
+AC_MSG_RESULT([$ZLIBDIR])
+AC_SUBST(ZLIBDIR, [$ZLIBDIR])
+
+# Did the user specify a location for the SZLIB library?
+AC_MSG_CHECKING([whether a location for the SZLIB library was specified])
+AC_ARG_WITH([szlib],
+              [AS_HELP_STRING([--with-szlib=<directory>],
+                              [Specify location of SZLIB library. SZLIB is not \
+			      required for netCDF-4, but you must specify its location \
+			      if HDF5 was built with SZLIB. Configure will expect to \
+			      find subdirs include and lib.])],
+            [SZLIBDIR=$with_szlib])
+AC_MSG_RESULT([$SZLIBDIR])
+AC_SUBST(SZLIBDIR, [$SZLIBDIR])
+
+AM_CONDITIONAL(USE_ZLIB_DIR, [test ! "x$ZLIBDIR" = x])
+AM_CONDITIONAL(USE_SZLIB_DIR, [test ! "x$SZLIBDIR" = x])
 
 # Do we want to build the fortran API? Check for --disable-f90
 nc_build_f90=yes
@@ -146,12 +199,17 @@ AM_CONDITIONAL(BUILD_F90, [test "x$nc_build_f90" = xyes])
 AC_MSG_CHECKING([whether a location for the netCDF library was specified])
 AC_ARG_WITH([netcdf],
               [AS_HELP_STRING([--with-netcdf=<directory>],
-                              [Specify location of netCDF library. Configure will expect to find subdirs include and lib.])],
-            [NETCDFDIR=$with_netcdf])
-NETCDFDIR=${NETCDFDIR}
-AC_MSG_RESULT([$NETCDFDIR])
-AM_CONDITIONAL(USE_NETCDF_DIR, [test ! "x$NETCDFDIR" = x])
-AC_SUBST(NETCDFDIR, [$NETCDFDIR])
+                              [Specify location of netCDF library. Configure will expect to find \
+			      subdirs include and lib.])], [], [with_netcdf=no])
+AC_MSG_RESULT([$with_netcdf])
+AM_CONDITIONAL([USE_NETCDF_DIR], [test ! x$with_netcdf = xno])
+if test ! x$with_netcdf = xno; then
+   AC_SUBST(NETCDFDIR, [$with_netcdf])
+   AC_SUBST(NCDUMPDIR, [$with_netcdf/bin])
+   LDFLAGS="${LDFLAGS} -L$NETCDFDIR/lib"
+else
+   AC_SUBST(NCDUMPDIR, [../../../../ncdump])
+fi
 
 # According to the autoconf mailing list gurus, we must test for
 # compilers unconditionally. That is, we can't skip looking for the
@@ -176,6 +234,18 @@ if test "${F77+set}" = set && test "x$F77" = x && test "x$nc_build_fortran" = xy
 fi
 AC_PROG_FC([mpxlf_r xlf90 fort xlf95 ifort ifc efc pgf95 lf95 g95 gfortran f95 frt pgf77 f77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 g77])
 
+if test "x$nc_build_f90" = xyes; then
+   AC_MSG_NOTICE([configuring fortran])
+   # Some f90 compilers change the case of the mod file names. Others
+   # require special flags to be set to deal with .f90 files. Find out
+   # about this compiler.
+   AC_LANG_PUSH(Fortran)
+   AC_FC_SRCEXT(f90)
+   AC_LANG_POP(Fortran)
+   AX_F90_MODULE_FLAG
+   AC_SUBST(MOD_FLAG, ${ax_cv_f90_modflag})
+fi
+
 AC_MSG_NOTICE([finding other utilities])
 
 AC_PROG_INSTALL
@@ -192,25 +262,15 @@ AC_MSG_NOTICE([checking for large file support])
 
 AC_SYS_LARGEFILE
 
-AC_MSG_NOTICE([displaying some results])
-
-## This next macro just prints some results for debugging
-## support issues.
-UD_DISPLAY_RESULTS
-
 AC_MSG_NOTICE([checking types, headers, and functions])
 
-UD_FORTRAN_TYPES
-UD_CHECK_LIB_MATH
 AC_CHECK_HEADER(stdlib.h, ,AC_DEFINE([NO_STDLIB_H], [], [no stdlib.h]))
 AC_CHECK_HEADER(sys/types.h, ,AC_DEFINE([NO_SYS_TYPES_H], [], [no sys_types.h]))
 AC_CHECK_HEADER([unistd.h])
 AC_CHECK_FUNC(strerror, ,AC_DEFINE([NO_STRERROR], [], [no strerror.h]))
 AC_CHECK_FUNC(strlcat,AC_DEFINE([HAVE_STRLCAT],1,[Define this if you have strlcat()]))
-UD_CHECK_FTRUNCATE
 AC_FUNC_ALLOCA
 AC_STRUCT_ST_BLKSIZE
-UD_CHECK_IEEE
 AC_TYPE_SIZE_T
 AC_TYPE_OFF_T
 AC_CHECK_TYPE(ssize_t, int)
@@ -223,34 +283,33 @@ AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(float)
 AC_CHECK_SIZEOF(double)
-UD_CHECK_SIZEOF(off_t)
-UD_CHECK_SIZEOF(size_t)
-UD_MAKEWHATIS
-
-# For nightly build testing, output CC, FC, etc.
-if test x$enable_compiler_recover = xno; then
-   echo "CC=$CC CXX=$CXX FC=$FC F77=$F77" >> comps.txt
-fi
+AC_CHECK_SIZEOF(off_t)
+#AC_CHECK_SIZEOF(size_t)
 
 AC_MSG_NOTICE([generating header files and makefiles])
 
+AC_CONFIG_FILES([gridspec/tools/make_hgrid/run_tests], 
+	           [chmod +x gridspec/tools/make_hgrid/run_tests])
+AC_CONFIG_FILES([gridspec/tools/make_vgrid/run_tests], 
+	           [chmod +x gridspec/tools/make_vgrid/run_tests])
+AC_CONFIG_FILES([gridspec/tools/make_topog/run_tests], 
+	           [chmod +x gridspec/tools/make_topog/run_tests])
+
 AC_CONFIG_FILES([Makefile
                  doc/Makefile
                  cfcheck/Makefile
                  src/Makefile
-		 gridspec_tools_20080702/Makefile
-		 gridspec_tools_20080702/shared/Makefile
-		 gridspec_tools_20080702/shared/mosaic/Makefile
-		 gridspec_tools_20080702/tools/Makefile
-		 gridspec_tools_20080702/tools/shared/Makefile
-		 gridspec_tools_20080702/tools/make_hgrid/Makefile
-		 gridspec_tools_20080702/tools/make_solo_mosaic/Makefile
-		 gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile
-		 gridspec_tools_20080702/tools/fregrid/Makefile
-		 gridspec_tools_20080702/tools/make_topog/Makefile
-		 gridspec_tools_20080702/tools/make_vgrid/Makefile
-		 gridspec_tools_20080702/tools/river_regrid/Makefile
-		 gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile])
+		 gridspec/Makefile
+		 gridspec/shared/Makefile
+		 gridspec/shared/mosaic/Makefile
+		 gridspec/tools/Makefile
+		 gridspec/tools/shared/Makefile
+		 gridspec/tools/make_hgrid/Makefile
+		 gridspec/tools/make_mosaic/Makefile
+		 gridspec/tools/make_coupler_mosaic/Makefile
+		 gridspec/tools/fregrid/Makefile
+		 gridspec/tools/make_topog/Makefile
+		 gridspec/tools/make_vgrid/Makefile])
 
 AC_OUTPUT()
 
diff --git a/depcomp b/depcomp
index e5f9736..df8eea7 100755
--- a/depcomp
+++ b/depcomp
@@ -1,10 +1,10 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2007-03-29.01
+scriptversion=2009-04-28.21; # UTC
 
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
-# Foundation, Inc.
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
+# Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@ scriptversion=2007-03-29.01
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -87,6 +85,15 @@ if test "$depmode" = dashXmstdout; then
    depmode=dashmstdout
 fi
 
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+   # This is just like msvisualcpp but w/o cygpath translation.
+   # Just convert the backslash-escaped backslashes to single forward
+   # slashes to satisfy depend.m4
+   cygpath_u="sed s,\\\\\\\\,/,g"
+   depmode=msvisualcpp
+fi
+
 case "$depmode" in
 gcc3)
 ## gcc 3 implements dependency tracking that does exactly what
@@ -192,14 +199,14 @@ sgi)
 ' < "$tmpdepfile" \
     | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
     tr '
-' ' ' >> $depfile
-    echo >> $depfile
+' ' ' >> "$depfile"
+    echo >> "$depfile"
 
     # The second pass generates a dummy entry for each header file.
     tr ' ' '
 ' < "$tmpdepfile" \
    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
-   >> $depfile
+   >> "$depfile"
   else
     # The sourcefile does not contain any dependencies, so just
     # store a dummy comment line, to avoid errors with the Makefile
@@ -328,7 +335,12 @@ hp2)
   if test -f "$tmpdepfile"; then
     sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
     # Add `dependent.h:' lines.
-    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
+    sed -ne '2,${
+	       s/^ *//
+	       s/ \\*$//
+	       s/$/:/
+	       p
+	     }' "$tmpdepfile" >> "$depfile"
   else
     echo "#dummy" > "$depfile"
   fi
@@ -404,7 +416,7 @@ dashmstdout)
 
   # Remove the call to Libtool.
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
@@ -455,32 +467,39 @@ makedepend)
   "$@" || exit $?
   # Remove any Libtool call
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
   fi
   # X makedepend
   shift
-  cleared=no
-  for arg in "$@"; do
+  cleared=no eat=no
+  for arg
+  do
     case $cleared in
     no)
       set ""; shift
       cleared=yes ;;
     esac
+    if test $eat = yes; then
+      eat=no
+      continue
+    fi
     case "$arg" in
     -D*|-I*)
       set fnord "$@" "$arg"; shift ;;
     # Strip any option that makedepend may not understand.  Remove
     # the object too, otherwise makedepend will parse it as a source file.
+    -arch)
+      eat=yes ;;
     -*|$object)
       ;;
     *)
       set fnord "$@" "$arg"; shift ;;
     esac
   done
-  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  obj_suffix=`echo "$object" | sed 's/^.*\././'`
   touch "$tmpdepfile"
   ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
   rm -f "$depfile"
@@ -500,7 +519,7 @@ cpp)
 
   # Remove the call to Libtool.
   if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
+    while test "X$1" != 'X--mode=compile'; do
       shift
     done
     shift
@@ -538,13 +557,27 @@ cpp)
 
 msvisualcpp)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout, regardless of -o,
-  # because we must use -o when running libtool.
+  # always write the preprocessed file to stdout.
   "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test "X$1" != 'X--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
   IFS=" "
   for arg
   do
     case "$arg" in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
     "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
 	set fnord "$@"
 	shift
@@ -557,16 +590,23 @@ msvisualcpp)
 	;;
     esac
   done
-  "$@" -E |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  "$@" -E 2>/dev/null |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
   echo "	" >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
+msvcmsys)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 none)
   exec "$@"
   ;;
@@ -585,5 +625,6 @@ exit 0
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 4efa58d..bb2444e 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -3,7 +3,7 @@
 
 # This is the automake file for the NetCDF CF Library documentation.
 
-# $Id: Makefile.am,v 1.6 2008/07/01 11:12:04 ed Exp $
+# $Id: Makefile.am,v 1.3 2009/11/11 11:27:33 ed Exp $
 
 info_TEXINFOS = libcf.texi
 
diff --git a/doc/Makefile.in b/doc/Makefile.in
index ab9dfb0..a7c674b 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -18,12 +19,13 @@
 
 # This is the automake file for the NetCDF CF Library documentation.
 
-# $Id: Makefile.am,v 1.6 2008/07/01 11:12:04 ed Exp $
+# $Id: Makefile.am,v 1.3 2009/11/11 11:27:33 ed Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -52,6 +54,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
 INFO_DEPS = $(srcdir)/libcf.info
@@ -70,9 +73,23 @@ am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
     *) f=$$p;; \
   esac;
-am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(pkgdatadir)"
-dist_pkgdataDATA_INSTALL = $(INSTALL_DATA)
 DATA = $(dist_pkgdata_DATA)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -87,7 +104,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -104,12 +120,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -125,13 +140,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -148,8 +162,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -194,7 +209,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -227,14 +241,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  doc/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  doc/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign doc/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -252,6 +266,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -261,7 +276,7 @@ clean-libtool:
 
 .texi.info:
 	restore=: && backupdir="$(am__leading_dot)am$$$$" && \
-	am__cwd=`pwd` && cd $(srcdir) && \
+	am__cwd=`pwd` && $(am__cd) $(srcdir) && \
 	rm -rf $$backupdir && mkdir $$backupdir && \
 	if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
 	  for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
@@ -273,10 +288,10 @@ clean-libtool:
 	 -o $@ $<; \
 	then \
 	  rc=0; \
-	  cd $(srcdir); \
+	  $(am__cd) $(srcdir); \
 	else \
 	  rc=$$?; \
-	  cd $(srcdir) && \
+	  $(am__cd) $(srcdir) && \
 	  $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
 	fi; \
 	rm -rf $$backupdir; exit $$rc
@@ -333,16 +348,18 @@ maintainer-clean-vti:
 
 uninstall-dvi-am:
 	@$(NORMAL_UNINSTALL)
-	@list='$(DVIS)'; for p in $$list; do \
-	  f=$(am__strip_dir) \
+	@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
 	  echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
 	  rm -f "$(DESTDIR)$(dvidir)/$$f"; \
 	done
 
 uninstall-html-am:
 	@$(NORMAL_UNINSTALL)
-	@list='$(HTMLS)'; for p in $$list; do \
-	  f=$(am__strip_dir) \
+	@list='$(HTMLS)'; test -n "$(htmldir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
 	  echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \
 	  rm -rf "$(DESTDIR)$(htmldir)/$$f"; \
 	done
@@ -356,7 +373,8 @@ uninstall-info-am:
 	  for file in $$list; do \
 	    relfile=`echo "$$file" | sed 's|^.*/||'`; \
 	    echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \
-	    install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
+	    if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
+	    then :; else test ! -f "$(DESTDIR)$(infodir)/$$relfile" || exit 1; fi; \
 	  done; \
 	else :; fi
 	@$(NORMAL_UNINSTALL)
@@ -372,16 +390,18 @@ uninstall-info-am:
 
 uninstall-pdf-am:
 	@$(NORMAL_UNINSTALL)
-	@list='$(PDFS)'; for p in $$list; do \
-	  f=$(am__strip_dir) \
+	@list='$(PDFS)'; test -n "$(pdfdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
 	  echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \
 	  rm -f "$(DESTDIR)$(pdfdir)/$$f"; \
 	done
 
 uninstall-ps-am:
 	@$(NORMAL_UNINSTALL)
-	@list='$(PSS)'; for p in $$list; do \
-	  f=$(am__strip_dir) \
+	@list='$(PSS)'; test -n "$(psdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
 	  echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \
 	  rm -f "$(DESTDIR)$(psdir)/$$f"; \
 	done
@@ -398,8 +418,8 @@ dist-info: $(INFO_DEPS)
 	  for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \
 	    if test -f $$file; then \
 	      relfile=`expr "$$file" : "$$d/\(.*\)"`; \
-	      test -f $(distdir)/$$relfile || \
-		cp -p $$file $(distdir)/$$relfile; \
+	      test -f "$(distdir)/$$relfile" || \
+		cp -p $$file "$(distdir)/$$relfile"; \
 	    else :; fi; \
 	  done; \
 	done
@@ -407,7 +427,11 @@ dist-info: $(INFO_DEPS)
 mostlyclean-aminfo:
 	-rm -rf libcf.aux libcf.cp libcf.cps libcf.fn libcf.ky libcf.kys libcf.log \
 	  libcf.pg libcf.pgs libcf.tmp libcf.toc libcf.tp libcf.tps \
-	  libcf.vr libcf.dvi libcf.pdf libcf.ps libcf.html
+	  libcf.vr
+
+clean-aminfo:
+	-test -z "libcf.dvi libcf.pdf libcf.ps libcf.html" \
+	|| rm -rf libcf.dvi libcf.pdf libcf.ps libcf.html
 
 maintainer-clean-aminfo:
 	@list='$(INFO_DEPS)'; for i in $$list; do \
@@ -418,20 +442,23 @@ maintainer-clean-aminfo:
 install-dist_pkgdataDATA: $(dist_pkgdata_DATA)
 	@$(NORMAL_INSTALL)
 	test -z "$(pkgdatadir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)"
-	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
+	@list='$(dist_pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \
+	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  f=$(am__strip_dir) \
-	  echo " $(dist_pkgdataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgdatadir)/$$f'"; \
-	  $(dist_pkgdataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgdatadir)/$$f"; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgdatadir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgdatadir)" || exit $$?; \
 	done
 
 uninstall-dist_pkgdataDATA:
 	@$(NORMAL_UNINSTALL)
-	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
-	  f=$(am__strip_dir) \
-	  echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \
-	done
+	@list='$(dist_pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(pkgdatadir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(pkgdatadir)" && rm -f $$files
 tags: TAGS
 TAGS:
 
@@ -455,13 +482,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -495,13 +526,14 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-aminfo clean-generic clean-libtool mostlyclean-am
 
 distclean: distclean-am
 	-rm -f Makefile
@@ -526,11 +558,14 @@ install-dvi: install-dvi-am
 install-dvi-am: $(DVIS)
 	@$(NORMAL_INSTALL)
 	test -z "$(dvidir)" || $(MKDIR_P) "$(DESTDIR)$(dvidir)"
-	@list='$(DVIS)'; for p in $$list; do \
+	@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
+	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  f=$(am__strip_dir) \
-	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(dvidir)/$$f'"; \
-	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(dvidir)/$$f"; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \
 	done
 install-exec-am:
 
@@ -539,26 +574,31 @@ install-html: install-html-am
 install-html-am: $(HTMLS)
 	@$(NORMAL_INSTALL)
 	test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"
-	@list='$(HTMLS)'; for p in $$list; do \
+	@list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \
+	for p in $$list; do \
 	  if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  f=$(am__strip_dir) \
+	  $(am__strip_dir) \
 	  if test -d "$$d$$p"; then \
 	    echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \
 	    $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
 	    echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
-	    $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
+	    $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \
 	  else \
-	    echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
-	    $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
+	    list2="$$list2 $$d$$p"; \
 	  fi; \
-	done
+	done; \
+	test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \
+	done; }
 install-info: install-info-am
 
 install-info-am: $(INFO_DEPS)
 	@$(NORMAL_INSTALL)
 	test -z "$(infodir)" || $(MKDIR_P) "$(DESTDIR)$(infodir)"
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-	list='$(INFO_DEPS)'; \
+	list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \
 	for file in $$list; do \
 	  case $$file in \
 	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
@@ -566,18 +606,19 @@ install-info-am: $(INFO_DEPS)
 	  if test -f $$file; then d=.; else d=$(srcdir); fi; \
 	  file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
 	  for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
-                       $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
+	               $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
 	    if test -f $$ifile; then \
-	      relfile=`echo "$$ifile" | sed 's|^.*/||'`; \
-	      echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \
-	      $(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \
+	      echo "$$ifile"; \
 	    else : ; fi; \
 	  done; \
-	done
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done
 	@$(POST_INSTALL)
 	@if (install-info --version && \
 	     install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
-	  list='$(INFO_DEPS)'; \
+	  list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \
 	  for file in $$list; do \
 	    relfile=`echo "$$file" | sed 's|^.*/||'`; \
 	    echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
@@ -591,23 +632,27 @@ install-pdf: install-pdf-am
 install-pdf-am: $(PDFS)
 	@$(NORMAL_INSTALL)
 	test -z "$(pdfdir)" || $(MKDIR_P) "$(DESTDIR)$(pdfdir)"
-	@list='$(PDFS)'; for p in $$list; do \
+	@list='$(PDFS)'; test -n "$(pdfdir)" || list=; \
+	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  f=$(am__strip_dir) \
-	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/$$f'"; \
-	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/$$f"; \
-	done
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)" || exit $$?; done
 install-ps: install-ps-am
 
 install-ps-am: $(PSS)
 	@$(NORMAL_INSTALL)
 	test -z "$(psdir)" || $(MKDIR_P) "$(DESTDIR)$(psdir)"
-	@list='$(PSS)'; for p in $$list; do \
+	@list='$(PSS)'; test -n "$(psdir)" || list=; \
+	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  f=$(am__strip_dir) \
-	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(psdir)/$$f'"; \
-	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(psdir)/$$f"; \
-	done
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \
+	  $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)" || exit $$?; done
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -634,10 +679,10 @@ uninstall-am: uninstall-dist_pkgdataDATA uninstall-dvi-am \
 
 .MAKE: install-am install-strip
 
-.PHONY: all all-am check check-am clean clean-generic clean-libtool \
-	dist-info distclean distclean-generic distclean-libtool \
-	distdir dvi dvi-am html html-am info info-am install \
-	install-am install-data install-data-am \
+.PHONY: all all-am check check-am clean clean-aminfo clean-generic \
+	clean-libtool dist-info distclean distclean-generic \
+	distclean-libtool distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am \
 	install-dist_pkgdataDATA install-dvi install-dvi-am \
 	install-exec install-exec-am install-html install-html-am \
 	install-info install-info-am install-man install-pdf \
@@ -671,6 +716,7 @@ web-tarball: all libcf_html
 	zip libcf_html *.pdf &> /dev/null
 	tar cf libcf_docs.tar $(nmans) *.pdf *.html *.tar.gz *.zip libcf
 	gzip -f libcf_docs.tar
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/doc/defines.texi b/doc/defines.texi
index c208bab..9e7caad 100644
--- a/doc/defines.texi
+++ b/doc/defines.texi
@@ -4,7 +4,7 @@
 @c This file is included by the texi file, and contains
 @c common definitions.
 
- at c $Id: defines.texi,v 1.2 2006/09/13 20:46:04 ed Exp $
+ at c $Id: defines.texi,v 1.3 2009/09/15 17:39:45 ed Exp $
 
 @set libcf-man The NetCDF CF Library Users Guide and Reference
 
@@ -12,6 +12,7 @@
 
 @c URLs for CF stuff.
 @set cf-url http://www.cgd.ucar.edu/cms/eaton/cf-metadata/CF-1.0.html
+ at set gridspec-url http://www.gfdl.noaa.gov/~vb/gridstd/gridstd.html
 
 @c home pages for netcdf, netcdf-4, netcdf java, hdf5, Unidata
 @set hdf5-url http://hdf.ncsa.uiuc.edu/HDF5
diff --git a/doc/libcf.info b/doc/libcf.info
index f001b29..bd1283c 100644
--- a/doc/libcf.info
+++ b/doc/libcf.info
@@ -1,5 +1,5 @@
-This is libcf.info, produced by makeinfo version 4.11 from
-/machine/shecky/lb_new9/doc//defines.texi.
+This is libcf.info, produced by makeinfo version 4.12 from
+/machine/libcf/lb_new1/doc//defines.texi.
 
 Copyright (C) 2006 University Corporation for Atmospheric Research
 
@@ -36,16 +36,17 @@ The NetCDF CF Library Users Guide and Reference
 ***********************************************
 
 This guide describes libcf, the netCDF CF Library. This document
-applies to libcf version 1.0-alpha3, and was last updated on 2 May 2007.
+applies to libcf version 1.0-alpha5, and was last updated on 15
+September 2009.
 
 * Menu:
 
 * Summary::
 * Installation::
-* cfcheck::
 * Files::
 * Variables::
 * Coordinates::
+* GRIDSPEC::
 * Combined Index::
 
 
@@ -80,7 +81,7 @@ done with netCDF itself. A Fortran 90 API is planned, but not yet begun.
 web site at `http://www.cgd.ucar.edu/cms/eaton/cf-metadata/CF-1.0.html'.
 
 
-File: libcf.info,  Node: Installation,  Next: cfcheck,  Prev: Summary,  Up: Top
+File: libcf.info,  Node: Installation,  Next: Files,  Prev: Summary,  Up: Top
 
 Downloading and Installing libcf
 ********************************
@@ -116,18 +117,9 @@ the above build commands), and the file config.log, which is generated
 by the configure script.
 
 
-File: libcf.info,  Node: cfcheck,  Next: Files,  Prev: Installation,  Up: Top
+File: libcf.info,  Node: Files,  Next: Variables,  Prev: Installation,  Up: Top
 
-1 The cfcheck Utility
-*********************
-
-The cfchck utility will chck a file to see if it contains valid CF
-metadata. Messages about the file are printed to stdout.
-
-
-File: libcf.info,  Node: Files,  Next: Variables,  Prev: cfcheck,  Up: Top
-
-2 Files
+1 Files
 *******
 
 * Menu:
@@ -141,7 +133,7 @@ File: libcf.info,  Node: Files,  Next: Variables,  Prev: cfcheck,  Up: Top
 
 File: libcf.info,  Node: nccf_def_convention,  Next: nccf_inq_convention,  Prev: Files,  Up: Files
 
-2.1 Mark a File as Conforming to CF Conventions
+1.1 Mark a File as Conforming to CF Conventions
 ===============================================
 
 Mark the file as following CF-1.0 conventions.
@@ -171,7 +163,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_convention,  Next: nccf_def_file,  Prev: nccf_def_convention,  Up: Files
 
-2.2 Determine if a File Claims to Conform to CF Conventions
+1.2 Determine if a File Claims to Conform to CF Conventions
 ===========================================================
 
 Determine if the file claims to follow CF-1.0 conventions. This
@@ -205,7 +197,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_file,  Next: nccf_inq_file,  Prev: nccf_inq_convention,  Up: Files
 
-2.3 Add description to the data with nccf_def_file
+1.3 Add description to the data with nccf_def_file
 ==================================================
 
 Add some or all of the CF recommended text attributes to a file. Any
@@ -258,7 +250,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_file,  Next: nccf_add_history,  Prev: nccf_def_file,  Up: Files
 
-2.4 Read the description of the data with nccf_inq_file
+1.4 Read the description of the data with nccf_inq_file
 =======================================================
 
 Read any existing CF recommended text attributes from the file.
@@ -360,7 +352,7 @@ Example
 
 File: libcf.info,  Node: nccf_add_history,  Prev: nccf_inq_file,  Up: Files
 
-2.5 Append to a History Attribute
+1.5 Append to a History Attribute
 =================================
 
 This function appends a time-stamped history string to the history
@@ -391,7 +383,7 @@ Example
 
 File: libcf.info,  Node: Variables,  Next: Coordinates,  Prev: Files,  Up: Top
 
-3 Variables
+2 Variables
 ***********
 
 * Menu:
@@ -433,7 +425,7 @@ File: libcf.info,  Node: Variables,  Next: Coordinates,  Prev: Files,  Up: Top
 
 File: libcf.info,  Node: nccf_def_var,  Next: nccf_inq_var,  Prev: Variables,  Up: Variables
 
-3.1 Add description to a variable with nccf_def_var
+2.1 Add description to a variable with nccf_def_var
 ===================================================
 
 Usage
@@ -481,7 +473,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_var,  Next: nccf_def_var_missing,  Prev: nccf_def_var,  Up: Variables
 
-3.2 Read variable description with nccf_inq_var
+2.2 Read variable description with nccf_inq_var
 ===============================================
 
 Read any existing CF recommended text attributes from a variable.
@@ -553,7 +545,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_var_missing,  Next: nccf_inq_var_missing,  Prev: nccf_inq_var,  Up: Variables
 
-3.3 Define missing data values for a variable with nccf_def_var_missing
+2.3 Define missing data values for a variable with nccf_def_var_missing
 =======================================================================
 
 nccf_def_notes
@@ -600,7 +592,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_var_missing,  Next: nccf_def_notes,  Prev: nccf_def_var_missing,  Up: Variables
 
-3.4 Learn about missing data settings with nccf_inq_var_missing
+2.4 Learn about missing data settings with nccf_inq_var_missing
 ===============================================================
 
 Get attributes which define missing data information. If the attributes
@@ -650,7 +642,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_notes,  Next: nccf_inq_notes,  Prev: nccf_inq_var_missing,  Up: Variables
 
-3.5 Add CF-Recommended Metadata to a File or Variable with
+2.5 Add CF-Recommended Metadata to a File or Variable with
 ==========================================================
 
 nccf_def_notes
@@ -704,7 +696,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_notes,  Next: nccf_def_latitude,  Prev: nccf_def_notes,  Up: Variables
 
-3.6 Read variable description with nccf_inq_notes
+2.6 Read variable description with nccf_inq_notes
 =================================================
 
 Read any existing CF recommended text attributes from a variable.
@@ -778,7 +770,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_latitude,  Next: nccf_inq_latitude,  Prev: nccf_inq_notes,  Up: Variables
 
-3.7 Define a coordinate variable and dimension for latitude with nccf_def_latitude
+2.7 Define a coordinate variable and dimension for latitude with nccf_def_latitude
 ==================================================================================
 
 Define a coordinate variable and dimension with all the CF recommended
@@ -825,7 +817,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_latitude,  Next: nccf_def_longitude,  Prev: nccf_def_latitude,  Up: Variables
 
-3.8 Learn about a latitude coordinate variable and dimension with
+2.8 Learn about a latitude coordinate variable and dimension with
 =================================================================
 
 nccf_inq_latitude
@@ -876,7 +868,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_longitude,  Next: nccf_inq_longitude,  Prev: nccf_inq_latitude,  Up: Variables
 
-3.9 Define a coordinate variable and dimension for longitude with nccf_def_longitude
+2.9 Define a coordinate variable and dimension for longitude with nccf_def_longitude
 ====================================================================================
 
 Define a coordinate variable and dimension with all the CF recommended
@@ -923,7 +915,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_longitude,  Next: nccf_def_lvl,  Prev: nccf_def_longitude,  Up: Variables
 
-3.10 Learn about a longitude coordinate variable and dimension with
+2.10 Learn about a longitude coordinate variable and dimension with
 ===================================================================
 
 nccf_inq_longitude
@@ -974,7 +966,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_lvl,  Next: nccf_inq_lvl,  Prev: nccf_inq_longitude,  Up: Variables
 
-3.11 Define a coordinate variable and dimension for level with nccf_def_lvl
+2.11 Define a coordinate variable and dimension for level with nccf_def_lvl
 ===========================================================================
 
 Define a coordinate variable and dimension with all the CF recommended
@@ -1037,7 +1029,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl,  Next: nccf_def_lvl_vert,  Prev: nccf_def_lvl,  Up: Variables
 
-3.12 Learn about a level coordinate variable and dimension with
+2.12 Learn about a level coordinate variable and dimension with
 ===============================================================
 
 nccf_inq_lvl
@@ -1096,7 +1088,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_lvl_vert,  Next: nccf_inq_lvl_vert,  Prev: nccf_inq_lvl,  Up: Variables
 
-3.13 Define a coordinate variable and dimension for level with nccf_def_lvl
+2.13 Define a coordinate variable and dimension for level with nccf_def_lvl
 ===========================================================================
 
 Define a unitless vertical coordinate variable and dimension from
@@ -1147,7 +1139,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_vert,  Next: nccf_def_time,  Prev: nccf_def_lvl_vert,  Up: Variables
 
-3.14 Learn about a level coordinate variable and dimension with
+2.14 Learn about a level coordinate variable and dimension with
 ===============================================================
 
 nccf_inq_lvl
@@ -1201,7 +1193,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_time,  Next: nccf_inq_time,  Prev: nccf_inq_lvl_vert,  Up: Variables
 
-3.15 Define a coordinate variable and dimension for time with nccf_def_time
+2.15 Define a coordinate variable and dimension for time with nccf_def_time
 ===========================================================================
 
 Define a coordinate variable and dimension with all the CF recommended
@@ -1248,7 +1240,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_time,  Next: nccf_def_ft_sigma,  Prev: nccf_def_time,  Up: Variables
 
-3.16 Learn about a time coordinate variable and dimension with
+2.16 Learn about a time coordinate variable and dimension with
 ==============================================================
 
 nccf_inq_time
@@ -1301,7 +1293,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_sigma,  Next: nccf_inq_lvl_sigma,  Prev: nccf_inq_time,  Up: Variables
 
-3.17 Define atmosphere sigma coordinate.
+2.17 Define atmosphere sigma coordinate.
 ========================================
 
 Define formula terms attribute for atmosphere sigma coordinate variable.
@@ -1336,7 +1328,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_sigma,  Next: nccf_def_ft_hybrid_sigma,  Prev: nccf_def_ft_sigma,  Up: Variables
 
-3.18 Inquire about atmosphere sigma coordinate.
+2.18 Inquire about atmosphere sigma coordinate.
 ===============================================
 
 nccf_inq_time
@@ -1394,7 +1386,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_hybrid_sigma,  Next: nccf_inq_lvl_hybrid_sigma,  Prev: nccf_inq_lvl_sigma,  Up: Variables
 
-3.19 Define atmosphere sigma coordinate.
+2.19 Define atmosphere sigma coordinate.
 ========================================
 
 Define formula terms attribute for atmosphere hybrid sigma coordinate
@@ -1437,7 +1429,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_hybrid_sigma,  Next: nccf_def_ft_hybrid_height,  Prev: nccf_def_ft_hybrid_sigma,  Up: Variables
 
-3.20 Inquire about atmosphere sigma coordinate.
+2.20 Inquire about atmosphere sigma coordinate.
 ===============================================
 
 Inquire about atmosphere hybrid sigma coordinate.
@@ -1502,7 +1494,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_hybrid_height,  Next: nccf_inq_lvl_hybrid_height,  Prev: nccf_inq_lvl_hybrid_sigma,  Up: Variables
 
-3.21 The formula_terms attribute for atmosphere hybrid height
+2.21 The formula_terms attribute for atmosphere hybrid height
 =============================================================
 
 Define formula terms attribute for atmosphere hybrid height coordinate
@@ -1542,7 +1534,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_hybrid_height,  Next: nccf_def_ft_sleve,  Prev: nccf_def_ft_hybrid_height,  Up: Variables
 
-3.22 Inquire about hybrid height coordinate.
+2.22 Inquire about hybrid height coordinate.
 ============================================
 
 Inquire about the hybrid height coordinate.
@@ -1602,7 +1594,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_sleve,  Next: nccf_inq_lvl_sleve,  Prev: nccf_inq_lvl_hybrid_height,  Up: Variables
 
-3.23 Define atmosphere sleve coordinate.
+2.23 Define atmosphere sleve coordinate.
 ========================================
 
 Define formula terms attribute for the atmosphere sleve coordinate
@@ -1652,7 +1644,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_sleve,  Next: nccf_def_ft_ocean_sigma,  Prev: nccf_def_ft_sleve,  Up: Variables
 
-3.24 Inquire About Sleve Coordinate.
+2.24 Inquire About Sleve Coordinate.
 ====================================
 
 Inquire about the sleve coordinate.
@@ -1725,7 +1717,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_ocean_sigma,  Next: nccf_inq_lvl_ocean_sigma,  Prev: nccf_inq_lvl_sleve,  Up: Variables
 
-3.25 Define Ocean Sigma Coordinate.
+2.25 Define Ocean Sigma Coordinate.
 ===================================
 
 Define the formula terms attribute for the ocean sigma coordinate
@@ -1761,7 +1753,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_ocean_sigma,  Next: nccf_def_ft_ocean_s,  Prev: nccf_def_ft_ocean_sigma,  Up: Variables
 
-3.26 Inquire About Ocean Sigma Coordinate.
+2.26 Inquire About Ocean Sigma Coordinate.
 ==========================================
 
 Inquire about the ocean sigma coordinate.
@@ -1813,7 +1805,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_ocean_s,  Next: nccf_inq_lvl_ocean_s,  Prev: nccf_inq_lvl_ocean_sigma,  Up: Variables
 
-3.27 Define Ocean S Coordinate.
+2.27 Define Ocean S Coordinate.
 ===============================
 
 Define ocean s coordinate.
@@ -1873,7 +1865,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_ocean_s,  Next: nccf_def_ft_ocean_sigma_z,  Prev: nccf_def_ft_ocean_s,  Up: Variables
 
-3.28 Inquire About Ocean S Coordinate.
+2.28 Inquire About Ocean S Coordinate.
 ======================================
 
 nccf_inq_time
@@ -1943,7 +1935,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_ocean_sigma_z,  Next: nccf_inq_lvl_ocean_sigma_z,  Prev: nccf_inq_lvl_ocean_s,  Up: Variables
 
-3.29 Define Ocean Sigma Z Coordinate.
+2.29 Define Ocean Sigma Z Coordinate.
 =====================================
 
 Define ocean sigma z coordinate.
@@ -2004,7 +1996,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_ocean_sigma_z,  Next: nccf_def_ft_ocean_dbl_sigma,  Prev: nccf_def_ft_ocean_sigma_z,  Up: Variables
 
-3.30 Inquire About Ocean Sigma Z Coordinate.
+2.30 Inquire About Ocean Sigma Z Coordinate.
 ============================================
 
 Inquire about the ocean sigma z coordinate.
@@ -2073,7 +2065,7 @@ Example
 
 File: libcf.info,  Node: nccf_def_ft_ocean_dbl_sigma,  Next: nccf_inq_lvl_ocean_dbl_sigma,  Prev: nccf_inq_lvl_ocean_sigma_z,  Up: Variables
 
-3.31 Define Ocean Double Sigma Coordinate.
+2.31 Define Ocean Double Sigma Coordinate.
 ==========================================
 
 Define ocean double sigma coordinate.
@@ -2137,7 +2129,7 @@ Example
 
 File: libcf.info,  Node: nccf_inq_lvl_ocean_dbl_sigma,  Next: nccf_get_vara,  Prev: nccf_def_ft_ocean_dbl_sigma,  Up: Variables
 
-3.32 Inquire About Ocean Double Sigma Coordinate.
+2.32 Inquire About Ocean Double Sigma Coordinate.
 =================================================
 
 Inquire about the ocean double sigma coordinate.
@@ -2210,7 +2202,7 @@ Example
 
 File: libcf.info,  Node: nccf_get_vara,  Prev: nccf_inq_lvl_ocean_dbl_sigma,  Up: Variables
 
-3.33 Get a geographic subset of the data.
+2.33 Get a geographic subset of the data.
 =========================================
 
 Get a geographic subset of the data.
@@ -2267,9 +2259,9 @@ Example
 
 
 
-File: libcf.info,  Node: Coordinates,  Next: Combined Index,  Prev: Variables,  Up: Top
+File: libcf.info,  Node: Coordinates,  Next: GRIDSPEC,  Prev: Variables,  Up: Top
 
-4 Coordinate Systems
+3 Coordinate Systems
 ********************
 
 * Menu:
@@ -2286,7 +2278,7 @@ File: libcf.info,  Node: Coordinates,  Next: Combined Index,  Prev: Variables,
 
 File: libcf.info,  Node: nccf-def-axis-type,  Next: nccf-inq-axis-type,  Prev: Coordinates,  Up: Coordinates
 
-4.1 Label the axis type of a coordinate var with nccf_def_axis_type
+3.1 Label the axis type of a coordinate var with nccf_def_axis_type
 ===================================================================
 
 Usage
@@ -2312,7 +2304,7 @@ Example
 
 File: libcf.info,  Node: nccf-inq-axis-type,  Next: nccf-def-coord-system,  Prev: nccf-def-axis-type,  Up: Coordinates
 
-4.2 Find out the axis type of a coordinate var with nccf_inq_axis_type
+3.2 Find out the axis type of a coordinate var with nccf_inq_axis_type
 ======================================================================
 
 Usage
@@ -2338,7 +2330,7 @@ Example
 
 File: libcf.info,  Node: nccf-def-coord-system,  Next: nccf-inq-coord-system,  Prev: nccf-inq-axis-type,  Up: Coordinates
 
-4.3 Define a coordinate system with nccf_def_coord_system
+3.3 Define a coordinate system with nccf_def_coord_system
 =========================================================
 
 Usage
@@ -2369,7 +2361,7 @@ Example
 
 File: libcf.info,  Node: nccf-inq-coord-system,  Next: nccf-assign-coord-system,  Prev: nccf-def-coord-system,  Up: Coordinates
 
-4.4 Find out about a coordinate system with nccf_inq_coord_system
+3.4 Find out about a coordinate system with nccf_inq_coord_system
 =================================================================
 
 Usage
@@ -2399,7 +2391,7 @@ Example
 
 File: libcf.info,  Node: nccf-assign-coord-system,  Next: nccf-def-transform,  Prev: nccf-inq-coord-system,  Up: Coordinates
 
-4.5 Assign a coordinate system to a var with nccf_assign_coord_system
+3.5 Assign a coordinate system to a var with nccf_assign_coord_system
 =====================================================================
 
 Usage
@@ -2428,7 +2420,7 @@ Example
 
 File: libcf.info,  Node: nccf-def-transform,  Next: nccf-inq-transform,  Prev: nccf-assign-coord-system,  Up: Coordinates
 
-4.6 Define a coordinate transform with nccf_def_transform
+3.6 Define a coordinate transform with nccf_def_transform
 =========================================================
 
 Usage
@@ -2459,7 +2451,7 @@ Example
 
 File: libcf.info,  Node: nccf-inq-transform,  Next: nccf-assign-transform,  Prev: nccf-def-transform,  Up: Coordinates
 
-4.7 Find out about a coordinate transform with nccf_inq_transform
+3.7 Find out about a coordinate transform with nccf_inq_transform
 =================================================================
 
 Usage
@@ -2491,7 +2483,7 @@ Example
 
 File: libcf.info,  Node: nccf-assign-transform,  Prev: nccf-inq-transform,  Up: Coordinates
 
-4.8 Assign a coordinate transform to a coordinate system with nccf_assign_transform
+3.8 Assign a coordinate transform to a coordinate system with nccf_assign_transform
 ===================================================================================
 
 Usage
@@ -2518,7 +2510,647 @@ Example
 
 
 
-File: libcf.info,  Node: Combined Index,  Prev: Coordinates,  Up: Top
+File: libcf.info,  Node: GRIDSPEC,  Next: Combined Index,  Prev: Coordinates,  Up: Top
+
+4 GRIDSPEC - A standard for the description of grids used in Earth System models
+********************************************************************************
+
+The GRIDSPEC is a proposed CF standard. It is not yet part of the
+Climate and Forecast Conventions. Support for GRIDSPEC in libcf is
+provided as a service to the CF community, allowing for the evaluation
+of the proposed GRIDSPEC standard.
+
+   Each of the GRIDSPEC tools listed below may be call
+programmatically, or with a command line utility.
+
+   For more information about GRIDSPEC see
+`http://www.gfdl.noaa.gov/~vb/gridstd/gridstd.html'.
+
+* Menu:
+
+* gs_make_hgrid::
+* gs_fregrid::
+* gs_make_solo_mosaic::
+* gs_river_regrid::
+* gs_transfer_to_mosaic::
+* gs_make_vgrid::
+* gs_make_coupler_mosaic::
+* gs_make_topog::
+
+
+File: libcf.info,  Node: gs_make_hgrid,  Next: gs_fregrid,  Prev: GRIDSPEC,  Up: GRIDSPEC
+
+4.1 Make a Horizontal Grid
+==========================
+
+This function can generate different types of horizontal grids. The
+output data is on supergrid ( model grid size x refinement(=2) ).  For
+'cubic_grid', six grid files which contain the grid information for each
+tile will be generated, otherwise one file will be generated.
+
+   Specify the grid type through grid_type parameter. The value of
+grid_type can be 'from_file', 'spectral_grid', 'spherical_grid',
+'conformal_cubic_grid', 'gnomonic_ed' or 'simple_cartesian_grid', with
+default value 'spherical_grid'.
+
+   The nlon and nlat parameters must be specified to indicate supergrid
+size (for cubic_grid, nlat is not needed because nlat has the same
+value as nlon).
+
+     int
+     gs_make_hgrid(char *grid_type, int *nlat, int *nlon,
+     	      int nxbnds0, int nybnds0, int nxbnds1, int nybnds1,
+     	      int nxbnds2, int nybnds2, double lat_join, int nratio,
+     	      double simple_dx, double simple_dy, int ntilex, int ntiley,
+                   char *gridname, char *center, char *history, double *xbnds,
+     	      double *ybnds)
+
+   The following grid types are available:
+
+`from_file'
+     my_grid_file must be specified. The grid " specified in
+     my_grid_file should be super grid vertex.
+
+`spectral_grid'
+     no other optional or required arguments.
+
+`regular_lonlat_grid'
+     nxbnds, nybnds xbnds, ybnds, must be specified to define the grid
+     bounds.
+
+`tripolar_grid'
+     nxbnds, nybnds, xbnds, ybnds, must be specified to define the grid
+     bounds. lat_join is optional with default value 65.
+
+`conformal_cubic_grid'
+     nratio is optional argument.
+
+`gnomonic_ed'
+     equal distance gnomonic cubic grid.
+
+`simple_cartesian_grid'
+     xbnds, ybnds must be specified to define
+         the grid bounds location and grid size. number
+                   of bounds must be 2 in both and x and
+                    y-direction. simple_dx and simple_dy must b
+                           specified to specify uniform cell length.
+
+
+`grid_type'
+     specify type of topography (see table above).
+
+`my_grid_file'
+     when this flag is present, the program will read grid information
+     from 'my_grid_file'. The file format can be ascii file or netcdf
+     file. Multiple file entry are allowed but the number should be
+     less than MAXBOUNDS.
+
+`nxbnds'
+     Specify number of zonal regions for varying resolution.
+
+`nybnds'
+     Specify number of meridinal regions for varying resolution.
+
+`xbnds'
+     Specify boundaries for defining zonal regions of varying
+     resolution. When tripolar is present, x also defines the longitude
+     of the two new poles nxbnds must be 2 and lon_start = x(1),
+     lon_end = x(nxbnds) are longitude of the two new poles.
+
+`ybnds'
+     Specify boundaries for defining meridional regions of varying
+     resolution
+
+`nlon'
+     Number of model grid points(supergrid) for each zonal regions of
+     varying resolution.
+
+`nlat'
+     Number of model grid points(supergid) for each meridinal regions of
+     varying resolution.
+
+`lat_join'
+     Specify latitude for joining spherical and rotate bipolar grid.
+     Default value is 65 degree.
+
+`nratio'
+     Speicify the refinement ratio when calculating cell length and
+     area of supergrid.
+
+`simple_dx'
+     Specify the uniform cell length in x-direction fo simple cartesian
+     grid.
+
+`simple_dy'
+     Specify the uniform cell length in y-direction fo simple cartesian
+     grid.
+
+`ndivx'
+     Specify number division in x-direction for each face, default
+     value is 1.
+
+`ndivy'
+     Specify number division in y-direction for each face, default
+     value is 1.
+
+`grid_name'
+     Specify the grid name. The output grid file name will be
+     grid_name.nc if there is one tile and grid_name.tile#.nc if there
+     is more than one tile The default value will be horizontal_grid.
+
+`center'
+     Specify the center location of grid. The valid entry will be
+     'none', 't_cell' or 'c_cell' with default value 'none'. The grid
+     refinement is assumed to be 2 in x and y-direction when center is
+     not 'none'. 'c_cell' should be used for the gr used in MOM4.
+
+
+
+File: libcf.info,  Node: gs_fregrid,  Next: gs_make_solo_mosaic,  Prev: gs_make_hgrid,  Up: GRIDSPEC
+
+4.2 Remap data from Input Mosaic to Output Mosaic
+=================================================
+
+This function remaps data (scalar or vector) from input_mosaic onto
+output_mosaic.
+
+   The target grid also could be specified through lonBegin, lonEnd,
+latBegin, latEnd, nlon and nlat.
+
+   Currently only T-cell scalar regridding and AGRID vector regridding
+(only bilinear interpolation is implemented for cubic grid vector
+interpolation). The interpolation algorithm used is controlled by
+interp_method with default 'conserve_order1'.
+
+   Currently only 'conserve_order1', 'conserve_order2' and 'bilinear'
+remapping scheme are implemented. 'bilinear' is only used to remap data
+from cubic grid to latlon grid. We will add more scheme in the future if
+needed. fregrid expects NetCDF format input. scalar_field and/or
+u_field/v_field must be specified. u_fld and v_fld must be paired
+together.
+
+     int
+     gs_fregrid(char *history, char *mosaic_in, char *mosaic_out, char *dir_in,
+                char *dir_out, char **input_file, int nfiles, char **output_file,
+                int nfiles_out, char *remap_file, char **scalar_name, int nscalar,
+                char **u_name, int nvector, char **v_name, int nvector2,
+                char *interp_method, char *test_case, double test_param,
+                unsigned int opcode, int grid_type, unsigned int finer_step,
+                int fill_missing, int nlon, int nlat, int check_conserve,
+                int y_at_center, double lonbegin, double lonend, double latbegin,
+                double latend, int kbegin, int kend, int lbegin, int lend)
+
+`innput_mosaic'
+     Specify the input mosaic information. This file contains list of
+     tile files which specify the grid information for each tile.
+
+`input_file'
+     specify the input file name. The suffix '.nc' can be omitted. The
+     suffix 'tile#' should not present for multiple-tile files. The
+     number of files must be 1 for scalar regridding and can be 1 or 2
+     for vector regridding. File path should not be includes.
+
+`scalar_field'
+     specify the scalar field name to be regridded. The multiple entry
+     field names are seperated by comma.
+
+`u_field'
+     specify the vector field u-componentname to be regridded. The
+     multiple entry field names are seperated by comma. u_field must be
+     paired together with v_field.
+
+`v_field'
+     specify the vector field v-componentname to be regridded. The
+     multiple entry field names are seperated by comma. v_field must be
+     paired together with u_field.
+
+`output_mosaic'
+     specify the output mosaic information. This file contains list of
+     tile files which specify the grid information for each tile. If
+     output_mosaic is not specified, nlon and nlat must be specified.
+
+`lonBegin  #'
+     specify the starting longitude(in degree) of the geographical
+     region of the target grid on which the output is desired. The
+     default value is 0.
+
+`lonEnd'
+     specify the ending longitude(in degree) of the geographical region
+     of the target grid on which the output is desired. The default
+     value is 360.
+
+`latBegin'
+     specify the starting latitude(in degree) of the geographical
+     region of the target grid on which the output is desired. The
+     default value is -90.
+
+`latEnd'
+     specify the ending latitude(in degree) of the geographical region
+     of the target grid on which the output is desired. The default
+     value is 90.
+
+`nlon'
+     specify number of grid box cells in x-direction for a regular
+     lat-lon grid.
+
+`nlat'
+     specify number of grid box cells in y-direction for a regular
+     lat-lon grid.
+
+`KlevelBegin'
+     specify begin index of the k-level (depth axis) that to be
+     regridded.
+
+`KlevelEnd'
+     specify end index of the k-level (depth axis) that to be regridded.
+
+`LstepBegin'
+     specify the begin index of L-step (time axis) that to be regridded.
+
+`LstepEnd'
+     specify the end index of L-step (time axis) that to be regridded.
+
+`output_file'
+     specify the output file name. If not presented, output_file will
+     take the value of input_file. The suffix '.nc' can be omitted. The
+     suffix 'tile#' should not present for multiple-tile files. The
+     number of files must be 1 for scalar regridding and can be 1 or 2
+     for vector regridding. File path should not be includes
+
+`input_dir'
+     specify the path that stores input_file. If not presented, the
+     input file is assumed to be stored in current diretory.
+
+`output_dir'
+     specify the path that will store output file. If not presented, the
+     output file will be stored in current diretory.
+
+`remap_file'
+     specify the file name that saves remapping information.  If
+     remap_file is specified and the file does not exist, remapping
+     information will be calculated ans stored in remap_file. If
+     remap_file is specified and the file exists, remapping information
+     will be read from remap_file.
+
+`interp_method'
+     specify the remapping algorithm to be used. Default is
+     'conserve_order1'. Currently only 'conserve_order1',
+     'conserve_order2' and 'bilinear' remapping scheme are implemented
+     in this tool. The bilinear scheme can only be used to remap data
+     from cubic grid to regular latlon grid. When interp_method is
+     'bilinear', nlon and nlat must be specified and the output data in
+     y-direction will be located at the center of cell or bound of the
+     cell depending on the setting of y_center.
+
+`test_case'
+     specify the test function to be used for testing.
+
+`grid_type'
+     specify the vector field grid location. default is AGRID and only
+     AGRID is implemented yet.
+
+`symmetry'
+     the grid is symmetry or not.
+
+`target_grid'
+     input cell area instead of calculating based on exchange grid
+     area. default is off.
+
+`-finer_step'
+     This is used only for bilinear interpolation. Set finer_step to a
+     positive integer to reduce noise in interpolation and get a
+     relatively smooth output. The default value is 0. When finer_step
+     is greater than 0, fregrid will first remap data from source grid
+     onto a finer grid with resolution that is power of 2 of
+     destination grid resolution using bilinear interpolation, then
+     using volume averaging to remap data from finer grid onto
+     destination grid.
+
+`center_y'
+     output latitude will locate at cell center, i.e., the starting
+     latitude will be -89 when nlat = 90. when center_y is not set,
+     starting latitude will be -90. for bilinear interpolation. For
+     conservative interpolation, center_y is assumed.
+
+`check_conserve'
+     check the conservation of conservative interpolation.  The area
+     sum will be printed out for input and output mosaic.
+
+
+
+File: libcf.info,  Node: gs_make_solo_mosaic,  Next: gs_river_regrid,  Prev: gs_fregrid,  Up: GRIDSPEC
+
+4.3 Generate Mosaic Information Between Tiles
+=============================================
+
+This function generates Mosaic information between tiles. The mosaic
+information includes: list of tile files, list of contact region
+specified by index, contact type.
+
+     int
+     gs_make_solo_mosaic(char *history, int ntiles, char *mosaic_name, char *grid_descriptor,
+                         char **tilefile, double periodx, double periody, char *dir)
+
+`num_tiles'
+     Number of tiles in the mosaic.
+
+`dir'
+     The directory that contains all the tile grid file.
+
+`mosaic_name'
+     mosaic name. The output file will be mosaic_name.nc.  default is
+     'mosaic'.
+
+`tile_file'
+     Grid file name of all tiles in the mosaic. The file name should be
+     relative file name ( exclude the absolute file path). The absolute
+     file path will be dir/tile_file.  If this option is not specified,
+     the tile_file will be 'horizontal_grid.tile#.nc'
+
+`periodx'
+     Specify the period in x-direction of mosaic. Default
+              value is 0 (not periodic).
+
+`periody'
+     Specify the period in y-direction of mosaic. Default value is 0
+     (not periodic).
+
+
+
+File: libcf.info,  Node: gs_river_regrid,  Next: gs_transfer_to_mosaic,  Prev: gs_make_solo_mosaic,  Up: GRIDSPEC
+
+4.4 Remap River Network Data
+============================
+
+river_regrid will remap river network data from global regular lat-lon
+grid onto any Other grid (includes regular lat-lon grid and cubic grid
+), which is specified through option mosaic. The river network source
+data is specified through option river_src.
+
+     int
+     gs_river_regrid(char *history, char *mosaic_file, char *river_src_file,
+        char *output_file)
+
+`mosaic'
+     specify the mosaic file of destination grid. This mosaic file
+     should be a coupler mosaic file, which contains link to land solo
+     mosaic and the exchange grid file.
+
+`river_src'
+     specify the river network source data file. The data is assumed on
+     regular lat-lon grid and the longitude is assumed from 0 to 360
+     degree and latitude is assumed from -90 to 90 degree.
+
+`output'
+     specify the output file base name. the suffix '.nc' should not be
+     included in the output_file. The default value is river_output.
+     For one tile mosaic, the actual result will be $output_file.nc.
+     For multiple tile mosaic, the result will be $output.tile#.nc.
+
+
+
+File: libcf.info,  Node: gs_transfer_to_mosaic,  Next: gs_make_vgrid,  Prev: gs_river_regrid,  Up: GRIDSPEC
+
+4.5 Transfer to Mosaic
+======================
+
+     int
+     gs_transfer_to_mosaic(char *old_file, char *mosaic_dir)
+
+`old_file'
+     The old file.
+
+`mosaic_dir'
+     The mosaic directory.
+
+
+
+File: libcf.info,  Node: gs_make_vgrid,  Next: gs_make_coupler_mosaic,  Prev: gs_transfer_to_mosaic,  Up: GRIDSPEC
+
+4.6 Make a Vertical Grid
+========================
+
+This program call be used to make vertical grid for FMS model.  It uses
+cubic-spline algorithm to calculate the grid cell location.  The output
+netcdf will contains information on supergrid with grid size equal
+model grid size multipling refinement ( always 2 ).  make_vgrid takes
+the following flags
+
+     int
+     gs_make_vgrid(char *history, int nbnds, int *bnds, int n1,
+     	      int n2, int *nz, char *gridname, char *center)
+
+`nbnds'
+     Specify number of vertical regions for varying resolution.
+
+`bnds'
+     Specify boundaries for defining vertical regions of varying
+     resolution.
+
+`nz'
+     Number of model grid points for each vertical regions of varying
+     resolution.
+
+`grid_name'
+     Specify the grid name. The output grid file name will be
+     grid_name.nc. The default value is vertical_grid.
+
+`center'
+     Specify the center location of grid. The valid entry will be
+     'none', 't_cell' or 'c_cell' with default value 'none'. The grid
+     refinement is assumed to be 2 in x and y-direction when center is
+     not 'none'. 'c_cell' should be used for the grid used in MOM4.
+
+
+
+File: libcf.info,  Node: gs_make_coupler_mosaic,  Next: gs_make_topog,  Prev: gs_make_vgrid,  Up: GRIDSPEC
+
+4.7 Generate Three Exchange Grids for FMS Coupler
+=================================================
+
+make_coupler_mosaic generates three exchange grids for the FMS coupler.
+The output file includes exchange grid files for fluxes between
+atmosphere and surface (sea ice and land), exchange grid files for
+runoff between land and sea ice. There might be more than one exchange
+grid files between two model solo mosaic because there might be multiple
+tiles in a solo mosaic. All the exchange grid information are between
+model grid, not between supergrid. We assume the refinement ratio
+between model grid and supergrid is 2. Currently we only output the
+exchange grid on T-cell.  Besides generate the exchange grid files,
+make_coupler_mosaic also generate the coupler mosaic file (the file name
+will be mosaic_name.nc) which contains the atmos, land and ocean mosaic
+path, ocean mosaic topog path and exchange grid file path.
+make_coupler_mosaic expects NetCDF format input.
+
+     int
+     gs_make_coupler_mosaic(char *history, char *amosaic, char *lmosaic,
+     		       char *omosaic, char *otopog, int interp_order,
+     		       double sea_level, char *mosaic_name, int check)
+
+`atmos_mosaic'
+     specify the atmosphere mosaic information. This file contains list
+     of tile files which specify the grid information for each tile.
+     Each grid is required to be regular lon/lat grid. The file name
+     can not be 'mosaic.nc'
+
+`ocean_mosaic'
+     specify the ocean mosaic information. This file contains list of
+     tile files which specify the grid information for each tile. The
+     file name can not be 'mosaic.nc'
+
+`ocean_topog'
+     specify the topography information for ocean mosaic.  The field
+     name of the topography is depth_tile# or depth when ntiles = 1,
+     The topography data is positive down.
+
+`land_mosaic'
+     specify the land mosaic information. This file contains list of
+     tile files which specify the grid information for each tile. Each
+     grid is required to be regular lon/lat grid. When land_mosaic is
+     not specified, atmosphere mosaic will be used to specify land
+     mosaic.  The file name can not be 'mosaic.nc'.
+
+`interp_order'
+     specify the order of conservative interplation. Its value can be 1
+     ( linear order ) or 2 ( second order ) with default value 2.
+
+`sea_level #'
+     specify the sea level ( in meters ) and its value will be used to
+     determine land/sea mask. When topography of a grid cell is less
+     than sea level, this grid cell will be land, otherwise it will be
+     ocean. Default value is 0
+
+`mosaic_name'
+     coupler mosaic name. The output coupler mosaic file will be
+     mosaic_name.nc. default value is 'mosaic'.
+
+`check'
+     check the tiling error.
+
+
+
+File: libcf.info,  Node: gs_make_topog,  Prev: gs_make_coupler_mosaic,  Up: GRIDSPEC
+
+4.8 Generate Topography for Any Mosaic
+======================================
+
+make_topog can generate topography for any Mosaic. The output file will
+contains the topography for each tile in the Mosaic. The field name in
+the output topography file will be depth_tile# and it is positive down.
+The topography data will be defined on model grid, the model grid size
+will be supergrid grid size divided by refinement (x_refine, y_refine,
+default is 2).  mosaic is a required option and all other options are
+optional, but some options are required depending on the choice of
+topog_type.
+
+     int
+     gs_make_topog(char *history, char *mosaic_file, char *topog_type,
+                   int x_refine, int y_refine,
+                   double basin_depth, char *topog_file, double bottom_depth,
+                   double min_depth, double scale_factor, int num_filter_pass,
+                   double gauss_amp, double gauss_scale, double slope_x,
+                   double slope_y, double bowl_south, double bowl_north,
+                   double bowl_west, double bowl_east, int fill_first_row,
+                   int filter_topog, int round_shallow, int fill_shallow,
+                   int deepen_shallow, int smooth_topo_allow_deepening,
+                   char *output_file)
+
+`mosaic'
+     Specify the mosaic file where topography data located.
+
+`topog_type'
+     Specify type of topography. Its value can be 'realistic',
+     'rectangular_basin', 'gaussian', 'bowl' or 'idealized'. The default
+     value is 'realistic'.
+
+`x_refine #'
+     the refinement ratio of model grid vs supergrid ins x-directin.
+     default value 2.
+
+`y_refine #'
+     the refinement ratio of model grid vs supergrid ins y-directin.
+     default value 2.
+
+`basin_depth #'
+     the basin depth when topog_type is 'rectangular_basin'. Default
+     value is 5000 meter.
+
+`topog_file'
+     Specify name of topograhy file (e.g. scripps, navy_topo, ...)
+
+`topog_field'
+     Specify name of topography field name in topog_file.
+
+`bottom_depth #'
+     maximum depth (or bottom depth) of ocean.  default value is 5000
+     meter.
+
+`min_depth #'
+     minimum depth of ocean.  default value is 10 meter.
+
+`scale_factor #'
+     scaling factor for topography data (e.g. -1 to flip sign or 0.01 to
+     convert from centimeters).  default value is 1.
+
+`num_filter_pass #'
+     number of passes of spatial filter default value is 1.
+
+`gauss_amp #'
+     height of gaussian bump as percentage of ocean depth. default
+     value is 0.5.
+
+`gauss_scale #'
+     width of gaussian bump as percentag e of basin width. Default
+     value is 0.25.
+
+`slope_x #'
+     rise of the ocean floor to the east for the gaussian bump. Default
+     value is 0.
+
+`slope_y #'
+     rise of the ocean floor to the north for the gaussian bump. Default
+     value is 0.
+
+`bowl_south #'
+     southern boundary of Winton bowl.  Default value is 60.
+
+`bowl_north #'
+     northern boundary of Winton bowl.  Default value is 70.
+
+`bowl_west #'
+     western boundary of Winton bowl.  Default value is 0.
+
+`bowl_east #'
+     eastern boundary of Winton bowl.  Default value is 20.
+
+`fill_first_row'
+     when true, make first row of ocean model all land points for ice
+     model.
+
+`filter_topog'
+     when true, apply filter to topography.
+
+`round_shallow'
+     when true, Make cells land if depth is less than 1/2 mimumim depth,
+     otherwise make ocean.
+
+`fill_shallow'
+     when specified, Make cells less than minimum depth land.
+
+`deepen_shallow'
+     when specified, Make cells less than minimum depth equal to
+     minimum depth.
+
+`smooth_topo_allow_deepening'
+     when specified, allow filter to deepen cells.
+
+`output'
+     The created netcdf file that contains mosaic topography. Default
+     value is 'topog.nc'
+
+
+
+File: libcf.info,  Node: Combined Index,  Prev: GRIDSPEC,  Up: Top
 
 Index
 *****
@@ -2534,59 +3166,67 @@ Index
 
 
 Tag Table:
-Node: Top1366
-Node: Summary1786
-Node: Installation3094
-Node: cfcheck4582
-Node: Files4833
-Node: nccf_def_convention5043
-Node: nccf_inq_convention5634
-Node: nccf_def_file6510
-Node: nccf_inq_file7828
-Node: nccf_add_history11119
-Node: Variables11691
-Node: nccf_def_var12594
-Node: nccf_inq_var13727
-Node: nccf_def_var_missing15873
-Node: nccf_inq_var_missing17201
-Node: nccf_def_notes18668
-Node: nccf_inq_notes20108
-Node: nccf_def_latitude22298
-Node: nccf_inq_latitude23542
-Node: nccf_def_longitude24835
-Node: nccf_inq_longitude26094
-Node: nccf_def_lvl27394
-Node: nccf_inq_lvl29142
-Node: nccf_def_lvl_vert30689
-Node: nccf_inq_lvl_vert32094
-Node: nccf_def_time33492
-Node: nccf_inq_time34774
-Node: nccf_def_ft_sigma36101
-Node: nccf_inq_lvl_sigma36785
-Node: nccf_def_ft_hybrid_sigma38104
-Node: nccf_inq_lvl_hybrid_sigma38981
-Node: nccf_def_ft_hybrid_height40570
-Node: nccf_inq_lvl_hybrid_height41435
-Node: nccf_def_ft_sleve42867
-Node: nccf_inq_lvl_sleve43911
-Node: nccf_def_ft_ocean_sigma45667
-Node: nccf_inq_lvl_ocean_sigma46373
-Node: nccf_def_ft_ocean_s47595
-Node: nccf_inq_lvl_ocean_s48901
-Node: nccf_def_ft_ocean_sigma_z50550
-Node: nccf_inq_lvl_ocean_sigma_z51960
-Node: nccf_def_ft_ocean_dbl_sigma53701
-Node: nccf_inq_lvl_ocean_dbl_sigma55181
-Node: nccf_get_vara57014
-Node: Coordinates58567
-Node: nccf-def-axis-type58910
-Node: nccf-inq-axis-type59401
-Node: nccf-def-coord-system59909
-Node: nccf-inq-coord-system60670
-Node: nccf-assign-coord-system61348
-Node: nccf-def-transform61944
-Node: nccf-inq-transform62685
-Node: nccf-assign-transform63561
-Node: Combined Index64225
+Node: Top1365
+Node: Summary1793
+Node: Installation3101
+Node: Files4587
+Node: nccf_def_convention4802
+Node: nccf_inq_convention5393
+Node: nccf_def_file6269
+Node: nccf_inq_file7587
+Node: nccf_add_history10878
+Node: Variables11450
+Node: nccf_def_var12353
+Node: nccf_inq_var13486
+Node: nccf_def_var_missing15632
+Node: nccf_inq_var_missing16960
+Node: nccf_def_notes18427
+Node: nccf_inq_notes19867
+Node: nccf_def_latitude22057
+Node: nccf_inq_latitude23301
+Node: nccf_def_longitude24594
+Node: nccf_inq_longitude25853
+Node: nccf_def_lvl27153
+Node: nccf_inq_lvl28901
+Node: nccf_def_lvl_vert30448
+Node: nccf_inq_lvl_vert31853
+Node: nccf_def_time33251
+Node: nccf_inq_time34533
+Node: nccf_def_ft_sigma35860
+Node: nccf_inq_lvl_sigma36544
+Node: nccf_def_ft_hybrid_sigma37863
+Node: nccf_inq_lvl_hybrid_sigma38740
+Node: nccf_def_ft_hybrid_height40329
+Node: nccf_inq_lvl_hybrid_height41194
+Node: nccf_def_ft_sleve42626
+Node: nccf_inq_lvl_sleve43670
+Node: nccf_def_ft_ocean_sigma45426
+Node: nccf_inq_lvl_ocean_sigma46132
+Node: nccf_def_ft_ocean_s47354
+Node: nccf_inq_lvl_ocean_s48660
+Node: nccf_def_ft_ocean_sigma_z50309
+Node: nccf_inq_lvl_ocean_sigma_z51719
+Node: nccf_def_ft_ocean_dbl_sigma53460
+Node: nccf_inq_lvl_ocean_dbl_sigma54940
+Node: nccf_get_vara56773
+Node: Coordinates58326
+Node: nccf-def-axis-type58663
+Node: nccf-inq-axis-type59154
+Node: nccf-def-coord-system59662
+Node: nccf-inq-coord-system60423
+Node: nccf-assign-coord-system61101
+Node: nccf-def-transform61697
+Node: nccf-inq-transform62438
+Node: nccf-assign-transform63314
+Node: GRIDSPEC63978
+Node: gs_make_hgrid64850
+Node: gs_fregrid69080
+Node: gs_make_solo_mosaic75927
+Node: gs_river_regrid77192
+Node: gs_transfer_to_mosaic78428
+Node: gs_make_vgrid78730
+Node: gs_make_coupler_mosaic80006
+Node: gs_make_topog82862
+Node: Combined Index86705
 
 End Tag Table
diff --git a/doc/libcf.pdf b/doc/libcf.pdf
index 2cc72ab..2302e78 100644
Binary files a/doc/libcf.pdf and b/doc/libcf.pdf differ
diff --git a/doc/libcf.ps b/doc/libcf.ps
index 547a019..312d345 100644
--- a/doc/libcf.ps
+++ b/doc/libcf.ps
@@ -1,17 +1,17 @@
 %!PS-Adobe-2.0
 %%Creator: dvips(k) 5.96.1 Copyright 2007 Radical Eye Software
 %%Title: libcf.dvi
-%%CreationDate: Sun Apr 12 08:13:45 2009
-%%Pages: 44
+%%CreationDate: Mon Nov 23 07:23:17 2009
+%%Pages: 52
 %%PageOrder: Ascend
 %%BoundingBox: 0 0 595 842
-%%DocumentFonts: CMBX12 CMR10 CMSY10 CMBXTI10 CMTI10 CMTT10 CMR9 CMTI9
+%%DocumentFonts: CMBX12 CMR10 CMSY10 CMMI12 CMMI10 CMTT10 CMR9 CMMI9
 %%DocumentPaperSizes: a4
 %%EndComments
 %DVIPSWebPage: (www.radicaleye.com)
 %DVIPSCommandLine: dvips -o libcf.ps libcf.dvi
 %DVIPSParameters: dpi=600
-%DVIPSSource:  TeX output 2009.04.12:0813
+%DVIPSSource:  TeX output 2009.11.23:0723
 %%BeginProcSet: tex.pro 0 0
 %!
 /TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S
@@ -75,29 +75,29 @@ forall Encoding{]exch pop}{cleartomark}ifelse}if/Encoding exch def}def
 end
 
 %%EndProcSet
-%%BeginFont: CMTI9
-%!PS-AdobeFont-1.1: CMTI9 1.0
-%%CreationDate: 1991 Aug 18 21:08:07
+%%BeginFont: CMMI9
+%!PS-AdobeFont-1.1: CMMI9 1.100
+%%CreationDate: 1996 Jul 23 07:53:55
 % Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
 11 dict begin
 /FontInfo 7 dict dup begin
-/version (1.0) readonly def
+/version (1.100) readonly def
 /Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
-/FullName (CMTI9) readonly def
+/FullName (CMMI9) readonly def
 /FamilyName (Computer Modern) readonly def
 /Weight (Medium) readonly def
 /ItalicAngle -14.04 def
 /isFixedPitch false def
 end readonly def
-/FontName /CMTI9 def
+/FontName /CMMI9 def
 /PaintType 0 def
 /FontType 1 def
 /FontMatrix [0.001 0 0 0.001 0 0] readonly def
 /Encoding 256 array
 0 1 255 {1 index exch /.notdef put} for
-dup 46 /period put
+dup 58 /period put
 readonly def
-/FontBBox{-35 -250 1148 750}readonly def
+/FontBBox{-29 -250 1075 750}readonly def
 currentdict end
 currentfile eexec
 D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
@@ -106,31 +106,31 @@ D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
 B72BEFDA23F5DF76BE05AF4CE93137A219ED8A04A9D7D6FDF37E6B7FCDE0D90B
 986423E5960A5D9FBB4C956556E8DF90CBFAEC476FA36FD9A5C8175C9AF513FE
 D919C2DDD26BDC0D99398B9F4D03D5993DFC0930297866E1CD0A319B6B1FD958
-9E3948FFB3DF7BFF10C9BDA4EFE5F68A8CB1526990D1357AE6D2F7C2D2EF8496
-4E47B39E6712EB8908A3265E5FAB40567E866C244814449F1E993AAB422C3F1D
-DFA8C7118584F2E5197FD4BFA3A8AE9E953C6CD4672C0FF51E41C3A919749C1A
-F06650DF4C5E17492164BDBCDF22609A74BFA7F69960A64B9F949FFC2A807458
-8579366C4F41BDE1FDFBCC4845FA19BBB6963D65EE8532549274BAEBDFF24FA6
-03235D1BE37C06B1938AF369DA75BF38DDBC87A1FF445EAA16E1895ABE9506B9
-211955753E447865D33CEF007391D2666A046277A30A49804FFCED3FEA5EB2C3
-E52EE14A9F75241EA10C91974CDA6236EB840FD44D6DDE4D9B3266C3B99BD38B
-D835BCA8CB819C073480FB972CC028D218F6A1D344CE1B63F4FBF2C826F412E1
-6E0B05A26125865A14FD7B7030B478BB8BC6BC395335C3BA940E1C348267F4F9
-0AF97BBEE253511940F1048E175D3569F7D05A28851B6F50765FEB6C9654FEDC
-1BF52F535DB5BB90C1BD5D2EBF75E0AEBE82B20507F3C28A03746781018D4EB2
-298E4F2C27ACF73FA73EBE43F014BB575AAD516C0407B29E1653375135ECB74D
-C91372F06FA8EF37C31AF3FA48AE65318EAA6C34830A5377ABB2DFA5DA53A574
-433484BA1466709A4B186761655C8E482833B697673E847C691079E7F1DCB8D6
-1AD91101D757B83E2090337D525AEECB028FB3C9F6A6E6AD2F322CFDC5A833E6
-1CE4EDBF41FD34FD61630581D222F854A76C2EA9FD72796A7C9CC1F6C2FCCD16
-E95CA05826A4ECFADA6A5FB83C41A7131E52BA6585DD6DD78515D8F7327DFC6F
-9404F89293D6ACB433CD0802C43F0E74C6C4766A23A6AE3788FE6CAE82E1A104
-BAEC8BEFDEFE4F292F625E60362F3886F602CE4121BF0AAD93526314BCBB5971
-40091A7BBF7EFB3BA355B88C897D9C70C841DE41309348751EDFFA8675215988
-49CB1599834A01EC6CD4FD813AFF97A614F56975775D5F48E9C1A9CE532FAEB1
-4EBE20C3FA87CFE03664C428BFC5C894668E507950005BD8C2BCA8998C1FB92C
-4E6B791BA05B79F332EB8AF5B0F851B8B7EE372EC0861B09C007CDF43F82D0B7
-35446F682A0DA7F4112CDABE4F922EACFCB7B8C88BF550B60957E7
+9E394A533A081C36D6F5CA5FED4F9AC9ADE41E04F9FC52E758C9F45A92BED935
+86F9CFDB57732045913A6422AD4206418610C81D882EE493DE9523CC1BFE1505
+DD1390B19BC1947A01B93BC668BE9B2A0E69A968554239B88C00AF9FBDF09CCD
+67D3B2094C11A04762FE8CC1E91D020A28B3C122D24BEAACF82313F4604F2FEF
+6E176D730A879BE45DD0D4996EF0247AEB1CA0AB08FF374D99F06D47B36F9554
+FAD9A2D3CE451B7791C3709D8A1DDDEFBD840C1B42AB824D5A0DFF0E0F15B0B7
+22AEEB877FF489581DA6FA8DA64944555101EB16F7AB0B717E148B7B98D8DBFD
+730C52937E226545CF8DC3E07C5BA30739BAFCD0F2B44275A6D503F582C0FB4F
+449963D0AD2FAFDE33BA3D77BCA9D1DF878DDAFCA2E22CC4BACD542B282164C7
+97C2BDE318AF9D501CA21F6E662E7AAB75A5F24D2C182E598D175D44E88AB19A
+E7CD59584F95B389183EE21B525BF52A3F23C0FE5383A5565A19361D716F508C
+AAB78411CA5A4D27552CC1C435760D5A89D535B71C593E755C616661363308DA
+A683F54ED0C23FB2C225A008392B0B719F66F11A946A090B7C00B662A3C69599
+B4ECB0CC70C85C4BBBF207E0026F6C7A19F2ACFB7A60804FC98A4BFFD7BFFF2B
+9529E6D9D4238002BBC255BC62959D6F3381FE06E0621B879D5FE5B541D45A1E
+759A6E7DC32B1D1632368D09A97039DF255B6492B1B2B7E2C1434E8306ECA7D3
+5A79B6D614B4979F10988BC76ED53A5F45315CD7DA216221F842FD0F3E050DD2
+BAC23C984D506D8F7D614BCB6B244F5F41321549BB0BD041FBF3053307168680
+3435E9C9445A59A7C666418C4F2512C32058B1CE1EA46C7839C6E372F6CC60AE
+2CF46DD2F130B532DE8ECD42D9204500E413799E298CF6426F28D23BB7216BEA
+1A618B3ECC61B44DDEF0BB22D640B47C09AC0DF378CE68FC9CD88BDAE9ED89CB
+431A5CF9C3E9528FEE7A9936C2B1CF7B38DD2B95773F0EA0051607BE1B0B3588
+A8B907A5EF011B4622C5093A7B107DD1EED6FEE9536DECF1CC96E65373D0F433
+30AE3C094654ABF4698C07F8C74E71D023DFD242EE83B1306786124DD8C6BFA7
+801E66CB944BE7EBCB3FE803EC97067AF7AFC8A4E9AC9D11
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
@@ -357,6 +357,8 @@ end readonly def
 /FontMatrix [0.001 0 0 0.001 0 0] readonly def
 /Encoding 256 array
 0 1 255 {1 index exch /.notdef put} for
+dup 34 /quotedbl put
+dup 35 /numbersign put
 dup 38 /ampersand put
 dup 40 /parenleft put
 dup 41 /parenright put
@@ -375,8 +377,12 @@ dup 59 /semicolon put
 dup 61 /equal put
 dup 62 /greater put
 dup 64 /at put
+dup 66 /B put
 dup 67 /C put
+dup 69 /E put
 dup 70 /F put
+dup 75 /K put
+dup 76 /L put
 dup 95 /underscore put
 dup 97 /a put
 dup 98 /b put
@@ -387,6 +393,7 @@ dup 102 /f put
 dup 103 /g put
 dup 104 /h put
 dup 105 /i put
+dup 106 /j put
 dup 107 /k put
 dup 108 /l put
 dup 109 /m put
@@ -403,6 +410,7 @@ dup 119 /w put
 dup 120 /x put
 dup 121 /y put
 dup 122 /z put
+dup 126 /asciitilde put
 readonly def
 /FontBBox{-4 -235 731 800}readonly def
 currentdict end
@@ -438,225 +446,266 @@ FF798F2ABFC4F3539392985C4CB324B0007229586D1E0321559F67C057FD7902
 86DB7DA1EDFC73D7697FD45E3A2928746BE164AFCBF8F5E8058815645D2180D8
 C19938D79834F4D677BDE57E3231402808137187C94E45B679BD59294184EF54
 172447AC57A8B69B4DAAC8F618ABFE8E6F085C4FA6A856A3B0FAE27B20E1DF3B
-8213D67C4856DB7836D1D58214E74109B47B0F8F4DF03B19D714FB6647262111
-3AD7BB240DE7DFBD1F17FFDA4FAAD1CFF3BFEAA81F5D11DD76BADDD8122A4AA4
-481F951D83972DECD70AA8987112F05C939A6FB0751ADF1E887CBAE6927896B8
-E6078B5D7A3E1798440B8308676413A34EC3BE778E162D2EA2ABCB6CC8DECE56
-6BCEB0ED31013C04E039115954159F45247708AC1AD42D74F2999FDB03F7C710
-D50E8F3FB6A4195819BACD7A3D11A93FD130BC076FCC12356752FB53444B948C
-758B08696A83FE867DE833DA391778C81DCFB897E81A86521EC86005BFA04E31
-6A3B3762478E38875AE91DD4E3F8F055BA69518E25CB99FE1945FBDC9BC87984
-576F8689770EBF9F224B8F0C2925795075329172D1B84E0613F0F8390F9CC2E0
-FBC9B60E71E7D74C36412F614BC37849AD3004BA89D16C9D9960850157A9D94F
-EEF61BCA1823807B70F9A469A48D3C61E333EDE6A019BA24B720DE733E2B840B
-37F259CAF06F94BB4A47F34FA8E76949FCC4A0CB782F4F3180B530C8CC5C411A
-0F686A63C7D93DA72DE6CAE17EE223E829595F5D50C821C6D9FE34822D47BAA6
-A2E5A5E82E52DB5332AEB4F3177D118BA9C5F576688B94F103E3738C5D06ED11
-93E26E93CB802BC120A50C5A9F4677755E4E0299AE61E45E1C188BF33547E40F
-FD582FDCA319F321D0D871A37C34F828E9CBFED80EB5CCEE1B6466532AF4F95C
-E688AC3B8221FF4067A78358B9B2A6E31C05A8BF726FD1B420D01CB975041266
-FD0A3F6DF80C5ADBED674FB15A8406A01B06A4484FA674193C8D19415BEC0EEC
-8D29D116A9D7AF4AA457DA3AF3441FBD54E5F0BDCD9A8E914CB783621E6AE74C
-A665EB6A4D48E6323B73CBBF56FC06E08EA3AB926A008CC744A7F4A20738D2D8
-16414FD5AD214EB30AE682ADA54E69614BB94F99575D22FABBCC0DA4C68A432A
-8D1958A06CEDBAFF69662BFC5C74DCE3ED8CF312DB17C018A41C117CB30DAE26
-461A2A700B37ABB035DB15EC1B95CB7F56115E2527852E803326EAED6A662F82
-651B9D520E762A07AE6A3A5363A49670A288F7F65DAEE3C30A7D90D6F5CB32A6
-4701DDED6689DC2D47BE484649C64B19AC2697BE73C8FA79CC582C203C1F7254
-D55402B10E0740F607A616F969E2FC795C79FF606DD837A124771D980F5B0224
-6999B69CFA2DAD32BAE60DF09B4D69154DF685ADC6D3C0F1675A563B20B29DFB
-30F98C790CF22E9516E418AC3C8847EF2DD8C82995062D06FEED105F131A705E
-9445475382301D642822019FD169E141B2AA55801588AAF6BF19BE22E7AB2197
-093CA847FAB3578ADA350B89DF297A8F3E949B28395E99D7B4B03AB0BFCDFF7B
-9742C4C0D76657C034815B6B7C6082AD1248C4AF17DB8C1B83CED3FCEE092430
-6044519B3D7ED05267D3049DE4FCBA4EF7DEA92E0780EDDBF5F80B63772EA114
-163624DAB481A2A71D47A961F7B15447216B3695A6E755A45E0C54D1EC718DEB
-94D1542B38CD3546456CEF66E6969C1A4B0795968FB1F0D1ADC6BB90F464C078
-206C0D97C545A39BEFA8262DC8516987AEDCEEC48D9CDFA676D5E54FAFD43CE6
-EFEF0D55DCFE8A79B1986D0C43DC87997A57DC97B12F164536E405DD9EF619A0
-D491B65E205F8306D91B11A553FE919D4722B7F465891B32AF522851013AF5AF
-2DD229F45D3BD79E6070E143424C84B28AFA00DC2B86C6D8F035AEA0F9D724C6
-F9EA53B731B6D5C47A9F873D86BA5553E19A6772BA8295AAA04EA3E4BD261D09
-A7F09D0221C95FD957789815D34AF9E696A4721BC548CE4C31E3465D7244C4BB
-AC3F7E32319D8B79FF85C2E362ABEECBF04AFF1D88EE2F0FCDF15A09C6ACC41A
-A470A318B7949B8F5EA75703CEEB59E61DBD25DD4BCF67DFE263848D31A30858
-5FB12B8789A2CBB5F2E5E0FA3B9FCF969E3DC16D8B8BA7415547BFCFECB5172D
-83FB99ED1F4A7800EFE3F377E81E2B14AE12444C3C182740310673038F2B0AFD
-E50C865DC9FC2078216A4747A7397E953F5BA85543567463A7D0D7640E91BAC6
-F7BB5A1C4D29B942E9BAEF1B92883CDA76644DB4777C4DA51740E4E931E42402
-DA7CD0D034C346416C8AE039C44B5793768028C1B683D130D2E80EBF4E8867EE
-68143EA767D11E931D0B5C3E27A7218257650AB9813CAE0FDE6F61389F8B41F6
-4B558BB98D801DDF6B305E139DD4D1B95E08A9BCF8AB8BB58C08D0A7D566F47E
-447F0053D202AF0258E95FCB95F8800CDADFB723966AE2F1D07A51D65BF5BA8A
-354285483D10E91439C6CDCCD9C42EF391A0222EEE6A704DB130CC76462F6F46
-7B72379060872B304B429AA12CF7D53BF103C2E913A3761915436D1D9B88BEB1
-F400DFC2095E529B8A45F9E0ECC44E6AABCB1C8CA77A830DC595667AA1F73283
-F355F6CE0B754C066A4BA890B9816414DA6439E1E518B5000CE9E3A12754F5C1
-CA97336E88CB3F3A30369183E995C47C7691E52BD019FD29A034A72986B4F43A
-043912BA6C21BD6528C3708F0DAD89C3089D9CC6F565E5A5326D18174E96C6A3
-992EA1DECEE6F35E25D6B055793B3B11D705ADE93311E291ECC8B95B7E4A13C3
-D32ECDCB0A9E43ED6A968BD3B34717562AFAF560E62BD573775CAA93F26BA9BC
-642075287981064E22CB011D116F7A6B412277D43DF620B54586187CAC34542A
-C9A09F9492BC0E0D854DAAD5899938661DCBD067DDE763B719A74FA70675C5A6
-CA1FFCF7E83DB7D503B4584B46C527D3A15336AA63914BAED1DBEF3D621D6D54
-8171B848566BA09E9FF3C37F5283C597A2EDFBB7971EFAC71A7A636C683AE869
-F25812C02987F65FAAAF9F1BCCA8D0DE3AEAC74BBE1BC87BCEE202D7917F7F51
-4D0A12DE910F071BB109AD25172F152848BC760384ACE1D94408E675D8499D04
-C6E101470FBFD27F502C44DC36A6F56965A2532F9D2D7231CD0E268EC51DF71C
-D5807762F1BF6FCDE33FC1AB726223881E049C31890681160D0C7B56E9B8AF57
-BDB335D9918C23B0116DAEAE5697226622AE1E5ECC984F3DD74B1DD29C8F4459
-2F2FD15D3832C2D0010A459683AA7567720F587B5A51505223C44858545B0666
-267B5D1F6A8E078BB696320286F2D38D1684AE1ED48E9CFADD1B6EB6D65C549B
-6B47C5827AA5B64C4EE507A76D7C4269BF626B7A4C41B2D05A3D6484A58AE550
-9FE37C777CFA4F467EF104AF820148A631D0AE216070F918757313B8F5F5D7B2
-BB61080DDAA8E810D40D1291B59676A9131A64B865894C249ADC74B3FBA876EB
-C978DBF582FA155D293610F4E2345FBC0A3B9E6CE67888F7BA6D1C79286BD01B
-703421FF9F36EA601D70DD73A9939ABA35A1001FAD38B7AD1257BB34F32BB30D
-A348C1FC748EB9EF830DC9A4F9933816F3A0AC8B765053A386159677FA1D9B27
-A8C85B8FE988CA77EF63FE4B373D4498E2D5672BC70E679AFF42B9FC64AE0A95
-4DF33E1BA839D3C4E99307030B28D5A4494E63EC998B18CF43EF5BAC12CC6A2A
-09320334220C95571F3C8898296CFD4164800B81613FE4B5ED37DC50A3A9055E
-406CA0643DF3618CF7B7CE739231FDEA58EFF0EAEE078B90FCE41200E8897078
-D4A6DE25683025C540D0FAB74435CAF41290BF54A26617F863622B465C9F536B
-90DEFD78BEF28D4AAD5D33A284031BED64448A778C242D2AA51394B04E546BDA
-A9FA06F08A8F86918F5B30F9082C3A3886BA5D435CEC88246CA4067DE1BEF717
-6B28B76C96E444F64F647F2E170E5E5850FDA1B1406DC026E20C55F03E1FCA05
-8884B560303DF9DA6065AF039CB33F9D4CD3657E07876A40ADC4C73004A4E597
-20AFF85F7405F22EDDFB73BE873830EB67C8358BB15C2325AE4CC8609A9F2885
-93ED26C0A697D4761ADC407692E8404C5A1639363A5F1820946F89B7EA2C2081
-3594D34C687BC7F7FCE3668981BDDD2F599E12E8BDFA328BDA437F1319E9B419
-8B32C3E197BA07ADBB68BA6552F9B0ABD57673D2C834427B2496709FCCD1482E
-FA4CC2B307D0445A41B186BBD6F34DA7D31310A3C85F40E62BEA882BDBF4B389
-5C5EA81E7626F20201AF68E732BF86C59E3E5530F4D20A24BADA5874A18ED480
-0696D2EEB1432D0BDECAEEF38CCC95CED9B086A2A8DF2A277934F07FB192AC75
-B71F694815154CF1796D454FDEA421EFAC953AC5B05A8AB6A0461A85126BCC41
-2E16E7954E3E9F45A65A99DD8FD30C7BC0BA8DEB5A3054F498E48C48D28FA8C0
-D0B5AE58C5CAFBA318C130F8CD6626D2136A6648E9E0F427036DA418BD249F08
-E7A990A45227FAC4D9FC481394B12C28F7363642B0C792F466FA0F3EFAD07E27
-EBD626CD1A37CBB77A7530897D68C9283264246921BB4191AA6861DBC62271B4
-5F985A8B47E742D4B0841DC618A65695A8E8E5AF2950B034DB7E899E91CD8985
-4F484684C9557D1EF645C87204E83A4F2C25E5A2E9197CDBC6CF6948F0D48F27
-2EFDDB68D6E8C6549EFA57CFFA186B3B043F2EE22C0974995F1C8F141A952212
-36791E0DE657B71C59DAF688E216EC97D14AE4581B5A06A8188E0F49B6F10779
-E3D191B09F23284D16E5115A1C3939C4855373A7EEBAB515EFDDCBD4AAC16DBC
-CD5851AB4957A5E2A789DFB4C6A3DA5A632F55606B487B8C24272CA4E352860E
-D2691CEDD82485727A262A8B8CCC5FBE9A3776BEF8FE5F95BABEC08495003EE4
-413B47A588B100D1CBC53DFF155AB4F8C5B08A3B7DDA971B05AA19DA5BC4A5BE
-B2881D8310DFB3D7BBCD7921BDD97C0D7E98D654731B38F4E15F9DD323321F50
-3302028B4594D90F8D8676C8D5FB904F99494A33130DEA004F47C261AB80E774
-C31A80D715419D83B03DA871A51780896B27A021DD25F3F9C42C8BDB166F02DB
-2B4E904428457CBC5C3F6F29113165BE629FBC3125E21C17E70BB14350AFD513
-73BA759ADA1FE851A3F0A7A9FDFC10B3DA5D18BB4FA9ED6CFBA62E01B0144668
-12A0FD436B00D0D638BE239A0E7BA495E1FD7DB834C69E6CF933D73535FE7C4F
-98881526BF158F73D300E39A7DB07AC14AC40DF761E759E6EE28C3C9F22F65AB
-D566EF5B57DE3C46B8ED633F7A103633C658A4F4EA7FF23EA93D301B417A874A
-99FF3301D55FD020DB0516E730CA6A5C8CB7016CE1DC0D88028462D99F38B22A
-665B8F2FEA806F3D2E8C3A124F532183D00481852DB19231A1B632B1DFE279D1
-8ACBC0FC3CE787F68BA67199B07624E58CD94FB8364F925C1683A1287ADA728B
-03E6F4755DC98A6288417CE03DACA227DA4A9D50FD4401133F061FEF43061528
-F3169B8E15D4494D68A430F5ED53840F4317268AB25B39614AC5F199880F70D0
-9AD786C100BCFF1C56EDFB3DBF6597314F98800EAD46503D6AB6BDB096B58EFA
-B389E540F5CEA1726A591D6A30FE3585A7E62CB240BA99453EB8B906AA0B79F8
-406F57639FCC7FFCA001751126B362FD4EAA5EB9E5DCA4E6A07E0F6646B51906
-95FF62BB59F920DB67CA6B87EECF72947B4E24B6D8D15ED0DDE5D0E5F75DF318
-87803A24A04D7912D604C16FD09E9AC64D672B433EAD7FCA48225A61318C97A3
-4977715831D30B60D78A787D9682925F97F6125599466D469566DFDD8FA18F37
-F8051409AD9C314CE13DD12AB4D2C69E4F6BB91F6D44B846C5700E1A58BD598B
-D0201471E75F244A3A68CCAC00EF305367C34B613C00248798C4730F8DCFDD26
-9CC0C9A0B74B724BEE5DBA1499F6FB63299C3084A1F1803A2D1BD87DF2C980D1
-28C95B5298DCD58737EB89B77C917A336656E8C04ECE7DC8FB3653B853B21C9A
-701B914E49F6F261538B363C4EDF115E7FF27387F06FE508CA532372DD974B93
-54252AC01BD5F132760FD3DA49893B2E913D31891CD5213C2C12B8D95EF64E01
-DD9392193E5CB0AD9B427BDAB9922C9D8FBD5A97A05488031074489B796B674D
-17F80AA40BB563ACFF3BAAAA1C66E0809EC1FAA11DF04CF6D562F5A7AFC217E6
-C5A498B02D54DD1DF2BD97A9DAE23940B853EA517728A8451E1D5801CB9998E8
-57CD918BCF328E00D48381F5EC1B2F09EFD42EEC9B8F0554C664AB0028624D31
-E5680BFD90210A5499733979F8DBD69835F2FC771336E5EF59B11F390C737940
-B5A466BC842176800280962F0DE9641CF95B67D837B519C90CF93F5AEE0C6BA1
-D07B4C3044A84240C49197F3C0033797807F07B204BB6CBACE2202C087FED7AA
-6C51325C9A0B4879EA242A78BAA5C5DA05A6BA8266ADFA1085240D77196F982D
-A762E218963F080F0DC4672E65728FA969CECB9C51D78BDB662C0A2D1E37EE86
-E39D3BFE904424CD07B880AF4D0D0E2AEAE2C14E8AF2D7D88ADC97608D267F39
-A69B2F721AD723C30E80B4BD5ABF85A909D3DE109FC9772D04387C0AB5FD7637
-6C8EEFAA4642A3AF91FD51A89FBE84EB7826F7FEF4FE94A11FA83129F8593744
-ED2539EC1CB1931B3CB73A1D7D8263A48B6C6A9B6D0A503C25BB304297F41DB5
-81FA84785C11A70E4DB52C60D6B74F39385347A2D05BC003052D6FA1E05ACF4E
-45C03960FDBF1491D28AA2A919B94FA6297F4552CE287D6E334597EC833E3374
-651B2F894D3F52E00CB3CB2244835EDD29B3A8681C7FA684AC5802166E35AC41
-A20AFDEB2B8F0D3C46851E7CB169540DE36CB02372D9ECAC37D9A17D8BD21FCD
-4189DFD6EC18B272345425023DC6360E48940899987BD29363D01EBB9AF9D4C6
-CEAB8ED76834E449A844F846832D8CEAFEFD9F5A72F8636C4BFD718B13632C8D
-28DE6DAF6DE1403709C54E1BD5B4A9522B07EFE29A3B15FFDACC439976BCC7AC
-E3B145BA2CCAB37D72A66E2ECBFB2EF8BC5029C27886B25842893B94DF0196EA
-6B8AB4A595A012A719AEA5D89DD544115EA0401102B85EA7F51D5A939E47AC18
-C4A99FE929AB29288A84904AE6214A9D1E4C2F9931C8D00A003D0DA3340A8E68
-D8682BC40F5130FA51434B2B3717618FE06E8C8333F2C766AD67F19C59D3C926
-1088B7A6210058D3C9E5105BCE9B9A4770394F5EADDD63A18DDA684F39F519F3
-CA0FBAAE3A2D3A12607AF2F6CE90121F2AFCC94F2C37270214F3E3E6808DA7BB
-2791450EC83CDD8DF57F4467DB05055A817B0FBE2ADB95D66702B4F598988EB7
-D411757AB7402A1FCC8E53CC68BF6778427B52F369C55D7E61757D445C5CBC02
-8E777899D022AA920E88337C60E18B7421F8C4A7AA3E5A0137C41C58332CAC13
-68AC6252FE8D22BF9E914F0B3B1C94DBDBD599B80AC09BF4A2511AF2D57EE315
-04272BFD64A865BCF5B0E10E2EE3FDFC1035B7DD91A13C5907D094D565CF7F40
-25FBB263E9C4747A3063310D3AD876F2E1DFA78B9DA9099FF43795686101546F
-16DCBEB4604659AE67E891637C30645081C3D10564A1C1A4F0952651B78EEA6F
-7C262893167D18137578FF9A852C0284C6791F8FAA2C586AC1ED238824BFFE29
-0096600DCFC25363F547F41EE3FE6FEC0AB14D4717E5769BFA63EB479B4A0552
-7A98C66E675002D1D62A4D33D4836B1E9D98C94834AF2BCE0FAFB20875AD0D31
-09D97EBAED67B84822B0549BDA09FFB8F89DAC2F19FCD8BED31253A67C59158F
-88AA469A63F1C3D00B2AC5E3CD7A930FC7D5240FB1FEA8747111E42F6B14938F
-EF1DB7D4D08851787F8CD532A16BB891DEB9A78BE88C7A67E0E57456589D606A
-4DA59A469CBAB5881A76E3D4E9C71AB9BB0AFBD1E6B26202AD0547DC611EB6C8
-40475F71F4BE718C0AF5BDEC2A32480641464A7987253B6EEAA06289A412199E
-40BB68C84B9726FA8AF04A3FAAEAD103BD186AE78F475FAB4771790E65E89E7A
-E7F38D3120F72B8AB91BDBFE8E11B7DAD2FD1F41EAF76FCE8DF7FCEB0C5827A5
-4ED1EB94EFEEA37DFE19620A8E4EC2DE8492B0CF30709C6F5863B7C7CD24CDF9
-40B993754D25540EE12C63A1E9ABB12AFCEADF27DF7B826C49717A1AB933C358
-711EC8BFFC409D7635ECF7DB903340796D321A4D7C6CB42B10E43379A55D4844
-D7FAD9826868C3AC37777934F9EC2153E7E41463D868A31FFFAC270122DB8ADA
-F936D18A0404D23D42D251CB2772764504125E75D889856E075D8E9DE697492C
-F743AFC1B34DDADD4BCFC236E8B4C5AB58FB7FB92F864A5D9E628220A2017E02
-97F19B049EA3F55F33F5108AD13D244BCE33860EC79F2007F3BABEBB5576DB13
-65111EBF823649A7B0C2D38772FE08BDAE60E746A94EF926C83421560BD497B5
-723B1A5720150933ED47D0E43D86E43D6DA0452E2CB8D6D106E87010500DCAD9
-47B462FC9DAFB2095D4AB685E24311EA2FD22BE258B0D9D4103908C30A90F47C
-EF603D880FCC2E355E3CA4020F893376064EB525F32746F6E61093F3D7559FAF
-EAE57E9693AB9736502B9D2E2C781F9021EB2D6AA6436DC0C54B00DD5E7E5703
-7D9C4E8DD501BA3871E9FA79E33A960B31FC2EF8B7CF248297DB00C6FEC9E224
-EC0A7500396394EC25D53441F1A1085CF1C4FC0AC58078973AEFBB5A3197F112
-55D1D949AB1D134D5ECE6D44CE63DE869DC62F6A62E77B6DC6D266301DE5ABA7
-744BEA07647AC376E8582C1DFF10DA66895850B0A56868F3008BF3A6986F785C
-A02CCCA2FEAF5A39C10A017088F7FDABD7EBECD3BD52C8800A512DEDB6D91DCD
-03798C6A6718B633D03ADF83E3D110EEFB6A5A57670688B09284221CBEF44158
-07A94A4FBFBE99ED2F1414E54523FB6E766DB0FD1CA4D524DAD9A8620AD263D1
-F2E58727EFCD2420069981CA18DE1DF340195CFED8303F86E9058CE14EC46856
-A81AA19735657C7B786D194FF9705A14B02125A22E4728C009110FF947665AA5
-2CDDE4ECFCA48AD3377B4E553D8CB6816305CAA3FB3F4AFB3DFBD4D5E4571A6F
-E11A9D7A5E736027E7BA8A70789F01E629E0C052AE29DFC91E95F715750E53E6
-7B86C1F09141088FD42734DB19C7D398217F385E36577CB4109EF269AAC7F152
-455EF9832007F7E558D35F5F0495925BD8DE3CE9115482897F4574D7FEFB4EDC
-49B8916A5038C9AA600FB7C89A07932B0665129BF22972D97EBEED625D8BEFD4
-103A1AAB67D4BD7F6EB07AD9C1EAB4766CB8B8487677791222ABCB769C73A457
-023FCC442915F93B3D442379D53F9B22C7C7D29E0359A62D0A35EA08E5BABE37
-A82ADA28E1F9862899ED4531B43D659B5A3BA8799DBBA44539D4FC5F7FA5F389
-EC399B67077BA926BF4DE173C911F64792CABAAE0D9FAA5864C4CC6747BB418D
-F47D462E7F4342FC1E6A28189ED54B6C665677EE7E5EA48EBD103F6F7C997946
-1456F2ED231F3B7B655334C054760EE9E65AB28CF89AEF0B733781421594C869
-A5E69F29EFD77F41E0EDC73C8B652CDDB280B4B54157830CC1D0086A44E3CB64
-B10F7D566E6A8319FDF1776B0FBF4B7FCDBF68DDF01F441FAC9A2CD6F534FC4E
-907E06871E74678FBB717AB06543B2AD5C84E3FE71CB06C8FA6CB0F56A10B9B5
-54D8278685B7C1BDBF80C4F0A7F4FDDC7DC57F2976C54F0A54ECE2F471784A90
-564DC8B48CADC0C268BE3F54F9E28A7CCEAFD293F870D28C720F1E4D496D2D5F
-C43212072D2C146F654EFA01B7101F041503D57043C1DC2ADDBBCED597E3417E
-CBE1EC5A78E29F219BAAAE286FB163F8E7531DF26A6102A1F194561A30BA3972
-B8ADEFA1A42EA58176029B82012484C65F3ECDB79BC8A309D01AEE16D3200414
-2480CDFAE07DF6F92085BA1E7B5D3236E3693643B8B9C508F308AE7EBD2D0A00
-4A2399BE2A7D9A6DC9002568CCD08FA1C7DEA9767579877F051BEF69A29AC722
-F7F5622921543FFC7726B928B8A3DC9C54A132828A5C3D4EA0AFA210D2B25EBF
-8965D590169B76CA60DF1F003B36F57CED778E93E5D0F337623493980FAFC39C
-71A2C45398447A2EEC5BAA19D59CA0844D82CA62D99FEECCA512B70253DE3B1B
-9119DC08FBDCB65AB1409A820FF332D98BA81CB9F86621A27B5D7E375BC5BB31
-AB4E5FCA0F3C7DDAC915703C2DB3CE0DBCC0365C6D4E8F462CC7E1F72577
+8213D67BA98090F1EE3BB63CA41A8B2F5C95B5E45EE23DFD8BB91FEBE4787113
+4B34BEBB4632F4D7E71CA6C730938309EAF06D1C16F13AEE13ADF9E99D615FE0
+E2B39A653382AFE1AA5F758B8C7EB02722DA8D89474ED625056509BC9BDE9DEE
+1E8951142A28319378A1DDA52BBF99D226F5829D9A7C2E01FC260CE9AA2786EF
+5DCD2F48F1F3BB0DD53BEF770B4CC4E174F49ED8ABCB237A6028EFA12F452039
+6F7F52B7D55F17ED0B5F69C63BF01D7E51056405C824D8A2F4D3AE277DF1DCAE
+3DB461880D70CE0B38151243D996CDEAE424506B3BC2632449BCE8CECA12AB3E
+B24FB1414C4BA56E3479F7C3DAA25499EA5A9CBA58CCAB4CFC3910C426F6F863
+3383A516692C1B5EE6E8C8CA0EA25CC33EAD2EE47C0DBA105148A031F42CD465
+E53466FDEF6E4A396F508CD1F02B5F03BB54DDE85782816D910572D8F95D0352
+B7A1573D6D860CCCFA596ECC929383BE85A2222214FAEE6EDA909FD997220B67
+9E5235A1D701FE82EC8AE7F837CF8B451675B8F0DDF4F3A6AC86377A8D34ECF4
+9DF8F393C550D0EC1208413CD30054C9DED3D823842A44832623960E4352F70B
+E77E5C63A68D3762EC2FDF20D5677496F77A3A621B0FE06284B88FCBEB0923BF
+14625BC7212D0C80B4D20BDA765CB637EF73E341FE6D1777B16FDB2BDD04A5A8
+801BBF34D10B16221090D92C2CAE2F8B0F85D9A92789A5CCDD806705B07A0FAC
+CCF584BB7FF25E58AD84CCFADDF8727B7F6C4F0A7697B390816EB24032F3439A
+BE93C3F183F92277B32B4863BDE0BBC256D3429287EFC9CE02C72825A705667D
+22A42B91AE0F122B4EAA16E2C2C2A3C16AE87DB08B2ACD37436B1137E8B976E5
+16BF2FAAF5B4BF8898DD2A42AAB1E8DC6467FF9FD4432CCC1DBCB2D4831118CB
+7962B9FF5A9055B3AFA23A57C517941902B19037B66EFB34C1C34E2F867E25FB
+501C4D56A1D29EF53A38917895D2A0B267E41E785CCCE4F010A30DF375E6D28C
+60D5FDC534E114B86192C34BE3866F756009F2E0E348D37C8E9EC65E8F8FDC8A
+76E6A2E0CEF1B504330AA0D626C122D415C8C5B25F4168BA383F2DEA0A3DA019
+456AACAE5BD00D237ECCCD84BB3E3653C6C33CE6E3657BCB4C9F7C6DC45D3753
+2C138C4BE7E73108A528A870D5C958099AE72CF6B1FE11FB2E8DE00DFC98FF43
+4E7F14DEC20389AEA428EFCFD592EEEA23121C8C34A2114FBBFED591DC087632
+086FA71131C9C3C2DC55FA60ED844080F7D5E41B70EBC0F8959D79CDCB507443
+2FEFE0A92A8703FD2BFFD13E8BD9572D12EF0A37B1E08E144C9A7618EA660FC6
+ED43A643558C3F7D9CA27AF5CB08F07D02F9624097C65413912B18F3264FF143
+1A3F4D1CC765AF491CDB2E2D151C128CB8687F387D4C8DD1633C31560355B3FB
+66E7D0E499BA3A7A4D99DD6FEA80AC68DD43C197E0980EAB6F1339FAC5FD4B47
+00C86D3CDB9783179252852F0CF4B6C4C1EAEE4E15FEE111D4F63575AC9DC123
+D50E5BD184BE3FAD9DDCF7C5F124AE4E72B62B90B4EB99130E7FAE23871DE075
+35DF81CF648ABD6C2A6B07FA27DADED93737674704EF2F01A4CED638A096F24B
+359BE698E374EE05CA2215788B38F1BBA7F3A27E513EF9C3D4C57100B441DF7E
+E74F5A1C024D4EC8B52815EAAA81E8EC57BCDDC1075DEF2178CA3267E39384B5
+07B5372A4E0D4B38F43EF06B54A9AB10FDA480620545486495D3A8B317AE0BB2
+B0AD892E815B90C31BF42BECDE9D8E679F7C8201CAF04E39094EA2BEEB586955
+5D35D2FB3967B5A733726196A84E51A8E89DAD46D97ABCB8ED6FC4371382BB9E
+D69E0D56B7F1D94A2BAE462005EEDCE64EC679F6A6A226E1A1EAB98FA5C62CD6
+731120402FC2F6AD84FBB298367E39892A4010AFBD26222B96053F1A37872960
+D41AC25E7DA313B80374A3581B911662980D23E3FD570C52894229EEF1571A35
+515A33B1CB25C22E399ED39A83484764FBF7A21F922BF5AEAC5E68EC3A615E4E
+87D5FBFE3D1D804F6982C0E08BABFE4DD9DBC07FC85ACE53B704C42F4885DB5D
+21002582C80AF571E43580C9ED5A85A1554F21CD0F48DB9E554DCD20CB2FAD15
+22DBE48286980ABDF10E2327FEEF3DA4D9DCFA9E5068248312CAB66445E4B143
+8D7785AD66E20BF7B18A02A0564900A42B4261E656B0899CE7ED0B986B8F9334
+8D9968FF8A2EB54A9FA281942C9E29928C3EA80EE6AEAC840A35138DB440F2E2
+450A64FED4FFD5BC9710F1D12BB659D17EE5AD9234CD8B666E3FE80E5E6F0C5A
+385934731F90771E3F45636B017525E972DD5AC3DEDB9D5048D459434ECD105C
+23B84EA784F96D9C21C026F91F92344196FFD79B3D7F3E4AB209F93BC29C2FA1
+DF25DE96A8CAC597EBF113397094452D3C4BB282DCA058CB7A79D82048D69113
+94D7CE7D8E674083D27E4EA02AF4A2902EC074B51706BF81B870901DF050BD93
+2CA06BFC4320DEA140F54802D4FC2055AAE3E658B9C99B8ADB81BC98D2CCD6A2
+D17D8916BECA6B7E9F31B58F35D27B55FC95FA9E4C3420A943964B98CAA9E208
+C6D560BF198CEB3BA0E4FCF6C995D572FF48D3B002A492D206E9BC18CD5875CD
+62FED8B571CCD88FDA0988A8F478A2D59E0FC7278F904FAACBDAFD8A167361E3
+2C7187CC6363B819DE03F4A4BC7783DD804726CFE3DCFFF15E77B39A0995DCC1
+DE541BEE08551FF12DD55D3CAAAA979CAFFFFCF9435A3C9D3E6E9300C1AA8CF1
+CF5C32932768413DE1D765EABE73DCE3748B52B69C90BECA8AE3F388B3474AB8
+C262CEBCB0985CF5F1BEEFE9B20DAF8A4D532B510FD085F328A14922CC48FF7B
+72AF643E1AFD209B90F2524E434A12125DDB8D64642A8FD41BECAFB1984ABF54
+EC48D754D6D9D3D5506344D4C9FCE34EDAB0E00F301EB108090F58503E994676
+2917D0D65061DBE9D5623F37466BC0E117C88A50CD3C57EF442F285AA10944C6
+3FEF56BA9AD9F6AC23B4A79DE18F55F656CCEF8A18BD9C104DDF106D41B5DD30
+045C2CCD23F7E061CBBF97358ED0E78E18B24FB65EA5F38C9801AF69BC19A827
+44D962D35B17CDA09D7E4E2EC63AF446CB82CB051B4D69B961E84796FBBC72E0
+7597D30013B5FB25924532E15124B1BD8A81755644CD080C2F8360EB08D5E7D1
+732D41468E2B064117641D640FFC31AFC2BCD6073A5C5BB7946D035CC8DA37FC
+4A049BF5CCD2E664E0C5F68215815E97BA6151E84819837C43369E959E32C711
+8100CFDD953EE9C63C5D449787E0DDC64E783F6002B0FFDB73C52EFF94A6A37D
+43F1E382E79D7C76AC8AA148E31DB60DC98E430A479C2827650D6513A9E1734A
+F13DAA66B10E7B9A345476620DFBEE3C9BE5BC0E78C17BC402789A9CF4DD6732
+B6E51A9D58A2FCC0D12C6692A08BD3B543CC593BF32804F0739384D917A4ABCA
+8F3AB59B1E192299D9961AEC80C6015A2AF48CFFE129AC7C5850CE98726CEFC2
+1F99D5DE498B12560BBF91EC750A626A62B83E67F475720C9145ECD18E7748C5
+0BB686EC7A1CEB398240687B836FE4445E5DE5E424A0BC3219E466BD2BC7906E
+89CAA6B0CDB09908EB51C7A557880BC31EDACAB54F40980DB61E58D73EFABD47
+18D254CA780BA19FBABDBF0474B344F74FC0854825D88499DBC5CD7C716CC3C0
+08BFA450FB9A683635ABA53FEF2CE78FA5DAA01EFA91BAD15E6B44C6238F87C5
+692A78447946BDE85F5C55264E94779A9897D1266282CBEC8EF54FE4ACCCCA6E
+430204838FB6071288203E94DFB09E48B94B3D3B8D3C3D9530DC4924699F26FD
+F194FCBB61420AC87DD5EF509D32A1661E7135B3FE500424ADEEF33A37FAE0B0
+32164841F68DFCF0D185692C278A692D075EC47C83C5B19EC0D93BDD99184916
+8D108B7C94133C6770D671CA045B073E5AEE987E2FEDA5FF7097C24FDB91C1E9
+02CE8E6394C6058A3367B7CF782FB29C4DCA39149FA6468D80F51AF1B8402306
+2914ABFCDE678889A24216905F974D71E32E8C0ECBC19856A44379741003D398
+5D2BD1EE909EF60CBC4AEBBF2BC19D9EAAC70CC096A4927C78896EDCC7B2DBC2
+E1542D5A7C3FF8A2220BBAB2BC18C606FADF7ECD1F6D389C0F5BE958C7DD6E36
+DD4E08948635ABF25ADEA0E8D66221F87AF37D14F320107837677005E26F58E6
+5945316205D92750099E79C8A6DBDD134C1D2B615A10911698B6F9D5B4DCD224
+B1D4F3C3734FCC2FB8A03B4D5871E3D034449C3924DF7B78D6C9BD47A361764D
+B5045267D81C2E5100E9FD83EA91CDB140E52CCDE57F5A2DB778D6B79FB5B0BB
+05993630997DD86EABCFDBF7DB2DCC235A7BEB0B7CB9D09BDCA000CC7B367D14
+E69D3CAA12A511CF36351863DFFB8E194200C932F4B5CD771DDD7029846FAE7E
+B64590AC5B8FDD50F9D5F15EAD57B556E77EF4138AAA39230A423CC592CA7831
+CD9F5777CDBEB2003A8DAAF5273A14A99E5584C1A6C61611EF94D9877FD98907
+3E63DEEE89AB712FB5C09C67501A25ACDDD58325B6DB966DBC55517769B5C069
+A379F5651A7B14E3E858856CD827D8F139A317680D02E955F9FFF760F1096F3C
+888BBDB40357293855DF6FDD6238235FF0E156F1F39416D83588FF56E04F0BF7
+ABBF6C49056758D198EC0CBDF6BFCAD918F64B22B12793BF2AA48936AE82BA13
+9FFBCC86ED8266AAFD51C512792AEB5F655C517D191EAC9AC4A1976207E1E61A
+90588449D9326DA0C69745E403317008567F6DE3EA8A78A312E9AD6263ABBCD6
+FD81F8937CA9DC064A6E1DAD521B97782838C20B02C95F422D0B37BA2777CD32
+54EB780791391735C91205A9E23419031174A25C300964AD6252309699AC7CF5
+E9BD1084D2908E39721619F9A93ABDDAF2B65471CB84861A9B0D11721CA7C0E1
+94030BD9849060F24CA0FDF851EE4D2B2F04CE962F5E687A0CB193EE75037F6F
+191909589C6D5039FA54B5AA11E89A5F2CFD1F59DC32C0A95BF0CEFC089A1CA0
+D5534917BF7E133B36F9EEB372E10DF85AD8D316F84D0CA3FDB5911A325D4E7F
+6F1EF9868DDD67B704518377BB726512DD3DD313C3580EED4C2A3ECF0FD27A27
+60DC53405DF0414B02CD56D15CD771D423696F2239F5C9924827351694A97663
+9A5780D60E10199F75A40D8D62FC099A4719CF33D9647476CF97F677A93754FD
+2AA49E07377DAECD76830BEC3234C605E7CA3F8D6B9ED181B311CD4E936B8DC9
+749D3B474638C4F180248F4372176C85A4611EEDE061BB6B2F202256A8A98C6C
+53F9D7221FF16D2E3A51272FE99CA683BC14D98E79B1098A35F6B9DDEE7C49F5
+48289726F454DE8B5D93CAF1A21EA1DEC11B61B2E5CEF614250A3E91587F559E
+115A228BF92B37C7BF808F8EBCD65A362C6380DE3E9B6256F22E67355C5C462C
+405B89BB0EF60F24D7BCE8F3047617D80FC3F38AE5BDACE63D86BF1CB8E6B023
+8D6B2588A75B584D80A1314C562D8778EADA93F4C759ECDA7A155E8706A0CEF8
+97F676C14C22C9A88663344733547CFAE879A9FD8A5C20D73503698039A224B6
+49EFFE18C51FD20BC5C3C9DAFA761DA75F08BDD7826B3B5951133E4B117504B5
+AD9DD9230CD5DE1F6FA35C2315F24F391EDC7DBE8D894901540B28A77F4F0600
+9461B40B3A52012A36B3D9D61DB4DE94C578A73CBE65B3B0BB72C36F7C48658C
+887AB02AFC75EC4ECBF3F6EBF4E04D9F2851EE09C6D3BBE56900187CA9E7F318
+29A95D5C26C854FA6DF3F5EBAB027471F7D6998474427FF3CAA83D3EA6199D59
+DA21BD2FC69541133CB3FF615782BF6E77B3C4E5C3F51FBAC16E059E83B9C0C5
+50E2E44C1022EB8CC87B986410D379E2D8598214F7204D848BE3C9EC88478625
+4FD9894102EBCF9CC9D38036D99C5BB4861B68DE8C2E6E90D2B963E05E6807D4
+6F6EC4174BC71D0F4BE4CB94BFCAD836811A742559AACF4568ECA058980BBA58
+48B0C0B99DDCE3489F92A8A512ADC802E4CF6B4FF02DE4ACF385F3D9399E30DE
+058F7368BA4AC36AE20DA20022A398B899EFA3C8C5672D7AE69603EB77CACEB3
+10A1CD1D691063662C73CA0213AC5D3BF7D4E5649A103DEE4F5A5AEC925F455C
+ADF028617505F11913115FF2F9C79950C62E6EC7057138365705859D51FDD193
+4B05A655963EB7A179B9D96AF6A1045EA6D2DB27F838911E9C8BADF79425AB2B
+EC62788868A680914097E89B09F4C4DF5BD57C1F48BF9A4505B19DAE914E1C58
+03D3DB90715167E11B5A32DF41719EB42728C67784E1A354244C98CB0DE1712B
+E1D8E7293E941234B450486743D053D3D5A445F909AD1461248755E49A198B96
+481ACE9E2F4747762DE1098F4C425A15C6F9F62555EBC479C313A2944788F25D
+9799A1D9B109A3A1EC31266F90A337181AE2DAA53D0222BCF9BDE511AC6B98DE
+9875C87F13E376B9B646266E66433AA571BD167C521524A7C4A1C6C8CB231057
+1A348FDF2577373256287311574AC45A2F82ED5B6C3F64223B5956634E0AFB0D
+99D8588D808689F3794A4E17F9F63CEE9B00B8A415FFBD7967AF6D59758B8B59
+3B2B15F91AA40082748DE8DB8B0ECCA17DF2B651AEFAEFACF57D742C0AEA321B
+61C63C4C1AB34494F25B8D4CA77301D5AF6B2232AEE464B21C78CFA7090CB4F6
+B44A51756C0E78CD5E7586E3E22096B773EFFB42606AE8756D90FFBE908E92F6
+7FAB9597E3F7D8EC5FDA47BE43324B3C3C5594DE0FD930B7AF545E524AF05BC6
+CA08863C3FA007C5B3D943A485EF7BF9BEFD8747040BE8BA67BDAB29C2426CF9
+349D56C6BE1E14F16376DF26E0706576C8FB2E8A4CD0EC07201A875D0EC78455
+BF9BC3E6FB6011AFED7DA6E022038979BFDB2C51FAE0A9ED956F0CF9B64DAC7D
+D46DF7BE0A4B5D76EC2BC92E8998B96D2F83FBB7D8DBDEACBDFC563AB8C4BE9B
+1DA3DB06E8E2A5A011118F9466A2D49CED60CD4F018B0CD6AEE48DD304D87AFE
+179A1E98819E7AF6615B32674E07201660311C6651D39B60FFA172ADC1827CC3
+70CAF8BB4CD70676BC1C36EC63B6CDBF1A772A40D346FD55E8EC56ADD6B8776C
+39C7E9ABAE4BB39E5004FEE8F1D1A2C4253D6F52744DB83AEF98348418528F5B
+4CB5C5B9002D28AACE942E665A9B194F70B9D43246BB5A90F6D83A0A86CBE286
+43FCAF6347B13EA1BC0A7B0617482A8DAA48927A4458F3F7356C066805421FDF
+D9BC28CBAE97F6D1495B98FC7E7DB5BF771B7BE8BFDD73455B6E6DEACE5C2B64
+A9753EED9B53162D56ED63BD81970F01909DCBF03A321F7FDB7775AC5FB1483F
+8AFCEC84FA54FECC0943D208DD70BFED8422DF974FC2395A7ED73C59893F27F3
+AE131B2CA79CCC672EC0889BEB9B92D7ABF0BE800E99926DCCB9A91614F8C82C
+8027C8536757F0CFF01CC545DC7512E9FB1744C2488DBDAB118A374932E93F04
+F8FEABD06239EA605A608996A3768770642787F2C684E6CB0748C64B87A39644
+39B5CEA6252DCDBF6C68F60DB4E6085FE2E8EBAFAFD2E8A6CB7A05E984677DC3
+19999AAE299F1D2992CFB35AB346D5A4A38AF9533E31D3A7B38A4CECCD7765FF
+6260D1008D128BD1C6C5F893567BB9A7FE1C0A215C0C39A8EA0599533A7A53E5
+E8796570A4B04A0B14807ED5CB744979D828AE2CFB624D1883A92ED74EAA5965
+6B776CF01C0A201366378BE236D73BF5AE74C2C686FB6D0D8A33AACBA19A907F
+39801051B3C3EB31D8D7345AF80870BE76A7F8C027A10BCFA10BAF075BF40619
+507C2BF54751C9F89909A639EBDA554A25B3B6B321496052EB27F33251F01760
+1950AC4300D0F2E616BD816271C078D61B72675CB5F09055A0F8B67827B81126
+063D14BC8C0885F63D47A13E5378436812939DA210D73EEDEAC1AB3CD4D51BA3
+3497798ED810A1AC9D9EFB8D26565E9E2EED11028FEDDA34057928EDE3E6B48E
+7826BCAE8EF5FAA4476167730F020F0A74AA9634F87AD41EB444F3A373454239
+4E2AAA1F00129D1C349E9552346FFA5CC260DB3C2E79E7CB51D407A9902C1421
+C442997D66CBA8111BB9A3AA4158F51AA715CED066C5CDACA28D4CA5EC6B3695
+728FD1E8CE6144E02AB8C129C184BE59D8969D9388C59FCD285E412BE54EA43E
+DA2E9D7C8E63BBCA0B32FFA8EDE9DCE029ACD633D7F2FE5E48382A8541B7A5E4
+8446622D467812359BAC9D4852082E663F2FEAF0E64EB4FF0C8DFBC90EE07C8B
+AFADEBA85B2F025FDC243149B1DCFE7F739CFF5CC6F77E8B0D0E80FCBCDE762D
+F173913A76BEFC853D1C45FF938645A61FD727762EC5DE953B4BE59D970DCA16
+521422A466C82B155212072DA38F79ACD7EA650F984D557E233CB4649F3EE7B4
+0FB31F5426AC187831FECFA360BCF71668FA5191943F68459CA7141D5913E1D9
+56E141CB7CB2BD9699950A9D60078C87BA7A3A02709AB9524BFAB7E50B5FD79B
+C003CE62E6D9498601B9E79CC885CB7176971A3C17A64B6EA7DFA8867BB578A8
+3079F189A839EB33F48C1EB8F87340BA2C61C4F4A17C517B97975339306A9F59
+FB864429AA2DFD52060760A617EAAB656E57D4C68B0CA0F2C80F44B6A1199EE8
+5ED5F83D3397F0E80A3344048E34ABC3B936E1F9F8B99CF24D40EDE6E08ACA0A
+D64E7AFE6208EC809B6C5D263249E6797CDCCD46C443257C3E5C2E1382A5A7F0
+5ABA38CFBF585BE2492C0EED5B043F6BD253816C39F6275869EB89B4C38417F1
+21E651EE6CDCC900BAD50D6EBC426ABF25F35BDA22D83F594C92191CE4FF00FC
+F13588AF5780029A8BDA5AE7E3E2E68D44CFE00B864FCD3E3EC40D1396DD467F
+5C04B826DE9F47660793E75DA6CFB5508D57C00CC26E23A1EE8E99CD9AAE9DB6
+19216CCE67FCA16D576B7C1709B0C263C919FAD9C6ACDC1704E4305ECF5E5B62
+8229736CF78BFD917FA00962BD96491EFF3F502E8462988E2E6B85C3665F491D
+B17AF9B2563F1FBDE421F7525C73F7DAF4660E79D158BD86B3DD049AC269DE35
+D92E44D9BE90486EB58A2E0D58BC6EC60E1805839B02C89A84C0A839C970002A
+A3AF60F15F35C3D919E91164CA16D8E9F573757D197D17D85B83C2F779FC2C2B
+C1E5B4E920EBB8895C63F146AF7444079A436FEA8C9DDDDD94ACA4EAFC294538
+EDC94E28307F09A1FB45183F1693117242E927CA67C1CF43682DEC39C25DEC85
+531A8B4F22364772E424B26600AF11914D90BBAB22EF0ABF631198A37116A668
+CE7A69039F0AB40C77741398F7D3A2ED6DBF361CE3F78868B4450E2FCE8F6D81
+7E655BE6B0FD1763C098C07DA0A590448380407A5C1509DFC19D5A48A48906B8
+77F9AE1BBA721AC9AFD9289EC9728EBFC8B7A8A7005EDA605A34436F9E187443
+EA14A72D05ED1CA6EDC6BD75DAF3BB933080C2E498B913D320A727A635061679
+CD2ED9A3CE500DA144245396EEDEFA0AF04C35E7EFD96808D9F9F2B31785B482
+84699594420CA0A39DA528F24E8AE117019740CF0D44180A7491E19A78701E61
+087AC1A47814160B48673B6D5239B701822B6C8EC893241A5A80BBEB23E205BB
+8BD4CF2D514BAAD704598C2FFF22065A58CA9F72B7A4CA631568483D1449E877
+EC419CC02C359F53D0F3A07470CA098096C8B7F8B13310AA06A27420DC5D5248
+D91F4F93F56C5CA489546D9C8B6D035A7353694280B9D5F0E3D2FCF6A5F518FC
+C718CCA64B1E1170D28E670485EE02538A3F85C3352CF6B9BCBA00250DA30728
+FBC18DA95A8C77404B6E44EF40A2C83A2DD12CF5A0468A4CDB9564CC0E5C50FB
+BBA1E80B15E65D99590395AA93B5DE142C781A723461EB3668EDD96F2F7917AD
+24490882C94A8D56C2F64EC3BFFCAE749A669C1B71FA97C0E50A681BB131457D
+515C1249E38A9FF8EFC71CDE5905CC00AE17AAF78DC49B5B90DC870D800BD1C9
+DA810059DCFA6E8D559C87958793D6DE7FEE5DA3E13929969EE1D79DF8DC8D33
+3854ED7CA2B4DB363D3A68A5EF13DE8EB290DF7E85C0182B371D6F07F9373F0D
+18418F7D52DF7771E7F28A8773FCB60E0BA988D13E60D2BAD7E3D53A45F4A622
+28906C55FB9875A0E888F949509B0435B0E1279B006059A74DEDD20B1162563C
+EF8D45AAC2B233EEAE934F8EEA58D8F23EFD8EA50AECD873CDCFFBB6D7E5645D
+1394E8443E81E9DE70545EE991EE9E8F1F5ED820429AF9A71FF9770972A8E583
+1386AB70A3ECAFB60B74E596593A4087D6E8AC81DCDBFB3E1FA8E969ED03F4EB
+53E818066F3DB521D995DBC51A71E011D0885D7D1D394D1C79AB22376AF02C10
+78B11F77FAE3BB6FFADC42C08599458B6BBC4C27E40B41B1727E97501C9B29CF
+ED7929196DF393C22AD31ABD933A744AF29E834B94C87F085EF5DE983BDB77E6
+84C45F56D66F070E1409B8A65FD3CCF7590250E91CE1EB1EB54B1D03FD480DBF
+568EED437875D9D75655F3B117569C8D33677B8AA5678B7CC5A5D1091BED07FE
+CADF0F26F8160A1EB2E8F2F3634E989A369CDD8FD4859D43617D689907B3F1B5
+CC1BAD1C580DA1018E38C74AFFC0BB5D746736A2961F73A85360605E752A8C81
+EAE92DF6D1486A19F5F3F79F9807A6358DCF75B13B6EAF95C7846EAB8807CEA9
+9C327ECE5E7274CDD9116CDB7829CE248F83F3932AFCAD231628137182E8F34C
+69539D201A7B877B7559EFBAB3808E268A0F6C10F179A7618876E0F4451C1B5E
+C30BA19676FD43035931D0D5977A2637C8E87364959B716BBE8633E33E40BEC2
+741D9C6820CCE47CFD19596C6ACA1E05FD86D1AD9EF67E0F6A592DDCEC6BDFB8
+63EFC5D0FA8045690C15B4BE2819A9D846D3C373BDDDE97D895AFB1F1DC60C74
+B157762B839E8BE12BE5B1E6B1C98FCA351D2F1144BA7FD9CB25C8E2C995595F
+0148445BDBF3DEAB517541E97A4C6E130A5EA74B5BB0A9D2D40876674BFE1FDA
+DA22E43FCAAF6FA028DF8B58923A66DA1B3F138EEFB936A8896CC35CD571FF8C
+43896CFA08C0BA382799053538F68693D22796A27F6F849F0CBFFD2F6F4E1B17
+C7D665E1420CBACF177A28A07C84AF696CD7EA4ABA509D9095ACB79777A671EC
+6582B1403113D29C38479CE22DFABA806751C17914A5C3559B9FA12803FFC75F
+EF20D87AAC04A1211C9926280860A9FBB1B067F0875BBBDF6E2D5952EF38DC25
+6D0EC803BF3000D31112FE826AF6C376FC86A544DB1DE284E5F631549CB46DDD
+1F5EA6F7AB970618CEA850E7C28FC6BC9D0269CE7161AB55F58010089A89BA54
+528B529A64815B315FBF9705A1698EE07D338B2667DF75943E5FD11BBE1462C1
+4D23A53F7F2C2D9E4C53E77840D82BEB8A7AABA7F0F539605C676FA0F2B5CFBB
+DCC720A7D5A8AB674F1AE1D956E14C634C3ACCE4C54DAC7CE7189062F2FFD86B
+3C204B468589CC3E40E16D706B1B48A670C7A82B7E3B4A530ED4C1C26E1CD6CA
+A22677CE63138071D10420F739F9BC8607F6E0AF079F1ED57F3E86BF2B603568
+41B478BBBFE4E27E03E1A5733208553FF62698C4AECEB4888A32FF1C09ED556A
+8448ECA3044302923584733D38431563B1CE6E12C549650DF3C09EDA7331F9C6
+482761DE1664676D899BFB7A435B77811C610A3667D1FCAECBF10AF749202D9C
+0059D1010A86313807CE9FD293B7F8D9DA2DD54822F937526D12C44360DF254B
+C94D834FD4E8D2675415D83F875ED92A36293323E365F2216EF6C4AF652C4308
+AD28CB5F5483A34EBF5BDDAC12553F2E5657B578E6E864A5BAFCB49E39BC70F5
+0517175B27C54A984FE7F731C85D4FB9AE80B1BF693B8CA0E7C7F27927C9545F
+E7AD81D47319F6A735B473C060633A9B8E7208321C5C2A1C6E7D9C7086120CA4
+1F36DF24E88522928D6D59DF7B94682A1C13F4D26551F73A00AFDEF73F553B61
+DECB364525CC5DABAC6E
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
@@ -667,29 +716,29 @@ AB4E5FCA0F3C7DDAC915703C2DB3CE0DBCC0365C6D4E8F462CC7E1F72577
 0000000000000000000000000000000000000000000000000000000000000000
 cleartomark
 %%EndFont 
-%%BeginFont: CMTI10
-%!PS-AdobeFont-1.1: CMTI10 1.00B
-%%CreationDate: 1992 Feb 19 19:56:16
+%%BeginFont: CMMI10
+%!PS-AdobeFont-1.1: CMMI10 1.100
+%%CreationDate: 1996 Jul 23 07:53:57
 % Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
 11 dict begin
 /FontInfo 7 dict dup begin
-/version (1.00B) readonly def
+/version (1.100) readonly def
 /Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
-/FullName (CMTI10) readonly def
+/FullName (CMMI10) readonly def
 /FamilyName (Computer Modern) readonly def
 /Weight (Medium) readonly def
 /ItalicAngle -14.04 def
 /isFixedPitch false def
 end readonly def
-/FontName /CMTI10 def
+/FontName /CMMI10 def
 /PaintType 0 def
 /FontType 1 def
 /FontMatrix [0.001 0 0 0.001 0 0] readonly def
 /Encoding 256 array
 0 1 255 {1 index exch /.notdef put} for
-dup 46 /period put
+dup 58 /period put
 readonly def
-/FontBBox{-163 -250 1146 969}readonly def
+/FontBBox{-32 -250 1048 750}readonly def
 currentdict end
 currentfile eexec
 D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
@@ -698,31 +747,31 @@ D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
 B72BEFDA23F5DF76BE05AF4CE93137A219ED8A04A9D7D6FDF37E6B7FCDE0D90B
 986423E5960A5D9FBB4C956556E8DF90CBFAEC476FA36FD9A5C8175C9AF513FE
 D919C2DDD26BDC0D99398B9F4D03D5993DFC0930297866E1CD0A319B6B1FD958
-9E3948FFB0B4E70F212EC976D65099D84E0D37A7A771C3101D6AD26A0513378F
-21EC3643079EECE0C9AB54B4772E5DCA82D0D4ACC7F42FB493AA04A3BF4A1BD6
-06ECE186315DBE9CFDCB1A0303E8D3E83027CD3AFA8F0BD466A8E8CA0E7164CF
-55B332FAD43482748DD4A1CB3F40CB1F5E67192B8216A0D8FE30F9F05BF016F5
-B5CC130A4B0796EE065495422FBA55BEE9BFD99D04464D987AC4D237C208FA86
-0B112E55CE7B3782A34BC22E3DE31755D9AFF19E490C8E43B85E17ECE87FA8B9
-1485831624D24F37C39BF9972D74E6EC4784727AC00B9C4A3AD3DA1C22BD6961
-7E0ADAF55422F22ACA5E4DCD4DF9FCD187A566B7FB661D0530454D0DD6C6C50A
-7A3875C6CBF8EC7769F32A1F3F7FC1C072BADEC97794D4E90E0035282A170402
-356E5A9CD9ABD80AC4342A5283E458A7269252F4541CBB6452B39ED54D336D0B
-19928E9CD1AB26AD83EB209E2EC75011A2643813053B5DBB0246097C4821B5F2
-C92554E9140BE35B2DBFCD98809A8EC9FC910FDE9E0D86457C70ACB056EBF90F
-244DC0A5BBD455E15D6E3180311D52CF50B0BF7D0A7F64F3A1821E0AEDBC2E7B
-AEB549FE1D51088C153799C6E089B5D5D65E1C4E2D2B430CDF1FFA23CCB25D95
-592943209E846E55B4CB54F6658CBA3C0B29796D69D0435D5431ABECF3448C15
-98CA2F36F3659E29AEB79355EC2ADF835CF0886C21B766B9DEBC3950B5B3B496
-2E06D980A8C60305B273232D4604F12632FB4F1B2F9703952C823C098543AED1
-CFB4ECF259A11985F0C944A57B5AFD853374FCF12305601200C2A393E2FC77FD
-F78C2BEB83AB223A89D9E231D1BB561CE1F4D3312049F31CD544C39354493803
-D47CF45482054818E8621801A97461EC7BF53C6AF1C38AC90B38342D51C4615C
-59D45B92606D0479F43149F2579DEF5A20B4D7D10528E9750ADFC4C7DDD73DA8
-432297E60ABBB72A637231049425393426F66BFC0851FE504E589F13351187A9
-D784ACC207B1F46537BAA5F2EBF637EB8DFD9D24982E2631F6D3A2DA47B4E9EA
-0C899DEF82A7DEB0ACDCE6043F36CE1F74BF1B00A1EE0765F497A67B95BE1871
-A8B3263B03D41ED8BD6B03CA5983912E094E2AE47DFDBF
+9E394A533A081C36D456A09920001A3D2199583EB9B84B4DEE08E3D12939E321
+990CD249827D9648574955F61BAAA11263A91B6C3D47A5190165B0C25ABF6D3E
+6EC187E4B05182126BB0D0323D943170B795255260F9FD25F2248D04F45DFBFB
+DEF7FF8B19BFEF637B210018AE02572B389B3F76282BEB29CC301905D388C721
+59616893E774413F48DE0B408BC66DCE3FE17CB9F84D205839D58014D6A88823
+D9320AE93AF96D97A02C4D5A2BB2B8C7925C4578003959C46E3CE1A2F0EAC4BF
+8B9B325E46435BDE60BC54D72BC8ACB5C0A34413AC87045DC7B84646A324B808
+6FD8E34217213E131C3B1510415CE45420688ED9C1D27890EC68BD7C1235FAF9
+1DAB3A369DD2FC3BE5CF9655C7B7EDA7361D7E05E5831B6B8E2EEC542A7B38EE
+03BE4BAC6079D038ACB3C7C916279764547C2D51976BABA94BA9866D79F13909
+95AA39B0F03103A07CBDF441B8C5669F729020AF284B7FF52A29C6255FCAACF1
+74109050FBA2602E72593FBCBFC26E726EE4AEF97B7632BC4F5F353B5C67FED2
+3EA752A4A57B8F7FEFF1D7341D895F0A3A0BE1D8E3391970457A967EFF84F6D8
+47750B1145B8CC5BD96EE7AA99DDC9E06939E383BDA41175233D58AD263EBF19
+AFC0E2F840512D321166547B306C592B8A01E1FA2564B9A26DAC14256414E4C8
+42616728D918C74D13C349F4186EC7B9708B86467425A6FDB3A396562F7EE4D8
+40B43621744CF8A23A6E532649B66C2A0002DD04F8F39618E4F572819DD34837
+B5A08E643FDCA1505AF6A1FA3DDFD1FA758013CAED8ACDDBBB334D664DFF5B53
+9560176676ABB71BBD0EE56B4CC492C0652750227CEC6CBEEE374709231B00CD
+0DE83AFDE295B314F6C8B1FFD32251C1925D96A64D739FF1DA4926460B28B3DE
+E949AA0BA3DDB16534FBA30C32092D5F712B5E8C8D5142F35AF2906E6C219D2C
+7FD9A368C193E0EB9C7E25FF03C546B6ED993F964CEDB1B8537C617170787F37
+88D6F2AD02384B01067FE3F98257BAB958BB3BCD1001090A4502DA0638080EC6
+DB784CC8AC37CDC01B29BC481D6A05ADC6188785262358C1BF1D694BBF31C1F1
+AF117C1ACED44AAC6EB4B9A2511A6762DDE8FCCBA5
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
@@ -733,29 +782,29 @@ A8B3263B03D41ED8BD6B03CA5983912E094E2AE47DFDBF
 0000000000000000000000000000000000000000000000000000000000000000
 cleartomark
 %%EndFont 
-%%BeginFont: CMBXTI10
-%!PS-AdobeFont-1.1: CMBXTI10 1.0
-%%CreationDate: 1991 Aug 18 17:46:30
+%%BeginFont: CMMI12
+%!PS-AdobeFont-1.1: CMMI12 1.100
+%%CreationDate: 1996 Jul 27 08:57:55
 % Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
 11 dict begin
 /FontInfo 7 dict dup begin
-/version (1.0) readonly def
+/version (1.100) readonly def
 /Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
-/FullName (CMBXTI10) readonly def
+/FullName (CMMI12) readonly def
 /FamilyName (Computer Modern) readonly def
-/Weight (Bold) readonly def
+/Weight (Medium) readonly def
 /ItalicAngle -14.04 def
 /isFixedPitch false def
 end readonly def
-/FontName /CMBXTI10 def
+/FontName /CMMI12 def
 /PaintType 0 def
 /FontType 1 def
 /FontMatrix [0.001 0 0 0.001 0 0] readonly def
 /Encoding 256 array
 0 1 255 {1 index exch /.notdef put} for
-dup 46 /period put
+dup 58 /period put
 readonly def
-/FontBBox{-29 -250 1274 754}readonly def
+/FontBBox{-30 -250 1026 750}readonly def
 currentdict end
 currentfile eexec
 D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
@@ -763,32 +812,32 @@ D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
 532F85D811C70D1429A19A5307EF63EB5C5E02C89FC6C20F6D9D89E7D91FE470
 B72BEFDA23F5DF76BE05AF4CE93137A219ED8A04A9D7D6FDF37E6B7FCDE0D90B
 986423E5960A5D9FBB4C956556E8DF90CBFAEC476FA36FD9A5C8175C9AF513FE
-D919C2DDD26BDC0D99398B9F4D004B836D34E88C20EEB527CE1124209388A2DF
-E27A8DF298A2693A9D529916AA0B2176E6ED237F69D84A8FEEB36861D1847207
-BE2BD61C6A412FFFEDFF13AFEC32AC7735BCCE5965F5966418A62ECB99112AB3
-3BC938EC590FF6922659125EB67E260BF02885E49BA6019E696D33F0B53606A2
-F515E0C45F323311613A94B838491BAB9FE230C5CC79D22925E3D882799F2707
-C32975A494F0F9513E4D8332E7E54470D9721FBD345CDBB48286F2F19CC6D66E
-BB631DD6476A509167A49CA525A72CA50E82C1D08C2B372DB54C5949C753B632
-2009B761EB90492ACD3CBE6A35CE1B66F3BC4D8DC36827CE4261A703328451D1
-879438479917C1647772999171DCCF1491A1C9086E0C6393506768F8757BD81D
-141C46EB9BF507EEC29962A0072B6C5D8C8588F3D68886CD2606DD3BD2FECCEF
-63245494E93EEA12AAFB06110E54ADC444C7E7619627A48A464394E5DE06EB46
-4C76A2FF010318BBE48B3776C826A265C66515717F7F2E943C60EBAB23D96B5B
-FD514A1C4E79BB3D3D2DEB936F90CD3FABF7B09FF7F564AB5CF4AF6A40E869FD
-395885A88F4A138B3CA6943A2D430BBE43D91F7F17621CAF52FB7161DA3B2003
-82244FB6EE792DCA1722C03392C296C029A2DCC5BAAB3EA03F8DEB039DC83AE1
-763AAB84776A2CCFFAE9EAF0BFDAE417E8BE682D237FFEDAF224AC09C9665019
-165CE32F5349E857177D94AD6396570932E1657ADE4D3FF57A3419946CCD210E
-57E5A1D91CF708395942527D127606350924D71BC21C6F969288B1C8CA3404ED
-E6219985F7301A20621368F74747EAD38990A4C9F2B62913B8FDB93657409FF5
-178DAA7C97C35EAFA47778CE03E863303582D8A9900EF4F8DA879DED54BACD7A
-4A50C18AA2ED906FC4DC073B1E6CA1E3855AD5B7698EF4A96B77DBE19A12382A
-CFA8717DE230CB6182F2250885B8E90AC42A66484A7B527061B223A6D1CC72D4
-890359E7E04690BFFA99FAB5CC9999F0873A9DBE49E33F79E483FAD72313DF9A
-7B7D926461988C23CCE9F71AB7BB63BDB2B10B3F78176380AFFC154825C9BDCE
-82303FBFC3B59E070438984C28D12E8655BBBF049125BF56DD2B0DE8C0450E55
-82832DA59EBEB001AAD86F2317460DD7ED264611B9043614221ECF
+D919C2DDD26BDC0D99398B9F4D03D6A8F05B47AF95EF28A9C561DBDC98C47CF5
+5250011D19E9366EB6FD153D3A100CAA6212E3D5D93990737F8D326D347B7EDC
+4391C9DF440285B8FC159D0E98D4258FC57892DCC57F7903449E07914FBE9E67
+3C15C2153C061EB541F66C11E7EE77D5D77C0B11E1AC55101DA976CCACAB6993
+EED1406FBB7FF30EAC9E90B90B2AF4EC7C273CA32F11A5C1426FF641B4A2FB2F
+4E68635C93DB835737567FAF8471CBC05078DCD4E40E25A2F4E5AF46C234CF59
+2A1CE8F39E1BA1B2A594355637E474167EAD4D97D51AF0A899B44387E1FD933A
+323AFDA6BA740534A510B4705C0A15647AFBF3E53A82BF320DD96753639BE49C
+2F79A1988863EF977B800C9DB5B42039C23EB86953713F730E03EA22FF7BB2C1
+D97D33FD77B1BDCC2A60B12CF7805CFC90C5B914C0F30A673DF9587F93E47CEA
+5932DD1930560C4F0D97547BCD805D6D854455B13A4D7382A22F562D7C55041F
+0FD294BDAA1834820F894265A667E5C97D95FF152531EF97258F56374502865D
+A1E7C0C5FB7C6FB7D3C43FEB3431095A59FBF6F61CEC6D6DEE09F4EB0FD70D77
+2A8B0A4984C6120293F6B947944BE23259F6EB64303D627353163B6505FC8A60
+00681F7A3968B6CBB49E0420A691258F5E7B07B417157803FCBE9B9FB1F80FD8
+CA0DA1186446DD565542BCCC7D339A1EB34C7F49246E8D72E987EB477C6DB757
+99AF86CEBCD7605C487A00CD2CD093098182DC57B20D78ECE0BECF3A0BF88EBA
+C866DB19F34BBBED6634AFC0F08D2AFB2A92578A6F8B4ADCD6594737FF6EED7D
+5B536DA9E3E2CADB40DB7C600EA4D100D33C3B92B1CF857E012C4EB370BA8295
+55B50047CC8911C98FE1A7BA6CDEA82D34476286E710776823690AD333DD3A49
+335002F4680DBE1C21174BF016B0DF799B01EB9D6988479A8334BBA2F8DC7146
+BC0DAE9DE3A6453B181808E68A89E0C02DAC6264D002B422EBC1CF14F65D9888
+15EE6D514D3457F7F3C6A3D17EE1DA076F73ECC392D349174DA9E4680F29CE10
+0157E42CA35F5DBFF56BFC3AA07E61A78DBE882C5AB388220C19750D3643E7C8
+23D6673027CE568A4ACCE1D12B1D9E5A43507F4AF9BC873237F65A6B95078DD2
+378007CF0F0DE7CCEF760E19D6D1D7B412EC5D4972
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
@@ -833,6 +882,7 @@ dup 55 /seven put
 dup 56 /eight put
 dup 57 /nine put
 dup 65 /A put
+dup 66 /B put
 dup 67 /C put
 dup 68 /D put
 dup 69 /E put
@@ -875,6 +925,7 @@ dup 118 /v put
 dup 119 /w put
 dup 120 /x put
 dup 121 /y put
+dup 122 /z put
 readonly def
 /FontBBox{-53 -251 1139 750}readonly def
 currentdict end
@@ -905,272 +956,280 @@ E2A1732B3627109EA446CB320EBBE2E78281CDF0890E2E72B6711335857F1E23
 0E73843FC6619DE017C8473A6D1B2BE5142DEBA285B98FA1CC5E64D2ADB981E6
 472971848451A245DDF6AA3B8225E9AC8E4630B0FF32D679EC27ACAD85C6394E
 A6F71023B660EE883D8B676837E9EBA4E42BA8F365433A900F1DC3A9F0E88A26
-331BDED95DB0237E9B61C5470AD852E6E29B5F064570B12D665F0C33AD57055F
-6FE0B6EDBE28218F8B98D3477B80DDB7AF5E54E3DBD387C9BE1F9E4BA77EA434
-7957AF06C0342A30CA7C9AC24343D3A47574364E08F82BD3262E67ADF671CCEB
-0BA31264BF2D61DB6DAC28FAE50FC5DF06A31019330F0AD1F299C4DEAEE8D689
-624EF2DB936E533FFC6A051BC12261A989DDCD59ABE84B3CF6F2B610AECD0438
-C154D212BD8815A6034A0206D8D285CDB252D5E3BBA981C4483B96B8B47D90AB
-5EA6EA4F1A1861FFE21D4BFC72C602925C7F20374BF6E40920C88069071D6ACF
-751408C1C496FEC4742AC7DA8CE83D3BBE8D280384187003E7C2247ED49717F2
-9D98C30EC1682A25E75D97E8F6BBAD3FDBD13B87F3629215F2F1C7BCA3B28186
-BA81E8B1E12DFCC22958F1528A5D0F11CAE8072E325F3353599F930DAAF6EF06
-EBF3DE7C863BE41D79053307A0871E836FC490DA6647C1502A341F3CCE58BDF4
-61DE65AB883B928904EA784C317B17C96B43705DDC48A39A1EE2605C25A05377
-0671A7B86AA10EA2B4D0FD8721BEEC55513B60D08D1D888DE22C809C2069B540
-C15F543F412DEED1A1E97E4C7278EB4546A6BFC9DE171482A96599E95872EFB7
-2BD89780A837B8E295057E80F3EEB241FD1BFAD9D3D03F1293A77EFB286893B2
-824AD4559512360013E7DE370562EE83FEE293B715705C88F8812B2D66F1201F
-C907CC0F9F0FE155A233DDEB0002F27FEF0979D79CD637BB6F730522FB4CBFA8
-18939580E8ECFB7CE47E35D37303E7798657D64D55B876853D396DE96285C454
-6F41BDE6913A3CED4257288B0F0C642529A86FAB68FA8B9CA272B55B4566B2DD
-110EBEAF3BB5C873D1D76EEEB8CCB3C191FED4F040ED96F4CBFBD2CF7FE7EFE4
-EF1B460301CC744516E5422E5FD69B54034BE6759D76897FA10D18F8EA2A51AA
-18A8DD9A9E5A450DB518935E755013C8AB6CC5CF8D40FC7A29F24040A8CDBB5A
-B4637B2426D380A01AD509A019E5C6E322CBDE419C2FFDC5F3B4B0B582EDDC15
-BCF68D106501BECDA54D547D8780A252F96290F4A85F0E4B61F54D3D0C33CFFC
-91BF8EBEF523415D6DB53EB30127F0A591B8AF198BFD58FD338A39B773A5AE9D
-8FCEF3333127ADF5A6C60B993D214797B3C6C8383B861D8D281B3570D243878D
-34EF43BFF936075CB88A8048643B12834EE9F98E8203B54E06A058C4A700CF4E
-52CB641058E97813A06FB1547270958D32C58628992E9B04CF94AAD437DB5676
-C8717CDEA5815A79B6258D35594B11BC4015BC243BC302220668B2F02DE9FCF6
-1136963F935C8DA3D180C0F5FAFC28754B806CD7B549EAC7C01DF6936766DD8D
-1C78ED8F5AFD9A1F968C7706D7C0F5030E6E94DBA0D1BD7A308CD7C97EA087B7
-019384B1F083DDA5375D5664B0270B4D531ED7F3806B0387EF3E1FA9E69A67BC
-99AF3BD13F7388F6979C3D07FC8C54171E5BF9BEF5F8919A8701EA0D57218128
-BA96A9BC78228269C4332EBA7F6404715C3499B8DDFAE50DE50DBF2BB49A8E1F
-B1FB869F7DECACC7BA4F1724D6E5923AB8F6186F7F15F5618364D49C92BFF44A
-ECF8F461341AE5F5CA8C6D5320934B95D9AA0D7B3CF516FCFF9B70CEC1E28E8E
-C4E65F1724E3F71956EDFFA1BEE98AB6F2441BBB20927530876BCBE33286B892
-D9D08ECED8ACAA4BC03869428842892A9CC6D359FB188462BAACAE8206D74B18
-A794F517C44BE4CDC696C7ED62762413D9DAE71DE3BC48541CB32F9468734292
-23A752E3FC08DAFBB8C54F9B7DAF4D46321F50E2A463649B48B817548320A738
-6CE61D1FC8C6CCC0DD680FCD7C82DC85AED15A2847947329D4BAE36206F46B1B
-F7E62EAE00DCFF68A99325320FEFFF254E8FFB6EB5D9D4F3095D89D20268BFF9
-9BCD60CEA4CA52D1BEA82D8CD0F9DF51E0EA1E4BE5AE4274B613054C6558F76D
-32D5855D2878B3EE448BBD9E1AB289D61B14A2881ACA235EF9F9379C28544F47
-ED3B0CB09E879E3BE653A86E64B5D1ED9457E22ED728F146770071DF60F54CCA
-E5BF8D7E4F6179D70EF0B9DD7D750419C4BBD29D7C1A5D53235C1FB99AD0B219
-489291F32F4597430A41CD44AF00CC35B5DF474AD857E1DE42587545E29A0736
-C8951DF261EE18C932908C5B4F72F6B891A883524E3F407C76DE813D72C97829
-6D833FED096EE15AB25B201FBA3E8F85865D992496F97AD5147DCFE3FD1923AC
-23FBF50DEF544ECBD965B542998D82FCA8A804F76CF928770AFF56723822E449
-37F31E10E444B8A4ACDC9C4EE969712F39F462ECE8E694F8725D7448D9EC8146
-E8C216010327842FE2F0F0B83E806EC2391AECCBC8154BDDF3CEFF1CF95E0663
-21AFBE1F425319860BC0AFCEF64ED7DB29BFF9C0353AFDC89E109CA334AF6805
-EBF0930AE87694A2335B2C6DBF512E6A3AA189C7F15F37406B809940B6A01AC0
-A906D9A1D7C0FA0586339359902055276A2909EAA088E3888E4A002C48579026
-C3951EBD9C01DD4868EDB87E405BEDCCE73B452238AF8339B74C2407D2BE42DD
-CD7FCDAAB4A974039D2A608C1DCC0B51580C1D4B842D22D46A74F5C03016B004
-756A60C05BCB5A52D432779D7B07415408131666F6F2E7C07C45A5D5CD1D0A3B
-F452FC0D7A16BDE8197EF6705FA7026781F56FAAF20EEF5A9E663D3DD3CB7BF7
-1132F6D74A6339B2215369A1698D6F97B759476999AA3966930397A7683280A6
-0A9C035FB58F5CE676DE452A3A8EE42AD1D8FDA1623C0EFB0CCB36AB0C365086
-F1D88EFA0C2A6BBE7A0F3E0565E20FC1B55C6745AF5E80A53546476567912B36
-B1940E4AF6F690EB2A1A3928CAAA6375AC66912AFF4F00F1E4C71BB4206B7A47
-3A0E8229594A7E6779A096F4A09AFB8CF0214813C863B131F70541DAA6A3D1FE
-C85AC96B683A3EE0FDC895E93CC8AEF52824BAF947EEB484FDE30EA7CA63D11E
-AC695D8C48FC4CC61CD7ACAD0ED4ECA30B08798B694D39DE042F2F08112BE7BD
-AB0B5EF4F901B9A3EFC8A1EA67E97C3F955537279A1721ED230960D74EDDDE9A
-E55B2E1AEC4DF5FAC3EDD7ED5646842CA8D48BF9D0AE583082BA529616442029
-FA2E3BAD31D21547B7235060688A0025EF73118764F215D10F0927EE92990909
-6CBD57971B5A1C777C667D6CEA6B9EB8635D18590FA24014282794184B4D594A
-F08DE8B4E386DB3476D6F91E35B3A16980C59378713829773FE88E4642F7203F
-E088AC1ADF305D9885750041E650C53FAA9764109A8833EBD44FF0EA35B63F93
-F2442A0144BDCE4E81C5F26D7DFFC3BBF3EB74CE9FD2F1EA8BB0A6D4C553ECEE
-5D3FF9146A892D6CF53111BB22163A3069838EBE7F28EBD9910FEF88732D5802
-153C3E260A9377A36257796F0A502D698A07365FB4AD9518A35F63EA6391C482
-4210F0C018BE26E8068C7265756EBFDFDE57583783C4905BA40E67216F43EBEB
-AA797304053AEC28B4CD65E30A87EE6B659F6238528A76C0533099E2E9E9AF7F
-D73C908224573F803F8D02BDCC09C8BBF6760D67C7B419CE108A3A378C378AB2
-19BFD6CC0AE1ABCC2D3326DBEF73BE88FFD19EFD84A0876F35B8D0049252CE0C
-5E4748773F69CA6DBF0A46B2BDB5AA322BA0E67C67CC406FB85409EBFAB07977
-5623033FAE3F98DC0BB467556A507601FC2C6DEB6A4E5987A07081D44A603AE7
-DD6B77FE7CB129D29598D3185A4F810F4D9AF89DBB864F6FFF3CD63EFB9C25B4
-8A292E7B30F15A106E2F2DC9AD16D70113117C2685A89DB772A3036D69CE2DDF
-FDF7652BF26B19FBE61D8BCE4CF0F0DEE010076A3EA8DCF18E6C30553EE635F9
-0ED1BE177E97CA37BAA80A6E4C92CE42028AFB9787E6B4563A16BF2FC3AD1E28
-3DA673E1CDCD3F0A7A581F14FC69449C0926218D9D1959805AB12D995DD3736F
-29DE76AA90CFE41D09BAA36B9326EF98CBF928A59677C8BDB13425391F1C5411
-559DAA8B37CC84CD600EA651139F9B748E406F298032638D8EB2B5E29D54A7B9
-79CF7D8FF9C8F12C961C4A8564642D3D3ADA2B4A4E43F08DEA497436D36E5730
-D71EA7BA106473917C332A305D6DA42AEC88F23AB130A5DF36BA15378908A005
-9CC02EE957269C11F0DCB374B31B3D8CF2C7767AFCDF21A3ABD2964E66FCBFE2
-951472401FEBB4D474273E1359A7C3825F26691E7764D7A070948CF96CC553EC
-CD61883492BF1755E8453E1B7E1E3114400CBDF932EC3B4019DE3A3E96DF82C8
-F433E56911EF61C475E2C04D615B3AC56E3B8CEEF8CCDFB71E8DE8A1A87D4A34
-BB15FCEF462B379FDFFBA04206B30F102CE7A01545250A1B6EEB2BF6BB5DDF91
-95A19FDFF07BF8E3E96AE5787CDBFAC7B7A9237ADD76F56A433FAA3A1DF07EF2
-A30E8E5C32156D4879BE8D57E9AB0B54E3C9307D95C3125F291F237DD1521500
-C1FC4F1296D9815E95972544CC94D333B1110FB172D8B103D03550533F05432A
-53D290877CA7FF907453B941ECF402348CB52BD49BCA63F9E73283C0CE43B13C
-43824A0CA86CABD6602C348F6D713987DF4F52174685558E8ADC613296322653
-65524EEB8C5B2BE22D4A22E523683C1D17B73DDAE508897E5F74D384E4E14681
-86B1EE335696B94DD16B4E5696AC8B756ABC3A43A700FBE6010E76144A17BBB4
-4C31C479DEF78A83EEF29DF98F81C58970279F8606378CB93F2068072A33E78F
-9B1ED42B28A7728D41E0D17FA3B3654540FD1BA52098D09C7A0E9B8A1C16F3F6
-8A72C687FF6FB6DD6A2326DD268248E9F00B4565A311696D94522C3598A0A2E4
-FBE09BA585B58DABF2CF4A325DE9E2BBB9D0E92E671F7FF4C901AE0F85A19E95
-CEE012C1F84256F582BAD52C392C17147E2503749FA82223DBCCDCECA6FFB222
-78CEC9C70BE09F0E503D9DE4EDF5D37A8D4C28C042A6CA2F3C978B1AC5C18381
-485779098F8E7D7D0896B092B3038516B9089FBABBAD2ABDB6970A4CC54F0887
-73EC8C36D73032949ABB339F2F75129FC2BDD6A396C38B47AA5363F69C24E1CD
-D562AB4A41DBC4BD0059BA66C3B22B93DDAD00AB1402B622BAAFEE9A3C3FC4CF
-7E8DA4E599F532FE3FEE7BE362164FFBAA3CFAC9E13EAEFA567E95390C0853A0
-12C135867AE57BBEF8714DC6E1D1FDA96D467CF3363233E67892B8641E119AF0
-E2852F1084CAF4D413686048BBE5898BDC94CE402FC39DF4113E9AFE72B925F2
-6A9479B9EBDA7E41B9FAF03265A52684775F08209DDC47AD283F7CF047CF54C3
-300334D354920AC3D99BB3B90B6CFC335E91406486180F11110918652CE06623
-B007440A5840A5C07E6C1EE91DECD4210903A4DBCDC3656A8284E9EAC89220CE
-03FDE218AA083592DE63096CEE6AB33649A5850DBA8A5A8BA81BE4A7A1D0EBB2
-97CCFDD3D9B844D819B5AE02ECFB8AF8C547529CD18F366245E35F4D19DCBE36
-0732806A0960A5EDC94D9CEC474A4E1A6ACBC3A3169AC11CA8E537ED145F8DF1
-3D92A6AF0E9058EB062A8E24BA9EB2AFA6E55274FD75DBBA0B30DAACB5D1365F
-D94755913EFED97D9D99046FD1510FD00C7988DBBADC79CA2BC4D58FC7F57BFE
-C178954C7A7BE7004CEAC4F578684AC6BE864F07F1581BD4316140E2DB6D9752
-48E489D9941020B26867CC9D3B8D914B4B20B815ED2471E98DF1589319B490B9
-49C6889D4C9CA326405025F5E81E45474FB223AC462C458BD205CD16D0C0787B
-9A49BEAA3EE20EA98876A75BCE11DCC527F3251A6149882062751328CEA38038
-F6043CC565A40ED88C7CD9154E257A1DECFF10E2010BE8893BB346FD1ED3F5AA
-EFC896F013461D9C60AED9A7B890D32CAC3B46C1D26980B60E4BBF201F83A18F
-6F2598F5B36E87169D64E79B8F6FE33C852D3F4ADBBB7960018ED13D3A452831
-4F9092249711E9041AA8E96BFAC131770D1A8EB2473E535B923F590ACE92F1B3
-7E85136844598EBE61EB1114A829303FF0265F82CCA35043611646707D861D9C
-4630388BF108BA8BECB4E7A0C2678637AECB627435B3212D9A02CAA74262E138
-1287009D2C4F39442B94B612B6A52ED75BBCA217F7CBB87097F3EB2CF2091A5F
-01C77E78BC158831A41A9AFC082DB8E6CB737BFFE009E0211CE0C147951E411A
-CF7F248F9E65C6E915FF3AB3AE8DD0C26E098E796ED96C0D3681E18A633B797D
-2697CE5BA51247B7F326FC0F9E9230B3B1E365BCCCD7B5697463B4CD5723D6EE
-9BA94A00A0DC00BB32EFCD147FDCC8B9E1C150901F95CD86B3D8F6509B4D3F00
-0D8803490ACECBE83EBF982DEF98CA14CBE15B7AC36CEBFB1C113F64EC847F63
-692F6FF42E0BA655118F0A1B5A8F9E7715DE526FBEB6DBB21362B005728CBFCF
-69804722C2AAEB72BA4F22BA7766E5D03E8AAC2F65A405A3C1F8560A4BB7ED14
-943820737CDE893B04D233FC6D91731ACCFF5757EAFDCA8F14B84D2B256DD8DD
-CA3FCE647E17484AFDFF61F6906ED894664BE2B0C71F378EFEFBE85F31577EE6
-1BF59FC334B6DB4B26157FD08CE5C0A05B91510FA718168FBD1D61BB7B1D51D2
-ED3810BCC5F0ABB94631A1E0204ABF2E5659A1CC0C93AB0C9CDB8DE518E170D3
-5A83A26AF036997E35A423C95EFCE7CB49AC770688704CDC35C51C2D7512041B
-66D0126761D1D37420B2AF03D39E4A9792646F3C7A599B229B287C486E224289
-DDF3E51FF96A05008EA01B2572C587A772D04D9EA1720049E09F1931FD47F7C9
-AFBC9B8CB882992B2C8C21A098621AFEF5B3131E2B18366CF98AFD645B31A49A
-99A5CBBAAC64DB7154BA7BE0C2750F82A578B55C8882EE305279DEC40DBF0C97
-CD8E53006C2B607E6C13373A6E64B73139ACE1B63D75FB129C55772B925B3383
-07AD3117E6626E2F58A3BA59DF5B61E9C095878CC3F5747D26A0D1ACF7E047C3
-1E07A2C0AD57E1929ACD5B06EB3479E68A06ADDFE809542A8D0040D5644B0E07
-B8784D34881354CCB1C9A10E4FE1A015F8922A1E8A659A20DCF647F57DFD432C
-83AFF6A45E10D98EA3A50361872A0725601F8C235A76D91BDC613AE5389A1FDB
-522B87301FE3693A6132777752BF3F5A548EA9650319E6A40F98699465589898
-B6684A53284D10055B56BF35E3AD5308EF0537F487DD7E64EAF76240BC6AFF56
-EA8F46FCBAEB28777AB47DC8ECFB9EC4EC93406E8C7AB2CB73657756A75D26D8
-34B14F7D094CE337458582B38D98736BF8162B036B053FB32CF1D857D2C6D8D1
-E8E774809C4E4B362143D50281DF45FBB2004D274B5E109F4798F59D54EDA2C2
-F677E5EFE97293B0FAC30A4EE5CA4BF10AD7DFF590432F1AEF7129F96C0BB72D
-55C2B4894C5A3A2F1AE47B799228D4234CCAEABC8C02D2E35E136DA9A8B88E73
-63F5C7DE5967175BB786D3AE8F85C01634797025CE0CCC2CFF85EAA2452E8AFA
-8641A9FC52A9093E22884571CB60D218A8DB925E2D986C71235CE7DD20892AC9
-8E7A94AE50E8FF61119A063B63FC06D68DAC7A0D37EB647580201FB4535E55B0
-85981D5C4EDC6BEC9CA29993EA54DB801A419D01DAB3A2CE750D4769AC38E430
-C6B3D61E6C4B2679F22965FAC6158E379002554628DEACA52E05141BBBCBF0DB
-8D964A8F18A02B88D1B915A03F1DAAA03F72358541E1FC3A865D9AACCDCAE1F5
-0AADD4D988D9011E86BE0BD1CB9876F393F6E41B4E0E529D78F7A19F5859B18A
-D0120194E6A9F8FC3623C42A6A520C03F94D37E0CB12A1DCACFD7EE7095E0051
-727A53A4957CD04B68A120FCC642D229BBD8F43C49935278C6FF2B177624D2A7
-C2E22BB61BCF755D3C4CE52277A1F861EA16D86E952CE57326FB8863853C50D0
-3E8BCB808DA0F15C9F1C1B1692C7B86193B9DFFE4034387CDA4A72D8B8E848C6
-0B3CE779F46BC15CE54149954DA50703EC958EEA0715D322B2AE8FC57A247BC8
-1F1FA97F8409E7B8853C491B876E3094E718D458AAAF51E6F53B2B05B2E9ACB9
-3E8AEA0F4A142BE3482227F9455B2335021A7766F6E77E8F2F0A7669477CF64E
-EC7B31C9FB1A1C0C2E2BF23790B5069730D1F9AC504B0B91FD4069B52B6818F9
-72CABA82E1C6A24C69900BF834229C8C8467D88DA0DACD75C8CCCD0189A0F747
-CE5147FEC1438C0D1F41B9BCB21859428C680B5FD8E5EE030AAFAADCF3532A82
-F2044368D88F29F243547C2AADBC5E5C5F49CBE6065FFDA0B6EA4269D4A46E3F
-6ABCCE1C12BF137E8B9324BF4FEEE6E5C96BDE3D32C568CE8794B44A847E8AD5
-80CD8F393260E7D53A1487AF07A694CE90E922BD7A546714A6F5F75A687C629E
-F505ADD53589B060723C7C4E9B65EBAC9F727156752FF66339CA1DCDBD863CE2
-9C8452F44DEC412872D5B8520F3C56EA490DD145C24E867DF9AC8DE7C2411B52
-97F3BB231CDAA7049873B4D33A5C6CE088EE383CA458EFDAA36F176F76F6C6AA
-A8197E4D2CAE615ABE711FC3C7170D40FFEAAB69A6CACB0C86C4E991A1DD9684
-AA8F1DE7804706FA92C96D181D4E21C2B7DA5631F4F5B9D8B80656815B9B8544
-10119F2D66869539028BF464070B7ACDEE565E618B52B0DA821FFA2F7664509B
-1FA0CF6D74A2BE783197FFB6935879F005C8CF7CAE763E770DA5CD249E139A65
-69E0601144D9A74EE1C3E584F938C7542E4EA00A5831C0FF5DC5F051A962BB6F
-E428FBBA007404413CF9BA42B4316A74585C222DB756DEBBDC960FF468ACF80A
-5FE03A001A14A0CF25FF30C8B6AA2DB0A4B7A3D97764F25B0BCDE21F7FAD3C36
-F6FAB189F96486CC03607F8BF3B34D445F9C989F0AF13C872B54E065321AB81E
-B494E9FA5F8A87591F5603FCC878728199BC3E890142165DA4288A112F9E4226
-D2DC9E257C4FDAC017220EBDF3E937DC32DF1143E2A09BC0CCA076E14640E276
-A3D2EEF5AC6EAA2C3BBE57421E755B8E71F14B7B5073CF97C3888637C2B1E90F
-5579AC27A812902DF5BDE0A3BF36609FD9847F12ED4F2CBF1953B6C8DEE0634F
-8E1B9A1EEBD223FBCBF6C213CBB17A93E2F793058D8A7630C77006E886D8739D
-95A0ADE232C7F861BF4B495C41BAE5E044CE9DF804660E202A3D25B7C9605A26
-2DB8D6A0896D3E35B2D409C532D685F800A5648E005A372F7FA83DB360A3A55B
-2622F76809F067A18152815B0FA3243A16D8593FAB2B93B2F7D018E320CF1A50
-F143D987656E5F1DCF3CCCCDBF65A1A4E77C9C69F16E1D1D481CD30400C53A22
-F499E1236D734B3FF934CA2E95F99F5485019C2FEF28E3F209F92CF90F223AE3
-F5C1A4C981FE2FEA180968392988ED006CAA90FAA6DFDCAD597B2264080DC824
-DFD24E764E93974DAD1B8B5070A10A3E0A731A8465860D41C77670C54B70CD8F
-DF96D7C8ED6D44D4401F5F32E3E66B6BDB39E3B20D4970483B4BBC054D1E00D8
-DE980B0280F950EDEE7E511E8A4CD9A02AE72C296B4E8AD941648B2BCAB7D11B
-5557A4FA75B71011B99E82881B1D8AAA5496777117CA616AC0BF974016132108
-E3220B9F620F15EEBBC33187C02268FE2B1A45A59A4BE6BD1ABD8EEDAD8B9BF0
-C0A6D2295A0F0DD1F0363813B4541D9E555817C96C44CE53BC27943F80915858
-8CD3929028980E7219026BF864842C07805DA8F3E164313259AA11FFE7043382
-7012F180EE1EAB9C014CB481ADA3F926172BE01BE1599CB7279431F66CDC979A
-E3D5A27D4E0B54A9B1F6F252E741EA3B49CE9DF89AFD8488FED2F427DAEE13B0
-2E10CC0AFD59234DE63E1BD0103FBB5749D0A134CD7F50E81F4B1298E344F6B1
-DD8AD742E0D4DEC6351C8F93759A2F91FD8E609B7E559B35E99AEC7932F4812F
-D51269ADDA7E6F6E368D15431A61C4AFF095910A0FEB7890BE646D85C927E5B0
-65455C9EC22DDB407D5B7BB16EFC6DEE612429845D2BDC8EB4F245B0A75AFAE0
-2DBA00A700A9AFDE5153F089C08F22812CDD8F9BD6C126D586768AC016139C21
-5EA2BDACF12033A6CA3A1AA765FDF22B4DC0EE235CA8670FC3C2EF50F3D26671
-BA1D0533317E0B8840622FAB5E820CD8F88F296DFD224D481AABB4216DFCF496
-AF559D180761201C0DED7BC3C682F59E47C5EEE39F6B352E33247EBB40A86517
-713825D53604733B59D1993CB667685AEF11E496BC4662CDDE8612AAD0D9F0D8
-49BCAE4AFD4D864AD86F666C2494F35D498A9D0547B01003231AFC6F033BC6DC
-D4D93609CA26820C4B418F3F029A363DF0EA10120B4448A8CFA982145E144C43
-A6621200B6E53BCBD79172FED756E5EB82FA5135F69C1FCBBEAA96CD6010D688
-7C3B0E963D155C86AF1AD1778159FCAFDFF8285E45760DDA07DD278D4FF0DE43
-4BE63F60188D74479479FE8BBBE8BBAB87F7F1CD3365830A37998E74DE0CE5A6
-A78AF21BCC1D2B4642DB0F85FB03BF99AAD623926EEB99CBE1FEC85C6C5FEDCD
-8551D7E126AD55B50491CD8D787252F27B3D0A6D21C9EB5349E338794C1C55CC
-AEE49E5BCDB720178EEF930EF804C4BEC1C5271FC190578B4C97AE17012D6734
-CD1ACC8A77C3AFEA4402402EBABBD696199A4A6DFFF124CA532F1AFC98698EA9
-5F7039BB104B40D4263F6AC6E1023974D3B404EC291038135AD5FC8CEFD7CC9C
-6746CF3DCA0BDD2D8CCD281098DEF29866324DF5FC1DF77CB4278DE6D91EC527
-7B2732B29AC9008856F9F938C29EFA94EC53914F01E1307EE83E15038205DDB7
-028CDAE0D7081D9C04B27407DA0217A9A94BAD54B85731B0DF36A8E73DD7D671
-B0AE588E224A8F408432018088CDEB1566038AA96D3ED603F5CA47BF391C7D31
-FD2A05148E794CAFB5B4C232AA0EC9B9408CA6A000C4C2832A4E1DFF05900370
-A489A1B0C98949692CCD69D01CAB740789C10C624CD65E5F2059571F172525CC
-B5778CC3EC149970333917BB8DDE47A13C4DDDDD5676638230ED7F690DD0777E
-16B64A0D4ADA9FA24AC45BA024FE8745AB43176D4E07244726D17BF31CE1D8DB
-6F1377B9FD95963A53E416C43460E93CE055CADB862C8F4B52E85FCFD3ABBBC9
-0CACD134824F947569C3FAA3C8343B2BD37B30A32878AD4B0446A325B98BF673
-FE3A2CC118AAF9534B2D2507BD61E88F11761B7BAEED94A7D67722392B02A5F7
-BC087D50ED2A0756CF91D6736D2BB1CADA53808D2289042819D4D27C9CED5FA1
-C35BBE221D81A9A9131FF943A28CC467ED62D35053A186259736E6C9D7FD7DA5
-EEC80323CECE7B088EFC552C8D670BAFCBAF94EE00BBF0C25E78EB1195486E49
-7B2DBB1783B54D6C875B76E67B862DB13A8A8AA9FFD7F3F4307E92A3C9405221
-6A573BA75E36A692D42152F9EAAE18874CF0161DBA6189F3C171A2E4544DD8A1
-3299793C9F39857611F6DADF508F0677DAB4C80DF77B5562A4BDE7A4455494DA
-E2D9DE005C39DF0C57263476E8EDF3047BF310663AC42D74DD77AF456ECA9CCC
-05D2447EB53CDB9E0A8C5B109A539BB719E6C9DEC658AB31D0EBCB5AD4B6EF69
-F14EE379622AAEC73EC504EE8B58C6031AE339C7783BF5746C4AB4EF38C81521
-6D9EBB75B8263BC37A2D2AC805FA0AD7037020525746B08F4D17E0516E67F7DA
-62935F8855B98FDE78489E792ECA0F66A0CC09D14F51593596D74AABB696A56F
-36D35D60F3FA0CCD6504F860F4C43D4FFDEA459CF3B4F0B16DD1AD4474F303BC
-3C5D4FE502B67B9B5892CB78A6A2D07726A47F7ACEB522D71B2B2EFA3AA36A26
-1313F77D6C788BDADB19493D155C4B01D8CB485461E2FA289417797D5844AF1A
-4761F961E9C71AA37073754E1E0DA4C1072F2B1E0186E72D3941E38846BA1108
-B138E4D12F822FADBF33FACAD121A1C1F57DACD87E8FA514AE813EA5742534F3
-75A24787397FB08DFDC21DBEEA1D51A651E82E8A0EF6356A9DDF97380C46F118
-CC8E23CFB1B8BDFB6416726313AD1235D01F172869B78605926D9BB33AAB54A0
-ABD6A0E79D898FE0B439B6332A7810A85DED0F76003095258651AA4FE6378B66
-843D5452E74F364D6CEAD6F83354675BFE3DA3ACBF72DC61BFD0093882C611EE
-8574308D0470EDD8D4681CD2FE3543307515E5B9505E36B52BFE6FDB1C1BEDA8
-B2044A7DEBDB522A8FA8151B3F75F55ABC65B09BBD96FCA14C13C1FE16FE5025
-2DD7F824492E250CD0A65FFEE7C48FAE8A22258CB4B7A829F8BB3C1D72562F62
-5C1960579109F89EC3E58EA248F7BE2BA2B34156D7F63B3F78A2EC2D
+331508EB5EA0129B0812E2B888CDC3CF50E799B35D0997A9D3EC69D785AD6C35
+BB0583EDB5FE7C28C30C34A905F11DEC9DB163C9B7BABAB718B7A8E7B0553DE1
+AF58738452D8733E5FB18A11CD4D57984F7E8B7EAA0845DA090C1A0F16EAE609
+CDD36788CD8EE8705DC743566FF343117647A7E83EFAC76F8AE39330AF1E8FF8
+A1AE6672B17DFF1B292E36990B96BF85B304D3298CF4AA460D574EBEEEA4FB0A
+EFBBA3F2F3818146B79ED15B2107B0043FC4B7C70284B905A53EB2839F552B99
+AEB32C52B1EB253538FBB9CF36F6027A4957016BD54DDAAE87FE899B6BA145C3
+8B644B84F15E84EC63AC9BA05909673CB2506CF61B3FE6FA59A75D98FEF28E49
+9312882C8178DD2D25201E10289B410122D815ADF500A9CB2B64F91FD1FCFEAC
+067358FEBA4CDE3E7D2AA6C055FE9C61A09CDA39A89031FCB02658B542ADE7DC
+D72A92D69AB9B6BB54FD76B1FC4588CA65EBF1A7D22A8E50337AAD4F1536681B
+151D6AEBF8C37F10FCC5C0A1CB1347D705E3A6E1084DB853E52979AFF0B2940B
+E5023565B44A990D82028FE506E4DDD6D0083894E6A83683961B53454504569D
+457C416123BFCFDBA9C29F1F383F41CFA8168892BA75C4F76157E0D777A7E543
+820458884EBC03A3527310C7966792AD248AE4F837BE54C117571D7114899B05
+5A5631CB5BB4D8616ADA849FF629433BC7FF9491913C475B41239541EA88529E
+96E9CF03AA174DA5F26272B1B81FFB9280657992806891F052F943ABC0A28CC3
+67B4D322596B0BF3DEEA82DF844C6B23743300C37012CEAC9749FC278C768F91
+4CECF64BE2C5D36BE78FF9FB534CC53E948A8C7191C6B185FD8B7F60654775E2
+77B98D26B27648CC84C88D375ACF0539FBE640A316651C26E090385A6BD8A7D9
+378B45D7B9F5FDBED80F307E957B98246DD6B59B402AB6FCBD3EDC423179D494
+F0A2878FACC2631A13E3E3577649038782F650C7C71893E16D1543AA5758BBAC
+18A0EF1531B441814C63341AE77C2764170779F6B5079CB37B5CEF93D8BC912C
+6D0AF13DDC1B89929C2E04071C5F23B4C80C39FB1CA568F1933A26A9B37A43F0
+91BABBD85432783909230C7E764A74C83B0DC9827EECB591254918F5147DBF1C
+5F8035C016722D36BAE202405339748FD247476A877E7D28EA9E9AD5A1A3A6C8
+4A268703D68DE934FF8EFFC264E55113EDE195E48D6046659D54D582E42E3E6F
+31C5B6DFACE214F2468624486B7C1311E7EE8CAE02265F40021E79CC7233F6E4
+2B61455654FBC8171DC35DC48E0184DE334F54D116AC6A84BD5CB993A6A3653B
+175430DD42034058465C8735E13319E5D8CE9EC9F8A527F6C4C3D6F85702F79E
+59E1EF197A921DB95C27464B3F2A08D0E880F30E3C88DE4E8E690A0EB1528A98
+F5936A07816B37ADFC44D0E81A6D06239F22B34A284E102054AA86533BDE68BB
+B0104F0FA81EF25CD427654850D42DAF4062EE75CC74D6662DE7E85FA96807E3
+571EDF162C017F9E8E403DA8B1F68F7629F54A59313104A17A9DB2466A03A36D
+318C1F1EBE532A56FE1B16BD08735CCF98C2FDF179F5164FB598F0AF8E120433
+9AD5BDBE4F03FFAD457D63A0606D5C65F1D7BFE7F27F2AD8B33B33F926B0F734
+7F464F8978EB6331A344CF076B12ED4167914C1E3DEDDA81DCA7CCFB3FC8B221
+5A5BCDA699B4792E8EAFF32F1521A8E4CCE84729B3C03882515680D1B4043D55
+2DC31C7BD4252A6449D9D1B1CC70BF69B14395AC49C2B233844A8A9FDA1E0F22
+85B4B2E490A67CA7E2FFFFC30A2B9F7813A430A9106F258D3BE59AB1E0D22D39
+F5A4503B8CDF418D2D4F25B5544D92557EF9C3D5D8D88E40927E5FE1C121F5F8
+6BFAD87C38EED25BEEA229DDA2E9893164D6C0AB3B7E513DFD93E8D4C67A1FA5
+C22BE730D035F0AFA9DF7E32A07180EC9D66B061C291FDA89DBF50F6796D9933
+C945B0D822E1079518850D54814EB047E64AB6C92626548185F0A20153056C55
+764974A54CB7B798D3B571AFEE438FF73F4D398A72526E9E08C468172D8B0F73
+DA0F2F2E07F900E45966726822097F6991D5365CA7052D144CF9EC7506CD3A66
+8B0C935D5F748135A70EF3D7FD900BB9C0C9D355A3066B77659B7E938F519DF3
+D11331283960D21F426B289B1425F3BEF5EA53DB9CEC31A376490473AB3E70EE
+1C80D3309BF09ECF910F4FFC766E1E8D335F8E0136ADF71DFA990700411469F4
+4FA674A051DFC9DD69DBF015C4854B1EE881F086505AA7DF696440A43BE2E4DE
+73CDF5D7584C8B239F754CF57F3B3F070AF9F1400B378BD4AE5E894DD0766248
+31666BD29D655F84689C96540A97002E25539B8DC5916F57CE3F662D0B141CB0
+CBF93E5570C206BDEF2521C7E80EF6D143C7A031CC721C22B51AEA6A99898CEC
+E81807148AEC9A9BB27F139307C17BC265EF674E1F5D0A314A3D82D0EE516635
+453A53520DFB87292AF8CD39ACB718C9EBBE32658B2E78A1FCB2BAB05CCCFDF5
+0F1021F19519640EDD4879F3F1BFEAF96F049D6A29656CBAC7D73F5BCD48BE61
+E3126E566F662756839A28A12AA35F918F1BD42802CADFF08880C457A4204E84
+39B74E7699C2B52681D4BBC0464B668ABAD126DFDF9620D3A3DC2579EDBEDBAD
+7EFB4B18D044B6C44C09426D926FC144BF54B0A99AF9940BAA96EC9A4E67BD51
+DCC9B8BA6F374B4051F88439A5418D2BF7A76F35A515C2D4479E07B531482650
+21177DA0BF946CEF21F5FD9C6DE01A75B6BB369AEFAFD26B0D24C496BE3772C1
+8D035AAFE18FE8773C0B045971652AA3DA7F4CE9A98A35FA2898DD0453AEAD0F
+B8D49BB9A9BF154A443B26EF6312FBEDB0581AFF33FF3E0623A06C0D37D2175D
+4A39E94FEEE5A49601760518251BC1053386BF2A2CA2519FBE304537CE1B10F0
+5A49BF52BCFF3E5E9899DA5D343BBCB6121AB2B2EEBFB2F5C8D75143B9C46371
+11863239F41ADABF9C5DF1F56F3B6F58EA027261DA2989E69D4C85864A9E2ABD
+C06219875A2EAB7FBA31EF8A419963F56A1794C7AA76E08505F4F69ABB1C8F2E
+7DDC84B60924369FB02276255C06592C3CBC39234B809F1E98164F579E33BF72
+9BFE3167E35D34F294849A5EC8B8D85E9CBE4B855792978B699A14D00B8C4E5E
+8243F3F253DAB290A0C31F0F61B1814016A51A6478EC75071FFDFA8DE171EE55
+558F65EC06BE4C61EFC10235CF8A67729FC8539B54E24149F40F156150A0E3D5
+ACEDB6317C663FB4D19351D1FB66283E31158C68F559AEA59CBFBEC8EA532A0B
+3E90AE9F7BD9FC88367B1BA34DF3FA6322EFDBCF1C9EBDA04EFA09AD50BEA044
+9D40863676648BA884D2BCE295CF78C484E1190CCC075E20036AF0DEBA4F3146
+25230B84531D3472109F52A7985614FD2A4BC7BA60CFF2B40BDA929F655CF041
+427B9DB5EE3423136F99BDF25AA587342C2A3D4259F9AB301E4950C77FC22A82
+3F14FEB80C1409F769F59A57DF18CB9891CD781114F67C91192870597D2AAF25
+C7409745E69C51E4ACFC57E17C062EFD124570D0DC03167589B3E0A479659D9A
+458F1FC8DEAB9BDD8AAEF79E683442F387EF855DA848FB2011B380236D34CEA1
+3989C37BFD2CDA7E554DB0CF2173622732E006055B93E680CF302DAE3F099A1E
+3CFFEA42266D1539E502BF51BFEE5BDAC2BD89BC2FFBF2370FA8D42550C97122
+2381B61CA5A18AB1F9DF2465F771F1941DA7DC4ABFB56A74F6CF5B599C17D303
+CEEF0DECA46C6026E6B450930A55C6D22FB585563A664368E9DAC2DC8A89FFC7
+339BED3672C4673518F06A3E11E82CA6A09AD9EFC62A8317FC48BB42FCE7629F
+58F23E4B0F2FE4B51996F3472FC776CF7AE9AA575790B091A195ED09B7CC79D0
+C6E9210688EB1FE4002C049B8019A2B6BEF58F8E4BD6C417E15615F8ABCDA902
+B3BF7DEF24505F7A343B4DD2CDED0B0F3FAA8AC566E02F746D8ABBDD50D5184F
+CE04468013BEA580EAFE461DFE50B4EA9442C92136C035B6F6CBED44B74EF6AD
+E80B1804E5108AE194967BDF98DD594F652D2DD51FA089D68B1E4B0C11D0662F
+708FDFC2D42C58A11E07494FE0187122EB052FAD53B747BA27FA78470A400C57
+A1299756081025F330FB88B2177E885191C3E89D97E3ED9742F93D9A67CC53B7
+6C65AA92DB402F2F4AD16CB273906FEF6E5FF1E70B5BF7E2B6B09D0AF93BFEAB
+B39D35788EFC09B2D1CD3043CC2BCCBB94D831C0E2318D56C0CEA05D3B3F8358
+9C52804BA1EF1AE81D4F7FEF8B92DEFBC93FEE62BC54578AE37D217A23CC11DD
+443DBC496EA4907C896660D15ACEAB1B71529B73E95B72E57A8150667D482473
+1B49E95DE290D1890DC6A2A4FF8B45BC2586C8EBC837DCA20238CC3D0798B69C
+48E2AAEE91B44C03091A07514079D3492BD927CD86DA61E0D144C13D0FB04B55
+55B267D27D6B4322CA8054EAD1B08E6CC6CAB901FE0F3133341C27FB84F3B11A
+FB79F277ACB50D951CE1DFAFC85A1FC0220CAB8E388814B5A3A0F4C357250723
+15FB784B01ECA0A6C01824695A8D1419AF48E4A10999B47E5431DA0FE16192BA
+4EBDD5F421D392C29E4807DE38DA7B95EBCECA19D08F1B18EDABF3EA50F893AC
+788817D0529A1B7965C0EDCBE31686412248D91B445E794A1D147D302D2F536D
+A6F1369C3E38327F793FEC3FBE23DA622B4BBA30A371503B63FA7E0005C7C085
+FE74FA0782F33976BCF1A787726A749928B07857E1141E2F9F3B5409B79F3B10
+7FCD1297F9C354A19BFBE7FC4531F2A943B63C1888808002E2915D1F7BCD940D
+C070AE31A3BCC518780262E3B57B4BEB9ABDFD86874F275FADD8ED869EC06ABA
+575980D28310CEBDDA56CAB85C7EC19E84A7130648C08A47807207DD47B9B048
+44CA4FED53ED41AADE6AED80E3F5CA649285D6F1EC77E4ADB45374E8404AE74F
+D43A290F32BCC677A734E8818BFB9E648CF52A81184E7A9BF559235D9CDAEDC6
+F9CF50A6510865216E67EFC78CB000D973964A5CF5F429E83CEEE3FDB3998546
+23A2E1B20C14E44E197B94408658A6EEB362C3D4BF6306E1485A8D735B556F04
+DFB7848B5CFDE0A03247179FE97B7D93E20E637A3E1F0905B7298509EC9EE81C
+5CB9DFBB248B73A91A470C31B79ADA893D409DE4812F878DD067DB645EACB250
+A25259C6B0B87081EF70DC70B7217A46B31892850317EBDA2637EE3E5923EB81
+F09AEF1DF421ABAF1966A336CC9DF75AF2AD05E0F95F34C84466BC4A09C670C9
+5A3AEEDBFF99CCB05A974A41F82B2787C65B7BE8B7A85EA906614D87B3D78AEB
+1694B1D927FC5BC9F156F7AF721DA1BAF76E90D3CA0891948B04DB4ACDBFB1A9
+E860EFB9B643F461C4BF1B07A1D55FB9AC069DE0C2C79FF04449C1993334175D
+103DC7FE13658233C0ADC2ECCA6A40E832076B834CE5DCA9FB6B690BFF2D46B7
+82DB5ECFAC9471F06277B8AF5A8CF54A00BC1D63C828D2EB41EF8A9C30D4844B
+EAD13739A615400C4027486DFB643910BE9E39084C6C4C836BABE5902B61A2B5
+0AD3AFA3BF4B1DE1C24C35C36DC4C6A454715ECD86EAE58BA245622B099BC4C0
+5BAF04B2343BC5806F6A7627BB4B58038840C8C990679EB066A89EFDDEC09158
+AFE52E8176AED1CDA31C874ED0E623EA798B18A3F277C7BA6C80CBA2AAE9282D
+4132FA086A32323932DFB61B48CA9828D10428EC06ABD1EEAACDA3CC6BCCA9EB
+13D866A227A56B1502728779EEB75C06309843D4E473DC41B6DA0E8D6D2B6EBC
+F9B9DC28AEF402833D035A8915CBA05F6E87313C51128353B04F0AAC6BFE93FE
+56C0328D0B41123EAFF4E994F8D9E688BFAD002773E78BE21548AE4FC5FA0325
+E3F7F4FFA96FD4DC29A82D335A3512CD4FCF892085A524C9818F814377779B3D
+FD395D6CB467A80F55D5931AC54DF8FAC8D685ADD195D7AA57CCA5E84195F716
+E6F5D3B9EEDF03905D4E453BC4D6CD16E80A889BBCE8E929FF0776F00E052015
+D2144C0ED590901CC11045EC712728EFE0B179C2CACEEF04F37373485AFCDEFF
+C8FE723B4BB2B5F3BA91010F392DC1CF49AADBBF529A61A38549B063F8A85CA5
+66254A6036E67DDAC251112FFBB051D32C3E52CE7A47052AB8B3EEB5FA7B85D3
+DED00EE565AB2F5D92AA8105A22020BB3638F0D3C3E311F236B87CF3294FEF18
+04FA0F914DD858D8E1B50D9F0B628E27551DBF530FAFEBA012F743D233E65453
+2D06D761BAAB99E946FE8758D5F078AEF38BC0E987401DCDF594FC582C88A80F
+068ACBB7B0D8B5CC55C3F81BE1F804C878B2A88507F014CAB17319EA6D1E7815
+1BF80DC5EDA82A8BE74F9B3892ED6ECF91972BA1C5323B6FE30AEA497A8BD6D6
+101A2B5D3C1C135DF4A2C5EFE8EB00B5A39878E983DFB0CFB65BF349068AE607
+E4A8746367508B3DB8E434487C7E0DD59D21E73B82FAF635C9C944BF96180692
+9145BDCBB9474AD2CF0445CE75089AFB3AAF1F382261CF9768C9E72DDB94134F
+D51B6CAB113A7321BB19237D87DB741D709D30C02CC12F0B1FE154051DE5D335
+53EC80BA069277C69E64293BA17F696C6B6A8E1A49E0AF9C80295B404FDF61D5
+15915D63DF1070ED77F6C8A72798FAF7A9E8CA06FF7C34058E1DF6DF2F78BD0A
+60A001B4DE939643A00782E335F2B650DADCA0D472E372D7EB69D7CC33A209BD
+DABDF28F5A6B57050D9AEB71400C6804A83D6042CFA1BBF3E4DDB135843B87FD
+8B3A90BBD26FE135751DDA74D3A58A190EC0D65BACF64D3847CBC6468563B847
+1375D0B46738B8A5E993E656EAF70C2B845D92621EA7D299EC0472709689BD8C
+CD0C914E4282E6F7081895E0CD61973B070E548BB9D644703D1CCEF37EE55690
+2A199C847FBA2CAF763858C7EFC1B1AB81DFC8D7EC384669A2359B8979DA0C57
+20B3696449B4F314F5C735DD48045877F014A66C9140567FB2C5E32D85A65F0F
+79F38E573D17C161E9934178E9EB9BDEC96901048E4581800A15B851F5EEC233
+F4CBCFDE5FCC516477531BAF235738DBF76490DE4775FD6DAA27873814B4E55C
+E9A18B3CFFB7C955D226556E82930FD5CE22EED90F82658E1CCA205C16E431D1
+78F6ADC91853BED7F08D5A0EE63624F5B3B7CF3D84E9051172215828CA11AF8B
+9A7E0529B0F765CFA39CBDFAF4E2BDE8B42F862A5B6EB81D17D11520F2EC5963
+8BF5FEAAF989E2F788FD06223E33889CAACDB6583A5DE8E6C4687279DD26C6D9
+6ACE03EF6F4DCA45B6D706564A9D3C4FD980DD736B6731CD04EBD360A977E3D8
+268B0C8C17771A4BAA1E57ECDD1753F6B2CC616A5E987A3602512F1EEF2F6687
+05C78C0D6FB8F3FC97718B5EE2F3EB70417C542EB55471660E1D5BD19593D057
+DDC6E3DFB28A730B3A5A5E8807DF0FE12741AFEF64B768135028849458C982A5
+7FD84DEBBA672C6802A0660B9D1C0CAF05F5945C82CD68696073C7FA1E69DA49
+1C96523AAAD110AE1FDAC90BD3B1B806955DBB4E6B39F1BF095A835C684340C0
+24FD0DFE275F112E29FF78CA1F5AA1DA666A375EBB2314E88CE92E5A0E332742
+4E3A47A9B18C5B22E3435649CA1E146BC429D791ADB58AEACEB9F0B5CF72C039
+A18859BD622529A5878F8C3830B59677B4B3E530EE07DA4A04E3FC9EF4F69E28
+818B3C86AF5439E955689A3D5EB4614945A39D43299118FA4A6A0495A0878FF7
+D88A5739AEA11D11EF0BC09DF14341EE973E7BCF73CC0B6B3DB6CEDA9955DD2B
+66602196FD3FE44EC36C85E8975583468DB9789CDBFEF07FE6C7DA6E27530C04
+AF64435DE75665E3B452B87E7EBC6CCB6504DD509EBFA07A94EE40826906C88D
+97BB26957268217A535AE2FEDE196D728929DB901A7513CDC0BD31722931EAF2
+C6EFEED4F60C56E558595E204310AB5F8EF645055D4FFBB209132E8063711F7D
+94C97AE8C2A06C9D3A7B1B4254344672239CEB439BCC2F961C62E29DE9B4A304
+B486F37BBDB4CC837423B62546B792FC3C238223160CFA32BC9756BCEB179739
+31DCD955C42AFA139A0FFE44180BC8BC0FC79F78768776AC122DE97D10ED094F
+2096015F91FC2E045C817F8F5F5CC466661361EC2DA988D6D57304D30FD86692
+A659EF3814CDCD55FC0857EA0500339C6C80902389E55CA97A46DCB44CB12EFB
+38705CC1937C0C5BFE77D03901965BD4700B88E9FB3BD9791986B5966B0A3C62
+41592C2A34DBDB5CFEA0ECA77F18B30E082B133E9D08CB7FEE8966AFC3918DB1
+65DD71E3A6D5899CD1C8DE132439FAB79D1C8EF20E2B88B5907522A9D3A7DF6F
+A2A0EE613D3E3DD7E8A548BBF05DAB69D9D9F2CB4FACA594D4385DB40AB44C73
+C7CE2A36547E97B90F8E98A3E86DC6ED97967CFB7E438011D05714067528B547
+ACD35F2A643653F6B2FDE2A216953C2A5FF6B78CA47655218771272F81E9D78D
+B09AF5F6DE4CE302C0D23D2BA7DF2280DB586D2667E112981F2D10DA7936B0D6
+4924AAB6A2179F213D0DBCF8DC3E291621601D84BB5F26B7B74E88B63DA807AC
+4AC0830655065A5C14B718CA5561FF0ADAF7FCDF38B817FA6056DD6414675BB9
+54585EB05B8F725C9C9A2F5093A86F442445229ABF287EDF9532DEF5C8AB2B5F
+34EAE1A3DEBEB0E9BEA8D14CB774F1BA8E4A5C1C2BF2161977CF61E798F81CF0
+9EFB6B1A013F1E6BFA2E49FDFC45F733C9E163C363967F1606C6BE26B0831678
+6BB6B4AA463CF6A819E1C98EE0647102A4275E7AE74EC151E047A4ECDF8CA056
+C2F223FBE22F6708FC0AA5C43544F77AD87A1EA607E33DCA06E78B0B090572DF
+2F893B8B8B6D303A2EED30B4183937F7FD13BBFC9DCFE62BC7FBD9E6991B3CCA
+AEB41AD2355DBFE6B928FA6E6DDCCEAF7C1BE7AC447C933B9D760C2D0556A64C
+7FD25BFACA2907AC992D73281262E49A2AB177C827F113886D1F986E477ACCC8
+006346098A34069D942A89B7F4FAE640A0816D9D499A02C3DF30740E0BDCC75B
+770698E9C1B791D4A9D12867FC985C2480C9324A88663D8D51E97D1003FE3DDC
+3016B5379EC43313F5725A0A88D91BC77C8B6049706AE1668490C4BFC8AE2529
+18720CD3AF6D788B2F818CB30CAE9B36BFC9BF4635B8F445CD4DBA4A5E604339
+833D438D0174FCEF5B7B6F2B049A423DE65E284BBE72EB264587FDDC319B7A4C
+44BBBE8CD81BF545FE9A65C526A2D9336A888B8B06AC7A337D2280787CEEDDDB
+4357FEE5D21AA170B16B0AC6E8F1E629C00871799E15F36C7AC39A6C034B3F80
+C84BAC46E3B13D05F9D5845B459EA3ADBDD5AA5206ED6F94C9240A6F1EC1670A
+C5462B6A19658C3BBE2512B6F30804EDC975D998596CD938F66B13A87EC19A8D
+7CCA35789448580ED7808B171915999D6A801F1ABF14685AA7DC1C35C5F82E4A
+18E4429A5D332086DC37E0B5278F7C3E80D538CF76287F208FA9716EB97C4D27
+30893C09302275D18CA65EF626319DDB88FB2EB4D6F6FDAF96EAAB9E35598FF7
+590996885F24EA89296EE222675B5E7ADBFA240F41D893354234A9100865CA8A
+BD00B9332C841510D4430E9F1B5C0BC473DC8D352A6D051F1E012A7330238977
+7D424523D83805D8C2CE26EF4496ECC42D0CDD55CF87FC27CB1AB4BBB5A78BFA
+FD6C153F80A7136FE52144F0C6AB9E090D1687FDB44E9C5CEAE503829E917573
+EDCFB285CE9DE6C0021B98DE596012EE82520819767A60CCFBD373F96EBA9F6A
+D2EAFE944232FCAEAD2373C62AAE00D5C4AD3B8D22BE1941159530ED3296E4E7
+AE46FE268ECD347E7D66E9369108E73535363C7CAB03B15B95C3F22149AE7B57
+EE820744B53213F89EE0FF3FAC8355FE1072A7D8E90CBF8FFCBA5F424E42D689
+B04E3307CA6599C698A02E2DAA37A828498E8B9D2381A5B93D165E1D72EC127A
+C9DD180AB549C6E79D276B64D035962824F07AFC592261C6A9808180F2CFAEA7
+02C05F181E51BB3FC95D0337C0DD162D0134001247A62DB9D1BB35F91474442D
+8281951862FFC133F315DCE51C384FAB089F0AB28DBCF3EB0FD9A6DEB89CE61E
+09912B68461D62030CFFBD449032A3BCBB54C62C7FB70AA5CC33A012586978FF
+2B91477AB295DE59B1A97498FD9FC938D6816CC23CBFABE552970CEC3ED38AEE
+64BF35FD5BBA70F081061B7183D413E51725C19A8DE85D7219FFAAEF2F796D70
+53976808EF20828531F6C46ADE650EEA890326501FCBD70AF1196B04F907A0D7
+3B466A638033EF953D77EF24F423F250BF6EF4B86253E25128D8FE1AE551F696
+0879D4067CFB13C47E3EBD997CFC6519A06DAF67BAA223E251919E9F135E0A94
+4C348BF05666A067EE58E86E72839A33C2CD3C9C1EC1C696CC42440AF467A1C3
+ACFCC7DC39204ACFF23B5C4004965C9C5847B7F0DA0B1E6ED1483BE9F880A57E
+6565FAE827B498C4ADB4523C6DD91499FDA732FC2C84E33136064061DF4EA7A4
+A55C1503223641B5FD03E45829D64BBEB4AD6BCD1B8EB2A2081A11E9A926A71A
+7C157A46CD0CC4A39CE32E086A92F4B28F251E6E3A91FB6258F6E81BA3C48503
+59BD96E26392D1F1F245CD5FB4B5CF7D1D581A68EF7C3B58C1703EE9451AD863
+662CED26AFE62EFECC93B1DF2DAF611EDC1A133E3C1E1723B4C378E9544A82A2
+2CF9856708862603431CC87F313EEBB83D1AEF2AEA31A6A4BDBDC640978EAFBC
+48CAE3010E3B33832307D6F94C58546AB68AFBEF9A4B2C51449AEC04BB457321
+469BA70A2914F14BA70153287818E12331A0F1CE7D18296088469BAC169564B0
+B2774EBFF627E0AF0260AAD06AAA09764A1C2C1F80F76E65948D8BF8D0BC01C4
+D738F99BCD84611783D6A543D4CA1924482A596EBBB112272CE218872A56C6F1
+69893F40B36BE39CE9F7BA3B5ADF4365D909E60A4B630F3007547830E483165A
+7B3DE584BA674BE0FF06F8A555FFE7D7AFFA5F67939F34728CA11B0428469A17
+2857889C8A472EB5055918704CD48DED7E90BA1DD19499F5464A0C661432EC9C
+9A9372D3F1A89F631BA843D5F0ED8C85C4AD0D961B716AA4237E509B2A2A25B0
+8A9A77E737E5032E9664F11C3F0B2ED6D5A67F5513ACD3EAA6643F365694CBBB
+EB660793B95D97E4054E614460837F77DD696CB003F01C04F84A675E31A68CD8
+9F5F48BDA2CA2FA3289DC5A50E33F05C946CA4BCFBAB13F72D50067F74E88540
+9F8A037553776B8DB57A38C87EE715B29F41CA3870C17DC55470B76DF779A567
+BA8A6C59F3FF628E29EADF817CFEF29FA953CF457C700F01402A4F21BB2AD515
+8A11787F888F7C7ED07DF72CD2462F86999D1E89A47A5BEB94EDA3D49F923E3E
+F13963C7368915CB2CAA6C4E8E523BEAF44FF92B39799030BDA82D842913067D
+3E8DE13B9E476ED30FAB3F63401BA0603F76F4E61923B2B34279E04F1997061C
+159888323AAD58893B33F89FAFB9FBD721EBDC66064B6C549048DF3A570CFE04
+BAE3673EAC21EBB65B55064799CEE8CD492BD5CF52F6438D271D3E3DCE96565D
+710EC4F76FD51261E7A3EA2549C50ACE245DBF93200D33959FA31961FA969D12
+74418C4E4BAD1B4970F528C6B61D7135CBEFEF02893FF168282194B83953B3B8
+A6B195D8C92EAE838EF255C561D27364F3324863607CCC0D07E0030490A0B8EC
+E098237E6CCA354332E66B892978C2F7B4851F784032E08D8F6DD2965BAE6CE3
+D6825EAE1B98F0C9C6B7EE021FEF2676DDA02439C42AE6736E32C7BA50DBF04A
+038AF23552B506D9C68A0F364ADD891077C8B36B285DCA3216C3B3BEE11D6FB0
+7871B2A3D9A7E70877B68E717C988877C4D8F669D3C7FE65A648592824B1A4B5
+02FE3134F48F5F526CB4EBE42F7D3464C340B229C49B322E1644E6A6E9FBF031
+E3E5978671B495BE9CF768A6BA67F0D394B794016B0A2CF9D4A191A996D66D67
+B6A89A2EA7EFA0D14F7A9951C01A767781F162D06ABA6D743FE824C3219075FD
+598614E04B2F94EA17ACDAAF2CC3EFF911BAC11D9A2F58AAE01D1037CE098105
+0B12AF8CB203125D9020D7CB524C1E1E52761D4C6FF230D19EF47E1C02AADB50
+08E91D97241A85CD94E4BE6F25694952224A4210ADFCAA1B0D5332365448022F
+BBCBA69DC8D3257D040096B6140420492920D02DB1D6C489197A03276283C10F
+AE103C7B1A6CEFB58908EFBB897913EF6AA5655FBE9E2205A53A696D4A57AAE9
+832698BA4346FC9F1DCE24C405E59D44CBB1CCD9D6B9E263D3A9E842910D4D58
+452816E85F482B28C824192372B782C188D8F0413A27FE97C5C7681BB59214E5
+1DF8FDFDFEC46B8149C6576F839D49D02C09001DBBDCE252DC0F74563D4F98FB
+647E7CA188058205F75339DBF12F5A2879B8D3A4917778CCEA0009F92C1A091C
+B332907C1DB5A52AA32CDB62D2949D93F11954786D76B02C44F5EB5DDDD1E09B
+2E5F317DF8C8717CC6EBB614659E4879C1BA25E3D5E32C5250C20A2E8B662953
+516C1556BD15D85EE2BEBFD4502ECD297F0C457B288152F67543A376BA1D71D6
+FE4F6A82AADAB1BB45FD2CB58F3E118BEE47873DA1
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
@@ -1257,10 +1316,14 @@ end readonly def
 /FontMatrix [0.001 0 0 0.001 0 0] readonly def
 /Encoding 256 array
 0 1 255 {1 index exch /.notdef put} for
+dup 11 /ff put
 dup 12 /fi put
 dup 13 /fl put
+dup 14 /ffi put
 dup 33 /exclam put
 dup 34 /quotedblright put
+dup 35 /numbersign put
+dup 36 /dollar put
 dup 39 /quoteright put
 dup 40 /parenleft put
 dup 41 /parenright put
@@ -1281,6 +1344,7 @@ dup 56 /eight put
 dup 57 /nine put
 dup 58 /colon put
 dup 59 /semicolon put
+dup 61 /equal put
 dup 65 /A put
 dup 66 /B put
 dup 67 /C put
@@ -1362,412 +1426,450 @@ AA0099DEFD326235965C63647921828BF269ECC87A2B1C8CAD6C78B6E561B007
 97BE2BC7CA32B4534075F6491BE959D1F635463E71679E527F4F456F774B2AF8
 FEF3D8C63B2F8B99FE0F73BA44B3CF15A613471EA3C7A1CD783D3EB41F4ACEE5
 20759B6A4C4466E2D80EF7C7866BAD06E5DF0434D2C607FC82C9EBD4D8902EE4
-0A7617C3AEACCB7CCE00319D0677AA6DB7E0250B51908F90A32C4175B6BFB279
-024EAE1B04D721A6C54FD62484F8949B2CE9B87D9CEE04DFF82BF14931B3CA03
-AA5F701B6F80BBCDF2C427C40A51597F0B1BFA25EDD7CE0EAF2EC676BF0059B7
-15DD5462BA30DE78A08DD533DC0E8D85F9DAFC5FD842F417265427E0F1B71834
-D2BF6EFAC3CCC40D3EF3B2E2080F148441BA45E5D0C0F7D8416730AF4BE4FC93
-1E965594E0364F0D4F1EC48004CEBDDAFB1F0EE0A8222358EAC0F62E6BFA3C9F
-46875EB4C999219B91E6147A49A668505667030CDF3495682B79C0F614AAEE68
-D976EFCDCB04127C0D7325A2211E49CD316935A0B472D1F9FFC68F7FBEBC7582
-036CB393016193A9783DD08D647E89C5BA4EFC8701BCCB6A5C027C4FA8644C06
-251B9E33FFEBB1B84AC4D4B148205C8CA7AF5EF97F2788EFB0B71473AD0F5EB4
-FC43F46602C53E53F5A6D1E445439F65967C51EAB636178FA377DB2DDE5FEF41
-9E91F3BEBCFBD3B4EBB510A0DF7F4D19C6552BC98F10E25612B1396020D7836F
-A3D3C865661DB276E428F09F048A916B4F07D8FD01AC1942A3CA342B0E531BF2
-3E9A7AF265ACE1585E331A8F8B5AE06FF085C1F349215581FC7D68D16395D934
-79B3BD866A4BF33913DEB54B4D00ED5EFF3313FBD1C5E6AC430567872BD935F2
-AF1A3F892266CEAC15DEF43BCB83DB075A69EAD7D2EA53303F65E04C5673411D
-EDFB32156120099AC210E623BADDF2991F96813AFBC1126DF53A0A776AF7D61A
-6B42225A5AAC1B0AFDDB59C5922143A156EED76E3E1ED01ECC6ED9F61B5711DC
-C5709EF5A3CED45628AC1728DFE98F07389777E04A7E407E3B007017C96F6EE7
-D0FCC0426C4D734A0B108FD2BEB48FFB6D107C5AB8EBC3584F13A40E5508AD9D
-5A081286BFCE1D5DAF5F3D86515244B4D0D77AF9820A93B7C90420FF4B8D634C
-2C5697E3E04802E2CD7B9AB8368F1A9DC214CF893AFC7BA3A8DC24B0E549E106
-F04530708DD03367D8501655B1501645F17E547C1C948DEA7A4814F22E2A1D55
-5AF16C55D6BB4EE9929C9CEE82C4D6A16D70D17AFBBC6551BB2C9D8B69F5DAE2
-5DF6C2187ACEB119EE6087BAF5E79340D115C53E710CC7E4C771F43ADE91D2E1
-1AEF7BB2E6C9ABED010A835514EEB6C9A2C93396FA12E8CD0B2F9045587E51D2
-7E059224A889B3E7620E57AB6CACFD769898B3955661824DD4AFCB9A7B218DF9
-F84B369F52E246723C7D0B26C145DA0AF81C83DAA091143FBBBD2A414114E34C
-7C994D8401119D5A46856367EE3FBBBB32155A00E5314641288A6E1FCE47F385
-71C2F7A7602F777C11884DEFEFA560333458DD227E63F3FE68A762CAB0A7308A
-FC59C9B293233DFA257E5D10BD5F12B7652C45C4C50F14F17E59A758BD7355EE
-A89B1EC954B86642B87F814F936577429C467BC8E97A481ED15E2633AD73830B
-DDE3DE50E1EC439204C7FE350C69494823725920719D613907163AD63FE83C6D
-1CB6DA81A6C816C747542CA09493306B44A7DCE934B877DD356F38D07D3E0355
-CB149BE6ED646E84DB9DB61859F6FC45BCE13EE42458D1991AC34AAE6EA72320
-3EC6346C38CA87107618ED3C46C331623D8FAACC6CF9292B8F1B407806A0D480
-8F51A5BC97F9DA77B70AD89F15168D1CD6D03C0C8CDCA6889F94956DED0BADFE
-734B830196C96F2A602B464B7CC1F84C1B43804B43383C56A4DFFBF49421CA9F
-C96968A727B52233E621366465F367B6250544489E0F2962BEAE409D22125156
-11ABB2BE5C66DCED5513A374AA07900DABE6170963935305FD496229F33940E0
-50448D4C46FDDF7E22AA0548BA72303D0E22D810020461944AD14E930E3585E3
-FE89A8DC9F75125E96D5915A4FCF40C9135F73F17C75E4CD0936949ADD9E554C
-577B4CA002A194665B1BCAA17FD03DFEC951299C511B31EA5A43539CDC7E3CBF
-7B7B1A420F0ABBBDBCB3A7C62873048A63FDCB496F2DE6CCD5D76FA56DBD56D7
-0508B3993C495FB5515557FD54178C7A509999DE4952BA329761EA5C69F6D790
-73C8B61CB77A9243445038EACD775A07AE9844BD93B636D37C8029E38A7B5351
-8D8AB7B86BA9C1F4AC8207614789908E9AEC8FDE6EEA3E9233918EE22B4CB5E9
-169C0E118595360A7B16E7FB13CC3AC68984260B36093862CB8A3B87920BF833
-257258EA992CCB954C1BB9D9927994F6AEB786F8731EC271585FE186834A6F71
-CB656FAD9D04E4CD7EAED405C691E5A8AB93938393950E7A321820D8B5B8D96E
-A53F01D44EB7119D1F0F4E142BEBA118D1747EDF157A57478E6A6B9BEC0D535E
-29886D53A3C002E41FE97FE56C9ECB3D9AF5711F7D0E349E960E3318B8CF19DF
-45084EF76622DA814160AB26D3C257E2DD6800E2532F66F559B5E2E113651F8E
-A49AAFAABBD5E07337BFA6826661A6BBC4651E650579EC40E4F2C994D302B128
-65E44D0084E1B3BE1FA80394427E1E79CF6F3662065B03C56E65D3C2E118DBFB
-2C985BB5296D97F14AB74DC43BB4ADB226E0E445EB9B2059CAD707D537FF4738
-33151609813C0A8E8DDFA0A447F6E48CA0F9F4430723D2985A1B593568B7FBC5
-A31E836744CB2DCFD960B722901757F69CE8012A0421DE83B02225F556F1E491
-06AA686A4B8724181F8AC65C956FF66031D604E56E1B55B8808DA2BAF9FE4B9F
-4A13D429423694D13634EBDB7E9EFC567C45FBA35C46A5C117FAC75933EFA08D
-C39BF1DEFE8EC72C9C64C4CE3188DA7D8CECAD67737519EBD2888988CB39C25C
-91BB0E21584676F94D6BA6FE27DC525E0D27532F6B144A72A9D61853F181A55A
-80250CC5C7A59BA6D4DFC60000240726DE878534C60571766D0EC238FF5068D6
-8BDA1BF9D3F3E78FDF266A83C4C9AA011BF065D1D36E0B8B470B7D5FF06EE5A8
-58892FFD0D166B9B2CDC117C89F75F62B5FA4F660C4DA0A4006600F81D60C064
-5C12772717725E68580F4A588FB02B1EEC9989E1AEA53D3B034895CF88824C0A
-7E13B8234AC04EF44D437C9DA3D80522A3C1207B794F96921A82EDD4A195615D
-D813ADCA82706C6595A134A5C9DED2B15EF0E6B920C7BEC45CF06C99EAD9A9EF
-A511A37F6CD86F785918F35545EA199934E5AACD854A29F8C690C486FDA31A7E
-781CF707930C3A2C106D03F53FBFB4E21D07D72AF24769FCC9DD6EA587DEF7A7
-AC5D62D807C28D8ADF974EEEAEBF97316CD2BDC42D5413B8A3D8743C1C4D8F8A
-CED82ECF94082AA666B342AC7DC5B140F7FF248D843B64764973E850A29D4BCA
-CD6B03803861E4C96ACA78B1EB807626E942F24C1B7FA4D88679480F40FD5F59
-7C40C253F1BB7D050C00376ACA5F45151E7075F124E3EC93E619F33E4A226F27
-CB5F0974EAC8889B7D46A6F53AD9E4FAFE94BB99450AFADF58ACD6C6DDC7BD40
-7E4B94669EDB229304C732F2EEEB25A4D4FBFFB8DB9156135D8720117A45907E
-7EA08315B5889B33DCEB805F5A07B3C24E11DB4649023981BC349822094B4E87
-DD5361168F6EA61B9734C21493F4CA850E2997B5F1D6F090C472E07298C28270
-2B36A99EB2DC13563CB1EB9AB0ED97B70AF2C23943FA398A7ACE4AF91FC0A191
-EB6974C9981ED59991B5B1A6A5895589BB6E930423C6CB212E13BDD3784E6D64
-003725B1C71210BCA7C599017E06D467FA9887C7A4E76B181F121EF28E4B7442
-7F63481778614D5816C84FFDB5B5B5450ECF199A97E23078FAFA474C37D0B73F
-488FAC068554C90319637D59C35E6BF3F7891D46315A2FBEC42E0D73B2271A5D
-01D743E63555692088ECA50D5C61C8D99F74CA6BB79C680B212802EFCEFFDF5A
-C02FC0C10E6F835072A944CD67DB04E7EE67BD86D013A9E5B02BB19940775BFF
-7F0A2FFFB3B747562E70AF3061407AC041639C783BE0285B064A55FC6D8E8076
-3293625DC5C209961881AF08EB6222C9C0BFDA710AC40011A582749F53507D81
-C9D41390CEBA6C9335B90567D0C92CEB9869C5FCAF2732249A39F5B64924F140
-0E6A9C24892E682DD2C3631B0FBCB43C42C42472299228BD289761866DEB91FB
-F679135CF0BA744827E20A4BD4364B7FAB05187EAF570991F6C3472748799431
-9795B0EA67C2367C24580098B8F53F542391890975AB97F515C6268159C424D6
-0F5BB0AC38FFF2A92F3DD3F56160A0788E2826F51AD17E49686F83381E49553C
-921A8A934D5891E20366DD2E6FDD9726687377C8C86D434DF63FA65459B64F72
-95F17A53C19F6DA977EECB1852C14169FDBDCC3CC014EADA124E66322EB5E075
-1A48527544928A3E3635D58D4A204A386D9620BBA9F79D78C71826C6BEB8F47A
-FDF42BE3A7E9A46C0334CB5F5EB526841918FB1941A8C29EAD33BB9A5B213C57
-1BC4170581D07BFF8F7130030AB7AE70E2343E95B973136CB90D9C8F34FA7070
-0B18934F33FEC980B9E64053CE5247900E468C23073193370F7889D848CA09E8
-C2B27723014CFA21A1F11AB364A2969CFFD08598C675AE69E99692B0ED712201
-B224FE298C536C8926230A56BD252018A4F8950B51AB3AB8CC3C84A9BAC6D7DA
-A26428B386B59A4491CD6B023DDFE08BB82107BB881CAEA51BC544395993F865
-C35770B7148AC054A05E890AB5324408217B4B18CF3C64D1CBFBB1553F282433
-843BF0BC8B17B9E226EDF449793653B0432A858F8AD1BB701583B04F52E02189
-2EA6939C66E5D811753FC6EDC5C63FBBBBFDAAA0EB1E43509959EEA8F29AB64E
-1995D388E5C5F985F4AF05105B90CF4D8B86878C3161F20E535FDCA4D16CEB49
-2C6B6BDF5CD95BD960A032DAD1F171495B9B8469851751A87B03D40858E785C0
-F4D3A6B383D8489D885C15B242C7129BDBF980AD7AE35AC8A9C3F59DD153D0B0
-838D78CBBD5DAF07761BC5A597EA1FE11F7422AFC90AE6BE4B5EA194CB1FA4AB
-8FE9459553F14D9BC6D983224C0466D23E69BD6A4895F93311F94C9AEDB86283
-EC1DCB65C6EB4FC27C80991E0B4A376B37D35FDCCA9BB9EBB22416C975C11C17
-A836E7E0A7C57A0AB47E277420423F4A2F16DE70A6C769B7F46732FDF9A25BDD
-971DDD76F6983ADE51FAFA6F73B1B389D7E617BCA7BCB211969BFF6562EFCC66
-321959D7AEEAA17B060A9208EE48A77EEF3682D3840E1A7B85F488A3D442B107
-096969B74065E8FD6A555DCE9B1C6AD1A38A0D075D89767F4A1434EE7E47DDF9
-4F01AC190D0919F09326B64B49095D68271602F4CF1F3F7C1AE24988DC7363CF
-824CAA1C1522D821EED54538D2F51E441196016EEAB3C2B89E4C86D47C459460
-C8A31360747F3A18693124AC5AE922E6F8DB46A34739D59C8B122A5DD5EDA1A9
-479A33D31832DB903312FACDF2FC1B9BCDD6424D829DC408D291375164AA7D91
-292C4EAB569CE1DF38F58C8821B1AD1EEB4AE79C2C90E96F39CD858593317CF5
-C5238C22D46210894B65DCEEE3A8DF2938ECB8FEB613CFC5F18070C317900666
-7E8F340CED47F5C2FAC3F12655FECE48AE3BD327099113A60FB44A1B44804067
-6F0077CB7A5541FD786099D64DDF863485B04067E2756EE0DD3394EA19B2AD26
-F201CDF8366D9C3AC67EFE72141583F7E3ED4575C9EB68070FF54769F3312614
-C12B060385A426614A0CA80755FA3356C7CC864443598E2B811CD9A7359F893A
-A86A35A97BA9D9517ABC7A053BE8087DA7001496BDFF9169285A68C7F97C6573
-F26B2A75394764A744FCA1DFBDD5E78B513F69C0125C662A5EBB630E2EA67E12
-C7AAFA10DA1A4A88FBAAB5F81FFB162EB8791DED68474863A6408B7652DEC81B
-69921C4E6287F4CB20D45A891AE933D67D0FF5FF6195665FB227BFD9492842A3
-2B2AD33B586398CD00803742AA050D5DC5F095AC562CADC68C6F0A9A2614A00E
-54BABA0DF44819DF2A06BF1DEE0ABB7C2B20511715AD92766586EBD1AD92E0B6
-6CB430829D432242DD30D0C9F8B469A5CBA77393D3196D768E2024AE3383BBFB
-927B8165251E843CEBCF39B5887DF37095B54E0A61DDA674A306F6BD03EE1260
-7DEA68675E81FC8BF1C718C2542CF3CD091AF816A7A237ADC66CDC52C1CE9029
-0A275CD4C9738AA31B85360AA56F95BDB1BD27C3AA0F89E33CA47C3E5CD93D25
-BF8D63E9C88025B98E99B951DC322D90F2B9763FD9028D723E3951D2022BFFB3
-600FD7550B6AC7F1DB0543E186029C517A73B76F087A79064100ABA1E57E1F3F
-59A4AE3CF2EEF27DC5E0CC02AF9D46412DD294E386379946C3BABF378DEBB0DC
-67FB9450BA36C2FDDB9518ADDB5FEB32C6932218ADE9D5C776ED403AA8B68369
-78E738A20D784E3194F949DE82868F30F7D396C2F018ABAAA2352301B1D78C96
-13515CC41B6E3075FCCBDDEE39FFE0EA878B2CDC244B48476D64713B4013758C
-8FBFC361B03EC0F3FAEC47FC38B7B2BDC92B32AC42B76A0D5B83F8A24145FB44
-4C6BBDF751C02616AC35AD02BBCCBDDF76EE802A3BB06329DCD7230583C83DC2
-C8895AFAF34999784E12A43A3199A4D0103B45DA3168C58B5F2FD9A40E6BDCB6
-491E91901A5FC767CE9E33170A5DBF6F6EFE498BF7B78F3EE81C3377B70673B6
-00B435CC71F7D49177C39A66396DB1C3F02844AC9AFD89D6635EACCDD2E7E57F
-B60A2F04CA48ED7A8980270CC25C0A124B2BE0622AAE30C4400F2511FB505D9C
-D3B9C34B8C87BD3A60EE2994120EE19CFF4D785B502B65EB4B0B7653466FF47A
-203C81F28926A30B5B18DAE4AA26A9BF35D545F78126F18C07321E8794F10840
-C22D4DE16699768976319BC7651BC9433D5CA15E76C4FC58A1D5AF397DA6E88F
-C54F14B65DC767A33B5D289E7CD614919116ACD185CF039559E873108AF68BD8
-4F4894640CB3232A75F2E153E7DDE25CECA0D2F4EA288FD71518D1698B3F2340
-2E69C0B73F1D36AF2986EACF28E99B203F03DD0032719BC040C53821880B76A6
-B60CC4A59BC1952836240DD21B682030148ED975FA648D3BF8569D955842BFFE
-21A3D8F951B8906AF1A1F88346F20FA2B3BCFFA7714AADB87AABAF2D3323F304
-55B7A458122F746E68271C8A85BA79340C44867B982BE0C6627FBC5AACB2EA0E
-ACBCF67F5DD943CB08FAF92249C81F967341F3AC3AE26FB0E873271FB54AFFD9
-706F7D1169F37963A387411E977147F1DD7566DD0FA240ABE9CEA3D7A188A1E0
-8855451B802A81DB5C7FFE207D753A689353F2980489ED02A84ED17BA657D1DD
-DC30A40CD360AC251C628089B9FF05414F6832482615862C8FB208FF01217FDB
-734326B8C91F28C05D8A224F4AB4B9A926F1309E1769AA2642F2E1B63D841019
-5533457201B380FCF42BA9ED26A28BFF5C75AF6479D4CF8B26B9C44ABB10DE43
-BEC8C43151AB117A8CBFF6C023BBEF29E7AEB350FD589B4403B6E31418A0326D
-BCFE07F51F2832E3E758712AE3750FBD78A70B2F09E6A75C850468381F8B957B
-48C6D2991FD8EC937417F47589206D22C2E9BB80EC02AE01AF10A49559F0B6B4
-482549A7935B93748A33BE61A1410218E267019D3110F3B6C90356362AE7AF0B
-70DB2E8AFA4AEEFC6ABAFAB5F333418DC5097ACD544A50FA00E8805683166659
-6B2E9D0E1EA6A1EC29E0BED32E87A6FFF0C84640EF8CC20351E75946BCB00A17
-E485D979CB00B6852507A65D239FFDA6D617AE626FEFEE4178CC13B8339A05CF
-070EE49D335D2FFEA52B613182C78E8C6EF72E8F4CE5E48609DE4E939E736B41
-328C865A549BF0E0D18BDFECBC5455292BFB64AF414E4A24219FBE593ABF1DF9
-E9B5F0ED36E1E1A861D9C154CD81F56BD1EB4D287B933D4F4064CDEC6C051573
-D24E10CF113C4CB0AF7D9DDF4A7AD2078D43AB878A15FD6B3F2DC03F56EF05BD
-72A76EA4B1721FF725C3F54FB49E23E9B002F4BD5763DBF2B02091ADA0498DAF
-0B60E400DCE7C0502FFB55D3EB9832F2C5F8D50EC8490481E77DBAB6299DF0B8
-66AD641B7C5F20333C68D15A370263F999084104F625C753D7A8587DAFCD978B
-7D682CC9A794926C352917301897E5B11659706455E855ECB4C45BC73477AF88
-4877E7FEC84997EFC16709844D328D1FEA5CA7AC4886B852C0A54358D412C464
-28274D31C8568C62AD9B96BE68C4517A39F3E59BF161EE48B213FAFE5DE65C82
-2AB8C1060571BAC861F85512D2EBCDBED65398C64DF09A84A5A7AFECF7D94AD6
-F4CAB610CF69F81BBAFBB96AB1FA594129634D20E09F5935E6D6BB3CDB607C57
-9E99BD190219439FFE97C08B9326A28AB2BBED7636D06A455357B57294F650DE
-BC21AF9BF03D1B8A10C38A025B3A4ED11D3A414CFB92E57034C9628E98ED1A17
-84D9D340763E1DB1899041A8DA36BB2D74D6E9AEECCE808487F29CD2DDB9F3F3
-9333C48FC64017248D52C6640EA0149CEB140102E208DD0DE45AD3DF58D69158
-98179AE449EF2BA73F3DEAA0161E08CBD1328DE6250AC730694C9DF1A0468419
-A618C76F7A41A85A6EC7A7490A0323AFA3BE6EC3182BF70AC7FD81AE4A97B7E1
-5D5DC5BECDCC34594301AE257E6594B0ED895A7A08B2D260690C237476596A01
-0BE50C1547E1F7CD5DD01468EB5D8BD6125951770A4B7FED6CE74F16C462F277
-F5D71ACB26D7543C951D235FF0FD9D22AB98BED474BED6906E969CEE0C2E109A
-2AC42F8C80DEBE055CCFF17F3BAB1B98A6ABE5E6FD09C0EB323743CE401351B5
-81CDD2DED0AA813AAFC92B8844D48F41E2B1F8256EB6DCFBD6A0900D96D05C60
-D192C1090BC3E1750AE8B777B7D4939EB63D7EE345D5F6D40251975EC4DAF299
-BA3F7C820A2D4B502976FF3144E91D9154614B4F8651F9EF818B095214A246EA
-1E3719E2BBE147C007D2F47A42B7466CE3C37E23EAC69B005B2E1569E6AE7233
-2BB811E25578805DFF8BB4E7A0E25D9ADC6C849B665654BAE5AE18C57F3C8AA9
-26405AE40A79C11C33305BF61F82CFFD3719ACDF860666C665D52EDF2F003757
-837502BD940E61C042BEF6739841F0FF337180D238D1CE71EBFA2018FE303E58
-05C7963D0AE266F0F89860EF6AA9F7F2230E0DE7663BBEE1AFCE164BF920A485
-DFA283CADD082FD73C8AA82BE92F3763D6C08CB4D62940CBB81108CCFAEC9A79
-8B17409B9AE9784A96F300647D663217A45FA71E2C3D944BE2F93CF18EA518CE
-465B7854AA5D63453E78DBDD9D78CBEB80D308E805B1E19C145072D94DB3E78A
-EEB91E7FD028CE0A6A9C7AC26E18602F897C8DCAAEF03135BAEEA7DABD45777C
-5EEE6553999C78388C4F63DA34D9CD729CBE44CF73A95526871B2C509C568DF7
-C7A732C825A0C196085287124A017B728A3B9D17D5C43637148FDCC344999EA9
-7885BEAA570940CB3591DB805F69C5023F682D026F52FF1C0926062B462F78B7
-A3C9290C4ECFD795439DBF052D83C3E3C2CA9E9A4BBC045B508A73364285BCFA
-C0A4BFE01053907499D419B1F349AF7759222ACBADD2396C9AF847408957FC0F
-EABA08899AFA14DE953719A4DF1BEDC25B78EC6B4C4CDC7199CBEB80E0F23948
-BAD67C8E6673AAEE6220A9407474583DDDD81C4C1521D2B26F63C24AF3D389A1
-254636CF05BF4BC71B0946B1900D733A855986428AC633F0181F521F929E5F3E
-4B6614EBB9A5A7CC26D87CE508DE7E023ABC38B48F428812BB6F2D225FC7AB0A
-C6A6058E943B4701DB3804D946D94C0E360CEE4011CB5111E7A3F83D3C730D59
-8AB5D70F1A454A0D25F48CDADEF3894063F40D42CB177E089462D27D40249ECD
-65D1D4B8BBDC20E63557B8631722DCC0BA60296E6C7F33FB5416570D63F2AE37
-D2CDD5B54BD4B0B6FF030BA79E3DF4204FDA6CBA3EB7358001B214DCAD378A96
-159A0A038F0882F9EEF701B2D82CEF958B48E2E613C33FD389DC9FDCB57AB76D
-59A6B8791D348A1228E5A7D5B3513715F2E2F0C519797ADE87FCAEABA28A99C5
-32CF7BB37AD7E7FEEF405009A0AAFBAD409A1B577F02DACD575F805916EEA691
-2DD0AE2009FFD9D339759FA92693AAEE6CD3534E64967CCD02CE3A3A3D26E09A
-17D4751B852AD2E435A888B1EBE5D73F7DC4FB1B48083C44B0F747C8ABCDA80C
-01FA7B334383F5A84D82FCBC8446981E0E4931496B171C73827D716C59D16B9F
-8591236F8716A5FE8B42857AB3298BB0955F641C5FF60C4B8D83576332763B13
-67A71F26F894C6B670AD04F6ADDAEF33475184EABBCF75AA146B20D29DA5D556
-A4F7DE1FA8C484E00E4FBE74C747953B9D0D53A0BE5B9668BC619C84E39A05F8
-1CB0ECEB23195A2E1FDAFDA62E66CB9A0B8F13B16874AD19CFB6A360B376ACD2
-08C0429A170B36D4B19F3AFFC616020818581750A1F13AB6AAE3AC1E7F37CE42
-B79948A8A99060A49CC0A7F5FA03125B0832510B0005BC7CED063EEF8D2A8B0E
-7D2AD0CBFD9B0CFD3DD00ECDFE9C82984F6AA2F437DAB9934C7826076253EFA0
-C58545990D9DA271921E259001B943E3A1BE32FB8FD9794EEFB993C471065CF5
-C2569DC04EFE2EBF9C2C3194F2DD0B80482E91AE7DA82B7BBD3CBD2AD6616DB1
-782F2E9B0E97D270C278A7EAB3230512809141AE6FA17B99820227608120ECCF
-44D00360CB2B8B0DF333E78047F06389412B9F51C9DBFB9510D8A98E657CE902
-E5C8434C88CC591C99731D20F87C33233D12BDF016493006DEAC5425C6772F51
-24354F1164CB243C95595016497D0DA5E3C61295E0B328110CCE282843C63CAA
-99ED00EB4348EF4C564DF03DE713B1A5F252C52BF47B16F1FDEEE9E9F9EB7FD0
-DFE8592B834D5C51AFD4F0378D1E7BD1555BC0D46A30D28CF0366E77CF595E09
-2CDF9778DC20E31D5A18980171A0B5E10D5FBA3334481E6DF77A962AE2D11975
-1F0FFD177230554DC97B9AB2408906A536288669F0EE9CDF77DDD56F8F0E3A91
-5A68BAC19B88C0BC87CAB9C45AAFE0C5036745808783649D7423E0BBCABC298A
-64625ACE66C04C1C75B35D8468000A39064A373AE5F4672412F899E019F41D6A
-86110A6EBF68BCF55AB8F5E25295C39744C8E13B8D075615DAD706B9AB9D435F
-896728D52F2E0B04F2AC698F4344E71F80B747D290CAA5930C407E98A7A37243
-06021F908C70717843F92BABB70545A2AFC9426674665CE52B0C8EB6065CF6BF
-113BEC9E13B585803E0C275A7D2C5435E4D323BA30B24EAC8EB56AFE01BB141E
-EF797673511DA24B3F5A2CECDBC879EA44C6C121756084A0E0DFCEAC8B49E028
-8ADB54B8E1592AC4034553A9D34B3B9BBF8A7196B6280409FF919D4A56060934
-799EB0FA6CDD713AA990CA3FD33124E09FB15E22E37FB29BCC511C5626A75CA7
-103E16CD0BBC7B2903DBCB05A60948C20499BBDBC650A9CEDA0240F38133FA1A
-F555856CEF3A1C136FDA97C47F7F71D5681D6D5ECE1C339A8DCA68F76ABD31AB
-45625F47459FED87BB8EF49B1B05F2BE4CB655C06762D39F2E916ADF23CC1F39
-080E16B9DA45CDEA90567331DEBF7E0A712BF669CD10E2727348949DF347C0C0
-E78DC877256BF311AD0B429CA120F8A12A3DE8E37618EA0566EFC920CCF5339F
-A0923515D05E4651BE7D9A2E000FD0B473E2A927EE0902C9251C3CB1D19AE689
-04512A87E632749831B7E24EE88F852F3057782F6D5CF6DD84FBE99C38F32284
-0D05C74CEA5E2A3CD0A5BE74C0F2D4C165A32674EBC0673B21546DD2A6AEAC43
-5A24D84BDC988D3C42522BEAF01501806D89479DADD98B4BB4B24D0A5B6682AA
-079C53541D4D0BC4540E6828D986225A2C145D4ADABCF88F7712D62D8BACFFC1
-03394C3ED2FCDF2B58814D2B57FA9624D7352A206CC1491547884B6808346D69
-FC3719B3AE6D02E5BB580CC3F0CBEEEA95C7951F56CDC92C20850EDFD6A1684F
-19CB1828C68F9C5E4DC582370CD40097578B8E4505FFABF7AF94A429ADAFBD64
-82527EDA4AE59B91926DFAE534E2D2D19BCB53F3E3753CA769520BF32E850203
-E02800C40904127A1E3F5D2962ED1A4BF25C52B75B4F637E37B5CC3D0882CE1A
-AA211E9D15021E11FD46B54DD33AC7A47375B9F2EB908DF4A3614657588C4C0D
-5CB4840FFA525F0FB6F0A6D7FE9343F5CF656FDCBCCB1483E90164CF255535AE
-635F9BF389D955A0D0E4AC4AC331EC3B9013180CB0F3094406FA8F9BDB67202F
-E4C8C6D1CB87D3593993B24876C20887A4498A0198EE25DD4DD37A829B476EE5
-A1C629F0E594C80836FC9E568B28450A94BEF5C5157CE5B9EAFAE776ADDDCF1F
-12E3F88A4E6D7ADD9E05D40ECB7353FECC07204B815D5BD96F7E2EC3CD4C1C76
-A05BA22B36E24346986B0A59C6394EE31B6C61E5AEF72886D4FA3E40E675FFED
-3442ABF385E9212259FF2485446D46D05E87D4F004711C4AD539123C87794EFB
-FC4A590D6C70BBE250E4790C6009A0421D5D0F3CD2A89BD2373E80CA4896F608
-639F2B2D967054FADBABE73359E57BAE511FA2DC290D4654FA0FF524B2B16FA9
-C745D3D773EB5FC648142E0085CEC9E66489E04275CB4EB2927B7D365029A54F
-45BF81A4DA4B2B774D993B7372AF67DC2821D042A27BCBCC6A7474955A2869C5
-775C48BF56A807AABE91F51EFF444D189790F880D2D324B30EE823D902E66693
-B060C24B15399E1BCCA644715D5CF019927AACA7AAAC185113B063D6485AD2BF
-E41F9F587B53568E183C90D646C8B8AE1EEB9C50A90EAB992D1F88B1EED8C9D7
-BD616A6DCC05E3FE7BA60BFEA0E9FD45947E831B02D2A5E3D3D27995482EE080
-51AA7538FA81424CC5077FFD640BE97ADB8C8EEC59E65051794DFCBAE797A325
-92CCE8B28CD50CB5BE3BE75F1029E76DF4199E672429DE2FE6D4750B3277B1D8
-6203F0C995653CFEF422696BCE9C5515B3933E730C09808D8B2407DE0ED2D061
-D653B1536A4F501D7CDA42BC341FF81F9B1C05223E8EDB5930966CC743705BFC
-7462E943F243AF897182CCBE151880E559348359C2AF9263639D14E8B1134929
-7236117F961EB46FADA897A990301A289AECA1FA89DA02432C3B33EC15809389
-B1C42B48DB92C176551DF7BB1F5CE04AB068EF66D64767A5D0A8AA5F201DF433
-8A055A7993FFA5CDA93F22ACCD35010CC4EE8F4411150790D98A7E5C04BBA6E7
-49F06316F0AF2FEB825CC7E38FAC2297557BEF4200D55C5B6C95EC166532C872
-99458090E0E6F9E3C363BAFB4BDAA081AE0DCC82B684AA8DC22ADBEC25914CDD
-58751D8BE5EC137A866248E8997810028B9CC7A4400DF96CD8F88FFA704003D6
-71FFFC00D299705DD5BFB4F3D8F0B5D87DA9343C6793ED0443324033ACBAD8F7
-4CF5EAA84772F6312C4B997662B200382BE445667677C03799FDB7A276940BB3
-86CC93E7EB713747EBC1B96351794207C58E3DD929F08CC62201D56C3ADEBADE
-05552BAF18B79C07D37DF2E322CC69CD3B47D056593671A7C0E975B79BE9BE78
-401BB872CFA23B177C5EF0FF5FB78A8FF65CCBD63A90B484FE88632A0C7EEAB7
-1F5D6C026C86B37E9E93ED8F98467528E10396502D4224F4A5424614AC7ACB22
-E7FD7CBB758E8B7212FEE509E0AA925AFB28EE9A27DDA1FA70FB8B19255227DB
-9E8C938EDC0BBFFB51304A55A60396D4296CF3B51B41B54715A7418D75C6278D
-B4FE364EC458CC84B53D84E8F73D2E2D6B3C54F82CE98B8827F26CA641F73EBA
-10A9C54828D61D3D58F6A9FF8BB0E475C5E65FB09DC016E496969E3E5E2B74B4
-33A7CDF9FB958EF0DE260028005B08E65CDEC444B3DF9386BEE7DCDEFD08EEE1
-F8D8C5E254FBBDF6A470A7E8FDE5FB4D9E691CD54459EC19CF9A44500EC7F8F7
-1A5ACF7444E33011FA8F5FFE35F2CBC0389D25E342C6CEAA7609F14FB07C2BBA
-7DBDBE6C81F84F1446FB4E1EE6B9D344789A474724BA46CD2A0C2DD2A85E40CA
-D99D07EE525274CE29CDD3CEE06BF50D8BFA746DE6B3913D56A0ED5A00CE6FC0
-9C9F7A6B9D3792BB0C155C9C4CA6A3676E6043A5AAC2D787D7BDAEB4BFAF215D
-DDDC38E4D863606F4626188FCE71C4E16A6B18C5DFAE43C4AF01B76A9AC8653E
-848A3AF21D414A0DEF5135C832C14F8F8D11AD1E03A2FD623B50453D8FF4351E
-655C4AE01875505CA29C3D10BF4C31EE6AEBED41FE527AAC918D74E744158777
-4A7E89B8CB0F256408BA0768803E77278A9C3DD1B5E891412DCEB8990C269E17
-4E322124C35466AC1275B7356708A0EA640E4932A86E2ECB219879159399EE7E
-E9D365D0F36652F18893EAC6D60B13A1E7A7537E35A91BD75C34221D7415905D
-914D2507B93CF9D7965382570B6286B0CE39A4F6C45013A9B6E51930870C5A4C
-D8987A6C6B98A2331CC99BAEA484D0326948B4EB58D72924750525C43F69A90C
-493C6D7A55102B30CBF53039A8C59115057C756A7E45EE3CC90A9090461C6EE4
-3BAAF0EE5142771F3FAF39E87B8B522A88071CBE4C535B4655F26DB65AE8E8ED
-98D6507B55AECC3E97736F882D97675CAB70824B2B025C89B8D23E8D2EA9325B
-4D9EC9CD264B3815E13A85FC22394D3C59836F3603CD9CC203339DA37EFCAF75
-41F8040019B91A3D34352A80091BB6BFBE00987461AB966F85A188F731716FC8
-02A4F351D826F6A7E311636F068598656A92C3BF53DA25E62D8DAD9B90D8695E
-E147A2CE3D282A2803FC0F8CB1DE4E20F253A414BE71EFF383F03BC19EBDF412
-F9E37843A93CE9E8E227BE75DB83B2076490A122C2B38405F0B53086E3C53066
-D53FDE7D2166A59C2B2852D84D3945D84FF0849572422B53F7050754295D1AF4
-939D78DC72CC0AD32FADC240D9675E34D16EE01CC7A50D406DB24C24EE2E776A
-9916E2BFFA4272E3A3BC9B4454CE3BE2FAB9F1A067711C61A7E9470589C11B0F
-BA39F8532B79979B5750E700A80121D9D09AE322BE1BBE56040340B1F22A834F
-567816DE9B149399052AA2265B0221D2EA3F7EABF4A9EBEA4F585463EAE8BB6B
-2D9B829FC24A5FEC5175CB10736B10FEE0857FBFA9009319B458FCAFE693FFA3
-CFC162935BA17062C7E99263DCE4DEE70A638A06D7CE49A8CC4BD897A3F08BB1
-7B0148990EB2407BF40BCF3AC14CA97C3016593AE6DE970D21466A2F0108348A
-1255143A81C52EF32C641025059D8AD912E8ACC07BEB0CF3359D506870B2B5D2
-627C69CC10BBD2430007FF70EDBCA7ABFD147D18728368D2835AA1BA33D9FA7C
-9186634910F1207BD6C40765778689891C2B13930CEDA5B21CA369ACC8D40B73
-5946D0ABB7E97DC28DBFB21082EA017ABE34C22FC0031FDCD0E1270E23E06A36
-2F4546B3D127D5F45BF0959594E659875723AA72B361F6516EAD66FB398A2073
-AACE5EBC8899C06448FCC8D94BBDC2CCA29EFDFED05B3CEF5BC1C77DC860C4F4
-C6169D9FB712B24ECDFEE9F3E7436398939F0A8E0ED7818467D68137B67B110D
-33395F3DF2EFA765E85395AC215561A8F86017B8442D7A84FBC143AF308C8DBA
-28549432786C0215E6779325EDCBD174E43E90549CF58DF7E8F6CAFAED50D234
-19243CF47725C1EC1B837723AAAC0AC67708617BF35664D298C841B67A63CE5E
-EFA09F63273A9BB8344267E509FF94579A4B9B5CB02DE2F5258830805C13191B
-3CF43264757ED321CECC33BE3EDEF79970437A982C2DB0A08C046679608A8629
-5BFE74F8EDBB84D685C7B69AD6FD3767EEDE5357D3EE49477BE5C1E62C287BBD
-1F7796BA5B23335C51F1AFB25FEFC6CF29FA85CC9A83D0974AD9F532477ACD25
-B6BEA051CCBA8BDA7DD380FB9CE894AC87B158624D59FE865ECD25C9BD5A851B
-62589A1024BB448D703C47C1695EFD3B0D7B59ABBD0FB8EE9A70173E5FBDC419
-02D31670D921B9F6169E075923AAF5D2688228AB791723C268C077CF57DFAFA4
-2722735A6260419C9E5CC3A6F24AA285EF8B0E6EFC7484DC90C373339B479528
-7F3817CB76BD0049D13925C06BF1131930F38A59DAC80BDCB71F93089F8105E3
-42864376F84B7BC94BD56AB4C8E38F3D73BFE8555A599A7DEBEB81CFF19C6D6B
-98A0DD456A39A662D2952B9099A19211B23356348965413DF1691F0573D907E6
-704D8EB84971ECB5CD41B2A099F259BDD423C5C6E0A7B74C72E1B3B1BBE3D1D2
-15F2DDB339B59733EF8BEBA4E00069E6DF3DFD40C7DAD8D7833C347DFD73B9CD
-EE7BEA6AB1E28406582CBECC1206D23D3F3E465BE70C544D3FDCCD0AEC777302
-16CD3ED87B57944C2C40E33B15F4FC80B4BAE4E39B607013D9BB8C559DB1AE0E
-D8679216FA8DFDBCCDBAC3F0E4725102740CBD98FDFA8ABE92C3D019A46FF5BA
-5E59497A7C035AEB30210A81077FF1379240F60EBA4243DC483D08D5D3EAE72F
-21EC055CC25900FC9531B086D7EED80109AC743D8C1E23CD450ACC080BF86F7A
-7CA8FE6B4311B12ADB277D1498912FF288C20DB9CF3BCDEF5C159A46494323A7
-F854DAB253B72479899464969ED9D7194946DC36149D95D48357215855055BF9
-A2DA1BBD7157D0DE0D1FCB1D746B43C019D97B0DBEAB66DB7310FB6059AEAB18
-59BBDF62194F6A4569C64253B26A56FA7405D2E6D1E54CC11C5853B3289349C8
-D5B11BA5DD873B81BD5778DDB75AF54D97F2AFFB159BEF6184957A4B8780DF83
-D5101D22800D16763E01B4EA6CD31305B0F3D907D9DDE534FFED13BA29D7FBD6
-3FA7D999979F9B9021EC27BFA54C7AC56B63541988846CCDA91B59FD9CF3F5F6
-9448FB7D001E36ED274BD5A8F629FC0C030425BD0ABDA3141F6536FBFB7B53DE
-EEAA400EF5D4726439954E8D61F88BC749EC8188A2AD0CE1469A3AE8A51F3CE9
-439DAEEF26E3BAA745EA3C58B539843D3CA89FF9677813EB2A607C09E8913495
-EAF0EFE186732FF601AFE57F36AF01BE56CC7047BC688CD362677EBE1F40107E
-B0540CBEEC3EFDCCC5E3DBBF4B07F265B396FEB6758D1F626BA723D28EC49B45
-E97C523A4A16BEF1AC447C6621B90FF97C0A9ABCC46C4351CF4291CB61EF3DC5
-977575A1D10FE127DD6ADE674F3B244DC7266A367B8BE4CE410E29737CCD48F2
-BBE26481B2E7DC282813B328975911F465FD5E51E7EFA423E9A2023675AADE3D
-5466A4D3F15DD19768A918F9F0734F1DD7334F9D08F190E90D2E220DF85DB88F
-A302CAF79698FB4BF1A2E045B5E929B9846758089ED5EA0B7189A0CA78C6A49D
-51F0A21F5DA03F2F5195C442B1F9F6CA52F117EC1683429A8E9DC473EB66C88D
-61AFE195558037276A62647E2380D63036D5EB02F60C4A483A75FBF28AD08A01
-1BB8B88FEAE6ECFB7563EBD308CE2434F7A09B3E5CE1167FBC6DC6FD88421C8A
-73A4BAED05EC769EEC22F6BB4409FED629835EBA79EBE2FB031634CE2224709E
-A77875CCA1F1C60A5589D2D5ECC09AD388503DE66F60CD11C8EFFE9568193BE8
-D7440A50BA89B2935638B797F4E44E8D8A9313E49269F11EACC2721E0CB8CFA7
-7AAAB154A93C8E731E39BB1D834B4359870A33349E4F0E3DFFD492522FD8F8D9
-2B18F15C4D7831140FF68EC857749A515469E443662FF3D1A5C423852A28B3A9
-E2AFED92DF0DDACACFB12070CB5701DC5032E55758B562ADCDA18E4B5DBD9093
-2900E9F5904BCD1B971C617A51080FE5E9FBF24B45B0D0B193A7F094147EB317
-5DB33B34959171B449863EC8F5EAE702D3E32C45AA34D03130FAD27ED825EBA2
-E9D2A6EC4499192445967AD7384AAD15D1A9965EBAA6139EA0846433FD3A07DE
-40FADF9A8B97EAE42CAA6BD92466E01BB0F110503A21E34D16FBC9F993F6C060
-0210CD71400E55C59EC63537A41C7B1B6F985D6C804D7A3431F7E0C665384BC0
-42A35BC3C0405123FB331CF5475BB0CED1A3BF0BE4C7A3BD430460FA323C2C2E
-4DA13CE05FD3D8BB39FFEF0796D7FDD159B04773D21C650E0E11EE278D638ED5
-EFCFADC823CFF93FF61EA140D9037EFE40B509ECA2DDA7E61499AFE1873BE563
-6845923FF830FD0D17C81251EBAB3169B85B93FAC02A3794DC81787159212803
-E5E129A8495170180E3F112C54DFA5152DBCB4D4BFCC6E432A4F4F925D858F78
-1226662C6141E58308E8EDF66D76B35D70C779C695D88752DCA70C27750460DC
-BC6E71DA6A41DB579E81FF5F7B64A8FE1BBE994E21B29E25817D127853C2CD64
-F69B1B95E2901C27C2FD4BD3FF99F173E282950538029D692C0BBD45A8558166
-D411A71F4D1267F3D296D67526F3DFC7791E2EC0194225BA7F8B63250E82FD87
-A3ADA14F1F1BE0B8C8E4F6AC2870A228F24C26002D92B7318C0D30822AC616CD
-A4A03FC572D15DAB661615AF113F4D1A757DBEC6789538BE41AE2B53DEBE8BFE
-4D6BBB755E93F763A1B625AE6A196174E5928A125216D34AEB40C963593B676E
-7C71C741D8B8EE7A1E10BC1ADA44A4147BE662101C24F13F5FD60B6C6AA0AB59
-3DC725710271ABBA645BCB3CF969224C36DB1C0AB4EE167CF0845DD70F0AB25F
-EF33A162D9D7DD9097176BFB1CA77E396EEF3CDEBD1134EF1A53C3CAFFFA4825
-221F9A79068660F347C1EDE934999F6352EBFD140F0C50CAB474C10A50F57FF8
-93A61134D318716C5ABD0C713F2AE005831116A40D58749FF6864940F17999FE
-DF725E769823A184B0C109AC30833C7953A46F4FFE18
+0A7617C3AEACCB7CCE00319D0677AA6DB7E0250B51908F966977BD8C8D07FDBD
+F4D058444E7D7D91788DEA997CBE0545902E67194B7BA3CD0BF454FCA60B9A20
+3E6BB526D2D5B5321EE18DD2A0B15E53BCB8E3E01067B30ED2DD2CB9B06D3122
+A737435305D42DE9C6B614926BFD44DF10D14402EBEDFF0B144B1C9BD22D7379
+5262FEEAFE31C8A721C2D46AA00C10681BA9970D09F1EA4FA77428025D4059BA
+2988AC2E3D7246BAAAFB89745F0E38580546045527C8779A254DB08DCC6FB9B9
+0E172209FBE3857AF495A7F2B34BC893D942C145C2204CFCD6A5C69FEFC25B60
+E412CB2BEAE7F7FAD03AF46344F6A7D483BBB1E896BF16B0F4C363799DF23CE2
+E8127996DE841B6F9D8A9E56BD799B6A938582988AF87151BB8D3AEA85C49857
+DD862B5E10D9F33D57795D656FB616BC9B8397B3612131A2B0F472656700958F
+739A548F7C3A348698AF9F6F9821D7A9FD4131781ACBF7EAB885A3AC254DBF94
+02FA697941A0F97F048861788BEACC20DE829764413CA58F9D045A6B38BCD6E6
+E4827247EDF1171F64E3B041A69B244308DC07F66643FCD7D5FD37F36EC4CB5F
+957D4ADAF91850A3B1A765E0E580EDC77556593D1B2E1C22685268469298688A
+45C474C9D0472D019CE1E83F25182D084AD85A49C502E8D679C227DA8E32045F
+8055D1622C478F8FDA342685F858DE3F53F1CEA0D70BF3FE09037D981E9E7FFB
+BC3F896535D0DCF53F4C85A1DA5D0B632484D1F25460E3EB38E251D2AA17817E
+F3B25A2A49C0AEDE0B89E277F52CBF744EF0243C409FD71FB0C574640CF11599
+117A4F42F27D8D282D34485AD116F7E753A8DEBFDF7C552A1179C02B7A37782B
+743D0DF85C15A333BE9EE82C13DBC9CB007DEB5900954AD9309902E08B3D5BB4
+E8414211B971CE8B9F05A61C15F400D9297745F606C6419E8A8A9ADCBDC39243
+617EFABFDCF9F836D14411BD72EE19D0BDE89234BF7D52E7A68ECC952FB74FE3
+33E1A87DA39AEEE9E90406E2B1CF3799C63E9BA858D54F38918B814C0DF0B696
+839C820C26FB473ACC5C08E2056457A74123A398806EECDB427BB183F5458105
+2B66D7E1FC3529025D3243A045625E9DD9417FA089B3C7C394D2B65C0367FF73
+79F17ADEC6B5D27A5D3D3E244A0839E38267ACF07B2D994C2B4E7F30A416EEE2
+D1688F167D1641A72A795B1F4DA3350F75AD6D546AA118B5F8A5085F5794E6E5
+28256CD31D250D8328C9620B8ACAB03E4A33DB4595E959F4D0FB1C8CE85A710E
+22F1940067C036A7DCED7EA48F1EB81AC4735FB26A249A32AC2E3E7636B32D31
+7D76FBEBA106D6C67C94A3BD4256B786B71C6EF8D191CA90CAD8D2EEAD42C6DD
+8BB4BEA7DAD4ECB6E002F3B71C2955A5A401E34D55F755BED68178C270109BAB
+FA0AD848347EB977325530B27180661A59447D7DB55A62D65309DE24B6638986
+1D3A539BD37E74C2C00DFED3336B5C6B28D915AB7188FFBCE3ADB3CB903944DF
+1BA5923A1C053D4682BB8616F44E81E18DB2B58298F4B1A6289CA993DF3E7C73
+B00DEA3A9B747FEEBC4A11E5B9B8B05CA2709B8AA935A42159D3DE399544F5AF
+AC1CC00F6CB94AB69856078C9A2EB2046BB9055CDD6A0622112F7D3710143F1C
+20CD8DAB4109CD47BC00EBCB88314081C1D6C43132412F261CE0262FA28DB7A3
+C7D8534BCBE1A60488EA230DC558B73C72AE87539A9D7E28C2BE05FC05F58DDD
+871178D227ADB9F0D01F5780F7CD67B369538A7F77631F1A5EBCF380A19F3B5F
+A0C08A2F6E094F6BF1B3B3673641FD5089157EA980D98F7CA8A682B21EB5E13C
+1EC7873AAC8D88A41F01F1F56085641C5EAC5E66C73D2C85D6B31F09CA745EC0
+2D5AC148BADAB62B8053F6E2AD05E7101E7B35612A446BDE809A3BFB56E169ED
+33EBAD52FF4B3A863FCC27B6D193A5B4580D151D0491A1381DE2DA4F197C83FC
+183CC96D14BCD9FAE955C046E46373357D60B19432EF18EECDFD0640C87B5C24
+D718DAACE05BEAFC1C808E89A0BE2FC02BE2E1E69CD8C076F849CF440C12FED4
+C1A34D86FACE8EBEA18C1A2BF48A71BAF2DA115D81BD2ABC1D58C7F968FA7A6C
+350D0C7FF5565373E3637E0DB09F0C474313C3DA0B6D4584C46E2F4B333BCC7C
+63D9544AC0E30D501AE00DA839DAA2DD95282A722429C34DEAB63955C7C43704
+603B37357181C382ADEFB472ECC13D467C4552FBF9551851A48E85B1CB4764B1
+7A412657C55CF481A5F17E3A67639E34BE681A8D2F446D8076AA01B3ED00D0C1
+8D3B3AF37D2F9F56ABE454700BA4C6C4960CC31F86CA523EE65CE030FAD935D0
+18251B13475E80DBB92F08D83B79ADF9A566F6DCEE4E6EAD7549B3B1ED91979E
+77A9DD6E53DE81327EA06789966D35DC7D03F181E13EC95910A8E592CACE806A
+363B820DF18007F4211215F86C2CE30392602469A4CCD6EFB00FD3C85C2F4253
+379684A7F07251986A5BB208E6A871C9ACC961326EA1E8E8A212493E0139BB8D
+A93B1033841DA18F1A56480B6FB748BC19FBAC315A9DC482928B37B5447F7980
+455E436160BAC682EB30A40238068C1ADE45ACA6FA2B123E4C3E14E4F5224855
+FF76580FA4A80A3184FFAD8327CA49F9202BD16C5AE5EA4A0E0A82B34D78B0B1
+8ED4474694B50F359462E4CFFEDEAB25B3166D60962147400FD8CA01E3B261ED
+3B2DF397760138F4943ACCEE160CDFF63B6205865883FB95C3ADB1770560AED6
+B44B2D0942CC01F263C997D47D9E74673C8A350F85408469A64CBE269C7D9F13
+B3E6289B5085DD156FAF740B94A000FA8F912A79C0FD2D56F708B71D59FACB3E
+119CA8AFB8E85F724E44C0EA1679DBE5E5A1C4925D5859106C57B6395C5FDB67
+F1F1054EFDE0895BCA5894A2D4B1FE7361564B5974C4A3B8B6D638295A732DF6
+904592D1243DB7ECF0226EC87B3795E864C5B08C27961EC717F39FDC6C4925E2
+FA7DF372393E3938D2F4FA72D4F722161EF22F765A58114ADCA08074FA169617
+78DD15195A58602BD24C5F30436E85FD043CF159E6A1E92C91D536B2FD10A478
+AF3D246B5653A3D8CB253843C187D37CB6FE632D55013849B6FC359088E3E81B
+947B7B745D672A0280AA870733185D0AD014E74432523AC384ABE071C5FD4F1B
+124B3C602F8E83C8CAFDAA573E9A415E03C7D58449F6FFF06B014574511B78C6
+DE06B5A28B76EDD85C198B451DBA22FD6309A9742AA692EC43D255573434C690
+20FB3FC3CC0379FC96EF6AFBF755D2F45EFE564F6F72F85E539EC7E7277EFF41
+0381531FFE1FD45103D598BF73B2A21E5645E9D5FC2AC33857D14FCC41CF683D
+E81C4B216BA786F3544DA46B10EE6C3E37E33CB79F33D1B4E046FF2C9B4667B8
+9C7BFFF93FF6F546FA59276C94F28058A7E3132DD94311B4A9ADEB256CD4EC32
+E2A4123DD236C43CD015C1CABE2791B6F62C5944E457FDFA034B8B420F558F77
+570C5202BC8B049B61116BE8BA1CDCE418BD02F09DE193E792B15549DEF456D8
+B9E52B4CDCC771A6B92749241C81A90152521773DBB7A813B6DE3AE001E2A1FE
+5A8020E58202271CCE4D404861C178E2F450D5F0DDA449230C2400BFAF5AEA06
+C7C92B256E4D98D96C147E4AB6CA32FD86302DC0EF22F8DC6CDFA8CA9E675B05
+A55FF3B9DA1322B9618CC9F010AC2E06C40592F3C16C704153C3DBE01D2699D3
+64D617BCA60AEF0E9C6D03EABEBE29AB76840E556A8F1D022153981953C2E7F1
+5BB364F9926ED6EF8AB2EA9CCC1079174FD101207017A985DE8ED9BA31952B70
+92B9562855D5649872EFCED6C3A01E2F01C045F04686FA69AF8C98996A17A5A0
+4A204AF0FCB6E470716598A9D3F6307ABE34B9CDEC0F2565CB03E130D9F3565E
+C268C6A62B9F600422DF3ECCC2E24CE89AE86CFDA0CFD5CD22B248406626B546
+CE8ADF997B463DAB26CCB72A31302157B9AAD5A697D0988D16A43EFE65435393
+FCE51CB134F63BA0F4D094066185BDD9043BFC2AD0C946F8ACE2C9F5B9D1D692
+FADBAA7785D256ABEDFC04B4B0485F63B431D5691E68B257843175C07478ABA3
+818A51A26603E8A1D94711932963B6379785CD78194F1CCE3425CF49653C22ED
+3EE08461B6399B9D12BE9E62402B246DADA240E1862F9A662F5E01979437F7A1
+291A728D3AFE5D2859845E81822C6C7EBDED1F27C677C2B6F2288C667443C019
+D78B6E9FE4D2779278779F1D52649E47E76E3BDF5D48AF6B145CCC2A95A6977F
+38FD58C8296187FC2916F0AB24EFC091A0B107C34A3F44BF13C8AA1779AA80DD
+11124BA47FA6299682A61895AAB75D4D6E34AA6DC4D4DF914D08C55FBE57A80B
+FD27777CA222B46BAB48E427FC70A28FA12E9FE9BFA0AF875A8E07B1CCF47134
+97D175D1843D6A6F9AAA0E49F13AD79847FBB1F570D7CCECA543A79678069002
+F953116B3A2FD3BE340C8940CF46285791E4D1FBE1E9EDFFD489EF95ACA75AAC
+83AC2818BFA2DD0DD9C13E162B202992856863B1160B952630A0CECA31C55F7C
+48ABA185420371148F103A12F909F8C67C29A6B2229DB1005A37D894D7CC95CE
+2AEB5B43D8F23ADD452DF622C30DCE537387181269396B0F124D8BA9A94C0543
+6263DDCB9F5CF1DE0DF305180DA43B5D5037AC83D20954E8BB1584BEBEA05D8A
+1B48A4FC8931D09B1F0E389E9A43CB211E64156DCD1F3BE8B1F5628792488858
+D51F5C336374FC3E157994DB66F0BE38124295CB70679FC637B073EA3295F577
+50A75E4BC19F8EE0037293A20F4E22FA15253C46024D792A0B774E25295EC570
+4B7280446D189245D7F96E6466CA032FE81F114A8849C168D7F97520EF1C9350
+DBB732B48494589105CAF7EB23F6294FF87DAC6E1930F72C5BE7F50952F526D5
+085105934426B347CDD55E5D774B0864FE03E04DCFC520A4E5EBDFCB5A5E9313
+7A38CF22A3F14CF55691C4FCA796E2DBCDA4095C6B879A619F82107F2B561711
+94C33B62FEFC049F86B5DEC80E812F467D654932323DFF4D390B7C89B0005F4E
+5873BA345BC6009E0CF6E962CA3A8F9DF158E66E334EE49D7DC27E94AFB014FD
+75EDE6D3B21F23A1C80AE04CCAF589E4920B442A3BF9FFA7BA35E1F20D138BE4
+03E31278B158EDEFEA76A8B9561938776AA2290468710CF6EF47AFD4844F70A0
+A07CEB3AC13344CC08B6619361C0B7E720ADD995640255302D98C4499D6BDEB7
+9A2719FD445AC77C5D7D09507362160C28D1FA5D30A42D6DBC1B8A8291C52079
+66E2EF53C7B758944DE0CDE69424267E67E2E4052768508B861BF4B3A4D27A09
+6706BCA5194AB5C4A3C379130273B5D3AFDEA51E99138025CB03ABDE2CC8106A
+BD96BD7F9B3A150CF8F9173DF337FDF2C6AB59CED890B45F23045E0F6AF7A9B2
+725620EB9F30693CB4B69414CF0D0B1F0D71AF1F67D23DA7A4B52B101309B2B1
+5A373717FE811F5020DB01179E2CAA5D955FBE7C56715AB6621E55CB3AF06F06
+CC56FCE9421384E3B0A77FD457E60DCF37DFA243CE3072E02CF35F664A01779A
+A48D097B5B2B88192E15090F1ADB2D0A8D1C0CCC10B26AC287BBC61D3DB3A915
+D538FF9B89A792E4C6D75D3C44A083EC5724780D7FF8A960345B92BCC044E4B3
+889155D70672833157F0FDD31C49A738C9B7A2F0D4997BA0A303AA5D91DDADBD
+1EDAFE42D233E25D31E7B97815D8C530D63AF26D68FDF0393C417FF44051B240
+35CF7A0645391B38D0003E9BAA3CE561AC4730B3489AFA5F18F970E9E43E48EF
+5EF8893DCFDE3F1704AA97CE8585C772C6E96FD35355B2D3D907C36373C4E85C
+8E273200B26B239360C9EBC63F99B71898A4F3EB2ED2EDC19F852423399EB21A
+F2F2303C7182501E6AA760711411C277CF890714B126A5F680A07639A97ED524
+C509842D518E3E0FAC5EF88839094A1119BD7AED21F021D38C4147886C6AACB3
+A72BE3A0D79F0971C3412C1DB447162C286DE215423D4541AF08F1BFDDFB7945
+1A838CFECD54B99A06C5DDD9854B20A449FD0B4E19DE2BB40715414E63421DFB
+74D056E01E52D989D47F56E9F34218EBF056632AE57BE5D19132B2AC1FBEB1CF
+A869A899BFAC374000D264E300541A91BB940F9346F9EE4194C485822BC2DEBE
+801EDA925CD0B2CF7A1BD83316B2AC4DBF07C2610642EFBDA725E6A887908944
+354DEEF3A022BB083FD939CB68EC789DEA7BF5BFAB5B6B91F587EA1FE94B6045
+9894094CC03407ADD66FFD0A8EDF5B48D534F31A6D5B0187BE860FC270EF5D66
+FBCBC1B64EB374D7FFB9D1EBE9171A349D12A8A9DDE868D4AF79E183BDF67DF5
+A8A7E87A81BBD7758CD3467F9C9EC3FF1519D7896415B7C26BDA22AB8F5078C2
+A35CD83EBDC8B1A11781A15108D390FA5B2262D2F210EBE5F7C8BD1AA8084913
+F54675B183151B878B60F441C74A40288C0ABF98C14374D8B5DA36D8C78EF697
+EB56F23C38F91CD639429A6DB60E8581326A00B7E074F2A20D64F14356BDE398
+052073B435986EA8612EB52D5CB8BD85F7199705FAE81BEAB5740D62C1F1C133
+F03E3A499CB6BBBE237DBB17FCABF44F4B9FD4F4F9E56C6E993E76D42F2FE7E4
+9ADA4B391772A859D49CBC09E543D2A51D5B9FFB7864780FCE4A15055E983026
+D699471767E93ACD164329986B0BB3BE331A90EBD4D835642F3B7D6AD830468E
+680D57C14ECB2EF77F650E6279CEDEB4E8AB8A4EA2F077E8FC717FDB988A9B8F
+ECA5110535B56BC5E5E861B7651C5513DA2A6068DBE2FCD17E85C4A9EC61C20A
+388722763F30261399BE69B465BF8E2135658A5638C70069CFCC4EBB086B903D
+668B0786ACD82DF2DFE5E78BC99286D4C22A71F2666CFDE9AD43D736EC3927A4
+3CBA975CD6E491C01262928D84A7B2E496A6C97B71B7FD31B2FEFC5A5306F961
+CB3F81AE3196ECFD280B70DEC319ADB53C1DF12D15BBFC015C7AFEB2AE5112FC
+E0B85110C6635ECE5B2AED74DD14AF064644A6199CFA1C605C1EDCE6CCEE3C58
+9B6D0E49BBADBFED049267ABCC7DE4BDE0A0CC8B3B6008DA16F94F8A9A1BBCFF
+A23B234829F60373D466CF2D09B26CFAF35AE72251EA084A07385C26926B172E
+CA468D3E0EF390C898488EB47566862A322A73B5952554B545A7B998C3DC2CAB
+F2F891F8DD6E14428350C46CA79B6A57A10BFA2721F348723A2AB59EC0C8DF7B
+F379AB402517FF87D9FCB51CFE75C78787E81C28A8692448744B8DEC74B12F0B
+2324B3A21676598568F01381375E39FB9A2A45547D83BB65A57228EAA6380055
+04179EA6A35FA22206B17FDDCDB51041563EFD9F23675069ED21403C1738BCBA
+55DEE0EA1BC8F73BC44CE309141058AD36D4917324D97BD08C43D7FFC645146B
+B2841F478BDCA45E22E35AC0AC13EAF0A2661580D73334775735BC14A4011AD6
+93021390234A1BB9F18076677DE513F0F52C775A0485F4C8EFD047A6A21A827D
+83BC8AFA6925878AE724A4E84640791875FAAC480CC4CCF6E5D107DE1C11810E
+B3216FCA3DEB4D040CB873E44E55EC27F8B427A8D77A8C689D7FC3F579103EB5
+FE7D21DB0013EF79BB73D50A9AD49CAA466C8F2641D277F84FDBB3AE6259060F
+ACD2978B75D32FE4AC6F3934EFEDB2E33382E55A6EFEF8B4AE759CA3CF65AA88
+B19F716A14AE905462FB85986C9B2BB7572253C166FFAAB0CBB64A052D8AE0F6
+6F1E9F8E0C4E87F3DA74852A31DBC7BB4C7F1EDF199B8B7B7B5967AED68500CB
+792A1DEAE616D080A93E0A3B1DA58C06FA27F46137495EAC1886F7B4A5118E8C
+C4D477DF342430153CA5CBBBFD0D29BA54356036CABA91F157B82F96B6D925E5
+84FA56DBA603D2C504CBDE4DD04E4FC6DD668237E7D4C60F71CA3F8049C07807
+D761D19B4836FAEA51BC11AECCCF5B32BCE46A089A5DB45424F76B10F1B6441D
+97EB8813787650DBB7ACD2291BC1A1F25A80464B3E71175D92FA1424C83FF058
+4A128AE5C90E288FC847D716A9C5FDC82FA0ABD338A9ED418172AAB8640820AE
+C3953B4634AD4787CD537B8F908A6CA73EE6E639EA334717FD29C1D1ABDC4FA5
+E4DCE1671EFADF9DD532563F87B93A5EA254E729A90B9B69B91B633ACA5A46A7
+140D1BD7F14BF09F92F065391C83562EBB0BAF2B761136FA3DF03BCE2B6CE469
+EDC044BAB9E7FB19E102E1DD4ED60135F7B7B49290D7428F7F553E034EF2BE2C
+22FB689B829A4566AB52F9A4FC54617F8AC56EDF72D507002DCDE6EC7E661109
+03E6D6C3F034DD93F5E285EA40A88C4F967D48FF4F66B996152D8A3EA847DC3D
+3EE12B349F4A32A1C77FEC78B50425326482C2DB095AA90CC7050AC6790E3491
+F7B6992B849FC408F2338B3FE5F10EA350137FFE1F8E18B6B17C960831D1CCB5
+75F631FA5A2E2FAE4D483F0C77938D566ABD0A4B424A4D50AB35E770DBBCFB53
+031FB89E14C8B5AFB16953550BA26FE94DB3DA75C0FCC2DA3BBEBA5A4004A684
+00FA8C97E33532A53AC8B3756D1822C0BCE2F61F860B04075CCFA67A6B09C258
+E6C0DA4A3FA951A9933270518AF0BB4BFFD88188FC29C39DB34B942AEC387B07
+6FE20C0332F2F1E8FB183FF40FA8653FFA722A832B080F57C4B1BCD9B4FC6257
+FC17C037896A417F029D227D57868260F68338ED4F5D5D8A553F1BC18BFE211C
+D0F3DAFE3FD052ED9F42DB9FEFE7089F054DD3D50E3D2ED0408F9C80D46356AF
+452FE1370A78031FA37A730944B41AF4C8BFB4A7FA4F38AAE6B5B6C419EC35EE
+18A0BCA5E4D009BA37B54493906D70916E5FBD4142B870138B0D8288087B5339
+61B391A24EEF4C4BC75975C5F131A48788725B04EE87B0DB80A449A78AF17A28
+B68A145C1B464C35241FF5E7C7CFBCF812FAB1F4D8C3B353FDEE0A530023A7F7
+3F80923D31BA3179858911374736417C5CAFA1F0AAA41275F4E9A138289D5EF9
+4925BE4106A31068C4F25A9847E76753A38CC3C1424C6BD55B1B13FCE6638E07
+7876592849B167E9708E9D6BAF878D8E0F4C836B7C7D1B4BDD1E05364FEA2C81
+25358C2B0A5BB9410096713147D476BBD92D4B4BB338E8D8B52686154CB23A13
+CAC8E673A1E48C67A5A56EE7719633A60D41BD0506967A78040356A413C7BCE4
+52468D1AE9B16959A481E23E96D2867338BA416B8494843B4F8A7508CAE67EFA
+8E09A393DD806879E6F88B6B37A75435E3C20BCE250F6DACA15CDF4E01A911BC
+BE923B7754F590E8244FCDEB1154281091DA21BEEA15E6237668D55AEEBD38CC
+C9F4CB9F71FA0E4391780B8729F843F46E506A40397EF2180FD1C53434A8703D
+FD349FE0207D016CC06A21241D280A0044C3DB9DB9ED28694A362CE60DE926C4
+8D24E653F0677A87F173650830DB2ADD2502FC77A37E311390E08EB3E3621D4E
+11493B9A068EEA534357BEDEE27EEB5670ED2BE6EA1FBFF255CCA6D54717932C
+33698C63C693455E865069753938FE260CFFFB0779C360E89A057D32501B9CE5
+E47E79302AFF3B6E61E09C201734A3D576DB66FF902E6762C894A597DAA81F88
+D02F081ED1443E85F46EC9B278EB0F02BD1F44120AB64B7C4471F216DCACBFD4
+858C67EC1BF6DD69A6FE39C828081A7FCB92E91F2161A73CC411BA593FEE9C87
+EFA92C6E3DEC5A71E953078475F1BF9D4EC5A578C1F9B78A8B3AC47A1A5D19ED
+01424D5636FB6D0DEA89DE935AC571BE3161E7A513528C93FCBE12BA9ABD4119
+E3584815CE47A7B906E6DAEF937D4A7DD1A02D1B278A8180C5FD3B2087CA64D7
+BCD5ED09E184D196372C3D077E78F2AA135D029AD6C826D10646E24EBD74718B
+5CD98BF6DDA180ABB4C98137DA64BA5EE5EF78F193B3B87C35ACF11C91F7EAB8
+8BCA389F532AE0281249E6C1E8C89220268716B475B1D5A1FB4E7C36ACE1885C
+106C8218AF8BB1DCA51AFE2FD21D5AE6C3505722B813E1A410B5E4DB911A1992
+A8E12C03479B0A700A49D6CE695CCADA1BE6C7A91B5949731953756C4538D3E7
+DD626756A7AAA8546EC41BB3CF3BD06BBC21AE420E0FF3DA27F5AE2C11B1DDDA
+198121EE4B2970A0E9CD506A7ABBC4A33851C30D1B5DAE551B9825289F28F872
+700E90DCEAE487CD9C3C0425040213D0E879D350334EC636B5EC2F4F783E484B
+926376C0CC1E5867A82935D2BD8CD6775B96B5D49A15FF3F623B84EE6FFFCC6C
+6E0DAF9BC0E89281077B19701E980DDA8F3B7101758AF5D27C961F791F7306E6
+4EEFB3715D444E7506A1E446F430A917848F252E65BDD2F04741537ADD1C7691
+3264150AC3166E5C1CD8A2EB7F54B6717B52A3E4C78942016EB3A98DBA6CC7F1
+0A81EE196C46D813E3E53D1E4F4A7EC580A53FC072042156AF669B8131CD9E6F
+E3FB758B7F60E5296B1F0C9A9E792DC052635658165E3976FED17DC7955BD2F4
+0399BF29EAF40C41B3434AA250C2C8F351718DF80601C835A83B0339D2E2E1EC
+AE01930EFAEFB7D8C31AD28C934B908D04BAE58BFE032934C80E168CA057A2FD
+069BCDF978078997E8369A6299018FBC8A397E685A1A7BE9FD7E2A3296C2196C
+14573328AF8FBCD1E7D78585E40004652A408AB4F60D061E2CCA1A242C2B3BF3
+9C7B997188D93075F2DCD56018FB19A795DAF806F35C37A3AAD93EC137786B14
+6A3F1E1EEFE61B3C97743FF7BEFEA9B404015838A9D444B049A4D3D0644BB1B8
+9364C088CDF5B6DF44D09FA64ADD16CBA31ECA7073B6051D1F75EA85070EE14B
+DCECAE41D89C362D31350463E68E6639A7E4C08208CF839186BEDAF797A12527
+B3D781A91E620460F5DDB4A399E3CD644DD39239CFCF57963E016EF503AB6558
+E54CA8C78A0BCB4C703A9A55DFB0C271B40446F82447361478E455590E803DC1
+6276A2F278E929C5ED162E7B6690C6806B6664A8FE705EC73CA4B384EFA394F9
+851D8610AB1159D16895FF4D419B2BDA1646F38B257AD5A3FC9CB5892A1B1C84
+EAC5A30EE5C67F4F91C425474E56916B70BEAA6FEA4833B423CDF13315243E22
+160A62D4427DF21099B8EF7DEA370A1D5F9FEAC8BEAB0F3C85A9F0A99E637139
+629FAF020B4E8C74402BB428FAEC8C2085D3F09E6AE8E52783B8FFB8310561F1
+636B1C092240F3B1FEC2F57842997F01DA2BEBA6EFA0DF79E014855C6A97F03B
+CB6644FA86C328D8D922F64D1C93ECBAE876CEFAD1A7A2D0EAAEEB13B2F7D6E6
+6EA60F46B3231A2863D86C33244B83CB5BE460555A8DB7C424AD98060B284779
+109FF0826A6D7EDCC5F253E6899556B7C0E71F7A7EB7493C838A40005A4F84D4
+64B33489F5CEEEB9A89A7314440285124CD7B08231DDCA054567074B991DD6F5
+3741E3EE315DA77C84320D88699637C86D6B47FE8FB3CF7F4AA5DB1B58972F6E
+87476F2D465A059F7AD1B366BEC64192243E8F85865DAE1C1BBB5415CE417939
+629EE39F56581202326BB4399E66BE91AC38121757599C3A187CEBD71E45795C
+EE51B717419B8B2FC6DC69361C8A106CAE1709F433D2F4948F76FB1CEB403787
+4B04E4AB6AB31B32992AC0E55EE997A9AF354090DDA249F45DAF6EDD4D1EE35A
+6C12F3CBEC9CD39608115BA838FF06A2AE6F552D92684E2C69226F5426501213
+B43FBCAEEFA2DEACC5E46A056F1940A60912094EBAFDB8354A765BC4A888E3BF
+FDA2D25E14231AB9AE0124E785B11C011887C8AA6B5799ECA670D805795AC031
+F194F0EB97D015DD26DD0B979AA4F0CD959100774ED80D2ACFE21102C0F13879
+60A38271D413012D89296E0EF4D695F24756A810BFFE4CCA4C84E92164598819
+8C8C388C645C2CB97B410AF2D1510D275550664A10C698CF4F0A5A48349B1319
+D543C34F12945EC9CC0C0C3E9F335873F6BD34A2852051FD5DA12A6254AD32D0
+6C6952F7509615E6F74ADBCCAD0FA5399A3A95D53A96EFD7EE02E72C4C381FDC
+081EA3AD1B28018723B6D2FD631674254527F33D249CA13D083C90C993F942D2
+99CD0F449417EFF72C386D980E270639ECD6FC2A8AC8F5EBF162BFC3896C48A7
+1116E2E4E85C5BF7823AEA88ABE42BDD66DC60CB122AA3E14D474680EE209CCC
+5866CBE83AD88E35B11490965A3E0F6ECECA9DE6B8D19C369BD376DC8F913B9F
+0D87A0EB72291C5BD198AD1953EE451BB9CBB5582E35517E0DCA3E3436B1C9F6
+BEF192AC209C1D4FF3637D396F363109A7B76C71FC93A939BED902484ACB9A29
+27074F659B9D9EA2F673725215622516F17BB9297E85B85AAA2AA83EB5028A91
+28685193157BFB81EEB2F4B2CB91517AFA50496B73608421337F127D1321F019
+F8138E0E3C4A5D84AF7DF648D363D356E158B8D29385D4FF5A2FE2C271CEB664
+B796DFD930D65C9947903184810B3A2D9291CDB4157934BC20BEC1B9ADFEAC27
+9468C3B58E97C57256DA43673F2A34B0A9C8BBC298965948370C9E4F193EBACC
+5D11F8FB1141274D43AD95A336F12629B79B910629D4BB88C65A390F243A0B93
+F551F51037CB0D86CF0B9D921B263AC7EAFF5432C0D3167FF11203B42DD573CE
+C100408FCE92604826D553E7BC48CBBE22C19294F4901369B7CB03427599E140
+195D4D363F78A33E20281740EAD7DE13CD99114D2AE48C4AC3CC2252E1BA62CE
+ECC7995B612F1617E64165F41DBAC99A837B888F0F02AB727BD9ABF1611BFB64
+83BC35D8ECF94DB817CB9E23CAF96963CB0D5B3F70CC10E1ED87895C8936A3EC
+4F73F66A4D8C78FC6D74662DDE70204A9114FEBD9E5196127E47A14E083C5B57
+A68B8AAFDD03A222E50F9E9DEA4B35AF713B14C6C3CB23B366CEEC5C721CB3EC
+0D38B5176CE6C7AB74FA8A4AD04A94E3452774F2CC43A30C9FD6C0FD06E71C7D
+97BF1CB932C2C7D5B1A566B3845EDD2FB7F4EBCF0581011C5B9BBB21A6E9C8E9
+1531217E38F91AD630EE7D332A99A99449166BFA91039811500171582D4A31B2
+8045BCD1D925DF2ABBE952D28C7580CFE212472D0A97D69D02E02DA9DDAA9701
+45A3470B6B69527AEC857E2BCF0BB1A186C150A304BC26F7D7C82403FDC5DA59
+EB706F7F6ED716025700D6A22F0DE056F74774BC304D8E6C8BE89843C85C5962
+81B5C4AF670DCB9F5BCF0AC4387937B24D12EF3531309A0A29FCF0072A74C831
+A90DD5318AD23E9F88C2D7F849DB6DF090D17FC57C4855E817E08997D0B1385C
+009323EFCEB6D68E557FDD7DD7D94674E41D0BE4A5C444C5F02074992BB16878
+485001F13C832AE4DBDD7F432709268170FFC068189AEE149DE6530CF92CAF11
+3E9464725692E1B516242E72BDC4F4084A1578F15C3B79D85C2668539E76322E
+31ACB8890079FA7ED36390D879C8B29C9984EDCC204D8070865A3FD738D3E693
+25CF751745DDC75AC6AB6699CCD07D9FDF8EF31937CA71001282410D943B093F
+4470C1F8ED8488ABF6A0D88D2F693558D8CA5B9E8EEC759D0A596C53A8794345
+7FD1B377198FB59C5ECDB227648E18836F497129BBD8E1892AD3E3187ACFC55C
+B325D93C07DC326AFB76B84B84FC783C797C8661FA18EA6C3DC2C0CE87F03B49
+823623AA75B4C2023C57C1A6A4012CEA83FE87799A233D156652CC05C7E0824D
+6A18C903D5805F8432882743DF736E538B1DF041B1668C6257ECF43EC5D693B8
+CC3B3D95C52D5F3B88B77419835357DF2AC26E66FE6B5E90EE6F212D56EC01DB
+A3F5EE670DBE55535762EDADABF645E2D5020FB344923AE7A9195AFB842A9EF9
+DA70D624DDB865AC36FCE7B4C8BBC06C78B29A776B42B15B28D61C6FCB64E036
+82B121E0AA49D06A096769599C139FEC7F74894D261DEDD6251DB2AD15D43038
+7709CAF7290EC8D8DDD7AE238C0A95B25E700C5D3D69DB1D9694AC366D37564E
+DEEF1CDA013E0C54952B24B2DCCFAAFEEE0E8A8EE43E9B539FB6E8A74618DBCE
+50C67ECB7CA88F9E9C5001999F8DA12066B73DEA420AD8883F22D5317ABBBB74
+9B9B8E8AD26E1456D476089D0389CE93D15F9692B4603ECA14F01A8254074690
+1CEAEC579B9ED835E70032A63777182A7AD54D6D8D1CA05072341CC1BCFD8737
+22AD61E367D38AB998F121EF7DC09B50548ABB47865EFF555EFB87E996CC9F0F
+4B16BE0B6F609734CF8B7232208D1DC291D90879F0EEEBC94293D25DC790B555
+5C3EE30D6358143D001A2E1F776A4D5927F24081F6C379F96EC79CCA88FBBE5F
+3F6DC2AA68A093A8E658A4EE82C3A3E7870CE4FF4EB0863986361E80CC0CBE77
+5542D2DB93E47DE011CDF6F1A8D2C54B8CD74AF17B3122B4199B9F81637BF436
+99D66C4F9E37487E73454CB2D6BE12B72B415DF501346697720951E1306A90D5
+3F6D4D16A0BFF81228148DFBADA170231A34293C0C84C2B98A8A2954ECEB38A1
+2BBCD63D4993D59B11F0C53612C98D1043E84566C5E91F959CFD50ADF275AF45
+67FA33C7DB5FD0447E5CF66367C8F2535C721400D48082975FB983A1A18FB2E5
+2B1C151A25DBE535B210BA0E0C77321A7A827EB81507C21FE16D9C085824668D
+394D5EF5DDB8568AB5AB34E38192FE5840226625409F1A51F2C8F1D20720D3DD
+2A4A7A73B47D03F131E1C302D8A0FE27259EAC476D2DA5D068228009A8B98670
+587ED171F852906A47E05D4A5B706EFDEDB0407926B1A7C7FC36B7DBCD5F677C
+26BEFC9B484BF1E77F778D8274D13BD119610F6B6B21B93FA2F85E20722C95F5
+4265DF8777F23974A9EE8DFA1BF6C95364F2F800D390DE71886D1365FE657D7E
+8FB0CF9BCB2B0D49380036EC40D6D84C4381081428E19AAAEBDF130CD6279EC2
+7F3FEA89AED7FD46A3DE9B7D7975E421E6B8E0D546640C0DBC82FAEDDFE41972
+63B8C32A85C9C3DE8F8E5DC20BA45EC8BEBCE7FDA0DFE984473B8B7E63C8FB97
+C8B55E8FB3943F28920B315CCB5B5EA6B0CF8592B9E85605F5910102981A3E8F
+430046B31C83F7A7178371AF53CD8D67BF0FFF983E9DAD05028624C7A3BC85A9
+CB08CDB500C1ED0C75FC6D158EBE8468CEB05B3CDD849434AAAED7CA951B1EF7
+9F1132304B44F599E3EECFFD0A7C933D043426D4ECE4C2DB5F86AAF263F462A8
+6B3C1096FB277EB543D3572E55D06113852736ED8FF87A82242B202B23ED1D8B
+A22DF7F705F9591E47C3A3DBEA0316AD36DB9685A1970054605C988392358E3E
+C6C3D774D1ECDEBEBD69BD58070E4A2F09530B110E48F1C5096B19127823A2DF
+019A4CA132F4CF45549791917D9CE15466975070EC9AA35EDCD006162AAA4B43
+9B8443EB5C0C8387900130760CB4C9D39086FB6A0529C6556B9B5A5964129E97
+F7BCC762417350605EF01B958CF64DAF4F6B206D540D09C8426B640A4683417F
+10A1E6FF66B5380ED995D1EB96ED88511D4E881A4AC59F5780C430067706D874
+CE5970B0A9BDCF810340AFB4A47B5BC5DAD7A6640F9EFBECCA45960B821DCBA9
+37E59A565C55096D2969C22408727BA8479B4F5686DE0B11DD3B4DE08CA9404F
+32545C8A4466E5FFC1F8087513CC0E4739A99A69B6069D89C6A1C18E5D66B66C
+71DF638483722689F703F6141AF2F397A226F10EE6D20F1539A8BC0DB1C0981F
+9873769658167D25BC92CA668A74C9222FC10CE06020239FB2AAFC991652D83F
+31F99338D34E37601D6B87E67AF0CE17204ED329FBF9AE05E5B5D0B06C24A504
+CA25D59789642E29DC5A22BA8F2E5CE7F97E69217091306D1914CEDEC400B0AD
+3CB9514BA8D44F4256B988EA65D7F1BFF3EC382C7C6F253C2EE1A8F40E046C07
+FAA4B1877BB26DD2F5427D39E4C144163B0070A99BA736ECAC3321D5DBC70029
+8BBBB883062910D05DCE6B0E9B560E635BCE7037BDD5580D64FF8E8AE1E40D72
+FC3D42D0B9BF60FFB8B2BC0DBF5FD36048CD52DF98B3C143A03A9A23D1613C9C
+DBE72FAA9FFE6F91F39B972394E922F2885A1FD4FD7C10F6FA0F33A089D414F3
+9DEEA619F236EC4212B12575BA4337312D76BBADFE2DF13F5B3E5E9E73792172
+0C3DBBBE0CE74C6DD49566D50C24B6672EEA6067DA23C428AD4D54C471D473D4
+19EE8A164BD75B182BBF2B608B698991905DA0326DC981B5E4A7BBFC9822258D
+80B8DB0D5C9A5E182392FCBD809599F7978EAC35493862589651DAE21C64412C
+B04AFA28341EEAB61799FC175400376FBD0A997AABE59861C6FC7F221863081B
+459809F602FABECE52A76777B99043D6FB322B7DB5755D20EC65E868CC3B83D8
+4F0622B90ADBE3B32F3A80CACC6562BFCF0FFB321CC8D4F6140866586130EC47
+E920D9C3AC6975E50060804EBD1EA64426C359C40C3B619C79877393E6026F27
+030B3B8837197F9A9D44A9761141C6986A7DD861677511964C707BA450683E0C
+FCA566824010C7D98C5664F84EEDAE3446F0369D3AB48DD0E27BB1C64B7F9B6E
+5990D53A40425930E6765D693A6A94D280B2FD0934BFED81C06ED7EAEB580D82
+A53B3D328478319E08100642347771D3CBA2C9AC18F23073F8B5416716705702
+D1B7ABACCDD257DDA3D2F7AC6C710F1382EB1B3DA1CF67AE1AEF2C3DBEBF6702
+E5C88B7724F0B1F978CD3228BC5FBCA2EA74EBA69866BB8B9C2529740355D53D
+ACE962F124D0AB995E871BB105398DDA8090DFB85F025E4B91AF3E99AB399612
+0B252E51525A04A699A1B7BD2A568E81CEB89CE4C78C349B68143CD0DA323F83
+EEC93C3E77D2CCE0A0296A1BBCA4C656A74BB2A2496943ED612CD433492B634A
+E4E905381154FA47CF28FB359170EC65B0A431E0B842CE3A9A8DB8C837D6AF8A
+5BB6834E130A04CF904B882E1AC9FC524BA46BA0BBA547128C1F8D7141B0E287
+DFBBAE01EDE86F553AFDF9ED71BDD7C1765C2CC90AD937DBDF0DEFCDCB831FEC
+74BDABA9D83E7EDB72A69C7B07D8332B23E862B92EE403606961EEF6368E34E9
+590E4D9424A22791E7F4FD5BE18100734264C8F739FC2E61FDBFE335F4F17D22
+BABBF8ADFFF1035404F12A795FB8EBA2257CCA57961AB45C136FF3710E9B86ED
+94B2806138C01D980763AE985B370C5DAD2D6F9B017774763CD48B11D007FC57
+5B03F42E6C8584CD967ED115DFAAA6521304D5CBCEA1C865A844919D6AAC2216
+0E0F8B5D867B8FBF0665015FF7A738B07B6FE3B24448FD35590BA742B154A653
+E14C272D4B841C6971CAC43492775B4A49DA477A7230D344896DA6CA9A561A06
+8CC9524BBA715CB6AD1C78E5367EEA0C004948CB2E268A648775F5F96192F6A9
+CCEADA57E9C3296552F7A2442DC225F6847EF5DF4739A32FAE5D42C120C03088
+26BD4A515852DB83F80798F2F2EFD82812C104816F10745758A9F2B7D3919F87
+3B0644193150DE1FE2517A74C3DFF71FD48AB15C17519DB564773FCB7E8A4562
+E353385A81857E27FB5FE31AB6CA05B1413564583D244B4B47146E11C5F617DB
+BE737348100F85E528BE5F02538E3C97C77B0106F51C485978308A1EA557BDF2
+F88BD86CBC9FC4764486752A38AEB77CD6E9357FE3EAD27531495CE0F9F5DAB6
+1C90E6B2660036997828611D6764BD3DBA81DD2CFF48B264CFAFD1FF0FE2A346
+6AB6D5D08BD672276354C864E9DAA4AA94F5AEEE374C6734B92B8A4253BCA770
+2D8513FA3823851F26EE7BD9FFCD5DE91E113352237EB68CE1EEF5CF5CB0384C
+7552F257E6ECC484FE7F7FEF0172DE689B3703374F9360F881068FCF2C95FA71
+A0031C100FDB0898E5B15832DEF7AA12B359B2C2B343F57CFE1679824B6F2D95
+6A611DB5718576D739EFCC6C4542C6CB63B195553FDE03F3EC8241DF3E4BDD95
+BFFF95A987B00B0323D282AC6BD6B13A995587D6C7F156BAE359EB897CB19333
+8E0194B4423F780495D23EDA74DC255953903F484ACF3834C3962F03BDC8EF7A
+187C077312DC1773A482C10643E16021385463715F60FCA5CDDB392736F6D803
+40BE48C2946B496612B0E6E10D49E3CE4A5FA0F13BB02F2C162BE59EB652EAFF
+66050FB12372292331AEC2988C0446F83DC57FF3C596ECE76DB48344204EDE43
+8986C8906CF4FB3CC248351B86A3AC618EBE8AC31C35B32961A1663EFA5C5B1E
+E3164993F3706AEA5C3F76BB2132C7D28D7C547A16BF70C195CD18A3C15E20AD
+2E6DA5C4872B5115BF537592D023C1B3A235279683139A8471C0B0D394096FAB
+059DCE80A01A923E66D8EAC760E69305E5AFDD8CE1D099BE91B6DF6455AB2690
+C6ED99AC1A984C6F1A9E9A4568B6D0F52453F7407694AA83F932593CC360532C
+7D00C682FB7C10FD0A0441F98FFEA848EF65A5FD0F6C554A33E2B6A105490756
+660155A9ED4E1C6521EBB6CEF53319971568FFC59DAC3301CA367E40D239DCBB
+249AA6D12F6AE88EA80F67D002AE06025AFE39B0FB2D0FD85306E60F970C75D5
+BCCD07134FE734D03EF10A18443B02D83975BFCCC0882B0E2050D45A0131B0C3
+2C681666EC60FAD9F825E9CF921BEA1355DB3807C6A09ACA10AF55B6A32D0594
+66D29B3FD1D45E491218AC54F3D9460AF1BA336283BC0954E1C76CFD3A60B769
+6C66EBA0A05066D6342E6FB4C497699F97281E98DA87ADA09DB2A2D28026DD27
+4069AE0A9FF21A0FAF70EF67EF8EFF4A50709FA553D20998D0C02F529663EC0A
+9F73792CC2B6EF23247DE434FBA13B898601FDF64D9CC78D7860BDDEC6645903
+6581368690AE6D3B35A25FF851E3D6474E26F29C081FD5769BE29A9C4D7255E4
+656563368E55BC8452729F35F6A072D42BE6B30CC8FC542FD44DF1F07EC147D0
+A757F41E4A858196D3B91933AD6A4AD5260B63EDE47FE96727BFDB40C4E0FCC4
+8EB056B0BF0FB7F63D8BB17A5DE4574C6FE2395048544B57342A049CF62B54B9
+7148B273D085F02AD5EE2A287F4784B69BA55D7D35EEC73BD9F2D9D5BA03E6C8
+A86E2363A4FEC3154C37F8C00D858B929075455444463B9BEAEAEFF6D0898F12
+E19BF799BB18BB73E6518A94CE26889EF2D7AFE9F21BF54FB7E22A93A9EC089B
+8208E562E1294F911D2DCA8124637019D3DAD6930C05DAF6D386B138613479D9
+F63A38514A8256E3844DEC7E803830D34B3D1A8D61D1B11FBF507788B388FEBB
+34958C7D41185E2EB6120DBB337026385A5EB785F96082F75B19A84753AF13AC
+72329CF81024C27ADD17763470E929BA85D3E84A34765ED28EC64A70C3A7FBDF
+25772D07B6B77CDE0CE08B5C373160A9A0F6960FF0F26D7004D51EF386204B43
+AFFAB475223B917A77419C6D213906E23E3865CE367DDB05D602F9D2D70968F7
+473FEC4A7A751833D026E64F6E41C3D55858411AD3B2F096195FC0AC70C8B267
+09F89FC57D36B1264E642E42552DBEEFAFD5495F9DD1EC53362B1716B47B5D35
+AA27AC9AA210BFA8A14398D480FFCDAC06FB6C2ADF9A9E873C087B506FE133CB
+FC2945E2585B111B2FE7B423F4EB538AADD632EFF87E6CF546DA2DFB06691130
+0AE91C2BE96AB3BBB3215946A235F1D318110ECD62D34FE5F8F3D24A2B2B9C48
+1B91F95523ECE45033259142562166BDA4EACDC1424937E2BBFD06CF8048442F
+39E979E4986FA612A25B2660341E9A88C2B639F24A6850C8645353219951F47A
+9BC914CE439561459172DDA8382744C0029FEC3A0FE73B8DD96E9D5B81855A26
+316600784DACEDDA45E93A266B8D4397A3888E9A75C3197DBFC75B3CA7069FF7
+9244A47FF21C6CBA7E0626ABC71A5FC4E48CB90A2A1A3CA0C53B59770D5F2D1C
+C5500C42EB126AF56F3217152E68BDC11F96F8CAA19C77D1FF70A63332322326
+3597981124702B13235BB6B90B8F48344200A5244494B02D3C0C12F1511BCC6E
+6E38D736A97F770F5C32DA03D8200CA3CA79F509CC3450AA1D00E60D920108EF
+CA502DA667373FD3491203343E85A22BA57486AB7D8E9B1AD9127B28D59D1D41
+A444E64306704FB7D7ACBF416B26844FDB1CCC35ABDB0344D91123AF0D13FAEF
+25537D5CF4ADA15C54B75F8B9587D27806FC7340C47D42AC40B4AF5D40C5F02F
+F7ADA2FEDD781EF69C7FF650BD414EE4F89ABC85353F3FAA01995B54053E8AFA
+3378BFABBE3454A5CACF2571BF97B0593949F4956DDB70187CC4AB31F33CBC0A
+7807B8398F86C6144CE4DBF96D3615BAC1165D97269475DAA32DECC9787AD215
+647A5DC23F0F58B6E6C94CE1CE63FCE4C7F852F27BAC12E0CCF464F5E7C5C022
+68EE0C016107EDBC2F214D50DD0D54F3C2565310ADC4D191262DFBFC934023F3
+193391C399E4047CA53150163435D71BEBFD6A07AD2175BDE21D4C28CD333CDA
+0394CB0931CDF3C6F8718434C6D87343944229B1035AFB77E74C90137B74FC5B
+5A0F710197E2A14A70F81DD6E295848F15C248F3FEE78E12C6968FDB60E131C2
+5A98D5D8E7FFCEC49ADD57524AB50A02D378
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
@@ -1779,30 +1881,31 @@ DF725E769823A184B0C109AC30833C7953A46F4FFE18
 cleartomark
 %%EndFont 
 TeXDict begin 39139632 55387786 1000 600 600 (libcf.dvi)
- at start /Fa 209[24 46[{}1 74.7198 /CMTI9 rf /Fb 138[43
+ at start /Fa 197[21 58[{}1 74.7198 /CMMI9 rf /Fb 138[43
 30 30 30 1[43 38 43 64 21 2[21 1[38 1[34 43 2[38 16[52
 6[28 2[50 2[55 1[58 7[38 7[38 38 3[21 44[{}23 74.7198
-/CMR9 rf /Fc 133[48 48 48 48 48 48 48 48 48 48 48 48
-48 48 48 48 1[48 48 48 48 48 48 48 48 48 1[48 24[48 2[48
-2[48 1[48 48 1[48 48 4[48 48 1[48 48 48 48 48 48 48 1[48
-48 48 1[48 38[{}46 90.9091 /CMTT10 rf /Fd 209[28 46[{}1
-90.9091 /CMTI10 rf /Fe 209[43 46[{}1 119.552 /CMBXTI10
-rf /Ff 134[85 85 117 1[90 63 64 66 2[81 90 134 45 85
-1[45 90 81 49 74 90 72 90 78 10[122 124 112 90 9[60 2[101
-1[124 117 14[81 81 81 81 49[{}33 143.462 /CMBX12 rf /Fg
-242[91 13[{}1 90.9091 /CMSY10 rf /Fh 134[71 71 97 71
-75 52 53 55 71 75 67 75 112 37 71 1[37 75 67 41 61 75
-60 75 65 6[82 3[102 103 94 75 100 1[92 101 1[128 81 2[50
-105 106 85 88 103 97 1[102 7[67 67 67 67 67 67 67 67
-67 67 1[37 45 32[75 12[{}55 119.552 /CMBX12 rf /Fi 133[40
-48 48 66 48 51 35 36 36 48 51 45 51 76 25 48 28 25 51
-45 28 40 51 40 51 45 4[45 1[56 68 68 93 68 68 66 51 67
-1[62 71 68 83 57 2[33 68 71 59 62 69 66 64 68 5[25 25
+/CMR9 rf /Fc 129[48 3[48 48 48 48 48 48 48 48 48 48 48
+48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 1[48 18[48
+48 4[48 48 1[48 48 1[48 1[48 48 1[48 48 4[48 48 1[48
+48 48 48 48 48 48 1[48 48 48 1[48 2[48 48 34[{}54 90.9091
+/CMTT10 rf /Fd 197[25 58[{}1 90.9091 /CMMI10 rf /Fe 197[33
+58[{}1 119.552 /CMMI12 rf /Ff 134[85 85 117 1[90 63 64
+66 1[90 81 90 134 45 2[45 90 81 49 74 90 72 90 78 10[122
+1[112 90 120 1[110 6[60 1[127 101 106 124 117 1[122 12[81
+81 81 81 3[54 45[{}38 143.462 /CMBX12 rf /Fg 242[91 13[{}1
+90.9091 /CMSY10 rf /Fh 133[60 71 71 97 71 75 52 53 55
+71 75 67 75 112 37 71 1[37 75 67 41 61 75 60 75 65 6[82
+3[102 103 94 75 100 1[92 101 105 128 81 2[50 105 106
+85 88 103 97 96 102 7[67 67 67 67 67 67 67 67 67 67 1[37
+45 32[75 12[{}58 119.552 /CMBX12 rf /Fi 133[40 48 48
+66 48 51 35 36 36 48 51 45 51 76 25 48 28 25 51 45 28
+40 51 40 51 45 4[45 1[56 68 68 93 68 68 66 51 67 1[62
+71 68 83 57 2[33 68 71 59 62 69 66 64 68 3[71 1[25 25
 45 45 45 45 45 45 45 45 45 45 45 25 30 25 1[45 35 35
-25 4[45 25 19[51 51 12[{}74 90.9091 /CMR10 rf /Fj 134[102
-3[108 75 76 79 3[108 4[54 108 1[59 88 108 86 108 94 11[149
-135 1[144 3[151 1[116 4[152 122 1[148 140 67[{}23 172.154
-/CMBX12 rf end
+25 2[45 76 45 25 18[76 51 51 53 11[{}79 90.9091 /CMR10
+rf /Fj 134[102 3[108 75 76 79 3[108 4[54 108 1[59 88
+108 86 108 94 11[149 135 1[144 3[151 1[116 4[152 122
+1[148 140 67[{}23 172.154 /CMBX12 rf end
 %%EndProlog
 %%BeginSetup
 %%Feature: *Resolution 600dpi
@@ -1813,10 +1916,10 @@ TeXDict begin
 %%Page: 1 1
 TeXDict begin 1 0 bop 150 1318 a Fj(The)64 b(NetCDF)i(CF)e(Library)h
 (Users)h(Guide)e(and)g(Reference)p 150 1418 3600 34 v
-3017 1515 a Fi(V)-8 b(ersion)31 b(1.0-alpha3)3364 1623
-y(Ma)m(y)g(2007)150 4935 y Fh(Ed)45 b(Hartnett)150 5068
-y(Unidata)h(Program)g(Cen)l(ter)p 150 5141 3600 17 v
-eop end
+3017 1515 a Fi(V)-8 b(ersion)31 b(1.0-alpha5)3118 1623
+y(Septem)m(b)s(er)f(2009)150 4935 y Fh(Ed)45 b(Hartnett)150
+5068 y(Unidata)h(Program)g(Cen)l(ter)p 150 5141 3600
+17 v eop end
 %%Page: 2 2
 TeXDict begin 2 1 bop 150 3713 a Fi(Cop)m(yrigh)m(t)602
 3710 y(c)577 3713 y Fg(\015)30 b Fi(2006)i(Univ)m(ersit)m(y)g(Corp)s
@@ -1848,207 +1951,242 @@ b(of)f(an)m(y)h(commercial)g(compan)m(y)g(or)f(pro)s(duct)e(in)i(this)g
 (ertising)h(or)g(publicit)m(y)f(purp)s(oses.)p eop end
 %%Page: -1 3
 TeXDict begin -1 2 bop 3725 -116 a Fi(i)150 299 y Ff(T)-13
-b(able)53 b(of)h(Con)l(ten)l(ts)150 632 y Fh(Summary)17
-b Fe(.)i(.)g(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)
-h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f
-(.)h(.)f(.)61 b Fh(1)150 898 y(Do)l(wnloading)46 b(and)f(Installing)h
-(lib)t(cf)28 b Fe(.)20 b(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)
-f(.)g(.)73 b Fh(3)150 1164 y(1)135 b(The)44 b(cfc)l(hec)l(k)h(Utilit)l
-(y)e Fe(.)19 b(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g
-(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)85 b Fh(5)150 1430
-y(2)135 b(Files)30 b Fe(.)20 b(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f
-(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)
-f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)75 b Fh(7)275 1567
-y Fi(2.1)92 b(Mark)30 b(a)h(File)h(as)e(Conforming)g(to)h(CF)f(Con)m(v)
-m(en)m(tions)9 b Fd(.)16 b(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g
-(.)g(.)g(.)g(.)g(.)38 b Fi(7)275 1677 y(2.2)92 b(Determine)31
+b(able)53 b(of)h(Con)l(ten)l(ts)150 641 y Fh(Summary)18
+b Fe(:)h(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)
+f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h
+(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)62 b Fh(1)150
+911 y(Do)l(wnloading)46 b(and)f(Installing)h(lib)t(cf)24
+b Fe(:)c(:)g(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)
+f(:)69 b Fh(3)150 1181 y(1)135 b(Files)10 b Fe(:)20 b(:)f(:)h(:)f(:)h
+(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)h(:)f(:)h(:)f(:)g(:)55 b Fh(5)275 1318 y Fi(1.1)92
+b(Mark)30 b(a)h(File)h(as)e(Conforming)g(to)h(CF)f(Con)m(v)m(en)m
+(tions)11 b Fd(:)17 b(:)e(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h
+(:)f(:)g(:)h(:)f(:)41 b Fi(5)275 1427 y(1.2)92 b(Determine)31
 b(if)f(a)h(File)h(Claims)e(to)h(Conform)f(to)h(CF)f(Con)m(v)m(en)m
-(tions)12 b Fd(.)17 b(.)e(.)g(.)g(.)g(.)42 b Fi(7)275
-1786 y(2.3)92 b(Add)29 b(description)i(to)g(the)f(data)h(with)f(nccf)p
-1993 1786 28 4 v 40 w(def)p 2152 1786 V 40 w(\014le)f
-Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)58 b Fi(7)275 1896 y(2.4)92 b(Read)30 b(the)h(description)f(of)h
-(the)f(data)h(with)f(nccf)p 2176 1896 V 40 w(inq)p 2340
-1896 V 40 w(\014le)20 b Fd(.)c(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)50 b Fi(8)275 2006 y(2.5)92 b(App)s(end)28 b(to)j(a)g(History)g
-(A)m(ttribute)22 b Fd(.)16 b(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)51 b Fi(10)150 2244 y Fh(3)135 b(V)-11 b(ariables)19
-b Fe(.)h(.)g(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)h(.)f(.)
-g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)64
-b Fh(11)275 2381 y Fi(3.1)92 b(Add)29 b(description)i(to)g(a)f(v)-5
-b(ariable)32 b(with)e(nccf)p 2047 2381 V 40 w(def)p 2206
-2381 V 39 w(v)-5 b(ar)18 b Fd(.)d(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)47 b Fi(11)275 2491 y(3.2)92 b(Read)30
-b(v)-5 b(ariable)31 b(description)g(with)f(nccf)p 1894
-2491 V 40 w(inq)p 2058 2491 V 40 w(v)-5 b(ar)27 b Fd(.)15
-b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)57
-b Fi(11)275 2600 y(3.3)92 b(De\014ne)30 b(missing)g(data)h(v)-5
-b(alues)31 b(for)f(a)h(v)-5 b(ariable)31 b(with)f(nccf)p
-2493 2600 V 40 w(def)p 2652 2600 V 40 w(v)-5 b(ar)p 2816
-2600 V 40 w(missing)481 2710 y Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54
-b Fi(12)275 2819 y(3.4)92 b(Learn)30 b(ab)s(out)g(missing)g(data)h
-(settings)g(with)g(nccf)p 2239 2819 V 40 w(inq)p 2403
-2819 V 39 w(v)-5 b(ar)p 2566 2819 V 40 w(missing)11 b
-Fd(.)k(.)g(.)40 b Fi(13)275 2929 y(3.5)92 b(Add)29 b(CF-Recommended)i
-(Metadata)h(to)f(a)g(File)h(or)e(V)-8 b(ariable)32 b(with)23
-b Fd(.)15 b(.)g(.)52 b Fi(14)275 3039 y(3.6)92 b(Read)30
-b(v)-5 b(ariable)31 b(description)g(with)f(nccf)p 1894
-3039 V 40 w(inq)p 2058 3039 V 40 w(notes)f Fd(.)15 b(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)58 b Fi(14)275
-3148 y(3.7)92 b(De\014ne)30 b(a)h(co)s(ordinate)g(v)-5
+(tions)20 b Fd(:)d(:)f(:)f(:)g(:)h(:)50 b Fi(5)275 1537
+y(1.3)92 b(Add)29 b(description)i(to)g(the)f(data)h(with)f(nccf)p
+1993 1537 28 4 v 40 w(def)p 2152 1537 V 40 w(\014le)10
+b Fd(:)16 b(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)40 b Fi(5)275 1646 y(1.4)92 b(Read)30 b(the)h(description)f
+(of)h(the)f(data)h(with)f(nccf)p 2176 1646 V 40 w(inq)p
+2340 1646 V 40 w(\014le)17 b Fd(:)f(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h
+(:)f(:)g(:)h(:)47 b Fi(6)275 1756 y(1.5)92 b(App)s(end)28
+b(to)j(a)g(History)g(A)m(ttribute)24 b Fd(:)16 b(:)f(:)h(:)f(:)g(:)h(:)
+f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)54 b Fi(8)150 1998
+y Fh(2)135 b(V)-11 b(ariables)35 b Fe(:)19 b(:)h(:)f(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)79
+b Fh(9)275 2135 y Fi(2.1)92 b(Add)29 b(description)i(to)g(a)f(v)-5
+b(ariable)32 b(with)e(nccf)p 2047 2135 V 40 w(def)p 2206
+2135 V 39 w(v)-5 b(ar)20 b Fd(:)c(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)50 b Fi(9)275 2245 y(2.2)92
+b(Read)30 b(v)-5 b(ariable)31 b(description)g(with)f(nccf)p
+1894 2245 V 40 w(inq)p 2058 2245 V 40 w(v)-5 b(ar)13
+b Fd(:)i(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)
+h(:)f(:)g(:)h(:)43 b Fi(9)275 2355 y(2.3)92 b(De\014ne)30
+b(missing)g(data)h(v)-5 b(alues)31 b(for)f(a)h(v)-5 b(ariable)31
+b(with)f(nccf)p 2493 2355 V 40 w(def)p 2652 2355 V 40
+w(v)-5 b(ar)p 2816 2355 V 40 w(missing)478 2464 y Fd(:)15
+b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)51 b Fi(10)275
+2574 y(2.4)92 b(Learn)30 b(ab)s(out)g(missing)g(data)h(settings)g(with)
+g(nccf)p 2239 2574 V 40 w(inq)p 2403 2574 V 39 w(v)-5
+b(ar)p 2566 2574 V 40 w(missing)15 b Fd(:)g(:)h(:)44
+b Fi(11)275 2683 y(2.5)92 b(Add)29 b(CF-Recommended)i(Metadata)h(to)f
+(a)g(File)h(or)e(V)-8 b(ariable)32 b(with)27 b Fd(:)15
+b(:)g(:)57 b Fi(12)275 2793 y(2.6)92 b(Read)30 b(v)-5
+b(ariable)31 b(description)g(with)f(nccf)p 1894 2793
+V 40 w(inq)p 2058 2793 V 40 w(notes)9 b Fd(:)16 b(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)39 b Fi(12)275
+2902 y(2.7)92 b(De\014ne)30 b(a)h(co)s(ordinate)g(v)-5
 b(ariable)31 b(and)f(dimension)g(for)g(latitude)h(with)456
-3258 y(nccf)p 621 3258 V 40 w(def)p 780 3258 V 40 w(latitude)15
-b Fd(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)44 b Fi(15)275
-3367 y(3.8)92 b(Learn)30 b(ab)s(out)g(a)h(latitude)g(co)s(ordinate)g(v)
--5 b(ariable)31 b(and)f(dimension)g(with)481 3477 y Fd(.)15
-b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)54 b Fi(16)275 3587 y(3.9)92 b(De\014ne)30
-b(a)h(co)s(ordinate)g(v)-5 b(ariable)31 b(and)f(dimension)g(for)g
-(longitude)h(with)456 3696 y(nccf)p 621 3696 V 40 w(def)p
-780 3696 V 40 w(longitude)d Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)57
-b Fi(17)275 3806 y(3.10)92 b(Learn)30 b(ab)s(out)g(a)h(longitude)g(co)s
-(ordinate)g(v)-5 b(ariable)31 b(and)f(dimension)g(with)481
-3915 y Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fi(17)275 4025
-y(3.11)92 b(De\014ne)31 b(a)f(co)s(ordinate)i(v)-5 b(ariable)31
-b(and)f(dimension)f(for)h(lev)m(el)j(with)456 4134 y(nccf)p
-621 4134 V 40 w(def)p 780 4134 V 40 w(lvl)12 b Fd(.)k(.)f(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)41 b Fi(18)275 4244
-y(3.12)92 b(Learn)30 b(ab)s(out)g(a)h(lev)m(el)h(co)s(ordinate)f(v)-5
-b(ariable)31 b(and)f(dimension)g(with)f Fd(.)15 b(.)58
-b Fi(19)275 4354 y(3.13)92 b(De\014ne)31 b(a)f(co)s(ordinate)i(v)-5
+3012 y(nccf)p 621 3012 V 40 w(def)p 780 3012 V 40 w(latitude)12
+b Fd(:)k(:)g(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)
+h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)41
+b Fi(13)275 3122 y(2.8)92 b(Learn)30 b(ab)s(out)g(a)h(latitude)g(co)s
+(ordinate)g(v)-5 b(ariable)31 b(and)f(dimension)g(with)478
+3231 y Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)
+f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)
+f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)51
+b Fi(14)275 3341 y(2.9)92 b(De\014ne)30 b(a)h(co)s(ordinate)g(v)-5
+b(ariable)31 b(and)f(dimension)g(for)g(longitude)h(with)456
+3450 y(nccf)p 621 3450 V 40 w(def)p 780 3450 V 40 w(longitude)22
+b Fd(:)16 b(:)g(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)52 b Fi(15)275
+3560 y(2.10)92 b(Learn)30 b(ab)s(out)g(a)h(longitude)g(co)s(ordinate)g
+(v)-5 b(ariable)31 b(and)f(dimension)g(with)478 3670
+y Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)
+h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)51 b Fi(15)275
+3779 y(2.11)92 b(De\014ne)31 b(a)f(co)s(ordinate)i(v)-5
 b(ariable)31 b(and)f(dimension)f(for)h(lev)m(el)j(with)456
-4463 y(nccf)p 621 4463 V 40 w(def)p 780 4463 V 40 w(lvl)12
-b Fd(.)k(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)41
-b Fi(20)275 4573 y(3.14)92 b(Learn)30 b(ab)s(out)g(a)h(lev)m(el)h(co)s
-(ordinate)f(v)-5 b(ariable)31 b(and)f(dimension)g(with)f
-Fd(.)15 b(.)58 b Fi(20)275 4682 y(3.15)92 b(De\014ne)31
-b(a)f(co)s(ordinate)i(v)-5 b(ariable)31 b(and)f(dimension)f(for)h(time)
-i(with)456 4792 y(nccf)p 621 4792 V 40 w(def)p 780 4792
-V 40 w(time)16 b Fd(.)g(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)45
-b Fi(21)275 4902 y(3.16)92 b(Learn)30 b(ab)s(out)g(a)h(time)g(co)s
-(ordinate)g(v)-5 b(ariable)31 b(and)f(dimension)g(with)f
-Fd(.)15 b(.)58 b Fi(22)275 5011 y(3.17)92 b(De\014ne)31
-b(atmosphere)f(sigma)h(co)s(ordinate.)9 b Fd(.)16 b(.)f(.)g(.)g(.)g(.)g
-(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-38 b Fi(23)275 5121 y(3.18)92 b(Inquire)29 b(ab)s(out)i(atmosphere)f
-(sigma)h(co)s(ordinate.)13 b Fd(.)k(.)e(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)43 b Fi(23)275 5230 y(3.19)92
-b(De\014ne)31 b(atmosphere)f(sigma)h(co)s(ordinate.)9
-b Fd(.)16 b(.)f(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)38 b Fi(24)275 5340 y(3.20)92
-b(Inquire)29 b(ab)s(out)i(atmosphere)f(sigma)h(co)s(ordinate.)13
-b Fd(.)k(.)e(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-43 b Fi(24)p eop end
+3889 y(nccf)p 621 3889 V 40 w(def)p 780 3889 V 40 w(lvl)16
+b Fd(:)g(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)
+f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)
+45 b Fi(16)275 3998 y(2.12)92 b(Learn)30 b(ab)s(out)g(a)h(lev)m(el)h
+(co)s(ordinate)f(v)-5 b(ariable)31 b(and)f(dimension)g(with)11
+b Fd(:)16 b(:)f(:)41 b Fi(17)275 4108 y(2.13)92 b(De\014ne)31
+b(a)f(co)s(ordinate)i(v)-5 b(ariable)31 b(and)f(dimension)f(for)h(lev)m
+(el)j(with)456 4218 y(nccf)p 621 4218 V 40 w(def)p 780
+4218 V 40 w(lvl)16 b Fd(:)g(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)45 b Fi(18)275 4327 y(2.14)92 b(Learn)30
+b(ab)s(out)g(a)h(lev)m(el)h(co)s(ordinate)f(v)-5 b(ariable)31
+b(and)f(dimension)g(with)11 b Fd(:)16 b(:)f(:)41 b Fi(18)275
+4437 y(2.15)92 b(De\014ne)31 b(a)f(co)s(ordinate)i(v)-5
+b(ariable)31 b(and)f(dimension)f(for)h(time)i(with)456
+4546 y(nccf)p 621 4546 V 40 w(def)p 780 4546 V 40 w(time)17
+b Fd(:)f(:)g(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)
+h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)46
+b Fi(19)275 4656 y(2.16)92 b(Learn)30 b(ab)s(out)g(a)h(time)g(co)s
+(ordinate)g(v)-5 b(ariable)31 b(and)f(dimension)g(with)11
+b Fd(:)16 b(:)f(:)41 b Fi(20)275 4765 y(2.17)92 b(De\014ne)31
+b(atmosphere)f(sigma)h(co)s(ordinate.)20 b Fd(:)d(:)e(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)
+f(:)50 b Fi(21)275 4875 y(2.18)92 b(Inquire)29 b(ab)s(out)i(atmosphere)
+f(sigma)h(co)s(ordinate.)16 b Fd(:)g(:)g(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)
+f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)45 b Fi(21)275 4985 y(2.19)92
+b(De\014ne)31 b(atmosphere)f(sigma)h(co)s(ordinate.)20
+b Fd(:)d(:)e(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)50 b Fi(22)275 5094 y(2.20)92
+b(Inquire)29 b(ab)s(out)i(atmosphere)f(sigma)h(co)s(ordinate.)16
+b Fd(:)g(:)g(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)
+h(:)45 b Fi(22)275 5204 y(2.21)92 b(The)30 b(form)m(ula)p
+1023 5204 V 40 w(terms)g(attribute)i(for)e(atmosphere)g(h)m(ybrid)f
+(heigh)m(t)15 b Fd(:)i(:)f(:)f(:)45 b Fi(23)275 5313
+y(2.22)92 b(Inquire)29 b(ab)s(out)i(h)m(ybrid)e(heigh)m(t)i(co)s
+(ordinate.)26 b Fd(:)15 b(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)55 b Fi(23)p eop
+end
 %%Page: -2 4
 TeXDict begin -2 3 bop 150 -116 a Fi(ii)2396 b(The)30
-b(CF)g(Library)g(Users)g(Guide)275 83 y(3.21)92 b(The)30
-b(form)m(ula)p 1023 83 28 4 v 40 w(terms)g(attribute)i(for)e
-(atmosphere)g(h)m(ybrid)f(heigh)m(t)10 b Fd(.)17 b(.)e(.)g(.)39
-b Fi(25)275 193 y(3.22)92 b(Inquire)29 b(ab)s(out)i(h)m(ybrid)e(heigh)m
-(t)i(co)s(ordinate.)18 b Fd(.)e(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)47 b Fi(25)275
-302 y(3.23)92 b(De\014ne)31 b(atmosphere)f(slev)m(e)i(co)s(ordinate.)e
-Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)58 b Fi(26)275 412 y(3.24)92
-b(Inquire)29 b(Ab)s(out)h(Slev)m(e)i(Co)s(ordinate.)8
-b Fd(.)16 b(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)38 b Fi(27)275
-521 y(3.25)92 b(De\014ne)31 b(Ocean)f(Sigma)h(Co)s(ordinate.)e
-Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)57 b Fi(28)275
-631 y(3.26)92 b(Inquire)29 b(Ab)s(out)h(Ocean)h(Sigma)g(Co)s(ordinate.)
-21 b Fd(.)16 b(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)51 b Fi(28)275 741 y(3.27)92 b(De\014ne)31
-b(Ocean)f(S)g(Co)s(ordinate.)17 b Fd(.)e(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)46 b Fi(29)275 850 y(3.28)92 b(Inquire)29
-b(Ab)s(out)h(Ocean)h(S)f(Co)s(ordinate.)10 b Fd(.)15
-b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)39 b Fi(29)275 960 y(3.29)92
-b(De\014ne)31 b(Ocean)f(Sigma)h(Z)f(Co)s(ordinate.)f
-Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)58 b Fi(30)275 1069
-y(3.30)92 b(Inquire)29 b(Ab)s(out)h(Ocean)h(Sigma)g(Z)f(Co)s(ordinate.)
-22 b Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)51 b Fi(31)275 1179 y(3.31)92 b(De\014ne)31
-b(Ocean)f(Double)h(Sigma)g(Co)s(ordinate.)23 b Fd(.)15
-b(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)52 b Fi(32)275 1289 y(3.32)92 b(Inquire)29 b(Ab)s(out)h(Ocean)h
-(Double)g(Sigma)g(Co)s(ordinate.)16 b Fd(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)h(.)f(.)g(.)g(.)45 b Fi(33)275 1398 y(3.33)92 b(Get)31
-b(a)g(geographic)h(subset)e(of)g(the)h(data.)18 b Fd(.)e(.)f(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g
-(.)g(.)47 b Fi(34)150 1641 y Fh(4)135 b(Co)t(ordinate)46
-b(Systems)12 b Fe(.)20 b(.)f(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)
-f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)57 b Fh(35)275
-1778 y Fi(4.1)92 b(Lab)s(el)30 b(the)g(axis)h(t)m(yp)s(e)g(of)f(a)h(co)
-s(ordinate)g(v)-5 b(ar)31 b(with)f(nccf)p 2432 1778 V
-40 w(def)p 2591 1778 V 39 w(axis)p 2784 1778 V 41 w(t)m(yp)s(e)481
-1887 y Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fi(35)275 1997
-y(4.2)92 b(Find)30 b(out)g(the)h(axis)g(t)m(yp)s(e)f(of)h(a)f(co)s
-(ordinate)i(v)-5 b(ar)30 b(with)g(nccf)p 2558 1997 V
-40 w(inq)p 2722 1997 V 40 w(axis)p 2916 1997 V 40 w(t)m(yp)s(e)481
-2106 y Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fi(35)275 2216
-y(4.3)92 b(De\014ne)30 b(a)h(co)s(ordinate)g(system)g(with)f(nccf)p
-1960 2216 V 40 w(def)p 2119 2216 V 40 w(co)s(ord)p 2379
-2216 V 39 w(system)8 b Fd(.)16 b(.)f(.)g(.)g(.)g(.)g(.)g(.)38
-b Fi(35)275 2325 y(4.4)92 b(Find)30 b(out)g(ab)s(out)g(a)h(co)s
-(ordinate)g(system)g(with)f(nccf)p 2316 2325 V 40 w(inq)p
-2480 2325 V 40 w(co)s(ord)p 2740 2325 V 40 w(system)481
-2435 y Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fi(36)275 2545
-y(4.5)92 b(Assign)29 b(a)i(co)s(ordinate)f(system)g(to)h(a)f(v)-5
-b(ar)30 b(with)f(nccf)p 2306 2545 V 40 w(assign)p 2584
-2545 V 41 w(co)s(ord)p 2845 2545 V 40 w(system)481 2654
-y Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fi(36)275 2764 y(4.6)92
-b(De\014ne)30 b(a)h(co)s(ordinate)g(transform)f(with)g(nccf)p
-2076 2764 V 40 w(def)p 2235 2764 V 40 w(transform)22
-b Fd(.)14 b(.)h(.)g(.)g(.)g(.)g(.)h(.)51 b Fi(36)275
-2873 y(4.7)92 b(Find)30 b(out)g(ab)s(out)g(a)h(co)s(ordinate)g
-(transform)f(with)g(nccf)p 2432 2873 V 40 w(inq)p 2596
-2873 V 40 w(transform)481 2983 y Fd(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54
-b Fi(37)275 3093 y(4.8)92 b(Assign)30 b(a)h(co)s(ordinate)g(transform)f
-(to)h(a)g(co)s(ordinate)g(system)f(with)456 3202 y(nccf)p
-621 3202 V 40 w(assign)p 899 3202 V 41 w(transform)23
-b Fd(.)14 b(.)h(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g
-(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)
-g(.)g(.)g(.)g(.)g(.)52 b Fi(37)150 3445 y Fh(Index)37
-b Fe(.)19 b(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h
-(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)h(.)f(.)h(.)f(.)g(.)h(.)f(.)h(.)f(.)
-h(.)f(.)g(.)h(.)f(.)82 b Fh(39)p eop end
+b(CF)g(Library)g(Users)g(Guide)275 83 y(2.23)92 b(De\014ne)31
+b(atmosphere)f(slev)m(e)i(co)s(ordinate.)20 b Fd(:)d(:)e(:)g(:)h(:)f(:)
+h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)50 b Fi(24)275 193 y(2.24)92 b(Inquire)29
+b(Ab)s(out)h(Slev)m(e)i(Co)s(ordinate.)25 b Fd(:)15 b(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)55 b Fi(25)275 302 y(2.25)92
+b(De\014ne)31 b(Ocean)f(Sigma)h(Co)s(ordinate.)24 b Fd(:)15
+b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)53 b Fi(26)275
+412 y(2.26)92 b(Inquire)29 b(Ab)s(out)h(Ocean)h(Sigma)g(Co)s(ordinate.)
+d Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)57 b Fi(26)275 521 y(2.27)92 b(De\014ne)31
+b(Ocean)f(S)g(Co)s(ordinate.)18 b Fd(:)e(:)g(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)48 b Fi(27)275 631 y(2.28)92
+b(Inquire)29 b(Ab)s(out)h(Ocean)h(S)f(Co)s(ordinate.)23
+b Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)52 b Fi(27)275
+741 y(2.29)92 b(De\014ne)31 b(Ocean)f(Sigma)h(Z)f(Co)s(ordinate.)21
+b Fd(:)16 b(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h
+(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)50 b Fi(28)275
+850 y(2.30)92 b(Inquire)29 b(Ab)s(out)h(Ocean)h(Sigma)g(Z)f(Co)s
+(ordinate.)25 b Fd(:)15 b(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)g(:)55 b Fi(29)275 960 y(2.31)92
+b(De\014ne)31 b(Ocean)f(Double)h(Sigma)g(Co)s(ordinate.)9
+b Fd(:)16 b(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h
+(:)f(:)g(:)h(:)f(:)h(:)38 b Fi(30)275 1069 y(2.32)92
+b(Inquire)29 b(Ab)s(out)h(Ocean)h(Double)g(Sigma)g(Co)s(ordinate.)13
+b Fd(:)j(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)43
+b Fi(31)275 1179 y(2.33)92 b(Get)31 b(a)g(geographic)h(subset)e(of)g
+(the)h(data.)9 b Fd(:)17 b(:)e(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)39
+b Fi(32)150 1421 y Fh(3)135 b(Co)t(ordinate)46 b(Systems)22
+b Fe(:)e(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)
+f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)67 b Fh(33)275
+1558 y Fi(3.1)92 b(Lab)s(el)30 b(the)g(axis)h(t)m(yp)s(e)g(of)f(a)h(co)
+s(ordinate)g(v)-5 b(ar)31 b(with)f(nccf)p 2432 1558 28
+4 v 40 w(def)p 2591 1558 V 39 w(axis)p 2784 1558 V 41
+w(t)m(yp)s(e)478 1668 y Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)
+f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f
+(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)
+51 b Fi(33)275 1778 y(3.2)92 b(Find)30 b(out)g(the)h(axis)g(t)m(yp)s(e)
+f(of)h(a)f(co)s(ordinate)i(v)-5 b(ar)30 b(with)g(nccf)p
+2558 1778 V 40 w(inq)p 2722 1778 V 40 w(axis)p 2916 1778
+V 40 w(t)m(yp)s(e)478 1887 y Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)
+h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h
+(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)
+h(:)51 b Fi(33)275 1997 y(3.3)92 b(De\014ne)30 b(a)h(co)s(ordinate)g
+(system)g(with)f(nccf)p 1960 1997 V 40 w(def)p 2119 1997
+V 40 w(co)s(ord)p 2379 1997 V 39 w(system)19 b Fd(:)d(:)f(:)h(:)f(:)h
+(:)f(:)g(:)49 b Fi(33)275 2106 y(3.4)92 b(Find)30 b(out)g(ab)s(out)g(a)
+h(co)s(ordinate)g(system)g(with)f(nccf)p 2316 2106 V
+40 w(inq)p 2480 2106 V 40 w(co)s(ord)p 2740 2106 V 40
+w(system)478 2216 y Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)
+h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)51
+b Fi(34)275 2325 y(3.5)92 b(Assign)29 b(a)i(co)s(ordinate)f(system)g
+(to)h(a)f(v)-5 b(ar)30 b(with)f(nccf)p 2306 2325 V 40
+w(assign)p 2584 2325 V 41 w(co)s(ord)p 2845 2325 V 40
+w(system)478 2435 y Fd(:)15 b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)
+h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)51
+b Fi(34)275 2545 y(3.6)92 b(De\014ne)30 b(a)h(co)s(ordinate)g
+(transform)f(with)g(nccf)p 2076 2545 V 40 w(def)p 2235
+2545 V 40 w(transform)13 b Fd(:)h(:)h(:)h(:)f(:)h(:)f(:)g(:)h(:)42
+b Fi(34)275 2654 y(3.7)92 b(Find)30 b(out)g(ab)s(out)g(a)h(co)s
+(ordinate)g(transform)f(with)g(nccf)p 2432 2654 V 40
+w(inq)p 2596 2654 V 40 w(transform)478 2764 y Fd(:)15
+b(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)51 b Fi(35)275
+2873 y(3.8)92 b(Assign)30 b(a)h(co)s(ordinate)g(transform)f(to)h(a)g
+(co)s(ordinate)g(system)f(with)456 2983 y(nccf)p 621
+2983 V 40 w(assign)p 899 2983 V 41 w(transform)13 b Fd(:)i(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)43 b Fi(35)150 3225 y Fh(4)135 b(GRIDSPEC)45
+b(-)f(A)h(standard)g(for)g(the)g(description)h(of)419
+3358 y(grids)f(used)g(in)g(Earth)g(System)h(mo)t(dels)21
+b Fe(:)f(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)66 b Fh(37)275
+3495 y Fi(4.1)92 b(Mak)m(e)32 b(a)e(Horizon)m(tal)j(Grid)20
+b Fd(:)15 b(:)g(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)
+f(:)h(:)f(:)g(:)h(:)49 b Fi(37)275 3605 y(4.2)92 b(Remap)30
+b(data)h(from)f(Input)f(Mosaic)j(to)f(Output)e(Mosaic)20
+b Fd(:)e(:)d(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)50
+b Fi(39)275 3714 y(4.3)92 b(Generate)31 b(Mosaic)h(Information)f(Bet)m
+(w)m(een)h(Tiles)22 b Fd(:)16 b(:)g(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)52 b Fi(41)275 3824 y(4.4)92
+b(Remap)30 b(Riv)m(er)h(Net)m(w)m(ork)h(Data)18 b Fd(:)f(:)e(:)h(:)f(:)
+h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)48
+b Fi(42)275 3934 y(4.5)92 b(T)-8 b(ransfer)29 b(to)i(Mosaic)19
+b Fd(:)f(:)d(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)
+g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)49 b Fi(42)275
+4043 y(4.6)92 b(Mak)m(e)32 b(a)e(V)-8 b(ertical)33 b(Grid)12
+b Fd(:)j(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)
+h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)42 b Fi(42)275 4153 y(4.7)92
+b(Generate)31 b(Three)f(Exc)m(hange)i(Grids)d(for)i(FMS)f(Coupler)25
+b Fd(:)15 b(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)55
+b Fi(43)275 4262 y(4.8)92 b(Generate)31 b(T)-8 b(op)s(ograph)m(y)31
+b(for)f(An)m(y)g(Mosaic)c Fd(:)16 b(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g
+(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)54
+b Fi(44)150 4505 y Fh(Index)22 b Fe(:)d(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h
+(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)
+h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f(:)h(:)f(:)h(:)f(:)h(:)f(:)g(:)h(:)f
+(:)h(:)f(:)67 b Fh(47)p eop end
 %%Page: 1 5
 TeXDict begin 1 4 bop 150 -116 a Fi(Summary)3172 b(1)150
 299 y Ff(Summary)150 533 y Fi(The)36 b(CF)h(con)m(v)m(en)m(tions)i(for)
@@ -2083,8 +2221,7 @@ b(or)44 b(more)g(information)g(ab)s(out)f(the)h(CF)g(Con)m(v)m(en)m
 2411 y Fc(http://www.cgd.ucar.edu/)o(cms/)o(eato)o(n/c)o(f-me)o(tada)o
 (ta/)o(CF-1)o(.0.h)o(tml)o Fi(.)p eop end
 %%Page: 2 6
-TeXDict begin 2 5 bop 150 -116 a Fi(2)2401 b(The)30 b(CF)g(Library)g
-(Users)g(Guide)p eop end
+TeXDict begin 2 5 bop eop end
 %%Page: 3 7
 TeXDict begin 3 6 bop 150 -116 a Fi(Do)m(wnloading)32
 b(and)d(Installing)j(lib)s(cf)2257 b(3)150 299 y Ff(Do)l(wnloading)51
@@ -2124,24 +2261,11 @@ b(send)f(the)g(*complete*)j(output)d(of)h(the)f(con\014gure)g(and)g
 (is)h(generated)g(b)m(y)f(the)h(con\014gure)f(script.)p
 eop end
 %%Page: 4 8
-TeXDict begin 4 7 bop 150 -116 a Fi(4)2401 b(The)30 b(CF)g(Library)g
-(Users)g(Guide)p eop end
+TeXDict begin 4 7 bop eop end
 %%Page: 5 9
 TeXDict begin 5 8 bop 150 -116 a Fi(Chapter)30 b(1:)41
-b(The)30 b(cfc)m(hec)m(k)i(Utilit)m(y)2332 b(5)150 299
-y Ff(1)80 b(The)54 b(cfc)l(hec)l(k)e(Utilit)l(y)150 533
-y Fi(The)32 b(cfc)m(hc)m(k)i(utilit)m(y)h(will)e(c)m(hc)m(k)h(a)f
-(\014le)g(to)g(see)g(if)g(it)h(con)m(tains)f(v)-5 b(alid)34
-b(CF)e(metadata.)50 b(Messages)34 b(ab)s(out)150 643
-y(the)d(\014le)f(are)h(prin)m(ted)f(to)h(stdout.)p eop
-end
-%%Page: 6 10
-TeXDict begin 6 9 bop 150 -116 a Fi(6)2401 b(The)30 b(CF)g(Library)g
-(Users)g(Guide)p eop end
-%%Page: 7 11
-TeXDict begin 7 10 bop 150 -116 a Fi(Chapter)30 b(2:)41
-b(Files)2905 b(7)150 299 y Ff(2)80 b(Files)150 687 y
-Fh(2.1)68 b(Mark)45 b(a)g(File)g(as)h(Conforming)f(to)h(CF)e(Con)l(v)l
+b(Files)2905 b(5)150 299 y Ff(1)80 b(Files)150 687 y
+Fh(1.1)68 b(Mark)45 b(a)g(File)g(as)h(Conforming)f(to)h(CF)e(Con)l(v)l
 (en)l(tions)150 846 y Fi(Mark)31 b(the)f(\014le)h(as)f(follo)m(wing)i
 (CF-1.0)g(con)m(v)m(en)m(tions.)275 997 y(This)c(functions)h(is)g
 (called)i(automatically)h(b)m(y)d(nccf)p 2081 997 28
@@ -2153,7 +2277,7 @@ b(ncid\);)150 1706 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)
 150 1962 y Fh(Return)45 b(Co)t(des)150 2122 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h(netCDF)g(error)
 f(co)s(de)h(for)f(failure.)150 2378 y Fh(Example)150
-2628 y(2.2)68 b(Determine)47 b(if)e(a)g(File)g(Claims)i(to)e(Conform)g
+2628 y(1.2)68 b(Determine)47 b(if)e(a)g(File)g(Claims)i(to)e(Conform)g
 (to)h(CF)389 2761 y(Con)l(v)l(en)l(tions)150 2920 y Fi(Determine)39
 b(if)g(the)f(\014le)h(claims)g(to)g(follo)m(w)h(CF-1.0)g(con)m(v)m(en)m
 (tions.)67 b(This)37 b(function)h(only)h(c)m(hec)m(ks)h(the)150
@@ -2171,21 +2295,21 @@ b(this)h(p)s(oin)m(ter)g(to)h(an)e(in)m(t)i(is)e(pro)m(vided,)j(a)e(1)g
 (otherwise.)150 4390 y Fh(Return)45 b(Co)t(des)150 4549
 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h
 (netCDF)g(error)f(co)s(de)h(for)f(failure.)150 4806 y
-Fh(Example)150 5071 y(2.3)68 b(Add)44 b(description)h(to)h(the)f(data)h
+Fh(Example)150 5071 y(1.3)68 b(Add)44 b(description)h(to)h(the)f(data)h
 (with)f(nccf)p 2629 5071 41 6 v 58 w(def)p 2864 5071
 V 60 w(\014le)150 5230 y Fi(Add)34 b(some)h(or)f(all)i(of)e(the)h(CF)f
 (recommended)h(text)g(attributes)g(to)h(a)e(\014le.)54
 b(An)m(y)34 b(parameters)h(whic)m(h)150 5340 y(are)c(set)g(to)g(NULL)f
 (will)h(b)s(e)f(ignored.)p eop end
-%%Page: 8 12
-TeXDict begin 8 11 bop 150 -116 a Fi(8)2401 b(The)30
-b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Usage)390
-458 y Fc(int)47 b(nccf_def_file\(int)c(ncid,)j(char)h(*title,)f(char)g
-(*history,)g(char)g(*institution,)1249 568 y(char)h(*source,)e(char)i
-(*comment,)e(char)i(*references\);)150 729 y(ncid)288
-b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 889 y Fc(title)240
-b Fi(If)35 b(non-NULL,)g(this)h(text)g(string)g(will)f(b)s(e)g(written)
-h(as)f(the)h(CF-recommended)f(\\title")630 999 y(attribute.)150
+%%Page: 6 10
+TeXDict begin 6 9 bop 150 -116 a Fi(6)2401 b(The)30 b(CF)g(Library)g
+(Users)g(Guide)150 299 y Fh(Usage)390 458 y Fc(int)47
+b(nccf_def_file\(int)c(ncid,)j(char)h(*title,)f(char)g(*history,)g
+(char)g(*institution,)1249 568 y(char)h(*source,)e(char)i(*comment,)e
+(char)i(*references\);)150 729 y(ncid)288 b Fi(The)30
+b(ncid)g(of)g(the)h(\014le.)150 889 y Fc(title)240 b
+Fi(If)35 b(non-NULL,)g(this)h(text)g(string)g(will)f(b)s(e)g(written)h
+(as)f(the)h(CF-recommended)f(\\title")630 999 y(attribute.)150
 1159 y Fc(history)144 b Fi(If)25 b(non-NULL,)g(this)g(text)h(string)f
 (will)g(b)s(e)f(written)i(as)f(the)g(CF-recommended)g(\\history")630
 1269 y(attribute.)150 1429 y Fc(institution)630 1539
@@ -2201,7 +2325,7 @@ g(CF-recommended)g(\\com-)630 2188 y(men)m(t")31 b(attribute.)150
 (\\refer-)630 2568 y(ences")c(attribute.)150 2802 y Fh(Return)45
 b(Co)t(des)150 2961 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(a)h(netCDF)g(error)f(co)s(de)h(for)f(failure.)150
-3195 y Fh(Example)150 3453 y(2.4)68 b(Read)46 b(the)f(description)g(of)
+3195 y Fh(Example)150 3453 y(1.4)68 b(Read)46 b(the)f(description)g(of)
 g(the)h(data)f(with)h(nccf)p 2902 3453 41 6 v 58 w(inq)p
 3143 3453 V 59 w(\014le)150 3612 y Fi(Read)31 b(an)m(y)f(existing)i(CF)
 e(recommended)g(text)h(attributes)g(from)f(the)h(\014le.)275
@@ -2224,9 +2348,9 @@ y Fc(int)47 b(nccf_inq_file\(int)c(ncid,)j(size_t)g(*title_lenp,)f
 5179 y(size_t)f(*references_lenp,)d(char)k(*references\);)150
 5340 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)p
 eop end
-%%Page: 9 13
-TeXDict begin 9 12 bop 150 -116 a Fi(Chapter)30 b(2:)41
-b(Files)2905 b(9)150 299 y Fc(title_lenp)630 408 y Fi(P)m(oin)m(ter)32
+%%Page: 7 11
+TeXDict begin 7 10 bop 150 -116 a Fi(Chapter)30 b(1:)41
+b(Files)2905 b(7)150 299 y Fc(title_lenp)630 408 y Fi(P)m(oin)m(ter)32
 b(to)f(size)p 1208 408 28 4 v 41 w(t)f(whic)m(h,)h(if)f(not)h(NULL,)f
 (will)h(get)g(the)g(length)g(of)f(the)h(title)h(attribute.)150
 575 y Fc(title)240 b Fi(P)m(oin)m(ter)24 b(to)f(c)m(har)g(arra)m(y)g
@@ -2281,9 +2405,9 @@ y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i(\014rst.)150
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h(netCDF)g(error)
 f(co)s(de)h(for)f(failure.)150 5299 y Fh(Example)p eop
 end
-%%Page: 10 14
-TeXDict begin 10 13 bop 150 -116 a Fi(10)2356 b(The)30
-b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(2.5)68 b(App)t(end)43
+%%Page: 8 12
+TeXDict begin 8 11 bop 150 -116 a Fi(8)2401 b(The)30
+b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(1.5)68 b(App)t(end)43
 b(to)j(a)f(History)h(A)l(ttribute)150 458 y Fi(This)30
 b(function)h(app)s(ends)e(a)i(time-stamp)s(ed)h(history)f(string)g(to)g
 (the)g(history)g(attribute,)h(creating)h(the)150 568
@@ -2296,10 +2420,10 @@ b Fi(The)30 b(string)g(to)h(app)s(end)e(to)i(the)g(history)f
 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h
 (netCDF)g(error)f(co)s(de)h(for)f(failure.)150 1903 y
 Fh(Example)p eop end
-%%Page: 11 15
-TeXDict begin 11 14 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(11)150 299 y Ff(3)80 b(V)-13
-b(ariables)150 631 y Fh(3.1)68 b(Add)44 b(description)h(to)h(a)f(v)-7
+%%Page: 9 13
+TeXDict begin 9 12 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2727 b(9)150 299 y Ff(2)80 b(V)-13
+b(ariables)150 631 y Fh(2.1)68 b(Add)44 b(description)h(to)h(a)f(v)-7
 b(ariable)46 b(with)f(nccf)p 2708 631 41 6 v 59 w(def)p
 2944 631 V 59 w(v)-7 b(ar)150 888 y(Usage)390 1048 y
 Fc(int)47 b(nccf_def_var\(int)c(ncid,)k(int)g(varid,)f(const)g(char)h
@@ -2324,7 +2448,7 @@ b(IDs)f(of)h(the)g(co)s(ordinate)g(v)-5 b(ariables)31
 b(for)f(this)g(v)-5 b(ariable.)150 3382 y Fh(Return)45
 b(Co)t(des)150 3542 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(a)h(netCDF)g(error)f(co)s(de)h(for)f(failure.)150
-3774 y Fh(Example)150 4032 y(3.2)68 b(Read)46 b(v)-7
+3774 y Fh(Example)150 4032 y(2.2)68 b(Read)46 b(v)-7
 b(ariable)46 b(description)f(with)g(nccf)p 2484 4032
 41 6 v 59 w(inq)p 2726 4032 V 59 w(v)-7 b(ar)150 4191
 y Fi(Read)31 b(an)m(y)f(existing)i(CF)e(recommended)g(text)h
@@ -2336,8 +2460,8 @@ y Fi(Read)31 b(an)m(y)f(existing)i(CF)e(recommended)g(text)h
 (*coord_varids\);)150 5181 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h
 (\014le.)150 5340 y Fc(varid)240 b Fi(The)30 b(v)-5 b(arid)30
 b(of)g(the)h(netCDF)g(v)-5 b(ariable.)p eop end
-%%Page: 12 16
-TeXDict begin 12 15 bop 150 -116 a Fi(12)2356 b(The)30
+%%Page: 10 14
+TeXDict begin 10 13 bop 150 -116 a Fi(10)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(units_lenp)630
 408 y Fi(P)m(oin)m(ter)g(to)g(size)p 1205 408 28 4 v
 41 w(t)f(whic)m(h,)h(if)f(not)g(NULL,)g(will)g(get)i(the)e(length)g(of)
@@ -2379,7 +2503,7 @@ b(listed)g(in)m(t)g(he)f(\\co)s(ordinates")i(attribute.)150
 3479 y Fh(Return)45 b(Co)t(des)150 3638 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h(netCDF)g(error)
 f(co)s(de)h(for)f(failure.)150 3867 y Fh(Example)150
-4107 y(3.3)68 b(De\014ne)45 b(missing)h(data)f(v)-7 b(alues)46
+4107 y(2.3)68 b(De\014ne)45 b(missing)h(data)f(v)-7 b(alues)46
 b(for)f(a)g(v)-7 b(ariable)46 b(with)389 4240 y(nccf)p
 634 4240 41 6 v 59 w(def)p 870 4240 V 59 w(v)-7 b(ar)p
 1113 4240 V 59 w(missing)150 4399 y Fi(nccf)p 315 4399
@@ -2393,9 +2517,9 @@ b(ncid,)46 b(int)h(varid,)f(const)h(void)f(*fill_valuep,)1726
 5184 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
 5340 y Fc(varid)240 b Fi(The)30 b(v)-5 b(arid)30 b(of)g(the)h(netCDF)g
 (v)-5 b(ariable)31 b(b)s(eing)f(describ)s(ed.)p eop end
-%%Page: 13 17
-TeXDict begin 13 16 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(13)150 299 y Fc(fill_valuep)630
+%%Page: 11 15
+TeXDict begin 11 14 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(11)150 299 y Fc(fill_valuep)630
 408 y Fi(If)35 b(non-NULL,)g(this)g(will)g(p)s(oin)m(t)g(to)h(a)g(v)-5
 b(alue)35 b(of)h(the)f(same)g(t)m(yp)s(e)h(as)f(this)g(v)-5
 b(arid,)36 b(whic)m(h)630 518 y(will)31 b(b)s(e)e(used)h(as)h(the)f
@@ -2415,7 +2539,7 @@ w(max")35 b(attribute.)53 b(If)34 b(this)h(parameter)g(is)f(non-NULL,)
 (e)e(pro)m(vided.)150 1701 y Fh(Return)45 b(Co)t(des)150
 1860 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f
 (an)h(error)f(co)s(de)g(for)g(failure.)150 2084 y Fh(Example)150
-2322 y(3.4)68 b(Learn)45 b(ab)t(out)g(missing)h(data)f(settings)i(with)
+2322 y(2.4)68 b(Learn)45 b(ab)t(out)g(missing)h(data)f(settings)i(with)
 389 2455 y(nccf)p 634 2455 41 6 v 59 w(inq)p 876 2455
 V 59 w(v)-7 b(ar)p 1119 2455 V 59 w(missing)150 2614
 y Fi(Get)32 b(attributes)f(whic)m(h)f(de\014ne)g(missing)h(data)g
@@ -2457,10 +2581,10 @@ b(alue)30 b(will)h(b)s(e)f(used.)150 5181 y Fh(Return)45
 b(Co)t(des)150 5340 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)p
 eop end
-%%Page: 14 18
-TeXDict begin 14 17 bop 150 -116 a Fi(14)2356 b(The)30
+%%Page: 12 16
+TeXDict begin 12 15 bop 150 -116 a Fi(12)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Example)150
-538 y(3.5)68 b(Add)44 b(CF-Recommended)h(Metadata)h(to)g(a)f(File)g(or)
+538 y(2.5)68 b(Add)44 b(CF-Recommended)h(Metadata)h(to)g(a)f(File)g(or)
 g(V)-11 b(ariable)389 671 y(with)150 831 y Fi(nccf)p
 315 831 28 4 v 40 w(def)p 474 831 V 40 w(notes)275 963
 y(This)35 b(functions)h(writes)h(up)e(to)i(four)f(text)h(attributes)g
@@ -2490,7 +2614,7 @@ g(CF-recommended)g(\\com-)630 3111 y(men)m(t")31 b(attribute.)150
 (\\refer-)630 3485 y(ences")c(attribute.)150 3713 y Fh(Return)45
 b(Co)t(des)150 3872 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(a)h(netCDF)g(error)f(co)s(de)h(for)f(failure.)150
-4100 y Fh(Example)150 4355 y(3.6)68 b(Read)46 b(v)-7
+4100 y Fh(Example)150 4355 y(2.6)68 b(Read)46 b(v)-7
 b(ariable)46 b(description)f(with)g(nccf)p 2484 4355
 41 6 v 59 w(inq)p 2726 4355 V 59 w(notes)150 4514 y Fi(Read)31
 b(an)m(y)f(existing)i(CF)e(recommended)g(text)h(attributes)g(from)f(a)h
@@ -2501,9 +2625,9 @@ y(size_t)f(*institution_lenp,)d(char)j(*institution,)1297
 5230 y(size_t)f(*comment_lenp,)e(char)i(*comment,)1297
 5340 y(size_t)g(*references_lenp,)d(char)k(*references\);)p
 eop end
-%%Page: 15 19
-TeXDict begin 15 18 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(15)150 299 y Fc(ncid)288 b Fi(The)30
+%%Page: 13 17
+TeXDict begin 13 16 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(13)150 299 y Fc(ncid)288 b Fi(The)30
 b(ncid)g(of)g(the)h(\014le.)150 447 y Fc(varid)240 b
 Fi(The)30 b(v)-5 b(arid)30 b(of)g(the)h(netCDF)g(v)-5
 b(ariable.)150 596 y Fc(institution_lenp)630 706 y Fi(P)m(oin)m(ter)45
@@ -2544,7 +2668,7 @@ y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i(\014rst.)150
 3720 y Fh(Return)45 b(Co)t(des)150 3880 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h(netCDF)g(error)
 f(co)s(de)h(for)f(failure.)150 4102 y Fh(Example)150
-4338 y(3.7)68 b(De\014ne)45 b(a)g(co)t(ordinate)h(v)-7
+4338 y(2.7)68 b(De\014ne)45 b(a)g(co)t(ordinate)h(v)-7
 b(ariable)46 b(and)e(dimension)i(for)f(latitude)389 4471
 y(with)g(nccf)p 940 4471 41 6 v 59 w(def)p 1176 4471
 V 59 w(latitude)150 4630 y Fi(De\014ne)31 b(a)h(co)s(ordinate)g(v)-5
@@ -2554,8 +2678,8 @@ b(ariable)32 b(and)e(dimension)h(with)g(all)h(the)f(CF)g(recommended)g
 b(ncid,)k(size_t)g(len,)h(nc_type)f(xtype,)1583 5230
 y(const)h(char)f(*formula_terms,)e(int)j(*lat_dimidp,)1583
 5340 y(int)g(*lat_varidp\);)p eop end
-%%Page: 16 20
-TeXDict begin 16 19 bop 150 -116 a Fi(16)2356 b(The)30
+%%Page: 14 18
+TeXDict begin 14 17 bop 150 -116 a Fi(14)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(ncid)288
 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 467 y Fc(len)336
 b Fi(The)30 b(length)h(of)f(this)g(co)s(ordinate)i(dimension.)150
@@ -2574,7 +2698,7 @@ V 39 w(latitude)h(will)g(write)f(the)g(dimension)g(ID)g(of)g(the)g
 1799 y(dinate)g(v)-5 b(ariable)31 b(for)f(the)h(latitude)g(here.)150
 2046 y Fh(Return)45 b(Co)t(des)150 2205 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s
-(de)g(for)g(failure.)150 2451 y Fh(Example)150 2698 y(3.8)68
+(de)g(for)g(failure.)150 2451 y Fh(Example)150 2698 y(2.8)68
 b(Learn)45 b(ab)t(out)g(a)g(latitude)i(co)t(ordinate)e(v)-7
 b(ariable)46 b(and)389 2830 y(dimension)g(with)150 2990
 y Fi(nccf)p 315 2990 V 40 w(inq)p 479 2990 V 40 w(latitude)275
@@ -2601,12 +2725,12 @@ V 40 w(terms")h(attribute,)g(zero)g(will)f(b)s(e)630
 Fi(If)c(non-NULL,)h(the)g(v)-5 b(arid)27 b(of)h(the)g(latitude)g(co)s
 (ordinate)h(v)-5 b(ariable)28 b(will)g(b)s(e)f(written)h(here.)p
 eop end
-%%Page: 17 21
-TeXDict begin 17 20 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(17)150 299 y Fh(Return)45 b(Co)t(des)150
+%%Page: 15 19
+TeXDict begin 15 18 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(15)150 299 y Fh(Return)45 b(Co)t(des)150
 458 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f
 (an)h(error)f(co)s(de)g(for)g(failure.)150 741 y Fh(Example)150
-1000 y(3.9)68 b(De\014ne)45 b(a)g(co)t(ordinate)h(v)-7
+1000 y(2.9)68 b(De\014ne)45 b(a)g(co)t(ordinate)h(v)-7
 b(ariable)46 b(and)e(dimension)i(for)f(longitude)389
 1133 y(with)g(nccf)p 940 1133 41 6 v 59 w(def)p 1176
 1133 V 59 w(longitude)150 1292 y Fi(De\014ne)31 b(a)h(co)s(ordinate)g
@@ -2633,14 +2757,14 @@ g(v)-5 b(ariable)34 b(ID)f(of)g(the)g(netCDF)h(co-)630
 3896 y(ordinate)d(v)-5 b(ariable)31 b(for)f(the)h(longitude)g(here.)150
 4179 y Fh(Return)45 b(Co)t(des)150 4338 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s
-(de)g(for)g(failure.)150 4621 y Fh(Example)150 4880 y(3.10)68
+(de)g(for)g(failure.)150 4621 y Fh(Example)150 4880 y(2.10)68
 b(Learn)45 b(ab)t(out)g(a)h(longitude)f(co)t(ordinate)h(v)-7
 b(ariable)46 b(and)456 5012 y(dimension)g(with)150 5172
 y Fi(nccf)p 315 5172 V 40 w(inq)p 479 5172 V 40 w(longitude)275
 5340 y(Inquire)29 b(ab)s(out)h(a)h(longitude)g(dimension)f(and)f(co)s
 (ordinate)j(v)-5 b(ariable.)p eop end
-%%Page: 18 22
-TeXDict begin 18 21 bop 150 -116 a Fi(18)2356 b(The)30
+%%Page: 16 20
+TeXDict begin 16 19 bop 150 -116 a Fi(16)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Usage)390
 458 y Fc(int)47 b(nccf_inq_longitude\(int)42 b(ncid,)k(size_t)g(*lenp,)
 g(nc_type)g(*xtypep,)1583 568 y(size_t)g(*ft_lenp,)g(char)g
@@ -2664,7 +2788,7 @@ Fi(If)22 b(non-NULL,)h(the)f(v)-5 b(arid)23 b(of)f(the)h(longitude)g
 (co)s(ordinate)h(v)-5 b(ariable)23 b(will)g(b)s(e)f(written)h(here.)150
 2362 y Fh(Return)45 b(Co)t(des)150 2521 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s
-(de)g(for)g(failure.)150 2746 y Fh(Example)150 2985 y(3.11)68
+(de)g(for)g(failure.)150 2746 y Fh(Example)150 2985 y(2.11)68
 b(De\014ne)45 b(a)h(co)t(ordinate)f(v)-7 b(ariable)46
 b(and)f(dimension)g(for)g(lev)l(el)456 3117 y(with)h(nccf)p
 1008 3117 41 6 v 58 w(def)p 1243 3117 V 60 w(lvl)150
@@ -2689,9 +2813,9 @@ f(whic)m(h)g(will)g(b)s(e)g(written)g(as)h(the)f(\\units")h(attribute)g
 (attribute)h(\\p)s(ositiv)m(e")g(to)g(\\do)m(wn".)43
 b(Set)31 b(to)h(an)m(y)f(other)h(v)-5 b(alue)31 b(to)h(get)630
 5340 y(\\up".)p eop end
-%%Page: 19 23
-TeXDict begin 19 22 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(19)150 299 y Fc(standard_name)630
+%%Page: 17 21
+TeXDict begin 17 20 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(17)150 299 y Fc(standard_name)630
 408 y Fi(If)29 b(non-NULL,)h(a)g(string)g(whic)m(h)g(will)g(b)s(e)f
 (written)h(as)g(the)g(\\standard)p 3075 408 28 4 v 40
 w(name")g(attribute)630 518 y(on)g(the)h(co)s(ordinate)g(v)-5
@@ -2709,7 +2833,7 @@ b(ID)g(of)f(the)g(netCDF)h(co)s(ordinate)630 1632 y(v)-5
 b(ariable)31 b(for)f(the)h(lev)m(el)h(here.)150 1857
 y Fh(Return)45 b(Co)t(des)150 2017 y Fi(This)30 b(function)g(returns)f
 (zero)i(for)f(success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-2242 y Fh(Example)150 2480 y(3.12)68 b(Learn)45 b(ab)t(out)g(a)h(lev)l
+2242 y Fh(Example)150 2480 y(2.12)68 b(Learn)45 b(ab)t(out)g(a)h(lev)l
 (el)g(co)t(ordinate)g(v)-7 b(ariable)46 b(and)e(dimension)456
 2613 y(with)150 2773 y Fi(nccf)p 315 2773 V 40 w(inq)p
 479 2773 V 40 w(lvl)275 2904 y(Inquire)29 b(ab)s(out)h(a)h(lev)m(el)h
@@ -2741,14 +2865,14 @@ Fi(If)45 b(non-NULL,)g(a)g(one)h(will)f(b)s(e)f(written)i(here)f(if)g
 5230 y Fc(lvl_dimidp)630 5340 y Fi(If)f(non-NULL,)g(the)h(dimid)e(of)i
 (the)f(lev)m(el)j(dimension)c(will)i(b)s(e)f(written)g(here.)p
 eop end
-%%Page: 20 24
-TeXDict begin 20 23 bop 150 -116 a Fi(20)2356 b(The)30
+%%Page: 18 22
+TeXDict begin 18 21 bop 150 -116 a Fi(18)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(lvl_varidp)630
 408 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(arid)30 b(of)g(the)h(lev)m(el)h
 (co)s(ordinate)f(v)-5 b(ariable)31 b(will)g(b)s(e)f(written)g(here.)150
 649 y Fh(Return)45 b(Co)t(des)150 809 y Fi(This)30 b(function)g
 (returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s(de)g(for)g
-(failure.)150 1050 y Fh(Example)150 1294 y(3.13)68 b(De\014ne)45
+(failure.)150 1050 y Fh(Example)150 1294 y(2.13)68 b(De\014ne)45
 b(a)h(co)t(ordinate)f(v)-7 b(ariable)46 b(and)f(dimension)g(for)g(lev)l
 (el)456 1427 y(with)h(nccf)p 1008 1427 41 6 v 58 w(def)p
 1243 1427 V 60 w(lvl)150 1587 y Fi(De\014ne)40 b(a)h(unitless)f(v)m
@@ -2788,15 +2912,15 @@ Fc(llvl_varidp)630 3912 y Fi(If)c(non-NULL,)f(the)i(function)e(will)i
 (ordinate)630 4022 y(v)-5 b(ariable)31 b(for)f(the)h(lev)m(el)h(here.)
 150 4263 y Fh(Return)45 b(Co)t(des)150 4422 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s
-(de)g(for)g(failure.)150 4663 y Fh(Example)150 4908 y(3.14)68
+(de)g(for)g(failure.)150 4663 y Fh(Example)150 4908 y(2.14)68
 b(Learn)45 b(ab)t(out)g(a)h(lev)l(el)g(co)t(ordinate)g(v)-7
 b(ariable)46 b(and)e(dimension)456 5040 y(with)150 5200
 y Fi(nccf)p 315 5200 V 40 w(inq)p 479 5200 V 40 w(lvl)275
 5340 y(Inquire)29 b(ab)s(out)h(a)h(lev)m(el)h(dimension)e(and)f(co)s
 (ordinate)j(v)-5 b(ariable.)p eop end
-%%Page: 21 25
-TeXDict begin 21 24 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(21)150 299 y Fh(Usage)390 458
+%%Page: 19 23
+TeXDict begin 19 22 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(19)150 299 y Fh(Usage)390 458
 y Fc(int)47 b(nccf_inq_lvl_vert\(int)42 b(ncid,)k(char)h(*name,)f
 (nc_type)g(*xtypep,)f(size_t)h(*lenp,)1440 568 y(int)h(*lvl_typep,)e
 (int)i(*lvl_dimidp,)d(int)j(*lvl_varidp\);)150 741 y(ncid)288
@@ -2832,7 +2956,7 @@ b(arid)30 b(of)g(the)h(lev)m(el)h(co)s(ordinate)f(v)-5
 b(ariable)31 b(will)g(b)s(e)f(written)g(here.)150 2764
 y Fh(Return)45 b(Co)t(des)150 2924 y Fi(This)30 b(function)g(returns)f
 (zero)i(for)f(success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-3170 y Fh(Example)150 3416 y(3.15)68 b(De\014ne)45 b(a)h(co)t(ordinate)
+3170 y Fh(Example)150 3416 y(2.15)68 b(De\014ne)45 b(a)h(co)t(ordinate)
 f(v)-7 b(ariable)46 b(and)f(dimension)g(for)g(time)456
 3549 y(with)h(nccf)p 1008 3549 41 6 v 58 w(def)p 1243
 3549 V 60 w(time)150 3708 y Fi(De\014ne)31 b(a)h(co)s(ordinate)g(v)-5
@@ -2851,8 +2975,8 @@ b Fi(The)30 b(length)h(of)f(this)g(co)s(ordinate)i(dimension.)150
 (written)i(as)f(the)g(\\form)m(ula)p 3060 5230 28 4 v
 41 w(terms")g(attribute)630 5340 y(on)d(the)h(co)s(ordinate)g(v)-5
 b(ariable.)p eop end
-%%Page: 22 26
-TeXDict begin 22 25 bop 150 -116 a Fi(22)2356 b(The)30
+%%Page: 20 24
+TeXDict begin 20 23 bop 150 -116 a Fi(20)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(lon_dimidp)630
 408 y Fi(If)e(non-NULL,)g(nccf)p 1364 408 28 4 v 40 w(def)p
 1523 408 V 39 w(time)h(will)g(write)f(the)g(dimension)g(ID)g(of)g(the)h
@@ -2863,7 +2987,7 @@ b(ariable)24 b(ID)f(of)g(the)g(netCDF)h(co)s(ordinate)630
 902 y(v)-5 b(ariable)31 b(for)f(the)h(time)g(here.)150
 1143 y Fh(Return)45 b(Co)t(des)150 1303 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s
-(de)g(for)g(failure.)150 1544 y Fh(Example)150 1788 y(3.16)68
+(de)g(for)g(failure.)150 1544 y Fh(Example)150 1788 y(2.16)68
 b(Learn)45 b(ab)t(out)g(a)h(time)f(co)t(ordinate)h(v)-7
 b(ariable)46 b(and)f(dimension)456 1921 y(with)150 2081
 y Fi(nccf)p 315 2081 V 40 w(inq)p 479 2081 V 40 w(time)275
@@ -2896,9 +3020,9 @@ b(will)g(b)s(e)f(written)g(here.)150 4897 y Fh(Return)45
 b(Co)t(des)150 5057 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
 5297 y Fh(Example)p eop end
-%%Page: 23 27
-TeXDict begin 23 26 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(23)150 299 y Fh(3.17)68 b(De\014ne)45
+%%Page: 21 25
+TeXDict begin 21 24 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(21)150 299 y Fh(2.17)68 b(De\014ne)45
 b(atmosphere)h(sigma)g(co)t(ordinate.)150 458 y Fi(De\014ne)31
 b(form)m(ula)f(terms)g(attribute)i(for)e(atmosphere)g(sigma)h(co)s
 (ordinate)h(v)-5 b(ariable.)150 691 y Fh(Usage)390 851
@@ -2912,7 +3036,7 @@ b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(ps)e(v)-5 b(ariable.)150
 b(ID)g(of)f(the)h(ptop)f(v)-5 b(ariable.)150 1941 y Fh(Return)45
 b(Co)t(des)150 2101 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-2334 y Fh(Example)150 2591 y(3.18)68 b(Inquire)45 b(ab)t(out)g
+2334 y Fh(Example)150 2591 y(2.18)68 b(Inquire)45 b(ab)t(out)g
 (atmosphere)h(sigma)g(co)t(ordinate.)150 2751 y Fi(nccf)p
 315 2751 28 4 v 40 w(inq)p 479 2751 V 40 w(time)275 2885
 y(Inquire)29 b(ab)s(out)h(atmosphere)h(sigma)g(co)s(ordinate.)150
@@ -2938,12 +3062,12 @@ b(will)g(b)s(e)f(written)g(here.)150 4674 y Fc(ptop_varidp)630
 5213 y Fc(lvl_varidp)630 5322 y Fi(If)g(non-NULL,)g(the)h(v)-5
 b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)p eop end
-%%Page: 24 28
-TeXDict begin 24 27 bop 150 -116 a Fi(24)2356 b(The)30
+%%Page: 22 26
+TeXDict begin 22 25 bop 150 -116 a Fi(22)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Return)45
 b(Co)t(des)150 458 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-691 y Fh(Example)150 948 y(3.19)68 b(De\014ne)45 b(atmosphere)h(sigma)g
+691 y Fh(Example)150 948 y(2.19)68 b(De\014ne)45 b(atmosphere)h(sigma)g
 (co)t(ordinate.)150 1107 y Fi(De\014ne)31 b(form)m(ula)f(terms)g
 (attribute)i(for)e(atmosphere)g(h)m(ybrid)f(sigma)i(co)s(ordinate)h(v)
 -5 b(ariable.)150 1339 y Fh(Usage)390 1499 y Fc(int)47
@@ -2961,7 +3085,7 @@ b(ariable)31 b(ID)g(of)f(the)h(ps)e(v)-5 b(ariable.)150
 b(ID)g(of)f(the)h(ptop)f(v)-5 b(ariable.)150 2906 y Fh(Return)45
 b(Co)t(des)150 3065 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-3297 y Fh(Example)150 3555 y(3.20)68 b(Inquire)45 b(ab)t(out)g
+3297 y Fh(Example)150 3555 y(2.20)68 b(Inquire)45 b(ab)t(out)g
 (atmosphere)h(sigma)g(co)t(ordinate.)150 3714 y Fi(Inquire)29
 b(ab)s(out)h(atmosphere)h(h)m(ybrid)e(sigma)i(co)s(ordinate.)150
 3946 y Fh(Usage)390 4106 y Fc(int)47 b(nccf_inq_lvl_hybrid_sigm)o
@@ -2980,9 +3104,9 @@ b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h(co)s(ordinate)g
 y Fc(a_varidp)96 b Fi(If)30 b(non-NULL,)g(the)h(v)-5
 b(ariable)31 b(ID)g(of)f(the)h(a)f(v)-5 b(ariable)32
 b(will)e(b)s(e)g(written)g(here.)p eop end
-%%Page: 25 29
-TeXDict begin 25 28 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(25)150 299 y Fc(b_varidp)96
+%%Page: 23 27
+TeXDict begin 23 26 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(23)150 299 y Fc(b_varidp)96
 b Fi(If)30 b(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h(b)e
 (v)-5 b(ariable)32 b(will)e(b)s(e)g(written)g(here.)150
 478 y Fc(ps_varidp)630 588 y Fi(If)g(non-NULL,)g(the)h(v)-5
@@ -2997,7 +3121,7 @@ b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)150 1717 y Fh(Return)45
 b(Co)t(des)150 1876 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-2138 y Fh(Example)150 2390 y(3.21)68 b(The)45 b(form)l(ula)p
+2138 y Fh(Example)150 2390 y(2.21)68 b(The)45 b(form)l(ula)p
 1188 2390 41 6 v 60 w(terms)h(attribute)g(for)f(atmosphere)h(h)l(ybrid)
 456 2523 y(heigh)l(t)150 2682 y Fi(De\014ne)31 b(form)m(ula)f(terms)g
 (attribute)i(for)e(atmosphere)g(h)m(ybrid)f(heigh)m(t)j(co)s(ordinate)f
@@ -3008,18 +3132,18 @@ h(a_varid,)f(int)g(b_varid,)1822 3214 y(int)h(orog_varid\);)150
 3582 y Fc(varid)240 b Fi(The)30 b(v)-5 b(arid)30 b(of)g(the)h(v)m
 (ertical)i(co)s(ordinate)e(v)-5 b(ariable.)150 3761 y
 Fc(a_varid)144 b Fi(The)30 b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(a)f(v)
--5 b(ariable.)150 3940 y Fc(b_varid)144 b Fi(The)30 b(v)-5
+-5 b(ariable.)150 3941 y Fc(b_varid)144 b Fi(The)30 b(v)-5
 b(ariable)31 b(ID)g(of)f(the)h(b)f(v)-5 b(ariable.)150
 4120 y Fc(orog_varid)630 4229 y Fi(The)30 b(v)-5 b(ariable)31
 b(ID)g(of)f(the)h(orog)g(v)-5 b(ariable.)150 4492 y Fh(Return)45
 b(Co)t(des)150 4651 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-4913 y Fh(Example)150 5181 y(3.22)68 b(Inquire)45 b(ab)t(out)g(h)l
+4913 y Fh(Example)150 5181 y(2.22)68 b(Inquire)45 b(ab)t(out)g(h)l
 (ybrid)g(heigh)l(t)h(co)t(ordinate.)150 5340 y Fi(Inquire)29
 b(ab)s(out)h(the)h(h)m(ybrid)e(heigh)m(t)i(co)s(ordinate.)p
 eop end
-%%Page: 26 30
-TeXDict begin 26 29 bop 150 -116 a Fi(26)2356 b(The)30
+%%Page: 24 28
+TeXDict begin 24 27 bop 150 -116 a Fi(24)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Usage)390
 458 y Fc(int)47 b(nccf_inq_lvl_hybrid_heig)o(ht\(i)o(nt)41
 b(ncid,)47 b(char)f(*name,)h(nc_type)e(*xtypep,)h(size_t)g(*lenp,)1870
@@ -3048,7 +3172,7 @@ b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)150 2820 y Fh(Return)45
 b(Co)t(des)150 2980 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-3217 y Fh(Example)150 3476 y(3.23)68 b(De\014ne)45 b(atmosphere)h(slev)
+3217 y Fh(Example)150 3476 y(2.23)68 b(De\014ne)45 b(atmosphere)h(slev)
 l(e)h(co)t(ordinate.)150 3636 y Fi(De\014ne)31 b(form)m(ula)f(terms)g
 (attribute)i(for)e(the)g(atmosphere)h(slev)m(e)h(co)s(ordinate)f(v)-5
 b(ariable.)150 3873 y Fh(Usage)390 4033 y Fc(int)47 b
@@ -3065,15 +3189,15 @@ b(ariable)31 b(ID)g(of)f(the)h(b1)f(v)-5 b(ariable.)150
 b(ID)g(of)f(the)h(b2)f(v)-5 b(ariable.)150 5230 y Fc(ztop_varid)630
 5340 y Fi(The)30 b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(ztop)g(v)-5
 b(ariable.)p eop end
-%%Page: 27 31
-TeXDict begin 27 30 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(27)150 299 y Fc(zsurf1_varid)630
+%%Page: 25 29
+TeXDict begin 25 28 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(25)150 299 y Fc(zsurf1_varid)630
 408 y Fi(The)30 b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(zsurf1)f(v)-5
 b(ariable.)150 573 y Fc(zsurf2_varid)630 683 y Fi(The)30
 b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(zsurf2)f(v)-5 b(ariable.)150
 923 y Fh(Return)45 b(Co)t(des)150 1082 y Fi(This)30 b(function)g
 (returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s(de)g(for)g
-(failure.)150 1322 y Fh(Example)150 1582 y(3.24)68 b(Inquire)45
+(failure.)150 1322 y Fh(Example)150 1582 y(2.24)68 b(Inquire)45
 b(Ab)t(out)f(Slev)l(e)i(Co)t(ordinate.)150 1741 y Fi(Inquire)29
 b(ab)s(out)h(the)h(slev)m(e)h(co)s(ordinate.)150 1981
 y Fh(Usage)390 2141 y Fc(int)47 b(nccf_inq_lvl_sleve\(int)42
@@ -3109,12 +3233,12 @@ b(will)f(b)s(e)g(written)h(here.)150 4665 y Fc(zsurf2_varidp)630
 5213 y Fc(lvl_varidp)630 5322 y Fi(If)g(non-NULL,)g(the)h(v)-5
 b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)p eop end
-%%Page: 28 32
-TeXDict begin 28 31 bop 150 -116 a Fi(28)2356 b(The)30
+%%Page: 26 30
+TeXDict begin 26 29 bop 150 -116 a Fi(26)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Return)45
 b(Co)t(des)150 458 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-677 y Fh(Example)150 927 y(3.25)68 b(De\014ne)45 b(Ocean)h(Sigma)f(Co)t
+677 y Fh(Example)150 927 y(2.25)68 b(De\014ne)45 b(Ocean)h(Sigma)f(Co)t
 (ordinate.)150 1086 y Fi(De\014ne)31 b(the)f(form)m(ula)h(terms)f
 (attribute)h(for)f(the)h(o)s(cean)g(sigma)g(co)s(ordinate)g(v)-5
 b(ariable.)150 1305 y Fh(Usage)390 1464 y Fc(int)47 b
@@ -3128,7 +3252,7 @@ b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(eta)g(v)-5 b(ariable.)150
 b(ID)g(of)f(the)h(depth)e(v)-5 b(ariable.)150 2483 y
 Fh(Return)45 b(Co)t(des)150 2642 y Fi(This)30 b(function)g(returns)f
 (zero)i(for)f(success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-2860 y Fh(Example)150 3111 y(3.26)68 b(Inquire)45 b(Ab)t(out)f(Ocean)i
+2860 y Fh(Example)150 3111 y(2.26)68 b(Inquire)45 b(Ab)t(out)f(Ocean)i
 (Sigma)f(Co)t(ordinate.)150 3270 y Fi(Inquire)29 b(ab)s(out)h(the)h(o)s
 (cean)g(sigma)g(co)s(ordinate.)150 3488 y Fh(Usage)390
 3648 y Fc(int)47 b(nccf_inq_lvl_ocean_sigma)o(\(int)41
@@ -3151,12 +3275,12 @@ b(will)g(b)s(e)f(written)g(here.)150 4958 y Fc(lvl_dimidp)630
 y Fc(lvl_varidp)630 5322 y Fi(If)g(non-NULL,)g(the)h(v)-5
 b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)p eop end
-%%Page: 29 33
-TeXDict begin 29 32 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(29)150 299 y Fh(Return)45 b(Co)t(des)150
+%%Page: 27 31
+TeXDict begin 27 30 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(27)150 299 y Fh(Return)45 b(Co)t(des)150
 458 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f
 (an)h(error)f(co)s(de)g(for)g(failure.)150 686 y Fh(Example)150
-941 y(3.27)68 b(De\014ne)45 b(Ocean)h(S)e(Co)t(ordinate.)150
+941 y(2.27)68 b(De\014ne)45 b(Ocean)h(S)e(Co)t(ordinate.)150
 1101 y Fi(De\014ne)31 b(o)s(cean)g(s)f(co)s(ordinate.)150
 1329 y Fh(Usage)390 1488 y Fc(int)47 b(nccf_def_ft_ocean_s\(int)41
 b(ncid,)47 b(const)f(char)h(*name,)f(nc_type)g(xtype,)g(size_t)g(len,)
@@ -3185,13 +3309,13 @@ b(ariable)26 b(ID)f(of)g(the)g(netCDF)g(co)s(ordinate)h(v)-5
 b(ariable)26 b(will)f(b)s(e)f(written)630 4178 y(here.)150
 4406 y Fh(Return)45 b(Co)t(des)150 4565 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s
-(de)g(for)g(failure.)150 4793 y Fh(Example)150 5048 y(3.28)68
+(de)g(for)g(failure.)150 4793 y Fh(Example)150 5048 y(2.28)68
 b(Inquire)45 b(Ab)t(out)f(Ocean)i(S)e(Co)t(ordinate.)150
 5208 y Fi(nccf)p 315 5208 V 40 w(inq)p 479 5208 V 40
 w(time)275 5340 y(Inquire)29 b(ab)s(out)h(the)h(o)s(cean)g(s)f(co)s
 (ordinate.)p eop end
-%%Page: 30 34
-TeXDict begin 30 33 bop 150 -116 a Fi(30)2356 b(The)30
+%%Page: 28 32
+TeXDict begin 28 31 bop 150 -116 a Fi(28)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Usage)390
 458 y Fc(int)47 b(nccf_inq_lvl_ocean_s\(int)41 b(ncid,)46
 b(char)h(*name,)f(nc_type)g(*xtypep,)g(size_t)g(*lenp,)1583
@@ -3226,7 +3350,7 @@ b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)150 3328 y Fh(Return)45
 b(Co)t(des)150 3488 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-3721 y Fh(Example)150 3979 y(3.29)68 b(De\014ne)45 b(Ocean)h(Sigma)f(Z)
+3721 y Fh(Example)150 3979 y(2.29)68 b(De\014ne)45 b(Ocean)h(Sigma)f(Z)
 g(Co)t(ordinate.)150 4138 y Fi(De\014ne)31 b(o)s(cean)g(sigma)g(z)f(co)
 s(ordinate.)150 4372 y Fh(Usage)390 4531 y Fc(int)47
 b(nccf_def_ft_ocean_sigma_)o(z\(in)o(t)42 b(ncid,)k(const)g(char)h
@@ -3239,9 +3363,9 @@ b Fi(The)30 b(v)-5 b(arid)30 b(of)g(the)h(v)m(ertical)i(co)s(ordinate)e
 (v)-5 b(ariable.)150 5340 y Fc(xtype)240 b Fi(The)30
 b(t)m(yp)s(e)g(of)h(this)f(co)s(ordinate)h(v)-5 b(ariable.)p
 eop end
-%%Page: 31 35
-TeXDict begin 31 34 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(31)150 299 y Fc(len)336 b Fi(The)30
+%%Page: 29 33
+TeXDict begin 29 32 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(29)150 299 y Fc(len)336 b Fi(The)30
 b(length)h(of)f(this)g(co)s(ordinate)i(dimension.)150
 452 y Fc(eta_varid)630 561 y Fi(The)e(v)-5 b(ariable)31
 b(ID)g(of)f(the)h(eta)g(v)-5 b(ariable.)150 714 y Fc(depth_varid)630
@@ -3260,7 +3384,7 @@ b(ID)f(of)g(the)g(netCDF)g(co)s(ordinate)h(v)-5 b(ariable)26
 b(will)f(b)s(e)f(written)630 2355 y(here.)150 2581 y
 Fh(Return)45 b(Co)t(des)150 2741 y Fi(This)30 b(function)g(returns)f
 (zero)i(for)f(success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-2966 y Fh(Example)150 3221 y(3.30)68 b(Inquire)45 b(Ab)t(out)f(Ocean)i
+2966 y Fh(Example)150 3221 y(2.30)68 b(Inquire)45 b(Ab)t(out)f(Ocean)i
 (Sigma)f(Z)g(Co)t(ordinate.)150 3380 y Fi(Inquire)29
 b(ab)s(out)h(the)h(o)s(cean)g(sigma)g(z)g(co)s(ordinate.)150
 3606 y Fh(Usage)390 3765 y Fc(int)47 b(nccf_inq_lvl_ocean_sigma)o
@@ -3282,8 +3406,8 @@ b(will)g(b)s(e)f(written)g(here.)150 5230 y Fc(depth_varidp)630
 5340 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
 (depth)e(v)-5 b(ariable)31 b(will)g(b)s(e)f(written)g(here.)p
 eop end
-%%Page: 32 36
-TeXDict begin 32 35 bop 150 -116 a Fi(32)2356 b(The)30
+%%Page: 30 34
+TeXDict begin 30 33 bop 150 -116 a Fi(30)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(depth_c_varidp)630
 408 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
 (depth)p 2328 408 28 4 v 39 w(c)g(v)-5 b(ariable)31 b(will)g(b)s(e)e
@@ -3300,7 +3424,7 @@ b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)150 1765 y Fh(Return)45
 b(Co)t(des)150 1925 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-2170 y Fh(Example)150 2432 y(3.31)68 b(De\014ne)45 b(Ocean)h(Double)f
+2170 y Fh(Example)150 2432 y(2.31)68 b(De\014ne)45 b(Ocean)h(Double)f
 (Sigma)g(Co)t(ordinate.)150 2591 y Fi(De\014ne)31 b(o)s(cean)g(double)f
 (sigma)h(co)s(ordinate.)150 2837 y Fh(Usage)390 2996
 y Fc(int)47 b(nccf_def_ft_ocean_dbl_si)o(gma\()o(int)41
@@ -3325,9 +3449,9 @@ b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(href)e(v)-5 b(ariable.)150
 5230 y Fc(k_c_varid)630 5340 y Fi(The)30 b(v)-5 b(ariable)31
 b(ID)g(of)f(the)h(k)p 1605 5340 V 40 w(c)f(v)-5 b(ariable.)p
 eop end
-%%Page: 33 37
-TeXDict begin 33 36 bop 150 -116 a Fi(Chapter)30 b(3:)41
-b(V)-8 b(ariables)2681 b(33)150 299 y Fc(lvl_dimidp)630
+%%Page: 31 35
+TeXDict begin 31 34 bop 150 -116 a Fi(Chapter)30 b(2:)41
+b(V)-8 b(ariables)2681 b(31)150 299 y Fc(lvl_dimidp)630
 408 y Fi(If)37 b(non-NULL,)g(the)g(dimension)g(ID)g(of)g(the)h(netCDF)f
 (co)s(ordinate)h(dimension)f(will)h(b)s(e)630 518 y(written)30
 b(here.)150 670 y Fc(lvl_varidp)630 779 y Fi(If)24 b(non-NULL,)h(the)g
@@ -3335,7 +3459,7 @@ b(here.)150 670 y Fc(lvl_varidp)630 779 y Fi(If)24 b(non-NULL,)h(the)g
 b(ariable)26 b(will)f(b)s(e)f(written)630 889 y(here.)150
 1114 y Fh(Return)45 b(Co)t(des)150 1273 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(an)h(error)f(co)s
-(de)g(for)g(failure.)150 1498 y Fh(Example)150 1752 y(3.32)68
+(de)g(for)g(failure.)150 1498 y Fh(Example)150 1752 y(2.32)68
 b(Inquire)45 b(Ab)t(out)f(Ocean)i(Double)f(Sigma)g(Co)t(ordinate.)150
 1911 y Fi(Inquire)29 b(ab)s(out)h(the)h(o)s(cean)g(double)f(sigma)h(co)
 s(ordinate.)150 2136 y Fh(Usage)390 2295 y Fc(int)47
@@ -3372,12 +3496,12 @@ g(here.)150 4951 y Fc(lvl_dimidp)630 5061 y Fi(If)g(non-NULL,)g(the)h
 g(here.)150 5213 y Fc(lvl_varidp)630 5322 y Fi(If)g(non-NULL,)g(the)h
 (v)-5 b(arid)30 b(of)g(the)h(co)s(ordinate)g(v)-5 b(ariable)31
 b(will)g(b)s(e)f(written)g(here.)p eop end
-%%Page: 34 38
-TeXDict begin 34 37 bop 150 -116 a Fi(34)2356 b(The)30
+%%Page: 32 36
+TeXDict begin 32 35 bop 150 -116 a Fi(32)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Return)45
 b(Co)t(des)150 458 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(an)h(error)f(co)s(de)g(for)g(failure.)150
-691 y Fh(Example)150 948 y(3.33)68 b(Get)46 b(a)f(geographic)h(subset)f
+691 y Fh(Example)150 948 y(2.33)68 b(Get)46 b(a)f(geographic)h(subset)f
 (of)g(the)g(data.)150 1108 y Fi(Get)31 b(a)g(geographic)h(subset)e(of)g
 (the)h(data.)150 1340 y Fh(Usage)533 1499 y Fc(int)47
 b(nccf_get_vara\(int)c(ncid,)k(int)f(varid,)h(float)f(*lat_bounds,)e
@@ -3414,10 +3538,10 @@ b(m)m(ust)g(b)s(e)f(allo)s(cated)630 4139 y(\(and)i(deallo)s(cated\))j
 4531 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f
 (an)h(error)f(co)s(de)g(for)g(failure.)150 4764 y Fh(Example)p
 eop end
-%%Page: 35 39
-TeXDict begin 35 38 bop 150 -116 a Fi(Chapter)30 b(4:)41
-b(Co)s(ordinate)30 b(Systems)2250 b(35)150 299 y Ff(4)80
-b(Co)t(ordinate)53 b(Systems)150 657 y Fh(4.1)68 b(Lab)t(el)45
+%%Page: 33 37
+TeXDict begin 33 36 bop 150 -116 a Fi(Chapter)30 b(3:)41
+b(Co)s(ordinate)30 b(Systems)2250 b(33)150 299 y Ff(3)80
+b(Co)t(ordinate)53 b(Systems)150 657 y Fh(3.1)68 b(Lab)t(el)45
 b(the)h(axis)f(t)l(yp)t(e)g(of)g(a)h(co)t(ordinate)f(v)-7
 b(ar)45 b(with)389 790 y(nccf)p 634 790 41 6 v 59 w(def)p
 870 790 V 59 w(axis)p 1155 790 V 60 w(t)l(yp)t(e)150
@@ -3426,7 +3550,7 @@ b(ar)45 b(with)389 790 y(nccf)p 634 790 41 6 v 59 w(def)p
 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 1745 y Fh(Return)45
 b(Co)t(des)150 1905 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(a)h(netCDF)g(error)f(co)s(de)h(for)f(failure.)150
-2153 y Fh(Example)150 2400 y(4.2)68 b(Find)44 b(out)h(the)h(axis)f(t)l
+2153 y Fh(Example)150 2400 y(3.2)68 b(Find)44 b(out)h(the)h(axis)f(t)l
 (yp)t(e)g(of)h(a)f(co)t(ordinate)g(v)-7 b(ar)45 b(with)389
 2533 y(nccf)p 634 2533 V 59 w(inq)p 876 2533 V 59 w(axis)p
 1161 2533 V 60 w(t)l(yp)t(e)150 2796 y(Usage)390 2955
@@ -3435,7 +3559,7 @@ y Fc(int)390 3065 y(nccf_inq_axis_type\(int)d(ncid,)k(int)h(varid,)f
 b(ncid)g(of)g(the)h(\014le.)150 3489 y Fh(Return)45 b(Co)t(des)150
 3648 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f
 (a)h(netCDF)g(error)f(co)s(de)h(for)f(failure.)150 3896
-y Fh(Example)150 4159 y(4.3)68 b(De\014ne)45 b(a)g(co)t(ordinate)h
+y Fh(Example)150 4159 y(3.3)68 b(De\014ne)45 b(a)g(co)t(ordinate)h
 (system)g(with)f(nccf)p 2582 4159 V 59 w(def)p 2818 4159
 V 59 w(co)t(ord)p 3205 4159 V 59 w(system)150 4422 y(Usage)390
 4581 y Fc(int)390 4691 y(nccf_def_coord_system\(in)o(t)d(ncid,)k(const)
@@ -3450,12 +3574,12 @@ w(CHAR\))d(v)-5 b(ar,)36 b(whose)f(v)-5 b(arid)35 b(is)150
 5165 y(returned)29 b(in)h(system)p 902 5165 V 40 w(v)-5
 b(arid.)150 5340 y Fc(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)
 p eop end
-%%Page: 36 40
-TeXDict begin 36 39 bop 150 -116 a Fi(36)2356 b(The)30
+%%Page: 34 38
+TeXDict begin 34 37 bop 150 -116 a Fi(34)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Return)45
 b(Co)t(des)150 458 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(a)h(netCDF)g(error)f(co)s(de)h(for)f(failure.)150
-691 y Fh(Example)150 934 y(4.4)68 b(Find)44 b(out)h(ab)t(out)g(a)h(co)t
+691 y Fh(Example)150 934 y(3.4)68 b(Find)44 b(out)h(ab)t(out)g(a)h(co)t
 (ordinate)f(system)h(with)389 1066 y(nccf)p 634 1066
 41 6 v 59 w(inq)p 876 1066 V 59 w(co)t(ord)p 1263 1066
 V 59 w(system)150 1324 y(Usage)390 1483 y Fc(int)390
@@ -3468,7 +3592,7 @@ b(ar.)150 2107 y Fc(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)
 150 2341 y Fh(Return)45 b(Co)t(des)150 2500 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h(netCDF)g(error)
 f(co)s(de)h(for)f(failure.)150 2733 y Fh(Example)150
-2975 y(4.5)68 b(Assign)45 b(a)g(co)t(ordinate)h(system)f(to)h(a)f(v)-7
+2975 y(3.5)68 b(Assign)45 b(a)g(co)t(ordinate)h(system)f(to)h(a)f(v)-7
 b(ar)45 b(with)389 3108 y(nccf)p 634 3108 V 59 w(assign)p
 1043 3108 V 60 w(co)t(ord)p 1431 3108 V 58 w(system)150
 3366 y(Usage)390 3525 y Fc(int)390 3635 y(nccf_assign_coord_system)o
@@ -3479,14 +3603,14 @@ b(ar.)150 3930 y Fc(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)
 150 4163 y Fh(Return)45 b(Co)t(des)150 4323 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h(netCDF)g(error)
 f(co)s(de)h(for)f(failure.)150 4556 y Fh(Example)150
-4813 y(4.6)68 b(De\014ne)45 b(a)g(co)t(ordinate)h(transform)g(with)f
+4813 y(3.6)68 b(De\014ne)45 b(a)g(co)t(ordinate)h(transform)g(with)f
 (nccf)p 2755 4813 V 58 w(def)p 2990 4813 V 60 w(transform)150
 5071 y(Usage)390 5230 y Fc(int)390 5340 y(nccf_def_transform\(int)d
 (ncid,)k(const)g(char)h(*name,)f(const)h(char)f(*transform_type,)p
 eop end
-%%Page: 37 41
-TeXDict begin 37 40 bop 150 -116 a Fi(Chapter)30 b(4:)41
-b(Co)s(ordinate)30 b(Systems)2250 b(37)1201 299 y Fc(const)47
+%%Page: 35 39
+TeXDict begin 35 38 bop 150 -116 a Fi(Chapter)30 b(3:)41
+b(Co)s(ordinate)30 b(Systems)2250 b(35)1201 299 y Fc(const)47
 b(char)f(*transform_name,)e(int)j(*transform_varid\);)275
 437 y Fi(De\014ne)40 b(a)g(co)s(ordinate)h(transform.)68
 b(This)39 b(adds)h(a)g(\(scalar,)k(NC)p 2585 437 28 4
@@ -3497,7 +3621,7 @@ p 3020 546 V 39 w(v)-5 b(arid.)150 711 y Fc(ncid)288
 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 949 y Fh(Return)45
 b(Co)t(des)150 1108 y Fi(This)30 b(function)g(returns)f(zero)i(for)f
 (success,)h(or)f(a)h(netCDF)g(error)f(co)s(de)h(for)f(failure.)150
-1346 y Fh(Example)150 1589 y(4.7)68 b(Find)44 b(out)h(ab)t(out)g(a)h
+1346 y Fh(Example)150 1589 y(3.7)68 b(Find)44 b(out)h(ab)t(out)g(a)h
 (co)t(ordinate)f(transform)h(with)389 1722 y(nccf)p 634
 1722 41 6 v 59 w(inq)p 876 1722 V 59 w(transform)150
 1981 y(Usage)390 2141 y Fc(int)390 2250 y(nccf_inq_transform\(int)c
@@ -3516,7 +3640,7 @@ V 40 w(len.)150 2991 y Fc(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h
 (\014le.)150 3229 y Fh(Return)45 b(Co)t(des)150 3388
 y Fi(This)30 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h
 (netCDF)g(error)f(co)s(de)h(for)f(failure.)150 3626 y
-Fh(Example)150 3870 y(4.8)68 b(Assign)45 b(a)g(co)t(ordinate)h
+Fh(Example)150 3870 y(3.8)68 b(Assign)45 b(a)g(co)t(ordinate)h
 (transform)f(to)h(a)f(co)t(ordinate)h(system)389 4003
 y(with)f(nccf)p 940 4003 41 6 v 59 w(assign)p 1349 4003
 V 60 w(transform)150 4262 y(Usage)390 4421 y Fc(int)390
@@ -3529,27 +3653,622 @@ b(that)g(holds)f(the)h(co)s(ordinate)g(system)f(attributes.)150
 5181 y Fh(Return)45 b(Co)t(des)150 5340 y Fi(This)30
 b(function)g(returns)f(zero)i(for)f(success,)h(or)f(a)h(netCDF)g(error)
 f(co)s(de)h(for)f(failure.)p eop end
-%%Page: 38 42
-TeXDict begin 38 41 bop 150 -116 a Fi(38)2356 b(The)30
+%%Page: 36 40
+TeXDict begin 36 39 bop 150 -116 a Fi(36)2356 b(The)30
 b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Example)p
 eop end
+%%Page: 37 41
+TeXDict begin 37 40 bop 150 -116 a Fi(Chapter)20 b(4:)36
+b(GRIDSPEC)19 b(-)i(A)f(standard)g(for)g(the)g(description)h(of)f
+(grids)g(used)f(in)h(Earth)g(System)g(mo)s(dels37)150
+141 y Ff(4)80 b(GRIDSPEC)54 b(-)f(A)h(standard)f(for)h(the)f
+(description)d(of)311 299 y(grids)j(used)f(in)i(Earth)f(System)g(mo)t
+(dels)150 575 y Fi(The)28 b(GRIDSPEC)f(is)i(a)f(prop)s(osed)f(CF)h
+(standard.)39 b(It)29 b(is)f(not)h(y)m(et)g(part)f(of)g(the)h(Climate)g
+(and)f(F)-8 b(orecast)150 685 y(Con)m(v)m(en)m(tions.)40
+b(Supp)s(ort)21 b(for)i(GRIDSPEC)g(in)g(lib)s(cf)h(is)f(pro)m(vided)g
+(as)h(a)g(service)g(to)g(the)g(CF)f(comm)m(unit)m(y)-8
+b(,)150 795 y(allo)m(wing)32 b(for)e(the)h(ev)-5 b(aluation)32
+b(of)e(the)h(prop)s(osed)e(GRIDSPEC)h(standard.)275 943
+y(Eac)m(h)43 b(of)f(the)h(GRIDSPEC)e(to)s(ols)i(listed)g(b)s(elo)m(w)g
+(ma)m(y)g(b)s(e)f(call)h(programmatically)-8 b(,)48 b(or)42
+b(with)h(a)150 1053 y(command)30 b(line)h(utilit)m(y)-8
+b(.)275 1202 y(F)g(or)21 b(more)f(information)h(ab)s(out)f(GRIDSPEC)f
+(see)i Fc(http://www.gfdl.noaa.gov)o(/~vb)o(/gri)o(dst)o(d/gr)o(idst)o
+(d.h)o(tml)p Fi(.)150 1455 y Fh(4.1)68 b(Mak)l(e)46 b(a)f(Horizon)l
+(tal)h(Grid)150 1615 y Fi(This)27 b(function)g(can)h(generate)h
+(di\013eren)m(t)f(t)m(yp)s(es)g(of)f(horizon)m(tal)i(grids.)40
+b(The)27 b(output)g(data)h(is)g(on)f(sup)s(er-)150 1724
+y(grid)k(\()h(mo)s(del)f(grid)g(size)h(x)f(re\014nemen)m(t\(=2\))h(\).)
+44 b(F)-8 b(or)32 b('cubic)p 2257 1724 28 4 v 40 w(grid',)g(six)f(grid)
+g(\014les)g(whic)m(h)g(con)m(tain)i(the)150 1834 y(grid)d(information)h
+(for)f(eac)m(h)h(tile)h(will)f(b)s(e)f(generated,)h(otherwise)g(one)g
+(\014le)f(will)h(b)s(e)f(generated.)275 1983 y(Sp)s(ecify)44
+b(the)i(grid)f(t)m(yp)s(e)g(through)g(grid)p 1720 1983
+V 40 w(t)m(yp)s(e)g(parameter.)86 b(The)45 b(v)-5 b(alue)46
+b(of)g(grid)p 3222 1983 V 39 w(t)m(yp)s(e)g(can)g(b)s(e)150
+2092 y('from)p 366 2092 V 40 w(\014le',)40 b('sp)s(ectral)p
+948 2092 V 41 w(grid',)f('spherical)p 1609 2092 V 41
+w(grid',)g('conformal)p 2312 2092 V 41 w(cubic)p 2560
+2092 V 40 w(grid',)h('gnomonic)p 3250 2092 V 41 w(ed')e(or)g('sim-)150
+2202 y(ple)p 272 2202 V 40 w(cartesian)p 665 2202 V 41
+w(grid',)31 b(with)f(default)h(v)-5 b(alue)31 b('spherical)p
+2066 2202 V 40 w(grid'.)275 2350 y(The)22 b(nlon)h(and)f(nlat)h
+(parameters)h(m)m(ust)f(b)s(e)f(sp)s(eci\014ed)g(to)i(indicate)g(sup)s
+(ergrid)d(size)j(\(for)f(cubic)p 3534 2350 V 40 w(grid,)150
+2460 y(nlat)31 b(is)f(not)h(needed)f(b)s(ecause)g(nlat)h(has)f(the)h
+(same)g(v)-5 b(alue)30 b(as)h(nlon\).)390 2609 y Fc(int)390
+2718 y(gs_make_hgrid\(char)43 b(*grid_type,)i(int)h(*nlat,)h(int)f
+(*nlon,)676 2828 y(int)h(nxbnds0,)f(int)h(nybnds0,)e(int)i(nxbnds1,)f
+(int)h(nybnds1,)676 2937 y(int)g(nxbnds2,)f(int)h(nybnds2,)e(double)h
+(lat_join,)g(int)h(nratio,)676 3047 y(double)f(simple_dx,)f(double)i
+(simple_dy,)e(int)h(ntilex,)g(int)h(ntiley,)1058 3157
+y(char)g(*gridname,)e(char)h(*center,)g(char)h(*history,)e(double)h
+(*xbnds,)676 3266 y(double)g(*ybnds\))275 3415 y Fi(The)29
+b(follo)m(wing)j(grid)e(t)m(yp)s(es)h(are)g(a)m(v)-5
+b(ailable:)150 3595 y Fc(from_file)630 3705 y Fi(m)m(y)p
+757 3705 V 40 w(grid)p 954 3705 V 40 w(\014le)35 b(m)m(ust)f(b)s(e)g
+(sp)s(eci\014ed.)52 b(The)34 b(grid)g Fc(")h Fi(sp)s(eci\014ed)e(in)h
+(m)m(y)p 2982 3705 V 41 w(grid)p 3180 3705 V 39 w(\014le)h(should)f(b)s
+(e)630 3815 y(sup)s(er)29 b(grid)h(v)m(ertex.)150 3988
+y Fc(spectral_grid)630 4098 y Fi(no)g(other)h(optional)g(or)g(required)
+e(argumen)m(ts.)150 4271 y Fc(regular_lonlat_grid)630
+4381 y Fi(nxbnds,)f(n)m(ybnds)h(xbnds,)g(ybnds,)g(m)m(ust)h(b)s(e)g(sp)
+s(eci\014ed)g(to)h(de\014ne)e(the)i(grid)f(b)s(ounds.)150
+4554 y Fc(tripolar_grid)630 4664 y Fi(nxbnds,)40 b(n)m(ybnds,)h(xbnds,)
+g(ybnds,)f(m)m(ust)g(b)s(e)f(sp)s(eci\014ed)h(to)g(de\014ne)f(the)h
+(grid)g(b)s(ounds.)630 4774 y(lat)p 741 4774 V 41 w(join)30
+b(is)h(optional)g(with)f(default)h(v)-5 b(alue)31 b(65.)150
+4947 y Fc(conformal_cubic_grid)630 5057 y Fi(nratio)g(is)f(optional)i
+(argumen)m(t.)150 5230 y Fc(gnomonic_ed)630 5340 y Fi(equal)f(distance)
+g(gnomonic)g(cubic)f(grid.)p eop end
+%%Page: 38 42
+TeXDict begin 38 41 bop 150 -116 a Fi(38)2356 b(The)30
+b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(simple_cartesian_grid)630
+408 y Fi(xbnds,)25 b(ybnds)f(m)m(ust)h(b)s(e)g(sp)s(eci\014ed)g(to)h
+(de\014ne)f(the)g(grid)g(b)s(ounds)f(lo)s(cation)j(and)e(grid)g(size.)
+630 518 y(n)m(um)m(b)s(er)38 b(of)h(b)s(ounds)e(m)m(ust)i(b)s(e)f(2)i
+(in)f(b)s(oth)f(and)h(x)g(and)f(y-direction.)68 b(simple)p
+3432 518 28 4 v 40 w(dx)39 b(and)630 628 y(simple)p 889
+628 V 40 w(dy)30 b(m)m(ust)g(b)g(sp)s(eci\014ed)g(to)h(sp)s(ecify)f
+(uniform)f(cell)i(length.)150 799 y Fc(grid_type)630
+908 y Fi(sp)s(ecify)f(t)m(yp)s(e)h(of)f(top)s(ograph)m(y)h(\(see)g
+(table)g(ab)s(o)m(v)m(e\).)150 1080 y Fc(my_grid_file)630
+1189 y Fi(when)60 b(this)g(\015ag)h(is)g(presen)m(t,)69
+b(the)61 b(program)f(will)h(read)g(grid)f(information)h(from)630
+1299 y('m)m(y)p 782 1299 V 40 w(grid)p 979 1299 V 40
+w(\014le'.)41 b(The)27 b(\014le)h(format)h(can)f(b)s(e)f(ascii)j
+(\014le)e(or)g(netcdf)g(\014le.)40 b(Multiple)29 b(\014le)f(en)m(try)
+630 1408 y(are)j(allo)m(w)m(ed)h(but)e(the)g(n)m(um)m(b)s(er)f(should)h
+(b)s(e)f(less)i(than)f(MAXBOUNDS.)150 1580 y Fc(nxbnds)192
+b Fi(Sp)s(ecify)30 b(n)m(um)m(b)s(er)f(of)h(zonal)i(regions)e(for)h(v)
+-5 b(arying)30 b(resolution.)150 1751 y Fc(nybnds)192
+b Fi(Sp)s(ecify)30 b(n)m(um)m(b)s(er)f(of)h(meridinal)h(regions)f(for)h
+(v)-5 b(arying)30 b(resolution.)150 1922 y Fc(xbnds)240
+b Fi(Sp)s(ecify)23 b(b)s(oundaries)g(for)g(de\014ning)g(zonal)i
+(regions)g(of)f(v)-5 b(arying)24 b(resolution.)39 b(When)24
+b(trip)s(o-)630 2032 y(lar)36 b(is)g(presen)m(t,)h(x)f(also)g
+(de\014nes)f(the)h(longitude)g(of)g(the)g(t)m(w)m(o)h(new)e(p)s(oles)h
+(nxbnds)d(m)m(ust)630 2141 y(b)s(e)f(2)i(and)e(lon)p
+1141 2141 V 40 w(start)h(=)g(x\(1\),)i(lon)p 1849 2141
+V 40 w(end)d(=)h(x\(nxbnds\))e(are)j(longitude)f(of)g(the)g(t)m(w)m(o)h
+(new)630 2251 y(p)s(oles.)150 2422 y Fc(ybnds)240 b Fi(Sp)s(ecify)30
+b(b)s(oundaries)f(for)h(de\014ning)f(meridional)i(regions)g(of)f(v)-5
+b(arying)31 b(resolution)150 2593 y Fc(nlon)288 b Fi(Num)m(b)s(er)28
+b(of)h(mo)s(del)h(grid)e(p)s(oin)m(ts\(sup)s(ergrid\))g(for)h(eac)m(h)i
+(zonal)f(regions)g(of)f(v)-5 b(arying)29 b(reso-)630
+2703 y(lution.)150 2874 y Fc(nlat)288 b Fi(Num)m(b)s(er)37
+b(of)h(mo)s(del)f(grid)h(p)s(oin)m(ts\(sup)s(ergid\))f(for)g(eac)m(h)i
+(meridinal)f(regions)g(of)g(v)-5 b(arying)630 2984 y(resolution.)150
+3155 y Fc(lat_join)96 b Fi(Sp)s(ecify)33 b(latitude)i(for)f(joining)h
+(spherical)f(and)f(rotate)j(bip)s(olar)e(grid.)51 b(Default)35
+b(v)-5 b(alue)35 b(is)630 3265 y(65)c(degree.)150 3436
+y Fc(nratio)192 b Fi(Sp)s(eicify)25 b(the)h(re\014nemen)m(t)f(ratio)i
+(when)d(calculating)k(cell)f(length)f(and)e(area)j(of)f(sup)s(ergrid.)
+150 3607 y Fc(simple_dx)630 3717 y Fi(Sp)s(ecify)k(the)g(uniform)f
+(cell)j(length)f(in)f(x-direction)h(fo)g(simple)f(cartesian)i(grid.)150
+3888 y Fc(simple_dy)630 3998 y Fi(Sp)s(ecify)e(the)g(uniform)f(cell)j
+(length)f(in)f(y-direction)h(fo)g(simple)f(cartesian)i(grid.)150
+4169 y Fc(ndivx)240 b Fi(Sp)s(ecify)30 b(n)m(um)m(b)s(er)f(division)h
+(in)g(x-direction)h(for)g(eac)m(h)g(face,)h(default)e(v)-5
+b(alue)31 b(is)g(1.)150 4340 y Fc(ndivy)240 b Fi(Sp)s(ecify)30
+b(n)m(um)m(b)s(er)f(division)h(in)g(y-direction)h(for)g(eac)m(h)g
+(face,)h(default)e(v)-5 b(alue)31 b(is)g(1.)150 4511
+y Fc(grid_name)630 4621 y Fi(Sp)s(ecify)d(the)i(grid)f(name.)40
+b(The)29 b(output)g(grid)g(\014le)g(name)g(will)h(b)s(e)e(grid)p
+3074 4621 V 40 w(name.nc)i(if)f(there)630 4730 y(is)39
+b(one)h(tile)g(and)e(grid)p 1419 4730 V 40 w(name.tile#.nc)j(if)e
+(there)g(is)g(more)h(than)e(one)i(tile)g(The)f(default)630
+4840 y(v)-5 b(alue)31 b(will)g(b)s(e)e(horizon)m(tal)p
+1561 4840 V 42 w(grid.)150 5011 y Fc(center)192 b Fi(Sp)s(ecify)36
+b(the)i(cen)m(ter)g(lo)s(cation)h(of)e(grid.)61 b(The)37
+b(v)-5 b(alid)38 b(en)m(try)f(will)h(b)s(e)e('none',)k('t)p
+3441 5011 V 40 w(cell')f(or)630 5121 y('c)p 701 5121
+V 41 w(cell')g(with)f(default)g(v)-5 b(alue)38 b('none'.)64
+b(The)37 b(grid)h(re\014nemen)m(t)g(is)g(assumed)f(to)i(b)s(e)e(2)h(in)
+630 5230 y(x)c(and)f(y-direction)i(when)d(cen)m(ter)j(is)f(not)g
+('none'.)51 b('c)p 2511 5230 V 41 w(cell')35 b(should)e(b)s(e)g(used)g
+(for)h(the)g(gr)630 5340 y(used)c(in)g(MOM4.)p eop end
 %%Page: 39 43
-TeXDict begin 39 42 bop 150 -116 a Fi(Index)3286 b(39)150
-299 y Ff(Index)150 610 y Fh(A)150 726 y Fb(API,)25 b(C)8
-b Fa(.)14 b(.)e(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g
-(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
-g(.)h(.)f(.)g(.)h(.)34 b Fb(1)150 814 y(API,)25 b(F90)9
-b Fa(.)14 b(.)e(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h
-(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)
-g(.)h(.)f(.)35 b Fb(1)150 901 y(API,)25 b(F)-6 b(ortran)19
-b Fa(.)12 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g
-(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)g(.)h(.)f(.)g(.)h(.)f(.)g(.)45
-b Fb(1)2025 610 y Fh(S)2025 919 y Fb(supp)r(orted)25
-b(programming)i(languages)22 b Fa(.)12 b(.)h(.)f(.)g(.)h(.)f(.)g(.)h(.)
-f(.)g(.)h(.)f(.)47 b Fb(1)p eop end
+TeXDict begin 39 42 bop 150 -116 a Fi(Chapter)20 b(4:)36
+b(GRIDSPEC)19 b(-)i(A)f(standard)g(for)g(the)g(description)h(of)f
+(grids)g(used)f(in)h(Earth)g(System)g(mo)s(dels39)150
+299 y Fh(4.2)68 b(Remap)46 b(data)f(from)h(Input)e(Mosaic)h(to)h
+(Output)e(Mosaic)150 458 y Fi(This)30 b(function)g(remaps)g(data)h
+(\(scalar)g(or)g(v)m(ector\))h(from)e(input)p 2382 458
+28 4 v 39 w(mosaic)h(on)m(to)h(output)p 3192 458 V 40
+w(mosaic.)275 602 y(The)25 b(target)i(grid)f(also)g(could)g(b)s(e)f(sp)
+s(eci\014ed)g(through)g(lonBegin,)k(lonEnd,)d(latBegin,)i(latEnd,)f
+(nlon)150 712 y(and)j(nlat.)275 856 y(Curren)m(tly)h(only)h(T-cell)i
+(scalar)f(regridding)f(and)f(A)m(GRID)i(v)m(ector)h(regridding)e
+(\(only)h(bilinear)f(in-)150 965 y(terp)s(olation)25
+b(is)g(implemen)m(ted)g(for)f(cubic)g(grid)g(v)m(ector)i(in)m(terp)s
+(olation\).)40 b(The)24 b(in)m(terp)s(olation)i(algorithm)150
+1075 y(used)k(is)g(con)m(trolled)i(b)m(y)e(in)m(terp)p
+1238 1075 V 40 w(metho)s(d)g(with)g(default)h('conserv)m(e)p
+2480 1075 V 41 w(order1'.)275 1219 y(Curren)m(tly)c(only)h('conserv)m
+(e)p 1248 1219 V 41 w(order1',)h('conserv)m(e)p 1979
+1219 V 42 w(order2')f(and)g('bilinear')g(remapping)g(sc)m(heme)h(are)
+150 1329 y(implemen)m(ted.)45 b('bilinear')32 b(is)g(only)g(used)f(to)h
+(remap)g(data)g(from)f(cubic)h(grid)f(to)i(latlon)f(grid.)45
+b(W)-8 b(e)33 b(will)150 1438 y(add)24 b(more)i(sc)m(heme)g(in)e(the)i
+(future)e(if)h(needed.)38 b(fregrid)25 b(exp)s(ects)g(NetCDF)i(format)e
+(input.)38 b(scalar)p 3548 1438 V 41 w(\014eld)150 1548
+y(and/or)30 b(u)p 510 1548 V 40 w(\014eld/v)p 810 1548
+V 40 w(\014eld)g(m)m(ust)g(b)s(e)g(sp)s(eci\014ed.)40
+b(u)p 1849 1548 V 39 w(\015d)30 b(and)f(v)p 2244 1548
+V 40 w(\015d)h(m)m(ust)g(b)s(e)g(paired)g(together.)390
+1692 y Fc(int)390 1801 y(gs_fregrid\(char)44 b(*history,)h(char)i
+(*mosaic_in,)d(char)j(*mosaic_out,)d(char)j(*dir_in,)915
+1911 y(char)g(*dir_out,)e(char)i(**input_file,)d(int)j(nfiles,)e(char)i
+(**output_file,)915 2021 y(int)g(nfiles_out,)e(char)h(*remap_file,)f
+(char)h(**scalar_name,)e(int)j(nscalar,)915 2130 y(char)g(**u_name,)e
+(int)i(nvector,)e(char)i(**v_name,)e(int)i(nvector2,)915
+2240 y(char)g(*interp_method,)c(char)k(*test_case,)e(double)h
+(test_param,)915 2349 y(unsigned)g(int)g(opcode,)g(int)h(grid_type,)e
+(unsigned)h(int)h(finer_step,)915 2459 y(int)g(fill_missing,)d(int)j
+(nlon,)f(int)h(nlat,)g(int)g(check_conserve,)915 2568
+y(int)g(y_at_center,)d(double)i(lonbegin,)g(double)g(lonend,)g(double)g
+(latbegin,)915 2678 y(double)g(latend,)g(int)h(kbegin,)f(int)h(kend,)f
+(int)h(lbegin,)f(int)h(lend\))150 2852 y(innput_mosaic)630
+2961 y Fi(Sp)s(ecify)33 b(the)h(input)e(mosaic)j(information.)50
+b(This)33 b(\014le)g(con)m(tains)i(list)f(of)g(tile)h(\014les)e(whic)m
+(h)630 3071 y(sp)s(ecify)d(the)h(grid)f(information)g(for)h(eac)m(h)g
+(tile.)150 3240 y Fc(input_file)630 3349 y Fi(sp)s(ecify)h(the)g(input)
+f(\014le)h(name.)46 b(The)31 b(su\016x)g('.nc')i(can)f(b)s(e)f
+(omitted.)47 b(The)31 b(su\016x)g('tile#')630 3459 y(should)39
+b(not)i(presen)m(t)f(for)g(m)m(ultiple-tile)i(\014les.)70
+b(The)40 b(n)m(um)m(b)s(er)f(of)h(\014les)g(m)m(ust)g(b)s(e)g(1)g(for)
+630 3569 y(scalar)31 b(regridding)f(and)g(can)h(b)s(e)f(1)h(or)f(2)h
+(for)g(v)m(ector)h(regridding.)40 b(File)32 b(path)e(should)g(not)630
+3678 y(b)s(e)g(includes.)150 3847 y Fc(scalar_field)630
+3957 y Fi(sp)s(ecify)35 b(the)g(scalar)h(\014eld)e(name)h(to)h(b)s(e)e
+(regridded.)54 b(The)35 b(m)m(ultiple)g(en)m(try)g(\014eld)g(names)630
+4066 y(are)c(sep)s(erated)f(b)m(y)g(comma.)150 4235 y
+Fc(u_field)144 b Fi(sp)s(ecify)31 b(the)g(v)m(ector)i(\014eld)e(u-comp)
+s(onen)m(tname)g(to)h(b)s(e)f(regridded.)42 b(The)31
+b(m)m(ultiple)h(en)m(try)630 4345 y(\014eld)42 b(names)h(are)g(sep)s
+(erated)g(b)m(y)f(comma.)79 b(u)p 2295 4345 V 40 w(\014eld)42
+b(m)m(ust)h(b)s(e)f(paired)g(together)i(with)630 4454
+y(v)p 684 4454 V 40 w(\014eld.)150 4623 y Fc(v_field)144
+b Fi(sp)s(ecify)31 b(the)h(v)m(ector)h(\014eld)e(v-comp)s(onen)m(tname)
+h(to)g(b)s(e)f(regridded.)43 b(The)31 b(m)m(ultiple)h(en)m(try)630
+4733 y(\014eld)43 b(names)f(are)i(sep)s(erated)f(b)m(y)f(comma.)80
+b(v)p 2294 4733 V 40 w(\014eld)42 b(m)m(ust)h(b)s(e)f(paired)h
+(together)h(with)630 4842 y(u)p 687 4842 V 40 w(\014eld.)150
+5011 y Fc(output_mosaic)630 5121 y Fi(sp)s(ecify)30 b(the)h(output)f
+(mosaic)i(information.)42 b(This)29 b(\014le)i(con)m(tains)h(list)f(of)
+g(tile)h(\014les)e(whic)m(h)630 5230 y(sp)s(ecify)24
+b(the)h(grid)f(information)g(for)h(eac)m(h)g(tile.)40
+b(If)24 b(output)p 2624 5230 V 40 w(mosaic)h(is)g(not)f(sp)s
+(eci\014ed,)h(nlon)630 5340 y(and)30 b(nlat)h(m)m(ust)f(b)s(e)g(sp)s
+(eci\014ed.)p eop end
 %%Page: 40 44
 TeXDict begin 40 43 bop 150 -116 a Fi(40)2356 b(The)30
-b(CF)g(Library)g(Users)g(Guide)p eop end
+b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(lonBegin)e(#)630
+408 y Fi(sp)s(ecify)c(the)h(starting)h(longitude\(in)f(degree\))h(of)f
+(the)g(geographical)i(region)e(of)g(the)g(target)630
+518 y(grid)30 b(on)g(whic)m(h)g(the)h(output)f(is)g(desired.)41
+b(The)30 b(default)g(v)-5 b(alue)31 b(is)f(0.)150 667
+y Fc(lonEnd)192 b Fi(sp)s(ecify)29 b(the)g(ending)f(longitude\(in)i
+(degree\))g(of)f(the)g(geographical)i(region)f(of)f(the)g(target)630
+776 y(grid)h(on)g(whic)m(h)g(the)h(output)f(is)g(desired.)41
+b(The)30 b(default)g(v)-5 b(alue)31 b(is)f(360.)150 925
+y Fc(latBegin)96 b Fi(sp)s(ecify)30 b(the)g(starting)h(latitude\(in)h
+(degree\))f(of)g(the)f(geographical)j(region)d(of)h(the)f(target)630
+1035 y(grid)g(on)g(whic)m(h)g(the)h(output)f(is)g(desired.)41
+b(The)30 b(default)g(v)-5 b(alue)31 b(is)f(-90.)150 1183
+y Fc(latEnd)192 b Fi(sp)s(ecify)34 b(the)h(ending)f(latitude\(in)h
+(degree\))h(of)f(the)f(geographical)j(region)e(of)g(the)f(target)630
+1293 y(grid)c(on)g(whic)m(h)g(the)h(output)f(is)g(desired.)41
+b(The)30 b(default)g(v)-5 b(alue)31 b(is)f(90.)150 1442
+y Fc(nlon)288 b Fi(sp)s(ecify)30 b(n)m(um)m(b)s(er)f(of)i(grid)f(b)s(o)
+m(x)g(cells)h(in)g(x-direction)g(for)f(a)h(regular)f(lat-lon)i(grid.)
+150 1590 y Fc(nlat)288 b Fi(sp)s(ecify)30 b(n)m(um)m(b)s(er)f(of)i
+(grid)f(b)s(o)m(x)g(cells)h(in)g(y-direction)g(for)f(a)h(regular)f
+(lat-lon)i(grid.)150 1739 y Fc(KlevelBegin)630 1849 y
+Fi(sp)s(ecify)e(b)s(egin)g(index)g(of)g(the)h(k-lev)m(el)h(\(depth)e
+(axis\))h(that)g(to)h(b)s(e)d(regridded.)150 1998 y Fc(KlevelEnd)630
+2107 y Fi(sp)s(ecify)h(end)g(index)g(of)g(the)h(k-lev)m(el)h(\(depth)e
+(axis\))h(that)g(to)g(b)s(e)f(regridded.)150 2256 y Fc(LstepBegin)630
+2365 y Fi(sp)s(ecify)g(the)h(b)s(egin)f(index)f(of)i(L-step)g(\(time)g
+(axis\))g(that)g(to)g(b)s(e)f(regridded.)150 2514 y Fc(LstepEnd)96
+b Fi(sp)s(ecify)30 b(the)h(end)e(index)h(of)h(L-step)f(\(time)i(axis\))
+f(that)g(to)g(b)s(e)f(regridded.)150 2663 y Fc(output_file)630
+2772 y Fi(sp)s(ecify)d(the)h(output)g(\014le)f(name.)40
+b(If)27 b(not)h(presen)m(ted,)h(output)p 2750 2772 28
+4 v 40 w(\014le)e(will)h(tak)m(e)i(the)e(v)-5 b(alue)28
+b(of)630 2882 y(input)p 849 2882 V 39 w(\014le.)39 b(The)26
+b(su\016x)f('.nc')h(can)g(b)s(e)f(omitted.)41 b(The)25
+b(su\016x)g('tile#')i(should)e(not)h(presen)m(t)630 2992
+y(for)33 b(m)m(ultiple-tile)j(\014les.)49 b(The)33 b(n)m(um)m(b)s(er)f
+(of)h(\014les)g(m)m(ust)g(b)s(e)g(1)h(for)f(scalar)h(regridding)f(and)
+630 3101 y(can)e(b)s(e)e(1)i(or)g(2)f(for)g(v)m(ector)i(regridding.)41
+b(File)31 b(path)f(should)g(not)g(b)s(e)g(includes)150
+3250 y Fc(input_dir)630 3360 y Fi(sp)s(ecify)22 b(the)h(path)f(that)h
+(stores)g(input)p 1935 3360 V 39 w(\014le.)38 b(If)22
+b(not)h(presen)m(ted,)h(the)f(input)f(\014le)g(is)h(assumed)630
+3469 y(to)31 b(b)s(e)f(stored)g(in)g(curren)m(t)h(diretory)-8
+b(.)150 3618 y Fc(output_dir)630 3727 y Fi(sp)s(ecify)26
+b(the)h(path)g(that)g(will)g(store)g(output)f(\014le.)40
+b(If)26 b(not)h(presen)m(ted,)h(the)f(output)f(\014le)h(will)630
+3837 y(b)s(e)j(stored)g(in)g(curren)m(t)g(diretory)-8
+b(.)150 3986 y Fc(remap_file)630 4095 y Fi(sp)s(ecify)34
+b(the)g(\014le)h(name)f(that)h(sa)m(v)m(es)h(remapping)e(information.)
+53 b(If)33 b(remap)p 3270 4095 V 40 w(\014le)i(is)f(sp)s(ec-)630
+4205 y(i\014ed)f(and)g(the)g(\014le)h(do)s(es)f(not)h(exist,)h
+(remapping)e(information)g(will)h(b)s(e)f(calculated)i(ans)630
+4315 y(stored)k(in)f(remap)p 1280 4315 V 40 w(\014le.)66
+b(If)39 b(remap)p 1875 4315 V 40 w(\014le)f(is)h(sp)s(eci\014ed)g(and)f
+(the)h(\014le)g(exists,)j(remapping)630 4424 y(information)31
+b(will)f(b)s(e)g(read)g(from)g(remap)p 2089 4424 V 40
+w(\014le.)150 4573 y Fc(interp_method)630 4682 y Fi(sp)s(ecify)48
+b(the)h(remapping)f(algorithm)i(to)g(b)s(e)e(used.)95
+b(Default)49 b(is)g('conserv)m(e)p 3411 4682 V 41 w(order1'.)630
+4792 y(Curren)m(tly)44 b(only)h('conserv)m(e)p 1637 4792
+V 41 w(order1',)k('conserv)m(e)p 2388 4792 V 41 w(order2')c(and)f
+('bilinear')i(remapping)630 4902 y(sc)m(heme)40 b(are)f(implemen)m(ted)
+h(in)f(this)g(to)s(ol.)68 b(The)38 b(bilinear)i(sc)m(heme)g(can)f(only)
+g(b)s(e)g(used)630 5011 y(to)c(remap)f(data)g(from)g(cubic)g(grid)g(to)
+h(regular)f(latlon)i(grid.)51 b(When)34 b(in)m(terp)p
+3320 5011 V 40 w(metho)s(d)g(is)630 5121 y('bilinear',)k(nlon)d(and)g
+(nlat)h(m)m(ust)f(b)s(e)g(sp)s(eci\014ed)g(and)g(the)g(output)h(data)g
+(in)f(y-direction)630 5230 y(will)25 b(b)s(e)e(lo)s(cated)j(at)f(the)g
+(cen)m(ter)g(of)g(cell)h(or)e(b)s(ound)e(of)j(the)f(cell)i(dep)s
+(ending)d(on)h(the)h(setting)630 5340 y(of)31 b(y)p 788
+5340 V 40 w(cen)m(ter.)p eop end
+%%Page: 41 45
+TeXDict begin 41 44 bop 150 -116 a Fi(Chapter)20 b(4:)36
+b(GRIDSPEC)19 b(-)i(A)f(standard)g(for)g(the)g(description)h(of)f
+(grids)g(used)f(in)h(Earth)g(System)g(mo)s(dels41)150
+299 y Fc(test_case)630 408 y Fi(sp)s(ecify)30 b(the)h(test)g(function)f
+(to)h(b)s(e)f(used)f(for)h(testing.)150 572 y Fc(grid_type)630
+681 y Fi(sp)s(ecify)38 b(the)h(v)m(ector)i(\014eld)d(grid)g(lo)s
+(cation.)68 b(default)39 b(is)f(A)m(GRID)i(and)e(only)h(A)m(GRID)h(is)
+630 791 y(implemen)m(ted)31 b(y)m(et.)150 954 y Fc(symmetry)96
+b Fi(the)31 b(grid)f(is)g(symmetry)g(or)g(not.)150 1118
+y Fc(target_grid)630 1227 y Fi(input)36 b(cell)i(area)f(instead)g(of)g
+(calculating)h(based)f(on)f(exc)m(hange)i(grid)f(area.)60
+b(default)37 b(is)630 1337 y(o\013.)150 1500 y Fc(-finer_step)630
+1610 y Fi(This)30 b(is)h(used)g(only)g(for)g(bilinear)g(in)m(terp)s
+(olation.)45 b(Set)31 b(\014ner)p 2728 1610 28 4 v 39
+w(step)g(to)h(a)f(p)s(ositiv)m(e)i(in)m(teger)630 1719
+y(to)25 b(reduce)f(noise)g(in)g(in)m(terp)s(olation)h(and)f(get)h(a)g
+(relativ)m(ely)h(smo)s(oth)e(output.)38 b(The)24 b(default)630
+1829 y(v)-5 b(alue)29 b(is)f(0.)41 b(When)28 b(\014ner)p
+1510 1829 V 39 w(step)h(is)f(greater)i(than)e(0,)i(fregrid)e(will)g
+(\014rst)g(remap)g(data)h(from)630 1938 y(source)23 b(grid)g(on)m(to)h
+(a)f(\014ner)f(grid)h(with)g(resolution)g(that)h(is)f(p)s(o)m(w)m(er)g
+(of)g(2)g(of)g(destination)h(grid)630 2048 y(resolution)36
+b(using)e(bilinear)i(in)m(terp)s(olation,)h(then)e(using)g(v)m(olume)h
+(a)m(v)m(eraging)h(to)f(remap)630 2158 y(data)31 b(from)f(\014ner)f
+(grid)h(on)m(to)i(destination)f(grid.)150 2321 y Fc(center_y)96
+b Fi(output)34 b(latitude)i(will)e(lo)s(cate)j(at)e(cell)h(cen)m(ter,)h
+(i.e.,)g(the)d(starting)i(latitude)f(will)g(b)s(e)f(-89)630
+2431 y(when)k(nlat)h(=)f(90.)67 b(when)38 b(cen)m(ter)p
+1853 2431 V 41 w(y)h(is)g(not)g(set,)i(starting)f(latitude)g(will)f(b)s
+(e)f(-90.)67 b(for)630 2540 y(bilinear)31 b(in)m(terp)s(olation.)42
+b(F)-8 b(or)31 b(conserv)-5 b(ativ)m(e)32 b(in)m(terp)s(olation,)g(cen)
+m(ter)p 3022 2540 V 41 w(y)e(is)h(assumed.)150 2703 y
+Fc(check_conserve)630 2813 y Fi(c)m(hec)m(k)45 b(the)f(conserv)-5
+b(ation)45 b(of)f(conserv)-5 b(ativ)m(e)46 b(in)m(terp)s(olation.)82
+b(The)43 b(area)i(sum)d(will)j(b)s(e)630 2923 y(prin)m(ted)30
+b(out)h(for)f(input)f(and)h(output)g(mosaic.)150 3161
+y Fh(4.3)68 b(Generate)46 b(Mosaic)f(Information)h(Bet)l(w)l(een)h
+(Tiles)150 3320 y Fi(This)23 b(function)g(generates)i(Mosaic)g
+(information)f(b)s(et)m(w)m(een)h(tiles.)39 b(The)23
+b(mosaic)i(information)f(includes:)150 3430 y(list)31
+b(of)g(tile)g(\014les,)g(list)g(of)f(con)m(tact)j(region)e(sp)s
+(eci\014ed)f(b)m(y)g(index,)g(con)m(tact)j(t)m(yp)s(e.)390
+3568 y Fc(int)390 3678 y(gs_make_solo_mosaic\(char)41
+b(*history,)k(int)i(ntiles,)f(char)h(*mosaic_name,)d(char)j
+(*grid_descriptor,)1345 3787 y(char)f(**tilefile,)f(double)h(periodx,)g
+(double)g(periody,)f(char)i(*dir\))150 3953 y(num_tiles)630
+4062 y Fi(Num)m(b)s(er)29 b(of)i(tiles)g(in)f(the)h(mosaic.)150
+4226 y Fc(dir)336 b Fi(The)30 b(directory)h(that)g(con)m(tains)g(all)h
+(the)e(tile)i(grid)e(\014le.)150 4389 y Fc(mosaic_name)630
+4499 y Fi(mosaic)h(name.)41 b(The)30 b(output)g(\014le)h(will)f(b)s(e)g
+(mosaic)p 2406 4499 V 41 w(name.nc.)41 b(default)31 b(is)f('mosaic'.)
+150 4662 y Fc(tile_file)630 4771 y Fi(Grid)k(\014le)h(name)g(of)f(all)i
+(tiles)f(in)g(the)g(mosaic.)54 b(The)34 b(\014le)h(name)g(should)e(b)s
+(e)h(relativ)m(e)j(\014le)630 4881 y(name)20 b(\()h(exclude)g(the)f
+(absolute)i(\014le)e(path\).)37 b(The)20 b(absolute)h(\014le)g(path)f
+(will)h(b)s(e)f(dir/tile)p 3574 4881 V 41 w(\014le.)630
+4991 y(If)30 b(this)g(option)h(is)f(not)h(sp)s(eci\014ed,)f(the)h(tile)
+p 2114 4991 V 41 w(\014le)f(will)h(b)s(e)f('horizon)m(tal)p
+3017 4991 V 42 w(grid.tile#.nc')150 5154 y Fc(periodx)144
+b Fi(Sp)s(ecify)30 b(the)g(p)s(erio)s(d)f(in)h(x-direction)i(of)e
+(mosaic.)42 b(Default)32 b(v)-5 b(alue)30 b(is)h(0)g(\(not)g(p)s(erio)s
+(dic\).)150 5317 y Fc(periody)144 b Fi(Sp)s(ecify)30
+b(the)g(p)s(erio)s(d)f(in)h(y-direction)i(of)e(mosaic.)42
+b(Default)32 b(v)-5 b(alue)30 b(is)h(0)g(\(not)g(p)s(erio)s(dic\).)p
+eop end
+%%Page: 42 46
+TeXDict begin 42 45 bop 150 -116 a Fi(42)2356 b(The)30
+b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(4.4)68 b(Remap)46
+b(Riv)l(er)g(Net)l(w)l(ork)g(Data)150 458 y Fi(riv)m(er)p
+338 458 28 4 v 40 w(regrid)32 b(will)h(remap)f(riv)m(er)g(net)m(w)m
+(ork)h(data)g(from)f(global)h(regular)g(lat-lon)h(grid)d(on)m(to)j(an)m
+(y)e(Other)150 568 y(grid)24 b(\(includes)g(regular)g(lat-lon)i(grid)e
+(and)g(cubic)g(grid)g(\),)i(whic)m(h)e(is)g(sp)s(eci\014ed)f(through)h
+(option)h(mosaic.)150 677 y(The)30 b(riv)m(er)g(net)m(w)m(ork)i(source)
+e(data)h(is)g(sp)s(eci\014ed)e(through)h(option)h(riv)m(er)p
+2654 677 V 40 w(src.)390 825 y Fc(int)390 935 y(gs_river_regrid\(char)
+42 b(*history,)k(char)g(*mosaic_file,)e(char)j(*river_src_file,)533
+1044 y(char)g(*output_file\))150 1223 y(mosaic)192 b
+Fi(sp)s(ecify)29 b(the)h(mosaic)h(\014le)f(of)g(destination)h(grid.)40
+b(This)29 b(mosaic)i(\014le)f(should)f(b)s(e)g(a)h(coupler)630
+1333 y(mosaic)h(\014le,)g(whic)m(h)f(con)m(tains)i(link)e(to)h(land)f
+(solo)i(mosaic)f(and)f(the)g(exc)m(hange)i(grid)e(\014le.)150
+1505 y Fc(river_src)630 1615 y Fi(sp)s(ecify)21 b(the)h(riv)m(er)g(net)
+m(w)m(ork)h(source)f(data)g(\014le.)38 b(The)22 b(data)g(is)g(assumed)f
+(on)g(regular)h(lat-lon)630 1724 y(grid)27 b(and)f(the)h(longitude)h
+(is)f(assumed)f(from)g(0)i(to)f(360)i(degree)e(and)g(latitude)h(is)f
+(assumed)630 1834 y(from)j(-90)h(to)h(90)f(degree.)150
+2007 y Fc(output)192 b Fi(sp)s(ecify)39 b(the)g(output)g(\014le)g(base)
+g(name.)67 b(the)39 b(su\016x)f('.nc')i(should)e(not)h(b)s(e)g
+(included)f(in)630 2116 y(the)j(output)p 1071 2116 V
+40 w(\014le.)73 b(The)40 b(default)i(v)-5 b(alue)41 b(is)g(riv)m(er)p
+2368 2116 V 41 w(output.)72 b(F)-8 b(or)42 b(one)f(tile)i(mosaic,)i
+(the)630 2226 y(actual)29 b(result)f(will)g(b)s(e)g($output)p
+1761 2226 V 40 w(\014le.nc.)40 b(F)-8 b(or)29 b(m)m(ultiple)f(tile)i
+(mosaic,)f(the)f(result)g(will)h(b)s(e)630 2335 y($output.tile#.nc.)150
+2587 y Fh(4.5)68 b(T)-11 b(ransfer)45 b(to)g(Mosaic)390
+2747 y Fc(int)390 2856 y(gs_transfer_to_mosaic\(ch)o(ar)d(*old_file,)j
+(char)h(*mosaic_dir\))150 3035 y(old_file)96 b Fi(The)30
+b(old)g(\014le.)150 3208 y Fc(mosaic_dir)630 3317 y Fi(The)g(mosaic)h
+(directory)-8 b(.)150 3569 y Fh(4.6)68 b(Mak)l(e)46 b(a)f(V)-11
+b(ertical)45 b(Grid)150 3729 y Fi(This)31 b(program)h(call)h(b)s(e)e
+(used)g(to)h(mak)m(e)h(v)m(ertical)h(grid)e(for)f(FMS)h(mo)s(del.)45
+b(It)32 b(uses)f(cubic-spline)h(algo-)150 3838 y(rithm)k(to)h
+(calculate)i(the)e(grid)g(cell)g(lo)s(cation.)62 b(The)36
+b(output)g(netcdf)g(will)h(con)m(tains)h(information)f(on)150
+3948 y(sup)s(ergrid)20 b(with)i(grid)g(size)i(equal)e(mo)s(del)h(grid)f
+(size)h(m)m(ultipling)g(re\014nemen)m(t)f(\()g(alw)m(a)m(ys)i(2)f(\).)
+38 b(mak)m(e)p 3510 3948 V 41 w(vgrid)150 4058 y(tak)m(es)32
+b(the)e(follo)m(wing)i(\015ags)390 4205 y Fc(int)390
+4315 y(gs_make_vgrid\(char)43 b(*history,)i(int)i(nbnds,)f(int)h
+(*bnds,)f(int)h(n1,)676 4424 y(int)g(n2,)g(int)g(*nz,)g(char)f
+(*gridname,)f(char)i(*center\))150 4603 y(nbnds)240 b
+Fi(Sp)s(ecify)30 b(n)m(um)m(b)s(er)f(of)h(v)m(ertical)j(regions)e(for)f
+(v)-5 b(arying)30 b(resolution.)150 4776 y Fc(bnds)288
+b Fi(Sp)s(ecify)30 b(b)s(oundaries)f(for)h(de\014ning)f(v)m(ertical)k
+(regions)d(of)h(v)-5 b(arying)30 b(resolution.)150 4948
+y Fc(nz)384 b Fi(Num)m(b)s(er)29 b(of)i(mo)s(del)f(grid)g(p)s(oin)m(ts)
+g(for)g(eac)m(h)i(v)m(ertical)h(regions)d(of)h(v)-5 b(arying)30
+b(resolution.)150 5121 y Fc(grid_name)630 5230 y Fi(Sp)s(ecify)35
+b(the)g(grid)g(name.)56 b(The)35 b(output)g(grid)g(\014le)g(name)g
+(will)h(b)s(e)f(grid)p 3151 5230 V 40 w(name.nc.)55 b(The)630
+5340 y(default)31 b(v)-5 b(alue)30 b(is)h(v)m(ertical)p
+1559 5340 V 42 w(grid.)p eop end
+%%Page: 43 47
+TeXDict begin 43 46 bop 150 -116 a Fi(Chapter)20 b(4:)36
+b(GRIDSPEC)19 b(-)i(A)f(standard)g(for)g(the)g(description)h(of)f
+(grids)g(used)f(in)h(Earth)g(System)g(mo)s(dels43)150
+299 y Fc(center)192 b Fi(Sp)s(ecify)36 b(the)i(cen)m(ter)g(lo)s(cation)
+h(of)e(grid.)61 b(The)37 b(v)-5 b(alid)38 b(en)m(try)f(will)h(b)s(e)e
+('none',)k('t)p 3441 299 28 4 v 40 w(cell')f(or)630 408
+y('c)p 701 408 V 41 w(cell')34 b(with)e(default)h(v)-5
+b(alue)33 b('none'.)47 b(The)32 b(grid)h(re\014nemen)m(t)f(is)h
+(assumed)f(to)h(b)s(e)f(2)h(in)f(x)630 518 y(and)i(y-direction)h(when)e
+(cen)m(ter)i(is)f(not)h('none'.)52 b('c)p 2433 518 V
+41 w(cell')36 b(should)d(b)s(e)g(used)h(for)g(the)g(grid)630
+628 y(used)c(in)g(MOM4.)150 852 y Fh(4.7)68 b(Generate)46
+b(Three)f(Exc)l(hange)g(Grids)g(for)g(FMS)f(Coupler)150
+1012 y Fi(mak)m(e)p 362 1012 V 41 w(coupler)p 691 1012
+V 40 w(mosaic)h(generates)f(three)g(exc)m(hange)g(grids)f(for)g(the)h
+(FMS)f(coupler.)80 b(The)42 b(output)150 1121 y(\014le)h(includes)f
+(exc)m(hange)j(grid)d(\014les)h(for)g(\015uxes)f(b)s(et)m(w)m(een)h
+(atmosphere)g(and)f(surface)h(\(sea)h(ice)g(and)150 1231
+y(land\),)35 b(exc)m(hange)h(grid)e(\014les)g(for)g(runo\013)f(b)s(et)m
+(w)m(een)i(land)f(and)f(sea)i(ice.)53 b(There)34 b(migh)m(t)g(b)s(e)g
+(more)g(than)150 1341 y(one)40 b(exc)m(hange)h(grid)f(\014les)g(b)s(et)
+m(w)m(een)g(t)m(w)m(o)h(mo)s(del)f(solo)h(mosaic)g(b)s(ecause)f(there)g
+(migh)m(t)g(b)s(e)f(m)m(ultiple)150 1450 y(tiles)45 b(in)e(a)i(solo)f
+(mosaic.)83 b(All)44 b(the)g(exc)m(hange)h(grid)f(information)g(are)g
+(b)s(et)m(w)m(een)h(mo)s(del)e(grid,)48 b(not)150 1560
+y(b)s(et)m(w)m(een)36 b(sup)s(ergrid.)54 b(W)-8 b(e)37
+b(assume)e(the)g(re\014nemen)m(t)h(ratio)g(b)s(et)m(w)m(een)g(mo)s(del)
+f(grid)h(and)e(sup)s(ergrid)g(is)150 1669 y(2.)57 b(Curren)m(tly)35
+b(w)m(e)h(only)g(output)f(the)h(exc)m(hange)h(grid)e(on)h(T-cell.)57
+b(Besides)36 b(generate)i(the)d(exc)m(hange)150 1779
+y(grid)42 b(\014les,)j(mak)m(e)p 783 1779 V 41 w(coupler)p
+1112 1779 V 40 w(mosaic)e(also)g(generate)h(the)e(coupler)g(mosaic)i
+(\014le)e(\(the)g(\014le)g(name)h(will)150 1888 y(b)s(e)31
+b(mosaic)p 548 1888 V 41 w(name.nc\))h(whic)m(h)f(con)m(tains)i(the)f
+(atmos,)h(land)e(and)g(o)s(cean)h(mosaic)h(path,)f(o)s(cean)g(mosaic)
+150 1998 y(top)s(og)44 b(path)f(and)g(exc)m(hange)h(grid)f(\014le)h
+(path.)79 b(mak)m(e)p 2092 1998 V 41 w(coupler)p 2421
+1998 V 40 w(mosaic)44 b(exp)s(ects)g(NetCDF)h(format)150
+2108 y(input.)390 2238 y Fc(int)390 2348 y(gs_make_coupler_mosaic\(c)o
+(har)c(*history,)46 b(char)g(*amosaic,)g(char)g(*lmosaic,)724
+2457 y(char)h(*omosaic,)e(char)i(*otopog,)e(int)i(interp_order,)724
+2567 y(double)f(sea_level,)f(char)i(*mosaic_name,)d(int)j(check\))150
+2719 y(atmos_mosaic)630 2828 y Fi(sp)s(ecify)36 b(the)g(atmosphere)h
+(mosaic)g(information.)58 b(This)36 b(\014le)g(con)m(tains)h(list)g(of)
+g(tile)g(\014les)630 2938 y(whic)m(h)h(sp)s(ecify)g(the)h(grid)f
+(information)h(for)f(eac)m(h)i(tile.)66 b(Eac)m(h)39
+b(grid)f(is)h(required)e(to)j(b)s(e)630 3047 y(regular)31
+b(lon/lat)h(grid.)40 b(The)30 b(\014le)g(name)h(can)g(not)f(b)s(e)g
+('mosaic.nc')150 3199 y Fc(ocean_mosaic)630 3309 y Fi(sp)s(ecify)j(the)
+h(o)s(cean)g(mosaic)h(information.)51 b(This)33 b(\014le)h(con)m(tains)
+h(list)f(of)g(tile)h(\014les)e(whic)m(h)630 3418 y(sp)s(ecify)c(the)g
+(grid)g(information)g(for)g(eac)m(h)h(tile.)42 b(The)29
+b(\014le)g(name)g(can)g(not)h(b)s(e)e('mosaic.nc')150
+3570 y Fc(ocean_topog)630 3680 y Fi(sp)s(ecify)38 b(the)g(top)s(ograph)
+m(y)h(information)g(for)f(o)s(cean)h(mosaic.)65 b(The)38
+b(\014eld)g(name)g(of)h(the)630 3789 y(top)s(ograph)m(y)c(is)h(depth)p
+1448 3789 V 39 w(tile#)g(or)g(depth)e(when)g(n)m(tiles)j(=)e(1,)i(The)d
+(top)s(ograph)m(y)i(data)g(is)630 3899 y(p)s(ositiv)m(e)31
+b(do)m(wn.)150 4050 y Fc(land_mosaic)630 4160 y Fi(sp)s(ecify)37
+b(the)h(land)f(mosaic)h(information.)63 b(This)36 b(\014le)i(con)m
+(tains)g(list)h(of)e(tile)i(\014les)e(whic)m(h)630 4270
+y(sp)s(ecify)e(the)g(grid)g(information)h(for)f(eac)m(h)h(tile.)57
+b(Eac)m(h)36 b(grid)e(is)i(required)e(to)i(b)s(e)f(regular)630
+4379 y(lon/lat)42 b(grid.)71 b(When)41 b(land)p 1650
+4379 V 39 w(mosaic)h(is)f(not)f(sp)s(eci\014ed,)j(atmosphere)e(mosaic)h
+(will)f(b)s(e)630 4489 y(used)30 b(to)h(sp)s(ecify)f(land)g(mosaic.)42
+b(The)29 b(\014le)i(name)f(can)h(not)g(b)s(e)e('mosaic.nc'.)150
+4640 y Fc(interp_order)630 4750 y Fi(sp)s(ecify)i(the)h(order)f(of)h
+(conserv)-5 b(ativ)m(e)33 b(in)m(terplation.)46 b(Its)32
+b(v)-5 b(alue)32 b(can)g(b)s(e)f(1)h(\()f(linear)h(order)630
+4860 y(\))f(or)f(2)h(\()f(second)h(order)f(\))g(with)g(default)h(v)-5
+b(alue)31 b(2.)150 5011 y Fc(sea_level)d(#)630 5121 y
+Fi(sp)s(ecify)21 b(the)h(sea)g(lev)m(el)h(\()e(in)h(meters)f(\))h(and)f
+(its)g(v)-5 b(alue)22 b(will)g(b)s(e)f(used)f(to)j(determine)e
+(land/sea)630 5230 y(mask.)50 b(When)33 b(top)s(ograph)m(y)g(of)h(a)f
+(grid)g(cell)i(is)e(less)h(than)f(sea)h(lev)m(el,)i(this)d(grid)g(cell)
+i(will)630 5340 y(b)s(e)30 b(land,)g(otherwise)h(it)g(will)f(b)s(e)g(o)
+s(cean.)42 b(Default)31 b(v)-5 b(alue)31 b(is)f(0)p eop
+end
+%%Page: 44 48
+TeXDict begin 44 47 bop 150 -116 a Fi(44)2356 b(The)30
+b(CF)g(Library)g(Users)g(Guide)150 299 y Fc(mosaic_name)630
+408 y Fi(coupler)i(mosaic)h(name.)46 b(The)32 b(output)f(coupler)h
+(mosaic)h(\014le)g(will)f(b)s(e)f(mosaic)p 3361 408 28
+4 v 41 w(name.nc.)630 518 y(default)g(v)-5 b(alue)30
+b(is)h('mosaic'.)150 674 y Fc(check)240 b Fi(c)m(hec)m(k)32
+b(the)f(tiling)g(error.)150 903 y Fh(4.8)68 b(Generate)46
+b(T)-11 b(op)t(ograph)l(y)44 b(for)i(An)l(y)e(Mosaic)150
+1063 y Fi(mak)m(e)p 362 1063 V 41 w(top)s(og)e(can)f(generate)h(top)s
+(ograph)m(y)f(for)g(an)m(y)g(Mosaic.)74 b(The)40 b(output)h(\014le)g
+(will)g(con)m(tains)h(the)150 1172 y(top)s(ograph)m(y)26
+b(for)g(eac)m(h)h(tile)g(in)f(the)g(Mosaic.)41 b(The)25
+b(\014eld)h(name)g(in)f(the)i(output)e(top)s(ograph)m(y)h(\014le)g
+(will)h(b)s(e)150 1282 y(depth)p 384 1282 V 39 w(tile#)e(and)f(it)g(is)
+g(p)s(ositiv)m(e)h(do)m(wn.)38 b(The)24 b(top)s(ograph)m(y)g(data)g
+(will)h(b)s(e)e(de\014ned)g(on)h(mo)s(del)f(grid,)j(the)150
+1391 y(mo)s(del)j(grid)g(size)h(will)g(b)s(e)f(sup)s(ergrid)e(grid)i
+(size)h(divided)f(b)m(y)g(re\014nemen)m(t)g(\(x)p 2808
+1391 V 41 w(re\014ne,)g(y)p 3169 1391 V 40 w(re\014ne,)g(default)150
+1501 y(is)j(2\).)47 b(mosaic)33 b(is)f(a)h(required)e(option)i(and)f
+(all)h(other)f(options)g(are)h(optional,)h(but)e(some)g(options)h(are)
+150 1611 y(required)d(dep)s(ending)e(on)j(the)f(c)m(hoice)i(of)f(top)s
+(og)p 1830 1611 V 41 w(t)m(yp)s(e.)390 1743 y Fc(int)390
+1853 y(gs_make_topog\(char)43 b(*history,)i(char)i(*mosaic_file,)d
+(char)j(*topog_type,)1058 1963 y(int)g(x_refine,)e(int)i(y_refine,)1058
+2072 y(double)f(basin_depth,)f(char)h(*topog_file,)f(double)h
+(bottom_depth,)1058 2182 y(double)g(min_depth,)f(double)h
+(scale_factor,)f(int)h(num_filter_pass,)1058 2291 y(double)g
+(gauss_amp,)f(double)h(gauss_scale,)f(double)h(slope_x,)1058
+2401 y(double)g(slope_y,)g(double)g(bowl_south,)f(double)h(bowl_north,)
+1058 2511 y(double)g(bowl_west,)f(double)h(bowl_east,)f(int)i
+(fill_first_row,)1058 2620 y(int)g(filter_topog,)d(int)j
+(round_shallow,)d(int)j(fill_shallow,)1058 2730 y(int)g
+(deepen_shallow,)d(int)j(smooth_topo_allow_deepe)o(ning)o(,)1058
+2839 y(char)g(*output_file\))150 2995 y(mosaic)192 b
+Fi(Sp)s(ecify)30 b(the)g(mosaic)i(\014le)e(where)g(top)s(ograph)m(y)h
+(data)g(lo)s(cated.)150 3152 y Fc(topog_type)630 3261
+y Fi(Sp)s(ecify)42 b(t)m(yp)s(e)h(of)g(top)s(ograph)m(y)-8
+b(.)78 b(Its)42 b(v)-5 b(alue)43 b(can)g(b)s(e)f('realistic',)49
+b('rectangular)p 3457 3261 V 41 w(basin',)630 3371 y('gaussian',)31
+b('b)s(o)m(wl')g(or)f('idealized'.)43 b(The)30 b(default)g(v)-5
+b(alue)31 b(is)g('realistic'.)150 3527 y Fc(x_refine)d(#)630
+3636 y Fi(the)j(re\014nemen)m(t)f(ratio)h(of)g(mo)s(del)f(grid)g(vs)g
+(sup)s(ergrid)f(ins)h(x-directin.)41 b(default)30 b(v)-5
+b(alue)31 b(2.)150 3792 y Fc(y_refine)d(#)630 3902 y
+Fi(the)j(re\014nemen)m(t)f(ratio)h(of)g(mo)s(del)f(grid)g(vs)g(sup)s
+(ergrid)f(ins)h(y-directin.)41 b(default)30 b(v)-5 b(alue)31
+b(2.)150 4058 y Fc(basin_depth)c(#)630 4168 y Fi(the)33
+b(basin)e(depth)h(when)f(top)s(og)p 1757 4168 V 41 w(t)m(yp)s(e)i(is)f
+('rectangular)p 2572 4168 V 41 w(basin'.)47 b(Default)33
+b(v)-5 b(alue)33 b(is)f(5000)630 4277 y(meter.)150 4433
+y Fc(topog_file)630 4543 y Fi(Sp)s(ecify)e(name)g(of)h(top)s(ograh)m(y)
+g(\014le)f(\(e.g.)42 b(scripps,)30 b(na)m(vy)p 2607 4543
+V 40 w(top)s(o,)h(...\))150 4699 y Fc(topog_field)630
+4809 y Fi(Sp)s(ecify)f(name)g(of)h(top)s(ograph)m(y)f(\014eld)g(name)h
+(in)f(top)s(og)p 2550 4809 V 40 w(\014le.)150 4965 y
+Fc(bottom_depth)d(#)630 5074 y Fi(maxim)m(um)j(depth)g(\(or)h(b)s
+(ottom)f(depth\))g(of)h(o)s(cean.)41 b(default)31 b(v)-5
+b(alue)31 b(is)f(5000)i(meter.)150 5230 y Fc(min_depth)c(#)630
+5340 y Fi(minim)m(um)i(depth)f(of)i(o)s(cean.)41 b(default)31
+b(v)-5 b(alue)30 b(is)h(10)g(meter.)p eop end
+%%Page: 45 49
+TeXDict begin 45 48 bop 150 -116 a Fi(Chapter)20 b(4:)36
+b(GRIDSPEC)19 b(-)i(A)f(standard)g(for)g(the)g(description)h(of)f
+(grids)g(used)f(in)h(Earth)g(System)g(mo)s(dels45)150
+299 y Fc(scale_factor)27 b(#)630 408 y Fi(scaling)34
+b(factor)g(for)e(top)s(ograph)m(y)h(data)h(\(e.g.)49
+b(-1)34 b(to)f(\015ip)f(sign)h(or)g(0.01)h(to)g(con)m(v)m(ert)g(from)
+630 518 y(cen)m(timeters\).)43 b(default)30 b(v)-5 b(alue)31
+b(is)g(1.)150 677 y Fc(num_filter_pass)26 b(#)630 787
+y Fi(n)m(um)m(b)s(er)j(of)i(passes)f(of)g(spatial)i(\014lter)e(default)
+h(v)-5 b(alue)31 b(is)f(1.)150 946 y Fc(gauss_amp)e(#)630
+1056 y Fi(heigh)m(t)j(of)g(gaussian)f(bump)f(as)i(p)s(ercen)m(tage)g
+(of)g(o)s(cean)g(depth.)40 b(default)30 b(v)-5 b(alue)31
+b(is)g(0.5.)150 1215 y Fc(gauss_scale)c(#)630 1325 y
+Fi(width)j(of)g(gaussian)h(bump)d(as)j(p)s(ercen)m(tag)g(e)g(of)g
+(basin)e(width.)40 b(Default)32 b(v)-5 b(alue)31 b(is)f(0.25.)150
+1484 y Fc(slope_x)e(#)68 b Fi(rise)30 b(of)h(the)g(o)s(cean)g(\015o)s
+(or)e(to)j(the)e(east)h(for)g(the)f(gaussian)h(bump.)39
+b(Default)31 b(v)-5 b(alue)31 b(is)g(0.)150 1644 y Fc(slope_y)d(#)68
+b Fi(rise)30 b(of)h(the)g(o)s(cean)g(\015o)s(or)e(to)j(the)e(north)g
+(for)g(the)h(gaussian)f(bump.)39 b(Default)32 b(v)-5
+b(alue)30 b(is)h(0.)150 1803 y Fc(bowl_south)d(#)630
+1913 y Fi(southern)h(b)s(oundary)g(of)h(Win)m(ton)i(b)s(o)m(wl.)40
+b(Default)32 b(v)-5 b(alue)31 b(is)f(60.)150 2072 y Fc(bowl_north)e(#)
+630 2182 y Fi(northern)h(b)s(oundary)g(of)h(Win)m(ton)h(b)s(o)m(wl.)41
+b(Default)31 b(v)-5 b(alue)31 b(is)g(70.)150 2341 y Fc(bowl_west)d(#)
+630 2451 y Fi(w)m(estern)j(b)s(oundary)d(of)i(Win)m(ton)i(b)s(o)m(wl.)
+40 b(Default)32 b(v)-5 b(alue)31 b(is)f(0.)150 2610 y
+Fc(bowl_east)e(#)630 2720 y Fi(eastern)j(b)s(oundary)d(of)j(Win)m(ton)g
+(b)s(o)m(wl.)41 b(Default)31 b(v)-5 b(alue)31 b(is)f(20.)150
+2879 y Fc(fill_first_row)630 2989 y Fi(when)f(true,)i(mak)m(e)g
+(\014rst)f(ro)m(w)g(of)h(o)s(cean)g(mo)s(del)f(all)h(land)f(p)s(oin)m
+(ts)h(for)f(ice)h(mo)s(del.)150 3148 y Fc(filter_topog)630
+3258 y Fi(when)e(true,)i(apply)f(\014lter)g(to)h(top)s(ograph)m(y)-8
+b(.)150 3417 y Fc(round_shallow)630 3527 y Fi(when)26
+b(true,)h(Mak)m(e)h(cells)g(land)e(if)h(depth)f(is)g(less)h(than)g(1/2)
+h(mim)m(umim)e(depth,)h(otherwise)630 3636 y(mak)m(e)k(o)s(cean.)150
+3796 y Fc(fill_shallow)630 3905 y Fi(when)e(sp)s(eci\014ed,)h(Mak)m(e)i
+(cells)g(less)e(than)h(minim)m(um)e(depth)h(land.)150
+4065 y Fc(deepen_shallow)630 4174 y Fi(when)f(sp)s(eci\014ed,)g(Mak)m
+(e)j(cells)f(less)f(than)f(minim)m(um)g(depth)g(equal)i(to)f(minim)m
+(um)f(depth.)150 4334 y Fc(smooth_topo_allow_deepen)o(ing)630
+4443 y Fi(when)g(sp)s(eci\014ed,)h(allo)m(w)i(\014lter)f(to)g(deep)s
+(en)e(cells.)150 4603 y Fc(output)192 b Fi(The)33 b(created)i(netcdf)f
+(\014le)f(that)i(con)m(tains)g(mosaic)f(top)s(ograph)m(y)-8
+b(.)52 b(Default)35 b(v)-5 b(alue)34 b(is)g('to-)630
+4712 y(p)s(og.nc')p eop end
+%%Page: 46 50
+TeXDict begin 46 49 bop eop end
+%%Page: 47 51
+TeXDict begin 47 50 bop 150 -116 a Fi(Index)3286 b(47)150
+299 y Ff(Index)150 610 y Fh(A)150 726 y Fb(API,)25 b(C)17
+b Fa(:)d(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)
+g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g
+(:)g(:)h(:)f(:)g(:)g(:)g(:)44 b Fb(1)150 814 y(API,)25
+b(F90)15 b Fa(:)g(:)e(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)h
+(:)f(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)
+g(:)g(:)g(:)g(:)g(:)h(:)f(:)42 b Fb(1)150 901 y(API,)25
+b(F)-6 b(ortran)21 b Fa(:)13 b(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)h
+(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)
+g(:)g(:)g(:)g(:)g(:)h(:)47 b Fb(1)2025 610 y Fh(S)2025
+919 y Fb(supp)r(orted)25 b(programming)i(languages)18
+b Fa(:)c(:)g(:)f(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)45
+b Fb(1)p eop end
+%%Page: 48 52
+TeXDict begin 48 51 bop eop end
 %%Trailer
 
 userdict /end-hook known{end-hook}if
diff --git a/doc/libcf.texi b/doc/libcf.texi
index b2b971c..48db11f 100644
--- a/doc/libcf.texi
+++ b/doc/libcf.texi
@@ -1,5 +1,5 @@
 \input texinfo @c -*-texinfo-*-
- at comment $Id: libcf.texi,v 1.11 2007/05/02 20:29:47 ed Exp $
+ at comment $Id: libcf.texi,v 1.3 2009/09/15 17:39:45 ed Exp $
 @c %**start of header
 @setfilename libcf.info
 @settitle The CF Library Users Guide 
@@ -45,10 +45,10 @@ applies to libcf version @value{VERSION}, and was last updated on
 @menu
 * Summary::                     
 * Installation::                
-* cfcheck::                     
 * Files::                       
 * Variables::                   
 * Coordinates::                 
+* GRIDSPEC::                    
 * Combined Index::              
 @end menu
 
@@ -85,7 +85,7 @@ with netCDF itself. A Fortran 90 API is planned, but not yet begun.
 For more information about the CF Conventions, see the CF Metadata
 web site at @uref{@value{cf-url}}.
 
- at node Installation, cfcheck, Summary, Top
+ at node Installation, Files, Summary, Top
 @unnumbered Downloading and Installing libcf
 
 Currently, and for some time to come, libcf is in alpha release. The
@@ -123,13 +123,13 @@ configure and build output, in ASCII (the output.txt file produced by
 the above build commands), and the file config.log, which is generated
 by the configure script.
 
- at node cfcheck, Files, Installation, Top
- at chapter The cfcheck Utility
+ at c  @node cfcheck, Files, Installation, Top
+ at c  @chapter The cfcheck Utility
 
-The cfchck utility will chck a file to see if it contains valid CF
-metadata. Messages about the file are printed to stdout.
+ at c  The cfchck utility will chck a file to see if it contains valid CF
+ at c  metadata. Messages about the file are printed to stdout.
 
- at node Files, Variables, cfcheck, Top
+ at node Files, Variables, Installation, Top
 @chapter Files
 
 @menu
@@ -2272,7 +2272,7 @@ This function returns zero for success, or an error code for failure.
 @example
 @end example
  
- at node Coordinates, Combined Index, Variables, Top
+ at node Coordinates, GRIDSPEC, Variables, Top
 @chapter Coordinate Systems
 
 @menu
@@ -2537,7 +2537,646 @@ failure.
 @example
 @end example
  
- at node Combined Index,  , Coordinates, Top
+ at node GRIDSPEC, Combined Index, Coordinates, Top
+ at chapter GRIDSPEC - A standard for the description of grids used in Earth System models
+
+The GRIDSPEC is a proposed CF standard. It is not yet part of the
+Climate and Forecast Conventions. Support for GRIDSPEC in libcf is
+provided as a service to the CF community, allowing for the evaluation
+of the proposed GRIDSPEC standard.
+
+Each of the GRIDSPEC tools listed below may be call programmatically, or
+with a command line utility.
+
+For more information about GRIDSPEC see @url{@value{gridspec-url}}.
+
+ at menu
+* gs_make_hgrid::               
+* gs_fregrid::                  
+* gs_make_solo_mosaic::         
+* gs_river_regrid::             
+* gs_transfer_to_mosaic::       
+* gs_make_vgrid::               
+* gs_make_coupler_mosaic::      
+* gs_make_topog::               
+ at end menu
+
+ at node gs_make_hgrid, gs_fregrid, GRIDSPEC, GRIDSPEC
+ at section Make a Horizontal Grid
+
+This function can generate different types of horizontal grids. The
+output data is on supergrid ( model grid size x refinement(=2) ).  For
+'cubic_grid', six grid files which contain the grid information for each
+tile will be generated, otherwise one file will be generated. 
+
+Specify the grid type through grid_type parameter. The value of
+grid_type can be 'from_file', 'spectral_grid', 'spherical_grid',
+'conformal_cubic_grid', 'gnomonic_ed' or 'simple_cartesian_grid', with
+default value 'spherical_grid'. 
+
+The nlon and nlat parameters must be specified to
+indicate supergrid size (for cubic_grid, nlat is not needed because
+nlat has the same value as nlon).  
+
+ at example
+int
+gs_make_hgrid(char *grid_type, int *nlat, int *nlon, 
+	      int nxbnds0, int nybnds0, int nxbnds1, int nybnds1, 
+	      int nxbnds2, int nybnds2, double lat_join, int nratio, 
+	      double simple_dx, double simple_dy, int ntilex, int ntiley,
+              char *gridname, char *center, char *history, double *xbnds, 
+	      double *ybnds)
+ at end example
+
+The following grid types are available:
+
+ at table @code 
+
+ at item from_file 
+my_grid_file must be specified. The grid " specified in my_grid_file
+should be super grid vertex.
+
+ at item spectral_grid 
+no other optional or required arguments.       
+
+ at item regular_lonlat_grid 
+nxbnds, nybnds xbnds, ybnds, must be specified to define the
+grid bounds.
+
+ at item tripolar_grid 
+nxbnds, nybnds, xbnds, ybnds, must be specified to define the
+grid bounds. lat_join is optional with default value 65.
+
+ at item conformal_cubic_grid 
+nratio is optional argument.                 
+
+ at item gnomonic_ed 
+equal distance gnomonic cubic grid.            
+
+ at item simple_cartesian_grid 
+xbnds, ybnds must be specified to define   
+                               the grid bounds location and grid size. number 
+                               of bounds must be 2 in both and x and          
+                               y-direction. simple_dx and simple_dy must b
+                               specified to specify uniform cell length.      
+
+ at end table
+
+                                                                              
+ at table @code
+                                                                              
+ at item grid_type 
+specify type of topography (see table above).
+                                                                              
+ at item my_grid_file 
+when this flag is present, the program will read grid information from
+'my_grid_file'. The file format can be ascii file or netcdf
+file. Multiple file entry are allowed but the number should be less than
+MAXBOUNDS.
+
+ at item nxbnds
+Specify number of zonal regions for varying resolution.                                      
+                                                                              
+ at item nybnds
+Specify number of meridinal regions for varying resolution.                                      
+                                                                              
+ at item xbnds 
+Specify boundaries for defining zonal regions of varying
+resolution. When tripolar is present, x also defines the longitude of
+the two new poles nxbnds must be 2 and lon_start = x(1), lon_end =
+x(nxbnds) are longitude of the two new poles.
+                                                                              
+ at item ybnds
+Specify boundaries for defining meridional regions of varying resolution                    
+                                                                              
+ at item nlon 
+Number of model grid points(supergrid) for each zonal regions of varying
+resolution.
+                                                                               
+ at item nlat 
+Number of model grid points(supergid) for each meridinal regions of
+varying resolution.
+                                                                              
+ at item lat_join
+Specify latitude for joining spherical and rotate bipolar grid. Default
+value is 65 degree.
+                                                                              
+ at item nratio 
+Speicify the refinement ratio when calculating cell length and area of
+supergrid.
+                                                                              
+ at item simple_dx 
+Specify the uniform cell length in x-direction fo simple cartesian grid.
+                                                                              
+ at item simple_dy 
+Specify the uniform cell length in y-direction fo simple cartesian grid.
+                                                                              
+ at item ndivx 
+Specify number division in x-direction for each face, default value is
+1.
+                                                                              
+ at item ndivy 
+Specify number division in y-direction for each face, default value is
+1.
+                                                                              
+ at item grid_name 
+Specify the grid name. The output grid file name will be grid_name.nc if
+there is one tile and grid_name.tile#.nc if there is more than one tile
+The default value will be horizontal_grid.
+                                                                              
+ at item center 
+Specify the center location of grid. The valid entry will be 'none',
+'t_cell' or 'c_cell' with default value 'none'. The grid refinement is
+assumed to be 2 in x and y-direction when center is not 'none'. 'c_cell'
+should be used for the gr used in MOM4.
+
+ at end table
+
+ at node gs_fregrid, gs_make_solo_mosaic, gs_make_hgrid, GRIDSPEC
+ at section Remap data from Input Mosaic to Output Mosaic
+
+This function remaps data (scalar or vector) from input_mosaic onto
+output_mosaic.
+
+The target grid also could be specified through lonBegin,
+lonEnd, latBegin, latEnd, nlon and nlat. 
+
+Currently only T-cell scalar regridding and AGRID vector regridding
+(only bilinear interpolation is implemented for cubic grid vector
+interpolation). The interpolation algorithm used is controlled by
+interp_method with default 'conserve_order1'. 
+
+Currently only 'conserve_order1', 'conserve_order2' and 'bilinear'
+remapping scheme are implemented. 'bilinear' is only used to remap data
+from cubic grid to latlon grid. We will add more scheme in the future if
+needed. fregrid expects NetCDF format input. scalar_field and/or
+u_field/v_field must be specified. u_fld and v_fld must be paired
+together.
+
+ at example
+int
+gs_fregrid(char *history, char *mosaic_in, char *mosaic_out, char *dir_in, 
+           char *dir_out, char **input_file, int nfiles, char **output_file, 
+           int nfiles_out, char *remap_file, char **scalar_name, int nscalar,
+           char **u_name, int nvector, char **v_name, int nvector2, 
+           char *interp_method, char *test_case, double test_param, 
+           unsigned int opcode, int grid_type, unsigned int finer_step,
+           int fill_missing, int nlon, int nlat, int check_conserve, 
+           int y_at_center, double lonbegin, double lonend, double latbegin,
+           double latend, int kbegin, int kend, int lbegin, int lend)
+ at end example
+                                                                              
+ at table @code
+ at item innput_mosaic 
+Specify the input mosaic information. This file contains list of tile
+files which specify the grid information for each tile.
+                                                                                     
+ at item input_file 
+specify the input file name. The suffix '.nc' can be omitted. The suffix
+'tile#' should not present for multiple-tile files. The number of files
+must be 1 for scalar regridding and can be 1 or 2 for vector
+regridding. File path should not be includes.
+                                                                                     
+ at item scalar_field
+specify the scalar field name to be regridded. The multiple entry field
+names are seperated by comma.
+                                                                                         
+ at item u_field 
+specify the vector field u-componentname to be regridded. The multiple
+entry field names are seperated by comma. u_field must be paired
+together with v_field.
+                                                                                         
+ at item v_field 
+specify the vector field v-componentname to be regridded. The multiple
+entry field names are seperated by comma. v_field must be paired
+together with u_field.
+                                                                                       
+ at item output_mosaic 
+specify the output mosaic information. This file contains list of tile
+files which specify the grid information for each tile. If output_mosaic
+is not specified, nlon and nlat must be specified.
+                                                                                     
+ at item lonBegin  # 
+specify the starting longitude(in degree) of the geographical region of
+the target grid on which the output is desired. The default value is 0.
+                                                                                     
+ at item lonEnd   
+specify the ending longitude(in degree) of the geographical region of
+the target grid on which the output is desired. The default value is
+360.
+                                                                                     
+ at item latBegin  
+specify the starting latitude(in degree) of the geographical region of
+the target grid on which the output is desired. The default value is
+-90.
+                                                                                     
+ at item latEnd   
+specify the ending latitude(in degree) of the geographical region of the
+target grid on which the output is desired. The default value is 90.
+                                                                                     
+ at item nlon 
+specify number of grid box cells in x-direction for a regular lat-lon
+grid.
+                                                                                     
+ at item nlat 
+specify number of grid box cells in y-direction for a regular lat-lon
+grid.
+                                                                                       
+ at item KlevelBegin 
+specify begin index of the k-level (depth axis) that to be regridded.
+                                                                                     
+ at item KlevelEnd 
+specify end index of the k-level (depth axis) that to be regridded.
+                                                                                     
+ at item LstepBegin 
+specify the begin index of L-step (time axis) that to be regridded.
+                                                                                     
+ at item LstepEnd 
+specify the end index of L-step (time axis) that to be regridded.
+                                                                                       
+ at item output_file 
+specify the output file name. If not presented, output_file will take
+the value of input_file. The suffix '.nc' can be omitted. The suffix
+'tile#' should not present for multiple-tile files. The number of files
+must be 1 for scalar regridding and can be 1 or 2 for vector
+regridding. File path should not be includes
+                                                                                     
+ at item input_dir 
+specify the path that stores input_file. If not presented, the input
+file is assumed to be stored in current diretory.
+                                                                                     
+ at item output_dir 
+specify the path that will store output file. If not presented, the
+output file will be stored in current diretory.
+                                                                                     
+ at item remap_file 
+specify the file name that saves remapping information.  If remap_file
+is specified and the file does not exist, remapping information will be
+calculated ans stored in remap_file. If remap_file is specified and the
+file exists, remapping information will be read from remap_file.
+                                                                                     
+ at item interp_method 
+specify the remapping algorithm to be used. Default is
+'conserve_order1'. Currently only 'conserve_order1', 'conserve_order2'
+and 'bilinear' remapping scheme are implemented in this tool. The
+bilinear scheme can only be used to remap data from cubic grid to
+regular latlon grid. When interp_method is 'bilinear', nlon and nlat
+must be specified and the output data in y-direction will be located at
+the center of cell or bound of the cell depending on the setting of
+y_center.
+                                                                                     
+ at item test_case 
+specify the test function to be used for testing.
+                                                                                     
+ at item grid_type 
+specify the vector field grid location. default is AGRID and only AGRID
+is implemented yet.
+                                                                                     
+ at item symmetry 
+the grid is symmetry or not.
+                                                                                     
+ at item target_grid 
+input cell area instead of calculating based on exchange grid
+area. default is off.
+                                                                                     
+ at item -finer_step 
+This is used only for bilinear interpolation. Set finer_step to a
+positive integer to reduce noise in interpolation and get a relatively
+smooth output. The default value is 0. When finer_step is greater than
+0, fregrid will first remap data from source grid onto a finer grid with
+resolution that is power of 2 of destination grid resolution using
+bilinear interpolation, then using volume averaging to remap data from
+finer grid onto destination grid.
+                                                                                     
+ at item center_y
+output latitude will locate at cell center, i.e., the starting latitude
+will be -89 when nlat = 90. when center_y is not set, starting latitude
+will be -90. for bilinear interpolation. For conservative interpolation,
+center_y is assumed.
+                                                                                     
+ at item check_conserve
+check the conservation of conservative interpolation.  The area sum will
+be printed out for input and output mosaic.
+                                                                              
+ at end table
+
+ at node gs_make_solo_mosaic, gs_river_regrid, gs_fregrid, GRIDSPEC
+ at section Generate Mosaic Information Between Tiles
+
+This function generates Mosaic information between tiles. The mosaic
+information includes: list of tile files, list of contact region
+specified by index, contact type.
+
+ at example
+int
+gs_make_solo_mosaic(char *history, int ntiles, char *mosaic_name, char *grid_descriptor,
+                    char **tilefile, double periodx, double periody, char *dir)
+ at end example
+                                                                              
+ at table @code
+             
+ at item num_tiles 
+Number of tiles in the mosaic.
+                                                                                
+ at item dir 
+The directory that contains all the tile grid file.
+                                                                                
+ at item mosaic_name 
+mosaic name. The output file will be mosaic_name.nc.  default is
+'mosaic'.
+                                                                                
+ at item tile_file 
+Grid file name of all tiles in the mosaic. The file name should be
+relative file name ( exclude the absolute file path). The absolute file
+path will be dir/tile_file.  If this option is not specified, the
+tile_file will be 'horizontal_grid.tile#.nc'
+                                                                                
+ at item periodx 
+Specify the period in x-direction of mosaic. Default    
+                        value is 0 (not periodic).                              
+                                                                                
+ at item periody 
+Specify the period in y-direction of mosaic. Default value is 0 (not periodic).
+                                                                 
+ at end table
+
+ at node gs_river_regrid, gs_transfer_to_mosaic, gs_make_solo_mosaic, GRIDSPEC
+ at section Remap River Network Data
+
+river_regrid will remap river network data from global regular lat-lon
+grid onto any Other grid (includes regular lat-lon grid and cubic grid
+), which is specified through option mosaic. The river network source
+data is specified through option river_src.
+
+ at example
+int
+gs_river_regrid(char *history, char *mosaic_file, char *river_src_file, 
+   char *output_file)
+ at end example
+                                                                              
+ at table @code
+ at item mosaic 
+specify the mosaic file of destination grid. This mosaic file should be
+a coupler mosaic file, which contains link to land solo mosaic and the
+exchange grid file.
+                                                                                     
+ at item river_src 
+specify the river network source data file. The data is assumed on
+regular lat-lon grid and the longitude is assumed from 0 to 360 degree
+and latitude is assumed from -90 to 90 degree.
+                                                                                     
+ at item output 
+specify the output file base name. the suffix '.nc' should not be
+included in the output_file. The default value is river_output. For one
+tile mosaic, the actual result will be $output_file.nc. For multiple
+tile mosaic, the result will be $output.tile#.nc.
+
+ at end table
+
+ at node gs_transfer_to_mosaic, gs_make_vgrid, gs_river_regrid, GRIDSPEC
+ at section Transfer to Mosaic
+
+ at example
+int
+gs_transfer_to_mosaic(char *old_file, char *mosaic_dir)
+ at end example
+                                                                              
+ at table @code
+
+ at item old_file
+The old file.
+
+ at item mosaic_dir
+The mosaic directory.
+                                                                              
+ at end table
+
+ at node gs_make_vgrid, gs_make_coupler_mosaic, gs_transfer_to_mosaic, GRIDSPEC
+ at section Make a Vertical Grid
+
+This program call be used to make vertical grid for FMS model.     
+It uses cubic-spline algorithm to calculate the grid cell location.
+The output netcdf will contains information on supergrid with grid 
+size equal model grid size multipling refinement ( always 2 ).     
+make_vgrid takes the following flags                               
+
+ at example
+int 
+gs_make_vgrid(char *history, int nbnds, int *bnds, int n1, 
+	      int n2, int *nz, char *gridname, char *center)
+ at end example
+                                                                              
+ at table @code
+ at item nbnds 
+Specify number of vertical regions for varying resolution.
+                                                                               
+ at item bnds 
+Specify boundaries for defining vertical regions of varying resolution.
+                                                                             
+ at item nz 
+Number of model grid points for each vertical regions of varying
+resolution.
+                                                                                
+ at item grid_name 
+Specify the grid name. The output grid file name will be
+grid_name.nc. The default value is vertical_grid.
+                                                                                  
+ at item center 
+Specify the center location of grid. The valid entry will be 'none',
+'t_cell' or 'c_cell' with default value 'none'. The grid refinement is
+assumed to be 2 in x and y-direction when center is not 'none'. 'c_cell'
+should be used for the grid used in MOM4.
+                                                                              
+ at end table
+
+ at node gs_make_coupler_mosaic, gs_make_topog, gs_make_vgrid, GRIDSPEC
+ at section Generate Three Exchange Grids for FMS Coupler
+
+make_coupler_mosaic generates three exchange grids for the FMS
+coupler. The output file includes exchange grid files for fluxes between
+atmosphere and surface (sea ice and land), exchange grid files for
+runoff between land and sea ice. There might be more than one exchange
+grid files between two model solo mosaic because there might be multiple
+tiles in a solo mosaic. All the exchange grid information are between
+model grid, not between supergrid. We assume the refinement ratio
+between model grid and supergrid is 2. Currently we only output the
+exchange grid on T-cell.  Besides generate the exchange grid files,
+make_coupler_mosaic also generate the coupler mosaic file (the file name
+will be mosaic_name.nc) which contains the atmos, land and ocean mosaic
+path, ocean mosaic topog path and exchange grid file path.
+make_coupler_mosaic expects NetCDF format input.
+
+ at example
+int 
+gs_make_coupler_mosaic(char *history, char *amosaic, char *lmosaic, 
+		       char *omosaic, char *otopog, int interp_order, 
+		       double sea_level, char *mosaic_name, int check)
+ at end example
+
+ at table @code
+                                                                              
+ at item atmos_mosaic 
+specify the atmosphere mosaic information. This file contains list of
+tile files which specify the grid information for each tile. Each grid
+is required to be regular lon/lat grid. The file name can not be
+'mosaic.nc'
+
+ at item ocean_mosaic 
+specify the ocean mosaic information. This file contains list of tile
+files which specify the grid information for each tile. The file name
+can not be 'mosaic.nc'
+
+ at item ocean_topog 
+specify the topography information for ocean mosaic.  The field name of
+the topography is depth_tile# or depth when ntiles = 1, The topography
+data is positive down.
+
+ at item land_mosaic 
+specify the land mosaic information. This file contains list of tile
+files which specify the grid information for each tile. Each grid is
+required to be regular lon/lat grid. When land_mosaic is not specified,
+atmosphere mosaic will be used to specify land mosaic.  The file name
+can not be 'mosaic.nc'.
+
+ at item interp_order 
+specify the order of conservative interplation. Its value can be 1 (
+linear order ) or 2 ( second order ) with default value 2.
+                                                                                            
+ at item sea_level # 
+specify the sea level ( in meters ) and its value will be used to determine
+land/sea mask. When topography of a grid cell is less than sea level,
+this grid cell will be land, otherwise it will be ocean. Default value
+is 0
+
+ at item mosaic_name 
+coupler mosaic name. The output coupler mosaic file will be
+mosaic_name.nc. default value is 'mosaic'.
+
+ at item check 
+check the tiling error.
+                                                                              
+ at end table
+
+ at node gs_make_topog,  , gs_make_coupler_mosaic, GRIDSPEC
+ at section Generate Topography for Any Mosaic
+
+make_topog can generate topography for any Mosaic. The output file will
+contains the topography for each tile in the Mosaic. The field name in
+the output topography file will be depth_tile# and it is positive down.
+The topography data will be defined on model grid, the model grid size
+will be supergrid grid size divided by refinement (x_refine, y_refine,
+default is 2).  mosaic is a required option and all other options are
+optional, but some options are required depending on the choice of
+topog_type.  
+
+ at example
+int 
+gs_make_topog(char *history, char *mosaic_file, char *topog_type, 
+              int x_refine, int y_refine, 
+              double basin_depth, char *topog_file, double bottom_depth, 
+              double min_depth, double scale_factor, int num_filter_pass, 
+              double gauss_amp, double gauss_scale, double slope_x,
+              double slope_y, double bowl_south, double bowl_north, 
+              double bowl_west, double bowl_east, int fill_first_row, 
+              int filter_topog, int round_shallow, int fill_shallow, 
+              int deepen_shallow, int smooth_topo_allow_deepening, 
+              char *output_file)
+ at end example
+                                                                              
+ at table @code
+ at item mosaic 
+Specify the mosaic file where topography data located.
+                                                                                     
+ at item topog_type 
+Specify type of topography. Its value can be 'realistic',
+'rectangular_basin', 'gaussian', 'bowl' or 'idealized'. The default
+value is 'realistic'.
+                                                                                     
+ at item x_refine # 
+the refinement ratio of model grid vs supergrid ins x-directin. default
+value 2.
+                                                                                     
+ at item y_refine # 
+the refinement ratio of model grid vs supergrid ins y-directin. default
+value 2.
+                                                                                     
+ at item basin_depth # 
+the basin depth when topog_type is 'rectangular_basin'. Default value is
+5000 meter.
+                                                                                     
+ at item topog_file 
+Specify name of topograhy file (e.g. scripps, navy_topo, ...)
+                                                                                     
+ at item topog_field 
+Specify name of topography field name in topog_file.
+                                                                                     
+ at item bottom_depth # 
+maximum depth (or bottom depth) of ocean.  default value is 5000 meter.
+                                                                                     
+ at item min_depth # 
+minimum depth of ocean.  default value is 10 meter.
+                                                                                       
+ at item scale_factor # 
+scaling factor for topography data (e.g. -1 to flip sign or 0.01 to
+convert from centimeters).  default value is 1.
+                                                                                     
+ at item num_filter_pass # 
+number of passes of spatial filter default value is 1.
+                                                                                     
+ at item gauss_amp # 
+height of gaussian bump as percentage of ocean depth. default value is
+0.5.
+                                                                                     
+ at item gauss_scale # 
+width of gaussian bump as percentag e of basin width. Default value is
+0.25.
+                                                                                     
+ at item slope_x # 
+rise of the ocean floor to the east for the gaussian bump. Default value
+is 0.
+                                                                                     
+ at item slope_y # 
+rise of the ocean floor to the north for the gaussian bump. Default
+value is 0.
+                                                                                     
+ at item bowl_south # 
+southern boundary of Winton bowl.  Default value is 60.
+                                                                                     
+ at item bowl_north # 
+northern boundary of Winton bowl.  Default value is 70.
+                                                                                     
+ at item bowl_west # 
+western boundary of Winton bowl.  Default value is 0.
+                                                                                       
+ at item bowl_east # 
+eastern boundary of Winton bowl.  Default value is 20.
+                                                                                     
+ at item fill_first_row 
+when true, make first row of ocean model all land points for ice model.
+                                                                                     
+ at item filter_topog 
+when true, apply filter to topography.
+                                                                                     
+ at item round_shallow 
+when true, Make cells land if depth is less than 1/2 mimumim depth,
+otherwise make ocean.
+                                                                                     
+ at item fill_shallow 
+when specified, Make cells less than minimum depth land.
+                                                                                     
+ at item deepen_shallow 
+when specified, Make cells less than minimum depth equal to minimum depth.
+                                                                                     
+ at item smooth_topo_allow_deepening 
+when specified, allow filter to deepen cells.
+                                                                                     
+ at item output 
+The created netcdf file that contains mosaic topography. Default value
+is 'topog.nc'
+                                                                              
+ at end table
+
+ at node Combined Index,  , GRIDSPEC, Top
 @unnumbered Index
 
 @printindex cp
diff --git a/doc/mdate-sh b/doc/mdate-sh
index cd916c0..e631b22 100755
--- a/doc/mdate-sh
+++ b/doc/mdate-sh
@@ -1,10 +1,10 @@
 #!/bin/sh
 # Get modification time of a file or directory and pretty-print it.
 
-scriptversion=2005-06-29.22
+scriptversion=2009-04-28.21; # UTC
 
-# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software
-# Foundation, Inc.
+# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005, 2007, 2009 Free
+# Software Foundation, Inc.
 # written by Ulrich Drepper <drepper at gnu.ai.mit.edu>, June 1995
 #
 # This program is free software; you can redistribute it and/or modify
@@ -18,8 +18,7 @@ scriptversion=2005-06-29.22
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -75,6 +74,10 @@ if ls -L /dev/null 1>/dev/null 2>&1; then
 else
   ls_command='ls -l -d'
 fi
+# Avoid user/group names that might have spaces, when possible.
+if ls -n /dev/null 1>/dev/null 2>&1; then
+  ls_command="$ls_command -n"
+fi
 
 # A `ls -l' line looks as follows on OS/2.
 #  drwxrwx---        0 Aug 11  2001 foo
@@ -89,7 +92,7 @@ fi
 # words should be skipped to get the date.
 
 # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
-set x`ls -l -d /`
+set x`$ls_command /`
 
 # Find which argument is the month.
 month=
@@ -197,5 +200,6 @@ echo $day $month $year
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/doc/stamp-vti b/doc/stamp-vti
index 5da139a..a391247 100644
--- a/doc/stamp-vti
+++ b/doc/stamp-vti
@@ -1,4 +1,4 @@
- at set UPDATED 2 May 2007
- at set UPDATED-MONTH May 2007
- at set EDITION 1.0-alpha4
- at set VERSION 1.0-alpha4
+ at set UPDATED 15 September 2009
+ at set UPDATED-MONTH September 2009
+ at set EDITION 1.0-alpha5
+ at set VERSION 1.0-alpha5
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
index ff2c406..0d3ba16 100644
--- a/doc/texinfo.tex
+++ b/doc/texinfo.tex
@@ -3,16 +3,16 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2005-07-05.19}
+\def\texinfoversion{2009-05-16.16}
 %
-% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
-% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software
-% Foundation, Inc.
+% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
+% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+% 2007, 2008, 2009 Free Software Foundation, Inc.
 %
-% This texinfo.tex file is free software; you can redistribute it and/or
+% This texinfo.tex file is free software: you can redistribute it and/or
 % modify it under the terms of the GNU General Public License as
-% published by the Free Software Foundation; either version 2, or (at
-% your option) any later version.
+% published by the Free Software Foundation, either version 3 of the
+% License, or (at your option) any later version.
 %
 % This texinfo.tex file is distributed in the hope that it will be
 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
@@ -20,9 +20,7 @@
 % General Public License for more details.
 %
 % You should have received a copy of the GNU General Public License
-% along with this texinfo.tex file; see the file COPYING.  If not, write
-% to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-% Boston, MA 02110-1301, USA.
+% along with this program.  If not, see <http://www.gnu.org/licenses/>.
 %
 % As a special exception, when this file is read by TeX when processing
 % a Texinfo source document, you may use the result without
@@ -67,7 +65,7 @@
 \everyjob{\message{[Texinfo version \texinfoversion]}%
   \catcode`+=\active \catcode`\_=\active}
 
-\message{Basics,}
+
 \chardef\other=12
 
 % We never want plain's \outer definition of \+ in Texinfo.
@@ -99,6 +97,10 @@
 \let\ptexslash=\/
 \let\ptexstar=\*
 \let\ptext=\t
+\let\ptextop=\top
+{\catcode`\'=\active
+\global\let\ptexquoteright'}% Math-mode def from plain.tex.
+\let\ptexraggedright=\raggedright
 
 % If this character appears in an error message or help string, it
 % starts a new line in the output.
@@ -153,28 +155,22 @@
 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
 
-% In some macros, we cannot use the `\? notation---the left quote is
-% in some cases the escape char.
-\chardef\backChar  = `\\
+% Since the category of space is not known, we have to be careful.
+\chardef\spacecat = 10
+\def\spaceisspace{\catcode`\ =\spacecat}
+
+% sometimes characters are active, so we need control sequences.
 \chardef\colonChar = `\:
 \chardef\commaChar = `\,
+\chardef\dashChar  = `\-
 \chardef\dotChar   = `\.
 \chardef\exclamChar= `\!
-\chardef\plusChar  = `\+
+\chardef\lquoteChar= `\`
 \chardef\questChar = `\?
+\chardef\rquoteChar= `\'
 \chardef\semiChar  = `\;
 \chardef\underChar = `\_
 
-\chardef\spaceChar = `\ %
-\chardef\spacecat = 10
-\def\spaceisspace{\catcode\spaceChar=\spacecat}
-
-{% for help with debugging.
- % example usage: \expandafter\show\activebackslash
- \catcode`\! = 0 \catcode`\\ = \active
- !global!def!activebackslash{\}
-}
-
 % Ignore a token.
 %
 \def\gobble#1{}
@@ -285,6 +281,50 @@
 \newdimen\cornerthick \cornerthick=.3pt
 \newdimen\topandbottommargin \topandbottommargin=.75in
 
+% Output a mark which sets \thischapter, \thissection and \thiscolor.
+% We dump everything together because we only have one kind of mark.
+% This works because we only use \botmark / \topmark, not \firstmark.
+%
+% A mark contains a subexpression of the \ifcase ... \fi construct.
+% \get*marks macros below extract the needed part using \ifcase.
+%
+% Another complication is to let the user choose whether \thischapter
+% (\thissection) refers to the chapter (section) in effect at the top
+% of a page, or that at the bottom of a page.  The solution is
+% described on page 260 of The TeXbook.  It involves outputting two
+% marks for the sectioning macros, one before the section break, and
+% one after.  I won't pretend I can describe this better than DEK...
+\def\domark{%
+  \toks0=\expandafter{\lastchapterdefs}%
+  \toks2=\expandafter{\lastsectiondefs}%
+  \toks4=\expandafter{\prevchapterdefs}%
+  \toks6=\expandafter{\prevsectiondefs}%
+  \toks8=\expandafter{\lastcolordefs}%
+  \mark{%
+                   \the\toks0 \the\toks2
+      \noexpand\or \the\toks4 \the\toks6
+    \noexpand\else \the\toks8
+  }%
+}
+% \topmark doesn't work for the very first chapter (after the title
+% page or the contents), so we use \firstmark there -- this gets us
+% the mark with the chapter defs, unless the user sneaks in, e.g.,
+% @setcolor (or @url, or @link, etc.) between @contents and the very
+% first @chapter.
+\def\gettopheadingmarks{%
+  \ifcase0\topmark\fi
+  \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
+}
+\def\getbottomheadingmarks{\ifcase1\botmark\fi}
+\def\getcolormarks{\ifcase2\topmark\fi}
+
+% Avoid "undefined control sequence" errors.
+\def\lastchapterdefs{}
+\def\lastsectiondefs{}
+\def\prevchapterdefs{}
+\def\prevsectiondefs{}
+\def\lastcolordefs{}
+
 % Main output routine.
 \chardef\PAGE = 255
 \output = {\onepageout{\pagecontents\PAGE}}
@@ -302,7 +342,9 @@
   %
   % Do this outside of the \shipout so @code etc. will be expanded in
   % the headline as they should be, not taken literally (outputting ''code).
+  \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
   \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
+  \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
   \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
   %
   {%
@@ -311,6 +353,13 @@
     % before the \shipout runs.
     %
     \indexdummies         % don't expand commands in the output.
+    \normalturnoffactive  % \ in index entries must not stay \, e.g., if
+               % the page break happens to be in the middle of an example.
+               % We don't want .vr (or whatever) entries like this:
+               % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
+               % "\acronym" won't work when it's read back in;
+               % it needs to be
+               % {\code {{\tt \backslashcurfont }acronym}
     \shipout\vbox{%
       % Do this early so pdf references go to the beginning of the page.
       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
@@ -338,9 +387,9 @@
       \pagebody{#1}%
       \ifdim\ht\footlinebox > 0pt
         % Only leave this space if the footline is nonempty.
-        % (We lessened \vsize for it in \oddfootingxxx.)
+        % (We lessened \vsize for it in \oddfootingyyy.)
         % The \baselineskip=24pt in plain's \makefootline has no effect.
-        \vskip 2\baselineskip
+        \vskip 24pt
         \unvbox\footlinebox
       \fi
       %
@@ -374,7 +423,7 @@
 % marginal hacks, juha at viisa.uucp (Juha Takala)
 \ifvoid\margin\else % marginal info is present
   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
-\dimen@=\dp#1 \unvbox#1
+\dimen@=\dp#1\relax \unvbox#1\relax
 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
 \ifr at ggedbottom \kern-\dimen@ \vfil \fi}
 }
@@ -396,7 +445,7 @@
 %
 \def\parsearg{\parseargusing{}}
 \def\parseargusing#1#2{%
-  \def\next{#2}%
+  \def\argtorun{#2}%
   \begingroup
     \obeylines
     \spaceisspace
@@ -415,7 +464,7 @@
 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
 \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
 
-% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
+% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
 %
 % \argremovec might leave us with trailing space, e.g.,
 %    @end itemize  @c foo
@@ -427,8 +476,7 @@
 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
   \def\temp{#3}%
   \ifx\temp\empty
-    % We cannot use \next here, as it holds the macro to run;
-    % thus we reuse \temp.
+    % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
     \let\temp\finishparsearg
   \else
     \let\temp\argcheckspaces
@@ -440,14 +488,14 @@
 % If a _delimited_ argument is enclosed in braces, they get stripped; so
 % to get _exactly_ the rest of the line, we had to prevent such situation.
 % We prepended an \empty token at the very beginning and we expand it now,
-% just before passing the control to \next.
-% (Similarily, we have to think about #3 of \argcheckspacesY above: it is
+% just before passing the control to \argtorun.
+% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
 % either the null string, or it ends with \^^M---thus there is no danger
 % that a pair of braces would be stripped.
 %
 % But first, we have to remove the trailing space token.
 %
-\def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}}
+\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
 
 % \parseargdef\foo{...}
 %	is roughly equivalent to
@@ -498,12 +546,12 @@
 % used to check whether the current environment is the one expected.
 %
 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
-% are not treated as enviroments; they don't open a group.  (The
+% are not treated as environments; they don't open a group.  (The
 % implementation of @end takes care not to call \endgroup in this
 % special case.)
 
 
-% At runtime, environments start with this:
+% At run-time, environments start with this:
 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
 % initialize
 \let\thisenv\empty
@@ -521,7 +569,7 @@
   \fi
 }
 
-% Evironment mismatch, #1 expected:
+% Environment mismatch, #1 expected:
 \def\badenverr{%
   \errhelp = \EMsimple
   \errmessage{This command can appear only \inenvironment\temp,
@@ -605,8 +653,8 @@
 \def\jmacro{j}
 \def\dotless#1{%
   \def\temp{#1}%
-  \ifx\temp\imacro \ptexi
-  \else\ifx\temp\jmacro \j
+  \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
+  \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
   \else \errmessage{@dotless can be used only with i or j}%
   \fi\fi
 }
@@ -661,7 +709,7 @@
 \def\?{?\spacefactor=\endofsentencespacefactor\space}
 
 % @frenchspacing on|off  says whether to put extra space after punctuation.
-% 
+%
 \def\onword{on}
 \def\offword{off}
 %
@@ -872,15 +920,20 @@ where each line of input produces a line of output.}
   \temp
 }
 
-% @include file    insert text of that file as input.
+% @include FILE -- \input text of FILE.
 %
 \def\include{\parseargusing\filenamecatcodes\includezzz}
 \def\includezzz#1{%
   \pushthisfilestack
   \def\thisfile{#1}%
   {%
-    \makevalueexpandable
-    \def\temp{\input #1 }%
+    \makevalueexpandable  % we want to expand any @value in FILE.
+    \turnoffactive        % and allow special characters in the expansion
+    \indexnofonts         % Allow `@@' and other weird things in file names.
+    \edef\temp{\noexpand\input #1 }%
+    %
+    % This trickery is to read FILE outside of a group, in case it makes
+    % definitions, etc.
     \expandafter
   }\temp
   \popthisfilestack
@@ -895,6 +948,8 @@ where each line of input produces a line of output.}
   \catcode`>=\other
   \catcode`+=\other
   \catcode`-=\other
+  \catcode`\`=\other
+  \catcode`\'=\other
 }
 
 \def\pushthisfilestack{%
@@ -1051,9 +1106,9 @@ where each line of input produces a line of output.}
 % _ active, and distinguish by seeing if the current family is \slfam,
 % which is what @var uses.
 {
-  \catcode\underChar = \active
+  \catcode`\_ = \active
   \gdef\mathunderscore{%
-    \catcode\underChar=\active
+    \catcode`\_=\active
     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
   }
 }
@@ -1070,6 +1125,16 @@ where each line of input produces a line of output.}
   \mathunderscore
   \let\\ = \mathbackslash
   \mathactive
+  % make the texinfo accent commands work in math mode
+  \let\"=\ddot
+  \let\'=\acute
+  \let\==\bar
+  \let\^=\hat
+  \let\`=\grave
+  \let\u=\breve
+  \let\v=\check
+  \let\~=\tilde
+  \let\dotaccent=\dot
   $\finishmath
 }
 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
@@ -1083,28 +1148,41 @@ where each line of input produces a line of output.}
   \catcode`< = \active
   \catcode`> = \active
   \catcode`+ = \active
+  \catcode`' = \active
   \gdef\mathactive{%
     \let^ = \ptexhat
     \let< = \ptexless
     \let> = \ptexgtr
     \let+ = \ptexplus
+    \let' = \ptexquoteright
   }
 }
 
-% @bullet and @minus need the same treatment as @math, just above.
+% Some math mode symbols.
 \def\bullet{$\ptexbullet$}
-\def\minus{$-$}
+\def\geq{\ifmmode \ge\else $\ge$\fi}
+\def\leq{\ifmmode \le\else $\le$\fi}
+\def\minus{\ifmmode -\else $-$\fi}
 
 % @dots{} outputs an ellipsis using the current font.
-% We do .5em per period so that it has the same spacing in a typewriter
-% font as three actual period characters.
+% We do .5em per period so that it has the same spacing in the cm
+% typewriter fonts as three actual period characters; on the other hand,
+% in other typewriter fonts three periods are wider than 1.5em.  So do
+% whichever is larger.
 %
 \def\dots{%
   \leavevmode
-  \hbox to 1.5em{%
-    \hskip 0pt plus 0.25fil
-    .\hfil.\hfil.%
-    \hskip 0pt plus 0.5fil
+  \setbox0=\hbox{...}% get width of three periods
+  \ifdim\wd0 > 1.5em
+    \dimen0 = \wd0
+  \else
+    \dimen0 = 1.5em
+  \fi
+  \hbox to \dimen0{%
+    \hskip 0pt plus.25fil
+    .\hskip 0pt plus1fil
+    .\hskip 0pt plus1fil
+    .\hskip 0pt plus.5fil
   }%
 }
 
@@ -1197,33 +1275,33 @@ where each line of input produces a line of output.}
   \fi
 \fi
 
-% PDF uses PostScript string constants for the names of xref targets, to
+% PDF uses PostScript string constants for the names of xref targets,
 % for display in the outlines, and in other places.  Thus, we have to
 % double any backslashes.  Otherwise, a name like "\node" will be
 % interpreted as a newline (\n), followed by o, d, e.  Not good.
 % http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html
 % (and related messages, the final outcome is that it is up to the TeX
 % user to double the backslashes and otherwise make the string valid, so
-% that's we do).
+% that's what we do).
 
 % double active backslashes.
-% 
+%
 {\catcode`\@=0 \catcode`\\=\active
- @gdef at activebackslash{@catcode`@\=@active @otherbackslash}
  @gdef at activebackslashdouble{%
-   @catcode at backChar=@active
+   @catcode`@\=@active
    @let\=@doublebackslash}
 }
 
 % To handle parens, we must adopt a different approach, since parens are
 % not active characters.  hyperref.dtx (which has the same problem as
-% us) handles it with this amazing macro to replace tokens.  I've
-% tinkered with it a little for texinfo, but it's definitely from there.
-% 
+% us) handles it with this amazing macro to replace tokens, with minor
+% changes for Texinfo.  It is included here under the GPL by permission
+% from the author, Heiko Oberdiek.
+%
 % #1 is the tokens to replace.
 % #2 is the replacement.
 % #3 is the control sequence with the string.
-% 
+%
 \def\HyPsdSubst#1#2#3{%
   \def\HyPsdReplace##1#1##2\END{%
     ##1%
@@ -1243,53 +1321,132 @@ where each line of input produces a line of output.}
 \def\backslashparens#1{%
   \xdef#1{#1}% redefine it as its expansion; the definition is simply
              % \lastnode when called from \setref -> \pdfmkdest.
-  \HyPsdSubst{(}{\backslashlparen}{#1}%
-  \HyPsdSubst{)}{\backslashrparen}{#1}%
+  \HyPsdSubst{(}{\realbackslash(}{#1}%
+  \HyPsdSubst{)}{\realbackslash)}{#1}%
 }
 
-{\catcode\exclamChar = 0 \catcode\backChar = \other
- !gdef!backslashlparen{\(}%
- !gdef!backslashrparen{\)}%
-}
+\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
+with PDF output, and none of those formats could be found.  (.eps cannot
+be supported due to the design of the PDF format; use regular TeX (DVI
+output) for that.)}
 
 \ifpdf
-  \input pdfcolor
-  \pdfcatalog{/PageMode /UseOutlines}%
+  %
+  % Color manipulation macros based on pdfcolor.tex.
+  \def\cmykDarkRed{0.28 1 1 0.35}
+  \def\cmykBlack{0 0 0 1}
+  %
+  % k sets the color for filling (usual text, etc.);
+  % K sets the color for stroking (thin rules, e.g., normal _'s).
+  \def\pdfsetcolor#1{\pdfliteral{#1 k  #1 K}}
+  %
+  % Set color, and create a mark which defines \thiscolor accordingly,
+  % so that \makeheadline knows which color to restore.
+  \def\setcolor#1{%
+    \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
+    \domark
+    \pdfsetcolor{#1}%
+  }
+  %
+  \def\maincolor{\cmykBlack}
+  \pdfsetcolor{\maincolor}
+  \edef\thiscolor{\maincolor}
+  \def\lastcolordefs{}
+  %
+  \def\makefootline{%
+    \baselineskip24pt
+    \line{\pdfsetcolor{\maincolor}\the\footline}%
+  }
+  %
+  \def\makeheadline{%
+    \vbox to 0pt{%
+      \vskip-22.5pt
+      \line{%
+        \vbox to8.5pt{}%
+        % Extract \thiscolor definition from the marks.
+        \getcolormarks
+        % Typeset the headline with \maincolor, then restore the color.
+        \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
+      }%
+      \vss
+    }%
+    \nointerlineskip
+  }
+  %
+  %
+  \pdfcatalog{/PageMode /UseOutlines}
+  %
+  % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
   \def\dopdfimage#1#2#3{%
-    \def\imagewidth{#2}%
-    \def\imageheight{#3}%
-    % without \immediate, pdftex seg faults when the same image is
+    \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
+    \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
+    %
+    % pdftex (and the PDF format) support .png, .jpg, .pdf (among
+    % others).  Let's try in that order.
+    \let\pdfimgext=\empty
+    \begingroup
+      \openin 1 #1.png \ifeof 1
+        \openin 1 #1.jpg \ifeof 1
+          \openin 1 #1.jpeg \ifeof 1
+            \openin 1 #1.JPG \ifeof 1
+              \openin 1 #1.pdf \ifeof 1
+                \openin 1 #1.PDF \ifeof 1
+                  \errhelp = \nopdfimagehelp
+                  \errmessage{Could not find image file #1 for pdf}%
+                \else \gdef\pdfimgext{PDF}%
+                \fi
+              \else \gdef\pdfimgext{pdf}%
+              \fi
+            \else \gdef\pdfimgext{JPG}%
+            \fi
+          \else \gdef\pdfimgext{jpeg}%
+          \fi
+        \else \gdef\pdfimgext{jpg}%
+        \fi
+      \else \gdef\pdfimgext{png}%
+      \fi
+      \closein 1
+    \endgroup
+    %
+    % without \immediate, ancient pdftex seg faults when the same image is
     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
     \ifnum\pdftexversion < 14
       \immediate\pdfimage
     \else
       \immediate\pdfximage
     \fi
-      \ifx\empty\imagewidth\else width \imagewidth \fi
-      \ifx\empty\imageheight\else height \imageheight \fi
+      \ifdim \wd0 >0pt width \imagewidth \fi
+      \ifdim \wd2 >0pt height \imageheight \fi
       \ifnum\pdftexversion<13
-         #1.pdf%
+         #1.\pdfimgext
        \else
-         {#1.pdf}%
+         {#1.\pdfimgext}%
        \fi
     \ifnum\pdftexversion < 14 \else
       \pdfrefximage \pdflastximage
     \fi}
+  %
   \def\pdfmkdest#1{{%
     % We have to set dummies so commands such as @code, and characters
     % such as \, aren't expanded when present in a section title.
-    \atdummies
+    \indexnofonts
+    \turnoffactive
     \activebackslashdouble
+    \makevalueexpandable
     \def\pdfdestname{#1}%
     \backslashparens\pdfdestname
-    \pdfdest name{\pdfdestname} xyz%
-  }}%
+    \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
+  }}
   %
   % used to mark target names; must be expandable.
-  \def\pdfmkpgn#1{#1}%
+  \def\pdfmkpgn#1{#1}
+  %
+  % by default, use a color that is dark enough to print on paper as
+  % nearly black, but still distinguishable for online viewing.
+  \def\urlcolor{\cmykDarkRed}
+  \def\linkcolor{\cmykDarkRed}
+  \def\endlink{\setcolor{\maincolor}\pdfendlink}
   %
-  \let\linkcolor = \Blue  % was Cyan, but that seems light?
-  \def\endlink{\Black\pdfendlink}
   % Adding outlines to PDF; macros for calculating structure of outlines
   % come from Petr Olsak
   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
@@ -1390,8 +1547,8 @@ where each line of input produces a line of output.}
       % now, I guess we'll just let the pdf reader have its way.
       \indexnofonts
       \setupdatafile
-      \activebackslash
-      \input \jobname.toc
+      \catcode`\\=\active \otherbackslash
+      \input \tocreadfilename
     \endgroup
   }
   %
@@ -1409,11 +1566,23 @@ where each line of input produces a line of output.}
   \else
     \let \startlink \pdfstartlink
   \fi
+  % make a live url in pdf output.
   \def\pdfurl#1{%
     \begingroup
-      \normalturnoffactive\def\@{@}%
+      % it seems we really need yet another set of dummies; have not
+      % tried to figure out what each command should do in the context
+      % of @url.  for now, just make @/ a no-op, that's the only one
+      % people have actually reported a problem with.
+      %
+      \normalturnoffactive
+      \def\@{@}%
+      \let\/=\empty
       \makevalueexpandable
-      \leavevmode\Red
+      % do we want to go so far as to use \indexnofonts instead of just
+      % special-casing \var here?
+      \def\var##1{##1}%
+      %
+      \leavevmode\setcolor{\urlcolor}%
       \startlink attr{/Border [0 0 0]}%
         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
     \endgroup}
@@ -1440,13 +1609,15 @@ where each line of input produces a line of output.}
     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
   \def\pdflink#1{%
     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
-    \linkcolor #1\endlink}
+    \setcolor{\linkcolor}#1\endlink}
   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
 \else
+  % non-pdf mode
   \let\pdfmkdest = \gobble
   \let\pdfurl = \gobble
   \let\endlink = \relax
-  \let\linkcolor = \relax
+  \let\setcolor = \gobble
+  \let\pdfsetcolor = \gobble
   \let\pdfmakeoutlines = \relax
 \fi  % \ifx\pdfoutput
 
@@ -1472,6 +1643,10 @@ where each line of input produces a line of output.}
 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
 \def\tt{\fam=\ttfam \setfontstyle{tt}}
 
+% Unfortunately, we have to override this for titles and the like, since
+% in those cases "rm" is bold.  Sigh.
+\def\rmisbold{\rm\def\curfontstyle{bf}}
+
 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
 % So we set up a \sf.
 \newfam\sffam
@@ -1481,6 +1656,7 @@ where each line of input produces a line of output.}
 % We don't need math for this font style.
 \def\ttsl{\setfontstyle{ttsl}}
 
+
 % Default leading.
 \newdimen\textleading  \textleading = 13.2pt
 
@@ -1492,8 +1668,12 @@ where each line of input produces a line of output.}
 \def\strutheightpercent{.70833}
 \def\strutdepthpercent {.29167}
 %
+% can get a sort of poor man's double spacing by redefining this.
+\def\baselinefactor{1}
+%
 \def\setleading#1{%
-  \normalbaselineskip = #1\relax
+  \dimen0 = #1\relax
+  \normalbaselineskip = \baselinefactor\dimen0
   \normallineskip = \lineskipfactor\normalbaselineskip
   \normalbaselines
   \setbox\strutbox =\hbox{%
@@ -1502,10 +1682,279 @@ where each line of input produces a line of output.}
   }%
 }
 
+% PDF CMaps.  See also LaTeX's t1.cmap.
+%
+% do nothing with this by default.
+\expandafter\let\csname cmapOT1\endcsname\gobble
+\expandafter\let\csname cmapOT1IT\endcsname\gobble
+\expandafter\let\csname cmapOT1TT\endcsname\gobble
+
+% if we are producing pdf, and we have \pdffontattr, then define cmaps.
+% (\pdffontattr was introduced many years ago, but people still run
+% older pdftex's; it's easy to conditionalize, so we do.)
+\ifpdf \ifx\pdffontattr\undefined \else
+  \begingroup
+    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
+    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
+%%DocumentNeededResources: ProcSet (CIDInit)
+%%IncludeResource: ProcSet (CIDInit)
+%%BeginResource: CMap (TeX-OT1-0)
+%%Title: (TeX-OT1-0 TeX OT1 0)
+%%Version: 1.000
+%%EndComments
+/CIDInit /ProcSet findresource begin
+12 dict begin
+begincmap
+/CIDSystemInfo
+<< /Registry (TeX)
+/Ordering (OT1)
+/Supplement 0
+>> def
+/CMapName /TeX-OT1-0 def
+/CMapType 2 def
+1 begincodespacerange
+<00> <7F>
+endcodespacerange
+8 beginbfrange
+<00> <01> <0393>
+<09> <0A> <03A8>
+<23> <26> <0023>
+<28> <3B> <0028>
+<3F> <5B> <003F>
+<5D> <5E> <005D>
+<61> <7A> <0061>
+<7B> <7C> <2013>
+endbfrange
+40 beginbfchar
+<02> <0398>
+<03> <039B>
+<04> <039E>
+<05> <03A0>
+<06> <03A3>
+<07> <03D2>
+<08> <03A6>
+<0B> <00660066>
+<0C> <00660069>
+<0D> <0066006C>
+<0E> <006600660069>
+<0F> <00660066006C>
+<10> <0131>
+<11> <0237>
+<12> <0060>
+<13> <00B4>
+<14> <02C7>
+<15> <02D8>
+<16> <00AF>
+<17> <02DA>
+<18> <00B8>
+<19> <00DF>
+<1A> <00E6>
+<1B> <0153>
+<1C> <00F8>
+<1D> <00C6>
+<1E> <0152>
+<1F> <00D8>
+<21> <0021>
+<22> <201D>
+<27> <2019>
+<3C> <00A1>
+<3D> <003D>
+<3E> <00BF>
+<5C> <201C>
+<5F> <02D9>
+<60> <2018>
+<7D> <02DD>
+<7E> <007E>
+<7F> <00A8>
+endbfchar
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+%%EndResource
+%%EOF
+    }\endgroup
+  \expandafter\edef\csname cmapOT1\endcsname#1{%
+    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
+  }%
+%
+% \cmapOT1IT
+  \begingroup
+    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
+    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
+%%DocumentNeededResources: ProcSet (CIDInit)
+%%IncludeResource: ProcSet (CIDInit)
+%%BeginResource: CMap (TeX-OT1IT-0)
+%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
+%%Version: 1.000
+%%EndComments
+/CIDInit /ProcSet findresource begin
+12 dict begin
+begincmap
+/CIDSystemInfo
+<< /Registry (TeX)
+/Ordering (OT1IT)
+/Supplement 0
+>> def
+/CMapName /TeX-OT1IT-0 def
+/CMapType 2 def
+1 begincodespacerange
+<00> <7F>
+endcodespacerange
+8 beginbfrange
+<00> <01> <0393>
+<09> <0A> <03A8>
+<25> <26> <0025>
+<28> <3B> <0028>
+<3F> <5B> <003F>
+<5D> <5E> <005D>
+<61> <7A> <0061>
+<7B> <7C> <2013>
+endbfrange
+42 beginbfchar
+<02> <0398>
+<03> <039B>
+<04> <039E>
+<05> <03A0>
+<06> <03A3>
+<07> <03D2>
+<08> <03A6>
+<0B> <00660066>
+<0C> <00660069>
+<0D> <0066006C>
+<0E> <006600660069>
+<0F> <00660066006C>
+<10> <0131>
+<11> <0237>
+<12> <0060>
+<13> <00B4>
+<14> <02C7>
+<15> <02D8>
+<16> <00AF>
+<17> <02DA>
+<18> <00B8>
+<19> <00DF>
+<1A> <00E6>
+<1B> <0153>
+<1C> <00F8>
+<1D> <00C6>
+<1E> <0152>
+<1F> <00D8>
+<21> <0021>
+<22> <201D>
+<23> <0023>
+<24> <00A3>
+<27> <2019>
+<3C> <00A1>
+<3D> <003D>
+<3E> <00BF>
+<5C> <201C>
+<5F> <02D9>
+<60> <2018>
+<7D> <02DD>
+<7E> <007E>
+<7F> <00A8>
+endbfchar
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+%%EndResource
+%%EOF
+    }\endgroup
+  \expandafter\edef\csname cmapOT1IT\endcsname#1{%
+    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
+  }%
+%
+% \cmapOT1TT
+  \begingroup
+    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
+    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
+%%DocumentNeededResources: ProcSet (CIDInit)
+%%IncludeResource: ProcSet (CIDInit)
+%%BeginResource: CMap (TeX-OT1TT-0)
+%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
+%%Version: 1.000
+%%EndComments
+/CIDInit /ProcSet findresource begin
+12 dict begin
+begincmap
+/CIDSystemInfo
+<< /Registry (TeX)
+/Ordering (OT1TT)
+/Supplement 0
+>> def
+/CMapName /TeX-OT1TT-0 def
+/CMapType 2 def
+1 begincodespacerange
+<00> <7F>
+endcodespacerange
+5 beginbfrange
+<00> <01> <0393>
+<09> <0A> <03A8>
+<21> <26> <0021>
+<28> <5F> <0028>
+<61> <7E> <0061>
+endbfrange
+32 beginbfchar
+<02> <0398>
+<03> <039B>
+<04> <039E>
+<05> <03A0>
+<06> <03A3>
+<07> <03D2>
+<08> <03A6>
+<0B> <2191>
+<0C> <2193>
+<0D> <0027>
+<0E> <00A1>
+<0F> <00BF>
+<10> <0131>
+<11> <0237>
+<12> <0060>
+<13> <00B4>
+<14> <02C7>
+<15> <02D8>
+<16> <00AF>
+<17> <02DA>
+<18> <00B8>
+<19> <00DF>
+<1A> <00E6>
+<1B> <0153>
+<1C> <00F8>
+<1D> <00C6>
+<1E> <0152>
+<1F> <00D8>
+<20> <2423>
+<27> <2019>
+<60> <2018>
+<7F> <00A8>
+endbfchar
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+%%EndResource
+%%EOF
+    }\endgroup
+  \expandafter\edef\csname cmapOT1TT\endcsname#1{%
+    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
+  }%
+\fi\fi
+
+
 % Set the font macro #1 to the font named #2, adding on the
 % specified font prefix (normally `cm').
-% #3 is the font's design size, #4 is a scale factor
-\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
+% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
+% encoding (currently only OT1, OT1IT and OT1TT are allowed, pass
+% empty to omit).
+\def\setfont#1#2#3#4#5{%
+  \font#1=\fontprefix#2#3 scaled #4
+  \csname cmap#5\endcsname#1%
+}
+% This is what gets called when #5 of \setfont is empty.
+\let\cmap\gobble
+% emacs-page end of cmaps
 
 % Use cm as the default font prefix.
 % To specify the font prefix, you must define \fontprefix
@@ -1530,118 +1979,293 @@ where each line of input produces a line of output.}
 \def\scshape{csc}
 \def\scbshape{csc}
 
+% Definitions for a main text size of 11pt.  This is the default in
+% Texinfo.
+%
+\def\definetextfontsizexi{%
 % Text fonts (11.2pt, magstep1).
 \def\textnominalsize{11pt}
 \edef\mainmagstep{\magstephalf}
-\setfont\textrm\rmshape{10}{\mainmagstep}
-\setfont\texttt\ttshape{10}{\mainmagstep}
-\setfont\textbf\bfshape{10}{\mainmagstep}
-\setfont\textit\itshape{10}{\mainmagstep}
-\setfont\textsl\slshape{10}{\mainmagstep}
-\setfont\textsf\sfshape{10}{\mainmagstep}
-\setfont\textsc\scshape{10}{\mainmagstep}
-\setfont\textttsl\ttslshape{10}{\mainmagstep}
+\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
+\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
+\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
+\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
+\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
+\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
+\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
+\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
 \font\texti=cmmi10 scaled \mainmagstep
 \font\textsy=cmsy10 scaled \mainmagstep
+\def\textecsize{1095}
 
 % A few fonts for @defun names and args.
-\setfont\defbf\bfshape{10}{\magstep1}
-\setfont\deftt\ttshape{10}{\magstep1}
-\setfont\defttsl\ttslshape{10}{\magstep1}
+\setfont\defbf\bfshape{10}{\magstep1}{OT1}
+\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
+\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
 
 % Fonts for indices, footnotes, small examples (9pt).
 \def\smallnominalsize{9pt}
-\setfont\smallrm\rmshape{9}{1000}
-\setfont\smalltt\ttshape{9}{1000}
-\setfont\smallbf\bfshape{10}{900}
-\setfont\smallit\itshape{9}{1000}
-\setfont\smallsl\slshape{9}{1000}
-\setfont\smallsf\sfshape{9}{1000}
-\setfont\smallsc\scshape{10}{900}
-\setfont\smallttsl\ttslshape{10}{900}
+\setfont\smallrm\rmshape{9}{1000}{OT1}
+\setfont\smalltt\ttshape{9}{1000}{OT1TT}
+\setfont\smallbf\bfshape{10}{900}{OT1}
+\setfont\smallit\itshape{9}{1000}{OT1IT}
+\setfont\smallsl\slshape{9}{1000}{OT1}
+\setfont\smallsf\sfshape{9}{1000}{OT1}
+\setfont\smallsc\scshape{10}{900}{OT1}
+\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
 \font\smalli=cmmi9
 \font\smallsy=cmsy9
+\def\smallecsize{0900}
 
 % Fonts for small examples (8pt).
 \def\smallernominalsize{8pt}
-\setfont\smallerrm\rmshape{8}{1000}
-\setfont\smallertt\ttshape{8}{1000}
-\setfont\smallerbf\bfshape{10}{800}
-\setfont\smallerit\itshape{8}{1000}
-\setfont\smallersl\slshape{8}{1000}
-\setfont\smallersf\sfshape{8}{1000}
-\setfont\smallersc\scshape{10}{800}
-\setfont\smallerttsl\ttslshape{10}{800}
+\setfont\smallerrm\rmshape{8}{1000}{OT1}
+\setfont\smallertt\ttshape{8}{1000}{OT1TT}
+\setfont\smallerbf\bfshape{10}{800}{OT1}
+\setfont\smallerit\itshape{8}{1000}{OT1IT}
+\setfont\smallersl\slshape{8}{1000}{OT1}
+\setfont\smallersf\sfshape{8}{1000}{OT1}
+\setfont\smallersc\scshape{10}{800}{OT1}
+\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
 \font\smalleri=cmmi8
 \font\smallersy=cmsy8
+\def\smallerecsize{0800}
 
 % Fonts for title page (20.4pt):
 \def\titlenominalsize{20pt}
-\setfont\titlerm\rmbshape{12}{\magstep3}
-\setfont\titleit\itbshape{10}{\magstep4}
-\setfont\titlesl\slbshape{10}{\magstep4}
-\setfont\titlett\ttbshape{12}{\magstep3}
-\setfont\titlettsl\ttslshape{10}{\magstep4}
-\setfont\titlesf\sfbshape{17}{\magstep1}
+\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
+\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
+\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
+\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
+\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
+\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
 \let\titlebf=\titlerm
-\setfont\titlesc\scbshape{10}{\magstep4}
+\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
 \font\titlei=cmmi12 scaled \magstep3
 \font\titlesy=cmsy10 scaled \magstep4
-\def\authorrm{\secrm}
-\def\authortt{\sectt}
+\def\titleecsize{2074}
 
 % Chapter (and unnumbered) fonts (17.28pt).
 \def\chapnominalsize{17pt}
-\setfont\chaprm\rmbshape{12}{\magstep2}
-\setfont\chapit\itbshape{10}{\magstep3}
-\setfont\chapsl\slbshape{10}{\magstep3}
-\setfont\chaptt\ttbshape{12}{\magstep2}
-\setfont\chapttsl\ttslshape{10}{\magstep3}
-\setfont\chapsf\sfbshape{17}{1000}
+\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
+\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
+\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
+\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
+\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
+\setfont\chapsf\sfbshape{17}{1000}{OT1}
 \let\chapbf=\chaprm
-\setfont\chapsc\scbshape{10}{\magstep3}
+\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
 \font\chapi=cmmi12 scaled \magstep2
 \font\chapsy=cmsy10 scaled \magstep3
+\def\chapecsize{1728}
 
 % Section fonts (14.4pt).
 \def\secnominalsize{14pt}
-\setfont\secrm\rmbshape{12}{\magstep1}
-\setfont\secit\itbshape{10}{\magstep2}
-\setfont\secsl\slbshape{10}{\magstep2}
-\setfont\sectt\ttbshape{12}{\magstep1}
-\setfont\secttsl\ttslshape{10}{\magstep2}
-\setfont\secsf\sfbshape{12}{\magstep1}
+\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
+\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
+\setfont\secsl\slbshape{10}{\magstep2}{OT1}
+\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
+\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
+\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
 \let\secbf\secrm
-\setfont\secsc\scbshape{10}{\magstep2}
+\setfont\secsc\scbshape{10}{\magstep2}{OT1}
 \font\seci=cmmi12 scaled \magstep1
 \font\secsy=cmsy10 scaled \magstep2
+\def\sececsize{1440}
 
 % Subsection fonts (13.15pt).
 \def\ssecnominalsize{13pt}
-\setfont\ssecrm\rmbshape{12}{\magstephalf}
-\setfont\ssecit\itbshape{10}{1315}
-\setfont\ssecsl\slbshape{10}{1315}
-\setfont\ssectt\ttbshape{12}{\magstephalf}
-\setfont\ssecttsl\ttslshape{10}{1315}
-\setfont\ssecsf\sfbshape{12}{\magstephalf}
+\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
+\setfont\ssecit\itbshape{10}{1315}{OT1IT}
+\setfont\ssecsl\slbshape{10}{1315}{OT1}
+\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
+\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
+\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
 \let\ssecbf\ssecrm
-\setfont\ssecsc\scbshape{10}{1315}
+\setfont\ssecsc\scbshape{10}{1315}{OT1}
 \font\sseci=cmmi12 scaled \magstephalf
 \font\ssecsy=cmsy10 scaled 1315
+\def\ssececsize{1200}
 
 % Reduced fonts for @acro in text (10pt).
 \def\reducednominalsize{10pt}
-\setfont\reducedrm\rmshape{10}{1000}
-\setfont\reducedtt\ttshape{10}{1000}
-\setfont\reducedbf\bfshape{10}{1000}
-\setfont\reducedit\itshape{10}{1000}
-\setfont\reducedsl\slshape{10}{1000}
-\setfont\reducedsf\sfshape{10}{1000}
-\setfont\reducedsc\scshape{10}{1000}
-\setfont\reducedttsl\ttslshape{10}{1000}
+\setfont\reducedrm\rmshape{10}{1000}{OT1}
+\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
+\setfont\reducedbf\bfshape{10}{1000}{OT1}
+\setfont\reducedit\itshape{10}{1000}{OT1IT}
+\setfont\reducedsl\slshape{10}{1000}{OT1}
+\setfont\reducedsf\sfshape{10}{1000}{OT1}
+\setfont\reducedsc\scshape{10}{1000}{OT1}
+\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
 \font\reducedi=cmmi10
 \font\reducedsy=cmsy10
+\def\reducedecsize{1000}
+
+% reset the current fonts
+\textfonts
+\rm
+} % end of 11pt text font size definitions
+
+
+% Definitions to make the main text be 10pt Computer Modern, with
+% section, chapter, etc., sizes following suit.  This is for the GNU
+% Press printing of the Emacs 22 manual.  Maybe other manuals in the
+% future.  Used with @smallbook, which sets the leading to 12pt.
+%
+\def\definetextfontsizex{%
+% Text fonts (10pt).
+\def\textnominalsize{10pt}
+\edef\mainmagstep{1000}
+\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
+\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
+\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
+\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
+\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
+\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
+\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
+\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
+\font\texti=cmmi10 scaled \mainmagstep
+\font\textsy=cmsy10 scaled \mainmagstep
+\def\textecsize{1000}
+
+% A few fonts for @defun names and args.
+\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
+\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
+\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
+\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
+
+% Fonts for indices, footnotes, small examples (9pt).
+\def\smallnominalsize{9pt}
+\setfont\smallrm\rmshape{9}{1000}{OT1}
+\setfont\smalltt\ttshape{9}{1000}{OT1TT}
+\setfont\smallbf\bfshape{10}{900}{OT1}
+\setfont\smallit\itshape{9}{1000}{OT1IT}
+\setfont\smallsl\slshape{9}{1000}{OT1}
+\setfont\smallsf\sfshape{9}{1000}{OT1}
+\setfont\smallsc\scshape{10}{900}{OT1}
+\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
+\font\smalli=cmmi9
+\font\smallsy=cmsy9
+\def\smallecsize{0900}
+
+% Fonts for small examples (8pt).
+\def\smallernominalsize{8pt}
+\setfont\smallerrm\rmshape{8}{1000}{OT1}
+\setfont\smallertt\ttshape{8}{1000}{OT1TT}
+\setfont\smallerbf\bfshape{10}{800}{OT1}
+\setfont\smallerit\itshape{8}{1000}{OT1IT}
+\setfont\smallersl\slshape{8}{1000}{OT1}
+\setfont\smallersf\sfshape{8}{1000}{OT1}
+\setfont\smallersc\scshape{10}{800}{OT1}
+\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
+\font\smalleri=cmmi8
+\font\smallersy=cmsy8
+\def\smallerecsize{0800}
+
+% Fonts for title page (20.4pt):
+\def\titlenominalsize{20pt}
+\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
+\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
+\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
+\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
+\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
+\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
+\let\titlebf=\titlerm
+\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
+\font\titlei=cmmi12 scaled \magstep3
+\font\titlesy=cmsy10 scaled \magstep4
+\def\titleecsize{2074}
+
+% Chapter fonts (14.4pt).
+\def\chapnominalsize{14pt}
+\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
+\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
+\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
+\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
+\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
+\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
+\let\chapbf\chaprm
+\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
+\font\chapi=cmmi12 scaled \magstep1
+\font\chapsy=cmsy10 scaled \magstep2
+\def\chapecsize{1440}
+
+% Section fonts (12pt).
+\def\secnominalsize{12pt}
+\setfont\secrm\rmbshape{12}{1000}{OT1}
+\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
+\setfont\secsl\slbshape{10}{\magstep1}{OT1}
+\setfont\sectt\ttbshape{12}{1000}{OT1TT}
+\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
+\setfont\secsf\sfbshape{12}{1000}{OT1}
+\let\secbf\secrm
+\setfont\secsc\scbshape{10}{\magstep1}{OT1}
+\font\seci=cmmi12
+\font\secsy=cmsy10 scaled \magstep1
+\def\sececsize{1200}
+
+% Subsection fonts (10pt).
+\def\ssecnominalsize{10pt}
+\setfont\ssecrm\rmbshape{10}{1000}{OT1}
+\setfont\ssecit\itbshape{10}{1000}{OT1IT}
+\setfont\ssecsl\slbshape{10}{1000}{OT1}
+\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
+\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
+\setfont\ssecsf\sfbshape{10}{1000}{OT1}
+\let\ssecbf\ssecrm
+\setfont\ssecsc\scbshape{10}{1000}{OT1}
+\font\sseci=cmmi10
+\font\ssecsy=cmsy10
+\def\ssececsize{1000}
+
+% Reduced fonts for @acro in text (9pt).
+\def\reducednominalsize{9pt}
+\setfont\reducedrm\rmshape{9}{1000}{OT1}
+\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
+\setfont\reducedbf\bfshape{10}{900}{OT1}
+\setfont\reducedit\itshape{9}{1000}{OT1IT}
+\setfont\reducedsl\slshape{9}{1000}{OT1}
+\setfont\reducedsf\sfshape{9}{1000}{OT1}
+\setfont\reducedsc\scshape{10}{900}{OT1}
+\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
+\font\reducedi=cmmi9
+\font\reducedsy=cmsy9
+\def\reducedecsize{0900}
+
+% reduce space between paragraphs
+\divide\parskip by 2
+
+% reset the current fonts
+\textfonts
+\rm
+} % end of 10pt text font size definitions
+
+
+% We provide the user-level command
+%   @fonttextsize 10
+% (or 11) to redefine the text font size.  pt is assumed.
+%
+\def\xword{10}
+\def\xiword{11}
+%
+\parseargdef\fonttextsize{%
+  \def\textsizearg{#1}%
+  \wlog{doing @fonttextsize \textsizearg}%
+  %
+  % Set \globaldefs so that documents can use this inside @tex, since
+  % makeinfo 4.8 does not support it, but we need it nonetheless.
+  %
+ \begingroup \globaldefs=1
+  \ifx\textsizearg\xword \definetextfontsizex
+  \else \ifx\textsizearg\xiword \definetextfontsizexi
+  \else
+    \errhelp=\EMsimple
+    \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
+  \fi\fi
+ \endgroup
+}
+
 
 % In order for the font changes to affect most math symbols and letters,
 % we have to define the \textfont of the standard families.  Since
@@ -1682,7 +2306,7 @@ where each line of input produces a line of output.}
   \def\curfontsize{title}%
   \def\lsize{chap}\def\lllsize{subsec}%
   \resetmathfonts \setleading{25pt}}
-\def\titlefont#1{{\titlefonts\rm #1}}
+\def\titlefont#1{{\titlefonts\rmisbold #1}}
 \def\chapfonts{%
   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
@@ -1733,6 +2357,16 @@ where each line of input produces a line of output.}
   \def\lsize{smaller}\def\lllsize{smaller}%
   \resetmathfonts \setleading{9.5pt}}
 
+% Fonts for short table of contents.
+\setfont\shortcontrm\rmshape{12}{1000}{OT1}
+\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
+\setfont\shortcontsl\slshape{12}{1000}{OT1}
+\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
+
+% Define these just so they can be easily changed for other fonts.
+\def\angleleft{$\langle$}
+\def\angleright{$\rangle$}
+
 % Set the fonts to use with the @small... environments.
 \let\smallexamplefonts = \smallfonts
 
@@ -1746,28 +2380,128 @@ where each line of input produces a line of output.}
 %
 % By the way, for comparison, here's what fits with @example (10pt):
 %   8.5x11=71  smallbook=60  a4=75  a5=58
-%
-% I wish the USA used A4 paper.
 % --karl, 24jan03.
 
-
 % Set up the default fonts, so we can use them for creating boxes.
 %
-\textfonts \rm
+\definetextfontsizexi
 
-% Define these so they can be easily changed for other fonts.
-\def\angleleft{$\langle$}
-\def\angleright{$\rangle$}
+
+\message{markup,}
+
+% Check if we are currently using a typewriter font.  Since all the
+% Computer Modern typewriter fonts have zero interword stretch (and
+% shrink), and it is reasonable to expect all typewriter fonts to have
+% this property, we can check that font parameter.
+%
+\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
+
+% Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
+% define and register \INITMACRO to be called on markup style changes.
+% \INITMACRO can check \currentmarkupstyle for the innermost
+% style and the set of \ifmarkupSTYLE switches for all styles
+% currently in effect.
+\newif\ifmarkupvar
+\newif\ifmarkupsamp
+\newif\ifmarkupkey
+%\newif\ifmarkupfile % @file == @samp.
+%\newif\ifmarkupoption % @option == @samp.
+\newif\ifmarkupcode
+\newif\ifmarkupkbd
+%\newif\ifmarkupenv % @env == @code.
+%\newif\ifmarkupcommand % @command == @code.
+\newif\ifmarkuptex % @tex (and part of @math, for now).
+\newif\ifmarkupexample
+\newif\ifmarkupverb
+\newif\ifmarkupverbatim
+
+\let\currentmarkupstyle\empty
+
+\def\setupmarkupstyle#1{%
+  \csname markup#1true\endcsname
+  \def\currentmarkupstyle{#1}%
+  \markupstylesetup
+}
+
+\let\markupstylesetup\empty
+
+\def\defmarkupstylesetup#1{%
+  \expandafter\def\expandafter\markupstylesetup
+    \expandafter{\markupstylesetup #1}%
+  \def#1%
+}
+
+% Markup style setup for left and right quotes.
+\defmarkupstylesetup\markupsetuplq{%
+  \expandafter\let\expandafter \temp \csname markupsetuplq\currentmarkupstyle\endcsname
+  \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
+}
+
+\defmarkupstylesetup\markupsetuprq{%
+  \expandafter\let\expandafter \temp \csname markupsetuprq\currentmarkupstyle\endcsname
+  \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
+}
+
+{
+\catcode`\'=\active
+\catcode`\`=\active
+
+\gdef\markupsetuplqdefault{\let`\lq}
+\gdef\markupsetuprqdefault{\let'\rq}
+
+\gdef\markupsetcodequoteleft{\let`\codequoteleft}
+\gdef\markupsetcodequoteright{\let'\codequoteright}
+
+\gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft}
+}
+
+\let\markupsetuplqcode \markupsetcodequoteleft
+\let\markupsetuprqcode \markupsetcodequoteright
+\let\markupsetuplqexample \markupsetcodequoteleft
+\let\markupsetuprqexample \markupsetcodequoteright
+\let\markupsetuplqverb \markupsetcodequoteleft
+\let\markupsetuprqverb \markupsetcodequoteright
+\let\markupsetuplqverbatim \markupsetcodequoteleft
+\let\markupsetuprqverbatim \markupsetcodequoteright
+
+\let\markupsetuplqsamp \markupsetnoligaturesquoteleft
+\let\markupsetuplqkbd \markupsetnoligaturesquoteleft
+
+% Allow an option to not replace quotes with a regular directed right
+% quote/apostrophe (char 0x27), but instead use the undirected quote
+% from cmtt (char 0x0d).  The undirected quote is ugly, so don't make it
+% the default, but it works for pasting with more pdf viewers (at least
+% evince), the lilypond developers report.  xpdf does work with the
+% regular 0x27.
+%
+\def\codequoteright{%
+  \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
+    \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
+      '%
+    \else \char'15 \fi
+  \else \char'15 \fi
+}
+%
+% and a similar option for the left quote char vs. a grave accent.
+% Modern fonts display ASCII 0x60 as a grave accent, so some people like
+% the code environments to do likewise.
+%
+\def\codequoteleft{%
+  \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
+    \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
+      % [Knuth] pp. 380,381,391
+      % \relax disables Spanish ligatures ?` and !` of \tt font.
+      \relax`%
+    \else \char'22 \fi
+  \else \char'22 \fi
+}
+
+% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
+\def\noligaturesquoteleft{\relax\lq}
 
 % Count depth in font-changes, for error checks
 \newcount\fontdepth \fontdepth=0
 
-% Fonts for short table of contents.
-\setfont\shortcontrm\rmshape{12}{1000}
-\setfont\shortcontbf\bfshape{10}{\magstep1}  % no cmb12
-\setfont\shortcontsl\slshape{12}{1000}
-\setfont\shortconttt\ttshape{12}{1000}
-
 %% Add scribe-like font environments, plus @l for inline lisp (usually sans
 %% serif) and @ii for TeX italic
 
@@ -1782,17 +2516,22 @@ where each line of input produces a line of output.}
 % @var is set to this for defun arguments.
 \def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx}
 
-% like \smartslanted except unconditionally use \sl.  We never want
+% @cite is like \smartslanted except unconditionally use \sl.  We never want
 % ttsl for book titles, do we?
 \def\cite#1{{\sl #1}\futurelet\next\smartitalicx}
 
 \let\i=\smartitalic
 \let\slanted=\smartslanted
-\let\var=\smartslanted
+\def\var#1{{\setupmarkupstyle{var}\smartslanted{#1}}}
 \let\dfn=\smartslanted
 \let\emph=\smartitalic
 
-% @b, explicit bold.
+% Explicit font changes: @r, @sc, undocumented @ii.
+\def\r#1{{\rm #1}}              % roman font
+\def\sc#1{{\smallcaps#1}}       % smallcaps font
+\def\ii#1{{\it #1}}             % italic font
+
+% @b, explicit bold.  Also @strong.
 \def\b#1{{\bf #1}}
 \let\strong=\b
 
@@ -1824,21 +2563,35 @@ where each line of input produces a line of output.}
 \catcode`@=\other
 \def\endofsentencespacefactor{3000}% default
 
+% @t, explicit typewriter.
 \def\t#1{%
   {\tt \rawbackslash \plainfrenchspacing #1}%
   \null
 }
-\def\samp#1{`\tclose{#1}'\null}
-\setfont\keyrm\rmshape{8}{1000}
-\font\keysy=cmsy9
-\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
-  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
-    \vbox{\hrule\kern-0.4pt
-     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
-    \kern-0.4pt\hrule}%
-  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
-% The old definition, with no lozenge:
-%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
+
+% @samp.
+\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
+
+% definition of @key that produces a lozenge.  Doesn't adjust to text size.
+%\setfont\keyrm\rmshape{8}{1000}{OT1}
+%\font\keysy=cmsy9
+%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
+%  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
+%    \vbox{\hrule\kern-0.4pt
+%     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
+%    \kern-0.4pt\hrule}%
+%  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
+
+% definition of @key with no lozenge.  If the current font is already
+% monospace, don't change it; that way, we respect @kbdinputstyle.  But
+% if it isn't monospace, then use \tt.
+%
+\def\key#1{{\setupmarkupstyle{key}%
+  \nohyphenation
+  \ifmonospace\else\tt\fi
+  #1}\null}
+
+% ctrl is no longer a Texinfo command.
 \def\ctrl #1{{\tt \rawbackslash \hat}#1}
 
 % @file, @option are the same as @samp.
@@ -1878,11 +2631,14 @@ where each line of input produces a line of output.}
 % and arrange explicitly to hyphenate at a dash.
 %  -- rms.
 {
-  \catcode`\-=\active
-  \catcode`\_=\active
+  \catcode`\-=\active \catcode`\_=\active
+  \catcode`\'=\active \catcode`\`=\active
+  \global\let'=\rq \global\let`=\lq  % default definitions
   %
   \global\def\code{\begingroup
-    \catcode`\-=\active  \catcode`\_=\active
+    \setupmarkupstyle{code}%
+    % The following should really be moved into \setupmarkupstyle handlers.
+    \catcode\dashChar=\active  \catcode\underChar=\active
     \ifallowcodebreaks
      \let-\codedash
      \let_\codeunder
@@ -1913,7 +2669,7 @@ where each line of input produces a line of output.}
 % each of the four underscores in __typeof__.  This is undesirable in
 % some manuals, especially if they don't have long identifiers in
 % general.  @allowcodebreaks provides a way to control this.
-% 
+%
 \newif\ifallowcodebreaks  \allowcodebreakstrue
 
 \def\keywordtrue{true}
@@ -1933,6 +2689,7 @@ where each line of input produces a line of output.}
 
 % @kbd is like @code, except that if the argument is just one @key command,
 % then @kbd has no effect.
+\def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}}
 
 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
 %   `example' (@kbd uses ttsl only inside of @example and friends),
@@ -1954,20 +2711,27 @@ where each line of input produces a line of output.}
 \def\wordexample{example}
 \def\wordcode{code}
 
-% Default is `distinct.'
+% Default is `distinct'.
 \kbdinputstyle distinct
 
 \def\xkey{\key}
 \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
 \ifx\one\xkey\ifx\threex\three \key{#2}%
-\else{\tclose{\kbdfont\look}}\fi
-\else{\tclose{\kbdfont\look}}\fi}
+\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
+\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi}
 
 % For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
 \let\indicateurl=\code
 \let\env=\code
 \let\command=\code
 
+% @clicksequence{File @click{} Open ...}
+\def\clicksequence#1{\begingroup #1\endgroup}
+
+% @clickstyle @arrow   (by default)
+\parseargdef\clickstyle{\def\click{#1}}
+\def\click{\arrow}
+
 % @uref (abbreviation for `urlref') takes an optional (comma-separated)
 % second argument specifying the text to display and an optional third
 % arg as text to display instead of (rather than in addition to) the url
@@ -2017,34 +2781,20 @@ where each line of input produces a line of output.}
   \let\email=\uref
 \fi
 
-% Check if we are currently using a typewriter font.  Since all the
-% Computer Modern typewriter fonts have zero interword stretch (and
-% shrink), and it is reasonable to expect all typewriter fonts to have
-% this property, we can check that font parameter.
-%
-\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
-
 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
 %
 \def\dmn#1{\thinspace #1}
 
-\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
-
 % @l was never documented to mean ``switch to the Lisp font'',
 % and it is not used as such in any manual I can find.  We need it for
 % Polish suppressed-l.  --karl, 22sep96.
 %\def\l#1{{\li #1}\null}
 
-% Explicit font changes: @r, @sc, undocumented @ii.
-\def\r#1{{\rm #1}}              % roman font
-\def\sc#1{{\smallcaps#1}}       % smallcaps font
-\def\ii#1{{\it #1}}             % italic font
-
 % @acronym for "FBI", "NATO", and the like.
 % We print this one point size smaller, since it's intended for
 % all-uppercase.
-% 
+%
 \def\acronym#1{\doacronym #1,,\finish}
 \def\doacronym#1,#2,#3\finish{%
   {\selectfonts\lsize #1}%
@@ -2056,7 +2806,7 @@ where each line of input produces a line of output.}
 
 % @abbr for "Comput. J." and the like.
 % No font change, but don't do end-of-sentence spacing.
-% 
+%
 \def\abbr#1{\doabbr #1,,\finish}
 \def\doabbr#1,#2,#3\finish{%
   {\plainfrenchspacing #1}%
@@ -2066,6 +2816,44 @@ where each line of input produces a line of output.}
   \fi
 }
 
+
+\message{glyphs,}
+
+% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
+%
+% Since these characters are used in examples, they should be an even number of
+% \tt widths. Each \tt character is 1en, so two makes it 1em.
+%
+\def\point{$\star$}
+\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
+\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
+\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
+\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
+\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
+
+% The @error{} command.
+% Adapted from the TeXbook's \boxit.
+%
+\newbox\errorbox
+%
+{\tentt \global\dimen0 = 3em}% Width of the box.
+\dimen2 = .55pt % Thickness of rules
+% The text. (`r' is open on the right, `e' somewhat less so on the left.)
+\setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt}
+%
+\setbox\errorbox=\hbox to \dimen0{\hfil
+   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
+   \advance\hsize by -2\dimen2 % Rules.
+   \vbox{%
+      \hrule height\dimen2
+      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
+         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
+         \kern3pt\vrule width\dimen2}% Space to right.
+      \hrule height\dimen2}
+    \hfil}
+%
+\def\error{\leavevmode\lower.7ex\copy\errorbox}
+
 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
 %
 \def\pounds{{\it\$}}
@@ -2075,49 +2863,113 @@ where each line of input produces a line of output.}
 % Theiling, which support regular, slanted, bold and bold slanted (and
 % "outlined" (blackboard board, sort of) versions, which we don't need).
 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
-% 
+%
 % Although only regular is the truly official Euro symbol, we ignore
 % that.  The Euro is designed to be slightly taller than the regular
 % font height.
-% 
+%
 % feymr - regular
 % feymo - slanted
 % feybr - bold
 % feybo - bold slanted
-% 
+%
 % There is no good (free) typewriter version, to my knowledge.
 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
 % Hmm.
-% 
+%
 % Also doesn't work in math.  Do we need to do math with euro symbols?
 % Hope not.
-% 
-% 
+%
+%
 \def\euro{{\eurofont e}}
 \def\eurofont{%
   % We set the font at each command, rather than predefining it in
   % \textfonts and the other font-switching commands, so that
   % installations which never need the symbol don't have to have the
   % font installed.
-  % 
+  %
   % There is only one designed size (nominal 10pt), so we always scale
   % that to the current nominal size.
-  % 
+  %
   % By the way, simply using "at 1em" works for cmr10 and the like, but
   % does not work for cmbx10 and other extended/shrunken fonts.
-  % 
+  %
   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
   %
-  \ifx\curfontstyle\bfstylename 
+  \ifx\curfontstyle\bfstylename
     % bold:
     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
-  \else 
+  \else
     % regular:
     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
   \fi
   \thiseurofont
 }
 
+% Glyphs from the EC fonts.  We don't use \let for the aliases, because
+% sometimes we redefine the original macro, and the alias should reflect
+% the redefinition.
+%
+% Use LaTeX names for the Icelandic letters.
+\def\DH{{\ecfont \char"D0}} % Eth
+\def\dh{{\ecfont \char"F0}} % eth
+\def\TH{{\ecfont \char"DE}} % Thorn
+\def\th{{\ecfont \char"FE}} % thorn
+%
+\def\guillemetleft{{\ecfont \char"13}}
+\def\guillemotleft{\guillemetleft}
+\def\guillemetright{{\ecfont \char"14}}
+\def\guillemotright{\guillemetright}
+\def\guilsinglleft{{\ecfont \char"0E}}
+\def\guilsinglright{{\ecfont \char"0F}}
+\def\quotedblbase{{\ecfont \char"12}}
+\def\quotesinglbase{{\ecfont \char"0D}}
+%
+% This positioning is not perfect (see the ogonek LaTeX package), but
+% we have the precomposed glyphs for the most common cases.  We put the
+% tests to use those glyphs in the single \ogonek macro so we have fewer
+% dummy definitions to worry about for index entries, etc.
+%
+% ogonek is also used with other letters in Lithuanian (IOU), but using
+% the precomposed glyphs for those is not so easy since they aren't in
+% the same EC font.
+\def\ogonek#1{{%
+  \def\temp{#1}%
+  \ifx\temp\macrocharA\Aogonek
+  \else\ifx\temp\macrochara\aogonek
+  \else\ifx\temp\macrocharE\Eogonek
+  \else\ifx\temp\macrochare\eogonek
+  \else
+    \ecfont \setbox0=\hbox{#1}%
+    \ifdim\ht0=1ex\accent"0C #1%
+    \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
+    \fi
+  \fi\fi\fi\fi
+  }%
+}
+\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
+\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
+\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
+\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
+%
+% Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
+\def\ecfont{%
+  % We can't distinguish serif/sans and italic/slanted, but this
+  % is used for crude hacks anyway (like adding French and German
+  % quotes to documents typeset with CM, where we lose kerning), so
+  % hopefully nobody will notice/care.
+  \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
+  \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
+  \ifx\curfontstyle\bfstylename
+    % bold:
+    \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
+  \else
+    % regular:
+    \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
+  \fi
+  \thisecfont
+}
+
 % @registeredsymbol - R in a circle.  The font for the R should really
 % be smaller yet, but lllsize is the best we can do for now.
 % Adapted from the plain.tex definition of \copyright.
@@ -2128,14 +2980,24 @@ where each line of input produces a line of output.}
     }$%
 }
 
+% @textdegree - the normal degrees sign.
+%
+\def\textdegree{$^\circ$}
+
 % Laurent Siebenmann reports \Orb undefined with:
 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
 % so we'll define it if necessary.
-% 
+%
 \ifx\Orb\undefined
 \def\Orb{\mathhexbox20D}
 \fi
 
+% Quotes.
+\chardef\quotedblleft="5C
+\chardef\quotedblright=`\"
+\chardef\quoteleft=`\`
+\chardef\quoteright=`\'
+
 
 \message{page headings,}
 
@@ -2220,12 +3082,9 @@ where each line of input produces a line of output.}
 \let\subtitlerm=\tenrm
 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
 
-\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines
-		\let\tt=\authortt}
-
 \parseargdef\title{%
   \checkenv\titlepage
-  \leftline{\titlefonts\rm #1}
+  \leftline{\titlefonts\rmisbold #1}
   % print a rule at the page bottom also.
   \finishedtitlepagefalse
   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
@@ -2246,7 +3105,7 @@ where each line of input produces a line of output.}
   \else
     \checkenv\titlepage
     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
-    {\authorfont \leftline{#1}}%
+    {\secfonts\rmisbold \leftline{#1}}%
   \fi
 }
 
@@ -2299,12 +3158,39 @@ where each line of input produces a line of output.}
   %
   % Leave some space for the footline.  Hopefully ok to assume
   % @evenfooting will not be used by itself.
-  \global\advance\pageheight by -\baselineskip
-  \global\advance\vsize by -\baselineskip
+  \global\advance\pageheight by -12pt
+  \global\advance\vsize by -12pt
 }
 
 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
 
+% @evenheadingmarks top     \thischapter <- chapter at the top of a page
+% @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
+%
+% The same set of arguments for:
+%
+% @oddheadingmarks
+% @evenfootingmarks
+% @oddfootingmarks
+% @everyheadingmarks
+% @everyfootingmarks
+
+\def\evenheadingmarks{\headingmarks{even}{heading}}
+\def\oddheadingmarks{\headingmarks{odd}{heading}}
+\def\evenfootingmarks{\headingmarks{even}{footing}}
+\def\oddfootingmarks{\headingmarks{odd}{footing}}
+\def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
+                          \headingmarks{odd}{heading}{#1} }
+\def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
+                          \headingmarks{odd}{footing}{#1} }
+% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
+\def\headingmarks#1#2#3 {%
+  \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
+  \global\expandafter\let\csname get#1#2marks\endcsname \temp
+}
+
+\everyheadingmarks bottom
+\everyfootingmarks bottom
 
 % @headings double      turns headings on for double-sided printing.
 % @headings single      turns headings on for single-sided printing.
@@ -2447,7 +3333,7 @@ where each line of input produces a line of output.}
     % cause the example and the item to crash together.  So we use this
     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
     % \parskip glue after all.  Section titles are handled this way also.
-    % 
+    %
     \penalty 10001
     \endgroup
     \itemxneedsnegativevskipfalse
@@ -2541,9 +3427,18 @@ where each line of input produces a line of output.}
   \parindent=0pt
   \parskip=\smallskipamount
   \ifdim\parskip=0pt \parskip=2pt \fi
+  %
+  % Try typesetting the item mark that if the document erroneously says
+  % something like @itemize @samp (intending @table), there's an error
+  % right away at the @itemize.  It's not the best error message in the
+  % world, but it's better than leaving it to the @item.  This means if
+  % the user wants an empty mark, they have to say @w{} not just @w.
   \def\itemcontents{#1}%
+  \setbox0 = \hbox{\itemcontents}%
+  %
   % @itemize with no arg is equivalent to @itemize @bullet.
   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
+  %
   \let\item=\itemizeitem
 }
 
@@ -2564,6 +3459,7 @@ where each line of input produces a line of output.}
    \ifnum\lastpenalty<10000 \parskip=0in \fi
    \noindent
    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
+   %
    \vadjust{\penalty 1200}}% not good to break after first line of item.
   \flushcr
 }
@@ -2785,12 +3681,19 @@ where each line of input produces a line of output.}
 %
 % @headitem starts a heading row, which we typeset in bold.
 % Assignments have to be global since we are inside the implicit group
-% of an alignment entry.  Note that \everycr resets \everytab.
-\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}%
+% of an alignment entry.  \everycr resets \everytab so we don't have to
+% undo it ourselves.
+\def\headitemfont{\b}% for people to use in the template row; not changeable
+\def\headitem{%
+  \checkenv\multitable
+  \crcr
+  \global\everytab={\bf}% can't use \headitemfont since the parsing differs
+  \the\everytab % for the first item
+}%
 %
 % A \tab used to include \hskip1sp.  But then the space in a template
 % line is not enough.  That is bad.  So let's go back to just `&' until
-% we encounter the problem it was intended to solve again.
+% we again encounter the problem the 1sp was intended to solve.
 %					--karl, nathan at acm.org, 20apr99.
 \def\tab{\checkenv\multitable &\the\everytab}%
 
@@ -2959,6 +3862,7 @@ where each line of input produces a line of output.}
 
 \def\doignore#1{\begingroup
   % Scan in ``verbatim'' mode:
+  \obeylines
   \catcode`\@ = \other
   \catcode`\{ = \other
   \catcode`\} = \other
@@ -2979,16 +3883,16 @@ where each line of input produces a line of output.}
   \gdef\dodoignore#1{%
     % #1 contains the command name as a string, e.g., `ifinfo'.
     %
-    % Define a command to find the next `@end #1', which must be on a line
-    % by itself.
-    \long\def\doignoretext##1^^M at end #1{\doignoretextyyy##1^^M@#1\_STOP_}%
+    % Define a command to find the next `@end #1'.
+    \long\def\doignoretext##1^^M at end #1{%
+      \doignoretextyyy##1^^M@#1\_STOP_}%
+    %
     % And this command to find another #1 command, at the beginning of a
     % line.  (Otherwise, we would consider a line `@c @ifset', for
     % example, to count as an @ifset for nesting.)
     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
     %
     % And now expand that command.
-    \obeylines %
     \doignoretext ^^M%
   }%
 }
@@ -3018,7 +3922,12 @@ where each line of input produces a line of output.}
 }
 
 % Finish off ignored text.
-\def\enddoignore{\endgroup\ignorespaces}
+{ \obeylines%
+  % Ignore anything after the last `@end #1'; this matters in verbatim
+  % environments, where otherwise the newline after an ignored conditional
+  % would result in a blank line in the output.
+  \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
+}
 
 
 % @set VAR sets the variable VAR to an empty value.
@@ -3183,11 +4092,11 @@ where each line of input produces a line of output.}
 \def\dosynindex#1#2#3{%
   % Only do \closeout if we haven't already done it, else we'll end up
   % closing the target index.
-  \expandafter \ifx\csname donesynindex#2\endcsname \undefined
+  \expandafter \ifx\csname donesynindex#2\endcsname \relax
     % The \closeout helps reduce unnecessary open files; the limit on the
     % Acorn RISC OS is a mere 16 files.
     \expandafter\closeout\csname#2indfile\endcsname
-    \expandafter\let\csname\donesynindex#2\endcsname = 1
+    \expandafter\let\csname donesynindex#2\endcsname = 1
   \fi
   % redefine \fooindfile:
   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
@@ -3221,12 +4130,39 @@ where each line of input produces a line of output.}
   \escapechar = `\\     % use backslash in output files.
   \def\@{@}% change to @@ when we switch to @ as escape char in index files.
   \def\ {\realbackslash\space }%
+  %
   % Need these in case \tex is in effect and \{ is a \delimiter again.
   % But can't use \lbracecmd and \rbracecmd because texindex assumes
   % braces and backslashes are used only as delimiters.
   \let\{ = \mylbrace
   \let\} = \myrbrace
   %
+  % I don't entirely understand this, but when an index entry is
+  % generated from a macro call, the \endinput which \scanmacro inserts
+  % causes processing to be prematurely terminated.  This is,
+  % apparently, because \indexsorttmp is fully expanded, and \endinput
+  % is an expandable command.  The redefinition below makes \endinput
+  % disappear altogether for that purpose -- although logging shows that
+  % processing continues to some further point.  On the other hand, it
+  % seems \endinput does not hurt in the printed index arg, since that
+  % is still getting written without apparent harm.
+  %
+  % Sample source (mac-idx3.tex, reported by Graham Percival to
+  % help-texinfo, 22may06):
+  % @macro funindex {WORD}
+  % @findex xyz
+  % @end macro
+  % ...
+  % @funindex commtest
+  %
+  % The above is not enough to reproduce the bug, but it gives the flavor.
+  %
+  % Sample whatsit resulting:
+  % . at write3{\entry{xyz}{@folio }{@code {xyz at endinput }}}
+  %
+  % So:
+  \let\endinput = \empty
+  %
   % Do the redefinitions.
   \commondummies
 }
@@ -3244,6 +4180,7 @@ where each line of input produces a line of output.}
   %
   % Do the redefinitions.
   \commondummies
+  \otherbackslash
 }
 
 % Called from \indexdummies and \atdummies.
@@ -3274,19 +4211,23 @@ where each line of input produces a line of output.}
   % Non-English letters.
   \definedummyword\AA
   \definedummyword\AE
+  \definedummyword\DH
   \definedummyword\L
-  \definedummyword\OE
   \definedummyword\O
+  \definedummyword\OE
+  \definedummyword\TH
   \definedummyword\aa
   \definedummyword\ae
+  \definedummyword\dh
+  \definedummyword\exclamdown
   \definedummyword\l
-  \definedummyword\oe
   \definedummyword\o
-  \definedummyword\ss
-  \definedummyword\exclamdown
-  \definedummyword\questiondown
+  \definedummyword\oe
   \definedummyword\ordf
   \definedummyword\ordm
+  \definedummyword\questiondown
+  \definedummyword\ss
+  \definedummyword\th
   %
   % Although these internal commands shouldn't show up, sometimes they do.
   \definedummyword\bf
@@ -3311,12 +4252,24 @@ where each line of input produces a line of output.}
   \definedummyword\equiv
   \definedummyword\error
   \definedummyword\euro
+  \definedummyword\guillemetleft
+  \definedummyword\guillemetright
+  \definedummyword\guilsinglleft
+  \definedummyword\guilsinglright
   \definedummyword\expansion
   \definedummyword\minus
+  \definedummyword\ogonek
   \definedummyword\pounds
   \definedummyword\point
   \definedummyword\print
+  \definedummyword\quotedblbase
+  \definedummyword\quotedblleft
+  \definedummyword\quotedblright
+  \definedummyword\quoteleft
+  \definedummyword\quoteright
+  \definedummyword\quotesinglbase
   \definedummyword\result
+  \definedummyword\textdegree
   %
   % We want to disable all macros so that they are not expanded by \write.
   \macrolist
@@ -3330,63 +4283,63 @@ where each line of input produces a line of output.}
 
 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
 %
-% Better have this without active chars.
-{
-  \catcode`\~=\other
-  \gdef\commondummiesnofonts{%
-    % Control letters and accents.
-    \definedummyletter\!%
-    \definedummyaccent\"%
-    \definedummyaccent\'%
-    \definedummyletter\*%
-    \definedummyaccent\,%
-    \definedummyletter\.%
-    \definedummyletter\/%
-    \definedummyletter\:%
-    \definedummyaccent\=%
-    \definedummyletter\?%
-    \definedummyaccent\^%
-    \definedummyaccent\`%
-    \definedummyaccent\~%
-    \definedummyword\u
-    \definedummyword\v
-    \definedummyword\H
-    \definedummyword\dotaccent
-    \definedummyword\ringaccent
-    \definedummyword\tieaccent
-    \definedummyword\ubaraccent
-    \definedummyword\udotaccent
-    \definedummyword\dotless
-    %
-    % Texinfo font commands.
-    \definedummyword\b
-    \definedummyword\i
-    \definedummyword\r
-    \definedummyword\sc
-    \definedummyword\t
-    %
-    % Commands that take arguments.
-    \definedummyword\acronym
-    \definedummyword\cite
-    \definedummyword\code
-    \definedummyword\command
-    \definedummyword\dfn
-    \definedummyword\emph
-    \definedummyword\env
-    \definedummyword\file
-    \definedummyword\kbd
-    \definedummyword\key
-    \definedummyword\math
-    \definedummyword\option
-    \definedummyword\samp
-    \definedummyword\strong
-    \definedummyword\tie
-    \definedummyword\uref
-    \definedummyword\url
-    \definedummyword\var
-    \definedummyword\verb
-    \definedummyword\w
-  }
+\def\commondummiesnofonts{%
+  % Control letters and accents.
+  \definedummyletter\!%
+  \definedummyaccent\"%
+  \definedummyaccent\'%
+  \definedummyletter\*%
+  \definedummyaccent\,%
+  \definedummyletter\.%
+  \definedummyletter\/%
+  \definedummyletter\:%
+  \definedummyaccent\=%
+  \definedummyletter\?%
+  \definedummyaccent\^%
+  \definedummyaccent\`%
+  \definedummyaccent\~%
+  \definedummyword\u
+  \definedummyword\v
+  \definedummyword\H
+  \definedummyword\dotaccent
+  \definedummyword\ogonek
+  \definedummyword\ringaccent
+  \definedummyword\tieaccent
+  \definedummyword\ubaraccent
+  \definedummyword\udotaccent
+  \definedummyword\dotless
+  %
+  % Texinfo font commands.
+  \definedummyword\b
+  \definedummyword\i
+  \definedummyword\r
+  \definedummyword\sc
+  \definedummyword\t
+  %
+  % Commands that take arguments.
+  \definedummyword\acronym
+  \definedummyword\cite
+  \definedummyword\code
+  \definedummyword\command
+  \definedummyword\dfn
+  \definedummyword\emph
+  \definedummyword\env
+  \definedummyword\file
+  \definedummyword\kbd
+  \definedummyword\key
+  \definedummyword\math
+  \definedummyword\option
+  \definedummyword\pxref
+  \definedummyword\ref
+  \definedummyword\samp
+  \definedummyword\strong
+  \definedummyword\tie
+  \definedummyword\uref
+  \definedummyword\url
+  \definedummyword\var
+  \definedummyword\verb
+  \definedummyword\w
+  \definedummyword\xref
 }
 
 % \indexnofonts is used when outputting the strings to sort the index
@@ -3417,19 +4370,23 @@ where each line of input produces a line of output.}
   % Non-English letters.
   \def\AA{AA}%
   \def\AE{AE}%
+  \def\DH{DZZ}%
   \def\L{L}%
   \def\OE{OE}%
   \def\O{O}%
+  \def\TH{ZZZ}%
   \def\aa{aa}%
   \def\ae{ae}%
+  \def\dh{dzz}%
+  \def\exclamdown{!}%
   \def\l{l}%
   \def\oe{oe}%
-  \def\o{o}%
-  \def\ss{ss}%
-  \def\exclamdown{!}%
-  \def\questiondown{?}%
   \def\ordf{a}%
   \def\ordm{o}%
+  \def\o{o}%
+  \def\questiondown{?}%
+  \def\ss{ss}%
+  \def\th{zzz}%
   %
   \def\LaTeX{LaTeX}%
   \def\TeX{TeX}%
@@ -3439,29 +4396,40 @@ where each line of input produces a line of output.}
   \def\bullet{bullet}%
   \def\comma{,}%
   \def\copyright{copyright}%
-  \def\registeredsymbol{R}%
   \def\dots{...}%
   \def\enddots{...}%
   \def\equiv{==}%
   \def\error{error}%
   \def\euro{euro}%
   \def\expansion{==>}%
+  \def\guillemetleft{<<}%
+  \def\guillemetright{>>}%
+  \def\guilsinglleft{<}%
+  \def\guilsinglright{>}%
   \def\minus{-}%
-  \def\pounds{pounds}%
   \def\point{.}%
+  \def\pounds{pounds}%
   \def\print{-|}%
+  \def\quotedblbase{"}%
+  \def\quotedblleft{"}%
+  \def\quotedblright{"}%
+  \def\quoteleft{`}%
+  \def\quoteright{'}%
+  \def\quotesinglbase{,}%
+  \def\registeredsymbol{R}%
   \def\result{=>}%
+  \def\textdegree{o}%
   %
   % We need to get rid of all macros, leaving only the arguments (if present).
   % Of course this is not nearly correct, but it is the best we can do for now.
   % makeinfo does not expand macros in the argument to @deffn, which ends up
   % writing an index entry, and texindex isn't prepared for an index sort entry
   % that starts with \.
-  % 
+  %
   % Since macro invocations are followed by braces, we can just redefine them
   % to take a single TeX argument.  The case of a macro invocation that
   % goes to end-of-line is not handled.
-  % 
+  %
   \macrolist
 }
 
@@ -3490,11 +4458,7 @@ where each line of input produces a line of output.}
     %
     \edef\writeto{\csname#1indfile\endcsname}%
     %
-    \ifvmode
-      \dosubindsanitize
-    \else
-      \dosubindwrite
-    \fi
+    \safewhatsit\dosubindwrite
   }%
   \fi
 }
@@ -3531,13 +4495,13 @@ where each line of input produces a line of output.}
   \temp
 }
 
-% Take care of unwanted page breaks:
+% Take care of unwanted page breaks/skips around a whatsit:
 %
 % If a skip is the last thing on the list now, preserve it
 % by backing up by \lastskip, doing the \write, then inserting
 % the skip again.  Otherwise, the whatsit generated by the
-% \write will make \lastskip zero.  The result is that sequences
-% like this:
+% \write or \pdfdest will make \lastskip zero.  The result is that
+% sequences like this:
 % @end defun
 % @tindex whatever
 % @defun ...
@@ -3561,25 +4525,31 @@ where each line of input produces a line of output.}
 %
 \edef\zeroskipmacro{\expandafter\the\csname z at skip\endcsname}
 %
+\newskip\whatsitskip
+\newcount\whatsitpenalty
+%
 % ..., ready, GO:
 %
-\def\dosubindsanitize{%
+\def\safewhatsit#1{%
+\ifhmode
+  #1%
+\else
   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
-  \skip0 = \lastskip
+  \whatsitskip = \lastskip
   \edef\lastskipmacro{\the\lastskip}%
-  \count255 = \lastpenalty
+  \whatsitpenalty = \lastpenalty
   %
   % If \lastskip is nonzero, that means the last item was a
   % skip.  And since a skip is discardable, that means this
-  % -\skip0 glue we're inserting is preceded by a
+  % -\whatsitskip glue we're inserting is preceded by a
   % non-discardable item, therefore it is not a potential
   % breakpoint, therefore no \nobreak needed.
   \ifx\lastskipmacro\zeroskipmacro
   \else
-    \vskip-\skip0
+    \vskip-\whatsitskip
   \fi
   %
-  \dosubindwrite
+  #1%
   %
   \ifx\lastskipmacro\zeroskipmacro
     % If \lastskip was zero, perhaps the last item was a penalty, and
@@ -3587,19 +4557,20 @@ where each line of input produces a line of output.}
     % to re-insert the same penalty (values >10000 are used for various
     % signals); since we just inserted a non-discardable item, any
     % following glue (such as a \parskip) would be a breakpoint.  For example:
-    % 
+    %
     %   @deffn deffn-whatever
     %   @vindex index-whatever
     %   Description.
     % would allow a break between the index-whatever whatsit
     % and the "Description." paragraph.
-    \ifnum\count255>9999 \penalty\count255 \fi
+    \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
   \else
     % On the other hand, if we had a nonzero \lastskip,
     % this make-up glue would be preceded by a non-discardable item
     % (the whatsit from the \write), so we must insert a \nobreak.
-    \nobreak\vskip\skip0
+    \nobreak\vskip\whatsitskip
   \fi
+\fi
 }
 
 % The index entry written in the file actually looks like
@@ -3642,6 +4613,7 @@ where each line of input produces a line of output.}
   %
   \smallfonts \rm
   \tolerance = 9500
+  \plainfrenchspacing
   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
   %
   % See if the index file exists and is nonempty.
@@ -3715,7 +4687,7 @@ where each line of input produces a line of output.}
 %
 % A straightforward implementation would start like this:
 %	\def\entry#1#2{...
-% But this frozes the catcodes in the argument, and can cause problems to
+% But this freezes the catcodes in the argument, and can cause problems to
 % @code, which sets - active.  This problem was fixed by a kludge---
 % ``-'' was active throughout whole index, but this isn't really right.
 %
@@ -3771,11 +4743,8 @@ where each line of input produces a line of output.}
     % The following is kludged to not output a line of dots in the index if
     % there are no page numbers.  The next person who breaks this will be
     % cursed by a Unix daemon.
-    \def\tempa{{\rm }}%
-    \def\tempb{#1}%
-    \edef\tempc{\tempa}%
-    \edef\tempd{\tempb}%
-    \ifx\tempc\tempd
+    \setbox\boxA = \hbox{#1}%
+    \ifdim\wd\boxA = 0pt
       \ %
     \else
       %
@@ -3799,9 +4768,9 @@ where each line of input produces a line of output.}
   \endgroup
 }
 
-% Like \dotfill except takes at least 1 em.
+% Like plain.tex's \dotfill, except uses up at least 1 em.
 \def\indexdotfill{\cleaders
-  \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
+  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
 
 \def\primary #1{\line{#1\hfil}}
 
@@ -3911,6 +4880,34 @@ where each line of input produces a line of output.}
 %
 % All done with double columns.
 \def\enddoublecolumns{%
+  % The following penalty ensures that the page builder is exercised
+  % _before_ we change the output routine.  This is necessary in the
+  % following situation:
+  %
+  % The last section of the index consists only of a single entry.
+  % Before this section, \pagetotal is less than \pagegoal, so no
+  % break occurs before the last section starts.  However, the last
+  % section, consisting of \initial and the single \entry, does not
+  % fit on the page and has to be broken off.  Without the following
+  % penalty the page builder will not be exercised until \eject
+  % below, and by that time we'll already have changed the output
+  % routine to the \balancecolumns version, so the next-to-last
+  % double-column page will be processed with \balancecolumns, which
+  % is wrong:  The two columns will go to the main vertical list, with
+  % the broken-off section in the recent contributions.  As soon as
+  % the output routine finishes, TeX starts reconsidering the page
+  % break.  The two columns and the broken-off section both fit on the
+  % page, because the two columns now take up only half of the page
+  % goal.  When TeX sees \eject from below which follows the final
+  % section, it invokes the new output routine that we've set after
+  % \balancecolumns below; \onepageout will try to fit the two columns
+  % and the final section into the vbox of \pageheight (see
+  % \pagebody), causing an overfull box.
+  %
+  % Note that glue won't work here, because glue does not exercise the
+  % page builder, unlike penalties (see The TeXbook, pp. 280-281).
+  \penalty0
+  %
   \output = {%
     % Split the last of the double-column material.  Leave it on the
     % current page, no automatic page break.
@@ -4020,11 +5017,15 @@ where each line of input produces a line of output.}
   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
 
-% Each @chapter defines this as the name of the chapter.
-% page headings and footings can use it.  @section does likewise.
-% However, they are not reliable, because we don't use marks.
+% Each @chapter defines these (using marks) as the number+name, number
+% and name of the chapter.  Page headings and footings can use
+% these.  @section does likewise.
 \def\thischapter{}
+\def\thischapternum{}
+\def\thischaptername{}
 \def\thissection{}
+\def\thissectionnum{}
+\def\thissectionname{}
 
 \newcount\absseclevel % used to calculate proper heading level
 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
@@ -4137,7 +5138,9 @@ where each line of input produces a line of output.}
   \gdef\chaplevelprefix{\the\chapno.}%
   \resetallfloatnos
   %
-  \message{\putwordChapter\space \the\chapno}%
+  % \putwordChapter can contain complex things in translations.
+  \toks0=\expandafter{\putwordChapter}%
+  \message{\the\toks0 \space \the\chapno}%
   %
   % Write the actual heading.
   \chapmacro{#1}{Ynumbered}{\the\chapno}%
@@ -4148,15 +5151,17 @@ where each line of input produces a line of output.}
   \global\let\subsubsection = \numberedsubsubsec
 }
 
-\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
+\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
+%
 \def\appendixzzz#1{%
   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
     \global\advance\appendixno by 1
   \gdef\chaplevelprefix{\appendixletter.}%
   \resetallfloatnos
   %
-  \def\appendixnum{\putwordAppendix\space \appendixletter}%
-  \message{\appendixnum}%
+  % \putwordAppendix can contain complex things in translations.
+  \toks0=\expandafter{\putwordAppendix}%
+  \message{\the\toks0 \space \appendixletter}%
   %
   \chapmacro{#1}{Yappendix}{\appendixletter}%
   %
@@ -4288,7 +5293,6 @@ where each line of input produces a line of output.}
 %       3) Likewise, headings look best if no \parindent is used, and
 %          if justification is not attempted.  Hence \raggedright.
 
-
 \def\majorheading{%
   {\advance\chapheadingskip by 10pt \chapbreak }%
   \parsearg\chapheadingzzz
@@ -4297,8 +5301,8 @@ where each line of input produces a line of output.}
 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
 \def\chapheadingzzz#1{%
   {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
-                    \parindent=0pt\raggedright
-                    \rm #1\hfill}}%
+                    \parindent=0pt\ptexraggedright
+                    \rmisbold #1\hfill}}%
   \bigskip \par\penalty 200\relax
   \suppressfirstparagraphindent
 }
@@ -4325,7 +5329,20 @@ where each line of input produces a line of output.}
 
 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
 \def\chappager{\par\vfill\supereject}
-\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
+% Because \domark is called before \chapoddpage, the filler page will
+% get the headings for the next chapter, which is wrong.  But we don't
+% care -- we just disable all headings on the filler page.
+\def\chapoddpage{%
+  \chappager
+  \ifodd\pageno \else
+    \begingroup
+      \evenheadline={\hfil}\evenfootline={\hfil}%
+      \oddheadline={\hfil}\oddfootline={\hfil}%
+      \hbox to 0pt{}%
+      \chappager
+    \endgroup
+  \fi
+}
 
 \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
 
@@ -4359,41 +5376,78 @@ where each line of input produces a line of output.}
 \def\Yappendixkeyword{Yappendix}
 %
 \def\chapmacro#1#2#3{%
+  % Insert the first mark before the heading break (see notes for \domark).
+  \let\prevchapterdefs=\lastchapterdefs
+  \let\prevsectiondefs=\lastsectiondefs
+  \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
+                        \gdef\thissection{}}%
+  %
+  \def\temptype{#2}%
+  \ifx\temptype\Ynothingkeyword
+    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+                          \gdef\thischapter{\thischaptername}}%
+  \else\ifx\temptype\Yomitfromtockeyword
+    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+                          \gdef\thischapter{}}%
+  \else\ifx\temptype\Yappendixkeyword
+    \toks0={#1}%
+    \xdef\lastchapterdefs{%
+      \gdef\noexpand\thischaptername{\the\toks0}%
+      \gdef\noexpand\thischapternum{\appendixletter}%
+      % \noexpand\putwordAppendix avoids expanding indigestible
+      % commands in some of the translations.
+      \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
+                                 \noexpand\thischapternum:
+                                 \noexpand\thischaptername}%
+    }%
+  \else
+    \toks0={#1}%
+    \xdef\lastchapterdefs{%
+      \gdef\noexpand\thischaptername{\the\toks0}%
+      \gdef\noexpand\thischapternum{\the\chapno}%
+      % \noexpand\putwordChapter avoids expanding indigestible
+      % commands in some of the translations.
+      \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
+                                 \noexpand\thischapternum:
+                                 \noexpand\thischaptername}%
+    }%
+  \fi\fi\fi
+  %
+  % Output the mark.  Pass it through \safewhatsit, to take care of
+  % the preceding space.
+  \safewhatsit\domark
+  %
+  % Insert the chapter heading break.
   \pchapsepmacro
+  %
+  % Now the second mark, after the heading break.  No break points
+  % between here and the heading.
+  \let\prevchapterdefs=\lastchapterdefs
+  \let\prevsectiondefs=\lastsectiondefs
+  \domark
+  %
   {%
-    \chapfonts \rm
+    \chapfonts \rmisbold
     %
-    % Have to define \thissection before calling \donoderef, because the
+    % Have to define \lastsection before calling \donoderef, because the
     % xref code eventually uses it.  On the other hand, it has to be called
     % after \pchapsepmacro, or the headline will change too soon.
-    \gdef\thissection{#1}%
-    \gdef\thischaptername{#1}%
+    \gdef\lastsection{#1}%
     %
     % Only insert the separating space if we have a chapter/appendix
     % number, and don't print the unnumbered ``number''.
-    \def\temptype{#2}%
     \ifx\temptype\Ynothingkeyword
       \setbox0 = \hbox{}%
       \def\toctype{unnchap}%
-      \gdef\thischapter{#1}%
     \else\ifx\temptype\Yomitfromtockeyword
       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
       \def\toctype{omit}%
-      \gdef\thischapter{}%
     \else\ifx\temptype\Yappendixkeyword
       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
       \def\toctype{app}%
-      % We don't substitute the actual chapter name into \thischapter
-      % because we don't want its macros evaluated now.  And we don't
-      % use \thissection because that changes with each section.
-      %
-      \xdef\thischapter{\putwordAppendix{} \appendixletter:
-                        \noexpand\thischaptername}%
     \else
       \setbox0 = \hbox{#3\enspace}%
       \def\toctype{numchap}%
-      \xdef\thischapter{\putwordChapter{} \the\chapno:
-                        \noexpand\thischaptername}%
     \fi\fi\fi
     %
     % Write the toc entry for this chapter.  Must come before the
@@ -4409,7 +5463,8 @@ where each line of input produces a line of output.}
     \donoderef{#2}%
     %
     % Typeset the actual heading.
-    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
+    \nobreak % Avoid page breaks at the interline glue.
+    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
           \hangindent=\wd0 \centerparametersmaybe
           \unhbox0 #1\par}%
   }%
@@ -4433,8 +5488,8 @@ where each line of input produces a line of output.}
 %
 \def\unnchfopen #1{%
 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
-                       \parindent=0pt\raggedright
-                       \rm #1\hfill}}\bigskip \par\nobreak
+                       \parindent=0pt\ptexraggedright
+                       \rmisbold #1\hfill}}\bigskip \par\nobreak
 }
 \def\chfopen #1#2{\chapoddpage {\chapfonts
 \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
@@ -4443,7 +5498,7 @@ where each line of input produces a line of output.}
 \def\centerchfopen #1{%
 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
                        \parindent=0pt
-                       \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
+                       \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak
 }
 \def\CHAPFopen{%
   \global\let\chapmacro=\chfopen
@@ -4471,47 +5526,108 @@ where each line of input produces a line of output.}
 % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
 % section number.
 %
+\def\seckeyword{sec}
+%
 \def\sectionheading#1#2#3#4{%
   {%
     % Switch to the right set of fonts.
-    \csname #2fonts\endcsname \rm
+    \csname #2fonts\endcsname \rmisbold
+    %
+    \def\sectionlevel{#2}%
+    \def\temptype{#3}%
+    %
+    % Insert first mark before the heading break (see notes for \domark).
+    \let\prevsectiondefs=\lastsectiondefs
+    \ifx\temptype\Ynothingkeyword
+      \ifx\sectionlevel\seckeyword
+        \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
+                              \gdef\thissection{\thissectionname}}%
+      \fi
+    \else\ifx\temptype\Yomitfromtockeyword
+      % Don't redefine \thissection.
+    \else\ifx\temptype\Yappendixkeyword
+      \ifx\sectionlevel\seckeyword
+        \toks0={#1}%
+        \xdef\lastsectiondefs{%
+          \gdef\noexpand\thissectionname{\the\toks0}%
+          \gdef\noexpand\thissectionnum{#4}%
+          % \noexpand\putwordSection avoids expanding indigestible
+          % commands in some of the translations.
+          \gdef\noexpand\thissection{\noexpand\putwordSection{}
+                                     \noexpand\thissectionnum:
+                                     \noexpand\thissectionname}%
+        }%
+      \fi
+    \else
+      \ifx\sectionlevel\seckeyword
+        \toks0={#1}%
+        \xdef\lastsectiondefs{%
+          \gdef\noexpand\thissectionname{\the\toks0}%
+          \gdef\noexpand\thissectionnum{#4}%
+          % \noexpand\putwordSection avoids expanding indigestible
+          % commands in some of the translations.
+          \gdef\noexpand\thissection{\noexpand\putwordSection{}
+                                     \noexpand\thissectionnum:
+                                     \noexpand\thissectionname}%
+        }%
+      \fi
+    \fi\fi\fi
+    %
+    % Go into vertical mode.  Usually we'll already be there, but we
+    % don't want the following whatsit to end up in a preceding paragraph
+    % if the document didn't happen to have a blank line.
+    \par
+    %
+    % Output the mark.  Pass it through \safewhatsit, to take care of
+    % the preceding space.
+    \safewhatsit\domark
     %
     % Insert space above the heading.
     \csname #2headingbreak\endcsname
     %
-    % Only insert the space after the number if we have a section number.
-    \def\sectionlevel{#2}%
-    \def\temptype{#3}%
+    % Now the second mark, after the heading break.  No break points
+    % between here and the heading.
+    \let\prevsectiondefs=\lastsectiondefs
+    \domark
     %
+    % Only insert the space after the number if we have a section number.
     \ifx\temptype\Ynothingkeyword
       \setbox0 = \hbox{}%
       \def\toctype{unn}%
-      \gdef\thissection{#1}%
+      \gdef\lastsection{#1}%
     \else\ifx\temptype\Yomitfromtockeyword
       % for @headings -- no section number, don't include in toc,
-      % and don't redefine \thissection.
+      % and don't redefine \lastsection.
       \setbox0 = \hbox{}%
       \def\toctype{omit}%
       \let\sectionlevel=\empty
     \else\ifx\temptype\Yappendixkeyword
       \setbox0 = \hbox{#4\enspace}%
       \def\toctype{app}%
-      \gdef\thissection{#1}%
+      \gdef\lastsection{#1}%
     \else
       \setbox0 = \hbox{#4\enspace}%
       \def\toctype{num}%
-      \gdef\thissection{#1}%
+      \gdef\lastsection{#1}%
     \fi\fi\fi
     %
-    % Write the toc entry (before \donoderef).  See comments in \chfplain.
+    % Write the toc entry (before \donoderef).  See comments in \chapmacro.
     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
     %
     % Write the node reference (= pdf destination for pdftex).
-    % Again, see comments in \chfplain.
+    % Again, see comments in \chapmacro.
     \donoderef{#3}%
     %
+    % Interline glue will be inserted when the vbox is completed.
+    % That glue will be a valid breakpoint for the page, since it'll be
+    % preceded by a whatsit (usually from the \donoderef, or from the
+    % \writetocentry if there was no node).  We don't want to allow that
+    % break, since then the whatsits could end up on page n while the
+    % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
+    \nobreak
+    %
     % Output the actual section heading.
-    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
+    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
           \hangindent=\wd0  % zero if no section number
           \unhbox0 #1}%
   }%
@@ -4527,11 +5643,11 @@ where each line of input produces a line of output.}
   % glue accumulate.  (Not a breakpoint because it's preceded by a
   % discardable item.)
   \vskip-\parskip
-  % 
+  %
   % This is purely so the last item on the list is a known \penalty >
   % 10000.  This is so \startdefun can avoid allowing breakpoints after
   % section headings.  Otherwise, it would insert a valid breakpoint between:
-  % 
+  %
   %   @section sec-whatever
   %   @deffn def-whatever
   \penalty 10001
@@ -4572,7 +5688,7 @@ where each line of input produces a line of output.}
        \edef\temp{%
          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
        \temp
-      }
+      }%
     \fi
   \fi
   %
@@ -4589,7 +5705,7 @@ where each line of input produces a line of output.}
 % These characters do not print properly in the Computer Modern roman
 % fonts, so we must take special care.  This is more or less redundant
 % with the Texinfo input format setup at the end of this file.
-% 
+%
 \def\activecatcodes{%
   \catcode`\"=\active
   \catcode`\$=\active
@@ -4607,7 +5723,7 @@ where each line of input produces a line of output.}
 \def\readtocfile{%
   \setupdatafile
   \activecatcodes
-  \input \jobname.toc
+  \input \tocreadfilename
 }
 
 \newskip\contentsrightmargin \contentsrightmargin=1in
@@ -4626,7 +5742,6 @@ where each line of input produces a line of output.}
   %
   % Don't need to put `Contents' or `Short Contents' in the headline.
   % It is abundantly clear what they are.
-  \def\thischapter{}%
   \chapmacro{#1}{Yomitfromtoc}{}%
   %
   \savepageno = \pageno
@@ -4638,11 +5753,16 @@ where each line of input produces a line of output.}
     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
 }
 
+% redefined for the two-volume lispref.  We always output on
+% \jobname.toc even if this is redefined.
+%
+\def\tocreadfilename{\jobname.toc}
 
 % Normal (long) toc.
+%
 \def\contents{%
   \startcontents{\putwordTOC}%
-    \openin 1 \jobname.toc
+    \openin 1 \tocreadfilename\space
     \ifeof 1 \else
       \readtocfile
     \fi
@@ -4680,7 +5800,7 @@ where each line of input produces a line of output.}
     \let\numsubsubsecentry = \numsecentry
     \let\appsubsubsecentry = \numsecentry
     \let\unnsubsubsecentry = \numsecentry
-    \openin 1 \jobname.toc
+    \openin 1 \tocreadfilename\space
     \ifeof 1 \else
       \readtocfile
     \fi
@@ -4805,45 +5925,12 @@ where each line of input produces a line of output.}
 \message{environments,}
 % @foo ... @end foo.
 
-% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
-%
-% Since these characters are used in examples, it should be an even number of
-% \tt widths. Each \tt character is 1en, so two makes it 1em.
-%
-\def\point{$\star$}
-\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
-\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
-\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
-\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
-
-% The @error{} command.
-% Adapted from the TeXbook's \boxit.
-%
-\newbox\errorbox
-%
-{\tentt \global\dimen0 = 3em}% Width of the box.
-\dimen2 = .55pt % Thickness of rules
-% The text. (`r' is open on the right, `e' somewhat less so on the left.)
-\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
-%
-\setbox\errorbox=\hbox to \dimen0{\hfil
-   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
-   \advance\hsize by -2\dimen2 % Rules.
-   \vbox{%
-      \hrule height\dimen2
-      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
-         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
-         \kern3pt\vrule width\dimen2}% Space to right.
-      \hrule height\dimen2}
-    \hfil}
-%
-\def\error{\leavevmode\lower.7ex\copy\errorbox}
-
 % @tex ... @end tex    escapes into raw Tex temporarily.
 % One exception: @ is still an escape character, so that @end tex works.
 % But \@ or @@ will get a plain tex @ character.
 
 \envdef\tex{%
+  \setupmarkupstyle{tex}%
   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
@@ -4853,6 +5940,8 @@ where each line of input produces a line of output.}
   \catcode `\|=\other
   \catcode `\<=\other
   \catcode `\>=\other
+  \catcode`\`=\other
+  \catcode`\'=\other
   \escapechar=`\\
   %
   \let\b=\ptexb
@@ -4872,6 +5961,7 @@ where each line of input produces a line of output.}
   \let\/=\ptexslash
   \let\*=\ptexstar
   \let\t=\ptext
+  \expandafter \let\csname top\endcsname=\ptextop  % outer
   \let\frenchspacing=\plainfrenchspacing
   %
   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
@@ -4987,6 +6077,7 @@ where each line of input produces a line of output.}
 
 % This macro is called at the beginning of all the @example variants,
 % inside a group.
+\newdimen\nonfillparindent
 \def\nonfillstart{%
   \aboveenvbreak
   \hfuzz = 12pt % Don't be fussy
@@ -4994,7 +6085,12 @@ where each line of input produces a line of output.}
   \let\par = \lisppar % don't ignore blank lines
   \obeylines % each line of input is a line of output
   \parskip = 0pt
+  % Turn off paragraph indentation but redefine \indent to emulate
+  % the normal \indent.
+  \nonfillparindent=\parindent
   \parindent = 0pt
+  \let\indent\nonfillindent
+  %
   \emergencystretch = 0pt % don't try to avoid overfull boxes
   \ifx\nonarrowing\relax
     \advance \leftskip by \lispnarrowing
@@ -5005,6 +6101,24 @@ where each line of input produces a line of output.}
   \let\exdent=\nofillexdent
 }
 
+\begingroup
+\obeyspaces
+% We want to swallow spaces (but not other tokens) after the fake
+% @indent in our nonfill-environments, where spaces are normally
+% active and set to @tie, resulting in them not being ignored after
+% @indent.
+\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
+\gdef\nonfillindentcheck{%
+\ifx\temp %
+\expandafter\nonfillindentgobble%
+\else%
+\leavevmode\nonfillindentbox%
+\fi%
+}%
+\endgroup
+\def\nonfillindentgobble#1{\nonfillindent}
+\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
+
 % If you want all examples etc. small: @set dispenvsize small.
 % If you want even small examples the full size: @set dispenvsize nosmall.
 % This affects the following displayed environments:
@@ -5015,12 +6129,18 @@ where each line of input produces a line of output.}
 \let\SETdispenvsize\relax
 \def\setnormaldispenv{%
   \ifx\SETdispenvsize\smallword
+    % end paragraph for sake of leading, in case document has no blank
+    % line.  This is redundant with what happens in \aboveenvbreak, but
+    % we need to do it before changing the fonts, and it's inconvenient
+    % to change the fonts afterward.
+    \ifnum \lastpenalty=10000 \else \endgraf \fi
     \smallexamplefonts \rm
   \fi
 }
 \def\setsmalldispenv{%
   \ifx\SETdispenvsize\nosmallword
   \else
+    \ifnum \lastpenalty=10000 \else \endgraf \fi
     \smallexamplefonts \rm
   \fi
 }
@@ -5047,11 +6167,10 @@ where each line of input produces a line of output.}
 %
 \maketwodispenvs {lisp}{example}{%
   \nonfillstart
-  \tt
+  \tt\setupmarkupstyle{example}%
   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
   \gobble       % eat return
 }
-
 % @display/@smalldisplay: same as @lisp except keep current font.
 %
 \makedispenv {display}{%
@@ -5086,12 +6205,36 @@ where each line of input produces a line of output.}
 \let\Eflushright = \afterenvbreak
 
 
+% @raggedright does more-or-less normal line breaking but no right
+% justification.  From plain.tex.
+\envdef\raggedright{%
+  \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
+}
+\let\Eraggedright\par
+
+\envdef\raggedleft{%
+  \parindent=0pt \leftskip0pt plus2em
+  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
+  \hbadness=10000 % Last line will usually be underfull, so turn off
+                  % badness reporting.
+}
+\let\Eraggedleft\par
+
+\envdef\raggedcenter{%
+  \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
+  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
+  \hbadness=10000 % Last line will usually be underfull, so turn off
+                  % badness reporting.
+}
+\let\Eraggedcenter\par
+
+
 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
 % and narrows the margins.  We keep \parskip nonzero in general, since
 % we're doing normal filling.  So, when using \aboveenvbreak and
 % \afterenvbreak, temporarily make \parskip 0.
 %
-\envdef\quotation{%
+\def\quotationstart{%
   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
   \parindent=0pt
   %
@@ -5106,6 +6249,17 @@ where each line of input produces a line of output.}
   \parsearg\quotationlabel
 }
 
+\envdef\quotation{%
+  \setnormaldispenv
+  \quotationstart
+}
+
+\envdef\smallquotation{%
+  \setsmalldispenv
+  \quotationstart
+}
+\let\Esmallquotation = \Equotation
+
 % We have retained a nonzero parskip for the environment, since we're
 % doing normal filling.
 %
@@ -5141,18 +6295,16 @@ where each line of input produces a line of output.}
   \do\ \do\\\do\{\do\}\do\$\do\&%
   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
   \do\<\do\>\do\|\do\@\do+\do\"%
+  % Don't do the quotes -- if we do, @set txicodequoteundirected and
+  % @set txicodequotebacktick will not have effect on @verb and
+  % @verbatim, and ?` and !` ligatures won't get disabled.
+  %\do\`\do\'%
 }
 %
 % [Knuth] p. 380
 \def\uncatcodespecials{%
   \def\do##1{\catcode`##1=\other}\dospecials}
 %
-% [Knuth] pp. 380,381,391
-% Disable Spanish ligatures ?` and !` of \tt font
-\begingroup
-  \catcode`\`=\active\gdef`{\relax\lq}
-\endgroup
-%
 % Setup for the @verb command.
 %
 % Eight spaces for a tab
@@ -5164,7 +6316,7 @@ where each line of input produces a line of output.}
 \def\setupverb{%
   \tt  % easiest (and conventionally used) font for verbatim
   \def\par{\leavevmode\endgraf}%
-  \catcode`\`=\active
+  \setupmarkupstyle{verb}%
   \tabeightspaces
   % Respect line breaks,
   % print special symbols as themselves, and
@@ -5179,6 +6331,7 @@ where each line of input produces a line of output.}
 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
 %
 \def\starttabbox{\setbox0=\hbox\bgroup}
+%
 \begingroup
   \catcode`\^^I=\active
   \gdef\tabexpand{%
@@ -5192,14 +6345,16 @@ where each line of input produces a line of output.}
     }%
   }
 \endgroup
+
+% start the verbatim environment.
 \def\setupverbatim{%
   \let\nonarrowing = t%
   \nonfillstart
   % Easiest (and conventionally used) font for verbatim
   \tt
   \def\par{\leavevmode\egroup\box0\endgraf}%
-  \catcode`\`=\active
   \tabexpand
+  \setupmarkupstyle{verbatim}%
   % Respect line breaks,
   % print special symbols as themselves, and
   % make each space count
@@ -5259,6 +6414,7 @@ where each line of input produces a line of output.}
   {%
     \makevalueexpandable
     \setupverbatim
+    \indexnofonts       % Allow `@@' and other weird things in file names.
     \input #1
     \afterenvbreak
   }%
@@ -5284,27 +6440,35 @@ where each line of input produces a line of output.}
   \endgroup
 }
 
+
 \message{defuns,}
 % @defun etc.
 
 \newskip\defbodyindent \defbodyindent=.4in
 \newskip\defargsindent \defargsindent=50pt
 \newskip\deflastargmargin \deflastargmargin=18pt
+\newcount\defunpenalty
 
 % Start the processing of @deffn:
 \def\startdefun{%
   \ifnum\lastpenalty<10000
     \medbreak
+    \defunpenalty=10003 % Will keep this @deffn together with the
+                        % following @def command, see below.
   \else
     % If there are two @def commands in a row, we'll have a \nobreak,
     % which is there to keep the function description together with its
     % header.  But if there's nothing but headers, we need to allow a
     % break somewhere.  Check specifically for penalty 10002, inserted
-    % by \defargscommonending, instead of 10000, since the sectioning
+    % by \printdefunline, instead of 10000, since the sectioning
     % commands also insert a nobreak penalty, and we don't want to allow
     % a break between a section heading and a defun.
-    % 
-    \ifnum\lastpenalty=10002 \penalty2000 \fi
+    %
+    % As a minor refinement, we avoid "club" headers by signalling
+    % with penalty of 10003 after the very first @deffn in the
+    % sequence (see above), and penalty of 10002 after any following
+    % @def command.
+    \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
     %
     % Similarly, after a section heading, do not allow a break.
     % But do insert the glue.
@@ -5322,7 +6486,7 @@ where each line of input produces a line of output.}
   %
   % As above, allow line break if we have multiple x headers in a row.
   % It's not a great place, though.
-  \ifnum\lastpenalty=10002 \penalty3000 \fi
+  \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
   %
   % And now, it's time to reuse the body of the original defun:
   \expandafter\gobbledefun#1%
@@ -5340,7 +6504,7 @@ where each line of input produces a line of output.}
     \advance\rightskip by 0pt plus 1fil
     \endgraf
     \nobreak\vskip -\parskip
-    \penalty 10002  % signal to \startdefun and \dodefunx
+    \penalty\defunpenalty  % signal to \startdefun and \dodefunx
     % Some of the @defun-type tags do not enable magic parentheses,
     % rendering the following check redundant.  But we don't optimize.
     \checkparencounts
@@ -5350,7 +6514,7 @@ where each line of input produces a line of output.}
 \def\Edefun{\endgraf\medbreak}
 
 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
-% the only thing remainnig is to define \deffnheader.
+% the only thing remaining is to define \deffnheader.
 %
 \def\makedefun#1{%
   \expandafter\let\csname E#1\endcsname = \Edefun
@@ -5529,7 +6693,7 @@ where each line of input produces a line of output.}
   %
   % On the other hand, if an argument has two dashes (for instance), we
   % want a way to get ttsl.  Let's try @var for that.
-  \let\var=\ttslanted
+  \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
   #1%
   \sl\hyphenchar\font=45
 }
@@ -5609,12 +6773,14 @@ where each line of input produces a line of output.}
   \ifnum\parencount=0 \else \badparencount \fi
   \ifnum\brackcount=0 \else \badbrackcount \fi
 }
+% these should not use \errmessage; the glibc manual, at least, actually
+% has such constructs (when documenting function pointers).
 \def\badparencount{%
-  \errmessage{Unbalanced parentheses in @def}%
+  \message{Warning: unbalanced parentheses in @def...}%
   \global\parencount=0
 }
 \def\badbrackcount{%
-  \errmessage{Unbalanced square braces in @def}%
+  \message{Warning: unbalanced square brackets in @def...}%
   \global\brackcount=0
 }
 
@@ -5649,7 +6815,6 @@ where each line of input produces a line of output.}
     \spaceisspace
     %
     % Append \endinput to make sure that TeX does not see the ending newline.
-    %
     % I've verified that it is necessary both for e-TeX and for ordinary TeX
     %							--kasal, 29nov03
     \scantokens{#1\endinput}%
@@ -5682,7 +6847,7 @@ where each line of input produces a line of output.}
 % This does \let #1 = #2, with \csnames; that is,
 %   \let \csname#1\endcsname = \csname#2\endcsname
 % (except of course we have to play expansion games).
-% 
+%
 \def\cslet#1#2{%
   \expandafter\let
   \csname#1\expandafter\endcsname
@@ -5710,6 +6875,10 @@ where each line of input produces a line of output.}
 % all characters are catcode 10, 11 or 12, except \ which is active
 % (as in normal texinfo). It is necessary to change the definition of \.
 
+% Non-ASCII encodings make 8-bit characters active, so un-activate
+% them to avoid their expansion.  Must do this non-globally, to
+% confine the change to the current group.
+
 % It's necessary to have hard CRs when the macro is executed. This is
 % done by  making ^^M (\endlinechar) catcode 12 when reading the macro
 % body, and then making it the \newlinechar in \scanmacro.
@@ -5724,6 +6893,7 @@ where each line of input produces a line of output.}
   \catcode`\_=\other
   \catcode`\|=\other
   \catcode`\~=\other
+  \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
 }
 
 \def\scanargctxt{%
@@ -5916,11 +7086,11 @@ where each line of input produces a line of output.}
 % {.  If so it reads up to the closing }, if not, it reads the whole
 % line.  Whatever was read is then fed to the next control sequence
 % as an argument (by \parsebrace or \parsearg)
-\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
+\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
 \def\braceorlinexxx{%
   \ifx\nchar\bgroup\else
     \expandafter\parsearg
-  \fi \next}
+  \fi \macnamexxx}
 
 
 % @alias.
@@ -5941,7 +7111,6 @@ where each line of input produces a line of output.}
 \message{cross references,}
 
 \newwrite\auxfile
-
 \newif\ifhavexrefs    % True if xref values are known.
 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
 
@@ -5986,7 +7155,7 @@ where each line of input produces a line of output.}
 
 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
 % anchor), which consists of three parts:
-% 1) NAME-title - the current sectioning name taken from \thissection,
+% 1) NAME-title - the current sectioning name taken from \lastsection,
 %                 or the anchor name.
 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
 %                 empty for anchors.
@@ -6005,10 +7174,10 @@ where each line of input produces a line of output.}
 	\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
 	  ##1}{##2}}% these are parameters of \writexrdef
       }%
-      \toks0 = \expandafter{\thissection}%
+      \toks0 = \expandafter{\lastsection}%
       \immediate \writexrdef{title}{\the\toks0 }%
       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
-      \writexrdef{pg}{\folio}% will be written later, during \shipout
+      \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, during \shipout
     }%
   \fi
 }
@@ -6052,22 +7221,25 @@ where each line of input produces a line of output.}
   %
   % Make link in pdf output.
   \ifpdf
-    \leavevmode
-    \getfilename{#4}%
-    {\turnoffactive
+    {\indexnofonts
+     \turnoffactive
+     % This expands tokens, so do it after making catcode changes, so _
+     % etc. don't get their TeX definitions.
+     \getfilename{#4}%
+     %
      % See comments at \activebackslashdouble.
      {\activebackslashdouble \xdef\pdfxrefdest{#1}%
       \backslashparens\pdfxrefdest}%
      %
+     \leavevmode
+     \startlink attr{/Border [0 0 0]}%
      \ifnum\filenamelength>0
-       \startlink attr{/Border [0 0 0]}%
-         goto file{\the\filename.pdf} name{\pdfxrefdest}%
+       goto file{\the\filename.pdf} name{\pdfxrefdest}%
      \else
-       \startlink attr{/Border [0 0 0]}%
-         goto name{\pdfmkpgn{\pdfxrefdest}}%
+       goto name{\pdfmkpgn{\pdfxrefdest}}%
      \fi
     }%
-    \linkcolor
+    \setcolor{\linkcolor}%
   \fi
   %
   % Float references are printed completely differently: "Figure 1.2"
@@ -6085,7 +7257,7 @@ where each line of input produces a line of output.}
     % If the user specified the print name (third arg) to the ref,
     % print it instead of our usual "Figure 1.2".
     \ifdim\wd0 = 0pt
-      \refx{#1-snt}%
+      \refx{#1-snt}{}%
     \else
       \printedrefname
     \fi
@@ -6105,7 +7277,7 @@ where each line of input produces a line of output.}
     % is a loss.  Therefore, we give the text of the node name again, so it
     % is as if TeX is seeing it for the first time.
     \ifdim \wd1 > 0pt
-      \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
+      \putwordSection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
     \else
       % _ (for example) has to be the character _ for the purposes of the
       % control sequence corresponding to the node, but it has to expand
@@ -6201,10 +7373,18 @@ where each line of input produces a line of output.}
 % collisions).  But if this is a float type, we have more work to do.
 %
 \def\xrdef#1#2{%
-  \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value.
+  {% The node name might contain 8-bit characters, which in our current
+   % implementation are changed to commands like @'e.  Don't let these
+   % mess up the control sequence name.
+    \indexnofonts
+    \turnoffactive
+    \xdef\safexrefname{#1}%
+  }%
+  %
+  \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
   %
   % Was that xref control sequence that we just defined for a float?
-  \expandafter\iffloat\csname XR#1\endcsname
+  \expandafter\iffloat\csname XR\safexrefname\endcsname
     % it was a float, and we have the (safe) float type in \iffloattype.
     \expandafter\let\expandafter\floatlist
       \csname floatlist\iffloattype\endcsname
@@ -6219,7 +7399,8 @@ where each line of input produces a line of output.}
     %
     % Remember this xref in the control sequence \floatlistFLOATTYPE,
     % for later use in \listoffloats.
-    \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}%
+    \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
+      {\safexrefname}}%
   \fi
 }
 
@@ -6323,6 +7504,7 @@ where each line of input produces a line of output.}
   \input\jobname.#1
 \endgroup}
 
+
 \message{insertions,}
 % including footnotes.
 
@@ -6405,7 +7587,7 @@ where each line of input produces a line of output.}
 % In case a @footnote appears in a vbox, save the footnote text and create
 % the real \insert just after the vbox finished.  Otherwise, the insertion
 % would be lost.
-% Similarily, if a @footnote appears inside an alignment, save the footnote
+% Similarly, if a @footnote appears inside an alignment, save the footnote
 % text to a box and make the \insert when a row of the table is finished.
 % And the same can be done for other insert classes.  --kasal, 16nov03.
 
@@ -6509,15 +7691,19 @@ where each line of input produces a line of output.}
   % If the image is by itself, center it.
   \ifvmode
     \imagevmodetrue
-    \nobreak\bigskip
+    \nobreak\medskip
     % Usually we'll have text after the image which will insert
     % \parskip glue, so insert it here too to equalize the space
     % above and below.
     \nobreak\vskip\parskip
     \nobreak
-    \line\bgroup\hss
   \fi
   %
+  % Leave vertical mode so that indentation from an enclosing
+  % environment such as @quotation is respected.  On the other hand, if
+  % it's at the top level, we don't want the normal paragraph indentation.
+  \noindent
+  %
   % Output the image.
   \ifpdf
     \dopdfimage{#1}{#2}{#3}%
@@ -6528,7 +7714,7 @@ where each line of input produces a line of output.}
     \epsfbox{#1.eps}%
   \fi
   %
-  \ifimagevmode \hss \egroup \bigbreak \fi  % space after the image
+  \ifimagevmode \medskip \fi  % space after the standalone image
 \endgroup}
 
 
@@ -6595,13 +7781,13 @@ where each line of input produces a line of output.}
       \global\advance\floatno by 1
       %
       {%
-        % This magic value for \thissection is output by \setref as the
+        % This magic value for \lastsection is output by \setref as the
         % XREFLABEL-title value.  \xrefX uses it to distinguish float
         % labels (which have a completely different output format) from
         % node and anchor labels.  And \xrdef uses it to construct the
         % lists of floats.
         %
-        \edef\thissection{\floatmagic=\safefloattype}%
+        \edef\lastsection{\floatmagic=\safefloattype}%
         \setref{\floatlabel}{Yfloat}%
       }%
     \fi
@@ -6669,6 +7855,7 @@ where each line of input produces a line of output.}
       % caption if specified, else the full caption if specified, else nothing.
       {%
         \atdummies
+        %
         % since we read the caption text in the macro world, where ^^M
         % is turned into a normal character, we have to scan it back, so
         % we don't write the literal three characters "^^M" into the aux file.
@@ -6689,8 +7876,9 @@ where each line of input produces a line of output.}
   %
   % place the captured inserts
   %
-  % BEWARE: when the floats start float, we have to issue warning whenever an
-  % insert appears inside a float which could possibly float. --kasal, 26may04
+  % BEWARE: when the floats start floating, we have to issue warning
+  % whenever an insert appears inside a float which could possibly
+  % float. --kasal, 26may04
   %
   \checkinserts
 }
@@ -6734,7 +7922,7 @@ where each line of input produces a line of output.}
 
 % #1 is the control sequence we are passed; we expand into a conditional
 % which is true if #1 represents a float ref.  That is, the magic
-% \thissection value which we \setref above.
+% \lastsection value which we \setref above.
 %
 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
 %
@@ -6795,39 +7983,909 @@ where each line of input produces a line of output.}
   \writeentry
 }}
 
+
 \message{localization,}
-% and i18n.
 
-% @documentlanguage is usually given very early, just after
-% @setfilename.  If done too late, it may not override everything
-% properly.  Single argument is the language abbreviation.
-% It would be nice if we could set up a hyphenation file here.
+% For single-language documents, @documentlanguage is usually given very
+% early, just after @documentencoding.  Single argument is the language
+% (de) or locale (de_DE) abbreviation.
 %
-\parseargdef\documentlanguage{%
+{
+  \catcode`\_ = \active
+  \globaldefs=1
+\parseargdef\documentlanguage{\begingroup
+  \let_=\normalunderscore  % normal _ character for filenames
   \tex % read txi-??.tex file in plain TeX.
-    % Read the file if it exists.
+    % Read the file by the name they passed if it exists.
     \openin 1 txi-#1.tex
     \ifeof 1
-      \errhelp = \nolanghelp
-      \errmessage{Cannot read language file txi-#1.tex}%
+      \documentlanguagetrywithoutunderscore{#1_\finish}%
     \else
+      \globaldefs = 1  % everything in the txi-LL files needs to persist
       \input txi-#1.tex
     \fi
     \closein 1
-  \endgroup
+  \endgroup % end raw TeX
+\endgroup}
+%
+% If they passed de_DE, and txi-de_DE.tex doesn't exist,
+% try txi-de.tex.
+%
+\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
+  \openin 1 txi-#1.tex
+  \ifeof 1
+    \errhelp = \nolanghelp
+    \errmessage{Cannot read language file txi-#1.tex}%
+  \else
+    \globaldefs = 1  % everything in the txi-LL files needs to persist
+    \input txi-#1.tex
+  \fi
+  \closein 1
 }
+}% end of special _ catcode
+%
 \newhelp\nolanghelp{The given language definition file cannot be found or
-is empty.  Maybe you need to install it?  In the current directory
-should work if nowhere else does.}
+is empty.  Maybe you need to install it?  Putting it in the current
+directory should work if nowhere else does.}
 
+% This macro is called from txi-??.tex files; the first argument is the
+% \language name to set (without the "\lang@" prefix), the second and
+% third args are \{left,right}hyphenmin.
+%
+% The language names to pass are determined when the format is built.
+% See the etex.log file created at that time, e.g.,
+% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
+%
+% With TeX Live 2008, etex now includes hyphenation patterns for all
+% available languages.  This means we can support hyphenation in
+% Texinfo, at least to some extent.  (This still doesn't solve the
+% accented characters problem.)
+%
+\catcode`@=11
+\def\txisetlanguage#1#2#3{%
+  % do not set the language if the name is undefined in the current TeX.
+  \expandafter\ifx\csname lang@#1\endcsname \relax
+    \message{no patterns for #1}%
+  \else
+    \global\language = \csname lang@#1\endcsname
+  \fi
+  % but there is no harm in adjusting the hyphenmin values regardless.
+  \global\lefthyphenmin = #2\relax
+  \global\righthyphenmin = #3\relax
+}
 
-% @documentencoding should change something in TeX eventually, most
-% likely, but for now just recognize it.
-\let\documentencoding = \comment
+% Helpers for encodings.
+% Set the catcode of characters 128 through 255 to the specified number.
+%
+\def\setnonasciicharscatcode#1{%
+   \count255=128
+   \loop\ifnum\count255<256
+      \global\catcode\count255=#1\relax
+      \advance\count255 by 1
+   \repeat
+}
 
+\def\setnonasciicharscatcodenonglobal#1{%
+   \count255=128
+   \loop\ifnum\count255<256
+      \catcode\count255=#1\relax
+      \advance\count255 by 1
+   \repeat
+}
 
-% Page size parameters.
+% @documentencoding sets the definition of non-ASCII characters
+% according to the specified encoding.
 %
+\parseargdef\documentencoding{%
+  % Encoding being declared for the document.
+  \def\declaredencoding{\csname #1.enc\endcsname}%
+  %
+  % Supported encodings: names converted to tokens in order to be able
+  % to compare them with \ifx.
+  \def\ascii{\csname US-ASCII.enc\endcsname}%
+  \def\latnine{\csname ISO-8859-15.enc\endcsname}%
+  \def\latone{\csname ISO-8859-1.enc\endcsname}%
+  \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
+  \def\utfeight{\csname UTF-8.enc\endcsname}%
+  %
+  \ifx \declaredencoding \ascii
+     \asciichardefs
+  %
+  \else \ifx \declaredencoding \lattwo
+     \setnonasciicharscatcode\active
+     \lattwochardefs
+  %
+  \else \ifx \declaredencoding \latone
+     \setnonasciicharscatcode\active
+     \latonechardefs
+  %
+  \else \ifx \declaredencoding \latnine
+     \setnonasciicharscatcode\active
+     \latninechardefs
+  %
+  \else \ifx \declaredencoding \utfeight
+     \setnonasciicharscatcode\active
+     \utfeightchardefs
+  %
+  \else
+    \message{Unknown document encoding #1, ignoring.}%
+  %
+  \fi % utfeight
+  \fi % latnine
+  \fi % latone
+  \fi % lattwo
+  \fi % ascii
+}
+
+% A message to be logged when using a character that isn't available
+% the default font encoding (OT1).
+%
+\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
+
+% Take account of \c (plain) vs. \, (Texinfo) difference.
+\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
+
+% First, make active non-ASCII characters in order for them to be
+% correctly categorized when TeX reads the replacement text of
+% macros containing the character definitions.
+\setnonasciicharscatcode\active
+%
+% Latin1 (ISO-8859-1) character definitions.
+\def\latonechardefs{%
+  \gdef^^a0{~}
+  \gdef^^a1{\exclamdown}
+  \gdef^^a2{\missingcharmsg{CENT SIGN}}
+  \gdef^^a3{{\pounds}}
+  \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
+  \gdef^^a5{\missingcharmsg{YEN SIGN}}
+  \gdef^^a6{\missingcharmsg{BROKEN BAR}}
+  \gdef^^a7{\S}
+  \gdef^^a8{\"{}}
+  \gdef^^a9{\copyright}
+  \gdef^^aa{\ordf}
+  \gdef^^ab{\guillemetleft}
+  \gdef^^ac{$\lnot$}
+  \gdef^^ad{\-}
+  \gdef^^ae{\registeredsymbol}
+  \gdef^^af{\={}}
+  %
+  \gdef^^b0{\textdegree}
+  \gdef^^b1{$\pm$}
+  \gdef^^b2{$^2$}
+  \gdef^^b3{$^3$}
+  \gdef^^b4{\'{}}
+  \gdef^^b5{$\mu$}
+  \gdef^^b6{\P}
+  %
+  \gdef^^b7{$^.$}
+  \gdef^^b8{\cedilla\ }
+  \gdef^^b9{$^1$}
+  \gdef^^ba{\ordm}
+  %
+  \gdef^^bb{\guilletright}
+  \gdef^^bc{$1\over4$}
+  \gdef^^bd{$1\over2$}
+  \gdef^^be{$3\over4$}
+  \gdef^^bf{\questiondown}
+  %
+  \gdef^^c0{\`A}
+  \gdef^^c1{\'A}
+  \gdef^^c2{\^A}
+  \gdef^^c3{\~A}
+  \gdef^^c4{\"A}
+  \gdef^^c5{\ringaccent A}
+  \gdef^^c6{\AE}
+  \gdef^^c7{\cedilla C}
+  \gdef^^c8{\`E}
+  \gdef^^c9{\'E}
+  \gdef^^ca{\^E}
+  \gdef^^cb{\"E}
+  \gdef^^cc{\`I}
+  \gdef^^cd{\'I}
+  \gdef^^ce{\^I}
+  \gdef^^cf{\"I}
+  %
+  \gdef^^d0{\DH}
+  \gdef^^d1{\~N}
+  \gdef^^d2{\`O}
+  \gdef^^d3{\'O}
+  \gdef^^d4{\^O}
+  \gdef^^d5{\~O}
+  \gdef^^d6{\"O}
+  \gdef^^d7{$\times$}
+  \gdef^^d8{\O}
+  \gdef^^d9{\`U}
+  \gdef^^da{\'U}
+  \gdef^^db{\^U}
+  \gdef^^dc{\"U}
+  \gdef^^dd{\'Y}
+  \gdef^^de{\TH}
+  \gdef^^df{\ss}
+  %
+  \gdef^^e0{\`a}
+  \gdef^^e1{\'a}
+  \gdef^^e2{\^a}
+  \gdef^^e3{\~a}
+  \gdef^^e4{\"a}
+  \gdef^^e5{\ringaccent a}
+  \gdef^^e6{\ae}
+  \gdef^^e7{\cedilla c}
+  \gdef^^e8{\`e}
+  \gdef^^e9{\'e}
+  \gdef^^ea{\^e}
+  \gdef^^eb{\"e}
+  \gdef^^ec{\`{\dotless i}}
+  \gdef^^ed{\'{\dotless i}}
+  \gdef^^ee{\^{\dotless i}}
+  \gdef^^ef{\"{\dotless i}}
+  %
+  \gdef^^f0{\dh}
+  \gdef^^f1{\~n}
+  \gdef^^f2{\`o}
+  \gdef^^f3{\'o}
+  \gdef^^f4{\^o}
+  \gdef^^f5{\~o}
+  \gdef^^f6{\"o}
+  \gdef^^f7{$\div$}
+  \gdef^^f8{\o}
+  \gdef^^f9{\`u}
+  \gdef^^fa{\'u}
+  \gdef^^fb{\^u}
+  \gdef^^fc{\"u}
+  \gdef^^fd{\'y}
+  \gdef^^fe{\th}
+  \gdef^^ff{\"y}
+}
+
+% Latin9 (ISO-8859-15) encoding character definitions.
+\def\latninechardefs{%
+  % Encoding is almost identical to Latin1.
+  \latonechardefs
+  %
+  \gdef^^a4{\euro}
+  \gdef^^a6{\v S}
+  \gdef^^a8{\v s}
+  \gdef^^b4{\v Z}
+  \gdef^^b8{\v z}
+  \gdef^^bc{\OE}
+  \gdef^^bd{\oe}
+  \gdef^^be{\"Y}
+}
+
+% Latin2 (ISO-8859-2) character definitions.
+\def\lattwochardefs{%
+  \gdef^^a0{~}
+  \gdef^^a1{\ogonek{A}}
+  \gdef^^a2{\u{}}
+  \gdef^^a3{\L}
+  \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
+  \gdef^^a5{\v L}
+  \gdef^^a6{\'S}
+  \gdef^^a7{\S}
+  \gdef^^a8{\"{}}
+  \gdef^^a9{\v S}
+  \gdef^^aa{\cedilla S}
+  \gdef^^ab{\v T}
+  \gdef^^ac{\'Z}
+  \gdef^^ad{\-}
+  \gdef^^ae{\v Z}
+  \gdef^^af{\dotaccent Z}
+  %
+  \gdef^^b0{\textdegree}
+  \gdef^^b1{\ogonek{a}}
+  \gdef^^b2{\ogonek{ }}
+  \gdef^^b3{\l}
+  \gdef^^b4{\'{}}
+  \gdef^^b5{\v l}
+  \gdef^^b6{\'s}
+  \gdef^^b7{\v{}}
+  \gdef^^b8{\cedilla\ }
+  \gdef^^b9{\v s}
+  \gdef^^ba{\cedilla s}
+  \gdef^^bb{\v t}
+  \gdef^^bc{\'z}
+  \gdef^^bd{\H{}}
+  \gdef^^be{\v z}
+  \gdef^^bf{\dotaccent z}
+  %
+  \gdef^^c0{\'R}
+  \gdef^^c1{\'A}
+  \gdef^^c2{\^A}
+  \gdef^^c3{\u A}
+  \gdef^^c4{\"A}
+  \gdef^^c5{\'L}
+  \gdef^^c6{\'C}
+  \gdef^^c7{\cedilla C}
+  \gdef^^c8{\v C}
+  \gdef^^c9{\'E}
+  \gdef^^ca{\ogonek{E}}
+  \gdef^^cb{\"E}
+  \gdef^^cc{\v E}
+  \gdef^^cd{\'I}
+  \gdef^^ce{\^I}
+  \gdef^^cf{\v D}
+  %
+  \gdef^^d0{\DH}
+  \gdef^^d1{\'N}
+  \gdef^^d2{\v N}
+  \gdef^^d3{\'O}
+  \gdef^^d4{\^O}
+  \gdef^^d5{\H O}
+  \gdef^^d6{\"O}
+  \gdef^^d7{$\times$}
+  \gdef^^d8{\v R}
+  \gdef^^d9{\ringaccent U}
+  \gdef^^da{\'U}
+  \gdef^^db{\H U}
+  \gdef^^dc{\"U}
+  \gdef^^dd{\'Y}
+  \gdef^^de{\cedilla T}
+  \gdef^^df{\ss}
+  %
+  \gdef^^e0{\'r}
+  \gdef^^e1{\'a}
+  \gdef^^e2{\^a}
+  \gdef^^e3{\u a}
+  \gdef^^e4{\"a}
+  \gdef^^e5{\'l}
+  \gdef^^e6{\'c}
+  \gdef^^e7{\cedilla c}
+  \gdef^^e8{\v c}
+  \gdef^^e9{\'e}
+  \gdef^^ea{\ogonek{e}}
+  \gdef^^eb{\"e}
+  \gdef^^ec{\v e}
+  \gdef^^ed{\'\i}
+  \gdef^^ee{\^\i}
+  \gdef^^ef{\v d}
+  %
+  \gdef^^f0{\dh}
+  \gdef^^f1{\'n}
+  \gdef^^f2{\v n}
+  \gdef^^f3{\'o}
+  \gdef^^f4{\^o}
+  \gdef^^f5{\H o}
+  \gdef^^f6{\"o}
+  \gdef^^f7{$\div$}
+  \gdef^^f8{\v r}
+  \gdef^^f9{\ringaccent u}
+  \gdef^^fa{\'u}
+  \gdef^^fb{\H u}
+  \gdef^^fc{\"u}
+  \gdef^^fd{\'y}
+  \gdef^^fe{\cedilla t}
+  \gdef^^ff{\dotaccent{}}
+}
+
+% UTF-8 character definitions.
+%
+% This code to support UTF-8 is based on LaTeX's utf8.def, with some
+% changes for Texinfo conventions.  It is included here under the GPL by
+% permission from Frank Mittelbach and the LaTeX team.
+%
+\newcount\countUTFx
+\newcount\countUTFy
+\newcount\countUTFz
+
+\gdef\UTFviiiTwoOctets#1#2{\expandafter
+   \UTFviiiDefined\csname u8:#1\string #2\endcsname}
+%
+\gdef\UTFviiiThreeOctets#1#2#3{\expandafter
+   \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
+%
+\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
+   \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
+
+\gdef\UTFviiiDefined#1{%
+  \ifx #1\relax
+    \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
+  \else
+    \expandafter #1%
+  \fi
+}
+
+\begingroup
+  \catcode`\~13
+  \catcode`\"12
+
+  \def\UTFviiiLoop{%
+    \global\catcode\countUTFx\active
+    \uccode`\~\countUTFx
+    \uppercase\expandafter{\UTFviiiTmp}%
+    \advance\countUTFx by 1
+    \ifnum\countUTFx < \countUTFy
+      \expandafter\UTFviiiLoop
+    \fi}
+
+  \countUTFx = "C2
+  \countUTFy = "E0
+  \def\UTFviiiTmp{%
+    \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
+  \UTFviiiLoop
+
+  \countUTFx = "E0
+  \countUTFy = "F0
+  \def\UTFviiiTmp{%
+    \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
+  \UTFviiiLoop
+
+  \countUTFx = "F0
+  \countUTFy = "F4
+  \def\UTFviiiTmp{%
+    \xdef~{\noexpand\UTFviiiFourOctets\string~}}
+  \UTFviiiLoop
+\endgroup
+
+\begingroup
+  \catcode`\"=12
+  \catcode`\<=12
+  \catcode`\.=12
+  \catcode`\,=12
+  \catcode`\;=12
+  \catcode`\!=12
+  \catcode`\~=13
+
+  \gdef\DeclareUnicodeCharacter#1#2{%
+    \countUTFz = "#1\relax
+    \wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
+    \begingroup
+      \parseXMLCharref
+      \def\UTFviiiTwoOctets##1##2{%
+        \csname u8:##1\string ##2\endcsname}%
+      \def\UTFviiiThreeOctets##1##2##3{%
+        \csname u8:##1\string ##2\string ##3\endcsname}%
+      \def\UTFviiiFourOctets##1##2##3##4{%
+        \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
+      \expandafter\expandafter\expandafter\expandafter
+       \expandafter\expandafter\expandafter
+       \gdef\UTFviiiTmp{#2}%
+    \endgroup}
+
+  \gdef\parseXMLCharref{%
+    \ifnum\countUTFz < "A0\relax
+      \errhelp = \EMsimple
+      \errmessage{Cannot define Unicode char value < 00A0}%
+    \else\ifnum\countUTFz < "800\relax
+      \parseUTFviiiA,%
+      \parseUTFviiiB C\UTFviiiTwoOctets.,%
+    \else\ifnum\countUTFz < "10000\relax
+      \parseUTFviiiA;%
+      \parseUTFviiiA,%
+      \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
+    \else
+      \parseUTFviiiA;%
+      \parseUTFviiiA,%
+      \parseUTFviiiA!%
+      \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
+    \fi\fi\fi
+  }
+
+  \gdef\parseUTFviiiA#1{%
+    \countUTFx = \countUTFz
+    \divide\countUTFz by 64
+    \countUTFy = \countUTFz
+    \multiply\countUTFz by 64
+    \advance\countUTFx by -\countUTFz
+    \advance\countUTFx by 128
+    \uccode `#1\countUTFx
+    \countUTFz = \countUTFy}
+
+  \gdef\parseUTFviiiB#1#2#3#4{%
+    \advance\countUTFz by "#10\relax
+    \uccode `#3\countUTFz
+    \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
+\endgroup
+
+\def\utfeightchardefs{%
+  \DeclareUnicodeCharacter{00A0}{\tie}
+  \DeclareUnicodeCharacter{00A1}{\exclamdown}
+  \DeclareUnicodeCharacter{00A3}{\pounds}
+  \DeclareUnicodeCharacter{00A8}{\"{ }}
+  \DeclareUnicodeCharacter{00A9}{\copyright}
+  \DeclareUnicodeCharacter{00AA}{\ordf}
+  \DeclareUnicodeCharacter{00AB}{\guillemetleft}
+  \DeclareUnicodeCharacter{00AD}{\-}
+  \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
+  \DeclareUnicodeCharacter{00AF}{\={ }}
+
+  \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
+  \DeclareUnicodeCharacter{00B4}{\'{ }}
+  \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
+  \DeclareUnicodeCharacter{00BA}{\ordm}
+  \DeclareUnicodeCharacter{00BB}{\guillemetright}
+  \DeclareUnicodeCharacter{00BF}{\questiondown}
+
+  \DeclareUnicodeCharacter{00C0}{\`A}
+  \DeclareUnicodeCharacter{00C1}{\'A}
+  \DeclareUnicodeCharacter{00C2}{\^A}
+  \DeclareUnicodeCharacter{00C3}{\~A}
+  \DeclareUnicodeCharacter{00C4}{\"A}
+  \DeclareUnicodeCharacter{00C5}{\AA}
+  \DeclareUnicodeCharacter{00C6}{\AE}
+  \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
+  \DeclareUnicodeCharacter{00C8}{\`E}
+  \DeclareUnicodeCharacter{00C9}{\'E}
+  \DeclareUnicodeCharacter{00CA}{\^E}
+  \DeclareUnicodeCharacter{00CB}{\"E}
+  \DeclareUnicodeCharacter{00CC}{\`I}
+  \DeclareUnicodeCharacter{00CD}{\'I}
+  \DeclareUnicodeCharacter{00CE}{\^I}
+  \DeclareUnicodeCharacter{00CF}{\"I}
+
+  \DeclareUnicodeCharacter{00D0}{\DH}
+  \DeclareUnicodeCharacter{00D1}{\~N}
+  \DeclareUnicodeCharacter{00D2}{\`O}
+  \DeclareUnicodeCharacter{00D3}{\'O}
+  \DeclareUnicodeCharacter{00D4}{\^O}
+  \DeclareUnicodeCharacter{00D5}{\~O}
+  \DeclareUnicodeCharacter{00D6}{\"O}
+  \DeclareUnicodeCharacter{00D8}{\O}
+  \DeclareUnicodeCharacter{00D9}{\`U}
+  \DeclareUnicodeCharacter{00DA}{\'U}
+  \DeclareUnicodeCharacter{00DB}{\^U}
+  \DeclareUnicodeCharacter{00DC}{\"U}
+  \DeclareUnicodeCharacter{00DD}{\'Y}
+  \DeclareUnicodeCharacter{00DE}{\TH}
+  \DeclareUnicodeCharacter{00DF}{\ss}
+
+  \DeclareUnicodeCharacter{00E0}{\`a}
+  \DeclareUnicodeCharacter{00E1}{\'a}
+  \DeclareUnicodeCharacter{00E2}{\^a}
+  \DeclareUnicodeCharacter{00E3}{\~a}
+  \DeclareUnicodeCharacter{00E4}{\"a}
+  \DeclareUnicodeCharacter{00E5}{\aa}
+  \DeclareUnicodeCharacter{00E6}{\ae}
+  \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
+  \DeclareUnicodeCharacter{00E8}{\`e}
+  \DeclareUnicodeCharacter{00E9}{\'e}
+  \DeclareUnicodeCharacter{00EA}{\^e}
+  \DeclareUnicodeCharacter{00EB}{\"e}
+  \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
+  \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
+  \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
+  \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
+
+  \DeclareUnicodeCharacter{00F0}{\dh}
+  \DeclareUnicodeCharacter{00F1}{\~n}
+  \DeclareUnicodeCharacter{00F2}{\`o}
+  \DeclareUnicodeCharacter{00F3}{\'o}
+  \DeclareUnicodeCharacter{00F4}{\^o}
+  \DeclareUnicodeCharacter{00F5}{\~o}
+  \DeclareUnicodeCharacter{00F6}{\"o}
+  \DeclareUnicodeCharacter{00F8}{\o}
+  \DeclareUnicodeCharacter{00F9}{\`u}
+  \DeclareUnicodeCharacter{00FA}{\'u}
+  \DeclareUnicodeCharacter{00FB}{\^u}
+  \DeclareUnicodeCharacter{00FC}{\"u}
+  \DeclareUnicodeCharacter{00FD}{\'y}
+  \DeclareUnicodeCharacter{00FE}{\th}
+  \DeclareUnicodeCharacter{00FF}{\"y}
+
+  \DeclareUnicodeCharacter{0100}{\=A}
+  \DeclareUnicodeCharacter{0101}{\=a}
+  \DeclareUnicodeCharacter{0102}{\u{A}}
+  \DeclareUnicodeCharacter{0103}{\u{a}}
+  \DeclareUnicodeCharacter{0104}{\ogonek{A}}
+  \DeclareUnicodeCharacter{0105}{\ogonek{a}}
+  \DeclareUnicodeCharacter{0106}{\'C}
+  \DeclareUnicodeCharacter{0107}{\'c}
+  \DeclareUnicodeCharacter{0108}{\^C}
+  \DeclareUnicodeCharacter{0109}{\^c}
+  \DeclareUnicodeCharacter{0118}{\ogonek{E}}
+  \DeclareUnicodeCharacter{0119}{\ogonek{e}}
+  \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
+  \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
+  \DeclareUnicodeCharacter{010C}{\v{C}}
+  \DeclareUnicodeCharacter{010D}{\v{c}}
+  \DeclareUnicodeCharacter{010E}{\v{D}}
+
+  \DeclareUnicodeCharacter{0112}{\=E}
+  \DeclareUnicodeCharacter{0113}{\=e}
+  \DeclareUnicodeCharacter{0114}{\u{E}}
+  \DeclareUnicodeCharacter{0115}{\u{e}}
+  \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
+  \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
+  \DeclareUnicodeCharacter{011A}{\v{E}}
+  \DeclareUnicodeCharacter{011B}{\v{e}}
+  \DeclareUnicodeCharacter{011C}{\^G}
+  \DeclareUnicodeCharacter{011D}{\^g}
+  \DeclareUnicodeCharacter{011E}{\u{G}}
+  \DeclareUnicodeCharacter{011F}{\u{g}}
+
+  \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
+  \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
+  \DeclareUnicodeCharacter{0124}{\^H}
+  \DeclareUnicodeCharacter{0125}{\^h}
+  \DeclareUnicodeCharacter{0128}{\~I}
+  \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
+  \DeclareUnicodeCharacter{012A}{\=I}
+  \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
+  \DeclareUnicodeCharacter{012C}{\u{I}}
+  \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
+
+  \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
+  \DeclareUnicodeCharacter{0131}{\dotless{i}}
+  \DeclareUnicodeCharacter{0132}{IJ}
+  \DeclareUnicodeCharacter{0133}{ij}
+  \DeclareUnicodeCharacter{0134}{\^J}
+  \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
+  \DeclareUnicodeCharacter{0139}{\'L}
+  \DeclareUnicodeCharacter{013A}{\'l}
+
+  \DeclareUnicodeCharacter{0141}{\L}
+  \DeclareUnicodeCharacter{0142}{\l}
+  \DeclareUnicodeCharacter{0143}{\'N}
+  \DeclareUnicodeCharacter{0144}{\'n}
+  \DeclareUnicodeCharacter{0147}{\v{N}}
+  \DeclareUnicodeCharacter{0148}{\v{n}}
+  \DeclareUnicodeCharacter{014C}{\=O}
+  \DeclareUnicodeCharacter{014D}{\=o}
+  \DeclareUnicodeCharacter{014E}{\u{O}}
+  \DeclareUnicodeCharacter{014F}{\u{o}}
+
+  \DeclareUnicodeCharacter{0150}{\H{O}}
+  \DeclareUnicodeCharacter{0151}{\H{o}}
+  \DeclareUnicodeCharacter{0152}{\OE}
+  \DeclareUnicodeCharacter{0153}{\oe}
+  \DeclareUnicodeCharacter{0154}{\'R}
+  \DeclareUnicodeCharacter{0155}{\'r}
+  \DeclareUnicodeCharacter{0158}{\v{R}}
+  \DeclareUnicodeCharacter{0159}{\v{r}}
+  \DeclareUnicodeCharacter{015A}{\'S}
+  \DeclareUnicodeCharacter{015B}{\'s}
+  \DeclareUnicodeCharacter{015C}{\^S}
+  \DeclareUnicodeCharacter{015D}{\^s}
+  \DeclareUnicodeCharacter{015E}{\cedilla{S}}
+  \DeclareUnicodeCharacter{015F}{\cedilla{s}}
+
+  \DeclareUnicodeCharacter{0160}{\v{S}}
+  \DeclareUnicodeCharacter{0161}{\v{s}}
+  \DeclareUnicodeCharacter{0162}{\cedilla{t}}
+  \DeclareUnicodeCharacter{0163}{\cedilla{T}}
+  \DeclareUnicodeCharacter{0164}{\v{T}}
+
+  \DeclareUnicodeCharacter{0168}{\~U}
+  \DeclareUnicodeCharacter{0169}{\~u}
+  \DeclareUnicodeCharacter{016A}{\=U}
+  \DeclareUnicodeCharacter{016B}{\=u}
+  \DeclareUnicodeCharacter{016C}{\u{U}}
+  \DeclareUnicodeCharacter{016D}{\u{u}}
+  \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
+  \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
+
+  \DeclareUnicodeCharacter{0170}{\H{U}}
+  \DeclareUnicodeCharacter{0171}{\H{u}}
+  \DeclareUnicodeCharacter{0174}{\^W}
+  \DeclareUnicodeCharacter{0175}{\^w}
+  \DeclareUnicodeCharacter{0176}{\^Y}
+  \DeclareUnicodeCharacter{0177}{\^y}
+  \DeclareUnicodeCharacter{0178}{\"Y}
+  \DeclareUnicodeCharacter{0179}{\'Z}
+  \DeclareUnicodeCharacter{017A}{\'z}
+  \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
+  \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
+  \DeclareUnicodeCharacter{017D}{\v{Z}}
+  \DeclareUnicodeCharacter{017E}{\v{z}}
+
+  \DeclareUnicodeCharacter{01C4}{D\v{Z}}
+  \DeclareUnicodeCharacter{01C5}{D\v{z}}
+  \DeclareUnicodeCharacter{01C6}{d\v{z}}
+  \DeclareUnicodeCharacter{01C7}{LJ}
+  \DeclareUnicodeCharacter{01C8}{Lj}
+  \DeclareUnicodeCharacter{01C9}{lj}
+  \DeclareUnicodeCharacter{01CA}{NJ}
+  \DeclareUnicodeCharacter{01CB}{Nj}
+  \DeclareUnicodeCharacter{01CC}{nj}
+  \DeclareUnicodeCharacter{01CD}{\v{A}}
+  \DeclareUnicodeCharacter{01CE}{\v{a}}
+  \DeclareUnicodeCharacter{01CF}{\v{I}}
+
+  \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
+  \DeclareUnicodeCharacter{01D1}{\v{O}}
+  \DeclareUnicodeCharacter{01D2}{\v{o}}
+  \DeclareUnicodeCharacter{01D3}{\v{U}}
+  \DeclareUnicodeCharacter{01D4}{\v{u}}
+
+  \DeclareUnicodeCharacter{01E2}{\={\AE}}
+  \DeclareUnicodeCharacter{01E3}{\={\ae}}
+  \DeclareUnicodeCharacter{01E6}{\v{G}}
+  \DeclareUnicodeCharacter{01E7}{\v{g}}
+  \DeclareUnicodeCharacter{01E8}{\v{K}}
+  \DeclareUnicodeCharacter{01E9}{\v{k}}
+
+  \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
+  \DeclareUnicodeCharacter{01F1}{DZ}
+  \DeclareUnicodeCharacter{01F2}{Dz}
+  \DeclareUnicodeCharacter{01F3}{dz}
+  \DeclareUnicodeCharacter{01F4}{\'G}
+  \DeclareUnicodeCharacter{01F5}{\'g}
+  \DeclareUnicodeCharacter{01F8}{\`N}
+  \DeclareUnicodeCharacter{01F9}{\`n}
+  \DeclareUnicodeCharacter{01FC}{\'{\AE}}
+  \DeclareUnicodeCharacter{01FD}{\'{\ae}}
+  \DeclareUnicodeCharacter{01FE}{\'{\O}}
+  \DeclareUnicodeCharacter{01FF}{\'{\o}}
+
+  \DeclareUnicodeCharacter{021E}{\v{H}}
+  \DeclareUnicodeCharacter{021F}{\v{h}}
+
+  \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
+  \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
+  \DeclareUnicodeCharacter{0228}{\cedilla{E}}
+  \DeclareUnicodeCharacter{0229}{\cedilla{e}}
+  \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
+  \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
+
+  \DeclareUnicodeCharacter{0232}{\=Y}
+  \DeclareUnicodeCharacter{0233}{\=y}
+  \DeclareUnicodeCharacter{0237}{\dotless{j}}
+
+  \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
+
+  \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
+  \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
+  \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
+  \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
+  \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
+  \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
+  \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
+  \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
+  \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
+  \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
+  \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
+  \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
+
+  \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
+  \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
+
+  \DeclareUnicodeCharacter{1E20}{\=G}
+  \DeclareUnicodeCharacter{1E21}{\=g}
+  \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
+  \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
+  \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
+  \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
+  \DeclareUnicodeCharacter{1E26}{\"H}
+  \DeclareUnicodeCharacter{1E27}{\"h}
+
+  \DeclareUnicodeCharacter{1E30}{\'K}
+  \DeclareUnicodeCharacter{1E31}{\'k}
+  \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
+  \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
+  \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
+  \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
+  \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
+  \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
+  \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
+  \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
+  \DeclareUnicodeCharacter{1E3E}{\'M}
+  \DeclareUnicodeCharacter{1E3F}{\'m}
+
+  \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
+  \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
+  \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
+  \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
+  \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
+  \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
+  \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
+  \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
+  \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
+  \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
+
+  \DeclareUnicodeCharacter{1E54}{\'P}
+  \DeclareUnicodeCharacter{1E55}{\'p}
+  \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
+  \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
+  \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
+  \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
+  \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
+  \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
+  \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
+  \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
+
+  \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
+  \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
+  \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
+  \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
+  \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
+  \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
+  \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
+  \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
+  \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
+  \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
+
+  \DeclareUnicodeCharacter{1E7C}{\~V}
+  \DeclareUnicodeCharacter{1E7D}{\~v}
+  \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
+  \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
+
+  \DeclareUnicodeCharacter{1E80}{\`W}
+  \DeclareUnicodeCharacter{1E81}{\`w}
+  \DeclareUnicodeCharacter{1E82}{\'W}
+  \DeclareUnicodeCharacter{1E83}{\'w}
+  \DeclareUnicodeCharacter{1E84}{\"W}
+  \DeclareUnicodeCharacter{1E85}{\"w}
+  \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
+  \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
+  \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
+  \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
+  \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
+  \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
+  \DeclareUnicodeCharacter{1E8C}{\"X}
+  \DeclareUnicodeCharacter{1E8D}{\"x}
+  \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
+  \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
+
+  \DeclareUnicodeCharacter{1E90}{\^Z}
+  \DeclareUnicodeCharacter{1E91}{\^z}
+  \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
+  \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
+  \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
+  \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
+  \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
+  \DeclareUnicodeCharacter{1E97}{\"t}
+  \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
+  \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
+
+  \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
+  \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
+
+  \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
+  \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
+  \DeclareUnicodeCharacter{1EBC}{\~E}
+  \DeclareUnicodeCharacter{1EBD}{\~e}
+
+  \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
+  \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
+  \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
+  \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
+
+  \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
+  \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
+
+  \DeclareUnicodeCharacter{1EF2}{\`Y}
+  \DeclareUnicodeCharacter{1EF3}{\`y}
+  \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
+
+  \DeclareUnicodeCharacter{1EF8}{\~Y}
+  \DeclareUnicodeCharacter{1EF9}{\~y}
+
+  \DeclareUnicodeCharacter{2013}{--}
+  \DeclareUnicodeCharacter{2014}{---}
+  \DeclareUnicodeCharacter{2018}{\quoteleft}
+  \DeclareUnicodeCharacter{2019}{\quoteright}
+  \DeclareUnicodeCharacter{201A}{\quotesinglbase}
+  \DeclareUnicodeCharacter{201C}{\quotedblleft}
+  \DeclareUnicodeCharacter{201D}{\quotedblright}
+  \DeclareUnicodeCharacter{201E}{\quotedblbase}
+  \DeclareUnicodeCharacter{2022}{\bullet}
+  \DeclareUnicodeCharacter{2026}{\dots}
+  \DeclareUnicodeCharacter{2039}{\guilsinglleft}
+  \DeclareUnicodeCharacter{203A}{\guilsinglright}
+  \DeclareUnicodeCharacter{20AC}{\euro}
+
+  \DeclareUnicodeCharacter{2192}{\expansion}
+  \DeclareUnicodeCharacter{21D2}{\result}
+
+  \DeclareUnicodeCharacter{2212}{\minus}
+  \DeclareUnicodeCharacter{2217}{\point}
+  \DeclareUnicodeCharacter{2261}{\equiv}
+}% end of \utfeightchardefs
+
+
+% US-ASCII character definitions.
+\def\asciichardefs{% nothing need be done
+   \relax
+}
+
+% Make non-ASCII characters printable again for compatibility with
+% existing Texinfo documents that may use them, even without declaring a
+% document encoding.
+%
+\setnonasciicharscatcode \other
+
+
+\message{formatting,}
+
 \newdimen\defaultparindent \defaultparindent = 15pt
 
 \chapheadingskip = 15pt plus 4pt minus 2pt
@@ -6840,7 +8898,7 @@ should work if nowhere else does.}
 % Don't be so finicky about underfull hboxes, either.
 \hbadness = 2000
 
-% Following George Bush, just get rid of widows and orphans.
+% Following George Bush, get rid of widows and orphans.
 \widowpenalty=10000
 \clubpenalty=10000
 
@@ -6887,6 +8945,10 @@ should work if nowhere else does.}
   \ifpdf
     \pdfpageheight #7\relax
     \pdfpagewidth #8\relax
+    % if we don't reset these, they will remain at "1 true in" of
+    % whatever layout pdftex was dumped with.
+    \pdfhorigin = 1 true in
+    \pdfvorigin = 1 true in
   \fi
   %
   \setleading{\textleading}
@@ -6901,7 +8963,7 @@ should work if nowhere else does.}
   \textleading = 13.2pt
   %
   % If page is nothing but text, make it come out even.
-  \internalpagesizes{46\baselineskip}{6in}%
+  \internalpagesizes{607.2pt}{6in}% that's 46 lines
                     {\voffset}{.25in}%
                     {\bindingoffset}{36pt}%
                     {11in}{8.5in}%
@@ -6913,7 +8975,7 @@ should work if nowhere else does.}
   \textleading = 12pt
   %
   \internalpagesizes{7.5in}{5in}%
-                    {\voffset}{.25in}%
+                    {-.2in}{0in}%
                     {\bindingoffset}{16pt}%
                     {9.25in}{7in}%
   %
@@ -6957,7 +9019,7 @@ should work if nowhere else does.}
   % \global\normaloffset = -6mm
   % \global\bindingoffset = 10mm
   % @end tex
-  \internalpagesizes{51\baselineskip}{160mm}
+  \internalpagesizes{673.2pt}{160mm}% that's 51 lines
                     {\voffset}{\hoffset}%
                     {\bindingoffset}{44pt}%
                     {297mm}{210mm}%
@@ -7022,7 +9084,7 @@ should work if nowhere else does.}
   \parskip = 3pt plus 2pt minus 1pt
   \setleading{\textleading}%
   %
-  \dimen0 = #1
+  \dimen0 = #1\relax
   \advance\dimen0 by \voffset
   %
   \dimen2 = \hsize
@@ -7041,6 +9103,9 @@ should work if nowhere else does.}
 
 \message{and turning on texinfo input format.}
 
+% DEL is a comment character, in case @c does not suffice.
+\catcode`\^^? = 14
+
 % Define macros to output various characters with catcode for normal text.
 \catcode`\"=\other
 \catcode`\~=\other
@@ -7117,6 +9182,13 @@ should work if nowhere else does.}
 % \otherifyactive is called near the end of this file.
 \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
 
+% Used sometimes to turn off (effectively) the active characters even after
+% parsing them.
+\def\turnoffactive{%
+  \normalturnoffactive
+  \otherbackslash
+}
+
 \catcode`\@=0
 
 % \backslashcurfont outputs one backslash character in current font,
@@ -7124,28 +9196,29 @@ should work if nowhere else does.}
 \global\chardef\backslashcurfont=`\\
 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
 
-% \rawbackslash defines an active \ to do \backslashcurfont.
-% \otherbackslash defines an active \ to be a literal `\' character with
-% catcode other.
-{\catcode`\\=\active
- @gdef at rawbackslash{@let\=@backslashcurfont}
- @gdef at otherbackslash{@let\=@realbackslash}
-}
-
 % \realbackslash is an actual character `\' with catcode other, and
 % \doublebackslash is two of them (for the pdf outlines).
 {\catcode`\\=\other @gdef at realbackslash{\} @gdef at doublebackslash{\\}}
 
-% \normalbackslash outputs one backslash in fixed width font.
-\def\normalbackslash{{\tt\backslashcurfont}}
-
+% In texinfo, backslash is an active character; it prints the backslash
+% in fixed width font.
 \catcode`\\=\active
+ at def@normalbackslash{{@tt at backslashcurfont}}
+% On startup, @fixbackslash assigns:
+%  @let \ = @normalbackslash
+
+% \rawbackslash defines an active \ to do \backslashcurfont.
+% \otherbackslash defines an active \ to be a literal `\' character with
+% catcode other.
+ at gdef@rawbackslash{@let\=@backslashcurfont}
+ at gdef@otherbackslash{@let\=@realbackslash}
 
-% Used sometimes to turn off (effectively) the active characters
-% even after parsing them.
- at def@turnoffactive{%
+% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
+% the literal character `\'.
+%
+ at def@normalturnoffactive{%
+  @let\=@normalbackslash
   @let"=@normaldoublequote
-  @let\=@realbackslash
   @let~=@normaltilde
   @let^=@normalcaret
   @let_=@normalunderscore
@@ -7154,15 +9227,11 @@ should work if nowhere else does.}
   @let>=@normalgreater
   @let+=@normalplus
   @let$=@normaldollar %$ font-lock fix
+  @markupsetuplqdefault
+  @markupsetuprqdefault
   @unsepspaces
 }
 
-% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
-% the literal character `\'.  (Thus, \ is not expandable when this is in
-% effect.)
-%
- at def@normalturnoffactive{@turnoffactive @let\=@normalbackslash}
-
 % Make _ and + \other characters, temporarily.
 % This is canceled by @fixbackslash.
 @otherifyactive
@@ -7175,7 +9244,7 @@ should work if nowhere else does.}
 @global at let\ = @eatinput
 
 % On the other hand, perhaps the file did not have a `\input texinfo'. Then
-% the first `\{ in the file would cause an error. This macro tries to fix
+% the first `\' in the file would cause an error. This macro tries to fix
 % that, assuming it is called before the first `\' could plausibly occur.
 % Also turn back on active characters that might appear in the input
 % file name, in case not using a pre-dumped format.
@@ -7194,9 +9263,21 @@ should work if nowhere else does.}
 @catcode`@# = @other
 @catcode`@% = @other
 
+ at c Finally, make ` and ' active, so that txicodequoteundirected and
+ at c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
+ at c don't make ` and ' active, @code will not get them as active chars.
+ at c Do this last of all since we use ` in the previous @catcode assignments.
+ at catcode`@'=@active
+ at catcode`@`=@active
+ at markupsetuplqdefault
+ at markupsetuprqdefault
+
+ at c Gnulib now utterly and painfully insists on no trailing whitespace.
+ at c So we have to nuke it.
 
 @c Local variables:
 @c eval: (add-hook 'write-file-hooks 'time-stamp)
+ at c eval: (add-hook 'write-file-hooks 'nuke-trailing-whitespace)
 @c page-delimiter: "^\\\\message"
 @c time-stamp-start: "def\\\\texinfoversion{"
 @c time-stamp-format: "%:y-%02m-%02d.%02H"
diff --git a/doc/version.texi b/doc/version.texi
index 5da139a..a391247 100644
--- a/doc/version.texi
+++ b/doc/version.texi
@@ -1,4 +1,4 @@
- at set UPDATED 2 May 2007
- at set UPDATED-MONTH May 2007
- at set EDITION 1.0-alpha4
- at set VERSION 1.0-alpha4
+ at set UPDATED 15 September 2009
+ at set UPDATED-MONTH September 2009
+ at set EDITION 1.0-alpha5
+ at set VERSION 1.0-alpha5
diff --git a/gridspec/Makefile.am b/gridspec/Makefile.am
new file mode 100644
index 0000000..486effd
--- /dev/null
+++ b/gridspec/Makefile.am
@@ -0,0 +1,8 @@
+# This is an automake file, part of libcf, a NetCDF CF Library
+# package. Libcf is developed by Ed Hartnett at Unidata, copyright
+# 2009; GRIDSPEC code is developed by Zhi Liang, GFDL, copyright 2008.
+# See the COPYRIGHT file for more information.
+
+# $Id: Makefile.am,v 1.2 2009/11/21 12:58:06 ed Exp $
+
+SUBDIRS = shared tools
\ No newline at end of file
diff --git a/gridspec_tools_20080702/Makefile.in b/gridspec/Makefile.in
similarity index 75%
rename from gridspec_tools_20080702/Makefile.in
rename to gridspec/Makefile.in
index 916e8da..1051cd5 100644
--- a/gridspec_tools_20080702/Makefile.in
+++ b/gridspec/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -13,10 +14,18 @@
 # PARTICULAR PURPOSE.
 
 @SET_MAKE@
+
+# This is an automake file, part of libcf, a NetCDF CF Library
+# package. Libcf is developed by Ed Hartnett at Unidata, copyright
+# 2009; GRIDSPEC code is developed by Zhi Liang, GFDL, copyright 2008.
+# See the COPYRIGHT file for more information.
+
+# $Id: Makefile.am,v 1.2 2009/11/21 12:58:06 ed Exp $
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -31,7 +40,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = gridspec_tools_20080702
+subdir = gridspec
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -43,6 +52,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -54,10 +64,38 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
 	ps-recursive uninstall-recursive
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
 AMTAR = @AMTAR@
@@ -70,7 +108,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -87,12 +124,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -108,13 +144,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -131,8 +166,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -177,7 +213,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -196,14 +231,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -221,6 +256,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -252,7 +288,7 @@ $(RECURSIVE_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done; \
 	if test "$$dot_seen" = "no"; then \
@@ -286,16 +322,16 @@ $(RECURSIVE_CLEAN_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done && test -z "$$fail"
 tags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 	done
 ctags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
 	done
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
@@ -303,14 +339,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
 	  include_option=--etags-include; \
@@ -322,7 +358,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test ! -f $$subdir/TAGS || \
-	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
@@ -331,29 +367,34 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -374,29 +415,44 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
-	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test -d "$(distdir)/$$subdir" \
 	    || $(MKDIR_P) "$(distdir)/$$subdir" \
 	    || exit 1; \
-	    distdir=`$(am__cd) $(distdir) && pwd`; \
-	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
-	    (cd $$subdir && \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
 	      $(MAKE) $(AM_MAKEFLAGS) \
-	        top_distdir="$$top_distdir" \
-	        distdir="$$distdir/$$subdir" \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
 		am__remove_distdir=: \
 		am__skip_length_check=: \
+		am__skip_mode_fix=: \
 	        distdir) \
 	      || exit 1; \
 	  fi; \
@@ -426,6 +482,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -444,6 +501,8 @@ dvi-am:
 
 html: html-recursive
 
+html-am:
+
 info: info-recursive
 
 info-am:
@@ -452,18 +511,28 @@ install-data-am:
 
 install-dvi: install-dvi-recursive
 
+install-dvi-am:
+
 install-exec-am:
 
 install-html: install-html-recursive
 
+install-html-am:
+
 install-info: install-info-recursive
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-recursive
 
+install-pdf-am:
+
 install-ps: install-ps-recursive
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-recursive
@@ -484,8 +553,8 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
-	install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+	install-am install-strip tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
 	all all-am check check-am clean clean-generic clean-libtool \
@@ -501,6 +570,7 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
 	uninstall uninstall-am
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec/shared/Makefile.am b/gridspec/shared/Makefile.am
new file mode 100644
index 0000000..f246388
--- /dev/null
+++ b/gridspec/shared/Makefile.am
@@ -0,0 +1,6 @@
+# This is an automake file, part of libcf, a NetCDF CF Library
+# package. Libcf is developed by Ed Hartnett at Unidata, copyright
+# 2009; GRIDSPEC code is developed by Zhi Liang, GFDL, copyright 2008.
+# See the COPYRIGHT file for more information.
+
+SUBDIRS = mosaic
\ No newline at end of file
diff --git a/gridspec_tools_20080702/shared/Makefile.in b/gridspec/shared/Makefile.in
similarity index 76%
rename from gridspec_tools_20080702/shared/Makefile.in
rename to gridspec/shared/Makefile.in
index 5c2115c..3d20fc1 100644
--- a/gridspec_tools_20080702/shared/Makefile.in
+++ b/gridspec/shared/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -13,10 +14,16 @@
 # PARTICULAR PURPOSE.
 
 @SET_MAKE@
+
+# This is an automake file, part of libcf, a NetCDF CF Library
+# package. Libcf is developed by Ed Hartnett at Unidata, copyright
+# 2009; GRIDSPEC code is developed by Zhi Liang, GFDL, copyright 2008.
+# See the COPYRIGHT file for more information.
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -31,7 +38,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = gridspec_tools_20080702/shared
+subdir = gridspec/shared
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -43,6 +50,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -54,10 +62,38 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
 	ps-recursive uninstall-recursive
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
 AMTAR = @AMTAR@
@@ -70,7 +106,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -87,12 +122,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -108,13 +142,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -131,8 +164,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -177,7 +211,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -196,14 +229,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/shared/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/shared/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/shared/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/shared/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -221,6 +254,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -252,7 +286,7 @@ $(RECURSIVE_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done; \
 	if test "$$dot_seen" = "no"; then \
@@ -286,16 +320,16 @@ $(RECURSIVE_CLEAN_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done && test -z "$$fail"
 tags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 	done
 ctags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
 	done
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
@@ -303,14 +337,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
 	  include_option=--etags-include; \
@@ -322,7 +356,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test ! -f $$subdir/TAGS || \
-	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
@@ -331,29 +365,34 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -374,29 +413,44 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
-	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test -d "$(distdir)/$$subdir" \
 	    || $(MKDIR_P) "$(distdir)/$$subdir" \
 	    || exit 1; \
-	    distdir=`$(am__cd) $(distdir) && pwd`; \
-	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
-	    (cd $$subdir && \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
 	      $(MAKE) $(AM_MAKEFLAGS) \
-	        top_distdir="$$top_distdir" \
-	        distdir="$$distdir/$$subdir" \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
 		am__remove_distdir=: \
 		am__skip_length_check=: \
+		am__skip_mode_fix=: \
 	        distdir) \
 	      || exit 1; \
 	  fi; \
@@ -426,6 +480,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -444,6 +499,8 @@ dvi-am:
 
 html: html-recursive
 
+html-am:
+
 info: info-recursive
 
 info-am:
@@ -452,18 +509,28 @@ install-data-am:
 
 install-dvi: install-dvi-recursive
 
+install-dvi-am:
+
 install-exec-am:
 
 install-html: install-html-recursive
 
+install-html-am:
+
 install-info: install-info-recursive
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-recursive
 
+install-pdf-am:
+
 install-ps: install-ps-recursive
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-recursive
@@ -484,8 +551,8 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
-	install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+	install-am install-strip tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
 	all all-am check check-am clean clean-generic clean-libtool \
@@ -501,6 +568,7 @@ uninstall-am:
 	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
 	uninstall uninstall-am
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec/shared/mosaic/Makefile.am b/gridspec/shared/mosaic/Makefile.am
new file mode 100644
index 0000000..f8f0415
--- /dev/null
+++ b/gridspec/shared/mosaic/Makefile.am
@@ -0,0 +1,71 @@
+# This is an automake file, part of libcf, a NetCDF CF Library
+# package. Libcf is developed by Ed Hartnett at Unidata, copyright
+# 2009; GRIDSPEC code is developed by Zhi Liang, GFDL, copyright 2008.
+# See the COPYRIGHT file for more information.
+
+# This automake file is in charge of building the gridspec
+# tools/shared convenience library.
+
+# $Id: Makefile.am,v 1.3 2009/09/10 16:30:14 ed Exp $
+
+noinst_LTLIBRARIES = libshared.la 
+libshared_la_SOURCES = constant.h create_xgrid.c create_xgrid.h	\
+gradient_c2l.c gradient_c2l.h interp.c interp.h mosaic_util.c	\
+mosaic_util.h read_mosaic.c read_mosaic.h
+
+AM_CPPFLAGS = 
+AM_LDFLAGS =
+LDADD = -lm
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
+
+
+
+
diff --git a/gridspec_tools_20080702/shared/mosaic/Makefile.in b/gridspec/shared/mosaic/Makefile.in
similarity index 77%
rename from gridspec_tools_20080702/shared/mosaic/Makefile.in
rename to gridspec/shared/mosaic/Makefile.in
index 76f6abb..28b8c8c 100644
--- a/gridspec_tools_20080702/shared/mosaic/Makefile.in
+++ b/gridspec/shared/mosaic/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,15 +15,21 @@
 
 @SET_MAKE@
 
+# This is an automake file, part of libcf, a NetCDF CF Library
+# package. Libcf is developed by Ed Hartnett at Unidata, copyright
+# 2009; GRIDSPEC code is developed by Zhi Liang, GFDL, copyright 2008.
+# See the COPYRIGHT file for more information.
+
 # This automake file is in charge of building the gridspec
 # tools/shared convenience library.
 
-# $Id: Makefile.am,v 1.1 2009/04/03 15:02:15 ed Exp $
+# $Id: Makefile.am,v 1.3 2009/09/10 16:30:14 ed Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -37,15 +44,34 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-
-# If the user specified a root location for NETCDF, use it.
 @USE_NETCDF_DIR_TRUE at am__append_1 = -I at NETCDFDIR@/include
 @USE_NETCDF_DIR_TRUE at am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-subdir = gridspec_tools_20080702/shared/mosaic
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/shared/mosaic
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -57,6 +83,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libshared_la_LIBADD =
 am_libshared_la_OBJECTS = create_xgrid.lo gradient_c2l.lo interp.lo \
@@ -65,6 +92,7 @@ libshared_la_OBJECTS = $(am_libshared_la_OBJECTS)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -91,7 +119,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -108,12 +135,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -129,13 +155,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -152,8 +177,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -198,7 +224,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -214,9 +239,14 @@ libshared_la_SOURCES = constant.h create_xgrid.c create_xgrid.h	\
 gradient_c2l.c gradient_c2l.h interp.c interp.h mosaic_util.c	\
 mosaic_util.h read_mosaic.c read_mosaic.h
 
-AM_CPPFLAGS = $(am__append_1) $(am__append_3)
-AM_LDFLAGS = $(am__append_2) $(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
+AM_CPPFLAGS = $(am__append_1) $(am__append_5) $(am__append_8) \
+	$(am__append_12) $(am__append_14) $(am__append_16) \
+	$(am__append_18)
+AM_LDFLAGS = $(am__append_2) $(am__append_6) $(am__append_9) \
+	$(am__append_13) $(am__append_15) $(am__append_17) \
+	$(am__append_19)
+LDADD = -lm $(am__append_3) $(am__append_4) $(am__append_7) \
+	$(am__append_10) $(am__append_11)
 all: all-am
 
 .SUFFIXES:
@@ -225,14 +255,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/shared/mosaic/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/shared/mosaic/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/shared/mosaic/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/shared/mosaic/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -250,6 +280,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 
 clean-noinstLTLIBRARIES:
 	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@@ -277,7 +308,7 @@ distclean-compile:
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -285,7 +316,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -293,7 +324,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -309,14 +340,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -324,29 +355,34 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -367,13 +403,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -401,6 +441,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -422,6 +463,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -430,18 +473,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am:
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -479,6 +532,7 @@ uninstall-am:
 	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
 	pdf pdf-am ps ps-am tags uninstall uninstall-am
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec/shared/mosaic/constant.h b/gridspec/shared/mosaic/constant.h
new file mode 100644
index 0000000..7a6b5b5
--- /dev/null
+++ b/gridspec/shared/mosaic/constant.h
@@ -0,0 +1,38 @@
+#ifndef CONSTANT_H_
+#define CONSTANT_H_
+#define RADIUS        (6371000.)
+#define STRING        255
+#define STRING_NAME        "string"
+#define MOSAIC_NAME        "mosaic"
+#define NTILES_NAME        "ntiles"
+#define NMOSAIC_NAME       "nmosaic"
+#define NCONTACT_NAME      "ncontact"
+#define TILE_FILES_NAME    "tile_files"
+#define MOSAIC_FILES_NAME  "mosaic_files"
+#define CONTACT_FILES_NAME "contact_files"
+#define OVERLAP_FILES_NAME "overlap_files"
+#define TILE_NAME          "tile"
+#define NX_NAME            "nx"
+#define NY_NAME            "ny"
+#define NXP_NAME           "nxp"
+#define NYP_NAME           "nyp"
+#define X_NAME             "x"
+#define Y_NAME             "y"
+#define DX_NAME            "dx"
+#define DY_NAME            "dy"
+#define ANGLE_DX_NAME      "angle_dx"
+#define ANGLE_DY_NAME      "angle_dy"
+#define ARCX_NAME          "arcx"
+#define DEPTH_NAME         "depth"
+#define MASK_NAME          "area_frac"
+#define NZV_NAME           "nzv"
+#define ZETA_NAME          "zeta"
+#define GRID_VERSION_NAME  "grid_version"
+#define CODE_VERSION_NAME  "code_version"
+#define HISTORY_NAME       "history"
+#define CONFORMAL_NAME     "isConformal"
+#define REGULAR_NAME       "isRegular"
+#define DISCRETIZATION_NAME "discretizationType"
+#define GEOMETRY_NAME       "geometryType"
+#define CONGRUCENCE_NAME    "congruentTiles"
+#endif
diff --git a/gridspec_tools_20080702/shared/mosaic/create_xgrid.c b/gridspec/shared/mosaic/create_xgrid.c
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/create_xgrid.c
rename to gridspec/shared/mosaic/create_xgrid.c
diff --git a/gridspec_tools_20080702/shared/mosaic/create_xgrid.h b/gridspec/shared/mosaic/create_xgrid.h
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/create_xgrid.h
rename to gridspec/shared/mosaic/create_xgrid.h
diff --git a/gridspec_tools_20080702/shared/mosaic/gradient_c2l.c b/gridspec/shared/mosaic/gradient_c2l.c
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/gradient_c2l.c
rename to gridspec/shared/mosaic/gradient_c2l.c
diff --git a/gridspec_tools_20080702/shared/mosaic/gradient_c2l.h b/gridspec/shared/mosaic/gradient_c2l.h
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/gradient_c2l.h
rename to gridspec/shared/mosaic/gradient_c2l.h
diff --git a/gridspec_tools_20080702/shared/mosaic/interp.c b/gridspec/shared/mosaic/interp.c
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/interp.c
rename to gridspec/shared/mosaic/interp.c
diff --git a/gridspec_tools_20080702/shared/mosaic/interp.h b/gridspec/shared/mosaic/interp.h
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/interp.h
rename to gridspec/shared/mosaic/interp.h
diff --git a/gridspec_tools_20080702/shared/mosaic/mosaic_util.c b/gridspec/shared/mosaic/mosaic_util.c
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/mosaic_util.c
rename to gridspec/shared/mosaic/mosaic_util.c
diff --git a/gridspec_tools_20080702/shared/mosaic/mosaic_util.h b/gridspec/shared/mosaic/mosaic_util.h
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/mosaic_util.h
rename to gridspec/shared/mosaic/mosaic_util.h
diff --git a/gridspec_tools_20080702/shared/mosaic/read_mosaic.c b/gridspec/shared/mosaic/read_mosaic.c
similarity index 92%
rename from gridspec_tools_20080702/shared/mosaic/read_mosaic.c
rename to gridspec/shared/mosaic/read_mosaic.c
index cc82b25..e5ce4df 100644
--- a/gridspec_tools_20080702/shared/mosaic/read_mosaic.c
+++ b/gridspec/shared/mosaic/read_mosaic.c
@@ -4,6 +4,7 @@
 #include <string.h>
 #include "read_mosaic.h"
 #include "constant.h"
+#include "mosaic_util.h"
 #ifdef use_netCDF
 #include <netcdf.h>
 #endif
@@ -47,6 +48,36 @@ void get_file_dir(const char *file, char *dir)
 }; /* get_file_dir */
 
 
+int field_exist(const char* file, const char *name)
+{
+  int ncid, varid, status, existed;
+  char msg[512];  
+#ifdef use_netCDF
+  status = nc_open(file, NC_NOWRITE, &ncid);
+  if(status != NC_NOERR) {
+    sprintf(msg, "field_exist: in opening file %s", file);
+    handle_netcdf_error(msg, status);
+  }
+  status = nc_inq_varid(ncid, name, &varid);  
+  if(status == NC_NOERR)
+    existed = 1;
+  else
+    existed = 0;
+    
+  status = nc_close(ncid);
+  if(status != NC_NOERR) {
+    sprintf(msg, "field_exist: in closing file %s.", file);
+    handle_netcdf_error(msg, status);
+  }
+
+  return existed;
+#else
+  error_handler("read_mosaic: Add flag -Duse_netCDF when compiling");
+
+#endif
+  return 0; 
+}; /* field_exist */
+
 int get_dimlen(const char* file, const char *name)
 {
   int ncid, dimid, status, len;
@@ -78,7 +109,7 @@ int get_dimlen(const char* file, const char *name)
   
   len = size;
   if(status != NC_NOERR) {
-    sprintf(msg, "in closing file ", file);
+    sprintf(msg, "in closing file %s", file);
     handle_netcdf_error(msg, status);
   }
 #else
@@ -216,7 +247,7 @@ void get_double_data(const char *file, const char *name, double *data)
 #ifdef use_netCDF    
   status = nc_open(file, NC_NOWRITE, &ncid);
   if(status != NC_NOERR) {
-    sprintf(msg, "in opening file ", file);
+    sprintf(msg, "in opening file %s", file);
     handle_netcdf_error(msg, status);
   }
   status = nc_inq_varid(ncid, name, &varid);
@@ -252,7 +283,7 @@ void get_var_text_att(const char *file, const char *name, const char *attname, c
 #ifdef use_netCDF    
   status = nc_open(file, NC_NOWRITE, &ncid);
   if(status != NC_NOERR) {
-    sprintf(msg, "in opening file ", file);
+    sprintf(msg, "in opening file %s", file);
     handle_netcdf_error(msg, status);
   }
   status = nc_inq_varid(ncid, name, &varid);
@@ -410,11 +441,18 @@ int read_mosaic_ncontacts_(const char *mosaic_file)
 #endif
 int read_mosaic_ncontacts(const char *mosaic_file)
 {
-
+  char contact_file[STRING], file[STRING], dir[STRING];
   int ncontacts;
 
-  ncontacts = get_dimlen(mosaic_file, "ncontact");
-
+  if(field_exist(mosaic_file, CONTACT_FILES_NAME) ) {
+    get_file_dir(mosaic_file, dir);
+    get_string_data(mosaic_file, CONTACT_FILES_NAME, file);
+    sprintf(contact_file, "%s/%s", dir, file);
+    ncontacts = get_dimlen(contact_file, NCONTACT_NAME);
+  }
+  else
+    ncontacts = 0;
+  
   return ncontacts;
   
 }; /* read_mosaic_ncontacts */
@@ -469,23 +507,29 @@ void read_mosaic_contact_(const char *mosaic_file, int *tile1, int *tile2, int *
 void read_mosaic_contact(const char *mosaic_file, int *tile1, int *tile2, int *istart1, int *iend1,
 			 int *jstart1, int *jend1, int *istart2, int *iend2, int *jstart2, int *jend2)
 {
-  char contacts[STRING];
+  char contacts[STRING], tilefile[STRING], tilepath[STRING];
   char **gridtiles;
 #define MAXVAR 40
   char pstring[MAXVAR][STRING];
   int ntiles, ncontacts, n, m, l, nstr, found;
   const int x_refine = 2, y_refine = 2;
-  
+  char contact_file[STRING], file[STRING], dir[STRING];
+
+  get_file_dir(mosaic_file, dir);  
   ntiles = get_dimlen(mosaic_file, "ntiles");
   gridtiles = (char **)malloc(ntiles*sizeof(char *));
   for(n=0; n<ntiles; n++) {
     gridtiles[n] = (char *)malloc(STRING*sizeof(char));
-    get_string_data_level(mosaic_file, "gridtiles", gridtiles[n], &n);
+    get_string_data_level(mosaic_file,  TILE_FILES_NAME, tilefile, &n);
+    sprintf(tilepath,"%s/%s", dir, tilefile);
+    get_string_data(tilepath, TILE_NAME, gridtiles[n]);
   }
-    
-  ncontacts = get_dimlen(mosaic_file, "ncontact"); 
+
+  get_string_data(mosaic_file, CONTACT_FILES_NAME, file);
+  sprintf(contact_file, "%s/%s", dir, file);    
+  ncontacts = get_dimlen(contact_file, NCONTACT_NAME);
   for(n = 0; n < ncontacts; n++) {
-    get_string_data_level(mosaic_file, "contacts", contacts, &n);
+    get_string_data_level(contact_file, "contacts", contacts, &n);
     /* parse the string contacts to get tile number */
     tokenize( contacts, ":", STRING, MAXVAR, pstring, &nstr);
     if(nstr != 4) error_handler("Error from read_mosaic: number of elements "
@@ -510,7 +554,7 @@ void read_mosaic_contact(const char *mosaic_file, int *tile1, int *tile2, int *i
     }
     if(!found) error_handler("error from read_mosaic: the second tile name specified "
 			     "in contact is not found in tile list");    
-    get_string_data_level(mosaic_file, "contact_index", contacts, &n);
+    get_string_data_level(contact_file, "contact_index", contacts, &n);
     /* parse the string to get contact index */
     tokenize( contacts, ":,", STRING, MAXVAR, pstring, &nstr);
     if(nstr != 8) error_handler("Error from read_mosaic: number of elements "
diff --git a/gridspec_tools_20080702/shared/mosaic/read_mosaic.h b/gridspec/shared/mosaic/read_mosaic.h
similarity index 100%
rename from gridspec_tools_20080702/shared/mosaic/read_mosaic.h
rename to gridspec/shared/mosaic/read_mosaic.h
diff --git a/gridspec/tools/Makefile.am b/gridspec/tools/Makefile.am
new file mode 100644
index 0000000..7e4387a
--- /dev/null
+++ b/gridspec/tools/Makefile.am
@@ -0,0 +1,12 @@
+SUBDIRS = shared make_hgrid make_vgrid make_mosaic fregrid make_topog	\
+make_coupler_mosaic
+
+# These tests must be turned on with --enable-gridspec-file-tests.
+if BUILD_GRIDSPEC_FILE_TESTS
+TESTS = get_data.sh test.sh test_all.sh
+endif
+
+EXTRA_DIST = test.sh test_all.sh get_data.sh
+CLEANFILES = *.nc
+
+
diff --git a/gridspec_tools_20080702/tools/Makefile.in b/gridspec/tools/Makefile.in
similarity index 61%
rename from gridspec_tools_20080702/tools/Makefile.in
rename to gridspec/tools/Makefile.in
index 1391d7f..85ebdec 100644
--- a/gridspec_tools_20080702/tools/Makefile.in
+++ b/gridspec/tools/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,8 +16,9 @@
 @SET_MAKE@
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -31,7 +33,7 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-subdir = gridspec_tools_20080702/tools
+subdir = gridspec/tools
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -43,6 +45,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -54,10 +57,40 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
 	ps-recursive uninstall-recursive
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir
 ETAGS = etags
 CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
 DIST_SUBDIRS = $(SUBDIRS)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
 AMTAR = @AMTAR@
@@ -70,7 +103,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -87,12 +119,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -108,13 +139,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -131,8 +161,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -177,7 +208,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -188,9 +218,14 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-SUBDIRS = shared make_hgrid make_solo_mosaic make_coupler_mosaic	\
-make_topog make_vgrid river_regrid transfer_to_mosaic_grid fregrid
+SUBDIRS = shared make_hgrid make_vgrid make_mosaic fregrid make_topog	\
+make_coupler_mosaic
 
+
+# These tests must be turned on with --enable-gridspec-file-tests.
+ at BUILD_GRIDSPEC_FILE_TESTS_TRUE@TESTS = get_data.sh test.sh test_all.sh
+EXTRA_DIST = test.sh test_all.sh get_data.sh
+CLEANFILES = *.nc
 all: all-recursive
 
 .SUFFIXES:
@@ -198,14 +233,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -223,6 +258,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -254,7 +290,7 @@ $(RECURSIVE_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done; \
 	if test "$$dot_seen" = "no"; then \
@@ -288,16 +324,16 @@ $(RECURSIVE_CLEAN_TARGETS):
 	  else \
 	    local_target="$$target"; \
 	  fi; \
-	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 	  || eval $$failcom; \
 	done && test -z "$$fail"
 tags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 	done
 ctags-recursive:
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
 	done
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
@@ -305,14 +341,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
 	  include_option=--etags-include; \
@@ -324,7 +360,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test ! -f $$subdir/TAGS || \
-	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
@@ -333,33 +369,130 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	$(am__tty_colors); \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=XPASS; \
+	      ;; \
+	      *) \
+		col=$$grn; res=PASS; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xfail=`expr $$xfail + 1`; \
+		col=$$lgn; res=XFAIL; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=FAIL; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      col=$$blu; res=SKIP; \
+	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
+	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="$$All$$all $$tests passed"; \
+	    else \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all $$tests failed"; \
+	    else \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes$$std"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
 distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -376,34 +509,50 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
-	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
 	    test -d "$(distdir)/$$subdir" \
 	    || $(MKDIR_P) "$(distdir)/$$subdir" \
 	    || exit 1; \
-	    distdir=`$(am__cd) $(distdir) && pwd`; \
-	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
-	    (cd $$subdir && \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
 	      $(MAKE) $(AM_MAKEFLAGS) \
-	        top_distdir="$$top_distdir" \
-	        distdir="$$distdir/$$subdir" \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
 		am__remove_distdir=: \
 		am__skip_length_check=: \
+		am__skip_mode_fix=: \
 	        distdir) \
 	      || exit 1; \
 	  fi; \
 	done
 check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
 check: check-recursive
 all-am: Makefile
 installdirs: installdirs-recursive
@@ -425,9 +574,11 @@ install-strip:
 mostlyclean-generic:
 
 clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -446,6 +597,8 @@ dvi-am:
 
 html: html-recursive
 
+html-am:
+
 info: info-recursive
 
 info-am:
@@ -454,18 +607,28 @@ install-data-am:
 
 install-dvi: install-dvi-recursive
 
+install-dvi-am:
+
 install-exec-am:
 
 install-html: install-html-recursive
 
+install-html-am:
+
 install-info: install-info-recursive
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-recursive
 
+install-pdf-am:
+
 install-ps: install-ps-recursive
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-recursive
@@ -486,22 +649,23 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
-	install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) check-am \
+	ctags-recursive install-am install-strip tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
-	all all-am check check-am clean clean-generic clean-libtool \
-	ctags ctags-recursive distclean distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs installdirs-am maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
-	uninstall uninstall-am
+	all all-am check check-TESTS check-am clean clean-generic \
+	clean-libtool ctags ctags-recursive distclean \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs installdirs-am \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags tags-recursive uninstall uninstall-am
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/gridspec/tools/fregrid/Makefile.am b/gridspec/tools/fregrid/Makefile.am
new file mode 100644
index 0000000..5549fbc
--- /dev/null
+++ b/gridspec/tools/fregrid/Makefile.am
@@ -0,0 +1,66 @@
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2009, see the COPYRIGHT file for more
+## information.
+
+# This automake file is in charge of building the gridspec
+# fregrid tool.
+
+# $Id: Makefile.am,v 1.4 2009/11/16 14:07:35 zhi Exp $
+
+bin_PROGRAMS = fregrid
+fregrid_SOURCES = fregrid.c
+
+# Initalize these.
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared	\
+-I$(top_srcdir)/gridspec/shared/mosaic
+AM_LDFLAGS = -L../shared -L../../shared/mosaic
+LDADD = -ltoolsshared -lshared -lnetcdf -lm
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
diff --git a/gridspec_tools_20080702/tools/fregrid/Makefile.in b/gridspec/tools/fregrid/Makefile.in
similarity index 69%
rename from gridspec_tools_20080702/tools/fregrid/Makefile.in
rename to gridspec/tools/fregrid/Makefile.in
index c6fb3bc..3784c9f 100644
--- a/gridspec_tools_20080702/tools/fregrid/Makefile.in
+++ b/gridspec/tools/fregrid/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,12 +18,13 @@
 # This automake file is in charge of building the gridspec
 # fregrid tool.
 
-# $Id: Makefile.am,v 1.2 2009/04/06 22:21:10 ed Exp $
+# $Id: Makefile.am,v 1.4 2009/11/16 14:07:35 zhi Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -37,21 +39,35 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-bin_PROGRAMS = fregrid$(EXEEXT) gs_fregrid$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
+bin_PROGRAMS = fregrid$(EXEEXT)
 @USE_NETCDF_DIR_TRUE at am__append_1 = -I at NETCDFDIR@/include
 @USE_NETCDF_DIR_TRUE at am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/fregrid
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/tools/fregrid
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -63,25 +79,19 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_fregrid_OBJECTS = bilinear_interp.$(OBJEXT) \
-	conserve_interp.$(OBJEXT) fregrid.$(OBJEXT) \
-	fregrid_util.$(OBJEXT)
+am_fregrid_OBJECTS = fregrid.$(OBJEXT)
 fregrid_OBJECTS = $(am_fregrid_OBJECTS)
 fregrid_LDADD = $(LDADD)
 am__DEPENDENCIES_1 =
-fregrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_gs_fregrid_OBJECTS = bilinear_interp.$(OBJEXT) \
-	conserve_interp.$(OBJEXT) gs_fregrid.$(OBJEXT) \
-	fregrid_util.$(OBJEXT)
-gs_fregrid_OBJECTS = $(am_gs_fregrid_OBJECTS)
-gs_fregrid_LDADD = $(LDADD)
-gs_fregrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
+fregrid_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__append_4) \
+	$(am__append_7) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -91,8 +101,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(fregrid_SOURCES) $(gs_fregrid_SOURCES)
-DIST_SOURCES = $(fregrid_SOURCES) $(gs_fregrid_SOURCES)
+SOURCES = $(fregrid_SOURCES)
+DIST_SOURCES = $(fregrid_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -108,7 +118,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -125,12 +134,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -146,13 +154,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -169,8 +176,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -215,7 +223,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -226,24 +233,19 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-fregrid_SOURCES = bilinear_interp.c bilinear_interp.h		\
-conserve_interp.c conserve_interp.h fregrid.c fregrid_util.c	\
-fregrid_util.h globals.h
-
-gs_fregrid_SOURCES = bilinear_interp.c bilinear_interp.h	\
-conserve_interp.c conserve_interp.h gs_fregrid.c fregrid_util.c	\
-fregrid_util.h globals.h
-
+fregrid_SOURCES = fregrid.c
 
 # Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared \
+	-I$(top_srcdir)/gridspec/shared/mosaic $(am__append_1) \
+	$(am__append_5) $(am__append_8) $(am__append_12) \
+	$(am__append_14) $(am__append_16) $(am__append_18)
 AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
+	$(am__append_6) $(am__append_9) $(am__append_13) \
+	$(am__append_15) $(am__append_17) $(am__append_19)
+LDADD = -ltoolsshared -lshared -lnetcdf -lm $(am__append_3) \
+	$(am__append_4) $(am__append_7) $(am__append_10) \
+	$(am__append_11)
 all: all-am
 
 .SUFFIXES:
@@ -252,14 +254,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/fregrid/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/fregrid/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/fregrid/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/fregrid/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -277,40 +279,53 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 
 clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
 fregrid$(EXEEXT): $(fregrid_OBJECTS) $(fregrid_DEPENDENCIES) 
 	@rm -f fregrid$(EXEEXT)
 	$(LINK) $(fregrid_OBJECTS) $(fregrid_LDADD) $(LIBS)
-gs_fregrid$(EXEEXT): $(gs_fregrid_OBJECTS) $(gs_fregrid_DEPENDENCIES) 
-	@rm -f gs_fregrid$(EXEEXT)
-	$(LINK) $(gs_fregrid_OBJECTS) $(gs_fregrid_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -318,16 +333,12 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/bilinear_interp.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/conserve_interp.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fregrid.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fregrid_util.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_fregrid.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -335,7 +346,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -343,7 +354,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -359,14 +370,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -374,29 +385,34 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -417,13 +433,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -454,6 +474,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -474,6 +495,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -482,18 +505,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -532,6 +565,7 @@ uninstall-am: uninstall-binPROGRAMS
 	pdf pdf-am ps ps-am tags uninstall uninstall-am \
 	uninstall-binPROGRAMS
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec_tools_20080702/tools/fregrid/fregrid.c b/gridspec/tools/fregrid/fregrid.c
similarity index 63%
rename from gridspec_tools_20080702/tools/fregrid/fregrid.c
rename to gridspec/tools/fregrid/fregrid.c
index bbc88e8..1ccc37a 100644
--- a/gridspec_tools_20080702/tools/fregrid/fregrid.c
+++ b/gridspec/tools/fregrid/fregrid.c
@@ -3,13 +3,10 @@
 #include <string.h>
 #include <getopt.h>
 #include <math.h>
+#include "mpp.h"
 #include "globals.h"
-#include "constant.h"
-#include "read_mosaic.h"
-#include "mpp_io.h"
-#include "conserve_interp.h"
-#include "bilinear_interp.h"
-#include "fregrid_util.h"
+#include "tool_util.h"
+#include "mosaic_util.h"
 
 char *usage[] = {
   "",
@@ -169,7 +166,6 @@ char *usage[] = {
   NULL};
 
 const double D2R = M_PI/180.;
-char tagname[] = "$Name:  $";
 
 int main(int argc, char* argv[])
 {
@@ -178,10 +174,8 @@ int main(int argc, char* argv[])
   char    *mosaic_out=NULL;           /* input mosaic file name */
   char    *dir_in=NULL;               /* input file location */
   char    *dir_out=NULL;              /* output file location */
-  int     ntiles_in = 0;              /* number of tiles in input mosaic */
-  int     ntiles_out = 0;             /* number of tiles in output mosaic */
-  int     nfiles     = 0;              /* number of input file */
-  int     nfiles_out = 0;             /* number of output file */
+  unsigned int nfiles     = 0;        /* number of input file */
+  unsigned int nfiles_out = 0;             /* number of output file */
   char    input_file [NFILE][STRING];
   char    output_file[NFILE][STRING];
   char    scalar_name[NVAR] [STRING];
@@ -199,7 +193,7 @@ int main(int argc, char* argv[])
   char    interp_method[STRING] = "conserve_order1";
   int     y_at_center = 0;
   int     grid_type = AGRID;
-  int     nscalar=0, nvector=0, nvector2;
+  unsigned int nscalar=0, nvector=0, nvector2=0;
   int     option_index, c, i, n, m, l;
   char    entry[MAXSTRING];  /* should be long enough */
   char    txt[STRING];
@@ -225,6 +219,7 @@ int main(int argc, char* argv[])
   
   int errflg = (argc == 1);
   int fid;
+   int ret;
   
   static struct option long_options[] = {
     {"input_mosaic",     required_argument, NULL, 'a'},
@@ -282,12 +277,12 @@ int main(int argc, char* argv[])
     case 'e':
       if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -e");
       strcpy(entry, optarg);
-      tokenize(entry, ",", STRING, NFILE, input_file, &nfiles);
+      tokenize(entry, ",", STRING, NFILE, (char *)input_file, &nfiles);
       break;
     case 'f':
       if(strlen(optarg) >= MAXSTRING)  mpp_error("fregrid: the entry is not long for option -f");      
       strcpy(entry, optarg);
-      tokenize(entry, ",", STRING, NFILE, output_file, &nfiles_out);
+      tokenize(entry, ",", STRING, NFILE, (char *)output_file, &nfiles_out);
       break;
     case 'g':
       remap_file = optarg;
@@ -295,17 +290,17 @@ int main(int argc, char* argv[])
     case 's':
       if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -s");      
       strcpy(entry, optarg);
-      tokenize(entry, ",", STRING, NVAR, scalar_name, &nscalar);
+      tokenize(entry, ",", STRING, NVAR, (char *)scalar_name, &nscalar);
       break;
     case 'u':
       if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -u");      
       strcpy(entry, optarg);
-      tokenize(entry, ",", STRING, NVAR, u_name, &nvector);
+      tokenize(entry, ",", STRING, NVAR, (char *)u_name, &nvector);
       break;        
     case 'v':
       if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -v");      
       strcpy(entry, optarg);
-      tokenize(entry, ",", STRING, NVAR, v_name, &nvector2);
+      tokenize(entry, ",", STRING, NVAR, (char *)v_name, &nvector2);
       break;      
     case 'j':
       strcpy(interp_method, optarg);
@@ -383,60 +378,9 @@ int main(int argc, char* argv[])
     while (*u) { fprintf(stderr, "%s\n", *u); u++; }
     exit(2);
   }      
-  /* check the arguments */
-  if( !mosaic_in  ) mpp_error("fregrid: input_mosaic is not specified");
-  if( !mosaic_out ) {
-    if(nlon == 0 || nlat ==0 ) mpp_error("fregrid: when output_mosaic is not specified, nlon and nlat should be specified");
-    if(lonend <= lonbegin) mpp_error("fregrid: when output_mosaic is not specified, lonEnd should be larger than lonBegin");
-    if(latend <= latbegin) mpp_error("fregrid: when output_mosaic is not specified, latEnd should be larger than latBegin");
-  }
-  else {
-    if(nlon !=0 || nlat != 0) mpp_error("fregrid: when output_mosaic is specified, nlon and nlat should not be specified");
-  }
-  
-  if( nfiles == 0) {
-    if(nvector > 0 || nscalar > 0 || nvector2 > 0)
-      mpp_error("fregrid: when --input_file is not specified, --scalar_field, --u_field and --v_field should also not be specified");
-    if(!remap_file) mpp_error("fregrid: when --input_file is not specified, remap_file must be specified to save weight information");
-    save_weight_only = 1;
-    if(mpp_pe()==mpp_root_pe())printf("NOTE: No input file specified in this run, no data file will be regridded "
-				      "and only weight information is calculated.\n");
-  }
-  else if( nfiles == 1 || nfiles ==2) {
-    if( nvector != nvector2 ) mpp_error("fregrid: number of fields specified in u_field must be the same as specified in v_field");
-    if( nscalar+nvector==0 ) mpp_error("fregrid: both scalar_field and vector_field are not specified");
-    /* when nvector =2 and nscalar=0, nfiles can be 2 otherwise nfiles must be 1 */
-    if( nscalar && nfiles != 1 )
-      mpp_error("fregrid: when scalar_field is specified, number of files must be 1");
-    if( nfiles_out == 0 ) {
-      for(i=0; i<nfiles; i++) strcpy(output_file[i], input_file[i]);
-    }
-    else if (nfiles_out != nfiles )
-      mpp_error("fregrid:number of input file is not equal to number of output file");
-  }
-  else
-    mpp_error("fregrid: number of input file should be 1 or 2");
-
-  if(kbegin != 0 || kend != -1) { /* at least one of kbegin and kend is set */
-    if(kbegin < 1 || kend < kbegin) mpp_error("fregrid:KlevelBegin should be a positive integer and no larger "
-					      "than KlevelEnd when you want pick certain klevel");
-  }
-  if(lbegin != 0 || lend != -1) { /* at least one of lbegin and lend is set */
-     if(lbegin < 1 || lend < lbegin) mpp_error("fregrid:LstepBegin should be a positive integer and no larger "
-					      "than LstepEnd when you want pick certain Lstep");
-  }
-  
-  if(nvector > 0) {
-    opcode |= VECTOR;
-    if(grid_type == AGRID)
-      opcode |= AGRID;
-    else if(grid_type == BGRID)
-      opcode |= BGRID;
-  }
   
   /* define history to be the history in the grid file */
   strcpy(history,argv[0]);
-
   for(i=1;i<argc;i++) {
     strcat(history, " ");
     if(strlen(argv[i]) > MAXENTRY) { /* limit the size of each entry, here we are assume the only entry that is longer than
@@ -449,220 +393,18 @@ int main(int argc, char* argv[])
       strcat(history, argv[i]);
   }
   
-  /* get the mosaic information of input and output mosaic*/
-  fid = mpp_open(mosaic_in, MPP_READ);
-  ntiles_in = mpp_get_dimlen(fid, "ntiles");
-  mpp_close(fid);
-  if(mosaic_out) {
-    fid = mpp_open(mosaic_out, MPP_READ);
-    ntiles_out = mpp_get_dimlen(fid, "ntiles");
-    mpp_close(fid);
-  }
-  else
-    ntiles_out = 1;
 
-  if(!strcmp(interp_method, "conserve_order1") ) {
-    if(mpp_pe() == mpp_root_pe())printf("****fregrid: first order conservative scheme will be used for regridding.\n");
-    opcode |= CONSERVE_ORDER1;
-  }
-  else if(!strcmp(interp_method, "conserve_order2") ) {
-    if(mpp_pe() == mpp_root_pe())printf("****fregrid: second order conservative scheme will be used for regridding.\n");
-    opcode |= CONSERVE_ORDER2;
-  }
-  else if(!strcmp(interp_method, "bilinear") ) {
-    if(mpp_pe() == mpp_root_pe())printf("****fregrid: bilinear remapping scheme will be used for regridding.\n");  
-    opcode |= BILINEAR;
-  }
-  else
-    mpp_error("fregrid: interp_method must be 'conserve_order1', 'conserve_order2' or 'bilinear'");
-
-  if(test_case) {
-    if(nfiles != 1) mpp_error("fregrid: when test_case is specified, nfiles should be 1");
-    sprintf(output_file[0], "%s.%s.output", test_case, interp_method);
-  }
-
-  if(check_conserve) opcode |= CHECK_CONSERVE;
-  
-  if( opcode & BILINEAR ) {
-    int ncontact;
-    ncontact = read_mosaic_ncontacts(mosaic_in);
-    if( nlon == 0 || nlat == 0) mpp_error("fregrid: when interp_method is bilinear, nlon and nlat should be specified");
-    if(ntiles_in != 6) mpp_error("fregrid: when interp_method is bilinear, the input mosaic should be 6 tile cubic grid");
-    if(ncontact !=12)  mpp_error("fregrid: when interp_method is bilinear, the input mosaic should be 12 contact cubic grid");
-    if(mpp_npes() > 1) mpp_error("fregrid: parallel is not implemented for bilinear remapping");
-  }
-  else
-    y_at_center = 1;
-
-
-  /* memory allocation for data structure */
-  grid_in   = (Grid_config *)malloc(ntiles_in *sizeof(Grid_config));
-  grid_out  = (Grid_config *)malloc(ntiles_out*sizeof(Grid_config));
-  bound_T   = (Bound_config *)malloc(ntiles_in *sizeof(Bound_config));
-  interp    = (Interp_config *)malloc(ntiles_out*sizeof(Interp_config));
-  get_input_grid( ntiles_in, grid_in, bound_T, mosaic_in, opcode );
-  if(mosaic_out)
-    get_output_grid_from_mosaic( ntiles_out, grid_out, mosaic_out, opcode );
-  else
-    get_output_grid_by_size(ntiles_out, grid_out, lonbegin, lonend, latbegin, latend,
-			    nlon, nlat, finer_step, y_at_center, opcode);
-
-  if(remap_file) set_remap_file(ntiles_out, mosaic_out, remap_file, interp, &opcode, save_weight_only);
-
-  /* preparing for the interpolation, if remapping information exist, read it from remap_file,
-     otherwise create the remapping information and write it to remap_file
-  */
-   if( opcode & BILINEAR ) /* bilinear interpolation from cubic to lalon */
-     setup_bilinear_interp(ntiles_in, grid_in, ntiles_out, grid_out, interp, opcode );
-   else
-     setup_conserve_interp(ntiles_in, grid_in, ntiles_out, grid_out, interp, opcode);
-  
-   if(save_weight_only) {
-     if(mpp_pe() == mpp_root_pe() ) {
-       printf("NOTE: Successfully running fregrid and the following files which store weight information are generated.\n");
-       for(n=0; n<ntiles_out; n++) {
-	 printf("****%s\n", interp[n].remap_file);
-       }
-     }
-     mpp_end();
-     return 0;     
-   }
-  
-  file_in   = (File_config *)malloc(ntiles_in *sizeof(File_config));
-  file_out  = (File_config *)malloc(ntiles_out*sizeof(File_config));
- 
-  if(nfiles == 2) {
-    file2_in   = (File_config *)malloc(ntiles_in *sizeof(File_config));
-    file2_out  = (File_config *)malloc(ntiles_out*sizeof(File_config));
-  }
-  if(nscalar > 0) {
-    scalar_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
-    scalar_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));
-  }
-  if(nvector > 0) {
-    u_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
-    u_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));    
-    v_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
-    v_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));
-  }
-  
-      
-  set_mosaic_data_file(ntiles_in, mosaic_in, dir_in, file_in,  input_file[0]);
-  set_mosaic_data_file(ntiles_out, mosaic_out, dir_out, file_out, output_file[0]);
-  if(nfiles == 2) {
-    set_mosaic_data_file(ntiles_in, mosaic_in, dir_in, file2_in,  input_file[1]);
-    set_mosaic_data_file(ntiles_out, mosaic_out, dir_out, file2_out, output_file[1]);    
-  }
-
-  for(n=0; n<ntiles_in; n++) file_in[n].fid = mpp_open(file_in[n].name, MPP_READ);
-
-  set_field_struct ( ntiles_in,   scalar_in,   nscalar, scalar_name[0], file_in);
-  set_field_struct ( ntiles_out,  scalar_out,  nscalar, scalar_name[0], file_out);
-  set_field_struct ( ntiles_in,   u_in,        nvector, u_name[0], file_in);
-  set_field_struct ( ntiles_out,  u_out,       nvector, u_name[0], file_out);
-  if(nfiles == 1) {
-    set_field_struct ( ntiles_in,   v_in,        nvector, v_name[0], file_in);
-    set_field_struct ( ntiles_out,  v_out,       nvector, v_name[0], file_out);
-  }
-  else {
-    set_field_struct ( ntiles_in,   v_in,        nvector, v_name[0], file2_in);
-    set_field_struct ( ntiles_out,  v_out,       nvector, v_name[0], file2_out);
-  }
-
-  get_input_metadata(ntiles_in, nfiles, file_in, file2_in, scalar_in, u_in, v_in, grid_in, kbegin, kend, lbegin, lend );
-
-  set_output_metadata(ntiles_in, nfiles, file_in, file2_in, scalar_in, u_in, v_in,
-		      ntiles_out, file_out, file2_out, scalar_out, u_out, v_out, grid_out, history, tagname );
-
-  if(nscalar > 0) get_field_missing(ntiles_in, scalar_in);
-  if(nvector > 0) {
-    get_field_missing(ntiles_in, u_in);
-    get_field_missing(ntiles_in, v_in);
-  }
-  
-   /* set time step to 1, only test scalar field now, nz need to be 1 */
-   if(test_case) {
-     if(nscalar != 1 || nvector != 0) mpp_error("fregrid: when test_case is specified, nscalar must be 1 and nvector must be 0");
-     if(scalar_in->var->nz != 1) mpp_error("fregrid: when test_case is specified, number of vertical level must be 1");
-     file_in->nt = 1;
-     file_out->nt = 1;
-   }
-   
-  /* Then doing the regridding */
-  for(m=0; m<file_in->nt; m++) {
-    int memsize, level;
-
-    write_output_time(ntiles_out, file_out, m);
-    if(nfiles > 1) write_output_time(ntiles_out, file2_out, m);
-    
-    /* first interp scalar variable */
-    for(l=0; l<nscalar; l++) {
-      if( !scalar_in->var[l].has_taxis && m>0) continue;
-      level = m + scalar_in->var[l].lstart;
-      if(test_case)
-	get_test_input_data(test_case, test_param, ntiles_in, scalar_in, grid_in, bound_T, opcode);
-      else
-        get_input_data(ntiles_in, scalar_in, grid_in, bound_T, l, level, opcode);
-      allocate_field_data(ntiles_out, scalar_out, grid_out, l);
-      if( opcode & BILINEAR )
-	do_scalar_bilinear_interp(interp, l, ntiles_in, grid_in, grid_out, scalar_in, scalar_out, finer_step, fill_missing);
-      else
-	do_scalar_conserve_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, scalar_in, scalar_out, opcode);
-      write_field_data(ntiles_out, scalar_out, grid_out, l, m);
-      if(opcode & CONSERVE_ORDER2) {
-	for(n=0; n<ntiles_in; n++) {
-	  free(scalar_in[n].grad_x);
-	  free(scalar_in[n].grad_y);
-	  if(scalar_in[n].var[l].has_missing) free(scalar_in[n].grad_mask);
-	}
-      }
-      for(n=0; n<ntiles_in; n++) free(scalar_in[n].data);
-      for(n=0; n<ntiles_out; n++) free(scalar_out[n].data);
-    }
-
-    /* then interp vector field */
-    for(l=0; l<nvector; l++) {
-      if( !u_in[n].var[l].has_taxis && m>0) continue;
-      level = m + u_in->var[l].lstart;
-      get_input_data(ntiles_in, u_in, grid_in, bound_T, l, level, opcode);
-      get_input_data(ntiles_in, v_in, grid_in, bound_T, l, level, opcode);
-      allocate_field_data(ntiles_out, u_out, grid_out, l);
-      allocate_field_data(ntiles_out, v_out, grid_out, l);
-      if( opcode & BILINEAR )
-	do_vector_bilinear_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, u_in, v_in, u_out, v_out, finer_step, fill_missing);
-      else
-	do_vector_conserve_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, u_in, v_in, u_out, v_out, opcode);
-      
-      write_field_data(ntiles_out, u_out, grid_out, l, m);
-      write_field_data(ntiles_out, v_out, grid_out, l, m);
-      for(n=0; n<ntiles_in; n++) {
-	free(u_in[n].data);
-	free(v_in[n].data);
-      }
-      for(n=0; n<ntiles_out; n++) {
-	free(u_out[n].data);
-	free(v_out[n].data);
-      }      
-    }
-  }
-
-  if(mpp_pe() == mpp_root_pe() ) {
-    printf("Successfully running fregrid and the following output file are generated.\n");
-    for(n=0; n<ntiles_out; n++) {
-      mpp_close(file_out[n].fid);
-      printf("****%s\n", file_out[n].name);
-      if( nfiles > 1 ) {
-	mpp_close(file2_out[n].fid);
-	printf("****%s\n", file2_out[n].name);
-      }
-    }
-  }
+   if ((ret = gs_fregrid(history, mosaic_in, mosaic_out, dir_in, 
+                         dir_out, input_file, nfiles, output_file, nfiles_out, 
+                         remap_file, scalar_name, nscalar, u_name, nvector, 
+                         v_name, nvector2, interp_method, test_case, test_param, 
+                         opcode, grid_type, finer_step, fill_missing, nlon, nlat, check_conserve, 
+                         y_at_center, lonbegin, lonend, latbegin, latend, 
+                         lbegin, kend, lbegin, lend)))
+      return ret;
       
   mpp_end();
   return 0;
   
 } /* end of main */
   
-
-  
-  
diff --git a/gridspec/tools/get_data.sh b/gridspec/tools/get_data.sh
new file mode 100755
index 0000000..50e70c7
--- /dev/null
+++ b/gridspec/tools/get_data.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# This shell script runs the ncdump tests.
+# $Id: get_data.sh,v 1.2 2009/09/08 17:14:52 ed Exp $
+
+set -e
+echo ""
+#!/bin/sh
+
+# This shell file runs benchmarks on the 2D radar data on parallel platforms.
+
+# $Id: get_data.sh,v 1.2 2009/09/08 17:14:52 ed Exp $
+
+set -e
+echo ""
+echo "Getting GRIDSPEC test input data from Unidata FTP site..."
+
+file_list='19800101.atmos_daily.tile1.nc  19800101.atmos_daily.tile4.nc  get_data.sh OCCAM_p5degree.nc 19800101.atmos_daily.tile2.nc  19800101.atmos_daily.tile5.nc 19800101.atmos_daily.tile3.nc 19800101.atmos_daily.tile6.nc'
+for file in $file_list; do
+    if test -f $file; then
+	echo "we already have $file..."
+    else
+	wget ftp://ftp.unidata.ucar.edu/pub/libcf/sample_data/gridspec/$file
+    fi
+done
+
+exit 0
+
diff --git a/gridspec/tools/make_coupler_mosaic/Makefile.am b/gridspec/tools/make_coupler_mosaic/Makefile.am
new file mode 100644
index 0000000..2359a93
--- /dev/null
+++ b/gridspec/tools/make_coupler_mosaic/Makefile.am
@@ -0,0 +1,67 @@
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2009, see the COPYRIGHT file for more
+## information.
+
+# This automake file is in charge of building the gridspec
+# make_coupler_mosaic tool.
+
+# $Id: Makefile.am,v 1.4 2009/11/16 14:11:31 zhi Exp $
+
+bin_PROGRAMS = make_coupler_mosaic
+make_coupler_mosaic_SOURCES = make_coupler_mosaic.c
+
+# Initalize these.
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared	\
+-I$(top_srcdir)/gridspec/shared/mosaic
+AM_LDFLAGS = -L../shared -L../../shared/mosaic
+LDADD = -ltoolsshared -lshared -lnetcdf -lm
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
+
diff --git a/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.in b/gridspec/tools/make_coupler_mosaic/Makefile.in
similarity index 69%
rename from gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.in
rename to gridspec/tools/make_coupler_mosaic/Makefile.in
index 507aaa0..c0162a5 100644
--- a/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.in
+++ b/gridspec/tools/make_coupler_mosaic/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,12 +18,13 @@
 # This automake file is in charge of building the gridspec
 # make_coupler_mosaic tool.
 
-# $Id: Makefile.am,v 1.2 2009/04/07 15:14:47 ed Exp $
+# $Id: Makefile.am,v 1.4 2009/11/16 14:11:31 zhi Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -37,22 +39,35 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-bin_PROGRAMS = make_coupler_mosaic$(EXEEXT) \
-	gs_make_coupler_mosaic$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
+bin_PROGRAMS = make_coupler_mosaic$(EXEEXT)
 @USE_NETCDF_DIR_TRUE at am__append_1 = -I at NETCDFDIR@/include
 @USE_NETCDF_DIR_TRUE at am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/make_coupler_mosaic
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/tools/make_coupler_mosaic
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -64,21 +79,20 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_gs_make_coupler_mosaic_OBJECTS = gs_make_coupler_mosaic.$(OBJEXT)
-gs_make_coupler_mosaic_OBJECTS = $(am_gs_make_coupler_mosaic_OBJECTS)
-gs_make_coupler_mosaic_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-gs_make_coupler_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1)
 am_make_coupler_mosaic_OBJECTS = make_coupler_mosaic.$(OBJEXT)
 make_coupler_mosaic_OBJECTS = $(am_make_coupler_mosaic_OBJECTS)
 make_coupler_mosaic_LDADD = $(LDADD)
-make_coupler_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am__DEPENDENCIES_1 =
+make_coupler_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__append_4) $(am__append_7) $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -88,10 +102,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(gs_make_coupler_mosaic_SOURCES) \
-	$(make_coupler_mosaic_SOURCES)
-DIST_SOURCES = $(gs_make_coupler_mosaic_SOURCES) \
-	$(make_coupler_mosaic_SOURCES)
+SOURCES = $(make_coupler_mosaic_SOURCES)
+DIST_SOURCES = $(make_coupler_mosaic_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -107,7 +119,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -124,12 +135,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -145,13 +155,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -168,8 +177,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -214,7 +224,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -226,17 +235,18 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 make_coupler_mosaic_SOURCES = make_coupler_mosaic.c
-gs_make_coupler_mosaic_SOURCES = gs_make_coupler_mosaic.c
 
 # Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared \
+	-I$(top_srcdir)/gridspec/shared/mosaic $(am__append_1) \
+	$(am__append_5) $(am__append_8) $(am__append_12) \
+	$(am__append_14) $(am__append_16) $(am__append_18)
 AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
+	$(am__append_6) $(am__append_9) $(am__append_13) \
+	$(am__append_15) $(am__append_17) $(am__append_19)
+LDADD = -ltoolsshared -lshared -lnetcdf -lm $(am__append_3) \
+	$(am__append_4) $(am__append_7) $(am__append_10) \
+	$(am__append_11)
 all: all-am
 
 .SUFFIXES:
@@ -245,14 +255,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/make_coupler_mosaic/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/make_coupler_mosaic/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -270,37 +280,50 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 
 clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-gs_make_coupler_mosaic$(EXEEXT): $(gs_make_coupler_mosaic_OBJECTS) $(gs_make_coupler_mosaic_DEPENDENCIES) 
-	@rm -f gs_make_coupler_mosaic$(EXEEXT)
-	$(LINK) $(gs_make_coupler_mosaic_OBJECTS) $(gs_make_coupler_mosaic_LDADD) $(LIBS)
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
 make_coupler_mosaic$(EXEEXT): $(make_coupler_mosaic_OBJECTS) $(make_coupler_mosaic_DEPENDENCIES) 
 	@rm -f make_coupler_mosaic$(EXEEXT)
 	$(LINK) $(make_coupler_mosaic_OBJECTS) $(make_coupler_mosaic_LDADD) $(LIBS)
@@ -311,13 +334,12 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_make_coupler_mosaic.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_coupler_mosaic.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -325,7 +347,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -333,7 +355,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -349,14 +371,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -364,29 +386,34 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -407,13 +434,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -444,6 +475,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -464,6 +496,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -472,18 +506,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -522,6 +566,7 @@ uninstall-am: uninstall-binPROGRAMS
 	pdf pdf-am ps ps-am tags uninstall uninstall-am \
 	uninstall-binPROGRAMS
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec/tools/make_coupler_mosaic/make_coupler_mosaic.c b/gridspec/tools/make_coupler_mosaic/make_coupler_mosaic.c
new file mode 100644
index 0000000..a2f1633
--- /dev/null
+++ b/gridspec/tools/make_coupler_mosaic/make_coupler_mosaic.c
@@ -0,0 +1,206 @@
+/*
+ * Modify land grid to match ocean grid at coast and calculate atmos/land,
+ * atmos/ocean, and land/ocean overlaps using the Sutherland-Hodgeman polygon
+ * clipping algorithm (Sutherland, I. E. and G. W. Hodgeman, 1974:  Reentrant
+ * polygon clipping, CACM, 17(1), 32-42).
+ *  Warning, when the atmos grid is cubic grid, the number of model points should be
+ *  even to avoid tiling error. I will come back to solve this issue in the future.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <string.h>
+#include <math.h>
+#include "constant.h"
+#include "mpp.h"
+#include "tool_util.h"
+#include "mpp_domain.h"
+
+
+char *usage[] = {
+  "",
+  "  make_coupler_mosaic --atmos_mosaic atmos_mosaic.nc --ice_mosaic ice_mosaic.nc ",
+  "              --ice_topog_mosaic ice_topog_mosaic.nc [--land_mosaic land_mosaic.nc] ",
+  "              [--ocean_topog_mosaic ocean_topog_mosaic.nc] [--sea_level #]  ",
+  "              [--interp_method #] [--mosaic_name mosaic_name] [--check ] ",
+  " ",
+  "make_coupler_mosaic generates three exchange grids for the FMS coupler. The output ",
+  "file includes exchange grid files for fluxes between atmosphere and surface (sea ice ",
+  "and land), exchange grid files for runoff between land and sea ice. There might be more ",
+  "than one exchange grid files between two model solo mosaic because there might be ",
+  "multiple tiles in a solo mosaic. All the exchange grid information are between model ",
+  "grid, not between supergrid. We assume the refinement ratio between model grid and ",
+  "supergrid is 2. Currently we only output the exchange grid on T-cell. ",
+  "Besides generate the exchange grid files, make_coupler_mosaic also generate the ",
+  "coupler mosaic file (the file name will be mosaic_name.nc) which contains the atmos, ",
+  "land and ocean mosaic path, ocean mosaic topog path and exchange grid file path. ",
+  "make_coupler_mosaic expects NetCDF format input.",
+  " ",
+  "make_coupler_mosaic takes the following flags:",
+  "",
+  "REQUIRED:",
+  "",
+  "--atmos_mosaic atmos_mosaic.nc specify the atmosphere mosaic information. This file",
+  "                               contains list of tile files which specify the grid ",
+  "                               information for each tile. Each grid is required to be ",
+  "                               regular lon/lat grid. The file name can not be 'mosaic.nc' ",
+  "",
+  "--ice_mosaic ice_mosaic.nc     specify the ice mosaic information. This file",
+  "                               contains list of tile files which specify the grid ",
+  "                               information for each tile. The file name can not be 'mosaic.nc' ",
+  " ",
+  "--ice_topog_mosaic filename    specify the ice topography mosaic file name, which contains link to",
+  "                               topography data on each tile. The topography data is positive down. ",
+  " ",
+  "OPTIONAL FLAGS",
+  "",
+  "--land_mosaic land_mosaic.nc   specify the land mosaic information. This file",
+  "                               contains list of tile files which specify the grid ",
+  "                               information for each tile. Each grid is required to be ",
+  "                               regular lon/lat grid. When land_mosaic is not specified,",
+  "                               atmosphere mosaic will be used to specify land mosaic.",
+  "                               The file name can not be 'mosaic.nc'.",
+  " ",
+  "--ocean_mosaic ocean_mosaic.nc specify the ocean mosaic information. This file",
+  "                               contains list of tile files which specify the grid ",
+  "                               information for each tile. The file name can not be 'mosaic.nc' ",
+  " ",  
+  "--interp_order #               specify the order of conservative interplation. Its value ",
+  "                               can be 1 ( linear order ) or 2 ( second order ) with default ",
+  "                               value 2.                                                     ",
+  "                                                                                            ",
+  "--sea_level #                  specify the sea level ( in meters ) and its value will be used",
+  "                               to determine land/sea mask. When topography of  ",
+  "                               a grid cell is less than sea level, this grid cell will be land,",
+  "                               otherwise it will be ocean. Default value is 0",
+  " ",
+  "--mosaic_name mosaic_name      coupler mosaic name. The output coupler mosaic file will be ",
+  "                               mosaic_name.nc. default value is 'mosaic'. ",
+  " ",  
+  "--check                        check the tiling error",
+    "", 
+  "A sample call to make_coupler_mosaic that makes exchange grids for atmosphere, land and ocean ",
+  "mosaic (atmosphere and land are coincident) is: ",
+  "",
+  "  make_coupler_mosaic --atmos_mosaic atmos_mosaic.nc --ocean_mosaic ocean_mosaic.nc ",
+  "                  --ocean_topog_mosaic ocean_topog_mosaic.nc",
+  "",
+  NULL };
+
+
+int main (int argc, char *argv[])
+{
+  int c, i, same_mosaic;
+  extern char *optarg;
+  char *imosaic  = NULL;
+  char *omosaic  = NULL;
+  char *amosaic  = NULL;
+  char *lmosaic  = NULL;
+  char *itopog   = NULL;
+  char mosaic_name[STRING] = "mosaic", mosaic_file[STRING];
+  char imosaic_name[STRING], amosaic_name[STRING], lmosaic_name[STRING];
+  char **otile_name=NULL, **atile_name=NULL, **ltile_name=NULL;
+  int x_refine = 2, y_refine = 2;
+  int  interp_order = 2;
+  int check = 0;
+  int errflg = (argc == 1);
+  char history[512];
+  int nfile_lxo=0, nfile_axo=0, nfile_axl=0;
+  int    ntile_ocn, ntile_atm, ntile_lnd;
+  int    *nxo = NULL, *nyo = NULL, *nxa = NULL, *nya = NULL, *nxl = NULL, *nyl = NULL;
+  double **xocn = NULL, **yocn = NULL, **xatm = NULL, **yatm = NULL, **xlnd = NULL, **ylnd = NULL;
+  double **area_ocn = NULL, **area_lnd = NULL, **area_atm = NULL;
+  double **omask = NULL;
+  double sea_level = 0.;
+  int    lnd_same_as_atm = 0;
+  int    option_index = 0;
+  double axo_area_sum = 0, axl_area_sum = 0;
+  int    ocn_south_ext = 0;
+   int ret;
+    
+  static struct option long_options[] = {
+    {"atmos_mosaic",       required_argument, NULL, 'a'},
+    {"land_mosaic",        required_argument, NULL, 'l'},
+    {"ice_mosaic",         required_argument, NULL, 'i'},
+    {"ocean_mosaic",       required_argument, NULL, 'o'},
+    {"ice_topog_mosaic",   required_argument, NULL, 't'},
+    {"sea_level",          required_argument, NULL, 's'},
+    {"interp_order",       required_argument, NULL, 'r'},
+    {"mosaic_name",        required_argument, NULL, 'm'},
+    {"check",              no_argument,       NULL, 'n'},
+    {NULL, 0, NULL, 0}
+  };
+
+  mpp_init(&argc, &argv);
+  mpp_domain_init();
+  
+  /*
+   * process command line
+   */
+
+  while ((c = getopt_long(argc, argv, "i:", long_options, &option_index) ) != -1)
+    switch (c) {
+    case 'a': 
+      amosaic = optarg;
+      break;
+    case 'l': 
+      lmosaic = optarg;
+      break;
+    case 'i':
+      imosaic = optarg;
+      break;
+    case 'o':
+      omosaic = optarg;
+      break;
+    case 't':
+      itopog = optarg;
+      break;
+    case 'r':
+      interp_order = atoi(optarg);
+      break;
+    case 's':
+      sea_level = atof(optarg);
+      break;
+    case 'm':
+      strcpy(mosaic_name,optarg);
+      break;
+    case 'n':
+      check = 1;
+      break;
+    case '?':
+      errflg++;
+    }
+  if (errflg || !amosaic || !imosaic || !itopog) {
+    char **u = usage;
+    while (*u) { fprintf(stderr, "%s\n", *u); u++; }
+    exit(2);
+  }
+
+  /* interp_order should be 1 or 2 */
+  if(interp_order != 1 && interp_order !=2 )mpp_error("make_coupler_mosaic: interp_order should be 1 or 2");
+  
+  strcpy(history,argv[0]);
+
+  for(i=1;i<argc;i++) {
+    strcat(history, " ");
+    strcat(history, argv[i]);
+  }
+
+  /*if lmosaic is not specifiied, assign amosaic value to it */
+  if(!lmosaic) lmosaic = amosaic;
+  if(!omosaic) omosaic = imosaic;
+  
+  if ((ret = gs_make_coupler_mosaic(history, amosaic, lmosaic, omosaic, imosaic, itopog, 
+                                     interp_order, sea_level, mosaic_name, check)))
+      return ret;
+  
+  if(mpp_pe()== mpp_root_pe())printf("\n***** Congratulation! You have successfully run make_coupler_mosaic\n");
+  mpp_end();
+
+  return 0;
+  
+} /* main */
+
+
diff --git a/gridspec/tools/make_hgrid/Makefile.am b/gridspec/tools/make_hgrid/Makefile.am
new file mode 100644
index 0000000..e4068a4
--- /dev/null
+++ b/gridspec/tools/make_hgrid/Makefile.am
@@ -0,0 +1,75 @@
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2009, see the COPYRIGHT file for more
+## information.
+
+# This automake file is in charge of building the gridspec make_hgrid
+# tools.
+
+# $Id: Makefile.am,v 1.4 2009/11/16 14:14:02 zhi Exp $
+
+bin_PROGRAMS = make_hgrid
+make_hgrid_SOURCES = make_hgrid.c
+
+# Initalize these.
+AM_CPPFLAGS = -I../shared -I$(top_srcdir)/gridspec/tools/shared	\
+-I../../shared/mosaic -I$(top_srcdir)/gridspec/shared/mosaic
+
+AM_LDFLAGS = -L../shared -L../../shared/mosaic
+
+LDADD = -ltoolsshared -lshared -lm
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
+TESTS = run_tests
+EXTRA_DIST = run_tests.in
+CLEANFILES = horizontal_grid.nc gs_horizontal_grid.nc	\
+horizontal_grid.cdl gs_horizontal_grid.cdl
+DISTCLEANFILES = run_tests
+
+
diff --git a/cfcheck/Makefile.in b/gridspec/tools/make_hgrid/Makefile.in
similarity index 63%
copy from cfcheck/Makefile.in
copy to gridspec/tools/make_hgrid/Makefile.in
index 69ea17e..bc1e628 100644
--- a/cfcheck/Makefile.in
+++ b/gridspec/tools/make_hgrid/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -14,18 +15,16 @@
 
 @SET_MAKE@
 
-# This is part of the libcf library.
+# This automake file is in charge of building the gridspec make_hgrid
+# tools.
 
-# This automake file handles the building of cfcheck.
-
-# Ed Hartnett 11/23/06
-
-# $Id: Makefile.am,v 1.3 2007/05/27 06:56:11 ed Exp $
+# $Id: Makefile.am,v 1.4 2009/11/16 14:14:02 zhi Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -40,22 +39,37 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_1 = -lhdf5_hl -lhdf5 -lz
-
-# If the user specified a root location for NETCDF, use it.
- at USE_NETCDF_DIR_TRUE@am__append_2 = -I at NETCDFDIR@/include
- at USE_NETCDF_DIR_TRUE@am__append_3 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_4 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_5 = -L at HDF5DIR@/lib
-bin_PROGRAMS = cfcheck$(EXEEXT)
-subdir = cfcheck
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+bin_PROGRAMS = make_hgrid$(EXEEXT)
+ at USE_NETCDF_DIR_TRUE@am__append_1 = -I at NETCDFDIR@/include
+ at USE_NETCDF_DIR_TRUE@am__append_2 = -L at NETCDFDIR@/lib
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/tools/make_hgrid
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/run_tests.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -65,18 +79,20 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = run_tests
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_cfcheck_OBJECTS = cfcheck.$(OBJEXT)
-cfcheck_OBJECTS = $(am_cfcheck_OBJECTS)
-cfcheck_LDADD = $(LDADD)
+am_make_hgrid_OBJECTS = make_hgrid.$(OBJEXT)
+make_hgrid_OBJECTS = $(am_make_hgrid_OBJECTS)
+make_hgrid_LDADD = $(LDADD)
 am__DEPENDENCIES_1 =
-cfcheck_DEPENDENCIES = ../src/libcf.la $(am__DEPENDENCIES_1)
+make_hgrid_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__append_4) \
+	$(am__append_7) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -86,10 +102,12 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(cfcheck_SOURCES)
-DIST_SOURCES = $(cfcheck_SOURCES)
+SOURCES = $(make_hgrid_SOURCES)
+DIST_SOURCES = $(make_hgrid_SOURCES)
 ETAGS = etags
 CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
@@ -103,7 +121,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -120,12 +137,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -141,13 +157,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -164,8 +179,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -210,7 +226,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -221,17 +236,25 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-
-# Find libcf.h here.
-AM_CPPFLAGS = -I${top_srcdir}/src $(am__append_2) $(am__append_4)
-AM_LDFLAGS = $(am__append_3) $(am__append_5)
-
-# Link in our libcf library, also netCDF.
-LDADD = ../src/libcf.la -lnetcdf $(am__append_1)
-EXTRA_DIST = tst_cfcheck.sh
-cfcheck_SOURCES = cfcheck.c
-TESTS = tst_cfcheck.sh
-CLEANFILES = useage.txt
+make_hgrid_SOURCES = make_hgrid.c
+
+# Initalize these.
+AM_CPPFLAGS = -I../shared -I$(top_srcdir)/gridspec/tools/shared \
+	-I../../shared/mosaic -I$(top_srcdir)/gridspec/shared/mosaic \
+	$(am__append_1) $(am__append_5) $(am__append_8) \
+	$(am__append_12) $(am__append_14) $(am__append_16) \
+	$(am__append_18)
+AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
+	$(am__append_6) $(am__append_9) $(am__append_13) \
+	$(am__append_15) $(am__append_17) $(am__append_19)
+LDADD = -ltoolsshared -lshared -lm $(am__append_3) $(am__append_4) \
+	$(am__append_7) $(am__append_10) $(am__append_11)
+TESTS = run_tests
+EXTRA_DIST = run_tests.in
+CLEANFILES = horizontal_grid.nc gs_horizontal_grid.nc	\
+horizontal_grid.cdl gs_horizontal_grid.cdl
+
+DISTCLEANFILES = run_tests
 all: all-am
 
 .SUFFIXES:
@@ -240,14 +263,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  cfcheck/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  cfcheck/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/make_hgrid/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/make_hgrid/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -265,37 +288,55 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+run_tests: $(top_builddir)/config.status $(srcdir)/run_tests.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 
 clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-cfcheck$(EXEEXT): $(cfcheck_OBJECTS) $(cfcheck_DEPENDENCIES) 
-	@rm -f cfcheck$(EXEEXT)
-	$(LINK) $(cfcheck_OBJECTS) $(cfcheck_LDADD) $(LIBS)
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
+make_hgrid$(EXEEXT): $(make_hgrid_OBJECTS) $(make_hgrid_DEPENDENCIES) 
+	@rm -f make_hgrid$(EXEEXT)
+	$(LINK) $(make_hgrid_OBJECTS) $(make_hgrid_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -303,12 +344,12 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cfcheck.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_hgrid.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -316,7 +357,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -324,7 +365,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -340,14 +381,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -355,37 +396,43 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 check-TESTS: $(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[	 ]'; \
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
 	srcdir=$(srcdir); export srcdir; \
 	list=' $(TESTS) '; \
+	$(am__tty_colors); \
 	if test -n "$$list"; then \
 	  for tst in $$list; do \
 	    if test -f ./$$tst; then dir=./; \
@@ -394,49 +441,63 @@ check-TESTS: $(TESTS)
 	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
 	      all=`expr $$all + 1`; \
 	      case " $(XFAIL_TESTS) " in \
-	      *$$ws$$tst$$ws*) \
+	      *[\ \	]$$tst[\ \	]*) \
 		xpass=`expr $$xpass + 1`; \
 		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
+		col=$$red; res=XPASS; \
 	      ;; \
 	      *) \
-		echo "PASS: $$tst"; \
+		col=$$grn; res=PASS; \
 	      ;; \
 	      esac; \
 	    elif test $$? -ne 77; then \
 	      all=`expr $$all + 1`; \
 	      case " $(XFAIL_TESTS) " in \
-	      *$$ws$$tst$$ws*) \
+	      *[\ \	]$$tst[\ \	]*) \
 		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
+		col=$$lgn; res=XFAIL; \
 	      ;; \
 	      *) \
 		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
+		col=$$red; res=FAIL; \
 	      ;; \
 	      esac; \
 	    else \
 	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
+	      col=$$blu; res=SKIP; \
 	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
 	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
 	  if test "$$failed" -eq 0; then \
 	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
+	      banner="$$All$$all $$tests passed"; \
 	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
 	    fi; \
 	  else \
 	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
+	      banner="$$failed of $$all $$tests failed"; \
 	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
 	    fi; \
 	  fi; \
 	  dashes="$$banner"; \
 	  skipped=""; \
 	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
 	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
 	      dashes="$$skipped"; \
 	  fi; \
@@ -447,11 +508,15 @@ check-TESTS: $(TESTS)
 	      dashes="$$report"; \
 	  fi; \
 	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
 	  echo "$$banner"; \
 	  test -z "$$skipped" || echo "$$skipped"; \
 	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
+	  echo "$$dashes$$std"; \
 	  test "$$failed" -eq 0; \
 	else :; fi
 
@@ -471,13 +536,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -510,6 +579,8 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -530,6 +601,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -538,18 +611,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -572,7 +655,7 @@ ps-am:
 
 uninstall-am: uninstall-binPROGRAMS
 
-.MAKE: install-am install-strip
+.MAKE: check-am install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
 	clean-binPROGRAMS clean-generic clean-libtool ctags distclean \
@@ -588,6 +671,7 @@ uninstall-am: uninstall-binPROGRAMS
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags uninstall uninstall-am uninstall-binPROGRAMS
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec_tools_20080702/tools/make_hgrid/gs_make_hgrid.c b/gridspec/tools/make_hgrid/make_hgrid.c
similarity index 96%
rename from gridspec_tools_20080702/tools/make_hgrid/gs_make_hgrid.c
rename to gridspec/tools/make_hgrid/make_hgrid.c
index db3c309..5c85e7b 100644
--- a/gridspec_tools_20080702/tools/make_hgrid/gs_make_hgrid.c
+++ b/gridspec/tools/make_hgrid/make_hgrid.c
@@ -6,7 +6,9 @@
 #include "create_hgrid.h"
 #include "mpp.h"
 #include "mpp_domain.h"
-#include "mpp_io.h"
+#include "tool_util.h"
+#include "mosaic_util.h"
+
 
 #define MAXBOUNDS 100
 #define STRINGLEN 255
@@ -193,24 +195,17 @@ int main(int argc, char* argv[])
    char my_grid_file[MAXBOUNDS][STRINGLEN];
    double lat_join=65.;
    double simple_dx=0, simple_dy=0;
-   int nx, ny, nxp, nyp, ntiles=1, ntilex=0, ntiley=0, ntiles_file;
+   int nx, ny, nxp, nyp, ntiles=1, ntilex=0, ntiley=0;
+   unsigned int ntiles_file;
    double *x=NULL, *y=NULL, *dx=NULL, *dy=NULL, *angle_dx=NULL, *angle_dy=NULL, *area=NULL;
   
    char history[2560];
    char gridname[32] = "horizontal_grid";
    char center[32] = "none";
-   char geometry[32] = "spherical";
-   char projection[32] = "none";
-   char arcx[32] = "small_circle";
-   char north_pole_tile[32] = "0.0 90.0";
-   char north_pole_arcx[32] = "0.0 90.0";
-   char discretization[32]  = "logically_rectangular";
-   char conformal[32]       = "true";
    char mesg[256], str[128];
    char entry[MAXBOUNDS*STRINGLEN];
    int isc, iec, jsc, jec, nxc, nyc, layout[2];
-   domain2D domain;
-   int n, errflg, c, i;  
+   int errflg, c, i;  
    int option_index;
    int ret;
 
@@ -249,7 +244,7 @@ int main(int argc, char* argv[])
 	    break;
 	 case 'b':
 	    strcpy(entry, optarg);
-	    tokenize(entry, ",", STRINGLEN, MAXBOUNDS, my_grid_file, &ntiles_file);
+	    tokenize(entry, ",", STRINGLEN, MAXBOUNDS, (char *)my_grid_file, &ntiles_file);
 	    break;
 	 case 'c':
 	    nxbnds0 = atoi(optarg);
@@ -321,12 +316,17 @@ int main(int argc, char* argv[])
       strcat(history, argv[i]);
    }
 
+   if( strcmp(grid_type,"from_file") ==0 ) {   
+     if(ntiles_file == 0) mpp_error("make_hgrid: grid_type is 'from_file', but my_grid_file is not specified");
+     ntiles = ntiles_file;
+   }
+   
    if(mpp_pe() == mpp_root_pe() ) printf("==>NOTE: the grid type is %s\n",grid_type);
 
    /* Do everything. */
-   if ((ret = gs_make_hgrid(grid_type, entry, nxbnds0, nybnds0, nxbnds1, 
+   if ((ret = gs_make_hgrid(grid_type, nlat, nlon, nxbnds0, nybnds0, nxbnds1, 
                             nybnds1, nxbnds2, nybnds2, lat_join, nratio, simple_dx, 
-                            simple_dy, ntilex, ntiley, gridname, center)))
+                            simple_dy, ntilex, ndivx, ntiley, ndivy, gridname, center, history, xbnds, ybnds)))
       return ret;
 
    if(mpp_pe() == mpp_root_pe()) printf("generate_grid is run successfully. \n");
diff --git a/gridspec/tools/make_hgrid/run_tests.in b/gridspec/tools/make_hgrid/run_tests.in
new file mode 100644
index 0000000..ce96421
--- /dev/null
+++ b/gridspec/tools/make_hgrid/run_tests.in
@@ -0,0 +1,36 @@
+#!/bin/sh
+# This shell script runs the ncdump tests.
+# $Id: run_tests.in,v 1.4 2009/11/16 14:19:21 zhi Exp $
+
+set -e
+echo ""
+echo "*** Testing gridspec hgrids."
+
+echo "*** generating regular lon-lat grid (supergrid size 60x20)..."
+./make_hgrid --grid_type regular_lonlat_grid --nxbnd 2 --nybnd 2  \
+    --xbnd 0,30 --ybnd 50,60  --nlon 60 --nlat 20
+
+#echo "*** generating tripolar grid with various grid resolution and C-cell centered..."
+#./make_hgrid --grid_type tripolar_grid --nxbnd 2 --nybnd 7 --xbnd -280,80 \
+#    --ybnd -82,-30,-10,0,10,30,90 --nlon 720 --nlat 104,48,40,40,48,120 --grid_name om3_grid \
+#    --center c_cell  --periodx 360 
+
+# echo "*** generating simple cartesian grid(supergrid size 20x20)..."
+# ./make_hgrid --grid_type simple_cartesian_grid --xbnds 0,30 --ybnds 50,60 \
+#     --nlon 20 --nlat 20  --simple_dx 1000 --simple_dy 1000
+
+# echo "*** generating conformal cubic grid. (supergrid size 60x60 for each tile)..."
+# ./make_hgrid --grid_type simple_cartesian_grid --xbnd 0,30 --ybnd 50,60 \
+#     --nlon 20 --nlat 20  --simple_dx 1000 --simple_dy 1000
+
+# echo "*** generating conformal cubic grid. (supergrid size 60x60 for each tile)..."
+# ./make_hgrid --grid_type conformal_cubic_grid --nlon 60 --nratio 2
+
+# echo "*** generating gnomonic cubic grid with equal_dist_face_edge..."
+# ./make_hgrid  --grid_type gnomonic_ed --nlon 60
+
+# echo "*** generating spectral grid. (supergrid size 128x64)..."
+# ./make_hgrid --grid_type spectral_grid --nlon 128 --nlat 64
+
+echo "*** All gridspec hgrid tests passed!"
+exit 0
diff --git a/gridspec/tools/make_mosaic/Makefile.am b/gridspec/tools/make_mosaic/Makefile.am
new file mode 100644
index 0000000..8f66c89
--- /dev/null
+++ b/gridspec/tools/make_mosaic/Makefile.am
@@ -0,0 +1,73 @@
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2009, see the COPYRIGHT file for more
+## information.
+
+# This automake file is in charge of building the gridspec make_hgrid
+# tools.
+
+# $Id: Makefile.am,v 1.2 2009/11/16 16:38:32 zhi Exp $
+
+bin_PROGRAMS = make_mosaic
+make_mosaic_SOURCES = make_mosaic.c
+
+# Initalize these.
+AM_CPPFLAGS = -I../shared -I../../shared/mosaic
+AM_LDFLAGS = -L../shared -L../../shared/mosaic
+
+LDADD = -ltoolsshared -lshared -lm
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
+#TESTS = run_tests
+#EXTRA_DIST = run_tests.in
+#CLEANFILES = horizontal_grid.nc gs_horizontal_grid.nc	\
+#horizontal_grid.cdl gs_horizontal_grid.cdl
+#DISTCLEANFILES = run_tests
+
+
diff --git a/gridspec_tools_20080702/tools/make_hgrid/Makefile.in b/gridspec/tools/make_mosaic/Makefile.in
similarity index 67%
rename from gridspec_tools_20080702/tools/make_hgrid/Makefile.in
rename to gridspec/tools/make_mosaic/Makefile.in
index f374e5d..76572f2 100644
--- a/gridspec_tools_20080702/tools/make_hgrid/Makefile.in
+++ b/gridspec/tools/make_mosaic/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,12 +18,13 @@
 # This automake file is in charge of building the gridspec make_hgrid
 # tools.
 
-# $Id: Makefile.am,v 1.3 2009/04/04 11:22:53 ed Exp $
+# $Id: Makefile.am,v 1.2 2009/11/16 16:38:32 zhi Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -37,21 +39,35 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-bin_PROGRAMS = make_hgrid$(EXEEXT) gs_make_hgrid$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
+bin_PROGRAMS = make_mosaic$(EXEEXT)
 @USE_NETCDF_DIR_TRUE at am__append_1 = -I at NETCDFDIR@/include
 @USE_NETCDF_DIR_TRUE at am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/make_hgrid
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/tools/make_mosaic
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -63,27 +79,19 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_gs_make_hgrid_OBJECTS = gs_make_hgrid.$(OBJEXT) \
-	create_conformal_cubic_grid.$(OBJEXT) \
-	create_gnomonic_cubic_grid.$(OBJEXT) \
-	create_grid_from_file.$(OBJEXT) create_lonlat_grid.$(OBJEXT)
-gs_make_hgrid_OBJECTS = $(am_gs_make_hgrid_OBJECTS)
-gs_make_hgrid_LDADD = $(LDADD)
+am_make_mosaic_OBJECTS = make_mosaic.$(OBJEXT)
+make_mosaic_OBJECTS = $(am_make_mosaic_OBJECTS)
+make_mosaic_LDADD = $(LDADD)
 am__DEPENDENCIES_1 =
-gs_make_hgrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_make_hgrid_OBJECTS = make_hgrid.$(OBJEXT) \
-	create_conformal_cubic_grid.$(OBJEXT) \
-	create_gnomonic_cubic_grid.$(OBJEXT) \
-	create_grid_from_file.$(OBJEXT) create_lonlat_grid.$(OBJEXT)
-make_hgrid_OBJECTS = $(am_make_hgrid_OBJECTS)
-make_hgrid_LDADD = $(LDADD)
-make_hgrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
+make_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__append_4) \
+	$(am__append_7) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -93,8 +101,8 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(gs_make_hgrid_SOURCES) $(make_hgrid_SOURCES)
-DIST_SOURCES = $(gs_make_hgrid_SOURCES) $(make_hgrid_SOURCES)
+SOURCES = $(make_mosaic_SOURCES)
+DIST_SOURCES = $(make_mosaic_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -110,7 +118,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -127,12 +134,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -148,13 +154,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -171,8 +176,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -217,7 +223,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -228,24 +233,17 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-make_hgrid_SOURCES = make_hgrid.c create_conformal_cubic_grid.c		\
-create_gnomonic_cubic_grid.c create_grid_from_file.c create_hgrid.h	\
-create_lonlat_grid.c
-
-gs_make_hgrid_SOURCES = gs_make_hgrid.c create_conformal_cubic_grid.c	\
-create_gnomonic_cubic_grid.c create_grid_from_file.c create_hgrid.h	\
-create_lonlat_grid.c
-
+make_mosaic_SOURCES = make_mosaic.c
 
 # Initalize these.
 AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
+	$(am__append_5) $(am__append_8) $(am__append_12) \
+	$(am__append_14) $(am__append_16) $(am__append_18)
 AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
+	$(am__append_6) $(am__append_9) $(am__append_13) \
+	$(am__append_15) $(am__append_17) $(am__append_19)
+LDADD = -ltoolsshared -lshared -lm $(am__append_3) $(am__append_4) \
+	$(am__append_7) $(am__append_10) $(am__append_11)
 all: all-am
 
 .SUFFIXES:
@@ -254,14 +252,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_hgrid/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_hgrid/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/make_mosaic/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/make_mosaic/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -279,40 +277,53 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 
 clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-gs_make_hgrid$(EXEEXT): $(gs_make_hgrid_OBJECTS) $(gs_make_hgrid_DEPENDENCIES) 
-	@rm -f gs_make_hgrid$(EXEEXT)
-	$(LINK) $(gs_make_hgrid_OBJECTS) $(gs_make_hgrid_LDADD) $(LIBS)
-make_hgrid$(EXEEXT): $(make_hgrid_OBJECTS) $(make_hgrid_DEPENDENCIES) 
-	@rm -f make_hgrid$(EXEEXT)
-	$(LINK) $(make_hgrid_OBJECTS) $(make_hgrid_LDADD) $(LIBS)
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
+make_mosaic$(EXEEXT): $(make_mosaic_OBJECTS) $(make_mosaic_DEPENDENCIES) 
+	@rm -f make_mosaic$(EXEEXT)
+	$(LINK) $(make_mosaic_OBJECTS) $(make_mosaic_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -320,17 +331,12 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_conformal_cubic_grid.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_gnomonic_cubic_grid.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_grid_from_file.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_lonlat_grid.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_make_hgrid.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_hgrid.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_mosaic.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -338,7 +344,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -346,7 +352,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -362,14 +368,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -377,29 +383,34 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -420,13 +431,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -457,6 +472,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -477,6 +493,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -485,18 +503,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -535,6 +563,13 @@ uninstall-am: uninstall-binPROGRAMS
 	pdf pdf-am ps ps-am tags uninstall uninstall-am \
 	uninstall-binPROGRAMS
 
+
+#TESTS = run_tests
+#EXTRA_DIST = run_tests.in
+#CLEANFILES = horizontal_grid.nc gs_horizontal_grid.nc	\
+#horizontal_grid.cdl gs_horizontal_grid.cdl
+#DISTCLEANFILES = run_tests
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec/tools/make_mosaic/make_mosaic.c b/gridspec/tools/make_mosaic/make_mosaic.c
new file mode 100644
index 0000000..f380de5
--- /dev/null
+++ b/gridspec/tools/make_mosaic/make_mosaic.c
@@ -0,0 +1,177 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <getopt.h>
+#include "constant.h"
+#include "mpp.h"
+#include "tool_util.h"
+
+char *usage[] = {
+  "",
+  " make_mosaic --num_tiles num_tiles --tile_file tile_file [--dir directory]       ",
+  "             [--num_mosaic num_mosaic] [--mosaic_file mosaic_file]               ",
+  "             [--mosaic_name mosaic_name] [--periodx #] [--periody #]             ",
+  "             [--generate_contact]                                                ",
+  "                                                                                 ",
+  "make_mosaic generates Mosaic of tile grid files. If generate_overlap is          ",
+  "specified, it also contains a link to the mosaic file that contains contact      ",
+  "information of child files, specified by index, contact type.                    ",
+  "                                                                                 ",
+  "make_solo_mosaic takes the following flags:                                      ",
+  "                                                                                 ",
+  "REQUIRED:                                                                        ",
+  "                                                                                 ",
+  "--num_tiles num_tiles    Number of grid tiles.                                   ",
+  "                                                                                 ",
+  "--tile_file tile_file    File name of all grid tiles. The number of entry must   ",
+  "be ntiles (The file name should be full file name) or 1 (The file name will be   ",
+  "base file name, which does not include tile name).                               ",
+  "                                                                                 ",    
+  "OPTIONAL FLAGS                                                                   ",
+  "                                                                                 ",  
+  "--num_mosaic #     Number of child mosaic file.                                  ",
+  "                                                                                 ",
+  "--mosaic_file mosaic_file File name of child mosaic file. The number of entry    ",
+  "                          must be num_mosaic.                                    ",
+  "                                                                                 ",    
+  "--dir directory          The directory that contains all the child files. If dir ",
+  "                         is not specified, the file path should be contained in  ",
+  "                         child_file.                                             ",
+  "                                                                                 ",  
+  "--mosaic_name name       mosaic name. The output file will be mosaic_name.nc.    ",
+  "                         default is 'mosaic'.                                    ",
+  "                                                                                 ",
+  "--periodx #              Specify the period in x-direction of mosaic. Default    ",
+  "                         value is 0 (not periodic). This is needed only when     ",
+  "                         child_file are tile grid files.                         ",
+  "                                                                                 ",
+  "--periody #              Specify the period in y-direction of mosaic. Default    ",
+  "                         value is 0 (not periodic).  This is needed only when    ",
+  "                         child_file are tile grid files.                         ",
+  "                                                                                 ",
+  "--generate_contact       Specify whether to generate the contact between mosaic  ",
+  "                         when num_mosaic is greater than 1                       ",
+  "                                                                                 ",
+  NULL};
+  
+const int MAXCHILD = 100;
+
+main (int argc, char *argv[])
+{
+
+  extern char *optarg;
+  char *pch=NULL, *tile_dir=NULL, history[512], entry[1280];
+  char tilefile[MAXCHILD][STRING];
+  char mosaicfile[MAXCHILD][STRING];
+  int  ntile=0, ntile2=0;
+  int  nmosaic=0, nmosaic2=0;
+  int  generate_contact = 0;
+
+  double periodx=0, periody=0;
+
+  char mosaic_name[128] = "mosaic";
+  char grid_descriptor[128] = "";
+  int c, i, n, m, l, errflg;
+  int ret;
+  
+  int option_index = 0;
+  static struct option long_options[] = {
+    {"mosaic_name",       required_argument, NULL, 'm'},
+    {"num_tiles",         required_argument, NULL, 'n'},
+    {"grid_descriptor",   required_argument, NULL, 'g'},
+    {"tile_file",         required_argument, NULL, 'f'},
+    {"num_mosaic",  required_argument, NULL, 'l'},
+    {"mosaic_file", required_argument, NULL, 'k'},
+    {"periodx",           required_argument, NULL, 'x'},
+    {"periody",           required_argument, NULL, 'y'},
+    {"tile_directory",    required_argument, NULL, 'd'},
+    {"generate_contact",  no_argument,       NULL, 'c'},
+    {NULL, 0, NULL, 0}
+  };
+
+  mpp_init(&argc, &argv);
+  /* this tool must be run one processor */
+  if(mpp_npes()>1) mpp_error("make_mosaic: this tool must be run on one processor");
+  
+  errflg = (argc == 1);
+  /* First read command line arguments. */
+
+  while ((c = getopt_long(argc, argv, "h", long_options, &option_index)) != -1) {
+    switch (c) {
+    case 'n':
+      ntile = atoi(optarg);
+      break;
+    case 'm':
+      strcpy(mosaic_name, optarg);
+      break;
+    case 'g':
+      strcpy(grid_descriptor, optarg);
+      break;
+    case 'f':
+      strcpy(entry, optarg); 
+      pch = strtok(entry, ", ");
+      while( pch != NULL) {
+        strcpy(tilefile[ntile2++], pch);
+	pch = strtok(NULL, ", ");
+      }
+      break;
+    case 'l':
+      nmosaic = atoi(optarg);
+      break;
+    case 'k':
+      strcpy(entry, optarg); 
+      pch = strtok(entry, ", ");
+      while( pch != NULL) {
+        strcpy(mosaicfile[nmosaic2++], pch);
+	pch = strtok(NULL, ", ");
+      }
+      break;
+    case 'x':
+      periodx = atof(optarg);
+      break;
+    case 'y':
+      periody = atof(optarg);
+      break; 
+    case 'd':  // path of the simple grid file.
+      tile_dir = optarg;
+      break;
+    case 'c':
+      generate_contact = 1;
+      break;
+    case '?':
+      errflg++;
+    }
+  }
+
+  if (errflg || ntile < 1) {
+    char **u = usage;
+    while (*u) { fprintf(stderr, "%s\n", *u); u++; }
+    exit(2);      
+  }
+
+  if(nmosaic>0) {
+    if(nmosaic != nmosaic2) mpp_error("make_mosaic: then number of entry specified through --mosaic_file "
+				      "must equal to num_mosaic" );
+  }
+  
+  strcpy(history,argv[0]);
+
+  for(i=1;i<argc;i++) {
+    strcat(history, " ");
+    strcat(history, argv[i]);
+  }
+
+
+  if ((ret = gs_make_mosaic(history, ntile, mosaic_name, nmosaic, mosaicfile, grid_descriptor,
+			    ntile2, tilefile, periodx, periody, generate_contact, tile_dir )))
+     return ret;
+
+  mpp_end();
+
+  return 0;
+  
+  
+}; // end of main
+
+
+
diff --git a/gridspec/tools/make_topog/Makefile.am b/gridspec/tools/make_topog/Makefile.am
new file mode 100644
index 0000000..a872fa5
--- /dev/null
+++ b/gridspec/tools/make_topog/Makefile.am
@@ -0,0 +1,70 @@
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2009, see the COPYRIGHT file for more
+## information.
+
+# This automake file is in charge of building the gridspec
+# make_topog tool.
+
+# $Id: Makefile.am,v 1.4 2009/11/16 14:15:43 zhi Exp $
+
+bin_PROGRAMS = make_topog
+make_topog_SOURCES = make_topog.c
+
+# Initalize these.
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared	\
+-I$(top_srcdir)/gridspec/shared/mosaic
+AM_LDFLAGS = -L../shared -L../../shared/mosaic
+LDADD = -ltoolsshared -lshared -lnetcdf -lm
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
+TESTS = run_tests
+EXTRA_DIST = run_tests.in
+CLEANFILES = topog.nc gs_topog.nc topog.cdl gs_topog.cdl
+DISTCLEANFILES = run_tests
\ No newline at end of file
diff --git a/gridspec_tools_20080702/tools/make_topog/Makefile.in b/gridspec/tools/make_topog/Makefile.in
similarity index 55%
rename from gridspec_tools_20080702/tools/make_topog/Makefile.in
rename to gridspec/tools/make_topog/Makefile.in
index 85fc7a2..f1146d3 100644
--- a/gridspec_tools_20080702/tools/make_topog/Makefile.in
+++ b/gridspec/tools/make_topog/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,12 +18,13 @@
 # This automake file is in charge of building the gridspec
 # make_topog tool.
 
-# $Id: Makefile.am,v 1.2 2009/04/07 22:02:40 ed Exp $
+# $Id: Makefile.am,v 1.4 2009/11/16 14:15:43 zhi Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -37,22 +39,37 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-bin_PROGRAMS = make_topog$(EXEEXT) gs_make_topog$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
+bin_PROGRAMS = make_topog$(EXEEXT)
 @USE_NETCDF_DIR_TRUE at am__append_1 = -I at NETCDFDIR@/include
 @USE_NETCDF_DIR_TRUE at am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/make_topog
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/tools/make_topog
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/run_tests.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -62,22 +79,20 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = run_tests
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_gs_make_topog_OBJECTS = make_topog.$(OBJEXT) topog.$(OBJEXT)
-gs_make_topog_OBJECTS = $(am_gs_make_topog_OBJECTS)
-gs_make_topog_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-gs_make_topog_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_make_topog_OBJECTS = make_topog.$(OBJEXT) topog.$(OBJEXT)
+am_make_topog_OBJECTS = make_topog.$(OBJEXT)
 make_topog_OBJECTS = $(am_make_topog_OBJECTS)
 make_topog_LDADD = $(LDADD)
-make_topog_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am__DEPENDENCIES_1 =
+make_topog_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__append_4) \
+	$(am__append_7) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -87,10 +102,12 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(gs_make_topog_SOURCES) $(make_topog_SOURCES)
-DIST_SOURCES = $(gs_make_topog_SOURCES) $(make_topog_SOURCES)
+SOURCES = $(make_topog_SOURCES)
+DIST_SOURCES = $(make_topog_SOURCES)
 ETAGS = etags
 CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
@@ -104,7 +121,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -121,12 +137,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -142,13 +157,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -165,8 +179,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -211,7 +226,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -222,18 +236,23 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-make_topog_SOURCES = make_topog.c  topog.c  topog.h
-gs_make_topog_SOURCES = make_topog.c  topog.c  topog.h
+make_topog_SOURCES = make_topog.c
 
 # Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared \
+	-I$(top_srcdir)/gridspec/shared/mosaic $(am__append_1) \
+	$(am__append_5) $(am__append_8) $(am__append_12) \
+	$(am__append_14) $(am__append_16) $(am__append_18)
 AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
+	$(am__append_6) $(am__append_9) $(am__append_13) \
+	$(am__append_15) $(am__append_17) $(am__append_19)
+LDADD = -ltoolsshared -lshared -lnetcdf -lm $(am__append_3) \
+	$(am__append_4) $(am__append_7) $(am__append_10) \
+	$(am__append_11)
+TESTS = run_tests
+EXTRA_DIST = run_tests.in
+CLEANFILES = topog.nc gs_topog.nc topog.cdl gs_topog.cdl
+DISTCLEANFILES = run_tests
 all: all-am
 
 .SUFFIXES:
@@ -242,14 +261,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_topog/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_topog/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/make_topog/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/make_topog/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -267,37 +286,52 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+run_tests: $(top_builddir)/config.status $(srcdir)/run_tests.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 
 clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-gs_make_topog$(EXEEXT): $(gs_make_topog_OBJECTS) $(gs_make_topog_DEPENDENCIES) 
-	@rm -f gs_make_topog$(EXEEXT)
-	$(LINK) $(gs_make_topog_OBJECTS) $(gs_make_topog_LDADD) $(LIBS)
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
 make_topog$(EXEEXT): $(make_topog_OBJECTS) $(make_topog_DEPENDENCIES) 
 	@rm -f make_topog$(EXEEXT)
 	$(LINK) $(make_topog_OBJECTS) $(make_topog_LDADD) $(LIBS)
@@ -309,12 +343,11 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_topog.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/topog.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -322,7 +355,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -330,7 +363,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -346,14 +379,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -361,33 +394,130 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	$(am__tty_colors); \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=XPASS; \
+	      ;; \
+	      *) \
+		col=$$grn; res=PASS; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xfail=`expr $$xfail + 1`; \
+		col=$$lgn; res=XFAIL; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=FAIL; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      col=$$blu; res=SKIP; \
+	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
+	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="$$All$$all $$tests passed"; \
+	    else \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all $$tests failed"; \
+	    else \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes$$std"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
 distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -404,17 +534,22 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
 check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
 check: check-am
 all-am: Makefile $(PROGRAMS)
 installdirs:
@@ -438,9 +573,12 @@ install-strip:
 mostlyclean-generic:
 
 clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -461,6 +599,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -469,18 +609,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -503,21 +653,22 @@ ps-am:
 
 uninstall-am: uninstall-binPROGRAMS
 
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-libtool ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-binPROGRAMS install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am \
-	uninstall-binPROGRAMS
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+	clean-binPROGRAMS clean-generic clean-libtool ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-binPROGRAMS install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/gridspec_tools_20080702/tools/make_topog/make_topog.c b/gridspec/tools/make_topog/make_topog.c
similarity index 63%
rename from gridspec_tools_20080702/tools/make_topog/make_topog.c
rename to gridspec/tools/make_topog/make_topog.c
index c030a85..54ac11d 100644
--- a/gridspec_tools_20080702/tools/make_topog/make_topog.c
+++ b/gridspec/tools/make_topog/make_topog.c
@@ -7,6 +7,7 @@
 #include "mpp_domain.h"
 #include "mpp_io.h"
 #include "tool_util.h"
+#include "constant.h"
 
 char *usage[] = {
   "",
@@ -22,7 +23,7 @@ char *usage[] = {
   "              [--bowl_north #] [--bowl_west #] [--bowl_east #]                           ",
   "              [--fill_first_row] [--filter_topog] [--round_shallow]                      ",
   "              [--fill_shallow] [--deepen_shallow] [--smooth_topo_allow_deepening]        ",
-  "              [--output output_file [--help]                                             ",
+  "              [--topog_mosaic topog_mosaic] [--help]                                             ",
   "                                                                                         ",
   "   make_topog can generate topography for any Mosaic. The output file                    ",
   "   will contains the topography for each tile in the Mosaic. The field name in           ",
@@ -123,8 +124,10 @@ char *usage[] = {
   "                                                                                         ",
   "   --smooth_topo_allow_deepening when specified, allow filter to deepen cells.           ",
   "                                                                                         ",
-  "   --output output_file          The created netcdf file that contains mosaic            ",
-  "                                 topography. Default value is 'topog.nc'                 ",
+  "   --topog_mosaic topog_mosaic   Specify the name of the topog mosaic. The topog mosaic  ",
+  "                                 file name will be topog_mosaic.nc. Default value is     ",
+  "                                 'topog_mosaic'. The topography data file on each tile   ",
+  "                                 will be topog_mosaic.tile#.nc                           ",
   "   --help                        Print out this message and then exit.                   ",
   "                                                                                         ",   
   "   Example                                                                               ", 
@@ -142,13 +145,11 @@ char *usage[] = {
   "",
   NULL };
 
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
-
 int main(int argc, char* argv[])
 {
   char   *mosaic_file = NULL, *topog_file = NULL, *topog_field = NULL;
-  char   topog_type[32] = "realistic", output_file[32] = "topog.nc";
+  char   topog_type[32] = "realistic", topog_mosaic[128] = "topog_mosaic";
+  char   history[512];
   int    num_filter_pass = 1;
   int    x_refine = 2, y_refine = 2;
   double basin_depth = 5000, bottom_depth = 5000, min_depth = 10, scale_factor = 1;
@@ -159,7 +160,7 @@ int main(int argc, char* argv[])
   int    deepen_shallow = 0, smooth_topo_allow_deepening = 0;
   int    errflg = (argc == 1);
   int    option_index, i, c;
-
+  int    ret;
   
   /*
    * process command line
@@ -191,7 +192,7 @@ int main(int argc, char* argv[])
     {"fill_shallow",                no_argument,       NULL, 'w'},
     {"deepen_shallow",              no_argument,       NULL, 'x'},
     {"smooth_topo_allow_deepening", no_argument,       NULL, 'y'},
-    {"output",                      required_argument, NULL, 'o'},
+    {"topog_mosaic",                required_argument, NULL, 'o'},
     {"help",                        no_argument,       NULL, 'h'},
     {0, 0, 0, 0},
   };
@@ -280,7 +281,7 @@ int main(int argc, char* argv[])
       smooth_topo_allow_deepening = 1;
       break;
     case 'o':
-      strcpy(output_file,optarg);
+      strcpy(topog_mosaic,optarg);
       break; 
     case '?':
       errflg++;
@@ -293,217 +294,29 @@ int main(int argc, char* argv[])
     exit(2);
   }
 
+  /* history will be write out as global attribute
+     in output file to specify the command line arguments
+  */
 
-  /* Write out arguments value  */
-  if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> the topog_type is: %s\n",topog_type);
-  if(x_refine != 2 || y_refine != 2 ) mpp_error("Error from make_topog: x_refine and y_refine should be 2, contact developer");
-  if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> x_refine is %d, y_refine is %d\n",
-				       x_refine, y_refine);
+  strcpy(history,argv[0]);
 
-  if (strcmp(topog_type,"rectangular_basin") == 0) {
-    if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> the basin depth is %f\n",basin_depth);
-  }
-  else if (strcmp(topog_type,"gaussian") == 0) {
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n", bottom_depth );
-      printf("NOTE from make_topog ==> min_depth is: %f\n", min_depth );
-      printf("NOTE from make_topog ==> gauss_amp is: %f\n", gauss_amp );
-      printf("NOTE from make_topog ==> gauss_scale is: %f\n", gauss_scale );
-      printf("NOTE from make_topog ==> slope_x is: %f\n", slope_x );
-      printf("NOTE from make_topog ==> slope_y is: %f\n", slope_y );      
-    }
-  }
-  else if(strcmp(topog_type,"bowl") == 0) {
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
-      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
-      printf("NOTE from make_topog ==> bowl_south is: %f\n",bowl_south);
-      printf("NOTE from make_topog ==> bowl_north is: %f\n",bowl_north);
-      printf("NOTE from make_topog ==> bowl_west is: %f\n",bowl_west);
-      printf("NOTE from make_topog ==> bowl_east is: %f\n",bowl_east);
-    }
-  }
-  else if(strcmp(topog_type,"idealized") == 0) {
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
-      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
-    }
-  }
-  else if(strcmp(topog_type,"realistic") == 0) {
-    if(!topog_file || !topog_field)
-      mpp_error("Error from make_topog: when topog_type is realistic, topog_file and topog_field must be specified.");
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
-      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
-      printf("NOTE from make_topog ==> topog_file is: %s\n", topog_file);
-      printf("NOTE from make_topog ==> topog_field is: %s\n", topog_field);
-      printf("NOTE from make_topog ==> scale_factor is: %f\n", scale_factor);
-      printf("NOTE from make_topog ==> num_filter_pass is: %d\n", num_filter_pass);
-      if(fill_first_row) printf("NOTE from make_topog ==>make first row of ocean model all land points.\n");
-      if(filter_topog) printf("NOTE from make_topog ==>will apply filter to topography.\n");
-      if(round_shallow) printf("NOTE from make_topog ==>Make cells land if depth is less than 1/2 "
-			       "mimumim depth, otherwise make ocean.\n");
-      if(fill_shallow) printf("NOTE from make_topog ==>Make cells less than minimum depth land.\n");
-      if(deepen_shallow) printf("NOTE from make_topog ==>Make cells less than minimum depth equal to minimum depth.\n");
-      if(smooth_topo_allow_deepening) printf("NOTE from make_topog ==>allow filter to deepen cells.\n");
-    }
-  }
-  else {
-    mpp_error("make_topog: topog_type should be rectangular_basin, gaussian, bowl, idealized or realistic");
-  }
-  
-  if(mpp_pe() == mpp_root_pe()) {
-    printf("**************************************************\n");
-    printf("Begin to generate topography \n");
+  for(i=1;i<argc;i++) {
+    strcat(history, " ");
+    strcat(history, argv[i]);
   }
-
-  {
-    const int STRING = 255;
-    int m_fid, g_fid, vid;
-    int ntiles, fid, dim_ntiles, n, dims[2];
-    size_t start[4], nread[4], nwrite[4];
-    int *nx, *ny, *nxp, *nyp;
-    int *id_depth;
-    double *depth, *x, *y;
-    char **tile_files;
-    char history[512], dimx_name[128], dimy_name[128], depth_name[128];
-    char gridfile[256], griddir[256];
     
-    /* history will be write out as global attribute
-       in output file to specify the command line arguments
-    */
-
-    strcpy(history,argv[0]);
-
-    for(i=1;i<argc;i++) {
-      strcat(history, " ");
-      strcat(history, argv[i]);
-    }
-
-    /* grid should be located in the same directory of mosaic file */
-    get_file_path(mosaic_file, griddir);
-    
-    /* get mosaic dimension */
-    m_fid = mpp_open(mosaic_file, MPP_READ);
-    ntiles = mpp_get_dimlen( m_fid, "ntiles");
-    tile_files = (char **)malloc(ntiles*sizeof(double *));
-    id_depth = (int *)malloc(ntiles*sizeof(int));
-    /* loop through each tile to get tile information and set up meta data for output file */
-    fid = mpp_open(output_file, MPP_WRITE);
-    mpp_def_global_att(fid, "grid_version", grid_version);
-    mpp_def_global_att(fid, "code_version", tagname);
-    mpp_def_global_att(fid, "history", history);
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    nx = (int *)malloc(ntiles*sizeof(int));
-    ny = (int *)malloc(ntiles*sizeof(int));
-    nxp = (int *)malloc(ntiles*sizeof(int));
-    nyp = (int *)malloc(ntiles*sizeof(int));   
-    for( n = 0; n < ntiles; n++ ) {
-      tile_files[n] = (char *)malloc(STRING*sizeof(double));
-      start[0] = n;
-      start[1] = 0;
-      nread[0] = 1;
-      nread[1] = STRING;
-      vid = mpp_get_varid(m_fid, "gridfiles");
-      mpp_get_var_value_block(m_fid, vid, start, nread, gridfile);
-      sprintf(tile_files[n], "%s/%s", griddir, gridfile);
-      g_fid = mpp_open(tile_files[n], MPP_READ);
-      nx[n] = mpp_get_dimlen(g_fid, "nx");
-      ny[n] = mpp_get_dimlen(g_fid, "ny");
-      if( nx[n]%x_refine != 0 ) mpp_error("make_topog: supergrid x-size can not be divided by x_refine");
-      if( ny[n]%y_refine != 0 ) mpp_error("make_topog: supergrid y-size can not be divided by y_refine");
-      nx[n] /= x_refine;
-      ny[n] /= y_refine;
-      nxp[n] = nx[n] + 1;
-      nyp[n] = ny[n] + 1;
-      if(ntiles == 1) {
-	strcpy(dimx_name, "nx");
-	strcpy(dimy_name, "ny");
-	strcpy(depth_name, "depth");
-      }
-      else {
-	sprintf(dimx_name, "nx_tile%d", n+1);
-	sprintf(dimy_name, "ny_tile%d", n+1);
-	sprintf(depth_name, "depth_tile%d", n+1);
-      }
-
-      dims[1] = mpp_def_dim(fid, dimx_name, nx[n]); 
-      dims[0] = mpp_def_dim(fid, dimy_name, ny[n]);
-      id_depth[n] = mpp_def_var(fid, depth_name, NC_DOUBLE, 2, dims,  2, "standard_name",
-				"topographic depth at T-cell centers", "units", "meters");
-      mpp_close(g_fid);
-    }
-    mpp_close(m_fid);
-    mpp_end_def(fid);
+  
+  /* Write out arguments value  */
+  if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> the topog_type is: %s\n",topog_type);
+  if ((ret = gs_make_topog(history, mosaic_file, topog_type, x_refine, y_refine, basin_depth, topog_file, topog_field,
+			   bottom_depth, min_depth, scale_factor, num_filter_pass, gauss_amp, gauss_scale,
+			   slope_x, slope_y, bowl_south, bowl_north, bowl_west, bowl_east, fill_first_row, 
+                           filter_topog, round_shallow, fill_shallow, deepen_shallow,
+			   smooth_topo_allow_deepening, topog_mosaic) ) )
+      return ret;
 
-    /* Generate topography and write out to the output_file */
-    for(n=0; n<ntiles; n++) {
-      int layout[2], isc, iec, jsc, jec, nxc, nyc, ni, i, j;
-      double *gdata, *tmp;
-      domain2D domain;
-      
-      /* define the domain, each tile will be run on all the processors. */
-      mpp_define_layout( nx[n], ny[n], mpp_npes(), layout);
-      mpp_define_domain2d( nx[n], ny[n], layout, 0, 0, &domain);
-      mpp_get_compute_domain2d( domain, &isc, &iec, &jsc, &jec);
-      nxc = iec - isc + 1;
-      nyc = jec - jsc + 1;
-      
-      depth = (double *)malloc(nxc*nyc*sizeof(double));
-      x     = (double *)malloc((nxc+1)*(nyc+1)*sizeof(double));
-      y     = (double *)malloc((nxc+1)*(nyc+1)*sizeof(double));
-      tmp   = (double *)malloc((nxc*x_refine+1)*(nyc*y_refine+1)*sizeof(double));
-      start[0] = jsc*y_refine; start[1] = isc*x_refine;
-      nread[0] = nyc*y_refine+1; nread[1] = nxc*x_refine+1;
-      ni       = nxc*x_refine+1;
-      g_fid = mpp_open(tile_files[n], MPP_READ);
-      vid = mpp_get_varid(g_fid, "x");
-      mpp_get_var_value_block(g_fid, vid, start, nread, tmp);
-      for(j = 0; j < nyc+1; j++) for(i = 0; i < nxc+1; i++)
-	x[j*(nxc+1)+i] = tmp[(j*y_refine)*ni+i*x_refine];
-      vid = mpp_get_varid(g_fid, "y");
-      mpp_get_var_value_block( g_fid, vid, start, nread, tmp);
-      mpp_close(g_fid);
-      for(j = 0; j < nyc+1; j++) for(i = 0; i < nxc+1; i++)
-	y[j*(nxc+1)+i] = tmp[(j*y_refine)*ni+i*x_refine];
-      if (strcmp(topog_type,"rectangular_basin") == 0)
-	create_rectangular_topog(nx[n], ny[n], basin_depth, depth);
-      else if (strcmp(topog_type,"gaussian") == 0)
-	create_gaussian_topog(nx[n], ny[n], x, y, bottom_depth, min_depth,
-			      gauss_amp, gauss_scale, slope_x, slope_y, depth);
-      else if (strcmp(topog_type,"bowl") == 0)
-	create_bowl_topog(nx[n], ny[n], x, y, bottom_depth, min_depth, bowl_east,
-			  bowl_south, bowl_west, bowl_north, depth);
-      else if (strcmp(topog_type,"idealized") == 0)
-	create_idealized_topog( nx[n], ny[n], x, y, bottom_depth, min_depth, depth);
-      else if (strcmp(topog_type,"realistic") == 0)
-	create_realistic_topog(nxc, nyc, x, y, topog_file, topog_field, scale_factor,
-			       fill_first_row, filter_topog, num_filter_pass,
-			       smooth_topo_allow_deepening, round_shallow, fill_shallow,
-			       deepen_shallow, min_depth, depth );
-      gdata = (double *)malloc(nx[n]*ny[n]*sizeof(double));
-      mpp_global_field_double(domain, nxc, nyc, depth, gdata);
-      mpp_put_var_value(fid, id_depth[n], gdata);
-      free(x);
-      free(y);
-      free(tmp);
-      free(depth);
-      free(gdata);
-      mpp_delete_domain2d(&domain);
-    }
-    mpp_close(fid);
   
-    /*release memory */
-    free(id_depth);
-    for(n=0; n<ntiles; n++) free(tile_files[n]);
-    free(tile_files);
-    free(nx);
-    free(ny);
-    free(nxp);
-    free(nyp);
-  }
-    
-  if(mpp_pe() == mpp_root_pe() ) printf("Successfully generate %s\n",output_file);
+  if(mpp_pe() == mpp_root_pe() ) printf("Successfully generate %s\n",topog_mosaic);
 
   mpp_end();
 
diff --git a/gridspec/tools/make_topog/run_tests.in b/gridspec/tools/make_topog/run_tests.in
new file mode 100644
index 0000000..437e56f
--- /dev/null
+++ b/gridspec/tools/make_topog/run_tests.in
@@ -0,0 +1,21 @@
+#!/bin/sh
+# This shell script runs the GRIDSPEC make_topog tests.
+# $Id: run_tests.in,v 1.2 2009/09/08 17:14:52 ed Exp $
+
+set -e
+echo ""
+echo "*** Testing gridspec topog."
+
+# echo "*** generating realistic topography..."
+# ./make_topog --mosaic mosaic.nc --topog_type realistic \
+#     --topog_file /archive/fms/mom4/input_data/OCCAM_p5degree.nc --topog_field TOPO \
+#     --scale_factor -1 
+# ./gs_make_topog --mosaic mosaic.nc --topog_type realistic \
+#     --topog_file /archive/fms/mom4/input_data/OCCAM_p5degree.nc --topog_field TOPO \
+#     --scale_factor -1 --grid_name gs_topog_grid
+# @NCDUMPDIR@/ncdump topog.nc > topog.cdl
+# @NCDUMPDIR@/ncdump -n topog gs_topog.nc > gs_topog.cdl
+# #diff -w topog.cdl gs_topog.cdl 
+
+echo "*** All gridspec topog tests passed!"
+exit 0
diff --git a/gridspec/tools/make_vgrid/Makefile.am b/gridspec/tools/make_vgrid/Makefile.am
new file mode 100644
index 0000000..052d23a
--- /dev/null
+++ b/gridspec/tools/make_vgrid/Makefile.am
@@ -0,0 +1,72 @@
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2009, see the COPYRIGHT file for more
+## information.
+
+# This automake file is in charge of building the gridspec
+# make_vgrid tool.
+
+# $Id: Makefile.am,v 1.4 2009/11/16 14:17:46 zhi Exp $
+
+bin_PROGRAMS = make_vgrid
+make_vgrid_SOURCES = make_vgrid.c
+
+# Initalize these.
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared	\
+-I$(top_srcdir)/gridspec/shared/mosaic
+AM_LDFLAGS = -L../shared -L../../shared/mosaic
+LDADD = -ltoolsshared -lshared -lnetcdf -lm
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
+TESTS = run_tests
+EXTRA_DIST = run_tests.in
+CLEANFILES = horizontal_grid.nc gs_horizontal_grid.nc		\
+horizontal_grid.cdl gs_horizontal_grid.cdl vertical_grid.nc	\
+gs_vertical_grid.nc vertical_grid.cdl gs_vertical_grid.cdl
+DISTCLEANFILES = run_tests
\ No newline at end of file
diff --git a/gridspec_tools_20080702/tools/make_vgrid/Makefile.in b/gridspec/tools/make_vgrid/Makefile.in
similarity index 54%
rename from gridspec_tools_20080702/tools/make_vgrid/Makefile.in
rename to gridspec/tools/make_vgrid/Makefile.in
index 31c9141..eb62cbc 100644
--- a/gridspec_tools_20080702/tools/make_vgrid/Makefile.in
+++ b/gridspec/tools/make_vgrid/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,12 +18,13 @@
 # This automake file is in charge of building the gridspec
 # make_vgrid tool.
 
-# $Id: Makefile.am,v 1.2 2009/04/08 11:39:02 ed Exp $
+# $Id: Makefile.am,v 1.4 2009/11/16 14:17:46 zhi Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -37,22 +39,37 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-bin_PROGRAMS = make_vgrid$(EXEEXT) gs_make_vgrid$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
+bin_PROGRAMS = make_vgrid$(EXEEXT)
 @USE_NETCDF_DIR_TRUE at am__append_1 = -I at NETCDFDIR@/include
 @USE_NETCDF_DIR_TRUE at am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/make_vgrid
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/tools/make_vgrid
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+	$(srcdir)/run_tests.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -62,23 +79,20 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = run_tests
+CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
-am_gs_make_vgrid_OBJECTS = create_vgrid.$(OBJEXT) \
-	gs_make_vgrid.$(OBJEXT)
-gs_make_vgrid_OBJECTS = $(am_gs_make_vgrid_OBJECTS)
-gs_make_vgrid_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-gs_make_vgrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_make_vgrid_OBJECTS = create_vgrid.$(OBJEXT) make_vgrid.$(OBJEXT)
+am_make_vgrid_OBJECTS = make_vgrid.$(OBJEXT)
 make_vgrid_OBJECTS = $(am_make_vgrid_OBJECTS)
 make_vgrid_LDADD = $(LDADD)
-make_vgrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am__DEPENDENCIES_1 =
+make_vgrid_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__append_4) \
+	$(am__append_7) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -88,10 +102,12 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
-SOURCES = $(gs_make_vgrid_SOURCES) $(make_vgrid_SOURCES)
-DIST_SOURCES = $(gs_make_vgrid_SOURCES) $(make_vgrid_SOURCES)
+SOURCES = $(make_vgrid_SOURCES)
+DIST_SOURCES = $(make_vgrid_SOURCES)
 ETAGS = etags
 CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
@@ -105,7 +121,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -122,12 +137,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -143,13 +157,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -166,8 +179,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -212,7 +226,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -223,18 +236,26 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-make_vgrid_SOURCES = create_vgrid.c create_vgrid.h make_vgrid.c
-gs_make_vgrid_SOURCES = create_vgrid.c create_vgrid.h gs_make_vgrid.c
+make_vgrid_SOURCES = make_vgrid.c
 
 # Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
+AM_CPPFLAGS = -I$(top_srcdir)/gridspec/tools/shared \
+	-I$(top_srcdir)/gridspec/shared/mosaic $(am__append_1) \
+	$(am__append_5) $(am__append_8) $(am__append_12) \
+	$(am__append_14) $(am__append_16) $(am__append_18)
 AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
+	$(am__append_6) $(am__append_9) $(am__append_13) \
+	$(am__append_15) $(am__append_17) $(am__append_19)
+LDADD = -ltoolsshared -lshared -lnetcdf -lm $(am__append_3) \
+	$(am__append_4) $(am__append_7) $(am__append_10) \
+	$(am__append_11)
+TESTS = run_tests
+EXTRA_DIST = run_tests.in
+CLEANFILES = horizontal_grid.nc gs_horizontal_grid.nc		\
+horizontal_grid.cdl gs_horizontal_grid.cdl vertical_grid.nc	\
+gs_vertical_grid.nc vertical_grid.cdl gs_vertical_grid.cdl
+
+DISTCLEANFILES = run_tests
 all: all-am
 
 .SUFFIXES:
@@ -243,14 +264,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_vgrid/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_vgrid/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/make_vgrid/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/make_vgrid/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -268,37 +289,52 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+run_tests: $(top_builddir)/config.status $(srcdir)/run_tests.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p || test -f $$p1; \
+	  then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' `; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
 
 clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-gs_make_vgrid$(EXEEXT): $(gs_make_vgrid_OBJECTS) $(gs_make_vgrid_DEPENDENCIES) 
-	@rm -f gs_make_vgrid$(EXEEXT)
-	$(LINK) $(gs_make_vgrid_OBJECTS) $(gs_make_vgrid_LDADD) $(LIBS)
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
 make_vgrid$(EXEEXT): $(make_vgrid_OBJECTS) $(make_vgrid_DEPENDENCIES) 
 	@rm -f make_vgrid$(EXEEXT)
 	$(LINK) $(make_vgrid_OBJECTS) $(make_vgrid_LDADD) $(LIBS)
@@ -309,14 +345,12 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_vgrid.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_make_vgrid.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_vgrid.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -324,7 +358,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -332,7 +366,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -348,14 +382,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -363,33 +397,130 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
+check-TESTS: $(TESTS)
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
+	srcdir=$(srcdir); export srcdir; \
+	list=' $(TESTS) '; \
+	$(am__tty_colors); \
+	if test -n "$$list"; then \
+	  for tst in $$list; do \
+	    if test -f ./$$tst; then dir=./; \
+	    elif test -f $$tst; then dir=; \
+	    else dir="$(srcdir)/"; fi; \
+	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xpass=`expr $$xpass + 1`; \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=XPASS; \
+	      ;; \
+	      *) \
+		col=$$grn; res=PASS; \
+	      ;; \
+	      esac; \
+	    elif test $$? -ne 77; then \
+	      all=`expr $$all + 1`; \
+	      case " $(XFAIL_TESTS) " in \
+	      *[\ \	]$$tst[\ \	]*) \
+		xfail=`expr $$xfail + 1`; \
+		col=$$lgn; res=XFAIL; \
+	      ;; \
+	      *) \
+		failed=`expr $$failed + 1`; \
+		col=$$red; res=FAIL; \
+	      ;; \
+	      esac; \
+	    else \
+	      skip=`expr $$skip + 1`; \
+	      col=$$blu; res=SKIP; \
+	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
+	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
+	  if test "$$failed" -eq 0; then \
+	    if test "$$xfail" -eq 0; then \
+	      banner="$$All$$all $$tests passed"; \
+	    else \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+	    fi; \
+	  else \
+	    if test "$$xpass" -eq 0; then \
+	      banner="$$failed of $$all $$tests failed"; \
+	    else \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	    fi; \
+	  fi; \
+	  dashes="$$banner"; \
+	  skipped=""; \
+	  if test "$$skip" -ne 0; then \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
+	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$skipped"; \
+	  fi; \
+	  report=""; \
+	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+	    report="Please report to $(PACKAGE_BUGREPORT)"; \
+	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+	      dashes="$$report"; \
+	  fi; \
+	  dashes=`echo "$$dashes" | sed s/./=/g`; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
+	  echo "$$banner"; \
+	  test -z "$$skipped" || echo "$$skipped"; \
+	  test -z "$$report" || echo "$$report"; \
+	  echo "$$dashes$$std"; \
+	  test "$$failed" -eq 0; \
+	else :; fi
+
 distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -406,17 +537,22 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
 check-am: all-am
+	$(MAKE) $(AM_MAKEFLAGS) check-TESTS
 check: check-am
 all-am: Makefile $(PROGRAMS)
 installdirs:
@@ -440,9 +576,12 @@ install-strip:
 mostlyclean-generic:
 
 clean-generic:
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -463,6 +602,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -471,18 +612,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-binPROGRAMS
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -505,21 +656,22 @@ ps-am:
 
 uninstall-am: uninstall-binPROGRAMS
 
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-libtool ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-binPROGRAMS install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am \
-	uninstall-binPROGRAMS
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+	clean-binPROGRAMS clean-generic clean-libtool ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-binPROGRAMS install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS
+
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/gridspec_tools_20080702/tools/make_vgrid/gs_make_vgrid.c b/gridspec/tools/make_vgrid/make_vgrid.c
similarity index 96%
rename from gridspec_tools_20080702/tools/make_vgrid/gs_make_vgrid.c
rename to gridspec/tools/make_vgrid/make_vgrid.c
index 0ff8321..8f5daea 100644
--- a/gridspec_tools_20080702/tools/make_vgrid/gs_make_vgrid.c
+++ b/gridspec/tools/make_vgrid/make_vgrid.c
@@ -2,8 +2,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <getopt.h>
-#include "create_vgrid.h"
-#include "mpp_io.h"
+#include "tool_util.h"
+#include "mpp.h"
+
 
 #define MAXBOUNDS 100
 
@@ -56,8 +57,7 @@ char *usage[] = {
   "",
   NULL };  
 
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
+/*char tagname[] = "$Name:  $"; */
 
 int main(int argc, char* argv[])
 {
@@ -66,7 +66,6 @@ int main(int argc, char* argv[])
   int    nz[MAXBOUNDS-1];
   char gridname[128]= "vertical_grid";
   char filename[128];
-  double *zeta;
   char center[32] = "none";
   char entry[512];
   char history[256];
@@ -124,7 +123,8 @@ int main(int argc, char* argv[])
     strcat(history, argv[i]);
   }
 
-  if ((ret = gs_make_vgrid(history, nbnds, n1, n2, gridname, center)))
+  if ((ret = gs_make_vgrid(history, nbnds, bnds, n1, n2, 
+			   nz, gridname, center)))
      return ret;
 
   mpp_end();
diff --git a/gridspec/tools/make_vgrid/run_tests.in b/gridspec/tools/make_vgrid/run_tests.in
new file mode 100644
index 0000000..873f9e5
--- /dev/null
+++ b/gridspec/tools/make_vgrid/run_tests.in
@@ -0,0 +1,13 @@
+#!/bin/sh
+# This shell script runs the GRIDSPEC make_vgrid tests.
+# $Id: run_tests.in,v 1.3 2009/11/16 14:17:46 zhi Exp $
+
+set -e
+echo ""
+echo "*** Testing gridspec vgrids."
+
+echo "*** generating regular lon-lat grid (supergrid size 60x20)..."
+./make_vgrid --nbnds 3 --bnds 10,200,1000 --nz 10,20
+
+echo "*** All gridspec vgrid tests passed!"
+exit 0
diff --git a/gridspec/tools/shared/Makefile.am b/gridspec/tools/shared/Makefile.am
new file mode 100644
index 0000000..c70dcee
--- /dev/null
+++ b/gridspec/tools/shared/Makefile.am
@@ -0,0 +1,76 @@
+## This is an automake file, part of Unidata's NetCDF CF Library
+## package. Copyright 2009, see the COPYRIGHT file for more
+## information.
+
+# This automake file is in charge of building the gridspec
+# tools/shared convenience library.
+
+# $Id: Makefile.am,v 1.4 2009/11/16 14:31:30 zhi Exp $
+
+noinst_LTLIBRARIES = libtoolsshared.la
+libtoolsshared_la_SOURCES = mpp.c mpp_domain.c mpp_domain.h mpp.h	\
+mpp_io.c mpp_io.h tool_util.c tool_util.h create_lonlat_grid.c		\
+create_gnomonic_cubic_grid.c create_grid_from_file.c			\
+create_conformal_cubic_grid.c create_hgrid.h fregrid_util.c fregrid_util.h \
+conserve_interp.c conserve_interp.h bilinear_interp.c bilinear_interp.h \
+topog.c topog.h create_vgrid.c create_vgrid.h \
+make_boundary_contact.c make_boundary_contact.h \
+make_xgrid_contact.c make_xgrid_contact.h
+
+AM_CPPFLAGS = -I../shared -I$(top_srcdir)/gridspec/shared/mosaic 
+
+AM_LDFLAGS =
+LDADD =
+
+if USE_NETCDF_DIR
+AM_CPPFLAGS += -I at NETCDFDIR@/include
+AM_LDFLAGS += -L at NETCDFDIR@/lib
+LDADD += -lnetcdf
+else
+if USE_NETCDF4
+LDADD += ../../../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../../../libsrc4
+else
+LDADD += ../../../../libsrc/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
+endif
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+# If the user specified a root for HDF5, use it.
+if USE_HDF5_DIR
+AM_CPPFLAGS += -I at HDF5DIR@/include
+AM_LDFLAGS += -L at HDF5DIR@/lib
+endif
+
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
+
+
+
+
+
diff --git a/gridspec_tools_20080702/tools/shared/Makefile.in b/gridspec/tools/shared/Makefile.in
similarity index 76%
rename from gridspec_tools_20080702/tools/shared/Makefile.in
rename to gridspec/tools/shared/Makefile.in
index ccc6a6d..3819912 100644
--- a/gridspec_tools_20080702/tools/shared/Makefile.in
+++ b/gridspec/tools/shared/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,12 +18,13 @@
 # This automake file is in charge of building the gridspec
 # tools/shared convenience library.
 
-# $Id: Makefile.am,v 1.8 2009/04/08 15:57:16 ed Exp $
+# $Id: Makefile.am,v 1.4 2009/11/16 14:31:30 zhi Exp $
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -37,15 +39,34 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-
-# If the user specified a root location for NETCDF, use it.
 @USE_NETCDF_DIR_TRUE at am__append_1 = -I at NETCDFDIR@/include
 @USE_NETCDF_DIR_TRUE at am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-subdir = gridspec_tools_20080702/tools/shared
+ at USE_NETCDF_DIR_TRUE@am__append_3 = -lnetcdf
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_4 = ../../../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_5 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_6 = -L../../../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../../../libsrc/libnetcdf.la 
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../../../libsrc
+ at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz 
+ at USE_HDF4_TRUE@am__append_11 = -lmfhdf -ldf -ljpeg
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_12 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_13 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_14 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_15 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_16 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_17 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_18 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_19 = -L at SZLIBDIR@/lib
+subdir = gridspec/tools/shared
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -57,18 +78,20 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libtoolsshared_la_LIBADD =
 am_libtoolsshared_la_OBJECTS = mpp.lo mpp_domain.lo mpp_io.lo \
 	tool_util.lo create_lonlat_grid.lo \
 	create_gnomonic_cubic_grid.lo create_grid_from_file.lo \
 	create_conformal_cubic_grid.lo fregrid_util.lo \
-	conserve_interp.lo bilinear_interp.lo topog.lo get_contact.lo \
-	create_vgrid.lo transfer_to_mosaic.lo
+	conserve_interp.lo bilinear_interp.lo topog.lo create_vgrid.lo \
+	make_boundary_contact.lo make_xgrid_contact.lo
 libtoolsshared_la_OBJECTS = $(am_libtoolsshared_la_OBJECTS)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -95,7 +118,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -112,12 +134,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -133,13 +154,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -156,8 +176,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -202,7 +223,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -213,20 +233,25 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-noinst_LTLIBRARIES = libtoolsshared.la 
+noinst_LTLIBRARIES = libtoolsshared.la
 libtoolsshared_la_SOURCES = mpp.c mpp_domain.c mpp_domain.h mpp.h	\
 mpp_io.c mpp_io.h tool_util.c tool_util.h create_lonlat_grid.c		\
 create_gnomonic_cubic_grid.c create_grid_from_file.c			\
-create_conformal_cubic_grid.c fregrid_util.c conserve_interp.c		\
-bilinear_interp.c topog.c get_contact.c create_vgrid.c			\
-transfer_to_mosaic.c
-
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic -I../make_hgrid \
-	-I../fregrid -I../make_coupler_mosaic -I../make_topog \
-	-I../make_solo_mosaic -I../make_vgrid -I../river_regrid \
-	-I../transfer_to_mosaic_grid $(am__append_1) $(am__append_3)
-AM_LDFLAGS = $(am__append_2) $(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
+create_conformal_cubic_grid.c create_hgrid.h fregrid_util.c fregrid_util.h \
+conserve_interp.c conserve_interp.h bilinear_interp.c bilinear_interp.h \
+topog.c topog.h create_vgrid.c create_vgrid.h \
+make_boundary_contact.c make_boundary_contact.h \
+make_xgrid_contact.c make_xgrid_contact.h
+
+AM_CPPFLAGS = -I../shared -I$(top_srcdir)/gridspec/shared/mosaic \
+	$(am__append_1) $(am__append_5) $(am__append_8) \
+	$(am__append_12) $(am__append_14) $(am__append_16) \
+	$(am__append_18)
+AM_LDFLAGS = $(am__append_2) $(am__append_6) $(am__append_9) \
+	$(am__append_13) $(am__append_15) $(am__append_17) \
+	$(am__append_19)
+LDADD = $(am__append_3) $(am__append_4) $(am__append_7) \
+	$(am__append_10) $(am__append_11)
 all: all-am
 
 .SUFFIXES:
@@ -235,14 +260,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/shared/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/shared/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gridspec/tools/shared/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign gridspec/tools/shared/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -260,6 +285,7 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 
 clean-noinstLTLIBRARIES:
 	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@@ -286,18 +312,18 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_lonlat_grid.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_vgrid.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fregrid_util.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/get_contact.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_boundary_contact.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_xgrid_contact.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mpp.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mpp_domain.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mpp_io.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tool_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/topog.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/transfer_to_mosaic.Plo at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -305,7 +331,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -313,7 +339,7 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
@@ -329,14 +355,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -344,29 +370,34 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -387,13 +418,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -421,6 +456,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -442,6 +478,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -450,18 +488,28 @@ install-data-am:
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am:
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -499,6 +547,7 @@ uninstall-am:
 	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
 	pdf pdf-am ps ps-am tags uninstall uninstall-am
 
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/gridspec_tools_20080702/tools/fregrid/bilinear_interp.c b/gridspec/tools/shared/bilinear_interp.c
similarity index 98%
rename from gridspec_tools_20080702/tools/fregrid/bilinear_interp.c
rename to gridspec/tools/shared/bilinear_interp.c
index 337b2da..1c99cf2 100644
--- a/gridspec_tools_20080702/tools/fregrid/bilinear_interp.c
+++ b/gridspec/tools/shared/bilinear_interp.c
@@ -5,6 +5,7 @@
 #include "mosaic_util.h"
 #include "bilinear_interp.h"
 #include "mpp_io.h"
+#include "mpp.h"
 
 #define min(a,b) (a<b ? a:b)
 #define max(a,b) (a>b ? a:b)
@@ -24,6 +25,9 @@ void do_c2l_interp(const Interp_config *interp, int nx_in, int ny_in, int nz, co
 void sort_index(int ntiles, int *index, double *shortest);
 int get_index(const Grid_config *grid_in, const Grid_config *grid_out, int *index,
 	       int i_in, int j_in, int l_in, int i_out, int j_out);
+int get_closest_index(const Grid_config *grid_in, const Grid_config *grid_out, int *index,
+		      int i_in, int j_in, int l_in, int i_out, int j_out);
+
 /*******************************************************************************
   void setup_bilinear_interp( )
     !------------------------------------------------------------------!
@@ -429,12 +433,13 @@ void do_scalar_bilinear_interp(const Interp_config *interp, int vid, int ntiles_
   ny_out     = grid_out->ny_fine;
   nx_in       = grid_in->nx;
   ny_in       = grid_in->ny;
-  nz          = field_in[0].var[vid].nz;
+  /* currently we are regridding one vertical level for each call to reduce the memory usage */
+  nz = 1;  
   missing     = field_in[0].var[vid].missing;
   has_missing = field_in[0].var[vid].has_missing;
 
   data_fine = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
-
+  
   do_c2l_interp(interp, nx_in, ny_in, nz, field_in, nx_out, ny_out, data_fine, has_missing, missing, fill_missing);
   do_latlon_coarsening(data_fine, grid_out->latt1D_fine, nx_out, ny_out, nz, field_out->data,
 		       finer_step, has_missing, missing);
@@ -464,11 +469,12 @@ void do_vector_bilinear_interp(Interp_config *interp, int vid, int ntiles_in, co
   ny_in       = grid_in->ny;
   nxd         = nx_in + 2;
   nyd         = ny_in + 2;
-  nz          = u_in[0].var[vid].nz;
+  /* currently we are regridding one vertical level for each call to reduce the memory usage */
+  nz = 1;  
   missing     = u_in[0].var[vid].missing;
   has_missing = u_in[0].var[vid].has_missing;
 
-
+  
   x_latlon   = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
   y_latlon   = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
   z_latlon   = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
@@ -552,7 +558,7 @@ void do_c2l_interp(const Interp_config *interp, int nx_in, int ny_in, int nz, co
       d_in[1] = field_in[tile].data[k*nxd*nyd+(jc+1)*nxd+ic];
       d_in[2] = field_in[tile].data[k*nxd*nyd+(jc+1)*nxd+ic+1];
       d_in[3] = field_in[tile].data[k*nxd*nyd+jc    *nxd+ic+1];
-      if (d_in[0] == missing || d_in[1] == missing || d_in[3] == missing || d_in[4] == missing ) {
+      if (d_in[0] == missing || d_in[1] == missing || d_in[2] == missing || d_in[3] == missing ) {
 	if (fill_missing) {
 	  ind = max_weight_index( &(interp->weight[4*n1]), 4);
 	  data_out[k*nx_out*ny_out+n1] = d_in[ind];
diff --git a/gridspec_tools_20080702/tools/fregrid/bilinear_interp.h b/gridspec/tools/shared/bilinear_interp.h
similarity index 100%
rename from gridspec_tools_20080702/tools/fregrid/bilinear_interp.h
rename to gridspec/tools/shared/bilinear_interp.h
diff --git a/gridspec_tools_20080702/tools/shared/conserve_interp.c b/gridspec/tools/shared/conserve_interp.c
similarity index 77%
rename from gridspec_tools_20080702/tools/shared/conserve_interp.c
rename to gridspec/tools/shared/conserve_interp.c
index 05d714d..7639ad2 100644
--- a/gridspec_tools_20080702/tools/shared/conserve_interp.c
+++ b/gridspec/tools/shared/conserve_interp.c
@@ -11,6 +11,7 @@
 #include "fregrid_util.h"
 #include "mpp.h"
 #include "mpp_io.h"
+#include "read_mosaic.h"
 
 #define  AREA_RATIO (1.e-3)
 
@@ -414,128 +415,125 @@ void do_scalar_conserve_interp(Interp_config *interp, int varid, int ntiles_in,
 			       int ntiles_out, const Grid_config *grid_out, const Field_config *field_in,
 			       Field_config *field_out, unsigned int opcode)
 {
-  int nx1, ny1, nx2, ny2, nz, i1, j1, i2, j2, tile, n, k, m, i, j, kk, n1, n2;
-  int has_missing, halo;
+  int nx1, ny1, nx2, ny2, i1, j1, i2, j2, tile, n, m, i, j, n1, n2;
+  int has_missing, halo, interp_method;
   double area, missing, di, dj;
   double *out_area;
 
+  interp_method = field_in->var[varid].interp_method;
   halo = 0;
-  if(opcode & CONSERVE_ORDER2) halo = 1;
+  if(interp_method == CONSERVE_ORDER2) halo = 1;
   
   missing = field_in->var[varid].missing;
   has_missing = field_in->var[varid].has_missing;
-  nz = field_in->var[varid].nz;
   
   for(m=0; m<ntiles_out; m++) {
     nx2 = grid_out[m].nxc;
     ny2 = grid_out[m].nyc;
     out_area = (double *)malloc(nx2*ny2*sizeof(double));
     
-    for(i=0; i<nx2*ny2*nz; i++) field_out[m].data[i] = 0.0;
+    for(i=0; i<nx2*ny2; i++) field_out[m].data[i] = 0.0;
     
-    for(k=0; k<nz; k++) {
-      kk = k*nx2*ny2;
-      for(i=0; i<nx2*ny2; i++) out_area[i] = 0.0;
-      if(opcode & CONSERVE_ORDER1) {
-	if(has_missing) {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];    
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    if( field_in[tile].data[k*nx1*ny1+j1*nx1+i1] != missing ) {
-	      field_out[m].data[kk+j2*nx2+i2] += field_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
-	      out_area[j2*nx2+i2] += area;
-	    }
-	  }
-	}
-	else {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];    
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    field_out[m].data[kk+j2*nx2+i2] += field_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
+    for(i=0; i<nx2*ny2; i++) out_area[i] = 0.0;
+    if(interp_method == CONSERVE_ORDER1) {
+      if(has_missing) {
+	for(n=0; n<interp[m].nxgrid; n++) {
+	  i2   = interp[m].i_out[n];
+	  j2   = interp[m].j_out[n];
+	  i1   = interp[m].i_in [n];
+	  j1   = interp[m].j_in [n];    
+	  tile = interp[m].t_in [n];
+	  area = interp[m].area [n];
+	  nx1  = grid_in[tile].nx;
+	  ny1  = grid_in[tile].ny;
+	  if( field_in[tile].data[j1*nx1+i1] != missing ) {
+	    field_out[m].data[j2*nx2+i2] += field_in[tile].data[j1*nx1+i1]*area;
 	    out_area[j2*nx2+i2] += area;
 	  }
-	}	  
+	}
       }
       else {
-	if(has_missing) {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];
-	    di   = interp[m].di_in[n];
-	    dj   = interp[m].dj_in[n];
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    n2 = k*(nx1+2)*(ny1+2)+(j1+1)*(nx1+2)+i1+1;
-	    if( field_in[tile].data[n2] != missing ) {
-	      n1 = k*nx1*ny1+j1*nx1+i1;
-              if(field_in[tile].grad_mask[n1]) { /* use zero gradient */
-		field_out[m].data[kk+j2*nx2+i2] += field_in[tile].data[n2]*area;
-	      }
-	      else {
-		field_out[m].data[kk+j2*nx2+i2] += (field_in[tile].data[n2]+field_in[tile].grad_x[n1]*di
-						    +field_in[tile].grad_y[n1]*dj)*area;
-	      }
-	      out_area[j2*nx2+i2] += area;
-	    }
-	  }
+	for(n=0; n<interp[m].nxgrid; n++) {
+	  i2   = interp[m].i_out[n];
+	  j2   = interp[m].j_out[n];
+	  i1   = interp[m].i_in [n];
+	  j1   = interp[m].j_in [n];    
+	  tile = interp[m].t_in [n];
+	  area = interp[m].area [n];
+	  nx1  = grid_in[tile].nx;
+	  ny1  = grid_in[tile].ny;
+	  field_out[m].data[j2*nx2+i2] += field_in[tile].data[j1*nx1+i1]*area;
+	  out_area[j2*nx2+i2] += area;
 	}
-	else {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];
-	    di   = interp[m].di_in[n];
-	    dj   = interp[m].dj_in[n];
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    n1 = k*nx1*ny1+j1*nx1+i1;
-	    n2 = k*(nx1+2)*(ny1+2)+(j1+1)*(nx1+2)+i1+1;
-	    field_out[m].data[kk+j2*nx2+i2] += (field_in[tile].data[n2]+field_in[tile].grad_x[n1]*di
-						+field_in[tile].grad_y[n1]*dj)*area;
+      }	  
+    }
+    else {
+      if(has_missing) {
+	for(n=0; n<interp[m].nxgrid; n++) {
+	  i2   = interp[m].i_out[n];
+	  j2   = interp[m].j_out[n];
+	  i1   = interp[m].i_in [n];
+	  j1   = interp[m].j_in [n];
+	  di   = interp[m].di_in[n];
+	  dj   = interp[m].dj_in[n];
+	  tile = interp[m].t_in [n];
+	  area = interp[m].area [n];
+	  nx1  = grid_in[tile].nx;
+	  ny1  = grid_in[tile].ny;
+	  n2 = (j1+1)*(nx1+2)+i1+1;
+	  if( field_in[tile].data[n2] != missing ) {
+	    n1 = j1*nx1+i1;
+	    if(field_in[tile].grad_mask[n1]) { /* use zero gradient */
+	      field_out[m].data[j2*nx2+i2] += field_in[tile].data[n2]*area;
+	    }
+	    else {
+	      field_out[m].data[j2*nx2+i2] += (field_in[tile].data[n2]+field_in[tile].grad_x[n1]*di
+						  +field_in[tile].grad_y[n1]*dj)*area;
+	    }
 	    out_area[j2*nx2+i2] += area;
 	  }
 	}
       }
-      if(opcode & TARGET) {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0)
-	    field_out[m].data[kk+i] /= grid_out[m].area[i];
-	  else
-	    field_out[m].data[kk+i] = missing;
+      else {
+	for(n=0; n<interp[m].nxgrid; n++) {
+	  i2   = interp[m].i_out[n];
+	  j2   = interp[m].j_out[n];
+	  i1   = interp[m].i_in [n];
+	  j1   = interp[m].j_in [n];
+	  di   = interp[m].di_in[n];
+	  dj   = interp[m].dj_in[n];
+	  tile = interp[m].t_in [n];
+	  area = interp[m].area [n];
+	  nx1  = grid_in[tile].nx;
+	  ny1  = grid_in[tile].ny;
+	  n1 = j1*nx1+i1;
+	  n2 = (j1+1)*(nx1+2)+i1+1;
+	  field_out[m].data[j2*nx2+i2] += (field_in[tile].data[n2]+field_in[tile].grad_x[n1]*di
+					      +field_in[tile].grad_y[n1]*dj)*area;
+	  out_area[j2*nx2+i2] += area;
 	}
       }
-      else {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0)
-	    field_out[m].data[kk+i] /= out_area[i];
-	  else
-	    field_out[m].data[kk+i] = missing;
-	}      
+    }
+    if(opcode & TARGET) {
+      for(i=0; i<nx2*ny2; i++) {
+	if(out_area[i] > 0)
+	  field_out[m].data[i] /= grid_out[m].area[i];
+	else
+	  field_out[m].data[i] = missing;
       }
     }
-
-    free(out_area);
+    else {
+      for(i=0; i<nx2*ny2; i++) {
+	if(out_area[i] > 0)
+	  field_out[m].data[i] /= out_area[i];
+	else
+	  field_out[m].data[i] = missing;
+      }      
+    }
   }
 
+  free(out_area);
+
   /* conservation check if needed */
   if(opcode & CHECK_CONSERVE) {
     double gsum_in, gsum_out, dd;
@@ -548,12 +546,9 @@ void do_scalar_conserve_interp(Interp_config *interp, int varid, int ntiles_in,
       area = (double *)malloc(nx1*ny1*sizeof(double));
       get_grid_area(&nx1, &ny1, grid_in[n].lonc, grid_in[n].latc, area);
       
-      for(k=0; k<nz; k++) {
-	kk = k*(nx1+2*halo)*(ny1+2*halo);
-	for(j=0; j<ny1; j++) for(i=0; i<nx1; i++) {
-	  dd = field_in[n].data[kk+(j+halo)*(nx1+2*halo)+i+halo];
-	  if(dd != missing) gsum_in += dd*area[j*nx1+i];
-	}
+      for(j=0; j<ny1; j++) for(i=0; i<nx1; i++) {
+	dd = field_in[n].data[(j+halo)*(nx1+2*halo)+i+halo];
+	if(dd != missing) gsum_in += dd*area[j*nx1+i];
       }
       free(area);
     }
@@ -563,12 +558,9 @@ void do_scalar_conserve_interp(Interp_config *interp, int varid, int ntiles_in,
       area = (double *)malloc(nx2*ny2*sizeof(double));
       get_grid_area(&nx2, &ny2, grid_out[n].lonc, grid_out[n].latc, area);
       
-      for(k=0; k<nz; k++) {
-	kk = k*nx2*ny2;
-	for(j=0; j<ny2; j++) for(i=0; i<nx2; i++) {
-	  dd = field_out[n].data[kk+j*nx2+i];
-	  if(dd != missing) gsum_out += dd*area[j*nx2+i];
-	}
+      for(j=0; j<ny2; j++) for(i=0; i<nx2; i++) {
+	dd = field_out[n].data[j*nx2+i];
+	if(dd != missing) gsum_out += dd*area[j*nx2+i];
       }
       free(area);
     }
@@ -593,25 +585,22 @@ void do_vector_conserve_interp(Interp_config *interp, int varid, int ntiles_in,
                                const Grid_config *grid_out, const Field_config *u_in,  const Field_config *v_in,
                                Field_config *u_out, Field_config *v_out, unsigned int opcode)  
 {
-  int          nx1, ny1, nx2, ny2, nz, i1, j1, i2, j2, tile, n, k, m, i, kk;
+  int          nx1, ny1, nx2, ny2, i1, j1, i2, j2, tile, n, m, i;
   double       area, missing, tmp_x, tmp_y;
   double       *out_area;
 
-  nz = u_in->var[varid].nz;
   missing = u_in->var[varid].missing;  
   /* first rotate input data */
   for(n = 0; n < ntiles_in; n++) {
     if(grid_in[n].rotate) {
       nx1 = grid_in[n].nx;
       ny1 = grid_in[n].ny;
-      for(k = 0; k < nz; k++) {
-	for(i=0; i<nx1*ny1; i++) {
-	  tmp_x = u_in[n].data[k*nx1*ny1+i];
-	  tmp_y = v_in[n].data[k*nx1*ny1+i];
-	  if( tmp_x != missing && tmp_y != missing) {
-	    u_in[n].data[k*nx1*ny1+i] = tmp_x * grid_in[n].cosrot[i] - tmp_y * grid_in[n].sinrot[i];
-	    v_in[n].data[k*nx1*ny1+i] = tmp_x * grid_in[n].sinrot[i] + tmp_y * grid_in[n].cosrot[i];
-	  }
+      for(i=0; i<nx1*ny1; i++) {
+	tmp_x = u_in[n].data[i];
+	tmp_y = v_in[n].data[i];
+	if( tmp_x != missing && tmp_y != missing) {
+	  u_in[n].data[i] = tmp_x * grid_in[n].cosrot[i] - tmp_y * grid_in[n].sinrot[i];
+	  v_in[n].data[i] = tmp_x * grid_in[n].sinrot[i] + tmp_y * grid_in[n].cosrot[i];
 	}
       }
     }
@@ -622,68 +611,65 @@ void do_vector_conserve_interp(Interp_config *interp, int varid, int ntiles_in,
     ny2 = grid_out[m].nyc;
     out_area = (double *)malloc(nx2*ny2*sizeof(double));
     
-    for(i=0; i<nx2*ny2*nz; i++) {
+    for(i=0; i<nx2*ny2; i++) {
       u_out[m].data[i] = 0.0;
       v_out[m].data[i] = 0.0;
     }
-    for(k=0; k<nz; k++) {
-      kk = k*nx2*ny2;
-      for(i=0; i<nx2*ny2; i++) out_area[i] = 0.0;
+    for(i=0; i<nx2*ny2; i++) out_area[i] = 0.0;
     
-      for(n=0; n<interp[m].nxgrid; n++) {
-	i2   = interp[m].i_out[n];
-	j2   = interp[m].j_out[n];
-	i1   = interp[m].i_in [n];
-	j1   = interp[m].j_in [n];    
-	tile = interp[m].t_in [n];
-	area = interp[m].area [n];
-	nx1  = grid_in[tile].nx;
-	ny1  = grid_in[tile].ny;
-	tmp_x = u_in[tile].data[k*nx1*ny1+j1*nx1+i1];
-	tmp_y = v_in[tile].data[k*nx1*ny1+j1*nx1+i1];
-	if( tmp_x != missing && tmp_y != missing ) {
-	  u_out[m].data[kk+j2*nx2+i2] += u_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
-	  v_out[m].data[kk+j2*nx2+i2] += v_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
-	  out_area[j2*nx2+i2] += area;
-	}
+    for(n=0; n<interp[m].nxgrid; n++) {
+      i2   = interp[m].i_out[n];
+      j2   = interp[m].j_out[n];
+      i1   = interp[m].i_in [n];
+      j1   = interp[m].j_in [n];    
+      tile = interp[m].t_in [n];
+      area = interp[m].area [n];
+      nx1  = grid_in[tile].nx;
+      ny1  = grid_in[tile].ny;
+      tmp_x = u_in[tile].data[j1*nx1+i1];
+      tmp_y = v_in[tile].data[j1*nx1+i1];
+      if( tmp_x != missing && tmp_y != missing ) {
+	u_out[m].data[j2*nx2+i2] += u_in[tile].data[j1*nx1+i1]*area;
+	v_out[m].data[j2*nx2+i2] += v_in[tile].data[j1*nx1+i1]*area;
+	out_area[j2*nx2+i2] += area;
       }
-      if(opcode & TARGET) {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0) {
-	    u_out[m].data[kk+i] /= grid_out[m].area[i];
-	    v_out[m].data[kk+i] /= grid_out[m].area[i];
-	  }
-	  else {
-	    u_out[m].data[kk+i] = missing;
-	    v_out[m].data[kk+i] = missing;
-	  }
+    }
+    if(opcode & TARGET) {
+      for(i=0; i<nx2*ny2; i++) {
+	if(out_area[i] > 0) {
+	  u_out[m].data[i] /= grid_out[m].area[i];
+	  v_out[m].data[i] /= grid_out[m].area[i];
+	}
+	else {
+	  u_out[m].data[i] = missing;
+	  v_out[m].data[i] = missing;
 	}
       }
-      else {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0) {
-	    u_out[m].data[kk+i] /= out_area[i];
-	    v_out[m].data[kk+i] /= out_area[i];
-	  }
-	  else {
-	    u_out[m].data[kk+i] = missing;
-	    v_out[m].data[kk+i] = missing;
-	  }
-	}      
-      }
-      /* rotate the data if needed */
-      if(grid_out[m].rotate) {
-	for(i=0; i<nx2*ny2; i++) {
-	  tmp_x = u_out[m].data[k*nx2*ny2+i];
-	  tmp_y = v_out[m].data[k*nx2*ny2+i];
-	  if( tmp_x != missing && tmp_y != missing) {
-	    u_out[m].data[k*nx2*ny2+i] =  tmp_x * grid_out[m].cosrot[i] + tmp_y * grid_out[m].sinrot[i];
-	    v_out[m].data[k*nx2*ny2+i] = -tmp_x * grid_out[m].sinrot[i] + tmp_y * grid_out[m].cosrot[i];
-	  }
+    }
+    else {
+      for(i=0; i<nx2*ny2; i++) {
+	if(out_area[i] > 0) {
+	  u_out[m].data[i] /= out_area[i];
+	  v_out[m].data[i] /= out_area[i];
+	}
+	else {
+	  u_out[m].data[i] = missing;
+	  v_out[m].data[i] = missing;
+	}
+      }      
+    }
+    /* rotate the data if needed */
+    if(grid_out[m].rotate) {
+      for(i=0; i<nx2*ny2; i++) {
+	tmp_x = u_out[m].data[i];
+	tmp_y = v_out[m].data[i];
+	if( tmp_x != missing && tmp_y != missing) {
+	  u_out[m].data[i] =  tmp_x * grid_out[m].cosrot[i] + tmp_y * grid_out[m].sinrot[i];
+	  v_out[m].data[i] = -tmp_x * grid_out[m].sinrot[i] + tmp_y * grid_out[m].cosrot[i];
 	}
       }
     }
     free(out_area);
-  }    
+  }
   
 }; /* do_vector_conserve_interp */
diff --git a/gridspec_tools_20080702/tools/fregrid/conserve_interp.h b/gridspec/tools/shared/conserve_interp.h
similarity index 100%
rename from gridspec_tools_20080702/tools/fregrid/conserve_interp.h
rename to gridspec/tools/shared/conserve_interp.h
diff --git a/gridspec_tools_20080702/tools/shared/create_conformal_cubic_grid.c b/gridspec/tools/shared/create_conformal_cubic_grid.c
similarity index 99%
rename from gridspec_tools_20080702/tools/shared/create_conformal_cubic_grid.c
rename to gridspec/tools/shared/create_conformal_cubic_grid.c
index b044ea7..4809157 100644
--- a/gridspec_tools_20080702/tools/shared/create_conformal_cubic_grid.c
+++ b/gridspec/tools/shared/create_conformal_cubic_grid.c
@@ -2,6 +2,8 @@
 #include <stdio.h>
 #include <complex.h>
 #include <math.h>
+#include <string.h>
+#include "mpp.h"
 #include "mosaic_util.h"
 #include "tool_util.h"
 #include "constant.h"
@@ -243,8 +245,8 @@ void conformal_map_coords2xyz ( int ni, int nj, double *lx, double *ly,
 {
   const double RA = sqrt(3.)-1;
   const double THRD = 1./3.;
-  const complex CB = -1. + I;
-  const complex CC = RA*CB/2.;
+  const double complex CB = -1. + I;
+  const double complex CC = RA*CB/2.;
   const int order = 29;
   const double A[] = { 1.47713057321600,
 		       -0.38183513110512,
@@ -277,7 +279,7 @@ void conformal_map_coords2xyz ( int ni, int nj, double *lx, double *ly,
 		       -0.00010518717478,
 		       -0.00009749136078,
   };
-  complex w, zc,a,b;
+  double complex w, zc,a,b;
   int i, j, n, m;
   double xc, yc, h, t;
   size_t *dims;
diff --git a/gridspec_tools_20080702/tools/make_hgrid/create_gnomonic_cubic_grid.c b/gridspec/tools/shared/create_gnomonic_cubic_grid.c
similarity index 99%
rename from gridspec_tools_20080702/tools/make_hgrid/create_gnomonic_cubic_grid.c
rename to gridspec/tools/shared/create_gnomonic_cubic_grid.c
index 8d37c16..5f3b4fb 100644
--- a/gridspec_tools_20080702/tools/make_hgrid/create_gnomonic_cubic_grid.c
+++ b/gridspec/tools/shared/create_gnomonic_cubic_grid.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
+#include "mpp.h"
 #include "constant.h"
 #include "mosaic_util.h"
 #include "tool_util.h"
diff --git a/gridspec_tools_20080702/tools/make_hgrid/create_grid_from_file.c b/gridspec/tools/shared/create_grid_from_file.c
similarity index 73%
rename from gridspec_tools_20080702/tools/make_hgrid/create_grid_from_file.c
rename to gridspec/tools/shared/create_grid_from_file.c
index 3dc60cc..e639d62 100644
--- a/gridspec_tools_20080702/tools/make_hgrid/create_grid_from_file.c
+++ b/gridspec/tools/shared/create_grid_from_file.c
@@ -3,6 +3,7 @@
 #include <complex.h>
 #include <math.h>
 #include <string.h>
+#include "mpp.h"
 #include "mosaic_util.h"
 #include "tool_util.h"
 #include "constant.h"
@@ -23,6 +24,7 @@ void create_grid_from_file( char *file, int *nlon, int *nlat, double *x, double
   double *xb, *yb, *xt, *yt, *xc, *yc;
   double p1[4], p2[4];
   int nx, ny, nxp, nyp, ni, nj, i, j, n;
+  int is_uniform;
   FILE *pFile;
   char mesg[256], txt[128];
   
@@ -62,28 +64,53 @@ void create_grid_from_file( char *file, int *nlon, int *nlat, double *x, double
       x[(j*2+1)*nxp+i*2+1] = xt[j*ni+i];
       y[(j*2+1)*nxp+i*2+1] = yt[j*ni+i];
     }
-    for(j=0; j<nj+1; j++) for(i=0; i<ni; i++) {
-      x[j*2*nxp+i*2+1] = (xc[j*(ni+1)+i]+xc[j*(ni+1)+i+1])*0.5;
-      y[j*2*nxp+i*2+1] = (yc[j*(ni+1)+i]+yc[j*(ni+1)+i+1])*0.5;
-    }    
-    for(j=0; j<nj; j++) for(i=0; i<ni+1; i++) {
-      x[(j*2+1)*nxp+i*2] = (xc[j*(ni+1)+i]+xc[(j+1)*(ni+1)+i])*0.5;
-      y[(j*2+1)*nxp+i*2] = (yc[j*(ni+1)+i]+yc[(j+1)*(ni+1)+i])*0.5;
+    /* check if the grid is uniform of not */
+    is_uniform = 1;
+    for(j=0; j<nj; j++) {
+      for(i=1; i<ni; i++) {
+	if(yt[j*ni+i] != yt[j*ni]) is_uniform = 0;
+      }
+    }
+    
+    for(i=0; i<ni; i++) {
+      for(j=1; j<nj; j++) {
+	if(xt[j*ni+i] != xt[i]) is_uniform = 0;
+      }
     }
 
+    if(is_uniform) {
+       for(j=0; j<nj+1; j++) for(i=0; i<ni; i++) {
+         x[j*2*nxp+i*2+1] = xt[i];   
+         y[j*2*nxp+i*2+1] = yc[j*(ni+1)+i];
+       }
+       for(j=0; j<nj; j++) for(i=0; i<ni+1; i++) {
+	 x[(j*2+1)*nxp+i*2] = xc[j*(ni+1)+i];
+	 y[(j*2+1)*nxp+i*2] = yt[j*ni];
+       }
+    }
+    else {
+      for(j=0; j<nj+1; j++) for(i=0; i<ni; i++) {
+	x[j*2*nxp+i*2+1] = (xc[j*(ni+1)+i]+xc[j*(ni+1)+i+1])*0.5;
+	y[j*2*nxp+i*2+1] = (yc[j*(ni+1)+i]+yc[j*(ni+1)+i+1])*0.5;
+      }    
+      for(j=0; j<nj; j++) for(i=0; i<ni+1; i++) {
+	x[(j*2+1)*nxp+i*2] = (xc[j*(ni+1)+i]+xc[(j+1)*(ni+1)+i])*0.5;
+	y[(j*2+1)*nxp+i*2] = (yc[j*(ni+1)+i]+yc[(j+1)*(ni+1)+i])*0.5;
+      }
+    }
     for(j=0; j<nyp; j++) for(i=0; i<nx; i++) {
-      p1[0] = x[j*nxp+i]; p2[0] = x[j*nxp+i+1];
-      p1[1] = y[j*nxp+i]; p2[1] = y[j*nxp+i+1];
+      p1[0] = x[j*nxp+i]*D2R; p2[0] = x[j*nxp+i+1]*D2R;
+      p1[1] = y[j*nxp+i]*D2R; p2[1] = y[j*nxp+i+1]*D2R;
       dx[j*nx+i] = great_circle_distance(p1, p2);
     }
     for(j=0; j<ny; j++) for(i=0; i<nxp; i++) {
-      p1[0] = x[j*nxp+i]; p2[0] = x[(j+1)*nxp+i];
-      p1[1] = y[j*nxp+i]; p2[1] = y[(j+1)*nxp+i];
+      p1[0] = x[j*nxp+i]*D2R; p2[0] = x[(j+1)*nxp+i]*D2R;
+      p1[1] = y[j*nxp+i]*D2R; p2[1] = y[(j+1)*nxp+i]*D2R;
       dy[j*nxp+i] = great_circle_distance(p1, p2);
     }    
     for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-      p1[0] = x[j*nxp+i]; p1[1] = x[j*nxp+i+1]; p1[2] = x[(j+1)*nxp+i+1]; p1[3] = x[(j+1)*nxp+i];
-      p2[0] = y[j*nxp+i]; p2[1] = y[j*nxp+i+1]; p2[2] = y[(j+1)*nxp+i+1]; p2[3] = y[(j+1)*nxp+i];
+      p1[0] = x[j*nxp+i]*D2R; p1[1] = x[j*nxp+i+1]*D2R; p1[2] = x[(j+1)*nxp+i+1]*D2R; p1[3] = x[(j+1)*nxp+i]*D2R;
+      p2[0] = y[j*nxp+i]*D2R; p2[1] = y[j*nxp+i+1]*D2R; p2[2] = y[(j+1)*nxp+i+1]*D2R; p2[3] = y[(j+1)*nxp+i]*D2R;
       area[j*nx+i] = poly_area(p1, p2, 4);
     }
     /* currently set angle to 0 */
diff --git a/gridspec_tools_20080702/tools/make_hgrid/create_hgrid.h b/gridspec/tools/shared/create_hgrid.h
similarity index 89%
rename from gridspec_tools_20080702/tools/make_hgrid/create_hgrid.h
rename to gridspec/tools/shared/create_hgrid.h
index 88ac844..964c323 100644
--- a/gridspec_tools_20080702/tools/make_hgrid/create_hgrid.h
+++ b/gridspec/tools/shared/create_hgrid.h
@@ -7,17 +7,17 @@
   contact: Zhi.Liang at noaa.gov
 
 *******************************************************************************/
-#ifdef CREATE_HGRID_H_
+#ifndef CREATE_HGRID_H_
 #define CREATE_HGRID_H_
 void create_regular_lonlat_grid( int *nxbnds, int *nybnds, double *xbnds, double *ybnds,
 		         	 int *nlon, int *nlat, int *isc, int *iec,
 				 int *jsc, int *jec, double *x, double *y, double *dx,
-				 double *dy, double *area, double *angle_dx, char *center_cell );
+				 double *dy, double *area, double *angle_dx, const char *center );
 
 void create_simple_cartesian_grid( double *xbnds, double *ybnds, int *nlon, int *nlat,
 				   double *simple_dx, double *simple_dy, int *isc, int *iec,
 				   int *jsc, int *jec, double *x, double *y,
-				   double *dx, double *dy, double *area, double *angle_dx, char *center_cell );
+				   double *dx, double *dy, double *area, double *angle_dx);
 
 void create_grid_from_file( char *file, int *nlon, int *nlat, double *x, double *y, double *dx, double *dy,
            		    double *area, double *angle_dx );
@@ -29,7 +29,7 @@ void create_spectral_grid( int *nlon, int *nlat, int *isc, int *iec,
 void create_tripolar_grid( int *nxbnds, int *nybnds, double *xbnds, double *ybnds,
 			   int *nlon, int *nlat, double *lat_join_in, int *isc, int *iec,
 			   int *jsc, int *jec, double *x, double *y, double *dx, double *dy,
-			   double *area, double *angle_dx );
+			   double *area, double *angle_dx, const char *center  );
 
 void create_conformal_cubic_grid( int *npts, int *nratio, char *method, char *orientation, double *x,
 			          double *y, double *dx, double *dy, double *area, double *angle_dx,
diff --git a/gridspec_tools_20080702/tools/shared/create_lonlat_grid.c b/gridspec/tools/shared/create_lonlat_grid.c
similarity index 99%
rename from gridspec_tools_20080702/tools/shared/create_lonlat_grid.c
rename to gridspec/tools/shared/create_lonlat_grid.c
index f562c69..6636ecf 100644
--- a/gridspec_tools_20080702/tools/shared/create_lonlat_grid.c
+++ b/gridspec/tools/shared/create_lonlat_grid.c
@@ -3,6 +3,7 @@
 #include <complex.h>
 #include <math.h>
 #include <string.h>
+#include "mpp.h"
 #include "mosaic_util.h"
 #include "interp.h"
 #include "tool_util.h"
diff --git a/gridspec_tools_20080702/tools/make_vgrid/create_vgrid.c b/gridspec/tools/shared/create_vgrid.c
similarity index 100%
rename from gridspec_tools_20080702/tools/make_vgrid/create_vgrid.c
rename to gridspec/tools/shared/create_vgrid.c
diff --git a/gridspec_tools_20080702/tools/make_vgrid/create_vgrid.h b/gridspec/tools/shared/create_vgrid.h
similarity index 100%
rename from gridspec_tools_20080702/tools/make_vgrid/create_vgrid.h
rename to gridspec/tools/shared/create_vgrid.h
diff --git a/gridspec_tools_20080702/tools/fregrid/fregrid_util.c b/gridspec/tools/shared/fregrid_util.c
similarity index 78%
rename from gridspec_tools_20080702/tools/fregrid/fregrid_util.c
rename to gridspec/tools/shared/fregrid_util.c
index 2e12176..f17b5ca 100644
--- a/gridspec_tools_20080702/tools/fregrid/fregrid_util.c
+++ b/gridspec/tools/shared/fregrid_util.c
@@ -3,9 +3,13 @@
 #include <math.h>
 #include <string.h>
 #include "fregrid_util.h"
+#include "mpp.h"
 #include "mpp_io.h"
+#include "tool_util.h"
 #include "mosaic_util.h"
+#include "read_mosaic.h"
 #include "gradient_c2l.h"
+#include "globals.h"
 
 #define D2R (M_PI/180)
 #define R2D (180/M_PI)
@@ -14,6 +18,8 @@ void init_halo(double *var, int nx, int ny, int nz, int halo);
 void update_halo(int nx, int ny, int nz, double *data, Bound_config *bound, Data_holder *dHold);
 void setup_boundary(const char *mosaic_file, int ntiles, Grid_config *grid, Bound_config *bound, int halo, int position);
 void delete_bound_memory(int ntiles, Bound_config *bound);
+void copy_var_config(const Var_config *var_in, Var_config *var_out);
+void init_var_config(Var_config *var, int interp_method);
 /*******************************************************************************
   void setup_tile_data_file(Mosaic_config mosaic, const char *filename)
   This routine will setup the data file name for each tile.
@@ -23,7 +29,8 @@ void set_mosaic_data_file(int ntiles, const char *mosaic_file, const char *dir,
 			  const char *filename)
 {
   char   str1[STRING]="", str2[STRING]="", tilename[STRING]="";
-  int    i, n, len, fid, vid;
+  char   gridfile[STRING], gridpath[STRING], griddir[STRING];
+  int    i, len, fid, vid, gid, g_fid;
   size_t start[4], nread[4];
 
   len = strlen(filename); 
@@ -45,19 +52,25 @@ void set_mosaic_data_file(int ntiles, const char *mosaic_file, const char *dir,
   nread[1] = STRING;
   if(ntiles > 1) {
     if(!mosaic_file) mpp_error("fregrid_util: when ntiles is greater than 1, mosaic_file should be defined");
+    get_file_path(mosaic_file, griddir);
     fid = mpp_open(mosaic_file, MPP_READ);
-    vid = mpp_get_varid(fid, "gridtiles");
-  }
-  for(i = 0; i < ntiles; i++) {
-    start[0] = i;
-    if(ntiles > 1) {
-      mpp_get_var_value_block(fid, vid, start, nread, tilename);
+    gid = mpp_get_varid(fid, TILE_FILES_NAME);
+    for(i = 0; i < ntiles; i++) {
+      start[0] = i; start[1] = 0; nread[0] = 1; nread[1] = STRING;
+      mpp_get_var_value_block(fid, gid, start, nread, gridfile);
+      sprintf(gridpath, "%s/%s", griddir, gridfile);
+      g_fid = mpp_open(gridpath, MPP_READ);
+      vid   = mpp_get_varid(g_fid, TILE_NAME);
+      mpp_get_var_value(g_fid, vid, tilename);
+      mpp_close(g_fid);
       if(strlen(str2) + strlen(tilename) > STRING -5) mpp_error("set_mosaic_data_file(fregrid_util): length of str2 + "
 								"length of tilename should be no greater than STRING-5");
       sprintf(file[i].name, "%s.%s.nc", str2, tilename);
     }
-    else 
-      sprintf(file[i].name, "%s.nc", str2);
+    mpp_close(fid);
+  }
+  else {
+    for(i = 0; i < ntiles; i++) sprintf(file[i].name, "%s.nc", str2);
   }
 
 }; /* setup_data_file */
@@ -113,7 +126,7 @@ void get_input_grid(int ntiles, Grid_config *grid, Bound_config *bound_T, const
   get_file_path(mosaic_file, dir);
   for(n=0; n<ntiles; n++) {
     start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-    vid = mpp_get_varid(m_fid, "gridfiles");
+    vid = mpp_get_varid(m_fid, TILE_FILES_NAME);
     mpp_get_var_value_block(m_fid, vid, start, nread, filename);
     sprintf(grid_file, "%s/%s", dir, filename);
     g_fid = mpp_open(grid_file, MPP_READ);
@@ -308,7 +321,7 @@ void get_output_grid_from_mosaic(int ntiles, Grid_config *grid, const char *mosa
   
   for(n=0; n<ntiles; n++) {
     start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-    vid = mpp_get_varid(m_fid, "gridfiles");
+    vid = mpp_get_varid(m_fid, TILE_FILES_NAME);
     mpp_get_var_value_block(m_fid, vid, start, nread, filename);
     sprintf(grid_file, "%s/%s", dir, filename);
     g_fid = mpp_open(grid_file, MPP_READ);
@@ -347,8 +360,8 @@ void get_output_grid_from_mosaic(int ntiles, Grid_config *grid, const char *mosa
       grid[n].lonc[j*(grid[n].nxc+1)+i] = x[jj*(2*nx[n]+1)+ii] * D2R;
       grid[n].latc[j*(grid[n].nxc+1)+i] = y[jj*(2*nx[n]+1)+ii] * D2R;
     }
-    for(i=0; i<nx[n]+1; i++) grid[n].lonc1D[i] = x[i] * D2R;
-    for(j=0; j<ny[n]+1; j++) grid[n].latc1D[j] = y[j*(nx[n]+1)] * D2R;
+    for(i=0; i<nx[n]+1; i++) grid[n].lonc1D[i] = x[2*i] * D2R;
+    for(j=0; j<ny[n]+1; j++) grid[n].latc1D[j] = y[2*j*(2*nx[n]+1)] * D2R;
 
     for(i=0; i<nx[n]; i++) grid[n].lont1D[i] = x[2*nx[n]+1+2*i+1] * D2R;
     for(j=0; j<ny[n]; j++) grid[n].latt1D[j] = y[(2*j+1)*(2*nx[n]+1) + 1] * D2R;
@@ -488,23 +501,83 @@ void get_output_grid_by_size(int ntiles, Grid_config *grid, double lonbegin, dou
   }
   
 }; /* get_output_grid_by_size */
+
+
+/*******************************************************************************
+void init_var_config(Var_config *var)
+*******************************************************************************/
+void init_var_config(Var_config *var, int interp_method)
+{
+  var->nz            = 1;
+  var->nn            = 1;
+  var->has_naxis     = 0;
+  var->has_zaxis     = 0;
+  var->has_taxis     = 0;  
+  var->kstart        = 0;
+  var->kend          = 0;
+  var->lstart        = 0;
+  var->lend          = 0;
+  var->ndim          = 0;
+  var->interp_method = interp_method;
+  
+}
+
+/*******************************************************************************
+void copy_var_config(Var_config *var)
+*******************************************************************************/
+void copy_var_config(const Var_config *var_in, Var_config *var_out)
+{
+  int i;
+  
+  var_out->nz            = var_in->nz;
+  var_out->nn            = var_in->nn;
+  var_out->has_naxis     = var_in->has_naxis;
+  var_out->has_zaxis     = var_in->has_zaxis;
+  var_out->has_taxis     = var_in->has_taxis;
+  var_out->kstart        = var_in->kstart;
+  var_out->kend          = var_in->kend ;
+  var_out->lstart        = var_in->lstart;
+  var_out->lend          = var_in->lend;
+  var_out->ndim          = var_in->ndim;
+  var_out->interp_method = var_in->interp_method;
+  for(i=0; i<var_in->ndim; i++) var_out->index[i] = var_in->index[i];
+}
   
+
 /*******************************************************************************
   void get_input_metadata(Mosaic_config, *mosaic)
 *******************************************************************************/
 void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config *file2,
 		        Field_config *scalar, Field_config *u_comp, Field_config *v_comp,
-			const Grid_config *grid, int kbegin, int kend, int lbegin, int lend)
+			const Grid_config *grid, int kbegin, int kend, int lbegin, int lend,
+			unsigned int opcode)
 {
   int     n, m, i, l, ll, nscalar, nvector, nfield;
   int     ndim, dimsize[4], nz;
-  nc_type type[4];
-  char    cart[4];
-  char    dimname[4][STRING], bndname[4][STRING], errmsg[STRING];
+  nc_type type[5];
+  char    cart[5];
+  char    dimname[5][STRING], bndname[5][STRING], errmsg[STRING];
   File_config  *file  = NULL;
   Field_config *field = NULL;
   size_t start[4], nread[4];
+  int interp_method, use_bilinear, use_conserve;
+  char    remap_method[STRING];
   
+  use_bilinear = 0;
+  use_conserve = 0;
+  if(opcode & CONSERVE_ORDER1) {
+    use_conserve = 1;
+    interp_method = CONSERVE_ORDER1;
+  }
+  else if(opcode & CONSERVE_ORDER2) {
+    use_conserve = 1;
+    interp_method = CONSERVE_ORDER2;
+  }
+  else if(opcode & BILINEAR) {
+    use_bilinear = 1;
+    interp_method = BILINEAR;
+  }
+    
   /* First find out how many fields in file and file2. */
   nscalar = 0;
   nvector = 0;
@@ -526,30 +599,12 @@ void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config
   }
              
   for(l=0; l<nscalar; l++) for(n=0; n<ntiles; n++) {
-    scalar[n].var[l].nz        = 1;
-    scalar[n].var[l].has_zaxis = 0;
-    scalar[n].var[l].has_taxis = 0;
-    scalar[n].var[l].kstart    = 0;
-    scalar[n].var[l].kend      = 0;
-    scalar[n].var[l].lstart    = 0;
-    scalar[n].var[l].lend      = 0;
+    init_var_config(scalar[n].var+l, interp_method);
   }
     
   for(l=0; l<nvector; l++) for(n=0; n<ntiles; n++) {
-    u_comp[n].var[l].nz        = 1;
-    u_comp[n].var[l].has_zaxis = 0;
-    u_comp[n].var[l].has_taxis = 0;
-    u_comp[n].var[l].kstart    = 0;
-    u_comp[n].var[l].kend      = 0;
-    u_comp[n].var[l].lstart    = 0;
-    u_comp[n].var[l].lend      = 0;
-    v_comp[n].var[l].nz        = 1;
-    v_comp[n].var[l].has_zaxis = 0;
-    v_comp[n].var[l].has_taxis = 0;
-    v_comp[n].var[l].kstart    = 0;
-    v_comp[n].var[l].kend      = 0;
-    v_comp[n].var[l].lstart    = 0;
-    v_comp[n].var[l].lend      = 0;   
+    init_var_config(u_comp[n].var+l, interp_method);
+    init_var_config(v_comp[n].var+l, interp_method);
   }
   
   nfield = (nfiles == 1)? (nscalar+2*nvector):nvector;  /* when nfiles = 2, no scalar */
@@ -579,12 +634,41 @@ void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config
 
       	field[n].var[ll].vid = mpp_get_varid(file[n].fid, field[n].var[ll].name);
 	field[n].var[ll].type  = mpp_get_var_type(file[n].fid, field[n].var[ll].vid);
+	if(field[n].var[ll].type != NC_SHORT && field[n].var[ll].type != NC_INT &&
+	   field[n].var[ll].type != NC_FLOAT && field[n].var[ll].type != NC_DOUBLE ) {
+	  sprintf(errmsg, "fregrid_util(get_input_metadata): field %s in file %s has an invalid type, "
+		  "the type should be NC_DOUBLE, NC_FLOAT, NC_INT or NC_SHORT", field[n].var[ll].name, file[n].name );
+	  mpp_error(errmsg);
+	}
         /* check if time_avg_info attribute existed in any variables */
 	if(!file[n].has_tavg_info) {
 	  if(mpp_var_att_exist(file[n].fid, field[n].var[ll].vid, "time_avg_info") ) file[n].has_tavg_info = 1;
 	}
-	ndim = mpp_get_var_ndim(file[n].fid, field[n].var[ll].vid);
+	/* get the interp_method from the field attribute if existing */
+	if(mpp_var_att_exist(file[n].fid, field[n].var[ll].vid, "interp_method")) {
+	  mpp_get_var_att(file[n].fid, field[n].var[ll].vid, "interp_method", remap_method);
+	  if(!strcmp(remap_method, "conserve_order1") ) {
+	    use_conserve = 1;
+	    field[n].var[ll].interp_method = CONSERVE_ORDER1;
+	  }
+	  else if(!strcmp(remap_method, "conserve_order2") ) {
+	    use_conserve = 1;
+	    field[n].var[ll].interp_method = CONSERVE_ORDER2;
+	  }
+	  else if(!strcmp(remap_method, "bilinear") ) {
+	    use_bilinear = 1;
+	    field[n].var[ll].interp_method = BILINEAR;
+	  }
+	  else {
+	    sprintf(errmsg, "get_input_metadata(fregrid_util.c): in file %s, attribute interp_method of field %s has value = %s"
+		    "is not suitable, it should be conserve_order1, conserve_order2 or bilinear", file[n].name,
+		    field[n].var[ll].name, remap_method);
+      	    mpp_error(errmsg);
+	  }
+	}
 	
+	ndim = mpp_get_var_ndim(file[n].fid, field[n].var[ll].vid);
+	if(ndim <2 || ndim>5) mpp_error("get_input_metadata(fregrid_util.c): ndim should be no less than 2 and no larger than 5");	
 	for(i=0; i<ndim; i++) {
 	  int vid;
           mpp_get_var_dimname(file[n].fid, field[n].var[ll].vid, i, dimname[i]);
@@ -595,30 +679,44 @@ void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config
 	  mpp_get_var_bndname(file[n].fid, vid, bndname[i]);
       	}
 	field[n].var[ll].ndim = ndim;
-	if(ndim <2 || ndim>4) mpp_error("get_input_metadata(fregrid_util.c): ndim should be no less than 2 and no larger than 4");
 	if(cart[ndim-1] != 'X') mpp_error("get_input_metadata(fregrid_util.c): the last dimension cartesian should be 'X'");
 	if(cart[ndim-2] != 'Y') mpp_error("get_input_metadata(fregrid_util.c): the second last dimension cartesian should be 'Y'");
 	if(dimsize[ndim-1] != grid[n].nx) mpp_error("get_input_metadata(fregrid_util.c): x-size in grid file in not the same as in data file");
-	if(dimsize[ndim-2] != grid[n].ny) mpp_error("get_input_metadata(fregrid_util.c): y-size in grid file in not the same as in data file");	
-	if(cart[0] == 'Z' || cart[1] == 'Z') {
-	  field[n].var[ll].has_zaxis = 1;
-	  field[n].var[ll].nz        = cart[0] == 'Z'? dimsize[0]:dimsize[1];
-	  /* the selected vertical level should be between 1 and nz. */
-	  if(kend > field[n].var[ll].nz) {
-	    sprintf(errmsg, "get_input_metadata(fregrid_util.c): KlevelEnd should be no larger than "
-		    "number of vertical levels of field %s in file %s.", field[n].var[ll].name, file[n].name);
-	    mpp_error(errmsg);
+	if(dimsize[ndim-2] != grid[n].ny) mpp_error("get_input_metadata(fregrid_util.c): y-size in grid file in not the same as in data file");
+        if(ndim > 2) {
+	  if(cart[ndim-3] == 'Z') {
+	    field[n].var[ll].has_zaxis = 1;
+	    field[n].var[ll].nz        = dimsize[ndim-3];
+	    if(kend > field[n].var[ll].nz) {
+	      sprintf(errmsg, "get_input_metadata(fregrid_util.c): KlevelEnd should be no larger than "
+		      "number of vertical levels of field %s in file %s.", field[n].var[ll].name, file[n].name);
+	      mpp_error(errmsg);
+	    }
+	    if(kbegin>0) {
+	      field[n].var[ll].kstart = kbegin - 1;
+	      field[n].var[ll].kend   = kend - 1;
+	      field[n].var[ll].nz     = kend - kbegin + 1;
+	    }
+	    else {
+	      field[n].var[ll].kstart = 0;
+	      field[n].var[ll].kend   = field[n].var[ll].nz - 1;
+	    }	    
 	  }
-	  if(kbegin>0) {
-	    field[n].var[ll].kstart = kbegin - 1;
-	    field[n].var[ll].kend   = kend - 1;
-	    field[n].var[ll].nz     = kend - kbegin + 1;
+	  else if(cart[ndim-3] == 'N') {
+	    field[n].var[ll].has_naxis = 1;
+	    field[n].var[ll].nn        = dimsize[ndim-3];
 	  }
-	  else {
-	    field[n].var[ll].kstart = 0;
-	    field[n].var[ll].kend   = field[n].var[ll].nz - 1;
+	}
+	if(ndim > 3) {
+	  if(cart[ndim-4] == 'Z') {
+	    mpp_error("get_input_metadata(fregrid_util.c): the Z-axis must be the third dimension");
+	  }
+	  if(cart[ndim-4] == 'N') {
+	    field[n].var[ll].has_naxis = 1;
+	    field[n].var[ll].nn        = dimsize[ndim-4];
 	  }
 	}
+	  
 	if(cart[0] == 'T') {
 	  field[n].var[ll].has_taxis = 1;
 	  if(lend > dimsize[0]) {
@@ -720,6 +818,8 @@ void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config
 	}      
 	if(field[n].var[ll].ndim != field[0].var[ll].ndim)
 	  mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for var ndim");
+	if(field[n].var[ll].interp_method != field[0].var[ll].interp_method)
+	  mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for interp_method");
 	for(i=0; i<field[n].var[ll].ndim; i++) {  
 	  if(field[n].var[ll].index[i] != field[0].var[ll].index[i])
 	    mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for var dimindex");
@@ -740,7 +840,7 @@ void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config
 	  start[0] = lbegin-1;
 	else
 	  start[0] = 0;
-	  nread[0] = file[n].nt; nread[1] = 1; 
+	nread[0] = file[n].nt; nread[1] = 1; 
 	mpp_get_var_value_block(file[n].fid, file[n].id_t1, start, nread, file[n].t1);
 	mpp_get_var_value_block(file[n].fid, file[n].id_t2, start, nread, file[n].t2);	
 	mpp_get_var_value_block(file[n].fid, file[n].id_dt, start, nread, file[n].dt);
@@ -749,6 +849,11 @@ void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config
 
   } /*nfile*/
 
+  /* make sure bilinear and conservative interpolation do not co-exist. */
+  if(use_bilinear && use_conserve) mpp_error("get_input_metadata(fregrid_util.c): bilinear interpolation and conservative "
+					     "interpolation can not co-exist, check you option interp_method in command "
+					     "line and field attribute interp_method in source file");
+  
 }; /* get_input_metadata */
   
 
@@ -762,48 +867,25 @@ void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in
 			  Field_config *u_out, Field_config *v_out, const Grid_config *grid_out,
 			  const char *history, const char *tagname)
 {
-  int m, n, ndim, i, l, dims[4];
+  int m, n, ndim, i, l, dims[5];
   int dim_bnds, dim_time;
   int nscalar, nvector;
   const File_config *file_in = NULL;
   File_config *file_out = NULL;
 
+  
   nscalar = 0;
   nvector = 0;
   if( scalar_in) nscalar = scalar_in->nvar;
   if( u_in)      nvector = u_in->nvar;
   for(n=0; n<ntiles_out; n++) {
     for(l=0; l<nscalar; l++) {
-      scalar_out[n].var[l].kstart      = scalar_in[0].var[l].kstart;
-      scalar_out[n].var[l].kend        = scalar_in[0].var[l].kend;
-      scalar_out[n].var[l].lstart      = scalar_in[0].var[l].lstart;
-      scalar_out[n].var[l].lend        = scalar_in[0].var[l].lend;
-      scalar_out[n].var[l].nz          = scalar_in[0].var[l].nz;
-      scalar_out[n].var[l].has_zaxis   = scalar_in[0].var[l].has_zaxis;
-      scalar_out[n].var[l].has_taxis   = scalar_in[0].var[l].has_taxis;
-      scalar_out[n].var[l].ndim        = scalar_in[0].var[l].ndim;
-      for(i=0; i<scalar_in[0].var[l].ndim; i++) scalar_out[n].var[l].index[i] = scalar_in[0].var[l].index[i];
+      copy_var_config(scalar_in[0].var+l, scalar_out[n].var+l);
     }
     
     for(l=0; l<nvector; l++) {
-      u_out[n].var[l].ndim        = u_in[0].var[l].ndim;
-      v_out[n].var[l].ndim        = v_in[0].var[l].ndim;
-      for(i=0; i<u_in[0].var[l].ndim; i++) u_out[n].var[l].index[i] = u_in[0].var[l].index[i];
-      for(i=0; i<v_in[0].var[l].ndim; i++) v_out[n].var[l].index[i] = v_in[0].var[l].index[i];
-      u_out[n].var[l].kstart      = u_in[0].var[l].kstart;
-      u_out[n].var[l].kend        = u_in[0].var[l].kend;
-      u_out[n].var[l].lstart      = u_in[0].var[l].lstart;
-      u_out[n].var[l].lend        = u_in[0].var[l].lend;
-      u_out[n].var[l].nz          = u_in[0].var[l].nz;
-      u_out[n].var[l].has_zaxis   = u_in[0].var[l].has_zaxis;
-      u_out[n].var[l].has_taxis   = u_in[0].var[l].has_taxis;
-      v_out[n].var[l].kstart      = v_in[0].var[l].kstart;
-      v_out[n].var[l].kend        = v_in[0].var[l].kend;
-      v_out[n].var[l].lstart      = v_in[0].var[l].lstart;
-      v_out[n].var[l].lend        = v_in[0].var[l].lend;
-      v_out[n].var[l].nz          = v_in[0].var[l].nz;
-      v_out[n].var[l].has_zaxis   = v_in[0].var[l].has_zaxis;
-      v_out[n].var[l].has_taxis   = v_in[0].var[l].has_taxis;
+      copy_var_config(u_in[0].var+l, u_out[n].var+l);
+      copy_var_config(v_in[0].var+l, v_out[n].var+l);
     }
   }
   
@@ -878,6 +960,8 @@ void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in
 	  break;	  
 	}
       }
+	for(l=0; l<nscalar; l++)scalar_out[n].var[l].type = scalar_in[0].var[l].type;
+      
       if(mpp_pe() == mpp_root_pe()) {
 	file_out[n].fid = mpp_open(file_out[n].name, MPP_WRITE);
 	mpp_copy_global_att(file_in[0].fid, file_out[n].fid);
@@ -918,11 +1002,16 @@ void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in
 
 	/* define the field meta data */
 	for(l=0; l<nscalar; l++) {
-	  scalar_out[n].var[l].type = scalar_in[0].var[l].type;
 	  for(i=0; i<scalar_out[n].var[l].ndim; i++) dims[i] = file_out[n].axis[scalar_out[n].var[l].index[i]].dimid;
 	  scalar_out[n].var[l].vid = mpp_def_var(file_out[n].fid, scalar_out[n].var[l].name, scalar_out[n].var[l].type,
 						   scalar_out[n].var[l].ndim, dims, 0); 
 	  mpp_copy_var_att(file_in[0].fid, scalar_in[0].var[l].vid, file_out[n].fid, scalar_out[n].var[l].vid);
+	  if(scalar_out[n].var[l].interp_method == CONSERVE_ORDER1)
+             mpp_def_var_att(file_out[n].fid, scalar_out[n].var[l].vid, "interp_method", "conserve_order1");
+	  else if(scalar_out[n].var[l].interp_method == CONSERVE_ORDER2)
+             mpp_def_var_att(file_out[n].fid, scalar_out[n].var[l].vid, "interp_method", "conserve_order2");
+	  else if(scalar_out[n].var[l].interp_method == BILINEAR)
+             mpp_def_var_att(file_out[n].fid, scalar_out[n].var[l].vid, "interp_method", "bilinear");
 	}
 	for(l=0; l<nvector; l++) {
 	  if(m==0) {
@@ -931,6 +1020,13 @@ void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in
 	    u_out[n].var[l].vid = mpp_def_var(file_out[n].fid, u_out[n].var[l].name, u_out[n].var[l].type,
 			        		u_out[n].var[l].ndim, dims, 0); 
 	    mpp_copy_var_att(file_in[0].fid, u_in[0].var[l].vid, file_out[n].fid, u_out[n].var[l].vid);
+	    if(u_out[n].var[l].interp_method == CONSERVE_ORDER1)
+	      mpp_def_var_att(file_out[n].fid, u_out[n].var[l].vid, "remapping_method", "conserve_order1");
+	    else if(u_out[n].var[l].interp_method == CONSERVE_ORDER2)
+	      mpp_def_var_att(file_out[n].fid, u_out[n].var[l].vid, "remapping_method", "conserve_order2");
+	    else if(u_out[n].var[l].interp_method == BILINEAR)
+	      mpp_def_var_att(file_out[n].fid, u_out[n].var[l].vid, "remapping_method", "bilinear");
+	    
 	  }
 	  if(m==1 || nfiles == 1) {
 	    v_out[n].var[l].type = v_in[0].var[l].type;
@@ -938,6 +1034,12 @@ void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in
 	    v_out[n].var[l].vid = mpp_def_var(file_out[n].fid, v_out[n].var[l].name, v_out[n].var[l].type,
 						v_out[n].var[l].ndim, dims, 0); 
 	    mpp_copy_var_att(file_in[0].fid, v_in[0].var[l].vid, file_out[n].fid, v_out[n].var[l].vid);
+	    if(v_out[n].var[l].interp_method == CONSERVE_ORDER1)
+	      mpp_def_var_att(file_out[n].fid, v_out[n].var[l].vid, "remapping_method", "conserve_order1");
+	    else if(v_out[n].var[l].interp_method == CONSERVE_ORDER2)
+	      mpp_def_var_att(file_out[n].fid, v_out[n].var[l].vid, "remapping_method", "conserve_order2");
+	    else if(v_out[n].var[l].interp_method == BILINEAR)
+	      mpp_def_var_att(file_out[n].fid, v_out[n].var[l].vid, "remapping_method", "bilinear");
 	  }
 	}
 	/* define time avg info variables */
@@ -972,9 +1074,9 @@ void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in
 }; /* set_output_metadata */
 
 /*******************************************************************************
-   void get_field_missing( )
+   void get_field_attribute( )
    *******************************************************************************/
-void get_field_missing( int ntiles, Field_config *field)
+void get_field_attribute( int ntiles, Field_config *field)
 {
   int n, l, nfield;
   char str[128];
@@ -984,16 +1086,41 @@ void get_field_missing( int ntiles, Field_config *field)
   for(l=0; l<nfield; l++) {
     for(n=0; n<ntiles; n++) {
       field[n].var[l].missing = 0;
+      field[n].var[l].scale   = 0;
+      field[n].var[l].offset  = 0;
       field[n].var[l].vid = mpp_get_varid(*(field[n].fid), field[n].var[l].name);
       if( field[n].var[l].has_missing = mpp_var_att_exist(*(field[n].fid), field[n].var[l].vid, "missing_value") ) {
-	mpp_get_var_att(*(field[n].fid), field[n].var[l].vid, "missing_value", (void *)(&(field[n].var[l].missing)));
-	//	  field[n].var[l].missing = atof(str);
+	mpp_get_var_att_double(*(field[n].fid), field[n].var[l].vid, "missing_value", &(field[n].var[l].missing));
       }
+      if(mpp_var_att_exist(*(field[n].fid), field[n].var[l].vid, "scale_factor")) {
+	mpp_get_var_att_double(*(field[n].fid), field[n].var[l].vid, "scale_factor", &(field[n].var[l].scale) );
+      }
+      if(mpp_var_att_exist(*(field[n].fid), field[n].var[l].vid, "add_offset")) {
+	mpp_get_var_att_double(*(field[n].fid), field[n].var[l].vid, "add_offset", &(field[n].var[l].offset) );
+      }      
     }
   }
 
-}; /* get_field_missing */
+}; /* get_field_attribute */
 
+/*******************************************************************************
+void copy_field_attribute()
+*******************************************************************************/
+void copy_field_attribute( int ntiles_out, Field_config *field_in, Field_config *field_out)
+{
+
+  int n, l;
+  
+  for(n=0; n<ntiles_out; n++) 
+    for(l=0; l<field_out->nvar; l++) {
+      field_out[n].var[l].missing = field_in->var[l].missing;
+      field_out[n].var[l].scale   = field_in->var[l].scale;
+      field_out[n].var[l].offset  = field_in->var[l].offset;
+    }
+  
+
+}
+  
 
 /*******************************************************************************
 void set_remap_file( )
@@ -1096,51 +1223,84 @@ void write_output_time(int ntiles, File_config *file, int level)
   get the input data for the number l variable.
   -------------------------------------------------------------------------*/
 void get_input_data(int ntiles, Field_config *field, Grid_config *grid, Bound_config *bound,
-		    int varid, int level, unsigned int opcode)
+		    int varid, int level_z, int level_n, int level_t)
 {
-  int         halo, i, j, k, i1, i2, n, memsize, nx, ny, nz, ndim, nbound, l;
-  size_t      start[4], nread[4];
+  int         halo, i, j, i1, i2, n, memsize, nx, ny, ndim, nbound, l, pos;
+  size_t      *start, *nread;
   double      *data;
+  short       *data_i2;
+  int         *data_i4;
   Data_holder *dHold;
-
-  if(opcode & CONSERVE_ORDER1)
+  int         interp_method;
+  
+  interp_method = field->var[varid].interp_method;
+  if(interp_method == CONSERVE_ORDER1)
     halo = 0;
   else
     halo = 1;
-  nz = field->var[varid].nz;
-  
-  for(i=0; i<4; i++) {
+
+  ndim = field->var[varid].ndim;
+  if(ndim < 2) mpp_error("fregrid_util(get_input_data): ndim must be no less than 2");
+  nread  = (size_t *)malloc(ndim*sizeof(size_t));
+  start  = (size_t *)malloc(ndim*sizeof(size_t));
+  for(i=0; i<ndim; i++) {
     start[i] = 0; nread[i] = 1;
   }
-  start[0] = level;
-
+  pos = 0;
+  if(field->var[varid].has_taxis) start[pos++] = level_t;
+  if(field->var[varid].has_naxis) start[pos++] = level_n;
+  if(field->var[varid].has_zaxis) start[pos++] = level_z;
+  if(ndim != pos + 2) mpp_error("fregrid_util(get_input_data): mimstch between ndim and has_taxis/has_zaxis/has_naxis");
+  
   /* first read input data for each tile */
   for(n=0; n<ntiles; n++) {
     nx = grid[n].nx;
     ny = grid[n].ny;
     memsize = 1;
-    ndim = field[n].var[varid].ndim;
-    nread[ndim-1] = nx;
-    nread[ndim-2] = ny;
-    if(field[n].var[varid].has_zaxis) {
-      start[ndim-3] = field->var[varid].kstart;
-      nread[ndim-3] = nz;
-    }
-    memsize = (nx+2*halo)*(ny+2*halo)*nz;
-	
+    nread[pos]   = ny;
+    nread[pos+1] = nx;
+    memsize = (nx+2*halo)*(ny+2*halo);
+    
     field[n].data = (double *)malloc(memsize*sizeof(double));
-    if(halo ==0) {
-      mpp_get_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nread, field[n].data);
-    }
+    if(halo ==0 )
+      data = field[n].data;
     else {
-      data = (double *)malloc(nx*ny*nz*sizeof(double));
+      data = (double *)malloc(nx*ny*sizeof(double));
+      init_halo(field[n].data, nx, ny, 1, 1);
+    }
+    
+    switch(field[n].var[varid].type) {
+    case NC_SHORT:
+      data_i2 = (short *)malloc(memsize*sizeof(short));
+      mpp_get_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nread, data_i2);
+      for(i=0; i<nx*ny; i++) data[i] = data_i2[i];
+      free(data_i2);
+      break;
+    case NC_INT:
+      data_i4 = (int *)malloc(memsize*sizeof(int));
+      mpp_get_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nread, data_i4);
+      for(i=0; i<nx*ny; i++) data[i] = data_i4[i];
+      free(data_i4);
+      break;      
+    case NC_DOUBLE:case NC_FLOAT:
       mpp_get_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nread, data);
-      init_halo(field[n].data, nx, ny, nz, 1);
+      break;
+    default:
+      mpp_error("fregrid_util(get_input_data): field type should be NC_INT, NC_SHORT, NC_FLOAT or NC_DOUBLE");
+    }
+      
+    if(field[n].var[varid].scale != 0) {
+      for(i=0; i<nx*ny; i++) data[i] *= field[n].var[varid].scale;
+    }
+    if(field[n].var[varid].offset != 0) {
+      for(i=0; i<nx*ny; i++) data[i] += field[n].var[varid].offset;
+    }      
 
+    if(halo != 0) {
       /* copy the data onto compute domain */
-      for(k=0; k<nz; k++) for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	i1 = k*(nx+2*halo)*(ny+2*halo)+(j+halo)*(nx+2*halo)+i+halo;
-	i2 = k*nx*ny+j*nx+i;
+      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
+	i1 = (j+halo)*(nx+2*halo)+i+halo;
+	i2 = j*nx+i;
 	field[n].data[i1] = data[i2];
       }
       free(data);
@@ -1158,41 +1318,38 @@ void get_input_data(int ntiles, Field_config *field, Grid_config *grid, Bound_co
 	  dHold[l].nx = grid[bound[n].tile2[l]].nx+2;
 	  dHold[l].ny = grid[bound[n].tile2[l]].ny+2;
 	}
-	update_halo(grid[n].nx+2, grid[n].ny+2, nz, field[n].data, &(bound[n]), dHold );
+	update_halo(grid[n].nx+2, grid[n].ny+2, 1, field[n].data, &(bound[n]), dHold );
 	for(l=0; l<nbound; l++) dHold[l].data = NULL;
 	free(dHold);
       }
     }
     /* second order conservative interpolation, gradient need to be calculated */
-    if(opcode & CONSERVE_ORDER2) {
+    if(interp_method == CONSERVE_ORDER2) {
       for(n=0; n<ntiles; n++) {
 	int is_true = 1;
 	nx = grid[n].nx;
 	ny = grid[n].ny;
-	field[n].grad_x = (double *)malloc(nx*ny*nz*sizeof(double));
-	field[n].grad_y = (double *)malloc(nx*ny*nz*sizeof(double));
-	for(k=0; k<nz; k++) {
-	  grad_c2l(&(grid[n].nx), &(grid[n].ny), field[n].data+k*(nx+2)*(ny+2), grid[n].dx, grid[n].dy, grid[n].area,
+	field[n].grad_x = (double *)malloc(nx*ny*sizeof(double));
+	field[n].grad_y = (double *)malloc(nx*ny*sizeof(double));
+	  grad_c2l(&(grid[n].nx), &(grid[n].ny), field[n].data, grid[n].dx, grid[n].dy, grid[n].area,
 		   grid[n].edge_w, grid[n].edge_e, grid[n].edge_s, grid[n].edge_n,
 		   grid[n].en_n, grid[n].en_e, grid[n].vlon_t, grid[n].vlat_t, 
-		   field[n].grad_x+k*nx*ny, field[n].grad_y+k*nx*ny, &is_true, &is_true, &is_true, &is_true);
-	}
+		   field[n].grad_x, field[n].grad_y, &is_true, &is_true, &is_true, &is_true);
 	/* where there is missing and using second order conservative interpolation, need to calculate mask for gradient */
 	if( field[n].var[varid].has_missing ) {
 	  int ip1, im1, jp1, jm1,kk,ii,jj;
 	  double missing;
 	  missing = field[n].var[varid].missing;
-	  field[n].grad_mask = (int *)malloc(nx*ny*nz*sizeof(int));
-	  for(k=0; k<nz; k++) for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
+	  field[n].grad_mask = (int *)malloc(nx*ny*sizeof(int));
+	  for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
 	    ii=i+1; ip1 = ii+1; im1 = ii-1; jj = j+1; jp1 = jj+1; jm1 = jj-1;
-	    kk = k*(nx+2)*(ny+2);
-	    if(field[n].data[kk+jm1*(nx+2)+im1] == missing || field[n].data[kk+jm1*(nx+2)+ii ] == missing ||
-	       field[n].data[kk+jm1*(nx+2)+ip1] == missing || field[n].data[kk+jj *(nx+2)+im1] == missing ||
-	       field[n].data[kk+jj *(nx+2)+ip1] == missing || field[n].data[kk+jp1*(nx+2)+im1] == missing ||
-	       field[n].data[kk+jp1*(nx+2)+ii ] == missing || field[n].data[kk+jp1*(nx+2)+ip1] == missing  )
-	      field[n].grad_mask[k*nx*ny+j*nx+i] = 1;
+	    if(field[n].data[jm1*(nx+2)+im1] == missing || field[n].data[jm1*(nx+2)+ii ] == missing ||
+	       field[n].data[jm1*(nx+2)+ip1] == missing || field[n].data[jj *(nx+2)+im1] == missing ||
+	       field[n].data[jj *(nx+2)+ip1] == missing || field[n].data[jp1*(nx+2)+im1] == missing ||
+	       field[n].data[jp1*(nx+2)+ii ] == missing || field[n].data[jp1*(nx+2)+ip1] == missing  )
+	      field[n].grad_mask[j*nx+i] = 1;
 	    else
-	      field[n].grad_mask[k*nx*ny+j*nx+i] = 0;
+	      field[n].grad_mask[j*nx+i] = 0;
 	  }
 	}
       }
@@ -1299,13 +1456,13 @@ void get_test_input_data(char *test_case, double test_param, int ntiles, Field_c
 }; /* get_test_input_data */
 
 
-void allocate_field_data(int ntiles, Field_config *field, Grid_config *grid, int l)
+void allocate_field_data(int ntiles, Field_config *field, Grid_config *grid)
 {
   int n, i;
   size_t memsize;
   
   for(n=0; n<ntiles; n++) {
-    memsize = grid[n].nx*grid[n].ny*field[n].var[l].nz;
+    memsize = grid[n].nx*grid[n].ny;
     field[n].data = (double *)malloc(memsize*sizeof(double));
   }
 
@@ -1313,46 +1470,77 @@ void allocate_field_data(int ntiles, Field_config *field, Grid_config *grid, int
 
 
 /*-------------------------------------------------------------------------
-  write_output_data(Mosaic_config *output)
+  write_field_data(Mosaic_config *output)
   write data to output file
   -----------------------------------------------------------------------*/
-void write_field_data(int ntiles, Field_config *field, Grid_config *grid, int l, int level)
+void write_field_data(int ntiles, Field_config *field, Grid_config *grid, int varid, int level_z, int level_n, int level_t)
 {
   double *gdata;
-  int    nx, ny, nz, n, ndim, i, j, k;
-  size_t nwrite[4], start[4];
+  short  *data_i2;
+  int    *data_i4;
+  int    nx, ny, n, ndim, i, j, data_size, pos;
+  size_t *nwrite, *start;
 
-  nz = field->var[l].nz;
-  for(i=0; i<4; i++) {
+  ndim = field->var[varid].ndim;
+  if(ndim < 2) mpp_error("fregrid_util(write_field_data): ndim must be no less than 2");
+
+  nwrite = (size_t *)malloc(ndim*sizeof(size_t));
+  start  = (size_t *)malloc(ndim*sizeof(size_t));
+  for(i=0; i<ndim; i++) {
     start[i] = 0; nwrite[i] = 1;
   }
-  start[0] = level;      
+
+  pos = 0;
+  if(field->var[varid].has_taxis) start[pos++] = level_t;
+  if(field->var[varid].has_naxis) start[pos++] = level_n;
+  if(field->var[varid].has_zaxis) start[pos++] = level_z;
+  if(ndim != pos + 2) mpp_error("fregrid_util(write_field_data): mimstch between ndim and has_taxis/has_zaxis/has_naxis");
+  
   for(n=0; n<ntiles; n++) {
     /* global data onto root pe */
     nx = grid[n].nx;
     ny = grid[n].ny;
-    
-    ndim = field[n].var[l].ndim;
-    nwrite[ndim-1] = nx;
-    nwrite[ndim-2] = ny;
-    if(field[n].var[l].has_zaxis) nwrite[ndim-3] = nz;
+    nwrite[pos]   = ny;
+    nwrite[pos+1] = nx;    
+    data_size = nx*ny;
+
+    if(field[n].var[varid].offset != 0) {
+      for(i=0; i<nx*ny; i++) field[n].data[i] -= field[n].var[varid].offset;
+    }
+    if(field[n].var[varid].scale != 0) {
+      for(i=0; i<nx*ny; i++) field[n].data[i] /= field[n].var[varid].scale;
+    }
+
     if(mpp_npes() == 1) {
-      mpp_put_var_value_block(*(field[n].fid), field[n].var[l].vid, start, nwrite, field[n].data);
+      gdata = field[n].data;
     }
     else {
-      gdata = (double *)malloc(nx*ny*nz*sizeof(double));
-      mpp_global_field_double_3D(grid[n].domain, grid[n].nxc, grid[n].nyc, nz,
-				 field[n].data, gdata);
-      /*     for(k=0; k<nz; k++) { */
-      /*      mpp_global_field_double(grid[n].domain, grid[n].nxc, grid[n].nyc, */
-      /* 			      field[n].data+k*grid[n].nxc*grid[n].nyc, gdata+k*nx*ny); */
-      /*    } */
+      gdata = (double *)malloc(nx*ny*sizeof(double));
+      mpp_global_field_double(grid[n].domain, grid[n].nxc, grid[n].nyc,
+			      field[n].data, gdata);
+    }
     
-      if(mpp_pe() == mpp_root_pe())mpp_put_var_value_block(*(field[n].fid), field[n].var[l].vid,
-							   start, nwrite, gdata);
-      free(gdata);
+    switch(field[n].var[varid].type) {
+    case NC_SHORT:
+      data_i2 = (short *)malloc(data_size*sizeof(short));
+      for(i=0; i<data_size; i++) data_i2[i] = (short)gdata[i];
+      if(mpp_pe() == mpp_root_pe()) mpp_put_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nwrite, data_i2);
+      free(data_i2);
+      break;
+    case NC_INT:
+      data_i4 = (int *)malloc(data_size*sizeof(int));
+      for(i=0; i<data_size; i++) data_i4[i] = (int)gdata[i];
+      if(mpp_pe() == mpp_root_pe()) mpp_put_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nwrite, data_i4);
+      free(data_i4);
+      break;
+    case NC_DOUBLE:case NC_FLOAT:
+      if(mpp_pe() == mpp_root_pe())mpp_put_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nwrite, gdata);
+      break;
+    default:
+      mpp_error("fregrid_util(write_field_data): field type should be NC_SHORT, NC_FLOAT or NC_DOUBLE");
     }
-  }  
+    if(mpp_npes() != 1) free(gdata);
+  }
 
 };/* write_output_data */
 
diff --git a/gridspec_tools_20080702/tools/fregrid/fregrid_util.h b/gridspec/tools/shared/fregrid_util.h
similarity index 79%
rename from gridspec_tools_20080702/tools/fregrid/fregrid_util.h
rename to gridspec/tools/shared/fregrid_util.h
index 12b390e..e07b5ad 100644
--- a/gridspec_tools_20080702/tools/fregrid/fregrid_util.h
+++ b/gridspec/tools/shared/fregrid_util.h
@@ -10,19 +10,21 @@ void get_output_grid_by_size(int ntiles, Grid_config *grid, double lonbegin, dou
                              int nlon, int nlat, int finer_steps, int center_y, unsigned int opcode);
 void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config *file2,
 		        Field_config *scalar, Field_config *u_comp, Field_config *v_comp,
-			const Grid_config *grid, int kbegin, int kend, int lbegin, int lend);
+			const Grid_config *grid, int kbegin, int kend, int lbegin, int lend, unsigned int opcode);
 void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in, const File_config *file2_in,
 			  const Field_config *scalar_in, const Field_config *u_in, const Field_config *v_in,
 			  int ntiles_out, File_config *file1_out, File_config *file2_out, Field_config *scalar_out,
-			  Field_config *u_out, Field_config *v_out, const Grid_config *grid_out, const char *history, const char *tagname);
-void get_field_missing( int ntiles, Field_config *field);
+			  Field_config *u_out, Field_config *v_out, const Grid_config *grid_out, const char *history, 
+                          const char *tagname);
+void get_field_attribute( int ntiles, Field_config *field);
+void copy_field_attribute( int ntiles_out, Field_config *field_in, Field_config *field_out);
 void set_remap_file( int ntiles, const char *mosaic_file, const char *remap_file, Interp_config *interp, unsigned int *opcode, int save_weight_only);
 void write_output_time(int ntiles, File_config *output, int level);
-void get_input_data(int ntiles, Field_config *field, Grid_config *grid, Bound_config *bound, 
-                    int l, int level, unsigned int opcode);
+void get_input_data(int ntiles, Field_config *field, Grid_config *grid, Bound_config *bound,
+		    int varid, int level_z, int level_n, int level_t);
 void get_test_input_data(char *test_case, double test_param, int ntiles, Field_config *field,
 			 Grid_config *grid, Bound_config *bound, unsigned int opcode);
-void allocate_field_data(int ntiles, Field_config *field, Grid_config *grid, int l);
-void write_field_data(int ntiles, Field_config *output, Grid_config *grid, int l, int level);
+void allocate_field_data(int ntiles, Field_config *field, Grid_config *grid);
+void write_field_data(int ntiles, Field_config *field, Grid_config *grid, int varid, int level_z, int level_n, int level_t);
 
 #endif
diff --git a/gridspec/tools/shared/make_boundary_contact.c b/gridspec/tools/shared/make_boundary_contact.c
new file mode 100644
index 0000000..0a92326
--- /dev/null
+++ b/gridspec/tools/shared/make_boundary_contact.c
@@ -0,0 +1,483 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "mpp_io.h"
+#include "mpp.h"
+#include "make_boundary_contact.h"
+#include "mosaic_util.h"
+#include "tool_util.h"
+
+const int MAXCONTACT = 100;
+double* east_bound(const double *data, int nx, int ny);
+double* west_bound(const double *data, int nx, int ny);
+double* south_bound(const double *data, int nx, int ny);
+double* north_bound(const double *data, int nx, int ny);
+int get_contact_index( int size1, int size2, double *x1, double *y1, double *x2, double *y2, double periodx,
+		       double periody, int *start1, int *end1, int *start2, int *end2);
+#define EPSLN (1.0e-10)
+
+/************************************************************************************************
+  This routine will create the boundary condition of the mosaic, whose tile grid files
+  are tilefile. Then save the boundary condition (line contact) into file file
+  contact_file. Return ncontact.
+  This routine assume the starting and ending points of the  contact line are coincidence with
+  the grid points of both tiles. lrg_rectangle tiles are assumed. 
+************************************************************************************************/
+int make_boundary_contact(const char *mosaic_name, int ntile, char tilefile[][STRING],
+			  const char *contact_file, double periodx, double periody,
+			  const char *history, char *grid_type, char *congruence)
+{
+  char tagname[] = "$Name:  $";
+
+  double *xb1, *yb1, *xb2, *yb2;
+  int ncontact, start1, end1, start2, end2;
+  int nx1, ny1, nx2, ny2, n, m, i;
+  int *nxp=NULL, *nyp=NULL;
+  double **x=NULL, **y=NULL;
+  double *x1=NULL, *x2=NULL, *y1=NULL, *y2=NULL;
+  int tile1[MAXCONTACT], tile2[MAXCONTACT];
+  int istart1[MAXCONTACT], iend1[MAXCONTACT], jstart1[MAXCONTACT], jend1[MAXCONTACT];
+  int istart2[MAXCONTACT], iend2[MAXCONTACT], jstart2[MAXCONTACT], jend2[MAXCONTACT];
+  char tile_history[512];
+  char **tile_name=NULL;
+  
+  /* First read the grid */
+  nxp = (int *)malloc(ntile*sizeof(int));
+  nyp = (int *)malloc(ntile*sizeof(int));
+  x = (double **)malloc(ntile*sizeof(double *));
+  y = (double **)malloc(ntile*sizeof(double *));
+  tile_name = (char **)malloc(ntile*sizeof(char *));
+  strcpy(grid_type, "not-specified");
+  for(n=0; n<ntile; n++) {
+    int fid, vid;
+    fid = mpp_open(tilefile[n], MPP_READ);
+    nxp[n] = mpp_get_dimlen(fid, "nxp");
+    nyp[n] = mpp_get_dimlen(fid, "nyp");
+    x[n] = (double *)malloc(nxp[n]*nyp[n]*sizeof(double));
+    y[n] = (double *)malloc(nxp[n]*nyp[n]*sizeof(double));
+    tile_name[n] = (char *)malloc(STRING*sizeof(char));
+    vid = mpp_get_varid(fid, "tile");
+    mpp_get_var_value(fid, vid, tile_name[n]);
+    vid = mpp_get_varid(fid, "x");
+    mpp_get_var_value(fid, vid, x[n]);
+    vid = mpp_get_varid(fid, "y");
+    mpp_get_var_value(fid, vid, y[n]);
+    if(n==0) {
+      if(mpp_global_att_exist(fid, "history")) {
+	char *pch;
+	mpp_get_global_att(fid, "history", tile_history);
+	pch = strtok (tile_history," ");
+	while (pch != NULL) {
+	  pch = strtok (NULL, " ");
+	  if( !strcmp(pch, "--grid_type") ) {
+	    pch = strtok (NULL, " ");
+	    if(!strcmp(pch, "gnomonic_ed"))
+	      strcpy(grid_type, "gnomonic_cubic_sphere");
+	    else
+	      strcpy(grid_type, pch);
+	    break;
+	  }
+	}
+      }
+    }
+    
+    mpp_close(fid);
+  }  
+
+  strcpy(congruence, "true");
+  for(n=1; n<ntile; n++) {
+    if(nxp[n] != nxp[n-1] || nyp[n] != nyp[n-1] ) {
+      strcpy(congruence, "false");
+      break;
+    }
+  }
+  
+  ncontact = 0;
+  for(n=0; n<ntile; n++) {
+    for(m=n; m<ntile; m++) {
+      x1 = x[n];
+      x2 = x[m];
+      y1 = y[n];
+      y2 = y[m];
+      nx1 = nxp[n]; ny1 = nyp[n];
+      nx2 = nxp[m]; ny2 = nyp[m];
+      /* East bound of tile1 and west bound of tile2 */
+      xb1 = east_bound(x1, nx1, ny1);
+      yb1 = east_bound(y1, nx1, ny1);
+      xb2 = west_bound(x2, nx2, ny2);
+      yb2 = west_bound(y2, nx2, ny2);
+      if( get_contact_index( ny1, ny2, xb1, yb1, xb2, yb2, periodx, 0.0, &start1, &end1, &start2, &end2) ) {
+	if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 1");
+	istart1[ncontact] = nx1-1;
+	iend1[ncontact]   = nx1-1;
+	istart2[ncontact] = 1;
+	iend2[ncontact]   = 1;    
+	jstart1[ncontact] = start1;
+	jend1[ncontact]   = end1;
+	jstart2[ncontact] = start2;
+	jend2[ncontact]   = end2;
+	tile1[ncontact]   = n;
+	tile2[ncontact]   = m;
+	ncontact++;   
+      }
+
+      /* East bound of tile1 and SOUTH bound of tile2, tile1 and tile must be different tile */
+      if(n != m) {
+	free(xb2);
+	free(yb2);
+	xb2 = south_bound(x2, nx2, ny2);
+	yb2 = south_bound(y2, nx2, ny2);
+	if( get_contact_index( ny1, nx2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
+	  if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 2");
+	  istart1[ncontact] = nx1-1;
+	  iend1[ncontact]   = nx1-1;
+	  istart2[ncontact] = start2;
+	  iend2[ncontact]   = end2;    
+	  jstart1[ncontact] = start1;
+	  jend1[ncontact]   = end1;
+	  jstart2[ncontact] = 1;
+	  jend2[ncontact]   = 1;
+	  tile1[ncontact]   = n;
+	  tile2[ncontact]   = m;  
+	  ncontact++;
+	}
+      }
+      free(xb1);
+      free(yb1);   
+      free(xb2);
+      free(yb2);  
+  
+      /* South bound of tile1 and NORTH bound of tile2 */
+      xb1 = south_bound(x1, nx1, ny1);
+      yb1 = south_bound(y1, nx1, ny1);
+      xb2 = north_bound(x2, nx2, ny2);
+      yb2 = north_bound(y2, nx2, ny2);
+      if( get_contact_index( nx1, nx2, xb1, yb1, xb2, yb2, 0.0, periody, &start1, &end1, &start2, &end2) ) {
+	if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 3");
+	istart1[ncontact] = start1;
+	iend1[ncontact]   = end1;
+	istart2[ncontact] = start2;
+	iend2[ncontact]   = end2;    
+	jstart1[ncontact] = 1;
+	jend1[ncontact]   = 1;
+	jstart2[ncontact] = ny2-1;
+	jend2[ncontact]   = ny2-1;
+	tile1[ncontact]   = n;
+	tile2[ncontact]   = m;
+	ncontact++;
+      }
+
+      /* South bound of tile1 and East bound of tile2, tile1 and tile must be different tile*/  
+      if(n != m ) {
+	free(xb2);
+	free(yb2);
+	xb2 = east_bound(x2, nx2, ny2);
+	yb2 = east_bound(y2, nx2, ny2);
+	if( get_contact_index( nx1, ny2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
+	  if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 4");
+	  istart1[ncontact] = start1;
+	  iend1[ncontact]   = end1;
+	  istart2[ncontact] = nx2-1;
+	  iend2[ncontact]   = nx2-1;    
+	  jstart1[ncontact] = 1;
+	  jend1[ncontact]   = 1;
+	  jstart2[ncontact] = start2;
+	  jend2[ncontact]   = end2;
+	  tile1[ncontact]   = n;
+	  tile2[ncontact]   = m;
+	  ncontact++;
+	}
+      }
+      free(xb1);
+      free(yb1);   
+      free(xb2);
+      free(yb2);  
+
+      /* to avoid duplicate, the following will be done only when tile1 not equal to tile2 */
+      if(n != m) {
+	/* West bound of tile1 and east bound of tile2*/
+	xb1 = west_bound(x1, nx1, ny1);
+	yb1 = west_bound(y1, nx1, ny1);
+	xb2 = east_bound(x2, nx2, ny2);
+	yb2 = east_bound(y2, nx2, ny2);
+	if( get_contact_index( ny1, ny2, xb1, yb1, xb2, yb2, periodx, 0.0, &start1, &end1, &start2, &end2) ) {
+	  if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 5");
+	  istart1[ncontact] = 1;
+	  iend1[ncontact]   = 1;
+	  istart2[ncontact] = nx2-1;
+	  iend2[ncontact]   = nx2-1;    
+	  jstart1[ncontact] = start1;
+	  jend1[ncontact]   = end1;
+	  jstart2[ncontact] = start2;
+	  jend2[ncontact]   = end2;
+	  tile1[ncontact]   = n;
+	  tile2[ncontact]   = m;
+	  ncontact++;
+	}
+	free(xb2);
+	free(yb2);
+
+	/* West bound of tile1 and North bound of tile2 */  
+	xb2 = north_bound(x2, nx2, ny2);
+	yb2 = north_bound(y2, nx2, ny2);
+	if( get_contact_index( ny1, nx2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
+	  if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 6");
+	  istart1[ncontact] = 1;
+	  iend1[ncontact]   = 1;
+	  istart2[ncontact] = start2;
+	  iend2[ncontact]   = end2;    
+	  jstart1[ncontact] = start1;
+	  jend1[ncontact]   = end1;
+	  jstart2[ncontact] = ny2-1;
+	  jend2[ncontact]   = ny2-1;
+	  tile1[ncontact]   = n;
+	  tile2[ncontact]   = m;
+	  ncontact++;
+	}
+	free(xb1);
+	free(yb1);   
+	free(xb2);
+	free(yb2);  
+
+  
+	/* North bound of tile1 and South bound of tile2 */
+	xb1 = north_bound(x1, nx1, ny1);
+	yb1 = north_bound(y1, nx1, ny1);
+	xb2 = south_bound(x2, nx2, ny2);
+	yb2 = south_bound(y2, nx2, ny2);
+	if( get_contact_index( nx1, nx2, xb1, yb1, xb2, yb2, 0.0, periody, &start1, &end1, &start2, &end2) ) {
+	  if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 7");
+	  istart1[ncontact] = start1;
+	  iend1[ncontact]   = end1;
+	  istart2[ncontact] = start2;
+	  iend2[ncontact]   = end2;    
+	  jstart1[ncontact] = ny1-1;
+	  jend1[ncontact]   = ny1-1;
+	  jstart2[ncontact] = 1;
+	  jend2[ncontact]   = 1;
+	  tile1[ncontact]   = n;
+	  tile2[ncontact]   = m;
+	  ncontact++;
+	}
+	free(xb2);
+	free(yb2);
+
+	/* North bound of tile1 and West bound of tile2 */  
+	xb2 = west_bound(x2, nx2, ny2);
+	yb2 = west_bound(y2, nx2, ny2);
+	if( get_contact_index( nx1, ny2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
+	  if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 8");
+	  istart1[ncontact] = start1;
+	  iend1[ncontact]   = end1;
+	  istart2[ncontact] = 1;
+	  iend2[ncontact]   = 1;    
+	  jstart1[ncontact] = ny1-1;
+	  jend1[ncontact]   = ny1-1;
+	  jstart2[ncontact] = start2;
+	  jend2[ncontact]   = end2;
+	  tile1[ncontact]   = n;
+	  tile2[ncontact]   = m;
+	  ncontact++;
+	}
+	free(xb1);
+	free(yb1);   
+	free(xb2);
+	free(yb2);  
+      }
+
+      /* when tile1 = tile2, we need to consider about folded. Only foled north is considered here */
+      if(n == m) {
+	int i, folded = 1;
+	double dx;
+	xb1 = north_bound(x1, nx1, ny1);
+	yb1 = north_bound(y1, nx1, ny1);
+	for(i=0; i<nx1/2; i++) {
+	  if( yb1[i] != yb1[nx1-i-1] ) {
+	    folded = 0;
+	    break;
+	  }
+	  dx = fabs(xb1[i] - xb1[nx1-i-1]);
+	  if( dx !=0 && dx != 360 ) {
+	    folded = 0;
+	    break;
+	  }
+	}
+	if(folded) {
+	  if(ncontact == MAXCONTACT) mpp_error("make_boundary_contact: number of contacts is more than MAXCONTACT 9");
+	  istart1[ncontact] = 1;
+	  iend1[ncontact]   = nx1/2;
+	  istart2[ncontact] = nx1-1;
+	  iend2[ncontact]   = nx1/2+1;    
+	  jstart1[ncontact] = ny1-1;
+	  jend1[ncontact]   = ny1-1;
+	  jstart2[ncontact] = ny1-1;
+	  jend2[ncontact]   = ny1-1;
+	  tile1[ncontact]   = n;
+	  tile2[ncontact]   = m;
+	  ncontact++;
+	}
+	free(xb1);
+	free(yb1);
+      }
+    }
+  }
+  
+  /* write out data */
+  if(ncontact>0) {
+    char str[STRING], outfile[STRING];
+    int fid, dim_ncontact, dim_string, id_mosaic, id_contacts;
+    int id_contact_index, dim[2];
+    size_t start[4], nwrite[4];
+
+    fid = mpp_open(contact_file, MPP_WRITE);
+    /* define dimenison */
+    dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
+    dim_string = mpp_def_dim(fid, "string", STRING);    
+    /* define variable */
+    dim[0] = dim_ncontact; dim[1] = dim_string;
+    id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
+			      "contact_type", "boundary", "alignment", "true",
+			      "contact_index", "contact_index", "orientation", "orient");
+    id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
+				   "starting_ending_point_index_of_contact");
+
+    mpp_def_global_att(fid, "grid_version", grid_version);
+    mpp_def_global_att(fid, "code_version", tagname);
+    mpp_def_global_att(fid, "history", history);
+    mpp_end_def(fid);
+
+    /* write out data */
+    for(i=0; i<4; i++) {
+      start[i] = 0; nwrite[i] = 1;
+    }
+
+    for(n=0; n<ncontact; n++) {
+      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[tile1[n]], mosaic_name,
+	      tile_name[tile2[n]]);
+      start[0] = n; nwrite[1] = strlen(str);
+      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
+      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", istart1[n], iend1[n], jstart1[n], jend1[n],
+	      istart2[n], iend2[n], jstart2[n], jend2[n] );
+      nwrite[1] = strlen(str);
+      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
+    }
+    mpp_close(fid);    
+  }  
+
+
+  /* release memory */
+  for(n=0; n<ntile; n++) {
+    free(tile_name[n]);
+    free(x[n]);
+    free(y[n]);
+  }
+  free(tile_name);
+  free(nxp);
+  free(nyp);
+  free(x);
+  free(y);
+  
+  return ncontact;
+}; /*make_boundary_contact*/
+
+
+/*************************************************************************************************/
+int get_contact_index( int size1, int size2, double *x1, double *y1, double *x2, double *y2, double periodx,
+		       double periody, int *start1, int *end1, int *start2, int *end2)
+{
+  int i1, i2;
+  double dx, dy;
+
+  /* Find the first point in tile 1 cocindent with a point in tile2  */
+  *start1 = -1;
+  *start2 = -1;
+  for(i1=0; i1<size1; i1++) {
+    for(i2=0; i2<size2; i2++) {
+      dx = fabs(x1[i1]- x2[i2]);
+      dx = min(dx, fabs(dx-periodx));
+      dy = fabs(y1[i1]- y2[i2]);
+      dy = min(dy, fabs(dy-periody));
+      if( dx < EPSLN && dy <EPSLN ) {
+	*start1 = i1+1;
+	*start2 = i2+1;
+	goto foundstart;
+      }
+    }
+  }
+
+  return 0;
+    
+  foundstart:
+
+  /* Find the last point in tile 1 cocindent with a point in tile2 */
+  *end1 = -1;
+  *end2 = -1;
+  for(i1=size1-1; i1>=0; i1--) {
+    for(i2=size2-1; i2>=0; i2--) {
+      dx = fabs(x1[i1]- x2[i2]);
+      dx = min(dx, fabs(dx-periodx));
+      dy = fabs(y1[i1]- y2[i2]);
+      dy = min(dy, fabs(dy-periody));
+      if( dx < EPSLN && dy <EPSLN ) {
+	*end1 = i1+1;
+	*end2 = i2+1;
+	goto foundend;
+      }
+    }
+  }
+
+  return 0;
+    
+ foundend: if( *start1 == *end1 || *start2 == *end2 ) return 0;
+
+  if(*start1 > *end1 )
+    (*start1)--;
+  else
+    (*end1)--;
+
+  if(*start2 > *end2 )
+    (*start2)--;
+  else
+    (*end2)--;  
+
+  return 1;
+    
+};
+
+
+double* west_bound(const double *data, int nx, int ny)
+{
+  int i;
+  double *bnd;
+  bnd = (double *)malloc(ny*sizeof(double));
+  for(i=0; i<ny; i++) bnd[i] = data[i*nx];
+  return bnd;
+}
+
+double* east_bound(const double *data, int nx, int ny)
+{
+  int i;
+  double *bnd;
+  bnd = (double *)malloc(ny*sizeof(double));
+  for(i=0; i<ny; i++) bnd[i] = data[i*nx+nx-1];
+  return bnd;
+}
+
+double* south_bound(const double *data, int nx, int ny)
+{
+  int i;
+  double *bnd;
+  bnd = (double *)malloc(nx*sizeof(double));
+  for(i=0; i<nx; i++) bnd[i] = data[i];
+  return bnd;
+}
+
+double* north_bound(const double *data, int nx, int ny)
+{
+  int i;
+  double *bnd;
+  bnd = (double *)malloc(nx*sizeof(double));
+  for(i=0; i<nx; i++) bnd[i] = data[(ny-1)*nx+i];
+  return bnd;
+}
diff --git a/gridspec/tools/shared/make_boundary_contact.h b/gridspec/tools/shared/make_boundary_contact.h
new file mode 100644
index 0000000..761ba08
--- /dev/null
+++ b/gridspec/tools/shared/make_boundary_contact.h
@@ -0,0 +1,7 @@
+#ifndef MAKE_BOUNDATRY_CONTACT_
+#define MAKE_BOUNDATRY_CONTACT_
+#include "constant.h"
+int make_boundary_contact(const char *mosaic_name, int ntile, char tilefile[][STRING],
+			  const char *contact_file, double periodx, double periody, 
+                          const char *history, char *grid_type, char *congruence);
+#endif
diff --git a/gridspec/tools/shared/make_xgrid_contact.c b/gridspec/tools/shared/make_xgrid_contact.c
new file mode 100644
index 0000000..1cc01be
--- /dev/null
+++ b/gridspec/tools/shared/make_xgrid_contact.c
@@ -0,0 +1,227 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "mpp_io.h"
+#include "mpp.h"
+#include "constant.h"
+#include "make_xgrid_contact.h"
+#include "create_xgrid.h"
+#include "tool_util.h"
+#define  MAX_XGRID_FILE (100)
+ 
+
+typedef struct {
+  int nx, ny;
+  double *x, *y;
+  double *mask;
+  char tile_name[STRING];
+} grid_type;
+
+
+/* This routine will get all the tile grid information */
+void get_mosaic_grid(const char *mosaic, int ntiles, grid_type *Grid)
+{
+  int nx, ny, n, i, j;
+  int m_fid, g_fid, vid, vid_childfile;
+  char dir[STRING], grid_file[STRING], filename[STRING];
+  double *tmpx=NULL, *tmpy=NULL;
+  size_t start[4], nread[4];
+  
+  m_fid = mpp_open(mosaic, MPP_READ);
+  vid_childfile = mpp_get_varid(m_fid, TILE_FILES_NAME);
+  get_file_path(mosaic , dir);
+  for(n=0; n<ntiles ; n++) {
+    start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
+    mpp_get_var_value_block(m_fid, vid_childfile, start, nread, filename);
+    sprintf(grid_file, "%s/%s", dir, filename);
+    g_fid = mpp_open(grid_file, MPP_READ);
+    vid = mpp_get_varid(g_fid, "tile");
+    mpp_get_var_value(g_fid, vid, Grid[n].tile_name);
+  
+    nx = mpp_get_dimlen(g_fid, "nx");
+    ny = mpp_get_dimlen(g_fid, "ny");
+    if(nx%2) mpp_error("make_xgrid_mosaic: the size of dimension nx of mosaic should be even (on supergrid)");
+    if(ny%2) mpp_error("make_xgrid_mosaic: the size of dimension ny of mosaic should be even (on supergrid)");
+    tmpx = (double *)malloc((nx+1)*(ny+1)*sizeof(double));
+    tmpy = (double *)malloc((nx+1)*(ny+1)*sizeof(double));
+    nx /= 2;
+    ny /= 2;
+    Grid[n].nx =nx;
+    Grid[n].ny =ny;
+    Grid[n].x = (double *)malloc((nx+1)*(ny+1)*sizeof(double));
+    Grid[n].y = (double *)malloc((nx+1)*(ny+1)*sizeof(double));
+    Grid[n].mask = (double *)malloc(nx*ny*sizeof(double));
+    vid = mpp_get_varid(g_fid, "x");
+    mpp_get_var_value(g_fid, vid, tmpx);
+    vid = mpp_get_varid(g_fid, "y");
+    mpp_get_var_value(g_fid, vid, tmpy);
+    for(j=0; j<=ny; j++) for(i=0; i<=nx; i++) {
+      Grid[n].x[j*(nx+1)+i] = tmpx[2*j*(2*nx+1)+2*i];
+      Grid[n].y[j*(nx+1)+i] = tmpy[2*j*(2*nx+1)+2*i];
+    }
+    
+    for(i=0; i<nx*ny; i++) Grid[n].mask[i] = 1.0;
+    free(tmpx);
+    free(tmpy);
+    mpp_close(g_fid);
+  }  
+
+  mpp_close(m_fid);
+  
+}
+  
+
+
+/****************************************************************************
+  This routine will compute the exchange grid information between two mosaic
+  and write out those information.
+
+****************************************************************************/
+int make_xgrid_contact(const char* mosaic1, const char* mosaic2, const char* contact_file,
+		       const char* history)
+{
+  int fid, vid, n;
+  int ntiles1, ntiles2, n1, n2, nxgrid, nxfile=0;
+  grid_type *Grid1=NULL, *Grid2=NULL;
+  int *i1=NULL, *j1=NULL, *i2=NULL, *j2=NULL;
+  double *di1=NULL, *dj1=NULL, *di2=NULL, *dj2=NULL, *xarea=NULL;
+  double *clon=NULL, *clat=NULL;
+  
+  char xfile[MAX_XGRID_FILE][STRING];
+  char mosaic1_name[STRING], mosaic2_name[STRING];  
+  char tagname[] = "$Name:  $";
+  
+  /* First read the grid information of mosaic1*/
+  fid = mpp_open(mosaic1, MPP_READ);
+  ntiles1 = mpp_get_dimlen(fid, NTILES_NAME);
+  vid = mpp_get_varid(fid, MOSAIC_NAME);    
+  mpp_get_var_value(fid, vid, mosaic1_name);
+  mpp_close(fid);
+  fid = mpp_open(mosaic2, MPP_READ);
+  vid = mpp_get_varid(fid, MOSAIC_NAME);    
+  mpp_get_var_value(fid, vid, mosaic2_name);
+  ntiles2 = mpp_get_dimlen(fid, NTILES_NAME);
+  mpp_close(fid);
+  Grid1 = (grid_type *)malloc(ntiles1*sizeof(grid_type));
+  Grid2 = (grid_type *)malloc(ntiles2*sizeof(grid_type));
+  get_mosaic_grid(mosaic1, ntiles1, Grid1);
+  get_mosaic_grid(mosaic2, ntiles2, Grid2);
+  i1    = (int    *)malloc(MAXXGRID   * sizeof(int   ));
+  j1    = (int    *)malloc(MAXXGRID   * sizeof(int   ));
+  i2    = (int    *)malloc(MAXXGRID   * sizeof(int   ));
+  j2    = (int    *)malloc(MAXXGRID   * sizeof(int   ));
+  clon  = (double *)malloc(MAXXGRID   * sizeof(double));
+  clat  = (double *)malloc(MAXXGRID   * sizeof(double));
+  di1   = (double *)malloc(MAXXGRID   * sizeof(double));
+  dj1   = (double *)malloc(MAXXGRID   * sizeof(double));
+  di2   = (double *)malloc(MAXXGRID   * sizeof(double));
+  dj2   = (double *)malloc(MAXXGRID   * sizeof(double));
+  xarea = (double *)malloc(MAXXGRID   * sizeof(double));
+
+  nxfile = 0;
+  for(n1=0; n1<ntiles1; n1++) {
+    for(n2=0;n2<ntiles2;n2++) {
+      nxgrid = create_xgrid_2dx2d_order2(&(Grid1[n1].nx), &(Grid1[n1].ny), &(Grid2[n2].nx), &(Grid2[n2].ny),
+					 Grid1[n1].x, Grid1[n1].y, Grid1[n2].x, Grid1[n2].y, Grid1[n1].mask,
+					 i1, j1, i2, j2, xarea, clon, clat);
+      if(nxgrid>0) {
+	int dim_ncontact, dim_two, dims[2], i;
+	int id_tile1_cell, id_tile2_cell, id_xgrid_area, id_tile1_dist, id_tile2_dist;
+	size_t start[4], nwrite[4];
+	if(nxfile==MAX_XGRID_FILE) mpp_error("make_xgrid_contact: number of exchange grid file is greater "
+					     "than MAX_XGRID_FILE, increase MAX_XGRID_FILE");
+	sprintf(xfile[nxfile], "%s_%sXlnd_%s_%s.nc", mosaic1_name, Grid1[n1].tile_name, mosaic2_name, Grid2[n2].tile_name);
+	fid = mpp_open(xfile[nxfile], MPP_WRITE);
+	dim_ncontact = mpp_def_dim(fid, "ncontact", nxgrid);
+	dim_two    = mpp_def_dim(fid, "two", 2);
+	dims[0] = dim_ncontact;
+	dims[1] = dim_two;
+	id_tile1_cell = mpp_def_var(fid, "tile1_cell", NC_INT, 2, dims, 1,
+				    "standard_name", "parent_cell_indices_in_mosaic1");
+	id_tile2_cell = mpp_def_var(fid, "tile2_cell", NC_INT, 2, dims, 1,
+				    "standard_name", "parent_cell_indices_in_mosaic2");
+	id_xgrid_area = mpp_def_var(fid, "xgrid_area", NC_DOUBLE, 1, &dim_ncontact, 2,
+				    "standard_name", "exchange_grid_area", "units", "m2");
+	id_tile1_dist = mpp_def_var(fid, "tile1_distance", NC_DOUBLE, 2, dims, 1,
+				    "standard_name", "distance_from_parent1_cell_centroid");
+	id_tile2_dist = mpp_def_var(fid, "tile2_distance", NC_DOUBLE, 2, dims, 1,
+				    "standard_name", "distance_from_parent2_cell_centroid");
+
+	mpp_end_def(fid);
+	for(i=0; i<4; i++) {
+	  start[i] = 0; nwrite[i] = 1;
+	}
+	   
+	mpp_put_var_value(fid, id_tile1_cell, i1);
+	mpp_put_var_value(fid, id_tile2_cell, i2);
+	mpp_put_var_value(fid, id_xgrid_area, xarea);
+	/*	mpp_put_var_value(fid, id_tile1_dist, di1);
+	  mpp_put_var_value(fid, id_tile2_dist, di2); */
+	start[1] = 1;
+	mpp_put_var_value(fid, id_tile1_cell, j1);
+	mpp_put_var_value(fid, id_tile2_cell, j2);
+	/*	mpp_put_var_value(fid, id_tile1_dist, dj1);
+	  mpp_put_var_value(fid, id_tile2_dist, dj2); */
+	mpp_close(fid);
+	nxfile ++;
+      }
+    }
+  }
+
+  if(nxfile >0) {
+    int dim_string, dim_nchild, dim[2];
+    int id_childfile, i;
+    size_t start[4], nwrite[4];
+    
+    fid = mpp_open(contact_file, MPP_WRITE);
+    dim_string = mpp_def_dim(fid, STRING_NAME, STRING);  
+    dim_nchild = mpp_def_dim(fid, NCONTACT_NAME, nxfile);
+    dim[0] = dim_nchild; dim[1] = dim_string;
+    id_childfile = mpp_def_var(fid, TILE_FILES_NAME, MPP_CHAR, 2, dim, 0);
+    mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+    mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+    mpp_def_global_att(fid, HISTORY_NAME, history);
+    mpp_end_def(fid);    
+    /* write out data */
+    for(i=0; i<4; i++) {
+      start[i] = 0; nwrite[i] = 1;
+    }
+    for(n=0; n<nxfile; n++) {
+      start[0] = n;
+       nwrite[1] = strlen(xfile[n]);
+       mpp_put_var_value_block(fid, id_childfile, start, nwrite, xfile[n]);
+    }
+    mpp_close(fid);
+  }
+
+  free(i1);
+  free(j1);
+  free(i2);
+  free(j2);  
+  free(di1);
+  free(dj1);
+  free(di2);
+  free(dj2);
+  free(xarea);
+
+  for(n=0; n<ntiles1; n++) {
+    free(Grid1[n].x);
+    free(Grid1[n].y);
+  }
+  for(n=0; n<ntiles2; n++) {
+    free(Grid2[n].x);
+    free(Grid2[n].y);
+  }
+  
+  free(Grid1);
+  free(Grid2);
+  
+  return nxfile;
+    
+}; /* make_xgrid_contact */
+
+
+
+
+
+  
diff --git a/gridspec/tools/shared/make_xgrid_contact.h b/gridspec/tools/shared/make_xgrid_contact.h
new file mode 100644
index 0000000..42f168b
--- /dev/null
+++ b/gridspec/tools/shared/make_xgrid_contact.h
@@ -0,0 +1,4 @@
+#ifndef MAKE_XGRID_CONTACT_
+#define MAKE_XGRID_CONTACT_
+int make_xgrid_contact(const char* mosaic1, const char* mosaic2, const char* contact_file, const char* history);
+#endif
diff --git a/gridspec_tools_20080702/tools/shared/mpp.c b/gridspec/tools/shared/mpp.c
similarity index 99%
rename from gridspec_tools_20080702/tools/shared/mpp.c
rename to gridspec/tools/shared/mpp.c
index 86c6d84..3fc320e 100644
--- a/gridspec_tools_20080702/tools/shared/mpp.c
+++ b/gridspec/tools/shared/mpp.c
@@ -194,7 +194,7 @@ void mpp_sum_int(int count, int *data)
 }; /* mpp_sum_int */
 
 /*******************************************************************************
-  int mpp_sum_double(int count, double *data)
+  void mpp_sum_double(int count, double *data)
   sum double over all the pes.
 *******************************************************************************/
 void mpp_sum_double(int count, double *data)
diff --git a/gridspec_tools_20080702/tools/shared/mpp.h b/gridspec/tools/shared/mpp.h
similarity index 95%
rename from gridspec_tools_20080702/tools/shared/mpp.h
rename to gridspec/tools/shared/mpp.h
index a212b74..51781f1 100644
--- a/gridspec_tools_20080702/tools/shared/mpp.h
+++ b/gridspec/tools/shared/mpp.h
@@ -20,5 +20,6 @@ void mpp_recv_double(double* data, int size, int from_pe); /* recv data */
 void mpp_recv_int(int* data, int size, int from_pe); /* recv data */
 void mpp_error(char *str);
 void mpp_sum_int(int count, int *data);
+void mpp_sum_double(int count, double *data);
 void mpp_sync_self();
 #endif
diff --git a/gridspec_tools_20080702/tools/shared/mpp_domain.c b/gridspec/tools/shared/mpp_domain.c
similarity index 100%
rename from gridspec_tools_20080702/tools/shared/mpp_domain.c
rename to gridspec/tools/shared/mpp_domain.c
diff --git a/gridspec_tools_20080702/tools/shared/mpp_domain.h b/gridspec/tools/shared/mpp_domain.h
similarity index 100%
rename from gridspec_tools_20080702/tools/shared/mpp_domain.h
rename to gridspec/tools/shared/mpp_domain.h
diff --git a/gridspec_tools_20080702/tools/shared/mpp_io.c b/gridspec/tools/shared/mpp_io.c
similarity index 79%
rename from gridspec_tools_20080702/tools/shared/mpp_io.c
rename to gridspec/tools/shared/mpp_io.c
index 51d4c98..495248b 100644
--- a/gridspec_tools_20080702/tools/shared/mpp_io.c
+++ b/gridspec/tools/shared/mpp_io.c
@@ -100,6 +100,9 @@ int mpp_open(const char *file, int action) {
     status = nc_create(curfile, NC_WRITE, &ncid);
 #endif
     break;
+  case MPP_APPEND:
+    status = nc_open(curfile, NC_WRITE, &ncid);
+    break;
   case MPP_READ:
     status = nc_open(curfile,NC_NOWRITE, &ncid);
     break;
@@ -148,6 +151,31 @@ void mpp_close(int fid)
 /*******************************************************************************/
 
 /*********************************************************************
+  int mpp_get_dimid(int fid, const char *dimname)
+  get the id of the dimname from file with fid, 
+*********************************************************************/
+int mpp_get_dimid(int fid, const char *dimname)
+{
+  int status, dimid;
+  char errmsg[512];
+  
+  /* First look through existing variables to see
+     if the fldid of varname is already retrieved. */
+  if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_dimid): invalid id number, id should be "
+				    "a nonnegative integer that less than nfiles");
+  
+  status =  nc_inq_dimid(files[fid].ncid, dimname, &dimid);
+  if(status != NC_NOERR) {
+    sprintf(errmsg, "mpp_io(mpp_get_dimid): error in get dimension id of %s from file %s", dimname, files[fid].name);
+    netcdf_error(errmsg, status);
+  }
+
+  return dimid;
+
+};/* mpp_get_dimid */
+
+
+/*********************************************************************
   int mpp_get_varid(int fid, const char *varname)
   get the id of the varname from file with fid, the id will be the index
   in files[fid].var.
@@ -224,6 +252,9 @@ int mpp_get_dimlen(int fid, const char *name)
 void mpp_get_var_value(int fid, int vid, void *data)
 {
   int status;
+  int *data_i4;
+  short *data_i2;
+  float *data_r4;
   char errmsg[512];
   
   if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_value_block): invalid fid number, fid should be "
@@ -232,22 +263,26 @@ void mpp_get_var_value(int fid, int vid, void *data)
 				    "a nonnegative integer that less than nvar");
 
   switch(files[fid].var[vid].type) {
-  case NC_DOUBLE: case NC_FLOAT:
+  case NC_DOUBLE:case NC_FLOAT:
     status = nc_get_var_double(files[fid].ncid, files[fid].var[vid].fldid, data);
     break;
   case NC_INT:
     status = nc_get_var_int(files[fid].ncid, files[fid].var[vid].fldid, data);
-    break;     
+    break;
+  case NC_SHORT:
+    status = nc_get_var_short(files[fid].ncid, files[fid].var[vid].fldid, data);
+    break;    
   case NC_CHAR:
     status = nc_get_var_text(files[fid].ncid, files[fid].var[vid].fldid, data);
     break; 
   default:
     sprintf(errmsg, "mpp_io(mpp_get_var_value): field %s in file %s has an invalid type, "
-	    "the type should be NC_DOUBLE, NC_FLOAT", files[fid].var[vid].name, files[fid].name );
+	    "the type should be NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT or NC_CHAR",
+	    files[fid].var[vid].name, files[fid].name );
     mpp_error(errmsg);
   }    
   if(status != NC_NOERR) {
-    sprintf(errmsg, "mpp_io(mpp_get_var_value_block): Error in getting value of variable %s from file %s",
+    sprintf(errmsg, "mpp_io(mpp_get_var_value): Error in getting value of variable %s from file %s",
 	    files[fid].var[vid].name, files[fid].name );
     netcdf_error(errmsg, status);
   }
@@ -269,18 +304,22 @@ void mpp_get_var_value_block(int fid, int vid, const size_t *start, const size_t
 				    "a nonnegative integer that less than nvar");
 
   switch(files[fid].var[vid].type) {
-  case NC_DOUBLE: case NC_FLOAT:
+  case NC_DOUBLE:case NC_FLOAT:
     status = nc_get_vara_double(files[fid].ncid, files[fid].var[vid].fldid, start, nread, data);
     break;
   case NC_INT:
     status = nc_get_vara_int(files[fid].ncid, files[fid].var[vid].fldid, start, nread, data);
-    break;     
+    break;
+  case NC_SHORT:
+    status = nc_get_vara_short(files[fid].ncid, files[fid].var[vid].fldid, start, nread, data);
+    break;  
   case NC_CHAR:
     status = nc_get_vara_text(files[fid].ncid, files[fid].var[vid].fldid, start, nread, data);
     break; 
   default:
-    sprintf(errmsg, "mpp_io(mpp_get_var_value): field %s in file %s has an invalid type, "
-	    "the type should be NC_DOUBLE, NC_FLOAT", files[fid].var[vid].name, files[fid].name );
+    sprintf(errmsg, "mpp_io(mpp_get_var_value_block): field %s in file %s has an invalid type, "
+	    "the type should be NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT or NC_CHAR",
+	    files[fid].var[vid].name, files[fid].name );
     mpp_error(errmsg);
   }    
   if(status != NC_NOERR) {
@@ -300,7 +339,58 @@ void mpp_get_var_att(int fid, int vid, const char *name, void *val)
   int status;
   char errmsg[512];
   nc_type type;
+
   
+  if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_att): invalid fid number, fid should be "
+				    "a nonnegative integer that less than nfiles");
+  if(vid<0 || vid >=files[fid].nvar) mpp_error("mpp_io(mpp_get_var_att): invalid vid number, vid should be "
+				    "a nonnegative integer that less than nvar");
+
+  status = nc_inq_atttype(files[fid].ncid, files[fid].var[vid].fldid, name, &type);
+  if(status != NC_NOERR) {
+    sprintf(errmsg, "mpp_io(mpp_get_var_att): Error in getting type of attribute %s of field %s in file %s ",
+	    name, files[fid].var[vid].name, files[fid].name );
+    netcdf_error(errmsg, status);
+  }
+  
+  switch(type) {
+  case NC_DOUBLE:case NC_FLOAT:
+    status = nc_get_att_double(files[fid].ncid, files[fid].var[vid].fldid, name, val);
+    break;
+  case NC_INT:
+    status = nc_get_att_int(files[fid].ncid, files[fid].var[vid].fldid, name, val);
+    break;      
+  case NC_SHORT:
+    status = nc_get_att_short(files[fid].ncid, files[fid].var[vid].fldid, name, val);
+    break;
+  case NC_CHAR:
+    status = nc_get_att_text(files[fid].ncid, files[fid].var[vid].fldid, name, val);
+    break;    
+  default:
+    sprintf(errmsg, "mpp_io(mpp_get_var_att): attribute %s of field %s in file %s has an invalid type, "
+	    "the type should be NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT or NC_CHAR",
+	    name, files[fid].var[vid].name, files[fid].name );
+    mpp_error(errmsg);
+  }
+  
+  if(status != NC_NOERR) {
+    sprintf(errmsg, "mpp_io(mpp_get_var_att): Error in getting value of attribute %s of variable %s from file %s",
+	    name, files[fid].var[vid].name, files[fid].name );
+    netcdf_error(errmsg, status);
+  }
+}
+
+/*******************************************************************
+ void mpp_get_var_att_double(int fid, int vid, const char *name, double *val)
+ get the attribute value of vid from file fid.
+ ******************************************************************/
+void mpp_get_var_att_double(int fid, int vid, const char *name, double *val)
+{
+  int status;
+  char errmsg[512];
+  nc_type type;
+  short sval;
+  int   ival;
   
   if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_att): invalid fid number, fid should be "
 				    "a nonnegative integer that less than nfiles");
@@ -315,12 +405,21 @@ void mpp_get_var_att(int fid, int vid, const char *name, void *val)
   }
   
   switch(type) {
-  case NC_DOUBLE: case NC_FLOAT:
+  case NC_DOUBLE:case NC_FLOAT:
     status = nc_get_att_double(files[fid].ncid, files[fid].var[vid].fldid, name, val);
     break;
+  case NC_INT:
+    status = nc_get_att_int(files[fid].ncid, files[fid].var[vid].fldid, name, &ival);
+    *val = ival;
+    break;      
+  case NC_SHORT:
+    status = nc_get_att_short(files[fid].ncid, files[fid].var[vid].fldid, name, &sval);
+    *val = sval;
+    break;
   default:
     sprintf(errmsg, "mpp_io(mpp_get_var_att): attribute %s of field %s in file %s has an invalid type, "
-	    "the type should be NC_DOUBLE, NC_FLOAT", name, files[fid].var[vid].name, files[fid].name );
+	    "the type should be NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT or NC_CHAR",
+	    name, files[fid].var[vid].name, files[fid].name );
     mpp_error(errmsg);
   }
   
@@ -351,15 +450,21 @@ void mpp_get_global_att(int fid, const char *name, void *val)
   }
   
   switch(type) {
-  case NC_DOUBLE: case NC_FLOAT:
+  case NC_DOUBLE:case NC_FLOAT:
     status = nc_get_att_double(files[fid].ncid, NC_GLOBAL, name, val);
     break;
+  case NC_INT:
+    status = nc_get_att_int(files[fid].ncid, NC_GLOBAL, name, val);
+    break;
+  case NC_SHORT:
+    status = nc_get_att_short(files[fid].ncid, NC_GLOBAL, name, val);
+    break;  
   case NC_CHAR:
     status = nc_get_att_text(files[fid].ncid, NC_GLOBAL, name, val);
     break;  
   default:
     sprintf(errmsg, "mpp_io(mpp_get_global_att): global attribute %s in file %s has an invalid type, "
-	    "the type should be NC_DOUBLE, NC_FLOAT", name, files[fid].name );
+	    "the type should be NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT or NC_CHAR", name, files[fid].name );
     mpp_error(errmsg);
   }
   
@@ -556,6 +661,27 @@ int mpp_var_att_exist(int fid, int vid, const char *att)
 }; /* mpp_att_exist */
 
 
+/***************************************************************************
+  int mpp_global_att_exist(int fid, const char *att)
+  check global attribute "att" exist or not.
+***************************************************************************/
+int mpp_global_att_exist(int fid, const char *att)
+{
+  int    status;
+  size_t attlen;
+  nc_type atttype;
+
+  if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_var_att_exist): invalid fid number, fid should be "
+				    "a nonnegative integer that less than nfiles");
+  
+  status = nc_inq_att(files[fid].ncid, NC_GLOBAL, att, &atttype, &attlen);
+  if(status == NC_NOERR) 
+    return 1;
+  else
+    return 0;
+  
+}; /* mpp_att_exist */
+
 /*******************************************************************************/
 /*                                                                             */
 /*     The following are routines to write out data                            */
@@ -650,6 +776,31 @@ void mpp_def_global_att(int fid, const char *name, const char *val)
   
 }; /* mpp_def_global_att */
 
+
+/**********************************************************************
+void mpp_def_var_att(int fid, int vid, const char *attname, const char *attval)
+ define one field attribute
+*********************************************************************/
+void mpp_def_var_att(int fid, int vid, const char *attname, const char *attval)
+{
+  int ncid, fldid, status;
+  char errmsg[512];
+  
+  if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_def_var_att): invalid fid number, fid should be "
+				      "a nonnegative integer that less than nfiles");
+  if(vid<0 || vid >=files[fid].nvar) mpp_error("mpp_io(mpp_def_var_att): invalid vid number, vid should be "
+					       "a nonnegative integer that less than nvar");
+  ncid  = files[fid].ncid;
+  fldid = files[fid].var[vid].fldid;
+  status = nc_put_att_text(ncid,fldid,attname,strlen(attval),attval);
+  if(status != NC_NOERR ) {
+    sprintf(errmsg, "mpp_io(mpp_def_var_att): Error in put attribute %s of var %s of file %s",
+	    attname, files[fid].var[vid].name, files[fid].name );
+    netcdf_error(errmsg, status);
+  }
+  
+} /* mpp_def_var_att */
+
 /**********************************************************************
   void mpp_copy_var_att(fid_in, fid_out)
   copy all the field attribute from infile to outfile
@@ -697,6 +848,8 @@ void mpp_copy_var_att(int fid_in, int vid_in, int fid_out, int vid_out)
 }; /* mpp_copy_field_att */
 
 
+
+
 /**********************************************************************
   void mpp_copy_global_att(fid_in, fid_out)
   copy all the global attribute from infile to outfile
@@ -758,15 +911,22 @@ void mpp_put_var_value(int fid, int vid, const void* data)
 				    "a nonnegative integer that less than nvar");
 
   switch(files[fid].var[vid].type) {
-  case NC_DOUBLE: case NC_FLOAT:
+  case NC_DOUBLE:case NC_FLOAT:
     status = nc_put_var_double(files[fid].ncid, files[fid].var[vid].fldid, data);
     break;
   case NC_INT:
     status = nc_put_var_int(files[fid].ncid, files[fid].var[vid].fldid, data);
-    break;     
+    break;
+  case NC_SHORT:
+    status = nc_put_var_short(files[fid].ncid, files[fid].var[vid].fldid, data);
+    break;
+  case NC_CHAR:
+    status = nc_put_var_text(files[fid].ncid, files[fid].var[vid].fldid, data);
+    break;    
   default:
     sprintf(errmsg, "mpp_io(mpp_put_var_value): field %s in file %s has an invalid type, "
-	    "the type should be NC_DOUBLE, NC_FLOAT", files[fid].var[vid].name, files[fid].name );
+	    "the type should be NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT or NC_CHAR",
+	    files[fid].var[vid].name, files[fid].name );
     mpp_error(errmsg);
   }
   
@@ -795,18 +955,22 @@ void mpp_put_var_value_block(int fid, int vid, const size_t *start, const size_t
 				    "a nonnegative integer that less than nvar");
 
   switch(files[fid].var[vid].type) {
-  case NC_DOUBLE: case NC_FLOAT:
+  case NC_DOUBLE:case NC_FLOAT:
     status = nc_put_vara_double(files[fid].ncid, files[fid].var[vid].fldid, start, nwrite, data);
     break;
   case NC_INT:
     status = nc_put_vara_int(files[fid].ncid, files[fid].var[vid].fldid, start, nwrite, data);
-    break;     
+    break;
+  case NC_SHORT:
+    status = nc_put_vara_short(files[fid].ncid, files[fid].var[vid].fldid, start, nwrite, data);
+    break;    
   case NC_CHAR:
     status = nc_put_vara_text(files[fid].ncid, files[fid].var[vid].fldid, start, nwrite, data);
-    break; 
+    break;
   default:
-    sprintf(errmsg, "mpp_io(mpp_get_var_value_block): field %s in file %s has an invalid type, "
-	    "the type should be NC_DOUBLE, NC_FLOAT", files[fid].var[vid].name, files[fid].name );
+    sprintf(errmsg, "mpp_io(mpp_put_var_value_block): field %s in file %s has an invalid type, "
+	    "the type should be NC_DOUBLE, NC_FLOAT, NC_INT, NC_SHORT or NC_CHAR",
+	    files[fid].var[vid].name, files[fid].name );
     mpp_error(errmsg);
   }    
   
@@ -819,6 +983,25 @@ void mpp_put_var_value_block(int fid, int vid, const size_t *start, const size_t
 }; /* mpp_put_var_value_block */
 
 /*********************************************************************
+   void mpp_redef(int fid) 
+   redef the meta data of netcdf file with fid.
+ *******************************************************************/
+void mpp_redef(int fid) {
+  int status;
+  char errmsg[512];
+  
+  if( mpp_pe() != mpp_root_pe() ) return;
+  if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_redef): invalid fid number, fid should be "
+				      "a nonnegative integer that less than nfiles");
+  
+  status = nc_redef(files[fid].ncid);
+  if(status != NC_NOERR) {
+    sprintf(errmsg, "mpp_io(mpp_redef): Error in redef the meta data of file %s", files[fid].name );
+    netcdf_error(errmsg, status);
+  }
+} /* mpp_redef */
+
+/*********************************************************************
    void mpp_end_def(int ncid) 
    end the definition of netcdf file with ncid.
  *******************************************************************/
@@ -829,8 +1012,11 @@ void mpp_end_def(int fid) {
   if( mpp_pe() != mpp_root_pe() ) return;
   if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_end_def): invalid fid number, fid should be "
 				      "a nonnegative integer that less than nfiles");
-  
-  status = nc_enddef(files[fid].ncid);
+  if(HEADER_BUFFER_VALUE>0)
+    status = nc__enddef(files[fid].ncid, HEADER_BUFFER_VALUE, 4, 0, 4);
+  else
+    status = nc_enddef(files[fid].ncid);
+    
   if(status != NC_NOERR) {
     sprintf(errmsg, "mpp_io(mpp_end_def): Error in end definition of file %s", files[fid].name );
     netcdf_error(errmsg, status);
@@ -870,6 +1056,20 @@ int mpp_field_exist(const char *file, const char *field)
 
 }
 
- 
+int mpp_var_exist(int fid, const char *field)
+{
+  int status, varid;
+
+  if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_var_exist): invalid fid number, fid should be "
+				      "a nonnegative integer that less than nfiles");
+  
+  status = nc_inq_varid(files[fid].ncid, field, &varid);
+
+  if(status == NC_NOERR)
+    return 1;
+  else
+    return 0;
+
+} 
 
 
diff --git a/gridspec_tools_20080702/tools/shared/mpp_io.h b/gridspec/tools/shared/mpp_io.h
similarity index 80%
rename from gridspec_tools_20080702/tools/shared/mpp_io.h
rename to gridspec/tools/shared/mpp_io.h
index cd3ee03..25c608c 100644
--- a/gridspec_tools_20080702/tools/shared/mpp_io.h
+++ b/gridspec/tools/shared/mpp_io.h
@@ -12,33 +12,43 @@ will be written out from root pe.
 
 #define MPP_WRITE 100
 #define MPP_READ  200
+#define MPP_APPEND  300
 #define MPP_INT NC_INT
 #define MPP_DOUBLE NC_DOUBLE
 #define MPP_CHAR NC_CHAR
+/*#define HEADER_BUFFER_VALUE (16384)*/
+#define HEADER_BUFFER_VALUE (8192)
 
 int mpp_open(const char *file, int action);
 void mpp_close(int ncid);
 int mpp_get_varid(int fid, const char *varname);
+int mpp_get_dimid(int fid, const char *dimname);
 int mpp_get_dimlen(int fid, const char *name);
 void mpp_get_var_value(int fid, int vid, void *data);
 void mpp_get_var_value_block(int fid, int vid, const size_t *start, const size_t *nread, void *data);
 void mpp_get_var_att(int fid, int vid, const char *name, void *val);
+void mpp_get_var_att_double(int fid, int vid, const char *name, double *val);
 void mpp_get_global_att(int fid, const char *name, void *val);
 int mpp_get_var_ndim(int fid, int vid);
 nc_type mpp_get_var_type(int fid, int vid);
+char mpp_get_var_cart(int fid, int vid);
 void mpp_get_var_dimname(int fid, int vid, int ind, char *name);
 char mpp_get_dim_cart(int fid, const char *name);
 void mpp_get_var_bndname(int fid, int vid, char *bndname);
 int mpp_var_att_exist(int fid, int vid, const char *att);
+int mpp_global_att_exist(int fid, const char *att);
 
 int mpp_def_dim(int fid, const char* name, int size);
 int mpp_def_var(int fid, const char* name, nc_type type, int ndim, const int *dims, int natts, ...);
 void mpp_def_global_att(int fid, const char *name, const char *val);
+void mpp_def_var_att(int fid, int vid, const char *attname, const char *attval);
 void mpp_copy_var_att(int fid_in, int vid_in, int fid_out, int vid_out);
 void mpp_copy_global_att(int fid_in, int fid_out);
 void mpp_put_var_value(int fid, int vid, const void* data);
 void mpp_put_var_value_block(int fid, int vid, const size_t *start, const size_t *nread, const void *data);
 void mpp_end_def(int fid);
+void mpp_redef(int fid);
 int mpp_file_exist(const char *file);
 int mpp_field_exist(const char *file, const char *field);
+int mpp_var_exist(int fid, const char *field);
 #endif
diff --git a/gridspec/tools/shared/tool_util.c b/gridspec/tools/shared/tool_util.c
new file mode 100644
index 0000000..93b13c6
--- /dev/null
+++ b/gridspec/tools/shared/tool_util.c
@@ -0,0 +1,3554 @@
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include "constant.h"
+#include "mosaic_util.h"
+#include "read_mosaic.h"
+#include "tool_util.h"
+#include "interp.h"
+#include "mpp.h"
+#include "mpp_domain.h"
+#include "mpp_io.h"
+#include "conserve_interp.h"
+#include "bilinear_interp.h"
+#include "fregrid_util.h"
+
+#define  D2R (M_PI/180.)
+#define  R2D (180./M_PI)
+
+char tagname[] = "$Name:  $";
+
+const double SMALL = 1.0e-4;
+double distant(double a, double b, double met1, double met2);
+double bp_lam(double x, double y, double bpeq, double rp);
+double bp_phi(double x, double y, double bpsp, double bpnp);
+double lon_in_range(double lon, double lon_strt);
+void vtx_insert(double *x, double *y, int *n, int n_ins);
+void vtx_delete(double *x, double *y, int *n, int n_del);
+int lon_fix(double *x, double *y, int n_in, double tlon);
+
+/***************************************************************************
+  void get_file_path(const char *file, char *dir)
+  get the directory where file is located. The dir will be the complate path
+  before the last "/". If no "/" exist in file, the path will be current ".".
+***************************************************************************/
+void get_file_path(const char *file, char *dir)
+{
+  int len;
+  char *strptr = NULL;
+
+  /* get the diretory */
+ 
+  strptr = strrchr(file, '/');
+  if(strptr) {
+    len = strptr - file;
+    strncpy(dir, file, len);
+  }
+  else {
+    len = 1;
+    strcpy(dir, ".");
+  }
+  dir[len] = 0;
+
+}; /* get_file_path */
+
+/* This file will get the directory that stores the file and the file name (without the dir path) */
+void get_file_dir_and_name(char *file, char *filedir, char *filename)
+{
+  char *fptr=NULL;
+  int siz;
+  
+  fptr = strrchr(file, '/');
+
+    if(!fptr) {
+      strcpy(filename, file);
+      strcpy(filedir, "./");
+    }
+    else {
+      ++fptr;
+      siz = fptr - file;
+      strcpy(filename, fptr);
+      strncpy(filedir, file, siz);      
+    }
+};
+
+
+int get_int_entry(char *line, int* value)
+{
+  char* pch;
+  int num;
+  
+  pch = strtok(line, ", ");
+  num = 0;
+  while( pch != NULL) {
+    value[num++] = atoi(pch);
+    pch = strtok(NULL, ", ");
+  }
+  return num;
+    
+};
+
+int get_double_entry(char *line, double *value)
+{
+  char* pch;
+  int num;
+  
+  pch = strtok(line, ", ");
+  num = 0;
+  while( pch != NULL) {
+    value[num++] = atof(pch);
+    pch = strtok(NULL, ", ");
+  }
+  return num;
+};
+
+/*********************************************************************
+  double spherical_dist(double x1, double y1, double x2, double y2)
+  return distance between spherical grid on the earth
+*********************************************************************/
+
+double spherical_dist(double x1, double y1, double x2, double y2)
+{
+  double dist = 0.0;
+  double h1, h2;
+  
+  if(x1 == x2) {
+    h1 = RADIUS;
+    h2 = RADIUS;
+    dist = distant(y1,y2,h1,h2);
+  }
+  else if(y1 == y2) {
+    h1 = RADIUS * cos(y1*D2R);
+    h2 = RADIUS * cos(y2*D2R);
+    dist = distant(x1,x2,h1,h2);
+  }
+  else 
+    mpp_error("tool_till: This is not rectangular grid");
+
+  return dist;
+}; /* spherical_dist */
+  
+
+/*********************************************************************
+  void double bipolar_dist(double x1, double y1, double x2, double y2)
+  return distance of bipolar grids
+*********************************************************************/
+double bipolar_dist(double x1, double y1, double x2, double y2,
+		    double bpeq, double bpsp, double bpnp, double rp )
+{
+  double dist, x[2],y[2], bp_lon[2], bp_lat[2], metric[2];
+  double h1[2], h2[2], chic;
+  int n;
+  
+  x[0] = x1;  x[1] = x2;
+  y[0] = y1;  y[1] = y2;
+  
+  /*--- get the bipolar grid and metric term ----------------------------*/
+  for(n=0; n<2; n++){
+    bp_lon[n] = bp_lam(x[n],y[n],bpeq, rp);     /* longitude (degrees) in bipolar grid system */
+    bp_lat[n] = bp_phi(x[n],y[n],bpsp, bpnp);  /* latitude (degrees) in bipolar grid system */
+    h1[n]     = RADIUS*cos(bp_lat[n]*D2R);
+    h2[n]     = RADIUS;
+    metric[n] = 1.0;
+    if (fabs(y[n]-90.0) < SMALL || fabs(bp_lon[n]*D2R) >= SMALL
+	|| fabs(bp_lat[n]*D2R) >= SMALL) {
+      chic = acos(cos(bp_lon[n]*D2R)*cos(bp_lat[n]*D2R));            /* eqn. 6 */
+      metric[n] = rp*(1/pow(cos(chic/2),2))/(1+(pow(rp,2))*(pow(tan(chic/2),2)));/* eq 3 */
+    }
+  }
+
+  /*--- then calculate the distance -------------------------------------*/
+  if(x1 == x2) 
+    dist = distant(bp_lon[0],bp_lon[1],metric[0]*h1[0],metric[1]*h1[1]);
+  else if(y1 == y2) 
+    dist = distant(bp_lat[0],bp_lat[1],metric[0]*h2[0],metric[1]*h2[1]);
+  else
+    mpp_error("tool_util: This tripolar grid not transformed from rectangular grid");    
+
+  return dist;
+  
+}; /* bipolar_dist */
+
+/*********************************************************************
+  double distant(double a, double b, double met1, double met2)
+  return distant on the earth
+*********************************************************************/
+double distant(double a, double b, double met1, double met2)
+{
+   return fabs(a-b)*D2R*(met1+met2)/2. ;
+}; /* distant */
+
+/*********************************************************************
+   double spherical_area(double x1, double y1, double x2, double y2,
+                   double x3, double y3, double x4, double y4 )            
+   rectangular grid box area
+ ********************************************************************/
+double spherical_area(double x1, double y1, double x2, double y2,
+		      double x3, double y3, double x4, double y4 )
+{
+  double area, dx, lat1, lat2, x[4],y[4];
+  int i, ip;
+  
+  x[0] = x1; y[0] = y1;
+  x[1] = x2; y[1] = y2;
+  x[2] = x3; y[2] = y3;
+  x[3] = x4; y[3] = y4;
+
+  area = 0.0;
+
+  for(i=0; i<4; i++) {
+    ip = i+1;
+    if(ip ==4) ip = 0;
+    dx = (x[ip] - x[i])*D2R;
+    lat1 = y[ip]*D2R;
+    lat2 = y[i]*D2R;
+    if(dx==0.0) continue;
+    if(dx > M_PI)  dx = dx - 2.0*M_PI;
+    if(dx < -M_PI) dx = dx + 2.0*M_PI;
+
+    if (lat1 == lat2) /* cheap area calculation along latitude  */
+      area = area - dx*sin(lat1);
+    else 
+      area = area - dx*(sin(lat1)+sin(lat2))/2;   /*  TRAPEZOID_RULE */
+  }
+
+  area = area * RADIUS * RADIUS;
+
+  return area;
+}; /* spherical_area */
+
+/*********************************************************************
+   double bipolar_area(double x1, double y1, double x2, double y2,
+                       double x3, double y3, double x4, double y4 )            
+   bipolar grid  area
+ ********************************************************************/
+double bipolar_area(double x1, double y1, double x2, double y2,
+			  double x3, double y3, double x4, double y4 )
+{
+  double area, dx, lat1, lat2, x[8],y[8];
+  int i, ip, n;
+  
+  x[0] = x1; y[0] = y1;
+  x[1] = x2; y[1] = y2;
+  x[2] = x3; y[2] = y3;
+  x[3] = x4; y[3] = y4;
+
+
+  /*--- first fix the longitude at the pole -----------------------------*/
+  n = lon_fix(x, y, 4, 180.);
+
+  /*--- calculate the area ----------------------------------------------  */
+  area = 0.0;  
+  for(i=0; i<n; i++){
+    ip = i+1;
+    if(ip == n) ip = 0;
+    dx   = (x[ip] - x[i])*D2R;
+    lat1 = y[ip]*D2R;
+    lat2 = y[i]*D2R;
+    if(dx==0.0) continue;
+    if(dx > M_PI)  dx = dx - 2.0*M_PI;
+    if(dx < -M_PI) dx = dx + 2.0*M_PI;
+
+    if (lat1 == lat2)  /* cheap area calculation along latitude */
+      area = area - dx*sin(lat1);
+    else
+      area = area - dx*(sin(lat1)+sin(lat2))/2;   /*  TRAPEZOID_RULE */
+  }
+  
+  area = area * RADIUS * RADIUS;
+
+  return area;
+}; /* bipolar_area */
+
+/*********************************************************************
+  double lat_dist(double x1, double x2)
+  distance (in degrees) between points on lat. circle
+ ********************************************************************/
+  double lat_dist(double x1, double x2)
+{
+  return min(fmod(x1-x2+720,360.),fmod(x2-x1+720,360.));
+};
+
+
+/*********************************************************************
+  double bp_lam(double x, double y, double bpeq)
+  find bipolar grid longitude given geo. coordinates
+ ********************************************************************/
+  double bp_lam(double x, double y, double bpeq, double rp)
+{
+  double bp_lam;
+
+  /*  bp_lam = ((90-y)/(90-lat_join))*90 */
+  /* invert eqn. 5 with phic=0 to place point at specified geo. lat */
+  bp_lam = 2.*atan(tan((0.5*M_PI-y*D2R)/2)/rp)*R2D;
+  if (lat_dist(x,bpeq)<90.) bp_lam = -bp_lam;
+  return bp_lam;
+}; /* bp_lam */
+
+/*********************************************************************
+   double bp_phi(double x, double y, double bpsp, double bpnp)
+   find bipolar grid latitude given geo. coordinates
+ ********************************************************************/
+   double bp_phi(double x, double y, double bpsp, double bpnp)
+{
+  if (lat_dist(x,bpsp)<90.)
+    return (-90+lat_dist(x,bpsp));
+  else
+    return ( 90-lat_dist(x,bpnp));
+}; /* bp_phi */
+
+
+/*********************************************************************
+  void tp_trans(double& lon, double& lat, double lon_ref)
+  calculate tripolar grid
+ ********************************************************************/
+void tp_trans(double *lon, double *lat, double lon_ref, double lon_start, 
+		    double lam0, double bpeq, double bpsp, double bpnp, double rp )
+{
+  double lamc, phic, lams, chic, phis;
+  
+  lamc = bp_lam(*lon, *lat, bpeq, rp )*D2R;
+  phic = bp_phi(*lon, *lat, bpsp, bpnp)*D2R;
+
+  if (fabs(*lat-90.) < SMALL) {
+       if (phic > 0) 
+	 *lon=lon_in_range(lon_start,lon_ref);
+       else
+	 *lon=lon_start+180.;
+       chic = acos(cos(lamc)*cos(phic));                     /* eqn. 6 */
+       phis = M_PI*0.5-2*atan(rp*tan(chic/2));                   /* eqn. 5 */
+       *lat = phis*R2D;
+       return;
+  }
+
+  if (fabs(lamc) < SMALL && fabs(phic) < SMALL) {
+    *lat=90.;
+    *lon=lon_ref;
+  }
+  else {
+    lams = fmod(lam0+M_PI+M_PI/2-atan2(sin(lamc),tan(phic)),2*M_PI);  /* eqn. 5 */
+    chic = acos(cos(lamc)*cos(phic));                          /* eqn. 6 */
+    phis = M_PI*0.5-2*atan(rp*tan(chic/2));                        /* eqn. 5 */
+    *lon = lams*R2D;
+    *lon = lon_in_range(*lon,lon_ref); 
+    *lat = phis*R2D;
+  }
+}; /* tp_trans */
+
+/*********************************************************************
+  double Lon_in_range(double lon, double lon_strt)
+  Returns lon_strt <= longitude <= lon_strt+360
+ ********************************************************************/
+double lon_in_range(double lon, double lon_strt)
+{
+  double lon_in_range, lon_end;
+
+  lon_in_range = lon;
+  lon_end = lon_strt+360.;
+
+  if (fabs(lon_in_range - lon_strt) < SMALL) 
+    lon_in_range = lon_strt;
+  else if (fabs(lon_in_range - lon_end) < SMALL)
+    lon_in_range = lon_strt;
+  else {
+    while(1) {
+      if (lon_in_range < lon_strt)          
+	lon_in_range = lon_in_range +  360.;
+      else if (lon_in_range  >  lon_end)
+	lon_in_range  = lon_in_range - 360.;
+      else
+	break;
+    }
+  }
+  return lon_in_range;
+}; /* lon_in_range */
+
+
+/*********************************************************************
+   int lon_fix(double *x, double *y, int n_in, double tlon) 
+   fix longitude at pole.
+ ********************************************************************/
+int lon_fix(double *x, double *y, int n_in, double tlon)
+{
+  int i, ip, im, n_out;
+  double x_sum, dx;
+  
+  n_out = n_in;
+  i     = 0;
+  while( i < n_out) {
+    if(fabs(y[i]) >= 90.-SMALL) {
+      im = i - 1;
+      if(im < 0) im = im + n_out;
+      ip = i + 1;
+      if(ip >= n_out) ip = ip - n_out;
+      /*--- all pole points must be paired ---------------------------- */
+      if(y[im] == y[i] && y[ip] == y[i] ) {
+	vtx_delete(x,y, &n_out, i);
+	i = i - 1;
+      }
+      else if(y[im] != y[i] && y[ip] != y[i] ) {
+        vtx_insert(x,y,&n_out,i);
+	i = i + 1;
+      }
+    }
+    i = i + 1;
+  }
+
+  /*--- first of pole pair has longitude of previous vertex -------------
+    --- second of pole pair has longitude of subsequent vertex ---------- */
+  for(i=0;i<n_out;i++){
+    if(fabs(y[i]) >= 90.-SMALL) {
+      im= i - 1;
+      if(im < 0) im = im + n_out;
+      ip = i + 1;
+      if(ip >= n_out) ip = ip - n_out;
+
+      if(y[im] != y[i]) x[i] = x[im];
+      if(y[ip] != y[i]) x[i] = x[ip];
+    }
+  }
+
+  if(n_out == 0) return 0;
+
+  x_sum = x[1];
+  for(i=1;i< n_out;i++){
+    dx = x[i] - x[i-1];
+    if(dx < -180) 
+      dx = dx + 360;
+    else if (dx >  180)
+      dx = dx - 360;
+
+    x[i] = x[i-1] + dx;
+    x_sum = x_sum + x[i];
+  }
+
+  dx = x_sum/(n_out) - tlon;
+  if (dx < -180.) 
+    for(i=0;i<n_out;i++) x[i] = x[i] + 360.;
+  else if (dx > 180.)
+    for(i=0;i<n_out;i++) x[i] = x[i] - 360.;
+
+  return n_out;
+  
+}; /* lon_fix */
+
+
+/*********************************************************************
+   void vtx_delete(double *x, double *y, int *n, int n_del)
+   delete vertex
+ ********************************************************************/
+void vtx_delete(double *x, double *y, int *n, int n_del)
+{
+  int i;
+
+  for(i=n_del; i<=*n-2; i++)
+    {
+      x[i] = x[i+1];
+      y[i] = y[i+1];
+    }
+  (*n)--;
+}; /* vtx_delete */
+
+/*********************************************************************
+   void Vtx_insert(double *x, double *y, int *n, int n_del)
+   insert vertex
+ ********************************************************************/
+void vtx_insert(double *x, double *y, int *n, int n_ins)
+{
+  int i;
+
+  for(i=*n-1; i>=n_ins; i--){
+    x[i+1] = x[i];
+    y[i+1] = y[i];
+  }
+  (*n)++;
+
+}; /* vtx_insert */
+
+
+/*----------------------------------------------------------------------
+    void vect_cross(e, p1, p2)
+    Perform cross products of 3D vectors: e = P1 X P2
+    -------------------------------------------------------------------*/
+    
+/********************************************************************************
+  void compute_grid_bound(int nb, const couble *bnds, const int *npts, int *grid_size, const char *center_cell)
+  compute the 1-D grid location.
+********************************************************************************/
+double* compute_grid_bound(int nb, const double *bnds, const int *npts, int *grid_size, const char *center)
+{
+  int    refine, i, n, np;
+  double *grid=NULL, *tmp=NULL;
+  double *grid1=NULL, *grid2=NULL;
+
+  if(!strcmp(center, "none") )
+    refine = 1;
+  else if(!strcmp(center, "t_cell") || !strcmp(center, "c_cell") )
+    refine = 2;
+  else
+    mpp_error("tool_util: center should be 'none', 'c_cell' or 't_cell' ");
+	  
+  grid1 = (double *)malloc(nb*sizeof(double));
+  grid1[0] = 1;
+  n = 0;
+  for(i=1; i<nb; i++) {
+    if(npts[i-1]%refine) mpp_error("tool_util: when center_cell is not 'none', npts should be divided by 2");
+    n += npts[i-1]/refine;
+    grid1[i] = n+1;
+  }
+  np = n + 1;
+  *grid_size = n*refine;
+  tmp   = (double *)malloc(np*sizeof(double));
+  grid  = (double *)malloc((*grid_size+1)*sizeof(double));
+  grid2 = (double *)malloc(np*sizeof(double));
+  for(i=0;i<np;i++) grid2[i] = i + 1.0;
+
+  cubic_spline( nb, np, grid1, grid2, bnds, tmp, 1e30, 1e30);
+  if(!strcmp(center, "none")) {
+    for(i=0; i<np; i++) grid[i] = tmp[i];
+  }
+  else if(!strcmp(center, "t_cell")) {
+    for(i=0; i<np; i++) grid[2*i] = tmp[i];
+    for(i=0; i<n;  i++) grid[2*i+1] = 0.5*(tmp[i]+tmp[i+1]);
+  }
+  else if( !strcmp(center, "c_cell")) {
+    for(i=0; i<np; i++) grid[2*i] = tmp[i];
+    grid[1] = 0.5*(tmp[0]+tmp[1]);
+    for(i=1; i<n;  i++) grid[2*i+1] = 2*grid[2*i] - grid[2*i-1];
+  }
+    
+  free(grid1);
+  free(grid2);
+  free(tmp);  
+
+  return grid;
+  
+};/* compute_grid_bound */
+
+double* get_subregion(int ni, double *data, int is, int ie, int js, int je)
+{
+  int i, j, pos;
+  double *ldata;
+  
+  ldata = (double *)malloc((ie-is+1)*(je-js+1)*sizeof(double));
+  pos = 0;
+  for(j=js; j<=je; j++)
+    for(i=is; i<=ie; i++) ldata[pos++] = data[j*ni+i];
+
+  return ldata;
+  
+}; /* get_subregion */
+
+
+#define MAXBOUNDS 100
+#define STRINGLEN 255
+#define GRID_VERSION "0.2"
+#define TAGNAME "$Name:  $"
+
+#include "create_hgrid.h"
+
+int
+gs_make_hgrid(char *grid_type, int *nlat, int *nlon, 
+	      int nxbnds0, int nybnds0, int nxbnds1, int nybnds1, 
+	      int nxbnds2, int nybnds2, double lat_join, int nratio, 
+	      double simple_dx, double simple_dy, int ntilex, int *ndivx,
+	      int ntiley, int *ndivy,
+              char *gridname, char *center, char *history, double *xbnds, 
+	      double *ybnds)
+{
+  
+   char method[32] = "conformal";
+   char orientation[32] = "center_pole";
+   int  nxbnds=2, nybnds=2;
+   char my_grid_file[MAXBOUNDS][STRINGLEN];
+   int nx, ny, nxp, nyp, ntiles=1;
+   double *x=NULL, *y=NULL, *dx=NULL, *dy=NULL, *angle_dx=NULL, *angle_dy=NULL, *area=NULL;
+
+   char geometry[32] = "spherical";
+   char projection[32] = "none";
+   char arcx[32] = "small_circle";
+   char north_pole_tile[32] = "lon:0.0, lat:90.0";
+   char north_pole_arcx[32] = "lon:0.0, lat:90.0";
+   char discretization[32]  = "logically_rectangular";
+   char conformal[32]       = "true";
+   char regular[32]         = "true";
+   
+   char mesg[256], str[128];
+   int isc, iec, jsc, jec, nxc, nyc, layout[2];
+   domain2D domain;
+   int n, errflg, c, i;  
+
+   /* check the command-line arguments to make sure the value are suitable */
+   if( strcmp(grid_type,"regular_lonlat_grid") ==0 ) {
+      nxbnds = nxbnds0; nybnds = nybnds0;
+      if( nxbnds <2 || nybnds < 2) mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', "
+      "both nxbnds and nybnds should be no less than 2");
+      if( nxbnds != nxbnds1 || nxbnds != nxbnds2+1 )
+	 mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', nxbnds does"
+	 "not match number of entry in xbnds or nlon");
+      if( nybnds != nybnds1 || nybnds != nybnds2+1 )
+	 mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', nybnds does "
+	 "not match number of entry in ybnds or nlat");
+   }
+   else if( strcmp(grid_type,"tripolar_grid") ==0 ) {
+      strcpy(projection, "tripolar");
+      strcpy(regular, "false");
+      nxbnds = nxbnds0; nybnds = nybnds0;
+      if( nxbnds != 2) mpp_error("make_hgrid: grid type is 'tripolar_grid', nxbnds should be 2");
+      if( nybnds < 2) mpp_error("make_hgrid: grid type is 'tripolar_grid', nybnds should be no less than 2");
+      if( nxbnds != nxbnds1 || nxbnds != nxbnds2+1 )
+	 mpp_error("make_hgrid: grid type is 'tripolar_grid', nxbnds does not match number of entry in xbnds or nlon");
+      if( nybnds != nybnds1 || nybnds != nybnds2+1 )
+	 mpp_error("make_hgrid: grid type is 'tripolar_grid', nybnds does not match number of entry in ybnds or nlat");
+   }
+   else if( strcmp(grid_type,"from_file") ==0 ) {
+      /* For ascii file, nlon and nlat should be specified through --nlon, --nlat
+	 For netcdf file, grid resolution will be read from grid file
+      */
+    
+      for(n=0; n<ntiles; n++) {
+	 if(strstr(my_grid_file[n],".nc") ) {
+	    /* get the grid size for each tile, the grid is on model grid, should need to multiply by 2 */
+	    int fid;
+	    fid = mpp_open(my_grid_file[n], MPP_READ);
+	    nlon[n] = mpp_get_dimlen(fid, "grid_xt")*2;
+	    nlat[n] = mpp_get_dimlen(fid, "grid_yt")*2;
+	    mpp_close(fid);
+	 }
+	 else {
+	    if(nxbnds2 != ntiles || nybnds2 != ntiles ) mpp_error("make_hgrid: grid type is 'from_file', number entry entered "
+	    "through --nlon and --nlat should be equal to number of files "
+	    "specified through --my_grid_file");
+	 }
+      }
+      /* for simplify purpose, currently we assume all the tile have the same grid size */
+      for(n=1; n<ntiles; n++) {
+	 if( nlon[n] != nlon[0] || nlat[n] != nlat[0])  mpp_error("make_hgrid: grid_type is from_file, all the tiles should "
+	 "have same grid size, contact developer");
+      }
+   }
+   else if( strcmp(grid_type,"simple_cartesian_grid") ==0) {
+      strcpy(geometry, "planar");
+      strcpy(north_pole_tile, "none");
+      if(nxbnds1 != 2 || nybnds1 != 2 ) mpp_error("make_hgrid: grid type is 'simple_cartesian_grid', number entry entered "
+      "through --xbnds and --ybnds should be 2");
+      if(nxbnds2 != 1 || nybnds2 != 1 ) mpp_error("make_hgrid: grid type is 'simple_cartesian_grid', number entry entered "
+      "through --nlon and --nlat should be 1");
+      if(simple_dx == 0 || simple_dy == 0) mpp_error("make_hgrid: grid_type is 'simple_cartesian_grid', "
+      "both simple_dx and simple_dy both should be specified");
+   }
+   else if ( strcmp(grid_type,"spectral_grid") ==0 ) {
+      if(nxbnds2 != 1 || nybnds2 != 1 ) mpp_error("make_hgrid: grid type is 'spectral_grid', number entry entered "
+      "through --nlon and --nlat should be 1");    
+   }
+   else if( strcmp(grid_type,"conformal_cubic_grid") ==0 ) {
+      strcpy(projection, "cube_gnomonic");
+      strcpy(regular, "false");
+      if(nxbnds2 != 1 ) mpp_error("make_hgrid: grid type is 'conformal_cubic_grid', number entry entered "
+      "through --nlon should be 1");
+      if(nratio < 1) mpp_error("make_hgrid: grid type is 'conformal_cubic_grid', nratio should be a positive integer");
+   }
+   else if(  !strcmp(grid_type,"gnomonic_ed") ) {
+      strcpy(projection, "cube_gnomonic");
+      strcpy(conformal, "false");
+      strcpy(regular, "false");
+      if(nxbnds2 != 1 ) mpp_error("make_hgrid: grid type is 'gnomonic_cubic_grid', number entry entered "
+      "through --nlon should be 1");
+   }
+   else {
+      mpp_error("make_hgrid: only grid_type = 'regular_lonlat_grid', 'tripolar_grid', 'from_file', "
+      "'gnomonic_ed', 'conformal_cubic_grid', 'simple_cartesian_grid' and "
+      "'spectral_grid' is implemented");  
+   }
+  
+   /* get super grid size */
+
+   if( !strcmp(grid_type,"gnomonic_ed") || !strcmp(grid_type,"conformal_cubic_grid") ) {
+      nx = nlon[0];
+      ny = nx;
+   }
+   else {
+      nx = 0;
+      ny = 0;
+      for(n=0; n<nxbnds-1; n++) nx += nlon[n];
+      for(n=0; n<nybnds-1; n++) ny += nlat[n];  
+   }
+   nxp = nx + 1;
+   nyp = ny + 1;
+
+   if( !strcmp(grid_type,"gnomonic_ed") || !strcmp(grid_type,"conformal_cubic_grid") ) {
+      ntiles = 6;
+      /* Cubic grid is required to run on single processor.*/
+      if(mpp_npes() > 1) mpp_error( "make_hgrid: cubic grid generation must be run one processor, contact developer");
+   }
+   /* Currently we restrict nx can be divided by ndivx and ny can be divided by ndivy */
+   if(ntilex >0 && ntilex != ntiles) mpp_error("make_hgrid: number of entry specified through --ndivx does not equal ntiles");
+   if(ntiley >0 && ntiley != ntiles) mpp_error("make_hgrid: number of entry specified through --ndivy does not equal ntiles");   
+   for(n=0; n<ntiles; n++) {
+      if( nx%ndivx[n] ) mpp_error("make_hgrid: nx can not be divided by ndivx");
+      if( ny%ndivy[n] ) mpp_error("make_hgrid: ny can not be divided by ndivy");
+   }
+
+   if(strcmp(center,"none") && strcmp(center,"c_cell") && strcmp(center,"t_cell") )
+      mpp_error("make_hgrid: center should be 'none', 'c_cell' or 't_cell' ");
+  
+   /* set up domain decomposition, x and y will be on global domain and
+      other fields will be on compute domain. 
+   */
+
+   mpp_define_layout( nx, ny, mpp_npes(), layout);
+   mpp_define_domain2d( nx, ny, layout, 0, 0, &domain);
+   mpp_get_compute_domain2d(domain, &isc, &iec, &jsc, &jec);
+   nxc = iec - isc + 1;
+   nyc = jec - jsc + 1;
+
+   /* create grid information */
+   x        = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
+   y        = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
+   dx       = (double *) malloc(nxc*(nyc+1)*ntiles*sizeof(double));
+   dy       = (double *) malloc((nxc+1)*nyc*ntiles*sizeof(double));
+   area     = (double *) malloc(nxc    *nyc*ntiles*sizeof(double));
+   angle_dx = (double *) malloc((nxc+1)*(nyc+1)*ntiles*sizeof(double));
+   if( strcmp(conformal,"true") !=0 )angle_dy = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
+  
+   if(strcmp(grid_type,"regular_lonlat_grid") ==0) 
+      create_regular_lonlat_grid(&nxbnds, &nybnds, xbnds, ybnds, nlon, nlat, &isc, &iec, &jsc, &jec,
+      x, y, dx, dy, area, angle_dx, center);
+   else if(strcmp(grid_type,"tripolar_grid") ==0) 
+      create_tripolar_grid(&nxbnds, &nybnds, xbnds, ybnds, nlon, nlat, &lat_join, &isc, &iec, &jsc, &jec,
+      x, y, dx, dy, area, angle_dx, center);
+   else if( strcmp(grid_type,"from_file") ==0 ) {
+      for(n=0; n<ntiles; n++) {
+	 int n1, n2, n3, n4;
+	 n1 = n * nxp * nyp;
+	 n2 = n * nx  * nyp;
+	 n3 = n * nxp * ny;
+	 n4 = n * nx  * ny;
+	 create_grid_from_file(my_grid_file[n], &nx, &ny, x+n1, y+n1, dx+n2, dy+n3, area+n4, angle_dx+n1);
+      }
+   }
+   else if(strcmp(grid_type,"simple_cartesian_grid") ==0) 
+      create_simple_cartesian_grid(xbnds, ybnds, &nx, &ny, &simple_dx, &simple_dy, &isc, &iec, &jsc, &jec,
+      x, y, dx, dy, area, angle_dx );
+   else if(strcmp(grid_type,"spectral_grid") ==0 )
+      create_spectral_grid(&nx, &ny, &isc, &iec, &jsc, &jec, x, y, dx, dy, area, angle_dx );
+   else if(strcmp(grid_type,"conformal_cubic_grid") ==0 ) 
+      create_conformal_cubic_grid(&nx, &nratio, method, orientation, x, y, dx, dy, area, angle_dx, angle_dy );
+   else if(strcmp(grid_type,"gnomonic_ed") ==0 ) 
+      create_gnomonic_cubic_grid(grid_type, &nx, x, y, dx, dy, area, angle_dx, angle_dy );
+  
+   /* write out data */
+   {
+      int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
+      int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp, m;
+      size_t start[4], nwrite[4];
+      double *tmp, *gdata;
+      char tilename[128] = "";
+      char outfile[128] = "";
+    
+      l = 0;
+      for(n=0 ; n< ntiles; n++) {
+	 for(j=0; j<ndivy[n]; j++) {
+	    for(i=0; i<ndivx[n]; i++) {
+	       ++l;
+	       sprintf(tilename, "tile%d", l);
+	       if(ntiles>1 || ndivx[n]>1 || ndivy[n] > 1)
+		  sprintf(outfile, "%s.tile%d.nc", gridname, l);
+	       else
+		  sprintf(outfile, "%s.nc", gridname);
+	       fid = mpp_open(outfile, MPP_WRITE);
+	       /* define dimenison */
+	       ni = nx/ndivx[n];
+	       nj = ny/ndivy[n];
+	       nip = ni + 1;
+	       njp = nj + 1;
+	       dimlist[0] = mpp_def_dim(fid, STRING_NAME, STRINGLEN);
+	       dimlist[1] = mpp_def_dim(fid, NX_NAME, ni);
+	       dimlist[2] = mpp_def_dim(fid, NY_NAME, nj);
+	       dimlist[3] = mpp_def_dim(fid, NXP_NAME, nip);
+	       dimlist[4] = mpp_def_dim(fid, NYP_NAME, njp);
+	       /* define variable */
+	       if( strcmp(north_pole_tile, "none") == 0) /* no north pole, then no projection */
+		 id_tile = mpp_def_var(fid, TILE_NAME, MPP_CHAR, 1, dimlist, 6, "standard_name", "grid_tile_spec",
+				       GEOMETRY_NAME, geometry,
+				       DISCRETIZATION_NAME, discretization, CONFORMAL_NAME, conformal,
+				       REGULAR_NAME, regular, "projection", projection);
+	       else
+		 id_tile = mpp_def_var(fid, TILE_NAME, MPP_CHAR, 1, dimlist, 7, "standard_name", "grid_tile_spec",
+				       GEOMETRY_NAME, geometry, DISCRETIZATION_NAME,
+				       discretization, CONFORMAL_NAME, conformal, REGULAR_NAME, regular,
+				       "projection", projection, "north_pole", north_pole_tile );
+
+	       dims[0] = dimlist[4]; dims[1] = dimlist[3];
+	       id_x = mpp_def_var(fid, X_NAME, MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude",
+				  "units", "degree_east");
+	       id_y = mpp_def_var(fid, Y_NAME, MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude",
+				  "units", "degree_north");
+	       dims[0] = dimlist[4]; dims[1] = dimlist[1];
+	       id_dx = mpp_def_var(fid, DX_NAME, MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance",
+				   "units", "meters");
+	       dims[0] = dimlist[2]; dims[1] = dimlist[3];
+	       id_dy = mpp_def_var(fid, DY_NAME, MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance",
+				   "units", "meters");
+	       dims[0] = dimlist[2]; dims[1] = dimlist[1];
+	       id_area = mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area",
+				     "units", "m2" );
+	       dims[0] = dimlist[4]; dims[1] = dimlist[3];
+	       id_angle_dx = mpp_def_var(fid, ANGLE_DX_NAME, MPP_DOUBLE, 2, dims, 2, "standard_name",
+					 "grid_vertex_x_angle_WRT_geographic_east", "units", "degrees_east");
+	       if(strcmp(conformal, "true") != 0)
+		 id_angle_dy = mpp_def_var(fid, ANGLE_DY_NAME, MPP_DOUBLE, 2, dims, 2, "standard_name",
+					   "grid_vertex_y_angle_WRT_geographic_north", "units", "degrees_north");
+	       if( strcmp(north_pole_arcx, "none") == 0)
+		 id_arcx = mpp_def_var(fid, ARCX_NAME, MPP_CHAR, 1, dimlist, 1, "standard_name", "grid_edge_x_arc_type" );
+	       else
+		 id_arcx = mpp_def_var(fid, ARCX_NAME, MPP_CHAR, 1, dimlist, 2, "standard_name", "grid_edge_x_arc_type",
+				       "north_pole", north_pole_arcx );
+	       mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+	       mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+	       mpp_def_global_att(fid, HISTORY_NAME, history);
+      
+	       mpp_end_def(fid);
+	       for(m=0; m<4; m++) { start[m] = 0; nwrite[m] = 0; }
+	       nwrite[0] = strlen(tilename);
+	       mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
+
+	       tmp = get_subregion(nxp, x+n*nxp*nyp, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
+	       mpp_put_var_value(fid, id_x, tmp);
+	       free(tmp);
+	       tmp = get_subregion(nxp, y+n*nxp*nyp, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
+	       mpp_put_var_value(fid, id_y, tmp);
+	       free(tmp);
+	       gdata = (double *)malloc(nx*nyp*sizeof(double));
+	       mpp_global_field_double(domain, nxc, nyc+1, dx+n*nx*nyp, gdata);
+	       tmp = get_subregion( nx, gdata, i*ni, (i+1)*ni-1, j*nj, (j+1)*nj);
+	       mpp_put_var_value(fid, id_dx, tmp);
+	       free(tmp);
+	       free(gdata);
+	       gdata = (double *)malloc(nxp*ny*sizeof(double));
+	       mpp_global_field_double(domain, nxc+1, nyc, dy+n*nxp*ny, gdata);
+	       tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj-1);
+	       mpp_put_var_value(fid, id_dy, tmp);
+	       free(tmp);
+	       free(gdata);	  
+	       gdata = (double *)malloc(nx*ny*sizeof(double));
+	       mpp_global_field_double(domain, nxc, nyc, area+n*nx*ny, gdata);
+	       tmp = get_subregion( nx, gdata, i*ni, (i+1)*ni-1, j*nj, (j+1)*nj-1);
+	       mpp_put_var_value(fid, id_area, tmp);
+	       free(tmp);
+	       free(gdata);
+	       gdata = (double *)malloc(nxp*nyp*sizeof(double));
+	       mpp_global_field_double(domain, nxc+1, nyc+1, angle_dx+n*nxp*nyp, gdata);
+	       tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
+	       mpp_put_var_value(fid, id_angle_dx, tmp);
+	       free(tmp);
+	       free(gdata);
+	  
+	       if(strcmp(conformal, "true") != 0) {
+		 gdata = (double *)malloc(nxp*nyp*sizeof(double));
+		 mpp_global_field_double(domain, nxc+1, nyc+1, angle_dy+n*nxp*nyp, gdata);
+		 tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
+		 mpp_put_var_value(fid, id_angle_dy, tmp);
+		 free(tmp);
+		 free(gdata);
+	       }
+	       nwrite[0] = strlen(arcx);
+	       mpp_put_var_value_block(fid, id_arcx, start, nwrite, arcx );
+	       mpp_close(fid);
+	    }
+	       
+	 }
+      }
+   }
+
+   free(x);
+   free(y);
+   free(dx);
+   free(dy);
+   free(area);
+   free(angle_dx);
+   if(strcmp(conformal, "true") != 0) free(angle_dy);
+
+   return 0;
+   
+}
+
+int
+gs_fregrid(char *history, char *mosaic_in, char *mosaic_out, char *dir_in, 
+           char *dir_out, char input_file[][STRING], int nfiles, char output_file[][STRING], 
+           int nfiles_out, char *remap_file, char scalar_name[][STRING], int nscalar,
+           char u_name[][STRING], int nvector, char v_name[][STRING], int nvector2, 
+           char *interp_method, char *test_case, double test_param, 
+           unsigned int opcode, int grid_type, unsigned int finer_step,
+           int fill_missing, int nlon, int nlat, int check_conserve, 
+           int y_at_center, double lonbegin, double lonend, double latbegin,
+           double latend, int kbegin, int kend, int lbegin, int lend)
+{
+  int     ntiles_in = 0;              /* number of tiles in input mosaic */
+  int     ntiles_out = 0;             /* number of tiles in output mosaic */
+  int     i, n, m, l;
+  char    txt[STRING];
+
+  Grid_config   *grid_in    = NULL;   /* store input grid  */
+  Grid_config   *grid_out   = NULL;   /* store output grid */
+  Field_config  *scalar_in  = NULL;   /* store input scalar data */
+  Field_config  *scalar_out = NULL;   /* store output scalar data */
+  Field_config  *u_in       = NULL;   /* store input vector u-component */
+  Field_config  *v_in       = NULL;   /* store input vector v-component */
+  Field_config  *u_out      = NULL;   /* store input vector u-component */
+  Field_config  *v_out      = NULL;   /* store input vector v-component */
+  File_config   *file_in    = NULL;   /* store input file information */
+  File_config   *file_out   = NULL;   /* store output file information */
+  File_config   *file2_in   = NULL;   /* store input file information */
+  File_config   *file2_out  = NULL;   /* store output file information */
+  Bound_config  *bound_T    = NULL;   /* store halo update information for T-cell*/
+  Interp_config *interp     = NULL;   /* store remapping information */
+  int save_weight_only      = 0;
+  
+  int fid;
+  
+  /* check the arguments */
+  if( !mosaic_in  ) mpp_error("fregrid: input_mosaic is not specified");
+  if( !mosaic_out ) {
+    if(nlon == 0 || nlat ==0 ) mpp_error("fregrid: when output_mosaic is not specified, nlon and nlat should be specified");
+    if(lonend <= lonbegin) mpp_error("fregrid: when output_mosaic is not specified, lonEnd should be larger than lonBegin");
+    if(latend <= latbegin) mpp_error("fregrid: when output_mosaic is not specified, latEnd should be larger than latBegin");
+  }
+  else {
+    if(nlon !=0 || nlat != 0) mpp_error("fregrid: when output_mosaic is specified, nlon and nlat should not be specified");
+  }
+  
+  if( nfiles == 0) {
+    if(nvector > 0 || nscalar > 0 || nvector2 > 0)
+      mpp_error("fregrid: when --input_file is not specified, --scalar_field, --u_field and --v_field should also not be specified");
+    if(!remap_file) mpp_error("fregrid: when --input_file is not specified, remap_file must be specified to save weight information");
+    save_weight_only = 1;
+    if(mpp_pe()==mpp_root_pe())printf("NOTE: No input file specified in this run, no data file will be regridded "
+				      "and only weight information is calculated.\n");
+  }
+  else if( nfiles == 1 || nfiles ==2) {
+    if( nvector != nvector2 ) mpp_error("fregrid: number of fields specified in u_field must be the same as specified in v_field");
+    if( nscalar+nvector==0 ) mpp_error("fregrid: both scalar_field and vector_field are not specified");
+    /* when nvector =2 and nscalar=0, nfiles can be 2 otherwise nfiles must be 1 */
+    if( nscalar && nfiles != 1 )
+      mpp_error("fregrid: when scalar_field is specified, number of files must be 1");
+    if( nfiles_out == 0 ) {
+      for(i=0; i<nfiles; i++) strcpy(output_file[i], input_file[i]);
+    }
+    else if (nfiles_out != nfiles )
+      mpp_error("fregrid:number of input file is not equal to number of output file");
+  }
+  else
+    mpp_error("fregrid: number of input file should be 1 or 2");
+
+  if(kbegin != 0 || kend != -1) { /* at least one of kbegin and kend is set */
+    if(kbegin < 1 || kend < kbegin) mpp_error("fregrid:KlevelBegin should be a positive integer and no larger "
+					      "than KlevelEnd when you want pick certain klevel");
+  }
+  if(lbegin != 0 || lend != -1) { /* at least one of lbegin and lend is set */
+     if(lbegin < 1 || lend < lbegin) mpp_error("fregrid:LstepBegin should be a positive integer and no larger "
+					      "than LstepEnd when you want pick certain Lstep");
+  }
+  
+  if(nvector > 0) {
+    opcode |= VECTOR;
+    if(grid_type == AGRID)
+      opcode |= AGRID;
+    else if(grid_type == BGRID)
+      opcode |= BGRID;
+  }
+  
+  /* get the mosaic information of input and output mosaic*/
+  fid = mpp_open(mosaic_in, MPP_READ);
+  ntiles_in = mpp_get_dimlen(fid, "ntiles");
+  mpp_close(fid);
+  if(mosaic_out) {
+    fid = mpp_open(mosaic_out, MPP_READ);
+    ntiles_out = mpp_get_dimlen(fid, "ntiles");
+    mpp_close(fid);
+  }
+  else
+    ntiles_out = 1;
+
+  if(!strcmp(interp_method, "conserve_order1") ) {
+    if(mpp_pe() == mpp_root_pe())printf("****fregrid: first order conservative scheme will be used for regridding.\n");
+    opcode |= CONSERVE_ORDER1;
+  }
+  else if(!strcmp(interp_method, "conserve_order2") ) {
+    if(mpp_pe() == mpp_root_pe())printf("****fregrid: second order conservative scheme will be used for regridding.\n");
+    opcode |= CONSERVE_ORDER2;
+  }
+  else if(!strcmp(interp_method, "bilinear") ) {
+    if(mpp_pe() == mpp_root_pe())printf("****fregrid: bilinear remapping scheme will be used for regridding.\n");  
+    opcode |= BILINEAR;
+  }
+  else
+    mpp_error("fregrid: interp_method must be 'conserve_order1', 'conserve_order2' or 'bilinear'");
+
+  if(test_case) {
+    if(nfiles != 1) mpp_error("fregrid: when test_case is specified, nfiles should be 1");
+    sprintf(output_file[0], "%s.%s.output", test_case, interp_method);
+  }
+
+  if(check_conserve) opcode |= CHECK_CONSERVE;
+  
+  if( opcode & BILINEAR ) {
+    int ncontact;
+    ncontact = read_mosaic_ncontacts(mosaic_in);
+    if( nlon == 0 || nlat == 0) mpp_error("fregrid: when interp_method is bilinear, nlon and nlat should be specified");
+    if(ntiles_in != 6) mpp_error("fregrid: when interp_method is bilinear, the input mosaic should be 6 tile cubic grid");
+    if(ncontact !=12)  mpp_error("fregrid: when interp_method is bilinear, the input mosaic should be 12 contact cubic grid");
+    if(mpp_npes() > 1) mpp_error("fregrid: parallel is not implemented for bilinear remapping");
+  }
+  else
+    y_at_center = 1;
+
+
+  /* memory allocation for data structure */
+  grid_in   = (Grid_config *)malloc(ntiles_in *sizeof(Grid_config));
+  grid_out  = (Grid_config *)malloc(ntiles_out*sizeof(Grid_config));
+  bound_T   = (Bound_config *)malloc(ntiles_in *sizeof(Bound_config));
+  interp    = (Interp_config *)malloc(ntiles_out*sizeof(Interp_config));
+  get_input_grid( ntiles_in, grid_in, bound_T, mosaic_in, opcode );
+  if(mosaic_out)
+    get_output_grid_from_mosaic( ntiles_out, grid_out, mosaic_out, opcode );
+  else
+    get_output_grid_by_size(ntiles_out, grid_out, lonbegin, lonend, latbegin, latend,
+			    nlon, nlat, finer_step, y_at_center, opcode);
+
+   if(remap_file) set_remap_file(ntiles_out, mosaic_out, remap_file, interp, &opcode, save_weight_only);  
+  
+  if(!save_weight_only) {
+    file_in   = (File_config *)malloc(ntiles_in *sizeof(File_config));
+    file_out  = (File_config *)malloc(ntiles_out*sizeof(File_config));
+ 
+    if(nfiles == 2) {
+      file2_in   = (File_config *)malloc(ntiles_in *sizeof(File_config));
+      file2_out  = (File_config *)malloc(ntiles_out*sizeof(File_config));
+    }
+    if(nscalar > 0) {
+      scalar_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
+      scalar_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));
+    }
+    if(nvector > 0) {
+      u_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
+      u_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));    
+      v_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
+      v_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));
+    }
+  
+    set_mosaic_data_file(ntiles_in, mosaic_in, dir_in, file_in,  input_file[0]);
+    set_mosaic_data_file(ntiles_out, mosaic_out, dir_out, file_out, output_file[0]);
+    if(nfiles == 2) {
+      set_mosaic_data_file(ntiles_in, mosaic_in, dir_in, file2_in,  input_file[1]);
+      set_mosaic_data_file(ntiles_out, mosaic_out, dir_out, file2_out, output_file[1]);    
+    }
+
+    for(n=0; n<ntiles_in; n++) file_in[n].fid = mpp_open(file_in[n].name, MPP_READ);
+
+    set_field_struct ( ntiles_in,   scalar_in,   nscalar, scalar_name[0], file_in);
+    set_field_struct ( ntiles_out,  scalar_out,  nscalar, scalar_name[0], file_out);
+    set_field_struct ( ntiles_in,   u_in,        nvector, u_name[0], file_in);
+    set_field_struct ( ntiles_out,  u_out,       nvector, u_name[0], file_out);
+    if(nfiles == 1) {
+      set_field_struct ( ntiles_in,   v_in,        nvector, v_name[0], file_in);
+      set_field_struct ( ntiles_out,  v_out,       nvector, v_name[0], file_out);
+    }
+    else {
+      set_field_struct ( ntiles_in,   v_in,        nvector, v_name[0], file2_in);
+      set_field_struct ( ntiles_out,  v_out,       nvector, v_name[0], file2_out);
+    }
+
+    get_input_metadata(ntiles_in, nfiles, file_in, file2_in, scalar_in, u_in, v_in, grid_in, kbegin, kend, lbegin, lend, opcode);
+
+    set_output_metadata(ntiles_in, nfiles, file_in, file2_in, scalar_in, u_in, v_in,
+			ntiles_out, file_out, file2_out, scalar_out, u_out, v_out, grid_out, history, tagname);
+    /* when the interp_method specified through command line is CONSERVE_ORDER1, but the interp_method in the source file
+       field attribute is CONSERVE_ORDER2, need to modify the interp_method value */
+    if(opcode & CONSERVE_ORDER1) {
+      for(l=0; l<nscalar; l++) {
+	if(scalar_out->var[l].interp_method == CONSERVE_ORDER2) {
+	  if(mpp_pe() == mpp_root_pe())printf("NOTE from fregrid: even though the interp_method specified through command line is "
+					      "conserve_order1, the interp_method is reset to conserve_order2 because some fields in "
+					      "the source data have interp_method attribute value conserve_order2");
+	  opcode = opcode & ~CONSERVE_ORDER1;
+	  opcode |= CONSERVE_ORDER2;
+	  break;
+	}
+      }
+    }
+    if(opcode & CONSERVE_ORDER1) {
+      for(l=0; l<nvector; l++) {
+	if(u_out->var[l].interp_method == CONSERVE_ORDER2) {
+	  if(mpp_pe() == mpp_root_pe())printf("NOTE from fregrid: even though the interp_method specified through command line is "
+					      "conserve_order1, the interp_method is reset to conserve_order2 because some fields in "
+					      "the source data have interp_method attribute value conserve_order2");
+	  opcode = opcode & ~CONSERVE_ORDER1;
+	  opcode |= CONSERVE_ORDER2;
+	  break;
+	}
+      }
+    }    
+  }
+  
+  /* preparing for the interpolation, if remapping information exist, read it from remap_file,
+     otherwise create the remapping information and write it to remap_file
+  */
+   if( opcode & BILINEAR ) /* bilinear interpolation from cubic to lalon */
+     setup_bilinear_interp(ntiles_in, grid_in, ntiles_out, grid_out, interp, opcode );
+   else
+     setup_conserve_interp(ntiles_in, grid_in, ntiles_out, grid_out, interp, opcode);
+  
+   if(save_weight_only) {
+     if(mpp_pe() == mpp_root_pe() ) {
+       printf("NOTE: Successfully running fregrid and the following files which store weight information are generated.\n");
+       for(n=0; n<ntiles_out; n++) {
+	 printf("****%s\n", interp[n].remap_file);
+       }
+     }
+     mpp_end();
+     return 0;     
+   }
+  
+   if(nscalar > 0) {
+     get_field_attribute(ntiles_in, scalar_in);
+     copy_field_attribute(ntiles_out, scalar_in, scalar_out);
+   }
+   
+   if(nvector > 0) {
+     get_field_attribute(ntiles_in, u_in);
+     get_field_attribute(ntiles_in, v_in);
+     copy_field_attribute(ntiles_out, u_in, u_out);
+     copy_field_attribute(ntiles_out, v_in, v_out);
+   }
+
+
+  
+   /* set time step to 1, only test scalar field now, nz need to be 1 */
+   if(test_case) {
+     if(nscalar != 1 || nvector != 0) mpp_error("fregrid: when test_case is specified, nscalar must be 1 and nvector must be 0");
+     if(scalar_in->var->nz != 1) mpp_error("fregrid: when test_case is specified, number of vertical level must be 1");
+     file_in->nt = 1;
+     file_out->nt = 1;
+   }
+   
+  /* Then doing the regridding */
+  for(m=0; m<file_in->nt; m++) {
+    int memsize, level_z, level_n, level_t;
+
+    write_output_time(ntiles_out, file_out, m);
+    if(nfiles > 1) write_output_time(ntiles_out, file2_out, m);
+    
+    /* first interp scalar variable */
+    for(l=0; l<nscalar; l++) {
+      if( !scalar_in->var[l].has_taxis && m>0) continue;
+      level_t = m + scalar_in->var[l].lstart;
+      /*--- to reduce memory usage, we are only do remapping for on horizontal level one time */
+      for(level_n =0; level_n < scalar_in->var[l].nn; level_n++)
+	for(level_z=scalar_in->var[l].kstart; level_z <= scalar_in->var[l].kend; level_z++)
+	  {	    
+	    if(test_case)
+	      get_test_input_data(test_case, test_param, ntiles_in, scalar_in, grid_in, bound_T, opcode);
+	    else
+	      get_input_data(ntiles_in, scalar_in, grid_in, bound_T, l, level_z, level_n, level_t);
+	    allocate_field_data(ntiles_out, scalar_out, grid_out);
+	    if( opcode & BILINEAR ) 
+	      do_scalar_bilinear_interp(interp, l, ntiles_in, grid_in, grid_out, scalar_in, scalar_out, finer_step, fill_missing);
+	    else
+	      do_scalar_conserve_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, scalar_in, scalar_out, opcode);
+	    write_field_data(ntiles_out, scalar_out, grid_out, l, level_z, level_n, m);
+	    if(scalar_out->var[l].interp_method == CONSERVE_ORDER2) {
+	      for(n=0; n<ntiles_in; n++) {
+		free(scalar_in[n].grad_x);
+		free(scalar_in[n].grad_y);
+		if(scalar_in[n].var[l].has_missing) free(scalar_in[n].grad_mask);
+	      }
+	    }
+	    for(n=0; n<ntiles_in; n++) free(scalar_in[n].data);
+	    for(n=0; n<ntiles_out; n++) free(scalar_out[n].data);
+	  }
+    }
+
+    /* then interp vector field */
+    for(l=0; l<nvector; l++) {
+      if( !u_in[n].var[l].has_taxis && m>0) continue;
+      level_t = m + u_in->var[l].lstart;
+      get_input_data(ntiles_in, u_in, grid_in, bound_T, l, level_z, level_n, level_t);
+      get_input_data(ntiles_in, v_in, grid_in, bound_T, l, level_z, level_n, level_t);
+      allocate_field_data(ntiles_out, u_out, grid_out);
+      allocate_field_data(ntiles_out, v_out, grid_out);
+      if( opcode & BILINEAR )
+	do_vector_bilinear_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, u_in, v_in, u_out, v_out, finer_step, fill_missing);
+      else
+	do_vector_conserve_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, u_in, v_in, u_out, v_out, opcode);
+      
+      write_field_data(ntiles_out, u_out, grid_out, l, level_z, level_n, m);
+      write_field_data(ntiles_out, v_out, grid_out, l, level_z, level_n, m);
+      for(n=0; n<ntiles_in; n++) {
+	free(u_in[n].data);
+	free(v_in[n].data);
+      }
+      for(n=0; n<ntiles_out; n++) {
+	free(u_out[n].data);
+	free(v_out[n].data);
+      }      
+    }
+  }
+
+  if(mpp_pe() == mpp_root_pe() ) {
+    printf("Successfully running fregrid and the following output file are generated.\n");
+    for(n=0; n<ntiles_out; n++) {
+      mpp_close(file_out[n].fid);
+      printf("****%s\n", file_out[n].name);
+      if( nfiles > 1 ) {
+	mpp_close(file2_out[n].fid);
+	printf("****%s\n", file2_out[n].name);
+      }
+    }
+  }
+   return 0;
+}
+
+#include "topog.h"
+
+int 
+gs_make_topog(char *history, char *mosaic_file, char *topog_type, 
+              int x_refine, int y_refine, 
+              double basin_depth, char *topog_file, char *topog_field, double bottom_depth, 
+              double min_depth, double scale_factor, int num_filter_pass, 
+              double gauss_amp, double gauss_scale, double slope_x,
+              double slope_y, double bowl_south, double bowl_north, 
+              double bowl_west, double bowl_east, int fill_first_row, 
+              int filter_topog, int round_shallow, int fill_shallow, 
+              int deepen_shallow, int smooth_topo_allow_deepening, 
+              char *topog_mosaic)
+{
+  char   output_file[STRING];
+  char   mosaic_file_name[STRING];
+  int    i, c;
+
+  if(x_refine != 2 || y_refine != 2 ) mpp_error("Error from make_topog: x_refine and y_refine should be 2, contact developer");
+  if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> x_refine is %d, y_refine is %d\n",
+				       x_refine, y_refine);
+
+  if (strcmp(topog_type,"rectangular_basin") == 0) {
+    if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> the basin depth is %f\n",basin_depth);
+  }
+  else if (strcmp(topog_type,"gaussian") == 0) {
+    if(mpp_pe() == mpp_root_pe()){
+      printf("NOTE from make_topog ==> bottom_depth is: %f\n", bottom_depth );
+      printf("NOTE from make_topog ==> min_depth is: %f\n", min_depth );
+      printf("NOTE from make_topog ==> gauss_amp is: %f\n", gauss_amp );
+      printf("NOTE from make_topog ==> gauss_scale is: %f\n", gauss_scale );
+      printf("NOTE from make_topog ==> slope_x is: %f\n", slope_x );
+      printf("NOTE from make_topog ==> slope_y is: %f\n", slope_y );      
+    }
+  }
+  else if(strcmp(topog_type,"bowl") == 0) {
+    if(mpp_pe() == mpp_root_pe()){
+      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
+      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
+      printf("NOTE from make_topog ==> bowl_south is: %f\n",bowl_south);
+      printf("NOTE from make_topog ==> bowl_north is: %f\n",bowl_north);
+      printf("NOTE from make_topog ==> bowl_west is: %f\n",bowl_west);
+      printf("NOTE from make_topog ==> bowl_east is: %f\n",bowl_east);
+    }
+  }
+  else if(strcmp(topog_type,"idealized") == 0) {
+    if(mpp_pe() == mpp_root_pe()){
+      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
+      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
+    }
+  }
+  else if(strcmp(topog_type,"realistic") == 0) {
+    if(!topog_file || !topog_field)
+      mpp_error("Error from make_topog: when topog_type is realistic, topog_file and topog_field must be specified.");
+    if(mpp_pe() == mpp_root_pe()){
+      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
+      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
+      printf("NOTE from make_topog ==> topog_file is: %s\n", topog_file);
+      printf("NOTE from make_topog ==> topog_field is: %s\n", topog_field);
+      printf("NOTE from make_topog ==> scale_factor is: %f\n", scale_factor);
+      printf("NOTE from make_topog ==> num_filter_pass is: %d\n", num_filter_pass);
+      if(fill_first_row) printf("NOTE from make_topog ==>make first row of ocean model all land points.\n");
+      if(filter_topog) printf("NOTE from make_topog ==>will apply filter to topography.\n");
+      if(round_shallow) printf("NOTE from make_topog ==>Make cells land if depth is less than 1/2 "
+			       "mimumim depth, otherwise make ocean.\n");
+      if(fill_shallow) printf("NOTE from make_topog ==>Make cells less than minimum depth land.\n");
+      if(deepen_shallow) printf("NOTE from make_topog ==>Make cells less than minimum depth equal to minimum depth.\n");
+      if(smooth_topo_allow_deepening) printf("NOTE from make_topog ==>allow filter to deepen cells.\n");
+    }
+  }
+  else {
+    mpp_error("make_topog: topog_type should be rectangular_basin, gaussian, bowl, idealized or realistic");
+  }
+  
+  if(mpp_pe() == mpp_root_pe()) {
+    printf("**************************************************\n");
+    printf("Begin to generate topography \n");
+  }
+
+  {
+    int m_fid, g_fid, vid;
+    int ntiles, fid, dim_ntiles, n, dims[2];
+    size_t start[4], nread[4], nwrite[4];
+    int *nx, *ny, *nxp, *nyp;
+    int *id_depth;
+    double *depth, *x, *y;
+    int  *t_fid;
+    int  dim_nchild, dim_string, id_mosaic, id_childfile;
+    char **tile_files, **topog_files;
+    char gridfile[256], griddir[256];
+    
+    /* grid should be located in the same directory of mosaic file */
+    get_file_dir_and_name(mosaic_file, griddir, mosaic_file_name);
+    get_file_path(mosaic_file, griddir);
+    
+    /* get mosaic dimension */
+    m_fid = mpp_open(mosaic_file, MPP_READ);
+    ntiles = mpp_get_dimlen( m_fid, "ntiles");
+    tile_files  = (char **)malloc(ntiles*sizeof(char *));
+    topog_files = (char **)malloc(ntiles*sizeof(char *));
+    t_fid       = (int *)  malloc(ntiles*sizeof(int ));
+    id_depth = (int *)malloc(ntiles*sizeof(int));
+    /* loop through each tile to get tile information and set up meta data for output file */
+    sprintf(output_file, "%s.nc", topog_mosaic);
+    fid = mpp_open(output_file, MPP_WRITE);
+    mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+    mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+    mpp_def_global_att(fid, HISTORY_NAME, history);
+    dim_nchild = mpp_def_dim(fid, NTILES_NAME, ntiles);
+    dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+    id_mosaic = mpp_def_var(fid, MOSAIC_FILES_NAME, MPP_CHAR, 1, &dim_string, 1, "standard_name", "grid_mosaic_files");
+    dims[0] = dim_nchild; dims[1] = dim_string;
+    id_childfile = mpp_def_var(fid, TILE_FILES_NAME, MPP_CHAR, 2, dims, 0);
+    mpp_end_def(fid);
+    
+    nx = (int *)malloc(ntiles*sizeof(int));
+    ny = (int *)malloc(ntiles*sizeof(int));
+    nxp = (int *)malloc(ntiles*sizeof(int));
+    nyp = (int *)malloc(ntiles*sizeof(int));    
+
+    for( n = 0; n < ntiles; n++ ) {
+      char tile_name[128];
+      tile_files[n] = (char *)malloc(STRING*sizeof(double));
+      topog_files[n] = (char *)malloc(STRING*sizeof(double));
+      start[0] = n;
+      start[1] = 0;
+      nread[0] = 1;
+      nread[1] = STRING;
+      vid = mpp_get_varid(m_fid, TILE_FILES_NAME);
+      mpp_get_var_value_block(m_fid, vid, start, nread, gridfile);
+      sprintf(tile_files[n], "%s/%s", griddir, gridfile);
+      
+      g_fid = mpp_open(tile_files[n], MPP_READ);
+      vid = mpp_get_varid(g_fid, "tile");
+      mpp_get_var_value(g_fid, vid, tile_name);
+      sprintf(topog_files[n],"%s.%s.nc", topog_mosaic, tile_name);
+      nx[n] = mpp_get_dimlen(g_fid, "nx");
+      ny[n] = mpp_get_dimlen(g_fid, "ny");
+      if( nx[n]%x_refine != 0 ) mpp_error("make_topog: supergrid x-size can not be divided by x_refine");
+      if( ny[n]%y_refine != 0 ) mpp_error("make_topog: supergrid y-size can not be divided by y_refine");
+      nx[n] /= x_refine;
+      ny[n] /= y_refine;
+      nxp[n] = nx[n] + 1;
+      nyp[n] = ny[n] + 1;
+
+      t_fid[n] = mpp_open(topog_files[n], MPP_WRITE);
+      mpp_def_global_att(t_fid[n], GRID_VERSION_NAME, grid_version);
+      mpp_def_global_att(t_fid[n], CODE_VERSION_NAME, tagname);
+      mpp_def_global_att(t_fid[n], HISTORY_NAME, history);      
+      dims[1] = mpp_def_dim(t_fid[n], NX_NAME, nx[n]); 
+      dims[0] = mpp_def_dim(t_fid[n], NY_NAME, ny[n]);
+      id_depth[n] = mpp_def_var(t_fid[n], DEPTH_NAME, NC_DOUBLE, 2, dims,  2, "standard_name",
+				"topographic depth at T-cell centers", "units", "meters");
+      mpp_close(g_fid);
+      mpp_end_def(t_fid[n]);
+    }
+    mpp_close(m_fid);
+
+    /* Generate topography and write out to the output_file */
+    for(n=0; n<ntiles; n++) {
+      int layout[2], isc, iec, jsc, jec, nxc, nyc, ni, i, j;
+      double *gdata, *tmp;
+      domain2D domain;
+      
+      /* define the domain, each tile will be run on all the processors. */
+      mpp_define_layout( nx[n], ny[n], mpp_npes(), layout);
+      mpp_define_domain2d( nx[n], ny[n], layout, 0, 0, &domain);
+      mpp_get_compute_domain2d( domain, &isc, &iec, &jsc, &jec);
+      nxc = iec - isc + 1;
+      nyc = jec - jsc + 1;
+      
+      depth = (double *)malloc(nxc*nyc*sizeof(double));
+      x     = (double *)malloc((nxc+1)*(nyc+1)*sizeof(double));
+      y     = (double *)malloc((nxc+1)*(nyc+1)*sizeof(double));
+      tmp   = (double *)malloc((nxc*x_refine+1)*(nyc*y_refine+1)*sizeof(double));
+      start[0] = jsc*y_refine; start[1] = isc*x_refine;
+      nread[0] = nyc*y_refine+1; nread[1] = nxc*x_refine+1;
+      ni       = nxc*x_refine+1;
+      g_fid = mpp_open(tile_files[n], MPP_READ);
+      vid = mpp_get_varid(g_fid, "x");
+      mpp_get_var_value_block(g_fid, vid, start, nread, tmp);
+      for(j = 0; j < nyc+1; j++) for(i = 0; i < nxc+1; i++)
+	x[j*(nxc+1)+i] = tmp[(j*y_refine)*ni+i*x_refine];
+      vid = mpp_get_varid(g_fid, "y");
+      mpp_get_var_value_block( g_fid, vid, start, nread, tmp);
+      mpp_close(g_fid);
+      for(j = 0; j < nyc+1; j++) for(i = 0; i < nxc+1; i++)
+	y[j*(nxc+1)+i] = tmp[(j*y_refine)*ni+i*x_refine];
+      if (strcmp(topog_type,"rectangular_basin") == 0)
+	create_rectangular_topog(nx[n], ny[n], basin_depth, depth);
+      else if (strcmp(topog_type,"gaussian") == 0)
+	create_gaussian_topog(nx[n], ny[n], x, y, bottom_depth, min_depth,
+			      gauss_amp, gauss_scale, slope_x, slope_y, depth);
+      else if (strcmp(topog_type,"bowl") == 0)
+	create_bowl_topog(nx[n], ny[n], x, y, bottom_depth, min_depth, bowl_east,
+			  bowl_south, bowl_west, bowl_north, depth);
+      else if (strcmp(topog_type,"idealized") == 0)
+	create_idealized_topog( nx[n], ny[n], x, y, bottom_depth, min_depth, depth);
+      else if (strcmp(topog_type,"realistic") == 0)
+	create_realistic_topog(nxc, nyc, x, y, topog_file, topog_field, scale_factor,
+			       fill_first_row, filter_topog, num_filter_pass,
+			       smooth_topo_allow_deepening, round_shallow, fill_shallow,
+			       deepen_shallow, min_depth, depth );
+      gdata = (double *)malloc(nx[n]*ny[n]*sizeof(double));
+      mpp_global_field_double(domain, nxc, nyc, depth, gdata);
+      mpp_put_var_value(t_fid[n], id_depth[n], gdata);
+      free(x);
+      free(y);
+      free(tmp);
+      free(depth);
+      free(gdata);
+      mpp_delete_domain2d(&domain);
+      mpp_close(t_fid[n]);
+    }
+
+    for(i=0; i<4; i++) {
+      start[i] = 0; nwrite[i] = 1;
+    }
+    nwrite[0] = strlen(mosaic_file_name);
+    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_file_name);
+    nwrite[0] = 1;
+    for(n=0; n<ntiles; n++) {
+      start[0]=n;
+      nwrite[1]=strlen(topog_files[n]);
+      mpp_put_var_value_block(fid, id_childfile, start, nwrite, topog_files[n]);
+    }
+    mpp_close(fid);
+  
+    /*release memory */
+    free(id_depth);
+    for(n=0; n<ntiles; n++) {
+      free(tile_files[n]);
+      free(topog_files[n]);
+    }
+    free(tile_files);
+    free(topog_files);
+    free(t_fid);
+    free(nx);
+    free(ny);
+    free(nxp);
+    free(nyp);
+  }
+  return 0;
+}
+
+#include "create_vgrid.h"
+
+int 
+gs_make_vgrid(char *history, int nbnds, double *bnds, int n1, 
+	      int n2, int *nz, char *gridname, char *center)
+{
+   int i, nk;
+   char filename[128];
+   double *zeta;
+   int c, option_index = 0;
+
+   /* check the command-line arguments to make sure the value are suitable */
+   if( nbnds < 2 ) mpp_error("number of bounds specified through -nbnd should be an integer greater than 1");
+   if( nbnds != n1 ) mpp_error("nbnds does not equal number entry specified through -bnd");
+   if( nbnds-1 != n2 ) mpp_error("nbnds-1 does not match number entry specified through -nz");
+
+   /* generate grid */
+   nk = 0;
+   for(i=0; i<nbnds-1; i++) nk += nz[i];
+   zeta = (double *)malloc((nk+1)*sizeof(double));
+   create_vgrid(nbnds, bnds, nz, zeta, center);
+
+   sprintf(filename, "%s.nc", gridname);
+  
+   /* write out vertical grid into a netcdf file */
+   {
+      int fid, dim, varid;
+    
+      fid = mpp_open(filename, MPP_WRITE);
+      dim  = mpp_def_dim(fid, NZV_NAME, nk+1);
+      varid = mpp_def_var(fid, ZETA_NAME, NC_DOUBLE, 1, &dim, 2, "standard_name", "vertical_grid_vertex",
+	  		"units", "meters");
+      mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+      mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+      mpp_def_global_att(fid, HISTORY_NAME, history);          
+      mpp_end_def(fid);
+      mpp_put_var_value(fid, varid, zeta);
+  
+      mpp_close(fid);
+   }
+
+   if(mpp_pe() == mpp_root_pe()) printf("Successfully generate vertical grid file %s\n", filename);
+   return 0;
+}
+
+#include "make_boundary_contact.h"
+#include "make_xgrid_contact.h"
+#define MAXCHILD  100
+
+int gs_make_mosaic(char *history, int ntile, char *mosaic_name, int nmosaic, char mosaicfile[][STRING],
+		   char *grid_descriptor, int n_tilefile, char tilefile[][STRING], double periodx, double periody,
+		   int  generate_contact, char *tile_dir )
+{
+  char gridfile[MAXCHILD][STRING];
+  char contact_file[STRING], overlap_file[STRING];
+  char basefile[STRING];
+  char congruence[STRING];
+  char grid_type[STRING];
+  int  ncontact=0, noverlap=0;
+  int n, i;
+
+  
+  if(ntile > MAXCHILD) {
+    mpp_error("make_mosaic: number of tiles is greater than MAXCHILD.");
+  }
+
+  /* ntile2 should equal ntile or ntile2 should be 1
+     if ntile2 is 1 and ntile is greater than 1, the tile file name is only the base file name,
+     need to add .tile#.nc at the end of the file
+  */
+  if(n_tilefile == ntile) {
+    /* do nothing */
+  }
+  else if(n_tilefile == 1) {
+    strcpy(basefile, tilefile[0]);
+    for(n=0; n<ntile; n++) sprintf(tilefile[n], "%s.tile%d.nc", basefile, n+1);
+  }
+  else {
+    mpp_error("make_mosaic: number of files (>1) specified through --child_file does not equal to num_tiles");
+  }
+  
+  if(tile_dir) {
+    n = strlen(tile_dir);
+    if( tile_dir[n-1] != '/') strcat(tile_dir, "/");
+    for(n=0; n<ntile; n++) sprintf(gridfile[n], "%s%s", tile_dir, tilefile[n]);
+  }
+  else {
+    for(n=0; n<ntile; n++) strcpy(gridfile[n], tilefile[n]);
+  }
+
+  /*
+    if num_mosaic is greater than 0, then number of entry specified through --mosaic_file
+    must equal to num_mosaic
+  */
+  if(nmosaic>0) {
+    if(nmosaic > MAXCHILD) mpp_error("make_mosaic: number of child mosaic is greater than MAXCHILD.");
+  } 
+  
+  ncontact = 0;
+
+  sprintf(contact_file, "%s.boundary_contact.nc", mosaic_name);
+  ncontact = make_boundary_contact(mosaic_name, ntile, gridfile, contact_file, periodx,
+				   periody, history, grid_type, congruence);
+  if(nmosaic > 0 && generate_contact ) {
+    int fid, vid;
+    char mosaic1_name[STRING], mosaic2_name[STRING];
+    /* when generating the overlap between mosaic, the number of mosaic must be two. */
+    if(nmosaic != 2) mpp_error("make_mosaic: num_mosaic must be 2 when generate_contact is specified");
+    fid = mpp_open(mosaicfile[0], MPP_READ);
+    vid = mpp_get_varid(fid, "mosaic");    
+    mpp_get_var_value(fid, vid, mosaic1_name);
+    mpp_close(fid);
+    fid = mpp_open(mosaicfile[1], MPP_READ);
+    vid = mpp_get_varid(fid, "mosaic");    
+    mpp_get_var_value(fid, vid, mosaic2_name);
+    mpp_close(fid);
+      
+    sprintf(contact_file, "%sX%s.nc", mosaic1_name, mosaic2_name);
+    noverlap = make_xgrid_contact(mosaicfile[0], mosaicfile[1], overlap_file, history);
+  }
+  
+  /* write out mosaic */
+  {
+    char outfile[STRING];
+    size_t start[4], nwrite[4];
+    int dim_ntile, dim_nmosaic, dim_ncontact, dim_string, id_mosaic, id_contact;
+    int fid, dim[2], id_tilefile, id_mosaicfile, id_overlap;
+    
+    sprintf(outfile, "%s.nc", mosaic_name);
+    fid = mpp_open(outfile, MPP_WRITE);
+    /* define dimenison */
+    dim_ntile = mpp_def_dim(fid, NTILES_NAME, ntile);
+    if(nmosaic>0)  dim_nmosaic = mpp_def_dim(fid, NMOSAIC_NAME, nmosaic);
+    dim_string = mpp_def_dim(fid, STRING_NAME, STRING);    
+    /* define variable */
+    id_mosaic = mpp_def_var(fid, MOSAIC_NAME, MPP_CHAR, 1, &dim_string, 6, "standard_name",
+			    "grid_mosaic_spec", "grid_type", grid_type, "children", "gridtiles",
+			    "contact_regions", "contacts", "grid_descriptor", grid_descriptor,
+			    CONGRUCENCE_NAME, congruence);
+    dim[0] = dim_ntile; dim[1] = dim_string;
+    id_tilefile = mpp_def_var(fid, TILE_FILES_NAME, MPP_CHAR, 2, dim, 0);
+
+    if(nmosaic>0) {
+      dim[0] = dim_nmosaic;
+      id_mosaicfile = mpp_def_var(fid, MOSAIC_FILES_NAME, MPP_CHAR, 2, dim, 0);
+    }
+    
+    if(ncontact>0) {
+      id_contact = mpp_def_var(fid, CONTACT_FILES_NAME, MPP_CHAR, 1, &dim_string, 2, "standard_name", "mosaic boundary contact",
+			       "contact_type", "boundary_contact");
+    }
+    if(noverlap>0) {
+      id_overlap = mpp_def_var(fid, OVERLAP_FILES_NAME, MPP_CHAR, 1, &dim_string, 2, "standard_name", "overlap between mosaic",
+			       "contact_type", "overlap");
+    }
+    mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+    mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+    mpp_def_global_att(fid, HISTORY_NAME, history);
+    mpp_end_def(fid);
+
+    /* write out data */
+    for(i=0; i<4; i++) {
+      start[i] = 0; nwrite[i] = 1;
+    }
+    nwrite[0] = strlen(mosaic_name);
+    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
+    nwrite[0] = 1;
+    if(ncontact>0) {
+      nwrite[0]=strlen(contact_file); 
+      mpp_put_var_value_block(fid, id_contact, start, nwrite, contact_file);
+    }
+    if(noverlap>0) {
+      nwrite[0]=strlen(overlap_file); 
+      mpp_put_var_value_block(fid, id_overlap, start, nwrite, overlap_file);
+    }
+
+    for(n=0; n<ntile; n++) {
+      start[0]=n; nwrite[0] =1;
+      nwrite[1] = strlen(tilefile[n]);
+      mpp_put_var_value_block(fid, id_tilefile, start, nwrite, tilefile[n]);
+    }
+
+    for(n=0; n<nmosaic; n++) {
+      start[0]=n;
+      nwrite[1] = strlen(mosaicfile[n]);
+      mpp_put_var_value_block(fid, id_mosaicfile, start, nwrite, mosaicfile[n]);
+    }
+    
+    mpp_close(fid);
+  }
+    
+  
+  printf("congradulation: You have successfully run make_mosaic\n");
+      
+  return 0;
+  
+}
+
+#include "create_xgrid.h"
+#define D2R (M_PI/180.)
+#define MAXXGRIDFILE 100 
+#define MX 2000  
+#define AREA_RATIO_THRESH (1.e-6)
+#define TINY_VALUE (1.e-7)
+#define TOLORENCE (1.e-4)
+#define MIN_AREA_FRAC (1.e-4)
+
+
+
+int gs_make_coupler_mosaic(char *history, char *amosaic, char *lmosaic, 
+                           char *omosaic, char *imosaic, char *itopog, int interp_order, 
+                           double sea_level, char *mosaic_name, int check)
+{
+  int c, i, same_mosaic;
+   char mosaic_file[STRING];
+   char imosaic_name[STRING], amosaic_name[STRING], lmosaic_name[STRING];
+  char **otile_name=NULL, **atile_name=NULL, **ltile_name=NULL;
+  int x_refine = 2, y_refine = 2;
+  int nfile_lxo=0, nfile_axo=0, nfile_axl=0;
+  char lxo_file[MAXXGRIDFILE][STRING];
+  char axo_file[MAXXGRIDFILE][STRING];
+  char axl_file[MAXXGRIDFILE][STRING];
+  char amosaicxlmosaic_file[STRING];
+  char amosaicximosaic_file[STRING];
+  char lmosaicximosaic_file[STRING];
+  char amosaic_dir[STRING], amosaic_file[STRING];
+  char lmosaic_dir[STRING], lmosaic_file[STRING];
+  char imosaic_dir[STRING], imosaic_file[STRING];
+  char omosaic_dir[STRING], omosaic_file[STRING];
+  char itopog_dir [STRING], itopog_file[STRING];
+  int    ntile_ocn, ntile_atm, ntile_lnd;
+  int    *nxo = NULL, *nyo = NULL, *nxa = NULL, *nya = NULL, *nxl = NULL, *nyl = NULL;
+  double **xocn = NULL, **yocn = NULL, **xatm = NULL, **yatm = NULL, **xlnd = NULL, **ylnd = NULL;
+  double **area_ocn = NULL, **area_lnd = NULL, **area_atm = NULL;
+  double **omask = NULL;
+  int    lnd_same_as_atm = 0;
+  int    option_index = 0;
+  double axo_area_sum = 0, axl_area_sum = 0;
+  int    ocn_south_ext = 0;
+    
+  /*mosaic_file can not have the same name as amosaic, lmosaic or imosaic, also the file name of
+    amosaic, lmosaic, imosaic can not be "mosaic.nc"
+  */
+  sprintf(mosaic_file, "%s.nc", mosaic_name);
+  get_file_dir_and_name(amosaic, amosaic_dir, amosaic_file);
+  get_file_dir_and_name(lmosaic, lmosaic_dir, lmosaic_file);
+  get_file_dir_and_name(omosaic, omosaic_dir, omosaic_file);
+  get_file_dir_and_name(imosaic, imosaic_dir, imosaic_file);
+  get_file_dir_and_name(itopog,  itopog_dir,  itopog_file);
+  
+  if( !strcmp(mosaic_file, amosaic) || !strcmp(mosaic_file, lmosaic) || !strcmp(mosaic_file, imosaic) ) 
+    mpp_error("make_coupler_mosaic: mosaic_file can not have the same name as amosaic, lmosaic or imosaic"); 
+  if( !strcmp(amosaic, "mosaic.nc") || !strcmp(lmosaic, "mosaic.nc") || !strcmp(imosaic, "mosaic.nc") ) 
+    mpp_error("make_coupler_mosaic: the file name of amosaic, lmosaic or imosaic can not be mosaic.nc"); 
+
+  
+  /*
+   * Read atmosphere grid
+   */
+  {
+    int n, m_fid, g_fid, vid, gid, tid;
+    size_t start[4], nread[4];
+    char filename[STRING], file[2*STRING];    
+
+    for(n=0; n<4; n++) {
+      start[n] = 0;
+      nread[n] = 1;
+    }
+
+    m_fid = mpp_open(amosaic, MPP_READ);
+    vid = mpp_get_varid(m_fid, MOSAIC_NAME);    
+    mpp_get_var_value(m_fid, vid, amosaic_name);
+    ntile_atm  = mpp_get_dimlen(m_fid, NTILES_NAME);
+    nxa        = (int *) malloc (ntile_atm*sizeof(int));
+    nya        = (int *) malloc (ntile_atm*sizeof(int));
+    xatm       = (double **) malloc( ntile_atm*sizeof(double *));
+    yatm       = (double **) malloc( ntile_atm*sizeof(double *));
+    area_atm   = (double **) malloc( ntile_atm*sizeof(double *));
+    atile_name = (char **)malloc(ntile_atm*sizeof(char *));
+    /* grid should be located in the same directory of mosaic file */
+    gid = mpp_get_varid(m_fid, TILE_FILES_NAME);
+    for(n=0; n<ntile_atm; n++) {
+      double *tmpx, *tmpy;
+      int i, j;
+      
+      start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
+      mpp_get_var_value_block(m_fid, gid, start, nread, filename);
+      atile_name[n] = (char *)malloc(STRING*sizeof(char));
+      sprintf(file, "%s/%s", amosaic_dir, filename);
+      g_fid = mpp_open(file, MPP_READ);
+      tid   = mpp_get_varid(g_fid, TILE_NAME);
+      mpp_get_var_value(g_fid, tid, atile_name[n]);
+      nxa[n] = mpp_get_dimlen(g_fid, NX_NAME);
+      nya[n] = mpp_get_dimlen(g_fid, NY_NAME);
+      if(nxa[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: atmos supergrid x-size can not be divided by x_refine");
+      if(nya[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: atmos supergrid y-size can not be divided by y_refine");
+      nxa[n] /= x_refine;
+      nya[n] /= y_refine;
+      xatm[n]     = (double *)malloc((nxa[n]+1)*(nya[n]+1)*sizeof(double));
+      yatm[n]     = (double *)malloc((nxa[n]+1)*(nya[n]+1)*sizeof(double));
+      area_atm[n] = (double *)malloc((nxa[n]  )*(nya[n]  )*sizeof(double));
+      tmpx        = (double *)malloc((nxa[n]*x_refine+1)*(nya[n]*y_refine+1)*sizeof(double));
+      tmpy        = (double *)malloc((nxa[n]*x_refine+1)*(nya[n]*y_refine+1)*sizeof(double));
+      vid = mpp_get_varid(g_fid,  X_NAME);
+      mpp_get_var_value(g_fid, vid, tmpx);
+      vid = mpp_get_varid(g_fid,  Y_NAME);
+      mpp_get_var_value(g_fid, vid, tmpy);      
+      for(j = 0; j < nya[n]+1; j++) for(i = 0; i < nxa[n]+1; i++) {
+	xatm[n][j*(nxa[n]+1)+i] = tmpx[(j*y_refine)*(nxa[n]*x_refine+1)+i*x_refine];
+	yatm[n][j*(nxa[n]+1)+i] = tmpy[(j*y_refine)*(nxa[n]*x_refine+1)+i*x_refine];
+      }
+      free(tmpx);
+      free(tmpy);      
+      /*scale grid from degree to radian, because create_xgrid assume the grid is in radians */
+      for(i=0; i<(nxa[n]+1)*(nya[n]+1); i++) {
+	xatm[n][i] *= D2R;
+	yatm[n][i] *= D2R;
+      }
+      get_grid_area(nxa+n, nya+n, xatm[n], yatm[n], area_atm[n]);
+      mpp_close(g_fid);
+    }
+    mpp_close(m_fid);
+  }
+
+  /*
+   * Read land grid
+   */
+  if (strcmp(lmosaic, amosaic) ) { /* land mosaic is different from atmosphere mosaic */
+    int n, m_fid, g_fid, vid, gid, tid;
+    size_t start[4], nread[4];
+    char filename[STRING], file[2*STRING];   
+
+    for(n=0; n<4; n++) {
+      start[n] = 0;
+      nread[n] = 1;
+    }
+    m_fid = mpp_open(lmosaic, MPP_READ);
+    vid = mpp_get_varid(m_fid, MOSAIC_NAME);    
+    mpp_get_var_value(m_fid, vid, lmosaic_name);
+    ntile_lnd  = mpp_get_dimlen(m_fid, NTILES_NAME);
+    nxl        = (int *) malloc (ntile_lnd*sizeof(int));
+    nyl        = (int *) malloc (ntile_lnd*sizeof(int));
+    xlnd       = (double **) malloc( ntile_lnd*sizeof(double *));
+    ylnd       = (double **) malloc( ntile_lnd*sizeof(double *));
+    area_lnd   = (double **) malloc( ntile_lnd*sizeof(double *));
+    ltile_name = (char **)malloc(ntile_lnd*sizeof(char *));
+    /* grid should be located in the same directory of mosaic file */
+    gid = mpp_get_varid(m_fid, TILE_FILES_NAME);
+    for(n=0; n<ntile_lnd; n++) {
+      double *tmpx, *tmpy;
+      int i, j;
+      
+      start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
+      mpp_get_var_value_block(m_fid, gid, start, nread, filename);
+      ltile_name[n] = (char *)malloc(STRING*sizeof(char));
+      mpp_get_var_value_block(m_fid, tid, start, nread,  ltile_name[n]);
+      sprintf(file, "%s/%s", lmosaic_dir, filename);
+      g_fid = mpp_open(file, MPP_READ);
+      tid   = mpp_get_varid(g_fid, TILE_NAME);
+      mpp_get_var_value(g_fid, tid, ltile_name[n]);
+      nxl[n] = mpp_get_dimlen(g_fid, NX_NAME);
+      nyl[n] = mpp_get_dimlen(g_fid, NY_NAME);
+      if(nxl[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: land supergrid x-size can not be divided by x_refine");
+      if(nyl[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: land supergrid y-size can not be divided by y_refine");
+      nxl[n]      /= x_refine;
+      nyl[n]      /= y_refine;
+      xlnd[n]     = (double *)malloc((nxl[n]+1)*(nyl[n]+1)*sizeof(double));
+      ylnd[n]     = (double *)malloc((nxl[n]+1)*(nyl[n]+1)*sizeof(double));
+      area_lnd[n] = (double *)malloc((nxl[n]  )*(nyl[n]  )*sizeof(double));
+      tmpx        = (double *)malloc((nxl[n]*x_refine+1)*(nyl[n]*y_refine+1)*sizeof(double));
+      tmpy        = (double *)malloc((nxl[n]*x_refine+1)*(nyl[n]*y_refine+1)*sizeof(double));
+      vid = mpp_get_varid(g_fid, X_NAME);
+      mpp_get_var_value(g_fid, vid, tmpx);
+      vid = mpp_get_varid(g_fid, Y_NAME);
+      mpp_get_var_value(g_fid, vid, tmpy);     
+      for(j = 0; j < nyl[n]+1; j++) for(i = 0; i < nxl[n]+1; i++) {
+	xlnd[n][j*(nxl[n]+1)+i] = tmpx[(j*y_refine)*(nxl[n]*x_refine+1)+i*x_refine];
+	ylnd[n][j*(nxl[n]+1)+i] = tmpy[(j*y_refine)*(nxl[n]*x_refine+1)+i*x_refine];
+      }
+      free(tmpx);
+      free(tmpy);
+      /*scale grid from degree to radian, because create_xgrid assume the grid is in radians */
+      for(i=0; i<(nxl[n]+1)*(nyl[n]+1); i++) {
+	xlnd[n][i] *= D2R;
+	ylnd[n][i] *= D2R;
+      }
+      get_grid_area(nxl+n, nyl+n, xlnd[n], ylnd[n], area_lnd[n]);
+      mpp_close(g_fid);
+    }
+    mpp_close(m_fid);
+  }
+  else { /* land mosaic is same as atmosphere mosaic */
+    ntile_lnd = ntile_atm;
+    nxl = nxa;
+    nyl = nya;
+    xlnd = xatm;
+    ylnd = yatm;
+    area_lnd = area_atm;
+    lnd_same_as_atm = 1;
+    strcpy(lmosaic_name, amosaic_name);
+    ltile_name = atile_name;
+  }
+
+  /*
+   * Read ocean grid boundaries and mask (where water is) for each tile within the mosaic.
+   */
+  {
+    int n, ntiles, m_fid, g_fid, t_fid, vid, gid, tid, fid;
+    size_t start[4], nread[4];
+    char filename[STRING], file[2*STRING];
+    
+    for(n=0; n<4; n++) {
+      start[n] = 0;
+      nread[n] = 1;
+    }
+    fid = mpp_open(itopog, MPP_READ);
+    ntile_ocn  = mpp_get_dimlen(fid, NTILES_NAME);
+    m_fid = mpp_open(imosaic, MPP_READ);
+    ntiles = mpp_get_dimlen(m_fid, NTILES_NAME);
+    if(ntile_ocn != ntiles) mpp_error("make_coupler_mosaic: dimlen ntiles in ocean topog mosaic file is not the same as in ocean grid mosaic file");
+    
+    nxo      = (int     *) malloc(ntile_ocn*sizeof(int));
+    nyo      = (int     *) malloc(ntile_ocn*sizeof(int));
+    xocn     = (double **) malloc(ntile_ocn*sizeof(double *));
+    yocn     = (double **) malloc(ntile_ocn*sizeof(double *));
+    area_ocn = (double **) malloc(ntile_ocn*sizeof(double *));
+    otile_name = (char **) malloc(ntile_ocn*sizeof(char *));
+    
+    vid = mpp_get_varid(m_fid, MOSAIC_NAME);    
+    mpp_get_var_value(m_fid, vid, imosaic_name);
+    
+    gid = mpp_get_varid(m_fid, TILE_FILES_NAME);
+
+    /* For the purpose of reproducing between processor count, the layout
+       is set to (1, npes). */
+
+    for(n=0; n<ntile_ocn; n++) {
+      double *tmpx, *tmpy;
+      int i, j;
+      double min_atm_lat, min_lat;
+      
+      start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
+      mpp_get_var_value_block(m_fid, gid, start, nread, filename);
+      otile_name[n] = (char *)malloc(STRING*sizeof(char));
+      sprintf(file, "%s/%s", imosaic_dir, filename);
+      g_fid = mpp_open(file, MPP_READ);
+      tid   = mpp_get_varid(g_fid, TILE_NAME);
+      mpp_get_var_value(g_fid, tid, otile_name[n]);      
+      nxo[n] = mpp_get_dimlen(g_fid, NX_NAME);
+      nyo[n] = mpp_get_dimlen(g_fid, NY_NAME);
+      if(nxo[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: ocean supergrid x-size can not be divided by x_refine");
+      if(nyo[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: ocean supergrid y-size can not be divided by y_refine");
+      tmpx        = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
+      tmpy        = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
+      vid = mpp_get_varid(g_fid, X_NAME);
+      mpp_get_var_value(g_fid, vid, tmpx);
+      vid = mpp_get_varid(g_fid, Y_NAME);
+      mpp_get_var_value(g_fid, vid, tmpy);     
+   
+      /* sometimes the ocean is only covered part of atmosphere, especially not cover
+	 the south pole region. In order to get all the exchange grid between atmosXland,
+	 we need to extend one point to cover the whole atmosphere. This need the
+	 assumption of one-tile ocean. Also we assume the latitude is the along j=0
+      */
+      if(ntile_ocn == 1) {
+	int na;
+	for(i=1; i<=nxo[n]; i++) 
+	  if(tmpy[i] != tmpy[i-1]) mpp_error("make_coupler_mosaic: latitude is not uniform along j=0");
+	/* calculate the minimum of latitude of atmosphere grid */
+	min_atm_lat = 9999; /* dummy large value */
+	for(na=0; na<ntile_atm; na++) {
+	  min_lat = minval_double((nxa[na]+1)*(nya[na]+1), yatm[na]);
+	  if(min_atm_lat > min_lat) min_atm_lat = min_lat;
+	}
+	if(tmpy[0]*D2R > min_atm_lat + TINY_VALUE) { /* extend one point in south direction*/
+	  ocn_south_ext = 1;
+	}
+      }      
+      nxo[n] /= x_refine;
+      nyo[n] /= y_refine;
+      nyo[n] += ocn_south_ext;
+      xocn[n]     = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
+      yocn[n]     = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
+      area_ocn[n] = (double *)malloc((nxo[n]  )*(nyo[n]  )*sizeof(double));
+
+      for(j = 0; j < nyo[n]+1; j++) for(i = 0; i < nxo[n]+1; i++) {
+	xocn[n][(j+ocn_south_ext)*(nxo[n]+1)+i] = tmpx[(j*y_refine)*(nxo[n]*x_refine+1)+i*x_refine] * D2R;
+	yocn[n][(j+ocn_south_ext)*(nxo[n]+1)+i] = tmpy[(j*y_refine)*(nxo[n]*x_refine+1)+i*x_refine] * D2R;
+      }
+      if(ocn_south_ext==1) {
+	for(i=0; i<nxo[n]+1; i++) {
+	  xocn[n][i] = xocn[n][nxo[n]+1+i];
+	  yocn[n][i] = min_atm_lat;
+	}
+      }
+      free(tmpx);
+      free(tmpy);
+      get_grid_area(nxo+n, nyo+n, xocn[n], yocn[n], area_ocn[n]);
+      mpp_close(g_fid);
+    }
+    mpp_close(m_fid);
+    
+    /* read ocean topography */
+    tid= mpp_get_varid(fid, "tile_files"); 
+    
+    omask = (double **)malloc(ntile_ocn*sizeof(double *));
+    for(n=0; n<ntile_ocn; n++) {
+      char name[128];
+      char topog_file[256];
+      int nx, ny, i, j;
+      double *depth;
+
+      start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
+      mpp_get_var_value_block(fid, tid, start, nread, filename);
+      sprintf(topog_file, "%s/%s", itopog_dir, filename);
+      t_fid = mpp_open(topog_file, MPP_READ);
+      
+      nx = mpp_get_dimlen(t_fid, NX_NAME);
+      ny = mpp_get_dimlen(t_fid, NY_NAME);
+      if( nx != nxo[n] || ny+ocn_south_ext != nyo[n]) mpp_error("make_coupler_mosaic: grid size mismatch between mosaic file and topog file");
+      omask[n] = (double *)malloc(nxo[n]*nyo[n]*sizeof(double));
+      if(mpp_var_exist(t_fid, MASK_NAME)) {
+	if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: the ocean land/sea mask will be "
+					     "determined by field area_frac from file %s\n", itopog);
+        vid = mpp_get_varid(t_fid, MASK_NAME);
+	mpp_get_var_value(t_fid, vid, omask[n]);
+      }
+      else {
+	if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: the ocean land/sea mask will be "
+					     "determined by field depth from file %s\n", itopog);
+	depth    = (double *)malloc(nx*ny*sizeof(double));
+	vid = mpp_get_varid(t_fid, DEPTH_NAME);
+	mpp_get_var_value(t_fid, vid, depth);
+	for(i=0; i<nxo[n]*nyo[n]; i++) omask[n][i] = 0;
+	for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
+	  if(depth[j*nx+i] >sea_level) omask[n][(j+ocn_south_ext)*nx+i] = 1;
+	}
+	free(depth);
+      }
+      mpp_close(t_fid);
+    }
+    mpp_close(fid);
+  }    
+
+  
+  /* Either imosaic is different from both lmosaic and amosaic,
+     or all the three mosaic are the same
+  */
+  if(strcmp(imosaic_name, amosaic_name)) { /* imosaic is different from amosaic */
+    if(!strcmp(imosaic_name, lmosaic_name)) mpp_error("make_coupler_mosaic: imosaic is the same as lmosaic, "
+						      "but different from amosaic.");
+    same_mosaic = 0;
+  }
+  else { /* imosaic is same as amosaic */
+    if(strcmp(imosaic_name, lmosaic_name)) mpp_error("make_coupler_mosaic: imosaic is the same as amosaic, "
+						      "but different from lmosaic.");
+    same_mosaic = 1;
+  }
+    
+    
+  /***************************************************************************************
+     First generate the exchange grid between atmos mosaic and land/ocean mosaic              
+  ***************************************************************************************/
+  nfile_axo = 0;
+  nfile_axl = 0;
+  nfile_lxo = 0;
+  {
+    int no, nl, na, n;
+    size_t  **naxl, **naxo;
+    int     ***atmxlnd_ia,   ***atmxlnd_ja,   ***atmxlnd_il,   ***atmxlnd_jl;
+    int     ***atmxocn_ia,   ***atmxocn_ja,   ***atmxocn_io,   ***atmxocn_jo;
+    double  ***atmxlnd_area, ***atmxlnd_dia,  ***atmxlnd_dja,  ***atmxlnd_dil,  ***atmxlnd_djl;
+    double  ***atmxocn_area, ***atmxocn_dia,  ***atmxocn_dja,  ***atmxocn_dio,  ***atmxocn_djo;
+    double  ***atmxocn_clon, ***atmxocn_clat, ***atmxlnd_clon, ***atmxlnd_clat;
+    double   min_area; 
+
+    naxl         = (size_t ** )malloc(ntile_atm*sizeof(size_t *));
+    naxo         = (size_t ** )malloc(ntile_atm*sizeof(size_t *));
+    atmxlnd_area = (double ***)malloc(ntile_atm*sizeof(double **));
+    atmxlnd_ia   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+    atmxlnd_ja   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+    atmxlnd_il   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+    atmxlnd_jl   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+    atmxocn_area = (double ***)malloc(ntile_atm*sizeof(double **));
+    atmxocn_ia   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+    atmxocn_ja   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+    atmxocn_io   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+    atmxocn_jo   = (int    ***)malloc(ntile_atm*sizeof(int    **));
+
+    if(interp_order == 2 ) {
+      atmxlnd_dia  = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxlnd_dja  = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxlnd_dil  = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxlnd_djl  = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxocn_dia  = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxocn_dja  = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxocn_dio  = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxocn_djo  = (double ***)malloc(ntile_atm*sizeof(double **));      
+      atmxlnd_clon = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxlnd_clat = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxocn_clon = (double ***)malloc(ntile_atm*sizeof(double **));
+      atmxocn_clat = (double ***)malloc(ntile_atm*sizeof(double **));      
+    }
+    
+    for(na=0; na<ntile_atm; na++) {
+      naxl[na]         = (size_t * )malloc(ntile_lnd*sizeof(size_t));
+      naxo[na]         = (size_t * )malloc(ntile_ocn*sizeof(size_t));
+      atmxlnd_area[na] = (double **)malloc(ntile_lnd*sizeof(double *));
+      atmxlnd_ia[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
+      atmxlnd_ja[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
+      atmxlnd_il[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
+      atmxlnd_jl[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
+      atmxocn_area[na] = (double **)malloc(ntile_ocn*sizeof(double *));
+      atmxocn_ia[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
+      atmxocn_ja[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
+      atmxocn_io[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
+      atmxocn_jo[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
+    
+      if(interp_order == 2 ) {
+	atmxlnd_dia [na] = (double **)malloc(ntile_lnd*sizeof(double *));
+	atmxlnd_dja [na] = (double **)malloc(ntile_lnd*sizeof(double *));
+	atmxlnd_dil [na] = (double **)malloc(ntile_lnd*sizeof(double *));
+	atmxlnd_djl [na] = (double **)malloc(ntile_lnd*sizeof(double *));
+	atmxocn_dia [na] = (double **)malloc(ntile_ocn*sizeof(double *));
+	atmxocn_dja [na] = (double **)malloc(ntile_ocn*sizeof(double *));
+	atmxocn_dio [na] = (double **)malloc(ntile_ocn*sizeof(double *));
+	atmxocn_djo [na] = (double **)malloc(ntile_ocn*sizeof(double *));
+	atmxlnd_clon[na] = (double **)malloc(ntile_lnd*sizeof(double *));
+	atmxlnd_clat[na] = (double **)malloc(ntile_lnd*sizeof(double *));
+	atmxocn_clon[na] = (double **)malloc(ntile_ocn*sizeof(double *));
+	atmxocn_clat[na] = (double **)malloc(ntile_ocn*sizeof(double *));      
+      }
+
+      for(nl=0; nl<ntile_lnd; nl++) {
+	atmxlnd_area[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
+	atmxlnd_ia  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	atmxlnd_ja  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	atmxlnd_il  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	atmxlnd_jl  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	if(interp_order == 2 ) {
+	  atmxlnd_clon[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxlnd_clat[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxlnd_dia [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxlnd_dja [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxlnd_dil [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxlnd_djl [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
+	}
+      }
+ 
+      for(no=0; no<ntile_ocn; no++) {
+	atmxocn_area[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	atmxocn_ia  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	atmxocn_ja  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	atmxocn_io  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	atmxocn_jo  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));          
+	if(interp_order == 2 ) {
+	  atmxocn_clon[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxocn_clat[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxocn_dia [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxocn_dja [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxocn_dio [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	  atmxocn_djo [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	}
+      }
+    }
+      
+    for(na=0; na<ntile_atm; na++) {
+      
+      int      l, is, ie, js, je, la, ia, ja, il, jl, io, jo, layout[2];
+      int      n0, n1, n2, n3, na_in, nl_in, no_in, n_out, n_out2;
+      double   xa_min, ya_min, xo_min, yo_min, xl_min, yl_min, xa_avg;
+      double   xa_max, ya_max, xo_max, yo_max, xl_max, yl_max;
+      double   xarea;
+      double   xa[MV], ya[MV], xl[MV], yl[MV], xo[MV], yo[MV];
+      double   x_out[MV], y_out[MV];
+      double   atmxlnd_x[MX][MV], atmxlnd_y[MX][MV];
+      int      num_v[MX];
+      int      axl_i[MX], axl_j[MX], axl_t[MX];
+      double   axl_xmin[MX], axl_xmax[MX], axl_ymin[MX], axl_ymax[MX];
+      double   axl_area[MX], axl_clon[MX], axl_clat[MX];
+      size_t   count;
+      domain2D Dom;
+      
+      for(nl=0; nl<ntile_lnd; nl++) naxl[na][nl] = 0;
+      for(no=0; no<ntile_ocn; no++) naxo[na][no] = 0;
+      layout[0] = mpp_npes();
+      layout[1] = 1;
+        
+      mpp_define_domain2d(nxa[na]*nya[na], 1, layout, 0, 0, &Dom);
+      mpp_get_compute_domain2d(Dom, &is, &ie, &js, &je );
+      for(la=is;la<=ie;la++) {
+	
+	ia = la%nxa[na];
+	ja = la/nxa[na];
+	n0 = ja    *(nxa[na]+1) + ia;
+	n1 = ja    *(nxa[na]+1) + ia+1;
+	n2 = (ja+1)*(nxa[na]+1) + ia+1;
+	n3 = (ja+1)*(nxa[na]+1) + ia;
+	xa[0] = xatm[na][n0]; ya[0] = yatm[na][n0];
+        xa[1] = xatm[na][n1]; ya[1] = yatm[na][n1];
+	xa[2] = xatm[na][n2]; ya[2] = yatm[na][n2];
+        xa[3] = xatm[na][n3]; ya[3] = yatm[na][n3];
+	ya_min  = minval_double(4, ya);
+	ya_max  = maxval_double(4, ya);
+	na_in   = fix_lon(xa, ya, 4, M_PI);
+	xa_min  = minval_double(na_in, xa);
+	xa_max  = maxval_double(na_in, xa);
+	xa_avg  = avgval_double(na_in, xa);
+	count = 0;
+	for(nl=0; nl<ntile_lnd; nl++) {
+	  for(jl = 0; jl < nyl[nl]; jl ++) for(il = 0; il < nxl[nl]; il++) {
+	    n0 = jl    *(nxl[nl]+1) + il;
+	    n1 = jl    *(nxl[nl]+1) + il+1;
+	    n2 = (jl+1)*(nxl[nl]+1) + il+1;
+	    n3 = (jl+1)*(nxl[nl]+1) + il;
+	    xl[0] = xlnd[nl][n0]; yl[0] = ylnd[nl][n0];
+	    xl[1] = xlnd[nl][n1]; yl[1] = ylnd[nl][n1];
+	    xl[2] = xlnd[nl][n2]; yl[2] = ylnd[nl][n2];
+	    xl[3] = xlnd[nl][n3]; yl[3] = ylnd[nl][n3];
+	    yl_min = minval_double(4, yl);
+	    yl_max = maxval_double(4, yl);
+            if(yl_min >= ya_max || yl_max <= ya_min ) continue;	    
+	    nl_in  = fix_lon(xl, yl, 4, xa_avg);
+	    xl_min = minval_double(nl_in, xl);
+	    xl_max = maxval_double(nl_in, xl);
+	    /* xl should in the same range as xa after lon_fix, so no need to
+	       consider cyclic condition
+	    */
+	      	    
+	    if(xa_min >= xl_max || xa_max <= xl_min ) continue;	
+	    if (  (n_out = clip_2dx2d( xa, ya, na_in, xl, yl, nl_in, x_out, y_out )) > 0 ) {
+	      xarea = poly_area(x_out, y_out, n_out);
+	      min_area = min(area_lnd[nl][jl*nxl[nl]+il], area_atm[na][la]);
+	      if( xarea/min_area > AREA_RATIO_THRESH ) {
+		/*  remember the exchange grid vertices */
+		for(n=0; n<n_out; n++) {
+		  atmxlnd_x[count][n] = x_out[n];
+		  atmxlnd_y[count][n] = y_out[n];
+		}
+		axl_i[count]    = il;
+		axl_j[count]    = jl;
+		axl_t[count]    = nl;
+		num_v[count]    = n_out;
+		axl_xmin[count] = minval_double(n_out, x_out);
+		axl_xmax[count] = maxval_double(n_out, x_out);
+		axl_ymin[count] = minval_double(n_out, y_out);
+		axl_ymax[count] = maxval_double(n_out, y_out);
+		axl_area[count] = 0;
+		if(interp_order == 2) {
+		  axl_clon[count] = 0;
+		  axl_clat[count] = 0;
+		}
+		++count;
+		if(count>MX) mpp_error("make_coupler_mosaic: count is greater than MX, increase MX");
+      	      }
+	    }
+	  }
+	}
+
+	/* calculate atmos/ocean x-cells */
+	for(no=0; no<ntile_ocn; no++) {
+	  for(jo = 0; jo < nyo[no]; jo++) for(io = 0; io < nxo[no]; io++) {
+	    double ocn_frac, lnd_frac;
+	    n0 = jo    *(nxo[no]+1) + io;
+	    n1 = jo    *(nxo[no]+1) + io+1;
+	    n2 = (jo+1)*(nxo[no]+1) + io+1;
+	    n3 = (jo+1)*(nxo[no]+1) + io;
+	    xo[0] = xocn[no][n0]; yo[0] = yocn[no][n0];
+	    xo[1] = xocn[no][n1]; yo[1] = yocn[no][n1];
+	    xo[2] = xocn[no][n2]; yo[2] = yocn[no][n2];
+	    xo[3] = xocn[no][n3]; yo[3] = yocn[no][n3];
+	    yo_min = minval_double(4, yo);
+	    yo_max = maxval_double(4, yo);
+	    no_in  = fix_lon(xo, yo, 4, xa_avg);
+	    xo_min = minval_double(no_in, xo);
+	    xo_max = maxval_double(no_in, xo);
+	    ocn_frac = omask[no][jo*nxo[no]+io];
+	    lnd_frac = 1 - ocn_frac;
+	    if(ocn_frac > MIN_AREA_FRAC) { /* over sea/ice */
+	      /* xo should in the same range as xa after lon_fix, so no need to
+		 consider cyclic condition
+	      */
+              if(xa_min >= xo_max || xa_max <= xo_min || yo_min >= ya_max || yo_max <= ya_min ) continue;	    
+
+	      if (  (n_out = clip_2dx2d( xa, ya, na_in, xo, yo, no_in, x_out, y_out )) > 0) {
+		xarea = poly_area(x_out, y_out, n_out )*ocn_frac;
+		min_area = min(area_ocn[no][jo*nxo[no]+io], area_atm[na][la]);
+		if(xarea/min_area > AREA_RATIO_THRESH) {
+	    
+		  atmxocn_area[na][no][naxo[na][no]] = xarea;
+		  atmxocn_io[na][no][naxo[na][no]]   = io;
+		  atmxocn_jo[na][no][naxo[na][no]]   = jo;
+		  atmxocn_ia[na][no][naxo[na][no]]   = ia;
+		  atmxocn_ja[na][no][naxo[na][no]]   = ja;
+		  if(interp_order == 2) {
+		    atmxocn_clon[na][no][naxo[na][no]] = poly_ctrlon ( x_out, y_out, n_out, xa_avg)*ocn_frac;
+		    atmxocn_clat[na][no][naxo[na][no]] = poly_ctrlat ( x_out, y_out, n_out )*ocn_frac;		
+		  }
+		  ++(naxo[na][no]);
+		  if(naxo[na][no] > MAXXGRID) mpp_error("naxo is greater than MAXXGRID, increase MAXXGRID");
+		}
+	      }
+	    }
+	    if(lnd_frac > MIN_AREA_FRAC) { /* over land */
+	      /* find the overlap of atmxlnd and ocean cell */
+	      for(l=0; l<count; l++) {
+		if(axl_xmin[l] >= xo_max || axl_xmax[l] <= xo_min || axl_ymin[l] >= ya_max || axl_ymax[l] <= ya_min ) continue;	  
+		if((n_out = clip_2dx2d( atmxlnd_x[l], atmxlnd_y[l], num_v[l], xo, yo, no_in, x_out, y_out )) > 0) {
+		  xarea = poly_area(x_out, y_out, n_out )*lnd_frac;
+		  min_area = min(area_lnd[axl_t[l]][axl_j[l]*nxl[axl_t[l]]+axl_i[l]], area_atm[na][la]);
+		  if(xarea/min_area > AREA_RATIO_THRESH) {
+		    axl_area[l] += xarea;
+		    if(interp_order == 2) {
+		      axl_clon[l] += poly_ctrlon ( x_out, y_out, n_out, xa_avg)*lnd_frac;
+		      axl_clat[l] += poly_ctrlat ( x_out, y_out, n_out)*lnd_frac;
+		    }
+		  }
+		}
+	      }
+	    }
+	  }
+	}
+	/* get the exchange grid between land and atmos. */
+	for(l=0; l<count; l++) {
+	  nl = axl_t[l];
+	  min_area = min(area_lnd[nl][axl_j[l]*nxl[nl]+axl_i[l]], area_atm[na][la]);
+	  if(axl_area[l]/min_area > AREA_RATIO_THRESH) {
+	    atmxlnd_area[na][nl][naxl[na][nl]] = axl_area[l];
+	    atmxlnd_ia  [na][nl][naxl[na][nl]] = ia;
+	    atmxlnd_ja  [na][nl][naxl[na][nl]] = ja;
+	    atmxlnd_il  [na][nl][naxl[na][nl]] = axl_i[l];
+	    atmxlnd_jl  [na][nl][naxl[na][nl]] = axl_j[l];
+	    if(interp_order == 2) {
+	      atmxlnd_clon[na][nl][naxl[na][nl]] = axl_clon[l];
+	      atmxlnd_clat[na][nl][naxl[na][nl]] = axl_clat[l];
+	    }
+	    ++(naxl[na][nl]);
+	    if(naxl[na][nl] > MAXXGRID) mpp_error("naxl is greater than MAXXGRID, increase MAXXGRID");
+	  }
+	}   
+      }/* end of la loop */
+
+      mpp_delete_domain2d(&Dom);
+    } /* end of na loop */
+
+    /* calculate the centroid of model grid, as well as land_mask and ocean_mask */
+    {
+      double **l_area, **o_area;
+      int    nl, no, ll, lo;
+      l_area = (double **)malloc(ntile_lnd*sizeof(double *));
+      o_area = (double **)malloc(ntile_ocn*sizeof(double *));
+      for(nl =0; nl<ntile_lnd; nl++) {
+	l_area[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
+	for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
+	  l_area[nl][ll] = 0;
+	}
+      }
+      for(no =0; no<ntile_ocn; no++) {
+	o_area[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
+	for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
+	  o_area[no][lo] = 0;
+	}
+      }
+            
+      if(interp_order == 1) {
+	for(na=0; na<ntile_atm; na++) {
+	  for(nl=0; nl<ntile_lnd; nl++) {
+	    int nxgrid;
+	  
+	    nxgrid = naxl[na][nl];
+	    mpp_sum_int(1, &nxgrid);
+	    if(nxgrid > 0) {
+	      double *g_area;
+	      int    *g_il, *g_jl;
+	      int    ii;
+	      g_il = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_jl = (int    *)malloc(nxgrid*sizeof(int   ));	
+	      g_area = (double *)malloc(nxgrid*sizeof(double));
+	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_il[na][nl], g_il);
+	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_jl[na][nl], g_jl);
+	      mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], g_area);
+	      for(i=0; i<nxgrid; i++) {
+		ii = g_jl[i]*nxl[nl]+g_il[i];
+		l_area[nl][ii] += g_area[i];
+	      }
+	      free(g_il);
+	      free(g_jl);
+	      free(g_area);
+	    }
+	  }
+
+	  for(no=0; no<ntile_ocn; no++) {
+	    int nxgrid;
+	    nxgrid = naxo[na][no];
+	    mpp_sum_int(1, &nxgrid);
+	    if(nxgrid > 0) {
+	      double *g_area;
+	      int    *g_io, *g_jo;
+	      int    ii;
+	      g_io = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
+	      g_area = (double *)malloc(nxgrid*sizeof(double));
+	      mpp_gather_field_int   (naxo[na][no], atmxocn_io[na][no], g_io);
+	      mpp_gather_field_int   (naxo[na][no], atmxocn_jo[na][no], g_jo);
+	      mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], g_area);
+	      for(i=0; i<nxgrid; i++) {	      
+		ii = g_jo[i]*nxo[no]+g_io[i];
+		o_area[no][ii] += g_area[i];
+	      }
+	      free(g_io);
+	      free(g_jo);
+	      free(g_area);
+	    }
+	  }
+	}
+      }
+      else { /* interp_order == 2 */
+	double **l_clon, **l_clat;
+	double **o_clon, **o_clat;
+	double  *a_area,  *a_clon,  *a_clat;
+	int la;
+      
+	l_clon = (double **)malloc(ntile_lnd*sizeof(double *));
+	l_clat = (double **)malloc(ntile_lnd*sizeof(double *));
+	for(nl =0; nl<ntile_lnd; nl++) {
+	  l_clon[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
+	  l_clat[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
+	  for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
+	    l_clon[nl][ll] = 0;
+	    l_clat[nl][ll] = 0;
+	  }
+	}
+	o_clon = (double **)malloc(ntile_ocn*sizeof(double *));
+	o_clat = (double **)malloc(ntile_ocn*sizeof(double *));
+	for(no =0; no<ntile_ocn; no++) {
+	  o_clon[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
+	  o_clat[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
+	  for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
+	    o_clon[no][lo] = 0;
+	    o_clat[no][lo] = 0;
+	  }
+	}	
+	for(na=0; na<ntile_atm; na++) {
+	  //	double *area, *clon, *clat;
+      
+	  a_area = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
+	  a_clon = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
+	  a_clat = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
+	  for(la=0; la<nxa[na]*nya[na]; la++) {
+	    a_area[la] = 0;
+	    a_clon[la] = 0;
+	    a_clat[la] = 0;
+	  }
+
+	  for(nl=0; nl<ntile_lnd; nl++) {
+	    int nxgrid;
+	  
+	    nxgrid = naxl[na][nl];
+	    mpp_sum_int(1, &nxgrid);
+	    if(nxgrid > 0) {
+	      double *g_area, *g_clon, *g_clat;
+	      int    *g_ia,   *g_ja,   *g_il, *g_jl;
+	      int    ii;
+	      g_ia = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_ja = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_il = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_jl = (int    *)malloc(nxgrid*sizeof(int   ));	
+	      g_area = (double *)malloc(nxgrid*sizeof(double));
+	      g_clon = (double *)malloc(nxgrid*sizeof(double));
+	      g_clat = (double *)malloc(nxgrid*sizeof(double));
+	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_ia[na][nl], g_ia);
+	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_ja[na][nl], g_ja);
+	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_il[na][nl], g_il);
+	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_jl[na][nl], g_jl);
+	      mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], g_area);
+	      mpp_gather_field_double(naxl[na][nl], atmxlnd_clon[na][nl], g_clon);
+	      mpp_gather_field_double(naxl[na][nl], atmxlnd_clat[na][nl], g_clat);
+	      for(i=0; i<nxgrid; i++) {
+		ii = g_ja[i]*nxa[na]+g_ia[i];
+		a_area[ii] += g_area[i];
+		a_clon[ii] += g_clon[i];
+		a_clat[ii] += g_clat[i];
+		ii = g_jl[i]*nxl[nl]+g_il[i];
+		l_area[nl][ii] += g_area[i];
+		l_clon[nl][ii] += g_clon[i];
+		l_clat[nl][ii] += g_clat[i];
+	      }
+	      free(g_ia);
+	      free(g_ja);
+	      free(g_il);
+	      free(g_jl);
+	      free(g_area);
+	      free(g_clon);
+	      free(g_clat);
+	    }
+	  }
+
+	  for(no=0; no<ntile_ocn; no++) {
+	    int nxgrid;
+	    nxgrid = naxo[na][no];
+	    mpp_sum_int(1, &nxgrid);
+	    if(nxgrid > 0) {
+	      double *g_area, *g_clon, *g_clat;
+	      int    *g_ia,   *g_ja,   *g_io, *g_jo;
+	      int    ii;
+	      g_ia = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_ja = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_io = (int    *)malloc(nxgrid*sizeof(int   ));
+	      g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
+	      g_area = (double *)malloc(nxgrid*sizeof(double));
+	      g_clon = (double *)malloc(nxgrid*sizeof(double));
+	      g_clat = (double *)malloc(nxgrid*sizeof(double));
+	      mpp_gather_field_int   (naxo[na][no], atmxocn_ia[na][no], g_ia);
+	      mpp_gather_field_int   (naxo[na][no], atmxocn_ja[na][no], g_ja);
+	      mpp_gather_field_int   (naxo[na][no], atmxocn_io[na][no], g_io);
+	      mpp_gather_field_int   (naxo[na][no], atmxocn_jo[na][no], g_jo);
+	      mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], g_area);
+	      mpp_gather_field_double(naxo[na][no], atmxocn_clon[na][no], g_clon);
+	      mpp_gather_field_double(naxo[na][no], atmxocn_clat[na][no], g_clat);
+	      for(i=0; i<nxgrid; i++) {	      
+		ii = g_ja[i]*nxa[na]+g_ia[i];
+		a_area[ii] += g_area[i];
+		a_clon[ii] += g_clon[i];
+		a_clat[ii] += g_clat[i];
+		ii = g_jo[i]*nxo[no]+g_io[i];
+		o_area[no][ii] += g_area[i];
+		o_clon[no][ii] += g_clon[i];
+		o_clat[no][ii] += g_clat[i];
+	      }
+	      free(g_ia);
+	      free(g_ja);
+	      free(g_io);
+	      free(g_jo);
+	      free(g_area);
+	      free(g_clon);
+	      free(g_clat);
+	    }
+	  }
+
+	  for(la=0; la<nxa[na]*nya[na]; la++) {
+	    if(a_area[la] > 0) {
+	      a_clon[la] /= a_area[la];
+	      a_clat[la] /= a_area[la];
+	    }
+	  }
+	
+	  /* substract atmos centroid to get the centroid distance between atmos grid and exchange grid. */
+	  for(nl=0; nl<ntile_lnd; nl++) {
+	    for(i=0; i<naxl[na][nl]; i++) {
+	      la = atmxlnd_ja[na][nl][i]*nxa[na] + atmxlnd_ia[na][nl][i];
+	      atmxlnd_dia[na][nl][i] = atmxlnd_clon[na][nl][i]/atmxlnd_area[na][nl][i] - a_clon[la];
+	      atmxlnd_dja[na][nl][i] = atmxlnd_clat[na][nl][i]/atmxlnd_area[na][nl][i] - a_clat[la];
+	    }
+	  }
+	  for(no=0; no<ntile_ocn; no++) {
+	    for(i=0; i<naxo[na][no]; i++) {
+	      la = atmxocn_ja[na][no][i]*nxa[na] + atmxocn_ia[na][no][i];
+	      atmxocn_dia[na][no][i] = atmxocn_clon[na][no][i]/atmxocn_area[na][no][i] - a_clon[la];
+	      atmxocn_dja[na][no][i] = atmxocn_clat[na][no][i]/atmxocn_area[na][no][i] - a_clat[la];
+	    }
+	  }
+	
+	  free(a_area);
+	  free(a_clon);
+	  free(a_clat);
+	}
+
+      
+	/* centroid distance from exchange grid to land grid */
+	for(nl=0; nl<ntile_lnd; nl++) {
+	  for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
+	    if(l_area[nl][ll] > 0) {
+	      l_clon[nl][ll] /= l_area[nl][ll];
+	      l_clat[nl][ll] /= l_area[nl][ll];
+	    }
+	  }
+	  for(na=0; na<ntile_atm; na++) {
+	    for(i=0; i<naxl[na][nl]; i++) {
+	      ll = atmxlnd_jl[na][nl][i]*nxl[nl] + atmxlnd_il[na][nl][i];
+	      atmxlnd_dil[na][nl][i] = atmxlnd_clon[na][nl][i]/atmxlnd_area[na][nl][i] - l_clon[nl][ll];
+	      atmxlnd_djl[na][nl][i] = atmxlnd_clat[na][nl][i]/atmxlnd_area[na][nl][i] - l_clat[nl][ll];
+	    }
+	  }
+	  free(l_clon[nl]);
+	  free(l_clat[nl]);
+	}
+
+	/* centroid distance from exchange grid to ocean grid */
+	for(no=0; no<ntile_ocn; no++) {
+	  for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
+	    if(o_area[no][lo] > 0) {
+	      o_clon[no][lo] /= o_area[no][lo];
+	      o_clat[no][lo] /= o_area[no][lo];
+	    }
+	  }
+	  for(na=0; na<ntile_atm; na++) {
+	    for(i=0; i<naxo[na][no]; i++) {
+	      lo = atmxocn_jo[na][no][i]*nxo[no] + atmxocn_io[na][no][i];
+	      atmxocn_dio[na][no][i] = atmxocn_clon[na][no][i]/atmxocn_area[na][no][i] - o_clon[no][lo];
+	      atmxocn_djo[na][no][i] = atmxocn_clat[na][no][i]/atmxocn_area[na][no][i] - o_clat[no][lo];
+	    }
+	  }
+	  free(o_clon[no]);
+	  free(o_clat[no]);
+	}
+	free(o_clon);
+	free(o_clat);
+	free(l_clon);
+	free(l_clat);  
+      }
+
+      /* calculate ocean_frac and compare ocean_frac with omask */
+      /* also write out ocn_frac */
+      {
+	int    io, jo;
+	double ocn_frac;
+	int    id_mask, fid, dims[2];
+	char ocn_mask_file[STRING];
+	double *mask;
+	int ny;
+
+
+	for(no=0; no<ntile_ocn; no++) {
+	  ny = nyo[no]-ocn_south_ext;
+	  mask = (double *)malloc(nxo[no]*ny*sizeof(double));
+	  for(jo=0; jo<ny; jo++) for(io=0; io<nxo[no]; io++) {
+	    i = (jo+ocn_south_ext)*nxo[no]+io;
+	    ocn_frac = o_area[no][i]/area_ocn[no][i];
+	    if( fabs(omask[no][i] - ocn_frac) > TOLORENCE ) {
+	      printf("at ocean point (%d,%d), omask = %f, ocn_frac = %f, diff = %f\n",
+		     io, jo, omask[no][i], ocn_frac, omask[no][i] - ocn_frac);
+	      mpp_error("make_coupler_mosaic: omask is not equal ocn_frac");
+	    }
+	    mask[jo*nxo[no]+io] = ocn_frac;
+	  }
+	  if(ntile_ocn > 1)
+	    sprintf(ocn_mask_file, "ocean_mask_tile%d.nc", no+1);
+	  else
+	    strcpy(ocn_mask_file, "ocean_mask.nc");
+	  fid = mpp_open(ocn_mask_file, MPP_WRITE);
+	  mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+	  mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+	  mpp_def_global_att(fid, HISTORY_NAME, history);
+          	  
+
+	  dims[1] = mpp_def_dim(fid, NX_NAME, nxo[no]); 
+	  dims[0] = mpp_def_dim(fid, NY_NAME, ny);
+	  id_mask = mpp_def_var(fid, "mask", MPP_DOUBLE, 2, dims,  2, "standard_name",
+				"ocean fraction at T-cell centers", "units", "none");
+	  mpp_end_def(fid);
+	  mpp_put_var_value(fid, id_mask, mask);
+	  mpp_close(fid);
+	  free(mask);
+	}
+      }
+
+      /* calculate land_frac and  write out land_frac */
+      {
+	int    il, jl;
+	int    id_mask, fid, dims[2];
+	char lnd_mask_file[STRING];
+	double *mask;
+	
+	for(nl=0; nl<ntile_lnd; nl++) {
+	  mask = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
+	  for(jl=0; jl<nyl[nl]; jl++) for(il=0; il<nxl[nl]; il++) {
+	    i = jl*nxl[nl]+il;
+	    mask[i] = l_area[nl][i]/area_lnd[nl][i];
+	  }
+	  if(ntile_lnd > 1)
+	    sprintf(lnd_mask_file, "land_mask_tile%d.nc", nl+1);
+	  else
+	    strcpy(lnd_mask_file, "land_mask.nc");
+	  fid = mpp_open(lnd_mask_file, MPP_WRITE);
+	  mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+	  mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+	  mpp_def_global_att(fid, HISTORY_NAME, history);
+	  dims[1] = mpp_def_dim(fid, NX_NAME, nxl[nl]); 
+	  dims[0] = mpp_def_dim(fid, NY_NAME, nyl[nl]);
+	  id_mask = mpp_def_var(fid, "mask", MPP_DOUBLE, 2, dims,  2, "standard_name",
+				"land fraction at T-cell centers", "units", "none");
+	  mpp_end_def(fid);
+	  mpp_put_var_value(fid, id_mask, mask);
+	  free(mask);
+	  mpp_close(fid);
+	}
+      }        
+      
+      for(nl=0; nl<ntile_lnd; nl++) free(l_area[nl]);
+      for(no=0; no<ntile_ocn; no++) free(o_area[no]);      
+      free(o_area);
+      free(l_area);
+    }
+    
+    for(na=0; na<ntile_atm; na++) {
+    /* write out atmXlnd data*/
+      for(nl = 0; nl < ntile_lnd; nl++) {
+	int nxgrid;
+	nxgrid = naxl[na][nl];
+	mpp_sum_int(1, &nxgrid);
+	if(nxgrid>0) {
+	  size_t start[4], nwrite[4];
+	  int *gdata_int;
+	  double *gdata_dbl;
+	  
+	  int fid, dim_string, dim_ncells, dim_two, dims[4];
+	  int id_xgrid_area, id_contact, n;
+	  int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
+	  char contact[STRING];
+
+	  for(i=0; i<4; i++) {
+	    start[i] = 0; nwrite[i] = 1;
+	  }	  	  
+	  if(same_mosaic)
+	    sprintf(axl_file[nfile_axl], "atm_%s_%sXlnd_%s_%s.nc", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
+	  else
+	    sprintf(axl_file[nfile_axl], "%s_%sX%s_%s.nc", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
+	  sprintf(contact, "%s:%s::%s:%s", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
+	  fid = mpp_open(axl_file[nfile_axl], MPP_WRITE);
+	  mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+	  mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+	  mpp_def_global_att(fid, HISTORY_NAME, history);
+	  dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+	  dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
+	  dim_two    = mpp_def_dim(fid, "two", 2);
+	  if(interp_order == 2) {
+	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
+				     "contact_type", "exchange", "parent1_cell",
+				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
+				     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
+	  }
+	  else {
+	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
+				     "contact_type", "exchange", "parent1_cell",
+				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
+	  }
+	    
+	  dims[0] = dim_ncells; dims[1] = dim_two;
+	  id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
+	  id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
+	  id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
+				      "exchange_grid_area", "units", "m2");
+	  if(interp_order == 2) {
+	    id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
+	    id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
+	  }
+	  mpp_end_def(fid);
+
+	  /* the index will start from 1, instead of 0 ( fortran index) */
+	  for(i = 0;i < naxl[na][nl]; i++) {
+	    ++(atmxlnd_ia[na][nl][i]);
+	    ++(atmxlnd_ja[na][nl][i]);
+	    ++(atmxlnd_il[na][nl][i]);
+	    ++(atmxlnd_jl[na][nl][i]);
+	  }
+	  nwrite[0] = strlen(contact);
+	  mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
+     	  nwrite[0] = nxgrid;
+
+	  gdata_int = (int *)malloc(nxgrid*sizeof(int));
+	  gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
+
+	  mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], gdata_dbl);
+	  if(check) {
+	    for(n=0; n<nxgrid; n++) axl_area_sum += gdata_dbl[n];
+	  }
+	  mpp_put_var_value(fid, id_xgrid_area, gdata_dbl);
+	  mpp_gather_field_int(naxl[na][nl], atmxlnd_ia[na][nl], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
+	  mpp_gather_field_int(naxl[na][nl], atmxlnd_il[na][nl], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
+	  start[1] = 1;
+	  mpp_gather_field_int(naxl[na][nl], atmxlnd_ja[na][nl], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
+	  mpp_gather_field_int(naxl[na][nl], atmxlnd_jl[na][nl], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
+	  if(interp_order == 2) {
+	    start[1] = 0;
+  	    mpp_gather_field_double(naxl[na][nl], atmxlnd_dia[na][nl], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
+	    mpp_gather_field_double(naxl[na][nl], atmxlnd_dil[na][nl], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
+	    start[1] = 1;
+  	    mpp_gather_field_double(naxl[na][nl], atmxlnd_dja[na][nl], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
+	    mpp_gather_field_double(naxl[na][nl], atmxlnd_djl[na][nl], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
+	  }
+	  mpp_close(fid);
+	  free(gdata_int);
+	  free(gdata_dbl);
+	  ++nfile_axl;
+	}
+      } /* end of nl loop */
+
+      /* write out atmXocn data */
+      for(no = 0; no < ntile_ocn; no++) {
+	int nxgrid;
+	
+	nxgrid = naxo[na][no];
+	mpp_sum_int(1, &nxgrid);
+	if(nxgrid>0) {
+	  size_t start[4], nwrite[4];
+	  int *gdata_int;
+	  double *gdata_dbl;
+	  int fid, dim_string, dim_ncells, dim_two, dims[4];
+	  int id_xgrid_area, id_contact, n;
+	  int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;	  
+	  char contact[STRING];
+
+	  for(i=0; i<4; i++) {
+	    start[i] = 0; nwrite[i] = 1;
+	  }
+	  
+	  if(same_mosaic)
+	    sprintf(axo_file[nfile_axo], "atm_%s_%sXocn_%s_%s.nc", amosaic_name, atile_name[na], imosaic_name, otile_name[no]);
+	  else
+	    sprintf(axo_file[nfile_axo], "%s_%sX%s_%s.nc", amosaic_name, atile_name[na], imosaic_name, otile_name[no]);
+	  
+	  sprintf(contact, "%s:%s::%s:%s", amosaic_name, atile_name[na], imosaic_name, otile_name[no]);
+	  fid = mpp_open(axo_file[nfile_axo], MPP_WRITE);
+	  mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+          mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+	  mpp_def_global_att(fid, HISTORY_NAME, history);
+	  dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+	  dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
+	  dim_two    = mpp_def_dim(fid, "two", 2);
+	  if(interp_order == 2) {
+	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
+				   "contact_type", "exchange", "parent1_cell",
+				   "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
+				   "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
+	  }
+	  else {
+	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
+				   "contact_type", "exchange", "parent1_cell",
+				   "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area" );
+	  }
+	  dims[0] = dim_ncells; dims[1] = dim_two;
+	  id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
+	  id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
+	  id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
+				      "exchange_grid_area", "units", "m2");
+	  if(interp_order == 2) {
+	    id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name",
+					"distance_from_parent1_cell_centroid");
+	    id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name",
+					"distance_from_parent2_cell_centroid");
+	  }
+	  mpp_end_def(fid);
+
+	  /* the index will start from 1, instead of 0 ( fortran index) */
+	  for(i = 0;i < naxo[na][no]; i++) {
+	    ++(atmxocn_ia[na][no][i]);
+	    ++(atmxocn_ja[na][no][i]);
+	    ++(atmxocn_io[na][no][i]);
+	    atmxocn_jo[na][no][i] += 1-ocn_south_ext; /* possible one artificial j-level is added at south end */
+	  }
+
+          nwrite[0] = strlen(contact);
+	  mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
+	
+	  nwrite[0] = nxgrid;
+
+	  gdata_int = (int *)malloc(nxgrid*sizeof(int));
+	  gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
+
+	  mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], gdata_dbl);
+	  if(check) {
+	    for(n=0; n<nxgrid; n++) axo_area_sum += gdata_dbl[n];
+	  }
+	  mpp_put_var_value_block(fid, id_xgrid_area, start, nwrite, gdata_dbl);
+	  mpp_gather_field_int(naxo[na][no], atmxocn_ia[na][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
+	  mpp_gather_field_int(naxo[na][no], atmxocn_io[na][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
+	  start[1] = 1;
+	  mpp_gather_field_int(naxo[na][no], atmxocn_ja[na][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
+	  mpp_gather_field_int(naxo[na][no], atmxocn_jo[na][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
+	  if(interp_order == 2) {
+	    start[1] = 0;
+  	    mpp_gather_field_double(naxo[na][no], atmxocn_dia[na][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
+	    mpp_gather_field_double(naxo[na][no], atmxocn_dio[na][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
+	    start[1] = 1;
+  	    mpp_gather_field_double(naxo[na][no], atmxocn_dja[na][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
+	    mpp_gather_field_double(naxo[na][no], atmxocn_djo[na][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
+	  }
+	  mpp_close(fid);
+     	  free(gdata_int);
+	  free(gdata_dbl);
+	  ++nfile_axo;
+	}
+      } /* end of no loop */
+      
+    } /* end of na loop */
+
+    { /* write out atmos_mosaicXlnd_mosaic */
+      int fid, dim_nmosaic, dim_ncontact, id_mosaic, id_contact, dim_string, dims[4];
+      size_t start[4], nwrite[4];
+      if(same_mosaic)
+	sprintf(amosaicxlmosaic_file, "atm_%sXlnd_%s.nc", amosaic_name, lmosaic_name);
+      else
+        sprintf(amosaicxlmosaic_file, "%sX%s.nc", amosaic_name, lmosaic_name);
+      fid = mpp_open(amosaicxlmosaic_file, MPP_WRITE);
+      dim_nmosaic = mpp_def_dim(fid, NMOSAIC_NAME, 2);
+      dim_ncontact = mpp_def_dim(fid, NCONTACT_NAME, nfile_axl);
+      dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+      dims[0] = dim_nmosaic;
+      dims[1] = dim_string;
+      id_mosaic = mpp_def_var(fid, MOSAIC_FILES_NAME, MPP_CHAR, 2, dims, 0);
+      dims[0] = dim_ncontact;
+      id_contact = mpp_def_var(fid, CONTACT_FILES_NAME, MPP_CHAR, 2, dims, 0);
+      mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+      mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+      mpp_def_global_att(fid, HISTORY_NAME, history);
+      mpp_end_def(fid);
+      for(i=0; i<4; i++) {
+	start[i] = 0; nwrite[i] = 1;
+      }
+      start[0] = 0; nwrite[1] = strlen(amosaic_file);
+      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, amosaic_file);
+      start[0] = 1; nwrite[1] = strlen(lmosaic_file);
+      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, lmosaic_file);
+      for(n=0; n<nfile_axl; n++) {
+	start[0]=n;
+	nwrite[1] = strlen(axl_file[n]);
+	mpp_put_var_value_block(fid, id_contact, start, nwrite, axl_file[n]);
+      }
+      mpp_close(fid);
+    }
+
+    { /* write out atmos_mosaicXocean_mosaic */
+      int fid, dim_nmosaic, dim_ncontact, id_mosaic, id_contact, dim_string, dims[4];
+      size_t start[4], nwrite[4];
+
+      if(same_mosaic)
+	sprintf(amosaicximosaic_file, "atm_%sXocn_%s.nc", amosaic_name, imosaic_name);
+      else	  
+        sprintf(amosaicximosaic_file, "%sX%s.nc", amosaic_name, imosaic_name);
+      fid = mpp_open(amosaicximosaic_file, MPP_WRITE);
+      dim_nmosaic = mpp_def_dim(fid, NMOSAIC_NAME, 2);
+      dim_ncontact = mpp_def_dim(fid, NCONTACT_NAME, nfile_axo);
+      dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+      dims[0] = dim_nmosaic;
+      dims[1] = dim_string;
+      id_mosaic = mpp_def_var(fid, MOSAIC_FILES_NAME, MPP_CHAR, 2, dims, 0);
+      dims[0] = dim_ncontact;
+      id_contact = mpp_def_var(fid, CONTACT_FILES_NAME, MPP_CHAR, 2, dims, 0);
+      mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+      mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+      mpp_def_global_att(fid, HISTORY_NAME, history);
+      mpp_end_def(fid);
+      for(i=0; i<4; i++) {
+	start[i] = 0; nwrite[i] = 1;
+      }
+      start[0] = 0; nwrite[1] = strlen(amosaic_file);
+      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, amosaic_file);
+      start[0] = 1; nwrite[1] = strlen(imosaic_file);
+      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, imosaic_file);
+      for(n=0; n<nfile_axo; n++) {
+	start[0]=n;
+	nwrite[1] = strlen(axo_file[n]);
+	mpp_put_var_value_block(fid, id_contact, start, nwrite, axo_file[n]);
+      }
+      mpp_close(fid);
+    }
+
+    
+    /*release the memory */
+    for(na=0; na<ntile_atm; na++) {
+      for(nl=0; nl<ntile_lnd; nl++) {
+	free(atmxlnd_area[na][nl]);
+	free(atmxlnd_ia  [na][nl]);
+	free(atmxlnd_ja  [na][nl]);
+	free(atmxlnd_il  [na][nl]);
+	free(atmxlnd_jl  [na][nl]);
+	if(interp_order == 2) {
+	  free(atmxlnd_clon[na][nl]);
+	  free(atmxlnd_clat[na][nl]);
+	  free(atmxlnd_dia [na][nl]);
+	  free(atmxlnd_dja [na][nl]);
+	  free(atmxlnd_dil [na][nl]);
+	  free(atmxlnd_djl [na][nl]);
+	}
+      }
+      free(atmxlnd_area[na]);
+      free(atmxlnd_ia  [na]);
+      free(atmxlnd_ja  [na]);
+      free(atmxlnd_il  [na]);
+      free(atmxlnd_jl  [na]);
+      if(interp_order == 2) {
+	free(atmxlnd_clon[na]);
+	free(atmxlnd_clat[na]);
+	free(atmxlnd_dia [na]);
+	free(atmxlnd_dja [na]);
+	free(atmxlnd_dil [na]);
+	free(atmxlnd_djl [na]);
+      }
+      for(no=0; no<ntile_ocn; no++) {
+	free(atmxocn_area[na][no]);
+	free(atmxocn_ia  [na][no]);
+	free(atmxocn_ja  [na][no]);
+	free(atmxocn_io  [na][no]);
+	free(atmxocn_jo  [na][no]);
+	if(interp_order == 2) {
+	  free(atmxocn_clon[na][no]);
+	  free(atmxocn_clat[na][no]);
+	  free(atmxocn_dia [na][no]);
+	  free(atmxocn_dja [na][no]);
+	  free(atmxocn_dio [na][no]);
+	  free(atmxocn_djo [na][no]);
+	}
+      }
+      free(atmxocn_area[na]);
+      free(atmxocn_ia  [na]);
+      free(atmxocn_ja  [na]);
+      free(atmxocn_io  [na]);
+      free(atmxocn_jo  [na]);
+      if(interp_order == 2) {
+	free(atmxocn_clon[na]);
+	free(atmxocn_clat[na]);
+	free(atmxocn_dia [na]);
+	free(atmxocn_dja [na]);
+	free(atmxocn_dio [na]);
+	free(atmxocn_djo [na]);
+      }
+      free(naxl[na]);
+      free(naxo[na]);
+    }    
+    free(atmxlnd_area);
+    free(atmxlnd_ia  );
+    free(atmxlnd_ja  );
+    free(atmxlnd_il  );
+    free(atmxlnd_jl  );
+    free(atmxocn_area);
+    free(atmxocn_ia  );
+    free(atmxocn_ja  );
+    free(atmxocn_io  );
+    free(atmxocn_jo  );   
+    if(interp_order == 2) {
+      free(atmxlnd_clon);
+      free(atmxlnd_clat);
+      free(atmxlnd_dja );
+      free(atmxlnd_dia );
+      free(atmxlnd_dil );
+      free(atmxlnd_djl );
+      free(atmxocn_clon);
+      free(atmxocn_clat);
+      free(atmxocn_dia );
+      free(atmxocn_dja );
+      free(atmxocn_dio );
+      free(atmxocn_djo );
+    }
+    free(naxl);
+    free(naxo);
+  }
+  if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Complete the process to create exchange grids "
+				       "for fluxes between atmosphere and surface (sea ice and land)\n" );
+  
+  /***************************************************************************************
+     Then generate the exchange grid between land mosaic and ocean mosaic
+     if land mosaic is different from atmos mosaic
+  ***************************************************************************************/
+  nfile_lxo = 0;
+  if( !lnd_same_as_atm ) {
+    int     no, nl, ll, lo;
+    size_t  **nlxo;
+    int     ***lndxocn_il, ***lndxocn_jl, ***lndxocn_io, ***lndxocn_jo;
+    double  ***lndxocn_area, ***lndxocn_dil, ***lndxocn_djl, ***lndxocn_dio, ***lndxocn_djo;
+    double  ***lndxocn_clon, ***lndxocn_clat;
+    double  min_area;
+
+    nlxo         = (size_t ** )malloc(ntile_lnd*sizeof(size_t * ));
+    lndxocn_area = (double ***)malloc(ntile_lnd*sizeof(double **));
+    lndxocn_il   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
+    lndxocn_jl   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
+    lndxocn_io   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
+    lndxocn_jo   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
+    if(interp_order == 2) {
+      lndxocn_dil  = (double ***)malloc(ntile_lnd*sizeof(double **));
+      lndxocn_djl  = (double ***)malloc(ntile_lnd*sizeof(double **));
+      lndxocn_dio  = (double ***)malloc(ntile_lnd*sizeof(double **));
+      lndxocn_djo  = (double ***)malloc(ntile_lnd*sizeof(double **));
+      lndxocn_clon = (double ***)malloc(ntile_lnd*sizeof(double **));
+      lndxocn_clat = (double ***)malloc(ntile_lnd*sizeof(double **));
+    }
+    for(nl=0; nl<ntile_lnd; nl++) {
+      nlxo        [nl] = (size_t * )malloc(ntile_ocn*sizeof(size_t  ));
+      lndxocn_area[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
+      lndxocn_il  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
+      lndxocn_jl  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
+      lndxocn_io  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
+      lndxocn_jo  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
+      if(interp_order == 2) {
+	lndxocn_dil [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
+	lndxocn_djl [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
+	lndxocn_dio [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
+	lndxocn_djo [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
+	lndxocn_clon[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
+	lndxocn_clat[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
+      }
+      for(no=0; no<ntile_ocn; no++) {
+	lndxocn_area[nl][no] = (double *)malloc(MAXXGRID*sizeof(double));
+	lndxocn_il  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	lndxocn_jl  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	lndxocn_io  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
+	lndxocn_jo  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));          
+	if(interp_order == 2 ) {  
+	  lndxocn_dil[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
+	  lndxocn_djl[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
+	  lndxocn_dio[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
+	  lndxocn_djo[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
+	  lndxocn_clon[nl][no] = (double *)malloc(MAXXGRID*sizeof(double *));
+	  lndxocn_clat[nl][no] = (double *)malloc(MAXXGRID*sizeof(double *));
+	}
+      }
+    }
+ 
+    for(nl=0; nl<ntile_lnd; nl++) {
+      int      il, jl, io, jo, is, ie, js, je, layout[2];
+      int      n0, n1, n2, n3, nl_in, no_in, n_out, nxgrid;
+      double   xarea, xctrlon, xctrlat;
+      double   xl_min, yl_min, xo_min, yo_min, xl_avg;
+      double   xl_max, yl_max, xo_max, yo_max;
+      double   xl[MV], yl[MV], xo[MV], yo[MV], x_out[MV], y_out[MV];
+      domain2D Dom;
+
+      for(no=0; no<ntile_ocn; no++) nlxo[nl][no] = 0;
+      
+      layout[0] = mpp_npes();
+      layout[1] = 1;
+        
+      mpp_define_domain2d(nxl[nl]*nyl[nl], 1, layout, 0, 0, &Dom);
+      mpp_get_compute_domain2d(Dom, &is, &ie, &js, &je );
+      for(ll=is;ll<=ie;ll++) {
+	il = ll%nxl[nl];
+	jl = ll/nxl[nl];
+	n0 = jl    *(nxl[nl]+1) + il;
+	n1 = jl    *(nxl[nl]+1) + il+1;
+	n2 = (jl+1)*(nxl[nl]+1) + il+1;
+	n3 = (jl+1)*(nxl[nl]+1) + il;
+	xl[0] = xlnd[nl][n0]; yl[0] = ylnd[nl][n0];
+	xl[1] = xlnd[nl][n1]; yl[1] = ylnd[nl][n1];
+	xl[2] = xlnd[nl][n2]; yl[2] = ylnd[nl][n2];
+	xl[3] = xlnd[nl][n3]; yl[3] = ylnd[nl][n3];
+	yl_min  = minval_double(4, yl);
+	yl_max  = maxval_double(4, yl);
+	nl_in   = fix_lon(xl, yl, 4, M_PI);
+	xl_min  = minval_double(nl_in, xl);
+	xl_max  = maxval_double(nl_in, xl);
+	xl_avg  = avgval_double(nl_in, xl);      
+	for(no=0; no<ntile_ocn; no++) {
+	  for(jo = 0; jo < nyo[no]; jo++) for(io = 0; io < nxo[no]; io++) if(omask[no][jo*nxo[no]+io] > MIN_AREA_FRAC) {
+	    double ocn_frac;
+	    n0 = jo    *(nxo[no]+1) + io;
+	    n1 = jo    *(nxo[no]+1) + io+1;
+	    n2 = (jo+1)*(nxo[no]+1) + io+1;
+	    n3 = (jo+1)*(nxo[no]+1) + io;
+	    xo[0] = xocn[no][n0]; yo[0] = yocn[no][n0];
+	    xo[1] = xocn[no][n1]; yo[1] = yocn[no][n1];
+	    xo[2] = xocn[no][n2]; yo[2] = yocn[no][n2];
+	    xo[3] = xocn[no][n3]; yo[3] = yocn[no][n3];
+	    yo_min = minval_double(4, yo);
+	    yo_max = maxval_double(4, yo);
+            if(yo_min >= yl_max || yo_max <= yl_min ) continue;	    
+	    no_in  = fix_lon(xo, yo, 4, xl_avg);
+	    xo_min = minval_double(no_in, xo);
+	    xo_max = maxval_double(no_in, xo);
+	    /* xo should in the same range as xa after lon_fix, so no need to
+	       consider cyclic condition
+	    */
+	    if(xl_min >= xo_max || xl_max <= xo_min ) continue;
+	    ocn_frac = omask[no][jo*nxo[no]+io];
+	    if (  (n_out = clip_2dx2d( xl, yl, nl_in, xo, yo, no_in, x_out, y_out )) > 0 ){
+	      xarea = poly_area(x_out, y_out, n_out )*ocn_frac;
+	      min_area = min(area_ocn[no][jo*nxo[no]+io], area_lnd[nl][ll] );
+	      if(xarea/min_area > AREA_RATIO_THRESH ) {
+		lndxocn_area[nl][no][nlxo[nl][no]] = xarea;
+		lndxocn_io[nl][no][nlxo[nl][no]]   = io;
+		lndxocn_jo[nl][no][nlxo[nl][no]]   = jo;
+		lndxocn_il[nl][no][nlxo[nl][no]]   = il;
+		lndxocn_jl[nl][no][nlxo[nl][no]]   = jl;
+		if(interp_order == 2) {
+		  lndxocn_clon[nl][no][nlxo[nl][no]] = poly_ctrlon ( x_out, y_out, n_out, xl_avg)*ocn_frac;
+		  lndxocn_clat[nl][no][nlxo[nl][no]] = poly_ctrlat ( x_out, y_out, n_out )*ocn_frac;
+		}
+		++(nlxo[nl][no]);
+		if(nlxo[nl][no] > MAXXGRID) mpp_error("nlxo is greater than MAXXGRID, increase MAXXGRID");
+	      }
+	    }
+	  } /* end of io, jo loop */
+	} 
+      } /* end of ll( or il, jl) loop */
+      mpp_delete_domain2d(&Dom);
+    }/* for(nl=0; nl<ntile_lnd; nl++) */
+
+    /* calculate the centroid of model grid. */
+    if(interp_order == 2) {
+      double *l_area, *l_clon, *l_clat;
+      double **o_area, **o_clon, **o_clat;
+ 
+      o_area = (double **)malloc(ntile_ocn*sizeof(double *));
+      o_clon = (double **)malloc(ntile_ocn*sizeof(double *));
+      o_clat = (double **)malloc(ntile_ocn*sizeof(double *));
+      for(no =0; no<ntile_ocn; no++) {
+	o_area[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
+	o_clon[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
+	o_clat[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
+	for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
+	  o_area[no][lo] = 0;
+	  o_clon[no][lo] = 0;
+	  o_clat[no][lo] = 0;
+	}
+      }
+
+      for(nl=0; nl<ntile_lnd; nl++) {
+	l_area = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
+	l_clon = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
+	l_clat = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
+	for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
+	  l_area[ll] = 0;
+	  l_clon[ll] = 0;
+	  l_clat[ll] = 0;
+	}
+
+	for(no=0; no<ntile_ocn; no++) {
+	  int nxgrid;
+	  nxgrid = nlxo[nl][no];
+	  mpp_sum_int(1, &nxgrid);
+	  if(nxgrid > 0) {
+	    double *g_area, *g_clon, *g_clat;
+	    int    *g_il,   *g_jl,   *g_io, *g_jo;
+	    int    ii;
+	    g_il = (int    *)malloc(nxgrid*sizeof(int   ));
+	    g_jl = (int    *)malloc(nxgrid*sizeof(int   ));
+	    g_io = (int    *)malloc(nxgrid*sizeof(int   ));
+	    g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
+	    g_area = (double *)malloc(nxgrid*sizeof(double));
+	    g_clon = (double *)malloc(nxgrid*sizeof(double));
+	    g_clat = (double *)malloc(nxgrid*sizeof(double));
+	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_il[nl][no], g_il);
+	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_jl[nl][no], g_jl);
+	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_io[nl][no], g_io);
+	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_jo[nl][no], g_jo);
+	    mpp_gather_field_double(nlxo[nl][no], lndxocn_area[nl][no], g_area);
+	    mpp_gather_field_double(nlxo[nl][no], lndxocn_clon[nl][no], g_clon);
+	    mpp_gather_field_double(nlxo[nl][no], lndxocn_clat[nl][no], g_clat);
+	    for(i=0; i<nxgrid; i++) {	      
+	      ii = g_jl[i]*nxl[nl]+g_il[i];
+	      l_area[ii] += g_area[i];
+	      l_clon[ii] += g_clon[i];
+	      l_clat[ii] += g_clat[i];
+	      ii = g_jo[i]*nxo[no]+g_io[i];
+	      o_area[no][ii] += g_area[i];
+	      o_clon[no][ii] += g_clon[i];
+	      o_clat[no][ii] += g_clat[i];
+	    }
+	    free(g_il);
+	    free(g_jl);
+	    free(g_io);
+	    free(g_jo);
+	    free(g_area);
+	    free(g_clon);
+	    free(g_clat);
+	  }
+	}
+	for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
+	  if(l_area[ll] > 0) {
+	    l_clon[ll] /= l_area[ll];
+	    l_clat[ll] /= l_area[ll];
+	  }
+	}
+	/* substract land centroid to get the centroid distance between land grid and exchange grid. */
+	for(no=0; no<ntile_ocn; no++) {
+	  for(i=0; i<nlxo[nl][no]; i++) {
+	    ll = lndxocn_jl[nl][no][i]*nxl[nl] + lndxocn_il[nl][no][i];
+	    lndxocn_dil[nl][no][i] = lndxocn_clon[nl][no][i]/lndxocn_area[nl][no][i] - l_clon[ll];
+	    lndxocn_djl[nl][no][i] = lndxocn_clat[nl][no][i]/lndxocn_area[nl][no][i] - l_clat[ll];
+	  }
+	}
+	
+	free(l_area);
+	free(l_clon);
+	free(l_clat);	
+      }
+
+      /* centroid distance from exchange grid to ocean grid */
+      for(no=0; no<ntile_ocn; no++) {
+	for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
+	  if(o_area[no][lo] > 0) {
+	    o_clon[no][lo] /= o_area[no][lo];
+	    o_clat[no][lo] /= o_area[no][lo];
+	  }
+	}
+	for(nl=0; nl<ntile_lnd; nl++) {
+	  for(i=0; i<nlxo[nl][no]; i++) {
+	    lo = lndxocn_jo[nl][no][i]*nxo[no] + lndxocn_io[nl][no][i];
+	    lndxocn_dio[nl][no][i] = lndxocn_clon[nl][no][i]/lndxocn_area[nl][no][i] - o_clon[no][lo];
+	    lndxocn_djo[nl][no][i] = lndxocn_clat[nl][no][i]/lndxocn_area[nl][no][i] - o_clat[no][lo];
+	  }
+	}
+	free(o_area[no]);
+	free(o_clon[no]);
+	free(o_clat[no]);
+      }
+
+      free(o_area);
+      free(o_clon);
+      free(o_clat);
+    }
+
+    /* write out lndXocn data */
+    for(nl = 0; nl < ntile_lnd; nl++) {
+       for(no = 0; no < ntile_ocn; no++) {
+	 int nxgrid;
+	 
+	/* get total number of exchange grid on all the pes */
+	 nxgrid = nlxo[nl][no];
+	mpp_sum_int(1, &nxgrid);
+	
+	if(nxgrid >0) {
+	  size_t start[4], nwrite[4];
+	  int *gdata_int;
+	  double *gdata_dbl;
+	  
+	  char contact[STRING];
+	  int fid, dim_string, dim_ncells, dim_two, dims[4];
+	  int id_contact, id_xgrid_area, n;
+	  int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
+
+	  for(i=0; i<4; i++) {
+	    start[i] = 0; nwrite[i] = 1;
+	  }	  	  
+	  
+	  if(same_mosaic)
+	    sprintf(lxo_file[nfile_lxo], "lnd_%s_%sXocn_%s_%s.nc", lmosaic_name, ltile_name[nl], imosaic_name, otile_name[no]);
+	  else
+	    sprintf(lxo_file[nfile_lxo], "%s_%sX%s_%s.nc", lmosaic_name, ltile_name[nl], imosaic_name, otile_name[no]);
+	  sprintf(contact, "%s:%s::%s:%s", lmosaic_name, ltile_name[nl], imosaic_name, otile_name[no]);
+
+	  fid = mpp_open(lxo_file[nfile_lxo], MPP_WRITE);
+	  mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+          mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+	  mpp_def_global_att(fid, HISTORY_NAME, history);
+	  dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+	  dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
+	  dim_two    = mpp_def_dim(fid, "two", 2);
+	  if(interp_order == 2) {
+	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
+				     "contact_type", "exchange", "parent1_cell",
+				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
+				     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
+	  }
+	  else {
+	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
+				     "contact_type", "exchange", "parent1_cell",
+				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area" );
+	  }
+	  dims[0] = dim_ncells; dims[1] = dim_two;
+	  id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent1_cell_indices");
+	  id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent2_cell_indices");
+	  id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
+				      "exchange_grid_area", "units", "m2");
+
+	  if(interp_order == 2) {
+	    id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
+	    id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
+	  }
+	  mpp_end_def(fid);
+
+	  /* the index will start from 1, instead of 0 ( fortran index) */
+	  for(i = 0;i < nlxo[nl][no]; i++) {
+	    ++(lndxocn_il[nl][no][i]);
+	    ++(lndxocn_jl[nl][no][i]);
+	    ++(lndxocn_io[nl][no][i]);
+	    lndxocn_jo[nl][no][i] += 1 - ocn_south_ext; /* one artificial j-level may be added in the south end */
+	  }
+
+	  nwrite[0] = strlen(contact);
+	  mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
+	  nwrite[0] = nxgrid;
+
+	  gdata_int = (int *)malloc(nxgrid*sizeof(int));
+	  gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
+
+	  mpp_gather_field_double(nlxo[nl][no], lndxocn_area[nl][no], gdata_dbl);
+	  mpp_put_var_value(fid, id_xgrid_area, gdata_dbl);
+	  mpp_gather_field_int(nlxo[nl][no], lndxocn_il[nl][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
+	  mpp_gather_field_int(nlxo[nl][no], lndxocn_io[nl][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
+	  start[1] = 1;
+	  mpp_gather_field_int(nlxo[nl][no], lndxocn_jl[nl][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
+	  mpp_gather_field_int(nlxo[nl][no], lndxocn_jo[nl][no], gdata_int);
+	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
+	  if(interp_order == 2) {
+	    start[1] = 0;
+  	    mpp_gather_field_double(nlxo[nl][no], lndxocn_dil[nl][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
+	    mpp_gather_field_double(nlxo[nl][no], lndxocn_dio[nl][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
+	    start[1] = 1;
+  	    mpp_gather_field_double(nlxo[nl][no], lndxocn_djl[nl][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
+	    mpp_gather_field_double(nlxo[nl][no], lndxocn_djo[nl][no], gdata_dbl);
+	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
+	  }
+	  mpp_close(fid);
+	  free(gdata_int);
+	  free(gdata_dbl);
+	  ++nfile_lxo;
+	}
+       } /* for(no=0; no<ntile_ocn; no++) */
+    } /* for(nl=0; nl<ntile_lnd; nl++) */
+
+    { /* write out land_mosaicXocean_mosaic */
+      int fid, dim_nmosaic, dim_ncontact, id_mosaic, id_contact, dim_string, dims[4], n;
+	size_t start[4], nwrite[4];
+	  
+
+	sprintf(lmosaicximosaic_file, "%sX%s.nc", lmosaic_name, imosaic_name);
+	fid = mpp_open(lmosaicximosaic_file, MPP_WRITE);
+        dim_nmosaic = mpp_def_dim(fid, NMOSAIC_NAME, 2);
+	dim_ncontact = mpp_def_dim(fid, NCONTACT_NAME, nfile_lxo);
+	dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+	dims[0] = dim_nmosaic;
+	dims[1] = dim_string;
+	id_mosaic = mpp_def_var(fid, MOSAIC_FILES_NAME, MPP_CHAR, 2, dims, 0);
+	dims[0] = dim_ncontact;
+	id_contact = mpp_def_var(fid, CONTACT_FILES_NAME, MPP_CHAR, 2, dims, 0);
+	mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+	mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+	mpp_def_global_att(fid, HISTORY_NAME, history);
+	mpp_end_def(fid);
+	for(i=0; i<4; i++) {
+	  start[i] = 0; nwrite[i] = 1;
+	}
+	start[0] = 0; nwrite[1] = strlen(lmosaic_file);
+	mpp_put_var_value_block(fid, id_mosaic, start, nwrite, lmosaic_file);
+	start[0] = 1; nwrite[1] = strlen(imosaic_file);
+	mpp_put_var_value_block(fid, id_mosaic, start, nwrite, imosaic_file);
+	for(n=0; n<nfile_lxo; n++) {
+	  start[0]=n;
+	  nwrite[1] = strlen(lxo_file[n]);
+	  mpp_put_var_value_block(fid, id_contact, start, nwrite, lxo_file[n]);
+	}
+	mpp_close(fid);
+      }
+    
+    /* release the memory */
+    for(nl=0; nl<ntile_lnd; nl++) {
+      for(no=0; no<ntile_ocn; no++) {
+	free(lndxocn_area[nl][no]);
+	free(lndxocn_il  [nl][no]);
+	free(lndxocn_jl  [nl][no]);
+	free(lndxocn_io  [nl][no]);
+	free(lndxocn_jo  [nl][no]);
+	if(interp_order == 2) {
+	  free(lndxocn_clon[nl][no]);
+	  free(lndxocn_clat[nl][no]);
+	  free(lndxocn_dil [nl][no]);
+	  free(lndxocn_djl [nl][no]);
+	  free(lndxocn_dio [nl][no]);
+	  free(lndxocn_djo [nl][no]);
+	}
+      }
+      free(lndxocn_area[nl]);
+      free(lndxocn_il  [nl]);
+      free(lndxocn_jl  [nl]);
+      free(lndxocn_io  [nl]);
+      free(lndxocn_jo  [nl]);
+      if(interp_order == 2) {
+	free(lndxocn_clon[nl]);
+	free(lndxocn_clat[nl]);
+	free(lndxocn_dil [nl]);
+	free(lndxocn_djl [nl]);
+	free(lndxocn_dio [nl]);
+	free(lndxocn_djo [nl]);
+      }
+      free(nlxo[nl]);
+    }
+    free(nlxo);
+    free(lndxocn_area);
+    free(lndxocn_il  );
+    free(lndxocn_jl  );
+    free(lndxocn_io  );
+    free(lndxocn_jo  );   
+    if(interp_order == 2) {
+      free(lndxocn_clon);
+      free(lndxocn_clat);
+      free(lndxocn_dil );
+      free(lndxocn_djl );
+      free(lndxocn_dio );
+      free(lndxocn_djo );
+    }
+
+    if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Complete the process to create exchange grids "
+					 "for runoff between land and sea ice.\n" );
+  }
+  else {
+    strcpy(lmosaicximosaic_file, amosaicximosaic_file);
+    nfile_lxo = nfile_axo;
+    for(i=0; i<nfile_axo; i++) strcpy(lxo_file[i], axo_file[i]);
+    if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Since lmosaic is the same as amosaic, "
+					 "no need to compute the exchange grid between lmosaic and imosaic, "
+					 "simply use the exchange grid between amosaic and imosaic.\n");    
+  }
+
+  if(mpp_pe() == mpp_root_pe()) {
+    int n, i;
+    double axo_area_frac;
+    double axl_area_frac;
+    double tiling_area;
+    double *atm_area;
+    double atm_area_sum;
+
+    if(check) {
+      /* for cubic grid, when number of model points is odd, some grid cell area will be negative,
+	 need to think about how to solve this issue in the future */
+      /*      atm_area_sum = 4*M_PI*RADIUS*RADIUS; */
+      atm_area_sum = 0;
+      for(n=0; n<ntile_atm; n++) {
+	atm_area = (double *)malloc(nxa[n]*nya[n]*sizeof(double));
+	get_grid_area(&nxa[n], &nya[n], xatm[n], yatm[n], atm_area);
+	for(i=0; i<nxa[n]*nya[n]; i++) atm_area_sum += atm_area[i];
+	free(atm_area);
+      }
+      axo_area_frac = axo_area_sum/atm_area_sum*100;
+      axl_area_frac = axl_area_sum/atm_area_sum*100;
+      tiling_area   = (atm_area_sum-axo_area_sum-axl_area_sum)/atm_area_sum*100;    
+      printf("\nNOTE: axo_area_sum is %f and ocean fraction is %f%%\n", axo_area_sum, axo_area_frac);
+      printf("NOTE: axl_area_sum is %f and land  fraction is %f%%\n", axl_area_sum, axl_area_frac);
+      printf("NOTE: tiling error is %f%%\n", tiling_area );
+    }
+  }
+  
+  /*Fianlly create the coupler mosaic file mosaic_name.nc */
+  {
+    int fid, dim_string, dim_ncontact, dim_nmosaic, dims[4], n;
+    size_t start[4], nwrite[4];
+    int id_mosaic_file, id_contact_file, id_ocean_topog;
+    
+    fid = mpp_open(mosaic_file, MPP_WRITE);
+    mpp_def_global_att(fid, GRID_VERSION_NAME, grid_version);
+    mpp_def_global_att(fid, CODE_VERSION_NAME, tagname);
+    mpp_def_global_att(fid, HISTORY_NAME, history);
+    dim_nmosaic = mpp_def_dim(fid, NMOSAIC_NAME, 4);
+    dim_ncontact = mpp_def_dim(fid, NCONTACT_NAME, 3);
+    dim_string = mpp_def_dim(fid, STRING_NAME, STRING);
+    dims[0] = dim_nmosaic;
+    dims[1] = dim_string;
+    id_mosaic_file = mpp_def_var(fid, MOSAIC_FILES_NAME, MPP_CHAR, 2, dims,
+				  1, "standard_name", "mosaic_file_name");
+    dims[0] = dim_ncontact;
+    id_contact_file = mpp_def_var(fid, CONTACT_FILES_NAME, MPP_CHAR, 2, dims,
+				  1, "standard_name", "contact_file_name");
+    id_ocean_topog = mpp_def_var(fid, "ocean_topog_mosaic", MPP_CHAR, 1, &dim_string,
+				 1, "standard_name", "ocean_topog_mosaic_file_name");
+    
+    mpp_end_def(fid);
+    for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; }
+    start[0] = 0; nwrite[1] = strlen(amosaic_file);
+    mpp_put_var_value_block(fid, id_mosaic_file, start, nwrite, amosaic_file);
+    start[0] = 1; nwrite[1] = strlen(lmosaic_file);
+    mpp_put_var_value_block(fid, id_mosaic_file, start, nwrite, lmosaic_file);
+    start[0] = 2; nwrite[1] = strlen(imosaic_file);
+    mpp_put_var_value_block(fid, id_mosaic_file, start, nwrite, imosaic_file);
+    start[0] = 3; nwrite[1] = strlen(omosaic_file);
+    mpp_put_var_value_block(fid, id_mosaic_file, start, nwrite, omosaic_file);
+    
+    start[0] = 0; nwrite[1] = strlen(amosaicxlmosaic_file);
+    mpp_put_var_value_block(fid, id_contact_file, start, nwrite, amosaicxlmosaic_file);
+    start[0] = 1; nwrite[1] = strlen(amosaicximosaic_file);
+    mpp_put_var_value_block(fid, id_contact_file, start, nwrite, amosaicximosaic_file);
+    start[0] = 2; nwrite[1] = strlen(lmosaicximosaic_file);
+    mpp_put_var_value_block(fid, id_contact_file, start, nwrite, lmosaicximosaic_file);
+    start[0] = 0; nwrite[0] = strlen(itopog_file); nwrite[1] = 1;
+    mpp_put_var_value_block(fid, id_ocean_topog, start, nwrite, itopog_file);
+    mpp_close(fid);
+  }
+
+  return 0;
+  
+}
+  
+
+  
+  
diff --git a/gridspec/tools/shared/tool_util.h b/gridspec/tools/shared/tool_util.h
new file mode 100644
index 0000000..8682b66
--- /dev/null
+++ b/gridspec/tools/shared/tool_util.h
@@ -0,0 +1,62 @@
+/***********************************************************************
+                      tool_util.h
+    This header file provide some utilities routine that will be used in many tools.
+    
+    contact: Zhi.Liang at noaa.gov
+***********************************************************************/
+#ifndef TOOL_UTIL_H_
+#define TOOL_UTIL_H_
+#define grid_version ("0.3")
+#include "constant.h"
+double* get_subregion(int ni, double *data, int is, int ie, int js, int je);
+void get_file_path(const char *file, char *dir);
+int get_int_entry(char *line, int *value); 
+int get_double_entry(char *line, double *value);
+double spherical_dist(double x1, double y1, double x2, double y2);
+double spherical_area(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ); 
+double bipolar_dist(double x1, double y1, double x2, double y2, double bpeq, double bpsp, double bpnp, double rp );
+double bipolar_area(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 );
+void tp_trans(double *lon, double *lat, double lon_ref, double lon_start, 
+              double lam0, double bpeq, double bpsp, double bpnp, double rp );
+double* compute_grid_bound(int nb, const double *bnds, const int *npts, int *grid_size, const char *center);
+int gs_make_vgrid(char *history, int nbnds, double *bnds, int n1, 
+	      int n2, int *nz, char *gridname, char *center);
+
+int gs_make_hgrid(char *grid_type, int *nlat, int *nlon, 
+	      int nxbnds0, int nybnds0, int nxbnds1, int nybnds1, 
+	      int nxbnds2, int nybnds2, double lat_join, int nratio, 
+	      double simple_dx, double simple_dy, int ntilex, int *ndivx, 
+              int ntiley, int *ndivy,
+              char *gridname, char *center, char *history, double *xbnds, 
+	      double *ybnds);
+
+int gs_make_mosaic(char *history, int ntile, char *mosaic_name, int nmosaic, char mosaicfile[][STRING],
+		   char *grid_descriptor, int n_tilefile, char tilefile[][STRING], double periodx, double periody,
+		   int  generate_contact, char *dir );
+
+int gs_make_coupler_mosaic(char *history, char *amosaic, char *lmosaic, 
+                           char *omosaic, char *imosaic, char *itopog, int interp_order, 
+                           double sea_level, char *mosaic_name, int check);
+
+int gs_make_topog(char *history, char *mosaic_file, char *topog_type, 
+              int x_refine, int y_refine, 
+              double basin_depth, char *topog_file, char *topog_field, double bottom_depth, 
+              double min_depth, double scale_factor, int num_filter_pass, 
+              double gauss_amp, double gauss_scale, double slope_x,
+              double slope_y, double bowl_south, double bowl_north, 
+              double bowl_west, double bowl_east, int fill_first_row, 
+              int filter_topog, int round_shallow, int fill_shallow, 
+              int deepen_shallow, int smooth_topo_allow_deepening, 
+              char *topog_mosaic);
+
+int gs_fregrid(char *history, char *mosaic_in, char *mosaic_out, char *dir_in, 
+           char *dir_out, char input_file[][STRING], int nfiles, char output_file[][STRING], 
+           int nfiles_out, char *remap_file, char scalar_name[][STRING], int nscalar,
+           char u_name[][STRING], int nvector, char v_name[][STRING], int nvector2, 
+           char *interp_method, char *test_case, double test_param, 
+           unsigned int opcode, int grid_type, unsigned int finer_step,
+           int fill_missing, int nlon, int nlat, int check_conserve, 
+           int y_at_center, double lonbegin, double lonend, double latbegin,
+           double latend, int kbegin, int kend, int lbegin, int lend);
+
+#endif
diff --git a/gridspec_tools_20080702/tools/shared/topog.c b/gridspec/tools/shared/topog.c
similarity index 99%
rename from gridspec_tools_20080702/tools/shared/topog.c
rename to gridspec/tools/shared/topog.c
index 0f9e5a0..fc021fb 100644
--- a/gridspec_tools_20080702/tools/shared/topog.c
+++ b/gridspec/tools/shared/topog.c
@@ -4,7 +4,9 @@
 #include "topog.h"
 #include "create_xgrid.h"
 #include "mosaic_util.h"
+#include "interp.h"
 #include "mpp_io.h"
+#include "mpp.h"
 
 #define D2R (M_PI/180.)
 
diff --git a/gridspec_tools_20080702/tools/make_topog/topog.h b/gridspec/tools/shared/topog.h
similarity index 100%
rename from gridspec_tools_20080702/tools/make_topog/topog.h
rename to gridspec/tools/shared/topog.h
diff --git a/gridspec/tools/test.sh b/gridspec/tools/test.sh
new file mode 100755
index 0000000..2d330fc
--- /dev/null
+++ b/gridspec/tools/test.sh
@@ -0,0 +1,45 @@
+#!/bin/sh -f
+
+set -e
+echo ""
+echo "*** Testing gridspec grid commands."
+
+echo "*** make_vgrid will make a grid file with 30 grid cells..."
+../tools/make_vgrid/make_vgrid --nbnds 3 --bnds 10,200,1000 --nz 10,20
+
+echo "*** make a torus mosaic..."
+#../tools/make_hgrid/make_hgrid --grid_type regular_lonlat_grid --nxbnd 2 --nybnd 2 --xbnd 0,360 --ybnd -90,90 --nlon 160 --nlat 180 --grid_name torus_grid
+
+#../tools/make_mosaic/make_mosaic --num_tiles 1 --tile_file torus_grid.nc --periodx 360 --periody 180 --mosaic_name torus_mosaic
+
+echo "*** make a simple mosaic with four tiles..."
+
+#../tools/make_hgrid/make_hgrid --grid_type regular_lonlat_grid --nxbnd 2 --nybnd 2 --xbnd 0,360 --ybnd -90,90 --nlon 160 --nlat 180 --grid_name four_tile_grid --ndivx 2 --ndivy 2
+#../tools/make_mosaic/make_mosaic --num_tiles 4 --tile_file four_tile_grid --periodx 360 --mosaic_name four_tile_mosaic
+
+#echo "*** make a coupler mosaic with C48 atmosphere grid, N45 land grid and "
+#echo "    2 degree tripolar grid for ice and ocean model..."
+
+echo "*** make_hgrid and make_solo_mosaic C48 atmos grid..."
+../tools/make_hgrid/make_hgrid --grid_type gnomonic_ed --nlon 96 --grid_name C48_grid
+#../tools/make_mosaic/make_mosaic --num_tiles 6 --tile_file C48_grid --mosaic_name C48_mosaic 
+
+#echo "*** make_hgrid and make_solo_mosaic N45 land grid..."
+#../tools/make_hgrid/make_hgrid --grid_type regular_lonlat_grid --nxbnd 2 --nybnd 2 --xbnd 0,360 --ybnd -90,90 --nlon 288 --nlat 180 --grid_name N45_grid
+#../tools/make_mosaic/make_mosaic --num_tiles 1 --mosaic_name N45_mosaic --tile_file N45_grid.nc --periodx 360
+
+#echo "*** make_hgrid and make_solo_mosaic 2-degree tripolar.."
+#../tools/make_hgrid/make_hgrid --grid_type tripolar_grid --nxbnd 2 --nybnd 2 --xbnd -280,80 --ybnd -90,90 --nlon 360 --nlat 180 --grid_name tripolar_grid 
+#../tools/make_mosaic/make_mosaic --num_tiles 1 --mosaic_name tripolar_mosaic --tile_file tripolar_grid --periodx 360
+
+#echo "*** make_topog of tripolar grid..."
+#../tools/make_topog/make_topog --mosaic  tripolar_mosaic.nc --topog_file $indir/OCCAM_p5degree.nc --topog_field TOPO --scale_factor -1 --topog_mosaic tripolar_topog_mosaic
+
+#echo "*** make_coupler_mosaic..."
+#../tools/make_coupler_mosaic/make_coupler_mosaic --atmos_mosaic  $outdir/C48_mosaic.nc --land_mosaic  $outdir/N45_mosaic.nc --ice_mosaic  $outdir/tripolar_mosaic.nc --ice_topog_mosaic  $outdir/tripolar_topog_mosaic.nc 
+
+#echo "*** use fregrid to remap data from C48 onto N45 using first-order conservative interpolation..."
+#../tools/fregrid/fregrid --input_mosaic C48_mosaic.nc --input_dir $srcdir/../input --input_file 19800101.atmos_daily --scalar_field zsurf,temp,t_surf --output_mosaic N45_mosaic.nc --interp_method conserve_order2 --output_file 19800101.atmos_daily.N45.order1 --remap_file C48_to_N45_remap.order1.nc
+
+echo "*** All gridspec tests passed!"
+exit 0
diff --git a/gridspec/tools/test_all.sh b/gridspec/tools/test_all.sh
new file mode 100755
index 0000000..0534de1
--- /dev/null
+++ b/gridspec/tools/test_all.sh
@@ -0,0 +1,47 @@
+#!/bin/sh 
+set -e
+
+#river_regrid
+# cd $river_regrid_outdir
+# $tooldir/river_regrid --mosaic $indir/M45/mosaic.nc --river_src $indir/z1l_river_output_M45_tripolar_aug24.nc --output river_data_M45
+
+# $tooldir/river_regrid --mosaic $indir/C48/mosaic.nc --river_src $indir/z1l_river_output_M45_tripolar_aug24.nc --output river_data_C48
+
+# #transfer_to_mosaic_grid
+# cd $transfer_outdir
+# $tooldir/transfer_to_mosaic_grid --input_file $indir/M45.tripolar.grid_spec.nc
+
+# cd $outdir
+
+# #make_vgrid will make a grid file with 60 supergrid cells.
+
+# $tooldir/make_vgrid --nbnds 3 --bnds 10,200,1000 --nz 10,20
+
+# #make_hgrid and make_solo_mosaic C48
+# $tooldir/make_hgrid --grid_type gnomonic_ed --nlon 96
+
+# $tooldir/make_solo_mosaic --num_tiles 6 --dir $PWD --mosaic C48_mosaic
+
+# #make_hgrid and make_solo_mosaic N45
+# $tooldir/make_hgrid --grid_type regular_lonlat_grid --nxbnd 2 --nybnd 2 --xbnd 0,360 --ybnd -90,90 --nlon 288 --nlat 180 --grid_name N45_grid
+# $tooldir/make_solo_mosaic --num_tiles 1 --dir $PWD --mosaic N45_mosaic --tile_file N45_grid.nc --periodx 360
+
+# #make_hgrid and make_solo_mosaic 2-degree tripolar
+# $tooldir/make_hgrid --grid_type tripolar_grid --nxbnd 2 --nybnd 2 --xbnd -280,80 --ybnd -90,90 --nlon 360 --nlat 180 --grid_name tripolar_grid 
+
+# $tooldir/make_solo_mosaic --num_tiles 1 --dir $PWD --mosaic tripolar_mosaic --tile_file tripolar_grid --periodx 360
+
+# #make_topog of tripolar grid
+# $tooldir/make_topog --mosaic  $outdir/tripolar_mosaic.nc --topog_file $indir/OCCAM_p5degree.nc --topog_field TOPO --scale_factor -1 --output tripolar_topog.nc
+
+# #make_coupler_mosaic
+# $tooldir/make_coupler_mosaic --atmos_mosaic  $outdir/C48_mosaic.nc --land_mosaic  $outdir/N45_mosaic.nc --ocean_mosaic  $outdir/tripolar_mosaic.nc --ocean_topog  $outdir/tripolar_topog.nc 
+
+# mpirun -np 10 $tooldir/make_topog_parallel --mosaic $outdir/tripolar_mosaic.nc --topog_file $indir/OCCAM_p5degree.nc --topog_field TOPO --scale_factor -1 --output tripolar_topog.nc
+
+# mpirun -np 10 $tooldir/make_coupler_mosaic_parallel --atmos_mosaic $outdir/C48_mosaic.nc --land_mosaic $outdir/N45_mosaic.nc --ocean_mosaic $outdir/tripolar_mosaic.nc --ocean_topog $outdir/tripolar_topog.nc 
+
+# #compare data
+# foreach ncfile (`ls *.nc`)
+#   nccmp -md $ncfile ../$ncfile
+# end
diff --git a/gridspec_tools_20080702/Makefile.am b/gridspec_tools_20080702/Makefile.am
deleted file mode 100644
index d0e16d5..0000000
--- a/gridspec_tools_20080702/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = shared tools
\ No newline at end of file
diff --git a/gridspec_tools_20080702/shared/Makefile.am b/gridspec_tools_20080702/shared/Makefile.am
deleted file mode 100644
index dd68216..0000000
--- a/gridspec_tools_20080702/shared/Makefile.am
+++ /dev/null
@@ -1 +0,0 @@
-SUBDIRS = mosaic
\ No newline at end of file
diff --git a/gridspec_tools_20080702/shared/mosaic/Makefile.am b/gridspec_tools_20080702/shared/mosaic/Makefile.am
deleted file mode 100644
index 81552df..0000000
--- a/gridspec_tools_20080702/shared/mosaic/Makefile.am
+++ /dev/null
@@ -1,32 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# tools/shared convenience library.
-
-# $Id: Makefile.am,v 1.1 2009/04/03 15:02:15 ed Exp $
-
-noinst_LTLIBRARIES = libshared.la 
-libshared_la_SOURCES = constant.h create_xgrid.c create_xgrid.h	\
-gradient_c2l.c gradient_c2l.h interp.c interp.h mosaic_util.c	\
-mosaic_util.h read_mosaic.c read_mosaic.h
-
-AM_CPPFLAGS = 
-AM_LDFLAGS =
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-
-
diff --git a/gridspec_tools_20080702/shared/mosaic/constant.h b/gridspec_tools_20080702/shared/mosaic/constant.h
deleted file mode 100644
index 619ae07..0000000
--- a/gridspec_tools_20080702/shared/mosaic/constant.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#define RADIUS        (6371000.)
-#define STRING        255
diff --git a/gridspec_tools_20080702/tools/Makefile.am b/gridspec_tools_20080702/tools/Makefile.am
deleted file mode 100644
index 61da840..0000000
--- a/gridspec_tools_20080702/tools/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-SUBDIRS = shared make_hgrid make_solo_mosaic make_coupler_mosaic	\
-make_topog make_vgrid river_regrid transfer_to_mosaic_grid fregrid
\ No newline at end of file
diff --git a/gridspec_tools_20080702/tools/fregrid/Makefile.am b/gridspec_tools_20080702/tools/fregrid/Makefile.am
deleted file mode 100644
index fedd3ec..0000000
--- a/gridspec_tools_20080702/tools/fregrid/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# fregrid tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/06 22:21:10 ed Exp $
-
-bin_PROGRAMS = fregrid gs_fregrid
-fregrid_SOURCES = bilinear_interp.c bilinear_interp.h		\
-conserve_interp.c conserve_interp.h fregrid.c fregrid_util.c	\
-fregrid_util.h globals.h
-gs_fregrid_SOURCES = bilinear_interp.c bilinear_interp.h	\
-conserve_interp.c conserve_interp.h gs_fregrid.c fregrid_util.c	\
-fregrid_util.h globals.h
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/fregrid/conserve_interp.c b/gridspec_tools_20080702/tools/fregrid/conserve_interp.c
deleted file mode 100644
index 05d714d..0000000
--- a/gridspec_tools_20080702/tools/fregrid/conserve_interp.c
+++ /dev/null
@@ -1,689 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <netcdf.h>
-#include <math.h>
-#include "constant.h"
-#include "globals.h"
-#include "create_xgrid.h"
-#include "mosaic_util.h"
-#include "conserve_interp.h"
-#include "fregrid_util.h"
-#include "mpp.h"
-#include "mpp_io.h"
-
-#define  AREA_RATIO (1.e-3)
-
-/*******************************************************************************
-  void setup_conserve_interp
-  Setup the interpolation weight for conservative interpolation 
-*******************************************************************************/
-void setup_conserve_interp(int ntiles_in, const Grid_config *grid_in, int ntiles_out,
-			   Grid_config *grid_out, Interp_config *interp, unsigned int opcode) 
-{
-  int    n, m, i, ii, jj, nx_in, ny_in, nx_out, ny_out, tile;
-  size_t nxgrid, nxgrid2, nxgrid_prev;
-  int    *i_in, *j_in, *i_out, *j_out;
-  int   *tmp_t_in, *tmp_i_in, *tmp_j_in, *tmp_i_out, *tmp_j_out;
-  double *tmp_di_in, *tmp_dj_in;
-  double *xgrid_area, *tmp_area, *xgrid_clon, *xgrid_clat;
-  
-  double garea;
-  typedef struct{
-    double *area;
-    double *clon;
-    double *clat;
-  } CellStruct;
-  CellStruct *cell_in;
-  
-  i_in       = (int    *)malloc(MAXXGRID   * sizeof(int   ));
-  j_in       = (int    *)malloc(MAXXGRID   * sizeof(int   ));
-  i_out      = (int    *)malloc(MAXXGRID   * sizeof(int   ));
-  j_out      = (int    *)malloc(MAXXGRID   * sizeof(int   ));
-  xgrid_area = (double *)malloc(MAXXGRID   * sizeof(double));
-  if(opcode & CONSERVE_ORDER2) {
-    xgrid_clon = (double *)malloc(MAXXGRID   * sizeof(double));
-    xgrid_clat = (double *)malloc(MAXXGRID   * sizeof(double));
-  }
-  garea = 4*M_PI*RADIUS*RADIUS;
-
-  if( opcode & READ) {
-    for(n=0; n<ntiles_out; n++) {
-      if( interp[n].file_exist ) { /* reading from file */
-	int *t_in, *ind;
-	int fid, vid;
-	
-	nxgrid     = read_mosaic_xgrid_size(interp[n].remap_file);
-	t_in       = (int    *)malloc(nxgrid*sizeof(int   ));
-	ind        = (int    *)malloc(nxgrid*sizeof(int   ));
-	if(opcode & CONSERVE_ORDER1)
-	  read_mosaic_xgrid_order1(interp[n].remap_file, i_in, j_in, i_out, j_out, xgrid_area);
-	else
-	  read_mosaic_xgrid_order2(interp[n].remap_file, i_in, j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat);
-	
-	/*--- rescale the xgrid area */
-	for(i=0; i<nxgrid; i++) xgrid_area[i] *= garea;
-	fid = mpp_open(interp[n].remap_file, MPP_READ);
-	vid = mpp_get_varid(fid, "tile1");
-      	mpp_get_var_value(fid, vid, t_in);
-	mpp_close(fid);
-	/*distribute the exchange grid on each pe according to target grid index*/
-	interp[n].nxgrid = 0;
-	for(i=0; i<nxgrid; i++) {
-	  if( i_out[i] <= grid_out[n].iec && i_out[i] >= grid_out[n].isc &&
-	      j_out[i] <= grid_out[n].jec && j_out[i] >= grid_out[n].jsc )
-	    ind[interp[n].nxgrid++] = i;
-	}
-	interp[n].i_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	interp[n].j_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	interp[n].i_out  = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	interp[n].j_out  = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	interp[n].area   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	interp[n].t_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-
-	for(i=0; i< interp[n].nxgrid; i++) {
-	  interp[n].i_in [i] = i_in [ind[i]];
-	  interp[n].j_in [i] = j_in [ind[i]];
-	  interp[n].t_in [i] = t_in [ind[i]] - 1;
-	  interp[n].i_out[i] = i_out[ind[i]] - grid_out[n].isc;
-	  interp[n].j_out[i] = j_out[ind[i]] - grid_out[n].jsc;
-	  interp[n].area [i] = xgrid_area[ind[i]];
-     	}
-	if(opcode & CONSERVE_ORDER2) {
-	  interp[n].di_in   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	  interp[n].dj_in   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	  for(i=0; i< interp[n].nxgrid; i++) {
-	    interp[n].di_in[i] = xgrid_clon[ind[i]];
-	    interp[n].dj_in[i] = xgrid_clat[ind[i]];
-	  }
-	}	
-	free(t_in);
-	free(ind);
-      }
-    }
-    if(mpp_pe() == mpp_root_pe())printf("NOTE: Finish reading index and weight for conservative interpolation from file.\n");
-  }
-  else {
-    cell_in    = (CellStruct *)malloc(ntiles_in * sizeof(CellStruct));
-    for(m=0; m<ntiles_in; m++) {
-      nx_in = grid_in[m].nx;
-      ny_in = grid_in[m].ny;
-      cell_in[m].area = (double *)malloc(nx_in*ny_in*sizeof(double));
-      cell_in[m].clon = (double *)malloc(nx_in*ny_in*sizeof(double));
-      cell_in[m].clat = (double *)malloc(nx_in*ny_in*sizeof(double));
-      for(n=0; n<nx_in*ny_in; n++) {
-	cell_in[m].area[n] = 0;
-	cell_in[m].clon[n] = 0;
-        cell_in[m].clat[n] = 0;
-      }
-    }
-    for(n=0; n<ntiles_out; n++) {
-      nx_out    = grid_out[n].nxc;
-      ny_out    = grid_out[n].nyc;      
-      interp[n].nxgrid = 0;
-      for(m=0; m<ntiles_in; m++) {
-	double *mask;
-        nx_in = grid_in[m].nx;
-	ny_in = grid_in[m].ny;
-
-	mask = (double *)malloc(nx_in*ny_in*sizeof(double));
-	for(i=0; i<nx_in*ny_in; i++) mask[i] = 1.0; 
-	
-	if(opcode & CONSERVE_ORDER1) {
-	  nxgrid = create_xgrid_2dx2d_order1(&nx_in, &ny_in, &nx_out, &ny_out, grid_in[m].lonc,
-					     grid_in[m].latc,  grid_out[n].lonc,  grid_out[n].latc,
-					     mask, i_in, j_in, i_out, j_out, xgrid_area);
-	}
-	else if(opcode & CONSERVE_ORDER2) {
-	  int g_nxgrid;
-	  int    *g_i_in, *g_j_in;
-	  double *g_area, *g_clon, *g_clat;
-	  
-	  nxgrid = create_xgrid_2dx2d_order2(&nx_in, &ny_in, &nx_out, &ny_out, grid_in[m].lonc,
-					     grid_in[m].latc,  grid_out[n].lonc,  grid_out[n].latc,
-					     mask, i_in, j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat);
-	  /* For the purpose of bitiwise reproducing, the following operation is needed. */
-      	  g_nxgrid = nxgrid;
-	  mpp_sum_int(1, &g_nxgrid);
-	  if(g_nxgrid > 0) {
-	    g_i_in = (int    *)malloc(g_nxgrid*sizeof(int   ));
-	    g_j_in = (int    *)malloc(g_nxgrid*sizeof(int   ));			   
-	    g_area = (double *)malloc(g_nxgrid*sizeof(double));
-	    g_clon = (double *)malloc(g_nxgrid*sizeof(double));
-	    g_clat = (double *)malloc(g_nxgrid*sizeof(double));
-	    mpp_gather_field_int   (nxgrid, i_in,       g_i_in);
-	    mpp_gather_field_int   (nxgrid, j_in,       g_j_in);
-	    mpp_gather_field_double(nxgrid, xgrid_area, g_area);
-	    mpp_gather_field_double(nxgrid, xgrid_clon, g_clon);
-	    mpp_gather_field_double(nxgrid, xgrid_clat, g_clat);
-	    for(i=0; i<g_nxgrid; i++) {
-	      ii = g_j_in[i]*nx_in+g_i_in[i];
-	      cell_in[m].area[ii] += g_area[i];
-	      cell_in[m].clon[ii] += g_clon[i];
-	      cell_in[m].clat[ii] += g_clat[i];
-	    }
-	    free(g_i_in);
-	    free(g_j_in);
-	    free(g_area);
-	    free(g_clon);
-	    free(g_clat);
-	  }
-	}
-	else
-	  mpp_error("conserve_interp: interp_method should be CONSERVE_ORDER1 or CONSERVE_ORDER2");
-
-	free(mask);
-	if(nxgrid > 0) {
-	  nxgrid_prev = interp[n].nxgrid;
-	  interp[n].nxgrid += nxgrid;
-	  if(nxgrid_prev == 0 ) {
-	    interp[n].i_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].j_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].i_out  = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].j_out  = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].area   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	    interp[n].t_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    for(i=0; i<interp[n].nxgrid; i++) {
-	      interp[n].t_in [i] = m;
-	      interp[n].i_in [i] = i_in [i];
-	      interp[n].j_in [i] = j_in [i];
-	      interp[n].i_out[i] = i_out[i];
-	      interp[n].j_out[i] = j_out[i];
-	      interp[n].area[i]  = xgrid_area[i];
-	    }
-	    if(opcode & CONSERVE_ORDER2) {
-	      interp[n].di_in   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	      interp[n].dj_in   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	      for(i=0; i<interp[n].nxgrid; i++) {
-		jj = j_in [i]*nx_in+i_in [i];
-		interp[n].di_in [i] = xgrid_clon[i]/xgrid_area[i];
-		interp[n].dj_in [i] = xgrid_clat[i]/xgrid_area[i];
-	      }
-	    }
-	  }
-	  else {
-	    tmp_i_in  = interp[n].i_in;
-	    tmp_j_in  = interp[n].j_in;
-	    tmp_i_out = interp[n].i_out;
-	    tmp_j_out = interp[n].j_out;
-	    tmp_area  = interp[n].area;
-	    tmp_t_in  = interp[n].t_in;
-	    interp[n].i_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].j_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].i_out  = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].j_out  = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    interp[n].area   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	    interp[n].t_in   = (int    *)malloc(interp[n].nxgrid*sizeof(int   ));
-	    for(i=0; i<nxgrid_prev; i++) {
-	      interp[n].t_in [i] = tmp_t_in [i];
-	      interp[n].i_in [i] = tmp_i_in [i];
-	      interp[n].j_in [i] = tmp_j_in [i];
-	      interp[n].i_out[i] = tmp_i_out[i];
-	      interp[n].j_out[i] = tmp_j_out[i];
-	      interp[n].area [i] = tmp_area [i];
-	    }
-	    for(i=0; i<nxgrid; i++) {
-	      ii = i + nxgrid_prev;
-	      interp[n].t_in [ii] = m;
-	      interp[n].i_in [ii] = i_in [i];
-	      interp[n].j_in [ii] = j_in [i];
-	      interp[n].i_out[ii] = i_out[i];
-	      interp[n].j_out[ii] = j_out[i];
-	      interp[n].area [ii] = xgrid_area[i];
-	    }
-	    if(opcode & CONSERVE_ORDER2) {
-	      tmp_di_in  = interp[n].di_in;
-	      tmp_dj_in  = interp[n].dj_in;
-	      interp[n].di_in   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	      interp[n].dj_in   = (double *)malloc(interp[n].nxgrid*sizeof(double));
-	      for(i=0; i<nxgrid_prev; i++) { 
-		interp[n].di_in [i] = tmp_di_in [i];
-		interp[n].dj_in [i] = tmp_dj_in [i];
-	      }
-	      for(i=0; i<nxgrid; i++) {
-		ii = i + nxgrid_prev;
-		jj = j_in [i]*nx_in+i_in [i];
-		interp[n].di_in [ii] = xgrid_clon[i]/xgrid_area[i];
-		interp[n].dj_in [ii] = xgrid_clat[i]/xgrid_area[i];
-	      }
-	      free(tmp_di_in);
-	      free(tmp_dj_in);
-	    }
-	    free(tmp_t_in);
-	    free(tmp_i_in);
-	    free(tmp_j_in);
-	    free(tmp_i_out);
-	    free(tmp_j_out);
-	    free(tmp_area);
-	  }
-	}  /* if(nxgrid>0) */
-      }
-    }
-    if(opcode & CONSERVE_ORDER2) {
-      /* subtrack the grid_in clon and clat to get the distance between xgrid and grid_in */
-      for(n=0; n<ntiles_in; n++) {
-	double *area_in;
-	double x1_in[50], y1_in[50], lon_in_avg, clon, clat;
-	int    j, n0, n1, n2, n3, n1_in;
-	/* calcualte cell area */
-     	nx_in = grid_in[n].nx;
-	ny_in = grid_in[n].ny;
-	area_in = (double *)malloc(nx_in*ny_in*sizeof(double));
-	get_grid_area(&nx_in, &ny_in, grid_in[n].lonc, grid_in[n].latc, area_in);	
-	for(j=0; j<ny_in; j++) for(i=0; i<nx_in; i++) {
-	  ii = j*nx_in + i;
-	  if(cell_in[n].area[ii] > 0) {
-	    if( fabs(cell_in[n].area[ii]-area_in[ii])/area_in[ii] < AREA_RATIO ) {
-	      cell_in[n].clon[ii] /= cell_in[n].area[ii];
-	      cell_in[n].clat[ii] /= cell_in[n].area[ii];
-	    }
-	    else {
-	      n0 = j*(nx_in+1)+i;       n1 = j*(nx_in+1)+i+1;
-	      n2 = (j+1)*(nx_in+1)+i+1; n3 = (j+1)*(nx_in+1)+i;
-	      x1_in[0] = grid_in[n].lonc[n0]; y1_in[0] = grid_in[n].latc[n0];
-	      x1_in[1] = grid_in[n].lonc[n1]; y1_in[1] = grid_in[n].latc[n1];
-	      x1_in[2] = grid_in[n].lonc[n2]; y1_in[2] = grid_in[n].latc[n2];
-	      x1_in[3] = grid_in[n].lonc[n3]; y1_in[3] = grid_in[n].latc[n3];
-	      n1_in = fix_lon(x1_in, y1_in, 4, M_PI);
-	      lon_in_avg = avgval_double(n1_in, x1_in);
-              clon = poly_ctrlon(x1_in, y1_in, n1_in, lon_in_avg);
-	      clat = poly_ctrlat (x1_in, y1_in, n1_in );
-	      cell_in[n].clon[ii] = clon/area_in[ii];
-	      cell_in[n].clat[ii] = clat/area_in[ii];
-	    }
-	  } 
-	}
-	free(area_in);
-      }
-      for(n=0; n<ntiles_out; n++) {
-	for(i=0; i<interp[n].nxgrid; i++) {
-	  tile = interp[n].t_in[i];
-	  ii   = interp[n].j_in[i] * grid_in[tile].nx + interp[n].i_in[i];
-          interp[n].di_in[i] -= cell_in[tile].clon[ii];
-	  interp[n].dj_in[i] -= cell_in[tile].clat[ii];
-	}
-      }
-
-      /* free the memory */
-      for(n=0; n<ntiles_in; n++) {
-	free(cell_in[n].area);
-	free(cell_in[n].clon);
-	free(cell_in[n].clat);
-      }
-      free(cell_in);
-    }
-    if( opcode & WRITE) { /* write out remapping information */
-      for(n=0; n<ntiles_out; n++) {
-	int nxgrid;
-	
-	nxgrid = interp[n].nxgrid;
-	mpp_sum_int(1, &nxgrid);
-	if(nxgrid > 0) {
-	  size_t start[4], nwrite[4];
-	  int    fid, dim_string, dim_ncells, dim_two, dims[4];
-	  int    id_xgrid_area, id_tile1_dist;
-	  int    id_tile1_cell, id_tile2_cell, id_tile1;
-	  int    *gdata_int, *ldata_int;	  
-	  double *gdata_dbl;
-	  
-	  fid = mpp_open( interp[n].remap_file, MPP_WRITE);
-	  dim_string = mpp_def_dim(fid, "string", STRING);
-	  dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
-	  dim_two    = mpp_def_dim(fid, "two", 2);
-	  dims[0] = dim_ncells; dims[1] = dim_two;
-	  id_tile1      = mpp_def_var(fid, "tile1",      NC_INT, 1, &dim_ncells, 1,
-				      "standard_name", "tile_number_in_mosaic1");
-	  id_tile1_cell = mpp_def_var(fid, "tile1_cell", NC_INT, 2, dims, 1,
-				      "standard_name", "parent_cell_indices_in_mosaic1");
-	  id_tile2_cell = mpp_def_var(fid, "tile2_cell", NC_INT, 2, dims, 1,
-				      "standard_name", "parent_cell_indices_in_mosaic2");
-	  id_xgrid_area = mpp_def_var(fid, "xgrid_area", NC_DOUBLE, 1, &dim_ncells, 2,
-				      "standard_name", "exchange_grid_area", "units", "m2");
-	  if(opcode & CONSERVE_ORDER2) id_tile1_dist = mpp_def_var(fid, "tile1_distance", NC_DOUBLE, 2, dims, 1,
-								   "standard_name", "distance_from_parent1_cell_centroid");
-	  mpp_end_def(fid);
-	  for(i=0; i<4; i++) {
-	    start[i] = 0; nwrite[i] = 1;
-	  }
-	  nwrite[0] = nxgrid;
-	  gdata_int = (int *)malloc(nxgrid*sizeof(int));
-	  if(interp[n].nxgrid>0) ldata_int = (int *)malloc(interp[n].nxgrid*sizeof(int));
-	  gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
-	  mpp_gather_field_double(interp[n].nxgrid, interp[n].area, gdata_dbl);
-	  mpp_put_var_value(fid, id_xgrid_area, gdata_dbl);
-	  mpp_gather_field_int(interp[n].nxgrid, interp[n].t_in, gdata_int);
-	  for(i=0; i<nxgrid; i++) gdata_int[i]++;
-	  mpp_put_var_value(fid, id_tile1, gdata_int);
-	  mpp_gather_field_int(interp[n].nxgrid, interp[n].i_in, gdata_int);
-	  for(i=0; i<nxgrid; i++) gdata_int[i]++;
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  if(opcode & CONSERVE_ORDER2) {
-	    mpp_gather_field_double(interp[n].nxgrid, interp[n].di_in, gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	  }
-	  for(i=0; i<interp[n].nxgrid; i++) ldata_int[i] = interp[n].i_out[i] + grid_out[n].isc + 1; 
-	  mpp_gather_field_int(interp[n].nxgrid, ldata_int, gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  mpp_gather_field_int(interp[n].nxgrid, interp[n].j_in, gdata_int);
-	  for(i=0; i<nxgrid; i++) gdata_int[i]++;
-	  start[1] = 1;
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  if(opcode & CONSERVE_ORDER2) {
-	    mpp_gather_field_double(interp[n].nxgrid, interp[n].dj_in, gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	  }
-	  for(i=0; i<interp[n].nxgrid; i++) ldata_int[i] = interp[n].j_out[i] + grid_out[n].jsc + 1; 	  
-	  mpp_gather_field_int(interp[n].nxgrid, ldata_int, gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  free(gdata_int);
-	  free(gdata_dbl);
-	  if(interp[n].nxgrid>0)free(ldata_int);
-	  mpp_close(fid);
-	}
-      }
-    }
-    if(mpp_pe() == mpp_root_pe())printf("NOTE: done calculating index and weight for conservative interpolation\n");
-  }
-  /* get target grid area if needed */
-  if( opcode & TARGET ) {
-    for(n=0; n<ntiles_out; n++) {
-      nx_out    = grid_out[n].nxc;
-      ny_out    = grid_out[n].nyc; 
-      grid_out[n].area = (double *)malloc(nx_out*ny_out*sizeof(double));
-      get_grid_area(&nx_out,&ny_out, grid_out[n].lonc,  grid_out[n].latc, grid_out[n].area);
-    }
-  }
-  free(i_in);
-  free(j_in);
-  free(i_out);
-  free(j_out);
-  free(xgrid_area);
-  if(opcode & CONSERVE_ORDER2) {
-    free(xgrid_clon);
-    free(xgrid_clat);
-  }
-  
-}; /* setup_conserve_interp */
-
-
-/*******************************************************************************
- void do_scalar_conserve_interp( )
- doing conservative interpolation
-*******************************************************************************/
-void do_scalar_conserve_interp(Interp_config *interp, int varid, int ntiles_in, const Grid_config *grid_in,
-			       int ntiles_out, const Grid_config *grid_out, const Field_config *field_in,
-			       Field_config *field_out, unsigned int opcode)
-{
-  int nx1, ny1, nx2, ny2, nz, i1, j1, i2, j2, tile, n, k, m, i, j, kk, n1, n2;
-  int has_missing, halo;
-  double area, missing, di, dj;
-  double *out_area;
-
-  halo = 0;
-  if(opcode & CONSERVE_ORDER2) halo = 1;
-  
-  missing = field_in->var[varid].missing;
-  has_missing = field_in->var[varid].has_missing;
-  nz = field_in->var[varid].nz;
-  
-  for(m=0; m<ntiles_out; m++) {
-    nx2 = grid_out[m].nxc;
-    ny2 = grid_out[m].nyc;
-    out_area = (double *)malloc(nx2*ny2*sizeof(double));
-    
-    for(i=0; i<nx2*ny2*nz; i++) field_out[m].data[i] = 0.0;
-    
-    for(k=0; k<nz; k++) {
-      kk = k*nx2*ny2;
-      for(i=0; i<nx2*ny2; i++) out_area[i] = 0.0;
-      if(opcode & CONSERVE_ORDER1) {
-	if(has_missing) {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];    
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    if( field_in[tile].data[k*nx1*ny1+j1*nx1+i1] != missing ) {
-	      field_out[m].data[kk+j2*nx2+i2] += field_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
-	      out_area[j2*nx2+i2] += area;
-	    }
-	  }
-	}
-	else {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];    
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    field_out[m].data[kk+j2*nx2+i2] += field_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
-	    out_area[j2*nx2+i2] += area;
-	  }
-	}	  
-      }
-      else {
-	if(has_missing) {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];
-	    di   = interp[m].di_in[n];
-	    dj   = interp[m].dj_in[n];
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    n2 = k*(nx1+2)*(ny1+2)+(j1+1)*(nx1+2)+i1+1;
-	    if( field_in[tile].data[n2] != missing ) {
-	      n1 = k*nx1*ny1+j1*nx1+i1;
-              if(field_in[tile].grad_mask[n1]) { /* use zero gradient */
-		field_out[m].data[kk+j2*nx2+i2] += field_in[tile].data[n2]*area;
-	      }
-	      else {
-		field_out[m].data[kk+j2*nx2+i2] += (field_in[tile].data[n2]+field_in[tile].grad_x[n1]*di
-						    +field_in[tile].grad_y[n1]*dj)*area;
-	      }
-	      out_area[j2*nx2+i2] += area;
-	    }
-	  }
-	}
-	else {
-	  for(n=0; n<interp[m].nxgrid; n++) {
-	    i2   = interp[m].i_out[n];
-	    j2   = interp[m].j_out[n];
-	    i1   = interp[m].i_in [n];
-	    j1   = interp[m].j_in [n];
-	    di   = interp[m].di_in[n];
-	    dj   = interp[m].dj_in[n];
-	    tile = interp[m].t_in [n];
-	    area = interp[m].area [n];
-	    nx1  = grid_in[tile].nx;
-	    ny1  = grid_in[tile].ny;
-	    n1 = k*nx1*ny1+j1*nx1+i1;
-	    n2 = k*(nx1+2)*(ny1+2)+(j1+1)*(nx1+2)+i1+1;
-	    field_out[m].data[kk+j2*nx2+i2] += (field_in[tile].data[n2]+field_in[tile].grad_x[n1]*di
-						+field_in[tile].grad_y[n1]*dj)*area;
-	    out_area[j2*nx2+i2] += area;
-	  }
-	}
-      }
-      if(opcode & TARGET) {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0)
-	    field_out[m].data[kk+i] /= grid_out[m].area[i];
-	  else
-	    field_out[m].data[kk+i] = missing;
-	}
-      }
-      else {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0)
-	    field_out[m].data[kk+i] /= out_area[i];
-	  else
-	    field_out[m].data[kk+i] = missing;
-	}      
-      }
-    }
-
-    free(out_area);
-  }
-
-  /* conservation check if needed */
-  if(opcode & CHECK_CONSERVE) {
-    double gsum_in, gsum_out, dd;
-    double *area;
-    gsum_in = 0;
-    gsum_out = 0;
-    for(n=0; n<ntiles_in; n++) {
-      nx1  = grid_in[n].nx;
-      ny1  = grid_in[n].ny;
-      area = (double *)malloc(nx1*ny1*sizeof(double));
-      get_grid_area(&nx1, &ny1, grid_in[n].lonc, grid_in[n].latc, area);
-      
-      for(k=0; k<nz; k++) {
-	kk = k*(nx1+2*halo)*(ny1+2*halo);
-	for(j=0; j<ny1; j++) for(i=0; i<nx1; i++) {
-	  dd = field_in[n].data[kk+(j+halo)*(nx1+2*halo)+i+halo];
-	  if(dd != missing) gsum_in += dd*area[j*nx1+i];
-	}
-      }
-      free(area);
-    }
-    for(n=0; n<ntiles_out; n++) {
-      nx2  = grid_out[n].nxc;
-      ny2  = grid_out[n].nyc;
-      area = (double *)malloc(nx2*ny2*sizeof(double));
-      get_grid_area(&nx2, &ny2, grid_out[n].lonc, grid_out[n].latc, area);
-      
-      for(k=0; k<nz; k++) {
-	kk = k*nx2*ny2;
-	for(j=0; j<ny2; j++) for(i=0; i<nx2; i++) {
-	  dd = field_out[n].data[kk+j*nx2+i];
-	  if(dd != missing) gsum_out += dd*area[j*nx2+i];
-	}
-      }
-      free(area);
-    }
-    mpp_sum_double(1, &gsum_out);
-    
-    if(mpp_pe() == mpp_root_pe()) printf("the flux(data*area) sum of %s: input = %g, output = %g, diff = %g. \n",
-					 field_in->var[varid].name, gsum_in, gsum_out, gsum_out-gsum_in);
-        
-
-    
-  }
-  
-  
-}; /* do_scalar_conserve_interp */
-
-
-/*******************************************************************************
- void do_vector_conserve_interp( )
- doing conservative interpolation
-*******************************************************************************/
-void do_vector_conserve_interp(Interp_config *interp, int varid, int ntiles_in, const Grid_config *grid_in, int ntiles_out, 
-                               const Grid_config *grid_out, const Field_config *u_in,  const Field_config *v_in,
-                               Field_config *u_out, Field_config *v_out, unsigned int opcode)  
-{
-  int          nx1, ny1, nx2, ny2, nz, i1, j1, i2, j2, tile, n, k, m, i, kk;
-  double       area, missing, tmp_x, tmp_y;
-  double       *out_area;
-
-  nz = u_in->var[varid].nz;
-  missing = u_in->var[varid].missing;  
-  /* first rotate input data */
-  for(n = 0; n < ntiles_in; n++) {
-    if(grid_in[n].rotate) {
-      nx1 = grid_in[n].nx;
-      ny1 = grid_in[n].ny;
-      for(k = 0; k < nz; k++) {
-	for(i=0; i<nx1*ny1; i++) {
-	  tmp_x = u_in[n].data[k*nx1*ny1+i];
-	  tmp_y = v_in[n].data[k*nx1*ny1+i];
-	  if( tmp_x != missing && tmp_y != missing) {
-	    u_in[n].data[k*nx1*ny1+i] = tmp_x * grid_in[n].cosrot[i] - tmp_y * grid_in[n].sinrot[i];
-	    v_in[n].data[k*nx1*ny1+i] = tmp_x * grid_in[n].sinrot[i] + tmp_y * grid_in[n].cosrot[i];
-	  }
-	}
-      }
-    }
-  }
-  
-  for(m=0; m<ntiles_out; m++) {
-    nx2 = grid_out[m].nxc;
-    ny2 = grid_out[m].nyc;
-    out_area = (double *)malloc(nx2*ny2*sizeof(double));
-    
-    for(i=0; i<nx2*ny2*nz; i++) {
-      u_out[m].data[i] = 0.0;
-      v_out[m].data[i] = 0.0;
-    }
-    for(k=0; k<nz; k++) {
-      kk = k*nx2*ny2;
-      for(i=0; i<nx2*ny2; i++) out_area[i] = 0.0;
-    
-      for(n=0; n<interp[m].nxgrid; n++) {
-	i2   = interp[m].i_out[n];
-	j2   = interp[m].j_out[n];
-	i1   = interp[m].i_in [n];
-	j1   = interp[m].j_in [n];    
-	tile = interp[m].t_in [n];
-	area = interp[m].area [n];
-	nx1  = grid_in[tile].nx;
-	ny1  = grid_in[tile].ny;
-	tmp_x = u_in[tile].data[k*nx1*ny1+j1*nx1+i1];
-	tmp_y = v_in[tile].data[k*nx1*ny1+j1*nx1+i1];
-	if( tmp_x != missing && tmp_y != missing ) {
-	  u_out[m].data[kk+j2*nx2+i2] += u_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
-	  v_out[m].data[kk+j2*nx2+i2] += v_in[tile].data[k*nx1*ny1+j1*nx1+i1]*area;
-	  out_area[j2*nx2+i2] += area;
-	}
-      }
-      if(opcode & TARGET) {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0) {
-	    u_out[m].data[kk+i] /= grid_out[m].area[i];
-	    v_out[m].data[kk+i] /= grid_out[m].area[i];
-	  }
-	  else {
-	    u_out[m].data[kk+i] = missing;
-	    v_out[m].data[kk+i] = missing;
-	  }
-	}
-      }
-      else {
-	for(i=0; i<nx2*ny2; i++) {
-	  if(out_area[i] > 0) {
-	    u_out[m].data[kk+i] /= out_area[i];
-	    v_out[m].data[kk+i] /= out_area[i];
-	  }
-	  else {
-	    u_out[m].data[kk+i] = missing;
-	    v_out[m].data[kk+i] = missing;
-	  }
-	}      
-      }
-      /* rotate the data if needed */
-      if(grid_out[m].rotate) {
-	for(i=0; i<nx2*ny2; i++) {
-	  tmp_x = u_out[m].data[k*nx2*ny2+i];
-	  tmp_y = v_out[m].data[k*nx2*ny2+i];
-	  if( tmp_x != missing && tmp_y != missing) {
-	    u_out[m].data[k*nx2*ny2+i] =  tmp_x * grid_out[m].cosrot[i] + tmp_y * grid_out[m].sinrot[i];
-	    v_out[m].data[k*nx2*ny2+i] = -tmp_x * grid_out[m].sinrot[i] + tmp_y * grid_out[m].cosrot[i];
-	  }
-	}
-      }
-    }
-    free(out_area);
-  }    
-  
-}; /* do_vector_conserve_interp */
diff --git a/gridspec_tools_20080702/tools/fregrid/globals.h b/gridspec_tools_20080702/tools/fregrid/globals.h
deleted file mode 100644
index f58f54f..0000000
--- a/gridspec_tools_20080702/tools/fregrid/globals.h
+++ /dev/null
@@ -1,166 +0,0 @@
-#ifndef GLOBALS_H_
-#define GLOBALS_H_
-#include "constant.h"
-#include "mpp_domain.h"
-
-#define MAXATT   4096
-#define MAXSTRING 10240
-#define MAXENTRY  512
-#define NVAR     2048
-#define NFILE    32
-#define MAXDIM   10
-/* constants for grid type and grid location */
-#define ZERO   0
-#define NINETY 1
-#define MINUS_NINETY -1
-#define ONE_HUNDRED_EIGHTY 2
-#define CENTER 3
-#define CORNER 4
-#define EAST   4
-#define NORTH  5
-#define WEST   6
-#define SOUTH  7
-
-
-
-/* constants for option */
-#define CONSERVE_ORDER1 1
-#define CONSERVE_ORDER2 2
-#define BILINEAR        4
-#define VECTOR          8
-#define TARGET          16
-#define SYMMETRY        32
-#define AGRID           64
-#define BGRID           128
-#define READ            256
-#define WRITE           512
-#define CHECK_CONSERVE  1024
-
-typedef struct {
-  char   name[STRING];   /* variable name */
-  int    vid;
-  int    type;
-  int    ndim;
-  int    index[4];
-  int    nz;
-  int    kstart;
-  int    kend;
-  int    lstart;
-  int    lend;
-  int    has_zaxis;
-  int    has_taxis;
-  double missing;
-  int    has_missing;
-} Var_config;
-
-typedef struct {
-  char       *file;
-  int        *fid;
-  int         nvar;
-  double     *data;   /* array to store one variable data */
-  double     *grad_x; /* array to store one variable data gradient in x-direction */
-  double     *grad_y; /* array to store one variable data gradient in y-direction */
-  int        *grad_mask; /* array to store the mask for gradient */
-  Var_config *var;
-} Field_config;
-
-typedef struct {
-  char name[STRING];
-  char bndname[STRING];
-  int  dimid;
-  int  vid;
-  int  bndid;
-  int  size;
-  int  type;
-  char cart; 
-  int  bndtype;
-  double *bnddata;
-  double *data; 
-} Axis_config;
-
-typedef struct {
-  int  nt;
-  char name[STRING];
-  int fid;
-  int ndim;
-  Axis_config  *axis;
-  int has_tavg_info;
-  int id_t1, id_t2, id_dt;
-  double *t1, *t2, *dt;
-} File_config;
-
-typedef struct {
-  size_t nxgrid;
-  int *i_in;
-  int *j_in;
-  int *i_out;
-  int *j_out;
-  int *t_in;
-  double *di_in;
-  double *dj_in;
-  double *area;
-  double *weight;
-  int    *index;
-  char   remap_file[STRING];
-  int    file_exist;
-} Interp_config;
-
-
-typedef struct {
-  int halo;
-  int nx;
-  int ny;
-  int nx_fine;
-  int ny_fine;
-  int isc;
-  int iec;
-  int jsc;
-  int jec;
-  int nxc;
-  int nyc;
-  double *lonc;
-  double *latc;
-  double *lont;
-  double *latt;
-  double *xt;
-  double *yt;
-  double *xc;
-  double *yc;
-  double *zt;
-  double *dx;
-  double *dy;
-  double *area;
-  double *lonc1D;
-  double *latc1D;
-  double *lont1D;
-  double *latt1D;
-  double *latt1D_fine;
-  double *en_e;
-  double *en_n;
-  double *edge_w;
-  double *edge_e;
-  double *edge_s;
-  double *edge_n;
-  double *vlon_t;
-  double *vlat_t;
-  double *cosrot;
-  double *sinrot;
-  int    rotate;
-  domain2D domain;
-} Grid_config;
-
-typedef struct{
-  int nbound;
-  int *tile2;
-  int *is1, *ie1, *js1, *je1;
-  int *is2, *ie2, *js2, *je2;
-  int *rotate;
-} Bound_config;
-
-typedef struct{
-  double *data;
-  int nx;
-  int ny;
-} Data_holder;
-
-#endif
diff --git a/gridspec_tools_20080702/tools/fregrid/gs_fregrid.c b/gridspec_tools_20080702/tools/fregrid/gs_fregrid.c
deleted file mode 100644
index ba34f74..0000000
--- a/gridspec_tools_20080702/tools/fregrid/gs_fregrid.c
+++ /dev/null
@@ -1,416 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include <math.h>
-#include "globals.h"
-#include "constant.h"
-#include "read_mosaic.h"
-#include "mpp_io.h"
-#include "conserve_interp.h"
-#include "bilinear_interp.h"
-#include "fregrid_util.h"
-
-char *usage[] = {
-   "",
-   "  fregrid --input_mosaic input_mosaic --input_file input_file                         ",
-   "          [--scalar_field scalar_fld] [--u_field u_fld]  [--v_field v_fld]            ",
-   "          [--output_mosaic output_mosaic] [--lonBegin #decimal] [--lonEnd #decimal]   ",
-   "          [--latBegin #decimal] [--latEnd #decimal] [--nlon #integer]                 ",
-   "          [--nlat #integer] [--KlevelBegin #integer] [--KlevelEnd #integer]           ",
-   "          [--LstepBegin #integer] [--LstepEnd #integer]                               ",
-   "          [--output_file output_file] [--input_dir input_dir]                         ",
-   "          [--output_dir output_dir] [--remap_file remap_file]                         ",
-   "          [--interp_method method] [--grid_type grid_type] [--test_case test_case]    ",
-   "          [--symmetry] [--target_grid] [--finer_step #] [--fill_missing]              ",
-   "          [--center_y] [--check_conserve]                                             ",
-   "fregrid remap data (scalar or vector) from input_mosaic onto output_mosaic (The       ",
-   "target grid also could be specified through lonBegin, lonEnd, latBegin, latEnd, nlon  ",
-   "and nlat). Currently only T-cell scalar regridding and AGRID vector regridding (only  ",
-   "bilinear interpolation is implemented for cubic grid vector interpolation). The       ",
-   "interpolation algorithm used is controlled by --interp_method with default            ",
-   "'conserve_order1'. Currently only 'conserve_order1', 'conserve_order2' and 'bilinear' ",
-   "remapping scheme are implemented. 'bilinear' is only used to remap data from cubic    ",
-   "grid to latlon grid. We will add more scheme in the future if needed. fregrid expects ",
-   "NetCDF format input. scalar_field and/or u_field/v_field must be specified. u_fld and ",
-   "v_fld must be paired together.    ",
-   "                                                                                      ",
-   "fregrid takes the following flags:                                                    ",
-   "                                                                                      ",
-   "REQUIRED:                                                                             ",
-   "                                                                                      ",
-   "--input_mosaic  input_mosaic  specify the input mosaic information. This file         ",
-   "                              contains list of tile files which specify the grid      ",
-   "                              information for each tile.                              ",
-   "                                                                                      ",
-   "OPTIONAL FLAGS                                                                        ",
-   "                                                                                      ",  
-   "--input_file    input_file    specify the input file name. The suffix '.nc' can be    ",
-   "                              omitted. The suffix 'tile#' should not present for      ",
-   "                              multiple-tile files. The number of files must be 1 for  ",
-   "                              scalar regridding and can be 1 or 2 for vector          ",
-   "                              regridding. File path should not be includes.           ",
-   "                                                                                      ",
-   "--scalar_field    scalar_fld  specify the scalar field name to be regridded. The      ",
-   "                              multiple entry field names are seperated by comma.      ",
-   "                                                                                      ",    
-   "--u_field         u_fld       specify the vector field u-componentname to be          ",
-   "                              regridded. The multiple entry field names are seperated ",
-   "                              by comma. u_field must be paired together with v_field. ",
-   "                                                                                      ",    
-   "--v_field         v_fld       specify the vector field v-componentname to be          ",
-   "                              regridded. The multiple entry field names are seperated ",
-   "                              by comma. v_field must be paired together with u_field. ",
-   "                                                                                      ",  
-   "--output_mosaic output_mosaic specify the output mosaic information. This file        ",
-   "                              contains list of tile files which specify the grid      ",
-   "                              information for each tile. If output_mosaic is not      ",
-   "                              specified, nlon and nlat must be specified.             ",
-   "                                                                                      ",
-   "--lonBegin  #decimal          specify the starting longitude(in degree) of the        ",
-   "                              geographical region of the target grid on which the     ",
-   "                              output is desired. The default value is 0.              ",
-   "                                                                                      ",
-   "--lonEnd   #decimal           specify the ending longitude(in degree) of the          ",
-   "                              geographical region of the target grid on which the     ",
-   "                              output is desired. The default value is 360.            ",
-   "                                                                                      ",
-   "--latBegin  #decimal          specify the starting latitude(in degree) of the         ",
-   "                              geographical region of the target grid on which the     ",
-   "                              output is desired. The default value is -90.            ",
-   "                                                                                      ",
-   "--latEnd   #decimal           specify the ending latitude(in degree) of the           ",
-   "                              geographical region of the target grid on which the     ",
-   "                              output is desired. The default value is 90.             ",  
-   "                                                                                      ",
-   "--nlon #integer               specify number of grid box cells in x-direction for a   ",
-   "                              regular lat-lon grid.                                   ",
-   "                                                                                      ",
-   "--nlat #integer               specify number of grid box cells in y-direction for a   ",
-   "                              regular lat-lon grid.                                   ",
-   "                                                                                      ",  
-   "--KlevelBegin #integer        specify begin index of the k-level (depth axis) that    ",
-   "                              to be regridded.                                        ",
-   "                                                                                      ",
-   "--KlevelEnd #integer          specify end index of the k-level (depth axis) that      ",
-   "                              to be regridded.                                        ",  
-   "                                                                                      ",
-   "--LstepBegin #integer         specify the begin index of L-step (time axis) that      ",
-   "                              to be regridded.                                        ",
-   "                                                                                      ",
-   "--LstepEnd #integer           specify the end index of L-step (time axis) that        ",
-   "                              to be regridded.                                        ",  
-   "                                                                                      ",  
-   "--output_file   output_file   specify the output file name. If not presented,         ",
-   "                              output_file will take the value of input_file. The      ",
-   "                              suffix '.nc' can be omitted. The suffix 'tile#' should  ",
-   "                              not present for multiple-tile files. The number of      ",
-   "                              files must be 1 for scalar regridding and can be 1 or 2 ",
-   "                              for vector regridding. File path should not be includes.",  
-   "                                                                                      ",
-   "--input_dir     input_dir     specify the path that stores input_file. If not         ",
-   "                              presented, the input file is assumed to be stored in    ",
-   "                              current diretory.                                       ",
-   "                                                                                      ",
-   "--output_dir   output_dir     specify the path that will store output file. If not    ",
-   "                              presented, the output file will be stored in current    ",
-   "                              diretory.                                               ",
-   "                                                                                      ",
-   "--remap_file   remap_file     specify the file name that saves remapping information. ",
-   "                              If remap_file is specified and the file does not exist, ",
-   "                              remapping information will be calculated ans stored in  ",
-   "                              remap_file. If remap_file is specified and the file     ",
-   "                              exists, remapping information will be read from         ",
-   "                              remap_file.                                             ",
-   "                                                                                      ",
-   "--interp_method interp_method specify the remapping algorithm to be used. Default is  ",
-   "                              'conserve_order1'. Currently only 'conserve_order1',    ",
-   "                              'conserve_order2' and 'bilinear' remapping scheme are   ",
-   "                              implemented in this tool. The bilinear scheme can only  ",
-   "                              be used to remap data from cubic grid to regular latlon ",
-   "                              grid. When interp_method is 'bilinear', nlon and nlat   ",
-   "                              must be specified and the output data in y-direction    ",
-   "                              will be located at the center of cell or bound of the   ",
-   "                              cell depending on the setting of y_center.              ",
-   "                                                                                      ",
-   "--test_case test_case         specify the test function to be used for testing.       ",
-   "                                                                                      ",
-   "--grid_type     grid_type     specify the vector field grid location. default is      ",
-   "                              AGRID and only AGRID is implemented yet.                ",
-   "                                                                                      ",
-   "--symmetry                    indicate the grid is symmetry or not.                   ",
-   "                                                                                      ",
-   "--target_grid                 use input cell area instead of calculating based on     ",
-   "                              exchange grid area. default is off.                     ",
-   "                                                                                      ",
-   "---finer_step #integer        This is used only for bilinear interpolation. Set       ",
-   "                              finer_step to a positive integer to reduce noise in     ",
-   "                              interpolation and get a relatively smooth output. The   ",
-   "                              default value is 0. When finer_step is greater than 0,  ",
-   "                              fregrid will first remap data from source grid onto a   ",
-   "                              finer grid with resolution that is power of 2 of        ",
-   "                              destination grid resolution using bilinear              ",
-   "                              interpolation, then using volume averaging to remap     ",
-   "                              data from finer grid onto destination grid.             ",
-   "                                                                                      ",
-   "--center_y                    output latitude will locate at cell center, i.e., the   ",
-   "                              starting latitude will be -89 when nlat = 90. when      ",
-   "                              center_y is not set, starting latitude will be -90. for ",
-   "                              bilinear interpolation. For conservative interpolation, ",
-   "                              center_y is assumed.                                    ",
-   "                                                                                      ",
-   "--check_conserve              check the conservation of conservative interpolation.   ",
-   "                              The area sum will be printed out for input and output   ",
-   "                              mosaic.                                                 ",
-   "                                                                                      ",
-   "  fregrid --input_mosaic input_mosaic.nc --output_mosaic output_mosaic.nc             ",
-   "          --input_dir input_dir --input_file input_file --scalar_field temp,salt      ",
-   "                                                                                      ",
-   NULL};
-
-const double D2R = M_PI/180.;
-char tagname[] = "$Name:  $";
-
-int main(int argc, char* argv[])
-{
-   unsigned int opcode = 0;
-   char    *mosaic_in=NULL;            /* input mosaic file name */
-   char    *mosaic_out=NULL;           /* input mosaic file name */
-   char    *dir_in=NULL;               /* input file location */
-   char    *dir_out=NULL;              /* output file location */
-   int     ntiles_in = 0;              /* number of tiles in input mosaic */
-   int     ntiles_out = 0;             /* number of tiles in output mosaic */
-   int     nfiles     = 0;              /* number of input file */
-   int     nfiles_out = 0;             /* number of output file */
-   char    input_file [NFILE][STRING];
-   char    output_file[NFILE][STRING];
-   char    scalar_name[NVAR] [STRING];
-   char    u_name     [NVAR] [STRING];
-   char    v_name     [NVAR] [STRING];
-   char    *test_case = NULL;
-   double  test_param = 1;
-   int     check_conserve = 0; /* 0 means no check */
-   double  lonbegin = 0, lonend = 360;
-   double  latbegin = -90, latend = 90;			  
-   int     nlon = 0, nlat = 0;
-   int     kbegin = 0, kend = -1; 
-   int     lbegin = 0, lend = -1;
-   char    *remap_file = NULL;
-   char    interp_method[STRING] = "conserve_order1";
-   int     y_at_center = 0;
-   int     grid_type = AGRID;
-   int     nscalar=0, nvector=0, nvector2;
-   int     option_index, c, i, n, m, l;
-   char    entry[MAXSTRING];  /* should be long enough */
-   char    txt[STRING];
-   char    history[MAXATT];
-   int     fill_missing = 0;
-   unsigned int  finer_step = 0;
-
-   Grid_config   *grid_in    = NULL;   /* store input grid  */
-   Grid_config   *grid_out   = NULL;   /* store output grid */
-   Field_config  *scalar_in  = NULL;   /* store input scalar data */
-   Field_config  *scalar_out = NULL;   /* store output scalar data */
-   Field_config  *u_in       = NULL;   /* store input vector u-component */
-   Field_config  *v_in       = NULL;   /* store input vector v-component */
-   Field_config  *u_out      = NULL;   /* store input vector u-component */
-   Field_config  *v_out      = NULL;   /* store input vector v-component */
-   File_config   *file_in    = NULL;   /* store input file information */
-   File_config   *file_out   = NULL;   /* store output file information */
-   File_config   *file2_in   = NULL;   /* store input file information */
-   File_config   *file2_out  = NULL;   /* store output file information */
-   Bound_config  *bound_T    = NULL;   /* store halo update information for T-cell*/
-   Interp_config *interp     = NULL;   /* store remapping information */
-   int save_weight_only      = 0;
-  
-   int errflg = (argc == 1);
-   int fid;
-   int ret;
-  
-   static struct option long_options[] = {
-      {"input_mosaic",     required_argument, NULL, 'a'},
-      {"output_mosaic",    required_argument, NULL, 'b'},
-      {"input_dir",        required_argument, NULL, 'c'},
-      {"output_dir",       required_argument, NULL, 'd'},
-      {"input_file",       required_argument, NULL, 'e'},
-      {"output_file",      required_argument, NULL, 'f'},
-      {"remap_file",       required_argument, NULL, 'g'},
-      {"test_case",        required_argument, NULL, 'i'},
-      {"interp_method",    required_argument, NULL, 'j'},
-      {"test_parameter",   required_argument, NULL, 'k'},
-      {"symmetry",         no_argument,       NULL, 'l'},
-      {"grid_type",        required_argument, NULL, 'm'},
-      {"target_grid",      no_argument,       NULL, 'n'},
-      {"finer_step",       required_argument, NULL, 'o'},
-      {"fill_missing",     no_argument,       NULL, 'p'},
-      {"nlon",             required_argument, NULL, 'q'},
-      {"nlat",             required_argument, NULL, 'r'},
-      {"scalar_field",     required_argument, NULL, 's'},
-      {"check_conserve",   no_argument,       NULL, 't'},
-      {"u_field",          required_argument, NULL, 'u'},
-      {"v_field",          required_argument, NULL, 'v'},
-      {"center_y",         no_argument,       NULL, 'y'},
-      {"lonBegin",         required_argument, NULL, 'A'},
-      {"lonEnd",           required_argument, NULL, 'B'},
-      {"latBegin",         required_argument, NULL, 'C'},
-      {"latEnd",           required_argument, NULL, 'D'},
-      {"KlevelBegin",      required_argument, NULL, 'E'},
-      {"KlevelEnd",        required_argument, NULL, 'F'},
-      {"LstepBegin",       required_argument, NULL, 'G'},
-      {"LstepEnd",         required_argument, NULL, 'H'},
-      {"help",             no_argument,       NULL, 'h'},
-      {0, 0, 0, 0},
-   };  
-  
-   /* start parallel */
-   mpp_init(&argc, &argv);
-   mpp_domain_init();
-  
-   while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1) {
-      switch (c) {
-	 case 'a':
-	    mosaic_in  = optarg;
-	    break;
-	 case 'b':
-	    mosaic_out = optarg;
-	    break;
-	 case 'c':
-	    dir_in = optarg;
-	    break;
-	 case 'd':
-	    dir_out = optarg;
-	    break;
-	 case 'e':
-	    if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -e");
-	    strcpy(entry, optarg);
-	    tokenize(entry, ",", STRING, NFILE, input_file, &nfiles);
-	    break;
-	 case 'f':
-	    if(strlen(optarg) >= MAXSTRING)  mpp_error("fregrid: the entry is not long for option -f");      
-	    strcpy(entry, optarg);
-	    tokenize(entry, ",", STRING, NFILE, output_file, &nfiles_out);
-	    break;
-	 case 'g':
-	    remap_file = optarg;
-	    break;
-	 case 's':
-	    if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -s");      
-	    strcpy(entry, optarg);
-	    tokenize(entry, ",", STRING, NVAR, scalar_name, &nscalar);
-	    break;
-	 case 'u':
-	    if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -u");      
-	    strcpy(entry, optarg);
-	    tokenize(entry, ",", STRING, NVAR, u_name, &nvector);
-	    break;        
-	 case 'v':
-	    if(strlen(optarg) >= MAXSTRING) mpp_error("fregrid: the entry is not long for option -v");      
-	    strcpy(entry, optarg);
-	    tokenize(entry, ",", STRING, NVAR, v_name, &nvector2);
-	    break;      
-	 case 'j':
-	    strcpy(interp_method, optarg);
-	    break;
-	 case 'i':
-	    test_case = optarg;
-	    break;
-	 case 'k':
-	    test_param = atof(optarg);
-	    break;      
-	 case 'l':
-	    opcode |= SYMMETRY;
-	    break;
-	 case 'm':
-	    if(strcmp(optarg, "AGRID") == 0)
-	       grid_type = AGRID;
-	    else if(strcmp(optarg, "BGRID") == 0)
-	       grid_type = BGRID;
-	    else
-	       mpp_error("fregrid: only AGRID and BGRID vector regridding are implmented, contact developer");
-	    break;
-	 case 'n':
-	    opcode |= TARGET;
-	    break;
-	 case 'o':
-	    finer_step = atoi(optarg);
-	    break;
-	 case 'p':
-	    fill_missing = 1;
-	    break;
-	 case 'q':
-	    nlon = atoi(optarg);
-	    break;
-	 case 'r':
-	    nlat = atoi(optarg);
-	    break;
-	 case 't':
-	    check_conserve = 1;
-	    break;
-	 case 'y':
-	    y_at_center = 1;
-	    break;
-	 case 'A':
-	    lonbegin = atof(optarg);
-	    break;
-	 case 'B':
-	    lonend = atof(optarg);
-	    break;
-	 case 'C':
-	    latbegin = atof(optarg);
-	    break;
-	 case 'D':
-	    latend = atof(optarg);
-	    break;
-	 case 'E':
-	    kbegin = atoi(optarg);
-	    break;
-	 case 'F':
-	    kend = atoi(optarg);
-	    break;
-	 case 'G':
-	    lbegin = atoi(optarg);
-	    break;
-	 case 'H':
-	    lend = atoi(optarg);
-	    break;
-	 case '?':
-	    errflg++;
-	    break;
-      }
-   }
-
-   if (errflg) {
-      char **u = usage;
-      while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-      exit(2);
-   }      
-
-   /* define history to be the history in the grid file */
-   strcpy(history,argv[0]);
-   for(i=1;i<argc;i++) {
-      strcat(history, " ");
-      if(strlen(argv[i]) > MAXENTRY) { /* limit the size of each entry, here we are assume the only entry that is longer than
-					  MAXENTRY= 256 is the option --scalar_field --u_field and v_field */
-	 if(strcmp(argv[i-1], "--scalar_field") && strcmp(argv[i-1], "--u_field") && strcmp(argv[i-1], "--v_field") )
-	    mpp_error("fregrid: the entry ( is not scalar_field, u_field, v_field ) is too long, need to increase parameter MAXENTRY");
-	 strcat(history, "(**please see the field list in this file**)" );
-      }
-      else
-	 strcat(history, argv[i]);
-   }
-  
-
-   if ((ret = gs_fregrid(history, mosaic_in, mosaic_out, dir_in, 
-                         dir_out, input_file, nfiles, output_file, nfiles_out, 
-                         remap_file, scalar_name, nscalar, u_name, nvector, 
-                         v_name, nvector2, interp_method, test_case, test_param, 
-                         opcode, grid_type, finer_step, fill_missing, nlon, nlat, check_conserve, 
-                         y_at_center, lonbegin, lonend, latbegin, latend, 
-                         lbegin, kend, lbegin, lend)))
-      return ret;
-      
-   mpp_end();
-   return 0;
-  
-} /* end of main */
-  
diff --git a/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.am b/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.am
deleted file mode 100644
index 6b4d280..0000000
--- a/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# make_coupler_mosaic tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/07 15:14:47 ed Exp $
-
-bin_PROGRAMS = make_coupler_mosaic gs_make_coupler_mosaic
-make_coupler_mosaic_SOURCES = make_coupler_mosaic.c
-gs_make_coupler_mosaic_SOURCES = gs_make_coupler_mosaic.c
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/make_coupler_mosaic/gs_make_coupler_mosaic.c b/gridspec_tools_20080702/tools/make_coupler_mosaic/gs_make_coupler_mosaic.c
deleted file mode 100644
index 60f1a88..0000000
--- a/gridspec_tools_20080702/tools/make_coupler_mosaic/gs_make_coupler_mosaic.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Modify land grid to match ocean grid at coast and calculate atmos/land,
- * atmos/ocean, and land/ocean overlaps using the Sutherland-Hodgeman polygon
- * clipping algorithm (Sutherland, I. E. and G. W. Hodgeman, 1974:  Reentrant
- * polygon clipping, CACM, 17(1), 32-42).
- *  Warning, when the atmos grid is cubic grid, the number of model points should be
- *  even to avoid tiling error. I will come back to solve this issue in the future.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <math.h>
-#include "constant.h"
-#include "mpp.h"
-#include "mpp_io.h"
-#include "tool_util.h"
-#include "mpp_domain.h"
-#include "mosaic_util.h"
-#include "create_xgrid.h"
-
-
-char *usage[] = {
-   "",
-   "  make_coupler_mosaic --atmos_mosaic atmos_mosaic.nc --ocean_mosaic ocean_mosaic.nc ",
-   "              --ocean_topog ocean_topog.nc [--land_mosaic land_mosaic.nc] ",
-   "              [--sea_level #]  [--interp_method #] [--mosaic_name mosaic_name] ",
-   "              [--check ]                                                       ",
-   " ",
-   "make_coupler_mosaic generates three exchange grids for the FMS coupler. The output ",
-   "file includes exchange grid files for fluxes between atmosphere and surface (sea ice ",
-   "and land), exchange grid files for runoff between land and sea ice. There might be more ",
-   "than one exchange grid files between two model solo mosaic because there might be ",
-   "multiple tiles in a solo mosaic. All the exchange grid information are between model ",
-   "grid, not between supergrid. We assume the refinement ratio between model grid and ",
-   "supergrid is 2. Currently we only output the exchange grid on T-cell. ",
-   "Besides generate the exchange grid files, make_coupler_mosaic also generate the ",
-   "coupler mosaic file (the file name will be mosaic_name.nc) which contains the atmos, ",
-   "land and ocean mosaic path, ocean mosaic topog path and exchange grid file path. ",
-   "make_coupler_mosaic expects NetCDF format input.",
-   " ",
-   "make_coupler_mosaic takes the following flags:",
-   "",
-   "REQUIRED:",
-   "",
-   "--atmos_mosaic atmos_mosaic.nc specify the atmosphere mosaic information. This file",
-   "                               contains list of tile files which specify the grid ",
-   "                               information for each tile. Each grid is required to be ",
-   "                               regular lon/lat grid. The file name can not be 'mosaic.nc' ",
-   "",
-   "--ocean_mosaic ocean_mosaic.nc specify the ocean mosaic information. This file",
-   "                               contains list of tile files which specify the grid ",
-   "                               information for each tile. The file name can not be 'mosaic.nc' ",
-   " ",
-   "--ocean_topog ocean_topog.nc   specify the topography information for ocean mosaic.",
-   "                               The field name of the topography is depth_tile# or depth when ",
-   "                               ntiles = 1, The topography data is positive down.",
-   " ",
-   "OPTIONAL FLAGS",
-   "",
-   "--land_mosaic land_mosaic.nc   specify the land mosaic information. This file",
-   "                               contains list of tile files which specify the grid ",
-   "                               information for each tile. Each grid is required to be ",
-   "                               regular lon/lat grid. When land_mosaic is not specified,",
-   "                               atmosphere mosaic will be used to specify land mosaic.",
-   "                               The file name can not be 'mosaic.nc'.",
-   " ",
-   "--interp_order #               specify the order of conservative interplation. Its value "
-   "                               can be 1 ( linear order ) or 2 ( second order ) with default "
-   "                               value 2.                                                     "
-   "                                                                                            "
-   "--sea_level #                  specify the sea level ( in meters ) and its value will be used",
-   "                               to determine land/sea mask. When topography of  ",
-   "                               a grid cell is less than sea level, this grid cell will be land,",
-   "                               otherwise it will be ocean. Default value is 0",
-   " ",
-   "--mosaic_name mosaic_name      coupler mosaic name. The output coupler mosaic file will be ",
-   "                               mosaic_name.nc. default value is 'mosaic'. ",
-   " ",  
-   "--check                        check the tiling error",
-   "", 
-   "A sample call to make_coupler_mosaic that makes exchange grids for atmosphere, land and ocean ",
-   "mosaic (atmosphere and land are coincident) is: ",
-   "",
-   "  make_coupler_mosaic --atmos_mosaic atmos_mosaic.nc --ocean_mosaic ocean_mosaic.nc ",
-   "                  --ocean_topog ocean_topog.nc",
-   "",
-   NULL };
-
-#define D2R (M_PI/180.)
-#define MAXXGRIDFILE 100 
-#define MX 2000  
-#define AREA_RATIO_THRESH (1.e-6)
-#define TINY_VALUE (1.e-7)
-#define TOLORENCE (1.e-4)
-
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
-
-int main (int argc, char *argv[])
-{
-   int c, i, same_mosaic;
-   extern char *optarg;
-   char *omosaic  = NULL;
-   char *amosaic  = NULL;
-   char *lmosaic  = NULL;
-   char *otopog   = NULL;
-   char mosaic_name[STRING] = "mosaic", mosaic_file[STRING];
-   char omosaic_name[STRING], amosaic_name[STRING], lmosaic_name[STRING];
-   char **otile_name=NULL, **atile_name=NULL, **ltile_name=NULL;
-   int x_refine = 2, y_refine = 2;
-   int  interp_order = 2;
-   int check = 0;
-   int errflg = (argc == 1);
-   char history[512];
-   int nfile_lxo=0, nfile_axo=0, nfile_axl=0;
-   char lxo_file[MAXXGRIDFILE][STRING];
-   char axo_file[MAXXGRIDFILE][STRING];
-   char axl_file[MAXXGRIDFILE][STRING];  
-   char amosaic_dir[STRING], amosaic_file[STRING];
-   char lmosaic_dir[STRING], lmosaic_file[STRING];
-   char omosaic_dir[STRING], omosaic_file[STRING];
-   char otopog_dir[STRING], otopog_file[STRING];
-   int    ntile_ocn, ntile_atm, ntile_lnd;
-   int    *nxo = NULL, *nyo = NULL, *nxa = NULL, *nya = NULL, *nxl = NULL, *nyl = NULL;
-   double **xocn = NULL, **yocn = NULL, **xatm = NULL, **yatm = NULL, **xlnd = NULL, **ylnd = NULL;
-   double **area_ocn = NULL, **area_lnd = NULL, **area_atm = NULL;
-   double **omask = NULL;
-   double sea_level = 0.;
-   int    lnd_same_as_atm = 0;
-   int    option_index = 0;
-   double axo_area_sum = 0, axl_area_sum = 0;
-   int    ocn_south_ext = 0;
-   int ret;
-    
-   static struct option long_options[] = {
-      {"atmos_mosaic",       required_argument, NULL, 'a'},
-      {"land_mosaic",        required_argument, NULL, 'l'},
-      {"ocean_mosaic",       required_argument, NULL, 'o'},
-      {"ocean_topog",        required_argument, NULL, 't'},
-      {"sea_level",          required_argument, NULL, 's'},
-      {"interp_order",       required_argument, NULL, 'i'},
-      {"mosaic_name",        required_argument, NULL, 'm'},
-      {"check",              no_argument,       NULL, 'n'},
-      {NULL, 0, NULL, 0}
-   };
-
-   mpp_init(&argc, &argv);
-   mpp_domain_init();
-  
-   /*
-    * process command line
-    */
-
-   while ((c = getopt_long(argc, argv, "i:", long_options, &option_index) ) != -1)
-      switch (c) {
-	 case 'a': 
-	    amosaic = optarg;
-	    break;
-	 case 'l': 
-	    lmosaic = optarg;
-	    break;
-	 case 'o':
-	    omosaic = optarg;
-	    break;
-	 case 't':
-	    otopog = optarg;
-	    break;
-	 case 'i':
-	    interp_order = atoi(optarg);
-	    break;
-	 case 's':
-	    sea_level = atof(optarg);
-	    break;
-	 case 'm':
-	    strcpy(mosaic_name,optarg);
-	    break;
-	 case 'n':
-	    check = 1;
-	    break;
-	 case '?':
-	    errflg++;
-      }
-
-   if (errflg || !amosaic || !omosaic || !otopog) {
-      char **u = usage;
-      while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-      exit(2);
-   }
-
-   /* interp_order should be 1 or 2 */
-   if(interp_order != 1 && interp_order !=2 )mpp_error("make_coupler_mosaic: interp_order should be 1 or 2");
-  
-   strcpy(history,argv[0]);
-
-   for(i=1;i<argc;i++) {
-      strcat(history, " ");
-      strcat(history, argv[i]);
-   }
-
-   /*if lmosaic is not specifiied, assign amosaic value to it */
-   if(!lmosaic) lmosaic = amosaic;
-  
-   if ((ret = gs_make_coupler_mosaic(history, amosaic, lmosaic, omosaic, otopog, 
-                                     interp_order, sea_level, mosaic_name, check)))
-      return ret;
-
-   if(mpp_pe() == mpp_root_pe())
-      printf("\n***** Congratulation! You have successfully run make_coupler_mosaic\n");
-   mpp_end();
-
-   return 0;
-  
-} /* main */
-
-
diff --git a/gridspec_tools_20080702/tools/make_coupler_mosaic/make_coupler_mosaic.c b/gridspec_tools_20080702/tools/make_coupler_mosaic/make_coupler_mosaic.c
deleted file mode 100644
index 493d85a..0000000
--- a/gridspec_tools_20080702/tools/make_coupler_mosaic/make_coupler_mosaic.c
+++ /dev/null
@@ -1,2005 +0,0 @@
-/*
- * Modify land grid to match ocean grid at coast and calculate atmos/land,
- * atmos/ocean, and land/ocean overlaps using the Sutherland-Hodgeman polygon
- * clipping algorithm (Sutherland, I. E. and G. W. Hodgeman, 1974:  Reentrant
- * polygon clipping, CACM, 17(1), 32-42).
- *  Warning, when the atmos grid is cubic grid, the number of model points should be
- *  even to avoid tiling error. I will come back to solve this issue in the future.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <math.h>
-#include "constant.h"
-#include "mpp.h"
-#include "mpp_io.h"
-#include "tool_util.h"
-#include "mpp_domain.h"
-#include "mosaic_util.h"
-#include "create_xgrid.h"
-
-
-char *usage[] = {
-  "",
-  "  make_coupler_mosaic --atmos_mosaic atmos_mosaic.nc --ocean_mosaic ocean_mosaic.nc ",
-  "              --ocean_topog ocean_topog.nc [--land_mosaic land_mosaic.nc] ",
-  "              [--sea_level #]  [--interp_method #] [--mosaic_name mosaic_name] ",
-  "              [--check ]                                                       ",
-  " ",
-  "make_coupler_mosaic generates three exchange grids for the FMS coupler. The output ",
-  "file includes exchange grid files for fluxes between atmosphere and surface (sea ice ",
-  "and land), exchange grid files for runoff between land and sea ice. There might be more ",
-  "than one exchange grid files between two model solo mosaic because there might be ",
-  "multiple tiles in a solo mosaic. All the exchange grid information are between model ",
-  "grid, not between supergrid. We assume the refinement ratio between model grid and ",
-  "supergrid is 2. Currently we only output the exchange grid on T-cell. ",
-  "Besides generate the exchange grid files, make_coupler_mosaic also generate the ",
-  "coupler mosaic file (the file name will be mosaic_name.nc) which contains the atmos, ",
-  "land and ocean mosaic path, ocean mosaic topog path and exchange grid file path. ",
-  "make_coupler_mosaic expects NetCDF format input.",
-  " ",
-  "make_coupler_mosaic takes the following flags:",
-  "",
-  "REQUIRED:",
-  "",
-  "--atmos_mosaic atmos_mosaic.nc specify the atmosphere mosaic information. This file",
-  "                               contains list of tile files which specify the grid ",
-  "                               information for each tile. Each grid is required to be ",
-  "                               regular lon/lat grid. The file name can not be 'mosaic.nc' ",
-  "",
-  "--ocean_mosaic ocean_mosaic.nc specify the ocean mosaic information. This file",
-  "                               contains list of tile files which specify the grid ",
-  "                               information for each tile. The file name can not be 'mosaic.nc' ",
-  " ",
-  "--ocean_topog ocean_topog.nc   specify the topography information for ocean mosaic.",
-  "                               The field name of the topography is depth_tile# or depth when ",
-  "                               ntiles = 1, The topography data is positive down.",
-  " ",
-  "OPTIONAL FLAGS",
-  "",
-  "--land_mosaic land_mosaic.nc   specify the land mosaic information. This file",
-  "                               contains list of tile files which specify the grid ",
-  "                               information for each tile. Each grid is required to be ",
-  "                               regular lon/lat grid. When land_mosaic is not specified,",
-  "                               atmosphere mosaic will be used to specify land mosaic.",
-  "                               The file name can not be 'mosaic.nc'.",
-  " ",
-  "--interp_order #               specify the order of conservative interplation. Its value "
-  "                               can be 1 ( linear order ) or 2 ( second order ) with default "
-  "                               value 2.                                                     "
-  "                                                                                            "
-  "--sea_level #                  specify the sea level ( in meters ) and its value will be used",
-  "                               to determine land/sea mask. When topography of  ",
-  "                               a grid cell is less than sea level, this grid cell will be land,",
-  "                               otherwise it will be ocean. Default value is 0",
-  " ",
-  "--mosaic_name mosaic_name      coupler mosaic name. The output coupler mosaic file will be ",
-  "                               mosaic_name.nc. default value is 'mosaic'. ",
-  " ",  
-  "--check                        check the tiling error",
-    "", 
-  "A sample call to make_coupler_mosaic that makes exchange grids for atmosphere, land and ocean ",
-  "mosaic (atmosphere and land are coincident) is: ",
-  "",
-  "  make_coupler_mosaic --atmos_mosaic atmos_mosaic.nc --ocean_mosaic ocean_mosaic.nc ",
-  "                  --ocean_topog ocean_topog.nc",
-  "",
-  NULL };
-
-#define D2R (M_PI/180.)
-#define MAXXGRIDFILE 100 
-#define MX 2000  
-#define AREA_RATIO_THRESH (1.e-6)
-#define TINY_VALUE (1.e-7)
-#define TOLORENCE (1.e-4)
-
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
-
-/* This file will get the directory that stores the file and the file name (without the dir path) */
-void get_file_dir_and_name(char *file, char *filedir, char *filename)
-{
-  char *fptr=NULL;
-  int siz;
-  
-  fptr = strrchr(file, '/');
-
-    if(!fptr) {
-      strcpy(filename, file);
-      strcpy(filedir, "./");
-    }
-    else {
-      ++fptr;
-      siz = fptr - file;
-      strcpy(filename, fptr);
-      strncpy(filedir, file, siz);      
-    }
-};
-
-
-int main (int argc, char *argv[])
-{
-  int c, i, same_mosaic;
-  extern char *optarg;
-  char *omosaic  = NULL;
-  char *amosaic  = NULL;
-  char *lmosaic  = NULL;
-  char *otopog   = NULL;
-  char mosaic_name[STRING] = "mosaic", mosaic_file[STRING];
-  char omosaic_name[STRING], amosaic_name[STRING], lmosaic_name[STRING];
-  char **otile_name=NULL, **atile_name=NULL, **ltile_name=NULL;
-  int x_refine = 2, y_refine = 2;
-  int  interp_order = 2;
-  int check = 0;
-  int errflg = (argc == 1);
-  char history[512];
-  int nfile_lxo=0, nfile_axo=0, nfile_axl=0;
-  char lxo_file[MAXXGRIDFILE][STRING];
-  char axo_file[MAXXGRIDFILE][STRING];
-  char axl_file[MAXXGRIDFILE][STRING];  
-  char amosaic_dir[STRING], amosaic_file[STRING];
-  char lmosaic_dir[STRING], lmosaic_file[STRING];
-  char omosaic_dir[STRING], omosaic_file[STRING];
-  char otopog_dir[STRING], otopog_file[STRING];
-  int    ntile_ocn, ntile_atm, ntile_lnd;
-  int    *nxo = NULL, *nyo = NULL, *nxa = NULL, *nya = NULL, *nxl = NULL, *nyl = NULL;
-  double **xocn = NULL, **yocn = NULL, **xatm = NULL, **yatm = NULL, **xlnd = NULL, **ylnd = NULL;
-  double **area_ocn = NULL, **area_lnd = NULL, **area_atm = NULL;
-  double **omask = NULL;
-  double sea_level = 0.;
-  int    lnd_same_as_atm = 0;
-  int    option_index = 0;
-  double axo_area_sum = 0, axl_area_sum = 0;
-  int    ocn_south_ext = 0;
-    
-  static struct option long_options[] = {
-    {"atmos_mosaic",       required_argument, NULL, 'a'},
-    {"land_mosaic",        required_argument, NULL, 'l'},
-    {"ocean_mosaic",       required_argument, NULL, 'o'},
-    {"ocean_topog",        required_argument, NULL, 't'},
-    {"sea_level",          required_argument, NULL, 's'},
-    {"interp_order",       required_argument, NULL, 'i'},
-    {"mosaic_name",        required_argument, NULL, 'm'},
-    {"check",              no_argument,       NULL, 'n'},
-    {NULL, 0, NULL, 0}
-  };
-
-  mpp_init(&argc, &argv);
-  mpp_domain_init();
-  
-  /*
-   * process command line
-   */
-
-  while ((c = getopt_long(argc, argv, "i:", long_options, &option_index) ) != -1)
-    switch (c) {
-    case 'a': 
-      amosaic = optarg;
-      break;
-    case 'l': 
-      lmosaic = optarg;
-      break;
-    case 'o':
-      omosaic = optarg;
-      break;
-    case 't':
-      otopog = optarg;
-      break;
-    case 'i':
-      interp_order = atoi(optarg);
-      break;
-    case 's':
-      sea_level = atof(optarg);
-      break;
-    case 'm':
-      strcpy(mosaic_name,optarg);
-      break;
-    case 'n':
-      check = 1;
-      break;
-    case '?':
-      errflg++;
-    }
-  if (errflg || !amosaic || !omosaic || !otopog) {
-    char **u = usage;
-    while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-    exit(2);
-  }
-
-  /* interp_order should be 1 or 2 */
-  if(interp_order != 1 && interp_order !=2 )mpp_error("make_coupler_mosaic: interp_order should be 1 or 2");
-  
-  strcpy(history,argv[0]);
-
-  for(i=1;i<argc;i++) {
-    strcat(history, " ");
-    strcat(history, argv[i]);
-  }
-
-  /*if lmosaic is not specifiied, assign amosaic value to it */
-  if(!lmosaic) lmosaic = amosaic;
-  
-  /*mosaic_file can not have the same name as amosaic, lmosaic or omosaic, also the file name of
-    amosaic, lmosaic, omosaic can not be "mosaic.nc"
-  */
-  sprintf(mosaic_file, "%s.nc", mosaic_name);
-  get_file_dir_and_name(amosaic, amosaic_dir, amosaic_file);
-  get_file_dir_and_name(lmosaic, lmosaic_dir, lmosaic_file);
-  get_file_dir_and_name(omosaic, omosaic_dir, omosaic_file);
-  get_file_dir_and_name(otopog, otopog_dir, otopog_file);
-  if( !strcmp(mosaic_file, amosaic_file) || !strcmp(mosaic_file, lmosaic_file) || !strcmp(mosaic_file, omosaic_file) ) 
-    mpp_error("make_coupler_mosaic: mosaic_file can not have the same name as amosaic, lmosaic or omosaic"); 
-  if( !strcmp(amosaic_file, "mosaic.nc") || !strcmp(lmosaic_file, "mosaic.nc") || !strcmp(omosaic_file, "mosaic.nc") ) 
-    mpp_error("make_coupler_mosaic: the file name of amosaic, lmosaic or omosaic can not be mosaic.nc"); 
-
-  
-  /*
-   * Read atmosphere grid
-   */
-  {
-    int n, m_fid, g_fid, vid, gid, tid;
-    size_t start[4], nread[4];
-    char dir[STRING], filename[STRING], file[2*STRING];    
-
-    for(n=0; n<4; n++) {
-      start[n] = 0;
-      nread[n] = 1;
-    }
-
-    m_fid = mpp_open(amosaic, MPP_READ);
-    vid = mpp_get_varid(m_fid, "mosaic");    
-    mpp_get_var_value(m_fid, vid, amosaic_name);
-    ntile_atm  = mpp_get_dimlen(m_fid, "ntiles");
-    nxa        = (int *) malloc (ntile_atm*sizeof(int));
-    nya        = (int *) malloc (ntile_atm*sizeof(int));
-    xatm       = (double **) malloc( ntile_atm*sizeof(double *));
-    yatm       = (double **) malloc( ntile_atm*sizeof(double *));
-    area_atm   = (double **) malloc( ntile_atm*sizeof(double *));
-    atile_name = (char **)malloc(ntile_atm*sizeof(char *));
-    /* grid should be located in the same directory of mosaic file */
-    get_file_path(amosaic, dir);
-    gid = mpp_get_varid(m_fid, "gridfiles");
-    tid = mpp_get_varid(m_fid, "gridtiles");
-    for(n=0; n<ntile_atm; n++) {
-      double *tmpx, *tmpy;
-      int i, j;
-      
-      start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-      mpp_get_var_value_block(m_fid, gid, start, nread, filename);
-      atile_name[n] = (char *)malloc(STRING*sizeof(char));
-      mpp_get_var_value_block(m_fid, tid, start, nread,  atile_name[n]);
-      sprintf(file, "%s/%s", dir, filename);
-      g_fid = mpp_open(file, MPP_READ);
-      nxa[n] = mpp_get_dimlen(g_fid, "nx");
-      nya[n] = mpp_get_dimlen(g_fid, "ny");
-      if(nxa[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: atmos supergrid x-size can not be divided by x_refine");
-      if(nya[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: atmos supergrid y-size can not be divided by y_refine");
-      nxa[n] /= x_refine;
-      nya[n] /= y_refine;
-      xatm[n]     = (double *)malloc((nxa[n]+1)*(nya[n]+1)*sizeof(double));
-      yatm[n]     = (double *)malloc((nxa[n]+1)*(nya[n]+1)*sizeof(double));
-      area_atm[n] = (double *)malloc((nxa[n]  )*(nya[n]  )*sizeof(double));
-      tmpx        = (double *)malloc((nxa[n]*x_refine+1)*(nya[n]*y_refine+1)*sizeof(double));
-      tmpy        = (double *)malloc((nxa[n]*x_refine+1)*(nya[n]*y_refine+1)*sizeof(double));
-      vid = mpp_get_varid(g_fid, "x");
-      mpp_get_var_value(g_fid, vid, tmpx);
-      vid = mpp_get_varid(g_fid, "y");
-      mpp_get_var_value(g_fid, vid, tmpy);      
-      for(j = 0; j < nya[n]+1; j++) for(i = 0; i < nxa[n]+1; i++) {
-	xatm[n][j*(nxa[n]+1)+i] = tmpx[(j*y_refine)*(nxa[n]*x_refine+1)+i*x_refine];
-	yatm[n][j*(nxa[n]+1)+i] = tmpy[(j*y_refine)*(nxa[n]*x_refine+1)+i*x_refine];
-      }
-      free(tmpx);
-      free(tmpy);      
-      /*scale grid from degree to radian, because create_xgrid assume the grid is in radians */
-      for(i=0; i<(nxa[n]+1)*(nya[n]+1); i++) {
-	xatm[n][i] *= D2R;
-	yatm[n][i] *= D2R;
-      }
-      get_grid_area(nxa+n, nya+n, xatm[n], yatm[n], area_atm[n]);
-      mpp_close(g_fid);
-    }
-    mpp_close(m_fid);
-  }
-
-  /*
-   * Read land grid
-   */
-  if (strcmp(lmosaic, amosaic) ) { /* land mosaic is different from atmosphere mosaic */
-    int n, m_fid, g_fid, vid, gid, tid;
-    size_t start[4], nread[4];
-    char dir[STRING], filename[STRING], file[2*STRING];   
-
-    for(n=0; n<4; n++) {
-      start[n] = 0;
-      nread[n] = 1;
-    }
-    m_fid = mpp_open(lmosaic, MPP_READ);
-    vid = mpp_get_varid(m_fid, "mosaic");    
-    mpp_get_var_value(m_fid, vid, lmosaic_name);
-    ntile_lnd  = mpp_get_dimlen(m_fid, "ntiles");
-    nxl        = (int *) malloc (ntile_lnd*sizeof(int));
-    nyl        = (int *) malloc (ntile_lnd*sizeof(int));
-    xlnd       = (double **) malloc( ntile_lnd*sizeof(double *));
-    ylnd       = (double **) malloc( ntile_lnd*sizeof(double *));
-    area_lnd   = (double **) malloc( ntile_lnd*sizeof(double *));
-    ltile_name = (char **)malloc(ntile_lnd*sizeof(char *));
-    /* grid should be located in the same directory of mosaic file */
-    get_file_path(lmosaic, dir);
-    gid = mpp_get_varid(m_fid, "gridfiles");
-    tid = mpp_get_varid(m_fid, "gridtiles");    
-    for(n=0; n<ntile_lnd; n++) {
-      double *tmpx, *tmpy;
-      int i, j;
-      
-      start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-      mpp_get_var_value_block(m_fid, gid, start, nread, filename);
-      ltile_name[n] = (char *)malloc(STRING*sizeof(char));
-      mpp_get_var_value_block(m_fid, tid, start, nread,  ltile_name[n]);
-      sprintf(file, "%s/%s", dir, filename);
-      g_fid = mpp_open(file, MPP_READ);
-      nxl[n] = mpp_get_dimlen(g_fid, "nx");
-      nyl[n] = mpp_get_dimlen(g_fid, "ny");
-      if(nxl[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: land supergrid x-size can not be divided by x_refine");
-      if(nyl[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: land supergrid y-size can not be divided by y_refine");
-      nxl[n]      /= x_refine;
-      nyl[n]      /= y_refine;
-      xlnd[n]     = (double *)malloc((nxl[n]+1)*(nyl[n]+1)*sizeof(double));
-      ylnd[n]     = (double *)malloc((nxl[n]+1)*(nyl[n]+1)*sizeof(double));
-      area_lnd[n] = (double *)malloc((nxl[n]  )*(nyl[n]  )*sizeof(double));
-      tmpx        = (double *)malloc((nxl[n]*x_refine+1)*(nyl[n]*y_refine+1)*sizeof(double));
-      tmpy        = (double *)malloc((nxl[n]*x_refine+1)*(nyl[n]*y_refine+1)*sizeof(double));
-      vid = mpp_get_varid(g_fid, "x");
-      mpp_get_var_value(g_fid, vid, tmpx);
-      vid = mpp_get_varid(g_fid, "y");
-      mpp_get_var_value(g_fid, vid, tmpy);     
-      for(j = 0; j < nyl[n]+1; j++) for(i = 0; i < nxl[n]+1; i++) {
-	xlnd[n][j*(nxl[n]+1)+i] = tmpx[(j*y_refine)*(nxl[n]*x_refine+1)+i*x_refine];
-	ylnd[n][j*(nxl[n]+1)+i] = tmpy[(j*y_refine)*(nxl[n]*x_refine+1)+i*x_refine];
-      }
-      free(tmpx);
-      free(tmpy);
-      /*scale grid from degree to radian, because create_xgrid assume the grid is in radians */
-      for(i=0; i<(nxl[n]+1)*(nyl[n]+1); i++) {
-	xlnd[n][i] *= D2R;
-	ylnd[n][i] *= D2R;
-      }
-      get_grid_area(nxl+n, nyl+n, xlnd[n], ylnd[n], area_lnd[n]);
-      mpp_close(g_fid);
-    }
-    mpp_close(m_fid);
-  }
-  else { /* land mosaic is same as atmosphere mosaic */
-    ntile_lnd = ntile_atm;
-    nxl = nxa;
-    nyl = nya;
-    xlnd = xatm;
-    ylnd = yatm;
-    area_lnd = area_atm;
-    lnd_same_as_atm = 1;
-    strcpy(lmosaic_name, amosaic_name);
-    ltile_name = atile_name;
-  }
-
-  /*
-   * Read ocean grid boundaries and mask (where water is) for each tile within the mosaic.
-   */
-  {
-    int n, ntiles, m_fid, g_fid, t_fid, vid, gid, tid;
-    size_t start[4], nread[4];
-    char dir[STRING], filename[STRING], file[2*STRING];
-    
-    for(n=0; n<4; n++) {
-      start[n] = 0;
-      nread[n] = 1;
-    }
-    m_fid = mpp_open(omosaic, MPP_READ);
-    vid = mpp_get_varid(m_fid, "mosaic");    
-    mpp_get_var_value(m_fid, vid, omosaic_name);
-    ntile_ocn  = mpp_get_dimlen(m_fid, "ntiles");
-    nxo      = (int     *) malloc(ntile_ocn*sizeof(int));
-    nyo      = (int     *) malloc(ntile_ocn*sizeof(int));
-    xocn     = (double **) malloc(ntile_ocn*sizeof(double *));
-    yocn     = (double **) malloc(ntile_ocn*sizeof(double *));
-    area_ocn = (double **) malloc(ntile_ocn*sizeof(double *));
-    otile_name = (char **) malloc(ntile_ocn*sizeof(char *));
-    /* grid should be located in the same directory of mosaic file */
-    get_file_path(omosaic, dir);
-    gid = mpp_get_varid(m_fid, "gridfiles");
-    tid = mpp_get_varid(m_fid, "gridtiles");    
-
-    /* For the purpose of reproducing between processor count, the layout
-       is set to (1, npes). */
-
-    for(n=0; n<ntile_ocn; n++) {
-      double *tmpx, *tmpy;
-      int i, j;
-      double min_atm_lat, min_lat;
-      
-      start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-      mpp_get_var_value_block(m_fid, gid, start, nread, filename);
-      otile_name[n] = (char *)malloc(STRING*sizeof(char));
-      mpp_get_var_value_block(m_fid, tid, start, nread,  otile_name[n]);
-      sprintf(file, "%s/%s", dir, filename);
-      g_fid = mpp_open(file, MPP_READ);
-      nxo[n] = mpp_get_dimlen(g_fid, "nx");
-      nyo[n] = mpp_get_dimlen(g_fid, "ny");
-      if(nxo[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: ocean supergrid x-size can not be divided by x_refine");
-      if(nyo[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: ocean supergrid y-size can not be divided by y_refine");
-      tmpx        = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-      tmpy        = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-      vid = mpp_get_varid(g_fid, "x");
-      mpp_get_var_value(g_fid, vid, tmpx);
-      vid = mpp_get_varid(g_fid, "y");
-      mpp_get_var_value(g_fid, vid, tmpy);     
-   
-      /* sometimes the ocean is only covered part of atmosphere, especially not cover
-	 the south pole region. In order to get all the exchange grid between atmosXland,
-	 we need to extend one point to cover the whole atmosphere. This need the
-	 assumption of one-tile ocean. Also we assume the latitude is the along j=0
-      */
-      if(ntile_ocn == 1) {
-	int na;
-	for(i=1; i<=nxo[n]; i++) 
-	  if(tmpy[i] != tmpy[i-1]) mpp_error("make_coupler_mosaic: latitude is not uniform along j=0");
-	/* calculate the minimum of latitude of atmosphere grid */
-	min_atm_lat = 9999; /* dummy large value */
-	for(na=0; na<ntile_atm; na++) {
-	  min_lat = minval_double((nxa[na]+1)*(nya[na]+1), yatm[na]);
-	  if(min_atm_lat > min_lat) min_atm_lat = min_lat;
-	}
-	if(tmpy[0]*D2R > min_atm_lat + TINY_VALUE) { /* extend one point in south direction*/
-	  ocn_south_ext = 1;
-	}
-      }      
-      nxo[n] /= x_refine;
-      nyo[n] /= y_refine;
-      nyo[n] += ocn_south_ext;
-      xocn[n]     = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-      yocn[n]     = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-      area_ocn[n] = (double *)malloc((nxo[n]  )*(nyo[n]  )*sizeof(double));
-
-      for(j = 0; j < nyo[n]+1; j++) for(i = 0; i < nxo[n]+1; i++) {
-	xocn[n][(j+ocn_south_ext)*(nxo[n]+1)+i] = tmpx[(j*y_refine)*(nxo[n]*x_refine+1)+i*x_refine] * D2R;
-	yocn[n][(j+ocn_south_ext)*(nxo[n]+1)+i] = tmpy[(j*y_refine)*(nxo[n]*x_refine+1)+i*x_refine] * D2R;
-      }
-      if(ocn_south_ext==1) {
-	for(i=0; i<nxo[n]+1; i++) {
-	  xocn[n][i] = xocn[n][nxo[n]+1+i];
-	  yocn[n][i] = min_atm_lat;
-	}
-      }
-      free(tmpx);
-      free(tmpy);
-      get_grid_area(nxo+n, nyo+n, xocn[n], yocn[n], area_ocn[n]);
-      mpp_close(g_fid);
-    }
-    mpp_close(m_fid);
-    
-    /* read ocean topography */
-    t_fid = mpp_open(otopog, MPP_READ);
-    ntiles = mpp_get_dimlen(t_fid, "ntiles");
-    if(ntile_ocn != ntiles) mpp_error("make_coupler_mosaic: dimlen ntiles in mosaic file is not the same as dimlen in topog file");
-    omask = (double **)malloc(ntile_ocn*sizeof(double *));
-    for(n=0; n<ntile_ocn; n++) {
-      char name[128];
-      int nx, ny, i, j;
-      double *depth;
-
-      if(ntiles == 1)
-	strcpy(name, "nx");
-      else
-	sprintf(name, "nx_tile%d", n+1);
-      nx = mpp_get_dimlen(t_fid, name);
-      if(ntiles == 1)
-	strcpy(name, "ny");
-      else
-	sprintf(name, "ny_tile%d", n+1);
-      ny = mpp_get_dimlen(t_fid, name);
-      if( nx != nxo[n] || ny+ocn_south_ext != nyo[n]) mpp_error("make_coupler_mosaic: grid size mismatch between mosaic file and topog file");
-      if(ntiles == 1)
-	strcpy(name, "depth");
-      else
-        sprintf(name, "depth_tile%d", n+1);
-      depth    = (double *)malloc(nx*ny*sizeof(double));
-      omask[n] = (double *)malloc(nxo[n]*nyo[n]*sizeof(double));
-      vid = mpp_get_varid(t_fid, name);
-      mpp_get_var_value(t_fid, vid, depth);
-      for(i=0; i<nxo[n]*nyo[n]; i++) omask[n][i] = 0;
-      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	if(depth[j*nx+i] >sea_level) omask[n][(j+ocn_south_ext)*nx+i] = 1;
-      }
-      free(depth);
-    }
-    mpp_close(t_fid);
-  }    
-
-  
-  /* Either omosaic is different from both lmosaic and amosaic,
-     or all the three mosaic are the same
-  */
-  if(strcmp(omosaic_name, amosaic_name)) { /* omosaic is different from amosaic */
-    if(!strcmp(omosaic_name, lmosaic_name)) mpp_error("make_coupler_mosaic: omosaic is the same as lmosaic, "
-						      "but different from amosaic.");
-    same_mosaic = 0;
-  }
-  else { /* omosaic is same as amosaic */
-    if(strcmp(omosaic_name, lmosaic_name)) mpp_error("make_coupler_mosaic: omosaic is the same as amosaic, "
-						      "but different from lmosaic.");
-    same_mosaic = 1;
-  }
-    
-    
-  /***************************************************************************************
-     First generate the exchange grid between atmos mosaic and land/ocean mosaic              
-  ***************************************************************************************/
-  nfile_axo = 0;
-  nfile_axl = 0;
-  nfile_lxo = 0;
-  {
-    int no, nl, na, n;
-    size_t  **naxl, **naxo;
-    int     ***atmxlnd_ia,   ***atmxlnd_ja,   ***atmxlnd_il,   ***atmxlnd_jl;
-    int     ***atmxocn_ia,   ***atmxocn_ja,   ***atmxocn_io,   ***atmxocn_jo;
-    double  ***atmxlnd_area, ***atmxlnd_dia,  ***atmxlnd_dja,  ***atmxlnd_dil,  ***atmxlnd_djl;
-    double  ***atmxocn_area, ***atmxocn_dia,  ***atmxocn_dja,  ***atmxocn_dio,  ***atmxocn_djo;
-    double  ***atmxocn_clon, ***atmxocn_clat, ***atmxlnd_clon, ***atmxlnd_clat;
-    double   min_area; 
-
-    naxl         = (size_t ** )malloc(ntile_atm*sizeof(size_t *));
-    naxo         = (size_t ** )malloc(ntile_atm*sizeof(size_t *));
-    atmxlnd_area = (double ***)malloc(ntile_atm*sizeof(double **));
-    atmxlnd_ia   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-    atmxlnd_ja   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-    atmxlnd_il   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-    atmxlnd_jl   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-    atmxocn_area = (double ***)malloc(ntile_atm*sizeof(double **));
-    atmxocn_ia   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-    atmxocn_ja   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-    atmxocn_io   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-    atmxocn_jo   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-
-    if(interp_order == 2 ) {
-      atmxlnd_dia  = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxlnd_dja  = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxlnd_dil  = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxlnd_djl  = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxocn_dia  = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxocn_dja  = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxocn_dio  = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxocn_djo  = (double ***)malloc(ntile_atm*sizeof(double **));      
-      atmxlnd_clon = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxlnd_clat = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxocn_clon = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxocn_clat = (double ***)malloc(ntile_atm*sizeof(double **));      
-    }
-    
-    for(na=0; na<ntile_atm; na++) {
-      naxl[na]         = (size_t * )malloc(ntile_lnd*sizeof(size_t));
-      naxo[na]         = (size_t * )malloc(ntile_ocn*sizeof(size_t));
-      atmxlnd_area[na] = (double **)malloc(ntile_lnd*sizeof(double *));
-      atmxlnd_ia[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-      atmxlnd_ja[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-      atmxlnd_il[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-      atmxlnd_jl[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-      atmxocn_area[na] = (double **)malloc(ntile_ocn*sizeof(double *));
-      atmxocn_ia[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-      atmxocn_ja[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-      atmxocn_io[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-      atmxocn_jo[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-    
-      if(interp_order == 2 ) {
-	atmxlnd_dia [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	atmxlnd_dja [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	atmxlnd_dil [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	atmxlnd_djl [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	atmxocn_dia [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	atmxocn_dja [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	atmxocn_dio [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	atmxocn_djo [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	atmxlnd_clon[na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	atmxlnd_clat[na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	atmxocn_clon[na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	atmxocn_clat[na] = (double **)malloc(ntile_ocn*sizeof(double *));      
-      }
-
-      for(nl=0; nl<ntile_lnd; nl++) {
-	atmxlnd_area[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	atmxlnd_ia  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	atmxlnd_ja  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	atmxlnd_il  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	atmxlnd_jl  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	if(interp_order == 2 ) {
-	  atmxlnd_clon[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxlnd_clat[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxlnd_dia [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxlnd_dja [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxlnd_dil [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxlnd_djl [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	}
-      }
- 
-      for(no=0; no<ntile_ocn; no++) {
-	atmxocn_area[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	atmxocn_ia  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	atmxocn_ja  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	atmxocn_io  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	atmxocn_jo  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));          
-	if(interp_order == 2 ) {
-	  atmxocn_clon[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxocn_clat[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxocn_dia [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxocn_dja [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxocn_dio [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	  atmxocn_djo [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	}
-      }
-    }
-      
-    for(na=0; na<ntile_atm; na++) {
-      
-      int      l, is, ie, js, je, la, ia, ja, il, jl, io, jo, layout[2];
-      int      n0, n1, n2, n3, na_in, nl_in, no_in, n_out, n_out2;
-      double   xa_min, ya_min, xo_min, yo_min, xl_min, yl_min, xa_avg;
-      double   xa_max, ya_max, xo_max, yo_max, xl_max, yl_max;
-      double   xarea;
-      double   xa[MV], ya[MV], xl[MV], yl[MV], xo[MV], yo[MV];
-      double   x_out[MV], y_out[MV];
-      double   atmxlnd_x[MX][MV], atmxlnd_y[MX][MV];
-      int      num_v[MX];
-      int      axl_i[MX], axl_j[MX], axl_t[MX];
-      double   axl_xmin[MX], axl_xmax[MX], axl_ymin[MX], axl_ymax[MX];
-      double   axl_area[MX], axl_clon[MX], axl_clat[MX];
-      size_t   count;
-      domain2D Dom;
-      
-      for(nl=0; nl<ntile_lnd; nl++) naxl[na][nl] = 0;
-      for(no=0; no<ntile_ocn; no++) naxo[na][no] = 0;
-      layout[0] = mpp_npes();
-      layout[1] = 1;
-        
-      mpp_define_domain2d(nxa[na]*nya[na], 1, layout, 0, 0, &Dom);
-      mpp_get_compute_domain2d(Dom, &is, &ie, &js, &je );
-      for(la=is;la<=ie;la++) {
-	
-	ia = la%nxa[na];
-	ja = la/nxa[na];
-	n0 = ja    *(nxa[na]+1) + ia;
-	n1 = ja    *(nxa[na]+1) + ia+1;
-	n2 = (ja+1)*(nxa[na]+1) + ia+1;
-	n3 = (ja+1)*(nxa[na]+1) + ia;
-	xa[0] = xatm[na][n0]; ya[0] = yatm[na][n0];
-        xa[1] = xatm[na][n1]; ya[1] = yatm[na][n1];
-	xa[2] = xatm[na][n2]; ya[2] = yatm[na][n2];
-        xa[3] = xatm[na][n3]; ya[3] = yatm[na][n3];
-	ya_min  = minval_double(4, ya);
-	ya_max  = maxval_double(4, ya);
-	na_in   = fix_lon(xa, ya, 4, M_PI);
-	xa_min  = minval_double(na_in, xa);
-	xa_max  = maxval_double(na_in, xa);
-	xa_avg  = avgval_double(na_in, xa);
-	count = 0;
-	for(nl=0; nl<ntile_lnd; nl++) {
-	  for(jl = 0; jl < nyl[nl]; jl ++) for(il = 0; il < nxl[nl]; il++) {
-	    n0 = jl    *(nxl[nl]+1) + il;
-	    n1 = jl    *(nxl[nl]+1) + il+1;
-	    n2 = (jl+1)*(nxl[nl]+1) + il+1;
-	    n3 = (jl+1)*(nxl[nl]+1) + il;
-	    xl[0] = xlnd[nl][n0]; yl[0] = ylnd[nl][n0];
-	    xl[1] = xlnd[nl][n1]; yl[1] = ylnd[nl][n1];
-	    xl[2] = xlnd[nl][n2]; yl[2] = ylnd[nl][n2];
-	    xl[3] = xlnd[nl][n3]; yl[3] = ylnd[nl][n3];
-	    yl_min = minval_double(4, yl);
-	    yl_max = maxval_double(4, yl);
-            if(yl_min >= ya_max || yl_max <= ya_min ) continue;	    
-	    nl_in  = fix_lon(xl, yl, 4, xa_avg);
-	    xl_min = minval_double(nl_in, xl);
-	    xl_max = maxval_double(nl_in, xl);
-	    /* xl should in the same range as xa after lon_fix, so no need to
-	       consider cyclic condition
-	    */
-	      	    
-	    if(xa_min >= xl_max || xa_max <= xl_min ) continue;	
-	    if (  (n_out = clip_2dx2d( xa, ya, na_in, xl, yl, nl_in, x_out, y_out )) > 0 ) {
-	      xarea = poly_area(x_out, y_out, n_out);
-	      min_area = min(area_lnd[nl][jl*nxl[nl]+il], area_atm[na][la]);
-	      if( xarea/min_area > AREA_RATIO_THRESH ) {
-		/*  remember the exchange grid vertices */
-		for(n=0; n<n_out; n++) {
-		  atmxlnd_x[count][n] = x_out[n];
-		  atmxlnd_y[count][n] = y_out[n];
-		}
-		axl_i[count]    = il;
-		axl_j[count]    = jl;
-		axl_t[count]    = nl;
-		num_v[count]    = n_out;
-		axl_xmin[count] = minval_double(n_out, x_out);
-		axl_xmax[count] = maxval_double(n_out, x_out);
-		axl_ymin[count] = minval_double(n_out, y_out);
-		axl_ymax[count] = maxval_double(n_out, y_out);
-		axl_area[count] = 0;
-		if(interp_order == 2) {
-		  axl_clon[count] = 0;
-		  axl_clat[count] = 0;
-		}
-		++count;
-		if(count>MX) mpp_error("make_coupler_mosaic: count is greater than MX, increase MX");
-      	      }
-	    }
-	  }
-	}
-
-	/* calculate atmos/ocean x-cells */
-	for(no=0; no<ntile_ocn; no++) {
-	  for(jo = 0; jo < nyo[no]; jo++) for(io = 0; io < nxo[no]; io++) {	
-	    n0 = jo    *(nxo[no]+1) + io;
-	    n1 = jo    *(nxo[no]+1) + io+1;
-	    n2 = (jo+1)*(nxo[no]+1) + io+1;
-	    n3 = (jo+1)*(nxo[no]+1) + io;
-	    xo[0] = xocn[no][n0]; yo[0] = yocn[no][n0];
-	    xo[1] = xocn[no][n1]; yo[1] = yocn[no][n1];
-	    xo[2] = xocn[no][n2]; yo[2] = yocn[no][n2];
-	    xo[3] = xocn[no][n3]; yo[3] = yocn[no][n3];
-	    yo_min = minval_double(4, yo);
-	    yo_max = maxval_double(4, yo);
-	    no_in  = fix_lon(xo, yo, 4, xa_avg);
-	    xo_min = minval_double(no_in, xo);
-	    xo_max = maxval_double(no_in, xo);
-	    if(omask[no][jo*nxo[no]+io] > 0.5) { /* over sea/ice */
-	      /* xo should in the same range as xa after lon_fix, so no need to
-		 consider cyclic condition
-	      */
-              if(xa_min >= xo_max || xa_max <= xo_min || yo_min >= ya_max || yo_max <= ya_min ) continue;	    
-
-	      if (  (n_out = clip_2dx2d( xa, ya, na_in, xo, yo, no_in, x_out, y_out )) > 0) {
-		xarea = poly_area(x_out, y_out, n_out );
-		min_area = min(area_ocn[no][jo*nxo[no]+io], area_atm[na][la]);
-		if(xarea/min_area > AREA_RATIO_THRESH) {
-	    
-		  atmxocn_area[na][no][naxo[na][no]] = xarea;
-		  atmxocn_io[na][no][naxo[na][no]]   = io;
-		  atmxocn_jo[na][no][naxo[na][no]]   = jo;
-		  atmxocn_ia[na][no][naxo[na][no]]   = ia;
-		  atmxocn_ja[na][no][naxo[na][no]]   = ja;
-		  if(interp_order == 2) {
-		    atmxocn_clon[na][no][naxo[na][no]] = poly_ctrlon ( x_out, y_out, n_out, xa_avg);
-		    atmxocn_clat[na][no][naxo[na][no]] = poly_ctrlat ( x_out, y_out, n_out );		
-		  }
-		  ++(naxo[na][no]);
-		  if(naxo[na][no] > MAXXGRID) mpp_error("naxo is greater than MAXXGRID, increase MAXXGRID");
-		}
-	      }
-	    }
-	    else { /* over land */
-	      /* find the overlap of atmxlnd and ocean cell */
-	      for(l=0; l<count; l++) {
-		if(axl_xmin[l] >= xo_max || axl_xmax[l] <= xo_min || axl_ymin[l] >= ya_max || axl_ymax[l] <= ya_min ) continue;	  
-		if((n_out = clip_2dx2d( atmxlnd_x[l], atmxlnd_y[l], num_v[l], xo, yo, no_in, x_out, y_out )) > 0) {
-		  xarea = poly_area(x_out, y_out, n_out );
-		  min_area = min(area_lnd[axl_t[l]][axl_j[l]*nxl[axl_t[l]]+axl_i[l]], area_atm[na][la]);
-		  if(xarea/min_area > AREA_RATIO_THRESH) {
-		    axl_area[l] += xarea;
-		    if(interp_order == 2) {
-		      axl_clon[l] += poly_ctrlon ( x_out, y_out, n_out, xa_avg);
-		      axl_clat[l] += poly_ctrlat ( x_out, y_out, n_out);
-		    }
-		  }
-		}
-	      }
-	    }
-	  }
-	}
-	/* get the exchange grid between land and atmos. */
-	for(l=0; l<count; l++) {
-	  nl = axl_t[l];
-	  min_area = min(area_lnd[nl][axl_j[l]*nxl[nl]+axl_i[l]], area_atm[na][la]);
-	  if(axl_area[l]/min_area > AREA_RATIO_THRESH) {
-	    atmxlnd_area[na][nl][naxl[na][nl]] = axl_area[l];
-	    atmxlnd_ia  [na][nl][naxl[na][nl]] = ia;
-	    atmxlnd_ja  [na][nl][naxl[na][nl]] = ja;
-	    atmxlnd_il  [na][nl][naxl[na][nl]] = axl_i[l];
-	    atmxlnd_jl  [na][nl][naxl[na][nl]] = axl_j[l];
-	    if(interp_order == 2) {
-	      atmxlnd_clon[na][nl][naxl[na][nl]] = axl_clon[l];
-	      atmxlnd_clat[na][nl][naxl[na][nl]] = axl_clat[l];
-	    }
-	    ++(naxl[na][nl]);
-	    if(naxl[na][nl] > MAXXGRID) mpp_error("naxl is greater than MAXXGRID, increase MAXXGRID");
-	  }
-	}   
-      }/* end of la loop */
-
-      mpp_delete_domain2d(&Dom);
-    } /* end of na loop */
-
-    /* calculate the centroid of model grid, as well as land_mask and ocean_mask */
-    {
-      double **l_area, **o_area;
-      int    nl, no, ll, lo;
-      l_area = (double **)malloc(ntile_lnd*sizeof(double *));
-      o_area = (double **)malloc(ntile_ocn*sizeof(double *));
-      for(nl =0; nl<ntile_lnd; nl++) {
-	l_area[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	  l_area[nl][ll] = 0;
-	}
-      }
-      for(no =0; no<ntile_ocn; no++) {
-	o_area[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	  o_area[no][lo] = 0;
-	}
-      }
-            
-      if(interp_order == 1) {
-	for(na=0; na<ntile_atm; na++) {
-	  for(nl=0; nl<ntile_lnd; nl++) {
-	    int nxgrid;
-	  
-	    nxgrid = naxl[na][nl];
-	    mpp_sum_int(1, &nxgrid);
-	    if(nxgrid > 0) {
-	      double *g_area;
-	      int    *g_il, *g_jl;
-	      int    ii;
-	      g_il = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_jl = (int    *)malloc(nxgrid*sizeof(int   ));	
-	      g_area = (double *)malloc(nxgrid*sizeof(double));
-	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_il[na][nl], g_il);
-	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_jl[na][nl], g_jl);
-	      mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], g_area);
-	      for(i=0; i<nxgrid; i++) {
-		ii = g_jl[i]*nxl[nl]+g_il[i];
-		l_area[nl][ii] += g_area[i];
-	      }
-	      free(g_il);
-	      free(g_jl);
-	      free(g_area);
-	    }
-	  }
-
-	  for(no=0; no<ntile_ocn; no++) {
-	    int nxgrid;
-	    nxgrid = naxo[na][no];
-	    mpp_sum_int(1, &nxgrid);
-	    if(nxgrid > 0) {
-	      double *g_area;
-	      int    *g_io, *g_jo;
-	      int    ii;
-	      g_io = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
-	      g_area = (double *)malloc(nxgrid*sizeof(double));
-	      mpp_gather_field_int   (naxo[na][no], atmxocn_io[na][no], g_io);
-	      mpp_gather_field_int   (naxo[na][no], atmxocn_jo[na][no], g_jo);
-	      mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], g_area);
-	      for(i=0; i<nxgrid; i++) {	      
-		ii = g_jo[i]*nxo[no]+g_io[i];
-		o_area[no][ii] += g_area[i];
-	      }
-	      free(g_io);
-	      free(g_jo);
-	      free(g_area);
-	    }
-	  }
-	}
-      }
-      else { /* interp_order == 2 */
-	double **l_clon, **l_clat;
-	double **o_clon, **o_clat;
-	double  *a_area,  *a_clon,  *a_clat;
-	int la;
-      
-	l_clon = (double **)malloc(ntile_lnd*sizeof(double *));
-	l_clat = (double **)malloc(ntile_lnd*sizeof(double *));
-	for(nl =0; nl<ntile_lnd; nl++) {
-	  l_clon[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	  l_clat[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	  for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	    l_clon[nl][ll] = 0;
-	    l_clat[nl][ll] = 0;
-	  }
-	}
-	o_clon = (double **)malloc(ntile_ocn*sizeof(double *));
-	o_clat = (double **)malloc(ntile_ocn*sizeof(double *));
-	for(no =0; no<ntile_ocn; no++) {
-	  o_clon[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	  o_clat[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	  for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	    o_clon[no][lo] = 0;
-	    o_clat[no][lo] = 0;
-	  }
-	}	
-	for(na=0; na<ntile_atm; na++) {
-	  //	double *area, *clon, *clat;
-      
-	  a_area = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
-	  a_clon = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
-	  a_clat = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
-	  for(la=0; la<nxa[na]*nya[na]; la++) {
-	    a_area[la] = 0;
-	    a_clon[la] = 0;
-	    a_clat[la] = 0;
-	  }
-
-	  for(nl=0; nl<ntile_lnd; nl++) {
-	    int nxgrid;
-	  
-	    nxgrid = naxl[na][nl];
-	    mpp_sum_int(1, &nxgrid);
-	    if(nxgrid > 0) {
-	      double *g_area, *g_clon, *g_clat;
-	      int    *g_ia,   *g_ja,   *g_il, *g_jl;
-	      int    ii;
-	      g_ia = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_ja = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_il = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_jl = (int    *)malloc(nxgrid*sizeof(int   ));	
-	      g_area = (double *)malloc(nxgrid*sizeof(double));
-	      g_clon = (double *)malloc(nxgrid*sizeof(double));
-	      g_clat = (double *)malloc(nxgrid*sizeof(double));
-	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_ia[na][nl], g_ia);
-	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_ja[na][nl], g_ja);
-	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_il[na][nl], g_il);
-	      mpp_gather_field_int   (naxl[na][nl], atmxlnd_jl[na][nl], g_jl);
-	      mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], g_area);
-	      mpp_gather_field_double(naxl[na][nl], atmxlnd_clon[na][nl], g_clon);
-	      mpp_gather_field_double(naxl[na][nl], atmxlnd_clat[na][nl], g_clat);
-	      for(i=0; i<nxgrid; i++) {
-		ii = g_ja[i]*nxa[na]+g_ia[i];
-		a_area[ii] += g_area[i];
-		a_clon[ii] += g_clon[i];
-		a_clat[ii] += g_clat[i];
-		ii = g_jl[i]*nxl[nl]+g_il[i];
-		l_area[nl][ii] += g_area[i];
-		l_clon[nl][ii] += g_clon[i];
-		l_clat[nl][ii] += g_clat[i];
-	      }
-	      free(g_ia);
-	      free(g_ja);
-	      free(g_il);
-	      free(g_jl);
-	      free(g_area);
-	      free(g_clon);
-	      free(g_clat);
-	    }
-	  }
-
-	  for(no=0; no<ntile_ocn; no++) {
-	    int nxgrid;
-	    nxgrid = naxo[na][no];
-	    mpp_sum_int(1, &nxgrid);
-	    if(nxgrid > 0) {
-	      double *g_area, *g_clon, *g_clat;
-	      int    *g_ia,   *g_ja,   *g_io, *g_jo;
-	      int    ii;
-	      g_ia = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_ja = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_io = (int    *)malloc(nxgrid*sizeof(int   ));
-	      g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
-	      g_area = (double *)malloc(nxgrid*sizeof(double));
-	      g_clon = (double *)malloc(nxgrid*sizeof(double));
-	      g_clat = (double *)malloc(nxgrid*sizeof(double));
-	      mpp_gather_field_int   (naxo[na][no], atmxocn_ia[na][no], g_ia);
-	      mpp_gather_field_int   (naxo[na][no], atmxocn_ja[na][no], g_ja);
-	      mpp_gather_field_int   (naxo[na][no], atmxocn_io[na][no], g_io);
-	      mpp_gather_field_int   (naxo[na][no], atmxocn_jo[na][no], g_jo);
-	      mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], g_area);
-	      mpp_gather_field_double(naxo[na][no], atmxocn_clon[na][no], g_clon);
-	      mpp_gather_field_double(naxo[na][no], atmxocn_clat[na][no], g_clat);
-	      for(i=0; i<nxgrid; i++) {	      
-		ii = g_ja[i]*nxa[na]+g_ia[i];
-		a_area[ii] += g_area[i];
-		a_clon[ii] += g_clon[i];
-		a_clat[ii] += g_clat[i];
-		ii = g_jo[i]*nxo[no]+g_io[i];
-		o_area[no][ii] += g_area[i];
-		o_clon[no][ii] += g_clon[i];
-		o_clat[no][ii] += g_clat[i];
-	      }
-	      free(g_ia);
-	      free(g_ja);
-	      free(g_io);
-	      free(g_jo);
-	      free(g_area);
-	      free(g_clon);
-	      free(g_clat);
-	    }
-	  }
-
-	  for(la=0; la<nxa[na]*nya[na]; la++) {
-	    if(a_area[la] > 0) {
-	      a_clon[la] /= a_area[la];
-	      a_clat[la] /= a_area[la];
-	    }
-	  }
-	
-	  /* substract atmos centroid to get the centroid distance between atmos grid and exchange grid. */
-	  for(nl=0; nl<ntile_lnd; nl++) {
-	    for(i=0; i<naxl[na][nl]; i++) {
-	      la = atmxlnd_ja[na][nl][i]*nxa[na] + atmxlnd_ia[na][nl][i];
-	      atmxlnd_dia[na][nl][i] = atmxlnd_clon[na][nl][i]/atmxlnd_area[na][nl][i] - a_clon[la];
-	      atmxlnd_dja[na][nl][i] = atmxlnd_clat[na][nl][i]/atmxlnd_area[na][nl][i] - a_clat[la];
-	    }
-	  }
-	  for(no=0; no<ntile_ocn; no++) {
-	    for(i=0; i<naxo[na][no]; i++) {
-	      la = atmxocn_ja[na][no][i]*nxa[na] + atmxocn_ia[na][no][i];
-	      atmxocn_dia[na][no][i] = atmxocn_clon[na][no][i]/atmxocn_area[na][no][i] - a_clon[la];
-	      atmxocn_dja[na][no][i] = atmxocn_clat[na][no][i]/atmxocn_area[na][no][i] - a_clat[la];
-	    }
-	  }
-	
-	  free(a_area);
-	  free(a_clon);
-	  free(a_clat);
-	}
-
-      
-	/* centroid distance from exchange grid to land grid */
-	for(nl=0; nl<ntile_lnd; nl++) {
-	  for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	    if(l_area[nl][ll] > 0) {
-	      l_clon[nl][ll] /= l_area[nl][ll];
-	      l_clat[nl][ll] /= l_area[nl][ll];
-	    }
-	  }
-	  for(na=0; na<ntile_atm; na++) {
-	    for(i=0; i<naxl[na][nl]; i++) {
-	      ll = atmxlnd_jl[na][nl][i]*nxl[nl] + atmxlnd_il[na][nl][i];
-	      atmxlnd_dil[na][nl][i] = atmxlnd_clon[na][nl][i]/atmxlnd_area[na][nl][i] - l_clon[nl][ll];
-	      atmxlnd_djl[na][nl][i] = atmxlnd_clat[na][nl][i]/atmxlnd_area[na][nl][i] - l_clat[nl][ll];
-	    }
-	  }
-	  free(l_clon[nl]);
-	  free(l_clat[nl]);
-	}
-
-	/* centroid distance from exchange grid to ocean grid */
-	for(no=0; no<ntile_ocn; no++) {
-	  for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	    if(o_area[no][lo] > 0) {
-	      o_clon[no][lo] /= o_area[no][lo];
-	      o_clat[no][lo] /= o_area[no][lo];
-	    }
-	  }
-	  for(na=0; na<ntile_atm; na++) {
-	    for(i=0; i<naxo[na][no]; i++) {
-	      lo = atmxocn_jo[na][no][i]*nxo[no] + atmxocn_io[na][no][i];
-	      atmxocn_dio[na][no][i] = atmxocn_clon[na][no][i]/atmxocn_area[na][no][i] - o_clon[no][lo];
-	      atmxocn_djo[na][no][i] = atmxocn_clat[na][no][i]/atmxocn_area[na][no][i] - o_clat[no][lo];
-	    }
-	  }
-	  free(o_clon[no]);
-	  free(o_clat[no]);
-	}
-	free(o_clon);
-	free(o_clat);
-	free(l_clon);
-	free(l_clat);  
-      }
-
-      /* calculate ocean_frac and compare ocean_frac with omask */
-      /* also write out ocn_frac */
-      {
-	int    io, jo;
-	double ocn_frac;
-	int    id_mask, fid, dims[2];
-	char ocn_mask_file[STRING];
-	double *mask;
-	int ny;
-
-
-	for(no=0; no<ntile_ocn; no++) {
-	  ny = nyo[no]-ocn_south_ext;
-	  mask = (double *)malloc(nxo[no]*ny*sizeof(double));
-	  for(jo=0; jo<ny; jo++) for(io=0; io<nxo[no]; io++) {
-	    i = (jo+ocn_south_ext)*nxo[no]+io;
-	    ocn_frac = o_area[no][i]/area_ocn[no][i];
-	    if( fabs(omask[no][i] - ocn_frac) > TOLORENCE ) {
-	      printf("at ocean point (%d,%d), omask = %f, ocn_frac = %f, diff = %f\n",
-		     io, jo, omask[no][i], ocn_frac, omask[no][i] - ocn_frac);
-	      mpp_error("make_coupler_mosaic: omask is not equal ocn_frac");
-	    }
-	    mask[jo*nxo[no]+io] = ocn_frac;
-	  }
-	  if(ntile_ocn > 1)
-	    sprintf(ocn_mask_file, "ocean_mask_tile%d.nc", no+1);
-	  else
-	    strcpy(ocn_mask_file, "ocean_mask.nc");
-	  fid = mpp_open(ocn_mask_file, MPP_WRITE);
-	  mpp_def_global_att(fid, "grid_version", grid_version);
-	  mpp_def_global_att(fid, "code_version", tagname);
-	  mpp_def_global_att(fid, "history", history);
-          	  
-
-	  dims[1] = mpp_def_dim(fid, "nx", nxo[no]); 
-	  dims[0] = mpp_def_dim(fid, "ny", ny);
-	  id_mask = mpp_def_var(fid, "mask", MPP_DOUBLE, 2, dims,  2, "standard_name",
-				"ocean fraction at T-cell centers", "units", "none");
-	  mpp_end_def(fid);
-	  mpp_put_var_value(fid, id_mask, mask);
-	  mpp_close(fid);
-	  free(mask);
-	}
-      }
-
-      /* calculate land_frac and  write out land_frac */
-      {
-	int    il, jl;
-	int    id_mask, fid, dims[2];
-	char lnd_mask_file[STRING];
-	double *mask;
-	
-	for(nl=0; nl<ntile_lnd; nl++) {
-	  mask = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	  for(jl=0; jl<nyl[nl]; jl++) for(il=0; il<nxl[nl]; il++) {
-	    i = jl*nxl[nl]+il;
-	    mask[i] = l_area[nl][i]/area_lnd[nl][i];
-	  }
-	  if(ntile_lnd > 1)
-	    sprintf(lnd_mask_file, "land_mask_tile%d.nc", nl+1);
-	  else
-	    strcpy(lnd_mask_file, "land_mask.nc");
-	  fid = mpp_open(lnd_mask_file, MPP_WRITE);
-	  mpp_def_global_att(fid, "grid_version", grid_version);
-	  mpp_def_global_att(fid, "code_version", tagname);
-	  mpp_def_global_att(fid, "history", history);
-	  dims[1] = mpp_def_dim(fid, "nx", nxl[nl]); 
-	  dims[0] = mpp_def_dim(fid, "ny", nyl[nl]);
-	  id_mask = mpp_def_var(fid, "mask", MPP_DOUBLE, 2, dims,  2, "standard_name",
-				"land fraction at T-cell centers", "units", "none");
-	  mpp_end_def(fid);
-	  mpp_put_var_value(fid, id_mask, mask);
-	  free(mask);
-	  mpp_close(fid);
-	}
-      }        
-      
-      for(nl=0; nl<ntile_lnd; nl++) free(l_area[nl]);
-      for(no=0; no<ntile_ocn; no++) free(o_area[no]);      
-      free(o_area);
-      free(l_area);
-    }
-    
-  
-    for(na=0; na<ntile_atm; na++) {
-    /* write out atmXlnd data*/
-      for(nl = 0; nl < ntile_lnd; nl++) {
-	int nxgrid;
-	nxgrid = naxl[na][nl];
-	mpp_sum_int(1, &nxgrid);
-	if(nxgrid>0) {
-	  size_t start[4], nwrite[4];
-	  int *gdata_int;
-	  double *gdata_dbl;
-	  
-	  int fid, dim_string, dim_ncells, dim_two, dims[4];
-	  int id_xgrid_area, id_contact, n;
-	  int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-	  char contact[STRING];
-
-	  for(i=0; i<4; i++) {
-	    start[i] = 0; nwrite[i] = 1;
-	  }	  	  
-	  if(same_mosaic)
-	    sprintf(axl_file[nfile_axl], "atm_%s_%sXlnd_%s_%s.nc", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
-	  else
-	    sprintf(axl_file[nfile_axl], "%s_%sX%s_%s.nc", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
-	  sprintf(contact, "%s:%s::%s:%s", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
-	  fid = mpp_open(axl_file[nfile_axl], MPP_WRITE);
-	  mpp_def_global_att(fid, "grid_version", grid_version);
-	  mpp_def_global_att(fid, "code_version", tagname);
-	  mpp_def_global_att(fid, "history", history);
-	  dim_string = mpp_def_dim(fid, "string", STRING);
-	  dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
-	  dim_two    = mpp_def_dim(fid, "two", 2);
-	  if(interp_order == 2) {
-	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
-				     "contact_type", "exchange", "parent1_cell",
-				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
-				     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	  }
-	  else {
-	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
-				     "contact_type", "exchange", "parent1_cell",
-				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-	  }
-	    
-	  dims[0] = dim_ncells; dims[1] = dim_two;
-	  id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-	  id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-	  id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-				      "exchange_grid_area", "units", "m2");
-	  if(interp_order == 2) {
-	    id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-	    id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-	  }
-	  mpp_end_def(fid);
-
-	  /* the index will start from 1, instead of 0 ( fortran index) */
-	  for(i = 0;i < naxl[na][nl]; i++) {
-	    ++(atmxlnd_ia[na][nl][i]);
-	    ++(atmxlnd_ja[na][nl][i]);
-	    ++(atmxlnd_il[na][nl][i]);
-	    ++(atmxlnd_jl[na][nl][i]);
-	  }
-	  nwrite[0] = strlen(contact);
-	  mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-     	  nwrite[0] = nxgrid;
-
-	  gdata_int = (int *)malloc(nxgrid*sizeof(int));
-	  gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
-
-	  mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], gdata_dbl);
-	  if(check) {
-	    for(n=0; n<nxgrid; n++) axl_area_sum += gdata_dbl[n];
-	  }
-	  mpp_put_var_value(fid, id_xgrid_area, gdata_dbl);
-	  mpp_gather_field_int(naxl[na][nl], atmxlnd_ia[na][nl], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  mpp_gather_field_int(naxl[na][nl], atmxlnd_il[na][nl], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  start[1] = 1;
-	  mpp_gather_field_int(naxl[na][nl], atmxlnd_ja[na][nl], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  mpp_gather_field_int(naxl[na][nl], atmxlnd_jl[na][nl], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  if(interp_order == 2) {
-	    start[1] = 0;
-  	    mpp_gather_field_double(naxl[na][nl], atmxlnd_dia[na][nl], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	    mpp_gather_field_double(naxl[na][nl], atmxlnd_dil[na][nl], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	    start[1] = 1;
-  	    mpp_gather_field_double(naxl[na][nl], atmxlnd_dja[na][nl], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	    mpp_gather_field_double(naxl[na][nl], atmxlnd_djl[na][nl], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	  }
-	  mpp_close(fid);
-	  free(gdata_int);
-	  free(gdata_dbl);
-	  ++nfile_axl;
-	}
-      } /* end of nl loop */
-
-      /* write out atmXocn data */
-      for(no = 0; no < ntile_ocn; no++) {
-	int nxgrid;
-	
-	nxgrid = naxo[na][no];
-	mpp_sum_int(1, &nxgrid);
-	if(nxgrid>0) {
-	  size_t start[4], nwrite[4];
-	  int *gdata_int;
-	  double *gdata_dbl;
-	  int fid, dim_string, dim_ncells, dim_two, dims[4];
-	  int id_xgrid_area, id_contact, n;
-	  int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;	  
-	  char contact[STRING];
-
-	  for(i=0; i<4; i++) {
-	    start[i] = 0; nwrite[i] = 1;
-	  }
-	  
-	  if(same_mosaic)
-	    sprintf(axo_file[nfile_axo], "atm_%s_%sXocn_%s_%s.nc", amosaic_name, atile_name[na], omosaic_name, otile_name[no]);
-	  else
-	    sprintf(axo_file[nfile_axo], "%s_%sX%s_%s.nc", amosaic_name, atile_name[na], omosaic_name, otile_name[no]);
-	  
-	  sprintf(contact, "%s:%s::%s:%s", amosaic_name, atile_name[na], omosaic_name, otile_name[no]);
-	  fid = mpp_open(axo_file[nfile_axo], MPP_WRITE);
-	  mpp_def_global_att(fid, "grid_version", grid_version);
-          mpp_def_global_att(fid, "code_version", tagname);
-	  mpp_def_global_att(fid, "history", history);
-	  dim_string = mpp_def_dim(fid, "string", STRING);
-	  dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
-	  dim_two    = mpp_def_dim(fid, "two", 2);
-	  if(interp_order == 2) {
-	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
-				   "contact_type", "exchange", "parent1_cell",
-				   "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
-				   "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	  }
-	  else {
-	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
-				   "contact_type", "exchange", "parent1_cell",
-				   "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area" );
-	  }
-	  dims[0] = dim_ncells; dims[1] = dim_two;
-	  id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-	  id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-	  id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-				      "exchange_grid_area", "units", "m2");
-	  if(interp_order == 2) {
-	    id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name",
-					"distance_from_parent1_cell_centroid");
-	    id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name",
-					"distance_from_parent2_cell_centroid");
-	  }
-	  mpp_end_def(fid);
-
-	  /* the index will start from 1, instead of 0 ( fortran index) */
-	  for(i = 0;i < naxo[na][no]; i++) {
-	    ++(atmxocn_ia[na][no][i]);
-	    ++(atmxocn_ja[na][no][i]);
-	    ++(atmxocn_io[na][no][i]);
-	    atmxocn_jo[na][no][i] += 1-ocn_south_ext; /* possible one artificial j-level is added at south end */
-	  }
-
-          nwrite[0] = strlen(contact);
-	  mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	
-	  nwrite[0] = nxgrid;
-
-	  gdata_int = (int *)malloc(nxgrid*sizeof(int));
-	  gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
-
-	  mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], gdata_dbl);
-	  if(check) {
-	    for(n=0; n<nxgrid; n++) axo_area_sum += gdata_dbl[n];
-	  }
-	  mpp_put_var_value_block(fid, id_xgrid_area, start, nwrite, gdata_dbl);
-	  mpp_gather_field_int(naxo[na][no], atmxocn_ia[na][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  mpp_gather_field_int(naxo[na][no], atmxocn_io[na][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  start[1] = 1;
-	  mpp_gather_field_int(naxo[na][no], atmxocn_ja[na][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  mpp_gather_field_int(naxo[na][no], atmxocn_jo[na][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  if(interp_order == 2) {
-	    start[1] = 0;
-  	    mpp_gather_field_double(naxo[na][no], atmxocn_dia[na][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	    mpp_gather_field_double(naxo[na][no], atmxocn_dio[na][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	    start[1] = 1;
-  	    mpp_gather_field_double(naxo[na][no], atmxocn_dja[na][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	    mpp_gather_field_double(naxo[na][no], atmxocn_djo[na][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	  }
-	  mpp_close(fid);
-     	  free(gdata_int);
-	  free(gdata_dbl);
-	  ++nfile_axo;
-	}
-      } /* end of no loop */
-      
-    } /* end of na loop */
-
-    /*release the memory */
-    for(na=0; na<ntile_atm; na++) {
-      for(nl=0; nl<ntile_lnd; nl++) {
-	free(atmxlnd_area[na][nl]);
-	free(atmxlnd_ia  [na][nl]);
-	free(atmxlnd_ja  [na][nl]);
-	free(atmxlnd_il  [na][nl]);
-	free(atmxlnd_jl  [na][nl]);
-	if(interp_order == 2) {
-	  free(atmxlnd_clon[na][nl]);
-	  free(atmxlnd_clat[na][nl]);
-	  free(atmxlnd_dia [na][nl]);
-	  free(atmxlnd_dja [na][nl]);
-	  free(atmxlnd_dil [na][nl]);
-	  free(atmxlnd_djl [na][nl]);
-	}
-      }
-      free(atmxlnd_area[na]);
-      free(atmxlnd_ia  [na]);
-      free(atmxlnd_ja  [na]);
-      free(atmxlnd_il  [na]);
-      free(atmxlnd_jl  [na]);
-      if(interp_order == 2) {
-	free(atmxlnd_clon[na]);
-	free(atmxlnd_clat[na]);
-	free(atmxlnd_dia [na]);
-	free(atmxlnd_dja [na]);
-	free(atmxlnd_dil [na]);
-	free(atmxlnd_djl [na]);
-      }
-      for(no=0; no<ntile_ocn; no++) {
-	free(atmxocn_area[na][no]);
-	free(atmxocn_ia  [na][no]);
-	free(atmxocn_ja  [na][no]);
-	free(atmxocn_io  [na][no]);
-	free(atmxocn_jo  [na][no]);
-	if(interp_order == 2) {
-	  free(atmxocn_clon[na][no]);
-	  free(atmxocn_clat[na][no]);
-	  free(atmxocn_dia [na][no]);
-	  free(atmxocn_dja [na][no]);
-	  free(atmxocn_dio [na][no]);
-	  free(atmxocn_djo [na][no]);
-	}
-      }
-      free(atmxocn_area[na]);
-      free(atmxocn_ia  [na]);
-      free(atmxocn_ja  [na]);
-      free(atmxocn_io  [na]);
-      free(atmxocn_jo  [na]);
-      if(interp_order == 2) {
-	free(atmxocn_clon[na]);
-	free(atmxocn_clat[na]);
-	free(atmxocn_dia [na]);
-	free(atmxocn_dja [na]);
-	free(atmxocn_dio [na]);
-	free(atmxocn_djo [na]);
-      }
-      free(naxl[na]);
-      free(naxo[na]);
-    }    
-    free(atmxlnd_area);
-    free(atmxlnd_ia  );
-    free(atmxlnd_ja  );
-    free(atmxlnd_il  );
-    free(atmxlnd_jl  );
-    free(atmxocn_area);
-    free(atmxocn_ia  );
-    free(atmxocn_ja  );
-    free(atmxocn_io  );
-    free(atmxocn_jo  );   
-    if(interp_order == 2) {
-      free(atmxlnd_clon);
-      free(atmxlnd_clat);
-      free(atmxlnd_dja );
-      free(atmxlnd_dia );
-      free(atmxlnd_dil );
-      free(atmxlnd_djl );
-      free(atmxocn_clon);
-      free(atmxocn_clat);
-      free(atmxocn_dia );
-      free(atmxocn_dja );
-      free(atmxocn_dio );
-      free(atmxocn_djo );
-    }
-    free(naxl);
-    free(naxo);
-  }
-  if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Complete the process to create exchange grids "
-				       "for fluxes between atmosphere and surface (sea ice and land)\n" );
-  
-  /***************************************************************************************
-     Then generate the exchange grid between land mosaic and ocean mosaic
-     if land mosaic is different from atmos mosaic
-  ***************************************************************************************/
-  nfile_lxo = 0;
-  if( !lnd_same_as_atm ) {
-    int     no, nl, ll, lo;
-    size_t  **nlxo;
-    int     ***lndxocn_il, ***lndxocn_jl, ***lndxocn_io, ***lndxocn_jo;
-    double  ***lndxocn_area, ***lndxocn_dil, ***lndxocn_djl, ***lndxocn_dio, ***lndxocn_djo;
-    double  ***lndxocn_clon, ***lndxocn_clat;
-    double  min_area;
-
-    nlxo         = (size_t ** )malloc(ntile_lnd*sizeof(size_t * ));
-    lndxocn_area = (double ***)malloc(ntile_lnd*sizeof(double **));
-    lndxocn_il   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-    lndxocn_jl   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-    lndxocn_io   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-    lndxocn_jo   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-    if(interp_order == 2) {
-      lndxocn_dil  = (double ***)malloc(ntile_lnd*sizeof(double **));
-      lndxocn_djl  = (double ***)malloc(ntile_lnd*sizeof(double **));
-      lndxocn_dio  = (double ***)malloc(ntile_lnd*sizeof(double **));
-      lndxocn_djo  = (double ***)malloc(ntile_lnd*sizeof(double **));
-      lndxocn_clon = (double ***)malloc(ntile_lnd*sizeof(double **));
-      lndxocn_clat = (double ***)malloc(ntile_lnd*sizeof(double **));
-    }
-    for(nl=0; nl<ntile_lnd; nl++) {
-      nlxo        [nl] = (size_t * )malloc(ntile_ocn*sizeof(size_t  ));
-      lndxocn_area[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-      lndxocn_il  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-      lndxocn_jl  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-      lndxocn_io  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-      lndxocn_jo  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-      if(interp_order == 2) {
-	lndxocn_dil [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	lndxocn_djl [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	lndxocn_dio [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	lndxocn_djo [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	lndxocn_clon[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	lndxocn_clat[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-      }
-      for(no=0; no<ntile_ocn; no++) {
-	lndxocn_area[nl][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	lndxocn_il  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	lndxocn_jl  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	lndxocn_io  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	lndxocn_jo  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));          
-	if(interp_order == 2 ) {  
-	  lndxocn_dil[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	  lndxocn_djl[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	  lndxocn_dio[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	  lndxocn_djo[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	  lndxocn_clon[nl][no] = (double *)malloc(MAXXGRID*sizeof(double *));
-	  lndxocn_clat[nl][no] = (double *)malloc(MAXXGRID*sizeof(double *));
-	}
-      }
-    }
- 
-    for(nl=0; nl<ntile_lnd; nl++) {
-      int      il, jl, io, jo, is, ie, js, je, layout[2];
-      int      n0, n1, n2, n3, nl_in, no_in, n_out, nxgrid;
-      double   xarea, xctrlon, xctrlat;
-      double   xl_min, yl_min, xo_min, yo_min, xl_avg;
-      double   xl_max, yl_max, xo_max, yo_max;
-      double   xl[MV], yl[MV], xo[MV], yo[MV], x_out[MV], y_out[MV];
-      domain2D Dom;
-
-      for(no=0; no<ntile_ocn; no++) nlxo[nl][no] = 0;
-      
-      layout[0] = mpp_npes();
-      layout[1] = 1;
-        
-      mpp_define_domain2d(nxl[nl]*nyl[nl], 1, layout, 0, 0, &Dom);
-      mpp_get_compute_domain2d(Dom, &is, &ie, &js, &je );
-      for(ll=is;ll<=ie;ll++) {
-	il = ll%nxl[nl];
-	jl = ll/nxl[nl];
-	n0 = jl    *(nxl[nl]+1) + il;
-	n1 = jl    *(nxl[nl]+1) + il+1;
-	n2 = (jl+1)*(nxl[nl]+1) + il+1;
-	n3 = (jl+1)*(nxl[nl]+1) + il;
-	xl[0] = xlnd[nl][n0]; yl[0] = ylnd[nl][n0];
-	xl[1] = xlnd[nl][n1]; yl[1] = ylnd[nl][n1];
-	xl[2] = xlnd[nl][n2]; yl[2] = ylnd[nl][n2];
-	xl[3] = xlnd[nl][n3]; yl[3] = ylnd[nl][n3];
-	yl_min  = minval_double(4, yl);
-	yl_max  = maxval_double(4, yl);
-	nl_in   = fix_lon(xl, yl, 4, M_PI);
-	xl_min  = minval_double(nl_in, xl);
-	xl_max  = maxval_double(nl_in, xl);
-	xl_avg  = avgval_double(nl_in, xl);      
-	for(no=0; no<ntile_ocn; no++) {
-	  for(jo = 0; jo < nyo[no]; jo++) for(io = 0; io < nxo[no]; io++) if(omask[no][jo*nxo[no]+io] > 0.5) {	
-	    n0 = jo    *(nxo[no]+1) + io;
-	    n1 = jo    *(nxo[no]+1) + io+1;
-	    n2 = (jo+1)*(nxo[no]+1) + io+1;
-	    n3 = (jo+1)*(nxo[no]+1) + io;
-	    xo[0] = xocn[no][n0]; yo[0] = yocn[no][n0];
-	    xo[1] = xocn[no][n1]; yo[1] = yocn[no][n1];
-	    xo[2] = xocn[no][n2]; yo[2] = yocn[no][n2];
-	    xo[3] = xocn[no][n3]; yo[3] = yocn[no][n3];
-	    yo_min = minval_double(4, yo);
-	    yo_max = maxval_double(4, yo);
-            if(yo_min >= yl_max || yo_max <= yl_min ) continue;	    
-	    no_in  = fix_lon(xo, yo, 4, xl_avg);
-	    xo_min = minval_double(no_in, xo);
-	    xo_max = maxval_double(no_in, xo);
-	    /* xo should in the same range as xa after lon_fix, so no need to
-	       consider cyclic condition
-	    */
-	    if(xl_min >= xo_max || xl_max <= xo_min ) continue;
-	    if (  (n_out = clip_2dx2d( xl, yl, nl_in, xo, yo, no_in, x_out, y_out )) > 0 ){
-	      xarea = poly_area(x_out, y_out, n_out );
-	      min_area = min(area_ocn[no][jo*nxo[no]+io], area_lnd[nl][ll] );
-	      if(xarea/min_area > AREA_RATIO_THRESH ) {
-		lndxocn_area[nl][no][nlxo[nl][no]] = xarea;
-		lndxocn_io[nl][no][nlxo[nl][no]]   = io;
-		lndxocn_jo[nl][no][nlxo[nl][no]]   = jo;
-		lndxocn_il[nl][no][nlxo[nl][no]]   = il;
-		lndxocn_jl[nl][no][nlxo[nl][no]]   = jl;
-		if(interp_order == 2) {
-		  lndxocn_clon[nl][no][nlxo[nl][no]] = poly_ctrlon ( x_out, y_out, n_out, xl_avg);
-		  lndxocn_clat[nl][no][nlxo[nl][no]] = poly_ctrlat ( x_out, y_out, n_out );
-		}
-		++(nlxo[nl][no]);
-		if(nlxo[nl][no] > MAXXGRID) mpp_error("nlxo is greater than MAXXGRID, increase MAXXGRID");
-	      }
-	    }
-	  } /* end of io, jo loop */
-	} 
-      } /* end of ll( or il, jl) loop */
-      mpp_delete_domain2d(&Dom);
-    }/* for(nl=0; nl<ntile_lnd; nl++) */
-
-    /* calculate the centroid of model grid. */
-    if(interp_order == 2) {
-      double *l_area, *l_clon, *l_clat;
-      double **o_area, **o_clon, **o_clat;
- 
-      o_area = (double **)malloc(ntile_ocn*sizeof(double *));
-      o_clon = (double **)malloc(ntile_ocn*sizeof(double *));
-      o_clat = (double **)malloc(ntile_ocn*sizeof(double *));
-      for(no =0; no<ntile_ocn; no++) {
-	o_area[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	o_clon[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	o_clat[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	  o_area[no][lo] = 0;
-	  o_clon[no][lo] = 0;
-	  o_clat[no][lo] = 0;
-	}
-      }
-
-      for(nl=0; nl<ntile_lnd; nl++) {
-	l_area = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	l_clon = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	l_clat = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	  l_area[ll] = 0;
-	  l_clon[ll] = 0;
-	  l_clat[ll] = 0;
-	}
-
-	for(no=0; no<ntile_ocn; no++) {
-	  int nxgrid;
-	  nxgrid = nlxo[nl][no];
-	  mpp_sum_int(1, &nxgrid);
-	  if(nxgrid > 0) {
-	    double *g_area, *g_clon, *g_clat;
-	    int    *g_il,   *g_jl,   *g_io, *g_jo;
-	    int    ii;
-	    g_il = (int    *)malloc(nxgrid*sizeof(int   ));
-	    g_jl = (int    *)malloc(nxgrid*sizeof(int   ));
-	    g_io = (int    *)malloc(nxgrid*sizeof(int   ));
-	    g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
-	    g_area = (double *)malloc(nxgrid*sizeof(double));
-	    g_clon = (double *)malloc(nxgrid*sizeof(double));
-	    g_clat = (double *)malloc(nxgrid*sizeof(double));
-	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_il[nl][no], g_il);
-	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_jl[nl][no], g_jl);
-	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_io[nl][no], g_io);
-	    mpp_gather_field_int   (nlxo[nl][no], lndxocn_jo[nl][no], g_jo);
-	    mpp_gather_field_double(nlxo[nl][no], lndxocn_area[nl][no], g_area);
-	    mpp_gather_field_double(nlxo[nl][no], lndxocn_clon[nl][no], g_clon);
-	    mpp_gather_field_double(nlxo[nl][no], lndxocn_clat[nl][no], g_clat);
-	    for(i=0; i<nxgrid; i++) {	      
-	      ii = g_jl[i]*nxl[nl]+g_il[i];
-	      l_area[ii] += g_area[i];
-	      l_clon[ii] += g_clon[i];
-	      l_clat[ii] += g_clat[i];
-	      ii = g_jo[i]*nxo[no]+g_io[i];
-	      o_area[no][ii] += g_area[i];
-	      o_clon[no][ii] += g_clon[i];
-	      o_clat[no][ii] += g_clat[i];
-	    }
-	    free(g_il);
-	    free(g_jl);
-	    free(g_io);
-	    free(g_jo);
-	    free(g_area);
-	    free(g_clon);
-	    free(g_clat);
-	  }
-	}
-	for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	  if(l_area[ll] > 0) {
-	    l_clon[ll] /= l_area[ll];
-	    l_clat[ll] /= l_area[ll];
-	  }
-	}
-	/* substract land centroid to get the centroid distance between land grid and exchange grid. */
-	for(no=0; no<ntile_ocn; no++) {
-	  for(i=0; i<nlxo[nl][no]; i++) {
-	    ll = lndxocn_jl[nl][no][i]*nxl[nl] + lndxocn_il[nl][no][i];
-	    lndxocn_dil[nl][no][i] = lndxocn_clon[nl][no][i]/lndxocn_area[nl][no][i] - l_clon[ll];
-	    lndxocn_djl[nl][no][i] = lndxocn_clat[nl][no][i]/lndxocn_area[nl][no][i] - l_clat[ll];
-	  }
-	}
-	
-	free(l_area);
-	free(l_clon);
-	free(l_clat);	
-      }
-
-      /* centroid distance from exchange grid to ocean grid */
-      for(no=0; no<ntile_ocn; no++) {
-	for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	  if(o_area[no][lo] > 0) {
-	    o_clon[no][lo] /= o_area[no][lo];
-	    o_clat[no][lo] /= o_area[no][lo];
-	  }
-	}
-	for(nl=0; nl<ntile_lnd; nl++) {
-	  for(i=0; i<nlxo[nl][no]; i++) {
-	    lo = lndxocn_jo[nl][no][i]*nxo[no] + lndxocn_io[nl][no][i];
-	    lndxocn_dio[nl][no][i] = lndxocn_clon[nl][no][i]/lndxocn_area[nl][no][i] - o_clon[no][lo];
-	    lndxocn_djo[nl][no][i] = lndxocn_clat[nl][no][i]/lndxocn_area[nl][no][i] - o_clat[no][lo];
-	  }
-	}
-	free(o_area[no]);
-	free(o_clon[no]);
-	free(o_clat[no]);
-      }
-
-      free(o_area);
-      free(o_clon);
-      free(o_clat);
-    }
-
-    /* write out lndXocn data */
-    for(nl = 0; nl < ntile_lnd; nl++) {
-       for(no = 0; no < ntile_ocn; no++) {
-	 int nxgrid;
-	 
-	/* get total number of exchange grid on all the pes */
-	 nxgrid = nlxo[nl][no];
-	mpp_sum_int(1, &nxgrid);
-	
-	if(nxgrid >0) {
-	  size_t start[4], nwrite[4];
-	  int *gdata_int;
-	  double *gdata_dbl;
-	  
-	  char contact[STRING];
-	  int fid, dim_string, dim_ncells, dim_two, dims[4];
-	  int id_contact, id_xgrid_area, n;
-	  int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-
-	  for(i=0; i<4; i++) {
-	    start[i] = 0; nwrite[i] = 1;
-	  }	  	  
-	  
-	  if(same_mosaic)
-	    sprintf(lxo_file[nfile_lxo], "lnd_%s_%sXocn_%s_%s.nc", lmosaic_name, ltile_name[nl], omosaic_name, otile_name[no]);
-	  else
-	    sprintf(lxo_file[nfile_lxo], "%s_%sX%s_%s.nc", lmosaic_name, ltile_name[nl], omosaic_name, otile_name[no]);
-	  sprintf(contact, "%s:%s::%s:%s", lmosaic_name, ltile_name[nl], omosaic_name, otile_name[no]);
-
-	  fid = mpp_open(lxo_file[nfile_lxo], MPP_WRITE);
-	  mpp_def_global_att(fid, "grid_version", grid_version);
-          mpp_def_global_att(fid, "code_version", tagname);
-	  mpp_def_global_att(fid, "history", history);
-	  dim_string = mpp_def_dim(fid, "string", STRING);
-	  dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
-	  dim_two    = mpp_def_dim(fid, "two", 2);
-	  if(interp_order == 2) {
-	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
-				     "contact_type", "exchange", "parent1_cell",
-				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
-				     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	  }
-	  else {
-	    id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
-				     "contact_type", "exchange", "parent1_cell",
-				     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area" );
-	  }
-	  dims[0] = dim_ncells; dims[1] = dim_two;
-	  id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent1_cell_indices");
-	  id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent2_cell_indices");
-	  id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-				      "exchange_grid_area", "units", "m2");
-
-	  if(interp_order == 2) {
-	    id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-	    id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-	  }
-	  mpp_end_def(fid);
-
-	  /* the index will start from 1, instead of 0 ( fortran index) */
-	  for(i = 0;i < nlxo[nl][no]; i++) {
-	    ++(lndxocn_il[nl][no][i]);
-	    ++(lndxocn_jl[nl][no][i]);
-	    ++(lndxocn_io[nl][no][i]);
-	    lndxocn_jo[nl][no][i] += 1 - ocn_south_ext; /* one artificial j-level may be added in the south end */
-	  }
-
-	  nwrite[0] = strlen(contact);
-	  mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	  nwrite[0] = nxgrid;
-
-	  gdata_int = (int *)malloc(nxgrid*sizeof(int));
-	  gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
-
-	  mpp_gather_field_double(nlxo[nl][no], lndxocn_area[nl][no], gdata_dbl);
-	  mpp_put_var_value(fid, id_xgrid_area, gdata_dbl);
-	  mpp_gather_field_int(nlxo[nl][no], lndxocn_il[nl][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  mpp_gather_field_int(nlxo[nl][no], lndxocn_io[nl][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  start[1] = 1;
-	  mpp_gather_field_int(nlxo[nl][no], lndxocn_jl[nl][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	  mpp_gather_field_int(nlxo[nl][no], lndxocn_jo[nl][no], gdata_int);
-	  mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	  if(interp_order == 2) {
-	    start[1] = 0;
-  	    mpp_gather_field_double(nlxo[nl][no], lndxocn_dil[nl][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	    mpp_gather_field_double(nlxo[nl][no], lndxocn_dio[nl][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	    start[1] = 1;
-  	    mpp_gather_field_double(nlxo[nl][no], lndxocn_djl[nl][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-	    mpp_gather_field_double(nlxo[nl][no], lndxocn_djo[nl][no], gdata_dbl);
-	    mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	  }
-	  mpp_close(fid);
-	  free(gdata_int);
-	  free(gdata_dbl);
-	  ++nfile_lxo;
-	}
-       } /* for(no=0; no<ntile_ocn; no++) */
-    } /* for(nl=0; nl<ntile_lnd; nl++) */
-
-    /* release the memory */
-    for(nl=0; nl<ntile_lnd; nl++) {
-      for(no=0; no<ntile_ocn; no++) {
-	free(lndxocn_area[nl][no]);
-	free(lndxocn_il  [nl][no]);
-	free(lndxocn_jl  [nl][no]);
-	free(lndxocn_io  [nl][no]);
-	free(lndxocn_jo  [nl][no]);
-	if(interp_order == 2) {
-	  free(lndxocn_clon[nl][no]);
-	  free(lndxocn_clat[nl][no]);
-	  free(lndxocn_dil [nl][no]);
-	  free(lndxocn_djl [nl][no]);
-	  free(lndxocn_dio [nl][no]);
-	  free(lndxocn_djo [nl][no]);
-	}
-      }
-      free(lndxocn_area[nl]);
-      free(lndxocn_il  [nl]);
-      free(lndxocn_jl  [nl]);
-      free(lndxocn_io  [nl]);
-      free(lndxocn_jo  [nl]);
-      if(interp_order == 2) {
-	free(lndxocn_clon[nl]);
-	free(lndxocn_clat[nl]);
-	free(lndxocn_dil [nl]);
-	free(lndxocn_djl [nl]);
-	free(lndxocn_dio [nl]);
-	free(lndxocn_djo [nl]);
-      }
-      free(nlxo[nl]);
-    }
-    free(nlxo);
-    free(lndxocn_area);
-    free(lndxocn_il  );
-    free(lndxocn_jl  );
-    free(lndxocn_io  );
-    free(lndxocn_jo  );   
-    if(interp_order == 2) {
-      free(lndxocn_clon);
-      free(lndxocn_clat);
-      free(lndxocn_dil );
-      free(lndxocn_djl );
-      free(lndxocn_dio );
-      free(lndxocn_djo );
-    }
-
-    if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Complete the process to create exchange grids "
-					 "for runoff between land and sea ice.\n" );
-  }
-  else {
-    nfile_lxo = nfile_axo;
-    for(i=0; i<nfile_axo; i++) strcpy(lxo_file[i], axo_file[i]);
-    if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Since lmosaic is the same as amosaic, "
-					 "no need to compute the exchange grid between lmosaic and omosaic, "
-					 "simply use the exchange grid between amosaic and omosaic.\n");    
-  }
-
-  if(mpp_pe() == mpp_root_pe()) {
-    int n, i;
-    double axo_area_frac;
-    double axl_area_frac;
-    double tiling_area;
-    double *atm_area;
-    double atm_area_sum;
-
-    if(check) {
-      /* for cubic grid, when number of model points is odd, some grid cell area will be negative,
-	 need to think about how to solve this issue in the future */
-      /*      atm_area_sum = 4*M_PI*RADIUS*RADIUS; */
-      atm_area_sum = 0;
-      for(n=0; n<ntile_atm; n++) {
-	atm_area = (double *)malloc(nxa[n]*nya[n]*sizeof(double));
-	get_grid_area(&nxa[n], &nya[n], xatm[n], yatm[n], atm_area);
-	for(i=0; i<nxa[n]*nya[n]; i++) atm_area_sum += atm_area[i];
-	free(atm_area);
-      }
-      axo_area_frac = axo_area_sum/atm_area_sum*100;
-      axl_area_frac = axl_area_sum/atm_area_sum*100;
-      tiling_area   = (atm_area_sum-axo_area_sum-axl_area_sum)/atm_area_sum*100;    
-      printf("\nNOTE: axo_area_sum is %f and ocean fraction is %f%%\n", axo_area_sum, axo_area_frac);
-      printf("NOTE: axl_area_sum is %f and land  fraction is %f%%\n", axl_area_sum, axl_area_frac);
-      printf("NOTE: tiling error is %f%%\n", tiling_area );
-    }
-  }
-  
-  /*Fianlly create the coupler mosaic file mosaic_name.nc */
-  {
-    int fid, dim_string, dim_axo, dim_lxo, dim_axl, dims[4], n;
-    size_t start[4], nwrite[4];
-    int id_lmosaic_dir, id_lmosaic_file, id_omosaic_dir, id_omosaic_file;
-    int id_amosaic_dir, id_amosaic_file, id_otopog_dir, id_otopog_file;
-    int id_xgrids_dir, id_axo_file, id_lxo_file, id_axl_file;
-    int id_amosaic, id_lmosaic, id_omosaic;
-    
-    fid = mpp_open(mosaic_file, MPP_WRITE);
-    mpp_def_global_att(fid, "grid_version", grid_version);
-    mpp_def_global_att(fid, "code_version", tagname);
-    mpp_def_global_att(fid, "history", history);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-    dim_axo = mpp_def_dim(fid, "nfile_aXo", nfile_axo);
-    dim_axl = mpp_def_dim(fid, "nfile_aXl", nfile_axl);
-    dim_lxo = mpp_def_dim(fid, "nfile_lXo", nfile_lxo);
-    id_amosaic_dir  = mpp_def_var(fid, "atm_mosaic_dir", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "directory_storing_atmosphere_mosaic");
-    id_amosaic_file = mpp_def_var(fid, "atm_mosaic_file", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "atmosphere_mosaic_file_name");
-    id_amosaic      = mpp_def_var(fid, "atm_mosaic", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "atmosphere_mosaic_name");
-    id_lmosaic_dir  = mpp_def_var(fid, "lnd_mosaic_dir", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "directory_storing_land_mosaic");
-    id_lmosaic_file = mpp_def_var(fid, "lnd_mosaic_file", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "land_mosaic_file_name");
-    id_lmosaic      = mpp_def_var(fid, "lnd_mosaic", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "land_mosaic_name");        
-    id_omosaic_dir  = mpp_def_var(fid, "ocn_mosaic_dir", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "directory_storing_ocean_mosaic");
-    id_omosaic_file = mpp_def_var(fid, "ocn_mosaic_file", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "ocean_mosaic_file_name");
-    id_omosaic      = mpp_def_var(fid, "ocn_mosaic", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "ocean_mosaic_name");    
-    id_otopog_dir   = mpp_def_var(fid, "ocn_topog_dir", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "directory_storing_ocean_topog");
-    id_otopog_file  = mpp_def_var(fid, "ocn_topog_file", MPP_CHAR, 1, &dim_string,
-				  1, "standard_name", "ocean_topog_file_name");
-    /* since exchange grid is created in this tool, we may add command line option to specify where to store the output */
-    /*    id_xgrids_dir = mpp_def_var(fid, "xgrids_dir", MPP_CHAR, 1, &dim_string,
-	  1, "standard_name", "directory_storing_xgrids"); */
-    dims[0] = dim_axo; dims[1] = dim_string;
-    id_axo_file = mpp_def_var(fid, "aXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXocn_exchange_grid_file");
-    dims[0] = dim_axl; dims[1] = dim_string;
-    id_axl_file = mpp_def_var(fid, "aXl_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXlnd_exchange_grid_file");
-    dims[0] = dim_lxo; dims[1] = dim_string;
-    id_lxo_file = mpp_def_var(fid, "lXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "lndXocn_exchange_grid_file");
-    mpp_end_def(fid);
-    for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; }
-    
-    nwrite[0] = strlen(amosaic_dir);
-    mpp_put_var_value_block(fid, id_amosaic_dir, start, nwrite, amosaic_dir);
-    nwrite[0] = strlen(amosaic_file);
-    mpp_put_var_value_block(fid, id_amosaic_file, start, nwrite, amosaic_file);
-    nwrite[0] = strlen(amosaic_name);
-    mpp_put_var_value_block(fid, id_amosaic, start, nwrite, amosaic_name);
-    nwrite[0] = strlen(lmosaic_dir);
-    mpp_put_var_value_block(fid, id_lmosaic_dir, start, nwrite, lmosaic_dir);
-    nwrite[0] = strlen(lmosaic_file);
-    mpp_put_var_value_block(fid, id_lmosaic_file, start, nwrite, lmosaic_file);
-    nwrite[0] = strlen(lmosaic_name);
-    mpp_put_var_value_block(fid, id_lmosaic, start, nwrite, lmosaic_name);
-    nwrite[0] = strlen(omosaic_dir);
-    mpp_put_var_value_block(fid, id_omosaic_dir, start, nwrite, omosaic_dir);
-    nwrite[0] = strlen(omosaic_file);
-    mpp_put_var_value_block(fid, id_omosaic_file, start, nwrite, omosaic_file);
-    nwrite[0] = strlen(omosaic_name);
-    mpp_put_var_value_block(fid, id_omosaic, start, nwrite, omosaic_name);
-    nwrite[0] = strlen(otopog_dir);
-    mpp_put_var_value_block(fid, id_otopog_dir, start, nwrite, otopog_dir);
-    nwrite[0] = strlen(otopog_file);
-    mpp_put_var_value_block(fid, id_otopog_file, start, nwrite, otopog_file);
-    nwrite[0] = 1;
-
-    for(n=0; n<nfile_axo; n++) {
-      start[0] = n; nwrite[1] = strlen(axo_file[n]);
-      mpp_put_var_value_block(fid, id_axo_file, start, nwrite, axo_file[n]);
-    }
-    for(n=0; n<nfile_axl; n++) {
-      start[0] = n; nwrite[1] = strlen(axl_file[n]);
-      mpp_put_var_value_block(fid, id_axl_file, start, nwrite, axl_file[n]);
-    }
-    for(n=0; n<nfile_lxo; n++) {
-      start[0] = n; nwrite[1] = strlen(lxo_file[n]);
-      mpp_put_var_value_block(fid, id_lxo_file, start, nwrite, lxo_file[n]);
-    }    
-    mpp_close(fid);
-  }
-  
-  if(mpp_pe()== mpp_root_pe())printf("\n***** Congratulation! You have successfully run make_coupler_mosaic\n");
-  mpp_end();
-
-  return 0;
-  
-} /* main */
-
-
diff --git a/gridspec_tools_20080702/tools/make_hgrid/Makefile.am b/gridspec_tools_20080702/tools/make_hgrid/Makefile.am
deleted file mode 100644
index 5583a38..0000000
--- a/gridspec_tools_20080702/tools/make_hgrid/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec make_hgrid
-# tools.
-
-# $Id: Makefile.am,v 1.3 2009/04/04 11:22:53 ed Exp $
-
-bin_PROGRAMS = make_hgrid gs_make_hgrid
-make_hgrid_SOURCES = make_hgrid.c create_conformal_cubic_grid.c		\
-create_gnomonic_cubic_grid.c create_grid_from_file.c create_hgrid.h	\
-create_lonlat_grid.c
-gs_make_hgrid_SOURCES = gs_make_hgrid.c create_conformal_cubic_grid.c	\
-create_gnomonic_cubic_grid.c create_grid_from_file.c create_hgrid.h	\
-create_lonlat_grid.c
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/make_hgrid/create_conformal_cubic_grid.c b/gridspec_tools_20080702/tools/make_hgrid/create_conformal_cubic_grid.c
deleted file mode 100644
index b044ea7..0000000
--- a/gridspec_tools_20080702/tools/make_hgrid/create_conformal_cubic_grid.c
+++ /dev/null
@@ -1,814 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <complex.h>
-#include <math.h>
-#include "mosaic_util.h"
-#include "tool_util.h"
-#include "constant.h"
-#include "create_hgrid.h"
-#define  D2R (M_PI/180.)
-#define  R2D (180./M_PI)
-/*********************************************************************************
-   some private routines used in this file
-*********************************************************************************/
-void calc_geocoords_centerpole(int nx, int ny, double *x, double *y);
-void conformal_map_coords2xyz ( int ni, int nj, double *lx, double *ly, double *X, double *Y, double *Z );
-void map_xyz2lonlat(int ni, int nj, double *X, double *Y, double *Z, double *lon, double *lat );
-void rotate_about_xaxis(int ni, int nj, double *X, double *Y, double *Z, double angle);
-void permutiles(int ni, int nj, double *b, int num);
-void calc_fvgrid(int nx, int ny, int nratio, double *dx, double *dy, double *area);
-double* angle_between_vectors(int ni, int nj, double *vec1, double *vec2);
-double* excess_of_quad(int ni, int nj, double *vec1, double *vec2, double *vec3, double *vec4 );
-double* plane_normal(int ni, int nj, double *P1, double *P2);
-void calc_rotation_angle(int nxp, int nyp, double *x, double *y, double *angle_dx, double *angle_dy);
-
-
-/*******************************************************************************
-  void create_conformal_cubic_grid( int *npoints, int *nratio, char *method, char *orientation, double *x,
-                          double *y, double *dx, double *dy, double *area, double *angle_dx,
-                          double *angle_dy )
-  create cubic grid. All six tiles grid will be generated.
-*******************************************************************************/
-void create_conformal_cubic_grid( int *npts, int *nratio, char *method, char *orientation, double *x,
-			double *y, double *dx, double *dy, double *area, double *angle_dx,
-			double *angle_dy )
-{
-  int nx, ny, nxp, nyp;
-
-  nx  = *npts;
-  ny  = nx;
-  nxp = nx+1;
-  nyp = nxp;
-  
-  /*calculate geographic coordinates. */
-  if(strcmp(orientation, "center_pole") == 0)
-    calc_geocoords_centerpole(nx, ny, x, y);
-  else
-    mpp_error("create_cubic_grid: only center pole orientation is implemented");  
-
-  /* calculate cell length and area */
-  calc_fvgrid(nx, ny, *nratio, dx, dy, area);  
-
-  /*calculate rotation angle, just some workaround, will modify this in the future. */
-  calc_rotation_angle(nxp, nyp, x, y, angle_dx, angle_dy );
-  
-}; /* create_conformal_cubic_grid */
-
-/***********************************************************************
-   calc_geoocoords_centerpole(int nx, int ny, double *x, double *y);
-calculate geographic coordinates for all six tiles.
-
-***********************************************************************/
-void calc_geocoords_centerpole(int nx, int ny, double *x, double *y)
-{
-  int i, j, n, m, nxp, nyp, nxh, nyh;
-  double *lx, *ly, *X, *Y, *Z, *lonP, *latP, *lonE, *latE, *tmp;
-
-  nxp = nx+1;
-  nyp = ny+1;
-  nxh = (nxp+1)/2;
-  nyh = (nyp+1)/2;  
-  
-  lx = (double *)malloc(nxh*nyh*sizeof(double));
-  ly = (double *)malloc(nxh*nyh*sizeof(double));
-
-  n = 0;
-  for(j=0; j<nyh; j++) {
-    for(i=0; i<nxh; i++) {
-      lx[n] = -1. + 2.0*i/(nxp-1);
-      ly[n++] = -1. + 2.0*j/(nyp-1);
-    }
-  } 
-
-  X = (double *)malloc(nxh*nyh*sizeof(double));
-  Y = (double *)malloc(nxh*nyh*sizeof(double));
-  Z = (double *)malloc(nxh*nyh*sizeof(double));
-
-  /* calculating 3D coordinates on unit sphere */
-  conformal_map_coords2xyz( nxh, nyh, lx, ly, X, Y, Z);
-
-  lonP = (double *) malloc(nxp*nyp*sizeof(double));
-  latP = (double *) malloc(nxp*nyp*sizeof(double));
-  lonE = (double *) malloc(nxp*nyp*sizeof(double));
-  latE = (double *) malloc(nxp*nyp*sizeof(double));
-  
-  /* map 3D coordinates to geographical coordinates. */
-  map_xyz2lonlat( nxh, nyh, X, Y, Z, lx, ly );
-
-  /* coyy data from lx, ly to lonP and latP */
-  for(j=0;j<nyh;j++) {
-    for(i=0; i<nxh; i++) {
-      lonP[j*nxp+i] = lx[j*nxh+i];
-      latP[j*nxp+i] = ly[j*nxh+i];
-    }
-  }
-
-  /* enforce symmetry */
-  for(j=0;j<nyh;j++) {
-    for(i=0; i<nxh; i++) {
-      if( i<j )
-	latP[j*nxp+i] = 0.5*(latP[j*nxp+i] + latP[i*nxp+j]);
-      else
-	latP[j*nxp+i] = latP[i*nxp+j];       
-      if(lonP[j*nxp+i] >= M_PI ) lonP[j*nxp+i] -= 2*M_PI;
-    }
-  }
-
-  tmp = (double *) malloc(nxh*nyh*sizeof(double));
-  n = 0;
-  for(j=0; j<nyh; j++)
-    for(i=0; i<nxh; i++) tmp[n++] = lonP[j*nxp+i];
-
-  for(j=0;j<nyh;j++) {  
-    for(i=0; i<nxh; i++) {
-      lonP[j*nxp+i] = (tmp[j*nxh+i]-3./2.*M_PI-tmp[i*nxh+j])*0.5;
-      if(i==j) lonP[j*nxp+i] = -3.0/4.0*M_PI;
-    }
-  }
-
-  free(tmp);
-  
-  /*use symmetry to expand to full cubic */
-  for(j=0;j<nyh;j++) {
-    for(i=nxh;i<nxp; i++) {
-      lonP[j*nxp+i] = -M_PI-lonP[j*nxp+nxp-i-1];
-      latP[j*nxp+i] = latP[j*nxp+nxp-i-1];
-    }
-  }
-
-  for(j=nyh; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      lonP[j*nxp+i] = -lonP[(nyp-j-1)*nxp+i];
-      latP[j*nxp+i] = latP[(nyp-j-1)*nxp+i];
-    }
-  }       
-
-  rotate_about_xaxis(nxh, nyh, X, Y, Z, M_PI/2);   
-
-  map_xyz2lonlat( nxh, nyh, X, Y, Z, lx, ly );
-
-  /* coyy data from lx, ly to lonE and latE */
-  for(j=0;j<nyh;j++) {
-    for(i=0; i<nxh; i++) {
-      lonE[j*nxp+i] = lx[j*nxh+i];
-      latE[j*nxp+i] = ly[j*nxh+i];
-    }
-  }
-  
-  free(lx);
-  free(ly);
-  
-  /* enforce symmetry */
-  for(j=0;j<nyh;j++) lonE[j*nxp] = -3./4.*M_PI;
-  for(i=0;i<nxh;i++) {
-    latE[(nyh-1)*nxp+i] = 0;
-    latE[i]    = -latP[i];
-  }
-  /*use symmetry to expand to full cube. */
-  for(j=0;j<nxh; j++) {
-    for(i=nxh;i<nxp;i++) {
-      lonE[j*nxp+i] = -M_PI-lonE[j*nxp+nxp-i-1];
-      latE[j*nxp+i] = latE[j*nxp+nxp-i-1];
-    }
-  }
-
-  for(j=nyh; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      lonE[j*nxp+i] = lonE[(nyp-j-1)*nxp+i];
-      latE[j*nxp+i] = -latE[(nyp-j-1)*nxp+i];
-    }
-  }      
-
-  /*convert to geographic grid */
-  n = 0;
-  /* tile 1 */
-  for(m = 0; m < nxp*nyp; m++) { 
-    x[n] = lonE[m]*R2D-90.;
-    if(x[n]<=-180.) x[n] += 360.;
-    y[n++] = latE[m]*R2D;
-  }
-
-  /* tile 2 */
-  for(m = 0; m < nxp*nyp; m++) {
-    x[n] = lonE[m]*R2D;
-    y[n++] = latE[m]*R2D;
-  }
-
-  /* tile 3 */
-  for(m = 0; m < nxp*nyp; m++) {
-    x[n] = lonP[m]*R2D;
-    y[n++] = latP[m]*R2D;
-  }
-    
-  /* tile 4 */
-  for(j=0; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      x[n] = lonE[i*nxp+j]*R2D+90.;
-      y[n++] = latE[(nxp-i-1)*nxp+j]*R2D;
-    }
-  }
-
-  /* tile 5 */
-  for(j=0; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      x[n] = lonE[i*nxp+j]*R2D+180.;
-      y[n++] = latE[(nxp-i-1)*nxp+j]*R2D;
-    }
-  }
-
-  /* tile 6 */
-  for(j=0; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      x[n] = lonP[(nxp-i-1)*nxp+nyp-j-1]*R2D;
-      y[n++] = -latP[j*nxp+i]*R2D;
-    }
-  }
-
-  permutiles(nxp, nyp, x,2);
-  permutiles(nxp, nyp, y,2);
-
-}; /*calc_geocords_centerpole */
-
-/*************************************************************************
-  void conformal_map_coords2xyz ( double *lx, double * ly, double *X, double *Y, double *Z )
-  Conformal mapping of a cube onto a sphere maps (lx, ly) on the north-pole face of a cube
-  to (X,Y,Z) coordinates in physical space. 
-  Face is oriented normal to Z-axis with  X and Y increasing with lx and ly
-  valid ranges:  -1 < lx < 1   -1 < ly < 1
-  Based on matlab scripts from Alistair  ???? 
-**************************************************************************/
-  
-void conformal_map_coords2xyz ( int ni, int nj, double *lx, double *ly,
-     				   double *X, double *Y, double *Z )
-{
-  const double RA = sqrt(3.)-1;
-  const double THRD = 1./3.;
-  const complex CB = -1. + I;
-  const complex CC = RA*CB/2.;
-  const int order = 29;
-  const double A[] = { 1.47713057321600,
-		       -0.38183513110512,
-		       -0.05573055466344,
-		       -0.01895884801823,
-		       -0.00791314396396,
-		       -0.00486626515498,
-		       -0.00329250387158,
-		       -0.00235482619663,
-		       -0.00175869000970,
-		       -0.00135682443774,
-		       -0.00107458043205,
-		       -0.00086946107050,
-		       -0.00071604933286,
-		       -0.00059869243613,
-		       -0.00050696402446,
-		       -0.00043418115349,
-		       -0.00037537743098,
-		       -0.00032745130951,
-		       -0.00028769063795,
-		       -0.00025464473946,
-		       -0.00022659577923,
-		       -0.00020297175587,
-		       -0.00018247947703,
-		       -0.00016510295548,
-		       -0.00014967258633,
-		       -0.00013660647356,
-		       -0.00012466390509,
-		       -0.00011468147908,
-		       -0.00010518717478,
-		       -0.00009749136078,
-  };
-  complex w, zc,a,b;
-  int i, j, n, m;
-  double xc, yc, h, t;
-  size_t *dims;
-
-  for(n=0; n< ni*nj; n++) {
-    xc = fabs(lx[n]);
-    yc = fabs(ly[n]);
-    X[n] = xc;
-    Y[n] = yc;
-    xc   = 1 - xc;
-    yc   = 1 - yc;
-    if(fabs(ly[n]) > fabs(lx[n]) ) {
-      xc = 1-Y[n];
-      yc = 1-X[n];
-    }
-    zc  = cpow((xc+I*yc)/2.,4);
-    /*Evaluate the Taylor series.  */
-    w = 0;
-
-    for(m=order; m>=0; m--) w = ( w + A[m] ) * zc;
-    if( w != 0. ) w =  cpow(I,THRD) * cpow( w*I, THRD);
-    w = (w-RA)/(CB+CC*w);
-    X[n] = creal(w);  
-    Y[n] = cimag(w);
-    h    = 2./(1+cpow(X[n],2)+cpow(Y[n],2));
-    X[n] = X[n]*h;
-    Y[n] = Y[n]*h;
-    Z[n] = h-1;
-  }
-
-  for(n=0; n< ni*nj; n++) {
-    if(fabs(ly[n]) > fabs(lx[n]) ) {
-      t = X[n];
-      X[n] = Y[n];
-      Y[n] = t;
-    }
-
-    if(lx[n]<0)  X[n] = -X[n];
-    if(lx[n]==0) X[n] = 0;
-    if(ly[n]<0)  Y[n] = -Y[n];
-    if(ly[n]==0) Y[n] = 0;
-  }
-
-}; /* conformal_map_coords2xyz */
-
-
-
-/**********************************************************
-  Convert 3-D coordinates (x,y,z) to (lon,lat)
-  Assumes "lat" is positive with "z", equatorial plane
-  falls at z=0  and "lon" is measured anti-clockwise (eastward)
-  from x-axis (y=0) about z-axis.
-
-************************************************************/
-
-void map_xyz2lonlat(int ni, int nj, double *X, double *Y, double *Z, 
-		    double *lon, double *lat )
-{
-  int i, j, n;
-  double req;
-
-  for(n=0; n<ni*nj; n++) {
-    /*latitude */
-    req = sqrt(X[n]*X[n]+Y[n]*Y[n]);
-    if( req == 0)
-      if(Z[n] == 0 )
-	lat[n] = 0.;
-      else
-        lat[n] = M_PI*0.5;
-    else
-      lat[n] = atan( Z[n]/req );
-
-    /*longitude */
-    if(X[n] == 0)
-      lon[n] = M_PI*0.5;
-    else
-      lon[n] = atan(Y[n]/X[n]);
-
-    if(X[n]<0 && Y[n] >=0) lon[n] += M_PI;
-    if(X[n]<=0 && Y[n] < 0) lon[n] -= M_PI;
-  }
-  
-};  /* map_xyz2lonlat */
-
-
-/**************************************************************
-   void rotate_about_xaxis(int ni, int nj, double *X, double *Y, 
-	              	   double *Z, double angle)
-
-   Rotate about X axis by "angle"
-
-***************************************************************/
-
-void rotate_about_xaxis(int ni, int nj, double *X, double *Y, 
-	          	double *Z, double angle) {
-  int i, j, n;
-  double s,c,old;
-  const double tolerance = 1.e-9;
-
-  s=sin(angle);
-  c=cos(angle);
-
-  if (c<tolerance) {
-    c=0;
-    if(s>0)
-      s = 1;
-    else
-      s = -1;
-  }
-
-  for(n=0; n<ni*nj; n++) {
-    old = Y[n];
-    Y[n] = c*Y[n]-s*Z[n];
-    Z[n] = s*old+c*Z[n];
-  }
-
-}; /* rotate_about_xaxis */
-
-
-/*************************************************************************
-   void permutetiles(int ni, int nj, double *b, int n)
-
-   shifts the tile data left by n places around the equator
-   n=1, tile 2->1, 4->2, 5->4, 1->5, the tiles 3 and 6 get rotated 90 degs.
-
-*************************************************************************/
-
-void permutiles(int ni, int nj, double *b, int num) {
-
-  int i, j, k, n;
-  int ntiles = 6;
-  double *c=NULL;
-  
-  c = (double *)malloc(ni*nj*ntiles*sizeof(double));
-
-  for(k=0; k<num; k++) {
-    for(j=0;j<nj;j++) {
-      for(i=0;i<ni;i++) {
-	n = j*ni+i;
-	c[n]         = b[ni*nj+n];
-	c[ni*nj+n]   = b[3*ni*nj+i*ni+nj-j-1];
-	c[2*ni*nj+n] = b[2*ni*nj+i*ni+nj-j-1];
-	c[3*ni*nj+n] = b[4*ni*nj+n];
-	c[4*ni*nj+n] = b[(ni-i-1)*ni+j];
-	c[5*ni*nj+n] = b[5*ni*nj+(ni-i-1)*ni+j];
-      }
-    }
-    for(n=0; n<ni*nj*ntiles; n++) b[n] = c[n];
-  }
-
-  free(c);
-};  /* permutiles */
-
-/*************************************************************************
-
-     calc_fvgrid( lx, vector ly, vector dxl, vector dyl, vector areal)
-
-     Calculates finite volume grid info (dxl,dyl,areal) for conformal cubic grid 
-     with 3-D coordinates (X, Y, Z)
-     Meant to be used for single quadrant of tile but does work for full tile
-
-**************************************************************************/
-
-void calc_fvgrid(int nx, int ny, int nratio, double *dx, double *dy, double *area)
-{
-  int nxf, nyf, nif, njf, nxp, nyp, nxh, nyh, i, j, n, m;
-  double ar;
-  double *lx, *ly, *X, *Y, *Z, *vec1, *vec2, *vec3, *vec4, *dxl, *dyl, *areal;
-  size_t *dims;
-  
-  nxp = nx+1;
-  nyp = ny+1;
-  nxh = (nxp+1)/2;
-  nyh = (nyp+1)/2;
-
-  nxf = nx*nratio+1;
-  nyf = nxf; 
-  nif = (nxf+1)/2;
-  njf = nif;
-
-  lx = (double *)malloc(nif*njf*sizeof(double));
-  ly = (double *)malloc(nif*njf*sizeof(double));
-
-  n = 0;
-  for(j=0; j<njf; j++) {
-    for(i=0; i<nif; i++) {
-      lx[n] = -1. + 2.0*i/(nxf-1);
-      ly[n++] = -1. + 2.0*j/(nyf-1);
-    }
-  } 
-
-  X = (double *)malloc(nif*njf*sizeof(double));
-  Y = (double *)malloc(nif*njf*sizeof(double));
-  Z = (double *)malloc(nif*njf*sizeof(double));
-
- /* calculating 3D coordinates on unit sphere */
-  conformal_map_coords2xyz( nif, njf, lx, ly, X, Y, Z);
-
-  vec1  = (double *)malloc((nif-1)*njf*3*sizeof(double));
-  vec2  = (double *)malloc((nif-1)*njf*3*sizeof(double));
-
-  for(j=0;j<njf;j++) {
-    for(i=0;i<nif-1;i++) {
-      n = j*(nif-1)+i;
-      vec1[n] = X[j*nif+i];
-      vec2[n] = X[j*nif+i+1];
-      vec1[(nif-1)*njf+n] = Y[j*nif+i];
-      vec2[(nif-1)*njf+n] = Y[j*nif+i+1];
-      vec1[2*(nif-1)*njf+n] = Z[j*nif+i];
-      vec2[2*(nif-1)*njf+n] = Z[j*nif+i+1];
-    }
-  }
-  
-  dxl = angle_between_vectors( nif-1, njf, vec1, vec2);
-
-  free(vec1);
-  free(vec2);
-
-  vec1  = (double *)malloc(nif*(njf-1)*3*sizeof(double));
-  vec2  = (double *)malloc(nif*(njf-1)*3*sizeof(double));
-
-  for(j=0;j<njf-1;j++) {
-    for(i=0;i<nif;i++) {
-      n = j*nif+i;
-      vec1[n] = X[j*nif+i];
-      vec2[n] = X[(j+1)*nif+i];
-      vec1[nif*(njf-1)+n] = Y[j*nif+i];
-      vec2[nif*(njf-1)+n] = Y[(j+1)*nif+i];
-      vec1[2*nif*(njf-1)+n] = Z[j*nif+i];
-      vec2[2*nif*(njf-1)+n] = Z[(j+1)*nif+i];
-    }
-  }  
-
-  dyl = angle_between_vectors( nif, njf-1, vec1, vec2);
-  
-  free(vec1);
-  free(vec2);
-
-  vec1  = (double *)malloc((nif-1)*(njf-1)*3*sizeof(double));
-  vec2  = (double *)malloc((nif-1)*(njf-1)*3*sizeof(double)); 
-  vec3  = (double *)malloc((nif-1)*(njf-1)*3*sizeof(double));
-  vec4  = (double *)malloc((nif-1)*(njf-1)*3*sizeof(double)); 
-
-  for(j=0;j<njf-1;j++) {
-    for(i=0;i<nif-1;i++) {
-      n = j*(nif-1)+i;
-      vec1[n] = X[j*nif+i];
-      vec2[n] = X[j*nif+i+1];
-      vec3[n] = X[(j+1)*nif+i+1];
-      vec4[n] = X[(j+1)*nif+i];
-      vec1[(nif-1)*(njf-1)+n] = Y[j*nif+i];
-      vec2[(nif-1)*(njf-1)+n] = Y[j*nif+i+1];
-      vec3[(nif-1)*(njf-1)+n] = Y[(j+1)*nif+i+1];
-      vec4[(nif-1)*(njf-1)+n] = Y[(j+1)*nif+i];
-      vec1[2*(nif-1)*(njf-1)+n] = Z[j*nif+i];
-      vec2[2*(nif-1)*(njf-1)+n] = Z[j*nif+i+1];
-      vec3[2*(nif-1)*(njf-1)+n] = Z[(j+1)*nif+i+1];
-      vec4[2*(nif-1)*(njf-1)+n] = Z[(j+1)*nif+i];
-    }
-  }  
-
-  areal = excess_of_quad( nif-1, njf-1, vec1, vec2, vec3, vec4);
-  free(vec1);
-  free(vec2);
-  free(vec3);
-  free(vec4);  
-
-  /*Force some symmetry (probably does nothing) */
-  for(j=0; j<njf; j++) {
-    for(i=0; i<nif-1; i++) dxl[j*(nif-1)+i] = (dxl[j*(nif-1)+i]+dyl[i*nif+j])*0.5;
-  }
-
-  for(j=0; j<njf-1; j++) {
-    for(i=0; i<nif; i++) dyl[j*nif+i] = dxl[i*(nif-1)+j];
-  }
-
-  for(j=0; j<njf-1; j++) {
-    for(i=0; i<nif-1; i++) {
-      if(j<i) 
-	areal[j*(nif-1)+i] = (areal[j*(nif-1)+i]+areal[i*(nif-1)+j])*0.5;
-      else if(j>i)
-        areal[j*(nif-1)+i] = areal[i*(nif-1)+j];
-    }
-  }
-
-  /* Use symmetry to fill second octant */
-  for(j=1; j<njf; j++) {
-    for(i=0; i<j; i++) {
-      dxl[j*(nif-1)+i] = dyl[i*nif+j];
-    }
-  }
-
-  for(j=1; j<njf-1; j++) {
-    for(i=0; i<j; i++) {
-      areal[j*(nif-1)+i] = areal[i*(nif-1)+j];
-    }
-  }
-
-  /* copy data from fine grid to super grid. */
-  
-  for(j=0;j<nyh;j++) {
-    for(i=0;i<nxh-1;i++) {
-      ar = 0;
-      for(n=0;n<nratio;n++) ar = ar + dxl[j*nratio*(nif-1)+i*nratio+n];
-      dx[j*nx+i] = ar*RADIUS;
-    }
-  }
-    
-  for(j=0;j<nyh-1;j++) {
-    for(i=0;i<nxh-1;i++) {
-      ar = 0;
-      for(n=0; n<nratio; n++) 
-	for(m=0; m<nratio; m++) ar += areal[(j*nratio+n)*(nif-1)+i*nratio+m];
-      area[j*nx+i] = ar*RADIUS*RADIUS;
-    }
-  }
-  
-  /*use reflection symmetry of quadrants to fill face. */
-  for(j=0;j<nyh; j++) {
-    for(i=nxh-1; i<nx; i++) {
-      dx[j*nx+i] = dx[j*nx+nxp-i-2];
-    }
-  }
-
-  for(j=nyh;j<nyp; j++) {
-    for(i=0; i<nx; i++) {
-      dx[j*nx+i] = dx[(ny-j)*nx+i];
-    }
-  }
-
-  for(j=0;j<nyh-1; j++) {
-    for(i=nxh-1; i<nx; i++) {
-      area[j*nx+i]   = area[j*nx+nxp-i-2];
-    }
-  }
-
-  for(j=nyh-1;j<ny; j++) {
-    for(i=0; i<nx; i++) {
-      area[j*ny+i]   = area[(nyp-j-2)*nx+i];
-    }
-  }
-
-  /* copy dx to dy */
-  for(j=0;j<ny;j++) 
-    for(i=0;i<nxp;i++) dy[j*nxp+i] =  dx[i*nx+j] ;
-
-}; /* calc_fvgrid */
-
-
-/******************************************************************************* 
-   array<double>* angle_between_vectors(array<double> vec1, array<double> vec2)
-*******************************************************************************/
-
-double* angle_between_vectors(int ni, int nj, double *vec1, double *vec2) {
-  int n;
-  double vector_prod, nrm1, nrm2;
-  double *angle;
-  
-  angle = (double *)malloc(ni*nj*sizeof(double));
-
-  for(n=0; n<ni*nj; n++) {
-    vector_prod=vec1[n]*vec2[n] + vec1[ni*nj+n]*vec2[ni*nj+n] + vec1[2*ni*nj+n]*vec2[2*ni*nj+n];
-      nrm1=pow(vec1[n],2)+pow(vec1[ni*nj+n],2)+pow(vec1[2*ni*nj+n],2);
-      nrm2=pow(vec2[n],2)+pow(vec2[ni*nj+n],2)+pow(vec2[2*ni*nj+n],2);
-      angle[n] = acos( vector_prod/sqrt(nrm1*nrm2) );
-  }
-  return angle;
-}; /* angle_between_vectors */
-
-/*****************************************************************
-   double* excess_of_quad(int ni, int nj, double *vec1, double *vec2, 
-                          double *vec3, double *vec4 )
-*******************************************************************/
-double* excess_of_quad(int ni, int nj, double *vec1, double *vec2, double *vec3, double *vec4 )
-{
-  int n;
-  double ang12, ang23, ang34, ang41;
-  double *excess, *plane1, *plane2, *plane3, *plane4;
-  double *angle12, *angle23, *angle34, *angle41;
-  
-  excess = (double *)malloc(ni*nj*sizeof(double));
-
-  plane1=plane_normal(ni, nj, vec1, vec2);
-  plane2=plane_normal(ni, nj, vec2, vec3);
-  plane3=plane_normal(ni, nj, vec3, vec4);
-  plane4=plane_normal(ni, nj, vec4, vec1);
-  angle12=angle_between_vectors(ni, nj, plane2,plane1);
-  angle23=angle_between_vectors(ni, nj, plane3,plane2);
-  angle34=angle_between_vectors(ni, nj, plane4,plane3);
-  angle41=angle_between_vectors(ni, nj, plane1,plane4);
-
-  for(n=0; n<ni*nj; n++) {
-    ang12 = M_PI-angle12[n];
-    ang23 = M_PI-angle23[n];
-    ang34 = M_PI-angle34[n];
-    ang41 = M_PI-angle41[n];
-    excess[n] = ang12+ang23+ang34+ang41-2*M_PI;
-  }
-
-  free(plane1);
-  free(plane2);
-  free(plane3);
-  free(plane4);
-  free(angle12);
-  free(angle23);
-  free(angle34);
-  free(angle41);
-  
-  return excess;
-
-}; /* excess_of_quad */
-
-/***********************************************************************
-   double* plane_normal(int ni, int nj, double *P1, double *P2)
-***********************************************************************/
-
-double* plane_normal(int ni, int nj, double *P1, double *P2)
-{
-  int i, j, n;
-  double p1, p2, p3, mag;
-  double *plane;
-  
-  plane = (double *)malloc(ni*nj*3*sizeof(double));
-
-  for(j=0;j<nj;j++) {
-    for(i=0;i<ni;i++) {
-      n = j*ni + i;
-      p1 = P1[ni*nj+n] * P2[2*ni*nj+n] - P1[2*ni*nj+n] * P2[ni*nj+n];
-      p2 = P1[2*ni*nj+n] * P2[n] - P1[n] * P2[2*ni*nj+n];
-      p3 = P1[n] * P2[ni*nj+n] - P1[ni*nj+n] * P2[n];
-      mag=sqrt(pow(p1,2) + pow(p2,2) + pow(p3,2));
-      plane[n]=p1/mag;
-      plane[ni*nj+n]=p2/mag;
-      plane[2*ni*nj+n]=p3/mag;
-    }
-  }
-
-  return plane;
-
-};
-
-/******************************************************************
-
-  void calc_rotation_angle()
-
-******************************************************************/
-
-void calc_rotation_angle(int nxp, int nyp, double *x, double *y, double *angle_dx, double *angle_dy)
-{
-  int ip1, im1, jp1, jm1, tp1, tm1, i, j, n, ntiles, nx, ny;
-  double lon_scale;
-
-  nx = nxp - 1;
-  ny = nyp - 1;
-  ntiles = 6;
-  for(n=0; n<ntiles; n++) {
-    for(j=0; j<nyp; j++) {
-      for(i=0; i<nxp; i++) {
-	lon_scale = cos(y[n*nxp*nyp+j*nxp+i]*D2R);
-	tp1 = n;
-	tm1 = n;
-	ip1 = i+1;
-	im1 = i-1;
-	jp1 = j;
-	jm1 = j;
-
-        if(ip1 >= nxp) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tp1 = n+1;
-	    ip1 = 0;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tp1 = n+2;
-	    if(tp1 >= ntiles) tp1 -= ntiles;
-	    ip1 = ny-j-1;
-	    jp1 = 0;
-	  }
-	}        
-        if(im1 < 0) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tm1 = n-2;
-	    if(tm1 < 0) tm1 += ntiles;
-	    jm1 = ny;
-	    im1 = nx-j;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tm1 = n-1;
-	    im1 = nx;
-	  }
-	}
-
-	angle_dx[n*nxp*nyp+j*nxp+i] = atan2(y[tp1*nxp*nyp+jp1*nxp+ip1]-y[tm1*nxp*nyp+jm1*nxp+im1],
-					    (x[tp1*nxp*nyp+jp1*nxp+ip1]-x[tm1*nxp*nyp+jm1*nxp+im1])*lon_scale )*R2D;
-	tp1 = n;
-	tm1 = n;
-	ip1 = i;
-	im1 = i;
-	jp1 = j+1;
-	jm1 = j-1;
-        if(jp1 >=nyp) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tp1 = n+2;
-	    if(tp1 >= ntiles) tp1 -= ntiles;
-	    jp1 = nx-i;
-	    ip1 = 0;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tp1 = n+1;
-	    if(tp1 >= ntiles) tp1 -= ntiles;
-	    jp1 = 0;
-	  }
-	}        
-        if(jm1 < 0) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tm1 = n-1;
-	    if(tm1 < 0) tm1 += ntiles;
-	    jm1 = ny;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tm1 = n-2;
-	    if(tm1 < 0) tm1 += ntiles;
-	    im1 = nx;
-	    jm1 = nx-i;
-	  }
-	}	
-
-	angle_dy[n*nxp*nyp+j*nxp+i] = atan2(y[tp1*nxp*nyp+jp1*nxp+ip1]-y[tm1*nxp*nyp+jm1*nxp+im1],
-					    (x[tp1*nxp*nyp+jp1*nxp+ip1]-x[tm1*nxp*nyp+jm1*nxp+im1])*lon_scale )*R2D;
-      }
-    }
-  }
-
-}; /* calc_rotation_angle */
- 
diff --git a/gridspec_tools_20080702/tools/make_hgrid/create_lonlat_grid.c b/gridspec_tools_20080702/tools/make_hgrid/create_lonlat_grid.c
deleted file mode 100644
index f562c69..0000000
--- a/gridspec_tools_20080702/tools/make_hgrid/create_lonlat_grid.c
+++ /dev/null
@@ -1,406 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <complex.h>
-#include <math.h>
-#include <string.h>
-#include "mosaic_util.h"
-#include "interp.h"
-#include "tool_util.h"
-#include "constant.h"
-#include "create_hgrid.h"
-#define  D2R (M_PI/180.)
-#define  R2D (180./M_PI)
-
-/*********************************************************************************
-   some private routines used in this file
-*********************************************************************************/
-void set_regular_lonlat_grid( int nxp, int nyp, int isc, int iec, int jsc, int jec, double *xb, double *yb,
-			      double *x, double *y, double *dx, double *dy, double *area, double *angle );
-/************************************************************************************
-   void create_regular_lonlat_grid( int *nxbnds, int *nybnds, double *xbnds, double *ybnds,
-                                    int *nlon, int *nlat, int *isc, int *iec,
-                                    int *jsc, int *jec, double *x, double *y, double *dx,
-                                    double *dy, double *area, double *angle_dx )
-   calculate grid location, length, area and rotation angle.
-   The routine takes the following arguments
-
-   INPUT:
-
-   OUTPUT:
-
-************************************************************************************/
-void create_regular_lonlat_grid( int *nxbnds, int *nybnds, double *xbnds, double *ybnds,
-		         	 int *nlon, int *nlat, int *isc, int *iec,
-				 int *jsc, int *jec, double *x, double *y, double *dx,
-				 double *dy, double *area, double *angle_dx, const char *center )
-{
-  int nx, ny, nxp, nyp, nxb, nyb;
-  double *xb=NULL, *yb=NULL;
-  int refine;
-  
-  /* use cubic-spline interpolation algorithm to calculate nominal zonal grid location. */
-  nxb = *nxbnds;
-  nyb = *nybnds;
-
-  xb = compute_grid_bound(nxb, xbnds, nlon, &nx, center), 
-  nxp = nx + 1;
-  
-  yb = compute_grid_bound(nyb, ybnds, nlat, &ny, center), 
-  nyp = ny + 1;
-     
-  set_regular_lonlat_grid( nxp, nyp, *isc, *iec, *jsc, *jec, xb, yb, x, y, dx, dy, area, angle_dx);
-  free(xb);
-  free(yb);
-    
-}; /* create_regular_lonlat_grid */
-
-
-/************************************************************************************
-   void create_simple_cartesian_grid( double *xbnds, double *ybnds, int *nlon, int *nlat,
-                                      double *simple_dx, *simple_dy, int *isc, int *iec,
-				      int *jsc, int *jec, double *x, double *y,
-				      double *dx, double *dy, double *area, double *angle_dx )
-   calculate grid location, length, area and rotation angle.
-   The routine takes the following arguments
-
-   INPUT:
-
-   OUTPUT:
-
-************************************************************************************/
-void create_simple_cartesian_grid( double *xbnds, double *ybnds, int *nlon, int *nlat,
-				   double *simple_dx, double *simple_dy, int *isc, int *iec,
-				   int *jsc, int *jec, double *x, double *y,
-				   double *dx, double *dy, double *area, double *angle_dx )
-{
-  int nx, ny, nxp, nyp, i, j, n, nxc, nyc, nxb, nyb;
-  double *grid1=NULL, *grid2=NULL, *xb=NULL, *yb=NULL;
-
-  nxb = 2;
-  nyb = 2;
-  nx = *nlon;
-  ny = *nlat;
-  nxp = nx + 1;
-  nyp = ny + 1;  
-  /* use cubic-spline interpolation algorithm to calculate nominal zonal grid location. */
-  xb    = (double *)malloc(nxp*sizeof(double));
-  grid1 = (double *)malloc(nxb*sizeof(double));
-  grid1[0] = 1;
-  grid1[1] = nxp;
-  grid2 = (double *)malloc(nxp*sizeof(double));
-  for(i=0;i<nxp;i++) grid2[i] = i + 1.0;
-  cubic_spline( nxb, nxp, grid1, grid2, xbnds, xb, 1e30,1e30);
-  free(grid1);
-  free(grid2);
-
-  /* use cubic-spline interpolation algorithm to calculate nominal meridinal grid location. */
-  yb    = (double *)malloc(nyp*sizeof(double));
-  grid1 = (double *)malloc(nyb*sizeof(double));
-  grid1[0] = 1;
-  grid1[1] = nyp;
-  grid2 = (double *)malloc(nyp*sizeof(double));
-  for(j=0;j<nyp;j++) grid2[j] = j + 1.0;
-  cubic_spline( nyb, nyp, grid1, grid2, ybnds, yb, 1e30,1e30);
-  free(grid1);
-  free(grid2);
-
-  n = 0;
-  for(j=0; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      x[n] = xb[i];
-      y[n++] = yb[j];
-    }
-  }
-
-  nxc = *iec - *isc + 1;
-  nyc = *jec - *jsc + 1;
-  
-  for(n = 0; n< nxc*(nyc+1);     n++) dx[n] = *simple_dx;
-  for(n = 0; n< (nxc+1)*nyc;     n++) dy[n] = *simple_dy;
-  for(n = 0; n< nxc*nyc;         n++) area[n] = (*simple_dx)*(*simple_dy);
-  for(n = 0; n< (nxc+1)*(nyc+1); n++) angle_dx[n] = 0;
-  
-  free(xb);
-  free(yb);
-    
-}; /* create_simple_cartesian_grid */
-
-
-/*******************************************************************************
-   void create_spectral_grid( nt *nlon, int *nlat, int *isc, int *iec,
-                              int *jsc, int *jec, double *x, double *y, double *dx,
-                              double *dy, double *area, double *angle_dx )
-   generate spectral horizontal grid
-*******************************************************************************/
-void create_spectral_grid( int *nlon, int *nlat, int *isc, int *iec,
-			   int *jsc, int *jec, double *x, double *y, double *dx,
-			   double *dy, double *area, double *angle_dx )
-{
-  const int itermax = 10;
-  const double epsln = 1e-15;
-  int ni, nj, nx, ny, nxp, nyp, i, j, converge, iter;
-  double dlon, z, p1, p2, p3, z1, pp, a, b, c, d, sum_wts; 
-  double *xb, *yb, *lon, *lonb, *lat, *latb;
-  double *sin_hem, *wts_hem, *sin_lat, *wts_lat;
-  
-  nx = *nlon;
-  ny = *nlat;
-  nxp = nx + 1;
-  nyp = ny + 1;
-  ni = nx/2;
-  nj = ny/2;
-
-  xb = (double *) malloc(nxp*sizeof(double));
-  yb = (double *) malloc(nyp*sizeof(double));
-  lon     = (double *) malloc(ni    *sizeof(double));
-  lonb    = (double *) malloc((ni+1)*sizeof(double));
-  lat     = (double *) malloc(nj    *sizeof(double));
-  latb    = (double *) malloc((nj+1)*sizeof(double));
-  sin_hem = (double *) malloc(nj/2*sizeof(double));
-  wts_hem = (double *) malloc(nj/2*sizeof(double));
-  sin_lat = (double *) malloc(nj*sizeof(double));
-  wts_lat = (double *) malloc(nj*sizeof(double));
-  dlon = 360./ni;
-  for(i=0;i< ni;i++) lon[i] = i*dlon;
-  for(i=0;i<=ni;i++) lonb[i] = (i-0.5)*dlon;
-
-  for(j=0;j<nj/2;j++) {
-    converge = 0;
-    z = cos(M_PI*(j +0.75)/(nj + 0.5));
-    for(iter=1; iter<=itermax; i++){
-      p1 = 1.0;
-      p2 = 0.0;
-
-      for(i=1;i<=nj;i++) {
-        p3 = p2;
-        p2 = p1;
-        p1 = ((2.0*i - 1.0)*z*p2 - (i - 1.0)*p3)/i;
-      }
-
-      pp = nj*(z*p1 - p2)/(z*z - 1.0E+00);
-      z1 = z;
-      z  = z1 - p1/pp;
-      if(fabs(z - z1) < epsln ) {
-        converge = 1;
-	break;
-      }
-    }
-    if(! converge) mpp_error("create_spectral_grid: abscissas failed to converge "
-			     "in itermax iterations");
-    sin_hem [j]     = z;
-    wts_hem [j]     = 2.0/((1.0 - z*z)*pp*pp);
-  }
-
-  for(j=0;j<nj/2;j++) {
-    sin_lat[j]      = - sin_hem[j];
-    sin_lat[nj-1-j] =   sin_hem[j];
-    wts_lat[j]      =   wts_hem[j];
-    wts_lat[nj-1-j] =   wts_hem[j];
-  }
-
-  for(j=0;j<nj;j++){
-    lat[j]    = asin(sin_lat[j])*R2D;
-  }
-
-  latb[0] = -90.;
-  latb[nj] = 90.;
-  for(j=1;j<nj;j++) {
-    sum_wts = sum_wts + wts_lat[j-1];
-    latb[j] = asin(sum_wts-1.)*R2D;
-  }
-
-  for(i=0;i<=ni;i++) xb[i*2]   = lonb[i];
-  for(i=0;i<ni; i++) xb[i*2+1] = lon[i];
-  for(j=0;j<=nj;j++) yb[j*2]   = latb[j];
-  for(j=0;j<nj; j++) yb[j*2+1] = lat[j];
-
-  set_regular_lonlat_grid( nxp, nyp, *isc, *iec, *jsc, *jec, xb, yb, x, y, dx, dy, area, angle_dx );
-  free(xb);
-  free(yb);
-  free(lon);
-  free(lonb);
-  free(lat);
-  free(latb);
-  free(sin_hem);
-  free(wts_hem);
-  free(sin_lat);
-  free(wts_lat); 
-  
-}; /* create_spectral_grid */
-
-/*******************************************************************************
-   void set_regular_lonlat_grid( int nxp, int nyp, int isc, int iec, int jsc, int jec,
-                                 double *xb, double *yb, double *x, double *y,
-                                 double *dx, double *dy, double *area, double *angle )
-   set geographic grid location, calculate grid length, area and rotation angle
-   x and y are on global domain, the other fields are on compute domain 
-*******************************************************************************/
-void set_regular_lonlat_grid( int nxp, int nyp, int isc, int iec, int jsc, int jec, double *xb, double *yb,
-			      double *x, double *y, double *dx, double *dy, double *area, double *angle )
-{
-  int n, i, j;
-  
-  n = 0;
-  for(j=0; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      x[n]   = xb[i];
-      y[n++] = yb[j];
-    }
-  }
-  /* zonal length */
-  n = 0;
-  for(j=jsc; j<=jec+1; j++) {
-    for(i=isc; i<=iec; i++ ) {
-      dx[n++] = spherical_dist(x[j*nxp+i], y[j*nxp+i], x[j*nxp+i+1], y[j*nxp+i+1] );
-    }
-  }
-
-  /* meridinal length */
-  n = 0;
-  for(j=jsc; j<=jec; j++) {
-    for(i=isc; i<=iec+1; i++ ) {
-      dy[n++] = spherical_dist(x[j*nxp+i], y[j*nxp+i], x[(j+1)*nxp+i], y[(j+1)*nxp+i] );
-    }
-  }
-
-  /* cell area */
-  n = 0;
-  for(j=jsc; j<=jec; j++) {
-    for(i=isc; i<=iec; i++ ) {
-      area[n++] = box_area(x[j*nxp+i]*D2R, y[j*nxp+i]*D2R, x[(j+1)*nxp+i+1]*D2R, y[(j+1)*nxp+i+1]*D2R );
-    }
-  }
-
-  /* rotation angle */
-  n = 0;
-  for(j=jsc; j<=jec+1; j++) {
-    for(i=isc; i<=iec+1; i++ ) angle[n++] = 0;   
-  }
-
-};  /* set_regular_lonlat_grid */
-
-
-/*******************************************************************************
-   void create_tripolar_grid( int int nxbnds, int nybnds, double *xbnds, double *ybnds,
-                              int *nlon, int *nlat, double *lat_join_in, int *isc, int *iec,
-                              int *jsc, int *jec, double *x, double *y, double *dx, double *dy,
-			      double *area, double *angle_dx )
-   create tripolar grid infomrmation
-********************************************************************************/
-void create_tripolar_grid( int *nxbnds, int *nybnds, double *xbnds, double *ybnds,
-			   int *nlon, int *nlat, double *lat_join_in, int *isc, int *iec,
-			   int *jsc, int *jec, double *x, double *y, double *dx, double *dy,
-			   double *area, double *angle_dx, const char *center )
-{
-  int nxb, nyb, i, j, nx, ny, nxp, nyp, j_join, n, ip1, ii, n_count;
-  double lat_join, lon_start, lon_end, lon_bpeq, lon_bpnp, lon_bpsp;
-  double lam0, rp, lon_last, lon_scale;
-  double *xb, *yb;
-  double x_poly[20], y_poly[20];
-  
-  nxb = *nxbnds;
-  nyb = *nybnds;
-
-  xb = compute_grid_bound(nxb, xbnds, nlon, &nx, center), 
-  nxp = nx + 1;
-  
-  yb = compute_grid_bound(nyb, ybnds, nlat, &ny, center), 
-  nyp = ny + 1;
-
-  n = 0;
-  for(j=0; j<nyp; j++) {
-    for(i=0; i<nxp; i++) {
-      x[n] = xb[i];
-      y[n++] = yb[j];
-    }
-  }
-
-  lat_join = *lat_join_in;
-  j_join = nearest_index(lat_join, yb, nyp);
-  lat_join  = yb[j_join];
-  lon_start = xbnds[0];
-  lon_end   = xbnds[1];  
-  lon_bpeq = lon_start + 90. ;
-  lon_bpnp = lon_start;
-  lon_bpsp = lon_start+180.;
-  
-  if(*lat_join_in != lat_join) {
-    if(mpp_pe() == mpp_root_pe() )printf("NOTE: Change join latitude from %f to %f\n",*lat_join_in, lat_join);
-  }
-  /**********************************************************************
-     Transform from bipolar grid coordinates (bp_lon, bp_lat) to
-     geographic coordinates (geolon_t, geolat_t) following R. Murray,
-     "Explicit generation of orthogonal grids for ocean models",
-     1996, J.Comp.Phys., v. 126, p. 251-273.  All equation
-     numbers refer to the Murray paper.
-  **********************************************************************/
-
-  lam0 = fmod(lon_bpeq*D2R + 2*M_PI, 2*M_PI);
-  rp = tan((0.5*M_PI-lat_join*D2R)/2.);        /* eqn. 2 */
-
-  /*   calculate zonal length */
-  n = 0;
-  for(j=*jsc;j<=*jec+1;j++){
-    for(i=*isc;i<=*iec;i++){
-      if(j < j_join )  /* regular grid region */
-        dx[n++] = spherical_dist(x[j*nxp+i], y[j*nxp+i], x[j*nxp+i+1], y[j*nxp+i+1]);
-      else /*bipolar region */
-	dx[n++] = bipolar_dist(x[j*nxp+i], y[j*nxp+i], x[j*nxp+i+1], y[j*nxp+i+1], lon_bpeq, lon_bpsp, lon_bpnp, rp );
-    }
-  }
-  
-  /*   calculate meridinal length */
-  n = 0;
-  for(j=*jsc;j<=*jec;j++){
-    for(i=*isc;i<=*iec+1;i++){
-      if(j < j_join )  /* regular grid region */
-        dy[n++] = spherical_dist(x[j*nxp+i], y[j*nxp+i], x[(j+1)*nxp+i], y[(j+1)*nxp+i]);
-      else /*bipolar region */
-	dy[n++] = bipolar_dist(x[j*nxp+i], y[j*nxp+i], x[(j+1)*nxp+i], y[(j+1)*nxp+i], lon_bpeq, lon_bpsp, lon_bpnp, rp );
-    }
-  }
-  
-  /*define tripolar grid location */
-  for(j=j_join;j<nyp;j++) {
-    for(i=0;i<nxp;i++) {
-      lon_last = x[j*nxp+max(i-1,0)];
-      tp_trans(&(x[j*nxp+i]),&(y[j*nxp+i]),lon_last,lon_start, lam0, lon_bpeq, lon_bpsp, lon_bpnp, rp);
-    }
-  }
-
- /*calculte cell area */
-  n = 0;
-  for(j=*jsc;j<=*jec;j++){
-    for(i=*isc;i<=*iec;i++){
-      if(j < j_join) 
-	area[n++] = box_area(x[j*nxp+i]*D2R, y[j*nxp+i]*D2R, x[(j+1)*nxp+i+1]*D2R, y[(j+1)*nxp+i+1]*D2R);
-      else {
-	x_poly[0] = x[j*nxp+i]*D2R;       y_poly[0] = y[j*nxp+i]*D2R;
-	x_poly[1] = x[j*nxp+i+1]*D2R;     y_poly[1] = y[j*nxp+i+1]*D2R;
-	x_poly[2] = x[(j+1)*nxp+i+1]*D2R; y_poly[2] = y[(j+1)*nxp+i+1]*D2R;
-	x_poly[3] = x[(j+1)*nxp+i]*D2R;   y_poly[3] = y[(j+1)*nxp+i]*D2R;
-        n_count = fix_lon(x_poly, y_poly, 4, M_PI);
-	area[n++] = poly_area(x_poly, y_poly, n_count);
-      }
-    }
-  }  
-  
-  /*calculte rotation angle at cell vertex */
-  n = 0;
-  for(j=*jsc;j<=(*jec)+1;j++){
-    for(i=*isc;i<=(*iec)+1;i++){
-      if(j < j_join) 
-	angle_dx[n++] = 0.0;
-      else {
-	lon_scale = cos(y[j*nxp+i]*D2R);
-	if(i==0 || i == nx ) /* always at the boundary */
-	  angle_dx[n++] = 0;
-	else
-	  angle_dx[n++] = atan2(y[j*nxp+i+1]-y[j*nxp+i-1],(x[j*nxp+i+1]-x[j*nxp+i-1])*lon_scale)*R2D;
-      }
-    }
-  }
-  
-}; /* create_tripolar_grid */
-
-
diff --git a/gridspec_tools_20080702/tools/make_hgrid/make_hgrid.c b/gridspec_tools_20080702/tools/make_hgrid/make_hgrid.c
deleted file mode 100644
index f321564..0000000
--- a/gridspec_tools_20080702/tools/make_hgrid/make_hgrid.c
+++ /dev/null
@@ -1,626 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include <netcdf.h>
-#include "create_hgrid.h"
-#include "mpp.h"
-#include "mpp_domain.h"
-#include "mpp_io.h"
-
-const int MAXBOUNDS = 100;
-const int STRINGLEN = 255;
-  
-char *usage[] = {
-  "",
-  "                                                                                 ",
-  "                                                                                 ",
-  "                    Usage of make_hgrid                                          ",
-  "                                                                                 ",
-  "   make_hgrid --grid_type grid_type --my_grid_file my_grid_file                  ",
-  "                  --nxbnds nxbnds --nybnds nybnds                                ",
-  "                  --xbnds x(1),...,x(nxbnds) --ybnds y(1),...,y(nybnds)          ",
-  "                  --nlon nlon(1),...nlon(nxbnds-1)                               ",
-  "                  --nlat nlat(1),...nlat(nybnds-1)                               ",
-  "                  --lat_join lat_join --num_lon num_lon --nratio nratio          ",
-  "                  --simple_dx simple_dx --simple_dy simple_dy                    ",
-  "                  --ndivx ndivx --ndivy ndivy --grid_name gridname               ",
-  "                  --center center                                                ",
-  "                                                                                 ",
-  "   NOTE: This program can generate different types of horizontal grid. The       ",
-  "         output data is on supergrid ( model grid size x refinement(=2) ).       ",
-  "         For 'cubic_grid', six grid files which contain the grid information     ",
-  "         for each tile will be generate, otherwise one file will be generated    ",
-  "         you can specify the grid type through --grid_type. The value of         ",
-  "         grid_type can be 'from_file', 'spectral_grid', 'spherical_grid',        ",
-  "         'conformal_cubic_grid', 'gnomonic_ed' or 'simple_cartesian_grid',       ",
-  "         with default value 'spherical_grid'. --nlon and --nlat                  ",
-  "         must be specified to indicate supergrid size ( for cubic_grid,          ",
-  "         --nlat is not needed because nlat has the same value as nlon.           ",
-  "         --ndivx and --ndivy are optional arguments with default value 1.        ",
-  "         Besides --nlon, --nlat, --ndivx and --ndivy, other optional and         ",
-  "         requirement arguments for each type are,                                ",
-  "                                                                                 ",
-  "   1. 'from_file':              --my_grid_file must be specified. The grid    ",
-  "                                specified in my_grid_file should be super grid   ",
-  "                                vertex.                                          ",
-  "   2. 'spectral_grid':          no other optional or required arguments.         ",
-  "   3. 'regular_lonlat_grid':    --nxbnds, --nybnds --xbnds, --ybnds, must be     ",
-  "                                specified to define the grid bounds.             ",
-  "   4. 'tripolar_grid':          --nxbnds, --nybnds, --xbnds, --ybnds, must be    ",
-  "                                specified to define the grid bounds. --lat_join  ",
-  "                                is optional with default value 65.               ",
-  "   5  'conformal_cubic_grid':   --nratio is optional argument.                   ",
-  "   6  'gnomonic_ed'          :  equal distance gnomonic cubic grid.              ",
-  "   6. 'simple_cartesian_grid':  --xbnds, --ybnds must be specified to define     ",
-  "                                the grid bounds location and grid size. number   ",
-  "                                of bounds must be 2 in both and x and            ",
-  "                                y-direction. --simple_dx and --simple_dy must be ",
-  "                                specified to specify uniform cell length.        ",
-  "                                                                                 ",
-  "   make_hgrid take the following flags                                           ",
-  "                                                                                 ",
-  "   --grid_type grid_type      specify type of topography. See above for          ",
-  "                              grid type option.                                  "
-  "                                                                                 ",
-  "   --my_grid_file file        when this flag is present, the program will read   ",
-  "                              grid information from 'my_grid_file'. The file     ",
-  "                              format can be ascii file or netcdf file. Multiple  ",
-  "                              file entry are allowed but the number should be    ",
-  "                              less than MAXBOUNDS.                                ",
-  "                                                                                 ",
-  "   --nxbnds nxbnds            Specify number of zonal regions for varying        ",
-  "                              resolution.                                        ",
-  "                                                                                 ",
-  "   --nybnds nybnds            Specify number of meridinal regions for varying    ",
-  "                              resolution.                                        ",
-  "                                                                                 ",
-  "   --xbnds x(1),.,x(nxbnds)   Specify boundaries for defining zonal regions of   ",
-  "                              varying resolution. When --tripolar is present,    ",
-  "                              x also defines the longitude of the two new poles. ",
-  "                              nxbnds must be 2 and lon_start = x(1),             ",
-  "                              lon_end = x(nxbnds) are longitude of the two       ",
-  "                              new poles.                                         ",
-  "                                                                                 ",
-  "   --ybnds y(1),.,y(nybnds)   Specify boundaries for defining meridional         ",
-  "                              regions of varying resolution                      ",
-  "                                                                                 ",
-  "   --nlon nlon(1),..,nlon(nxbnds-1) Number of model grid points(supergrid) for   ",
-  "                                    each zonal regions of varying resolution.    ",
-  "                                                                                 ",  
-  "   --nlat nlat(1),..,nlat(nybnds-1) Number of model grid points(supergid) for    ",
-  "                                    each meridinal regions of varying resolution.",
-  "                                                                                 ",
-  "   --lat_join lat_join        Specify latitude for joining spherical and rotated ",
-  "                              bipolar grid. Default value is 65 degree.          ",
-  "                                                                                 ",
-  "   --nratio nratio            Speicify the refinement ratio when calculating     ",
-  "                              cell length and area of supergrid.                 ",
-  "                                                                                 ",
-  "   --simple_dx dimple_dx      Specify the uniform cell length in x-direction for ",
-  "                              simple cartesian grid.                             ",
-  "                                                                                 ",
-  "   --simple_dy dimple_dy      Specify the uniform cell length in y-direction for ",
-  "                              simple cartesian grid.                             ",  
-  "                                                                                 ",
-  "   --ndivx ndivx              Specify number division in x-direction for each    ",
-  "                              face, default value is 1.                          ",
-  "                                                                                 ",
-  "   --ndivy ndivy              Specify number division in y-direction for each    ",
-  "                              face, default value is 1.                          ",
-  "                                                                                 ",
-  "   --grid_name grid_name      Specify the grid name. The output grid file name   ",
-  "                              will be grid_name.nc if there is one tile and      ",
-  "                              grid_name.tile#.nc if there is more than one tile. ",
-  "                              The default value will be horizontal_grid.         ",
-  "                                                                                 ",
-  "   --center center            Specify the center location of grid. The valid     ",
-  "                              entry will be 'none', 't_cell' or 'c_cell' with    ",
-  "                              default value 'none'. The grid refinement is       ",
-  "                              assumed to be 2 in x and y-direction when center   ",
-  "                              is not 'none'. 'c_cell' should be used for the grid",
-  "                              used in MOM4.                                      ",     
-  "                                                                                 ",
-  "   Example                                                                       ",      
-  "                                                                                 ",
-  "                                                                                 ",
-  "   1. generating regular lon-lat grid (supergrid size 60x20)                     ",
-  "      > make_hgrid --grid_type regular_lonlat_grid --nxbnd 2 --nybnd 2           ",
-  "        --xbnd 0,30 --ybnd 50,60  --nlon 60 --nlat 20                            ",
-  "                                                                                 ",
-  "   2. generating tripolar grid with various grid resolution and C-cell centered  ",
-  "      > make_hgrid --grid_type tripolar_grid --nxbnd 2 --nybnd 7 --xbnd -280,80  ",
-  "                   --ybnd -82,-30,-10,0,10,30,90 --nlon 720                      ",
-  "                   --nlat 104,48,40,40,48,120 --grid_name om3_grid               ",
-  "                   --center c_cell  --periodx 360                                ",
-  "                                                                                 ",  
-  "   3. generating simple cartesian grid(supergrid size 20x20)                     ",
-  "      > make_hgrid --grid_type simple_cartesian_grid --xbnd 0,30 --ybnd 50,60    ",
-  "                   --nlon 20 --nlat 20  --simple_dx 1000 --simple_dy 1000        ",
-  "                                                                                 ",
-  "   4. generating conformal cubic grid. (supergrid size 60x60 for each tile)      ",
-  "      > make_hgrid --grid_type conformal_cubic_grid --nlon 60 --nratio 2         ",
-  "                                                                                 ",
-  "   5. generating gnomonic cubic grid with equal_dist_face_edge                   ",
-  "      > make_hgrid --grid_type gnomonic_ed --nlon 60                             ",
-  "                                                                                 ",
-  "   7. generating spectral grid. (supergrid size 128x64)                          ",
-  "      > make_hgrid --grid_type spectral_grid --nlon 128 --nlat 64                ",
-  "                                                                                 ",
-  "   7. Through    user-defined grids                                              ",
-  "      > make_hgrid --grid_type from_file --my_grid_file my_grid_file          ",
-  "                   --nlon 4 --nlat 4                                             ",
-  "                                                                                 ",
-  "       contents of sample my_grid_file                                           ",
-  "         The first line of my_grid_file will be text ( will be ignored)          ",     
-  "         followed by nlon+1 lines of real value of x-direction supergrid bound   ",
-  "         location. Then another line of text ( will be ignored), followed by     ",
-  "         nlat+1 lines of real value of y-direction supergrid bound location.     ",
-  "                                                                                 " ,     
-  "         For example:                                                            ",
-  "                                                                                 ",
-  "            x-grid                                                               ",
-  "            0.0                                                                  ",
-  "            5.0                                                                  ",
-  "            10.0                                                                 ",
-  "            15.0                                                                 ",
-  "            20.0                                                                 ",
-  "            y-grid                                                               ",
-  "            -10                                                                  ",
-  "            10                                                                   ",
-  "            20                                                                   ",
-  "            30                                                                   ",
-  "            40                                                                   ", 
-  "                                                                                 ",
-  "                                                                                 ",
-  "",
-  NULL };
-
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
-
-int main(int argc, char* argv[])
-{
-  int  nratio = 1;
-  int  ndivx[] = {1,1,1,1,1,1};
-  int  ndivy[] = {1,1,1,1,1,1};
-  char method[32] = "conformal";
-  char orientation[32] = "center_pole";
-  int  nxbnds=2, nybnds=2, nxbnds0=0, nybnds0=0, nxbnds1=0, nybnds1=0, nxbnds2=0, nybnds2=0;
-  double xbnds[MAXBOUNDS], ybnds[MAXBOUNDS];
-  int nlon[MAXBOUNDS-1], nlat[MAXBOUNDS-1];
-  char grid_type[128]="regular_lonlat_grid";
-  char my_grid_file[MAXBOUNDS][STRINGLEN];
-  double lat_join=65.;
-  double simple_dx=0, simple_dy=0;
-  int nx, ny, nxp, nyp, ntiles=1, ntilex=0, ntiley=0, ntiles_file;
-  double *x=NULL, *y=NULL, *dx=NULL, *dy=NULL, *angle_dx=NULL, *angle_dy=NULL, *area=NULL;
-  
-  char history[2560];
-  char gridname[32] = "horizontal_grid";
-  char center[32] = "none";
-  char geometry[32] = "spherical";
-  char projection[32] = "none";
-  char arcx[32] = "small_circle";
-  char north_pole_tile[32] = "0.0 90.0";
-  char north_pole_arcx[32] = "0.0 90.0";
-  char discretization[32]  = "logically_rectangular";
-  char conformal[32]       = "true";
-  char mesg[256], str[128];
-  char entry[MAXBOUNDS*STRINGLEN];
-  int isc, iec, jsc, jec, nxc, nyc, layout[2];
-  domain2D domain;
-  int n, errflg, c, i;  
-  int option_index;
-
-  static struct option long_options[] = {
-    {"grid_type",       required_argument, NULL, 'a'},
-    {"my_grid_file",    required_argument, NULL, 'b'},
-    {"nxbnds",          required_argument, NULL, 'c'},
-    {"nybnds",          required_argument, NULL, 'd'},
-    {"xbnds",           required_argument, NULL, 'e'},
-    {"ybnds",           required_argument, NULL, 'f'},
-    {"nlon",            required_argument, NULL, 'g'},
-    {"nlat",            required_argument, NULL, 'i'},
-    {"lat_join",        required_argument, NULL, 'j'},
-    {"nratio",          required_argument, NULL, 'k'},
-    {"simple_dx",       required_argument, NULL, 'l'},
-    {"simple_dy",       required_argument, NULL, 'm'},
-    {"ndivx",           required_argument, NULL, 'o'},
-    {"ndivy",           required_argument, NULL, 'p'},
-    {"grid_name",       required_argument, NULL, 'q'},
-    {"center",          required_argument, NULL, 'r'},
-    {"help",            no_argument,       NULL, 'h'},    
-    {0, 0, 0, 0},
-  };
-
-  /* start parallel */
-  mpp_init(&argc, &argv);
-  mpp_domain_init();  
-
-  /*
-   * process command line
-   */
-  errflg = argc <3;
-
-  while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1) {
-    switch (c) {
-    case 'a':
-      strcpy(grid_type, optarg);
-      break;
-    case 'b':
-      strcpy(entry, optarg);
-      tokenize(entry, ",", STRINGLEN, MAXBOUNDS, my_grid_file, &ntiles_file);
-      break;
-    case 'c':
-      nxbnds0 = atoi(optarg);
-      break;
-    case 'd':
-      nybnds0 = atoi(optarg);
-      break;        
-    case 'e':
-      strcpy(entry, optarg);
-      nxbnds1 = get_double_entry(entry, xbnds);
-      break;
-    case 'f':
-      strcpy(entry, optarg);
-      nybnds1 = get_double_entry(entry, ybnds);
-      break;
-    case 'g':
-      strcpy(entry, optarg);
-      nxbnds2 = get_int_entry(entry, nlon);
-      break;
-    case 'i':
-      strcpy(entry, optarg);
-      nybnds2 = get_int_entry(entry, nlat);
-      break;
-    case 'j':
-      lat_join = atof(optarg);
-      break; 
-    case 'k':
-      nratio = atoi(optarg);
-      break;      
-    case 'l':
-      simple_dx = atof(optarg);
-      break;
-    case 'm':
-      simple_dy = atof(optarg);
-      break;
-    case 'o':
-      strcpy(entry, optarg);
-      ntilex = get_int_entry(entry, ndivx);
-      break;
-    case 'p':
-      strcpy(entry, optarg);
-      ntiley = get_int_entry(entry, ndivy);
-      break;      
-    case 'q':
-      strcpy(gridname, optarg);
-      break;
-    case 'r':
-      strcpy(center, optarg);
-      break;
-    case 'h':
-      errflg++;
-      break;
-    case '?':
-      errflg++;      
-    }      
-  }
-  
-  if (errflg ) {
-    char **u = usage;
-    while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-    exit(2);
-  }  
-
-  /* define history to be the history in the grid file */
-  strcpy(history,argv[0]);
-
-  for(i=1;i<argc;i++) {
-    strcat(history, " ");
-    strcat(history, argv[i]);
-  }
-
-  if(mpp_pe() == mpp_root_pe() ) printf("==>NOTE: the grid type is %s\n",grid_type);
-
-
-  /* check the command-line arguments to make sure the value are suitable */
-
-  if( strcmp(grid_type,"regular_lonlat_grid") ==0 ) {
-    nxbnds = nxbnds0; nybnds = nybnds0;
-    if( nxbnds <2 || nybnds < 2) mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', "
-					   "both nxbnds and nybnds should be no less than 2");
-    if( nxbnds != nxbnds1 || nxbnds != nxbnds2+1 )
-      mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', nxbnds does"
-		"not match number of entry in xbnds or nlon");
-    if( nybnds != nybnds1 || nybnds != nybnds2+1 )
-      mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', nybnds does "
-		"not match number of entry in ybnds or nlat");
-  }
-  else if( strcmp(grid_type,"tripolar_grid") ==0 ) {
-    strcpy(projection, "tripolar");
-    nxbnds = nxbnds0; nybnds = nybnds0;
-    if( nxbnds != 2) mpp_error("make_hgrid: grid type is 'tripolar_grid', nxbnds should be 2");
-    if( nybnds < 2) mpp_error("make_hgrid: grid type is 'tripolar_grid', nybnds should be no less than 2");
-    if( nxbnds != nxbnds1 || nxbnds != nxbnds2+1 )
-      mpp_error("make_hgrid: grid type is 'tripolar_grid', nxbnds does not match number of entry in xbnds or nlon");
-    if( nybnds != nybnds1 || nybnds != nybnds2+1 )
-      mpp_error("make_hgrid: grid type is 'tripolar_grid', nybnds does not match number of entry in ybnds or nlat");
-  }
-  else if( strcmp(grid_type,"from_file") ==0 ) {
-    /* For ascii file, nlon and nlat should be specified through --nlon, --nlat
-       For netcdf file, grid resolution will be read from grid file
-    */
-    
-    if(ntiles_file == 0) mpp_error("make_hgrid: grid_type is 'from_file', but my_grid_file is not specified");
-    ntiles = ntiles_file;
-    for(n=0; n<ntiles; n++) {
-      if(strstr(my_grid_file[n],".nc") ) {
-	/* get the grid size for each tile, the grid is on model grid, should need to multiply by 2 */
-	int fid;
-	fid = mpp_open(my_grid_file[n], MPP_READ);
-	nlon[n] = mpp_get_dimlen(fid, "grid_xt")*2;
-	nlat[n] = mpp_get_dimlen(fid, "grid_yt")*2;
-	mpp_close(fid);
-      }
-      else {
-	if(nxbnds2 != ntiles || nybnds2 != ntiles ) mpp_error("make_hgrid: grid type is 'from_file', number entry entered "
-						"through --nlon and --nlat should be equal to number of files "
-							  "specified through --my_grid_file");
-      }
-    }
-    	/* for simplify purpose, currently we assume all the tile have the same grid size */
-    for(n=1; n<ntiles; n++) {
-      if( nlon[n] != nlon[0] || nlat[n] != nlat[0])  mpp_error("make_hgrid: grid_type is from_file, all the tiles should "
-							       "have same grid size, contact developer");
-    }
-  }
-  else if( strcmp(grid_type,"simple_cartesian_grid") ==0) {
-    strcpy(geometry, "planar");
-    strcpy(north_pole_tile, "none");
-    if(nxbnds1 != 2 || nybnds1 != 2 ) mpp_error("make_hgrid: grid type is 'simple_cartesian_grid', number entry entered "
-						"through --xbnds and --ybnds should be 2");
-    if(nxbnds2 != 1 || nybnds2 != 1 ) mpp_error("make_hgrid: grid type is 'simple_cartesian_grid', number entry entered "
-						"through --nlon and --nlat should be 1");
-    if(simple_dx == 0 || simple_dy == 0) mpp_error("make_hgrid: grid_type is 'simple_cartesian_grid', "
-						   "both simple_dx and simple_dy both should be specified");
-  }
-  else if ( strcmp(grid_type,"spectral_grid") ==0 ) {
-    if(nxbnds2 != 1 || nybnds2 != 1 ) mpp_error("make_hgrid: grid type is 'spectral_grid', number entry entered "
-						"through --nlon and --nlat should be 1");    
-  }
-  else if( strcmp(grid_type,"conformal_cubic_grid") ==0 ) {
-    strcpy(projection, "cube_gnomonic");
-    strcpy(conformal, "FALSE");
-    if(nxbnds2 != 1 ) mpp_error("make_hgrid: grid type is 'conformal_cubic_grid', number entry entered "
-				"through --nlon should be 1");
-    if(nratio < 1) mpp_error("make_hgrid: grid type is 'conformal_cubic_grid', nratio should be a positive integer");
-  }
-  else if(  !strcmp(grid_type,"gnomonic_ed") ) {
-    strcpy(projection, "cube_gnomonic");
-    strcpy(conformal, "FALSE");
-    if(nxbnds2 != 1 ) mpp_error("make_hgrid: grid type is 'gnomonic_cubic_grid', number entry entered "
-				"through --nlon should be 1");
-  }
-  else {
-    mpp_error("make_hgrid: only grid_type = 'regular_lonlat_grid', 'tripolar_grid', 'from_file', "
-	      "'gnomonic_ed', 'conformal_cubic_grid', 'simple_cartesian_grid' and "
-	      "'spectral_grid' is implemented");  
-  }
-  
-  /* get super grid size */
-
-  if( !strcmp(grid_type,"gnomonic_ed") || !strcmp(grid_type,"conformal_cubic_grid") ) {
-    nx = nlon[0];
-    ny = nx;
-  }
-  else {
-    nx = 0;
-    ny = 0;
-    for(n=0; n<nxbnds-1; n++) nx += nlon[n];
-    for(n=0; n<nybnds-1; n++) ny += nlat[n];  
-  }
-  nxp = nx + 1;
-  nyp = ny + 1;
-
-  if( !strcmp(grid_type,"gnomonic_ed") || !strcmp(grid_type,"conformal_cubic_grid") ) {
-    ntiles = 6;
-    /* Cubic grid is required to run on single processor.*/
-    if(mpp_npes() > 1) mpp_error( "make_hgrid: cubic grid generation must be run one processor, contact developer");
-  }
-  /* Currently we restrict nx can be divided by ndivx and ny can be divided by ndivy */
-  if(ntilex >0 && ntilex != ntiles) mpp_error("make_hgrid: number of entry specified through --ndivx does not equal ntiles");
-  if(ntiley >0 && ntiley != ntiles) mpp_error("make_hgrid: number of entry specified through --ndivy does not equal ntiles");   
-  for(n=0; n<ntiles; n++) {
-    if( nx%ndivx[n] ) mpp_error("make_hgrid: nx can not be divided by ndivx");
-    if( ny%ndivy[n] ) mpp_error("make_hgrid: ny can not be divided by ndivy");
-  }
-
-  if(strcmp(center,"none") && strcmp(center,"c_cell") && strcmp(center,"t_cell") )
-    mpp_error("make_hgrid: center should be 'none', 'c_cell' or 't_cell' ");
-  
-  /* set up domain decomposition, x and y will be on global domain and
-     other fields will be on compute domain. 
-  */
-
-  mpp_define_layout( nx, ny, mpp_npes(), layout);
-  mpp_define_domain2d( nx, ny, layout, 0, 0, &domain);
-  mpp_get_compute_domain2d(domain, &isc, &iec, &jsc, &jec);
-  nxc = iec - isc + 1;
-  nyc = jec - jsc + 1;
-
-  /* create grid information */
-  x        = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
-  y        = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
-  dx       = (double *) malloc(nxc*(nyc+1)*ntiles*sizeof(double));
-  dy       = (double *) malloc((nxc+1)*nyc*ntiles*sizeof(double));
-  area     = (double *) malloc(nxc    *nyc*ntiles*sizeof(double));
-  angle_dx = (double *) malloc((nxc+1)*(nyc+1)*ntiles*sizeof(double));
-  if( strcmp(conformal,"true") !=0 )angle_dy = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
-  
-  if(strcmp(grid_type,"regular_lonlat_grid") ==0) 
-    create_regular_lonlat_grid(&nxbnds, &nybnds, xbnds, ybnds, nlon, nlat, &isc, &iec, &jsc, &jec,
-			       x, y, dx, dy, area, angle_dx, center);
-  else if(strcmp(grid_type,"tripolar_grid") ==0) 
-    create_tripolar_grid(&nxbnds, &nybnds, xbnds, ybnds, nlon, nlat, &lat_join, &isc, &iec, &jsc, &jec,
-			 x, y, dx, dy, area, angle_dx, center);
-  else if( strcmp(grid_type,"from_file") ==0 ) {
-    for(n=0; n<ntiles; n++) {
-      int n1, n2, n3, n4;
-      n1 = n * nxp * nyp;
-      n2 = n * nx  * nyp;
-      n3 = n * nxp * ny;
-      n4 = n * nx  * ny;
-      create_grid_from_file(my_grid_file[n], &nx, &ny, x+n1, y+n1, dx+n2, dy+n3, area+n4, angle_dx+n1);
-    }
-  }
-  else if(strcmp(grid_type,"simple_cartesian_grid") ==0) 
-    create_simple_cartesian_grid(xbnds, ybnds, &nx, &ny, &simple_dx, &simple_dy, &isc, &iec, &jsc, &jec,
-				 x, y, dx, dy, area, angle_dx );
-  else if(strcmp(grid_type,"spectral_grid") ==0 )
-    create_spectral_grid(&nx, &ny, &isc, &iec, &jsc, &jec, x, y, dx, dy, area, angle_dx );
-  else if(strcmp(grid_type,"conformal_cubic_grid") ==0 ) 
-    create_conformal_cubic_grid(&nx, &nratio, method, orientation, x, y, dx, dy, area, angle_dx, angle_dy );
-  else if(strcmp(grid_type,"gnomonic_ed") ==0 ) 
-    create_gnomonic_cubic_grid(grid_type, &nx, x, y, dx, dy, area, angle_dx, angle_dy );
-  
-  /* write out data */
-  {
-    int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-    int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp, m;
-    size_t start[4], nwrite[4];
-    double *tmp, *gdata;
-    char tilename[128] = "";
-    char outfile[128] = "";
-    
-    l = 0;
-    for(n=0 ; n< ntiles; n++) {
-      for(j=0; j<ndivy[n]; j++) {
-	for(i=0; i<ndivx[n]; i++) {
-	  ++l;
-	  sprintf(tilename, "tile%d", l);
-	  if(ntiles>1)
-	    sprintf(outfile, "%s.tile%d.nc", gridname, l);
-	  else
-	    sprintf(outfile, "%s.nc", gridname);
-	  fid = mpp_open(outfile, MPP_WRITE);
-	  /* define dimenison */
-	  ni = nx/ndivx[n];
-	  nj = ny/ndivy[n];
-	  nip = ni + 1;
-	  njp = nj + 1;
-	  dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-	  dimlist[1] = mpp_def_dim(fid, "nx", ni);
-	  dimlist[2] = mpp_def_dim(fid, "ny", nj);
-	  dimlist[3] = mpp_def_dim(fid, "nxp", nip);
-	  dimlist[4] = mpp_def_dim(fid, "nyp", njp);
-	  /* define variable */
-	  if( strcmp(north_pole_tile, "none") == 0) /* no north pole, then no projection */
-	    id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 4, "standard_name", "grid_tile_spec",
-				  "geometry", geometry, "discretization", discretization, "conformal", conformal );
-	  else if( strcmp(projection, "none") == 0) 
-	    id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec",
-				  "geometry", geometry, "north_pole", north_pole_tile, "discretization",
-				  discretization, "conformal", conformal );
-	  else
-	    id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 6, "standard_name", "grid_tile_spec",
-				  "geometry", geometry, "north_pole", north_pole_tile, "projection", projection,
-				  "discretization", discretization, "conformal", conformal );
-	  dims[0] = dimlist[4]; dims[1] = dimlist[3];
-	  id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude",
-			     "units", "degree_east");
-	  id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude",
-			     "units", "degree_north");
-	  dims[0] = dimlist[4]; dims[1] = dimlist[1];
-	  id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance",
-			      "units", "meters");
-	  dims[0] = dimlist[2]; dims[1] = dimlist[3];
-	  id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance",
-			      "units", "meters");
-	  dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	  id_area = mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area",
-				"units", "m2" );
-	  dims[0] = dimlist[4]; dims[1] = dimlist[3];
-	  id_angle_dx = mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name",
-				    "grid_vertex_x_angle_WRT_geographic_east", "units", "degrees_east");
-	  if(strcmp(conformal, "true") != 0)
-	    id_angle_dy = mpp_def_var(fid, "angle_dy", MPP_DOUBLE, 2, dims, 2, "standard_name",
-				      "grid_vertex_y_angle_WRT_geographic_north", "units", "degrees_north");
-	  if( strcmp(north_pole_arcx, "none") == 0)
-	    id_arcx = mpp_def_var(fid, "arcx", MPP_CHAR, 1, dimlist, 1, "standard_name", "grid_edge_x_arc_type" );
-	  else
-	    id_arcx = mpp_def_var(fid, "arcx", MPP_CHAR, 1, dimlist, 2, "standard_name", "grid_edge_x_arc_type",
-				  "north_pole", north_pole_arcx );
-	  mpp_def_global_att(fid, "grid_version", grid_version);
-	  mpp_def_global_att(fid, "code_version", tagname);
-	  mpp_def_global_att(fid, "history", history);
-      
-	  mpp_end_def(fid);
-	  for(m=0; m<4; m++) { start[m] = 0; nwrite[m] = 0; }
-	  nwrite[0] = strlen(tilename);
-	  mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-
-          tmp = get_subregion(nxp, x+n*nxp*nyp, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-	  mpp_put_var_value(fid, id_x, tmp);
-	  free(tmp);
-          tmp = get_subregion(nxp, y+n*nxp*nyp, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-	  mpp_put_var_value(fid, id_y, tmp);
-	  free(tmp);
-	  gdata = (double *)malloc(nx*nyp*sizeof(double));
-	  mpp_global_field_double(domain, nxc, nyc+1, dx+n*nx*nyp, gdata);
-	  tmp = get_subregion( nx, gdata, i*ni, (i+1)*ni-1, j*nj, (j+1)*nj);
-	  mpp_put_var_value(fid, id_dx, tmp);
-	  free(tmp);
-	  free(gdata);
-	  gdata = (double *)malloc(nxp*ny*sizeof(double));
-	  mpp_global_field_double(domain, nxc+1, nyc, dy+n*nxp*ny, gdata);
-	  tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj-1);
-	  mpp_put_var_value(fid, id_dy, tmp);
-	  free(tmp);
-	  free(gdata);	  
-	  gdata = (double *)malloc(nx*ny*sizeof(double));
-	  mpp_global_field_double(domain, nxc, nyc, area+n*nx*ny, gdata);
-	  tmp = get_subregion( nx, gdata, i*ni, (i+1)*ni-1, j*nj, (j+1)*nj-1);
-	  mpp_put_var_value(fid, id_area, tmp);
-	  free(tmp);
-	  free(gdata);
-	  gdata = (double *)malloc(nxp*nyp*sizeof(double));
-	  mpp_global_field_double(domain, nxc+1, nyc+1, angle_dx+n*nxp*nyp, gdata);
-	  tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-	  mpp_put_var_value(fid, id_angle_dx, tmp);
-	  free(tmp);
-	  free(gdata);
-	  
-	  if(strcmp(conformal, "true") != 0) {
-	    gdata = (double *)malloc(nxp*nyp*sizeof(double));
-	    mpp_global_field_double(domain, nxc+1, nyc+1, angle_dy+n*nxp*nyp, gdata);
-	    tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-	    mpp_put_var_value(fid, id_angle_dy, tmp);
-	    free(tmp);
-	    free(gdata);
-	  }
-	  nwrite[0] = strlen(arcx);
-	  mpp_put_var_value_block(fid, id_arcx, start, nwrite, arcx );
-	  mpp_close(fid);
-	}
-      }
-    }
-  }
-
-  free(x);
-  free(y);
-  free(dx);
-  free(dy);
-  free(area);
-  free(angle_dx);
-  if(strcmp(conformal, "true") != 0) free(angle_dy);
-  if(mpp_pe() == mpp_root_pe()) printf("generate_grid is run successfully. \n");
-
-  mpp_end();
-
-  return 0;
-  
-};  /* end of main */
-
-
diff --git a/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.am b/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.am
deleted file mode 100644
index 1ce167f..0000000
--- a/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# make_solo_mosaic tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/08 11:30:58 ed Exp $
-
-bin_PROGRAMS = make_solo_mosaic gs_make_solo_mosaic
-make_solo_mosaic_SOURCES = get_contact.c get_contact.h	\
-make_solo_mosaic.c
-gs_make_solo_mosaic_SOURCES = get_contact.c get_contact.h	\
-gs_make_solo_mosaic.c
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.in b/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.in
deleted file mode 100644
index d9c8ca6..0000000
--- a/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.in
+++ /dev/null
@@ -1,532 +0,0 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
- at SET_MAKE@
-
-# This automake file is in charge of building the gridspec
-# make_solo_mosaic tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/08 11:30:58 ed Exp $
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-bin_PROGRAMS = make_solo_mosaic$(EXEEXT) gs_make_solo_mosaic$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
- at USE_NETCDF_DIR_TRUE@am__append_1 = -I at NETCDFDIR@/include
- at USE_NETCDF_DIR_TRUE@am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/make_solo_mosaic
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
-	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
-	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
-	$(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
-CONFIG_CLEAN_FILES =
-am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-PROGRAMS = $(bin_PROGRAMS)
-am_gs_make_solo_mosaic_OBJECTS = get_contact.$(OBJEXT) \
-	gs_make_solo_mosaic.$(OBJEXT)
-gs_make_solo_mosaic_OBJECTS = $(am_gs_make_solo_mosaic_OBJECTS)
-gs_make_solo_mosaic_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-gs_make_solo_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_make_solo_mosaic_OBJECTS = get_contact.$(OBJEXT) \
-	make_solo_mosaic.$(OBJEXT)
-make_solo_mosaic_OBJECTS = $(am_make_solo_mosaic_OBJECTS)
-make_solo_mosaic_LDADD = $(LDADD)
-make_solo_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
-SOURCES = $(gs_make_solo_mosaic_SOURCES) $(make_solo_mosaic_SOURCES)
-DIST_SOURCES = $(gs_make_solo_mosaic_SOURCES) \
-	$(make_solo_mosaic_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ALLOCA = @ALLOCA@
-AMTAR = @AMTAR@
-AR = @AR@
-AS = @AS@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DLLTOOL = @DLLTOOL@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FC = @FC@
-FCFLAGS = @FCFLAGS@
-FFLAGS = @FFLAGS@
-FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
-GREP = @GREP@
-HDF5DIR = @HDF5DIR@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LD = @LD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIPO = @LIPO@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
-MKDIR_P = @MKDIR_P@
-NETCDFDIR = @NETCDFDIR@
-NM = @NM@
-NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-RANLIB = @RANLIB@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WHATIS = @WHATIS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-ac_ct_F77 = @ac_ct_F77@
-ac_ct_FC = @ac_ct_FC@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-prog = @prog@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-make_solo_mosaic_SOURCES = get_contact.c get_contact.h	\
-make_solo_mosaic.c
-
-gs_make_solo_mosaic_SOURCES = get_contact.c get_contact.h	\
-gs_make_solo_mosaic.c
-
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
-AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
-	@for dep in $?; do \
-	  case '$(am__configure_deps)' in \
-	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
-	      exit 1;; \
-	  esac; \
-	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_solo_mosaic/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/make_solo_mosaic/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	@case '$?' in \
-	  *config.status*) \
-	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
-	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
-	esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure:  $(am__configure_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-install-binPROGRAMS: $(bin_PROGRAMS)
-	@$(NORMAL_INSTALL)
-	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
-
-uninstall-binPROGRAMS:
-	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
-
-clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-gs_make_solo_mosaic$(EXEEXT): $(gs_make_solo_mosaic_OBJECTS) $(gs_make_solo_mosaic_DEPENDENCIES) 
-	@rm -f gs_make_solo_mosaic$(EXEEXT)
-	$(LINK) $(gs_make_solo_mosaic_OBJECTS) $(gs_make_solo_mosaic_LDADD) $(LIBS)
-make_solo_mosaic$(EXEEXT): $(make_solo_mosaic_OBJECTS) $(make_solo_mosaic_DEPENDENCIES) 
-	@rm -f make_solo_mosaic$(EXEEXT)
-	$(LINK) $(make_solo_mosaic_OBJECTS) $(make_solo_mosaic_LDADD) $(LIBS)
-
-mostlyclean-compile:
-	-rm -f *.$(OBJEXT)
-
-distclean-compile:
-	-rm -f *.tab.c
-
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/get_contact.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_make_solo_mosaic.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_solo_mosaic.Po at am__quote@
-
-.c.o:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
-
-.c.obj:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.c.lo:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
- at am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
-	-rm -f *.lo
-
-clean-libtool:
-	-rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
-	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
-	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
-	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
-
-GTAGS:
-	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
-	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	list='$(DISTFILES)'; \
-	  dist_files=`for file in $$list; do echo $$file; done | \
-	  sed -e "s|^$$srcdirstrip/||;t" \
-	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
-	case $$dist_files in \
-	  */*) $(MKDIR_P) `echo "$$dist_files" | \
-			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
-			   sort -u` ;; \
-	esac; \
-	for file in $$dist_files; do \
-	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  if test -d $$d/$$file; then \
-	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
-	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
-	    || exit 1; \
-	  fi; \
-	done
-check-am: all-am
-check: check-am
-all-am: Makefile $(PROGRAMS)
-installdirs:
-	for dir in "$(DESTDIR)$(bindir)"; do \
-	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
-	done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-
-maintainer-clean-generic:
-	@echo "This command is intended for maintainers to use"
-	@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
-
-distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-exec-am: install-binPROGRAMS
-
-install-html: install-html-am
-
-install-info: install-info-am
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-ps: install-ps-am
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-binPROGRAMS
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-libtool ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-binPROGRAMS install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am \
-	uninstall-binPROGRAMS
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.c b/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.c
deleted file mode 100644
index 43a977a..0000000
--- a/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.c
+++ /dev/null
@@ -1,326 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-#include "mosaic_util.h"
-#include "get_contact.h"
-
-
-/************************************************************************************************
-         int get_align_contact(
-  This routine will return number of algined contacts bewteen two tiles (line contact).
-  This routine assume the starting and ending points of the  contact line are coincidence with
-  the grid points of both tiles. lrg_rectangle tiles are assumed. 
-  It will return the contact information, which includes 
-
-*************************************************************************************************/
-
-double* east_bound(const double *data, int nx, int ny);
-double* west_bound(const double *data, int nx, int ny);
-double* south_bound(const double *data, int nx, int ny);
-double* north_bound(const double *data, int nx, int ny);
-#define EPSLN (1.0e-10)
-
-int get_align_contact(int tile1, int tile2, int nx1, int ny1, int nx2, int ny2, 
-                      const double *x1, const double *y1, const double *x2, 
-                      const double *y2, double periodx, double periody,
-		      int *istart1, int *iend1, int *jstart1, int *jend1, 
-                      int *istart2, int *iend2, int *jstart2, int *jend2)
-{
-  double *xb1, *yb1, *xb2, *yb2;
-  int ncontact, start1, end1, start2, end2;
-  
-  ncontact = 0;
-  /* East bound of tile1 and west bound of tile2 */
-  xb1 = east_bound(x1, nx1, ny1);
-  yb1 = east_bound(y1, nx1, ny1);
-  xb2 = west_bound(x2, nx2, ny2);
-  yb2 = west_bound(y2, nx2, ny2);
-  if( get_contact_index( ny1, ny2, xb1, yb1, xb2, yb2, periodx, 0.0, &start1, &end1, &start2, &end2) ) {
-    istart1[ncontact] = nx1-1;
-    iend1[ncontact]   = nx1-1;
-    istart2[ncontact] = 1;
-    iend2[ncontact]   = 1;    
-    jstart1[ncontact] = start1;
-    jend1[ncontact]   = end1;
-    jstart2[ncontact] = start2;
-    jend2[ncontact]   = end2;
-    ncontact++;   
-  }
-
-  /* East bound of tile1 and SOUTH bound of tile2, tile1 and tile must be different tile */
-  if(tile1 != tile2) {
-    free(xb2);
-    free(yb2);
-    xb2 = south_bound(x2, nx2, ny2);
-    yb2 = south_bound(y2, nx2, ny2);
-    if( get_contact_index( ny1, nx2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = nx1-1;
-      iend1[ncontact]   = nx1-1;
-      istart2[ncontact] = start2;
-      iend2[ncontact]   = end2;    
-      jstart1[ncontact] = start1;
-      jend1[ncontact]   = end1;
-      jstart2[ncontact] = 1;
-      jend2[ncontact]   = 1;
-      ncontact++;
-    }
-  }
-  free(xb1);
-  free(yb1);   
-  free(xb2);
-  free(yb2);  
-  
-  /* South bound of tile1 and NORTH bound of tile2 */
-  xb1 = south_bound(x1, nx1, ny1);
-  yb1 = south_bound(y1, nx1, ny1);
-  xb2 = north_bound(x2, nx2, ny2);
-  yb2 = north_bound(y2, nx2, ny2);
-  if( get_contact_index( nx1, nx2, xb1, yb1, xb2, yb2, 0.0, periody, &start1, &end1, &start2, &end2) ) {
-    istart1[ncontact] = start1;
-    iend1[ncontact]   = end1;
-    istart2[ncontact] = start2;
-    iend2[ncontact]   = end2;    
-    jstart1[ncontact] = 1;
-    jend1[ncontact]   = 1;
-    jstart2[ncontact] = ny2-1;
-    jend2[ncontact]   = ny2-1;
-    ncontact++;
-  }
-
-  /* South bound of tile1 and East bound of tile2, tile1 and tile must be different tile*/  
-  if(tile1 != tile2 ) {
-    free(xb2);
-    free(yb2);
-    xb2 = east_bound(x2, nx2, ny2);
-    yb2 = east_bound(y2, nx2, ny2);
-    if( get_contact_index( nx1, ny2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = start1;
-      iend1[ncontact]   = end1;
-      istart2[ncontact] = nx2-1;
-      iend2[ncontact]   = nx2-1;    
-      jstart1[ncontact] = 1;
-      jend1[ncontact]   = 1;
-      jstart2[ncontact] = start2;
-      jend2[ncontact]   = end2;
-      ncontact++;
-    }
-  }
-  free(xb1);
-  free(yb1);   
-  free(xb2);
-  free(yb2);  
-
-  /* to avoid duplicate, the following will be done only when tile1 not equal to tile2 */
-  if(tile1 != tile2) {
-    /* West bound of tile1 and east bound of tile2*/
-    xb1 = west_bound(x1, nx1, ny1);
-    yb1 = west_bound(y1, nx1, ny1);
-    xb2 = east_bound(x2, nx2, ny2);
-    yb2 = east_bound(y2, nx2, ny2);
-    if( get_contact_index( ny1, ny2, xb1, yb1, xb2, yb2, periodx, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = 1;
-      iend1[ncontact]   = 1;
-      istart2[ncontact] = nx2-1;
-      iend2[ncontact]   = nx2-1;    
-      jstart1[ncontact] = start1;
-      jend1[ncontact]   = end1;
-      jstart2[ncontact] = start2;
-      jend2[ncontact]   = end2;
-      ncontact++;
-    }
-    free(xb2);
-    free(yb2);
-
-    /* West bound of tile1 and North bound of tile2 */  
-    xb2 = north_bound(x2, nx2, ny2);
-    yb2 = north_bound(y2, nx2, ny2);
-    if( get_contact_index( ny1, nx2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = 1;
-      iend1[ncontact]   = 1;
-      istart2[ncontact] = start2;
-      iend2[ncontact]   = end2;    
-      jstart1[ncontact] = start1;
-      jend1[ncontact]   = end1;
-      jstart2[ncontact] = ny2-1;
-      jend2[ncontact]   = ny2-1;
-      ncontact++;
-    }
-    free(xb1);
-    free(yb1);   
-    free(xb2);
-    free(yb2);  
-
-  
-    /* North bound of tile1 and South bound of tile2 */
-    xb1 = north_bound(x1, nx1, ny1);
-    yb1 = north_bound(y1, nx1, ny1);
-    xb2 = south_bound(x2, nx2, ny2);
-    yb2 = south_bound(y2, nx2, ny2);
-    if( get_contact_index( nx1, nx2, xb1, yb1, xb2, yb2, 0.0, periody, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = start1;
-      iend1[ncontact]   = end1;
-      istart2[ncontact] = start2;
-      iend2[ncontact]   = end2;    
-      jstart1[ncontact] = ny1-1;
-      jend1[ncontact]   = ny1-1;
-      jstart2[ncontact] = 1;
-      jend2[ncontact]   = 1;
-      ncontact++;
-    }
-    free(xb2);
-    free(yb2);
-
-    /* North bound of tile1 and West bound of tile2 */  
-    xb2 = west_bound(x2, nx2, ny2);
-    yb2 = west_bound(y2, nx2, ny2);
-    if( get_contact_index( nx1, ny2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = start1;
-      iend1[ncontact]   = end1;
-      istart2[ncontact] = 1;
-      iend2[ncontact]   = 1;    
-      jstart1[ncontact] = ny1-1;
-      jend1[ncontact]   = ny1-1;
-      jstart2[ncontact] = start2;
-      jend2[ncontact]   = end2;
-      ncontact++;
-    }
-    free(xb1);
-    free(yb1);   
-    free(xb2);
-    free(yb2);  
-  }
-
-  /* when tile1 = tile2, we need to consider about folded. Only foled north is considered here */
-  if(tile1 == tile2) {
-    int i, folded = 1;
-    double dx;
-    xb1 = north_bound(x1, nx1, ny1);
-    yb1 = north_bound(y1, nx1, ny1);
-    for(i=0; i<nx1/2; i++) {
-      if( yb1[i] != yb1[nx1-i-1] ) {
-	folded = 0;
-	break;
-      }
-      dx = fabs(xb1[i] - xb1[nx1-i-1]);
-      if( dx !=0 && dx != 360 ) {
-	folded = 0;
-	break;
-      }
-    }
-    if(folded) {
-      istart1[ncontact] = 1;
-      iend1[ncontact]   = nx1/2;
-      istart2[ncontact] = nx1-1;
-      iend2[ncontact]   = nx1/2+1;    
-      jstart1[ncontact] = ny1-1;
-      jend1[ncontact]   = ny1-1;
-      jstart2[ncontact] = ny1-1;
-      jend2[ncontact]   = ny1-1;
-      ncontact++;
-    }
-    free(xb1);
-    free(yb1);
-  }
-  
-  return ncontact;
-  
-};
-
-
-int get_contact_index( int size1, int size2, double *x1, double *y1, double *x2, double *y2, double periodx,
-		       double periody, int *start1, int *end1, int *start2, int *end2)
-{
-  int i1, i2;
-  double dx, dy;
-
-  /* Find the first point in tile 1 cocindent with a point in tile2  */
-  *start1 = -1;
-  *start2 = -1;
-  for(i1=0; i1<size1; i1++) {
-    for(i2=0; i2<size2; i2++) {
-      dx = fabs(x1[i1]- x2[i2]);
-      dx = min(dx, fabs(dx-periodx));
-      dy = fabs(y1[i1]- y2[i2]);
-      dy = min(dy, fabs(dy-periody));
-      if( dx < EPSLN && dy <EPSLN ) {
-	*start1 = i1+1;
-	*start2 = i2+1;
-	goto foundstart;
-      }
-    }
-  }
-
-  return 0;
-    
-  foundstart:
-
-  /* Find the last point in tile 1 cocindent with a point in tile2 */
-  *end1 = -1;
-  *end2 = -1;
-  for(i1=size1-1; i1>=0; i1--) {
-    for(i2=size2-1; i2>=0; i2--) {
-      dx = fabs(x1[i1]- x2[i2]);
-      dx = min(dx, fabs(dx-periodx));
-      dy = fabs(y1[i1]- y2[i2]);
-      dy = min(dy, fabs(dy-periody));
-      if( dx < EPSLN && dy <EPSLN ) {
-	*end1 = i1+1;
-	*end2 = i2+1;
-	goto foundend;
-      }
-    }
-  }
-
-  return 0;
-    
- foundend: if( *start1 == *end1 || *start2 == *end2 ) return 0;
-
-  if(*start1 > *end1 )
-    (*start1)--;
-  else
-    (*end1)--;
-
-  if(*start2 > *end2 )
-    (*start2)--;
-  else
-    (*end2)--;  
-
-  return 1;
-    
-};
-
-
-double* west_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(ny*sizeof(double));
-  for(i=0; i<ny; i++) bnd[i] = data[i*nx];
-  return bnd;
-}
-
-double* east_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(ny*sizeof(double));
-  for(i=0; i<ny; i++) bnd[i] = data[i*nx+nx-1];
-  return bnd;
-}
-
-double* south_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(nx*sizeof(double));
-  for(i=0; i<nx; i++) bnd[i] = data[i];
-  return bnd;
-}
-
-double* north_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(nx*sizeof(double));
-  for(i=0; i<nx; i++) bnd[i] = data[(ny-1)*nx+i];
-  return bnd;
-}
diff --git a/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.h b/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.h
deleted file mode 100644
index c881609..0000000
--- a/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef GET_CONTACT_
-#define GET_CONTACT_
-/**********************************************************************
-                       get_contact.h
-    This header file is used to compute aligned-contact between tiles
-**********************************************************************/
-
-int get_align_contact(int tile1, int tile2, int nx1, int ny1, int nx2, int ny2, 
-                      const double *x1, const double *y1, const double *x2, 
-                      const double *y2, double periodx, double periody,
-		      int *istart1, int *iend1, int *jstart1, int *jend1, 
-                      int *istart2, int *iend2, int *jstart2, int *jend2);
-#endif
diff --git a/gridspec_tools_20080702/tools/make_solo_mosaic/gs_make_solo_mosaic.c b/gridspec_tools_20080702/tools/make_solo_mosaic/gs_make_solo_mosaic.c
deleted file mode 100644
index 748ddfb..0000000
--- a/gridspec_tools_20080702/tools/make_solo_mosaic/gs_make_solo_mosaic.c
+++ /dev/null
@@ -1,152 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include "get_contact.h"
-#include "constant.h"
-#include "mpp_io.h"
-
-char *usage[] = {
-   "",
-   " make_solo_mosaic --num_tiles ntiles --dir directory [--mosaic_name mosaic_name] ",
-   "                 [--tile_file tile_file] [--periodx #] [--periody #]             ",
-   "                                                                                 ",
-   "make_solo_mosaic generates Mosaic information between tiles. The mosaic          ",
-   "information includes: list of tile files, list of contact region                 ",
-   "specified by index, contact type.                                                ",
-   "                                                                                 ",
-   "make_solo_mosaic takes the following flags:                                      ",
-   "                                                                                 ",
-   "REQUIRED:                                                                        ",
-   "                                                                                 ",
-   "--num_tiles ntiles     Number of tiles in the mosaic.                            ",
-   "                                                                                 ",
-   "--dir directory        The directory that contains all the tile grid file.       ",
-   "                                                                                 ",
-   "OPTIONAL FLAGS                                                                   ",
-   "                                                                                 ",
-   "--mosaic_name name     mosaic name. The output file will be mosaic_name.nc.      ",
-   "                       default is 'mosaic'.                                      ",
-   "                                                                                 ",
-   "--tile_file tile_file  Grid file name of all tiles in the mosaic. The file name  ",
-   "                       should be relative file name ( exclude the absolute       "
-   "                       file path). The absolute file path will be dir/tile_file. ",
-   "                       If this option is not specified, the tile_file will be    ",
-   "                       'horizontal_grid.tile#.nc'                                ",
-   "                                                                                 ",
-   "--periodx #             Specify the period in x-direction of mosaic. Default     ",
-   "                        value is 0 (not periodic).                               ",
-   "                                                                                 ",
-   "--periody #             Specify the period in y-direction of mosaic. Default     ",
-   "                        value is 0 (not periodic).                               ",  
-   NULL};
- 
-const int MAXTILE = 100;
-const int MAXCONTACT = 100;
-const int SHORTSTRING = 32;
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
-
-main (int argc, char *argv[])
-{
-  
-   extern char *optarg;
-   char *pch=NULL, *dir=NULL, history[512], entry[1280];
-   char tilefile[MAXTILE][STRING], tiletype[MAXTILE][SHORTSTRING];
-   char tile_name[MAXTILE][STRING];
-   int ntiles=0, nfiles=0, ncontact=0;
-   int *nxp, *nyp;
-   double **x, **y;
-   double periodx=0, periody=0;
-   int contact_tile1[MAXCONTACT], contact_tile2[MAXCONTACT];
-   int contact_tile1_istart[MAXCONTACT], contact_tile1_iend[MAXCONTACT];
-   int contact_tile1_jstart[MAXCONTACT], contact_tile1_jend[MAXCONTACT];
-   int contact_tile2_istart[MAXCONTACT], contact_tile2_iend[MAXCONTACT];
-   int contact_tile2_jstart[MAXCONTACT], contact_tile2_jend[MAXCONTACT];
-   char mosaic_name[128] = "solo_mosaic";
-   char grid_descriptor[128] = "";
-   int c, i, n, m, l, errflg;
-   int ret;
-  
-   int option_index = 0;
-   static struct option long_options[] = {
-      {"mosaic_name",     required_argument, NULL, 'm'},
-      {"num_tiles",       required_argument, NULL, 'n'},
-      {"grid_descriptor", required_argument, NULL, 'g'},
-      {"tile_file",       required_argument, NULL, 'f'},  
-      {"periodx",         required_argument, NULL, 'x'},
-      {"periody",         required_argument, NULL, 'y'},
-      {"directory",       required_argument, NULL, 'd'},
-      {NULL, 0, NULL, 0}
-   };
-
-   mpp_init(&argc, &argv);
-   /* this tool must be run one processor */
-   if(mpp_npes()>1) mpp_error("make_solo_mosaic: this tool must be run on one processor");
-  
-   errflg = (argc == 1);
-   /* First read command line arguments. */
-
-   while ((c = getopt_long(argc, argv, "h", long_options, &option_index)) != -1) {
-      switch (c) {
-	 case 'n':
-	    ntiles = atoi(optarg);
-	    break;
-	 case 'm':
-	    strcpy(mosaic_name, optarg);
-	    break;
-	 case 'g':
-	    strcpy(grid_descriptor, optarg);
-	    break;
-	 case 'f':
-	    strcpy(entry, optarg); 
-	    pch = strtok(entry, ", ");
-	    nfiles = 0;
-	    while( pch != NULL) {
-	       strcpy(tilefile[nfiles++], pch);
-	       pch = strtok(NULL, ", ");
-	    }
-	    break;
-	 case 'x':
-	    periodx = atof(optarg);
-	    break;
-	 case 'y':
-	    periody = atof(optarg);
-	    break; 
-	 case 'd':  // path of the simple grid file.
-	    dir = optarg;
-	    break;
-	 case '?':
-	    errflg++;
-      }
-   }
-
-   if (errflg || ntiles < 1 || !dir ) {
-      char **u = usage;
-      while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-      exit(2);      
-   }
-
-   strcpy(history,argv[0]);
-
-   for(i=1;i<argc;i++) {
-      strcat(history, " ");
-      strcat(history, argv[i]);
-   }
-
-   if(ntiles > MAXTILE) {
-      mpp_error("make_solo_mosaic: number of tiles is greater than MAXTILE.");
-   }
-
-   if ((ret = gs_make_solo_mosaic(history, ntiles, mosaic_name, grid_descriptor,
-                                  tilefile, periodx, periody, dir)))
-      return ret;
-  
-   printf("congradulation: You have successfully run make_solo_mosaic\n");
-
-   return 0;
-  
-}; // end of main
-
-
-
diff --git a/gridspec_tools_20080702/tools/make_solo_mosaic/make_solo_mosaic.c b/gridspec_tools_20080702/tools/make_solo_mosaic/make_solo_mosaic.c
deleted file mode 100644
index 3f7bf27..0000000
--- a/gridspec_tools_20080702/tools/make_solo_mosaic/make_solo_mosaic.c
+++ /dev/null
@@ -1,287 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include "get_contact.h"
-#include "constant.h"
-#include "mpp_io.h"
-
-char *usage[] = {
-  "",
-  " make_solo_mosaic --num_tiles ntiles --dir directory [--mosaic_name mosaic_name] ",
-  "                 [--tile_file tile_file] [--periodx #] [--periody #]             ",
-  "                                                                                 ",
-  "make_solo_mosaic generates Mosaic information between tiles. The mosaic          ",
-  "information includes: list of tile files, list of contact region                 ",
-  "specified by index, contact type.                                                ",
-  "                                                                                 ",
-  "make_solo_mosaic takes the following flags:                                      ",
-  "                                                                                 ",
-  "REQUIRED:                                                                        ",
-  "                                                                                 ",
-  "--num_tiles ntiles     Number of tiles in the mosaic.                            ",
-  "                                                                                 ",
-  "--dir directory        The directory that contains all the tile grid file.       ",
-  "                                                                                 ",
-  "OPTIONAL FLAGS                                                                   ",
-  "                                                                                 ",
-  "--mosaic_name name     mosaic name. The output file will be mosaic_name.nc.      ",
-  "                       default is 'mosaic'.                                      ",
-  "                                                                                 ",
-  "--tile_file tile_file  Grid file name of all tiles in the mosaic. The file name  ",
-  "                       should be relative file name ( exclude the absolute       "
-  "                       file path). The absolute file path will be dir/tile_file. ",
-  "                       If this option is not specified, the tile_file will be    ",
-  "                       'horizontal_grid.tile#.nc'                                ",
-  "                                                                                 ",
-  "--periodx #             Specify the period in x-direction of mosaic. Default     ",
-  "                        value is 0 (not periodic).                               ",
-  "                                                                                 ",
-  "--periody #             Specify the period in y-direction of mosaic. Default     ",
-  "                        value is 0 (not periodic).                               ",  
-  NULL};
- 
-const int MAXTILE = 100;
-const int MAXCONTACT = 100;
-const int SHORTSTRING = 32;
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
-
-main (int argc, char *argv[])
-{
-  
-  extern char *optarg;
-  char *pch=NULL, *dir=NULL, history[512], entry[1280];
-  char tilefile[MAXTILE][STRING], tiletype[MAXTILE][SHORTSTRING];
-  char tile_name[MAXTILE][STRING];
-  int ntiles=0, nfiles=0, ncontact=0;
-  int *nxp, *nyp;
-  double **x, **y;
-  double periodx=0, periody=0;
-  int contact_tile1[MAXCONTACT], contact_tile2[MAXCONTACT];
-  int contact_tile1_istart[MAXCONTACT], contact_tile1_iend[MAXCONTACT];
-  int contact_tile1_jstart[MAXCONTACT], contact_tile1_jend[MAXCONTACT];
-  int contact_tile2_istart[MAXCONTACT], contact_tile2_iend[MAXCONTACT];
-  int contact_tile2_jstart[MAXCONTACT], contact_tile2_jend[MAXCONTACT];
-  char mosaic_name[128] = "solo_mosaic";
-  char grid_descriptor[128] = "";
-  int c, i, n, m, l, errflg;
-  
-  int option_index = 0;
-  static struct option long_options[] = {
-    {"mosaic_name",     required_argument, NULL, 'm'},
-    {"num_tiles",       required_argument, NULL, 'n'},
-    {"grid_descriptor", required_argument, NULL, 'g'},
-    {"tile_file",       required_argument, NULL, 'f'},  
-    {"periodx",         required_argument, NULL, 'x'},
-    {"periody",         required_argument, NULL, 'y'},
-    {"directory",       required_argument, NULL, 'd'},
-    {NULL, 0, NULL, 0}
-  };
-
-  mpp_init(&argc, &argv);
-  /* this tool must be run one processor */
-  if(mpp_npes()>1) mpp_error("make_solo_mosaic: this tool must be run on one processor");
-  
-  errflg = (argc == 1);
-  /* First read command line arguments. */
-
-  while ((c = getopt_long(argc, argv, "h", long_options, &option_index)) != -1) {
-    switch (c) {
-    case 'n':
-      ntiles = atoi(optarg);
-      break;
-    case 'm':
-      strcpy(mosaic_name, optarg);
-      break;
-    case 'g':
-      strcpy(grid_descriptor, optarg);
-      break;
-    case 'f':
-      strcpy(entry, optarg); 
-      pch = strtok(entry, ", ");
-      nfiles = 0;
-      while( pch != NULL) {
-        strcpy(tilefile[nfiles++], pch);
-	pch = strtok(NULL, ", ");
-      }
-      break;
-    case 'x':
-      periodx = atof(optarg);
-      break;
-    case 'y':
-      periody = atof(optarg);
-      break; 
-    case 'd':  // path of the simple grid file.
-      dir = optarg;
-      break;
-    case '?':
-      errflg++;
-    }
-  }
-
-  if (errflg || ntiles < 1 || !dir ) {
-    char **u = usage;
-    while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-    exit(2);      
-  }
-
-  strcpy(history,argv[0]);
-
-  for(i=1;i<argc;i++) {
-    strcat(history, " ");
-    strcat(history, argv[i]);
-  }
-
-  if(ntiles > MAXTILE) {
-    mpp_error("make_solo_mosaic: number of tiles is greater than MAXTILE.");
-  }
-    
-  /*--- if file name is not specified through -f, file name will be horizontal_grid.tile#.nc */
-  if(nfiles == 0) {
-    if(ntiles == 1) {
-      sprintf(tilefile[0],"horizontal_grid.nc");
-    }
-    else {
-      for(n=0; n<ntiles; n++) {
-	sprintf(tilefile[n],"horizontal_grid.tile%d.nc",n+1);
-      }
-    }
-  }
-  else { /* Check if ntile are matching number of grid file passed through -f */
-    if( nfiles != ntiles) mpp_error("make_solo_mosaic: number of grid files specified through -n "
-				   " does not equal to number of files specified through -f = ");
-  }
-
-  n = strlen(dir);
-  if( dir[n-1] != '/') strcat(dir, "/");
-
-  /*First read all the grid files.*/
-  nxp = (int *)malloc(ntiles*sizeof(int));
-  nyp = (int *)malloc(ntiles*sizeof(int));
-  x = (double **)malloc(ntiles*sizeof(double *));
-  y = (double **)malloc(ntiles*sizeof(double *));
-  for(n=0; n<ntiles; n++) {
-    char filepath[512];
-    int fid, vid;
-    sprintf(filepath, "%s%s",dir, tilefile[n]);
-    fid = mpp_open(filepath, MPP_READ);
-    nxp[n] = mpp_get_dimlen(fid, "nxp");
-    nyp[n] = mpp_get_dimlen(fid, "nyp");
-    x[n] = (double *)malloc(nxp[n]*nyp[n]*sizeof(double));
-    y[n] = (double *)malloc(nxp[n]*nyp[n]*sizeof(double));
-    vid = mpp_get_varid(fid, "tile");
-    mpp_get_var_value(fid, vid, tile_name[n]);
-    vid = mpp_get_varid(fid, "x");
-    mpp_get_var_value(fid, vid, x[n]);
-    vid = mpp_get_varid(fid, "y");
-    mpp_get_var_value(fid, vid, y[n]);
-    mpp_close(fid);
-  }
-
-
-  /*find the contact region between tiles, currently assume the contact region are align-contact
-    There should be no contact between same directions of two tiles ( w-w, e-e, s-s, n-n)
-    We assume no contact between w-s, e-n ( will added in if needed ) . */
-  ncontact = 0;
-  for(n=0; n<ntiles; n++) {
-    for(m=n; m<ntiles; m++) {
-      int count;
-      int istart1[MAXCONTACT], iend1[MAXCONTACT], jstart1[MAXCONTACT], jend1[MAXCONTACT];
-      int istart2[MAXCONTACT], iend2[MAXCONTACT], jstart2[MAXCONTACT], jend2[MAXCONTACT];
-      count = get_align_contact(n+1, m+1, nxp[n], nyp[n], nxp[m], nyp[m], x[n], y[n], x[m], y[m],
-				periodx, periody, istart1, iend1, jstart1, jend1, istart2, iend2,
-				jstart2, jend2);
-      if(ncontact+count>MAXCONTACT) mpp_error("make_solo_mosaic: number of contacts is more than MAXCONTACT");
-      for(l=0; l<count; l++) {
-	contact_tile1_istart[ncontact] = istart1[l];
-	contact_tile1_iend  [ncontact] = iend1[l];
-	contact_tile1_jstart[ncontact] = jstart1[l];
-	contact_tile1_jend  [ncontact] = jend1[l];
-	contact_tile2_istart[ncontact] = istart2[l];
-	contact_tile2_iend  [ncontact] = iend2[l];
-	contact_tile2_jstart[ncontact] = jstart2[l];
-	contact_tile2_jend  [ncontact] = jend2[l];
-	contact_tile1       [ncontact] = n;
-	contact_tile2       [ncontact] = m;
-	ncontact++;
-      }
-    }
-  }
-
-  /* write out data */
-  {
-    char str[STRING], outfile[STRING];
-    int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-    int id_contact_index, id_griddir, id_gridfiles, dim[2];
-    size_t start[4], nwrite[4];
-
-    sprintf(outfile, "%s.nc", mosaic_name);
-    fid = mpp_open(outfile, MPP_WRITE);
-    /* define dimenison */
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-    dim_string = mpp_def_dim(fid, "string", STRING);    
-    /* define variable */
-    id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 4, "standard_name",
-			    "grid_mosaic_spec", "children", "gridtiles", "contact_regions", "contacts",
-			    "grid_descriptor", grid_descriptor);
-    dim[0] = dim_ntiles; dim[1] = dim_string;
-    id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-			       "standard_name", "grid_file_location");
-    id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-    id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-    if(ncontact>0) {
-      dim[0] = dim_ncontact; dim[1] = dim_string;
-      id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-				"contact_type", "boundary", "alignment", "true",
-				"contact_index", "contact_index", "orientation", "orient");
-      id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-				     "starting_ending_point_index_of_contact");
-
-    }
-    mpp_def_global_att(fid, "grid_version", grid_version);
-    mpp_def_global_att(fid, "code_version", tagname);
-    mpp_def_global_att(fid, "history", history);
-    mpp_end_def(fid);
-
-    /* write out data */
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-    nwrite[0] = strlen(mosaic_name);
-    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-    nwrite[0] = strlen(dir);
-    mpp_put_var_value_block(fid, id_griddir, start, nwrite, dir);
-    nwrite[0] = 1;
-    for(n=0; n<ntiles; n++) {
-      start[0] = n; nwrite[1] = strlen(tile_name[n]);
-      mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-      nwrite[1] = strlen(tilefile[n]);
-      mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-    }
-    
-    for(n=0; n<ncontact; n++) {
-      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-	      tile_name[contact_tile2[n]]);
-      start[0] = n; nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-	      contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-	      contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-      nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-    }
-    mpp_close(fid);    
-  }
-
-  
-  printf("congradulation: You have successfully run make_solo_mosaic\n");
-
-  return 0;
-  
-}; // end of main
-
-
-
diff --git a/gridspec_tools_20080702/tools/make_topog/Makefile.am b/gridspec_tools_20080702/tools/make_topog/Makefile.am
deleted file mode 100644
index 4a39d34..0000000
--- a/gridspec_tools_20080702/tools/make_topog/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# make_topog tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/07 22:02:40 ed Exp $
-
-bin_PROGRAMS = make_topog gs_make_topog
-make_topog_SOURCES = make_topog.c  topog.c  topog.h
-gs_make_topog_SOURCES = make_topog.c  topog.c  topog.h
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/make_topog/topog.c b/gridspec_tools_20080702/tools/make_topog/topog.c
deleted file mode 100644
index 0f9e5a0..0000000
--- a/gridspec_tools_20080702/tools/make_topog/topog.c
+++ /dev/null
@@ -1,542 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include "topog.h"
-#include "create_xgrid.h"
-#include "mosaic_util.h"
-#include "mpp_io.h"
-
-#define D2R (M_PI/180.)
-
-void filter_topo( int nx, int ny, int num_pass, int smooth_topo_allow_deepening, double *depth);
-void set_depth(int nx, int ny, const double *xbnd, const double *ybnd, double alat1, double slon1,
-	       double elon1, double alat2, double slon2, double elon2, double depth_in, double *depth);
-void enforce_min_depth(int nx, int ny, int round_shallow, int deepen_shallow,
-		       int fill_shallow, double min_depth, double *depth);
-
-/*********************************************************************
-   void create_rectangular_topog()
-   Constructing a rectangular basin with a flat bottom, basin_depth can be 0 ( all land).
- ********************************************************************/
-void create_rectangular_topog(int nx, int ny, double basin_depth, double *depth)
-{
-  int i;
-
-  for(i=0; i<nx*ny; i++)  depth[i] = basin_depth;
-}; /* create_rectangular_topog  */
-
-/*********************************************************************
-   void create_bowl_topog()
-   From "Simulation of density-driven frictional downslope flow
-   in z-coordinate mocean models"
-   Winton et al. JPO, Vol 28, No 11, 2163-2174, November 1998
- ********************************************************************/
-void create_bowl_topog(int nx, int ny, const double *x, const double *y, double bottom_depth,
-		       double min_depth, double bowl_east, double bowl_south, double bowl_west,
-		       double bowl_north, double *depth)
-{
-  double bottom, xx, yy;
-  int i, j, nxp, nyp;
-
-  nxp = nx+1;
-  nyp = ny+1;
-  
-  for(j=0;j<ny;j++){
-    for(i=0;i<nx;i++){
-      xx = (x[j*nxp+i]+x[j*nxp+i+1]+x[(j+1)*nxp+i]+x[(j+1)*nxp+i+1])*0.25;
-      yy = (y[j*nxp+i]+y[j*nxp+i+1]+y[(j+1)*nxp+i]+y[(j+1)*nxp+i+1])*0.25;	    
-      if (xx <= bowl_west  || xx >= bowl_east || yy <= bowl_south || yy >= bowl_north)            
-	bottom = min_depth;
-      else
-	bottom = min_depth + bottom_depth*(1.0-exp(-pow((yy-bowl_south)/2.0,2)))
-	  *(1.0-exp(-pow((yy-bowl_north)/2.0,2)))
-	  *(1.0-exp(-pow((xx-bowl_west)/4.0,2)))
-	  *(1.0-exp(-pow((xx-bowl_east)/4.0,2)));
-      depth[j*nx+i] = bottom;
-    }
-  }
-}; /* create_bowl_topog */
-
-
-/*********************************************************************
-   void create_gaussian_topog()
-   Constructing a gaussian bump
- ********************************************************************/
-void create_gaussian_topog(int nx, int ny, const double *x, const double *y, double bottom_depth,
-			   double min_depth, double gauss_amp, double gauss_scale, double slope_x,
-			   double slope_y, double *depth)
-{
-  double bump_height, bump_scale, xcent, ycent, arg, bottom;
-  double xe, xw, ys, yn;
-  double *xt, *yt;
-  int i, j, nxp, nyp;
-
-  xt = (double *)malloc(nx*ny*sizeof(double));
-  yt = (double *)malloc(nx*ny*sizeof(double));
-  for(j=0; j<ny; j++) {
-    for(i=0; i<nx; i++) {
-      xt[j*nx+i] = (x[j*nxp+i] + x[j*nxp+i+1] + x[(j+1)*nxp+i] + x[(j+1)*nxp+i+1])*0.25;
-      yt[j*nx+i] = (y[j*nxp+i] + y[j*nxp+i+1] + y[(j+1)*nxp+i] + y[(j+1)*nxp+i+1])*0.25;
-    }
-  }
-  
-  xw = xt[0];
-  ys = yt[0];
-  xe = xw;
-  yn = ys;
-
-  for(j=1;j<ny;j++){
-    for(i=1;i<nx;i++){
-      xw = min(xt[j*nx+i],xw); xe = max(xt[j*nx+i],xe);
-      ys = min(yt[j*nx+i],ys); yn = max(yt[j*nx+i],yn);
-    }
-  }
-
-  bump_height = gauss_amp*bottom_depth;
-  bump_scale = gauss_scale*min(xe-xw, yn-ys);
-  xcent = 0.5*(xe+xw);
-  ycent = 0.5*(yn+ys);
-
-  printf("Constructing a gaussian bump of height = %f meters with a scale width of %f degrees.\n",
-	 bump_height, bump_scale);
-  printf("The bump is centered at (lon,lat) = (%f,%f) deg.\n", xcent, ycent);
-  printf("The ocean floor rises with a slope of %f meters/deg towards the east and %f "
-	 " meters/deg to the north.", slope_x, slope_y) ;
-
-  for(j=0;i<nx*ny;j++){
-      arg = pow(xt[i]-xcent,2) + pow(yt[i]-ycent,2);
-      bottom = bottom_depth - bump_height*exp(-arg/pow(bump_scale,2));
-      bottom = bottom - slope_x*(xt[i]-xw)- slope_y*(yt[i]-ys);
-      depth[i] = max(bottom,min_depth);
-  }
-
-  free(xt);
-  free(yt);
-  
-}; /* create_gaussian_topog */
-
-
-/*********************************************************************
-
-  void create_idealized_topog
-   construct a highly "idealized" world ... piece by piece
-
-   note: the purpose of this geometry/topography is to automatically
-         map into arbitrary resolution as grid dimensions are
-         changed, thereby facilitating the implementation
-         and verification of the model on various computer platforms
-         without referencing the topographic database.  Although it
-         somewhat resembles the real world, it is NOT realistic.
-   Note: this routine needs to be re-thought for generalized curvilinear coordinates
-
- ********************************************************************/
-void create_idealized_topog( int nx, int ny, const double *x, const double *y,
-			     double bottom_depth, double min_depth, double *depth)
-{
-  int i, j, nxp, nyp;
-  double arg;
-  double *xbnd, *ybnd;
-  
-  for(j=0;j<ny;j++){
-    for(i=0;i<nx;i++) depth[j*nx+i]=bottom_depth;
-  }
-  
-  //antarctica
-  xbnd = (double *)malloc(nx*sizeof(double));
-  ybnd = (double *)malloc(ny*sizeof(double));
-  for(i=0; i<nx; i++) xbnd[i] = (x[i]+x[i+1])*0.5;
-  for(j=0; j<ny; j++) ybnd[j] = (y[j*nxp]+y[(j+1)*nxp])*0.5;
-  
-  set_depth (nx, ny, xbnd, ybnd, -90.0, 0.0, 360.0, -80.0, 0.0, 360.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -80.0, 360.0-25.0, 360.0, -70.0, 360.0, 360.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -80.0, 0.0, 360.0, -70.0, 0.0, 170.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -80.0, 360.0-135.0, 360.0-60.0, -68.0, 360.0-75.0, 360.0-60.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -70.0, 0.0, 155.0, -67.0, 50.0, 145.0, 0.0, depth);
-
-  // australia
-
-  set_depth (nx, ny, xbnd, ybnd, -35.0, 116.0, 120.0, -31.0, 114.0, 130.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -38.0, 140.0, 151.0, -31.0, 130.0, 151.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -31.0, 115.0, 153.0, -20.0, 113.0, 149.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -20.0, 113.0, 149.0, -11.0, 131.0, 143.0, 0.0, depth);
-
-  // south america
-
-  set_depth (nx, ny, xbnd, ybnd, -50.0, 360.0-74.0, 360.0-68.0, -40.0, 360.0-73.0, 360.0-62.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -40.0, 360.0-73.0, 360.0-62.0, -20.0, 360.0-70.0, 360.0-40.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -20.0, 360.0-70.0, 360.0-40.0, -16.0, 360.0-81.0, 360.0-35.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, -16.0, 360.0-81.0, 360.0-35.0, 0.0, 360.0-80.0, 360.0-50.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 0.0, 360.0-80.0, 360.0-50.0, 11.0, 360.0-75.0, 360.0-60.0, 0.0, depth);
-
-  // central america
-
-  set_depth (nx, ny, xbnd, ybnd, 6.0, 360.0-78.0, 360.0-75.0, 20.0, 360.0-105.0, 360.0-97.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 20.0, 360.0-105.0, 360.0-97.0, 30.0, 360.0-115.0, 360.0-94.0, 0.0, depth);
-
-  // north america
-
-  set_depth (nx, ny, xbnd, ybnd, 25.0, 360.0-82.0, 360.0-80.0, 30.0, 360.0-85.0, 360.0-81.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 30.0, 360.0-115.0, 360.0-80.0, 40.0, 360.0-124.0, 360.0-74.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 40.0, 360.0-124.0, 360.0-74.0, 50.0, 360.0-124.0, 360.0-57.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 50.0, 360.0-124.0, 360.0-57.0, 60.0, 360.0-140.0, 360.0-64.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 60.0, 360.0-165.0, 360.0-64.0, 65.0, 360.0-140.0, 360.0-64.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 65.0, 360.0-140.0, 360.0-64.0, 70.0, 360.0-162.0, 360.0-72.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 70.0, 360.0-162.0, 360.0-140.0, 72.0, 360.0-157.0, 360.0-157.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 70.0, 360.0-130.0, 360.0-70.0, 75.0, 360.0-120.0, 360.0-80.0, 0.0, depth);
-
-  // greenland
-
-  set_depth (nx, ny, xbnd, ybnd, 60.0, 360.0-45.0, 360.0-45.0, 75.0, 360.0-58.0, 360.0-19.0, 0.0, depth);
-
-  // africa
-
-  set_depth (nx, ny, xbnd, ybnd, -35.0, 19.0, 28.0, 6.0, 8.0, 50.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 6.0, 0.0, 50.0, 18.0, 0.0, 56.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 18.0, 0.0, 56.0, 26.0, 0.0, 59.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 6.0, 360.0-10.0, 360.0, 18.0, 360.0-18.0, 360.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 18.0, 360.0-18.0, 360.0, 26.0,  360.0-15.0, 360.0, 0.0, depth);
-
-  // northern africa and europe and asia
-
-  set_depth (nx, ny, xbnd, ybnd, 26.0, 360.0-15.0, 360.0, 40.0, 360.0-7.0, 360.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 40.0, 360.0-7.0, 360.0, 50.0, 360.0, 360.0, 0.0, depth);
-
-  set_depth (nx, ny, xbnd, ybnd, 8.0, 77.0, 78.0, 26.0, 65.0, 90.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 4.0, 99.0, 100.0, 26.0, 90.0, 115.0, 0.0, depth);
-
-  set_depth (nx, ny, xbnd, ybnd, 26.0, 0.0, 126.0, 40.0, 0.0, 122.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 40.0, 0.0, 130.0, 50.0, 0.0, 140.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 50.0, 0.0, 140.0, 60.0, 8.0, 140.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 60.0, 8.0, 163.0, 65.0, 13.0, 180.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 65.0, 13.0, 188.0, 70.0, 20.0, 180.0, 0.0, depth);
-  set_depth (nx, ny, xbnd, ybnd, 70.0, 70.0, 180.0, 75.0, 90.0, 100.0, 0.0, depth);
-
-  // add an "idealized" undulating topography
-
-  nxp = nx+1;
-  nyp = ny+1;
-  for(j=0;j<ny;j++){
-    for(i=0;i<nx;i++){
-      if (depth[j*nx+i] > 0.0 ) {
-	arg = bottom_depth*(1-0.4*fabs(cos(((j+1)*M_PI)/nyp)*sin(((i+1)*2*M_PI)/nxp)));
-        arg = max(arg, min_depth);      
-        depth[j*nx+i] = arg;
-      }
-    }
-  }
-
-  // add "idealized" ridges
-
-  arg = 0.666*bottom_depth;
-  
-  set_depth (nx, ny, xbnd, ybnd, -20.0, 360.0-20.0, 360.0-10.0, 30.0, 360.0-45.0, 360.0-35.0, arg, depth);
-  set_depth (nx, ny, xbnd, ybnd, 30.0, 360.0-45.0, 360.0-35.0, 60.0, 360.0-20.0,  360.0-30.0, arg, depth);
-  set_depth (nx, ny, xbnd, ybnd, -60.0,360.0-100.0, 360.0-130.0, 40.0, 360.0-160.0, 180.0, arg, depth);
-
-  arg = 0.5*bottom_depth;
-  
-  set_depth (nx, ny, xbnd, ybnd, -50.0, 360.0-120.0, 360.0-120.0, 30.0, 190.0, 190.0, arg, depth);
-
-  free(xbnd);
-  free(ybnd);
-  
-} /* create_idealized_topog */
-
-/*********************************************************************
-   void set_depth(double alat1, double slon1, double elon1, double alat2,
-                  double slon2, double elon2, double depth_in )
-        set the topography depth "depth[i][j](i,j)" = "depth_in" within the area of
-        the trapezoid bounded by vertices:
-        (alat1,slon1), (alat1,elon1), (alat2,slon2), and (alat2,elon2)
-   
-        inputs:
-   
-        alat1 = southern latitude of trapezoid (degrees)
-        slon1 = starting longitude of southern edge of trapezoid (deg)
-        elon1 = ending longitude of southern edge of trapezoid (deg)
-        alat2 = northern latitude of trapezoid (degrees)
-        slon2 = starting longitude of northern edge of trapezoid (deg)
-        elon2 = ending longitude of northern edge of trapezoid (deg)
-        depth_in = constant depth value
-   
- ********************************************************************/
-void set_depth(int nx, int ny, const double *xbnd, const double *ybnd, double alat1, double slon1, double elon1, double alat2,
-                      double slon2, double elon2, double depth_in, double *depth)
-{
-  double rdj, d;
-  int i, j, i1, i2, j1, j2, is, ie, js, je, is1, ie1, is2, ie2;
-  
-  j1 = nearest_index(alat1, ybnd, ny );
-  j2 = nearest_index(alat2, ybnd, ny );
-  js = min(j1,j2);
-  je = max(j1,j2);
-
-  i1  = nearest_index(slon1, xbnd, nx);
-  i2  = nearest_index(elon1, xbnd, nx);
-  is1 = min(i1,i2);
-  ie1 = max(i1,i2);
-
-  i1  = nearest_index(slon2, xbnd, nx );
-  i2  = nearest_index(elon2, xbnd, ny );
-  is2 = min(i1,i2);
-  ie2 = max(i1,i2);
-
-  is = is1;
-  ie = ie1;
-
-  // fill in the area bounded by (js,is1), (js,ie1), (je,is2), (je,ie2)
-  // the nudging of 1.e-5 is to insure that the test case resolution
-  // generates the same topography and geometry on various computers.
-
-  if (js == je) 
-    rdj = 1.0;
-  else
-    rdj = 1.0/(je-js);
-
-  for(j=js;j<=je;j++){
-    for(i=is;i<=ie;i++) depth[j*nx+i] = depth_in;
-    d = rdj*((j-js)*is2 + (je-j)*is1) + 1.0e-5;
-    is = ceil(d);
-    if( is - d > 0.5) is = is -1;
-    d = rdj*((j-js)*ie2 + (je-j)*ie1) + 1.0e-5;
-    ie = ceil(d);
-    if( ie - d > 0.5) ie = ie -1;
-  }
-
-}; /* set_depth */
-
-/*********************************************************************
-   void create_realistic_topog( )
-   reading data from source data file topog_file and remap it onto current grid
- ********************************************************************/
-void create_realistic_topog(int nx_dst, int ny_dst, const double *x_dst, const double *y_dst,
-			    const char* topog_file, const char* topog_field, double scale_factor,
-			    double fill_first_row, int filter_topog, int num_filter_pass,
-			    int smooth_topo_allow_deepening, int round_shallow, int fill_shallow,
-			    int deepen_shallow, double min_depth, double *depth )
-{
-  char xname[128], yname[128];
-  int nx_src, ny_src, nxp_src, nyp_src, i, j, count, n;
-  double *depth_src, *mask_src, *xt_src, *yt_src, *x_src, *y_src;
-  double *x_out, *y_out;
-  double missing;
-  int fid, vid;
-  
-  /* first read source topography data to get source grid and source topography */
-  fid = mpp_open(topog_file, MPP_READ);
-  vid = mpp_get_varid(fid, topog_field);
-  mpp_get_var_dimname(fid, vid, 1, xname);
-  mpp_get_var_dimname(fid, vid, 0, yname);
-  nx_src = mpp_get_dimlen( fid, xname );
-  ny_src = mpp_get_dimlen( fid, yname );
-  nxp_src = nx_src + 1;
-  nyp_src = ny_src + 1;
-  depth_src = (double *)malloc(nx_src*ny_src*sizeof(double));
-  mask_src = (double *)malloc(nx_src*ny_src*sizeof(double));
-  xt_src    = (double *)malloc(nx_src*sizeof(double));
-  yt_src    = (double *)malloc(ny_src*sizeof(double));
-  x_src    = (double *)malloc(nxp_src*nyp_src*sizeof(double)); 
-  y_src    = (double *)malloc(nxp_src*nyp_src*sizeof(double));
-
-  mpp_get_var_att(fid, vid, "missing_value", &missing);
-  mpp_get_var_value(fid, vid, depth_src);
-  vid = mpp_get_varid(fid, xname);
-  mpp_get_var_value(fid, vid, xt_src);
-  vid = mpp_get_varid(fid, yname);
-  mpp_get_var_value(fid, vid, yt_src);
-  mpp_close(fid);
-  
-  for(j=0; j<nyp_src; j++) {
-     for(i=1; i<nx_src; i++) x_src[j*nxp_src+i] = (xt_src[i-1] + xt_src[i])*0.5;
-     x_src[j*nxp_src] = 2*xt_src[0] - x_src[j*nxp_src+1];
-     x_src[j*nxp_src+nx_src] = 2*xt_src[nx_src-1] - x_src[j*nxp_src+nx_src-1];
-  }
-  for(i=0; i<nxp_src; i++) {
-    for(j=1; j<ny_src; j++) y_src[j*nxp_src+i] = (yt_src[j-1] + yt_src[j])*0.5;
-    y_src[i] = 2*yt_src[0] - y_src[nxp_src+i];
-    y_src[ny_src*nxp_src+i] = 2*yt_src[ny_src-1] - y_src[(ny_src-1)*nxp_src+i];
-  }
-    
-
-  for(i=0; i<nx_src*ny_src; i++) {
-    if(depth_src[i] == missing)
-      mask_src[i] = 0.0;
-    else {
-      depth_src[i] = depth_src[i]*scale_factor;
-      if( depth_src[i] <= 0.0)
-	mask_src[i] = 0.0;
-      else
-	mask_src[i] = 1.0;
-    }
-  }
-
-  /* scale grid to radius */
-  for(i=0; i<nxp_src*nyp_src; i++) {
-    x_src[i] = x_src[i]*D2R;
-    y_src[i] = y_src[i]*D2R;
-  }
-  x_out = (double *)malloc((nx_dst+1)*(ny_dst+1)*sizeof(double));
-  y_out = (double *)malloc((nx_dst+1)*(ny_dst+1)*sizeof(double));
-  for(i=0; i<(nx_dst+1)*(ny_dst+1); i++) {
-    x_out[i] = x_dst[i]*D2R;
-    y_out[i] = y_dst[i]*D2R;
-  }
-  
-  /* doing the conservative interpolation */
-  conserve_interp(nx_src, ny_src, nx_dst, ny_dst, x_src, y_src, x_out, y_out,
-		  mask_src, depth_src, depth );
-  
-  /* make first row of ocean model all land points for ice model */
-
-  if(fill_first_row) {
-    for(i=0;i<nx_dst;i++) {
-      depth[i] = 0.0;
-    }
-  }
-
-  if (filter_topog) filter_topo(nx_dst, ny_dst, num_filter_pass, smooth_topo_allow_deepening, depth);
-  /* enforce minimum depth when one of round_shallow, deepen_shallow or fill_shallow
-     is true ( At most one ).         */
-  count = 0;
-  if(round_shallow) count++;
-  if(fill_shallow) count++;
-  if(deepen_shallow) count++;
-  if(count > 1) mpp_error("topog: at most one of round_shallow/deepen_shallow/fill_shallow can be set to true");
-     
-  if(count>0) enforce_min_depth(nx_dst, ny_dst, round_shallow, deepen_shallow, fill_shallow,
-				min_depth, depth);
-
-  free(depth_src);
-  free(mask_src);
-  free(x_src);
-  free(y_src);
-  free(xt_src);
-  free(yt_src);
-  free(x_out);
-  free(y_out);
-  
-}; /* create_realistic_topog */
-
-
-/*********************************************************************
-
-    void filter_topo( int nx, int ny, int num_pass, double *depth)
-
-       smooth topographic depth "d" with "num_pass" applications of a 2D
-       version of a shapiro filter (weights = 1/4, 1/2, 1/4) . 
-       allow filtering to decrease the bottom depth but not increase it.
-       do not allow original geometry to change.
-       note: depth "d" should be on a grid of uniformly constant spacing
-
-********************************************************************/
-void filter_topo( int nx, int ny, int num_pass, int smooth_topo_allow_deepening, double *depth)
-{
-  double *rmask, *s;  
-  double f[9], d_old;
-  int n1, n2, i, j, n, m, ip, jp;
-  size_t *dims;
-  
-  rmask = (double *)malloc(nx*ny*sizeof(double));
-  s     = (double *)malloc(nx*ny*sizeof(double));
-
-  /* 2D symmetric filter weights */
-
-  f[0] = 1.0/16.0;
-  f[1] = 1.0/8.0;
-  f[2] = 1.0/16.0;
-  f[3] = 1.0/8.0;
-  f[4] = 1.0/4.0;
-  f[5] = 1.0/8.0;
-  f[6] = 1.0/16.0;
-  f[7] = 1.0/8.0;
-  f[8] = 1.0/16.0;
-  
-  /* geometry mask */
-  for(i=0; i<nx*ny; i++) {
-    if(depth[i] == 0.0)
-      rmask[i] = 0.0;
-    else
-      rmask[i] = 1.0;
-  }
-
-  for(n=1;n<=num_pass;n++) {
-    for(j=1;j<ny-1;j++) {
-      for(i=1;i<nx-1;i++) {
-	s[j*nx+i] = 0.0;
-	d_old = depth[j*nx+i];
-	for(ip=-1;ip<=1;ip++) {
-	  for(jp=-1;jp<=1;jp++) {
-	    m = (ip+1)*3 + jp+1;
-	    if (rmask[(j+jp)*nx+i+ip] == 0.0) 
-	      s[j*nx+i] = s[j*nx+i] + depth[j*nx+i]*f[m];
-            else
-	      s[j*nx+i] = s[j*nx+i] + depth[(j+jp)*nx+i+ip]*f[m];
-	  }
-	}
-	if (! smooth_topo_allow_deepening) {
-	  if (s[j*nx+i] > d_old)  s[j*nx+i] = d_old;
-	}
-	s[j*nx+i] = s[j*nx+i]*rmask[j*nx+i];
-      }
-    }
-    for(i=0; i<nx*ny; i++) depth[i] = s[i];
-  }
-  
-}; /* filter_topog */
-
-/*********************************************************************
-  void enforce_min_depth()
-  ! limit the minimum value of depth, depth should be >= min_depth. 
- ********************************************************************/
-void enforce_min_depth(int nx, int ny, int round_shallow, int deepen_shallow,
-			   int fill_shallow, double min_depth, double *depth)
-{
-  int i, j, n, l;
-  
-  if(mpp_pe() == mpp_root_pe() ) printf(" Enforcing the minimum topography depth to be %f\n",min_depth);
-
-  n = 0;
-  if(round_shallow) {    
-    for(j=0;j<ny;j++){
-      for(i=0;i<nx;i++){
-	l = j*nx+i;
-	if (depth[l] != 0 && depth[l] < min_depth) {
-	  n = n + 1;
-	  if ( depth[l] < 0.5*min_depth) {
-	    printf("Making location i,j,depth= %d,%d,%f to land.\n",i, j, depth[l]);
-	    depth[l] = 0.0;
-	  }
-	  else {
-	    printf("Setting location i,j,depth= %d,%d,%f to minimum ocean depth.\n",i,j, depth[l]);
-	    depth[l] = min_depth;
-	  }
-	}
-      }
-    }
-  }
-  else if (fill_shallow) {
-    for(j=0;j<ny;j++){
-      for(i=0;i<nx;i++){
-	l = j*nx+i;
-	if (depth[l] != 0 && depth[l] < min_depth) {
-	  n = n + 1;
-	  printf("Making location i,j,depth= %d,%d,%f to land.\n",i, j, depth[l]);
-	  depth[l] = 0.0;
-	}
-      }
-    }
-  }
-  else if (deepen_shallow) {
-    for(j=0;j<ny;j++){
-      for(i=0;i<nx;i++){
-	l = j*nx+i;
-	if (depth[l] != 0 && depth[l] < min_depth) {
-	  n = n + 1;
-	  printf("Setting location i,j,depth= %d,%d,%f to minimum ocean depth.\n",i,j, depth[l]);
-	  depth[l] = min_depth;
-	}
-      }
-    }
-  }
-
-}; /* enforce_min_depth */
diff --git a/gridspec_tools_20080702/tools/make_vgrid/Makefile.am b/gridspec_tools_20080702/tools/make_vgrid/Makefile.am
deleted file mode 100644
index 665483d..0000000
--- a/gridspec_tools_20080702/tools/make_vgrid/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# make_vgrid tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/08 11:39:02 ed Exp $
-
-bin_PROGRAMS = make_vgrid gs_make_vgrid
-make_vgrid_SOURCES = create_vgrid.c create_vgrid.h make_vgrid.c
-gs_make_vgrid_SOURCES = create_vgrid.c create_vgrid.h gs_make_vgrid.c
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/make_vgrid/make_vgrid.c b/gridspec_tools_20080702/tools/make_vgrid/make_vgrid.c
deleted file mode 100644
index 987a682..0000000
--- a/gridspec_tools_20080702/tools/make_vgrid/make_vgrid.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include "create_vgrid.h"
-#include "mpp_io.h"
-
-#define MAXBOUNDS 100
-
-char *usage[] = {
-  "",
-  "                                                                                 ",
-  "                                                                                 ",
-  "                    Usage of make_vgrid                                          ",
-  "                                                                                 ",
-  "   make_vgrid --nbnds nbnds --bnds z(1),...,z(nbnds) --nz nz                     ",
-  "              [--grid_name gridname]    [--center center]                        ",
-  "                                                                                 ",
-  "   NOTE: This program call be used to make vertical grid for FMS model.          ",
-  "         It uses cubic-spline algorithm to calculate the grid cell location.     ",
-  "         The output netcdf will contains information on supergrid with grid      ",
-  "         size equal model grid size multipling refinement ( always 2 ).          ",
-  "         make_vgrid takes the following flags                                    ",
-  "                                                                                 ",
-  "   Required Flags:                                                               ",
-  "                                                                                 ",
-  "   --nbnds nbnds             Specify number of vertical regions for varying      ",
-  "                             resolution.                                         ",
-  "                                                                                 ",  
-  "   --bnds z(1),.,z(nbnds)    Specify boundaries for defining vertical regions of ",
-  "                             varying resolution.                                 ",
-  "                                                                                 ",
-  "   --nz nz(1),..,nz(nbnds-1) Number of model grid points for each vertical       ",
-  "                             regions of varying resolution.                       "
-  "                                                                                 ",  
-  "   Optional Flags:                                                               ",
-  "                                                                                 ",
-  " --grid_name gridname        Specify the grid name. The output grid file name    ",
-  "                             will be grid_name.nc. The default value is          ",
-  "                             vertical_grid.                                      ",
-  "                                                                                 ",  
-  " --center   center           Specify the center location of grid. The valid      ",
-  "                             entry will be 'none', 't_cell' or 'c_cell' with     ",
-  "                             default value 'none'. The grid refinement is        ",
-  "                             assumed to be 2 in x and y-direction when center    ",
-  "                             is not 'none'. 'c_cell' should be used for the grid ",
-  "                             used in MOM4.                                       ",
-  "                                                                                 ",
-  "                                                                                 ",
-  "   Example                                                                       ",      
-  "                                                                                 ",
-  "                                                                                 ",
-  " make_vgrid --nbnds 3 --bnds 10,200,1000 --nz 10,20                             ",
-  "       will make a grid file with 60 supergrid cells, 30 model grid cells        ",
-  "       with refinement is 2.                                                     ",
-  "",
-  NULL };  
-
-char grid_version[] = "0.2";
-char tagname[] = "$Name:  $";
-
-int main(int argc, char* argv[])
-{
-  int nbnds, n1, n2, i, nk;
-  double bnds[MAXBOUNDS];
-  int    nz[MAXBOUNDS-1];
-  char gridname[128]= "vertical_grid";
-  char filename[128];
-  double *zeta;
-  char center[32] = "none";
-  char entry[512];
-  char history[256];
-  int errflg, c, option_index = 0;
-  static struct option long_options[]= {  
-    {"nbnds",    required_argument, NULL, 'n'},
-    {"bnds",     required_argument, NULL, 'b'},
-    {"nz",       required_argument, NULL, 'z'},
-    {"grid_name",required_argument, NULL, 'o'},        
-    {"center",   required_argument, NULL, 'c'},    
-    {0, 0, 0, 0}
-  };
-  
-    /*
-   * process command line
-   */
-  errflg = argc <4;
-  nbnds = 0;
-  n1 = 0;
-  n2 = 0;
-  while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1)
-    switch (c) {
-    case 'n':
-      nbnds = atoi(optarg);
-      break;
-    case 'b':
-      strcpy(entry, optarg);
-      n1 = get_double_entry(entry, bnds);
-      break;
-    case 'z':
-      strcpy(entry, optarg);
-      n2 = get_int_entry(entry, nz);
-      break;
-    case 'o':
-      strcpy(gridname, optarg);
-      break;
-    case 'c':
-      strcpy(center, optarg);
-      break;
-    case '?':
-      errflg++;      
-    }
-
-  if (errflg ) {
-    char **u = usage;
-    while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-    mpp_error("Wrong usage of this program, check arguments") ;
-  }    
-
-  /* check the command-line arguments to make sure the value are suitable */
-  if( nbnds < 2 ) mpp_error("number of bounds specified through -nbnd should be an integer greater than 1");
-  if( nbnds != n1 ) mpp_error("nbnds does not equal number entry specified through -bnd");
-  if( nbnds-1 != n2 ) mpp_error("nbnds-1 does not match number entry specified through -nz");
-
-  /* generate grid */
-  nk = 0;
-  for(i=0; i<nbnds-1; i++) nk += nz[i];
-  zeta = (double *)malloc((nk+1)*sizeof(double));
-  create_vgrid(nbnds, bnds, nz, zeta, center);
-
-  /* define history to be the history in the grid file */
-  strcpy(history,argv[0]);
-
-  for(i=1;i<argc;i++) {
-    strcat(history, " ");
-    strcat(history, argv[i]);
-  }
-
-  sprintf(filename, "%s.nc", gridname);
-  
-  /* write out vertical grid into a netcdf file */
-  {
-    int fid, dim, varid;
-    
-    fid = mpp_open(filename, MPP_WRITE);
-    dim  = mpp_def_dim(fid, "nzv", nk+1);
-    varid = mpp_def_var(fid, "zeta", NC_DOUBLE, 1, &dim, 2, "standard_name", "vertical_grid_vertex",
-			"units", "meters");
-    mpp_def_global_att(fid, "grid_version", grid_version);
-    mpp_def_global_att(fid, "code_version", tagname);
-    mpp_def_global_att(fid, "history", history);    
-    mpp_end_def(fid);
-    mpp_put_var_value(fid, varid, zeta);
-  
-    mpp_close(fid);
-  }
-
-  if(mpp_pe() == mpp_root_pe()) printf("Successfully generate vertical grid file %s\n", filename);
-  
-  mpp_end();
-
-  return 0;
-}    
diff --git a/gridspec_tools_20080702/tools/river_regrid/Makefile.am b/gridspec_tools_20080702/tools/river_regrid/Makefile.am
deleted file mode 100644
index f2d1a67..0000000
--- a/gridspec_tools_20080702/tools/river_regrid/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# river_regrid tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/08 11:39:02 ed Exp $
-
-bin_PROGRAMS = river_regrid gs_river_regrid
-river_regrid_SOURCES = river_regrid.c
-gs_river_regrid_SOURCES = gs_river_regrid.c
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/river_regrid/Makefile.in b/gridspec_tools_20080702/tools/river_regrid/Makefile.in
deleted file mode 100644
index b6583b5..0000000
--- a/gridspec_tools_20080702/tools/river_regrid/Makefile.in
+++ /dev/null
@@ -1,524 +0,0 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
- at SET_MAKE@
-
-# This automake file is in charge of building the gridspec
-# river_regrid tool.
-
-# $Id: Makefile.am,v 1.2 2009/04/08 11:39:02 ed Exp $
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-bin_PROGRAMS = river_regrid$(EXEEXT) gs_river_regrid$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
- at USE_NETCDF_DIR_TRUE@am__append_1 = -I at NETCDFDIR@/include
- at USE_NETCDF_DIR_TRUE@am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/river_regrid
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
-	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
-	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
-	$(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
-CONFIG_CLEAN_FILES =
-am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-PROGRAMS = $(bin_PROGRAMS)
-am_gs_river_regrid_OBJECTS = gs_river_regrid.$(OBJEXT)
-gs_river_regrid_OBJECTS = $(am_gs_river_regrid_OBJECTS)
-gs_river_regrid_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-gs_river_regrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_river_regrid_OBJECTS = river_regrid.$(OBJEXT)
-river_regrid_OBJECTS = $(am_river_regrid_OBJECTS)
-river_regrid_LDADD = $(LDADD)
-river_regrid_DEPENDENCIES = $(am__DEPENDENCIES_1)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
-SOURCES = $(gs_river_regrid_SOURCES) $(river_regrid_SOURCES)
-DIST_SOURCES = $(gs_river_regrid_SOURCES) $(river_regrid_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ALLOCA = @ALLOCA@
-AMTAR = @AMTAR@
-AR = @AR@
-AS = @AS@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DLLTOOL = @DLLTOOL@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FC = @FC@
-FCFLAGS = @FCFLAGS@
-FFLAGS = @FFLAGS@
-FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
-GREP = @GREP@
-HDF5DIR = @HDF5DIR@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LD = @LD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIPO = @LIPO@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
-MKDIR_P = @MKDIR_P@
-NETCDFDIR = @NETCDFDIR@
-NM = @NM@
-NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-RANLIB = @RANLIB@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WHATIS = @WHATIS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-ac_ct_F77 = @ac_ct_F77@
-ac_ct_FC = @ac_ct_FC@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-prog = @prog@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-river_regrid_SOURCES = river_regrid.c
-gs_river_regrid_SOURCES = gs_river_regrid.c
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
-AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
-	@for dep in $?; do \
-	  case '$(am__configure_deps)' in \
-	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
-	      exit 1;; \
-	  esac; \
-	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/river_regrid/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/river_regrid/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	@case '$?' in \
-	  *config.status*) \
-	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
-	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
-	esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure:  $(am__configure_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-install-binPROGRAMS: $(bin_PROGRAMS)
-	@$(NORMAL_INSTALL)
-	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
-
-uninstall-binPROGRAMS:
-	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
-
-clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-gs_river_regrid$(EXEEXT): $(gs_river_regrid_OBJECTS) $(gs_river_regrid_DEPENDENCIES) 
-	@rm -f gs_river_regrid$(EXEEXT)
-	$(LINK) $(gs_river_regrid_OBJECTS) $(gs_river_regrid_LDADD) $(LIBS)
-river_regrid$(EXEEXT): $(river_regrid_OBJECTS) $(river_regrid_DEPENDENCIES) 
-	@rm -f river_regrid$(EXEEXT)
-	$(LINK) $(river_regrid_OBJECTS) $(river_regrid_LDADD) $(LIBS)
-
-mostlyclean-compile:
-	-rm -f *.$(OBJEXT)
-
-distclean-compile:
-	-rm -f *.tab.c
-
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_river_regrid.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/river_regrid.Po at am__quote@
-
-.c.o:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
-
-.c.obj:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.c.lo:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
- at am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
-	-rm -f *.lo
-
-clean-libtool:
-	-rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
-	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
-	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
-	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
-
-GTAGS:
-	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
-	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	list='$(DISTFILES)'; \
-	  dist_files=`for file in $$list; do echo $$file; done | \
-	  sed -e "s|^$$srcdirstrip/||;t" \
-	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
-	case $$dist_files in \
-	  */*) $(MKDIR_P) `echo "$$dist_files" | \
-			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
-			   sort -u` ;; \
-	esac; \
-	for file in $$dist_files; do \
-	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  if test -d $$d/$$file; then \
-	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
-	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
-	    || exit 1; \
-	  fi; \
-	done
-check-am: all-am
-check: check-am
-all-am: Makefile $(PROGRAMS)
-installdirs:
-	for dir in "$(DESTDIR)$(bindir)"; do \
-	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
-	done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-
-maintainer-clean-generic:
-	@echo "This command is intended for maintainers to use"
-	@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
-
-distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-exec-am: install-binPROGRAMS
-
-install-html: install-html-am
-
-install-info: install-info-am
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-ps: install-ps-am
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-binPROGRAMS
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-libtool ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-binPROGRAMS install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am \
-	uninstall-binPROGRAMS
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/gridspec_tools_20080702/tools/river_regrid/gs_river_regrid.c b/gridspec_tools_20080702/tools/river_regrid/gs_river_regrid.c
deleted file mode 100644
index a7d738c..0000000
--- a/gridspec_tools_20080702/tools/river_regrid/gs_river_regrid.c
+++ /dev/null
@@ -1,119 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include <math.h>
-#include "mpp.h"
-#include "mpp_io.h"
-#include "create_xgrid.h"
-#include "constant.h"
-#include "mosaic_util.h"
-#include "tool_util.h"
-
-char *usage[] = {
-   "",
-   "  river_regrid --mosaic mosaic_grid --river_src river_src_file [--output output_file] ",
-   "                                                                                    ",
-   "river_regrid will remap river network data from global regular lat-lon grid onto any  ",
-   "other grid (includes regular lat-lon grid and cubic grid ), which is specified        ",
-   "through option --mosaic. The river network source data is specified through option    ",
-   "--river_src.                                                                          ",
-   "                                                                                      ",
-   "river_regrid takes the following flags:                                               ",
-   "                                                                                      ",
-   "REQUIRED:                                                                             ",
-   "                                                                                      ",
-   "--mosaic    mosaic_grid     specify the mosaic file of destination grid. This mosaic  ",
-   "                            file should be a coupler mosaic file, which contains link ",
-   "                            to land solo mosaic and the exchange grid file.           ",
-   "                                                                                      ",
-   "--river_src river_src_file  specify the river network source data file. The data is   ",
-   "                            assumed on regular lat-lon grid and the longitude is      ",
-   "                            assumed from 0 to 360 degree and latitude is assumed      ",
-   "                            from -90 to 90 degree.                                    ",
-   "                                                                                      ",
-   "OPTIONAL FLAGS                                                                        ",
-   "                                                                                      ",
-   "--output output_file        specify the output file base name. the suffix '.nc'       ",
-   "                            should not be included in the output_file. The default    ",
-   "                            value is river_output. For one tile mosaic, the actual    ",
-   "                            result will be $output_file.nc. For multiple tile mosaic, ",
-   "                            the result will be $output.tile#.nc.                      ",
-   "                                                                                      ",  
-   NULL
-};
-
-int main(int argc, char* argv[])
-{
-   unsigned int opcode = 0;  
-   int          option_index, c;
-   char         *mosaic_file     = NULL;
-   char         *river_src_file  = NULL;
-   char         output_file[256] = "river_output";
-   int          ntiles, n;
-   char         land_mosaic_dir[256];
-   char         land_mosaic[256];
-   char         land_mosaic_file[256];  
-   char         history[1024];
-  
-   river_type river_in;
-   river_type *river_out; /* may be more than one tile */
-
-   int errflg = (argc == 1);
-   int ret;
-
-   int    sizeof_int  = 0;
-   int    sizeof_double = 0;
-
-   static struct option long_options[] = {
-      {"mosaic_grid",       required_argument, NULL, 'a'},
-      {"river_src_file",    required_argument, NULL, 'b'},
-      {"output",            required_argument, NULL, 'c'},
-      {0, 0, 0, 0},
-   };      
-
-   mpp_init(&argc, &argv);
-   sizeof_int = sizeof(int);
-   sizeof_double = sizeof(double);
-  
-   /* currently we are assuming the tool is always run on 1 processor */
-   if(mpp_npes() > 1) mpp_error("river_regrid: parallel is not supported yet, try running one single processor");
-   while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1) {
-      switch (c) {
-	 case 'a':
-	    mosaic_file  = optarg;
-	    break;
-	 case 'b':
-	    river_src_file = optarg;
-	    break;
-	 case 'c':
-	    strcpy(output_file,optarg);
-	    break;
-	 case '?':
-	    errflg++;
-	    break;
-      }
-   }
-  
-   if (errflg) {
-      char **u = usage;
-      while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-      exit(2);
-   }       
-
-   strcpy(history,argv[0]);
-   for(n=1;n<argc;n++)  {
-      strcat(history, " ");
-      strcat(history, argv[n]); 
-   }
-
-   if ((ret = gs_river_regrid(history, mosaic_file, 
-                              river_src_file, output_file)))
-      return ret;
-
-   mpp_end();
-
-   return 0;  
-
-} /* end of main */
-
diff --git a/gridspec_tools_20080702/tools/river_regrid/river_regrid.c b/gridspec_tools_20080702/tools/river_regrid/river_regrid.c
deleted file mode 100644
index f821e9e..0000000
--- a/gridspec_tools_20080702/tools/river_regrid/river_regrid.c
+++ /dev/null
@@ -1,1484 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <getopt.h>
-#include <math.h>
-#include "mpp.h"
-#include "mpp_io.h"
-#include "create_xgrid.h"
-#include "constant.h"
-#include "mosaic_util.h"
-#include "tool_util.h"
-
-char *usage[] = {
-  "",
-  "  river_regrid --mosaic mosaic_grid --river_src river_src_file [--output output_file] ",
-  "                                                                                    ",
-  "river_regrid will remap river network data from global regular lat-lon grid onto any  ",
-  "other grid (includes regular lat-lon grid and cubic grid ), which is specified        ",
-  "through option --mosaic. The river network source data is specified through option    ",
-  "--river_src.                                                                          ",
-  "                                                                                      ",
-  "river_regrid takes the following flags:                                               ",
-  "                                                                                      ",
-  "REQUIRED:                                                                             ",
-  "                                                                                      ",
-  "--mosaic    mosaic_grid     specify the mosaic file of destination grid. This mosaic  ",
-  "                            file should be a coupler mosaic file, which contains link ",
-  "                            to land solo mosaic and the exchange grid file.           ",
-  "                                                                                      ",
-  "--river_src river_src_file  specify the river network source data file. The data is   ",
-  "                            assumed on regular lat-lon grid and the longitude is      ",
-  "                            assumed from 0 to 360 degree and latitude is assumed      ",
-  "                            from -90 to 90 degree.                                    ",
-  "                                                                                      ",
-  "OPTIONAL FLAGS                                                                        ",
-  "                                                                                      ",
-  "--output output_file        specify the output file base name. the suffix '.nc'       ",
-  "                            should not be included in the output_file. The default    ",
-  "                            value is river_output. For one tile mosaic, the actual    ",
-  "                            result will be $output_file.nc. For multiple tile mosaic, ",
-  "                            the result will be $output.tile#.nc.                      ",
-  "                                                                                      ",  
-  NULL
-};
-
-/* const double LARGE_VALUE       = 1e20; */
-/* const int    X_CYCLIC          = 1; */
-/* const int    Y_CYCLIC          = 2; */
-/* const int    CUBIC_GRID        = 4; */
-/* const int    x_refine          = 2; */
-/* const int    y_refine          = 2; */
-/* const double EPSLN             = 1.e-4; */
-/* const double MIN_AREA_RATIO    = 1.e-6; */
-/* const double D2R               = M_PI/180.; */
-/*const char   subA_name[]       = "subA";*/
-/* const char   tocell_name[]     = "tocell"; */
-/* const char   travel_name[]     = "travel"; */
-/* const char   basin_name[]      = "basin"; */
-/* const char   cellarea_name[]   = "cellarea"; */
-/* const char   celllength_name[] = "celllength"; */
-/* const char   landfrac_name[]   = "land_frac"; */
-/* const char   tagname[]         = "$Name:  $"; */
-/* const char   version[]         = "0.1"; */
-/* const int    ncells = 3; */
-char   xaxis_name[128];
-char   yaxis_name[128];
-/* char   gridx_name[] = "grid_x"; */
-/* char   gridy_name[] = "grid_y"; */
-/* char   x_name[]     = "x"; */
-/* char   y_name[]     = "y"; */
-/* double suba_cutoff = 1.e12;   */
-
-
-/* typedef struct { */
-/*   int nx; */
-/*   int ny; */
-/*   double *xt; */
-/*   double *yt; */
-/*   double *xb; */
-/*   double *yb; */
-/*   double *xb_r; */
-/*   double *yb_r; */
-/*   double *area; */
-/*   double *landfrac; */
-/*   double *subA; */
-/*   double *cellarea; */
-/*   double *celllength; */
-/*   int    *tocell; */
-/*   int    *travel; */
-/*   int    *basin; */
-/*   int    *dir; */
-/*   int    *last_point; */
-/*   double subA_missing; */
-/*   double cellarea_missing; */
-/*   double celllength_missing; */
-/*   int    tocell_missing; */
-/*   int    travel_missing; */
-/*   int    basin_missing; */
-/*   char   filename[128]; */
-/* } river_type; */
-
-//inline void swap(void *x, void *y, size_t l);
-void qsort_index(double array[], int start, int end, int rank[]);
-void get_source_data(const char *src_file, river_type *river_data);
-void get_mosaic_grid(const char *coupler_mosaic, const char *land_mosaic,
-		     int ntiles, river_type *river_data, unsigned int *opcode);
-void init_river_data(int ntiles, river_type *river_out, const river_type * const river_in);
-void calc_max_subA(const river_type *river_in, river_type *river_out,
-		   int ntiles, unsigned int opcode);
-void update_halo_double(int ntiles, double **data, int nx, int ny, unsigned int opcode);
-void update_halo_int(int ntiles, int **data, int nx, int ny, unsigned int opcode);
-int adjust_lon(double x[], double tlon);
-void calc_tocell(int ntiles, river_type *river_out, unsigned int opcode );
-void calc_river_data(int ntiles, river_type* river_data, unsigned int opcode  );
-void sort_basin(int ntiles, river_type* river_data);
-
-void check_river_data( );
-void write_river_data(const char *river_src_file, const char *output_file,
-		      river_type* river_out, const char *history, int ntiles);
-double distance(double lon1, double lat1, double lon2, double lat2);
-
-int main(int argc, char* argv[])
-{
-  unsigned int opcode = 0;  
-  int          option_index, c;
-  char         *mosaic_file     = NULL;
-  char         *river_src_file  = NULL;
-  char         output_file[256] = "river_output";
-  int          ntiles, n;
-  char         land_mosaic_dir[256];
-  char         land_mosaic[256];
-  char         land_mosaic_file[256];  
-  char         history[1024];
-  
-  river_type river_in;
-  river_type *river_out; /* may be more than one tile */
-
-  int errflg = (argc == 1);
-
-  int    sizeof_int  = 0;
-  int    sizeof_double = 0;
-
-  static struct option long_options[] = {
-    {"mosaic_grid",       required_argument, NULL, 'a'},
-    {"river_src_file",    required_argument, NULL, 'b'},
-    {"output",            required_argument, NULL, 'c'},
-    {0, 0, 0, 0},
-  };      
-
-  mpp_init(&argc, &argv);
-  sizeof_int = sizeof(int);
-  sizeof_double = sizeof(double);
-  
-  /* currently we are assuming the tool is always run on 1 processor */
-  if(mpp_npes() > 1) mpp_error("river_regrid: parallel is not supported yet, try running one single processor");
-  while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1) {
-    switch (c) {
-    case 'a':
-      mosaic_file  = optarg;
-      break;
-    case 'b':
-      river_src_file = optarg;
-      break;
-    case 'c':
-      strcpy(output_file,optarg);
-      break;
-    case '?':
-      errflg++;
-      break;
-    }
-  }
-  
-  if (errflg) {
-    char **u = usage;
-    while (*u) { fprintf(stderr, "%s\n", *u); u++; }
-    exit(2);
-  }       
-
-  /* check the arguments */
-  if( !mosaic_file    ) mpp_error("fregrid: mosaic_grid is not specified");
-  if( !river_src_file ) mpp_error("fregrid: river_source_file is not specified");
-
-  strcpy(history,argv[0]);
-  for(n=1;n<argc;n++)  {
-    strcat(history, " ");
-    strcat(history, argv[n]); 
-  }
-
-#ifdef test_qsort  
-  {
-    /* test qsort_index here */
-    int    i, size = 7;
-    double array[]={12,5,18,25,14, 4,11};
-    int    rank[]={1,2,3,4,5,6,7};
-
-    qsort_index(array, 0, size-1, rank);
-    for(i=0; i<size; i++) printf("value = %f, rank = %d \n", array[i], rank[i]);
-  }
-#endif
-  
-  /* First read the source data and source grid */
-  get_source_data(river_src_file, &river_in);
-
-  /* get the mosaic grid information */
-  {
-    int fid, vid;
-    get_file_path(mosaic_file, land_mosaic_dir);
-    fid = mpp_open(mosaic_file, MPP_READ);
-    vid = mpp_get_varid(fid, "lnd_mosaic_file");
-    mpp_get_var_value(fid, vid, land_mosaic_file);
-    sprintf(land_mosaic, "%s/%s", land_mosaic_dir, land_mosaic_file);
-    mpp_close(fid);
-    fid = mpp_open(land_mosaic, MPP_READ);
-    ntiles = mpp_get_dimlen( fid, "ntiles");
-    mpp_close(fid);
-  }
-  river_out = (river_type *)malloc(ntiles*sizeof(river_type));
-  
-  get_mosaic_grid(mosaic_file, land_mosaic, ntiles, river_out, &opcode);
-
-  init_river_data(ntiles, river_out, &river_in);
-  
-  calc_max_subA(&river_in, river_out, ntiles, opcode );
-
-  calc_tocell(ntiles, river_out, opcode );
-
-  calc_river_data(ntiles, river_out, opcode );
-
-  sort_basin(ntiles, river_out);
-  
-  check_river_data(ntiles, river_out);
-  
-  write_river_data(river_src_file, output_file, river_out, history, ntiles);
-  
-  printf("Successfully running river_regrid and the following output file are generated.\n");
-  for(n=0; n<ntiles; n++) printf("****%s\n", river_out[n].filename);
-  
-  mpp_end();
-
-  return 0;  
-
-} /* end of main */
-
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void get_source_data(char *src_file) */
-/*   read the source file to get the source grid and river network data */
-/*   -----------------------------------------------------------------------------*\/ */
-/* void get_source_data(const char *src_file, river_type *river_data) */
-/* { */
-/*   int nx, ny, nxp, nyp; */
-/*   int i, j; */
-/*   int fid, vid; */
-/*   double dbl_missing; */
-
-/*   fid = mpp_open(src_file, MPP_READ); */
-/*   vid = mpp_get_varid(fid, subA_name); */
-  
-/*   mpp_get_var_dimname(fid, vid, 1, xaxis_name); */
-/*   mpp_get_var_dimname(fid, vid, 0, yaxis_name); */
-/*   nx  = mpp_get_dimlen(fid, xaxis_name ); */
-/*   ny  = mpp_get_dimlen(fid, yaxis_name ); */
-/*   nxp = nx + 1; */
-/*   nyp = ny + 1; */
-/*   river_data->nx  = nx; */
-/*   river_data->ny  = ny; */
-  
-/*   river_data->xt   = (double *)malloc(nx*sizeof(double)); */
-/*   river_data->yt   = (double *)malloc(ny*sizeof(double)); */
-/*   river_data->xb   = (double *)malloc(nxp*sizeof(double));  */
-/*   river_data->yb   = (double *)malloc(nyp*sizeof(double)); */
-/*   river_data->xb_r = (double *)malloc(nxp*sizeof(double));  */
-/*   river_data->yb_r = (double *)malloc(nyp*sizeof(double)); */
-/*   river_data->subA = (double *)malloc(nx*ny*sizeof(double)); */
-/*   mpp_get_var_att(fid, vid, "missing_value", &(river_data->subA_missing) ); */
-/*   vid = mpp_get_varid(fid, tocell_name); */
-/*   mpp_get_var_att(fid, vid, "missing_value", &dbl_missing ); */
-/*   river_data->tocell_missing = dbl_missing; */
-/*   vid = mpp_get_varid(fid, travel_name); */
-/*   mpp_get_var_att(fid, vid, "missing_value", &dbl_missing ); */
-/*   river_data->travel_missing = dbl_missing; */
-/*   vid = mpp_get_varid(fid, basin_name); */
-/*   mpp_get_var_att(fid, vid, "missing_value", &dbl_missing ); */
-/*   river_data->basin_missing = dbl_missing; */
-/*   vid = mpp_get_varid(fid, cellarea_name); */
-/*   mpp_get_var_att(fid, vid, "missing_value", &(river_data->cellarea_missing) ); */
-/*   vid = mpp_get_varid(fid, celllength_name); */
-/*   mpp_get_var_att(fid, vid, "missing_value", &(river_data->celllength_missing) ); */
-
-/*   vid = mpp_get_varid(fid, subA_name); */
-/*   mpp_get_var_value(fid, vid, river_data->subA); */
-/*   vid = mpp_get_varid(fid, xaxis_name); */
-/*   mpp_get_var_value(fid, vid, river_data->xt); */
-/*   vid = mpp_get_varid(fid, yaxis_name); */
-/*   mpp_get_var_value(fid, vid, river_data->yt); */
-/*   mpp_close(fid); */
-  
-/*   for(i=1; i<nx; i++ ) river_data->xb[i] = 0.5*(river_data->xt[i-1]+river_data->xt[i]); */
-/*   for(j=1; j<ny; j++ ) river_data->yb[j] = 0.5*(river_data->yt[j-1]+river_data->yt[j]); */
-/*   river_data->xb[0] = 2*river_data->xt[0] - river_data->xb[1]; */
-/*   river_data->yb[0] = 2*river_data->yt[0] - river_data->yb[1]; */
-/*   river_data->xb[nx] = 2*river_data->xt[nx-1] - river_data->xb[nx-1]; */
-/*   river_data->yb[ny] = 2*river_data->yt[ny-1] - river_data->yb[ny-1]; */
-
-/*   /\* make sure the xb is in the range [0,360] and yb is in the range [-90,90] *\/ */
-/*   if(fabs(river_data->xb[0]) > EPSLN) mpp_error("river_regrid: The starting longitude of grid bound is not 0"); */
-/*   if(fabs(river_data->xb[nx]-360) > EPSLN) mpp_error("river_regrid: The ending longitude of grid bound is not 360");   */
-/*   if(fabs(river_data->yb[0]+90) > EPSLN) mpp_error("river_regrid: The starting latitude of grid bound is not -90"); */
-/*   if(fabs(river_data->yb[ny]-90) > EPSLN) mpp_error("river_regrid: The ending latitude of grid bound is not 90");   */
-/*   river_data->xb[0]  = 0.; */
-/*   river_data->xb[nx] = 360.; */
-/*   river_data->yb[0]  = -90.; */
-/*   river_data->yb[ny] = 90.; */
-/*   for(j=0; j<nyp; j++) river_data->yb_r[j] = river_data->yb[j]*D2R; */
-/*   for(i=0; i<nxp; i++) river_data->xb_r[i] = river_data->xb[i]*D2R; */
-
-/* } */
-
-/* /\*---------------------------------------------------------------------- */
-/*    read the grid of detination mosaic.  */
-/*    void get_mosaic_grid(char *file) */
-/*    where file is the coupler mosaic file. */
-/*    --------------------------------------------------------------------*\/ */
-/* void get_mosaic_grid(const char *coupler_mosaic, const char *land_mosaic, int ntiles, river_type *river_data, unsigned int *opcode) */
-/* { */
-/*   int    n_xgrid_files, nx, ny, nxp, nyp, ni, nj, nip, njp; */
-/*   int    n, m, i, j, ii, jj, nxp2, nyp2; */
-/*   size_t start[4], nread[4]; */
-/*   char   dir[STRING], gridfile[STRING], tilefile[STRING]; */
-/*   char   tilename[STRING], land_mosaic_name[STRING]; */
-/*   char   **xgrid_file; */
-/*   double *x, *y; */
-/*   double **pxt, **pyt; */
-/*   char *pfile; */
-/*   int  m_fid, m_vid, g_fid, g_vid; */
-
-/*   /\* coupler_mosaic, land_mosaic, and exchange grid file should be located in the same directory *\/ */
-/*   get_file_path(coupler_mosaic, dir); */
-  
-/*   m_fid = mpp_open(coupler_mosaic, MPP_READ); */
-/*   m_vid = mpp_get_varid(m_fid, "lnd_mosaic"); */
-/*   mpp_get_var_value(m_fid, m_vid, land_mosaic_name); */
-  
-/*   /\* get the exchange grid file name *\/ */
-/*   n_xgrid_files = mpp_get_dimlen(m_fid, "nfile_aXl"); */
-/*   xgrid_file = (char **)malloc(n_xgrid_files*sizeof(char *)); */
-
-/*   m_vid = mpp_get_varid(m_fid, "aXl_file"); */
-/*   for(n=0; n<n_xgrid_files; n++) { */
-/*     xgrid_file[n] = (char *)malloc(STRING*sizeof(char)); */
-/*     start[0] = n; */
-/*     start[1] = 0; */
-/*     nread[0] = 1; */
-/*     nread[1] = STRING;     */
-/*     mpp_get_var_value_block(m_fid, m_vid, start, nread, xgrid_file[n]); */
-/*   } */
-/*   mpp_close(m_fid); */
-/*   m_fid = mpp_open(land_mosaic, MPP_READ); */
-/*   m_vid = mpp_get_varid(m_fid, "gridfiles"); */
-  
-/*   for( n = 0; n < ntiles; n++ ) { */
-/*     double *area; */
-    
-/*     start[0] = n; */
-/*     start[1] = 0; */
-/*     nread[0] = 1; */
-/*     nread[1] = STRING; */
-/*     mpp_get_var_value_block(m_fid, m_vid, start, nread, tilefile); */
-/*     sprintf(gridfile, "%s/%s", dir, tilefile); */
-/*     g_fid = mpp_open(gridfile, MPP_READ); */
-/*     ni = mpp_get_dimlen(g_fid, "nx"); */
-/*     nj = mpp_get_dimlen(g_fid, "ny"); */
-/*     nip = ni + 1; */
-/*     njp = nj + 1; */
-/*     x = (double *)malloc(nip*njp*sizeof(double)); */
-/*     y = (double *)malloc(nip*njp*sizeof(double)); */
-/*     g_vid = mpp_get_varid(g_fid, "x"); */
-/*     mpp_get_var_value(g_fid, g_vid, x); */
-/*     g_vid = mpp_get_varid(g_fid, "y"); */
-/*     mpp_get_var_value(g_fid, g_vid, y); */
-/*     mpp_close(g_fid); */
-/*     if( ni%x_refine != 0 ) mpp_error("river_regrid: supergrid x-size can not be divided by x_refine"); */
-/*     if( nj%y_refine != 0 ) mpp_error("river_regrid: supergrid y-size can not be divided by y_refine"); */
-/*     nx   = ni/x_refine; */
-/*     ny   = nj/y_refine; */
-/*     nxp  = nx + 1; */
-/*     nyp  = ny + 1; */
-/*     nxp2 = nx + 2; */
-/*     nyp2 = ny + 2; */
-/*     river_data[n].nx       = nx; */
-/*     river_data[n].ny       = ny; */
-/*     river_data[n].xt       = (double *)malloc(nxp2*nyp2*sizeof(double));         */
-/*     river_data[n].yt       = (double *)malloc(nxp2*nyp2*sizeof(double)); */
-/*     river_data[n].xb       = (double *)malloc(nxp*nyp*sizeof(double)); */
-/*     river_data[n].yb       = (double *)malloc(nxp*nyp*sizeof(double)); */
-/*     river_data[n].xb_r     = (double *)malloc(nxp*nyp*sizeof(double)); */
-/*     river_data[n].yb_r     = (double *)malloc(nxp*nyp*sizeof(double));     */
-/*     river_data[n].area     = (double *)malloc(nx*ny*sizeof(double)); */
-/*     river_data[n].landfrac = (double *)malloc(nx*ny*sizeof(double));     */
-/*     area                   = (double *)malloc(nx*ny*sizeof(double)); */
-    
-/*     /\* copy the data from super grid to fine grid *\/ */
-/*     for(i=0; i<nx*ny; i++) area[i] = 0.0; */
-/*     for(j = 0; j < ny; j++) for(i = 0; i < nx; i++) { */
-/*       ii = i+1; */
-/*       jj = j+1; */
-/*       river_data[n].xt[jj*nxp2+ii] = x[(j*y_refine+1)*nip+i*x_refine+1]; */
-/*       river_data[n].yt[jj*nxp2+ii] = y[(j*y_refine+1)*nip+i*x_refine+1]; */
-/*     } */
-/*     for(j = 0; j < nyp; j++) for(i = 0; i < nxp; i++) { */
-/*       river_data[n].xb[j*nxp+i] = x[(j*y_refine)*nip+i*x_refine]; */
-/*       river_data[n].yb[j*nxp+i] = y[(j*y_refine)*nip+i*x_refine]; */
-/*     }      */
-/*     free(x); */
-/*     free(y); */
-/*     /\* calculate cell area *\/ */
-
-/*     for(m=0; m<nxp*nyp; m++) { */
-/*       river_data[n].xb_r[m] = river_data[n].xb[m] * D2R; */
-/*       river_data[n].yb_r[m] = river_data[n].yb[m] * D2R; */
-/*     } */
-/*     get_grid_area(&nx, &ny, river_data[n].xb_r, river_data[n].yb_r, river_data[n].area); */
-
-/*     /\* calculate the land fraction *\/ */
-/*     sprintf(tilename, "X%s_tile%d", land_mosaic_name, n+1); */
-/*     for(m=0; m<n_xgrid_files; m++) { */
-/*       if(strstr(xgrid_file[m],tilename)) { */
-/* 	int    nxgrid, l; */
-/* 	int    *i1, *j1, *i2, *j2; */
-/* 	double *xgrid_area; */
-/* 	char filewithpath[512]; */
-	
-/* 	sprintf(filewithpath, "%s/%s", dir, xgrid_file[m]); */
-/* 	g_fid = mpp_open(filewithpath, MPP_READ); */
-/* 	nxgrid = mpp_get_dimlen(g_fid, "ncells"); */
-/* 	mpp_close(g_fid); */
-/* 	i1         = (int    *)malloc(nxgrid*sizeof(int)); */
-/* 	j1         = (int    *)malloc(nxgrid*sizeof(int));	   */
-/* 	i2         = (int    *)malloc(nxgrid*sizeof(int)); */
-/* 	j2         = (int    *)malloc(nxgrid*sizeof(int)); */
-/* 	xgrid_area = (double *)malloc(nxgrid*sizeof(double)); */
-/* 	read_mosaic_xgrid_order1(filewithpath, i1, j1, i2, j2, xgrid_area); */
-/* 	for(l=0; l<nxgrid; l++) area[j2[l]*nx+i2[l]] += xgrid_area[l]; */
-/* 	free(i1); */
-/* 	free(j1); */
-/* 	free(i2); */
-/* 	free(j2); */
-/*       } */
-/*     } */
-
-/*     for(m=0; m<nx*ny; m++) area[m] *= 4*M_PI*RADIUS*RADIUS; */
-/*     for(m=0; m<nx*ny; m++) { */
-/*       river_data[n].landfrac[m] = area[m]/river_data[n].area[m]; */
-/*       /\* consider truncation error *\/ */
-/*       if(fabs(river_data[n].landfrac[m]-1) < EPSLN) river_data[n].landfrac[m] = 1; */
-/*       if(fabs(river_data[n].landfrac[m])   < EPSLN) river_data[n].landfrac[m] = 0; */
-/*       if(river_data[n].landfrac[m] > 1 || river_data[n].landfrac[m] < 0) */
-/* 	mpp_error("river_regrid: land_frac should be between 0 or 1"); */
-/*     } */
-/*     free(area); */
-/*   } /\* n = 0, ntiles *\/ */
-
-/*   mpp_close(m_fid); */
-  
-/*   /\* currently we are assuming all the times have the same grid size *\/ */
-/*   for(n=1; n<ntiles; n++) { */
-/*     if(river_data[n].nx != river_data[0].nx || river_data[n].ny != river_data[0].ny ) */
-/*       mpp_error("river_regrid: all the tiles should have the same grid size"); */
-/*   } */
-  
-/*   /\*---------------------------------------------------------------------------- */
-/*     get boundary condition, currently we are assuming the following case, */
-/*     solid walls: number of contact will be 0. */
-/*     x-cyclic:    number of contact will be 1. */
-/*     y-cyclic:    number of contact will be 1. */
-/*     torus:       number of contact will be 2. */
-/*     cubic:       number of contact will be 12. */
-/*     --------------------------------------------------------------------------*\/ */
-/*   { */
-/*     int ncontact; */
-/*     int *tile1, *tile2; */
-/*     int *istart1, *iend1, *jstart1, *jend1; */
-/*     int *istart2, *iend2, *jstart2, *jend2; */
-    
-/*     ncontact = read_mosaic_ncontacts(land_mosaic); */
-/*     tile1   = (int *)malloc(ncontact*sizeof(int)); */
-/*     tile2   = (int *)malloc(ncontact*sizeof(int)); */
-/*     istart1 = (int *)malloc(ncontact*sizeof(int)); */
-/*     iend1   = (int *)malloc(ncontact*sizeof(int)); */
-/*     jstart1 = (int *)malloc(ncontact*sizeof(int)); */
-/*     jend1   = (int *)malloc(ncontact*sizeof(int)); */
-/*     istart2 = (int *)malloc(ncontact*sizeof(int)); */
-/*     iend2   = (int *)malloc(ncontact*sizeof(int)); */
-/*     jstart2 = (int *)malloc(ncontact*sizeof(int)); */
-/*     jend2   = (int *)malloc(ncontact*sizeof(int)); */
-/*     if(ncontact >0) { */
-/*       read_mosaic_contact(land_mosaic, tile1, tile2, istart1, iend1, */
-/* 			  jstart1, jend1, istart2, iend2, jstart2, jend2); */
-/*       if(ncontact <= 2) { /\* x-cyclic of y-cyclic *\/ */
-/* 	if(ntiles !=1) mpp_error("river_regrid: number of tiles must be 1 for single contact"); */
-/* 	for(n=0; n<ncontact; n++) { */
-/* 	  if(istart1[n] == iend1[n] && istart2[n] == iend2[n] ) /\* x_cyclic *\/ */
-/* 	    *opcode |= X_CYCLIC; */
-/* 	  else if(jstart1[n] == jend1[n] && istart2[n] == iend2[n] ) /\* x_cyclic *\/ */
-/* 	    *opcode |= Y_CYCLIC; */
-/* 	  else */
-/* 	    mpp_error("river_regrid: for one-tile mosaic, the boundary condition should be either x-cyclic or y-cyclic"); */
-/* 	} */
-/*       } */
-/*       else if(ncontact == 12) { */
-/* 	if(ntiles != 6) mpp_error("river_regrid: the mosaic must be a 6-tile cubic grid for 12 contacts."); */
-/* 	*opcode |= CUBIC_GRID; */
-/*       } */
-/*       else */
-/* 	mpp_error("river_regrid: the number of contact should be either 0, 1, 2 or 6"); */
-/*     } */
-
-/*     free(tile1); */
-/*     free(tile2); */
-/*     free(istart1); */
-/*     free(iend1); */
-/*     free(jstart1); */
-/*     free(jend1); */
-/*     free(istart2); */
-/*     free(iend2); */
-/*     free(jstart2); */
-/*     free(jend2); */
-/*   } */
-
-/*   /\* update halo of xt and yt *\/ */
-/*   pxt = (double **)malloc(ntiles*sizeof(double *)); */
-/*   pyt = (double **)malloc(ntiles*sizeof(double *)); */
-/*   for(n=0; n<ntiles; n++) { */
-/*     pxt[n] = river_data[n].xt; */
-/*     pyt[n] = river_data[n].yt; */
-/*   } */
-/*   update_halo_double(ntiles, pxt, nx, ny, *opcode); */
-/*   update_halo_double(ntiles, pyt, nx, ny, *opcode); */
-/*   free(pxt); */
-/*   free(pyt); */
-  
-/* }; /\* get_mosaic_grid *\/ */
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void init_river_data */
-/*   allocate memory to river data and initialize these river data with missing value */
-/*   ----------------------------------------------------------------------------*\/ */
-/* void init_river_data(int ntiles, river_type *river_out, const river_type * const river_in) */
-/* { */
-/*   int nx, ny, nxp2, nyp2, n, i; */
-/*   int tocell_missing, subA_missing, travel_missing, basin_missing; */
-/*   double cellarea_missing, celllength_missing; */
-  
-/*   nx = river_out->nx; */
-/*   ny = river_out->ny; */
-/*   nxp2 = nx + 2; */
-/*   nyp2 = ny + 2; */
-/*   subA_missing   = river_in->subA_missing; */
-/*   tocell_missing = river_in->tocell_missing; */
-/*   travel_missing = river_in->travel_missing; */
-/*   basin_missing  = river_in->basin_missing; */
-/*   cellarea_missing = river_in->cellarea_missing; */
-/*   celllength_missing = river_in->celllength_missing; */
-/*   for(n=0; n<ntiles; n++) { */
-/*     river_out[n].subA_missing   = subA_missing; */
-/*     river_out[n].tocell_missing = tocell_missing; */
-/*     river_out[n].travel_missing = travel_missing; */
-/*     river_out[n].basin_missing  = basin_missing; */
-/*     river_out[n].cellarea_missing = cellarea_missing; */
-/*     river_out[n].celllength_missing  = celllength_missing; */
-/*     river_out[n].subA       = (double *)malloc(nxp2*nyp2*sizeof(double)); */
-/*     river_out[n].tocell     = (int    *)malloc(nxp2*nyp2*sizeof(int   )); */
-/*     river_out[n].travel     = (int    *)malloc(nxp2*nyp2*sizeof(int   )); */
-/*     river_out[n].basin      = (int    *)malloc(nxp2*nyp2*sizeof(int   )); */
-/*     river_out[n].dir        = (int    *)malloc(nxp2*nyp2*sizeof(int   )); */
-/*     river_out[n].cellarea   = (double *)malloc(nx  *ny  *sizeof(double)); */
-/*     river_out[n].celllength = (double *)malloc(nx  *ny  *sizeof(double)); */
-/*     river_out[n].last_point = (int    *)malloc(nx  *ny  *sizeof(int   )); */
-/*     for(i=0; i<nxp2*nyp2; i++) { */
-/*       river_out[n].subA  [i] = subA_missing; */
-/*       river_out[n].travel[i] = travel_missing; */
-/*       river_out[n].basin [i] = basin_missing; */
-/*       river_out[n].tocell[i] = tocell_missing; */
-/*       river_out[n].dir[i]    = -1; */
-/*     } */
-/*     for(i=0; i<nx*ny; i++) { */
-/*       river_out[n].cellarea[i]   = cellarea_missing; */
-/*       river_out[n].celllength[i] = celllength_missing; */
-/*       river_out[n].last_point[i] =  0; */
-/*     } */
-/*   } */
-
-/* } */
-
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void calc_max_subA(const river_type *river_in, river_type *river_out, int ntiles) */
-/*   find max value of suba in each model grid cell. */
-/*   ----------------------------------------------------------------------------*\/ */
-/* void calc_max_subA(const river_type *river_in, river_type *river_out, int ntiles, unsigned int opcode) */
-/* { */
-/*   int nx_in, ny_in; */
-/*   int nx_out, ny_out, nxp_out, nxp1, nyp1, nxp2, nyp2; */
-/*   int n, i, j, i1, j1, ii, jj, n_out; */
-/*   double missing, ll_y, ur_y, ll_x, ur_x; */
-/*   double xv1[4], yv1[4], xv2[20], yv2[20]; */
-/*   double *xb_in, *yb_in; */
-/*   double *xb_out, *yb_out; */
-/*   double **psubA; */
-  
-/*   nx_in = river_in->nx; */
-/*   ny_in = river_in->ny; */
-/*   xb_in = river_in->xb_r; */
-/*   yb_in = river_in->yb_r; */
-/*   missing = river_out->subA_missing; */
-  
-/*   for(n=0; n<ntiles; n++) { */
-/*     nx_out   = river_out[n].nx; */
-/*     ny_out   = river_out[n].ny; */
-/*     nxp2     = nx_out + 2; */
-/*     nyp2     = ny_out + 2;     */
-/*     nxp_out  = nx_out+1; */
-/*     xb_out   = river_out[n].xb_r; */
-/*     yb_out   = river_out[n].yb_r; */
-/*     for(j=0; j<ny_out; j++) for(i=0; i<nx_out; i++) { */
-/*       j1 = j+1; */
-/*       i1 = i+1; */
-/*       /\* set partial land cell and ocean cell to have large subA value *\/ */
-/*       if(river_out[n].landfrac[j*nx_out+i] < 1) { */
-/* 	river_out[n].subA[j1*nxp2+i1] = LARGE_VALUE; */
-/* 	continue; */
-/*       } */
-      
-/*       xv1[0] = xb_out[j*nxp_out+i]; */
-/*       xv1[1] = xb_out[j*nxp_out+i1]; */
-/*       xv1[2] = xb_out[j1*nxp_out+i1]; */
-/*       xv1[3] = xb_out[j1*nxp_out+i];  */
-/*       yv1[0] = yb_out[j*nxp_out+i]; */
-/*       yv1[1] = yb_out[j*nxp_out+i1]; */
-/*       yv1[2] = yb_out[j1*nxp_out+i1]; */
-/*       yv1[3] = yb_out[j1*nxp_out+i];  */
-      
-/*       for(jj=0; jj<ny_in; jj++) { */
-/* 	ll_y = yb_in[jj]; */
-/* 	ur_y = yb_in[jj+1]; */
-/* 	if (  (yv1[0]<=ll_y) && (yv1[1]<=ll_y) */
-/* 	      && (yv1[2]<=ll_y) && (yv1[3]<=ll_y) ) continue; */
-/* 	if (  (yv1[0]>=ur_y) && (yv1[1]>=ur_y) */
-/* 	      && (yv1[2]>=ur_y) && (yv1[3]>=ur_y) ) continue; */
-	
-/* 	for(ii=0; ii<nx_in; ii++) { */
-/* 	  if(river_in->subA[jj*nx_in+ii] == missing) continue; */
-/* 	  ll_x = xb_in[ii]; */
-/* 	  ur_x = xb_in[ii+1]; */
-/* 	  /\* adjust xv1 to make sure it is in the range as ll_x and ur_x *\/ */
-/* 	  adjust_lon(xv1, 0.5*(ll_x + ur_x) ); */
-/* 	  if ( (xv1[0]<=ll_x) && (xv1[1]<=ll_x) && (xv1[2]<=ll_x) && (xv1[3]<=ll_x) ) continue; */
-/* 	  if ( (xv1[0]>=ur_x) && (xv1[1]>=ur_x) && (xv1[2]>=ur_x) && (xv1[3]>=ur_x) ) continue;	   */
-/* 	  if ( (n_out = clip ( xv1, yv1, 4, ll_x, ll_y, ur_x, ur_y, xv2, yv2 )) > 0 ) { */
-/* 	    double xarea;  */
-/* 	    xarea = poly_area (xv2, yv2, n_out ); */
-/* 	    if( xarea/river_out[n].area[j*nx_out+i] < MIN_AREA_RATIO ) continue; */
-/* 	    if(river_in->subA[jj*nx_in+ii] > river_out[n].subA[j1*nxp2+i1]) */
-/* 	      river_out[n].subA[j1*nxp2+i1] = river_in->subA[jj*nx_in+ii]; */
-/* 	  } */
-/* 	} */
-/*       } */
-/*     } */
-/*   } */
-	
-/*   /\* fill the halo of subA *\/ */
-/*   psubA = (double **)malloc(ntiles*sizeof(double *)); */
-/*   for(n=0; n<ntiles; n++) psubA[n] = river_out[n].subA;  */
-/*   update_halo_double(ntiles, psubA, river_out->nx, river_out->ny, opcode);  */
-/*   free(psubA); */
-/* };/\* calc_max_subA *\/ */
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void update_halo_double(int ntiles, double *data, int nx, int ny, unsigned int opcode) */
-/*   We assume all the tiles have the same size. */
-/*   -----------------------------------------------------------------------------*\/ */
-/* void update_halo_double(int ntiles, double **data, int nx, int ny, unsigned int opcode) */
-/* { */
-/*   int nxp1, nyp1, nxp2, i, j, n; */
-/*   int te, tw, ts, tn; */
-  
-/*   nxp1   = nx + 1; */
-/*   nyp1   = ny + 1; */
-/*   nxp2   = nx + 2; */
-/*   if(opcode & X_CYCLIC) { */
-/*     for(j=1; j<nyp1; j++) { */
-/*       data[0][j*nxp2]      = data[0][j*nxp2+nx];     /\* West *\/ */
-/*       data[0][j*nxp2+nxp1] = data[0][j*nxp2+1];      /\* east *\/ */
-/*     } */
-/*   } */
-/*   if(opcode & Y_CYCLIC) { */
-/*     for(i=1; i<nyp1; i++) { */
-/*       data[0][i]           = data[0][ny*nxp2+i];     /\* south *\/ */
-/*       data[0][nyp1*nxp2+i] = data[0][nxp2+i];        /\* north *\/ */
-/*     } */
-/*   } */
-/*   if(opcode & X_CYCLIC && opcode & Y_CYCLIC) { */
-/*     data[0][0]              = data[0][ny*nxp2];      /\* southwest *\/ */
-/*     data[0][nxp1]           = data[0][ny*nxp2+1];    /\* southeast *\/     */
-/*     data[0][nyp1*nxp2+nxp1] = data[0][nxp2+1];       /\* northeast *\/ */
-/*     data[0][nyp1*nxp2]      = data[0][nxp2+nx];      /\* northwest *\/      */
-/*   } */
-
-/*   if(opcode & CUBIC_GRID) { */
-/*     for(n=0; n<ntiles; n++) { */
-      
-/*       if(n%2) { /\* tile 2 4 6 *\/ */
-/* 	tw = (n+5)%ntiles; te = (n+2)%ntiles; ts = (n+4)%ntiles; tn = (n+1)%ntiles; */
-/* 	for(j=1; j<nyp1; j++) { */
-/* 	  data[n][j*nxp2]      = data[tw][j*nxp2+nx];     /\* west *\/ */
-/* 	  data[n][j*nxp2+nxp1] = data[te][nxp2+(nxp1-j)]; /\* east *\/ */
-/* 	} */
-/* 	for(i=1; i<nxp1; i++) { */
-/* 	  data[n][i]           = data[ts][(nyp1-i)*nxp2+nx]; /\* south *\/ */
-/* 	  data[n][nyp1*nxp2+i] = data[tn][nxp2+i];           /\* north *\/ */
-/* 	} */
-/*       } else {  /\* tile 1, 3, 5 *\/ */
-/*        tw = (n+4)%ntiles; te = (n+1)%ntiles; ts = (n+5)%ntiles; tn = (n+2)%ntiles; */
-/* 	for(j=1; j<nyp1; j++) { */
-/* 	  data[n][j*nxp2]      = data[tw][ny*nxp2+nxp1-j]; /\* west *\/ */
-/* 	  data[n][j*nxp2+nxp1] = data[te][j*nxp2+1];       /\* east *\/ */
-/* 	} */
-/* 	for(i=1; i<nxp1; i++) { */
-/* 	  data[n][i]           = data[ts][ny*nxp2+i];       /\* south *\/ */
-/* 	  data[n][nyp1*nxp2+i] = data[tn][(nyp1-i)*nxp2+1]; /\* north *\/ */
-/* 	} */
-/*       } */
-/*     } */
-/*   } */
-  
-/* };/\* update_halo *\/ */
-
-/* void update_halo_int(int ntiles, int **data, int nx, int ny, unsigned int opcode) */
-/* { */
-/*   double **ldata; */
-/*   int n, i, j, nxp2, nyp2; */
-  
-/*   nxp2 = nx + 2; */
-/*   nyp2 = ny + 2; */
-
-
-  
-/*   ldata = (double **)malloc(ntiles*sizeof(double *)); */
-/*   for(n=0; n<ntiles; n++) { */
-/*     ldata[n] =  (double *)malloc(nxp2*nyp2*sizeof(double)); */
-/*     for(i=0; i<nxp2*nyp2; i++) ldata[n][i] = data[n][i]; */
-/*   } */
-/*   update_halo_double(ntiles, ldata, nx, ny, opcode); */
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(i=0; i<nxp2*nyp2; i++) data[n][i] = ldata[n][i]; */
-/*     free(ldata[n]); */
-/*   } */
-/*   free(ldata); */
-  
-/* } */
-
-/* int adjust_lon(double x[], double tlon) */
-/* { */
-/*   double x_sum, dx; */
-/*   int i, npts = 4; */
-
-/*   x_sum = x[0]; */
-/*   for (i=1;i<npts;i++) { */
-/*     double dx = x[i]-x[i-1]; */
-
-/*     if      (dx < -M_PI) dx = dx + 2*M_PI; */
-/*     else if (dx >  M_PI) dx = dx - 2*M_PI; */
-/*     x_sum += (x[i] = x[i-1] + dx); */
-/*   } */
-
-/*   dx = (x_sum/npts)-tlon; */
-/*   if      (dx < -M_PI) for (i=0;i<npts;i++) x[i] += 2*M_PI; */
-/*   else if (dx >  M_PI) for (i=0;i<npts;i++) x[i] -= 2*M_PI; */
-
-/* }; /\* adjust_lon *\/ */
-
-/* /\*------------------------------------------------------------------------------ */
-/*   Find the tocell value for the new grid. */
-/*   void calc_tocell( ) */
-/*   ----------------------------------------------------------------------------*\/ */
-/* void calc_tocell(int ntiles, river_type *river_data, unsigned int opcode )   */
-/* { */
-/*   const int out_flow[] = { 8, 4, 2, 16, -1, 1, 32, 64, 128}; */
-/*   const int out_dir[]  = { 3, 2, 1, 4,  -1, 0, 5,   6,   7}; */
-/*   int n, nx, ny, nxp2, ioff, joff; */
-/*   int i, j, ii, jj, iget, jget, im1, jm1; */
-/*   double tval, subA_missing, subA, subA_me; */
-/*   int **ptocell, **pdir; */
-  
-/*   nx = river_data->nx; */
-/*   ny = river_data->ny; */
-/*   nxp2 = nx + 2; */
-/*   subA_missing = river_data->subA_missing; */
-/*   ptocell = (int **)malloc(ntiles*sizeof(int *)); */
-/*   pdir    = (int **)malloc(ntiles*sizeof(int *)); */
-/*   for(n=0; n<ntiles; n++) { */
-/*     ptocell[n] = river_data[n].tocell; */
-/*     pdir   [n] = river_data[n].dir; */
-/*   } */
-  
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/*       jm1 = j - 1; */
-/*       im1 = i - 1; */
-/*       if(river_data[n].landfrac[jm1*nx+im1] == 0) { */
-/* 	/\* do nothing *\/ */
-/*       } */
-/*       else if(river_data[n].landfrac[jm1*nx+im1] < 1) { */
-/* 	ptocell[n][j*nxp2+i] = 0; */
-/*       } */
-/*       else { */
-/* 	subA_me = river_data[n].subA[j*nxp2+i]; */
-/* 	tval= -999 ;  iget= -1 ;  jget= -1; */
-/* 	if(subA_me > suba_cutoff ) { /\* tocell will be land cell with larger subA value, instead of neighboring ocean cell. *\/ */
-/* 	  for(joff=0; joff<ncells; joff++) { */
-/* 	    jj = jm1+joff; */
-/* 	    for(ioff=0; ioff<ncells; ioff++) { */
-/* 	      ii = im1+ioff; */
-/* 	      if(ioff == 1 && joff == 1) continue; */
-/* 	      subA = river_data[n].subA[jj*nxp2+ii]; */
-/* 	      if(subA > subA_me) { */
-/* 		if(tval == -999 ) { */
-/* 		  if(subA > tval) { */
-/* 		    iget = ioff; */
-/* 		    jget = joff; */
-/* 		    tval = subA; */
-/* 		  } */
-/* 		} */
-/* 		else if(tval < LARGE_VALUE) { */
-/* 		  if(subA > tval && subA < LARGE_VALUE) { */
-/* 		    iget = ioff; */
-/* 		    jget = joff; */
-/* 		    tval = subA; */
-/* 		  } */
-/* 		} */
-/* 		else { */
-/* 		  iget = ioff; */
-/* 		  jget = joff; */
-/* 		  tval = subA; */
-/* 		} */
-/* 	      } */
-/* 	    } */
-/* 	  } */
-/* 	} */
-/* 	else { */
-/* 	  for(joff=0; joff<ncells; joff++) { */
-/* 	    jj = jm1+joff; */
-/* 	    for(ioff=0; ioff<ncells; ioff++) { */
-/* 	      ii = im1+ioff; */
-/* 	      if(ioff == 1 && joff == 1) continue; */
-
-/* 	      subA = river_data[n].subA[jj*nxp2+ii]; */
-/* 	      if( subA != subA_missing ) { */
-/* 		if( subA >= tval) { */
-/* 		  iget = ioff; */
-/* 		  jget = joff; */
-/* 		  tval = subA; */
-/* 		} */
-/* 	      } */
-/* 	    } */
-/* 	  } */
-/* 	} */
-/* 	if(iget >= 0 && jget >= 0) { */
-/* 	  if(tval > river_data[n].subA[j*nxp2+i]) { */
-/* 	    ptocell[n][j*nxp2+i] = out_flow[jget*ncells+iget]; */
-/* 	    pdir   [n][j*nxp2+i] = out_dir [jget*ncells+iget]; */
-/* 	    if(pow(2,pdir[n][j*nxp2+i]) != ptocell[n][j*nxp2+i] ) */
-/* 	      mpp_error("river_regrid: pow(2,dir) should equal to tocell"); */
-/* 	  } */
-/* 	  else */
-/* 	    ptocell[n][j*nxp2+i] = 0; */
-/* 	} */
-/* 	else  */
-/* 	  ptocell[n][j*nxp2+i] = 0; */
-/*       } */
-/*     } */
-/*   } */
-/*   update_halo_int(ntiles, ptocell, nx, ny, opcode);    */
-/*   update_halo_int(ntiles, pdir, nx, ny, opcode); */
-/*   free(ptocell); */
-/*   free(pdir); */
-  
-/* };/\* calc_tocell *\/ */
-
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void calc_river_data() */
-/*   calculate travel and basin according to tocell, as well as celllength, cellarea. */
-/*   For each basin, one and only one river point will have tocell = 0, this point will */
-/*   have travel = 1. */
-/*   ----------------------------------------------------------------------------*\/ */
-/* void calc_river_data(int ntiles, river_type* river_data, unsigned int opcode ) */
-/* { */
-/*   int    nx, ny, nxp2, nyp2, n, i, j, ii, jj, nxp, nyp, im1, jm1, ioff, joff; */
-/*   int    cur_basin, cur_travel; */
-/*   int    not_done, dir, i_dest, j_dest; */
-/*   int    basin_missing, travel_missing, tocell_missing; */
-/*   int    maxtravel, maxbasin, travelnow; */
-/*   double subA_missing; */
-/*   int    **pbasin, **ptravel, **pdir; */
-/*   double **psubA; */
-/*   double xv[4], yv[4]; */
-  
-/*   const int di[] = {1,1,0,-1,-1,-1,0,1}; */
-/*   const int dj[] = {0,-1,-1,-1,0,1,1,1}; */
-/*   nx = river_data->nx; */
-/*   ny = river_data->ny; */
-/*   nxp  = nx+1; */
-/*   nyp  = ny+1; */
-/*   nxp2 = nx+2; */
-/*   nyp2 = ny+2; */
-/*   basin_missing  = river_data->basin_missing; */
-/*   subA_missing   = river_data->subA_missing; */
-/*   tocell_missing = river_data->tocell_missing; */
-/*   cur_basin = 0; */
-
-/*   /\* set up pointer *\/ */
-/*   pbasin  = (int **)malloc(ntiles*sizeof(int *)); */
-/*   ptravel = (int **)malloc(ntiles*sizeof(int *)); */
-/*   pdir    = (int **)malloc(ntiles*sizeof(int *)); */
-/*   psubA   = (double **)malloc(ntiles*sizeof(double *)); */
-/*   for(n=0; n<ntiles; n++) { */
-/*     pbasin [n] = river_data[n].basin; */
-/*     ptravel[n] = river_data[n].travel; */
-/*     psubA  [n] = river_data[n].subA; */
-/*     pdir   [n] = river_data[n].dir; */
-/*   } */
-
-
-/*   /\* reinitialize subA *\/ */
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(i=0; i<nxp2*nyp2; i++) psubA[n][i] = subA_missing;     */
-/*   } */
-  
-/*   /\* calculate celllength and cellarea *\/ */
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=0; j<ny; j++) for(i=0; i<nx; i++) { */
-/*       if(river_data[n].landfrac[j*nx+i] > 0) { */
-/* 	ii = i+1; */
-/* 	jj = j+1; */
-
-/* 	xv[0] = river_data[n].xb_r[j*nxp+i]; */
-/* 	xv[1] = river_data[n].xb_r[j*nxp+ii]; */
-/* 	xv[2] = river_data[n].xb_r[jj*nxp+ii]; */
-/* 	xv[3] = river_data[n].xb_r[jj*nxp+i]; */
-/* 	yv[0] = river_data[n].yb_r[j*nxp+i]; */
-/* 	yv[1] = river_data[n].yb_r[j*nxp+ii]; */
-/* 	yv[2] = river_data[n].yb_r[jj*nxp+ii]; */
-/* 	yv[3] = river_data[n].yb_r[jj*nxp+i]; */
-/* 	river_data[n].cellarea[j*nx+i] = river_data[n].area[j*nx+i]*river_data[n].landfrac[j*nx+i]; */
-/* 	dir = pdir[n][jj*nxp2+ii]; */
-/* 	if( dir >= 0) { */
-/* 	  i_dest = ii + di[dir]; */
-/* 	  j_dest = jj + dj[dir];	 */
-/* 	  river_data[n].celllength[j*nx+i] = distance(river_data[n].xt[jj*nxp2+ii], */
-/* 						      river_data[n].yt[jj*nxp2+ii], */
-/* 						      river_data[n].xt[j_dest*nxp2+i_dest], */
-/* 						      river_data[n].yt[j_dest*nxp2+i_dest] ); */
-/* 	} */
-/* 	else */
-/* 	  river_data[n].celllength[j*nx+i] = 0; */
-/*       } */
-/*     } */
-/*   } */
-
-  
-/*   /\* define the basinid and travel for the coast point *\/ */
-  
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/*       if(river_data[n].tocell[j*nxp2+i] == 0) { */
-/* 	pbasin[n] [j*nxp2+i] = ++cur_basin; */
-/* 	ptravel[n][j*nxp2+i] = 0; */
-/* 	river_data[n].last_point[(j-1)*nx+i-1] = 1; */
-/*       } */
-/*       else if(river_data[n].tocell[j*nxp2+i] > 0){ */
-/* 	dir = pdir[n][j*nxp2+i]; */
-/* 	i_dest = i + di[dir]; */
-/* 	j_dest = j + dj[dir]; */
-/* 	if(river_data[n].tocell[j_dest*nxp2+i_dest] == tocell_missing) { */
-/* 	  pbasin[n] [j*nxp2+i] = ++cur_basin; */
-/* 	  ptravel[n][j*nxp2+i] = 1; */
-/* 	  river_data[n].last_point[(j-1)*nx+i-1] = 1; */
-/* 	} */
-/*       } */
-/*     } */
-/*   } */
-
-/*   update_halo_int(ntiles, pbasin, nx, ny, opcode); */
-/*   update_halo_int(ntiles, ptravel, nx, ny, opcode); */
-  
-/*   /\* then define the travel and basin for all other points *\/ */
-/*   cur_travel = 0; */
-
-/*   not_done = 1; */
-/*   while(not_done) { */
-/*     not_done = 0; */
-/*     for(n=0; n<ntiles; n++) { */
-/*       for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/* 	dir = pdir[n][j*nxp2+i]; */
-/* 	if( dir >= 0 && pbasin[n][j*nxp2+i] == basin_missing ) { */
-/*           i_dest = i + di[dir]; */
-/* 	  j_dest = j + dj[dir]; */
-/* 	  if( ptravel[n][j_dest*nxp2+i_dest] == cur_travel ) { */
-/* 	    not_done = 1; /\* still have points need to be updateed *\/ */
-/* 	    if(pbasin[n][j_dest*nxp2+i_dest] == basin_missing) { */
-/* 	      mpp_error("river_grid: the tocell should have valid basin value"); */
-/* 	    } */
-/* 	    pbasin[n][j*nxp2+i] = pbasin[n][j_dest*nxp2+i_dest]; */
-/* 	    ptravel[n][j*nxp2+i] = cur_travel+1; */
-/* 	  } */
-/* 	} */
-/*       } */
-/*     } */
-/*     cur_travel++; */
-/*     update_halo_int(ntiles, pbasin, nx, ny, opcode); */
-/*     update_halo_int(ntiles, ptravel, nx, ny, opcode);     */
-/*   } */
-
-/*   /\* figure out maximum travel and maximum basin*\/ */
-/*   maxtravel = -1; */
-/*   maxbasin  = -1; */
-/*   basin_missing = river_data->basin_missing; */
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {     */
-/*       maxtravel = max(maxtravel, ptravel[n][j*nxp2+i]); */
-/*       maxbasin  = max(maxbasin,  pbasin[n][j*nxp2+i]); */
-/*     } */
-/*   } */
-
-/*   for(travelnow=maxtravel; travelnow>=0; travelnow--) { */
-/*     for(n=0; n<ntiles; n++) for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/*       jm1 = j - 1; */
-/*       im1 = i - 1; */
-/*       if(ptravel[n][j*nxp2+i] == travelnow) { */
-/* 	psubA[n][j*nxp2+i] = river_data[n].cellarea[jm1*nx+im1]; */
-/* 	/\* add the subA of from cell *\/ */
-/* 	for(joff=0; joff<ncells; joff++) for(ioff=0; ioff<ncells; ioff++) { */
-/* 	  if(ioff == 1 && joff == 1) continue; */
-/* 	  jj = jm1 + joff; */
-/* 	  ii = im1 + ioff; */
-/* 	  dir = pdir[n][jj*nxp2+ii]; */
-/* 	  /\* consider about the rotation when it is on the boundary *\/ */
-/* 	  if(dir >=0 ) { */
-/* 	    if( opcode & CUBIC_GRID ) { */
-/* 	      if(ii == 0) { /\* west *\/  */
-/* 		if(n%2==0) dir = (dir+2)%8;  /\* tile 1 3 5 *\/ */
-/* 	      } */
-/* 	      else if(ii == nxp) { /\*east *\/ */
-/* 		if(n%2==1) dir = (dir+2)%8;  /\* tile 2 4 6 *\/ */
-/* 	      } */
-/* 	      else if(jj == 0) { /\* south *\/ */
-/* 		if(n%2==1) dir = (dir+6)%8;  /\* tile 2 4 6 *\/ */
-/* 	      } */
-/* 	      else if(jj == nyp) { /\*north *\/ */
-/* 		if(n%2==0) dir = (dir+6)%8;  /\* tile 1 3 5 *\/ */
-/* 	      } */
-/* 	    } */
-/* 	    i_dest = ii + di[dir]; */
-/* 	    j_dest = jj + dj[dir]; */
-/* 	    if(i_dest == i && j_dest == j) psubA[n][j*nxp2+i] += psubA[n][jj*nxp2+ii]; */
-/* 	  } */
-/* 	} */
-/*       } */
-/*     } */
-/*     update_halo_double(ntiles, psubA, nx, ny, opcode); */
-/*   } */
-  
-/*   free(pbasin); */
-/*   free(ptravel); */
-/*   free(psubA); */
-/*   free(pdir); */
-/* }; /\*  calc_travel *\/ */
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void check_river_data( ) */
-/*   check to make sure all the river points have been assigned travel and basin value */
-/*   and all the ocean points will have missing value. */
-/*   ----------------------------------------------------------------------------*\/ */
-  
-/* void check_river_data(int ntiles, river_type *river_data ) */
-/* { */
-/*   int maxtravel = -1; */
-/*   int maxbasin  = -1; */
-/*   int nx, ny, nxp2, nyp2; */
-/*   int n, i, j, im1, jm1, ioff, joff, ii, jj; */
-/*   int tocell, travel, basin; */
-/*   int tocell_missing, travel_missing, basin_missing; */
-/*   int ncoast_full_land, nsink; */
-/*   double subA, subA_missing; */
-/*   int *ncoast; */
-  
-/*   /\* print out maximum travel and number of rivers *\/ */
-/*   maxtravel = -1; */
-/*   maxbasin  = -1; */
-/*   nx = river_data->nx; */
-/*   ny = river_data->ny; */
-/*   nxp2 = nx + 2; */
-/*   nyp2 = ny + 2; */
-/*   subA_missing = river_data->subA_missing; */
-/*   tocell_missing = river_data->tocell_missing; */
-/*   basin_missing = river_data->basin_missing; */
-/*   travel_missing = river_data->travel_missing; */
-  
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {     */
-/*       maxtravel = max(maxtravel, river_data[n].travel[j*nxp2+i]); */
-/*       maxbasin  = max(maxbasin, river_data[n].basin[j*nxp2+i]); */
-/*     } */
-/*   } */
-/*   printf("==> NOTE from river_regrid: maximum travel is %d and maximum basin is %d.\n", maxtravel, maxbasin); */
-
-/*   ncoast_full_land = 0; */
-/*   nsink = 0; */
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/*       jm1 = j - 1; */
-/*       im1 = i -1; */
-/*       subA   = river_data[n].subA  [j*nxp2+i]; */
-/*       tocell = river_data[n].tocell[j*nxp2+i]; */
-/*       travel = river_data[n].travel[j*nxp2+i]; */
-/*       basin  = river_data[n].basin [j*nxp2+i]; */
-/*       if( river_data[n].landfrac[jm1*nx+im1] == 0) { */
-/* 	if(tocell!= tocell_missing || travel != travel_missing || */
-/* 	   basin != basin_missing || subA != subA_missing) { */
-/* 	  printf("At ocean points (i=%d,j=%d), subA = %f, tocell = %d, travel = %d, basin = %d.\n ", */
-/* 		 i, j, subA, tocell, travel, basin); */
-/* 	  mpp_error("river_regrid, subA, tocell, travel, or basin is not missing value for some ocean points"); */
-/* 	} */
-/*       } */
-/*       else { */
-/* 	if(tocell == tocell_missing || travel == travel_missing || */
-/* 	   basin == basin_missing || subA == subA_missing) { */
-/* 	  printf("At river points (i=%d,j=%d), subA = %f, tocell = %d, travel = %d, basin = %d.\n ", */
-/* 		 i, j, subA, tocell, travel, basin); */
-/* 	  mpp_error("river_regrid, subA, tocell, travel, or basin is missing value for some river points"); */
-/* 	} */
-/*       } */
-/*       /\* check if the points with land_frac == 1 and tocell=0, those points should be sink.*\/ */
-/*       if(river_data[n].landfrac[jm1*nx+im1] == 1 && tocell == 0) { */
-/* 	for(joff=0; joff<ncells; joff++) { */
-/* 	  jj = jm1+joff; */
-/* 	  for(ioff=0; ioff<ncells; ioff++) { */
-/* 	    ii = im1+ioff; */
-/*             if(ioff == 1 && joff == 1) continue; */
-/* 	    if(river_data[n].tocell[jj*nxp2+ii] == tocell_missing) { */
-/* 	      ncoast_full_land++; */
-/* 	      printf("At point (%d,%d), tocell = 0 and landfrac = 1 is a coast point\n", i, j); */
-/* 	      goto done_check; */
-/* 	    } */
-/* 	  } */
-/* 	} */
-/* 	 printf("At point (%d,%d), tocell = 0 and landfrac = 1 is a sink point\n", i, j); */
-/*         nsink++; */
-/*       done_check: continue;	 */
-/*       } */
-/*     } */
-/*   } */
-
-/*   if(ncoast_full_land > 0) */
-/*     printf("Warning from river_regrid: there are %d coast points is a full land cell\n", ncoast_full_land); */
-/*   else */
-/*     printf("NOTE from river_regrid: there are no coast points is a full land cell\n"); */
-
-/*   if(nsink > 0) */
-/*     printf("Warning from river_regrid: there are %d sink points is a full land cell\n", nsink); */
-/*   else */
-/*     printf("NOTE from river_regrid: there are no sink points is a full land cell\n"); */
-  
-/*   /\* check river travel to make sure there is one and only one point with travel = 0. *\/ */
-/*   ncoast = (int *)malloc(maxbasin*sizeof(int)); */
-/*   for(n=0; n<maxbasin; n++) ncoast[n] = 0; */
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/*       if(river_data[n].last_point[(j-1)*nx+i-1] ) ++ncoast[river_data[n].basin[j*nxp2+i]-1]; */
-/*     } */
-/*   } */
-/*   for(n=0; n<maxbasin; n++) { */
-/*     if(ncoast[n] <= 0) { */
-/*       printf("river with basin = %d has no point with travel = 0.\n", n+1); */
-/*       mpp_error("river_regrid: some river has no point with travel = 0"); */
-/*     } */
-/*     else if(ncoast[n] >1) { */
-/*       printf("river with basin = %d has more than one point with travel = 0.\n", n+1); */
-/*       mpp_error("river_regrid: some river has more than one point with travel = 0"); */
-/*     } */
-/*   } */
-/*   free(ncoast); */
-  
-
-/* }; /\* check_river_data *\/ */
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void sort_basin(int ntiles, river_type* river_data); */
-/*   sorting the basin according to subA */
-/*   The river with larger subA at coast point will get smaller basinid. */
-/*   The basinid will be reorganized. */
-/*   -----------------------------------------------------------------------------*\/ */
-/* void sort_basin(int ntiles, river_type* river_data) */
-/* { */
-
-/*   int    nx, ny, nxp2, nyp2, i, j, n; */
-/*   int    maxbasin, basin_missing, basin; */
-/*   int    *rank, *indx; */
-/*   double subA_missing, *maxsuba; */
-  
-/*   river_type *river_tmp; */
-
-/*   nx   = river_data->nx; */
-/*   ny   = river_data->ny; */
-/*   nxp2 = nx + 2; */
-/*   nyp2 = ny + 2; */
-/*   river_tmp = (river_type *)malloc(ntiles*sizeof(river_type)); */
-
-/*   /\* calculate maximum basin *\/ */
-/*   maxbasin  = -1; */
-/*   basin_missing = river_data->basin_missing; */
-/*   for(n=0; n<ntiles; n++) { */
-/*     for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {     */
-/*       maxbasin  = max(maxbasin,  river_data[n].basin[j*nxp2+i]); */
-/*     } */
-/*   }   */
-
-/*   /\* copy basinid data to the tmp data *\/ */
-/*   for(n=0; n<ntiles; n++) { */
-/*     river_tmp[n].basin = (int *)malloc(nxp2*nyp2*sizeof(int)); */
-/*     for(i=0; i<nxp2*nyp2; i++) { */
-/*       river_tmp[n].basin[i] = river_data[n].basin[i]; */
-/*     } */
-/*   } */
-
-/*   /\* calculate maximum subA for each basin *\/ */
-/*   subA_missing = river_data->subA_missing; */
-/*   maxsuba = (double *)malloc(maxbasin*sizeof(double)); */
-/*   indx    = (int    *)malloc(maxbasin*sizeof(int   )); */
-/*   rank    = (int    *)malloc(maxbasin*sizeof(int   )); */
-/*   for(n=0; n<maxbasin; n++) { */
-/*     maxsuba[n] = subA_missing; */
-/*     indx[n]    = n; */
-/*     rank[n]    = -1; */
-/*   } */
-/*   for(n=0; n<ntiles; n++) for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/*     if(river_data[n].last_point[(j-1)*nx+i-1]) { /\* coast point *\/ */
-/*       basin = river_tmp[n].basin[j*nxp2+i]; */
-/*       if( basin > maxbasin || basin < 1) mpp_error("river_regrid: basin should be between 1 and maxbasin"); */
-/*       maxsuba[basin-1] = river_data[n].subA[j*nxp2+i]; */
-/*     } */
-/*   } */
-
-/*   /\* make sure maxsuba is assigned properly *\/ */
-/*   for(n=0; n<maxbasin; n++) { */
-/*     if(maxsuba[n] == subA_missing) mpp_error("river_regrid: maxsuba is not assigned for some basin"); */
-/*   } */
-  
-/*   /\* sort maxsuba to get the index rank *\/ */
-/*   qsort_index(maxsuba, 0, maxbasin-1, indx); */
-/*   for(n=0; n<maxbasin; n++) rank[indx[n]] = n; */
-/*   for(n=0; n<maxbasin; n++) { */
-/*     if(rank[n] < 0) mpp_error("river_regrid: rank should be no less than 0"); */
-/*   } */
-  
-/*   /\* now assign basin according to the index rank *\/ */
-/*   for(n=0; n<ntiles; n++) for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) { */
-/*     basin = river_tmp[n].basin[j*nxp2+i]; */
-/*     if(basin != basin_missing) { */
-/*       if( basin > maxbasin || basin < 1) mpp_error("river_regrid: basin should be a positive integer no larger than maxbasin"); */
-/*       river_data[n].basin[j*nxp2+i] = maxbasin - rank[basin-1]; */
-/*     } */
-/*   } */
-  
-/*   /\* release the memory *\/ */
-/*   for(n=0; n<ntiles; n++) free(river_tmp[n].basin); */
-/*   free(river_tmp); */
-/*   free(rank); */
-/*   free(maxsuba); */
-
-/* };/\* sort_basin *\/ */
-
-
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void write_river_data() */
-/*   write out river network output data which is on land grid. */
-/*   ----------------------------------------------------------------------------*\/ */
-/* void write_river_data(const char *river_src_file, const char *output_file, river_type* river_data, const char *history, int ntiles) */
-/* { */
-/*   double *subA, *yt, *xt; */
-/*   int    *tocell, *travel, *basin; */
-/*   int id_subA, id_subA_in, id_tocell, id_tocell_in; */
-/*   int id_travel, id_travel_in, id_basin, id_basin_in; */
-/*   int id_cellarea, id_celllength, id_landfrac; */
-/*   int id_cellarea_in, id_celllength_in, id_x, id_y; */
-/*   int id_xaxis, id_yaxis, id_xaxis_in, id_yaxis_in; */
-/*   int fid, fid_in, dimid[2]; */
-/*   int n, i, j, ii, jj, nx, ny, nxp2; */
-  
-/*   fid_in = mpp_open(river_src_file, MPP_READ); */
-/*   id_subA_in = mpp_get_varid(fid_in, subA_name); */
-/*   id_tocell_in = mpp_get_varid(fid_in, tocell_name); */
-/*   id_travel_in = mpp_get_varid(fid_in, travel_name); */
-/*   id_basin_in = mpp_get_varid(fid_in, basin_name); */
-/*   id_cellarea_in = mpp_get_varid(fid_in, cellarea_name); */
-/*   id_celllength_in = mpp_get_varid(fid_in, celllength_name); */
-/*   id_xaxis_in = mpp_get_varid(fid_in, xaxis_name); */
-/*   id_yaxis_in = mpp_get_varid(fid_in, yaxis_name); */
-/*   for(n=0; n<ntiles; n++) { */
-/*     if(ntiles>1) */
-/*       sprintf(river_data[n].filename, "%s.tile%d.nc", output_file, n+1); */
-/*     else */
-/*       sprintf(river_data[n].filename, "%s.nc", output_file); */
-
-/*     nx = river_data[n].nx; */
-/*     ny = river_data[n].ny; */
-/*     nxp2 = nx + 2; */
-/*     fid = mpp_open(river_data[n].filename, MPP_WRITE); */
-/*     mpp_def_global_att(fid, "version", version);   */
-/*     mpp_def_global_att(fid, "code_version", tagname); */
-/*     mpp_def_global_att(fid, "history", history); */
-/*     dimid[1] = mpp_def_dim(fid, gridx_name, nx); */
-/*     dimid[0] = mpp_def_dim(fid, gridy_name, ny); */
-/*     id_xaxis = mpp_def_var(fid, gridx_name, MPP_DOUBLE, 1, &(dimid[1]), 0); */
-/*     id_yaxis = mpp_def_var(fid, gridy_name, MPP_DOUBLE, 1, dimid, 0); */
-/*     mpp_copy_var_att(fid_in, id_xaxis_in, fid, id_xaxis); */
-/*     mpp_copy_var_att(fid_in, id_yaxis_in, fid, id_yaxis); */
-/*     id_subA = mpp_def_var(fid, subA_name, MPP_DOUBLE, 2, dimid , 0); */
-/*     mpp_copy_var_att(fid_in, id_subA_in, fid, id_subA); */
-/*     id_tocell = mpp_def_var(fid, tocell_name, MPP_INT, 2, dimid, 0); */
-/*     mpp_copy_var_att(fid_in, id_tocell_in, fid, id_tocell); */
-/*     id_travel = mpp_def_var(fid, travel_name, MPP_INT, 2, dimid , 0); */
-/*     mpp_copy_var_att(fid_in, id_travel_in, fid, id_travel); */
-/*     id_basin = mpp_def_var(fid, basin_name, MPP_INT, 2, dimid , 0); */
-/*     mpp_copy_var_att(fid_in, id_basin_in, fid, id_basin); */
-/*     id_cellarea = mpp_def_var(fid, cellarea_name, MPP_DOUBLE, 2, dimid , 0); */
-/*     mpp_copy_var_att(fid_in, id_cellarea_in, fid, id_cellarea); */
-/*     id_celllength = mpp_def_var(fid, celllength_name, MPP_DOUBLE, 2, dimid , 0); */
-/*     mpp_copy_var_att(fid_in, id_celllength_in, fid, id_celllength); */
-/*     id_landfrac = mpp_def_var(fid, landfrac_name, MPP_DOUBLE, 2, dimid, 2, */
-/* 			      "long_name", "land fraction", "units", "none"); */
-/*     id_x        = mpp_def_var(fid, x_name, MPP_DOUBLE, 2, dimid, 2, */
-/* 			      "long_name", "Geographic longitude", "units", "degree_east"); */
-/*     id_y        = mpp_def_var(fid, y_name, MPP_DOUBLE, 2, dimid, 2, */
-/* 			      "long_name", "Geographic latitude", "units", "degree_north");     */
-/*     mpp_end_def(fid); */
-/*     xt = (double *)malloc(nx*sizeof(double)); */
-/*     yt = (double *)malloc(ny*sizeof(double)); */
-/*     /\* */
-/*        for lat-lon grid, actual lon, lat will be written out, */
-/*        for cubic grid, index will be written out */
-/*     *\/ */
-/*     if(ntiles == 1) { */
-/*       for(i=0; i<nx; i++) xt[i] = river_data[n].xt[nxp2+i+1]; */
-/*       for(j=0; j<ny; j++) yt[j] = river_data[n].yt[(j+1)*nxp2+1]; */
-
-/*     } */
-/*     else { */
-/*       for(i=0; i<nx; i++) xt[i] = i+1; */
-/*       for(j=0; j<ny; j++) yt[j] = j+1; */
-/*     } */
-/*     mpp_put_var_value(fid, id_xaxis, xt); */
-/*     mpp_put_var_value(fid, id_yaxis, yt); */
-/*     free(xt); */
-/*     free(yt); */
-
-/*     /\* all the fields is on data domain, so need to copy to compute domain *\/ */
-/*     subA = (double *)malloc(nx*ny*sizeof(double)); */
-/*     travel = (int *)malloc(nx*ny*sizeof(int)); */
-/*     basin  = (int *)malloc(nx*ny*sizeof(int)); */
-/*     tocell = (int *)malloc(nx*ny*sizeof(int)); */
-/*     xt = (double *)malloc(nx*ny*sizeof(double)); */
-/*     yt = (double *)malloc(nx*ny*sizeof(double)); */
-/*     for(j=0; j<ny; j++) for(i=0; i<nx; i++) { */
-/*       ii = i + 1; */
-/*       jj = j + 1; */
-/*       subA[j*nx+i] = river_data[n].subA[jj*nxp2+ii]; */
-/*       tocell[j*nx+i] = river_data[n].tocell[jj*nxp2+ii]; */
-/*       travel[j*nx+i] = river_data[n].travel[jj*nxp2+ii]; */
-/*       basin [j*nx+i] = river_data[n].basin [jj*nxp2+ii]; */
-/*       xt    [j*nx+i] = river_data[n].xt    [jj*nxp2+ii]; */
-/*       yt    [j*nx+i] = river_data[n].yt    [jj*nxp2+ii]; */
-/*     } */
-    
-/*     mpp_put_var_value(fid, id_subA, subA); */
-/*     mpp_put_var_value(fid, id_tocell, tocell); */
-/*     mpp_put_var_value(fid, id_travel, travel); */
-/*     mpp_put_var_value(fid, id_basin, basin); */
-/*     mpp_put_var_value(fid, id_x, xt); */
-/*     mpp_put_var_value(fid, id_y, yt); */
-/*     mpp_put_var_value(fid, id_cellarea, river_data[n].cellarea); */
-/*     mpp_put_var_value(fid, id_celllength, river_data[n].celllength); */
-/*     mpp_put_var_value(fid, id_landfrac, river_data[n].landfrac); */
-/*     mpp_close(fid); */
-/*     free(subA); */
-/*     free(tocell); */
-/*     free(basin); */
-/*     free(travel); */
-/*     free(xt); */
-/*     free(yt); */
-/*   } */
-/*   mpp_close(fid_in); */
-
-/* };/\* write_river_data *\/ */
-
-
-/* /\*------------------------------------------------------------------------------ */
-/*   double distance(double lon1, double lat1, double lon2, double lat2) */
-/*   find the distance of any two grid. */
-/*   ----------------------------------------------------------------------------*\/ */
-/* double distance(double lon1, double lat1, double lon2, double lat2) */
-/* { */
-/*   double s1, s2, dx; */
-/*   double dist; */
-    
-/*   dx = lon2 - lon1; */
-/*   if(dx > 180.) dx = dx - 360.; */
-/*   if(dx < -180.) dx = dx + 360.; */
-
-/*   if(lon1 == lon2) */
-/*     dist = fabs(lat2 - lat1) * D2R; */
-/*   else if(lat1 == lat2)  */
-/*     dist = fabs(dx) * D2R * cos(lat1*D2R); */
-/*   else {   /\* diagonal distance *\/ */
-/*     s1 =  fabs(dx)  * D2R * cos(lat1*D2R); */
-/*     s2 =  fabs(lat2 - lat1) * D2R; */
-/*     dist = sqrt(s1*s1+s2*s2); */
-/*   } */
-/*   dist *= RADIUS; */
-
-/*   return dist; */
-/* }     */
-
-/* /\*------------------------------------------------------------------------------ */
-/*   void qsort_index(double array[], int start, int end, int rank[]) */
-/*   sort array in increasing order and get the rank of each member in the original array */
-/*   the array size of array and rank will be size.  */
-  
-/*   ----------------------------------------------------------------------------*\/ */
-/* #define swap(a,b,t) ((t)=(a),(a)=(b),(b)=(t)) */
-/* void qsort_index(double array[], int start, int end, int rank[]) */
-/* { */
-/*    double pivot; */
-/*    int tmp_int; */
-/*    double tmp_double; */
-
-/*    if (end > start) { */
-/*       int l = start + 1; */
-/*       int r = end; */
-/*       int pivot_index = (start+(end-start)/2); */
-/*       swap(array[start], array[pivot_index], tmp_double); /\*** choose arbitrary pivot ***\/ */
-/*       swap(rank[start],  rank[pivot_index],  tmp_int); */
-/*       pivot = array[start]; */
-/*       while(l < r) { */
-/*          if (array[l] <= pivot) { */
-/*             l++; */
-/*          } else { */
-/* 	   while(l < r && array[r] >= pivot) /\*** skip superfluous swaps ***\/ */
-/* 	     { */
-/* 	       --r; */
-/* 	     } */
-/*             swap(array[l], array[r], tmp_double); */
-/* 	    swap(rank[l],  rank[r],  tmp_int); */
-/*          } */
-/*       } */
-/*       if(l != end || array[end] > pivot ) { */
-/* 	l--; */
-/*         swap(array[start], array[l], tmp_double); */
-/*         swap(rank[start],  rank[l],  tmp_int); */
-/*         qsort_index(array, start, l, rank); */
-/*         qsort_index(array, r, end, rank); */
-/*       } */
-/*       else { /\* the first element is the largest one *\/ */
-/* 	swap(array[start], array[l], tmp_double); */
-/*         swap(rank[start],  rank[l],  tmp_int); */
-/*         qsort_index(array, start, l-1, rank); */
-/*       } */
-/*    } */
-/* } */
- 
-
-
diff --git a/gridspec_tools_20080702/tools/shared/Makefile.am b/gridspec_tools_20080702/tools/shared/Makefile.am
deleted file mode 100644
index 3c501d3..0000000
--- a/gridspec_tools_20080702/tools/shared/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# tools/shared convenience library.
-
-# $Id: Makefile.am,v 1.8 2009/04/08 15:57:16 ed Exp $
-
-noinst_LTLIBRARIES = libtoolsshared.la 
-libtoolsshared_la_SOURCES = mpp.c mpp_domain.c mpp_domain.h mpp.h	\
-mpp_io.c mpp_io.h tool_util.c tool_util.h create_lonlat_grid.c		\
-create_gnomonic_cubic_grid.c create_grid_from_file.c			\
-create_conformal_cubic_grid.c fregrid_util.c conserve_interp.c		\
-bilinear_interp.c topog.c get_contact.c create_vgrid.c			\
-transfer_to_mosaic.c
-
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic -I../make_hgrid	\
--I../fregrid -I../make_coupler_mosaic -I../make_topog		\
--I../make_solo_mosaic -I../make_vgrid -I../river_regrid		\
--I../transfer_to_mosaic_grid
-
-AM_LDFLAGS =
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-
-
diff --git a/gridspec_tools_20080702/tools/shared/bilinear_interp.c b/gridspec_tools_20080702/tools/shared/bilinear_interp.c
deleted file mode 100644
index 337b2da..0000000
--- a/gridspec_tools_20080702/tools/shared/bilinear_interp.c
+++ /dev/null
@@ -1,1131 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include "globals.h"
-#include "mosaic_util.h"
-#include "bilinear_interp.h"
-#include "mpp_io.h"
-
-#define min(a,b) (a<b ? a:b)
-#define max(a,b) (a>b ? a:b)
-#define sign(a,b)(b<0 ? -fabs(a):fabs(a))
-
-
-int max_weight_index( double *var, int nvar);
-double normalize_great_circle_distance(const double *v1, const double *v2);
-/*double spherical_angle(double *v1, double *v2, double *v3);*/
-double dist2side(const double *v1, const double *v2, const double *point);
-void redu2x(const double *varfin, const double *yfin, int nxfin, int nyfin, double *varcrs,
-	    int nxcrs, int nycrs, int nz, int has_missing, double missvalue);
-void do_latlon_coarsening(const double *var_latlon, const double *ylat, int nlon, int nlat, int nz,    
-			  double *var_latlon_crs, int finer_steps, int has_missing, double missvalue);
-void do_c2l_interp(const Interp_config *interp, int nx_in, int ny_in, int nz, const Field_config *field_in,
-		   int nx_out, int ny_out, double *data_out, int has_missing, double missing, int fill_missing );
-void sort_index(int ntiles, int *index, double *shortest);
-int get_index(const Grid_config *grid_in, const Grid_config *grid_out, int *index,
-	       int i_in, int j_in, int l_in, int i_out, int j_out);
-/*******************************************************************************
-  void setup_bilinear_interp( )
-    !------------------------------------------------------------------!
-    ! calculate weights for bilinear interpolation                     !
-    ! from cubed sphere to latlon grid                                 !
-    !                                                                  !
-    ! input:                                                           !
-    ! sph_corner      cubed sphere corner location in spherical coor   !
-    ! npx, npy        number of corners per tile                       !
-    ! ntiles          number of tiles                                  !
-    ! xlon, ylat      latlon grid coor                                 !
-    ! nlon, nlat      latlon grid dimension                            !
-    !                                                                  !
-    ! output:                                                          !
-    ! c2l_index       cubed sphere index for latlon interpolation      !
-    ! c2l_weight      weights for cubsph_to_latlon interpolation       !
-    ! elon_cubsph     lon unit vector for cubed sphere center          !
-    ! elat_cubsph     lat unit vector for cubed sphere center          !
-    ! elon_latlon     lon unit vector for latlon grid                  !
-    ! elat_latlon     lat unit vector for latlon grid                  !
-    !------------------------------------------------------------------!
-*******************************************************************************/
-void setup_bilinear_interp(int ntiles_in, const Grid_config *grid_in, int ntiles_out, const Grid_config *grid_out, 
-                      Interp_config *interp, unsigned int opcode)
-{
-  const int max_iter = 10;
-  double abs_center, dcub, dlon, dlat, coslat, distance;
-  double dist1, dist2, dist3, dist4, sum;
-  double *shortest;
-  int    i, j, n, l, ic, jc, lc, icc, jcc, i_min, i_max, j_min, j_max, iter;
-  int    n0, n1, n2, n3, n4, m0, m1;
-  int    nx_in, ny_in, nx_out, ny_out, nxd, nyd;
-  double v0[3], v1[3], v2[3], v3[3], v4[3];
-  int    all_done;
-  int    *found, *index;
-  
-  /* ntiles_in must be six and ntiles_out must be one */
-  if(ntiles_in != 6) mpp_error("Error from bilinear_interp: source mosaic should be cubic mosaic "
-			       "and have six tiles when using bilinear option");
-  if(ntiles_out != 1) mpp_error("Error from bilinear_interp: destination mosaic should be "
-				"one tile lat-lon grid when using bilinear option"); 
-  /*-----------------------------------------------------------------!
-    ! cubed sphere: cartesian coordinates of cell corners,             !
-    !               cell lenghts between corners,                      !
-    !               cartesian and spherical coordinates of cell centers! 
-    !               calculate latlon unit vector                       !
-    !-----------------------------------------------------------------*/
-
-  /* calculation is done on the fine grid */
-  nx_out   = grid_out->nx_fine;
-  ny_out   = grid_out->ny_fine;
-  nx_in    = grid_in->nx;       /* the cubic grid has same resolution on each face */
-  ny_in    = grid_in->ny;
-  nxd      = nx_in + 2;
-  nyd      = ny_in + 2;
-
-  interp->index  = (int    *)malloc(3*nx_out*ny_out*sizeof(int   ));
-  interp->weight = (double *)malloc(4*nx_out*ny_out*sizeof(double));
-
-  if( (opcode & READ) && interp->file_exist ) { /* reading from file */
-    int nx2, ny2, fid, vid;
-
-    /* check the size of the grid matching the size in remapping file */
-    printf("NOTE: reading index and weight for bilinear interpolation from file.\n");
-    fid = mpp_open(interp->remap_file, MPP_READ);
-    nx2 = mpp_get_dimlen(fid, "nlon");
-    ny2 = mpp_get_dimlen(fid, "nlat");
-    printf("grid size is nx=%d, ny=%d, remap file size is nx=%d, ny=%d.\n", nx_out, ny_out, nx2, ny2);
-    if(nx2 != nx_out || ny2 != ny_out ) mpp_error("bilinear_interp: size mismatch between grid size and remap file size");
-    vid = mpp_get_varid(fid, "index");
-    mpp_get_var_value(fid, vid, interp->index);
-    vid = mpp_get_varid(fid, "weight");
-    mpp_get_var_value(fid, vid, interp->weight);
-    mpp_close(fid);
-    return;
-  }
-  
-  /*------------------------------------------------------------------
-    find lower left corner on cubed sphere for given latlon location 
-    ------------------------------------------------------------------*/
-  found    = (int *)malloc(nx_out*ny_out*sizeof(int));
-  index    = (int *)malloc(ntiles_in*3*sizeof(int));
-  shortest = (double *)malloc(ntiles_in*sizeof(double));
-  for(i=0; i<nx_out*ny_out; i++) found[i] = 0;
-    
-  dlon=(M_PI+M_PI)/nx_out;
-  dlat=M_PI/(ny_out-1);
-
-  for(iter=1; iter<=max_iter; iter++) {
-    for(l=0; l<ntiles_in; l++) {
-      for(jc=1; jc<=ny_in; jc++) for(ic=1; ic<=nx_in; ic++) {
-	/*------------------------------------------------------
-	  guess latlon indexes for given cubed sphere cell     
-	  ------------------------------------------------------*/
-	n1 = jc*nxd+ic;
-	n2 = (jc+1)*nxd+ic+1;
-	v1[0] = grid_in[l].xt[n1];
-	v1[1] = grid_in[l].yt[n1];
-	v1[2] = grid_in[l].zt[n1];
-	v2[0] = grid_in[l].xt[n2];
-	v2[1] = grid_in[l].yt[n2];
-	v2[2] = grid_in[l].zt[n2];
-	dcub=iter*normalize_great_circle_distance(v1, v2);
-	j_min=max(   1,  floor((grid_in[l].latt[n1]-dcub+0.5*M_PI)/dlat)-iter+1);
-	j_max=min(ny_out,ceil((grid_in[l].latt[n1]+dcub+0.5*M_PI)/dlat)+iter-1);
-	if (j_min==1 || j_max==ny_out) {
-	  i_min=1;
-	  i_max=nx_out;
-	}
-        else {
-	  i_min=max(   1,  floor((grid_in[l].lont[n1]-dcub)/dlon-iter+1));
-	  i_max=min(nx_out,ceil((grid_in[l].lont[n1]+dcub)/dlon+iter-1));
-	}
-	for(j=j_min-1; j<j_max; j++) for(i=i_min-1; i<i_max; i++) {
-	  n0 = j*nx_out + i;
-	  /*--------------------------------------------------------------------
-            for latlon cell find nearest cubed sphere cell 
-            ------------------------------------------------------------------*/
-	  if (!found[n0]) {
-	    shortest[l]=M_PI+M_PI;
-	    for(jcc=jc; jcc<=min(ny_in, jc+1); jcc++) for(icc=ic; icc<=min(nx_in, ic+1); icc++) {
-	      n1 = jcc*nxd + icc;
-	      n2 = j*nx_out + i;
-	      v1[0] = grid_in[l].xt[n1];
-	      v1[1] = grid_in[l].yt[n1];
-	      v1[2] = grid_in[l].zt[n1];
-	      v2[0] = grid_out->xt[n2];
-	      v2[1] = grid_out->yt[n2];
-	      v2[2] = grid_out->zt[n2];	      
-	      distance=normalize_great_circle_distance(v1, v2);
-	      if (distance < shortest[l]) {
-		shortest[l]=distance;
-		index[3*l]  =icc;
-		index[3*l+1]=jcc;
-		index[3*l+2]=l;
-	      }
-	    }
-	    /*------------------------------------------------
-              determine lower left corner                    
-              ------------------------------------------------*/
-	    found[n0] = get_closest_index(&(grid_in[l]), grid_out, &(interp->index[3*(j*nx_out+i)]), index[3*l],
-			      index[3*l+1], index[3*l+2], i, j);
-	  }
-	}
-      }
-    }
-    if (iter>1) {
-      all_done = 1;
-      for(i=0; i<nx_out*ny_out; i++) {
-	if( !found[i]) {
-	  all_done = 0;
-	  break;
-	}
-      };
-      if (all_done) break;
-    }
-  }
-  
-  /*------------------------------------------------------------------
-    double check if lower left corner was found                      
-    calculate weights for interpolation                              
-    ------------------------------------------------------------------*/
-  for(j=0; j<ny_out; j++) for(i=0; i<nx_out; i++) {
-    n0 = j*nx_out + i;
-    m0 = 3*n0;
-    m1 = 4*n0;
-    if (!found[n0]) {
-      printf("**************************************************************\n");
-      printf("WARNING: didn't find lower left corner for (ilon,jlat) = (%d,%d)\n", i,j);
-      printf("will perform expensive global sweep\n");
-      printf("**************************************************************\n");
-      /*---------------------------------------------------------
-	for latlon cell find nearby cubed sphere cell           
-	---------------------------------------------------------*/
-      for(l=0; l<3*ntiles_in; l++) index[l] = 0;	
-      for(l=0; l<ntiles_in; l++) shortest[l] = M_PI + M_PI;
-      for(l=0; l<ntiles_in; l++) {
-	for(jc=0; jc<ny_in; j++) for(ic=0; ic<nx_in; ic++) {
-	  n1 = jc*nxd+ic;
-	  v1[0] = grid_in[l].xt[n1];
-	  v1[1] = grid_in[l].yt[n1];
-	  v1[2] = grid_in[l].zt[n1];
-	  v0[0] = grid_out[l].xt[n0];
-	  v0[1] = grid_out[l].yt[n0];
-	  v0[2] = grid_out[l].zt[n0];	    
-	  distance=normalize_great_circle_distance(v1, v2);
-	  if (distance<shortest[l]) {
-	    shortest[l]=distance;
-	    index[3*l  ]=ic;
-	    index[3*l+1]=jc;
-	    index[3*l+2]=l;
-	  }
-	}
-      }
-
-      /*---------------------------------------------------------
-	determine lower left corner                             
-	---------------------------------------------------------*/
-      sort_index(ntiles_in, index, shortest);
-      found[n0]=0;
-      for(l=0; l<ntiles_in; l++) {
-	if (!found[n0]) {
-	  found[n0]=get_index(&(grid_in[l]), grid_out, &(interp->index[3*(j*nx_out+i)]), index[3*l],
-			      index[3*l+1], index[3*l+2], i, j);
-	  if (found[n0]) break;
-	}
-      }
-      if (! found[n0] ) mpp_error("error from bilinear_interp: couldn't find lower left corner");
-    }
-    /*------------------------------------------------------------
-      calculate shortest distance to each side of rectangle      
-      formed by cubed sphere cell centers                        
-      special corner treatment                                   
-      ------------------------------------------------------------*/
-    ic=interp->index[m0];
-    jc=interp->index[m0+1];
-    l =interp->index[m0+2];
-    if (ic==nx_in && jc==ny_in) {
-      /*------------------------------------------------------------
-	calculate weights for bilinear interpolation near corner   
-	------------------------------------------------------------*/
-      n1 = jc*nxd+ic;
-      n2 = jc*nxd+ic+1;
-      n3 = (jc+1)*nxd+ic;
-      v1[0] = grid_in[l].xt[n1];
-      v1[1] = grid_in[l].yt[n1];
-      v1[2] = grid_in[l].zt[n1];
-      v2[0] = grid_in[l].xt[n2];
-      v2[1] = grid_in[l].yt[n2];
-      v2[2] = grid_in[l].zt[n2];
-      v3[0] = grid_in[l].xt[n3];
-      v3[1] = grid_in[l].yt[n3];
-      v3[2] = grid_in[l].zt[n3];
-      v0[0] = grid_out->xt[n0];
-      v0[1] = grid_out->yt[n0];
-      v0[2] = grid_out->zt[n0];	  
-      dist1=dist2side(v2, v3, v0);
-      dist2=dist2side(v2, v1, v0);
-      dist3=dist2side(v1, v3, v0);
-      interp->weight[m1]  =dist1;      /* ic,   jc    weight */
-      interp->weight[m1+1]=dist2;      /* ic,   jc+1  weight */
-      interp->weight[m1+2]=0.;         /* ic+1, jc+1  weight */
-      interp->weight[m1+3]=dist3;      /* ic+1, jc    weight */
-             
-      sum=interp->weight[m1]+interp->weight[m1+1]+interp->weight[m1+3];
-      interp->weight[m1]  /=sum;
-      interp->weight[m1+1]/=sum;
-      interp->weight[m1+3]/=sum;
-    }
-    else if (ic==0 && jc==ny_in) {
-      /*------------------------------------------------------------
-	calculate weights for bilinear interpolation near corner   
-	------------------------------------------------------------*/
-	
-      n1 = jc*nxd+ic;
-      n2 = jc*nxd+ic+1;
-      n3 = (jc+1)*nxd+ic+1;
-      v1[0] = grid_in[l].xt[n1];
-      v1[1] = grid_in[l].yt[n1];
-      v1[2] = grid_in[l].zt[n1];
-      v2[0] = grid_in[l].xt[n2];
-      v2[1] = grid_in[l].yt[n2];
-      v2[2] = grid_in[l].zt[n2];
-      v3[0] = grid_in[l].xt[n3];
-      v3[1] = grid_in[l].yt[n3];
-      v3[2] = grid_in[l].zt[n3];
-      v0[0] = grid_out->xt[n0];
-      v0[1] = grid_out->yt[n0];
-      v0[2] = grid_out->zt[n0];	  
-      dist1=dist2side(v3, v2, v0);
-      dist2=dist2side(v2, v1, v0);
-      dist3=dist2side(v3, v1, v0);             
-      interp->weight[m1]  =dist1;      /* ic,   jc    weight */
-      interp->weight[m1+1]=0.;         /* ic,   jc+1  weight */
-      interp->weight[m1+2]=dist2;      /* ic+1, jc+1  weight */
-      interp->weight[m1+3]=dist3;      /* ic+1, jc    weight */
-             
-      sum=interp->weight[m1]+interp->weight[m1+2]+interp->weight[m1+3];
-      interp->weight[m1]  /=sum;
-      interp->weight[m1+2]/=sum;
-      interp->weight[m1+3]/=sum;
-    }
-    else if (jc==0 && ic==nx_in) {
-      /*------------------------------------------------------------
-	calculate weights for bilinear interpolation near corner   
-	------------------------------------------------------------*/
-      n1 = jc*nxd+ic;
-      n2 = (jc+1)*nxd+ic;
-      n3 = (jc+1)*nxd+ic+1;
-      v1[0] = grid_in[l].xt[n1];
-      v1[1] = grid_in[l].yt[n1];
-      v1[2] = grid_in[l].zt[n1];
-      v2[0] = grid_in[l].xt[n2];
-      v2[1] = grid_in[l].yt[n2];
-      v2[2] = grid_in[l].zt[n2];
-      v3[0] = grid_in[l].xt[n3];
-      v3[1] = grid_in[l].yt[n3];
-      v3[2] = grid_in[l].zt[n3];
-      v0[0] = grid_out->xt[n0];
-      v0[1] = grid_out->yt[n0];
-      v0[2] = grid_out->zt[n0];	  
-      dist1=dist2side(v2, v3, v0);
-      dist2=dist2side(v1, v3, v0);
-      dist3=dist2side(v1, v2, v0);             	     
-             
-      interp->weight[m1]  =dist1;      /* ic,   jc    weight */
-      interp->weight[m1+1]=dist2;      /* ic,   jc+1  weight */
-      interp->weight[m1+2]=dist3;      /* ic+1, jc+1  weight */
-      interp->weight[m1+3]=0.;         /* ic+1, jc    weight */
-             
-      sum=interp->weight[m1]+interp->weight[m1+1]+interp->weight[m1+2];
-      interp->weight[m1]  /=sum;
-      interp->weight[m1+1]/=sum;
-      interp->weight[m1+2]/=sum;
-    }
-    else {
-      /*------------------------------------------------------------
-	calculate weights for bilinear interpolation if no corner  
-	------------------------------------------------------------*/
-      n1 = jc*nxd+ic;
-      n2 = jc*nxd+ic+1;
-      n3 = (jc+1)*nxd+ic;
-      n4 = (jc+1)*nxd+ic+1;
-      v1[0] = grid_in[l].xt[n1];
-      v1[1] = grid_in[l].yt[n1];
-      v1[2] = grid_in[l].zt[n1];
-      v2[0] = grid_in[l].xt[n2];
-      v2[1] = grid_in[l].yt[n2];
-      v2[2] = grid_in[l].zt[n2];
-      v3[0] = grid_in[l].xt[n3];
-      v3[1] = grid_in[l].yt[n3];
-      v3[2] = grid_in[l].zt[n3];
-      v4[0] = grid_in[l].xt[n4];
-      v4[1] = grid_in[l].yt[n4];
-      v4[2] = grid_in[l].zt[n4];	
-      v0[0] = grid_out->xt[n0];
-      v0[1] = grid_out->yt[n0];
-      v0[2] = grid_out->zt[n0];	  
-      dist1=dist2side(v1, v3, v0);
-      dist2=dist2side(v3, v4, v0);
-      dist3=dist2side(v4, v2, v0);
-      dist4=dist2side(v2, v1, v0);
-	
-      interp->weight[m1]  =dist2*dist3;      /* ic,   jc    weight */
-      interp->weight[m1+1]=dist3*dist4;      /* ic,   jc+1  weight */
-      interp->weight[m1+2]=dist4*dist1;      /* ic+1, jc+1  weight */
-      interp->weight[m1+3]=dist1*dist2;      /* ic+1, jc    weight */
-             
-      sum=interp->weight[m1]+interp->weight[m1+1]+interp->weight[m1+2]+interp->weight[m1+3];
-      interp->weight[m1]  /=sum;
-      interp->weight[m1+1]/=sum;
-      interp->weight[m1+2]/=sum;
-      interp->weight[m1+3]/=sum;
-    }
-  }
-
-  /* write out weight information if needed */
-  if( opcode & WRITE ) {
-    int fid, dim_three, dim_four, dim_nlon, dim_nlat, dims[3];
-    int fld_index, fld_weight;
-    
-    fid = mpp_open( interp->remap_file, MPP_WRITE);
-    dim_nlon = mpp_def_dim(fid, "nlon", nx_out);
-    dim_nlat = mpp_def_dim(fid, "nlat", ny_out);
-    dim_three = mpp_def_dim(fid, "three", 3);
-    dim_four  = mpp_def_dim(fid, "four", 4);
-    
-    dims[0] = dim_three; dims[1] = dim_nlat; dims[2] = dim_nlon;
-    fld_index = mpp_def_var(fid, "index", NC_INT, 3, dims, 0);
-    dims[0] = dim_four; dims[1] = dim_nlat; dims[2] = dim_nlon;
-    fld_weight = mpp_def_var(fid, "weight", NC_DOUBLE, 3, dims, 0);
-    mpp_end_def(fid);
-    mpp_put_var_value(fid, fld_index, interp->index);
-    mpp_put_var_value(fid, fld_weight, interp->weight);
-    mpp_close(fid);
-  }
-
-  /* release the memory */
-  free(found);
-  free(shortest);
-  free(index);
-  
-  printf("\n done calculating interp_index and interp_weight\n");
-}; /* setup_bilinear_interp */
-
-/*----------------------------------------------------------------------------
-   void do_scalar_bilinear_interp(Mosaic_config *input, Mosaic_config *output, int varid )
-   interpolate scalar data to latlon,                               !
-   --------------------------------------------------------------------------*/
-void do_scalar_bilinear_interp(const Interp_config *interp, int vid, int ntiles_in, const Grid_config *grid_in, const Grid_config *grid_out,
-			  const Field_config *field_in, Field_config *field_out, int finer_step, int fill_missing)
-{
-  int    nx_in, ny_in, nx_out, ny_out, nz;
-  int    n, ts, tn, tw, te;
-  int    has_missing;
-  double missing;
-  double *data_fine;
-  
-  /*------------------------------------------------------------------
-    determine target grid resolution                                 
-    ------------------------------------------------------------------*/
-  nx_out     = grid_out->nx_fine;
-  ny_out     = grid_out->ny_fine;
-  nx_in       = grid_in->nx;
-  ny_in       = grid_in->ny;
-  nz          = field_in[0].var[vid].nz;
-  missing     = field_in[0].var[vid].missing;
-  has_missing = field_in[0].var[vid].has_missing;
-
-  data_fine = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
-
-  do_c2l_interp(interp, nx_in, ny_in, nz, field_in, nx_out, ny_out, data_fine, has_missing, missing, fill_missing);
-  do_latlon_coarsening(data_fine, grid_out->latt1D_fine, nx_out, ny_out, nz, field_out->data,
-		       finer_step, has_missing, missing);
-  free(data_fine);
-  
-}; /* do_c2l_scalar_interp */
-
-
-   
-/*----------------------------------------------------------------------------
-   void do_vector_bilinear_interp()
-   interpolate vector data to latlon,                               !
-   --------------------------------------------------------------------------*/
-void do_vector_bilinear_interp(Interp_config *interp, int vid, int ntiles_in, const Grid_config *grid_in, int ntiles_out, 
-			  const Grid_config *grid_out, const Field_config *u_in,  const Field_config *v_in,
-			  Field_config *u_out, Field_config *v_out, int finer_step, int fill_missing)
-{
-  Field_config *var_cubsph;
-  int          nx_in, ny_in, nx_out, ny_out, nxd, nyd, nz, has_missing;
-  int          i, j, k, n, n1, n2, ts, tn, tw, te;
-  double       missing;
-  double       *x_latlon, *y_latlon, *z_latlon, *var_latlon;
-  
-  nx_out      = grid_out->nx_fine;
-  ny_out      = grid_out->ny_fine;
-  nx_in       = grid_in->nx;
-  ny_in       = grid_in->ny;
-  nxd         = nx_in + 2;
-  nyd         = ny_in + 2;
-  nz          = u_in[0].var[vid].nz;
-  missing     = u_in[0].var[vid].missing;
-  has_missing = u_in[0].var[vid].has_missing;
-
-
-  x_latlon   = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
-  y_latlon   = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
-  z_latlon   = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
-  var_latlon = (double *)malloc(nx_out*ny_out*nz*sizeof(double));
-  var_cubsph = (Field_config *)malloc(ntiles_in*sizeof(Field_config));
-  for(n=0; n<ntiles_in; n++) var_cubsph[n].data = (double *)malloc((nx_in+2)*(ny_in+2)*nz*sizeof(double));
-
-  for(n=0; n<ntiles_in; n++) {
-    for(k=0; k<nz; k++) for(j=0; j<nyd; j++) for(i=0; i<nxd; i++) {
-      n1 = k*nxd*nyd + j*nxd + i;
-      n2 = j*nxd + i;
-      var_cubsph[n].data[n1] = u_in[n].data[n1]*grid_in[n].vlon_t[3*n2]+v_in[n].data[n1]*grid_in[n].vlat_t[3*n2];
-    }
-  }
-
-  do_c2l_interp(interp, nx_in, ny_in, nz, var_cubsph, nx_out, ny_out, x_latlon, has_missing, missing, fill_missing);  
-
-  for(n=0; n<ntiles_in; n++) {
-    for(k=0; k<nz; k++) for(j=0; j<nyd; j++) for(i=0; i<nxd; i++) {
-      n1 = k*nxd*nyd + j*nxd + i;
-      n2 = j*nxd + i;
-      var_cubsph[n].data[n1] = u_in[n].data[n1]*grid_in[n].vlon_t[3*n2+1]+v_in[n].data[n1]*grid_in[n].vlat_t[3*n2+1];
-    }
-  }
-  do_c2l_interp(interp, nx_in, ny_in, nz, var_cubsph, nx_out, ny_out, y_latlon, has_missing, missing, fill_missing);  
-  
-  for(n=0; n<ntiles_in; n++) {
-    for(k=0; k<nz; k++) for(j=0; j<nyd; j++) for(i=0; i<nxd; i++) {
-      n1 = k*nxd*nyd + j*nxd + i;
-      n2 = j*nxd + i;
-      var_cubsph[n].data[n1] = u_in[n].data[n1]*grid_in[n].vlon_t[3*n2+2]+v_in[n].data[n1]*grid_in[n].vlat_t[3*n2+2];
-    }
-  }
-
-  do_c2l_interp(interp, nx_in, ny_in, nz, var_cubsph, nx_out, ny_out, z_latlon, has_missing, missing, fill_missing);  
-
-  for(n=0; n<ntiles_in; n++) free(var_cubsph[n].data);
-  free(var_cubsph);
-
-  
-  for(k=0; k<nz; k++) for(j=0; j<ny_out; j++) for(i=0; i<nx_out; i++) {
-    n1 = k*nx_out*ny_out + j*nx_out + i;
-    n2 = j*nx_out + i;
-    var_latlon[n1] = x_latlon[n1]*grid_out->vlon_t[3*n2] +  y_latlon[n1]*grid_out->vlon_t[3*n2+1] +  z_latlon[n1]*grid_out->vlon_t[3*n2+2];
-  }
-  do_latlon_coarsening(var_latlon, grid_out->latt1D_fine, nx_out, ny_out, nz, u_out->data,
-		       finer_step, has_missing, missing);
-
-  for(k=0; k<nz; k++) for(j=0; j<ny_out; j++) for(i=0; i<nx_out; i++) {
-    n1 = k*nx_out*ny_out + j*nx_out + i;
-    n2 = j*nx_out + i;
-    var_latlon[n1] = x_latlon[n1]*grid_out->vlat_t[3*n2] +  y_latlon[n1]*grid_out->vlat_t[3*n2+1] +  z_latlon[n1]*grid_out->vlat_t[3*n2+2];
-  }
-
-  do_latlon_coarsening(var_latlon, grid_out->latt1D_fine, nx_out, ny_out, nz, v_out->data,
-		       finer_step, has_missing, missing);
-
-  free(x_latlon);
-  free(y_latlon);
-  free(z_latlon);
-    
-}; /* do_vector_bilinear_interp */
-
-
-void do_c2l_interp(const Interp_config *interp, int nx_in, int ny_in, int nz, const Field_config *field_in,
-		   int nx_out, int ny_out, double *data_out, int has_missing, double missing, int fill_missing )
-{
-  int i, j, k, nxd, nyd, ic, jc, ind, n1, tile;
-  double d_in[4];
-  
-  nxd = nx_in + 2;
-  nyd = ny_in + 2;
-  
-  if (has_missing) {
-    for(k=0; k<nz; k++) for(j=0; j<ny_out; j++) for(i=0; i<nx_out; i++) {
-      n1      = j*nx_out+i;
-      ic      = interp->index[3*n1];
-      jc      = interp->index[3*n1+1];
-      tile    = interp->index[3*n1+2];
-      d_in[0] = field_in[tile].data[k*nxd*nyd+jc    *nxd+ic];
-      d_in[1] = field_in[tile].data[k*nxd*nyd+(jc+1)*nxd+ic];
-      d_in[2] = field_in[tile].data[k*nxd*nyd+(jc+1)*nxd+ic+1];
-      d_in[3] = field_in[tile].data[k*nxd*nyd+jc    *nxd+ic+1];
-      if (d_in[0] == missing || d_in[1] == missing || d_in[3] == missing || d_in[4] == missing ) {
-	if (fill_missing) {
-	  ind = max_weight_index( &(interp->weight[4*n1]), 4);
-	  data_out[k*nx_out*ny_out+n1] = d_in[ind];
-	}
-	else {
-	  data_out[k*nx_out*ny_out+n1] = missing;
-	}
-      }
-      else {
-	data_out[k*nx_out*ny_out+n1] = d_in[0]*interp->weight[4*n1] + d_in[1]*interp->weight[4*n1+1]
-	  + d_in[2]*interp->weight[4*n1+2] + d_in[3]*interp->weight[4*n1+3];
-      }
-    }
-  }
-  else {
-    for(k=0; k<nz; k++) for(j=0; j<ny_out; j++) for(i=0; i<nx_out; i++) {
-      n1      = j*nx_out+i;
-      ic      = interp->index[3*n1];
-      jc      = interp->index[3*n1+1];
-      tile    = interp->index[3*n1+2];
-      d_in[0] = field_in[tile].data[k*nxd*nyd+jc    *nxd+ic];
-      d_in[1] = field_in[tile].data[k*nxd*nyd+(jc+1)*nxd+ic];
-      d_in[2] = field_in[tile].data[k*nxd*nyd+(jc+1)*nxd+ic+1];
-      d_in[3] = field_in[tile].data[k*nxd*nyd+jc    *nxd+ic+1];
-      data_out[k*nx_out*ny_out+n1] = d_in[0]*interp->weight[4*n1] + d_in[1]*interp->weight[4*n1+1]
-	+ d_in[2]*interp->weight[4*n1+2] + d_in[3]*interp->weight[4*n1+3];
-    }
-  }
-  
-}; /* do_c2l_interp */
-
-   
-/*------------------------------------------------------------------
-  void sort_index()
-  sort index by shortest                                         
-  ----------------------------------------------------------------*/
-void sort_index(int ntiles, int *index, double *shortest)
-{
-  int l, ll, lll, i;
-  double *shortest_sort;
-  int    *index_sort;
-
-  shortest_sort = (double *)malloc(3*ntiles*sizeof(double));
-  index_sort    = (int    *)malloc(  ntiles*sizeof(int   ));
-  
-  for(l=0; l<3*ntiles; l++)index_sort[l] = 0;
-  for(l=0; l<ntiles; l++)shortest_sort[l] = M_PI+M_PI;
-  for(l=0; l<ntiles; l++) {
-    for(ll=0; ll<ntiles; ll++) {
-      if (shortest[l]<shortest_sort[ll]) {
-	for(lll=ntiles-2; lll>=ll; lll--) {
-	  index_sort[3*lll+1]=index_sort[3*lll];
-	  shortest_sort[lll+1]=shortest_sort[lll];
-	}
-	for(i=0; i<3; i++) index_sort[3*ll+i]=index[3*l+i];
-	shortest_sort[ll]=shortest[l];
-	break;
-      }
-    }
-  }
-
-  for(l=0; l<3*ntiles; l++) index[l]    = index_sort[l];
-  for(l=0; l<  ntiles; l++) shortest[l] = shortest_sort[l];
-
-  free(shortest_sort);
-  free(index_sort);
-  
-}; /* sort_index */
-
-
-/*------------------------------------------------------------------
-  void get_index(ig, jg, lg)
-  determine lower left corner                                    
-  ----------------------------------------------------------------*/
-int get_index(const Grid_config *grid_in, const Grid_config *grid_out, int *index,
-	       int i_in, int j_in, int l_in, int i_out, int j_out)
-{
-  int    ok, n0, n1, n2, n3, n4, n5;
-  int    nx_in, ny_in, nx_out, ny_out;
-  double v0[3], v1[3], v2[3], v3[3], v4[3], v5[3];
-  double angle_1, angle_1a, angle_1b, angle_2, angle_2a, angle_2b;
-  double angle_3, angle_3a, angle_3b, angle_4, angle_4a, angle_4b;
-  
-  ok=1;
-  nx_in  = grid_in->nx_fine;
-  ny_in  = grid_in->nx_fine;
-  nx_out = grid_out->nx;
-  ny_out = grid_out->nx;
-  n0 = j_out*nx_out + i_out;
-  n1 = j_in*nx_in + i_in;
-  n2 = j_in*nx_in + i_in+1;
-  n3 = (j_in+1)*nx_in + i_in;
-  v0[0] = grid_out->xt[n1];
-  v0[1] = grid_out->yt[n1];
-  v0[2] = grid_out->zt[n1];
-  v1[0] = grid_in->xt[n1];
-  v1[1] = grid_in->yt[n1];
-  v1[2] = grid_in->zt[n1];
-  v2[0] = grid_in->xt[n2];
-  v2[1] = grid_in->yt[n2];
-  v2[2] = grid_in->zt[n2];
-  v3[0] = grid_in->xt[n3];
-  v3[1] = grid_in->yt[n3];
-  v3[2] = grid_in->zt[n3];
-  angle_1 = spherical_angle(v1, v2, v3);
-  angle_1a= spherical_angle(v1, v2, v0); 
-  angle_1b= spherical_angle(v1, v3, v0);
-  
-  if (max(angle_1a,angle_1b)<angle_1) {
-    index[0]=i_in;
-    index[1]=j_in;
-    index[2]=l_in;
-  }
-  else {
-    n4 = j_in*nx_in + i_in-1;
-    v4[0] = grid_in->xt[n4];
-    v4[1] = grid_in->yt[n4];
-    v4[2] = grid_in->zt[n4];
-    angle_2 =spherical_angle(v1, v3, v4);
-    angle_2a=angle_1b;
-    angle_2b=spherical_angle(v1, v4, v0);
-    if (max(angle_2a,angle_2b)<angle_2) {
-      index[0]=i_in-1;
-      index[1]=j_in;
-      index[2]=l_in;
-    }
-    else {
-      n5 = (j_in-1)*nx_in + i_in;
-      v5[0] = grid_in->xt[n5];
-      v5[1] = grid_in->yt[n5];
-      v5[2] = grid_in->zt[n5];      
-      angle_3 =spherical_angle(v1, v4, v5);
-      angle_3a=angle_2b;
-      angle_3b=spherical_angle(v1, v5, v0);
-      if (max(angle_3a,angle_3b)<angle_3 && i_in>1 && j_in>1) {
-	index[0]=i_in-1;
-	index[1]=j_in-1;
-	index[2]=l_in;
-      }
-      else {
-	angle_4 =spherical_angle(v1, v5, v2);
-	angle_4a=angle_3b;
-	angle_4b=spherical_angle(v1, v2, v0);
-	if (max(angle_4a,angle_4b)<angle_4) {
-	  index[0]=i_in;
-	  index[1]=j_in-1;
-	  index[2]=l_in;
-	}
-        else {
-	  ok=0;
-	}
-      }
-    }
-  }
-  return ok;
-  
-}; /* get_index */
-
-
-/*-------------------------------------------------------------
-  determine lower left corner
-  void get_closest_index(int ig, int jg, int lg, int ok)
-  --------------------------------------------------------------*/
-int get_closest_index(const Grid_config *grid_in, const Grid_config *grid_out, int *index,
-		      int i_in, int j_in, int l_in, int i_out, int j_out)
-{
-  int found;
-  double angle_11, angle_11a, angle_11b;
-  double angle_22, angle_22a, angle_22b;
-  double angle_33, angle_33a, angle_33b;
-  double angle_44, angle_44a, angle_44b;
-  double angle_1,  angle_1a,  angle_1b;
-  double angle_2,  angle_2a,  angle_2b;
-  double angle_3,  angle_3a,  angle_3b;
-  double angle_4,  angle_4a,  angle_4b;  
-  int    n0, n1, n2, n3, n4, n5, n6, n7, n8;
-  int    nx_in, ny_in, nx_out, ny_out, nxd;
-  double v0[3], v1[3], v2[3], v3[3], v4[3], v5[3], v6[3], v7[3], v8[3];
-
-  found = 0;
-  nx_in  = grid_in->nx;
-  ny_in  = grid_in->ny;
-  nxd    = nx_in + 2;
-  nx_out = grid_out->nx_fine;
-  ny_out = grid_out->ny_fine;
-  n0     = j_out*nx_out+i_out;
-  n1     = j_in*nxd+i_in;
-  n2     = j_in*nxd+i_in+1;
-  n3     = (j_in+1)*nxd+i_in;
-  v1[0]  = grid_in->xt[n1];
-  v1[1]  = grid_in->yt[n1];
-  v1[2]  = grid_in->zt[n1];
-  v2[0]  = grid_in->xt[n2];
-  v2[1]  = grid_in->yt[n2];
-  v2[2]  = grid_in->zt[n2];
-  v3[0]  = grid_in->xt[n3];
-  v3[1]  = grid_in->yt[n3];
-  v3[2]  = grid_in->zt[n3];
-  v0[0]  = grid_out->xt[n0];
-  v0[1]  = grid_out->yt[n0];
-  v0[2]  = grid_out->zt[n0];
-  angle_1 =spherical_angle(v1, v2, v3);
-  angle_1a=spherical_angle(v1, v2, v0);
-  angle_1b=spherical_angle(v1, v3, v0);
-  if (max(angle_1a,angle_1b) <= angle_1) {
-    if (i_in==nx_in && j_in==ny_in) {
-      angle_11 =spherical_angle(v2, v3, v1);
-      angle_11a=spherical_angle(v2, v1, v0);
-      angle_11b=spherical_angle(v2, v3, v0);
-    }
-    else {
-      n4 = (j_in+1)*nxd+i_in+1;
-      v4[0]  = grid_in->xt[n4];
-      v4[1]  = grid_in->yt[n4];
-      v4[2]  = grid_in->zt[n4];
-      angle_11 =spherical_angle(v4, v3, v2);
-      angle_11a=spherical_angle(v4, v2, v0);
-      angle_11b=spherical_angle(v4, v3, v0);
-    }
-    if (max(angle_11a,angle_11b)<=angle_11) {
-      found = 1;
-      index[0]=i_in;
-      index[1]=j_in;
-      index[2]=l_in;
-    }
-  }
-  else {
-    n4 = j_in*nxd+i_in-1;
-    v4[0]  = grid_in->xt[n4];
-    v4[1]  = grid_in->yt[n4];
-    v4[2]  = grid_in->zt[n4]; 
-    angle_2 =spherical_angle(v1,v3,v4);
-    angle_2a=angle_1b;
-    angle_2b=spherical_angle(v1,v4,v0);
-    if (max(angle_2a,angle_2b)<=angle_2) {
-      if (i_in==1 && j_in==ny_in) {
-	angle_22 =spherical_angle(v3, v1, v4);
-	angle_22a=spherical_angle(v3, v4, v0);
-	angle_22b=spherical_angle(v3, v1, v0);
-      }
-      else {
-	n5 = (j_in+1)*nxd+i_in-1;
-	n6 = j_in    *nxd+i_in-1;
-	v5[0]  = grid_in->xt[n5];
-	v5[1]  = grid_in->yt[n5];
-	v5[2]  = grid_in->zt[n5];
-	v6[0]  = grid_in->xt[n6];
-	v6[1]  = grid_in->yt[n6];
-	v6[2]  = grid_in->zt[n6];
-	angle_22 =spherical_angle(v5, v3, v6);
-	angle_22a=spherical_angle(v5, v6, v0);
-	angle_22b=spherical_angle(v5, v3, v0);
-      }
-      if (max(angle_22a,angle_22b)<=angle_22) {
-	found=1;
-	index[0]=i_in-1;
-	index[1]=j_in;
-	index[2]=l_in;
-      }
-    }
-    else {
-      n5 = j_in*nxd+i_in-1;
-      n6 = (j_in-1)*nxd+i_in;
-      v5[0]  = grid_in->xt[n5];
-      v5[1]  = grid_in->yt[n5];
-      v5[2]  = grid_in->zt[n5];
-      v6[0]  = grid_in->xt[n6];
-      v6[1]  = grid_in->yt[n6];
-      v6[2]  = grid_in->zt[n6];	  
-      angle_3 =spherical_angle(v1, v5, v6);
-      angle_3a=angle_2b;
-      angle_3b=spherical_angle(v1, v6, v0);
-      if (max(angle_3a,angle_3b)<=angle_3 && i_in>1 && j_in>1) {
-	n7 = (j_in-1)*nxd+i_in-1;
-	v7[0]  = grid_in->xt[n7];
-	v7[1]  = grid_in->yt[n7];
-	v7[2]  = grid_in->zt[n7];    
-	angle_33 =spherical_angle(v7, v6, v5);
-	angle_33a=spherical_angle(v7, v5, v0);
-	angle_33b=spherical_angle(v7, v6, v0);
-	if (max(angle_33a,angle_33b)<=angle_33) {
-	  found=1;
-	  index[0]=i_in-1;
-	  index[1]=j_in-1;
-	  index[2]=l_in;
-	}
-      }
-      else {
-	angle_4 =spherical_angle(v1, v6, v2);
-	angle_4a=angle_3b;
-	angle_4b=spherical_angle(v1, v2, v0);
-	if (max(angle_4a,angle_4b)<=angle_4) {
-	  if (i_in==nx_in && j_in==1) {
-	    angle_44 =spherical_angle(v2, v1, v6);
-	    angle_44a=spherical_angle(v2, v6, v0);
-	    angle_44b=spherical_angle(v2, v1, v0);
-	  }
-	  else {
-	    n8 = (j_in-1)*nxd+i_in+1;
-	    v8[0]  = grid_in->xt[n8];
-	    v8[1]  = grid_in->yt[n8];
-	    v8[2]  = grid_in->zt[n8];   
-	    angle_44 =spherical_angle(v8, v2, v6);
-	    angle_44a=spherical_angle(v8, v6, v0);
-	    angle_44b=spherical_angle(v8, v2, v0);
-	  }
-	  if (max(angle_44a,angle_44b)<=angle_44) {
-	    found=1;
-	    index[0]=i_in;
-	    index[1]=j_in-1;
-	    index[2]=l_in;
-	  }
-	}
-      }
-    }
-  }
-  return found;
-  
-}; /* get_closest_index */
-	      
-
-
-/*--------------------------------------------------------------------------
-
-calculate normalized great circle distance between v1 and v2 
-double normalize_great_circle_distance(v1, v2)
----------------------------------------------------------------------------*/
-double normalize_great_circle_distance(const double *v1, const double *v2)
-{
-  double dist;
-
-  dist=(v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
-    /sqrt((v1[0]*v1[0]+v1[1]*v1[1]+v1[2]*v1[2])                 
-	  *(v2[0]*v2[0]+v2[1]*v2[1]+v2[2]*v2[2]));
-  dist = sign(min(1.,fabs(dist)),dist);
-  dist = acos(dist);
-  return dist;
-  
-}; /* normalize_great_circle_distance */
-
-/*------------------------------------------------------------------
-  double spherical_angle(v1, v2, v3)
-
-  calculate spherical angle of a triangle formed by v1, v2 and v3 at v1                                                            
-  ------------------------------------------------------------------*/
-/* double spherical_angle(double *v1, double *v2, double *v3) */
-/* { */
-/*   double angle; */
-/*   double px, py, pz, qx, qy, qz, abs_p, abs_q; */
-
-/*   /* vector product between v1 and v2 */
-/*   px = v1[1]*v2[2] - v1[2]*v2[1]; */
-/*   py = v1[2]*v2[0] - v1[0]*v2[2]; */
-/*   pz = v1[0]*v2[1] - v1[1]*v2[0]; */
-/*   /* vector product between v1 and v3  */
-/*   qx = v1[1]*v3[2] - v1[2]*v3[1]; */
-/*   qy = v1[2]*v3[0] - v1[0]*v3[2]; */
-/*   qz = v1[0]*v3[1] - v1[1]*v3[0]; */
-    
-/*   /* angle between p and q */ 
-/*   abs_p=px*px+py*py+pz*pz; */
-/*   abs_q=qx*qx+qy*qy+qz*qz; */
-/*   if (abs_p*abs_q==0.) */
-/*     angle=0.; */
-/*   else { */
-/*     angle = (px*qx+py*qy+pz*qz)/sqrt(abs_p*abs_q); */
-/*     angle = sign(min(1.,fabs(angle)),angle); */
-/*     angle = acos(angle); */
-/*   } */
-
-/*   return angle; */
-/* }; /* spherical_angle */
-
-/*---------------------------------------------------------------------
-  double dist2side(v1, v2, point)
-  calculate shortest normalized distance on sphere                 
-  from point to straight line defined by v1 and v2                 
-  ------------------------------------------------------------------*/
-double dist2side(const double *v1, const double *v2, const double *point)
-{
-  double angle, side;
-
-  angle = spherical_angle(v1, v2, point);
-  side  = normalize_great_circle_distance(v1, point);
-
-  return (asin(sin(side)*sin(angle)));
-
-};/* dist2side */
-
-  
-int max_weight_index( double *var, int nvar)
-{
-
-  int ind, i;
-
-  ind = 0;
-
-  for(i=1; i<nvar; i++) {
-    if(var[i]>var[ind]) ind = i;
-  }
-
-  return ind;
-}
-
-/*------------------------------------------------------------------------------
-  void do_latlon_coarsening(var_latlon, ylat, nlon, nlat, nz,     
-                            var_latlon_crs, nlon_crs, nlat_crs,   
-                            finer_steps, misval, varmisval)
-
-  calculate variable on coarser latlon grid                        
-  by doubling spatial resolution and preserving volume means       
-  ---------------------------------------------------------------------------*/
-void do_latlon_coarsening(const double *var_latlon, const double *ylat, int nlon, int nlat, int nz,    
-			  double *var_latlon_crs, int finer_steps, int has_missing, double missvalue)
-{
-
-  double  *var_latlon_old, *ylat_old, *var_latlon_new;
-  double  dlat;
-  int     nlon_old, nlat_old, nlon_new, nlat_new, steps, i, j;
-  int     nlon_crs, nlat_crs;
-  
-  nlon_crs=nlon/pow(2,finer_steps);
-  nlat_crs=(nlat-1)/pow(2,finer_steps)+1;
-  switch (finer_steps) {
-  case 0:
-    if (nlon_crs !=nlon || nlat_crs != nlat) mpp_error("bilinear_interp(do_latlon_coarsening): grid dimensions don't match");
-    for(i=0; i<nlon*nlat*nz; i++) var_latlon_crs[i] = var_latlon[i];
-    break;
-  case 1:
-    redu2x(var_latlon, ylat, nlon, nlat, var_latlon_crs, nlon_crs, nlat_crs, nz, has_missing, missvalue);
-    break;
-  default:
-    nlon_new=nlon;
-    nlat_new=nlat;
-    for(steps=1; steps<=finer_steps; steps++) {
-      nlon_old=nlon_new;
-      nlat_old=nlat_new;
-      var_latlon_old = (double *)malloc(nlon_old*nlat_old*nz*sizeof(double));
-      ylat_old       = (double *)malloc(nlat_old*sizeof(double));
-      if (steps==1) {
-	for(i=0; i<nlat; i++) ylat_old[i] = ylat[i]; 
-	for(i=0; i<nlon_old*nlat_old*nz; i++) var_latlon_old[i] = var_latlon[i];
-      }
-      else {
-	dlat=M_PI/(nlat_old-1);
-	ylat_old[0]=-0.5*M_PI;
-	ylat_old[nlat_old-1]= 0.5*M_PI;
-	for(j=1; j<nlat_old-1; j++) ylat_old[j] = ylat_old[0] + j*dlat;
-	for(i=0; i<nlon_old*nlat_old*nz; i++) var_latlon_old[i] = var_latlon_new[i];
-	free(var_latlon_new);
-      }
-          
-      nlon_new=nlon_new/2;
-      nlat_new=(nlat_new-1)/2+1;
-      var_latlon_new = (double *)malloc(nlon_new*nlat_new*nz*sizeof(double));
-      redu2x(var_latlon_old, ylat_old, nlon_old, nlat_old, var_latlon_new, nlon_new, nlat_new, nz, has_missing, missvalue);
-      free(var_latlon_old);
-      free(ylat_old);
-    }
-    for(i=0; i<nlon_new*nlat_new*nz; i++) var_latlon_crs[i] = var_latlon_new[i];
-    free(var_latlon_new);
-  }
-}; /* do_latlon_coarsening */
-
-/*------------------------------------------------------------------------------
-  void redu2x(varfin, yfin, nxfin, nyfin, varcrs, nxcrs, nycrs)
-  this routine is for reducing fvccm data by a factor of 2       
-  volume averaging for all data except at the poles              
-  original developer: S.-J. Lin                                  
-  ----------------------------------------------------------------------------*/
-void redu2x(const double *varfin, const double *yfin, int nxfin, int nyfin, double *varcrs,
-	    int nxcrs, int nycrs, int nz, int has_missing, double missvalue)
-{
-  double  *cosp, *acosp, *vartmp;
-  int     i, j, k, i2, j2, n1, n2;
-
-  /*------------------------------------------------------------------
-    calculate cosine of latitude                                   
-    trick in cosp needed to maintain a constant field              
-    ----------------------------------------------------------------*/
-  cosp  = (double *)malloc(nyfin*sizeof(double));
-  acosp = (double *)malloc(nyfin*sizeof(double));
-  vartmp = (double *)malloc(nxcrs*nyfin*nz*sizeof(double));
-  cosp[0]=0.;
-  cosp[nyfin-1]=0.;
-  for(j=1; j<nyfin-1; j++) cosp[j]  = cos(yfin[j]);
-  for(j=1; j<nyfin-1; j++) acosp[j] = 1./(cosp[j]+0.5*(cosp[j-1]+cosp[j+1]));
-
-  /*----------------------------------------------------------------
-    x-sweep                                                        
-    ----------------------------------------------------------------*/
-  if(has_missing) {
-    for(k=0; k<nz; k++) for(j=1; j<nyfin-1; j++) {
-      n1 = k*nxfin*nyfin+j*nxfin;
-      n2 = k*nxcrs*nyfin+j*nxcrs;
-      if (varfin[n1+nxfin-1] == missvalue || varfin[n1] == missvalue || varfin[n1+1] == missvalue)
-	vartmp[n2] = missvalue;
-      else
-	vartmp[n2] = 0.25*(varfin[n1+nxfin-1]+2.*varfin[n1]+varfin[n1+1]);
-      for(i=2; i<nxfin-1; i+=2) {
-	i2 = i/2;
-	if (varfin[n1+i-1] == missvalue || varfin[n1+i] == missvalue || varfin[n1+i+1] == missvalue) 
-	  vartmp[n2+i2] = missvalue;
-        else
-	  vartmp[n2+i2] = 0.25*(varfin[n1+i-1]+2.*varfin[n1+i]+varfin[n1+i+1]);
-      }
-    }
-  }
-  else {
-    for(k=0; k<nz; k++) for(j=1; j<nyfin-1; j++) {
-      n1 = k*nxfin*nyfin+j*nxfin;
-      n2 = k*nxcrs*nyfin+j*nxcrs;
-      vartmp[n2] = 0.25*(varfin[n1+nxfin-1]+2.*varfin[n1]+varfin[n1+1]);
-      for(i=2; i<nxfin-1; i+=2) {
-	i2 = i/2;
-	vartmp[n2+i2] = 0.25*(varfin[n1+i-1]+2.*varfin[n1+i]+varfin[n1+i+1]);
-      }
-    }
-  }
-  /*---------------------------------------------------------------------
-    poles:                                                         
-    this code segment works for both the scalar and vector fields. 
-    Winds at poles are wave-1; the follwoing is quick & dirty yet the correct way
-    The skipping method. A more rigorous way is to                 
-    recompute the wave-1 components for the coarser grid.          
-    --------------------------------------------------------------------*/
-  for(k=0; k<nz; k++) for(i=0; i<nxcrs; i++) {
-    i2 = i*2;
-    n1 = k*nxcrs*nycrs;
-    n2 = k*nxfin*nyfin; 
-    varcrs[n1+i] = varfin[n2+i2];
-    varcrs[n1+(nycrs-1)*nxcrs+i] = varfin[n1+(nyfin-1)*nxfin+i2];
-  }
-  /*----------------------------------------------------------------
-    y-sweep                                                        
-    ----------------------------------------------------------------*/
-  if (has_missing) {
-    for(k=0; k<nz; k++) for(j=1; j<nyfin-1; j++) for(i=0; i<nxcrs; i++) {
-      n1 = k*nxcrs*nyfin+j*nxcrs+i;
-      if (vartmp[n1] /= missvalue) vartmp[n1] *= cosp[j];
-    }
-    for(k=0; k<nz; k++) for(j=2; j<nyfin-2; j+=2) {
-      j2 = j/2;
-      for(i=0; i<nxcrs; i++) {
-	n1 = k*nxcrs*nyfin + i;
-	n2 = k*nxcrs*nycrs + i;
-	if (vartmp[n1+j*nxcrs] == missvalue || vartmp[n1+(j-1)*nxcrs] == missvalue
-	    || vartmp[n1+(j+1)*nxcrs] == missvalue )
-	  varcrs[n2+j2*nxcrs] = missvalue;
-	else
-	  varcrs[n2+j2*nxcrs] = acosp[j]*(vartmp[n1+j*nxcrs] + 0.5*(vartmp[n1+(j-1)*nxcrs]+ vartmp[n1+(j+1)*nxcrs]));
-      }
-    }
-  }
-  else {
-    for(k=0; k<nz; k++) for(j=1; j<nyfin-1; j++) for(i=0; i<nxcrs; i++) {
-      n1 = k*nxcrs*nyfin+j*nxcrs+i;
-      vartmp[n1] *= cosp[j];
-    }
-    for(k=0; k<nz; k++) for(j=2; j<nyfin-2; j+=2) {
-      j2 = j/2;
-      for(i=0; i<nxcrs; i++) {
-	n1 = k*nxcrs*nyfin + i;
-	n2 = k*nxcrs*nycrs + i;
-	varcrs[n2+j2*nxcrs] = acosp[j]*(vartmp[n1+j*nxcrs] + 0.5*(vartmp[n1+(j-1)*nxcrs]+ vartmp[n1+(j+1)*nxcrs]));
-      }
-    }
-  }
-
-  free(cosp);
-  free(acosp);
-  free(vartmp);
-  
-}; /*redu2x*/
-
-
diff --git a/gridspec_tools_20080702/tools/shared/create_gnomonic_cubic_grid.c b/gridspec_tools_20080702/tools/shared/create_gnomonic_cubic_grid.c
deleted file mode 100644
index 8d37c16..0000000
--- a/gridspec_tools_20080702/tools/shared/create_gnomonic_cubic_grid.c
+++ /dev/null
@@ -1,907 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "constant.h"
-#include "mosaic_util.h"
-#include "tool_util.h"
-#include "create_hgrid.h"
-#define  D2R (M_PI/180.)
-#define  R2D (180./M_PI)
-#define  EPSLN (1.e-10)
-
-/* private subroutines */
-void gnomonic_ed  (int ni, double* lamda, double* theta);
-void gnomonic_angl(int ni, double* lamda, double* theta);
-void gnomonic_dist(int ni, double* lamda, double* theta);
-void cartesian_to_spherical(double x, double y, double z, double *lon, double *lat, double *r);
-void spherical_to_cartesian(double lon, double lat, double r, double *x, double *y, double *z);
-void symm_ed(int ni, double *lamda, double *theta);
-void mirror_grid(int ni, int ntiles, double *x, double *y );
-void mirror_latlon(double lon1, double lat1, double lon2, double lat2, double lon0,
-		   double lat0, double *lon, double *lat);
-void rot_3d(int axis, double x1in, double y1in, double z1in, double angle, double *x2out,
-	    double *y2out, double *z2out, int degrees, int convert);
-double excess_of_quad2(const double *vec1, const double *vec2, const double *vec3, const double *vec4 );
-double angle_between_vectors2(const double *vec1, const double *vec2);
-void plane_normal2(const double *P1, const double *P2, double *plane);
-void calc_rotation_angle2(int nxp, double *x, double *y, double *angle_dx, double *angle_dy);
-void cell_center(int ni, const double *lonc, const double *latc, double *lont, double *latt);
-void cell_east(int ni, const double *lonc, const double *latc, double *lone, double *late);
-void cell_north(int ni, const double *lonc, const double *latc, double *lonn, double *latn);
-/*******************************************************************************
-  void create_gnomonic_cubic_grid( int *npoints, int *nratio, char *method, char *orientation, double *x,
-                          double *y, double *dx, double *dy, double *area, double *angle_dx,
-                          double *angle_dy )
-  create nomomic cubic grid. All six tiles grid will be generated.
-*******************************************************************************/
-void create_gnomonic_cubic_grid( char* grid_type, int *npts, double *x, double *y,
-				double *dx, double *dy, double *area, double *angle_dx,
-			        double *angle_dy )
-{
-  const int ntiles = 6;
-  int nx, nxp, ni, nip;
-  int i, j, n;
-  double p1[2], p2[2];
-  double p_ll[2], p_ul[2], p_lr[2], p_ur[2], ar;
-  double *lon, *lat;
-  double *xc, *yc, *xt, *yt;
-  double *xe, *ye, *xn, *yn;
-  
-  nx  = *npts;
-  if( nx%2 ) mpp_error("create_gnomonic_cubic_grid: supergrid size should be divided by 2");
-  ni  = nx/2;
-  nip = ni + 1;
-  nxp = nx+1;
-
-  lon = (double *)malloc(nip*nip*sizeof(double));
-  lat = (double *)malloc(nip*nip*sizeof(double));
-  
-  if(strcmp(grid_type, "gnomonic_ed")==0 )
-    gnomonic_ed(  ni, lon, lat);
-  else if(strcmp(grid_type,"gnomonic_dist")==0)
-    gnomonic_dist(ni, lon, lat);
-  else if(strcmp(grid_type,"gnomonic_angl")==0)
-    gnomonic_angl(ni, lon, lat);
-  else mpp_error("create_gnomonic_cubic_grid: grid type should be 'gnomonic_ed', "
-		 "'gnomonic_dist' or 'gnomonic_angl'");
-
-  symm_ed(ni, lon, lat);
-
-  xc = (double *)malloc(ntiles*nip*nip*sizeof(double));
-  yc = (double *)malloc(ntiles*nip*nip*sizeof(double));
-  xt = (double *)malloc(ntiles*ni *ni *sizeof(double));
-  yt = (double *)malloc(ntiles*ni *ni *sizeof(double));
-  xe = (double *)malloc(ntiles*nip*ni *sizeof(double));
-  ye = (double *)malloc(ntiles*nip*ni *sizeof(double));
-  xn = (double *)malloc(ntiles*ni *nip*sizeof(double));
-  yn = (double *)malloc(ntiles*ni *nip*sizeof(double));
-  
-  for(j=0; j<nip; j++) {
-    for(i=0; i<nip; i++) {
-      xc[j*nip+i] = lon[j*nip+i] - M_PI;
-      yc[j*nip+i] = lat[j*nip+i];
-    }
-  }
-  
-  /* mirror_grid assumes that the tile=1 is centered on equator
-     and greenwich meridian Lon[-pi,pi]  */
-  mirror_grid(ni, ntiles, xc, yc);
-
-  for(n=0; n<ntiles*nip*nip; n++) {
-#ifndef NO_SHIFT_WEST
-    /* This will result in the corner close to east coast of china */
-    xc[n] -= M_PI/18.;
-#endif    
-    if(xc[n] < 0.) xc[n] += 2.*M_PI;
-    if(fabs(xc[n]) < EPSLN) xc[n] = 0;
-    if(fabs(yc[n]) < EPSLN) yc[n] = 0;
-  }
-      
-  /* ensure consistency on the boundary between tiles */
-  for(j=0; j<nip; j++) {
-    xc[  nip*nip+j*nip] = xc[j*nip+ni];                 /* 1E -> 2W */
-    yc[  nip*nip+j*nip] = yc[j*nip+ni];                 /* 1E -> 2W */
-    xc[2*nip*nip+j*nip] = xc[ni*nip+ni-j];              /* 1N -> 3W */
-    yc[2*nip*nip+j*nip] = yc[ni*nip+ni-j];              /* 1N -> 3W */      
-  }
-  for(i=0; i<nip; i++) {
-    xc[4*nip*nip+ni*nip+i] = xc[(ni-i)*nip];            /* 1W -> 5N */
-    yc[4*nip*nip+ni*nip+i] = yc[(ni-i)*nip];            /* 1W -> 2N */
-    xc[5*nip*nip+ni*nip+i] = xc[i];                     /* 1S -> 6N */
-    yc[5*nip*nip+ni*nip+i] = yc[i];                     /* 1S -> 6N */      
-    xc[2*nip*nip+i]        = xc[nip*nip+ni*nip+i];      /* 2N -> 3S */
-    yc[2*nip*nip+i]        = yc[nip*nip+ni*nip+i];      /* 2N -> 3S */
-    xc[3*nip*nip+i]        = xc[nip*nip+(ni-i)*nip+ni];  /* 2E -> 4S */
-    yc[3*nip*nip+i]        = yc[nip*nip+(ni-i)*nip+ni];  /* 2E -> 4S */      
-  }
-  for(j=0; j<nip; j++) {
-    xc[5*nip*nip+j*nip+ni] = xc[nip*nip+ni-j];          /* 2S -> 6E */
-    yc[5*nip*nip+j*nip+ni] = yc[nip*nip+ni-j];          /* 2S -> 6E */  
-    xc[3*nip*nip+j*nip]    = xc[2*nip*nip+j*nip+ni];    /* 3E -> 4W */
-    yc[3*nip*nip+j*nip]    = yc[2*nip*nip+j*nip+ni];    /* 3E -> 4W */
-    xc[4*nip*nip+j*nip]    = xc[2*nip*nip+ni*nip+ni-j]; /* 3N -> 5W */
-    yc[4*nip*nip+j*nip]    = yc[2*nip*nip+ni*nip+ni-j]; /* 3N -> 5W */
-  }
-  for(i=0; i<nip; i++) {
-    xc[4*nip*nip+i] = xc[3*nip*nip+ni*nip+i];           /* 4N -> 5S */
-    yc[4*nip*nip+i] = yc[3*nip*nip+ni*nip+i];           /* 4N -> 5S */
-    xc[5*nip*nip+i] = xc[3*nip*nip+(ni-i)*nip+ni];      /* 4E -> 6S */
-    yc[5*nip*nip+i] = yc[3*nip*nip+(ni-i)*nip+ni];      /* 4E -> 6S */
-  }
-  for(j=0; j<nip; j++) {
-    xc[5*nip*nip+j*nip] = xc[4*nip*nip+j*nip+ni];    /* 5E -> 6W */
-    yc[5*nip*nip+j*nip] = yc[4*nip*nip+j*nip+ni];    /* 5E -> 6W */  
-  }
-
-  /* calculate grid box center location */
-       
-  for(n=0; n<ntiles; n++) {
-    cell_center(ni, xc+n*nip*nip, yc+n*nip*nip, xt+n*ni*ni, yt+n*ni*ni);
-    cell_east(ni, xc+n*nip*nip, yc+n*nip*nip, xe+n*nip*ni, ye+n*nip*ni);
-    cell_north(ni, xc+n*nip*nip, yc+n*nip*nip, xn+n*ni*nip, yn+n*ni*nip);
-  }
-
-  /* copy grid box vertices location into super grid */
-  for(n=0; n<ntiles; n++) for(j=0; j<nip; j++) for(i=0; i<nip; i++) {
-    x[n*nxp*nxp+j*2*nxp+i*2]=xc[n*nip*nip+j*nip+i];
-    y[n*nxp*nxp+j*2*nxp+i*2]=yc[n*nip*nip+j*nip+i];
-  }
-
-  /* copy grid box center location to super grid */
-  for(n=0; n<ntiles; n++) for(j=0; j<ni; j++) for(i=0; i<ni; i++) {
-    x[n*nxp*nxp+(j*2+1)*nxp+i*2+1]=xt[n*ni*ni+j*ni+i];
-    y[n*nxp*nxp+(j*2+1)*nxp+i*2+1]=yt[n*ni*ni+j*ni+i];
-  }  
-
-  /* copy grid box east location to super grid */
-  for(n=0; n<ntiles; n++) for(j=0; j<ni; j++) for(i=0; i<nip; i++) {
-    x[n*nxp*nxp+(j*2+1)*nxp+i*2]=xe[n*nip*ni+j*nip+i];
-    y[n*nxp*nxp+(j*2+1)*nxp+i*2]=ye[n*nip*ni+j*nip+i];
-  }  
-
-  /* copy grid box north location to super grid */
-  for(n=0; n<ntiles; n++) for(j=0; j<nip; j++) for(i=0; i<ni; i++) {
-    x[n*nxp*nxp+j*2*nxp+i*2+1]=xn[n*ni*nip+j*ni+i];
-    y[n*nxp*nxp+j*2*nxp+i*2+1]=yn[n*ni*nip+j*ni+i];
-  }  
-  
-  free(xt);
-  free(yt);
-  free(xc);
-  free(yc);  
-  free(xe);
-  free(ye);
-  free(xn);
-  free(yn);
-  
-  /* calculate grid cell length */
-  for(n=0; n<ntiles; n++) {
-    for(j=0; j<nxp; j++) {
-      for(i=0; i<nx; i++) {
-	p1[0] = x[n*nxp*nxp+j*nxp+i];
-	p1[1] = y[n*nxp*nxp+j*nxp+i];
-	p2[0] = x[n*nxp*nxp+j*nxp+i+1];
-	p2[1] = y[n*nxp*nxp+j*nxp+i+1];
-	dx[n*nx*nxp+j*nx+i] = great_circle_distance(p1, p2);
-      }
-    }
-  }
-
-  /* copy dx to dy */
-  for(n=0; n<ntiles; n++) {
-    for(j=0; j<nxp; j++) {
-      for(i=0; i<nx; i++) dy[n*nx*nxp+i*nxp+j] = dx[n*nx*nxp+j*nx+i];
-    }
-  }
-
-  /* ensure consistency on the boundaries between tiles */
-  for(j=0; j<nx; j++) {
-    dy[j*nxp]             = dx[4*nx*nxp+nx*nx+nx-j-1]; /* 5N -> 1W */
-    dy[j*nxp+nx]          = dy[nxp*nx+j*nxp];          /* 2W -> 1E */
-    dy[nxp*nx+j*nxp+nx]   = dx[3*nx*nxp+(nx-j-1)];     /* 4S -> 2E */
-    dy[2*nxp*nx+j*nxp]    = dx[nx*nx+nx-j-1];          /* 1N -> 3W */
-    dy[2*nxp*nx+j*nxp+nx] = dy[3*nxp*nx+j*nxp];        /* 4W -> 3E */
-    dy[3*nxp*nx+j*nxp+nx] = dx[5*nx*nxp+(nx-j-1)];     /* 4S -> 2E */
-    dy[4*nxp*nx+j*nxp]    = dx[2*nx*nxp+nx*nx+nx-j-1]; /* 3N -> 5W */
-    dy[4*nxp*nx+j*nxp+nx] = dy[5*nxp*nx+j*nxp];        /* 6W -> 5E */
-    dy[5*nxp*nx+j*nxp+nx] = dx[nx*nxp+(nx-j-1)];       /* 2S -> 6E */    
-  }
-
-  for(j=0; j<nx; j++) {
-    for(i=0; i<nx; i++) {
-      p_ll[0] = x[j*nxp+i];       p_ll[1] = y[j*nxp+i];
-      p_ul[0] = x[(j+1)*nxp+i];   p_ul[1] = y[(j+1)*nxp+i];
-      p_lr[0] = x[j*nxp+i+1];     p_lr[1] = y[j*nxp+i+1];
-      p_ur[0] = x[(j+1)*nxp+i+1]; p_ur[1] = y[(j+1)*nxp+i+1];
-      /* all the face have the same area */
-      ar = spherical_excess_area(p_ll, p_ul, p_lr, p_ur, RADIUS);
-      area[j*nx+i] = ar;
-      area[nx*nx+j*nx+i] = ar;
-      area[2*nx*nx+j*nx+i] = ar;
-      area[3*nx*nx+j*nx+i] = ar;
-      area[4*nx*nx+j*nx+i] = ar;
-      area[5*nx*nx+j*nx+i] = ar;        
-    }
-  }
-
-  /*calculate rotation angle, just some workaround, will modify this in the future. */
-  calc_rotation_angle2(nxp, x, y, angle_dx, angle_dy );
-
-  /* convert grid location from radians to degree */
-  for(i=0; i<nxp*nxp*ntiles; i++) {
-    x[i] = x[i]*R2D;
-    y[i] = y[i]*R2D;
-  }
-  
-}; /* void create_gnomonic_cubic_grid */
-
-
-/*-----------------------------------------------------
-      void gnomonic_ed
-  Equal distance along the 4 edges of the cubed sphere
-  -----------------------------------------------------
-  Properties: 
-  * defined by intersections of great circles
-  * max(dx,dy; global) / min(dx,dy; global) = sqrt(2) = 1.4142
-  * Max(aspect ratio) = 1.06089
-  * the N-S coordinate curves are const longitude on the 4 faces with equator 
-  For C2000: (dx_min, dx_max) = (3.921, 5.545)    in km unit
-  ! Ranges:
-  ! lamda = [0.75*pi, 1.25*pi]
-  ! theta = [-alpha, alpha]
-  --------------------------------------------------------*/
-void gnomonic_ed(int ni, double* lamda, double* theta)
-{
-
-  int i, j, n, nip;
-  double dely;
-  double *pp, *x, *y, *z;
-  double rsq3, alpha;
-
-
-  nip = ni + 1;
-  rsq3 = 1./sqrt(3.);
-  alpha = asin( rsq3 );
-
-  dely = 2.*alpha/ni;
-
-  /* Define East-West edges: */
-  for(j=0; j<nip; j++) {
-    lamda[j*nip]    = 0.75*M_PI;               /* West edge */
-    lamda[j*nip+ni] = 1.25*M_PI;               /* East edge */
-    theta[j*nip]    = -alpha + dely*j;       /* West edge */
-    theta[j*nip+ni] = theta[j*nip];          /* East edge */
-  }
-
-  /* Get North-South edges by symmetry: */
-
-  for(i=1; i<ni; i++) {
-      mirror_latlon(lamda[0], theta[0], lamda[ni*nip+ni], theta[ni*nip+ni],  
-		    lamda[i*nip], theta[i*nip], &lamda[i], &theta[i] );
-      lamda[ni*nip+i] = lamda[i];
-      theta[ni*nip+i] = -theta[i];
-  }
-
-  x = (double *)malloc(nip*nip*sizeof(double));
-  y = (double *)malloc(nip*nip*sizeof(double));
-  z = (double *)malloc(nip*nip*sizeof(double));
-  /* Set 4 corners: */
-  latlon2xyz(1, &lamda[0], &theta[0], &x[0], &y[0], &z[0]);
-  latlon2xyz(1, &lamda[ni], &theta[ni], &x[ni], &y[ni], &z[ni]);
-  latlon2xyz(1, &lamda[ni*nip], &theta[ni*nip], &x[ni*nip], &y[ni*nip], &z[ni*nip]);
-  latlon2xyz(1, &lamda[ni*nip+ni], &theta[ni*nip+ni], &x[ni*nip+ni], &y[ni*nip+ni], &z[ni*nip+ni]);
-
-  /* Map edges on the sphere back to cube:
-     Intersections at x=-rsq3   */
-
-  for(j=1; j<ni; j++) {
-    n = j*nip;
-    latlon2xyz(1, &lamda[n], &theta[n], &x[n], &y[n], &z[n]);
-    y[n] = -y[n]*rsq3/x[n];
-    z[n] = -z[n]*rsq3/x[n];
-  }
-
-  for(i=1; i<ni; i++) {
-    latlon2xyz(1, &lamda[i], &theta[i], &x[i], &y[i], &z[i]);
-    y[i] = -y[i]*rsq3/x[i];
-    z[i] = -z[i]*rsq3/x[i];
-  }    
-
-  for(j=0; j<nip; j++)
-    for(i=0; i<nip; i++) x[j*nip+i] = -rsq3;
-
-  for(j=1;j<nip; j++) {
-    for(i=1; i<nip; i++) {
-      y[j*nip+i] = y[i];
-      z[j*nip+i] = z[j*nip];
-    }
-  }
-
-  xyz2latlon(nip*nip, x, y, z, lamda, theta);
-
-}; /* gnomonic_ed */
-
-/*----------------------------------------------------------
-  void gnomonic_angl()
-  This is the commonly known equi-angular grid
-**************************************************************/
-
-void gnomonic_angl(int ni, double* lamda, double* theta)
-{
-
-
-
-}; /* gnomonic_angl */
-
-/*----------------------------------------------------------
-  void gnomonic_dist()
-  This is the commonly known equi-distance grid
-**************************************************************/
-
-void gnomonic_dist(int ni, double* lamda, double* theta)
-{
-
-
-
-}; /* gnomonic_dist */
-
-/*------------------------------------------------------------------
-        void mirror_latlon
-   Given the "mirror" as defined by (lon1, lat1), (lon2, lat2), and center 
-   of the sphere, compute the mirror image of (lon0, lat0) as  (lon, lat)
-   ---------------------------------------------------------------*/
-   
-void mirror_latlon(double lon1, double lat1, double lon2, double lat2, double lon0,
-		   double lat0, double *lon, double *lat)
-{
-  double p0[3], p1[3], p2[3], pp[3], nb[3];
-  double pdot;
-  int k;
-
-  latlon2xyz(1, &lon0, &lat0, &p0[0], &p0[1], &p0[2]);
-  latlon2xyz(1, &lon1, &lat1, &p1[0], &p1[1], &p1[2]);
-  latlon2xyz(1, &lon2, &lat2, &p2[0], &p2[1], &p2[2]);
-  vect_cross(p1, p2, nb);
-     
-  pdot = sqrt(nb[0]*nb[0]+nb[1]*nb[1]+nb[2]*nb[2]);
-  for(k=0; k<3; k++) nb[k] = nb[k]/pdot;
-
-  pdot = p0[0]*nb[0] + p0[1]*nb[1] + p0[2]*nb[2];
-  for(k=0; k<3; k++) pp[k] = p0[k] - 2*pdot*nb[k];
-  xyz2latlon(1, &pp[0], &pp[1], &pp[2], lon, lat);
-    
-}; /* mirror_latlon */
-
-/*-------------------------------------------------------------------------
-  void symm_ed(int ni, double *lamda, double *theta)
-  ! Make grid symmetrical to i=ni/2+1 and j=nj/2+1
-  ------------------------------------------------------------------------*/
-void symm_ed(int ni, double *lamda, double *theta)
-{
-  
-  int nip, i, j, ip, jp;
-  double avg;
-  
-  nip = ni+1;
-
-  for(j=1; j<nip; j++)
-    for(i=1; i<ni; i++) lamda[j*nip+i] = lamda[i];
-  
-  for(j=0; j<nip; j++) {
-    for(i=0; i<ni/2; i++) {
-      ip = ni - i;
-      avg = 0.5*(lamda[j*nip+i]-lamda[j*nip+ip]);
-      lamda[j*nip+i] = avg + M_PI;
-      lamda[j*nip+ip] = M_PI - avg;
-      avg = 0.5*(theta[j*nip+i]+theta[j*nip+ip]);
-      theta[j*nip+i] = avg;
-      theta[j*nip+ip] = avg;      
-    }
-  }
-
-  /* Make grid symmetrical to j=im/2+1 */
-  for(j = 0; j<ni/2; j++) {
-    jp = ni - j;
-    for(i=1; i<ni; i++) {
-      avg = 0.5*(lamda[j*nip+i]+lamda[jp*nip+i]);
-      lamda[j*nip+i] = avg;
-      lamda[jp*nip+i] = avg;
-      avg = 0.5*(theta[j*nip+i]-theta[jp*nip+i]);
-      theta[j*nip+i] = avg;
-      theta[jp*nip+i] = -avg;
-    }
-  }
-}/* symm_ed */
-
-/*------------------------------------------------------------------------------
-  void mirror_grid( )
-  Mirror Across the 0-longitude
-  ----------------------------------------------------------------------------*/
-void mirror_grid(int ni, int ntiles, double *x, double *y )
-{
-  int nip, i, j, ip, jp, nt;
-  double x1, y1, z1, x2, y2, z2, ang;
-
-  nip = ni+1;
-  
-  for(j=0; j<ceil(nip/2.); j++) {
-    jp = ni - j;
-    for(i=0; i<ceil(nip/2.); i++) {
-      ip = ni - i;
-      x1 = 0.25 * (fabs(x[j*nip+i]) + fabs(x[j*nip+ip]) + fabs(x[jp*nip+i]) + fabs(x[jp*nip+ip]) );
-      x[j*nip+i]   = x1 * (x[j*nip+i]   >=0 ? 1:-1);
-      x[j*nip+ip]  = x1 * (x[j*nip+ip]  >=0 ? 1:-1);
-      x[jp*nip+i]  = x1 * (x[jp*nip+i]  >=0 ? 1:-1);
-      x[jp*nip+ip] = x1 * (x[jp*nip+ip] >=0 ? 1:-1);      
-
-      y1 = 0.25 * (fabs(y[j*nip+i]) + fabs(y[j*nip+ip]) + fabs(y[jp*nip+i]) + fabs(y[jp*nip+ip]) );
-      y[j*nip+i]   = y1 * (y[j*nip+i]   >=0 ? 1:-1);
-      y[j*nip+ip]  = y1 * (y[j*nip+ip]  >=0 ? 1:-1);
-      y[jp*nip+i]  = y1 * (y[jp*nip+i]  >=0 ? 1:-1);
-      y[jp*nip+ip] = y1 * (y[jp*nip+ip] >=0 ? 1:-1);      
-      
-      /* force dateline/greenwich-meridion consitency */
-      if( nip%2 ) {
-	if( i == (nip-1)/2 ) {
-	  x[j*nip+i] = 0.0;
-	  x[jp*nip+i] = 0.0;
-	}
-      }
-    }
-  }
-
-  /* define the the other five tiles. */
-  for(nt=1; nt<ntiles; nt++) {
-    for(j=0; j<nip; j++) {
-      for(i=0; i<nip; i++) {
-	x1 = x[j*nip+i];
-	y1 = y[j*nip+i];
-	z1 = RADIUS;
-	switch (nt) {
-	case 1: /* tile 2 */
-	  ang = -90.;
-	  rot_3d( 3, x1, y1, z1, ang, &x2, &y2, &z2, 1, 1);  /* rotate about the z-axis */
-	  break;
-	case 2: /* tile 3 */
-	  ang = -90.;
-	  rot_3d( 3, x1, y1, z1, ang, &x2, &y2, &z2, 1, 1);  /* rotate about the z-axis */
-	  ang = 90.;
-	  rot_3d( 1, x2, y2, z2, ang, &x1, &y1, &z1, 1, 1); /* rotate about the z-axis */
-	  x2=x1;
-	  y2=y1;
-	  z2=z1;
-
-	  /* force North Pole and dateline/greenwich-meridion consitency */
-	  if(nip%2) {
-	    if( (i==(nip-1)/2) && (i==j) ) {
-	      x2 = 0;
-	      y2 = M_PI*0.5;
-	    }
-
-	    if( (j==(nip-1)/2) && (i<(nip-1)/2) ) x2 = 0;
-	    if( (j==(nip-1)/2) && (i>(nip-1)/2) ) x2 = M_PI;
-	  }
-	  break;
-	case 3: /* tile 4 */
-	  ang = -180.;
-	  rot_3d( 3, x1, y1, z1, ang, &x2, &y2, &z2, 1, 1); /* rotate about the z-axis */
-	  ang = 90.;
-	  rot_3d( 1, x2, y2, z2, ang, &x1, &y1, &z1, 1, 1); /* rotate about the z-axis */
-	  x2=x1;
-	  y2=y1;
-	  z2=z1;
-
-	  /* force dateline/greenwich-meridion consitency */
-	  if( nip%2 ) {
-	    if( j == (nip-1)/2 ) x2 = M_PI;
-	  }
-	  break;
-	case 4: /* tile 5 */
-	  ang = 90.;
-	  rot_3d( 3, x1, y1, z1, ang, &x2, &y2, &z2, 1, 1); /* rotate about the z-axis */
-	  ang = 90.;
-	  rot_3d( 2, x2, y2, z2, ang, &x1, &y1, &z1, 1, 1); /* rotate about the z-axis */
-	  x2=x1;
-	  y2=y1;
-	  z2=z1;
-	  break;
-	case 5: /* tile 6 */
-	  ang = 90.;
-	  rot_3d( 2, x1, y1, z1, ang, &x2, &y2, &z2, 1, 1); /* rotate about the z-axis */
-	  ang = 0.;
-	  rot_3d( 3, x2, y2, z2, ang, &x1, &y1, &z1, 1, 1); /* rotate about the z-axis */
-	  x2=x1;
-	  y2=y1;
-	  z2=z1;
-	  
-	  /* force South Pole and dateline/greenwich-meridion consitency */
-	  if(nip%2) {
-	    if( (i==(nip-1)/2) && (i==j) ) {
-	      x2 = 0;
-	      y2 = -M_PI*0.5;
-	    }
-
-	    if( (i==(nip-1)/2) && (j>(nip-1)/2) ) x2 = 0;
-	    if( (i==(nip-1)/2) && (j<(nip-1)/2) ) x2 = M_PI;
-	  }
-	  break;
-	}
-	x[nt*nip*nip+j*nip+i] = x2;
-	y[nt*nip*nip+j*nip+i] = y2;
-      }
-    }
-  }
-}; /* mirror_grid */
-
-
-/*-------------------------------------------------------------------------------
-  void rot_3d()
-  rotate points on a sphere in xyz coords (convert angle from
-  degrees to radians if necessary)
-  -----------------------------------------------------------------------------*/
-void rot_3d(int axis, double x1in, double y1in, double z1in, double angle, double *x2out,
-	    double *y2out, double *z2out, int degrees, int convert)
-{
-
-  double x1, y1, z1, x2, y2, z2, c, s;
-  
-  if(convert)
-    spherical_to_cartesian(x1in, y1in, z1in, &x1, &y1, &z1);
-  else {
-    x1=x1in;
-    y1=y1in;
-    z1=z1in;
-  }
-
-  if(degrees) angle = angle*D2R;
-
-  c = cos(angle);
-  s = sin(angle);
-
-  switch (axis) {
-  case 1:
-    x2 =  x1;
-    y2 =  c*y1 + s*z1;
-    z2 = -s*y1 + c*z1;
-    break;
-  case 2:
-    x2 = c*x1 - s*z1;
-    y2 = y1;
-    z2 = s*x1 + c*z1;
-    break;
-  case 3:
-    x2 =  c*x1 + s*y1;
-    y2 = -s*x1 + c*y1;
-    z2 = z1;
-    break;
-  default:
-    mpp_error("Invalid axis: must be 1 for X, 2 for Y, 3 for Z.");
-  }
-  
-  if(convert)
-    cartesian_to_spherical(x2, y2, z2, x2out, y2out, z2out);
-  else {
-    *x2out=x2;;
-    *y2out=y2;
-    *z2out=z2;
-    }
-} /* rot_3d */
-
-/*-------------------------------------------------------------
-  void cartesian_to_spherical(x, y, z, lon, lat, r)
-  may merge with xyz2latlon in the future
-  ------------------------------------------------------------*/
-void cartesian_to_spherical(double x, double y, double z, double *lon, double *lat, double *r)
-{
-
-  *r = sqrt(x*x + y*y + z*z);
-  if ( (fabs(x) + fabs(y)) < EPSLN )       /* poles */
-    *lon = 0.;
-  else
-    *lon = atan2(y,x);    /* range: [-pi,pi] */
-
-
-  *lat = acos(z/(*r)) - M_PI/2.;
-};/* cartesian_to_spherical */
-
-/*-------------------------------------------------------------------------------
-  void spherical_to_cartesian
-  convert from spheircal coordinates to xyz coords
-  may merge with latlon2xyz in the future
-  -----------------------------------------------------------------------------*/
-void spherical_to_cartesian(double lon, double lat, double r, double *x, double *y, double *z)
-{
-  *x = r * cos(lon) * cos(lat);
-  *y = r * sin(lon) * cos(lat);
-
-  *z = -r * sin(lat);
-} /* spherical_to_cartesian */
-
-
-/*****************************************************************
-   double* excess_of_quad(int ni, int nj, double *vec1, double *vec2, 
-                          double *vec3, double *vec4 )
-*******************************************************************/
-double excess_of_quad2(const double *vec1, const double *vec2, const double *vec3, const double *vec4 )
-{
-  double plane1[3], plane2[3], plane3[3], plane4[3];
-  double angle12, angle23, angle34, angle41, excess;
-  double ang12, ang23, ang34, ang41;
-  
-  plane_normal2(vec1, vec2, plane1);
-  plane_normal2(vec2, vec3, plane2);
-  plane_normal2(vec3, vec4, plane3);
-  plane_normal2(vec4, vec1, plane4);
-  angle12 = angle_between_vectors2(plane2,plane1);
-  angle23 = angle_between_vectors2(plane3,plane2);
-  angle34 = angle_between_vectors2(plane4,plane3);
-  angle41 = angle_between_vectors2(plane1,plane4);
-  ang12 = M_PI-angle12;
-  ang23 = M_PI-angle23;
-  ang34 = M_PI-angle34;
-  ang41 = M_PI-angle41;
-  excess = ang12+ang23+ang34+ang41-2*M_PI;
-  /*  excess = 2*M_PI - angle12 - angle23 - angle34 - angle41; */
-
-  return excess;
-
-}; /* excess_of_quad */
-
-/******************************************************************************* 
-double angle_between_vectors(const double *vec1, const double *vec2)
-*******************************************************************************/
-
-double angle_between_vectors2(const double *vec1, const double *vec2) {
-  int n;
-  double vector_prod, nrm1, nrm2;
-  double angle;
-  
-  vector_prod=vec1[0]*vec2[0] + vec1[1]*vec2[1] + vec1[2]*vec2[2];
-  nrm1=pow(vec1[0],2)+pow(vec1[1],2)+pow(vec1[2],2);
-  nrm2=pow(vec2[0],2)+pow(vec2[1],2)+pow(vec2[2],2);
-  if(nrm1*nrm2>0)
-    angle = acos( vector_prod/sqrt(nrm1*nrm2) );
-  else
-    angle = 0;
-  
-  return angle;
-}; /* angle_between_vectors */
-
-
-/***********************************************************************
-   double* plane_normal(int ni, int nj, double *P1, double *P2)
-***********************************************************************/
-
-void plane_normal2(const double *P1, const double *P2, double *plane)
-{
-  double mag;
-  
-  plane[0] = P1[1] * P2[2] - P1[2] * P2[1];
-  plane[1] = P1[2] * P2[0] - P1[0] * P2[2];
-  plane[2] = P1[0] * P2[1] - P1[1] * P2[0];
-  mag=sqrt(pow(plane[0],2) + pow(plane[1],2) + pow(plane[2],2));
-  if(mag>0) {
-    plane[0]=plane[0]/mag;
-    plane[1]=plane[1]/mag;
-    plane[2]=plane[2]/mag;
-  }
-  
-}; /* plane_normal */
-
-/******************************************************************
-
-  void calc_rotation_angle()
-
-******************************************************************/
-
-void calc_rotation_angle2(int nxp, double *x, double *y, double *angle_dx, double *angle_dy)
-{
-  int ip1, im1, jp1, jm1, tp1, tm1, i, j, n, ntiles, nx;
-  double lon_scale;
-
-  nx = nxp - 1;
-  ntiles = 6;
-  for(n=0; n<ntiles; n++) {
-    for(j=0; j<nxp; j++) {
-      for(i=0; i<nxp; i++) {
-	lon_scale = cos(y[n*nxp*nxp+j*nxp+i]*D2R);
-	tp1 = n;
-	tm1 = n;
-	ip1 = i+1;
-	im1 = i-1;
-	jp1 = j;
-	jm1 = j;
-
-        if(ip1 >= nxp) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tp1 = n+1;
-	    ip1 = 0;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tp1 = n+2;
-	    if(tp1 >= ntiles) tp1 -= ntiles;
-	    ip1 = nx-j-1;
-	    jp1 = 0;
-	  }
-	}        
-        if(im1 < 0) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tm1 = n-2;
-	    if(tm1 < 0) tm1 += ntiles;
-	    jm1 = nx;
-	    im1 = nx-j;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tm1 = n-1;
-	    im1 = nx;
-	  }
-	}
-
-	angle_dx[n*nxp*nxp+j*nxp+i] = atan2(y[tp1*nxp*nxp+jp1*nxp+ip1]-y[tm1*nxp*nxp+jm1*nxp+im1],
-					    (x[tp1*nxp*nxp+jp1*nxp+ip1]-x[tm1*nxp*nxp+jm1*nxp+im1])*lon_scale )*R2D;
-	tp1 = n;
-	tm1 = n;
-	ip1 = i;
-	im1 = i;
-	jp1 = j+1;
-	jm1 = j-1;
-        if(jp1 >=nxp) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tp1 = n+2;
-	    if(tp1 >= ntiles) tp1 -= ntiles;
-	    jp1 = nx-i;
-	    ip1 = 0;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tp1 = n+1;
-	    if(tp1 >= ntiles) tp1 -= ntiles;
-	    jp1 = 0;
-	  }
-	}        
-        if(jm1 < 0) {  /* find the neighbor tile. */
-	  if(n % 2 == 0) { /* tile 1, 3, 5 */
-	    tm1 = n-1;
-	    if(tm1 < 0) tm1 += ntiles;
-	    jm1 = nx;
-	  }
-	  else { /* tile 2, 4, 6 */
-	    tm1 = n-2;
-	    if(tm1 < 0) tm1 += ntiles;
-	    im1 = nx;
-	    jm1 = nx-i;
-	  }
-	}	
-
-	angle_dy[n*nxp*nxp+j*nxp+i] = atan2(y[tp1*nxp*nxp+jp1*nxp+ip1]-y[tm1*nxp*nxp+jm1*nxp+im1],
-					    (x[tp1*nxp*nxp+jp1*nxp+ip1]-x[tm1*nxp*nxp+jm1*nxp+im1])*lon_scale )*R2D;
-      }
-    }
-  }
-
-}; /* calc_rotation_angle2 */
-
-
-/* This routine calculate center location based on the vertices location */
-void cell_center(int ni, const double *lonc, const double *latc, double *lont, double *latt)
-{
-
-  int    nip, i, j, p, p1, p2, p3, p4;
-  double *xc, *yc, *zc, *xt, *yt, *zt;
-  double dd;
-  
-  nip = ni+1;  
-  xc = (double *)malloc(nip*nip*sizeof(double));
-  yc = (double *)malloc(nip*nip*sizeof(double));
-  zc = (double *)malloc(nip*nip*sizeof(double));
-  xt = (double *)malloc(ni *ni *sizeof(double));
-  yt = (double *)malloc(ni *ni *sizeof(double));
-  zt = (double *)malloc(ni *ni *sizeof(double));  
-  latlon2xyz(nip*nip, lonc, latc, xc, yc, zc); 
-
-  for(j=0; j<ni; j++) for(i=0; i<ni; i++) {
-    p =  j*ni+i;
-    p1 = j*nip+i;
-    p2 = j*nip+i+1;
-    p3 = (j+1)*nip+i+1;
-    p4 = (j+1)*nip+i;
-    xt[p] = xc[p1] + xc[p2] + xc[p3] + xc[p4];
-    yt[p] = yc[p1] + yc[p2] + yc[p3] + yc[p4];
-    zt[p] = zc[p1] + zc[p2] + zc[p3] + zc[p4];
-
-    dd = sqrt(pow(xt[p],2) + pow(yt[p],2) + pow(zt[p],2) );
-    xt[p] /= dd;
-    yt[p] /= dd;
-    zt[p] /= dd;
-  }
-  xyz2latlon(ni*ni, xt, yt, zt, lont, latt);
-  free(zt);
-  free(yt);
-  free(xt);
-  free(zc);
-  free(yc);
-  free(xc);
-  
-}; /* cell_center */
-
-
-/* This routine calculate east location based on the vertices location */
-void cell_east(int ni, const double *lonc, const double *latc, double *lone, double *late)
-{
-
-  int    nip, i, j, p, p1, p2;
-  double *xc, *yc, *zc, *xe, *ye, *ze;
-  double dd;
-  
-  nip = ni+1;  
-  xc = (double *)malloc(nip*nip*sizeof(double));
-  yc = (double *)malloc(nip*nip*sizeof(double));
-  zc = (double *)malloc(nip*nip*sizeof(double));
-  xe = (double *)malloc(nip*ni *sizeof(double));
-  ye = (double *)malloc(nip*ni *sizeof(double));
-  ze = (double *)malloc(nip*ni *sizeof(double));  
-  latlon2xyz(nip*nip, lonc, latc, xc, yc, zc); 
-
-  for(j=0; j<ni; j++) for(i=0; i<nip; i++) {
-    p =  j*nip+i;
-    p1 = j*nip+i;
-    p2 = (j+1)*nip+i;
-    xe[p] = xc[p1] + xc[p2];
-    ye[p] = yc[p1] + yc[p2];
-    ze[p] = zc[p1] + zc[p2];
-
-    dd = sqrt(pow(xe[p],2) + pow(ye[p],2) + pow(ze[p],2) );
-    xe[p] /= dd;
-    ye[p] /= dd;
-    ze[p] /= dd;
-  }
-  xyz2latlon(nip*ni, xe, ye, ze, lone, late);
-  free(ze);
-  free(ye);
-  free(xe);
-  free(zc);
-  free(yc);
-  free(xc);
-  
-}; /* cell_east */
-
-
-/* This routine calculate center location based on the vertices location */
-void cell_north(int ni, const double *lonc, const double *latc, double *lonn, double *latn)
-{
-
-  int    nip, i, j, p, p1, p2;
-  double *xc, *yc, *zc, *xn, *yn, *zn;
-  double dd;
-  
-  nip = ni+1;  
-  xc = (double *)malloc(nip*nip*sizeof(double));
-  yc = (double *)malloc(nip*nip*sizeof(double));
-  zc = (double *)malloc(nip*nip*sizeof(double));
-  xn = (double *)malloc(ni *nip*sizeof(double));
-  yn = (double *)malloc(ni *nip*sizeof(double));
-  zn = (double *)malloc(ni *nip*sizeof(double));  
-  latlon2xyz(nip*nip, lonc, latc, xc, yc, zc); 
-
-  for(j=0; j<nip; j++) for(i=0; i<ni; i++) {
-    p =  j*ni+i;
-    p1 = j*nip+i;
-    p2 = j*nip+i+1;
-    xn[p] = xc[p1] + xc[p2];
-    yn[p] = yc[p1] + yc[p2];
-    zn[p] = zc[p1] + zc[p2];
-
-    dd = sqrt(pow(xn[p],2) + pow(yn[p],2) + pow(zn[p],2) );
-    xn[p] /= dd;
-    yn[p] /= dd;
-    zn[p] /= dd;
-  }
-  xyz2latlon(ni*nip, xn, yn, zn, lonn, latn);
-  free(zn);
-  free(yn);
-  free(xn);
-  free(zc);
-  free(yc);
-  free(xc);
-  
-}; /* cell_north */
diff --git a/gridspec_tools_20080702/tools/shared/create_grid_from_file.c b/gridspec_tools_20080702/tools/shared/create_grid_from_file.c
deleted file mode 100644
index 3dc60cc..0000000
--- a/gridspec_tools_20080702/tools/shared/create_grid_from_file.c
+++ /dev/null
@@ -1,152 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <complex.h>
-#include <math.h>
-#include <string.h>
-#include "mosaic_util.h"
-#include "tool_util.h"
-#include "constant.h"
-#include "mpp_io.h"
-#include "create_hgrid.h"
-#define  D2R (M_PI/180.)
-#define  R2D (180./M_PI)
-
-/***********************************************************************
-  void create_grid_from_file( char *file, int *nlon, int *nlat, double *x, double *y, double *dx,
-                              double *dy, double *area, double *angle_dx )
-   the grid location is defined through ascii file. calculate cell length,
-   cell area and rotation angle  
-************************************************************************/
-void create_grid_from_file( char *file, int *nlon, int *nlat, double *x, double *y, double *dx, double *dy,
-           		    double *area, double *angle_dx )
-{
-  double *xb, *yb, *xt, *yt, *xc, *yc;
-  double p1[4], p2[4];
-  int nx, ny, nxp, nyp, ni, nj, i, j, n;
-  FILE *pFile;
-  char mesg[256], txt[128];
-  
-  /************************************************************
-     identify the grid_file is ascii file or netcdf file,
-     if the file name contains ".nc", it is a netcdf file,
-     otherwise it is ascii file.
-  *********************************************************/
-  nx  = *nlon;
-  ny  = *nlat;
-  nxp = nx + 1;
-  nyp = ny + 1;
-  if(strstr(file, ".nc") ) {
-    int fid, vid;
-
-    ni  = *nlon/2;
-    nj  = *nlat/2;
-    xc = (double *)malloc((ni+1)*(nj+1)*sizeof(double));
-    yc = (double *)malloc((ni+1)*(nj+1)*sizeof(double));
-    xt = (double *)malloc( ni   * nj   *sizeof(double));
-    yt = (double *)malloc( ni   * nj   *sizeof(double));
-    fid = mpp_open(file, MPP_READ);
-    vid = mpp_get_varid(fid, "grid_lon");
-    mpp_get_var_value(fid, vid, xc);
-    vid = mpp_get_varid(fid, "grid_lat");
-    mpp_get_var_value(fid, vid, yc);
-    vid = mpp_get_varid(fid, "grid_lont");
-    mpp_get_var_value(fid, vid, xt);
-    vid = mpp_get_varid(fid, "grid_latt");
-    mpp_get_var_value(fid, vid, yt);
-    mpp_close(fid);
-    for(j=0; j<nj+1; j++) for(i=0; i<ni+1; i++) {
-      x[j*2*nxp+i*2] = xc[j*(ni+1)+i];
-      y[j*2*nxp+i*2] = yc[j*(ni+1)+i];
-    }
-    for(j=0; j<nj; j++) for(i=0; i<ni; i++) {
-      x[(j*2+1)*nxp+i*2+1] = xt[j*ni+i];
-      y[(j*2+1)*nxp+i*2+1] = yt[j*ni+i];
-    }
-    for(j=0; j<nj+1; j++) for(i=0; i<ni; i++) {
-      x[j*2*nxp+i*2+1] = (xc[j*(ni+1)+i]+xc[j*(ni+1)+i+1])*0.5;
-      y[j*2*nxp+i*2+1] = (yc[j*(ni+1)+i]+yc[j*(ni+1)+i+1])*0.5;
-    }    
-    for(j=0; j<nj; j++) for(i=0; i<ni+1; i++) {
-      x[(j*2+1)*nxp+i*2] = (xc[j*(ni+1)+i]+xc[(j+1)*(ni+1)+i])*0.5;
-      y[(j*2+1)*nxp+i*2] = (yc[j*(ni+1)+i]+yc[(j+1)*(ni+1)+i])*0.5;
-    }
-
-    for(j=0; j<nyp; j++) for(i=0; i<nx; i++) {
-      p1[0] = x[j*nxp+i]; p2[0] = x[j*nxp+i+1];
-      p1[1] = y[j*nxp+i]; p2[1] = y[j*nxp+i+1];
-      dx[j*nx+i] = great_circle_distance(p1, p2);
-    }
-    for(j=0; j<ny; j++) for(i=0; i<nxp; i++) {
-      p1[0] = x[j*nxp+i]; p2[0] = x[(j+1)*nxp+i];
-      p1[1] = y[j*nxp+i]; p2[1] = y[(j+1)*nxp+i];
-      dy[j*nxp+i] = great_circle_distance(p1, p2);
-    }    
-    for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-      p1[0] = x[j*nxp+i]; p1[1] = x[j*nxp+i+1]; p1[2] = x[(j+1)*nxp+i+1]; p1[3] = x[(j+1)*nxp+i];
-      p2[0] = y[j*nxp+i]; p2[1] = y[j*nxp+i+1]; p2[2] = y[(j+1)*nxp+i+1]; p2[3] = y[(j+1)*nxp+i];
-      area[j*nx+i] = poly_area(p1, p2, 4);
-    }
-    /* currently set angle to 0 */
-    for(j=0; j<nyp; j++) for(i=0; i<nxp; i++) angle_dx[j*nxp+i] = 0;    
-    free(xt);
-    free(yt);
-    free(xc);
-    free(yc);
-  }
-  else {
-    pFile = fopen (file,"r");
-    if(!pFile) {
-      strcpy(mesg, "RegularSphericalGrid: Can not open ascii file ");
-      strcat(mesg,file);
-      mpp_error(mesg);
-    }
-
-    fscanf(pFile, "%s%*[^\n]",txt); /* header line (ignored) */
-    xb = (double *) malloc(nxp*sizeof(double));
-    yb = (double *) malloc(nyp*sizeof(double));
-    for(i=0;i<nxp;i++) 
-      fscanf(pFile, "%lg", xb+i); /* longitude */ 
-    fscanf(pFile, "%s%*[^\n]",txt); /* header line (ignored) */   
-    for(j=0;j<nyp;j++) fscanf(pFile, "%lg", yb+j); /* latitude */
-    
-    fclose(pFile);
-    n=0;
-    for(j=0; j<nyp; j++) {
-      for(i=0; i<nxp; i++) {
-	x[n]       = xb[i];
-	y[n]       = yb[j];
-	angle_dx[n++] = 0;   
-      }
-    }
-    /* zonal length */
-    n = 0;
-    for(j=0; j<nyp; j++) {
-      for(i=0; i<nx; i++ ) {
-	dx[n++] = spherical_dist(x[j*nxp+i], y[j*nxp+i], x[j*nxp+i+1], y[j*nxp+i+1] );
-      }
-    }
-
-    /* meridinal length */
-    n = 0;
-    for(j=0; j<ny; j++) {
-      for(i=0; i<nxp; i++ ) {
-	dy[n++] = spherical_dist(x[j*nxp+i], y[j*nxp+i], x[(j+1)*nxp+i], y[(j+1)*nxp+i] );
-      }
-    }
-
-    /* cell area */
-    n = 0;
-    for(j=0; j<ny; j++) {
-      for(i=0; i<nx; i++ ) {
-	area[n++] = box_area(x[j*nxp+i]*D2R, y[j*nxp+i]*D2R, x[(j+1)*nxp+i+1]*D2R, y[(j+1)*nxp+i+1]*D2R );
-      }
-    }
-
-    free(xb);
-    free(yb);
-  }
-}; /* create_grid_from_file */
-
-
-
-
diff --git a/gridspec_tools_20080702/tools/shared/create_vgrid.c b/gridspec_tools_20080702/tools/shared/create_vgrid.c
deleted file mode 100644
index 6e84402..0000000
--- a/gridspec_tools_20080702/tools/shared/create_vgrid.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <stdlib.h>
-#include "create_vgrid.h"
-#include "tool_util.h"
-
-/***********************************************************************
-   void create_vgrid(int nbnds, double *bnds, int *nz, char center, double *zeta)
-   This routine is used to create vertical grid. The created grid is on super grid.
-   the refinement is assumed to be 2.
-
-   INPUT:
-      nbnds:  number of vertical regions for varying resolution.      
-      bnds:   boundaries for defining vertical regions of varying resolution.
-              The size of bnds is nz.
-      nz:     Number of model grid points for each vertical regions of varying resolution.
-              The size of nz will be nz-1
-      center: grid cell center location. Its value can be 'N', 'T' or 'C' with default
-              value 'N'. When the value is 'N', supergrid location will be calculated.
-              When the value is 'T', model grid corner location will be calculated,
-              other grid location of the supergrid will be derived through T-cell
-              centered condition. When the value is 'C', model grid corner location will
-              be calculated, other grid location of the supergrid will be derived through
-              C-cell centered condition.
-
-   OUTPUT:
-      zeta:   created vertical grid location.
-
-***********************************************************************/
-
-void create_vgrid(int nbnds, double *bnds, int *nz, double *zeta, const char *center)
-{
-  int i, np;
-  double *zb=NULL;
-
-  
-  zb = compute_grid_bound(nbnds, bnds, nz, &np, center);
-  np++;
-  
-  for(i=0; i<np; i++) zeta[i] =zb[i];
-
-  free(zb);
-    
-  
-}; /* create_vgrid */
diff --git a/gridspec_tools_20080702/tools/shared/fregrid_util.c b/gridspec_tools_20080702/tools/shared/fregrid_util.c
deleted file mode 100644
index 2e12176..0000000
--- a/gridspec_tools_20080702/tools/shared/fregrid_util.c
+++ /dev/null
@@ -1,1597 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include "fregrid_util.h"
-#include "mpp_io.h"
-#include "mosaic_util.h"
-#include "gradient_c2l.h"
-
-#define D2R (M_PI/180)
-#define R2D (180/M_PI)
-#define EPSLN (1.e-10)
-void init_halo(double *var, int nx, int ny, int nz, int halo);
-void update_halo(int nx, int ny, int nz, double *data, Bound_config *bound, Data_holder *dHold);
-void setup_boundary(const char *mosaic_file, int ntiles, Grid_config *grid, Bound_config *bound, int halo, int position);
-void delete_bound_memory(int ntiles, Bound_config *bound);
-/*******************************************************************************
-  void setup_tile_data_file(Mosaic_config mosaic, const char *filename)
-  This routine will setup the data file name for each tile.
-*******************************************************************************/
-
-void set_mosaic_data_file(int ntiles, const char *mosaic_file, const char *dir, File_config *file,
-			  const char *filename)
-{
-  char   str1[STRING]="", str2[STRING]="", tilename[STRING]="";
-  int    i, n, len, fid, vid;
-  size_t start[4], nread[4];
-
-  len = strlen(filename); 
-  if( strstr(filename, ".nc") ) 
-    strncpy(str1, filename, len-3);
-  else
-    strcpy(str1, filename);
-  if(dir) {
-    if(strlen(dir)+strlen(str1) >= STRING)mpp_error("set_mosaic_data_file(fregrid_util): length of str1 + "
-						    "length of dir should be no greater than STRING");
-    sprintf(str2, "%s/%s", dir, str1);
-  }
-  else
-    strcpy(str2, str1);
-  
-  for(i=0; i<4; i++) {
-    start[i] = 0; nread[i] = 1;
-  }
-  nread[1] = STRING;
-  if(ntiles > 1) {
-    if(!mosaic_file) mpp_error("fregrid_util: when ntiles is greater than 1, mosaic_file should be defined");
-    fid = mpp_open(mosaic_file, MPP_READ);
-    vid = mpp_get_varid(fid, "gridtiles");
-  }
-  for(i = 0; i < ntiles; i++) {
-    start[0] = i;
-    if(ntiles > 1) {
-      mpp_get_var_value_block(fid, vid, start, nread, tilename);
-      if(strlen(str2) + strlen(tilename) > STRING -5) mpp_error("set_mosaic_data_file(fregrid_util): length of str2 + "
-								"length of tilename should be no greater than STRING-5");
-      sprintf(file[i].name, "%s.%s.nc", str2, tilename);
-    }
-    else 
-      sprintf(file[i].name, "%s.nc", str2);
-  }
-
-}; /* setup_data_file */
-
-/*******************************************************************************
-  void set_scalar_var()
-*******************************************************************************/
-void set_field_struct(int ntiles, Field_config *field, int nvar, char * varname, File_config *file)
-{
-  int  n, i;
-  
-  if(nvar == 0) return;
- 
-  for(n=0; n<ntiles; n++) {
-    field[n].file = file[n].name;
-    field[n].fid = &(file[n].fid);
-    field[n].nvar = nvar;
-    field[n].var = (Var_config *)malloc(nvar*sizeof(Var_config)); 
-    for(i=0; i<nvar; i++) 
-      strcpy(field[n].var[i].name, varname+i*STRING);
-  }
-
-}; /* set_field_var */
-
-
-/*******************************************************************************
-  void get_mosaic_grid()
-
-*******************************************************************************/
-void get_input_grid(int ntiles, Grid_config *grid, Bound_config *bound_T, const char *mosaic_file, unsigned int opcode)
-{
-  int         n, m1, m2, i, j, l, ind1, ind2, nlon, nlat;
-  int         ts, tw, tn, te, halo, nbound;
-  int         m_fid, g_fid, vid;
-  int         *nx, *ny;
-  double      *x, *y;
-  char         grid_file[256], filename[256], dir[256];
-  size_t        start[4], nread[4];
-  Data_holder *dHold;
-  Bound_config *bound_C;
-  
-  halo = 0;
-  if(opcode & BILINEAR) halo = 1;
-  for(n=0; n<4; n++) {
-    start[n] = 0; nread[n] = 1;
-  }
-
-  bound_C = (Bound_config *)malloc(ntiles*sizeof(Bound_config));
-  nx = (int *)malloc(ntiles * sizeof(int) );
-  ny = (int *)malloc(ntiles * sizeof(int) );
-
-  m_fid = mpp_open(mosaic_file, MPP_READ);
-  get_file_path(mosaic_file, dir);
-  for(n=0; n<ntiles; n++) {
-    start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-    vid = mpp_get_varid(m_fid, "gridfiles");
-    mpp_get_var_value_block(m_fid, vid, start, nread, filename);
-    sprintf(grid_file, "%s/%s", dir, filename);
-    g_fid = mpp_open(grid_file, MPP_READ);
-    
-    nx[n] = mpp_get_dimlen(g_fid, "nx");
-    ny[n] = mpp_get_dimlen(g_fid, "ny");
-    if(nx[n]%2) mpp_error("fregrid_util(get_input_grid): the size of dimension nx should be even (on supergrid)");
-    if(ny[n]%2) mpp_error("fregrid_util(get_input_grid): the size of dimension ny should be even (on supergrid)");
-    nx[n] /= 2;
-    ny[n] /= 2;
-    grid[n].halo = halo;
-    grid[n].nx   = nx[n];
-    grid[n].ny   = ny[n];
-    grid[n].nxc  = nx[n];
-    grid[n].nyc  = ny[n];
-    
-    /* get supergrid */
-    x = (double *)malloc((2*nx[n]+1)*(2*ny[n]+1)*sizeof(double));
-    y = (double *)malloc((2*nx[n]+1)*(2*ny[n]+1)*sizeof(double));
-
-    vid = mpp_get_varid(g_fid, "x");
-    mpp_get_var_value(g_fid, vid, x);
-    vid = mpp_get_varid(g_fid, "y");
-    mpp_get_var_value(g_fid, vid, y);
-    grid[n].lont = (double *) malloc((nx[n]+2)*(ny[n]+2)*sizeof(double));
-    grid[n].latt = (double *) malloc((nx[n]+2)*(ny[n]+2)*sizeof(double));
-    grid[n].lonc = (double *) malloc((nx[n]+1+2*halo)*(ny[n]+1+2*halo)*sizeof(double));
-    grid[n].latc = (double *) malloc((nx[n]+1+2*halo)*(ny[n]+1+2*halo)*sizeof(double));
-    if(halo>0) {
-      init_halo(grid[n].lonc, nx[n]+1, ny[n]+1, 1, halo);
-      init_halo(grid[n].latc, nx[n]+1, ny[n]+1, 1, halo);
-    }
-    for(j=0; j<=ny[n]; j++) for(i=0; i<=nx[n]; i++) {
-      ind1 = (j+halo)*(nx[n]+1+2*halo)+i+halo;
-      ind2 = 2*j*(2*nx[n]+1)+2*i;
-      grid[n].lonc[ind1] = x[ind2]*D2R;
-      grid[n].latc[ind1] = y[ind2]*D2R;
-    }
-    for(j=0; j<ny[n]; j++) for(i=0; i<nx[n]; i++) {
-      ind1 = (j+1)*(nx[n]+2)+i+1;
-      ind2 = (2*j+1)*(2*nx[n]+1)+2*i+1;
-      grid[n].lont[ind1] = x[ind2]*D2R;
-      grid[n].latt[ind1] = y[ind2]*D2R;
-    }
-    init_halo(grid[n].lont, nx[n], ny[n], 1, 1);
-    init_halo(grid[n].latt, nx[n], ny[n], 1, 1);
-    
-    if(opcode & CONSERVE_ORDER2 || opcode & BILINEAR ) {
-      grid[n].vlon_t = (double *) malloc(3*(nx[n]+2*halo)*(ny[n]+2*halo)*sizeof(double));
-      grid[n].vlat_t = (double *) malloc(3*(nx[n]+2*halo)*(ny[n]+2*halo)*sizeof(double));
-      grid[n].xt     = (double *) malloc((nx[n]+2)*(ny[n]+2)*sizeof(double));
-      grid[n].yt     = (double *) malloc((nx[n]+2)*(ny[n]+2)*sizeof(double));
-      grid[n].zt     = (double *) malloc((nx[n]+2)*(ny[n]+2)*sizeof(double));
-    }
-    /* if vector, need to get rotation angle */
-    /* we assume the grid is orthogonal */
-    if( opcode & VECTOR ) {
-      if( opcode & AGRID) {
-	double *angle;
-      	angle          = (double *) malloc((2*nx[n]+1)*(2*ny[n]+1)*sizeof(double));
-	grid[n].cosrot = (double *) malloc(nx[n]*ny[n]*sizeof(double));	 
-	grid[n].sinrot = (double *) malloc(nx[n]*ny[n]*sizeof(double));
-	vid = mpp_get_varid(g_fid, "angle_dx");
-	mpp_get_var_value(g_fid, vid, angle);
-	grid[n].rotate = 0;
-	for(j=0; j<ny[n]; j++) for(i=0; i<nx[n]; i++) {
-          m1 = j*nx[n]+i;
-	  m2 = (2*j+2)*(2*nx[n]+2)+2*i+2;
-	  grid[n].cosrot[m1] = cos(angle[m2]*D2R);
-	  grid[n].sinrot[m1] = sin(angle[m2]*D2R);
-	  if(fabs(grid[n].sinrot[m1]) > EPSLN) grid[n].rotate = 1;
-	}
-	free(angle);
-      }
-    }
-    free(x);
-    free(y);
-    mpp_close(g_fid);
-  }
-
-  mpp_close(m_fid);
-  
-  /* get the boundary condition */
-  setup_boundary(mosaic_file, ntiles, grid, bound_T, 1, CENTER);
-  if(opcode & BILINEAR)
-    setup_boundary(mosaic_file, ntiles, grid, bound_C, 1, CORNER);
-
-  for(n=0; n<ntiles; n++) {
-    nlon = grid[n].nx;
-    nlat = grid[n].ny;
-    nbound = bound_T[n].nbound;
-    if(nbound > 0 ) {
-      dHold = (Data_holder *)malloc(nbound*sizeof(Data_holder));
-      for(l=0; l<nbound; l++) {
-	dHold[l].data = grid[bound_T[n].tile2[l]].lont;
-	dHold[l].nx = grid[bound_T[n].tile2[l]].nx+2;
-	dHold[l].ny = grid[bound_T[n].tile2[l]].ny+2;
-      }
-      update_halo(nlon+2, nlat+2, 1, grid[n].lont, &(bound_T[n]), dHold );
-      for(l=0; l<nbound; l++) dHold[l].data = grid[bound_T[n].tile2[l]].latt;
-      update_halo(nlon+2, nlat+2, 1, grid[n].latt, &(bound_T[n]), dHold );
-	
-      for(l=0; l<nbound; l++) dHold[l].data = NULL;
-      free(dHold);
-    }
-  }
-  
-  if(opcode & BILINEAR) {
-
-  }
-  
-  /* for bilinear interpolation, need to get cell-center grid */
-  if(opcode & BILINEAR) {
-    /*--- fill the halo of corner cell */
-    for(n=0; n<ntiles; n++) {
-      nlon = grid[n].nx;
-      nlat = grid[n].ny;
-      latlon2xyz((nlon+2)*(nlat+2), grid[n].lont, grid[n].latt, grid[n].xt, grid[n].yt, grid[n].zt);
-      unit_vect_latlon((nlon+2)*(nlat+2), grid[n].lont, grid[n].latt, grid[n].vlon_t, grid[n].vlat_t);
-      nbound = bound_C[n].nbound;
-      if(nbound > 0) {
-	dHold = (Data_holder *)malloc(nbound*sizeof(Data_holder));
-	for(l=0; l<nbound; l++) {
-	  dHold[l].data = grid[bound_C[n].tile2[l]].lonc;
-	  dHold[l].nx   = grid[bound_C[n].tile2[l]].nx + 1 + 2*halo;
-	  dHold[l].ny   = grid[bound_C[n].tile2[l]].ny + 1 + 2*halo;
-	}
-	update_halo(nlon+1+2*halo, nlat+1+2*halo, 1, grid[n].lonc, &(bound_C[n]), dHold);
-	for(l=0; l<nbound; l++) dHold[l].data = grid[bound_C[n].tile2[l]].latc;
-	
-	update_halo(nlon+1+2*halo, nlat+1+2*halo, 1, grid[n].latc, &(bound_C[n]), dHold);
-	for(l=0; l<nbound; l++) dHold[l].data = NULL;
-	free(dHold);
-      }
-    }
-  }
-  else if(opcode & CONSERVE_ORDER2) {
-    double p1[3], p2[3], p3[3], p4[3];
-    
-    for(n=0; n<ntiles; n++) {
-      int is_true = 1;
-      nlon = grid[n].nx;
-      nlat = grid[n].ny;
-      /* calculate dx, dy, area */
-      grid[n].dx     = (double *)malloc(nlon    *(nlat+1)*sizeof(double));
-      grid[n].dy     = (double *)malloc((nlon+1)*nlat    *sizeof(double));
-      grid[n].area   = (double *)malloc(nlon    *nlat    *sizeof(double));
-      grid[n].edge_w = (double *)malloc(         (nlat+1)*sizeof(double));
-      grid[n].edge_e = (double *)malloc(         (nlat+1)*sizeof(double));
-      grid[n].edge_s = (double *)malloc((nlon+1)         *sizeof(double));
-      grid[n].edge_n = (double *)malloc((nlon+1)         *sizeof(double));
-      grid[n].en_n   = (double *)malloc(3*nlon  *(nlat+1)*sizeof(double));
-      grid[n].en_e   = (double *)malloc(3*(nlon+1)*nlat  *sizeof(double));
-      calc_c2l_grid_info(&nlon, &nlat, grid[n].lont, grid[n].latt, grid[n].lonc, grid[n].latc,
-			 grid[n].dx, grid[n].dy, grid[n].area, grid[n].edge_w, grid[n].edge_e,
-			 grid[n].edge_s, grid[n].edge_n, grid[n].en_n, grid[n].en_e,
-			 grid[n].vlon_t, grid[n].vlat_t, &is_true, &is_true, &is_true, &is_true);
-    }
-  }
-
-  if(opcode & BILINEAR) delete_bound_memory(ntiles, bound_C);
-  free(bound_C);
-  free(nx);
-  free(ny);
-}; /* get_input_grid */ 
-
-/*******************************************************************************
-  void get_output_grid_from_mosaic(Mosaic_config *mosaic)
-
-*******************************************************************************/
-void get_output_grid_from_mosaic(int ntiles, Grid_config *grid, const char *mosaic_file, unsigned int opcode)
-{
-  int         n, i, j, ii, jj, npes, layout[2];
-  int         m_fid, g_fid, vid;
-  int         *nx, *ny;
-  double      *x, *y;
-  size_t        start[4], nread[4];
-  char         grid_file[256], filename[256], dir[256];
-  
-  if(opcode & BILINEAR) mpp_error("fregrid_util: for bilinear interpolation, output grid can not got from mosaic file");
-  
-  npes   = mpp_npes();
-  nx = (int *)malloc(ntiles * sizeof(int) );
-  ny = (int *)malloc(ntiles * sizeof(int) );
-
-  for(n=0; n<4; n++) {
-    start[n] = 0;
-    nread[n] = 1;
-  }
-  m_fid = mpp_open(mosaic_file, MPP_READ);
-  get_file_path(mosaic_file, dir);
-  
-  for(n=0; n<ntiles; n++) {
-    start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-    vid = mpp_get_varid(m_fid, "gridfiles");
-    mpp_get_var_value_block(m_fid, vid, start, nread, filename);
-    sprintf(grid_file, "%s/%s", dir, filename);
-    g_fid = mpp_open(grid_file, MPP_READ);
-    nx[n] = mpp_get_dimlen(g_fid, "nx");
-    ny[n] = mpp_get_dimlen(g_fid, "ny");
-    if(nx[n]%2) mpp_error("fregrid_util(get_output_grid_from_mosaic): the size of dimension nx should be even (on supergrid)");
-    if(ny[n]%2) mpp_error("fregrid_util(get_output_grid_from_mosaic): the size of dimension ny should be even (on supergrid)");
-    nx[n] /= 2;
-    ny[n] /= 2;
-    grid[n].nx = nx[n];
-    grid[n].ny = ny[n];
-    /* to be able to reprocessor count, layout need to be set as follwoing */
-    layout[0] = 1;
-    layout[1] = npes;
-    mpp_define_domain2d(grid[n].nx, grid[n].ny, layout, 0, 0, &(grid[n].domain));
-    mpp_get_compute_domain2d(grid[n].domain, &(grid[n].isc), &(grid[n].iec), &(grid[n].jsc), &(grid[n].jec));
-    grid[n].nxc = grid[n].iec - grid[n].isc + 1;
-    grid[n].nyc = grid[n].jec - grid[n].jsc + 1;
-
-    grid[n].lonc  = (double *) malloc((grid[n].nxc+1)*(grid[n].nyc+1)*sizeof(double));
-    grid[n].latc  = (double *) malloc((grid[n].nxc+1)*(grid[n].nyc+1)*sizeof(double));
-    
-    grid[n].lont1D = (double *) malloc(nx[n]*sizeof(double));
-    grid[n].latt1D = (double *) malloc(ny[n]*sizeof(double));
-    grid[n].lonc1D = (double *) malloc((nx[n]+1)*sizeof(double));
-    grid[n].latc1D = (double *) malloc((ny[n]+1)*sizeof(double));
-    x = (double *) malloc((2*nx[n]+1)*(2*ny[n]+1)*sizeof(double));
-    y = (double *) malloc((2*nx[n]+1)*(2*ny[n]+1)*sizeof(double));
-    vid = mpp_get_varid(g_fid, "x");
-    mpp_get_var_value(g_fid, vid, x);
-    vid = mpp_get_varid(g_fid, "y");
-    mpp_get_var_value(g_fid, vid, y);
-    for(j=0; j<=grid[n].nyc; j++) for(i=0; i<=grid[n].nxc; i++) {
-      jj = 2*(j + grid[n].jsc);
-      ii = 2*(i + grid[n].isc);
-      grid[n].lonc[j*(grid[n].nxc+1)+i] = x[jj*(2*nx[n]+1)+ii] * D2R;
-      grid[n].latc[j*(grid[n].nxc+1)+i] = y[jj*(2*nx[n]+1)+ii] * D2R;
-    }
-    for(i=0; i<nx[n]+1; i++) grid[n].lonc1D[i] = x[i] * D2R;
-    for(j=0; j<ny[n]+1; j++) grid[n].latc1D[j] = y[j*(nx[n]+1)] * D2R;
-
-    for(i=0; i<nx[n]; i++) grid[n].lont1D[i] = x[2*nx[n]+1+2*i+1] * D2R;
-    for(j=0; j<ny[n]; j++) grid[n].latt1D[j] = y[(2*j+1)*(2*nx[n]+1) + 1] * D2R;
-    free(x);
-    free(y);
-      
-    /* if vector, need to get rotation angle */
-    /* we assume the grid is orthogonal */
-    if(opcode & VECTOR) {
-      if(opcode & AGRID) {
-	double *angle; 
-	angle          = (double *) malloc((2*nx[n]+1)*(2*ny[n]+1)*sizeof(double));
-	grid[n].cosrot = (double *) malloc(nx[n]*ny[n]*sizeof(double));	 
-	grid[n].sinrot = (double *) malloc(nx[n]*ny[n]*sizeof(double));
-	vid = mpp_get_varid(g_fid, "angle_dx");
-	mpp_get_var_value(g_fid, vid, angle);
-	grid[n].rotate = 0;
-	for(j=0; j<grid[n].nyc; j++) for(i=0; i<grid[n].nxc; i++) {
-	  jj = 2*(j + grid[n].jsc);
-	  ii = 2*(i + grid[n].isc);
-	  grid[n].cosrot[j*grid[n].nxc+i] = cos(angle[jj*(2*nx[n]+1)+ii]*D2R);
-	  grid[n].sinrot[j*grid[n].nxc+i] = sin(angle[jj*(2*nx[n]+1)+ii]*D2R);
-	  if(fabs(grid[n].sinrot[j*grid[n].nxc+i]) > EPSLN) grid[n].rotate = 1;
-	}
-	free(angle);
-      }
-    }
-    mpp_close(g_fid);
-  }
-
-  mpp_close(m_fid);
-  
-  free(nx);
-  free(ny);
-}; /* get_output_grid_from_mosaic*/ 
-
-/*******************************************************************************
-  void get_output_grid_by_size(Mosaic_config *mosaic, int nlon, int nlat, int finer_steps, unsigned int opcode)
-  calculate output grid based on nlon, nlat and finer steps.
-
-*******************************************************************************/
-void get_output_grid_by_size(int ntiles, Grid_config *grid, double lonbegin, double lonend, double latbegin, double latend,
-			     int nlon, int nlat, int finer_steps, int center_y, unsigned int opcode)
-{
-  double      dlon, dlat, lon_fine, lat_fine, lon_range, lat_range;
-  int         nx_fine, ny_fine, i, j, layout[2];
-  int nxc, nyc, ii, jj;
-  
-  if(ntiles !=1) mpp_error("fregrid_utils: ntiles of output mosaic must be 1 for bilinear interpolation");
-  if(finer_steps && !(opcode&BILINEAR)) mpp_error("fregrid_util: finer_steps must be 0 when interp_method is not bilinear");
-  
-  grid->nx      = nlon;
-  grid->ny      = nlat;
-  grid->nx_fine = pow(2,finer_steps)*nlon;
-  grid->ny_fine = pow(2,finer_steps)*(nlat-1)+1;
-  nx_fine       = grid->nx_fine;
-  ny_fine       = grid->ny_fine;
-  lon_range     = lonend - lonbegin;
-  lat_range     = latend - latbegin;
-
-  grid->lont1D = (double *)malloc(nlon*sizeof(double));
-  grid->latt1D = (double *)malloc(nlat*sizeof(double));
-  grid->lonc1D = (double *)malloc((nlon+1)*sizeof(double));
-  grid->latc1D = (double *)malloc((nlat+1)*sizeof(double));
-
-  dlon=lon_range/nlon;
-  for(i=0; i<nlon; i++) grid->lont1D[i]  = (lonbegin + (i + 0.5)*dlon)*D2R;
-  for(i=0; i<=nlon; i++) grid->lonc1D[i] = (lonbegin + i*dlon)*D2R;
-
-  layout[0] = 1;
-  layout[1] = mpp_npes();
-  mpp_define_domain2d(grid->nx, grid->ny, layout, 0, 0, &(grid->domain));
-  mpp_get_compute_domain2d(grid->domain, &(grid->isc), &(grid->iec), &(grid->jsc), &(grid->jec));
-  grid->nxc = grid->iec - grid->isc + 1;
-  grid->nyc = grid->jec - grid->jsc + 1;
-  nxc       = grid->nxc;
-  nyc       = grid->nyc;
-  if(center_y) {
-    dlat=lat_range/nlat;
-    for(j=0; j<nlat; j++) grid->latt1D[j] = (latbegin+(j+0.5)*dlat)*D2R;
-    for(j=0; j<=nlat; j++) grid->latc1D[j] = (latbegin+j*dlat)*D2R;
-  }
-  else {
-    dlat=lat_range/(nlat-1);
-    for(j=0; j<nlat; j++) grid->latt1D[j] = (latbegin+j*dlat)*D2R;
-    for(j=0; j<=nlat; j++) grid->latc1D[j] = (latbegin+(j-0.5)*dlat)*D2R;
-  }
-  
-  if(opcode & BILINEAR) {
-    grid->latt1D_fine = (double *)malloc(ny_fine*sizeof(double));
-    grid->lont   = (double *)malloc(nx_fine*ny_fine*sizeof(double));
-    grid->latt   = (double *)malloc(nx_fine*ny_fine*sizeof(double));
-    grid->xt     = (double *)malloc(nx_fine*ny_fine*sizeof(double));
-    grid->yt     = (double *)malloc(nx_fine*ny_fine*sizeof(double));  
-    grid->zt     = (double *)malloc(nx_fine*ny_fine*sizeof(double));  
-    grid->vlon_t = (double *)malloc(3*nx_fine*ny_fine*sizeof(double));
-    grid->vlat_t = (double *)malloc(3*nx_fine*ny_fine*sizeof(double));  
-
-    dlon = lon_range/nx_fine;
-    for(i=0; i<nx_fine; i++) {
-      lon_fine = (lonbegin + (i + 0.5)*dlon)*D2R;
-      for(j=0; j<ny_fine; j++) grid->lont[j*nx_fine+i] = lon_fine;
-    }
-    if(center_y) {
-      dlat=lat_range/ny_fine;
-      for(j=0; j<ny_fine; j++)grid->latt1D_fine[j] = (latbegin+(j+0.5)*dlat)*D2R;
-    }
-    else {
-      dlat = lat_range/(ny_fine-1);
-      for(j=0; j<ny_fine; j++) grid->latt1D_fine[j] = (latbegin+j*dlat)*D2R;
-     
-    }
-    for(j=0; j<ny_fine; j++) for(i=0; i<nx_fine; i++) {
-      grid->latt[j*nx_fine+i] = grid->latt1D_fine[j];
-    }
-    /* get the cartesian coordinates */  
-    latlon2xyz(nx_fine*ny_fine, grid->lont, grid->latt, grid->xt, grid->yt, grid->zt);
-
-    unit_vect_latlon(nx_fine*ny_fine, grid->lont, grid->latt, grid->vlon_t, grid->vlat_t);
-  
-  }
-  else { /* for conservative interpolation */
-
-    grid->lonc  = (double *) malloc((nxc+1)*(nyc+1)*sizeof(double));
-    grid->latc  = (double *) malloc((nxc+1)*(nyc+1)*sizeof(double));
-    for(j=0; j<=nyc; j++) {
-      jj = j + grid->jsc;
-      for(i=0; i<=nxc; i++) {
-	ii = i + grid->isc;
-	grid->lonc[j*(nxc+1)+i] = grid->lonc1D[ii];
-	grid->latc[j*(nxc+1)+i] = grid->latc1D[jj];
-      }
-    }
-    if(opcode & VECTOR) { /* no rotation is needed for regular lat-lon grid. */
-      grid->rotate = 0;
-    }
-  }
-  
-}; /* get_output_grid_by_size */
-  
-/*******************************************************************************
-  void get_input_metadata(Mosaic_config, *mosaic)
-*******************************************************************************/
-void get_input_metadata(int ntiles, int nfiles, File_config *file1, File_config *file2,
-		        Field_config *scalar, Field_config *u_comp, Field_config *v_comp,
-			const Grid_config *grid, int kbegin, int kend, int lbegin, int lend)
-{
-  int     n, m, i, l, ll, nscalar, nvector, nfield;
-  int     ndim, dimsize[4], nz;
-  nc_type type[4];
-  char    cart[4];
-  char    dimname[4][STRING], bndname[4][STRING], errmsg[STRING];
-  File_config  *file  = NULL;
-  Field_config *field = NULL;
-  size_t start[4], nread[4];
-  
-  /* First find out how many fields in file and file2. */
-  nscalar = 0;
-  nvector = 0;
-  if( scalar) nscalar = scalar->nvar;
-  if( u_comp) nvector = u_comp->nvar;
-
-  for(n=0; n<4; n++) {
-    start[n] = 0; nread[n] = 1;
-  }
-  
-  for(m=0; m<nfiles; m++) {
-    file = m==0? file1:file2;  
-    for(n=0; n<ntiles; n++) {
-      file[n].nt        = 1;
-      file[n].axis      = (Axis_config *)malloc(MAXDIM*sizeof(Axis_config));
-      file[n].ndim      = 0;
-      file[n].has_tavg_info = 0;
-    }
-  }
-             
-  for(l=0; l<nscalar; l++) for(n=0; n<ntiles; n++) {
-    scalar[n].var[l].nz        = 1;
-    scalar[n].var[l].has_zaxis = 0;
-    scalar[n].var[l].has_taxis = 0;
-    scalar[n].var[l].kstart    = 0;
-    scalar[n].var[l].kend      = 0;
-    scalar[n].var[l].lstart    = 0;
-    scalar[n].var[l].lend      = 0;
-  }
-    
-  for(l=0; l<nvector; l++) for(n=0; n<ntiles; n++) {
-    u_comp[n].var[l].nz        = 1;
-    u_comp[n].var[l].has_zaxis = 0;
-    u_comp[n].var[l].has_taxis = 0;
-    u_comp[n].var[l].kstart    = 0;
-    u_comp[n].var[l].kend      = 0;
-    u_comp[n].var[l].lstart    = 0;
-    u_comp[n].var[l].lend      = 0;
-    v_comp[n].var[l].nz        = 1;
-    v_comp[n].var[l].has_zaxis = 0;
-    v_comp[n].var[l].has_taxis = 0;
-    v_comp[n].var[l].kstart    = 0;
-    v_comp[n].var[l].kend      = 0;
-    v_comp[n].var[l].lstart    = 0;
-    v_comp[n].var[l].lend      = 0;   
-  }
-  
-  nfield = (nfiles == 1)? (nscalar+2*nvector):nvector;  /* when nfiles = 2, no scalar */
-  
-  for(m=0; m<nfiles; m++) {
-    file = m==0? file1:file2;
-    for(n=0; n<ntiles; n++) {
-      for(l=0; l<nfield; l++) {
-	if(nfiles == 1) {
-	  if(l<nscalar) {
-	    field = scalar;
-	    ll = l;
-	  }
-	  else if(l<nscalar + nvector) {
-	    field = u_comp;
-	    ll = l - nscalar;
-	  }
-	  else {
-	    field = v_comp;
-	    ll = l - nscalar - nvector;
-	  }
-	}
-	else {
-	  ll = l;
-	  field = (m==0)?u_comp:v_comp;
-	}
-
-      	field[n].var[ll].vid = mpp_get_varid(file[n].fid, field[n].var[ll].name);
-	field[n].var[ll].type  = mpp_get_var_type(file[n].fid, field[n].var[ll].vid);
-        /* check if time_avg_info attribute existed in any variables */
-	if(!file[n].has_tavg_info) {
-	  if(mpp_var_att_exist(file[n].fid, field[n].var[ll].vid, "time_avg_info") ) file[n].has_tavg_info = 1;
-	}
-	ndim = mpp_get_var_ndim(file[n].fid, field[n].var[ll].vid);
-	
-	for(i=0; i<ndim; i++) {
-	  int vid;
-          mpp_get_var_dimname(file[n].fid, field[n].var[ll].vid, i, dimname[i]);
-	  dimsize[i] = mpp_get_dimlen(file[n].fid, dimname[i]);
-	  vid = mpp_get_varid(file[n].fid, dimname[i]);
-	  cart[i] = mpp_get_var_cart(file[n].fid, vid);
-	  type[i] = mpp_get_var_type(file[n].fid, vid);
-	  mpp_get_var_bndname(file[n].fid, vid, bndname[i]);
-      	}
-	field[n].var[ll].ndim = ndim;
-	if(ndim <2 || ndim>4) mpp_error("get_input_metadata(fregrid_util.c): ndim should be no less than 2 and no larger than 4");
-	if(cart[ndim-1] != 'X') mpp_error("get_input_metadata(fregrid_util.c): the last dimension cartesian should be 'X'");
-	if(cart[ndim-2] != 'Y') mpp_error("get_input_metadata(fregrid_util.c): the second last dimension cartesian should be 'Y'");
-	if(dimsize[ndim-1] != grid[n].nx) mpp_error("get_input_metadata(fregrid_util.c): x-size in grid file in not the same as in data file");
-	if(dimsize[ndim-2] != grid[n].ny) mpp_error("get_input_metadata(fregrid_util.c): y-size in grid file in not the same as in data file");	
-	if(cart[0] == 'Z' || cart[1] == 'Z') {
-	  field[n].var[ll].has_zaxis = 1;
-	  field[n].var[ll].nz        = cart[0] == 'Z'? dimsize[0]:dimsize[1];
-	  /* the selected vertical level should be between 1 and nz. */
-	  if(kend > field[n].var[ll].nz) {
-	    sprintf(errmsg, "get_input_metadata(fregrid_util.c): KlevelEnd should be no larger than "
-		    "number of vertical levels of field %s in file %s.", field[n].var[ll].name, file[n].name);
-	    mpp_error(errmsg);
-	  }
-	  if(kbegin>0) {
-	    field[n].var[ll].kstart = kbegin - 1;
-	    field[n].var[ll].kend   = kend - 1;
-	    field[n].var[ll].nz     = kend - kbegin + 1;
-	  }
-	  else {
-	    field[n].var[ll].kstart = 0;
-	    field[n].var[ll].kend   = field[n].var[ll].nz - 1;
-	  }
-	}
-	if(cart[0] == 'T') {
-	  field[n].var[ll].has_taxis = 1;
-	  if(lend > dimsize[0]) {
-	    sprintf(errmsg, "get_input_metadata(fregrid_util.c): LstepEnd should be no larger than "
-		    "number of time levels of field %s in file %s.", field[n].var[ll].name, file[n].name);
-	    mpp_error(errmsg);
-	  }
-	  if(lbegin>0) {
-	    field[n].var[ll].lstart = lbegin - 1;
-	    field[n].var[ll].lend   = lend - 1;
-	    file[n].nt              = lend - lbegin + 1;
-	  }
-	  else {
-	    field[n].var[ll].lstart = 0;
-	    field[n].var[ll].lend   = dimsize[0] - 1;
-	    file[n].nt              = dimsize[0];
-	  }
-	    
-	}
-	for(i=0; i<ndim; i++) {
-	  /* loop through all the file dimensions to see if the dimension already exist or not */
-	  int found, j; 
-	  found = 0;
-	  for(j=0; j<file[n].ndim; j++) {
-	    if(!strcmp(dimname[i], file[n].axis[j].name) ) {
-	      found = 1;
-	      field[n].var[ll].index[i] = j;
-	      break;
-	    }
-	  }
-	  if(!found) {
-	    j                         = file[n].ndim;
-	    field[n].var[ll].index[i] = file[n].ndim;
-	    file[n].ndim++;
-            if(	file[n].ndim > MAXDIM) mpp_error("get_input_metadata(fregrid_util.c):ndim is greater than MAXDIM");
-
-	    file[n].axis[j].cart = cart[i];
-	    file[n].axis[j].type = type[i];
-	    strcpy(file[n].axis[j].name, dimname[i]);
-	    strcpy(file[n].axis[j].bndname, bndname[i]);
-	    file[n].axis[j].vid = mpp_get_varid(file[n].fid, dimname[i]);
-	    if(cart[i] == 'T') {
-	      start[0] = field[n].var[ll].lstart;
-	      file[n].axis[j].size = file[n].nt;
-	    }
-	    else if(cart[i] == 'Z') {
-	      start[0] = field[n].var[ll].kstart;
-	      file[n].axis[j].size = field[n].var[ll].nz;
-	    }
-	    else {
-	      start[0] = 0;
-               file[n].axis[j].size = dimsize[i];
-	    }
-	    file[n].axis[j].data = (double *)malloc(file[n].axis[j].size*sizeof(double));
-	    nread[0] = file[n].axis[j].size;
-	    mpp_get_var_value_block(file[n].fid, file[n].axis[j].vid, start, nread, file[n].axis[j].data);
-	    file[n].axis[j].bndtype = 0;
-	    if(strcmp(bndname[i], "none") ) {
-	      file[n].axis[j].bndid = mpp_get_varid(file[n].fid, bndname[i]);
-	      if(mpp_get_var_ndim(file[n].fid,file[n].axis[j].bndid) == 1) {
-		file[n].axis[j].bndtype = 1;
-		file[n].axis[j].bnddata = (double *)malloc((file[n].axis[j].size+1)*sizeof(double));
-		nread[0] = file[n].axis[j].size+1;
-	      }
-	      else {
-	        file[n].axis[j].bndtype = 2;
-		file[n].axis[j].bnddata = (double *)malloc(2*file[n].axis[j].size*sizeof(double));
-		nread[0] = file[n].axis[j].size; nread[1] = 2;
-	      }
-	      mpp_get_var_value_block(file[n].fid, file[n].axis[j].bndid, start, nread, file[n].axis[j].bnddata);
-	    }
-	  }
-	} /*ndim*/
-      }  /* nvar */
-    } /* ntile */
-    /* make sure the consistency between tiles */
-    for(n=1; n<ntiles; n++) {
-      if(file[n].has_tavg_info != file[0].has_tavg_info)
-	mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for field attribute has_tavg_info");
-      
-      if(file[n].ndim != file[0].ndim)
-	mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for file ndim");
-      for(l=0; l<file[n].ndim; l++) {
-	if(strcmp(file[n].axis[l].name, file[0].axis[l].name) )
-	   mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for file axis name");
-      }
-      for(l=0; l<nscalar+2*nvector; l++) {
-	if(l<nscalar) {
-	  field = scalar;
-	  ll = l;
-	}
-	else if(l<nscalar + nvector) {
-	  field = u_comp;
-	  ll = l - nscalar;
-	}
-	else {
-	  field = v_comp;
-	  ll = l - nscalar - nvector;
-	}      
-	if(field[n].var[ll].ndim != field[0].var[ll].ndim)
-	  mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for var ndim");
-	for(i=0; i<field[n].var[ll].ndim; i++) {  
-	  if(field[n].var[ll].index[i] != field[0].var[ll].index[i])
-	    mpp_error("get_input_metadata(fregrid_util.c): mismatch between tiles for var dimindex");
-	}
-      }
-    }
-    /* close the file and get the tavg_info */
-    for(n=0; n<ntiles; n++) {
-      if(file[n].has_tavg_info) {
-
-	file[n].t1    = (double *)malloc(file[n].nt*sizeof(double));
-	file[n].t2    = (double *)malloc(file[n].nt*sizeof(double));	
-	file[n].dt    = (double *)malloc(file[n].nt*sizeof(double));
-	file[n].id_t1 = mpp_get_varid(file[n].fid, "average_T1");
-	file[n].id_t2 = mpp_get_varid(file[n].fid, "average_T2");
-	file[n].id_dt = mpp_get_varid(file[n].fid, "average_DT");
-	if(lbegin > 0) 
-	  start[0] = lbegin-1;
-	else
-	  start[0] = 0;
-	  nread[0] = file[n].nt; nread[1] = 1; 
-	mpp_get_var_value_block(file[n].fid, file[n].id_t1, start, nread, file[n].t1);
-	mpp_get_var_value_block(file[n].fid, file[n].id_t2, start, nread, file[n].t2);	
-	mpp_get_var_value_block(file[n].fid, file[n].id_dt, start, nread, file[n].dt);
-      }
-    }
-
-  } /*nfile*/
-
-}; /* get_input_metadata */
-  
-
-/*******************************************************************************
-void set_output_metadata ( Mosaic_config *mosaic)
-*******************************************************************************/
-
-void set_output_metadata (int ntiles_in, int nfiles, const File_config *file1_in, const File_config *file2_in,
-			  const Field_config *scalar_in, const Field_config *u_in, const Field_config *v_in,
-			  int ntiles_out, File_config *file1_out, File_config *file2_out, Field_config *scalar_out,
-			  Field_config *u_out, Field_config *v_out, const Grid_config *grid_out,
-			  const char *history, const char *tagname)
-{
-  int m, n, ndim, i, l, dims[4];
-  int dim_bnds, dim_time;
-  int nscalar, nvector;
-  const File_config *file_in = NULL;
-  File_config *file_out = NULL;
-
-  nscalar = 0;
-  nvector = 0;
-  if( scalar_in) nscalar = scalar_in->nvar;
-  if( u_in)      nvector = u_in->nvar;
-  for(n=0; n<ntiles_out; n++) {
-    for(l=0; l<nscalar; l++) {
-      scalar_out[n].var[l].kstart      = scalar_in[0].var[l].kstart;
-      scalar_out[n].var[l].kend        = scalar_in[0].var[l].kend;
-      scalar_out[n].var[l].lstart      = scalar_in[0].var[l].lstart;
-      scalar_out[n].var[l].lend        = scalar_in[0].var[l].lend;
-      scalar_out[n].var[l].nz          = scalar_in[0].var[l].nz;
-      scalar_out[n].var[l].has_zaxis   = scalar_in[0].var[l].has_zaxis;
-      scalar_out[n].var[l].has_taxis   = scalar_in[0].var[l].has_taxis;
-      scalar_out[n].var[l].ndim        = scalar_in[0].var[l].ndim;
-      for(i=0; i<scalar_in[0].var[l].ndim; i++) scalar_out[n].var[l].index[i] = scalar_in[0].var[l].index[i];
-    }
-    
-    for(l=0; l<nvector; l++) {
-      u_out[n].var[l].ndim        = u_in[0].var[l].ndim;
-      v_out[n].var[l].ndim        = v_in[0].var[l].ndim;
-      for(i=0; i<u_in[0].var[l].ndim; i++) u_out[n].var[l].index[i] = u_in[0].var[l].index[i];
-      for(i=0; i<v_in[0].var[l].ndim; i++) v_out[n].var[l].index[i] = v_in[0].var[l].index[i];
-      u_out[n].var[l].kstart      = u_in[0].var[l].kstart;
-      u_out[n].var[l].kend        = u_in[0].var[l].kend;
-      u_out[n].var[l].lstart      = u_in[0].var[l].lstart;
-      u_out[n].var[l].lend        = u_in[0].var[l].lend;
-      u_out[n].var[l].nz          = u_in[0].var[l].nz;
-      u_out[n].var[l].has_zaxis   = u_in[0].var[l].has_zaxis;
-      u_out[n].var[l].has_taxis   = u_in[0].var[l].has_taxis;
-      v_out[n].var[l].kstart      = v_in[0].var[l].kstart;
-      v_out[n].var[l].kend        = v_in[0].var[l].kend;
-      v_out[n].var[l].lstart      = v_in[0].var[l].lstart;
-      v_out[n].var[l].lend        = v_in[0].var[l].lend;
-      v_out[n].var[l].nz          = v_in[0].var[l].nz;
-      v_out[n].var[l].has_zaxis   = v_in[0].var[l].has_zaxis;
-      v_out[n].var[l].has_taxis   = v_in[0].var[l].has_taxis;
-    }
-  }
-  
-  for(m=0; m<nfiles; m++) {
-    file_in  = m==0? file1_in:file2_in;
-    file_out = m==0? file1_out:file2_out;
-    for(n=0; n<ntiles_out; n++) {
-      char tilename[STRING];
-      file_out[n].nt        = file_in[0].nt;
-      ndim                  = file_in[0].ndim;
-      file_out[n].ndim      = ndim;
-      file_out[n].axis      = (Axis_config *)malloc(ndim*sizeof(Axis_config));
-      file_out[n].has_tavg_info = file_in[0].has_tavg_info;
-      
-      for(i=0; i<ndim; i++) {
-	file_out[n].axis[i].cart = file_in[0].axis[i].cart;
-	file_out[n].axis[i].size = file_in[0].axis[i].size;
-	if(file_out[n].axis[i].cart == 'X') file_out[n].axis[i].size = grid_out[n].nx;
-	if(file_out[n].axis[i].cart == 'Y') file_out[n].axis[i].size = grid_out[n].ny;	
-	file_out[n].axis[i].type    = file_in[0].axis[i].type;
-	file_out[n].axis[i].bndtype = file_in[0].axis[i].bndtype;
-	strcpy(file_out[n].axis[i].name, file_in[0].axis[i].name);
-	strcpy(file_out[n].axis[i].bndname, file_in[0].axis[i].bndname);
-      }
-      for(i=0; i<ndim; i++) {
-	file_out[n].axis[i].data = (double *)malloc(file_out[n].axis[i].size*sizeof(double));
-	if( file_out[n].axis[i].cart == 'X' ) {   /* x-axis */
-	  for(l=0; l<file_out[n].axis[i].size; l++) 
-	    file_out[n].axis[i].data[l] = grid_out[n].lont1D[l]*R2D; /* T-cell center */
-	}
-	else if ( file_out[n].axis[i].cart == 'Y') { /* y-axis */
-	  for(l=0; l<file_out[n].axis[i].size; l++) 
-	    file_out[n].axis[i].data[l] = grid_out[n].latt1D[l]*R2D; /* T-cell center */
-	}	  
-	else { /* z or t axis */
-	  for(l=0; l<file_out[n].axis[i].size; l++) 
-	    file_out[n].axis[i].data[l] = file_in[0].axis[i].data[l];
-	}
-	switch( file_out[n].axis[i].bndtype ) {
-	case 1:
-	  file_out[n].axis[i].bnddata = (double *)malloc((file_out[n].axis[i].size+1)*sizeof(double));
-	  if( file_out[n].axis[i].cart == 'X' ) {   /* x-axis */
-	    for(l=0; l<=file_out[n].axis[i].size; l++) file_out[n].axis[i].bnddata[l] = grid_out[n].lonc1D[l]*R2D;
-	  }
-	  else if(file_out[n].axis[i].cart == 'Y') {
-	    for(l=0; l<=file_out[n].axis[i].size; l++) file_out[n].axis[i].bnddata[l  ] = grid_out[n].latc1D[l]*R2D;
-	  }
-	  else {
-	    for(l=0; l<=file_out[n].axis[i].size; l++) file_out[n].axis[i].bnddata[l] = file_in[0].axis[i].bnddata[l];
-	  }
-	  break;
-     	case 2:
-	  file_out[n].axis[i].bnddata = (double *)malloc(2*file_out[n].axis[i].size*sizeof(double));
-	  if( file_out[n].axis[i].cart == 'X' ) {   /* x-axis */
-	    for(l=0; l<file_out[n].axis[i].size; l++) {
-	      file_out[n].axis[i].bnddata[2*l  ] = grid_out[n].lonc[l]*R2D;
-	      file_out[n].axis[i].bnddata[2*l+1] = grid_out[n].lonc[l+1]*R2D;
-	    }
-	  }
-	  else if(file_out[n].axis[i].cart == 'Y') {
-	    for(l=0; l<file_out[n].axis[i].size; l++) {
-	      file_out[n].axis[i].bnddata[2*l  ] = grid_out[n].latc[l]*R2D;
-	      file_out[n].axis[i].bnddata[2*l+1] = grid_out[n].latc[l+1]*R2D;
-	    }
-	  }
-	  else {
-	    for(l=0; l<file_out[n].axis[i].size; l++) {
-	      file_out[n].axis[i].bnddata[2*l  ] = file_in[0].axis[i].bnddata[2*l];
-	      file_out[n].axis[i].bnddata[2*l+1] = file_in[0].axis[i].bnddata[2*l+1];
-	    }
-	  }
-	  break;	  
-	}
-      }
-      if(mpp_pe() == mpp_root_pe()) {
-	file_out[n].fid = mpp_open(file_out[n].name, MPP_WRITE);
-	mpp_copy_global_att(file_in[0].fid, file_out[n].fid);
-	mpp_def_global_att(file_out[n].fid, "history", history);
-	mpp_def_global_att(file_out[n].fid, "code_version", tagname);
-	/* define dim_bnds if bnds axis exist */
-	for(i=0; i<ndim; i++) {
-	  if(file_out[n].axis[i].bndtype == 2) {
-	    dim_bnds = mpp_def_dim(file_out[n].fid, "bnds", 2);
-	    break;
-	  }
-	}
-	for(i=0; i<ndim; i++) {
-	  if(file_out[n].axis[i].cart=='T') {
-	    file_out[n].axis[i].dimid = mpp_def_dim(file_out[n].fid, file_out[n].axis[i].name, NC_UNLIMITED);
-	    dim_time = file_out[n].axis[i].dimid;
-	  }
-	  else
-	    file_out[n].axis[i].dimid = mpp_def_dim(file_out[n].fid, file_out[n].axis[i].name, file_out[n].axis[i].size);
-	  file_out[n].axis[i].vid = mpp_def_var(file_out[n].fid, file_out[n].axis[i].name, file_out[n].axis[i].type, 1,
-						  &(file_out[n].axis[i].dimid), 0);
-	  mpp_copy_var_att(file_in[0].fid, file_in[0].axis[i].vid, file_out[n].fid, file_out[n].axis[i].vid);
-	  switch( file_out[n].axis[i].bndtype ) {
-	  case 1:
-	    dims[0] = mpp_def_dim(file_out[n].fid, file_out[n].axis[i].bndname, file_out[n].axis[i].size+1);
-	    file_out[n].axis[i].bndid = mpp_def_var(file_out[n].fid, file_out[n].axis[i].bndname, file_out[n].axis[i].type, 1, dims , 0);
-	    mpp_copy_var_att(file_in[0].fid, file_in[0].axis[i].bndid, file_out[n].fid, file_out[n].axis[i].bndid);
-	    break;
-	  case 2:
-	    dims[0] = file_out[n].axis[i].dimid;
-	    dims[1] = dim_bnds;
-	    file_out[n].axis[i].bndid = mpp_def_var(file_out[n].fid, file_out[n].axis[i].bndname, file_out[n].axis[i].type, 2, dims , 0);
-	    mpp_copy_var_att(file_in[0].fid, file_in[0].axis[i].bndid, file_out[n].fid, file_out[n].axis[i].bndid);
-	    break;
-	  }
-	    
-	}
-
-	/* define the field meta data */
-	for(l=0; l<nscalar; l++) {
-	  scalar_out[n].var[l].type = scalar_in[0].var[l].type;
-	  for(i=0; i<scalar_out[n].var[l].ndim; i++) dims[i] = file_out[n].axis[scalar_out[n].var[l].index[i]].dimid;
-	  scalar_out[n].var[l].vid = mpp_def_var(file_out[n].fid, scalar_out[n].var[l].name, scalar_out[n].var[l].type,
-						   scalar_out[n].var[l].ndim, dims, 0); 
-	  mpp_copy_var_att(file_in[0].fid, scalar_in[0].var[l].vid, file_out[n].fid, scalar_out[n].var[l].vid);
-	}
-	for(l=0; l<nvector; l++) {
-	  if(m==0) {
-	    u_out[n].var[l].type = u_in[0].var[l].type;
-	    for(i=0; i<u_out[n].var[l].ndim; i++) dims[i] = file_out[n].axis[u_out[n].var[l].index[i]].dimid;
-	    u_out[n].var[l].vid = mpp_def_var(file_out[n].fid, u_out[n].var[l].name, u_out[n].var[l].type,
-			        		u_out[n].var[l].ndim, dims, 0); 
-	    mpp_copy_var_att(file_in[0].fid, u_in[0].var[l].vid, file_out[n].fid, u_out[n].var[l].vid);
-	  }
-	  if(m==1 || nfiles == 1) {
-	    v_out[n].var[l].type = v_in[0].var[l].type;
-	    for(i=0; i<v_out[n].var[l].ndim; i++) dims[i] = file_out[n].axis[v_out[n].var[l].index[i]].dimid;
-	    v_out[n].var[l].vid = mpp_def_var(file_out[n].fid, v_out[n].var[l].name, v_out[n].var[l].type,
-						v_out[n].var[l].ndim, dims, 0); 
-	    mpp_copy_var_att(file_in[0].fid, v_in[0].var[l].vid, file_out[n].fid, v_out[n].var[l].vid);
-	  }
-	}
-	/* define time avg info variables */
-	if(file_out[n].has_tavg_info) {
-	  int ll;
-	  file_out[n].id_t1 = mpp_def_var(file_out[n].fid, "average_T1", NC_DOUBLE, 1, &dim_time, 0);
-	  mpp_copy_var_att(file_in[0].fid, file_in[0].id_t1, file_out[n].fid, file_out[n].id_t1);
-	  file_out[n].id_t2 = mpp_def_var(file_out[n].fid, "average_T2", NC_DOUBLE, 1, &dim_time, 0);
-	  mpp_copy_var_att(file_in[0].fid, file_in[0].id_t2, file_out[n].fid, file_out[n].id_t2);	  
-	  file_out[n].id_dt = mpp_def_var(file_out[n].fid, "average_DT", NC_DOUBLE, 1, &dim_time, 0);
-	  mpp_copy_var_att(file_in[0].fid, file_in[0].id_dt, file_out[n].fid, file_out[n].id_dt);
-	  file_out[n].t1 = (double *)malloc(file_out[n].nt*sizeof(double));
-	  file_out[n].t2 = (double *)malloc(file_out[n].nt*sizeof(double));
-	  file_out[n].dt = (double *)malloc(file_out[n].nt*sizeof(double));
-	  for(ll=0; ll<file_out[n].nt; ll++) {
-	    file_out[n].t1[ll] = file_in[0].t1[ll];
-	    file_out[n].t2[ll] = file_in[0].t2[ll];
-	    file_out[n].dt[ll] = file_in[0].dt[ll];
-	  }
-	}
-	mpp_end_def(file_out[n].fid);
-	for(i=0; i<ndim; i++) {
-	  if(file_out[n].axis[i].cart == 'T') continue;
-	  mpp_put_var_value(file_out[n].fid, file_out[n].axis[i].vid, file_out[n].axis[i].data);
-	  if(strcmp(file_out[n].axis[i].bndname, "none") )
-	    mpp_put_var_value(file_out[n].fid, file_out[n].axis[i].bndid, file_out[n].axis[i].bnddata);
-	}
-      }
-    }
-  }
-  
-}; /* set_output_metadata */
-
-/*******************************************************************************
-   void get_field_missing( )
-   *******************************************************************************/
-void get_field_missing( int ntiles, Field_config *field)
-{
-  int n, l, nfield;
-  char str[128];
-  
-  nfield = field->nvar;
-
-  for(l=0; l<nfield; l++) {
-    for(n=0; n<ntiles; n++) {
-      field[n].var[l].missing = 0;
-      field[n].var[l].vid = mpp_get_varid(*(field[n].fid), field[n].var[l].name);
-      if( field[n].var[l].has_missing = mpp_var_att_exist(*(field[n].fid), field[n].var[l].vid, "missing_value") ) {
-	mpp_get_var_att(*(field[n].fid), field[n].var[l].vid, "missing_value", (void *)(&(field[n].var[l].missing)));
-	//	  field[n].var[l].missing = atof(str);
-      }
-    }
-  }
-
-}; /* get_field_missing */
-
-
-/*******************************************************************************
-void set_remap_file( )
-*******************************************************************************/
-void set_remap_file( int ntiles, const char *mosaic_file, const char *remap_file, Interp_config *interp,
-		     unsigned int *opcode, int save_weight_only)
-{
-  int    i, len, m, fid, vid;
-  size_t start[4], nread[4];
-  char str1[STRING], tilename[STRING];
-  int file_exist;
-  
-  if(!remap_file) return;
-  
-  for(i=0; i<4; i++) {
-    start[i] = 0; nread[i] = 1;
-  }
-  nread[1] = STRING;
-  
-  len = strlen(remap_file);
-  if(len >= STRING) mpp_error("setoutput_remap_file(fregrid_util): length of remap_file should be less than STRING");  
-  if( strstr(remap_file, ".nc") ) {
-    strncpy(str1, remap_file, len-3);
-    str1[len-3] = 0;
-  }
-  else
-    strcpy(str1, remap_file);
-
-  (*opcode) |= WRITE;
-
-  if(ntiles>1) {
-     fid = mpp_open(mosaic_file, MPP_READ);
-     vid   = mpp_get_varid(fid, "gridtiles");
-  }
-  
-  for(m=0; m<ntiles; m++) {
-    interp[m].file_exist = 0;
-    if(ntiles > 1) {
-      start[0] = m;
-      mpp_get_var_value_block(fid, vid, start, nread, tilename);
-      if(strlen(str1) + strlen(tilename) > STRING -5) mpp_error("set_output_remap_file(fregrid_util): length of str1 + "
-								"length of tilename should be no greater than STRING-5");
-      sprintf(interp[m].remap_file, "%s.%s.nc", str1, tilename);
-    }
-    else
-      sprintf(interp[m].remap_file, "%s.nc", str1);
-    /* check xgrid file to be read (=1) or write ( = 2) */
-    if(!save_weight_only && mpp_file_exist(interp[m].remap_file)) {
-      (*opcode) |= READ;
-      interp[m].file_exist = 1;
-    }
-      
-  }
-
-  if(ntiles>1) mpp_close(fid);
-  
-};/* set_remap_file */
-
-
-/*----------------------------------------------------------------------
-  void write_output_axis_data( )
-  write out time axis data of the output data file
-  --------------------------------------------------------------------*/
-void write_output_time(int ntiles, File_config *file, int level)
-{
-  int         i, n;
-  size_t      start[4], nwrite[4];
-
-  for(i=0; i<4; i++) {
-    start[i] = 0; nwrite[i] = 1;
-  }
-  start[0] = level;   
-  if( mpp_pe() == mpp_root_pe()) {
-    for(n=0; n<ntiles; n++) {
-      for(i=0; i<file[n].ndim; i++) {
-	if(file[n].axis[i].cart == 'T') {
-	  nwrite[1] = 1;
-	  mpp_put_var_value_block(file[n].fid, file[n].axis[i].vid, start,
-				 nwrite, &(file[n].axis[i].data[level]));
-	  if(strcmp(file[n].axis[i].bndname, "none") ) {
-	    nwrite[1] = 2;
-	    mpp_put_var_value_block(file[n].fid, file[n].axis[i].bndid, start,
-				   nwrite, &(file[n].axis[i].bnddata[level*2]));
-	  }
-	}
-      }
-      /* write out time_avg_info if exist */
-      if(file[n].has_tavg_info) {
-	nwrite[1] = 1;
-	mpp_put_var_value_block(file[n].fid, file[n].id_t1, start, nwrite, &(file[n].t1[level]) );
-	mpp_put_var_value_block(file[n].fid, file[n].id_t2, start, nwrite, &(file[n].t2[level]) );
-	mpp_put_var_value_block(file[n].fid, file[n].id_dt, start, nwrite, &(file[n].dt[level]) );
-      }
-    }
-  }
-}; /* write_output_time */
-
-/*---------------------------------------------------------------------------
-  void get_input_data(Mosaic_config *input, int l)
-  get the input data for the number l variable.
-  -------------------------------------------------------------------------*/
-void get_input_data(int ntiles, Field_config *field, Grid_config *grid, Bound_config *bound,
-		    int varid, int level, unsigned int opcode)
-{
-  int         halo, i, j, k, i1, i2, n, memsize, nx, ny, nz, ndim, nbound, l;
-  size_t      start[4], nread[4];
-  double      *data;
-  Data_holder *dHold;
-
-  if(opcode & CONSERVE_ORDER1)
-    halo = 0;
-  else
-    halo = 1;
-  nz = field->var[varid].nz;
-  
-  for(i=0; i<4; i++) {
-    start[i] = 0; nread[i] = 1;
-  }
-  start[0] = level;
-
-  /* first read input data for each tile */
-  for(n=0; n<ntiles; n++) {
-    nx = grid[n].nx;
-    ny = grid[n].ny;
-    memsize = 1;
-    ndim = field[n].var[varid].ndim;
-    nread[ndim-1] = nx;
-    nread[ndim-2] = ny;
-    if(field[n].var[varid].has_zaxis) {
-      start[ndim-3] = field->var[varid].kstart;
-      nread[ndim-3] = nz;
-    }
-    memsize = (nx+2*halo)*(ny+2*halo)*nz;
-	
-    field[n].data = (double *)malloc(memsize*sizeof(double));
-    if(halo ==0) {
-      mpp_get_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nread, field[n].data);
-    }
-    else {
-      data = (double *)malloc(nx*ny*nz*sizeof(double));
-      mpp_get_var_value_block(*(field[n].fid), field[n].var[varid].vid, start, nread, data);
-      init_halo(field[n].data, nx, ny, nz, 1);
-
-      /* copy the data onto compute domain */
-      for(k=0; k<nz; k++) for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	i1 = k*(nx+2*halo)*(ny+2*halo)+(j+halo)*(nx+2*halo)+i+halo;
-	i2 = k*nx*ny+j*nx+i;
-	field[n].data[i1] = data[i2];
-      }
-      free(data);
-    }
-  }  
-
-  /* update halo when halo > 0 */
-  if(halo > 0) {
-    for(n=0; n<ntiles; n++) {
-      nbound = bound[n].nbound;
-      if(nbound > 0) {
-	dHold = (Data_holder *)malloc(nbound*sizeof(Data_holder));
-	for(l=0; l<nbound; l++) {
-	  dHold[l].data = field[bound[n].tile2[l]].data;
-	  dHold[l].nx = grid[bound[n].tile2[l]].nx+2;
-	  dHold[l].ny = grid[bound[n].tile2[l]].ny+2;
-	}
-	update_halo(grid[n].nx+2, grid[n].ny+2, nz, field[n].data, &(bound[n]), dHold );
-	for(l=0; l<nbound; l++) dHold[l].data = NULL;
-	free(dHold);
-      }
-    }
-    /* second order conservative interpolation, gradient need to be calculated */
-    if(opcode & CONSERVE_ORDER2) {
-      for(n=0; n<ntiles; n++) {
-	int is_true = 1;
-	nx = grid[n].nx;
-	ny = grid[n].ny;
-	field[n].grad_x = (double *)malloc(nx*ny*nz*sizeof(double));
-	field[n].grad_y = (double *)malloc(nx*ny*nz*sizeof(double));
-	for(k=0; k<nz; k++) {
-	  grad_c2l(&(grid[n].nx), &(grid[n].ny), field[n].data+k*(nx+2)*(ny+2), grid[n].dx, grid[n].dy, grid[n].area,
-		   grid[n].edge_w, grid[n].edge_e, grid[n].edge_s, grid[n].edge_n,
-		   grid[n].en_n, grid[n].en_e, grid[n].vlon_t, grid[n].vlat_t, 
-		   field[n].grad_x+k*nx*ny, field[n].grad_y+k*nx*ny, &is_true, &is_true, &is_true, &is_true);
-	}
-	/* where there is missing and using second order conservative interpolation, need to calculate mask for gradient */
-	if( field[n].var[varid].has_missing ) {
-	  int ip1, im1, jp1, jm1,kk,ii,jj;
-	  double missing;
-	  missing = field[n].var[varid].missing;
-	  field[n].grad_mask = (int *)malloc(nx*ny*nz*sizeof(int));
-	  for(k=0; k<nz; k++) for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	    ii=i+1; ip1 = ii+1; im1 = ii-1; jj = j+1; jp1 = jj+1; jm1 = jj-1;
-	    kk = k*(nx+2)*(ny+2);
-	    if(field[n].data[kk+jm1*(nx+2)+im1] == missing || field[n].data[kk+jm1*(nx+2)+ii ] == missing ||
-	       field[n].data[kk+jm1*(nx+2)+ip1] == missing || field[n].data[kk+jj *(nx+2)+im1] == missing ||
-	       field[n].data[kk+jj *(nx+2)+ip1] == missing || field[n].data[kk+jp1*(nx+2)+im1] == missing ||
-	       field[n].data[kk+jp1*(nx+2)+ii ] == missing || field[n].data[kk+jp1*(nx+2)+ip1] == missing  )
-	      field[n].grad_mask[k*nx*ny+j*nx+i] = 1;
-	    else
-	      field[n].grad_mask[k*nx*ny+j*nx+i] = 0;
-	  }
-	}
-      }
-    }
-  }
-
-
-  
-}; /* get_input_data */
-
-/*---------------------------------------------------------------------------
-  void get_input_data(Mosaic_config *input, int l)
-  get the input data for the number l variable.
-  -------------------------------------------------------------------------*/
-void get_test_input_data(char *test_case, double test_param, int ntiles, Field_config *field,
-			 Grid_config *grid, Bound_config *bound, unsigned int opcode)
-{
-  int         halo, i, j, k, ii, n, nx, ny, l, nbound;
-  double      *data;
-  Data_holder *dHold;
-  char input_file[128];
-  int  fid, vid, dim[2]; 
-  
-  if(opcode & CONSERVE_ORDER1)
-    halo = 0;
-  else
-    halo = 1;
-  
-  for(n=0; n<ntiles; n++) {
-    nx = grid[n].nx;
-    ny = grid[n].ny;
-    field[n].data = (double *)malloc((nx+2*halo)*(ny+2*halo)*sizeof(double));
-    data          = (double *)malloc(nx*ny*sizeof(double));
-    if(!strcmp(test_case,"tanh_cosphi_costheta") ) {
-      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	data[j*ny+i] = tanh(test_param*cos(grid[n].lont[(j+1)*(nx+2)+i+1])*cos(grid[n].latt[(j+1)*(nx+2)+i+1]));
-      }
-    }
-    if(!strcmp(test_case,"tanh_sinphi_sintheta") ) {
-      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	data[j*ny+i] = tanh(test_param*sin(grid[n].lont[(j+1)*(nx+2)+i+1])*sin(grid[n].latt[(j+1)*(nx+2)+i+1]));
-      }
-    }    
-    else if(!strcmp(test_case,"cosphi_costheta") ) {
-      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	data[j*ny+i] = cos(grid[n].lont[(j+1)*(nx+2)+i+1])*cos(grid[n].latt[(j+1)*(nx+2)+i+1]);
-      }
-    }
-    else if(!strcmp(test_case,"sinphi_costheta") ) {
-      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	data[j*ny+i] = sin(grid[n].lont[(j+1)*(nx+2)+i+1])*cos(grid[n].latt[(j+1)*(nx+2)+i+1]);
-      }
-    }
-    else
-      mpp_error("fregrid_util: invalid choice of test_case");
-
-    /* write out input data */
-    sprintf(input_file, "%s.input.tile%d.nc", test_case, n+1);
-    fid = mpp_open(input_file, MPP_WRITE);
-    dim[0] = mpp_def_dim(fid, "grid_y", ny);
-    dim[1] = mpp_def_dim(fid, "grid_x", nx);
-    vid    = mpp_def_var(fid, "data", NC_DOUBLE, 2, dim, 0);
-    mpp_end_def(fid);
-    mpp_put_var_value(fid, vid, data);
-    mpp_close(fid);
-    
-    for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-      ii = (j+halo)*(nx+2*halo)+i+halo;
-      field[n].data[ii] = data[j*nx+i];
-    }
-    free(data);
-  }
-    
-  /* update halo when halo > 0 */
-  if(halo > 0) {
-    for(n=0; n<ntiles; n++) {
-      nbound = bound[n].nbound;
-      if(nbound > 0) {
-	dHold = (Data_holder *)malloc(nbound*sizeof(Data_holder));
-	for(l=0; l<nbound; l++) {
-	  dHold[l].data = field[bound[n].tile2[l]].data;
-	  dHold[l].nx = grid[bound[n].tile2[l]].nx+2;
-	  dHold[l].ny = grid[bound[n].tile2[l]].ny+2;
-	}
-	update_halo(grid[n].nx+2, grid[n].ny+2, 1, field[n].data, &(bound[n]), dHold );
-	for(l=0; l<nbound; l++) dHold[l].data = NULL;
-	free(dHold);
-      }
-    }
-    /* second order conservative interpolation, gradient need to be calculated */
-    if(opcode & CONSERVE_ORDER2) {
-      for(n=0; n<ntiles; n++) {
-	int is_true = 1;
-	field[n].grad_x = (double *)malloc((grid[n].nx+2)*(grid[n].ny+2)*sizeof(double));
-	field[n].grad_y = (double *)malloc((grid[n].nx+2)*(grid[n].ny+2)*sizeof(double));
-	grad_c2l(&(grid[n].nx), &(grid[n].ny), field[n].data, grid[n].dx, grid[n].dy, grid[n].area,
-		 grid[n].edge_w, grid[n].edge_e, grid[n].edge_s, grid[n].edge_n,
-		 grid[n].en_n, grid[n].en_e, grid[n].vlon_t, grid[n].vlat_t,
-		 field[n].grad_x, field[n].grad_y, &is_true, &is_true, &is_true, &is_true);
-      }
-    }
-  }
-  
-}; /* get_test_input_data */
-
-
-void allocate_field_data(int ntiles, Field_config *field, Grid_config *grid, int l)
-{
-  int n, i;
-  size_t memsize;
-  
-  for(n=0; n<ntiles; n++) {
-    memsize = grid[n].nx*grid[n].ny*field[n].var[l].nz;
-    field[n].data = (double *)malloc(memsize*sizeof(double));
-  }
-
-}; /* allocate_field_data */
-
-
-/*-------------------------------------------------------------------------
-  write_output_data(Mosaic_config *output)
-  write data to output file
-  -----------------------------------------------------------------------*/
-void write_field_data(int ntiles, Field_config *field, Grid_config *grid, int l, int level)
-{
-  double *gdata;
-  int    nx, ny, nz, n, ndim, i, j, k;
-  size_t nwrite[4], start[4];
-
-  nz = field->var[l].nz;
-  for(i=0; i<4; i++) {
-    start[i] = 0; nwrite[i] = 1;
-  }
-  start[0] = level;      
-  for(n=0; n<ntiles; n++) {
-    /* global data onto root pe */
-    nx = grid[n].nx;
-    ny = grid[n].ny;
-    
-    ndim = field[n].var[l].ndim;
-    nwrite[ndim-1] = nx;
-    nwrite[ndim-2] = ny;
-    if(field[n].var[l].has_zaxis) nwrite[ndim-3] = nz;
-    if(mpp_npes() == 1) {
-      mpp_put_var_value_block(*(field[n].fid), field[n].var[l].vid, start, nwrite, field[n].data);
-    }
-    else {
-      gdata = (double *)malloc(nx*ny*nz*sizeof(double));
-      mpp_global_field_double_3D(grid[n].domain, grid[n].nxc, grid[n].nyc, nz,
-				 field[n].data, gdata);
-      /*     for(k=0; k<nz; k++) { */
-      /*      mpp_global_field_double(grid[n].domain, grid[n].nxc, grid[n].nyc, */
-      /* 			      field[n].data+k*grid[n].nxc*grid[n].nyc, gdata+k*nx*ny); */
-      /*    } */
-    
-      if(mpp_pe() == mpp_root_pe())mpp_put_var_value_block(*(field[n].fid), field[n].var[l].vid,
-							   start, nwrite, gdata);
-      free(gdata);
-    }
-  }  
-
-};/* write_output_data */
-
-void get_contact_direction(int ncontact, const int *tile, const int *istart, const int *iend,
-			   const int *jstart, const int *jend, int *dir)
-{
-  int n;
-   
-  for(n=0; n<ncontact; n++) {
-    if(istart[n] == iend[n] && jstart[n] == jend[n])
-      mpp_error("fregrid_util: istart = iend and jstart = jend can not be both true for one contact");
-    if(istart[n] != iend[n] && jstart[n] != jend[n])
-      mpp_error("fregrid_util: either istart = iend or jstart = jend need to be true");
-    if(istart[n] == iend[n]) {
-      if(istart[n] == 0)
-	dir[n] = WEST;
-      else
-	dir[n] = EAST;
-    }
-    else {
-      if(jstart[n] == 0)
-	dir[n] = SOUTH;
-      else
-	dir[n] = NORTH;
-    }
-  }
-
-}
-
-void setup_boundary(const char *mosaic_file, int ntiles, Grid_config *grid, Bound_config *bound, int halo, int position)
-{
-  int ncontacts, shift, n, nbound, l, l2, nb, nx, ny;
-  int *tile, *dir;
-  int *istart, *iend, *jstart, *jend;
-
-  ncontacts = read_mosaic_ncontacts(mosaic_file);
-  if(ncontacts == 0) {
-    for(n=0; n<ntiles; n++) bound[n].nbound = 0;
-    return;
-  }
-
-  if(position == CENTER)
-    shift = 0;
-  else if(position == CORNER)
-    shift = 1;
-  else
-    mpp_error("fregrid_util: position should be CENTER or CORNER");
-  
-  tile   = (int *)malloc(2*ncontacts*sizeof(int));
-  istart = (int *)malloc(2*ncontacts*sizeof(int));
-  iend   = (int *)malloc(2*ncontacts*sizeof(int));
-  jstart = (int *)malloc(2*ncontacts*sizeof(int));
-  jend   = (int *)malloc(2*ncontacts*sizeof(int));
-  dir    = (int *)malloc(2*ncontacts*sizeof(int));
-  read_mosaic_contact(mosaic_file, tile, tile+ncontacts, istart, iend, jstart, jend,
-		      istart+ncontacts, iend+ncontacts, jstart+ncontacts, jend+ncontacts);
-  for(n=0; n<2*ncontacts; n++) --tile[n];
-  get_contact_direction(2*ncontacts, tile, istart, iend, jstart, jend, dir);
-  
-  /* First find number of boundary for each tile */
-  for(n=0; n<ntiles; n++) {
-    nbound = 0;
-    nx = grid[n].nx;
-    ny = grid[n].ny;
-    for(l=0; l<2*ncontacts; l++) {
-      if(tile[l] == n) nbound++;
-    }
-    bound[n].nbound = nbound;
-    if(nbound > 0) {
-      bound[n].is1    = (int *)malloc(nbound*sizeof(int));
-      bound[n].ie1    = (int *)malloc(nbound*sizeof(int));
-      bound[n].js1    = (int *)malloc(nbound*sizeof(int));
-      bound[n].je1    = (int *)malloc(nbound*sizeof(int));
-      bound[n].is2    = (int *)malloc(nbound*sizeof(int));
-      bound[n].ie2    = (int *)malloc(nbound*sizeof(int));
-      bound[n].js2    = (int *)malloc(nbound*sizeof(int));
-      bound[n].je2    = (int *)malloc(nbound*sizeof(int));      
-      bound[n].rotate = (int *)malloc(nbound*sizeof(int));
-      bound[n].tile2  = (int *)malloc(nbound*sizeof(int));
-      nb = 0;
-      for(l=0; l<2*ncontacts; l++) {
-	if(tile[l] != n) continue;
-	switch(dir[l]) {
-	case WEST:
-	  bound[n].is1[nb]  = 0;
-	  bound[n].ie1[nb]  = halo-1;
-	  bound[n].js1[nb]  = min(jstart[l],jend[l])+halo;
-	  bound[n].je1[nb]  = max(jstart[l],jend[l])+halo+shift;
-	  break;
-	case EAST:
-	  bound[n].is1[nb]  = nx+shift+halo;
-	  bound[n].ie1[nb]  = nx+shift+halo+halo-1;
-	  bound[n].js1[nb]  = min(jstart[l],jend[l])+halo;
-	  bound[n].je1[nb]  = max(jstart[l],jend[l])+halo+shift;
-	  break;
-	case SOUTH:
-	  bound[n].is1[nb]  = min(istart[l],iend[l])+halo;
-	  bound[n].ie1[nb]  = max(istart[l],iend[l])+halo+shift;
-	  bound[n].js1[nb]  = 0;
-	  bound[n].je1[nb]  = halo-1;
-	  break;
-	case NORTH:
-	  bound[n].is1[nb]  = min(istart[l],iend[l])+halo;
-	  bound[n].ie1[nb]  = max(istart[l],iend[l])+halo+shift;
-	  bound[n].js1[nb]  = ny+shift+halo;
-	  bound[n].je1[nb]  = ny+shift+halo+halo-1;
-	  break;	    
-	}
-	l2 = (l+ncontacts)%(2*ncontacts);
-	bound[n].tile2[nb] = tile[l2];
-	switch(dir[l2]) {
-	case WEST:
-	  bound[n].is2[nb]  = halo+shift;
-	  bound[n].ie2[nb]  = halo+shift+halo-1;
-	  bound[n].js2[nb]  = min(jstart[l2],jend[l2])+halo;
-	  bound[n].je2[nb]  = max(jstart[l2],jend[l2])+halo+shift;
-	  break;
-	case EAST:
-	  bound[n].is2[nb]  = nx-halo+1;
-	  bound[n].ie2[nb]  = nx;
-	  bound[n].js2[nb]  = min(jstart[l2],jend[l2])+halo;
-	  bound[n].je2[nb]  = max(jstart[l2],jend[l2])+halo+shift;
-	  break;
-	case SOUTH:
-	  bound[n].is2[nb]  = min(istart[l2],iend[l2])+halo;
-	  bound[n].ie2[nb]  = max(istart[l2],iend[l2])+halo+shift;
-	  bound[n].js2[nb]  = halo+shift;
-	  bound[n].je2[nb]  = halo+shift+halo-1;
-	  break;
-	case NORTH:
-	  bound[n].is2[nb]  = min(istart[l2],iend[l2])+halo;
-	  bound[n].ie2[nb]  = max(istart[l2],iend[l2])+halo+shift;
-	  bound[n].js2[nb]  = ny-halo+1;
-	  bound[n].je2[nb]  = ny;
-	  break;	    
-	}
-	bound[n].rotate[nb] = ZERO;
-	if(dir[l] == WEST && dir[l2] == NORTH) bound[n].rotate[nb] = NINETY;
-	if(dir[l] == EAST && dir[l2] == SOUTH) bound[n].rotate[nb]= NINETY;
-	if(dir[l] == SOUTH && dir[l2] == EAST) bound[n].rotate[nb] = MINUS_NINETY;
-	if(dir[l] == NORTH && dir[l2] == WEST) bound[n].rotate[nb] = MINUS_NINETY;      
-	if(dir[l] == NORTH && dir[l2] == NORTH) bound[n].rotate[nb] = ONE_HUNDRED_EIGHTY;
-	/* make sure the size match at the boundary */
-	if( (bound[n].ie2[nb]-bound[n].is2[nb]+1)*(bound[n].je2[nb]-bound[n].js2[nb]+1) !=
-	    (bound[n].ie1[nb]-bound[n].is1[nb]+1)*(bound[n].je1[nb]-bound[n].js1[nb]+1) )
-	  mpp_error("fregrid_util: size mismatch between the boundary");
-	nb++;
-      }      
-    }
-  }
-}; /* setup_boundary */
-
-void delete_bound_memory(int ntiles, Bound_config *bound)
-{
-  int n;
-  
-  for(n=0; n<ntiles; n++) {
-    if(bound[n].nbound > 0) {
-      free(bound[n].is1);
-      free(bound[n].ie1);
-      free(bound[n].js1);
-      free(bound[n].je1);
-      free(bound[n].is2);
-      free(bound[n].ie2);
-      free(bound[n].js2);
-      free(bound[n].je2);
-      free(bound[n].tile2);
-      free(bound[n].rotate);
-    }
-  }
-}
-  
-
-/*-----------------------------------------------------------------------------
-  void init_halo(double *var, int nx, int ny, int nz, int halo)
-  initialze the halo data to be zero.
-  ---------------------------------------------------------------------------*/
-void init_halo(double *var, int nx, int ny, int nz, int halo)
-{
-  int i, j, k;
-  int nxd, nyd, nall;
-
-  nxd = nx+2*halo;
-  nyd = ny+2*halo;
-  nall = nxd*nyd;
-  
-  for(k=0; k<nz; k++) {
-    for(j=0; j<nyd; j++) for(i=0; i<halo; i++) var[k*nall+j*nxd+i] = 0; /* west halo */
-    for(j=0; j<nyd; j++) for(i=nx+halo; i<nxd; i++) var[k*nall+j*nxd+i] = 0; /* east halo */
-    for(j=0; j<halo; j++) for(i=0; i<nxd; i++) var[k*nall+j*nxd+i] = 0; /* south halo */
-    for(j=ny+halo; j<nyd; j++) for(i=0; i<nxd; i++) var[k*nall+j*nxd+i] = 0; /* north halo */
-  }
-
-};/* init_halo */
-
- 
-void update_halo(int nx, int ny, int nz, double *data, Bound_config *bound, Data_holder *dHold)
-{
-  int nbound, n, i, j, k, l, size1, size2, nx2, ny2;
-  int is1, ie1, js1, je1, is2, ie2, js2, je2, bufsize;
-  double *buffer;
-  
-  nbound = bound->nbound;
-  size1  = nx*ny;
-
-  for(n=0; n<nbound; n++) {
-    is1 = bound->is1[n];
-    ie1 = bound->ie1[n];
-    js1 = bound->js1[n];
-    je1 = bound->je1[n];
-    is2 = bound->is2[n];
-    ie2 = bound->ie2[n];
-    js2 = bound->js2[n];
-    je2 = bound->je2[n];
-    nx2 = dHold[n].nx;
-    ny2 = dHold[n].ny;
-    size2 = nx2*ny2;
-    bufsize = nz*(ie2-is2+1)*(je2-js2+1);
-    buffer = (double *)malloc(bufsize*sizeof(double));
-    /* fill the buffer */
-    l = 0;
-    switch(bound->rotate[n]) {
-    case ZERO:
-      for(k=0; k<nz; k++) for(j=js2; j<=je2; j++) for(i=is2; i<=ie2; i++) buffer[l++] = dHold[n].data[k*size2+j*nx2+i];
-      break;
-    case NINETY:
-      for(k=0; k<nz; k++) for(i=ie2; i>=is2; i--) for(j=js2; j<=je2; j++) buffer[l++] = dHold[n].data[k*size2+j*nx2+i];
-      break;
-    case MINUS_NINETY:
-      for(k=0; k<nz; k++) for(i=is2; i<=ie2; i++) for(j=je2; j>=js2; j--) buffer[l++] = dHold[n].data[k*size2+j*nx2+i];
-      break;
-    case ONE_HUNDRED_EIGHTY:
-      for(k=0; k<nz; k++) for(j=je2; j>=js2; j--) for(i=ie2; i>=is2; i--) buffer[l++] = dHold[n].data[k*size2+j*nx2+i];
-      break;
-    }
-    l = 0;
-    for(k=0; k<nz; k++) for(j=js1; j<=je1; j++) for(i=is1; i<=ie1; i++) data[k*size1+j*nx+i] = buffer[l++];
-    free(buffer);
-  }  
-
-}
- 
diff --git a/gridspec_tools_20080702/tools/shared/get_contact.c b/gridspec_tools_20080702/tools/shared/get_contact.c
deleted file mode 100644
index 43a977a..0000000
--- a/gridspec_tools_20080702/tools/shared/get_contact.c
+++ /dev/null
@@ -1,326 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-#include "mosaic_util.h"
-#include "get_contact.h"
-
-
-/************************************************************************************************
-         int get_align_contact(
-  This routine will return number of algined contacts bewteen two tiles (line contact).
-  This routine assume the starting and ending points of the  contact line are coincidence with
-  the grid points of both tiles. lrg_rectangle tiles are assumed. 
-  It will return the contact information, which includes 
-
-*************************************************************************************************/
-
-double* east_bound(const double *data, int nx, int ny);
-double* west_bound(const double *data, int nx, int ny);
-double* south_bound(const double *data, int nx, int ny);
-double* north_bound(const double *data, int nx, int ny);
-#define EPSLN (1.0e-10)
-
-int get_align_contact(int tile1, int tile2, int nx1, int ny1, int nx2, int ny2, 
-                      const double *x1, const double *y1, const double *x2, 
-                      const double *y2, double periodx, double periody,
-		      int *istart1, int *iend1, int *jstart1, int *jend1, 
-                      int *istart2, int *iend2, int *jstart2, int *jend2)
-{
-  double *xb1, *yb1, *xb2, *yb2;
-  int ncontact, start1, end1, start2, end2;
-  
-  ncontact = 0;
-  /* East bound of tile1 and west bound of tile2 */
-  xb1 = east_bound(x1, nx1, ny1);
-  yb1 = east_bound(y1, nx1, ny1);
-  xb2 = west_bound(x2, nx2, ny2);
-  yb2 = west_bound(y2, nx2, ny2);
-  if( get_contact_index( ny1, ny2, xb1, yb1, xb2, yb2, periodx, 0.0, &start1, &end1, &start2, &end2) ) {
-    istart1[ncontact] = nx1-1;
-    iend1[ncontact]   = nx1-1;
-    istart2[ncontact] = 1;
-    iend2[ncontact]   = 1;    
-    jstart1[ncontact] = start1;
-    jend1[ncontact]   = end1;
-    jstart2[ncontact] = start2;
-    jend2[ncontact]   = end2;
-    ncontact++;   
-  }
-
-  /* East bound of tile1 and SOUTH bound of tile2, tile1 and tile must be different tile */
-  if(tile1 != tile2) {
-    free(xb2);
-    free(yb2);
-    xb2 = south_bound(x2, nx2, ny2);
-    yb2 = south_bound(y2, nx2, ny2);
-    if( get_contact_index( ny1, nx2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = nx1-1;
-      iend1[ncontact]   = nx1-1;
-      istart2[ncontact] = start2;
-      iend2[ncontact]   = end2;    
-      jstart1[ncontact] = start1;
-      jend1[ncontact]   = end1;
-      jstart2[ncontact] = 1;
-      jend2[ncontact]   = 1;
-      ncontact++;
-    }
-  }
-  free(xb1);
-  free(yb1);   
-  free(xb2);
-  free(yb2);  
-  
-  /* South bound of tile1 and NORTH bound of tile2 */
-  xb1 = south_bound(x1, nx1, ny1);
-  yb1 = south_bound(y1, nx1, ny1);
-  xb2 = north_bound(x2, nx2, ny2);
-  yb2 = north_bound(y2, nx2, ny2);
-  if( get_contact_index( nx1, nx2, xb1, yb1, xb2, yb2, 0.0, periody, &start1, &end1, &start2, &end2) ) {
-    istart1[ncontact] = start1;
-    iend1[ncontact]   = end1;
-    istart2[ncontact] = start2;
-    iend2[ncontact]   = end2;    
-    jstart1[ncontact] = 1;
-    jend1[ncontact]   = 1;
-    jstart2[ncontact] = ny2-1;
-    jend2[ncontact]   = ny2-1;
-    ncontact++;
-  }
-
-  /* South bound of tile1 and East bound of tile2, tile1 and tile must be different tile*/  
-  if(tile1 != tile2 ) {
-    free(xb2);
-    free(yb2);
-    xb2 = east_bound(x2, nx2, ny2);
-    yb2 = east_bound(y2, nx2, ny2);
-    if( get_contact_index( nx1, ny2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = start1;
-      iend1[ncontact]   = end1;
-      istart2[ncontact] = nx2-1;
-      iend2[ncontact]   = nx2-1;    
-      jstart1[ncontact] = 1;
-      jend1[ncontact]   = 1;
-      jstart2[ncontact] = start2;
-      jend2[ncontact]   = end2;
-      ncontact++;
-    }
-  }
-  free(xb1);
-  free(yb1);   
-  free(xb2);
-  free(yb2);  
-
-  /* to avoid duplicate, the following will be done only when tile1 not equal to tile2 */
-  if(tile1 != tile2) {
-    /* West bound of tile1 and east bound of tile2*/
-    xb1 = west_bound(x1, nx1, ny1);
-    yb1 = west_bound(y1, nx1, ny1);
-    xb2 = east_bound(x2, nx2, ny2);
-    yb2 = east_bound(y2, nx2, ny2);
-    if( get_contact_index( ny1, ny2, xb1, yb1, xb2, yb2, periodx, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = 1;
-      iend1[ncontact]   = 1;
-      istart2[ncontact] = nx2-1;
-      iend2[ncontact]   = nx2-1;    
-      jstart1[ncontact] = start1;
-      jend1[ncontact]   = end1;
-      jstart2[ncontact] = start2;
-      jend2[ncontact]   = end2;
-      ncontact++;
-    }
-    free(xb2);
-    free(yb2);
-
-    /* West bound of tile1 and North bound of tile2 */  
-    xb2 = north_bound(x2, nx2, ny2);
-    yb2 = north_bound(y2, nx2, ny2);
-    if( get_contact_index( ny1, nx2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = 1;
-      iend1[ncontact]   = 1;
-      istart2[ncontact] = start2;
-      iend2[ncontact]   = end2;    
-      jstart1[ncontact] = start1;
-      jend1[ncontact]   = end1;
-      jstart2[ncontact] = ny2-1;
-      jend2[ncontact]   = ny2-1;
-      ncontact++;
-    }
-    free(xb1);
-    free(yb1);   
-    free(xb2);
-    free(yb2);  
-
-  
-    /* North bound of tile1 and South bound of tile2 */
-    xb1 = north_bound(x1, nx1, ny1);
-    yb1 = north_bound(y1, nx1, ny1);
-    xb2 = south_bound(x2, nx2, ny2);
-    yb2 = south_bound(y2, nx2, ny2);
-    if( get_contact_index( nx1, nx2, xb1, yb1, xb2, yb2, 0.0, periody, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = start1;
-      iend1[ncontact]   = end1;
-      istart2[ncontact] = start2;
-      iend2[ncontact]   = end2;    
-      jstart1[ncontact] = ny1-1;
-      jend1[ncontact]   = ny1-1;
-      jstart2[ncontact] = 1;
-      jend2[ncontact]   = 1;
-      ncontact++;
-    }
-    free(xb2);
-    free(yb2);
-
-    /* North bound of tile1 and West bound of tile2 */  
-    xb2 = west_bound(x2, nx2, ny2);
-    yb2 = west_bound(y2, nx2, ny2);
-    if( get_contact_index( nx1, ny2, xb1, yb1, xb2, yb2, 0.0, 0.0, &start1, &end1, &start2, &end2) ) {
-      istart1[ncontact] = start1;
-      iend1[ncontact]   = end1;
-      istart2[ncontact] = 1;
-      iend2[ncontact]   = 1;    
-      jstart1[ncontact] = ny1-1;
-      jend1[ncontact]   = ny1-1;
-      jstart2[ncontact] = start2;
-      jend2[ncontact]   = end2;
-      ncontact++;
-    }
-    free(xb1);
-    free(yb1);   
-    free(xb2);
-    free(yb2);  
-  }
-
-  /* when tile1 = tile2, we need to consider about folded. Only foled north is considered here */
-  if(tile1 == tile2) {
-    int i, folded = 1;
-    double dx;
-    xb1 = north_bound(x1, nx1, ny1);
-    yb1 = north_bound(y1, nx1, ny1);
-    for(i=0; i<nx1/2; i++) {
-      if( yb1[i] != yb1[nx1-i-1] ) {
-	folded = 0;
-	break;
-      }
-      dx = fabs(xb1[i] - xb1[nx1-i-1]);
-      if( dx !=0 && dx != 360 ) {
-	folded = 0;
-	break;
-      }
-    }
-    if(folded) {
-      istart1[ncontact] = 1;
-      iend1[ncontact]   = nx1/2;
-      istart2[ncontact] = nx1-1;
-      iend2[ncontact]   = nx1/2+1;    
-      jstart1[ncontact] = ny1-1;
-      jend1[ncontact]   = ny1-1;
-      jstart2[ncontact] = ny1-1;
-      jend2[ncontact]   = ny1-1;
-      ncontact++;
-    }
-    free(xb1);
-    free(yb1);
-  }
-  
-  return ncontact;
-  
-};
-
-
-int get_contact_index( int size1, int size2, double *x1, double *y1, double *x2, double *y2, double periodx,
-		       double periody, int *start1, int *end1, int *start2, int *end2)
-{
-  int i1, i2;
-  double dx, dy;
-
-  /* Find the first point in tile 1 cocindent with a point in tile2  */
-  *start1 = -1;
-  *start2 = -1;
-  for(i1=0; i1<size1; i1++) {
-    for(i2=0; i2<size2; i2++) {
-      dx = fabs(x1[i1]- x2[i2]);
-      dx = min(dx, fabs(dx-periodx));
-      dy = fabs(y1[i1]- y2[i2]);
-      dy = min(dy, fabs(dy-periody));
-      if( dx < EPSLN && dy <EPSLN ) {
-	*start1 = i1+1;
-	*start2 = i2+1;
-	goto foundstart;
-      }
-    }
-  }
-
-  return 0;
-    
-  foundstart:
-
-  /* Find the last point in tile 1 cocindent with a point in tile2 */
-  *end1 = -1;
-  *end2 = -1;
-  for(i1=size1-1; i1>=0; i1--) {
-    for(i2=size2-1; i2>=0; i2--) {
-      dx = fabs(x1[i1]- x2[i2]);
-      dx = min(dx, fabs(dx-periodx));
-      dy = fabs(y1[i1]- y2[i2]);
-      dy = min(dy, fabs(dy-periody));
-      if( dx < EPSLN && dy <EPSLN ) {
-	*end1 = i1+1;
-	*end2 = i2+1;
-	goto foundend;
-      }
-    }
-  }
-
-  return 0;
-    
- foundend: if( *start1 == *end1 || *start2 == *end2 ) return 0;
-
-  if(*start1 > *end1 )
-    (*start1)--;
-  else
-    (*end1)--;
-
-  if(*start2 > *end2 )
-    (*start2)--;
-  else
-    (*end2)--;  
-
-  return 1;
-    
-};
-
-
-double* west_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(ny*sizeof(double));
-  for(i=0; i<ny; i++) bnd[i] = data[i*nx];
-  return bnd;
-}
-
-double* east_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(ny*sizeof(double));
-  for(i=0; i<ny; i++) bnd[i] = data[i*nx+nx-1];
-  return bnd;
-}
-
-double* south_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(nx*sizeof(double));
-  for(i=0; i<nx; i++) bnd[i] = data[i];
-  return bnd;
-}
-
-double* north_bound(const double *data, int nx, int ny)
-{
-  int i;
-  double *bnd;
-  bnd = (double *)malloc(nx*sizeof(double));
-  for(i=0; i<nx; i++) bnd[i] = data[(ny-1)*nx+i];
-  return bnd;
-}
diff --git a/gridspec_tools_20080702/tools/shared/tool_util.c b/gridspec_tools_20080702/tools/shared/tool_util.c
deleted file mode 100644
index e4aba73..0000000
--- a/gridspec_tools_20080702/tools/shared/tool_util.c
+++ /dev/null
@@ -1,5969 +0,0 @@
-
-
-#include <stdlib.h> 
-#include <stdio.h>
-#include <string.h>
-#include <math.h> 
-#include "constant.h" 
-#include "mosaic_util.h" 
-#include "tool_util.h"
-#include "interp.h"
-#include "mpp.h"
-#include "mpp_domain.h"
-#include "mpp_io.h"
-#include "conserve_interp.h"
-#include "bilinear_interp.h"
-#include "fregrid_util.h"
-
-#define  D2R (M_PI/180.)
-#define  R2D (180./M_PI)
-
-const double SMALL = 1.0e-4;
-double distant(double a, double b, double met1, double met2);
-double bp_lam(double x, double y, double bpeq, double rp);
-double bp_phi(double x, double y, double bpsp, double bpnp);
-double lon_in_range(double lon, double lon_strt);
-void vtx_insert(double *x, double *y, int *n, int n_ins);
-void vtx_delete(double *x, double *y, int *n, int n_del);
-int lon_fix(double *x, double *y, int n_in, double tlon);
-
-/***************************************************************************
-  void get_file_path(const char *file, char *dir)
-  get the directory where file is located. The dir will be the complate path
-  before the last "/". If no "/" exist in file, the path will be current ".".
-***************************************************************************/
-void get_file_path(const char *file, char *dir)
-{
-  int len;
-  char *strptr = NULL;
-
-  /* get the diretory */
- 
-  strptr = strrchr(file, '/');
-  if(strptr) {
-    len = strptr - file;
-    strncpy(dir, file, len);
-  }
-  else {
-    len = 1;
-    strcpy(dir, ".");
-  }
-  dir[len] = 0;
-
-}; /* get_file_path */
-
-int get_int_entry(char *line, int* value)
-{
-  char* pch;
-  int num;
-  
-  pch = strtok(line, ", ");
-  num = 0;
-  while( pch != NULL) {
-    value[num++] = atoi(pch);
-    pch = strtok(NULL, ", ");
-  }
-  return num;
-    
-};
-
-int get_double_entry(char *line, double *value)
-{
-  char* pch;
-  int num;
-  
-  pch = strtok(line, ", ");
-  num = 0;
-  while( pch != NULL) {
-    value[num++] = atof(pch);
-    pch = strtok(NULL, ", ");
-  }
-  return num;
-};
-
-/*********************************************************************
-  double spherical_dist(double x1, double y1, double x2, double y2)
-  return distance between spherical grid on the earth
-*********************************************************************/
-
-double spherical_dist(double x1, double y1, double x2, double y2)
-{
-  double dist = 0.0;
-  double h1, h2;
-  
-  if(x1 == x2) {
-    h1 = RADIUS;
-    h2 = RADIUS;
-    dist = distant(y1,y2,h1,h2);
-  }
-  else if(y1 == y2) {
-    h1 = RADIUS * cos(y1*D2R);
-    h2 = RADIUS * cos(y2*D2R);
-    dist = distant(x1,x2,h1,h2);
-  }
-  else 
-    mpp_error("tool_till: This is not rectangular grid");
-
-  return dist;
-}; /* spherical_dist */
-  
-
-/*********************************************************************
-  void double bipolar_dist(double x1, double y1, double x2, double y2)
-  return distance of bipolar grids
-*********************************************************************/
-double bipolar_dist(double x1, double y1, double x2, double y2,
-		    double bpeq, double bpsp, double bpnp, double rp )
-{
-  double dist, x[2],y[2], bp_lon[2], bp_lat[2], metric[2];
-  double h1[2], h2[2], chic;
-  int n;
-  
-  x[0] = x1;  x[1] = x2;
-  y[0] = y1;  y[1] = y2;
-  
-  /*--- get the bipolar grid and metric term ----------------------------*/
-  for(n=0; n<2; n++){
-    bp_lon[n] = bp_lam(x[n],y[n],bpeq, rp);     /* longitude (degrees) in bipolar grid system */
-    bp_lat[n] = bp_phi(x[n],y[n],bpsp, bpnp);  /* latitude (degrees) in bipolar grid system */
-    h1[n]     = RADIUS*cos(bp_lat[n]*D2R);
-    h2[n]     = RADIUS;
-    metric[n] = 1.0;
-    if (fabs(y[n]-90.0) < SMALL || fabs(bp_lon[n]*D2R) >= SMALL
-	|| fabs(bp_lat[n]*D2R) >= SMALL) {
-      chic = acos(cos(bp_lon[n]*D2R)*cos(bp_lat[n]*D2R));            /* eqn. 6 */
-      metric[n] = rp*(1/pow(cos(chic/2),2))/(1+(pow(rp,2))*(pow(tan(chic/2),2)));/* eq 3 */
-    }
-  }
-
-  /*--- then calculate the distance -------------------------------------*/
-  if(x1 == x2) 
-    dist = distant(bp_lon[0],bp_lon[1],metric[0]*h1[0],metric[1]*h1[1]);
-  else if(y1 == y2) 
-    dist = distant(bp_lat[0],bp_lat[1],metric[0]*h2[0],metric[1]*h2[1]);
-  else
-    mpp_error("tool_util: This tripolar grid not transformed from rectangular grid");    
-
-  return dist;
-  
-}; /* bipolar_dist */
-
-/*********************************************************************
-  double distant(double a, double b, double met1, double met2)
-  return distant on the earth
-*********************************************************************/
-double distant(double a, double b, double met1, double met2)
-{
-   return fabs(a-b)*D2R*(met1+met2)/2. ;
-}; /* distant */
-
-/*********************************************************************
-   double spherical_area(double x1, double y1, double x2, double y2,
-                   double x3, double y3, double x4, double y4 )            
-   rectangular grid box area
- ********************************************************************/
-double spherical_area(double x1, double y1, double x2, double y2,
-		      double x3, double y3, double x4, double y4 )
-{
-  double area, dx, lat1, lat2, x[4],y[4];
-  int i, ip;
-  
-  x[0] = x1; y[0] = y1;
-  x[1] = x2; y[1] = y2;
-  x[2] = x3; y[2] = y3;
-  x[3] = x4; y[3] = y4;
-
-  area = 0.0;
-
-  for(i=0; i<4; i++) {
-    ip = i+1;
-    if(ip ==4) ip = 0;
-    dx = (x[ip] - x[i])*D2R;
-    lat1 = y[ip]*D2R;
-    lat2 = y[i]*D2R;
-    if(dx==0.0) continue;
-    if(dx > M_PI)  dx = dx - 2.0*M_PI;
-    if(dx < -M_PI) dx = dx + 2.0*M_PI;
-
-    if (lat1 == lat2) /* cheap area calculation along latitude  */
-      area = area - dx*sin(lat1);
-    else 
-      area = area - dx*(sin(lat1)+sin(lat2))/2;   /*  TRAPEZOID_RULE */
-  }
-
-  area = area * RADIUS * RADIUS;
-
-  return area;
-}; /* spherical_area */
-
-/*********************************************************************
-   double bipolar_area(double x1, double y1, double x2, double y2,
-                       double x3, double y3, double x4, double y4 )            
-   bipolar grid  area
- ********************************************************************/
-double bipolar_area(double x1, double y1, double x2, double y2,
-			  double x3, double y3, double x4, double y4 )
-{
-  double area, dx, lat1, lat2, x[8],y[8];
-  int i, ip, n;
-  
-  x[0] = x1; y[0] = y1;
-  x[1] = x2; y[1] = y2;
-  x[2] = x3; y[2] = y3;
-  x[3] = x4; y[3] = y4;
-
-
-  /*--- first fix the longitude at the pole -----------------------------*/
-  n = lon_fix(x, y, 4, 180.);
-
-  /*--- calculate the area ----------------------------------------------  */
-  area = 0.0;  
-  for(i=0; i<n; i++){
-    ip = i+1;
-    if(ip == n) ip = 0;
-    dx   = (x[ip] - x[i])*D2R;
-    lat1 = y[ip]*D2R;
-    lat2 = y[i]*D2R;
-    if(dx==0.0) continue;
-    if(dx > M_PI)  dx = dx - 2.0*M_PI;
-    if(dx < -M_PI) dx = dx + 2.0*M_PI;
-
-    if (lat1 == lat2)  /* cheap area calculation along latitude */
-      area = area - dx*sin(lat1);
-    else
-      area = area - dx*(sin(lat1)+sin(lat2))/2;   /*  TRAPEZOID_RULE */
-  }
-  
-  area = area * RADIUS * RADIUS;
-
-  return area;
-}; /* bipolar_area */
-
-/*********************************************************************
-  double lat_dist(double x1, double x2)
-  distance (in degrees) between points on lat. circle
- ********************************************************************/
-  double lat_dist(double x1, double x2)
-{
-  return min(fmod(x1-x2+720,360.),fmod(x2-x1+720,360.));
-};
-
-
-/*********************************************************************
-  double bp_lam(double x, double y, double bpeq)
-  find bipolar grid longitude given geo. coordinates
- ********************************************************************/
-  double bp_lam(double x, double y, double bpeq, double rp)
-{
-  double bp_lam;
-
-  /*  bp_lam = ((90-y)/(90-lat_join))*90 */
-  /* invert eqn. 5 with phic=0 to place point at specified geo. lat */
-  bp_lam = 2.*atan(tan((0.5*M_PI-y*D2R)/2)/rp)*R2D;
-  if (lat_dist(x,bpeq)<90.) bp_lam = -bp_lam;
-  return bp_lam;
-}; /* bp_lam */
-
-/*********************************************************************
-   double bp_phi(double x, double y, double bpsp, double bpnp)
-   find bipolar grid latitude given geo. coordinates
- ********************************************************************/
-   double bp_phi(double x, double y, double bpsp, double bpnp)
-{
-  double bp_phi;
-
-  if (lat_dist(x,bpsp)<90.)
-    return (-90+lat_dist(x,bpsp));
-  else
-    return ( 90-lat_dist(x,bpnp));
-}; /* bp_phi */
-
-
-/*********************************************************************
-  void tp_trans(double& lon, double& lat, double lon_ref)
-  calculate tripolar grid
- ********************************************************************/
-void tp_trans(double *lon, double *lat, double lon_ref, double lon_start, 
-		    double lam0, double bpeq, double bpsp, double bpnp, double rp )
-{
-  double lamc, phic, lams, chic, phis;
-  
-  lamc = bp_lam(*lon, *lat, bpeq, rp )*D2R;
-  phic = bp_phi(*lon, *lat, bpsp, bpnp)*D2R;
-
-  if (fabs(*lat-90.) < SMALL) {
-       if (phic > 0) 
-	 *lon=lon_in_range(lon_start,lon_ref);
-       else
-	 *lon=lon_start+180.;
-       chic = acos(cos(lamc)*cos(phic));                     /* eqn. 6 */
-       phis = M_PI*0.5-2*atan(rp*tan(chic/2));                   /* eqn. 5 */
-       *lat = phis*R2D;
-       return;
-  }
-
-  if (fabs(lamc) < SMALL && fabs(phic) < SMALL) {
-    *lat=90.;
-    *lon=lon_ref;
-  }
-  else {
-    lams = fmod(lam0+M_PI+M_PI/2-atan2(sin(lamc),tan(phic)),2*M_PI);  /* eqn. 5 */
-    chic = acos(cos(lamc)*cos(phic));                          /* eqn. 6 */
-    phis = M_PI*0.5-2*atan(rp*tan(chic/2));                        /* eqn. 5 */
-    *lon = lams*R2D;
-    *lon = lon_in_range(*lon,lon_ref); 
-    *lat = phis*R2D;
-  }
-}; /* tp_trans */
-
-/*********************************************************************
-  double Lon_in_range(double lon, double lon_strt)
-  Returns lon_strt <= longitude <= lon_strt+360
- ********************************************************************/
-double lon_in_range(double lon, double lon_strt)
-{
-  double lon_in_range, lon_end;
-
-  lon_in_range = lon;
-  lon_end = lon_strt+360.;
-
-  if (fabs(lon_in_range - lon_strt) < SMALL) 
-    lon_in_range = lon_strt;
-  else if (fabs(lon_in_range - lon_end) < SMALL)
-    lon_in_range = lon_strt;
-  else {
-    while(1) {
-      if (lon_in_range < lon_strt)          
-	lon_in_range = lon_in_range +  360.;
-      else if (lon_in_range  >  lon_end)
-	lon_in_range  = lon_in_range - 360.;
-      else
-	break;
-    }
-  }
-  return lon_in_range;
-}; /* lon_in_range */
-
-
-/*********************************************************************
-   int lon_fix(double *x, double *y, int n_in, double tlon) 
-   fix longitude at pole.
- ********************************************************************/
-int lon_fix(double *x, double *y, int n_in, double tlon)
-{
-  int i, ip, im, n_out;
-  double x_sum, dx;
-  
-  n_out = n_in;
-  i     = 0;
-  while( i < n_out) {
-    if(fabs(y[i]) >= 90.-SMALL) {
-      im = i - 1;
-      if(im < 0) im = im + n_out;
-      ip = i + 1;
-      if(ip >= n_out) ip = ip - n_out;
-      /*--- all pole points must be paired ---------------------------- */
-      if(y[im] == y[i] && y[ip] == y[i] ) {
-	vtx_delete(x,y, &n_out, i);
-	i = i - 1;
-      }
-      else if(y[im] != y[i] && y[ip] != y[i] ) {
-        vtx_insert(x,y,&n_out,i);
-	i = i + 1;
-      }
-    }
-    i = i + 1;
-  }
-
-  /*--- first of pole pair has longitude of previous vertex -------------
-    --- second of pole pair has longitude of subsequent vertex ---------- */
-  for(i=0;i<n_out;i++){
-    if(fabs(y[i]) >= 90.-SMALL) {
-      im= i - 1;
-      if(im < 0) im = im + n_out;
-      ip = i + 1;
-      if(ip >= n_out) ip = ip - n_out;
-
-      if(y[im] != y[i]) x[i] = x[im];
-      if(y[ip] != y[i]) x[i] = x[ip];
-    }
-  }
-
-  if(n_out == 0) return 0;
-
-  x_sum = x[1];
-  for(i=1;i< n_out;i++){
-    dx = x[i] - x[i-1];
-    if(dx < -180) 
-      dx = dx + 360;
-    else if (dx >  180)
-      dx = dx - 360;
-
-    x[i] = x[i-1] + dx;
-    x_sum = x_sum + x[i];
-  }
-
-  dx = x_sum/(n_out) - tlon;
-  if (dx < -180.) 
-    for(i=0;i<n_out;i++) x[i] = x[i] + 360.;
-  else if (dx > 180.)
-    for(i=0;i<n_out;i++) x[i] = x[i] - 360.;
-
-  return n_out;
-  
-}; /* lon_fix */
-
-
-/*********************************************************************
-   void vtx_delete(double *x, double *y, int *n, int n_del)
-   delete vertex
- ********************************************************************/
-void vtx_delete(double *x, double *y, int *n, int n_del)
-{
-  int i;
-
-  for(i=n_del; i<=*n-2; i++)
-    {
-      x[i] = x[i+1];
-      y[i] = y[i+1];
-    }
-  (*n)--;
-}; /* vtx_delete */
-
-/*********************************************************************
-   void Vtx_insert(double *x, double *y, int *n, int n_del)
-   insert vertex
- ********************************************************************/
-void vtx_insert(double *x, double *y, int *n, int n_ins)
-{
-  int i;
-
-  for(i=*n-1; i>=n_ins; i--){
-    x[i+1] = x[i];
-    y[i+1] = y[i];
-  }
-  (*n)++;
-
-}; /* vtx_insert */
-
-
-/*----------------------------------------------------------------------
-    void vect_cross(e, p1, p2)
-    Perform cross products of 3D vectors: e = P1 X P2
-    -------------------------------------------------------------------*/
-    
-/********************************************************************************
-  void compute_grid_bound(int nb, const couble *bnds, const int *npts, int *grid_size, const char *center_cell)
-  compute the 1-D grid location.
-********************************************************************************/
-double* compute_grid_bound(int nb, const double *bnds, const int *npts, int *grid_size, const char *center)
-{
-  int    refine, i, n, np;
-  double *grid=NULL, *tmp=NULL;
-  double *grid1=NULL, *grid2=NULL;
-
-  if(!strcmp(center, "none") )
-    refine = 1;
-  else if(!strcmp(center, "t_cell") || !strcmp(center, "c_cell") )
-    refine = 2;
-  else
-    mpp_error("tool_util: center should be 'none', 'c_cell' or 't_cell' ");
-	  
-  grid1 = (double *)malloc(nb*sizeof(double));
-  grid1[0] = 1;
-  n = 0;
-  for(i=1; i<nb; i++) {
-    if(npts[i-1]%refine) mpp_error("tool_util: when center_cell is not 'none', npts should be divided by 2");
-    n += npts[i-1]/refine;
-    grid1[i] = n+1;
-  }
-  np = n + 1;
-  *grid_size = n*refine;
-  tmp   = (double *)malloc(np*sizeof(double));
-  grid  = (double *)malloc((*grid_size+1)*sizeof(double));
-  grid2 = (double *)malloc(np*sizeof(double));
-  for(i=0;i<np;i++) grid2[i] = i + 1.0;
-
-  cubic_spline( nb, np, grid1, grid2, bnds, tmp, 1e30, 1e30);
-  if(!strcmp(center, "none")) {
-    for(i=0; i<np; i++) grid[i] = tmp[i];
-  }
-  else if(!strcmp(center, "t_cell")) {
-    for(i=0; i<np; i++) grid[2*i] = tmp[i];
-    for(i=0; i<n;  i++) grid[2*i+1] = 0.5*(tmp[i]+tmp[i+1]);
-  }
-  else if( !strcmp(center, "c_cell")) {
-    for(i=0; i<np; i++) grid[2*i] = tmp[i];
-    grid[1] = 0.5*(tmp[0]+tmp[1]);
-    for(i=1; i<n;  i++) grid[2*i+1] = 2*grid[2*i] - grid[2*i-1];
-  }
-    
-  free(grid1);
-  free(grid2);
-  free(tmp);  
-
-  return grid;
-  
-};/* compute_grid_bound */
-
-double* get_subregion(int ni, double *data, int is, int ie, int js, int je)
-{
-  int i, j, pos;
-  double *ldata;
-  
-  ldata = (double *)malloc((ie-is+1)*(je-js+1)*sizeof(double));
-  pos = 0;
-  for(j=js; j<=je; j++)
-    for(i=is; i<=ie; i++) ldata[pos++] = data[j*ni+i];
-
-  return ldata;
-  
-}; /* get_subregion */
-
-#define MAXBOUNDS 100
-#define STRINGLEN 255
-#define GRID_VERSION "0.2"
-#define TAGNAME "$Name:  $"
-
-int
-gs_make_hgrid(char *grid_type, char *entry, int nxbnds0, int nybnds0, 
-              int nxbnds1, int nybnds1, int nxbnds2, int nybnds2, double lat_join,
-              int nratio, double simple_dx, double simple_dy, int ntilex, int ntiley,
-              char *gridname, char *center)
-{
-  
-   int  ndivx[] = {1,1,1,1,1,1};
-   int  ndivy[] = {1,1,1,1,1,1};
-   char method[32] = "conformal";
-   char orientation[32] = "center_pole";
-   int  nxbnds=2, nybnds=2;
-   double xbnds[MAXBOUNDS], ybnds[MAXBOUNDS];
-   int nlon[MAXBOUNDS-1], nlat[MAXBOUNDS-1];
-   char my_grid_file[MAXBOUNDS][STRINGLEN];
-   int nx, ny, nxp, nyp, ntiles=1, ntiles_file;
-   double *x=NULL, *y=NULL, *dx=NULL, *dy=NULL, *angle_dx=NULL, *angle_dy=NULL, *area=NULL;
-  
-   char history[2560];
-   char geometry[32] = "spherical";
-   char projection[32] = "none";
-   char arcx[32] = "small_circle";
-   char north_pole_tile[32] = "0.0 90.0";
-   char north_pole_arcx[32] = "0.0 90.0";
-   char discretization[32]  = "logically_rectangular";
-   char conformal[32]       = "true";
-   char mesg[256], str[128];
-   int isc, iec, jsc, jec, nxc, nyc, layout[2];
-   domain2D domain;
-   int n, errflg, c, i;  
-
-   /* check the command-line arguments to make sure the value are suitable */
-   if( strcmp(grid_type,"regular_lonlat_grid") ==0 ) {
-      nxbnds = nxbnds0; nybnds = nybnds0;
-      if( nxbnds <2 || nybnds < 2) mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', "
-      "both nxbnds and nybnds should be no less than 2");
-      if( nxbnds != nxbnds1 || nxbnds != nxbnds2+1 )
-	 mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', nxbnds does"
-	 "not match number of entry in xbnds or nlon");
-      if( nybnds != nybnds1 || nybnds != nybnds2+1 )
-	 mpp_error("make_hgrid: grid type is 'regular_lonlat_grid', nybnds does "
-	 "not match number of entry in ybnds or nlat");
-   }
-   else if( strcmp(grid_type,"tripolar_grid") ==0 ) {
-      strcpy(projection, "tripolar");
-      nxbnds = nxbnds0; nybnds = nybnds0;
-      if( nxbnds != 2) mpp_error("make_hgrid: grid type is 'tripolar_grid', nxbnds should be 2");
-      if( nybnds < 2) mpp_error("make_hgrid: grid type is 'tripolar_grid', nybnds should be no less than 2");
-      if( nxbnds != nxbnds1 || nxbnds != nxbnds2+1 )
-	 mpp_error("make_hgrid: grid type is 'tripolar_grid', nxbnds does not match number of entry in xbnds or nlon");
-      if( nybnds != nybnds1 || nybnds != nybnds2+1 )
-	 mpp_error("make_hgrid: grid type is 'tripolar_grid', nybnds does not match number of entry in ybnds or nlat");
-   }
-   else if( strcmp(grid_type,"from_file") ==0 ) {
-      /* For ascii file, nlon and nlat should be specified through --nlon, --nlat
-	 For netcdf file, grid resolution will be read from grid file
-      */
-    
-      if(ntiles_file == 0) mpp_error("make_hgrid: grid_type is 'from_file', but my_grid_file is not specified");
-      ntiles = ntiles_file;
-      for(n=0; n<ntiles; n++) {
-	 if(strstr(my_grid_file[n],".nc") ) {
-	    /* get the grid size for each tile, the grid is on model grid, should need to multiply by 2 */
-	    int fid;
-	    fid = mpp_open(my_grid_file[n], MPP_READ);
-	    nlon[n] = mpp_get_dimlen(fid, "grid_xt")*2;
-	    nlat[n] = mpp_get_dimlen(fid, "grid_yt")*2;
-	    mpp_close(fid);
-	 }
-	 else {
-	    if(nxbnds2 != ntiles || nybnds2 != ntiles ) mpp_error("make_hgrid: grid type is 'from_file', number entry entered "
-	    "through --nlon and --nlat should be equal to number of files "
-	    "specified through --my_grid_file");
-	 }
-      }
-      /* for simplify purpose, currently we assume all the tile have the same grid size */
-      for(n=1; n<ntiles; n++) {
-	 if( nlon[n] != nlon[0] || nlat[n] != nlat[0])  mpp_error("make_hgrid: grid_type is from_file, all the tiles should "
-	 "have same grid size, contact developer");
-      }
-   }
-   else if( strcmp(grid_type,"simple_cartesian_grid") ==0) {
-      strcpy(geometry, "planar");
-      strcpy(north_pole_tile, "none");
-      if(nxbnds1 != 2 || nybnds1 != 2 ) mpp_error("make_hgrid: grid type is 'simple_cartesian_grid', number entry entered "
-      "through --xbnds and --ybnds should be 2");
-      if(nxbnds2 != 1 || nybnds2 != 1 ) mpp_error("make_hgrid: grid type is 'simple_cartesian_grid', number entry entered "
-      "through --nlon and --nlat should be 1");
-      if(simple_dx == 0 || simple_dy == 0) mpp_error("make_hgrid: grid_type is 'simple_cartesian_grid', "
-      "both simple_dx and simple_dy both should be specified");
-   }
-   else if ( strcmp(grid_type,"spectral_grid") ==0 ) {
-      if(nxbnds2 != 1 || nybnds2 != 1 ) mpp_error("make_hgrid: grid type is 'spectral_grid', number entry entered "
-      "through --nlon and --nlat should be 1");    
-   }
-   else if( strcmp(grid_type,"conformal_cubic_grid") ==0 ) {
-      strcpy(projection, "cube_gnomonic");
-      strcpy(conformal, "FALSE");
-      if(nxbnds2 != 1 ) mpp_error("make_hgrid: grid type is 'conformal_cubic_grid', number entry entered "
-      "through --nlon should be 1");
-      if(nratio < 1) mpp_error("make_hgrid: grid type is 'conformal_cubic_grid', nratio should be a positive integer");
-   }
-   else if(  !strcmp(grid_type,"gnomonic_ed") ) {
-      strcpy(projection, "cube_gnomonic");
-      strcpy(conformal, "FALSE");
-      if(nxbnds2 != 1 ) mpp_error("make_hgrid: grid type is 'gnomonic_cubic_grid', number entry entered "
-      "through --nlon should be 1");
-   }
-   else {
-      mpp_error("make_hgrid: only grid_type = 'regular_lonlat_grid', 'tripolar_grid', 'from_file', "
-      "'gnomonic_ed', 'conformal_cubic_grid', 'simple_cartesian_grid' and "
-      "'spectral_grid' is implemented");  
-   }
-  
-   /* get super grid size */
-
-   if( !strcmp(grid_type,"gnomonic_ed") || !strcmp(grid_type,"conformal_cubic_grid") ) {
-      nx = nlon[0];
-      ny = nx;
-   }
-   else {
-      nx = 0;
-      ny = 0;
-      for(n=0; n<nxbnds-1; n++) nx += nlon[n];
-      for(n=0; n<nybnds-1; n++) ny += nlat[n];  
-   }
-   nxp = nx + 1;
-   nyp = ny + 1;
-
-   if( !strcmp(grid_type,"gnomonic_ed") || !strcmp(grid_type,"conformal_cubic_grid") ) {
-      ntiles = 6;
-      /* Cubic grid is required to run on single processor.*/
-      if(mpp_npes() > 1) mpp_error( "make_hgrid: cubic grid generation must be run one processor, contact developer");
-   }
-   /* Currently we restrict nx can be divided by ndivx and ny can be divided by ndivy */
-   if(ntilex >0 && ntilex != ntiles) mpp_error("make_hgrid: number of entry specified through --ndivx does not equal ntiles");
-   if(ntiley >0 && ntiley != ntiles) mpp_error("make_hgrid: number of entry specified through --ndivy does not equal ntiles");   
-   for(n=0; n<ntiles; n++) {
-      if( nx%ndivx[n] ) mpp_error("make_hgrid: nx can not be divided by ndivx");
-      if( ny%ndivy[n] ) mpp_error("make_hgrid: ny can not be divided by ndivy");
-   }
-
-   if(strcmp(center,"none") && strcmp(center,"c_cell") && strcmp(center,"t_cell") )
-      mpp_error("make_hgrid: center should be 'none', 'c_cell' or 't_cell' ");
-  
-   /* set up domain decomposition, x and y will be on global domain and
-      other fields will be on compute domain. 
-   */
-
-   mpp_define_layout( nx, ny, mpp_npes(), layout);
-   mpp_define_domain2d( nx, ny, layout, 0, 0, &domain);
-   mpp_get_compute_domain2d(domain, &isc, &iec, &jsc, &jec);
-   nxc = iec - isc + 1;
-   nyc = jec - jsc + 1;
-
-   /* create grid information */
-   x        = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
-   y        = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
-   dx       = (double *) malloc(nxc*(nyc+1)*ntiles*sizeof(double));
-   dy       = (double *) malloc((nxc+1)*nyc*ntiles*sizeof(double));
-   area     = (double *) malloc(nxc    *nyc*ntiles*sizeof(double));
-   angle_dx = (double *) malloc((nxc+1)*(nyc+1)*ntiles*sizeof(double));
-   if( strcmp(conformal,"true") !=0 )angle_dy = (double *) malloc(nxp*nyp*ntiles*sizeof(double));
-  
-   if(strcmp(grid_type,"regular_lonlat_grid") ==0) 
-      create_regular_lonlat_grid(&nxbnds, &nybnds, xbnds, ybnds, nlon, nlat, &isc, &iec, &jsc, &jec,
-      x, y, dx, dy, area, angle_dx, center);
-   else if(strcmp(grid_type,"tripolar_grid") ==0) 
-      create_tripolar_grid(&nxbnds, &nybnds, xbnds, ybnds, nlon, nlat, &lat_join, &isc, &iec, &jsc, &jec,
-      x, y, dx, dy, area, angle_dx, center);
-   else if( strcmp(grid_type,"from_file") ==0 ) {
-      for(n=0; n<ntiles; n++) {
-	 int n1, n2, n3, n4;
-	 n1 = n * nxp * nyp;
-	 n2 = n * nx  * nyp;
-	 n3 = n * nxp * ny;
-	 n4 = n * nx  * ny;
-	 create_grid_from_file(my_grid_file[n], &nx, &ny, x+n1, y+n1, dx+n2, dy+n3, area+n4, angle_dx+n1);
-      }
-   }
-   else if(strcmp(grid_type,"simple_cartesian_grid") ==0) 
-      create_simple_cartesian_grid(xbnds, ybnds, &nx, &ny, &simple_dx, &simple_dy, &isc, &iec, &jsc, &jec,
-      x, y, dx, dy, area, angle_dx );
-   else if(strcmp(grid_type,"spectral_grid") ==0 )
-      create_spectral_grid(&nx, &ny, &isc, &iec, &jsc, &jec, x, y, dx, dy, area, angle_dx );
-   else if(strcmp(grid_type,"conformal_cubic_grid") ==0 ) 
-      create_conformal_cubic_grid(&nx, &nratio, method, orientation, x, y, dx, dy, area, angle_dx, angle_dy );
-   else if(strcmp(grid_type,"gnomonic_ed") ==0 ) 
-      create_gnomonic_cubic_grid(grid_type, &nx, x, y, dx, dy, area, angle_dx, angle_dy );
-  
-   /* write out data */
-   {
-      int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-      int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp, m;
-      size_t start[4], nwrite[4];
-      double *tmp, *gdata;
-      char tilename[128] = "";
-      char outfile[128] = "";
-    
-      l = 0;
-      for(n=0 ; n< ntiles; n++) {
-	 for(j=0; j<ndivy[n]; j++) {
-	    for(i=0; i<ndivx[n]; i++) {
-	       ++l;
-	       sprintf(tilename, "tile%d", l);
-	       if(ntiles>1)
-		  sprintf(outfile, "%s.tile%d.nc", gridname, l);
-	       else
-		  sprintf(outfile, "%s.nc", gridname);
-	       fid = mpp_open(outfile, MPP_WRITE);
-	       /* define dimenison */
-	       ni = nx/ndivx[n];
-	       nj = ny/ndivy[n];
-	       nip = ni + 1;
-	       njp = nj + 1;
-	       dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-	       dimlist[1] = mpp_def_dim(fid, "nx", ni);
-	       dimlist[2] = mpp_def_dim(fid, "ny", nj);
-	       dimlist[3] = mpp_def_dim(fid, "nxp", nip);
-	       dimlist[4] = mpp_def_dim(fid, "nyp", njp);
-	       /* define variable */
-	       if( strcmp(north_pole_tile, "none") == 0) /* no north pole, then no projection */
-		  id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 4, "standard_name", "grid_tile_spec",
-		  "geometry", geometry, "discretization", discretization, "conformal", conformal );
-	       else if( strcmp(projection, "none") == 0) 
-		  id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec",
-		  "geometry", geometry, "north_pole", north_pole_tile, "discretization",
-		  discretization, "conformal", conformal );
-	       else
-		  id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 6, "standard_name", "grid_tile_spec",
-		  "geometry", geometry, "north_pole", north_pole_tile, "projection", projection,
-		  "discretization", discretization, "conformal", conformal );
-	       dims[0] = dimlist[4]; dims[1] = dimlist[3];
-	       id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude",
-	       "units", "degree_east");
-	       id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude",
-	       "units", "degree_north");
-	       dims[0] = dimlist[4]; dims[1] = dimlist[1];
-	       id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance",
-	       "units", "meters");
-	       dims[0] = dimlist[2]; dims[1] = dimlist[3];
-	       id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance",
-	       "units", "meters");
-	       dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	       id_area = mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area",
-	       "units", "m2" );
-	       dims[0] = dimlist[4]; dims[1] = dimlist[3];
-	       id_angle_dx = mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name",
-	       "grid_vertex_x_angle_WRT_geographic_east", "units", "degrees_east");
-	       if(strcmp(conformal, "true") != 0)
-		  id_angle_dy = mpp_def_var(fid, "angle_dy", MPP_DOUBLE, 2, dims, 2, "standard_name",
-		  "grid_vertex_y_angle_WRT_geographic_north", "units", "degrees_north");
-	       if( strcmp(north_pole_arcx, "none") == 0)
-		  id_arcx = mpp_def_var(fid, "arcx", MPP_CHAR, 1, dimlist, 1, "standard_name", "grid_edge_x_arc_type" );
-	       else
-		  id_arcx = mpp_def_var(fid, "arcx", MPP_CHAR, 1, dimlist, 2, "standard_name", "grid_edge_x_arc_type",
-		  "north_pole", north_pole_arcx );
-	       mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-	       mpp_def_global_att(fid, "code_version", TAGNAME);
-	       mpp_def_global_att(fid, "history", history);
-      
-	       mpp_end_def(fid);
-	       for(m=0; m<4; m++) { start[m] = 0; nwrite[m] = 0; }
-	       nwrite[0] = strlen(tilename);
-	       mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-
-	       tmp = get_subregion(nxp, x+n*nxp*nyp, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-	       mpp_put_var_value(fid, id_x, tmp);
-	       free(tmp);
-	       tmp = get_subregion(nxp, y+n*nxp*nyp, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-	       mpp_put_var_value(fid, id_y, tmp);
-	       free(tmp);
-	       gdata = (double *)malloc(nx*nyp*sizeof(double));
-	       mpp_global_field_double(domain, nxc, nyc+1, dx+n*nx*nyp, gdata);
-	       tmp = get_subregion( nx, gdata, i*ni, (i+1)*ni-1, j*nj, (j+1)*nj);
-	       mpp_put_var_value(fid, id_dx, tmp);
-	       free(tmp);
-	       free(gdata);
-	       gdata = (double *)malloc(nxp*ny*sizeof(double));
-	       mpp_global_field_double(domain, nxc+1, nyc, dy+n*nxp*ny, gdata);
-	       tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj-1);
-	       mpp_put_var_value(fid, id_dy, tmp);
-	       free(tmp);
-	       free(gdata);	  
-	       gdata = (double *)malloc(nx*ny*sizeof(double));
-	       mpp_global_field_double(domain, nxc, nyc, area+n*nx*ny, gdata);
-	       tmp = get_subregion( nx, gdata, i*ni, (i+1)*ni-1, j*nj, (j+1)*nj-1);
-	       mpp_put_var_value(fid, id_area, tmp);
-	       free(tmp);
-	       free(gdata);
-	       gdata = (double *)malloc(nxp*nyp*sizeof(double));
-	       mpp_global_field_double(domain, nxc+1, nyc+1, angle_dx+n*nxp*nyp, gdata);
-	       tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-	       mpp_put_var_value(fid, id_angle_dx, tmp);
-	       free(tmp);
-	       free(gdata);
-	  
-	       if(strcmp(conformal, "true") != 0) {
-		  gdata = (double *)malloc(nxp*nyp*sizeof(double));
-		  mpp_global_field_double(domain, nxc+1, nyc+1, angle_dy+n*nxp*nyp, gdata);
-		  tmp = get_subregion( nxp, gdata, i*ni, (i+1)*ni, j*nj, (j+1)*nj);
-		  mpp_put_var_value(fid, id_angle_dy, tmp);
-		  free(tmp);
-		  free(gdata);
-	       }
-	       nwrite[0] = strlen(arcx);
-	       mpp_put_var_value_block(fid, id_arcx, start, nwrite, arcx );
-	       mpp_close(fid);
-	    }
-	 }
-      }
-   }
-
-   free(x);
-   free(y);
-   free(dx);
-   free(dy);
-   free(area);
-   free(angle_dx);
-   if(strcmp(conformal, "true") != 0) free(angle_dy);
-}
-
-int
-gs_fregrid(char *history, char *mosaic_in, char *mosaic_out, char *dir_in, 
-           char *dir_out, char **input_file, int nfiles, char **output_file, 
-           int nfiles_out, char *remap_file, char **scalar_name, int nscalar,
-           char **u_name, int nvector, char **v_name, int nvector2, 
-           char *interp_method, char *test_case, double test_param, 
-           unsigned int opcode, int grid_type, unsigned int finer_step,
-           int fill_missing, int nlon, int nlat, int check_conserve, 
-           int y_at_center, double lonbegin, double lonend, double latbegin,
-           double latend, int kbegin, int kend, int lbegin, int lend)
-{
-   int     ntiles_in = 0;              /* number of tiles in input mosaic */
-   int     ntiles_out = 0;             /* number of tiles in output mosaic */
-   int     option_index, c, i, n, m, l;
-   char    txt[STRING];
-
-   Grid_config   *grid_in    = NULL;   /* store input grid  */
-   Grid_config   *grid_out   = NULL;   /* store output grid */
-   Field_config  *scalar_in  = NULL;   /* store input scalar data */
-   Field_config  *scalar_out = NULL;   /* store output scalar data */
-   Field_config  *u_in       = NULL;   /* store input vector u-component */
-   Field_config  *v_in       = NULL;   /* store input vector v-component */
-   Field_config  *u_out      = NULL;   /* store input vector u-component */
-   Field_config  *v_out      = NULL;   /* store input vector v-component */
-   File_config   *file_in    = NULL;   /* store input file information */
-   File_config   *file_out   = NULL;   /* store output file information */
-   File_config   *file2_in   = NULL;   /* store input file information */
-   File_config   *file2_out  = NULL;   /* store output file information */
-   Bound_config  *bound_T    = NULL;   /* store halo update information for T-cell*/
-   Interp_config *interp     = NULL;   /* store remapping information */
-   int save_weight_only      = 0;
-  
-   int fid;
-
-   /* check the arguments */
-   if( !mosaic_in  ) mpp_error("fregrid: input_mosaic is not specified");
-   if( !mosaic_out ) {
-      if(nlon == 0 || nlat ==0 ) mpp_error("fregrid: when output_mosaic is not specified, nlon and nlat should be specified");
-      if(lonend <= lonbegin) mpp_error("fregrid: when output_mosaic is not specified, lonEnd should be larger than lonBegin");
-      if(latend <= latbegin) mpp_error("fregrid: when output_mosaic is not specified, latEnd should be larger than latBegin");
-   }
-   else {
-      if(nlon !=0 || nlat != 0) mpp_error("fregrid: when output_mosaic is specified, nlon and nlat should not be specified");
-   }
-  
-   if( nfiles == 0) {
-      if(nvector > 0 || nscalar > 0 || nvector2 > 0)
-	 mpp_error("fregrid: when --input_file is not specified, --scalar_field, --u_field and --v_field should also not be specified");
-      if(!remap_file) mpp_error("fregrid: when --input_file is not specified, remap_file must be specified to save weight information");
-      save_weight_only = 1;
-      if(mpp_pe()==mpp_root_pe())printf("NOTE: No input file specified in this run, no data file will be regridded "
-      "and only weight information is calculated.\n");
-   }
-   else if( nfiles == 1 || nfiles ==2) {
-      if( nvector != nvector2 ) mpp_error("fregrid: number of fields specified in u_field must be the same as specified in v_field");
-      if( nscalar+nvector==0 ) mpp_error("fregrid: both scalar_field and vector_field are not specified");
-      /* when nvector =2 and nscalar=0, nfiles can be 2 otherwise nfiles must be 1 */
-      if( nscalar && nfiles != 1 )
-	 mpp_error("fregrid: when scalar_field is specified, number of files must be 1");
-      if( nfiles_out == 0 ) {
-	 for(i=0; i<nfiles; i++) strcpy(output_file[i], input_file[i]);
-      }
-      else if (nfiles_out != nfiles )
-	 mpp_error("fregrid:number of input file is not equal to number of output file");
-   }
-   else
-      mpp_error("fregrid: number of input file should be 1 or 2");
-
-   if(kbegin != 0 || kend != -1) { /* at least one of kbegin and kend is set */
-      if(kbegin < 1 || kend < kbegin) mpp_error("fregrid:KlevelBegin should be a positive integer and no larger "
-      "than KlevelEnd when you want pick certain klevel");
-   }
-   if(lbegin != 0 || lend != -1) { /* at least one of lbegin and lend is set */
-      if(lbegin < 1 || lend < lbegin) mpp_error("fregrid:LstepBegin should be a positive integer and no larger "
-      "than LstepEnd when you want pick certain Lstep");
-   }
-  
-   if(nvector > 0) {
-      opcode |= VECTOR;
-      if(grid_type == AGRID)
-	 opcode |= AGRID;
-      else if(grid_type == BGRID)
-	 opcode |= BGRID;
-   }
-  
-   /* get the mosaic information of input and output mosaic*/
-   fid = mpp_open(mosaic_in, MPP_READ);
-   ntiles_in = mpp_get_dimlen(fid, "ntiles");
-   mpp_close(fid);
-   if(mosaic_out) {
-      fid = mpp_open(mosaic_out, MPP_READ);
-      ntiles_out = mpp_get_dimlen(fid, "ntiles");
-      mpp_close(fid);
-   }
-   else
-      ntiles_out = 1;
-
-   if(!strcmp(interp_method, "conserve_order1") ) {
-      if(mpp_pe() == mpp_root_pe())printf("****fregrid: first order conservative scheme will be used for regridding.\n");
-      opcode |= CONSERVE_ORDER1;
-   }
-   else if(!strcmp(interp_method, "conserve_order2") ) {
-      if(mpp_pe() == mpp_root_pe())printf("****fregrid: second order conservative scheme will be used for regridding.\n");
-      opcode |= CONSERVE_ORDER2;
-   }
-   else if(!strcmp(interp_method, "bilinear") ) {
-      if(mpp_pe() == mpp_root_pe())printf("****fregrid: bilinear remapping scheme will be used for regridding.\n");  
-      opcode |= BILINEAR;
-   }
-   else
-      mpp_error("fregrid: interp_method must be 'conserve_order1', 'conserve_order2' or 'bilinear'");
-
-   if(test_case) {
-      if(nfiles != 1) mpp_error("fregrid: when test_case is specified, nfiles should be 1");
-      sprintf(output_file[0], "%s.%s.output", test_case, interp_method);
-   }
-
-   if(check_conserve) opcode |= CHECK_CONSERVE;
-  
-   if( opcode & BILINEAR ) {
-      int ncontact;
-      ncontact = read_mosaic_ncontacts(mosaic_in);
-      if( nlon == 0 || nlat == 0) mpp_error("fregrid: when interp_method is bilinear, nlon and nlat should be specified");
-      if(ntiles_in != 6) mpp_error("fregrid: when interp_method is bilinear, the input mosaic should be 6 tile cubic grid");
-      if(ncontact !=12)  mpp_error("fregrid: when interp_method is bilinear, the input mosaic should be 12 contact cubic grid");
-      if(mpp_npes() > 1) mpp_error("fregrid: parallel is not implemented for bilinear remapping");
-   }
-   else
-      y_at_center = 1;
-
-
-   /* memory allocation for data structure */
-   grid_in   = (Grid_config *)malloc(ntiles_in *sizeof(Grid_config));
-   grid_out  = (Grid_config *)malloc(ntiles_out*sizeof(Grid_config));
-   bound_T   = (Bound_config *)malloc(ntiles_in *sizeof(Bound_config));
-   interp    = (Interp_config *)malloc(ntiles_out*sizeof(Interp_config));
-   get_input_grid( ntiles_in, grid_in, bound_T, mosaic_in, opcode );
-   if(mosaic_out)
-      get_output_grid_from_mosaic( ntiles_out, grid_out, mosaic_out, opcode );
-   else
-      get_output_grid_by_size(ntiles_out, grid_out, lonbegin, lonend, latbegin, latend,
-      nlon, nlat, finer_step, y_at_center, opcode);
-
-   if(remap_file) set_remap_file(ntiles_out, mosaic_out, remap_file, interp, &opcode, save_weight_only);
-
-   /* preparing for the interpolation, if remapping information exist, read it from remap_file,
-      otherwise create the remapping information and write it to remap_file
-   */
-   if( opcode & BILINEAR ) /* bilinear interpolation from cubic to lalon */
-      setup_bilinear_interp(ntiles_in, grid_in, ntiles_out, grid_out, interp, opcode );
-   else
-      setup_conserve_interp(ntiles_in, grid_in, ntiles_out, grid_out, interp, opcode);
-  
-   if(save_weight_only) {
-      if(mpp_pe() == mpp_root_pe() ) {
-	 printf("NOTE: Successfully running fregrid and the following files which store weight information are generated.\n");
-	 for(n=0; n<ntiles_out; n++) {
-	    printf("****%s\n", interp[n].remap_file);
-	 }
-      }
-      mpp_end();
-      return 0;     
-   }
-  
-   file_in   = (File_config *)malloc(ntiles_in *sizeof(File_config));
-   file_out  = (File_config *)malloc(ntiles_out*sizeof(File_config));
- 
-   if(nfiles == 2) {
-      file2_in   = (File_config *)malloc(ntiles_in *sizeof(File_config));
-      file2_out  = (File_config *)malloc(ntiles_out*sizeof(File_config));
-   }
-   if(nscalar > 0) {
-      scalar_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
-      scalar_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));
-   }
-   if(nvector > 0) {
-      u_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
-      u_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));    
-      v_in  = (Field_config *)malloc(ntiles_in *sizeof(Field_config));
-      v_out = (Field_config *)malloc(ntiles_out *sizeof(Field_config));
-   }
-  
-      
-   set_mosaic_data_file(ntiles_in, mosaic_in, dir_in, file_in,  input_file[0]);
-   set_mosaic_data_file(ntiles_out, mosaic_out, dir_out, file_out, output_file[0]);
-   if(nfiles == 2) {
-      set_mosaic_data_file(ntiles_in, mosaic_in, dir_in, file2_in,  input_file[1]);
-      set_mosaic_data_file(ntiles_out, mosaic_out, dir_out, file2_out, output_file[1]);    
-   }
-
-   for(n=0; n<ntiles_in; n++) file_in[n].fid = mpp_open(file_in[n].name, MPP_READ);
-
-   set_field_struct ( ntiles_in,   scalar_in,   nscalar, scalar_name[0], file_in);
-   set_field_struct ( ntiles_out,  scalar_out,  nscalar, scalar_name[0], file_out);
-   set_field_struct ( ntiles_in,   u_in,        nvector, u_name[0], file_in);
-   set_field_struct ( ntiles_out,  u_out,       nvector, u_name[0], file_out);
-   if(nfiles == 1) {
-      set_field_struct ( ntiles_in,   v_in,        nvector, v_name[0], file_in);
-      set_field_struct ( ntiles_out,  v_out,       nvector, v_name[0], file_out);
-   }
-   else {
-      set_field_struct ( ntiles_in,   v_in,        nvector, v_name[0], file2_in);
-      set_field_struct ( ntiles_out,  v_out,       nvector, v_name[0], file2_out);
-   }
-
-   get_input_metadata(ntiles_in, nfiles, file_in, file2_in, scalar_in, u_in, v_in, grid_in, kbegin, kend, lbegin, lend );
-
-   set_output_metadata(ntiles_in, nfiles, file_in, file2_in, scalar_in, u_in, v_in,
-   ntiles_out, file_out, file2_out, scalar_out, u_out, v_out, grid_out, history, TAGNAME );
-
-   if(nscalar > 0) get_field_missing(ntiles_in, scalar_in);
-   if(nvector > 0) {
-      get_field_missing(ntiles_in, u_in);
-      get_field_missing(ntiles_in, v_in);
-   }
-  
-   /* set time step to 1, only test scalar field now, nz need to be 1 */
-   if(test_case) {
-      if(nscalar != 1 || nvector != 0) mpp_error("fregrid: when test_case is specified, nscalar must be 1 and nvector must be 0");
-      if(scalar_in->var->nz != 1) mpp_error("fregrid: when test_case is specified, number of vertical level must be 1");
-      file_in->nt = 1;
-      file_out->nt = 1;
-   }
-   
-   /* Then doing the regridding */
-   for(m=0; m<file_in->nt; m++) {
-      int memsize, level;
-
-      write_output_time(ntiles_out, file_out, m);
-      if(nfiles > 1) write_output_time(ntiles_out, file2_out, m);
-    
-      /* first interp scalar variable */
-      for(l=0; l<nscalar; l++) {
-	 if( !scalar_in->var[l].has_taxis && m>0) continue;
-	 level = m + scalar_in->var[l].lstart;
-	 if(test_case)
-	    get_test_input_data(test_case, test_param, ntiles_in, scalar_in, grid_in, bound_T, opcode);
-	 else
-	    get_input_data(ntiles_in, scalar_in, grid_in, bound_T, l, level, opcode);
-	 allocate_field_data(ntiles_out, scalar_out, grid_out, l);
-	 if( opcode & BILINEAR )
-	    do_scalar_bilinear_interp(interp, l, ntiles_in, grid_in, grid_out, scalar_in, scalar_out, finer_step, fill_missing);
-	 else
-	    do_scalar_conserve_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, scalar_in, scalar_out, opcode);
-	 write_field_data(ntiles_out, scalar_out, grid_out, l, m);
-	 if(opcode & CONSERVE_ORDER2) {
-	    for(n=0; n<ntiles_in; n++) {
-	       free(scalar_in[n].grad_x);
-	       free(scalar_in[n].grad_y);
-	       if(scalar_in[n].var[l].has_missing) free(scalar_in[n].grad_mask);
-	    }
-	 }
-	 for(n=0; n<ntiles_in; n++) free(scalar_in[n].data);
-	 for(n=0; n<ntiles_out; n++) free(scalar_out[n].data);
-      }
-
-      /* then interp vector field */
-      for(l=0; l<nvector; l++) {
-	 if( !u_in[n].var[l].has_taxis && m>0) continue;
-	 level = m + u_in->var[l].lstart;
-	 get_input_data(ntiles_in, u_in, grid_in, bound_T, l, level, opcode);
-	 get_input_data(ntiles_in, v_in, grid_in, bound_T, l, level, opcode);
-	 allocate_field_data(ntiles_out, u_out, grid_out, l);
-	 allocate_field_data(ntiles_out, v_out, grid_out, l);
-	 if( opcode & BILINEAR )
-	    do_vector_bilinear_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, u_in, v_in, u_out, v_out, finer_step, fill_missing);
-	 else
-	    do_vector_conserve_interp(interp, l, ntiles_in, grid_in, ntiles_out, grid_out, u_in, v_in, u_out, v_out, opcode);
-      
-	 write_field_data(ntiles_out, u_out, grid_out, l, m);
-	 write_field_data(ntiles_out, v_out, grid_out, l, m);
-	 for(n=0; n<ntiles_in; n++) {
-	    free(u_in[n].data);
-	    free(v_in[n].data);
-	 }
-	 for(n=0; n<ntiles_out; n++) {
-	    free(u_out[n].data);
-	    free(v_out[n].data);
-	 }      
-      }
-   }
-
-   if(mpp_pe() == mpp_root_pe() ) {
-      printf("Successfully running fregrid and the following output file are generated.\n");
-      for(n=0; n<ntiles_out; n++) {
-	 mpp_close(file_out[n].fid);
-	 printf("****%s\n", file_out[n].name);
-	 if( nfiles > 1 ) {
-	    mpp_close(file2_out[n].fid);
-	    printf("****%s\n", file2_out[n].name);
-	 }
-      }
-   }
-   return 0;
-}
-int 
-gs_make_topog(char *history, char *mosaic_file, char *topog_type, 
-              int x_refine, int y_refine, 
-              double basin_depth, char *topog_file, double bottom_depth, 
-              double min_depth, double scale_factor, int num_filter_pass, 
-              double gauss_amp, double gauss_scale, double slope_x,
-              double slope_y, double bowl_south, double bowl_north, 
-              double bowl_west, double bowl_east, int fill_first_row, 
-              int filter_topog, int round_shallow, int fill_shallow, 
-              int deepen_shallow, int smooth_topo_allow_deepening, 
-              char *output_file)
-{
-  char   *topog_field = NULL;
-  int    option_index, i, c;
-
-  if(x_refine != 2 || y_refine != 2 ) mpp_error("Error from make_topog: x_refine and y_refine should be 2, contact developer");
-  if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> x_refine is %d, y_refine is %d\n",
-				       x_refine, y_refine);
-
-  if (strcmp(topog_type,"rectangular_basin") == 0) {
-    if(mpp_pe() == mpp_root_pe()) printf("NOTE from make_topog ==> the basin depth is %f\n",basin_depth);
-  }
-  else if (strcmp(topog_type,"gaussian") == 0) {
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n", bottom_depth );
-      printf("NOTE from make_topog ==> min_depth is: %f\n", min_depth );
-      printf("NOTE from make_topog ==> gauss_amp is: %f\n", gauss_amp );
-      printf("NOTE from make_topog ==> gauss_scale is: %f\n", gauss_scale );
-      printf("NOTE from make_topog ==> slope_x is: %f\n", slope_x );
-      printf("NOTE from make_topog ==> slope_y is: %f\n", slope_y );      
-    }
-  }
-  else if(strcmp(topog_type,"bowl") == 0) {
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
-      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
-      printf("NOTE from make_topog ==> bowl_south is: %f\n",bowl_south);
-      printf("NOTE from make_topog ==> bowl_north is: %f\n",bowl_north);
-      printf("NOTE from make_topog ==> bowl_west is: %f\n",bowl_west);
-      printf("NOTE from make_topog ==> bowl_east is: %f\n",bowl_east);
-    }
-  }
-  else if(strcmp(topog_type,"idealized") == 0) {
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
-      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
-    }
-  }
-  else if(strcmp(topog_type,"realistic") == 0) {
-    if(!topog_file || !topog_field)
-      mpp_error("Error from make_topog: when topog_type is realistic, topog_file and topog_field must be specified.");
-    if(mpp_pe() == mpp_root_pe()){
-      printf("NOTE from make_topog ==> bottom_depth is: %f\n",bottom_depth);
-      printf("NOTE from make_topog ==> min_depth is: %f\n",min_depth);
-      printf("NOTE from make_topog ==> topog_file is: %s\n", topog_file);
-      printf("NOTE from make_topog ==> topog_field is: %s\n", topog_field);
-      printf("NOTE from make_topog ==> scale_factor is: %f\n", scale_factor);
-      printf("NOTE from make_topog ==> num_filter_pass is: %d\n", num_filter_pass);
-      if(fill_first_row) printf("NOTE from make_topog ==>make first row of ocean model all land points.\n");
-      if(filter_topog) printf("NOTE from make_topog ==>will apply filter to topography.\n");
-      if(round_shallow) printf("NOTE from make_topog ==>Make cells land if depth is less than 1/2 "
-			       "mimumim depth, otherwise make ocean.\n");
-      if(fill_shallow) printf("NOTE from make_topog ==>Make cells less than minimum depth land.\n");
-      if(deepen_shallow) printf("NOTE from make_topog ==>Make cells less than minimum depth equal to minimum depth.\n");
-      if(smooth_topo_allow_deepening) printf("NOTE from make_topog ==>allow filter to deepen cells.\n");
-    }
-  }
-  else {
-    mpp_error("make_topog: topog_type should be rectangular_basin, gaussian, bowl, idealized or realistic");
-  }
-  
-  if(mpp_pe() == mpp_root_pe()) {
-    printf("**************************************************\n");
-    printf("Begin to generate topography \n");
-  }
-
-  {
-#define STRING 255
-    int m_fid, g_fid, vid;
-    int ntiles, fid, dim_ntiles, n, dims[2];
-    size_t start[4], nread[4], nwrite[4];
-    int *nx, *ny, *nxp, *nyp;
-    int *id_depth;
-    double *depth, *x, *y;
-    char **tile_files;
-    char history[512], dimx_name[128], dimy_name[128], depth_name[128];
-    char gridfile[256], griddir[256];
-    
-    /* history will be write out as global attribute
-       in output file to specify the command line arguments
-    */
-
-    /* grid should be located in the same directory of mosaic file */
-    get_file_path(mosaic_file, griddir);
-    
-    /* get mosaic dimension */
-    m_fid = mpp_open(mosaic_file, MPP_READ);
-    ntiles = mpp_get_dimlen( m_fid, "ntiles");
-    tile_files = (char **)malloc(ntiles*sizeof(double *));
-    id_depth = (int *)malloc(ntiles*sizeof(int));
-    /* loop through each tile to get tile information and set up meta data for output file */
-    fid = mpp_open(output_file, MPP_WRITE);
-    mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-    mpp_def_global_att(fid, "code_version", TAGNAME);
-    mpp_def_global_att(fid, "history", history);
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    nx = (int *)malloc(ntiles*sizeof(int));
-    ny = (int *)malloc(ntiles*sizeof(int));
-    nxp = (int *)malloc(ntiles*sizeof(int));
-    nyp = (int *)malloc(ntiles*sizeof(int));   
-    for( n = 0; n < ntiles; n++ ) {
-      tile_files[n] = (char *)malloc(STRING*sizeof(double));
-      start[0] = n;
-      start[1] = 0;
-      nread[0] = 1;
-      nread[1] = STRING;
-      vid = mpp_get_varid(m_fid, "gridfiles");
-      mpp_get_var_value_block(m_fid, vid, start, nread, gridfile);
-      sprintf(tile_files[n], "%s/%s", griddir, gridfile);
-      g_fid = mpp_open(tile_files[n], MPP_READ);
-      nx[n] = mpp_get_dimlen(g_fid, "nx");
-      ny[n] = mpp_get_dimlen(g_fid, "ny");
-      if( nx[n]%x_refine != 0 ) mpp_error("make_topog: supergrid x-size can not be divided by x_refine");
-      if( ny[n]%y_refine != 0 ) mpp_error("make_topog: supergrid y-size can not be divided by y_refine");
-      nx[n] /= x_refine;
-      ny[n] /= y_refine;
-      nxp[n] = nx[n] + 1;
-      nyp[n] = ny[n] + 1;
-      if(ntiles == 1) {
-	strcpy(dimx_name, "nx");
-	strcpy(dimy_name, "ny");
-	strcpy(depth_name, "depth");
-      }
-      else {
-	sprintf(dimx_name, "nx_tile%d", n+1);
-	sprintf(dimy_name, "ny_tile%d", n+1);
-	sprintf(depth_name, "depth_tile%d", n+1);
-      }
-
-      dims[1] = mpp_def_dim(fid, dimx_name, nx[n]); 
-      dims[0] = mpp_def_dim(fid, dimy_name, ny[n]);
-      id_depth[n] = mpp_def_var(fid, depth_name, NC_DOUBLE, 2, dims,  2, "standard_name",
-				"topographic depth at T-cell centers", "units", "meters");
-      mpp_close(g_fid);
-    }
-    mpp_close(m_fid);
-    mpp_end_def(fid);
-
-    /* Generate topography and write out to the output_file */
-    for(n=0; n<ntiles; n++) {
-      int layout[2], isc, iec, jsc, jec, nxc, nyc, ni, i, j;
-      double *gdata, *tmp;
-      domain2D domain;
-      
-      /* define the domain, each tile will be run on all the processors. */
-      mpp_define_layout( nx[n], ny[n], mpp_npes(), layout);
-      mpp_define_domain2d( nx[n], ny[n], layout, 0, 0, &domain);
-      mpp_get_compute_domain2d( domain, &isc, &iec, &jsc, &jec);
-      nxc = iec - isc + 1;
-      nyc = jec - jsc + 1;
-      
-      depth = (double *)malloc(nxc*nyc*sizeof(double));
-      x     = (double *)malloc((nxc+1)*(nyc+1)*sizeof(double));
-      y     = (double *)malloc((nxc+1)*(nyc+1)*sizeof(double));
-      tmp   = (double *)malloc((nxc*x_refine+1)*(nyc*y_refine+1)*sizeof(double));
-      start[0] = jsc*y_refine; start[1] = isc*x_refine;
-      nread[0] = nyc*y_refine+1; nread[1] = nxc*x_refine+1;
-      ni       = nxc*x_refine+1;
-      g_fid = mpp_open(tile_files[n], MPP_READ);
-      vid = mpp_get_varid(g_fid, "x");
-      mpp_get_var_value_block(g_fid, vid, start, nread, tmp);
-      for(j = 0; j < nyc+1; j++) for(i = 0; i < nxc+1; i++)
-	x[j*(nxc+1)+i] = tmp[(j*y_refine)*ni+i*x_refine];
-      vid = mpp_get_varid(g_fid, "y");
-      mpp_get_var_value_block( g_fid, vid, start, nread, tmp);
-      mpp_close(g_fid);
-      for(j = 0; j < nyc+1; j++) for(i = 0; i < nxc+1; i++)
-	y[j*(nxc+1)+i] = tmp[(j*y_refine)*ni+i*x_refine];
-      if (strcmp(topog_type,"rectangular_basin") == 0)
-	create_rectangular_topog(nx[n], ny[n], basin_depth, depth);
-      else if (strcmp(topog_type,"gaussian") == 0)
-	create_gaussian_topog(nx[n], ny[n], x, y, bottom_depth, min_depth,
-			      gauss_amp, gauss_scale, slope_x, slope_y, depth);
-      else if (strcmp(topog_type,"bowl") == 0)
-	create_bowl_topog(nx[n], ny[n], x, y, bottom_depth, min_depth, bowl_east,
-			  bowl_south, bowl_west, bowl_north, depth);
-      else if (strcmp(topog_type,"idealized") == 0)
-	create_idealized_topog( nx[n], ny[n], x, y, bottom_depth, min_depth, depth);
-      else if (strcmp(topog_type,"realistic") == 0)
-	create_realistic_topog(nxc, nyc, x, y, topog_file, topog_field, scale_factor,
-			       fill_first_row, filter_topog, num_filter_pass,
-			       smooth_topo_allow_deepening, round_shallow, fill_shallow,
-			       deepen_shallow, min_depth, depth );
-      gdata = (double *)malloc(nx[n]*ny[n]*sizeof(double));
-      mpp_global_field_double(domain, nxc, nyc, depth, gdata);
-      mpp_put_var_value(fid, id_depth[n], gdata);
-      free(x);
-      free(y);
-      free(tmp);
-      free(depth);
-      free(gdata);
-      mpp_delete_domain2d(&domain);
-    }
-    mpp_close(fid);
-  
-    /*release memory */
-    free(id_depth);
-    for(n=0; n<ntiles; n++) free(tile_files[n]);
-    free(tile_files);
-    free(nx);
-    free(ny);
-    free(nxp);
-    free(nyp);
-  }
-  return 0;
-}
-
-#define MAXTILE 100
-#define MAXCONTACT 100
-#define SHORTSTRING 32
-
-int
-gs_make_solo_mosaic(char *history, int ntiles, char *mosaic_name, char *grid_descriptor,
-                    char **tilefile, double periodx, double periody, char *dir)
-{
-   char *pch=NULL;
-   char tiletype[MAXTILE][SHORTSTRING];
-   char tile_name[MAXTILE][STRING];
-   int nfiles=0, ncontact=0;
-   int *nxp, *nyp;
-   double **x, **y;
-   int contact_tile1[MAXCONTACT], contact_tile2[MAXCONTACT];
-   int contact_tile1_istart[MAXCONTACT], contact_tile1_iend[MAXCONTACT];
-   int contact_tile1_jstart[MAXCONTACT], contact_tile1_jend[MAXCONTACT];
-   int contact_tile2_istart[MAXCONTACT], contact_tile2_iend[MAXCONTACT];
-   int contact_tile2_jstart[MAXCONTACT], contact_tile2_jend[MAXCONTACT];
-   int c, i, n, m, l, errflg;
-    
-   /*--- if file name is not specified through -f, file name will be horizontal_grid.tile#.nc */
-   if(nfiles == 0) {
-      if(ntiles == 1) {
-	 sprintf(tilefile[0],"horizontal_grid.nc");
-      }
-      else {
-	 for(n=0; n<ntiles; n++) {
-	    sprintf(tilefile[n],"horizontal_grid.tile%d.nc",n+1);
-	 }
-      }
-   }
-   else { /* Check if ntile are matching number of grid file passed through -f */
-      if( nfiles != ntiles) mpp_error("make_solo_mosaic: number of grid files specified through -n "
-      " does not equal to number of files specified through -f = ");
-   }
-
-   n = strlen(dir);
-   if( dir[n-1] != '/') strcat(dir, "/");
-
-   /*First read all the grid files.*/
-   nxp = (int *)malloc(ntiles*sizeof(int));
-   nyp = (int *)malloc(ntiles*sizeof(int));
-   x = (double **)malloc(ntiles*sizeof(double *));
-   y = (double **)malloc(ntiles*sizeof(double *));
-   for(n=0; n<ntiles; n++) {
-      char filepath[512];
-      int fid, vid;
-      sprintf(filepath, "%s%s",dir, tilefile[n]);
-      fid = mpp_open(filepath, MPP_READ);
-      nxp[n] = mpp_get_dimlen(fid, "nxp");
-      nyp[n] = mpp_get_dimlen(fid, "nyp");
-      x[n] = (double *)malloc(nxp[n]*nyp[n]*sizeof(double));
-      y[n] = (double *)malloc(nxp[n]*nyp[n]*sizeof(double));
-      vid = mpp_get_varid(fid, "tile");
-      mpp_get_var_value(fid, vid, tile_name[n]);
-      vid = mpp_get_varid(fid, "x");
-      mpp_get_var_value(fid, vid, x[n]);
-      vid = mpp_get_varid(fid, "y");
-      mpp_get_var_value(fid, vid, y[n]);
-      mpp_close(fid);
-   }
-
-
-   /*find the contact region between tiles, currently assume the contact region are align-contact
-     There should be no contact between same directions of two tiles ( w-w, e-e, s-s, n-n)
-     We assume no contact between w-s, e-n ( will added in if needed ) . */
-   ncontact = 0;
-   for(n=0; n<ntiles; n++) {
-      for(m=n; m<ntiles; m++) {
-	 int count;
-	 int istart1[MAXCONTACT], iend1[MAXCONTACT], jstart1[MAXCONTACT], jend1[MAXCONTACT];
-	 int istart2[MAXCONTACT], iend2[MAXCONTACT], jstart2[MAXCONTACT], jend2[MAXCONTACT];
-	 count = get_align_contact(n+1, m+1, nxp[n], nyp[n], nxp[m], nyp[m], x[n], y[n], x[m], y[m],
-	 periodx, periody, istart1, iend1, jstart1, jend1, istart2, iend2,
-	 jstart2, jend2);
-	 if(ncontact+count>MAXCONTACT) mpp_error("make_solo_mosaic: number of contacts is more than MAXCONTACT");
-	 for(l=0; l<count; l++) {
-	    contact_tile1_istart[ncontact] = istart1[l];
-	    contact_tile1_iend  [ncontact] = iend1[l];
-	    contact_tile1_jstart[ncontact] = jstart1[l];
-	    contact_tile1_jend  [ncontact] = jend1[l];
-	    contact_tile2_istart[ncontact] = istart2[l];
-	    contact_tile2_iend  [ncontact] = iend2[l];
-	    contact_tile2_jstart[ncontact] = jstart2[l];
-	    contact_tile2_jend  [ncontact] = jend2[l];
-	    contact_tile1       [ncontact] = n;
-	    contact_tile2       [ncontact] = m;
-	    ncontact++;
-	 }
-      }
-   }
-
-   /* write out data */
-   {
-      char str[STRING], outfile[STRING];
-      int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-      int id_contact_index, id_griddir, id_gridfiles, dim[2];
-      size_t start[4], nwrite[4];
-
-      sprintf(outfile, "%s.nc", mosaic_name);
-      fid = mpp_open(outfile, MPP_WRITE);
-      /* define dimenison */
-      dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-      if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-      dim_string = mpp_def_dim(fid, "string", STRING);    
-      /* define variable */
-      id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 4, "standard_name",
-      "grid_mosaic_spec", "children", "gridtiles", "contact_regions", "contacts",
-      "grid_descriptor", grid_descriptor);
-      dim[0] = dim_ntiles; dim[1] = dim_string;
-      id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-      "standard_name", "grid_file_location");
-      id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-      id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-      if(ncontact>0) {
-	 dim[0] = dim_ncontact; dim[1] = dim_string;
-	 id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-	 "contact_type", "boundary", "alignment", "true",
-	 "contact_index", "contact_index", "orientation", "orient");
-	 id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-	 "starting_ending_point_index_of_contact");
-
-      }
-      mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-      mpp_def_global_att(fid, "code_version", TAGNAME);
-      mpp_def_global_att(fid, "history", history);
-      mpp_end_def(fid);
-
-      /* write out data */
-      for(i=0; i<4; i++) {
-	 start[i] = 0; nwrite[i] = 1;
-      }
-      nwrite[0] = strlen(mosaic_name);
-      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-      nwrite[0] = strlen(dir);
-      mpp_put_var_value_block(fid, id_griddir, start, nwrite, dir);
-      nwrite[0] = 1;
-      for(n=0; n<ntiles; n++) {
-	 start[0] = n; nwrite[1] = strlen(tile_name[n]);
-	 mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-	 nwrite[1] = strlen(tilefile[n]);
-	 mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-      }
-    
-      for(n=0; n<ncontact; n++) {
-	 sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-	 tile_name[contact_tile2[n]]);
-	 start[0] = n; nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-	 sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-	 contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-	 contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-	 nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-      }
-      mpp_close(fid);    
-   }
-   return 0;
-}
-
-#include "create_xgrid.h"
-#include "constant.h"
-#include "mosaic_util.h"
-#include "tool_util.h"
-
-const double LARGE_VALUE       = 1e20;
-const int    X_CYCLIC          = 1;
-const int    Y_CYCLIC          = 2;
-const int    CUBIC_GRID        = 4;
-const int    x_refine          = 2;
-const int    y_refine          = 2;
-const double EPSLN             = 1.e-4;
-const double MIN_AREA_RATIO    = 1.e-6;
-const char   subA_name[]       = "subA";
-const char   tocell_name[]     = "tocell";
-const char   travel_name[]     = "travel";
-const char   basin_name[]      = "basin";
-const char   cellarea_name[]   = "cellarea";
-const char   celllength_name[] = "celllength";
-const char   landfrac_name[]   = "land_frac";
-const char   version[]         = "0.1";
-const int    ncells = 3;
-char   xaxis_name[128];
-char   yaxis_name[128];
-char   gridx_name[] = "grid_x";
-char   gridy_name[] = "grid_y";
-char   x_name[]     = "x";
-char   y_name[]     = "y";
-int    sizeof_int  = 0;
-int    sizeof_double = 0;
-double suba_cutoff = 1.e12;  
-#define D2R (M_PI/180.)
-
-
-int
-gs_river_regrid(char *history, char *mosaic_file, char *river_src_file, 
-   char *output_file)
-{
-   unsigned int opcode = 0;  
-   int          option_index, c;
-   int          ntiles, n;
-   char         land_mosaic_dir[256];
-   char         land_mosaic[256];
-   char         land_mosaic_file[256];  
-  
-   river_type river_in;
-   river_type *river_out; /* may be more than one tile */
-
-   /* check the arguments */
-   if( !mosaic_file    ) mpp_error("fregrid: mosaic_grid is not specified");
-   if( !river_src_file ) mpp_error("fregrid: river_source_file is not specified");
-
-#ifdef test_qsort  
-   {
-      /* test qsort_index here */
-      int    i, size = 7;
-      double array[]={12,5,18,25,14, 4,11};
-      int    rank[]={1,2,3,4,5,6,7};
-
-      qsort_index(array, 0, size-1, rank);
-      for(i=0; i<size; i++) printf("value = %f, rank = %d \n", array[i], rank[i]);
-   }
-#endif
-  
-   /* First read the source data and source grid */
-   get_source_data(river_src_file, &river_in);
-
-   /* get the mosaic grid information */
-   {
-      int fid, vid;
-      get_file_path(mosaic_file, land_mosaic_dir);
-      fid = mpp_open(mosaic_file, MPP_READ);
-      vid = mpp_get_varid(fid, "lnd_mosaic_file");
-      mpp_get_var_value(fid, vid, land_mosaic_file);
-      sprintf(land_mosaic, "%s/%s", land_mosaic_dir, land_mosaic_file);
-      mpp_close(fid);
-      fid = mpp_open(land_mosaic, MPP_READ);
-      ntiles = mpp_get_dimlen( fid, "ntiles");
-      mpp_close(fid);
-   }
-   river_out = (river_type *)malloc(ntiles*sizeof(river_type));
-  
-   get_mosaic_grid(mosaic_file, land_mosaic, ntiles, river_out, &opcode);
-
-   init_river_data(ntiles, river_out, &river_in);
-  
-   calc_max_subA(&river_in, river_out, ntiles, opcode );
-
-   calc_tocell(ntiles, river_out, opcode );
-
-   calc_river_data(ntiles, river_out, opcode );
-
-   sort_basin(ntiles, river_out);
-  
-   check_river_data(ntiles, river_out);
-  
-   write_river_data(river_src_file, output_file, river_out, history, ntiles);
-  
-   printf("Successfully running river_regrid and the following output file are generated.\n");
-   for(n=0; n<ntiles; n++) printf("****%s\n", river_out[n].filename);
-   return 0;
-}
-
-/*------------------------------------------------------------------------------
-  void get_source_data(char *src_file)
-  read the source file to get the source grid and river network data
-  -----------------------------------------------------------------------------*/
-void get_source_data(const char *src_file, river_type *river_data)
-{
-   int nx, ny, nxp, nyp;
-   int i, j;
-   int fid, vid;
-   double dbl_missing;
-
-   fid = mpp_open(src_file, MPP_READ);
-   vid = mpp_get_varid(fid, subA_name);
-  
-   mpp_get_var_dimname(fid, vid, 1, xaxis_name);
-   mpp_get_var_dimname(fid, vid, 0, yaxis_name);
-   nx  = mpp_get_dimlen(fid, xaxis_name );
-   ny  = mpp_get_dimlen(fid, yaxis_name );
-   nxp = nx + 1;
-   nyp = ny + 1;
-   river_data->nx  = nx;
-   river_data->ny  = ny;
-  
-   river_data->xt   = (double *)malloc(nx*sizeof(double));
-   river_data->yt   = (double *)malloc(ny*sizeof(double));
-   river_data->xb   = (double *)malloc(nxp*sizeof(double)); 
-   river_data->yb   = (double *)malloc(nyp*sizeof(double));
-   river_data->xb_r = (double *)malloc(nxp*sizeof(double)); 
-   river_data->yb_r = (double *)malloc(nyp*sizeof(double));
-   river_data->subA = (double *)malloc(nx*ny*sizeof(double));
-   mpp_get_var_att(fid, vid, "missing_value", &(river_data->subA_missing) );
-   vid = mpp_get_varid(fid, tocell_name);
-   mpp_get_var_att(fid, vid, "missing_value", &dbl_missing );
-   river_data->tocell_missing = dbl_missing;
-   vid = mpp_get_varid(fid, travel_name);
-   mpp_get_var_att(fid, vid, "missing_value", &dbl_missing );
-   river_data->travel_missing = dbl_missing;
-   vid = mpp_get_varid(fid, basin_name);
-   mpp_get_var_att(fid, vid, "missing_value", &dbl_missing );
-   river_data->basin_missing = dbl_missing;
-   vid = mpp_get_varid(fid, cellarea_name);
-   mpp_get_var_att(fid, vid, "missing_value", &(river_data->cellarea_missing) );
-   vid = mpp_get_varid(fid, celllength_name);
-   mpp_get_var_att(fid, vid, "missing_value", &(river_data->celllength_missing) );
-
-   vid = mpp_get_varid(fid, subA_name);
-   mpp_get_var_value(fid, vid, river_data->subA);
-   vid = mpp_get_varid(fid, xaxis_name);
-   mpp_get_var_value(fid, vid, river_data->xt);
-   vid = mpp_get_varid(fid, yaxis_name);
-   mpp_get_var_value(fid, vid, river_data->yt);
-   mpp_close(fid);
-  
-   for(i=1; i<nx; i++ ) river_data->xb[i] = 0.5*(river_data->xt[i-1]+river_data->xt[i]);
-   for(j=1; j<ny; j++ ) river_data->yb[j] = 0.5*(river_data->yt[j-1]+river_data->yt[j]);
-   river_data->xb[0] = 2*river_data->xt[0] - river_data->xb[1];
-   river_data->yb[0] = 2*river_data->yt[0] - river_data->yb[1];
-   river_data->xb[nx] = 2*river_data->xt[nx-1] - river_data->xb[nx-1];
-   river_data->yb[ny] = 2*river_data->yt[ny-1] - river_data->yb[ny-1];
-
-   /* make sure the xb is in the range [0,360] and yb is in the range [-90,90] */
-   if(fabs(river_data->xb[0]) > EPSLN) mpp_error("river_regrid: The starting longitude of grid bound is not 0");
-   if(fabs(river_data->xb[nx]-360) > EPSLN) mpp_error("river_regrid: The ending longitude of grid bound is not 360");  
-   if(fabs(river_data->yb[0]+90) > EPSLN) mpp_error("river_regrid: The starting latitude of grid bound is not -90");
-   if(fabs(river_data->yb[ny]-90) > EPSLN) mpp_error("river_regrid: The ending latitude of grid bound is not 90");  
-   river_data->xb[0]  = 0.;
-   river_data->xb[nx] = 360.;
-   river_data->yb[0]  = -90.;
-   river_data->yb[ny] = 90.;
-   for(j=0; j<nyp; j++) river_data->yb_r[j] = river_data->yb[j]*D2R;
-   for(i=0; i<nxp; i++) river_data->xb_r[i] = river_data->xb[i]*D2R;
-
-}
-
-/*----------------------------------------------------------------------
-  read the grid of detination mosaic. 
-  void get_mosaic_grid(char *file)
-  where file is the coupler mosaic file.
-  --------------------------------------------------------------------*/
-void get_mosaic_grid(const char *coupler_mosaic, const char *land_mosaic, int ntiles, river_type *river_data, unsigned int *opcode)
-{
-   int    n_xgrid_files, nx, ny, nxp, nyp, ni, nj, nip, njp;
-   int    n, m, i, j, ii, jj, nxp2, nyp2;
-   size_t start[4], nread[4];
-   char   dir[STRING], gridfile[STRING], tilefile[STRING];
-   char   tilename[STRING], land_mosaic_name[STRING];
-   char   **xgrid_file;
-   double *x, *y;
-   double **pxt, **pyt;
-   char *pfile;
-   int  m_fid, m_vid, g_fid, g_vid;
-
-   /* coupler_mosaic, land_mosaic, and exchange grid file should be located in the same directory */
-   get_file_path(coupler_mosaic, dir);
-  
-   m_fid = mpp_open(coupler_mosaic, MPP_READ);
-   m_vid = mpp_get_varid(m_fid, "lnd_mosaic");
-   mpp_get_var_value(m_fid, m_vid, land_mosaic_name);
-  
-   /* get the exchange grid file name */
-   n_xgrid_files = mpp_get_dimlen(m_fid, "nfile_aXl");
-   xgrid_file = (char **)malloc(n_xgrid_files*sizeof(char *));
-
-   m_vid = mpp_get_varid(m_fid, "aXl_file");
-   for(n=0; n<n_xgrid_files; n++) {
-      xgrid_file[n] = (char *)malloc(STRING*sizeof(char));
-      start[0] = n;
-      start[1] = 0;
-      nread[0] = 1;
-      nread[1] = STRING;    
-      mpp_get_var_value_block(m_fid, m_vid, start, nread, xgrid_file[n]);
-   }
-   mpp_close(m_fid);
-   m_fid = mpp_open(land_mosaic, MPP_READ);
-   m_vid = mpp_get_varid(m_fid, "gridfiles");
-  
-   for( n = 0; n < ntiles; n++ ) {
-      double *area;
-    
-      start[0] = n;
-      start[1] = 0;
-      nread[0] = 1;
-      nread[1] = STRING;
-      mpp_get_var_value_block(m_fid, m_vid, start, nread, tilefile);
-      sprintf(gridfile, "%s/%s", dir, tilefile);
-      g_fid = mpp_open(gridfile, MPP_READ);
-      ni = mpp_get_dimlen(g_fid, "nx");
-      nj = mpp_get_dimlen(g_fid, "ny");
-      nip = ni + 1;
-      njp = nj + 1;
-      x = (double *)malloc(nip*njp*sizeof(double));
-      y = (double *)malloc(nip*njp*sizeof(double));
-      g_vid = mpp_get_varid(g_fid, "x");
-      mpp_get_var_value(g_fid, g_vid, x);
-      g_vid = mpp_get_varid(g_fid, "y");
-      mpp_get_var_value(g_fid, g_vid, y);
-      mpp_close(g_fid);
-      if( ni%x_refine != 0 ) mpp_error("river_regrid: supergrid x-size can not be divided by x_refine");
-      if( nj%y_refine != 0 ) mpp_error("river_regrid: supergrid y-size can not be divided by y_refine");
-      nx   = ni/x_refine;
-      ny   = nj/y_refine;
-      nxp  = nx + 1;
-      nyp  = ny + 1;
-      nxp2 = nx + 2;
-      nyp2 = ny + 2;
-      river_data[n].nx       = nx;
-      river_data[n].ny       = ny;
-      river_data[n].xt       = (double *)malloc(nxp2*nyp2*sizeof(double));        
-      river_data[n].yt       = (double *)malloc(nxp2*nyp2*sizeof(double));
-      river_data[n].xb       = (double *)malloc(nxp*nyp*sizeof(double));
-      river_data[n].yb       = (double *)malloc(nxp*nyp*sizeof(double));
-      river_data[n].xb_r     = (double *)malloc(nxp*nyp*sizeof(double));
-      river_data[n].yb_r     = (double *)malloc(nxp*nyp*sizeof(double));    
-      river_data[n].area     = (double *)malloc(nx*ny*sizeof(double));
-      river_data[n].landfrac = (double *)malloc(nx*ny*sizeof(double));    
-      area                   = (double *)malloc(nx*ny*sizeof(double));
-    
-      /* copy the data from super grid to fine grid */
-      for(i=0; i<nx*ny; i++) area[i] = 0.0;
-      for(j = 0; j < ny; j++) for(i = 0; i < nx; i++) {
-	    ii = i+1;
-	    jj = j+1;
-	    river_data[n].xt[jj*nxp2+ii] = x[(j*y_refine+1)*nip+i*x_refine+1];
-	    river_data[n].yt[jj*nxp2+ii] = y[(j*y_refine+1)*nip+i*x_refine+1];
-	 }
-      for(j = 0; j < nyp; j++) for(i = 0; i < nxp; i++) {
-	    river_data[n].xb[j*nxp+i] = x[(j*y_refine)*nip+i*x_refine];
-	    river_data[n].yb[j*nxp+i] = y[(j*y_refine)*nip+i*x_refine];
-	 }     
-      free(x);
-      free(y);
-      /* calculate cell area */
-
-      for(m=0; m<nxp*nyp; m++) {
-	 river_data[n].xb_r[m] = river_data[n].xb[m] * D2R;
-	 river_data[n].yb_r[m] = river_data[n].yb[m] * D2R;
-      }
-      get_grid_area(&nx, &ny, river_data[n].xb_r, river_data[n].yb_r, river_data[n].area);
-
-      /* calculate the land fraction */
-      sprintf(tilename, "X%s_tile%d", land_mosaic_name, n+1);
-      for(m=0; m<n_xgrid_files; m++) {
-	 if(strstr(xgrid_file[m],tilename)) {
-	    int    nxgrid, l;
-	    int    *i1, *j1, *i2, *j2;
-	    double *xgrid_area;
-	    char filewithpath[512];
-	
-	    sprintf(filewithpath, "%s/%s", dir, xgrid_file[m]);
-	    g_fid = mpp_open(filewithpath, MPP_READ);
-	    nxgrid = mpp_get_dimlen(g_fid, "ncells");
-	    mpp_close(g_fid);
-	    i1         = (int    *)malloc(nxgrid*sizeof(int));
-	    j1         = (int    *)malloc(nxgrid*sizeof(int));	  
-	    i2         = (int    *)malloc(nxgrid*sizeof(int));
-	    j2         = (int    *)malloc(nxgrid*sizeof(int));
-	    xgrid_area = (double *)malloc(nxgrid*sizeof(double));
-	    read_mosaic_xgrid_order1(filewithpath, i1, j1, i2, j2, xgrid_area);
-	    for(l=0; l<nxgrid; l++) area[j2[l]*nx+i2[l]] += xgrid_area[l];
-	    free(i1);
-	    free(j1);
-	    free(i2);
-	    free(j2);
-	 }
-      }
-
-      for(m=0; m<nx*ny; m++) area[m] *= 4*M_PI*RADIUS*RADIUS;
-      for(m=0; m<nx*ny; m++) {
-	 river_data[n].landfrac[m] = area[m]/river_data[n].area[m];
-	 /* consider truncation error */
-	 if(fabs(river_data[n].landfrac[m]-1) < EPSLN) river_data[n].landfrac[m] = 1;
-	 if(fabs(river_data[n].landfrac[m])   < EPSLN) river_data[n].landfrac[m] = 0;
-	 if(river_data[n].landfrac[m] > 1 || river_data[n].landfrac[m] < 0)
-	    mpp_error("river_regrid: land_frac should be between 0 or 1");
-      }
-      free(area);
-   } /* n = 0, ntiles */
-
-   mpp_close(m_fid);
-  
-   /* currently we are assuming all the times have the same grid size */
-   for(n=1; n<ntiles; n++) {
-      if(river_data[n].nx != river_data[0].nx || river_data[n].ny != river_data[0].ny )
-	 mpp_error("river_regrid: all the tiles should have the same grid size");
-   }
-  
-   /*----------------------------------------------------------------------------
-     get boundary condition, currently we are assuming the following case,
-     solid walls: number of contact will be 0.
-     x-cyclic:    number of contact will be 1.
-     y-cyclic:    number of contact will be 1.
-     torus:       number of contact will be 2.
-     cubic:       number of contact will be 12.
-     --------------------------------------------------------------------------*/
-   {
-      int ncontact;
-      int *tile1, *tile2;
-      int *istart1, *iend1, *jstart1, *jend1;
-      int *istart2, *iend2, *jstart2, *jend2;
-    
-      ncontact = read_mosaic_ncontacts(land_mosaic);
-      tile1   = (int *)malloc(ncontact*sizeof(int));
-      tile2   = (int *)malloc(ncontact*sizeof(int));
-      istart1 = (int *)malloc(ncontact*sizeof(int));
-      iend1   = (int *)malloc(ncontact*sizeof(int));
-      jstart1 = (int *)malloc(ncontact*sizeof(int));
-      jend1   = (int *)malloc(ncontact*sizeof(int));
-      istart2 = (int *)malloc(ncontact*sizeof(int));
-      iend2   = (int *)malloc(ncontact*sizeof(int));
-      jstart2 = (int *)malloc(ncontact*sizeof(int));
-      jend2   = (int *)malloc(ncontact*sizeof(int));
-      if(ncontact >0) {
-	 read_mosaic_contact(land_mosaic, tile1, tile2, istart1, iend1,
-	 jstart1, jend1, istart2, iend2, jstart2, jend2);
-	 if(ncontact <= 2) { /* x-cyclic of y-cyclic */
-	    if(ntiles !=1) mpp_error("river_regrid: number of tiles must be 1 for single contact");
-	    for(n=0; n<ncontact; n++) {
-	       if(istart1[n] == iend1[n] && istart2[n] == iend2[n] ) /* x_cyclic */
-		  *opcode |= X_CYCLIC;
-	       else if(jstart1[n] == jend1[n] && istart2[n] == iend2[n] ) /* x_cyclic */
-		  *opcode |= Y_CYCLIC;
-	       else
-		  mpp_error("river_regrid: for one-tile mosaic, the boundary condition should be either x-cyclic or y-cyclic");
-	    }
-	 }
-	 else if(ncontact == 12) {
-	    if(ntiles != 6) mpp_error("river_regrid: the mosaic must be a 6-tile cubic grid for 12 contacts.");
-	    *opcode |= CUBIC_GRID;
-	 }
-	 else
-	    mpp_error("river_regrid: the number of contact should be either 0, 1, 2 or 6");
-      }
-
-      free(tile1);
-      free(tile2);
-      free(istart1);
-      free(iend1);
-      free(jstart1);
-      free(jend1);
-      free(istart2);
-      free(iend2);
-      free(jstart2);
-      free(jend2);
-   }
-
-   /* update halo of xt and yt */
-   pxt = (double **)malloc(ntiles*sizeof(double *));
-   pyt = (double **)malloc(ntiles*sizeof(double *));
-   for(n=0; n<ntiles; n++) {
-      pxt[n] = river_data[n].xt;
-      pyt[n] = river_data[n].yt;
-   }
-   update_halo_double(ntiles, pxt, nx, ny, *opcode);
-   update_halo_double(ntiles, pyt, nx, ny, *opcode);
-   free(pxt);
-   free(pyt);
-  
-}; /* get_mosaic_grid */
-
-/*------------------------------------------------------------------------------
-  void init_river_data
-  allocate memory to river data and initialize these river data with missing value
-  ----------------------------------------------------------------------------*/
-void init_river_data(int ntiles, river_type *river_out, const river_type * const river_in)
-{
-   int nx, ny, nxp2, nyp2, n, i;
-   int tocell_missing, subA_missing, travel_missing, basin_missing;
-   double cellarea_missing, celllength_missing;
-  
-   nx = river_out->nx;
-   ny = river_out->ny;
-   nxp2 = nx + 2;
-   nyp2 = ny + 2;
-   subA_missing   = river_in->subA_missing;
-   tocell_missing = river_in->tocell_missing;
-   travel_missing = river_in->travel_missing;
-   basin_missing  = river_in->basin_missing;
-   cellarea_missing = river_in->cellarea_missing;
-   celllength_missing = river_in->celllength_missing;
-   for(n=0; n<ntiles; n++) {
-      river_out[n].subA_missing   = subA_missing;
-      river_out[n].tocell_missing = tocell_missing;
-      river_out[n].travel_missing = travel_missing;
-      river_out[n].basin_missing  = basin_missing;
-      river_out[n].cellarea_missing = cellarea_missing;
-      river_out[n].celllength_missing  = celllength_missing;
-      river_out[n].subA       = (double *)malloc(nxp2*nyp2*sizeof(double));
-      river_out[n].tocell     = (int    *)malloc(nxp2*nyp2*sizeof(int   ));
-      river_out[n].travel     = (int    *)malloc(nxp2*nyp2*sizeof(int   ));
-      river_out[n].basin      = (int    *)malloc(nxp2*nyp2*sizeof(int   ));
-      river_out[n].dir        = (int    *)malloc(nxp2*nyp2*sizeof(int   ));
-      river_out[n].cellarea   = (double *)malloc(nx  *ny  *sizeof(double));
-      river_out[n].celllength = (double *)malloc(nx  *ny  *sizeof(double));
-      river_out[n].last_point = (int    *)malloc(nx  *ny  *sizeof(int   ));
-      for(i=0; i<nxp2*nyp2; i++) {
-	 river_out[n].subA  [i] = subA_missing;
-	 river_out[n].travel[i] = travel_missing;
-	 river_out[n].basin [i] = basin_missing;
-	 river_out[n].tocell[i] = tocell_missing;
-	 river_out[n].dir[i]    = -1;
-      }
-      for(i=0; i<nx*ny; i++) {
-	 river_out[n].cellarea[i]   = cellarea_missing;
-	 river_out[n].celllength[i] = celllength_missing;
-	 river_out[n].last_point[i] =  0;
-      }
-   }
-
-}
-
-
-/*------------------------------------------------------------------------------
-  void calc_max_subA(const river_type *river_in, river_type *river_out, int ntiles)
-  find max value of suba in each model grid cell.
-  ----------------------------------------------------------------------------*/
-void calc_max_subA(const river_type *river_in, river_type *river_out, int ntiles, unsigned int opcode)
-{
-   int nx_in, ny_in;
-   int nx_out, ny_out, nxp_out, nxp1, nyp1, nxp2, nyp2;
-   int n, i, j, i1, j1, ii, jj, n_out;
-   double missing, ll_y, ur_y, ll_x, ur_x;
-   double xv1[4], yv1[4], xv2[20], yv2[20];
-   double *xb_in, *yb_in;
-   double *xb_out, *yb_out;
-   double **psubA;
-  
-   nx_in = river_in->nx;
-   ny_in = river_in->ny;
-   xb_in = river_in->xb_r;
-   yb_in = river_in->yb_r;
-   missing = river_out->subA_missing;
-  
-   for(n=0; n<ntiles; n++) {
-      nx_out   = river_out[n].nx;
-      ny_out   = river_out[n].ny;
-      nxp2     = nx_out + 2;
-      nyp2     = ny_out + 2;    
-      nxp_out  = nx_out+1;
-      xb_out   = river_out[n].xb_r;
-      yb_out   = river_out[n].yb_r;
-      for(j=0; j<ny_out; j++) for(i=0; i<nx_out; i++) {
-	    j1 = j+1;
-	    i1 = i+1;
-	    /* set partial land cell and ocean cell to have large subA value */
-	    if(river_out[n].landfrac[j*nx_out+i] < 1) {
-	       river_out[n].subA[j1*nxp2+i1] = LARGE_VALUE;
-	       continue;
-	    }
-      
-	    xv1[0] = xb_out[j*nxp_out+i];
-	    xv1[1] = xb_out[j*nxp_out+i1];
-	    xv1[2] = xb_out[j1*nxp_out+i1];
-	    xv1[3] = xb_out[j1*nxp_out+i]; 
-	    yv1[0] = yb_out[j*nxp_out+i];
-	    yv1[1] = yb_out[j*nxp_out+i1];
-	    yv1[2] = yb_out[j1*nxp_out+i1];
-	    yv1[3] = yb_out[j1*nxp_out+i]; 
-      
-	    for(jj=0; jj<ny_in; jj++) {
-	       ll_y = yb_in[jj];
-	       ur_y = yb_in[jj+1];
-	       if (  (yv1[0]<=ll_y) && (yv1[1]<=ll_y)
-	       && (yv1[2]<=ll_y) && (yv1[3]<=ll_y) ) continue;
-	       if (  (yv1[0]>=ur_y) && (yv1[1]>=ur_y)
-	       && (yv1[2]>=ur_y) && (yv1[3]>=ur_y) ) continue;
-	
-	       for(ii=0; ii<nx_in; ii++) {
-		  if(river_in->subA[jj*nx_in+ii] == missing) continue;
-		  ll_x = xb_in[ii];
-		  ur_x = xb_in[ii+1];
-		  /* adjust xv1 to make sure it is in the range as ll_x and ur_x */
-		  adjust_lon(xv1, 0.5*(ll_x + ur_x) );
-		  if ( (xv1[0]<=ll_x) && (xv1[1]<=ll_x) && (xv1[2]<=ll_x) && (xv1[3]<=ll_x) ) continue;
-		  if ( (xv1[0]>=ur_x) && (xv1[1]>=ur_x) && (xv1[2]>=ur_x) && (xv1[3]>=ur_x) ) continue;	  
-		  if ( (n_out = clip ( xv1, yv1, 4, ll_x, ll_y, ur_x, ur_y, xv2, yv2 )) > 0 ) {
-		     double xarea; 
-		     xarea = poly_area (xv2, yv2, n_out );
-		     if( xarea/river_out[n].area[j*nx_out+i] < MIN_AREA_RATIO ) continue;
-		     if(river_in->subA[jj*nx_in+ii] > river_out[n].subA[j1*nxp2+i1])
-			river_out[n].subA[j1*nxp2+i1] = river_in->subA[jj*nx_in+ii];
-		  }
-	       }
-	    }
-	 }
-   }
-	
-   /* fill the halo of subA */
-   psubA = (double **)malloc(ntiles*sizeof(double *));
-   for(n=0; n<ntiles; n++) psubA[n] = river_out[n].subA; 
-   update_halo_double(ntiles, psubA, river_out->nx, river_out->ny, opcode); 
-   free(psubA);
-};/* calc_max_subA */
-
-/*------------------------------------------------------------------------------
-  void update_halo_double(int ntiles, double *data, int nx, int ny, unsigned int opcode)
-  We assume all the tiles have the same size.
-  -----------------------------------------------------------------------------*/
-void update_halo_double(int ntiles, double **data, int nx, int ny, unsigned int opcode)
-{
-   int nxp1, nyp1, nxp2, i, j, n;
-   int te, tw, ts, tn;
-  
-   nxp1   = nx + 1;
-   nyp1   = ny + 1;
-   nxp2   = nx + 2;
-   if(opcode & X_CYCLIC) {
-      for(j=1; j<nyp1; j++) {
-	 data[0][j*nxp2]      = data[0][j*nxp2+nx];     /* West */
-	 data[0][j*nxp2+nxp1] = data[0][j*nxp2+1];      /* east */
-      }
-   }
-   if(opcode & Y_CYCLIC) {
-      for(i=1; i<nyp1; i++) {
-	 data[0][i]           = data[0][ny*nxp2+i];     /* south */
-	 data[0][nyp1*nxp2+i] = data[0][nxp2+i];        /* north */
-      }
-   }
-   if(opcode & X_CYCLIC && opcode & Y_CYCLIC) {
-      data[0][0]              = data[0][ny*nxp2];      /* southwest */
-      data[0][nxp1]           = data[0][ny*nxp2+1];    /* southeast */    
-      data[0][nyp1*nxp2+nxp1] = data[0][nxp2+1];       /* northeast */
-      data[0][nyp1*nxp2]      = data[0][nxp2+nx];      /* northwest */     
-   }
-
-   if(opcode & CUBIC_GRID) {
-      for(n=0; n<ntiles; n++) {
-      
-	 if(n%2) { /* tile 2 4 6 */
-	    tw = (n+5)%ntiles; te = (n+2)%ntiles; ts = (n+4)%ntiles; tn = (n+1)%ntiles;
-	    for(j=1; j<nyp1; j++) {
-	       data[n][j*nxp2]      = data[tw][j*nxp2+nx];     /* west */
-	       data[n][j*nxp2+nxp1] = data[te][nxp2+(nxp1-j)]; /* east */
-	    }
-	    for(i=1; i<nxp1; i++) {
-	       data[n][i]           = data[ts][(nyp1-i)*nxp2+nx]; /* south */
-	       data[n][nyp1*nxp2+i] = data[tn][nxp2+i];           /* north */
-	    }
-	 } else {  /* tile 1, 3, 5 */
-	    tw = (n+4)%ntiles; te = (n+1)%ntiles; ts = (n+5)%ntiles; tn = (n+2)%ntiles;
-	    for(j=1; j<nyp1; j++) {
-	       data[n][j*nxp2]      = data[tw][ny*nxp2+nxp1-j]; /* west */
-	       data[n][j*nxp2+nxp1] = data[te][j*nxp2+1];       /* east */
-	    }
-	    for(i=1; i<nxp1; i++) {
-	       data[n][i]           = data[ts][ny*nxp2+i];       /* south */
-	       data[n][nyp1*nxp2+i] = data[tn][(nyp1-i)*nxp2+1]; /* north */
-	    }
-	 }
-      }
-   }
-  
-};/* update_halo */
-
-void update_halo_int(int ntiles, int **data, int nx, int ny, unsigned int opcode)
-{
-   double **ldata;
-   int n, i, j, nxp2, nyp2;
-  
-   nxp2 = nx + 2;
-   nyp2 = ny + 2;
-
-
-  
-   ldata = (double **)malloc(ntiles*sizeof(double *));
-   for(n=0; n<ntiles; n++) {
-      ldata[n] =  (double *)malloc(nxp2*nyp2*sizeof(double));
-      for(i=0; i<nxp2*nyp2; i++) ldata[n][i] = data[n][i];
-   }
-   update_halo_double(ntiles, ldata, nx, ny, opcode);
-   for(n=0; n<ntiles; n++) {
-      for(i=0; i<nxp2*nyp2; i++) data[n][i] = ldata[n][i];
-      free(ldata[n]);
-   }
-   free(ldata);
-  
-}
-
-int adjust_lon(double x[], double tlon)
-{
-   double x_sum, dx;
-   int i, npts = 4;
-
-   x_sum = x[0];
-   for (i=1;i<npts;i++) {
-      double dx = x[i]-x[i-1];
-
-      if      (dx < -M_PI) dx = dx + 2*M_PI;
-      else if (dx >  M_PI) dx = dx - 2*M_PI;
-      x_sum += (x[i] = x[i-1] + dx);
-   }
-
-   dx = (x_sum/npts)-tlon;
-   if      (dx < -M_PI) for (i=0;i<npts;i++) x[i] += 2*M_PI;
-   else if (dx >  M_PI) for (i=0;i<npts;i++) x[i] -= 2*M_PI;
-
-}; /* adjust_lon */
-
-/*------------------------------------------------------------------------------
-  Find the tocell value for the new grid.
-  void calc_tocell( )
-  ----------------------------------------------------------------------------*/
-void calc_tocell(int ntiles, river_type *river_data, unsigned int opcode )  
-{
-   const int out_flow[] = { 8, 4, 2, 16, -1, 1, 32, 64, 128};
-   const int out_dir[]  = { 3, 2, 1, 4,  -1, 0, 5,   6,   7};
-   int n, nx, ny, nxp2, ioff, joff;
-   int i, j, ii, jj, iget, jget, im1, jm1;
-   double tval, subA_missing, subA, subA_me;
-   int **ptocell, **pdir;
-  
-   nx = river_data->nx;
-   ny = river_data->ny;
-   nxp2 = nx + 2;
-   subA_missing = river_data->subA_missing;
-   ptocell = (int **)malloc(ntiles*sizeof(int *));
-   pdir    = (int **)malloc(ntiles*sizeof(int *));
-   for(n=0; n<ntiles; n++) {
-      ptocell[n] = river_data[n].tocell;
-      pdir   [n] = river_data[n].dir;
-   }
-  
-   for(n=0; n<ntiles; n++) {
-      for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	    jm1 = j - 1;
-	    im1 = i - 1;
-	    if(river_data[n].landfrac[jm1*nx+im1] == 0) {
-	       /* do nothing */
-	    }
-	    else if(river_data[n].landfrac[jm1*nx+im1] < 1) {
-	       ptocell[n][j*nxp2+i] = 0;
-	    }
-	    else {
-	       subA_me = river_data[n].subA[j*nxp2+i];
-	       tval= -999 ;  iget= -1 ;  jget= -1;
-	       if(subA_me > suba_cutoff ) { /* tocell will be land cell with larger subA value, instead of neighboring ocean cell. */
-		  for(joff=0; joff<ncells; joff++) {
-		     jj = jm1+joff;
-		     for(ioff=0; ioff<ncells; ioff++) {
-			ii = im1+ioff;
-			if(ioff == 1 && joff == 1) continue;
-			subA = river_data[n].subA[jj*nxp2+ii];
-			if(subA > subA_me) {
-			   if(tval == -999 ) {
-			      if(subA > tval) {
-				 iget = ioff;
-				 jget = joff;
-				 tval = subA;
-			      }
-			   }
-			   else if(tval < LARGE_VALUE) {
-			      if(subA > tval && subA < LARGE_VALUE) {
-				 iget = ioff;
-				 jget = joff;
-				 tval = subA;
-			      }
-			   }
-			   else {
-			      iget = ioff;
-			      jget = joff;
-			      tval = subA;
-			   }
-			}
-		     }
-		  }
-	       }
-	       else {
-		  for(joff=0; joff<ncells; joff++) {
-		     jj = jm1+joff;
-		     for(ioff=0; ioff<ncells; ioff++) {
-			ii = im1+ioff;
-			if(ioff == 1 && joff == 1) continue;
-
-			subA = river_data[n].subA[jj*nxp2+ii];
-			if( subA != subA_missing ) {
-			   if( subA >= tval) {
-			      iget = ioff;
-			      jget = joff;
-			      tval = subA;
-			   }
-			}
-		     }
-		  }
-	       }
-	       if(iget >= 0 && jget >= 0) {
-		  if(tval > river_data[n].subA[j*nxp2+i]) {
-		     ptocell[n][j*nxp2+i] = out_flow[jget*ncells+iget];
-		     pdir   [n][j*nxp2+i] = out_dir [jget*ncells+iget];
-		     if(pow(2,pdir[n][j*nxp2+i]) != ptocell[n][j*nxp2+i] )
-			mpp_error("river_regrid: pow(2,dir) should equal to tocell");
-		  }
-		  else
-		     ptocell[n][j*nxp2+i] = 0;
-	       }
-	       else 
-		  ptocell[n][j*nxp2+i] = 0;
-	    }
-	 }
-   }
-   update_halo_int(ntiles, ptocell, nx, ny, opcode);   
-   update_halo_int(ntiles, pdir, nx, ny, opcode);
-   free(ptocell);
-   free(pdir);
-  
-};/* calc_tocell */
-
-
-/*------------------------------------------------------------------------------
-  void calc_river_data()
-  calculate travel and basin according to tocell, as well as celllength, cellarea.
-  For each basin, one and only one river point will have tocell = 0, this point will
-  have travel = 1.
-  ----------------------------------------------------------------------------*/
-void calc_river_data(int ntiles, river_type* river_data, unsigned int opcode )
-{
-   int    nx, ny, nxp2, nyp2, n, i, j, ii, jj, nxp, nyp, im1, jm1, ioff, joff;
-   int    cur_basin, cur_travel;
-   int    not_done, dir, i_dest, j_dest;
-   int    basin_missing, travel_missing, tocell_missing;
-   int    maxtravel, maxbasin, travelnow;
-   double subA_missing;
-   int    **pbasin, **ptravel, **pdir;
-   double **psubA;
-   double xv[4], yv[4];
-  
-   const int di[] = {1,1,0,-1,-1,-1,0,1};
-   const int dj[] = {0,-1,-1,-1,0,1,1,1};
-   nx = river_data->nx;
-   ny = river_data->ny;
-   nxp  = nx+1;
-   nyp  = ny+1;
-   nxp2 = nx+2;
-   nyp2 = ny+2;
-   basin_missing  = river_data->basin_missing;
-   subA_missing   = river_data->subA_missing;
-   tocell_missing = river_data->tocell_missing;
-   cur_basin = 0;
-
-   /* set up pointer */
-   pbasin  = (int **)malloc(ntiles*sizeof(int *));
-   ptravel = (int **)malloc(ntiles*sizeof(int *));
-   pdir    = (int **)malloc(ntiles*sizeof(int *));
-   psubA   = (double **)malloc(ntiles*sizeof(double *));
-   for(n=0; n<ntiles; n++) {
-      pbasin [n] = river_data[n].basin;
-      ptravel[n] = river_data[n].travel;
-      psubA  [n] = river_data[n].subA;
-      pdir   [n] = river_data[n].dir;
-   }
-
-
-   /* reinitialize subA */
-   for(n=0; n<ntiles; n++) {
-      for(i=0; i<nxp2*nyp2; i++) psubA[n][i] = subA_missing;    
-   }
-  
-   /* calculate celllength and cellarea */
-   for(n=0; n<ntiles; n++) {
-      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	    if(river_data[n].landfrac[j*nx+i] > 0) {
-	       ii = i+1;
-	       jj = j+1;
-
-	       xv[0] = river_data[n].xb_r[j*nxp+i];
-	       xv[1] = river_data[n].xb_r[j*nxp+ii];
-	       xv[2] = river_data[n].xb_r[jj*nxp+ii];
-	       xv[3] = river_data[n].xb_r[jj*nxp+i];
-	       yv[0] = river_data[n].yb_r[j*nxp+i];
-	       yv[1] = river_data[n].yb_r[j*nxp+ii];
-	       yv[2] = river_data[n].yb_r[jj*nxp+ii];
-	       yv[3] = river_data[n].yb_r[jj*nxp+i];
-	       river_data[n].cellarea[j*nx+i] = river_data[n].area[j*nx+i]*river_data[n].landfrac[j*nx+i];
-	       dir = pdir[n][jj*nxp2+ii];
-	       if( dir >= 0) {
-		  i_dest = ii + di[dir];
-		  j_dest = jj + dj[dir];	
-		  river_data[n].celllength[j*nx+i] = distance(river_data[n].xt[jj*nxp2+ii],
-		  river_data[n].yt[jj*nxp2+ii],
-		  river_data[n].xt[j_dest*nxp2+i_dest],
-		  river_data[n].yt[j_dest*nxp2+i_dest] );
-	       }
-	       else
-		  river_data[n].celllength[j*nx+i] = 0;
-	    }
-	 }
-   }
-
-  
-   /* define the basinid and travel for the coast point */
-  
-   for(n=0; n<ntiles; n++) {
-      for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	    if(river_data[n].tocell[j*nxp2+i] == 0) {
-	       pbasin[n] [j*nxp2+i] = ++cur_basin;
-	       ptravel[n][j*nxp2+i] = 0;
-	       river_data[n].last_point[(j-1)*nx+i-1] = 1;
-	    }
-	    else if(river_data[n].tocell[j*nxp2+i] > 0){
-	       dir = pdir[n][j*nxp2+i];
-	       i_dest = i + di[dir];
-	       j_dest = j + dj[dir];
-	       if(river_data[n].tocell[j_dest*nxp2+i_dest] == tocell_missing) {
-		  pbasin[n] [j*nxp2+i] = ++cur_basin;
-		  ptravel[n][j*nxp2+i] = 1;
-		  river_data[n].last_point[(j-1)*nx+i-1] = 1;
-	       }
-	    }
-	 }
-   }
-
-   update_halo_int(ntiles, pbasin, nx, ny, opcode);
-   update_halo_int(ntiles, ptravel, nx, ny, opcode);
-  
-   /* then define the travel and basin for all other points */
-   cur_travel = 0;
-
-   not_done = 1;
-   while(not_done) {
-      not_done = 0;
-      for(n=0; n<ntiles; n++) {
-	 for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	       dir = pdir[n][j*nxp2+i];
-	       if( dir >= 0 && pbasin[n][j*nxp2+i] == basin_missing ) {
-		  i_dest = i + di[dir];
-		  j_dest = j + dj[dir];
-		  if( ptravel[n][j_dest*nxp2+i_dest] == cur_travel ) {
-		     not_done = 1; /* still have points need to be updateed */
-		     if(pbasin[n][j_dest*nxp2+i_dest] == basin_missing) {
-			mpp_error("river_grid: the tocell should have valid basin value");
-		     }
-		     pbasin[n][j*nxp2+i] = pbasin[n][j_dest*nxp2+i_dest];
-		     ptravel[n][j*nxp2+i] = cur_travel+1;
-		  }
-	       }
-	    }
-      }
-      cur_travel++;
-      update_halo_int(ntiles, pbasin, nx, ny, opcode);
-      update_halo_int(ntiles, ptravel, nx, ny, opcode);    
-   }
-
-   /* figure out maximum travel and maximum basin*/
-   maxtravel = -1;
-   maxbasin  = -1;
-   basin_missing = river_data->basin_missing;
-   for(n=0; n<ntiles; n++) {
-      for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {    
-	    maxtravel = max(maxtravel, ptravel[n][j*nxp2+i]);
-	    maxbasin  = max(maxbasin,  pbasin[n][j*nxp2+i]);
-	 }
-   }
-
-   for(travelnow=maxtravel; travelnow>=0; travelnow--) {
-      for(n=0; n<ntiles; n++) for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	       jm1 = j - 1;
-	       im1 = i - 1;
-	       if(ptravel[n][j*nxp2+i] == travelnow) {
-		  psubA[n][j*nxp2+i] = river_data[n].cellarea[jm1*nx+im1];
-		  /* add the subA of from cell */
-		  for(joff=0; joff<ncells; joff++) for(ioff=0; ioff<ncells; ioff++) {
-			if(ioff == 1 && joff == 1) continue;
-			jj = jm1 + joff;
-			ii = im1 + ioff;
-			dir = pdir[n][jj*nxp2+ii];
-			/* consider about the rotation when it is on the boundary */
-			if(dir >=0 ) {
-			   if( opcode & CUBIC_GRID ) {
-			      if(ii == 0) { /* west */ 
-				 if(n%2==0) dir = (dir+2)%8;  /* tile 1 3 5 */
-			      }
-			      else if(ii == nxp) { /*east */
-				 if(n%2==1) dir = (dir+2)%8;  /* tile 2 4 6 */
-			      }
-			      else if(jj == 0) { /* south */
-				 if(n%2==1) dir = (dir+6)%8;  /* tile 2 4 6 */
-			      }
-			      else if(jj == nyp) { /*north */
-				 if(n%2==0) dir = (dir+6)%8;  /* tile 1 3 5 */
-			      }
-			   }
-			   i_dest = ii + di[dir];
-			   j_dest = jj + dj[dir];
-			   if(i_dest == i && j_dest == j) psubA[n][j*nxp2+i] += psubA[n][jj*nxp2+ii];
-			}
-		     }
-	       }
-	    }
-      update_halo_double(ntiles, psubA, nx, ny, opcode);
-   }
-  
-   free(pbasin);
-   free(ptravel);
-   free(psubA);
-   free(pdir);
-}; /*  calc_travel */
-
-/*------------------------------------------------------------------------------
-  void check_river_data( )
-  check to make sure all the river points have been assigned travel and basin value
-  and all the ocean points will have missing value.
-  ----------------------------------------------------------------------------*/
-  
-void check_river_data(int ntiles, river_type *river_data )
-{
-   int maxtravel = -1;
-   int maxbasin  = -1;
-   int nx, ny, nxp2, nyp2;
-   int n, i, j, im1, jm1, ioff, joff, ii, jj;
-   int tocell, travel, basin;
-   int tocell_missing, travel_missing, basin_missing;
-   int ncoast_full_land, nsink;
-   double subA, subA_missing;
-   int *ncoast;
-  
-   /* print out maximum travel and number of rivers */
-   maxtravel = -1;
-   maxbasin  = -1;
-   nx = river_data->nx;
-   ny = river_data->ny;
-   nxp2 = nx + 2;
-   nyp2 = ny + 2;
-   subA_missing = river_data->subA_missing;
-   tocell_missing = river_data->tocell_missing;
-   basin_missing = river_data->basin_missing;
-   travel_missing = river_data->travel_missing;
-  
-   for(n=0; n<ntiles; n++) {
-      for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {    
-	    maxtravel = max(maxtravel, river_data[n].travel[j*nxp2+i]);
-	    maxbasin  = max(maxbasin, river_data[n].basin[j*nxp2+i]);
-	 }
-   }
-   printf("==> NOTE from river_regrid: maximum travel is %d and maximum basin is %d.\n", maxtravel, maxbasin);
-
-   ncoast_full_land = 0;
-   nsink = 0;
-   for(n=0; n<ntiles; n++) {
-      for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	    jm1 = j - 1;
-	    im1 = i -1;
-	    subA   = river_data[n].subA  [j*nxp2+i];
-	    tocell = river_data[n].tocell[j*nxp2+i];
-	    travel = river_data[n].travel[j*nxp2+i];
-	    basin  = river_data[n].basin [j*nxp2+i];
-	    if( river_data[n].landfrac[jm1*nx+im1] == 0) {
-	       if(tocell!= tocell_missing || travel != travel_missing ||
-	       basin != basin_missing || subA != subA_missing) {
-		  printf("At ocean points (i=%d,j=%d), subA = %f, tocell = %d, travel = %d, basin = %d.\n ",
-		  i, j, subA, tocell, travel, basin);
-		  mpp_error("river_regrid, subA, tocell, travel, or basin is not missing value for some ocean points");
-	       }
-	    }
-	    else {
-	       if(tocell == tocell_missing || travel == travel_missing ||
-	       basin == basin_missing || subA == subA_missing) {
-		  printf("At river points (i=%d,j=%d), subA = %f, tocell = %d, travel = %d, basin = %d.\n ",
-		  i, j, subA, tocell, travel, basin);
-		  mpp_error("river_regrid, subA, tocell, travel, or basin is missing value for some river points");
-	       }
-	    }
-	    /* check if the points with land_frac == 1 and tocell=0, those points should be sink.*/
-	    if(river_data[n].landfrac[jm1*nx+im1] == 1 && tocell == 0) {
-	       for(joff=0; joff<ncells; joff++) {
-		  jj = jm1+joff;
-		  for(ioff=0; ioff<ncells; ioff++) {
-		     ii = im1+ioff;
-		     if(ioff == 1 && joff == 1) continue;
-		     if(river_data[n].tocell[jj*nxp2+ii] == tocell_missing) {
-			ncoast_full_land++;
-			printf("At point (%d,%d), tocell = 0 and landfrac = 1 is a coast point\n", i, j);
-			goto done_check;
-		     }
-		  }
-	       }
-	       printf("At point (%d,%d), tocell = 0 and landfrac = 1 is a sink point\n", i, j);
-	       nsink++;
-	      done_check: continue;	
-	    }
-	 }
-   }
-
-   if(ncoast_full_land > 0)
-      printf("Warning from river_regrid: there are %d coast points is a full land cell\n", ncoast_full_land);
-   else
-      printf("NOTE from river_regrid: there are no coast points is a full land cell\n");
-
-   if(nsink > 0)
-      printf("Warning from river_regrid: there are %d sink points is a full land cell\n", nsink);
-   else
-      printf("NOTE from river_regrid: there are no sink points is a full land cell\n");
-  
-   /* check river travel to make sure there is one and only one point with travel = 0. */
-   ncoast = (int *)malloc(maxbasin*sizeof(int));
-   for(n=0; n<maxbasin; n++) ncoast[n] = 0;
-   for(n=0; n<ntiles; n++) {
-      for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	    if(river_data[n].last_point[(j-1)*nx+i-1] ) ++ncoast[river_data[n].basin[j*nxp2+i]-1];
-	 }
-   }
-   for(n=0; n<maxbasin; n++) {
-      if(ncoast[n] <= 0) {
-	 printf("river with basin = %d has no point with travel = 0.\n", n+1);
-	 mpp_error("river_regrid: some river has no point with travel = 0");
-      }
-      else if(ncoast[n] >1) {
-	 printf("river with basin = %d has more than one point with travel = 0.\n", n+1);
-	 mpp_error("river_regrid: some river has more than one point with travel = 0");
-      }
-   }
-   free(ncoast);
-  
-
-}; /* check_river_data */
-
-/*------------------------------------------------------------------------------
-  void sort_basin(int ntiles, river_type* river_data);
-  sorting the basin according to subA
-  The river with larger subA at coast point will get smaller basinid.
-  The basinid will be reorganized.
-  -----------------------------------------------------------------------------*/
-void sort_basin(int ntiles, river_type* river_data)
-{
-
-   int    nx, ny, nxp2, nyp2, i, j, n;
-   int    maxbasin, basin_missing, basin;
-   int    *rank, *indx;
-   double subA_missing, *maxsuba;
-  
-   river_type *river_tmp;
-
-   nx   = river_data->nx;
-   ny   = river_data->ny;
-   nxp2 = nx + 2;
-   nyp2 = ny + 2;
-   river_tmp = (river_type *)malloc(ntiles*sizeof(river_type));
-
-   /* calculate maximum basin */
-   maxbasin  = -1;
-   basin_missing = river_data->basin_missing;
-   for(n=0; n<ntiles; n++) {
-      for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {    
-	    maxbasin  = max(maxbasin,  river_data[n].basin[j*nxp2+i]);
-	 }
-   }  
-
-   /* copy basinid data to the tmp data */
-   for(n=0; n<ntiles; n++) {
-      river_tmp[n].basin = (int *)malloc(nxp2*nyp2*sizeof(int));
-      for(i=0; i<nxp2*nyp2; i++) {
-	 river_tmp[n].basin[i] = river_data[n].basin[i];
-      }
-   }
-
-   /* calculate maximum subA for each basin */
-   subA_missing = river_data->subA_missing;
-   maxsuba = (double *)malloc(maxbasin*sizeof(double));
-   indx    = (int    *)malloc(maxbasin*sizeof(int   ));
-   rank    = (int    *)malloc(maxbasin*sizeof(int   ));
-   for(n=0; n<maxbasin; n++) {
-      maxsuba[n] = subA_missing;
-      indx[n]    = n;
-      rank[n]    = -1;
-   }
-   for(n=0; n<ntiles; n++) for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	    if(river_data[n].last_point[(j-1)*nx+i-1]) { /* coast point */
-	       basin = river_tmp[n].basin[j*nxp2+i];
-	       if( basin > maxbasin || basin < 1) mpp_error("river_regrid: basin should be between 1 and maxbasin");
-	       maxsuba[basin-1] = river_data[n].subA[j*nxp2+i];
-	    }
-	 }
-
-   /* make sure maxsuba is assigned properly */
-   for(n=0; n<maxbasin; n++) {
-      if(maxsuba[n] == subA_missing) mpp_error("river_regrid: maxsuba is not assigned for some basin");
-   }
-  
-   /* sort maxsuba to get the index rank */
-   qsort_index(maxsuba, 0, maxbasin-1, indx);
-   for(n=0; n<maxbasin; n++) rank[indx[n]] = n;
-   for(n=0; n<maxbasin; n++) {
-      if(rank[n] < 0) mpp_error("river_regrid: rank should be no less than 0");
-   }
-  
-   /* now assign basin according to the index rank */
-   for(n=0; n<ntiles; n++) for(j=1; j<=ny; j++) for(i=1; i<=nx; i++) {
-	    basin = river_tmp[n].basin[j*nxp2+i];
-	    if(basin != basin_missing) {
-	       if( basin > maxbasin || basin < 1) mpp_error("river_regrid: basin should be a positive integer no larger than maxbasin");
-	       river_data[n].basin[j*nxp2+i] = maxbasin - rank[basin-1];
-	    }
-	 }
-  
-   /* release the memory */
-   for(n=0; n<ntiles; n++) free(river_tmp[n].basin);
-   free(river_tmp);
-   free(rank);
-   free(maxsuba);
-
-};/* sort_basin */
-
-
-
-/*------------------------------------------------------------------------------
-  void write_river_data()
-  write out river network output data which is on land grid.
-  ----------------------------------------------------------------------------*/
-void write_river_data(const char *river_src_file, const char *output_file, river_type* river_data, const char *history, int ntiles)
-{
-   double *subA, *yt, *xt;
-   int    *tocell, *travel, *basin;
-   int id_subA, id_subA_in, id_tocell, id_tocell_in;
-   int id_travel, id_travel_in, id_basin, id_basin_in;
-   int id_cellarea, id_celllength, id_landfrac;
-   int id_cellarea_in, id_celllength_in, id_x, id_y;
-   int id_xaxis, id_yaxis, id_xaxis_in, id_yaxis_in;
-   int fid, fid_in, dimid[2];
-   int n, i, j, ii, jj, nx, ny, nxp2;
-  
-   fid_in = mpp_open(river_src_file, MPP_READ);
-   id_subA_in = mpp_get_varid(fid_in, subA_name);
-   id_tocell_in = mpp_get_varid(fid_in, tocell_name);
-   id_travel_in = mpp_get_varid(fid_in, travel_name);
-   id_basin_in = mpp_get_varid(fid_in, basin_name);
-   id_cellarea_in = mpp_get_varid(fid_in, cellarea_name);
-   id_celllength_in = mpp_get_varid(fid_in, celllength_name);
-   id_xaxis_in = mpp_get_varid(fid_in, xaxis_name);
-   id_yaxis_in = mpp_get_varid(fid_in, yaxis_name);
-   for(n=0; n<ntiles; n++) {
-      if(ntiles>1)
-	 sprintf(river_data[n].filename, "%s.tile%d.nc", output_file, n+1);
-      else
-	 sprintf(river_data[n].filename, "%s.nc", output_file);
-
-      nx = river_data[n].nx;
-      ny = river_data[n].ny;
-      nxp2 = nx + 2;
-      fid = mpp_open(river_data[n].filename, MPP_WRITE);
-      mpp_def_global_att(fid, "version", version);  
-      mpp_def_global_att(fid, "code_version", TAGNAME);
-      mpp_def_global_att(fid, "history", history);
-      dimid[1] = mpp_def_dim(fid, gridx_name, nx);
-      dimid[0] = mpp_def_dim(fid, gridy_name, ny);
-      id_xaxis = mpp_def_var(fid, gridx_name, MPP_DOUBLE, 1, &(dimid[1]), 0);
-      id_yaxis = mpp_def_var(fid, gridy_name, MPP_DOUBLE, 1, dimid, 0);
-      mpp_copy_var_att(fid_in, id_xaxis_in, fid, id_xaxis);
-      mpp_copy_var_att(fid_in, id_yaxis_in, fid, id_yaxis);
-      id_subA = mpp_def_var(fid, subA_name, MPP_DOUBLE, 2, dimid , 0);
-      mpp_copy_var_att(fid_in, id_subA_in, fid, id_subA);
-      id_tocell = mpp_def_var(fid, tocell_name, MPP_INT, 2, dimid, 0);
-      mpp_copy_var_att(fid_in, id_tocell_in, fid, id_tocell);
-      id_travel = mpp_def_var(fid, travel_name, MPP_INT, 2, dimid , 0);
-      mpp_copy_var_att(fid_in, id_travel_in, fid, id_travel);
-      id_basin = mpp_def_var(fid, basin_name, MPP_INT, 2, dimid , 0);
-      mpp_copy_var_att(fid_in, id_basin_in, fid, id_basin);
-      id_cellarea = mpp_def_var(fid, cellarea_name, MPP_DOUBLE, 2, dimid , 0);
-      mpp_copy_var_att(fid_in, id_cellarea_in, fid, id_cellarea);
-      id_celllength = mpp_def_var(fid, celllength_name, MPP_DOUBLE, 2, dimid , 0);
-      mpp_copy_var_att(fid_in, id_celllength_in, fid, id_celllength);
-      id_landfrac = mpp_def_var(fid, landfrac_name, MPP_DOUBLE, 2, dimid, 2,
-      "long_name", "land fraction", "units", "none");
-      id_x        = mpp_def_var(fid, x_name, MPP_DOUBLE, 2, dimid, 2,
-      "long_name", "Geographic longitude", "units", "degree_east");
-      id_y        = mpp_def_var(fid, y_name, MPP_DOUBLE, 2, dimid, 2,
-      "long_name", "Geographic latitude", "units", "degree_north");    
-      mpp_end_def(fid);
-      xt = (double *)malloc(nx*sizeof(double));
-      yt = (double *)malloc(ny*sizeof(double));
-      /*
-	for lat-lon grid, actual lon, lat will be written out,
-	for cubic grid, index will be written out
-      */
-      if(ntiles == 1) {
-	 for(i=0; i<nx; i++) xt[i] = river_data[n].xt[nxp2+i+1];
-	 for(j=0; j<ny; j++) yt[j] = river_data[n].yt[(j+1)*nxp2+1];
-
-      }
-      else {
-	 for(i=0; i<nx; i++) xt[i] = i+1;
-	 for(j=0; j<ny; j++) yt[j] = j+1;
-      }
-      mpp_put_var_value(fid, id_xaxis, xt);
-      mpp_put_var_value(fid, id_yaxis, yt);
-      free(xt);
-      free(yt);
-
-      /* all the fields is on data domain, so need to copy to compute domain */
-      subA = (double *)malloc(nx*ny*sizeof(double));
-      travel = (int *)malloc(nx*ny*sizeof(int));
-      basin  = (int *)malloc(nx*ny*sizeof(int));
-      tocell = (int *)malloc(nx*ny*sizeof(int));
-      xt = (double *)malloc(nx*ny*sizeof(double));
-      yt = (double *)malloc(nx*ny*sizeof(double));
-      for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	    ii = i + 1;
-	    jj = j + 1;
-	    subA[j*nx+i] = river_data[n].subA[jj*nxp2+ii];
-	    tocell[j*nx+i] = river_data[n].tocell[jj*nxp2+ii];
-	    travel[j*nx+i] = river_data[n].travel[jj*nxp2+ii];
-	    basin [j*nx+i] = river_data[n].basin [jj*nxp2+ii];
-	    xt    [j*nx+i] = river_data[n].xt    [jj*nxp2+ii];
-	    yt    [j*nx+i] = river_data[n].yt    [jj*nxp2+ii];
-	 }
-    
-      mpp_put_var_value(fid, id_subA, subA);
-      mpp_put_var_value(fid, id_tocell, tocell);
-      mpp_put_var_value(fid, id_travel, travel);
-      mpp_put_var_value(fid, id_basin, basin);
-      mpp_put_var_value(fid, id_x, xt);
-      mpp_put_var_value(fid, id_y, yt);
-      mpp_put_var_value(fid, id_cellarea, river_data[n].cellarea);
-      mpp_put_var_value(fid, id_celllength, river_data[n].celllength);
-      mpp_put_var_value(fid, id_landfrac, river_data[n].landfrac);
-      mpp_close(fid);
-      free(subA);
-      free(tocell);
-      free(basin);
-      free(travel);
-      free(xt);
-      free(yt);
-   }
-   mpp_close(fid_in);
-
-};/* write_river_data */
-
-
-/*------------------------------------------------------------------------------
-  double distance(double lon1, double lat1, double lon2, double lat2)
-  find the distance of any two grid.
-  ----------------------------------------------------------------------------*/
-double distance(double lon1, double lat1, double lon2, double lat2)
-{
-   double s1, s2, dx;
-   double dist;
-    
-   dx = lon2 - lon1;
-   if(dx > 180.) dx = dx - 360.;
-   if(dx < -180.) dx = dx + 360.;
-
-   if(lon1 == lon2)
-      dist = fabs(lat2 - lat1) * D2R;
-   else if(lat1 == lat2) 
-      dist = fabs(dx) * D2R * cos(lat1*D2R);
-   else {   /* diagonal distance */
-      s1 =  fabs(dx)  * D2R * cos(lat1*D2R);
-      s2 =  fabs(lat2 - lat1) * D2R;
-      dist = sqrt(s1*s1+s2*s2);
-   }
-   dist *= RADIUS;
-
-   return dist;
-}    
-
-/*------------------------------------------------------------------------------
-  void qsort_index(double array[], int start, int end, int rank[])
-  sort array in increasing order and get the rank of each member in the original array
-  the array size of array and rank will be size. 
-  
-  ----------------------------------------------------------------------------*/
-#define swap(a,b,t) ((t)=(a),(a)=(b),(b)=(t))
-void qsort_index(double array[], int start, int end, int rank[])
-{
-   double pivot;
-   int tmp_int;
-   double tmp_double;
-
-   if (end > start) {
-      int l = start + 1;
-      int r = end;
-      int pivot_index = (start+(end-start)/2);
-      swap(array[start], array[pivot_index], tmp_double); /*** choose arbitrary pivot ***/
-      swap(rank[start],  rank[pivot_index],  tmp_int);
-      pivot = array[start];
-      while(l < r) {
-         if (array[l] <= pivot) {
-            l++;
-         } else {
-	    while(l < r && array[r] >= pivot) /*** skip superfluous swaps ***/
-	    {
-	       --r;
-	    }
-            swap(array[l], array[r], tmp_double);
-	    swap(rank[l],  rank[r],  tmp_int);
-         }
-      }
-      if(l != end || array[end] > pivot ) {
-	 l--;
-	 swap(array[start], array[l], tmp_double);
-	 swap(rank[start],  rank[l],  tmp_int);
-	 qsort_index(array, start, l, rank);
-	 qsort_index(array, r, end, rank);
-      }
-      else { /* the first element is the largest one */
-	 swap(array[start], array[l], tmp_double);
-	 swap(rank[start],  rank[l],  tmp_int);
-	 qsort_index(array, start, l-1, rank);
-      }
-   }
-}
-#define PI M_PI
-  
-int
-gs_transfer_to_mosaic(char *old_file, char *mosaic_dir)
-{  
-   char *pch=NULL, history[512], entry[1280];
-   char tilefile[MAXTILE][STRING], tiletype[MAXTILE][SHORTSTRING];
-   char tile_name[MAXTILE][STRING];
-   int ntiles=0, nfiles=0, ncontact=0;
-   double periodx=0, periody=0;
-   int contact_tile1[MAXCONTACT], contact_tile2[MAXCONTACT];
-   int contact_tile1_istart[MAXCONTACT], contact_tile1_iend[MAXCONTACT];
-   int contact_tile1_jstart[MAXCONTACT], contact_tile1_jend[MAXCONTACT];
-   int contact_tile2_istart[MAXCONTACT], contact_tile2_iend[MAXCONTACT];
-   int contact_tile2_jstart[MAXCONTACT], contact_tile2_jend[MAXCONTACT];
-   char mosaic_name[128] = "atmos_mosaic";
-   char grid_descriptor[128] = "";
-   int c, i, n, m, l, errflg, check=0;
-
-   char atmos_name[128]="atmos", land_name[128]="land", ocean_name[128]="ocean";
-   char agrid_file[128], lgrid_file[128], ogrid_file[128];
-
-   int is_coupled_grid = 0, is_ocean_only =1; 
-   int interp_order=1;
-   double *x, *y, *dx, *dy, *area, *angle_dx, *angle_dy; 
-   int nx, ny, nxp, nyp;
-   const char mosaic_version[] = "0.2";
-
-   if(!old_file) mpp_error("Usage:\n \t \t transfer_to_mosaic --input_file input_file.nc");
-   if(mpp_field_exist(old_file, "AREA_ATMxOCN") ) is_coupled_grid = 1;
-   if(mpp_field_exist(old_file, "AREA_ATM") ) is_ocean_only = 0;
-   if(mpp_field_exist(old_file, "DI_ATMxOCN") ) interp_order= 2;
-// -----------------ocean_hgrid.nc---------------------------------[
-// Ocean
-   {
-      int nx_C, ny_C, nx_T, ny_T, nvertex;
-      int fid_old, vid;
-  
-      double *x_C, *y_C, *x_T, *y_T;
-      double *x_vert_T, *y_vert_T;
-
-
-      double *ds_00_02_C, *ds_00_20_C, *ds_01_11_C, *ds_01_21_C, *ds_02_22_C, 
-         *ds_10_11_C, *ds_10_12_C, *ds_11_21_C, *ds_11_12_C, *ds_20_22_C, 
-         *ds_01_11_T, *ds_01_21_T, *ds_02_22_T, *ds_10_11_T, *ds_10_12_T, 
-         *ds_11_12_T, *ds_11_21_T, *ds_20_22_T, 
-         *ds_01_21_E, *ds_10_12_N, *angle_C; 
-
- 
-      int i,j,k, i1, i2, j1, j2, k0, k1, k2, k3;
-      int ji, ji0, ji1, ji2, ji3;
-      int j1i1, j1i2, j2i1, j2i2; 
-      double unknown = 0.0; /* double unknown = -1.0E+10; */
-
-      fid_old = mpp_open(old_file, MPP_READ);
-      nx_C = mpp_get_dimlen(fid_old, "grid_x_C");
-      ny_C = mpp_get_dimlen(fid_old, "grid_y_C");
-      nx_T = mpp_get_dimlen(fid_old, "grid_x_T");
-      ny_T = mpp_get_dimlen(fid_old, "grid_y_T");
-      nvertex = mpp_get_dimlen(fid_old, "vertex");
-
-      printf("\nReading file: %s \n", old_file); 
-
-
-/* Reading Ocean Grid Variables */
-      x_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-      y_C = (double *) malloc(ny_C * nx_C * sizeof(double));
-      x_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-      y_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-      x_vert_T = (double *) malloc(nvertex*ny_T*nx_T*sizeof(double));
-      y_vert_T = (double *) malloc(nvertex*ny_T*nx_T*sizeof(double));
-      ds_01_11_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-      ds_10_11_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-      ds_11_21_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-      ds_11_12_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-      ds_01_11_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-      ds_10_11_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-      ds_11_12_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-      ds_11_21_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-      ds_02_22_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-      ds_20_22_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-      angle_C    = (double *) malloc(ny_C * nx_C * sizeof(double));
-  
-      vid = mpp_get_varid(fid_old, "x_C"); mpp_get_var_value(fid_old, vid, x_C);
-      vid = mpp_get_varid(fid_old, "y_C"); mpp_get_var_value(fid_old, vid, y_C);
-      vid = mpp_get_varid(fid_old, "x_T"); mpp_get_var_value(fid_old, vid, x_T);
-      vid = mpp_get_varid(fid_old, "y_T"); mpp_get_var_value(fid_old, vid, y_T);
-      vid = mpp_get_varid(fid_old, "x_vert_T"); mpp_get_var_value(fid_old, vid, x_vert_T);
-      vid = mpp_get_varid(fid_old, "y_vert_T"); mpp_get_var_value(fid_old, vid, y_vert_T);
-      vid = mpp_get_varid(fid_old, "ds_01_11_C"); mpp_get_var_value(fid_old, vid, ds_01_11_C);  
-      vid = mpp_get_varid(fid_old, "ds_10_11_C"); mpp_get_var_value(fid_old, vid, ds_10_11_C);
-      vid = mpp_get_varid(fid_old, "ds_11_21_C"); mpp_get_var_value(fid_old, vid, ds_11_21_C);    
-      vid = mpp_get_varid(fid_old, "ds_11_12_C"); mpp_get_var_value(fid_old, vid, ds_11_12_C);
-      vid = mpp_get_varid(fid_old, "ds_01_11_T"); mpp_get_var_value(fid_old, vid, ds_01_11_T);  
-      vid = mpp_get_varid(fid_old, "ds_10_11_T"); mpp_get_var_value(fid_old, vid, ds_10_11_T);
-      vid = mpp_get_varid(fid_old, "ds_11_21_T"); mpp_get_var_value(fid_old, vid, ds_11_21_T);    
-      vid = mpp_get_varid(fid_old, "ds_11_12_T"); mpp_get_var_value(fid_old, vid, ds_11_12_T);  
-      vid = mpp_get_varid(fid_old, "ds_02_22_T"); mpp_get_var_value(fid_old, vid, ds_02_22_T);    
-      vid = mpp_get_varid(fid_old, "ds_20_22_T"); mpp_get_var_value(fid_old, vid, ds_20_22_T);  
-      vid = mpp_get_varid(fid_old, "angle_C"); mpp_get_var_value(fid_old, vid, angle_C);  
-      mpp_close(fid_old);
-  
-      nx = 2*nx_T;  nxp = nx +1;
-      ny = 2*ny_T;  nyp = ny +1;
-      x = (double *) malloc(nxp*nyp * sizeof(double));
-      y = (double *) malloc(nxp*nyp* sizeof(double));
-      dx = (double *) malloc(nx*nyp * sizeof(double));
-      dy = (double *) malloc(nxp*ny * sizeof(double));
-      area = (double *) malloc(nx*ny * sizeof(double));
-      angle_dx = (double *) malloc(nxp*nyp * sizeof(double));
-
-      for(j = 0; j<ny_T; j++) {
-	 for(i = 0; i<nx_T; i++) {
-
-	    i2=2*(i+1); i1=i2-1;   j2=2*(j+1); j1=j2-1;
-
-	    j1i1=j1*nxp+i1; j1i2=j1*nxp+i2; j2i2=j2*nxp+i2; j2i1=j2*nxp+i1; 
-	    ji=j*nx_T+i;
-	    ji0=ji; ji1=ji0+nx_T*ny_T; ji2=ji1+nx_T*ny_T; ji3=ji2+nx_T*ny_T;
-
-	    x[j1i1] = x_T[ji];
-	    x[j1i2] = 0.5*(x_vert_T[ji1]+x_vert_T[ji2]);
-	    x[j2i2] = x_vert_T[ji2];
-	    x[j2i1] = 0.5*(x_vert_T[ji3]+x_vert_T[ji2]);
-
-	    y[j1i1] = y_T[ji];
-	    y[j1i2] = 0.5*(y_vert_T[ji1]+y_vert_T[ji2]);
-	    y[j2i2] = y_vert_T[ji2];
-	    y[j2i1] = 0.5*(y_vert_T[ji3]+y_vert_T[ji2]);
-
-/*      Mapping distance to new mosaic grid format from old grid
-
-	dx(1,1)=                  dx(2,1)=           
-	Ci-1,j------ds_11_21_C(i-1,j)---+-----ds_01_11_C(i,j)--------Ci,j
-	|                          |                            |
-	|                          |                            |
-	|                          |                            |
-	|                     ds_11_12_T                   ds_10_11_C(i,j)
-	|                          |                            |
-	|         dx(1,1)=         |          dx(2,1)=          |
-	+---------ds_01_11_T------Tij---------ds_11_21_T--------+
-	|                          |                            |
-	|                          |                            |
-	|                          |                            |
-	|                     ds_11_12_T                   ds_11_12_C(i,j-1)
-	|                          |                            |
-	|                          |                            |
-	Ci-1,j-1--------------------------+----------------------------Ci,j-1
-
-*/
-	    dx[(2*j+1)*nx  + (2*i)]   = ds_01_11_T[j*nx_T + i];
-	    dx[(2*j+1)*nx  + (2*i+1)] = ds_11_21_T[j*nx_T + i];
-	    if(i>0) dx[(2*j+2)*nx  + (2*i)]   = ds_11_21_C[j*nx_T + (i-1)];
-	    dx[(2*j+2)*nx  + (2*i+1)] = ds_01_11_C[j*nx_T + i];
-
-	    dy[(2*j  )*nxp + (2*i+1)]   = ds_10_11_T[j*nx_T + i];
-	    if(j>0) dy[(2*j  )*nxp + (2*i+2)]   = ds_11_12_C[(j-1)*nx_T + i];
-	    dy[(2*j+1)*nxp + (2*i+1)]   = ds_11_12_T[j*nx_T + i];
-	    dy[(2*j+1)*nxp + (2*i+2)]   = ds_10_11_C[j*nx_T + i];
-
-	    angle_dx[(2*j+1)*nxp + 2*i+1] = unknown;
-	    angle_dx[(2*j+1)*nxp + 2*i+2] = unknown;
-	    angle_dx[(2*j+2)*nxp + 2*i+1] = unknown;
-	    angle_dx[(2*j+2)*nxp + 2*i+2] = angle_C[j*nx_C + i ]; 
-
-	    if (j==0) {
-	       x[i1] = 0.5*(x_vert_T[ji0]+x_vert_T[ji1]);
-	       x[i2] = x_vert_T[ji1];
-	       y[i1] = 0.5*(y_vert_T[ji0]+y_vert_T[ji1]);
-	       y[i2] = y_vert_T[ji1];
-
-	       dx[ (2*i+0)] = unknown;
-	       dx[ (2*i+1)] = unknown;
-	       /* dy[(2*j  )*nxp + (2*i+2)]   = unknown; */
-	       dy[(2*j  )*nxp + (2*i+2)]   = ds_20_22_T[j*nx_T + i] - ds_10_11_C[j*nx_T + i];
-
-	       angle_dx[2*i+1] = unknown;
-	       angle_dx[2*i+2] = unknown;
-	    }
-
-	    if (i==0) {
-	       x[j1*nxp] = 0.5*(x_vert_T[ji0]+x_vert_T[ji3]);
-	       x[j2*nxp] = x_vert_T[ji3];
-	       y[j1*nxp] = 0.5*(y_vert_T[ji0]+y_vert_T[ji3]);
-	       y[j2*nxp] = y_vert_T[ji3];
-
-	       /* dx[(2*j+2)*nx  + (2*i)]   = unknown;*/
-	       dx[(2*j+2)*nx  + (2*i)]   = ds_02_22_T[j*nx_T + i] - ds_01_11_C[j*nx_T + i];
-	       dy[(2*j  )*nxp ]    = unknown;
-	       dy[(2*j+1)*nxp ]    = unknown;
-
-	       angle_dx[(2*j+1)*nxp] = unknown;
-	       angle_dx[(2*j+2)*nxp] = unknown;
-	    }
-	    if (i==0 && j==0) {
-	       x[0] = x_vert_T[ji0]; y[0] = y_vert_T[ji0];
-	       angle_dx[0] = unknown;
-	    }
-
-	 }
-      }
-
-      //for(j = 0; j<nyp; j++) { for(i = 0; i<nxp; i++) { if(angle_dx[j*nxp+i]>0.0) printf("%d %d %f\n ",i,j,angle_dx[j*nxp+i]); } }
-      //for(j = 0; j<ny_T; j++) { printf("%f ",y_C[j*nx_T+(nx_T+0)/4]); }
-      //for(i = 0; i<nx_T; i++) { if(y_T[(ny_T-1)*nx_T+i]>85.) printf("%f ",y_T[(ny_T-1)*nx_T+i]); }
-      //printf("\n\n");
-      //for(j = 0; j<nyp; j++) { printf("%f ",y[j*nxp+(nxp-1)/4]); }
-      //for(i = 0; i<nxp; i++) { if(y[(nyp-1)*nxp+i]>85.) printf("%f ",y[(nyp-1)*nxp+i]); }
-
-
-      /* write ocean-grid data */
-      /*-------ocean_hgrid.nc-------*/
-      {
-	 int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-	 int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-	 char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-	 char outfile[128] = "", tilename[128]="";
-	 size_t start[4], nwrite[4];
-    
-	 sprintf(outfile, "%s_hgrid.nc",ocean_name);
-	 printf("Writing %s\n", outfile);
-	 printf("\t nx_C=%d, ny_C=%d, x_T=%d, ny_T=%d \n", nx_C, ny_C,nx_T, ny_T); 
-	 sprintf(tilename, "tile%d", 1);
-	 fid = mpp_open(outfile, MPP_WRITE);
-
-	 dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-	 dimlist[1] = mpp_def_dim(fid, "nxp", nxp);
-	 dimlist[2] = mpp_def_dim(fid, "nyp", nyp);
-	 dimlist[3] = mpp_def_dim(fid, "nx", nx);
-	 dimlist[4] = mpp_def_dim(fid, "ny", ny);
-
-	 id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec",
-	 "tile_spec_version", tile_spec_version, "geometry", geometry,
-	 "discretization", discretization, "conformal", conformal );
-
-
-	 dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	 id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude",
-	 "units", "degree_east");
-	 id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude",
-	 "units", "degree_north");
-
-	 dims[0] = dimlist[2]; dims[1] = dimlist[3];
-	 id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance",
-	 "units", "meters");
-	 dims[0] = dimlist[4]; dims[1] = dimlist[1];
-	 id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance",
-	 "units", "meters");
-
-	 dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	 id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-	 "units", "degrees_east");
-
-	 dims[0] = dimlist[4]; dims[1] = dimlist[3];
-	 id_area= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area",
-	 "units", "m2");
-
-	 mpp_end_def(fid);
-
-	 for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	 nwrite[0] = strlen(tilename);
-	 mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-	 mpp_put_var_value(fid, id_x, x);
-	 mpp_put_var_value(fid, id_y, y);
-	 mpp_put_var_value(fid, id_dx, dx);
-	 mpp_put_var_value(fid, id_dy, dy);
-	 mpp_put_var_value(fid, id_angle_dx, angle_dx);
-	 mpp_close(fid);
-      }
-   }
-// ----------------------------------------------------------------]
-// -----------------atmos_hgrid.nc---------------------------------[
-// Atmosphere
-   int nxba, nyba, nxta, nyta, nxap, nyap;
-   if(is_coupled_grid) {
-      double *x_atmos, *y_atmos;
-      double *xba, *yba, *xta, *yta;
-      int i,j, fid_old, vid;
-
-      fid_old = mpp_open(old_file, MPP_READ);
-      nxba = mpp_get_dimlen(fid_old, "xba");
-      nyba = mpp_get_dimlen(fid_old, "yba");
-      nxta = mpp_get_dimlen(fid_old, "xta");
-      nyta = mpp_get_dimlen(fid_old, "yta");
-      xba = (double *) malloc(nxba * sizeof(double)); 
-      yba = (double *) malloc(nyba * sizeof(double)); 
-      xta = (double *) malloc(nxta * sizeof(double)); 
-      yta = (double *) malloc(nyta * sizeof(double)); 
-      vid = mpp_get_varid(fid_old, "xba"); mpp_get_var_value(fid_old, vid, xba);
-      vid = mpp_get_varid(fid_old, "yba"); mpp_get_var_value(fid_old, vid, yba);
-      vid = mpp_get_varid(fid_old, "xta"); mpp_get_var_value(fid_old, vid, xta);
-      vid = mpp_get_varid(fid_old, "yta"); mpp_get_var_value(fid_old, vid, yta);
-      mpp_close(fid_old);
-  
-      nxap = nxba + nxta; nyap = nyba + nyta; 
-      x_atmos = (double *) malloc(nxap*nyap * sizeof(double));
-      y_atmos = (double *) malloc(nxap*nyap * sizeof(double));
-
-      for(i = 0; i<nxba; i++) x_atmos[2*i]   = xba[i]; for(i = 0; i<nxta; i++) x_atmos[2*i+1]   = xta[i]; 
-
-      for(j = 0; j<nyba; j++) y_atmos[2*j*nxap]   = yba[j]; 
-      for(j = 0; j<nyta; j++) y_atmos[(2*j+1)*nxap]   = yta[j]; 
-
-      for(j = 1; j<nyap; j++) for(i = 0; i<nxap; i++) x_atmos[j*nxap + i]   = x_atmos[i];
-      for(i = 1; i<nxap; i++) for(j = 0; j<nyap; j++) y_atmos[j*nxap + i]   = y_atmos[j*nxap];
-
-      /* write Atmosphere-grid data */
-      {
-	 int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-	 int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-	 char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-	 char outfile[128] = "", tilename[128]="";
-	 size_t start[4], nwrite[4];
-    
-	 sprintf(outfile, "%s_hgrid.nc", atmos_name);
-	 printf("Writing %s\n", outfile);
-	 printf("\t nxba=%d, nyba=%d, nxta=%d, nyta=%d \n", nxba, nyba,nxta, nyta); 
-
-	 sprintf(tilename, "tile%d", 1);
-	 fid = mpp_open(outfile, MPP_WRITE);
-	 dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-	 dimlist[1] = mpp_def_dim(fid, "nxp", nxap);
-	 dimlist[2] = mpp_def_dim(fid, "nyp", nyap);
-	 dimlist[3] = mpp_def_dim(fid, "nx", nxap-1);
-	 dimlist[4] = mpp_def_dim(fid, "ny", nyap-1);
-	 id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec", "tile_spec_version", 
-	 tile_spec_version, "geometry", geometry, "discretization", discretization, "conformal", conformal );
-	 dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	 id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude", "units", "degree_east");
-	 id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude", "units", "degree_north");
-
-	 /* Following variables are not defined */
-	 dims[0] = dimlist[2]; dims[1] = dimlist[3];
-	 id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance", "units", "meters");
-	 dims[0] = dimlist[4]; dims[1] = dimlist[1];
-	 id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance", "units", "meters");
-	 dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	 id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-	 "units", "degrees_east");
-	 dims[0] = dimlist[4]; dims[1] = dimlist[3];
-	 id_angle_dx= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area", "units", "m2");
-	 /* ------------------------------------------- */
-	 mpp_end_def(fid);
-	 for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	 nwrite[0] = strlen(tilename);
-	 mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-	 mpp_put_var_value(fid, id_x, x_atmos);
-	 mpp_put_var_value(fid, id_y, y_atmos);
-	 mpp_close(fid);
-      }
-      free(xba); free(yba); free(xta); free(yta);  free(x_atmos); free(y_atmos);
-   }
-// ----------------------------------------------------------------]
-
-//.................. Land .......................
-//..................land_hgrid.nc................
-   int nxbl, nybl, nxtl, nytl,  nxlp, nylp;
-   if(is_coupled_grid){
-      double *x_land, *y_land;
-      double *xbl, *ybl, *xtl, *ytl;
-      int i,j, fid_old, vid;
-
-      fid_old = mpp_open(old_file, MPP_READ);
-  
-      nxbl = mpp_get_dimlen(fid_old, "xbl");
-      nybl = mpp_get_dimlen(fid_old, "ybl");
-      nxtl = mpp_get_dimlen(fid_old, "xtl");
-      nytl = mpp_get_dimlen(fid_old, "ytl");
-      xbl = (double *) malloc(nxbl * sizeof(double)); 
-      ybl = (double *) malloc(nybl * sizeof(double)); 
-      xtl = (double *) malloc(nxtl * sizeof(double)); 
-      ytl = (double *) malloc(nytl * sizeof(double)); 
-      vid = mpp_get_varid(fid_old, "xbl"); mpp_get_var_value(fid_old, vid, xbl);
-      vid = mpp_get_varid(fid_old, "ybl"); mpp_get_var_value(fid_old, vid, ybl);
-      vid = mpp_get_varid(fid_old, "xtl"); mpp_get_var_value(fid_old, vid, xtl);
-      vid = mpp_get_varid(fid_old, "ytl"); mpp_get_var_value(fid_old, vid, ytl);
-      mpp_close(fid_old);
-  
-      nxlp = nxbl + nxtl; nylp = nybl + nytl; 
-      x_land  = (double *) malloc(nxlp*nylp * sizeof(double));
-      y_land  = (double *) malloc(nxlp*nylp * sizeof(double));
-  
-      for(i = 0; i<nxbl; i++) x_land[2*i]   = xbl[i]; 
-      for(i = 0; i<nxtl; i++) x_land[2*i+1]   = xtl[i]; 
-
-      for(j = 0; j<nybl; j++) y_land[2*j*nxlp]   = ybl[j]; 
-      for(j = 0; j<nytl; j++) y_land[(2*j+1)*nxlp]   = ytl[j]; 
-
-      for(j = 1; j<nylp; j++) for(i = 0; i<nxlp; i++) x_land[j*nxlp + i]   = x_land[i];
-
-      for(i = 1; i<nxlp; i++) 
-	 for(j = 0; j<nylp; j++) 
-	    y_land[j*nxlp + i]   = y_land[j*nxlp];
-
-      /* write Land-grid data */
-      {
-	 int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-	 int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-	 char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-	 char outfile[128] = "", tilename[128]="";
-	 size_t start[4], nwrite[4];
-    
-	 sprintf(outfile, "%s_hgrid.nc",land_name);
-	 printf("Writing %s\n", outfile);
-	 printf("\t nxbl=%d, nybl=%d, nxtl=%d, nytl=%d \n", nxbl, nybl,nxtl, nytl); 
-
-	 sprintf(tilename, "tile%d", 1);
-	 fid = mpp_open(outfile, MPP_WRITE);
-	 dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-	 dimlist[1] = mpp_def_dim(fid, "nxp", nxlp);
-	 dimlist[2] = mpp_def_dim(fid, "nyp", nylp);
-	 dimlist[3] = mpp_def_dim(fid, "nx", nxlp-1);
-	 dimlist[4] = mpp_def_dim(fid, "ny", nylp-1);
-	 id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec", "tile_spec_version", 
-	 tile_spec_version, "geometry", geometry, "discretization", discretization, "conformal", conformal );
-	 dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	 id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude", "units", "degree_east");
-	 id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude", "units", "degree_north");
-
-	 /* Following variables are not defined */
-	 dims[0] = dimlist[2]; dims[1] = dimlist[3];
-	 id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance", "units", "meters");
-	 dims[0] = dimlist[4]; dims[1] = dimlist[1];
-	 id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance", "units", "meters");
-	 dims[0] = dimlist[2]; dims[1] = dimlist[1];
-	 id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-	 "units", "degrees_east");
-	 dims[0] = dimlist[4]; dims[1] = dimlist[3];
-	 id_angle_dx= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area", "units", "m2");
-	 /* ------------------------------------------- */
-
-	 mpp_end_def(fid);
-	 for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	 nwrite[0] = strlen(tilename);
-	 mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-	 mpp_put_var_value(fid, id_x, x_land);
-	 mpp_put_var_value(fid, id_y, y_land);
-	 mpp_close(fid);
-      }
-      free(xbl); free(ybl); free(xtl); free(ytl);  free(x_land); free(y_land);
-   }
-//-------------------------------ocean_vgrid.nc----------------------------------
-   { 
-      double *z, *zb, *zt;
-      int nzb, nzt, nz, i,j, fid_old, vid;
-
-      fid_old = mpp_open(old_file, MPP_READ);
-      nzb = mpp_get_dimlen(fid_old, "zb");
-      nzt = mpp_get_dimlen(fid_old, "zt");
-      zb = (double *) malloc(nzb * sizeof(double)); 
-      zt = (double *) malloc(nzt * sizeof(double)); 
-      vid = mpp_get_varid(fid_old, "zb"); mpp_get_var_value(fid_old, vid, zb);
-      vid = mpp_get_varid(fid_old, "zt"); mpp_get_var_value(fid_old, vid, zt);
-      mpp_close(fid_old);
-  
-      nz = nzb + nzt + 1; 
-      z = (double *) malloc(nz * sizeof(double));
-      z[0]=0.0; 
-      for(i = 0; i<nzt; i++) { z[2*i + 1]   = zt[i]; z[2*i+2]   = zb[i]; } 
-
-      {
-	 int fid, dim, varid;
-	 char outfile[128] = "";
-
-	 sprintf(outfile, "%s_vgrid.nc",ocean_name);
-	 printf("Writing %s\n", outfile);
-	 printf("\t nzb=%d, nzt=%d\n", nzb, nzt); 
-
-	 fid = mpp_open(outfile, MPP_WRITE);
-	 dim  = mpp_def_dim(fid, "nzv", nz);
-	 varid = mpp_def_var(fid, "zeta", MPP_DOUBLE, 1, &dim, 2, "standard_name", "vertical_grid_vertex", "units", "meters");
-	 mpp_end_def(fid);
-	 mpp_put_var_value(fid, varid, z);
-	 mpp_close(fid);
-      }
-      free(zb); free(zt); free(z);
-   }
-
-
-//-------------------------------topog.nc----------------------------------
-   { 
-      double *depth_t;
-      int nx, ny, ntiles, i,j, fid_old, vid;
-
-      fid_old = mpp_open(old_file, MPP_READ);  
-      nx= mpp_get_dimlen(fid_old, "grid_x_T");
-      ny= mpp_get_dimlen(fid_old, "grid_y_T");
-      depth_t= (double *) malloc(nx*ny* sizeof(double));
-      vid = mpp_get_varid(fid_old, "depth_t");  mpp_get_var_value(fid_old, vid, depth_t);
-      mpp_close(fid_old);
-  
-      {
-	 int fid, dim[2], varid, ntiles = 1, dim_ntile;
-	 char outfile[128] = "";
-	 sprintf(outfile, "topog.nc");
-	 printf("Writing %s\n", outfile);
-	 printf("\t nx=%d, ny=%d\n", nx, ny);
-	 fid = mpp_open(outfile, MPP_WRITE);
-	 dim_ntile = mpp_def_dim(fid, "ntiles", 1);
-	 dim[1]  = mpp_def_dim(fid, "nx", nx);
-	 dim[0]  = mpp_def_dim(fid, "ny", ny);
-	 varid = mpp_def_var(fid, "depth", MPP_DOUBLE, 2, dim, 2, "standard_name", "topographic depth at T-cell centers", "units", "meters");
-	 mpp_end_def(fid);
-	 mpp_put_var_value(fid, varid, depth_t);
-	 mpp_close(fid);
-      }
-      free(depth_t); 
-   }
-
-//................atmos_mosaic.nc............................
-   if(is_coupled_grid)  {
-      char str[STRING], outfile[STRING];
-      int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-      int id_contact_index, id_griddir, id_gridfiles, dim[2];
-
-      size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-      ntiles = 1, ncontact = 0; 
-
-      sprintf(mosaic_name, "%s_mosaic",atmos_name);
-      sprintf(outfile, "%s.nc", mosaic_name);
-      printf("Writing %s\n", outfile);
-
-      sprintf(tile_name[0], "tile%d", 1);
-      sprintf(tilefile[0], "%s_hgrid.nc",atmos_name);
-      fid = mpp_open(outfile, MPP_WRITE);
-
-      contact_tile1_istart[0]=nxba-1; contact_tile1_iend[0]=nxba-1; 
-      contact_tile1_jstart[0]=1; contact_tile1_jend[0]=nyba-1; 
-
-      contact_tile2_istart[0]=1; contact_tile2_iend[0]=1; 
-      contact_tile2_jstart[0]=1; contact_tile2_jend[0]=nyba-1;
-//--------Initilize values --------------
-
-      dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-      if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-      dim_string = mpp_def_dim(fid, "string", STRING);
-
-      id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-      "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-      "children", "gridtiles", "contact_regions", "contacts",
-      "grid_descriptor", grid_descriptor);
-      dim[0] = dim_ntiles; dim[1] = dim_string;
-      id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-      "standard_name", "grid_file_location");
-      id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-      id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-      if(ncontact>0) {
-	 dim[0] = dim_ncontact; dim[1] = dim_string;
-	 id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-	 "contact_type", "boundary", "alignment", "true",
-	 "contact_index", "contact_index", "orientation", "orient");
-	 id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-	 "starting_ending_point_index_of_contact");
-
-      }
-
-      //mpp_def_global(fid, "history", history);
-      mpp_end_def(fid);
-
-      /* write out data */
-      for(i=0; i<4; i++) {
-	 start[i] = 0; nwrite[i] = 1;
-      }
-      nwrite[0] = strlen(mosaic_name);
-      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-      nwrite[0] = strlen(mosaic_dir);
-      mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-      nwrite[0] = 1;
-      for(n=0; n<ntiles; n++) {
-	 start[0] = n; nwrite[1] = strlen(tile_name[n]);
-	 mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-	 nwrite[1] = strlen(tilefile[n]);
-	 mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-      }
-
-      for(n=0; n<ncontact; n++) {
-	 sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-	 tile_name[contact_tile2[n]]);
-	 start[0] = n; nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-	 sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-	 contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-	 contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-	 nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-      }
-      mpp_close(fid);
-   }
-
-//................land_mosaic.nc............................
-   if(is_coupled_grid)  {
-      char str[STRING], outfile[STRING];
-      int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-      int id_contact_index, id_griddir, id_gridfiles, dim[2];
-
-      size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-      ntiles = 1, ncontact = 1; 
-      contact_tile1_istart[1]=1; contact_tile1_iend[1]=1;
-      contact_tile1_jstart[1]=1; contact_tile1_jend[1]=nytl;
-
-      contact_tile2_istart[1]=nxtl; contact_tile2_iend[1]=nxtl;
-      contact_tile2_jstart[1]=1;    contact_tile2_jend[1]=nytl;
-    
-      sprintf(mosaic_name, "%s_mosaic",land_name);
-      sprintf(outfile, "%s.nc", mosaic_name);
-      printf("Writing %s\n", outfile);
-
-      sprintf(tile_name[0], "tile%d", 1);
-      sprintf(tilefile[0], "%s_hgrid.nc",land_name);
-      fid = mpp_open(outfile, MPP_WRITE);
-
-      contact_tile1_istart[0]=nxbl-1; contact_tile1_iend[0]=nxbl-1; 
-      contact_tile1_jstart[0]=1; contact_tile1_jend[0]=nybl-1; 
-
-      contact_tile2_istart[0]=1; contact_tile2_iend[0]=1; 
-      contact_tile2_jstart[0]=1; contact_tile2_jend[0]=nybl-1;
-//--------Initilize values --------------
-
-      dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-      if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-      dim_string = mpp_def_dim(fid, "string", STRING);
-
-      id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-      "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-      "children", "gridtiles", "contact_regions", "contacts",
-      "grid_descriptor", grid_descriptor);
-      dim[0] = dim_ntiles; dim[1] = dim_string;
-      id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-      "standard_name", "grid_file_location");
-      id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-      id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-      if(ncontact>0) {
-	 dim[0] = dim_ncontact; dim[1] = dim_string;
-	 id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-	 "contact_type", "boundary", "alignment", "true",
-	 "contact_index", "contact_index", "orientation", "orient");
-	 id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-	 "starting_ending_point_index_of_contact");
-
-      }
-
-      //mpp_def_global(fid, "history", history);
-      mpp_end_def(fid);
-
-      /* write out data */
-      for(i=0; i<4; i++) {
-	 start[i] = 0; nwrite[i] = 1;
-      }
-      nwrite[0] = strlen(mosaic_name);
-      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-      nwrite[0] = strlen(mosaic_dir);
-      mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-      nwrite[0] = 1;
-      for(n=0; n<ntiles; n++) {
-	 start[0] = n; nwrite[1] = strlen(tile_name[n]);
-	 mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-	 nwrite[1] = strlen(tilefile[n]);
-	 mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-      }
-
-      for(n=0; n<ncontact; n++) {
-	 sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-	 tile_name[contact_tile2[n]]);
-	 start[0] = n; nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-	 sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-	 contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-	 contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-	 nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-      }
-      mpp_close(fid);
-   }
-
-/* ...................... ocean_mosaic.nc .................*/
-   {
-      char str[STRING], outfile[STRING], x_boundary_type1[255]="", y_boundary_type1[255]="";
-      int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-      int id_contact_index, id_griddir, id_gridfiles, dim[2], itmp, fid_old;
-
-      size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-      ntiles = 1, ncontact = 0; 
-
-      sprintf(mosaic_name, "%s_mosaic",ocean_name);
-      sprintf(outfile, "%s.nc", mosaic_name);
-      printf("Writing %s\n", outfile);
-
-      sprintf(tile_name[0], "tile%d", 1);
-      sprintf(tilefile[0], "%s_hgrid.nc", ocean_name);
-    
-      /* ........... Read Boundary Type ................ */
-      fid_old = mpp_open(old_file, MPP_READ);
-      mpp_get_global_att(fid_old, "x_boundary_type",x_boundary_type1);
-      mpp_get_global_att(fid_old, "y_boundary_type",y_boundary_type1);
-      mpp_close(fid_old);
-      if (strcmp(x_boundary_type1, "cyclic")==0) {
-	 n = ncontact; ncontact = ncontact + 1; 
-	 contact_tile1_istart[n]=360; contact_tile1_iend[n]=360; 
-	 contact_tile1_jstart[n]=1; contact_tile1_jend[n]=180; 
-
-	 contact_tile2_istart[n]=1; contact_tile2_iend[n]=1; 
-	 contact_tile2_jstart[n]=1; contact_tile2_jend[n]=180;
-	 printf("\t x_boundary_type = %s, ncontact=%d \n",x_boundary_type1,ncontact);
-      }
-    
-      if (strcmp(y_boundary_type1, "fold_north_edge")==0) {
-	 n = ncontact; ncontact = ncontact + 1; 
-	 contact_tile1_istart[n]=1; contact_tile1_iend[n]=180;
-	 contact_tile1_jstart[n]=180; contact_tile1_jend[n]=180;
-
-	 contact_tile2_istart[n]=360; contact_tile2_iend[n]=181;
-	 contact_tile2_jstart[n]=180; contact_tile2_jend[n]=180;
-	 printf("\t y_boundary_type = %s, ncontact=%d \n",y_boundary_type1,ncontact);
-      }
-
-      fid = mpp_open(outfile, MPP_WRITE);
-
-//--------Initilize values --------------
-
-      dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-      if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-      dim_string = mpp_def_dim(fid, "string", STRING);
-
-      id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-      "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-      "children", "gridtiles", "contact_regions", "contacts",
-      "grid_descriptor", grid_descriptor);
-      dim[0] = dim_ntiles; dim[1] = dim_string;
-      id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-      "standard_name", "grid_file_location");
-      id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-      id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-      if(ncontact>0) {
-	 dim[0] = dim_ncontact; dim[1] = dim_string;
-	 id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-	 "contact_type", "boundary", "alignment", "true",
-	 "contact_index", "contact_index", "orientation", "orient");
-	 id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-	 "starting_ending_point_index_of_contact");
-
-      }
-
-      //mpp_def_global(fid, "history", history);
-      mpp_end_def(fid);
-
-      /* write out data */
-      for(i=0; i<4; i++) {
-	 start[i] = 0; nwrite[i] = 1;
-      }
-      nwrite[0] = strlen(mosaic_name);
-      mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-      nwrite[0] = strlen(mosaic_dir);
-      mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-      nwrite[0] = 1;
-      for(n=0; n<ntiles; n++) {
-	 start[0] = n; nwrite[1] = strlen(tile_name[n]);
-	 mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-	 nwrite[1] = strlen(tilefile[n]);
-	 mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-      }
-
-      for(n=0; n<ncontact; n++) {
-	 sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-	 tile_name[contact_tile2[n]]);
-	 start[0] = n; nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-	 sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-	 contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-	 contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-	 nwrite[1] = strlen(str);
-	 mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-      }
-      mpp_close(fid);
-   }
-/* ...................... atmosXland.nc .................*/
-   if(is_coupled_grid)  {
-      const char version[] = "0.2";
-      char lxo_file[STRING], axo_file[STRING], axl_file[STRING];
-      char amosaic_file[STRING], lmosaic_file[STRING], omosaic_file[STRING];
-      char otopog_file[STRING];
-
-      char atile_name[255], ltile_name[255], otile_name[255];
-      char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-      int  fid_old, vid;
-  
-      strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-      strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-      int no, nl, na, n;
-      size_t  naxl, naxo, naxl_step;
-      int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-      int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-      int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-      double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-      double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-      double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-
-      fid_old = mpp_open(old_file, MPP_READ);
-      naxl = mpp_get_dimlen(fid_old, "i_atmXlnd");
-//----------------
- 
-      /* write out atmXlnd data*/
-      if(naxl>0) {
-	 size_t start[4], nwrite[4];
-                                                                                                                                                          
-	 int fid, dim_string, dim_ncells, dim_two, dims[4];
-	 int id_xgrid_area, id_contact, n;
-	 int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-	 char contact[STRING];
-                                                                                                                                                          
-	 for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-	 }
-	 sprintf(axl_file, "%s_mosaicX%s_mosaic.nc", amosaic_name, lmosaic_name);
-	 printf("Writing %s_mosaicX%s_mosaic.nc\n", amosaic_name, lmosaic_name);
-	 sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", amosaic_name, atile_name, lmosaic_name, ltile_name);
-	 fid = mpp_open(axl_file, MPP_WRITE);
-	 //mpp_def_global(fid, "history", history);
-	 dim_string = mpp_def_dim(fid, "string", STRING);
-	 dim_ncells = mpp_def_dim(fid, "ncells", naxl);
-	 dim_two    = mpp_def_dim(fid, "two", 2);
-	 if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-	    "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-	    "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-	    "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	 }
-	 else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-	    "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-	    "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-	 }
-                                                                                                                                                          
-	 dims[0] = dim_ncells; dims[1] = dim_two;
-	 id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-	 id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-	 id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-	 "exchange_grid_area", "units", "m2");
-	 if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-	 }
-	 mpp_end_def(fid);
-
-	 for(i=0; i<4; i++) {start[i] = 0; nwrite[i] = 1;}
-	 nwrite[0] = strlen(contact);
-	 mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	 nwrite[0] = naxl;
-
-	 atmxlnd_area = (double *)malloc(naxl*sizeof(double)); 
-	 atmxlnd_ia   = (int    *)malloc(naxl*sizeof(int   )); 
-	 atmxlnd_ja   = (int    *)malloc(naxl*sizeof(int   )); 
-	 atmxlnd_il   = (int    *)malloc(naxl*sizeof(int   )); 
-	 atmxlnd_jl   = (int    *)malloc(naxl*sizeof(int   )); 
-	 vid = mpp_get_varid(fid_old, "AREA_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_area);
-	 vid = mpp_get_varid(fid_old, "I_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ia);
-	 vid = mpp_get_varid(fid_old, "J_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ja);
-	 vid = mpp_get_varid(fid_old, "I_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_il);
-	 vid = mpp_get_varid(fid_old, "J_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_jl);
-	  
-	 for(i=0;i<naxl;i++)atmxlnd_area[i] = atmxlnd_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-	 mpp_put_var_value(fid, id_xgrid_area, atmxlnd_area);
-	 mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxlnd_ia);
-	 mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxlnd_il);
-	 start[1] = 1;
-	 mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxlnd_ja);
-	 mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxlnd_jl);
-	 if(interp_order == 2) {
-            atmxlnd_di = (double *)malloc(naxl*sizeof(double)); 
-            atmxlnd_dj = (double *)malloc(naxl*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_di);
-	    vid = mpp_get_varid(fid_old, "DJ_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxlnd_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxlnd_dj);
-	 }
-	  
-	 mpp_close(fid);
-	 free(atmxlnd_area);
-      }
-      mpp_close(fid_old);
-   }
-/* ...................... atmosXocean.nc .................*/
-   if(is_coupled_grid)  {
-      const char version[] = "0.2";
-      char lxo_file[STRING];
-      char axo_file[STRING];
-      char axl_file[STRING];
-      char amosaic_file[STRING];
-      char lmosaic_file[STRING];
-      char omosaic_file[STRING];
-      char otopog_file[STRING];
-
-      char atile_name[255], ltile_name[255], otile_name[255];
-      char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-
-      strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-      strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-      int no, nl, na, n;
-      size_t  naxl, naxo, naxl_step;
-      int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-      int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-      int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-      double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-      double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-      double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-      int fid_old, vid;
-
-      fid_old = mpp_open(old_file, MPP_READ);
-      naxo = mpp_get_dimlen(fid_old, "i_atmXocn");
-//----------------
- 
-      /* write out atmXlnd data*/
-      if(naxo>0) {
-	 size_t start[4], nwrite[4];
-                                                                                                                                                          
-	 int fid, dim_string, dim_ncells, dim_two, dims[4];
-	 int id_xgrid_area, id_contact, n;
-	 int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-	 char contact[STRING];
-                                                                                                                                                          
-	 for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-	 }
-	 sprintf(axo_file, "%s_mosaicX%s_mosaic.nc", amosaic_name, omosaic_name);
-	 printf("Writing %s_mosaicX%s_mosaic.nc\n", amosaic_name, omosaic_name);
-	 sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", amosaic_name, atile_name, omosaic_name, otile_name);
-	 fid = mpp_open(axo_file, MPP_WRITE);
-	 //mpp_def_global(fid, "history", history);
-	 dim_string = mpp_def_dim(fid, "string", STRING);
-	 dim_ncells = mpp_def_dim(fid, "ncells", naxo);
-	 dim_two    = mpp_def_dim(fid, "two", 2);
-	 if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-	    "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-	    "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-	    "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	 }
-	 else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-	    "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-	    "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-	 }
-                                                                                                                                                          
-	 dims[0] = dim_ncells; dims[1] = dim_two;
-	 id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-	 id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-	 id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-	 "exchange_grid_area", "units", "m2");
-	 if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-	 }
-	 mpp_end_def(fid);
-
-	 for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1;}
-	 nwrite[0] = strlen(contact);
-	 mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	 nwrite[0] = naxo;
-
-	 atmxocn_area = (double *)malloc(naxo*sizeof(double)); 
-	 atmxocn_ia   = (int    *)malloc(naxo*sizeof(int   )); 
-	 atmxocn_ja   = (int    *)malloc(naxo*sizeof(int   )); 
-	 atmxocn_io   = (int    *)malloc(naxo*sizeof(int   )); 
-	 atmxocn_jo   = (int    *)malloc(naxo*sizeof(int   )); 
-	 vid = mpp_get_varid(fid_old, "AREA_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_area);
-	 vid = mpp_get_varid(fid_old, "I_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ia);
-	 vid = mpp_get_varid(fid_old, "J_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ja);
-	 vid = mpp_get_varid(fid_old, "I_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_io);
-	 vid = mpp_get_varid(fid_old, "J_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_jo);
-	  
-	 for(i=0;i<naxo;i++)atmxocn_area[i] = atmxocn_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-	 mpp_put_var_value(fid, id_xgrid_area, atmxocn_area);
-	 mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxocn_ia);
-	 mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxocn_io);
-	 start[1] = 1;
-	 mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxocn_ja);
-	 mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxocn_jo);
-	 if(interp_order == 2) {
-            atmxocn_di = (double *)malloc(naxo*sizeof(double)); 
-            atmxocn_dj = (double *)malloc(naxo*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_di);
-	    vid = mpp_get_varid(fid_old, "DJ_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxocn_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxocn_dj);
-	 }
-	 mpp_close(fid);
-	 free(atmxocn_area);
-      }
-      mpp_close(fid_old);
-   }
-/* ...................... landXocean.nc .................*/
-   if(is_coupled_grid)  {
-      const char version[] = "0.2";
-      char lxo_file[STRING];
-      char axo_file[STRING];
-      char axl_file[STRING];
-      char amosaic_file[STRING];
-      char lmosaic_file[STRING];
-      char omosaic_file[STRING];
-      char otopog_file[STRING];
-
-      char atile_name[255], ltile_name[255], otile_name[255];
-      char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-
-      strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-      strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-      int no, nl, na, n;
-      size_t  naxl, naxo, nlxo, naxl_step;
-      int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-      int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-      int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-      double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-      double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-      double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-      int     fid_old, vid;
-
-      fid_old = mpp_open(old_file, MPP_READ);
-      nlxo = mpp_get_dimlen(fid_old , "i_lndXocn");
-//----------------
- 
-      /* write out lndXocn data*/
-      if(nlxo>0) {
-	 size_t start[4], nwrite[4];
-                                                                                                                                                          
-	 int fid, dim_string, dim_ncells, dim_two, dims[4];
-	 int id_xgrid_area, id_contact, n;
-	 int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-	 char contact[STRING];
-                                                                                                                                                          
-	 for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-	 }
-	 sprintf(lxo_file, "%s_mosaicX%s_mosaic.nc", lmosaic_name, omosaic_name);
-	 printf("Writing %s_mosaicX%s_mosaic.nc\n", lmosaic_name, omosaic_name);
-	 sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", lmosaic_name, ltile_name, omosaic_name, otile_name);
-	 fid = mpp_open(lxo_file, MPP_WRITE);
-	 //mpp_def_global(fid, "history", history);
-	 dim_string = mpp_def_dim(fid, "string", STRING);
-	 dim_ncells = mpp_def_dim(fid, "ncells", nlxo);
-	 dim_two    = mpp_def_dim(fid, "two", 2);
-	 if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-	    "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-	    "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-	    "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	 }
-	 else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-	    "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-	    "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-	 }
-                                                                                                                                                          
-	 dims[0] = dim_ncells; dims[1] = dim_two;
-	 id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-	 id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-	 id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-	 "exchange_grid_area", "units", "m2");
-	 if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-	 }
-	 mpp_end_def(fid);
-
-	 for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1;}
-	 nwrite[0] = strlen(contact);
-	 mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	 nwrite[0] = nlxo;
-
-	 lndxocn_area = (double *)malloc(nlxo*sizeof(double)); 
-	 lndxocn_il   = (int    *)malloc(nlxo*sizeof(int   )); 
-	 lndxocn_jl   = (int    *)malloc(nlxo*sizeof(int   )); 
-	 lndxocn_io   = (int    *)malloc(nlxo*sizeof(int   )); 
-	 lndxocn_jo   = (int    *)malloc(nlxo*sizeof(int   )); 
-	 vid = mpp_get_varid(fid_old, "AREA_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_area);
-	 vid = mpp_get_varid(fid_old, "I_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_il);
-	 vid = mpp_get_varid(fid_old, "J_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jl);
-	 vid = mpp_get_varid(fid_old, "I_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_io);
-	 vid = mpp_get_varid(fid_old, "J_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jo);
-	  
-	 for(i=0;i<nlxo;i++)lndxocn_area[i] = lndxocn_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-	 mpp_put_var_value(fid, id_xgrid_area, lndxocn_area);
-	 mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, lndxocn_il);
-	 mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, lndxocn_io);
-	 start[1] = 1;
-	 mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, lndxocn_jl);
-	 mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, lndxocn_jo);
-	 if(interp_order == 2) {
-            lndxocn_di = (double *)malloc(nlxo*sizeof(double)); 
-            lndxocn_dj = (double *)malloc(nlxo*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_di);
-	    vid = mpp_get_varid(fid_old, "DJ_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, lndxocn_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, lndxocn_dj);
-	 }
-	 mpp_close(fid);
-	 free(lndxocn_area);
-      }
-      mpp_close(fid_old);
-   }
-
-/* ...................... mosaic.nc .................*/
-   {
-      const char version[] = "0.2";
-      char lxo_file[STRING], axo_file[STRING], axl_file[STRING], mosaic_file[STRING];
-      char amosaic_file[STRING], lmosaic_file[STRING], omosaic_file[STRING];
-      char amosaic_name[STRING], lmosaic_name[STRING], omosaic_name[STRING];
-      char otopog_file[STRING];
-
-      int fid, dim_string, dim_axo, dim_lxo, dim_axl, dims[4], n;
-      size_t start[4], nwrite[4];
-      int id_lmosaic_dir, id_lmosaic_file, id_omosaic_dir, id_omosaic_file;
-      int id_amosaic_dir, id_amosaic_file, id_otopog_dir, id_otopog_file;
-      int id_xgrids_dir, id_axo_file, id_lxo_file, id_axl_file;
-      int id_amosaic, id_lmosaic, id_omosaic;
-
-      int nfile_axo = 1, nfile_axl = 1, nfile_lxo = 1; 
-
-      strcpy(mosaic_file,"mosaic.nc");
-      printf("Writing %s\n", mosaic_file);
-
-      fid = mpp_open(mosaic_file, MPP_WRITE);
-      //  mpp_def_global(fid, "history", history);
-      dim_string = mpp_def_dim(fid, "string", STRING);
-      dim_axo = mpp_def_dim(fid, "nfile_aXo", nfile_axo);
-      dim_axl = mpp_def_dim(fid, "nfile_aXl", nfile_axl);
-      dim_lxo = mpp_def_dim(fid, "nfile_lXo", nfile_lxo);
-      id_amosaic_dir  = mpp_def_var(fid, "atm_mosaic_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_atmosphere_mosaic");
-      id_amosaic_file = mpp_def_var(fid, "atm_mosaic_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "atmosphere_mosaic_file_name");
-      id_amosaic      = mpp_def_var(fid, "atm_mosaic", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "atmosphere_mosaic_name");
-      id_lmosaic_dir  = mpp_def_var(fid, "lnd_mosaic_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_land_mosaic");
-      id_lmosaic_file = mpp_def_var(fid, "lnd_mosaic_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "land_mosaic_file_name");
-      id_lmosaic      = mpp_def_var(fid, "lnd_mosaic", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "land_mosaic_name");
-      id_omosaic_dir  = mpp_def_var(fid, "ocn_mosaic_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_ocean_mosaic");
-      id_omosaic_file = mpp_def_var(fid, "ocn_mosaic_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "ocean_mosaic_file_name");
-      id_omosaic      = mpp_def_var(fid, "ocn_mosaic", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "ocean_mosaic_name");
-      id_otopog_dir   = mpp_def_var(fid, "ocn_topog_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_ocean_topog");
-      id_otopog_file  = mpp_def_var(fid, "ocn_topog_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "ocean_topog_file_name");
-      /* since exchange grid is created in this tool, we may add command line option to specify where to store the output */
-      /*    id_xgrids_dir = mpp_def_var(fid, "xgrids_dir", MPP_CHAR, 1, &dim_string,
-	    1, "standard_name", "directory_storing_xgrids"); */
-      dims[0] = dim_axo; dims[1] = dim_string;
-      id_axo_file = mpp_def_var(fid, "aXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXocn_exchange_grid_file");
-      dims[0] = dim_axl; dims[1] = dim_string;
-      id_axl_file = mpp_def_var(fid, "aXl_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXlnd_exchange_grid_file");
-      dims[0] = dim_lxo; dims[1] = dim_string;
-      id_lxo_file = mpp_def_var(fid, "lXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "lndXocn_exchange_grid_file");
-      mpp_end_def(fid);
-
-      strcpy(otopog_file,"topog.nc");
-
-      sprintf(amosaic_name,"%s_mosaic",atmos_name); sprintf(lmosaic_name,"%s_mosaic",land_name); sprintf(omosaic_name,"%s_mosaic",ocean_name);
-      sprintf(amosaic_file,"%s.nc",amosaic_name); sprintf(lmosaic_file,"%s.nc",lmosaic_name); sprintf(omosaic_file,"%s.nc",omosaic_name);
-
-      sprintf(axl_file,"%sX%s.nc", amosaic_name, lmosaic_name); 
-      sprintf(axo_file,"%sX%s.nc", amosaic_name, omosaic_name); 
-      sprintf(lxo_file,"%sX%s.nc", lmosaic_name, omosaic_name); 
-
-      for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; }
-      nwrite[0] = strlen(mosaic_dir);
-      mpp_put_var_value_block(fid, id_amosaic_dir, start, nwrite, mosaic_dir);
-      nwrite[0] = strlen(amosaic_file);
-      mpp_put_var_value_block(fid, id_amosaic_file, start, nwrite, amosaic_file);
-      nwrite[0] = strlen(amosaic_name);
-      mpp_put_var_value_block(fid, id_amosaic, start, nwrite, amosaic_name);
-      nwrite[0] = strlen(mosaic_dir);
-      mpp_put_var_value_block(fid, id_lmosaic_dir, start, nwrite, mosaic_dir);
-      nwrite[0] = strlen(lmosaic_file);
-      mpp_put_var_value_block(fid, id_lmosaic_file, start, nwrite, lmosaic_file);
-      nwrite[0] = strlen(lmosaic_name);
-      mpp_put_var_value_block(fid, id_lmosaic, start, nwrite, lmosaic_name);
-      nwrite[0] = strlen(mosaic_dir);
-      mpp_put_var_value_block(fid, id_omosaic_dir, start, nwrite, mosaic_dir);
-      nwrite[0] = strlen(omosaic_file);
-      mpp_put_var_value_block(fid, id_omosaic_file, start, nwrite, omosaic_file);
-      nwrite[0] = strlen(omosaic_name);
-      mpp_put_var_value_block(fid, id_omosaic, start, nwrite, omosaic_name);
-      nwrite[0] = strlen(mosaic_dir);
-      mpp_put_var_value_block(fid, id_otopog_dir, start, nwrite, mosaic_dir);
-      nwrite[0] = strlen(otopog_file);
-      mpp_put_var_value_block(fid, id_otopog_file, start, nwrite, otopog_file);
-      for(i=0; i<4; i++) {
-	 start[i] = 0; nwrite[i] = 1;
-      }
-      start[0] = 0; nwrite[1] = strlen(axo_file);
-      mpp_put_var_value_block(fid, id_axo_file, start, nwrite, axo_file);
-
-      start[0] = 0; nwrite[1] = strlen(axl_file);
-      mpp_put_var_value_block(fid, id_axl_file, start, nwrite, axl_file);
-
-      start[0] = 0; nwrite[1] = strlen(lxo_file);
-      mpp_put_var_value_block(fid, id_lxo_file, start, nwrite, lxo_file);
-      mpp_close(fid);
-   }
-
-   return 0;
-}
-
-int 
-gs_make_vgrid(char *history, int nbnds, int n1, 
-int n2, char *gridname, char *center)
-{
-   int i, nk;
-   double bnds[MAXBOUNDS];
-   int    nz[MAXBOUNDS-1];
-   char filename[128];
-   double *zeta;
-   int c, option_index = 0;
-
-   /* check the command-line arguments to make sure the value are suitable */
-   if( nbnds < 2 ) mpp_error("number of bounds specified through -nbnd should be an integer greater than 1");
-   if( nbnds != n1 ) mpp_error("nbnds does not equal number entry specified through -bnd");
-   if( nbnds-1 != n2 ) mpp_error("nbnds-1 does not match number entry specified through -nz");
-
-   /* generate grid */
-   nk = 0;
-   for(i=0; i<nbnds-1; i++) nk += nz[i];
-   zeta = (double *)malloc((nk+1)*sizeof(double));
-   create_vgrid(nbnds, bnds, nz, zeta, center);
-
-   sprintf(filename, "%s.nc", gridname);
-  
-   /* write out vertical grid into a netcdf file */
-   {
-      int fid, dim, varid;
-    
-      fid = mpp_open(filename, MPP_WRITE);
-      dim  = mpp_def_dim(fid, "nzv", nk+1);
-      varid = mpp_def_var(fid, "zeta", NC_DOUBLE, 1, &dim, 2, "standard_name", "vertical_grid_vertex",
-      "units", "meters");
-      mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-      mpp_def_global_att(fid, "code_version", TAGNAME);
-      mpp_def_global_att(fid, "history", history);    
-      mpp_end_def(fid);
-      mpp_put_var_value(fid, varid, zeta);
-  
-      mpp_close(fid);
-   }
-
-   if(mpp_pe() == mpp_root_pe()) printf("Successfully generate vertical grid file %s\n", filename);
-   return 0;
-}
-
-
-/* This file will get the directory that stores the file and the file name (without the dir path) */
-void get_file_dir_and_name(char *file, char *filedir, char *filename)
-{
-   char *fptr=NULL;
-   int siz;
-  
-   fptr = strrchr(file, '/');
-
-   if(!fptr) {
-      strcpy(filename, file);
-      strcpy(filedir, "./");
-   }
-   else {
-      ++fptr;
-      siz = fptr - file;
-      strcpy(filename, fptr);
-      strncpy(filedir, file, siz);      
-   }
-};
-
-#define D2R (M_PI/180.)
-#define MAXXGRIDFILE 100 
-#define MX 2000  
-#define AREA_RATIO_THRESH (1.e-6)
-#define TINY_VALUE (1.e-7)
-#define TOLORENCE (1.e-4)
-
-int gs_make_coupler_mosaic(char *history, char *amosaic, char *lmosaic, 
-                           char *omosaic, char *otopog, int interp_order, 
-                           double sea_level, char *mosaic_name, int check)
-{  
-   int c, i, same_mosaic;
-   char mosaic_file[STRING];
-   char omosaic_name[STRING], amosaic_name[STRING], lmosaic_name[STRING];
-   char **otile_name=NULL, **atile_name=NULL, **ltile_name=NULL;
-   int x_refine = 2, y_refine = 2;
-   int nfile_lxo=0, nfile_axo=0, nfile_axl=0;
-   char lxo_file[MAXXGRIDFILE][STRING];
-   char axo_file[MAXXGRIDFILE][STRING];
-   char axl_file[MAXXGRIDFILE][STRING];  
-   char amosaic_dir[STRING], amosaic_file[STRING];
-   char lmosaic_dir[STRING], lmosaic_file[STRING];
-   char omosaic_dir[STRING], omosaic_file[STRING];
-   char otopog_dir[STRING], otopog_file[STRING];
-   int    ntile_ocn, ntile_atm, ntile_lnd;
-   int    *nxo = NULL, *nyo = NULL, *nxa = NULL, *nya = NULL, *nxl = NULL, *nyl = NULL;
-   double **xocn = NULL, **yocn = NULL, **xatm = NULL, **yatm = NULL, **xlnd = NULL, **ylnd = NULL;
-   double **area_ocn = NULL, **area_lnd = NULL, **area_atm = NULL;
-   double **omask = NULL;
-   int    lnd_same_as_atm = 0;
-   int    option_index = 0;
-   double axo_area_sum = 0, axl_area_sum = 0;
-   int    ocn_south_ext = 0;
-
-   /*mosaic_file can not have the same name as amosaic, lmosaic or omosaic, also the file name of
-     amosaic, lmosaic, omosaic can not be "mosaic.nc"
-   */
-   sprintf(mosaic_file, "%s.nc", mosaic_name);
-   get_file_dir_and_name(amosaic, amosaic_dir, amosaic_file);
-   get_file_dir_and_name(lmosaic, lmosaic_dir, lmosaic_file);
-   get_file_dir_and_name(omosaic, omosaic_dir, omosaic_file);
-   get_file_dir_and_name(otopog, otopog_dir, otopog_file);
-   if( !strcmp(mosaic_file, amosaic_file) || !strcmp(mosaic_file, lmosaic_file) || !strcmp(mosaic_file, omosaic_file) ) 
-      mpp_error("make_coupler_mosaic: mosaic_file can not have the same name as amosaic, lmosaic or omosaic"); 
-   if( !strcmp(amosaic_file, "mosaic.nc") || !strcmp(lmosaic_file, "mosaic.nc") || !strcmp(omosaic_file, "mosaic.nc") ) 
-      mpp_error("make_coupler_mosaic: the file name of amosaic, lmosaic or omosaic can not be mosaic.nc"); 
-
-  
-   /*
-    * Read atmosphere grid
-    */
-   {
-      int n, m_fid, g_fid, vid, gid, tid;
-      size_t start[4], nread[4];
-      char dir[STRING], filename[STRING], file[2*STRING];    
-
-      for(n=0; n<4; n++) {
-	 start[n] = 0;
-	 nread[n] = 1;
-      }
-
-      m_fid = mpp_open(amosaic, MPP_READ);
-      vid = mpp_get_varid(m_fid, "mosaic");    
-      mpp_get_var_value(m_fid, vid, amosaic_name);
-      ntile_atm  = mpp_get_dimlen(m_fid, "ntiles");
-      nxa        = (int *) malloc (ntile_atm*sizeof(int));
-      nya        = (int *) malloc (ntile_atm*sizeof(int));
-      xatm       = (double **) malloc( ntile_atm*sizeof(double *));
-      yatm       = (double **) malloc( ntile_atm*sizeof(double *));
-      area_atm   = (double **) malloc( ntile_atm*sizeof(double *));
-      atile_name = (char **)malloc(ntile_atm*sizeof(char *));
-      /* grid should be located in the same directory of mosaic file */
-      get_file_path(amosaic, dir);
-      gid = mpp_get_varid(m_fid, "gridfiles");
-      tid = mpp_get_varid(m_fid, "gridtiles");
-      for(n=0; n<ntile_atm; n++) {
-	 double *tmpx, *tmpy;
-	 int i, j;
-      
-	 start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-	 mpp_get_var_value_block(m_fid, gid, start, nread, filename);
-	 atile_name[n] = (char *)malloc(STRING*sizeof(char));
-	 mpp_get_var_value_block(m_fid, tid, start, nread,  atile_name[n]);
-	 sprintf(file, "%s/%s", dir, filename);
-	 g_fid = mpp_open(file, MPP_READ);
-	 nxa[n] = mpp_get_dimlen(g_fid, "nx");
-	 nya[n] = mpp_get_dimlen(g_fid, "ny");
-	 if(nxa[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: atmos supergrid x-size can not be divided by x_refine");
-	 if(nya[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: atmos supergrid y-size can not be divided by y_refine");
-	 nxa[n] /= x_refine;
-	 nya[n] /= y_refine;
-	 xatm[n]     = (double *)malloc((nxa[n]+1)*(nya[n]+1)*sizeof(double));
-	 yatm[n]     = (double *)malloc((nxa[n]+1)*(nya[n]+1)*sizeof(double));
-	 area_atm[n] = (double *)malloc((nxa[n]  )*(nya[n]  )*sizeof(double));
-	 tmpx        = (double *)malloc((nxa[n]*x_refine+1)*(nya[n]*y_refine+1)*sizeof(double));
-	 tmpy        = (double *)malloc((nxa[n]*x_refine+1)*(nya[n]*y_refine+1)*sizeof(double));
-	 vid = mpp_get_varid(g_fid, "x");
-	 mpp_get_var_value(g_fid, vid, tmpx);
-	 vid = mpp_get_varid(g_fid, "y");
-	 mpp_get_var_value(g_fid, vid, tmpy);      
-	 for(j = 0; j < nya[n]+1; j++) for(i = 0; i < nxa[n]+1; i++) {
-	       xatm[n][j*(nxa[n]+1)+i] = tmpx[(j*y_refine)*(nxa[n]*x_refine+1)+i*x_refine];
-	       yatm[n][j*(nxa[n]+1)+i] = tmpy[(j*y_refine)*(nxa[n]*x_refine+1)+i*x_refine];
-	    }
-	 free(tmpx);
-	 free(tmpy);      
-	 /*scale grid from degree to radian, because create_xgrid assume the grid is in radians */
-	 for(i=0; i<(nxa[n]+1)*(nya[n]+1); i++) {
-	    xatm[n][i] *= D2R;
-	    yatm[n][i] *= D2R;
-	 }
-	 get_grid_area(nxa+n, nya+n, xatm[n], yatm[n], area_atm[n]);
-	 mpp_close(g_fid);
-      }
-      mpp_close(m_fid);
-   }
-
-   /*
-    * Read land grid
-    */
-   if (strcmp(lmosaic, amosaic) ) { /* land mosaic is different from atmosphere mosaic */
-      int n, m_fid, g_fid, vid, gid, tid;
-      size_t start[4], nread[4];
-      char dir[STRING], filename[STRING], file[2*STRING];   
-
-      for(n=0; n<4; n++) {
-	 start[n] = 0;
-	 nread[n] = 1;
-      }
-      m_fid = mpp_open(lmosaic, MPP_READ);
-      vid = mpp_get_varid(m_fid, "mosaic");    
-      mpp_get_var_value(m_fid, vid, lmosaic_name);
-      ntile_lnd  = mpp_get_dimlen(m_fid, "ntiles");
-      nxl        = (int *) malloc (ntile_lnd*sizeof(int));
-      nyl        = (int *) malloc (ntile_lnd*sizeof(int));
-      xlnd       = (double **) malloc( ntile_lnd*sizeof(double *));
-      ylnd       = (double **) malloc( ntile_lnd*sizeof(double *));
-      area_lnd   = (double **) malloc( ntile_lnd*sizeof(double *));
-      ltile_name = (char **)malloc(ntile_lnd*sizeof(char *));
-      /* grid should be located in the same directory of mosaic file */
-      get_file_path(lmosaic, dir);
-      gid = mpp_get_varid(m_fid, "gridfiles");
-      tid = mpp_get_varid(m_fid, "gridtiles");    
-      for(n=0; n<ntile_lnd; n++) {
-	 double *tmpx, *tmpy;
-	 int i, j;
-      
-	 start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-	 mpp_get_var_value_block(m_fid, gid, start, nread, filename);
-	 ltile_name[n] = (char *)malloc(STRING*sizeof(char));
-	 mpp_get_var_value_block(m_fid, tid, start, nread,  ltile_name[n]);
-	 sprintf(file, "%s/%s", dir, filename);
-	 g_fid = mpp_open(file, MPP_READ);
-	 nxl[n] = mpp_get_dimlen(g_fid, "nx");
-	 nyl[n] = mpp_get_dimlen(g_fid, "ny");
-	 if(nxl[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: land supergrid x-size can not be divided by x_refine");
-	 if(nyl[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: land supergrid y-size can not be divided by y_refine");
-	 nxl[n]      /= x_refine;
-	 nyl[n]      /= y_refine;
-	 xlnd[n]     = (double *)malloc((nxl[n]+1)*(nyl[n]+1)*sizeof(double));
-	 ylnd[n]     = (double *)malloc((nxl[n]+1)*(nyl[n]+1)*sizeof(double));
-	 area_lnd[n] = (double *)malloc((nxl[n]  )*(nyl[n]  )*sizeof(double));
-	 tmpx        = (double *)malloc((nxl[n]*x_refine+1)*(nyl[n]*y_refine+1)*sizeof(double));
-	 tmpy        = (double *)malloc((nxl[n]*x_refine+1)*(nyl[n]*y_refine+1)*sizeof(double));
-	 vid = mpp_get_varid(g_fid, "x");
-	 mpp_get_var_value(g_fid, vid, tmpx);
-	 vid = mpp_get_varid(g_fid, "y");
-	 mpp_get_var_value(g_fid, vid, tmpy);     
-	 for(j = 0; j < nyl[n]+1; j++) for(i = 0; i < nxl[n]+1; i++) {
-	       xlnd[n][j*(nxl[n]+1)+i] = tmpx[(j*y_refine)*(nxl[n]*x_refine+1)+i*x_refine];
-	       ylnd[n][j*(nxl[n]+1)+i] = tmpy[(j*y_refine)*(nxl[n]*x_refine+1)+i*x_refine];
-	    }
-	 free(tmpx);
-	 free(tmpy);
-	 /*scale grid from degree to radian, because create_xgrid assume the grid is in radians */
-	 for(i=0; i<(nxl[n]+1)*(nyl[n]+1); i++) {
-	    xlnd[n][i] *= D2R;
-	    ylnd[n][i] *= D2R;
-	 }
-	 get_grid_area(nxl+n, nyl+n, xlnd[n], ylnd[n], area_lnd[n]);
-	 mpp_close(g_fid);
-      }
-      mpp_close(m_fid);
-   }
-   else { /* land mosaic is same as atmosphere mosaic */
-      ntile_lnd = ntile_atm;
-      nxl = nxa;
-      nyl = nya;
-      xlnd = xatm;
-      ylnd = yatm;
-      area_lnd = area_atm;
-      lnd_same_as_atm = 1;
-      strcpy(lmosaic_name, amosaic_name);
-      ltile_name = atile_name;
-   }
-
-   /*
-    * Read ocean grid boundaries and mask (where water is) for each tile within the mosaic.
-    */
-   {
-      int n, ntiles, m_fid, g_fid, t_fid, vid, gid, tid;
-      size_t start[4], nread[4];
-      char dir[STRING], filename[STRING], file[2*STRING];
-    
-      for(n=0; n<4; n++) {
-	 start[n] = 0;
-	 nread[n] = 1;
-      }
-      m_fid = mpp_open(omosaic, MPP_READ);
-      vid = mpp_get_varid(m_fid, "mosaic");    
-      mpp_get_var_value(m_fid, vid, omosaic_name);
-      ntile_ocn  = mpp_get_dimlen(m_fid, "ntiles");
-      nxo      = (int     *) malloc(ntile_ocn*sizeof(int));
-      nyo      = (int     *) malloc(ntile_ocn*sizeof(int));
-      xocn     = (double **) malloc(ntile_ocn*sizeof(double *));
-      yocn     = (double **) malloc(ntile_ocn*sizeof(double *));
-      area_ocn = (double **) malloc(ntile_ocn*sizeof(double *));
-      otile_name = (char **) malloc(ntile_ocn*sizeof(char *));
-      /* grid should be located in the same directory of mosaic file */
-      get_file_path(omosaic, dir);
-      gid = mpp_get_varid(m_fid, "gridfiles");
-      tid = mpp_get_varid(m_fid, "gridtiles");    
-
-      /* For the purpose of reproducing between processor count, the layout
-	 is set to (1, npes). */
-
-      for(n=0; n<ntile_ocn; n++) {
-	 double *tmpx, *tmpy;
-	 int i, j;
-	 double min_atm_lat, min_lat;
-      
-	 start[0] = n; start[1] = 0; nread[0] = 1; nread[1] = STRING;
-	 mpp_get_var_value_block(m_fid, gid, start, nread, filename);
-	 otile_name[n] = (char *)malloc(STRING*sizeof(char));
-	 mpp_get_var_value_block(m_fid, tid, start, nread,  otile_name[n]);
-	 sprintf(file, "%s/%s", dir, filename);
-	 g_fid = mpp_open(file, MPP_READ);
-	 nxo[n] = mpp_get_dimlen(g_fid, "nx");
-	 nyo[n] = mpp_get_dimlen(g_fid, "ny");
-	 if(nxo[n]%x_refine != 0 ) mpp_error("make_coupler_mosaic: ocean supergrid x-size can not be divided by x_refine");
-	 if(nyo[n]%y_refine != 0 ) mpp_error("make_coupler_mosaic: ocean supergrid y-size can not be divided by y_refine");
-	 tmpx        = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-	 tmpy        = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-	 vid = mpp_get_varid(g_fid, "x");
-	 mpp_get_var_value(g_fid, vid, tmpx);
-	 vid = mpp_get_varid(g_fid, "y");
-	 mpp_get_var_value(g_fid, vid, tmpy);     
-   
-	 /* sometimes the ocean is only covered part of atmosphere, especially not cover
-	    the south pole region. In order to get all the exchange grid between atmosXland,
-	    we need to extend one point to cover the whole atmosphere. This need the
-	    assumption of one-tile ocean. Also we assume the latitude is the along j=0
-	 */
-	 if(ntile_ocn == 1) {
-	    int na;
-	    for(i=1; i<=nxo[n]; i++) 
-	       if(tmpy[i] != tmpy[i-1]) mpp_error("make_coupler_mosaic: latitude is not uniform along j=0");
-	    /* calculate the minimum of latitude of atmosphere grid */
-	    min_atm_lat = 9999; /* dummy large value */
-	    for(na=0; na<ntile_atm; na++) {
-	       min_lat = minval_double((nxa[na]+1)*(nya[na]+1), yatm[na]);
-	       if(min_atm_lat > min_lat) min_atm_lat = min_lat;
-	    }
-	    if(tmpy[0]*D2R > min_atm_lat + TINY_VALUE) { /* extend one point in south direction*/
-	       ocn_south_ext = 1;
-	    }
-	 }      
-	 nxo[n] /= x_refine;
-	 nyo[n] /= y_refine;
-	 nyo[n] += ocn_south_ext;
-	 xocn[n]     = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-	 yocn[n]     = (double *)malloc((nxo[n]+1)*(nyo[n]+1)*sizeof(double));
-	 area_ocn[n] = (double *)malloc((nxo[n]  )*(nyo[n]  )*sizeof(double));
-
-	 for(j = 0; j < nyo[n]+1; j++) for(i = 0; i < nxo[n]+1; i++) {
-	       xocn[n][(j+ocn_south_ext)*(nxo[n]+1)+i] = tmpx[(j*y_refine)*(nxo[n]*x_refine+1)+i*x_refine] * D2R;
-	       yocn[n][(j+ocn_south_ext)*(nxo[n]+1)+i] = tmpy[(j*y_refine)*(nxo[n]*x_refine+1)+i*x_refine] * D2R;
-	    }
-	 if(ocn_south_ext==1) {
-	    for(i=0; i<nxo[n]+1; i++) {
-	       xocn[n][i] = xocn[n][nxo[n]+1+i];
-	       yocn[n][i] = min_atm_lat;
-	    }
-	 }
-	 free(tmpx);
-	 free(tmpy);
-	 get_grid_area(nxo+n, nyo+n, xocn[n], yocn[n], area_ocn[n]);
-	 mpp_close(g_fid);
-      }
-      mpp_close(m_fid);
-    
-      /* read ocean topography */
-      t_fid = mpp_open(otopog, MPP_READ);
-      ntiles = mpp_get_dimlen(t_fid, "ntiles");
-      if(ntile_ocn != ntiles) mpp_error("make_coupler_mosaic: dimlen ntiles in mosaic file is not the same as dimlen in topog file");
-      omask = (double **)malloc(ntile_ocn*sizeof(double *));
-      for(n=0; n<ntile_ocn; n++) {
-	 char name[128];
-	 int nx, ny, i, j;
-	 double *depth;
-
-	 if(ntiles == 1)
-	    strcpy(name, "nx");
-	 else
-	    sprintf(name, "nx_tile%d", n+1);
-	 nx = mpp_get_dimlen(t_fid, name);
-	 if(ntiles == 1)
-	    strcpy(name, "ny");
-	 else
-	    sprintf(name, "ny_tile%d", n+1);
-	 ny = mpp_get_dimlen(t_fid, name);
-	 if( nx != nxo[n] || ny+ocn_south_ext != nyo[n]) mpp_error("make_coupler_mosaic: grid size mismatch between mosaic file and topog file");
-	 if(ntiles == 1)
-	    strcpy(name, "depth");
-	 else
-	    sprintf(name, "depth_tile%d", n+1);
-	 depth    = (double *)malloc(nx*ny*sizeof(double));
-	 omask[n] = (double *)malloc(nxo[n]*nyo[n]*sizeof(double));
-	 vid = mpp_get_varid(t_fid, name);
-	 mpp_get_var_value(t_fid, vid, depth);
-	 for(i=0; i<nxo[n]*nyo[n]; i++) omask[n][i] = 0;
-	 for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
-	       if(depth[j*nx+i] >sea_level) omask[n][(j+ocn_south_ext)*nx+i] = 1;
-	    }
-	 free(depth);
-      }
-      mpp_close(t_fid);
-   }    
-
-  
-   /* Either omosaic is different from both lmosaic and amosaic,
-      or all the three mosaic are the same
-   */
-   if(strcmp(omosaic_name, amosaic_name)) { /* omosaic is different from amosaic */
-      if(!strcmp(omosaic_name, lmosaic_name)) mpp_error("make_coupler_mosaic: omosaic is the same as lmosaic, "
-      "but different from amosaic.");
-      same_mosaic = 0;
-   }
-   else { /* omosaic is same as amosaic */
-      if(strcmp(omosaic_name, lmosaic_name)) mpp_error("make_coupler_mosaic: omosaic is the same as amosaic, "
-      "but different from lmosaic.");
-      same_mosaic = 1;
-   }
-    
-    
-   /***************************************************************************************
-     First generate the exchange grid between atmos mosaic and land/ocean mosaic              
-   ***************************************************************************************/
-   nfile_axo = 0;
-   nfile_axl = 0;
-   nfile_lxo = 0;
-   {
-      int no, nl, na, n;
-      size_t  **naxl, **naxo;
-      int     ***atmxlnd_ia,   ***atmxlnd_ja,   ***atmxlnd_il,   ***atmxlnd_jl;
-      int     ***atmxocn_ia,   ***atmxocn_ja,   ***atmxocn_io,   ***atmxocn_jo;
-      double  ***atmxlnd_area, ***atmxlnd_dia,  ***atmxlnd_dja,  ***atmxlnd_dil,  ***atmxlnd_djl;
-      double  ***atmxocn_area, ***atmxocn_dia,  ***atmxocn_dja,  ***atmxocn_dio,  ***atmxocn_djo;
-      double  ***atmxocn_clon, ***atmxocn_clat, ***atmxlnd_clon, ***atmxlnd_clat;
-      double   min_area; 
-
-      naxl         = (size_t ** )malloc(ntile_atm*sizeof(size_t *));
-      naxo         = (size_t ** )malloc(ntile_atm*sizeof(size_t *));
-      atmxlnd_area = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxlnd_ia   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-      atmxlnd_ja   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-      atmxlnd_il   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-      atmxlnd_jl   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-      atmxocn_area = (double ***)malloc(ntile_atm*sizeof(double **));
-      atmxocn_ia   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-      atmxocn_ja   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-      atmxocn_io   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-      atmxocn_jo   = (int    ***)malloc(ntile_atm*sizeof(int    **));
-
-      if(interp_order == 2 ) {
-	 atmxlnd_dia  = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxlnd_dja  = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxlnd_dil  = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxlnd_djl  = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxocn_dia  = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxocn_dja  = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxocn_dio  = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxocn_djo  = (double ***)malloc(ntile_atm*sizeof(double **));      
-	 atmxlnd_clon = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxlnd_clat = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxocn_clon = (double ***)malloc(ntile_atm*sizeof(double **));
-	 atmxocn_clat = (double ***)malloc(ntile_atm*sizeof(double **));      
-      }
-    
-      for(na=0; na<ntile_atm; na++) {
-	 naxl[na]         = (size_t * )malloc(ntile_lnd*sizeof(size_t));
-	 naxo[na]         = (size_t * )malloc(ntile_ocn*sizeof(size_t));
-	 atmxlnd_area[na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	 atmxlnd_ia[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-	 atmxlnd_ja[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-	 atmxlnd_il[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-	 atmxlnd_jl[na]   = (int    **)malloc(ntile_lnd*sizeof(int    *));
-	 atmxocn_area[na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	 atmxocn_ia[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-	 atmxocn_ja[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-	 atmxocn_io[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-	 atmxocn_jo[na]   = (int    **)malloc(ntile_ocn*sizeof(int    *));
-    
-	 if(interp_order == 2 ) {
-	    atmxlnd_dia [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	    atmxlnd_dja [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	    atmxlnd_dil [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	    atmxlnd_djl [na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	    atmxocn_dia [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    atmxocn_dja [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    atmxocn_dio [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    atmxocn_djo [na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    atmxlnd_clon[na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	    atmxlnd_clat[na] = (double **)malloc(ntile_lnd*sizeof(double *));
-	    atmxocn_clon[na] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    atmxocn_clat[na] = (double **)malloc(ntile_ocn*sizeof(double *));      
-	 }
-
-	 for(nl=0; nl<ntile_lnd; nl++) {
-	    atmxlnd_area[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	    atmxlnd_ia  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    atmxlnd_ja  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    atmxlnd_il  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    atmxlnd_jl  [na][nl] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    if(interp_order == 2 ) {
-	       atmxlnd_clon[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxlnd_clat[na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxlnd_dia [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxlnd_dja [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxlnd_dil [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxlnd_djl [na][nl] = (double *)malloc(MAXXGRID*sizeof(double));
-	    }
-	 }
- 
-	 for(no=0; no<ntile_ocn; no++) {
-	    atmxocn_area[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	    atmxocn_ia  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    atmxocn_ja  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    atmxocn_io  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    atmxocn_jo  [na][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));          
-	    if(interp_order == 2 ) {
-	       atmxocn_clon[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxocn_clat[na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxocn_dia [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxocn_dja [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxocn_dio [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	       atmxocn_djo [na][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	    }
-	 }
-      }
-      
-      for(na=0; na<ntile_atm; na++) {
-      
-	 int      l, is, ie, js, je, la, ia, ja, il, jl, io, jo, layout[2];
-	 int      n0, n1, n2, n3, na_in, nl_in, no_in, n_out, n_out2;
-	 double   xa_min, ya_min, xo_min, yo_min, xl_min, yl_min, xa_avg;
-	 double   xa_max, ya_max, xo_max, yo_max, xl_max, yl_max;
-	 double   xarea;
-	 double   xa[MV], ya[MV], xl[MV], yl[MV], xo[MV], yo[MV];
-	 double   x_out[MV], y_out[MV];
-	 double   atmxlnd_x[MX][MV], atmxlnd_y[MX][MV];
-	 int      num_v[MX];
-	 int      axl_i[MX], axl_j[MX], axl_t[MX];
-	 double   axl_xmin[MX], axl_xmax[MX], axl_ymin[MX], axl_ymax[MX];
-	 double   axl_area[MX], axl_clon[MX], axl_clat[MX];
-	 size_t   count;
-	 domain2D Dom;
-      
-	 for(nl=0; nl<ntile_lnd; nl++) naxl[na][nl] = 0;
-	 for(no=0; no<ntile_ocn; no++) naxo[na][no] = 0;
-	 layout[0] = mpp_npes();
-	 layout[1] = 1;
-        
-	 mpp_define_domain2d(nxa[na]*nya[na], 1, layout, 0, 0, &Dom);
-	 mpp_get_compute_domain2d(Dom, &is, &ie, &js, &je );
-	 for(la=is;la<=ie;la++) {
-	
-	    ia = la%nxa[na];
-	    ja = la/nxa[na];
-	    n0 = ja    *(nxa[na]+1) + ia;
-	    n1 = ja    *(nxa[na]+1) + ia+1;
-	    n2 = (ja+1)*(nxa[na]+1) + ia+1;
-	    n3 = (ja+1)*(nxa[na]+1) + ia;
-	    xa[0] = xatm[na][n0]; ya[0] = yatm[na][n0];
-	    xa[1] = xatm[na][n1]; ya[1] = yatm[na][n1];
-	    xa[2] = xatm[na][n2]; ya[2] = yatm[na][n2];
-	    xa[3] = xatm[na][n3]; ya[3] = yatm[na][n3];
-	    ya_min  = minval_double(4, ya);
-	    ya_max  = maxval_double(4, ya);
-	    na_in   = fix_lon(xa, ya, 4, M_PI);
-	    xa_min  = minval_double(na_in, xa);
-	    xa_max  = maxval_double(na_in, xa);
-	    xa_avg  = avgval_double(na_in, xa);
-	    count = 0;
-	    for(nl=0; nl<ntile_lnd; nl++) {
-	       for(jl = 0; jl < nyl[nl]; jl ++) for(il = 0; il < nxl[nl]; il++) {
-		     n0 = jl    *(nxl[nl]+1) + il;
-		     n1 = jl    *(nxl[nl]+1) + il+1;
-		     n2 = (jl+1)*(nxl[nl]+1) + il+1;
-		     n3 = (jl+1)*(nxl[nl]+1) + il;
-		     xl[0] = xlnd[nl][n0]; yl[0] = ylnd[nl][n0];
-		     xl[1] = xlnd[nl][n1]; yl[1] = ylnd[nl][n1];
-		     xl[2] = xlnd[nl][n2]; yl[2] = ylnd[nl][n2];
-		     xl[3] = xlnd[nl][n3]; yl[3] = ylnd[nl][n3];
-		     yl_min = minval_double(4, yl);
-		     yl_max = maxval_double(4, yl);
-		     if(yl_min >= ya_max || yl_max <= ya_min ) continue;	    
-		     nl_in  = fix_lon(xl, yl, 4, xa_avg);
-		     xl_min = minval_double(nl_in, xl);
-		     xl_max = maxval_double(nl_in, xl);
-		     /* xl should in the same range as xa after lon_fix, so no need to
-			consider cyclic condition
-		     */
-	      	    
-		     if(xa_min >= xl_max || xa_max <= xl_min ) continue;	
-		     if (  (n_out = clip_2dx2d( xa, ya, na_in, xl, yl, nl_in, x_out, y_out )) > 0 ) {
-			xarea = poly_area(x_out, y_out, n_out);
-			min_area = min(area_lnd[nl][jl*nxl[nl]+il], area_atm[na][la]);
-			if( xarea/min_area > AREA_RATIO_THRESH ) {
-			   /*  remember the exchange grid vertices */
-			   for(n=0; n<n_out; n++) {
-			      atmxlnd_x[count][n] = x_out[n];
-			      atmxlnd_y[count][n] = y_out[n];
-			   }
-			   axl_i[count]    = il;
-			   axl_j[count]    = jl;
-			   axl_t[count]    = nl;
-			   num_v[count]    = n_out;
-			   axl_xmin[count] = minval_double(n_out, x_out);
-			   axl_xmax[count] = maxval_double(n_out, x_out);
-			   axl_ymin[count] = minval_double(n_out, y_out);
-			   axl_ymax[count] = maxval_double(n_out, y_out);
-			   axl_area[count] = 0;
-			   if(interp_order == 2) {
-			      axl_clon[count] = 0;
-			      axl_clat[count] = 0;
-			   }
-			   ++count;
-			   if(count>MX) mpp_error("make_coupler_mosaic: count is greater than MX, increase MX");
-			}
-		     }
-		  }
-	    }
-
-	    /* calculate atmos/ocean x-cells */
-	    for(no=0; no<ntile_ocn; no++) {
-	       for(jo = 0; jo < nyo[no]; jo++) for(io = 0; io < nxo[no]; io++) {	
-		     n0 = jo    *(nxo[no]+1) + io;
-		     n1 = jo    *(nxo[no]+1) + io+1;
-		     n2 = (jo+1)*(nxo[no]+1) + io+1;
-		     n3 = (jo+1)*(nxo[no]+1) + io;
-		     xo[0] = xocn[no][n0]; yo[0] = yocn[no][n0];
-		     xo[1] = xocn[no][n1]; yo[1] = yocn[no][n1];
-		     xo[2] = xocn[no][n2]; yo[2] = yocn[no][n2];
-		     xo[3] = xocn[no][n3]; yo[3] = yocn[no][n3];
-		     yo_min = minval_double(4, yo);
-		     yo_max = maxval_double(4, yo);
-		     no_in  = fix_lon(xo, yo, 4, xa_avg);
-		     xo_min = minval_double(no_in, xo);
-		     xo_max = maxval_double(no_in, xo);
-		     if(omask[no][jo*nxo[no]+io] > 0.5) { /* over sea/ice */
-			/* xo should in the same range as xa after lon_fix, so no need to
-			   consider cyclic condition
-			*/
-			if(xa_min >= xo_max || xa_max <= xo_min || yo_min >= ya_max || yo_max <= ya_min ) continue;	    
-
-			if (  (n_out = clip_2dx2d( xa, ya, na_in, xo, yo, no_in, x_out, y_out )) > 0) {
-			   xarea = poly_area(x_out, y_out, n_out );
-			   min_area = min(area_ocn[no][jo*nxo[no]+io], area_atm[na][la]);
-			   if(xarea/min_area > AREA_RATIO_THRESH) {
-	    
-			      atmxocn_area[na][no][naxo[na][no]] = xarea;
-			      atmxocn_io[na][no][naxo[na][no]]   = io;
-			      atmxocn_jo[na][no][naxo[na][no]]   = jo;
-			      atmxocn_ia[na][no][naxo[na][no]]   = ia;
-			      atmxocn_ja[na][no][naxo[na][no]]   = ja;
-			      if(interp_order == 2) {
-				 atmxocn_clon[na][no][naxo[na][no]] = poly_ctrlon ( x_out, y_out, n_out, xa_avg);
-				 atmxocn_clat[na][no][naxo[na][no]] = poly_ctrlat ( x_out, y_out, n_out );		
-			      }
-			      ++(naxo[na][no]);
-			      if(naxo[na][no] > MAXXGRID) mpp_error("naxo is greater than MAXXGRID, increase MAXXGRID");
-			   }
-			}
-		     }
-		     else { /* over land */
-			/* find the overlap of atmxlnd and ocean cell */
-			for(l=0; l<count; l++) {
-			   if(axl_xmin[l] >= xo_max || axl_xmax[l] <= xo_min || axl_ymin[l] >= ya_max || axl_ymax[l] <= ya_min ) continue;	  
-			   if((n_out = clip_2dx2d( atmxlnd_x[l], atmxlnd_y[l], num_v[l], xo, yo, no_in, x_out, y_out )) > 0) {
-			      xarea = poly_area(x_out, y_out, n_out );
-			      min_area = min(area_lnd[axl_t[l]][axl_j[l]*nxl[axl_t[l]]+axl_i[l]], area_atm[na][la]);
-			      if(xarea/min_area > AREA_RATIO_THRESH) {
-				 axl_area[l] += xarea;
-				 if(interp_order == 2) {
-				    axl_clon[l] += poly_ctrlon ( x_out, y_out, n_out, xa_avg);
-				    axl_clat[l] += poly_ctrlat ( x_out, y_out, n_out);
-				 }
-			      }
-			   }
-			}
-		     }
-		  }
-	    }
-	    /* get the exchange grid between land and atmos. */
-	    for(l=0; l<count; l++) {
-	       nl = axl_t[l];
-	       min_area = min(area_lnd[nl][axl_j[l]*nxl[nl]+axl_i[l]], area_atm[na][la]);
-	       if(axl_area[l]/min_area > AREA_RATIO_THRESH) {
-		  atmxlnd_area[na][nl][naxl[na][nl]] = axl_area[l];
-		  atmxlnd_ia  [na][nl][naxl[na][nl]] = ia;
-		  atmxlnd_ja  [na][nl][naxl[na][nl]] = ja;
-		  atmxlnd_il  [na][nl][naxl[na][nl]] = axl_i[l];
-		  atmxlnd_jl  [na][nl][naxl[na][nl]] = axl_j[l];
-		  if(interp_order == 2) {
-		     atmxlnd_clon[na][nl][naxl[na][nl]] = axl_clon[l];
-		     atmxlnd_clat[na][nl][naxl[na][nl]] = axl_clat[l];
-		  }
-		  ++(naxl[na][nl]);
-		  if(naxl[na][nl] > MAXXGRID) mpp_error("naxl is greater than MAXXGRID, increase MAXXGRID");
-	       }
-	    }   
-	 }/* end of la loop */
-
-	 mpp_delete_domain2d(&Dom);
-      } /* end of na loop */
-
-      /* calculate the centroid of model grid, as well as land_mask and ocean_mask */
-      {
-	 double **l_area, **o_area;
-	 int    nl, no, ll, lo;
-	 l_area = (double **)malloc(ntile_lnd*sizeof(double *));
-	 o_area = (double **)malloc(ntile_ocn*sizeof(double *));
-	 for(nl =0; nl<ntile_lnd; nl++) {
-	    l_area[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	    for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	       l_area[nl][ll] = 0;
-	    }
-	 }
-	 for(no =0; no<ntile_ocn; no++) {
-	    o_area[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	    for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	       o_area[no][lo] = 0;
-	    }
-	 }
-            
-	 if(interp_order == 1) {
-	    for(na=0; na<ntile_atm; na++) {
-	       for(nl=0; nl<ntile_lnd; nl++) {
-		  int nxgrid;
-	  
-		  nxgrid = naxl[na][nl];
-		  mpp_sum_int(1, &nxgrid);
-		  if(nxgrid > 0) {
-		     double *g_area;
-		     int    *g_il, *g_jl;
-		     int    ii;
-		     g_il = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_jl = (int    *)malloc(nxgrid*sizeof(int   ));	
-		     g_area = (double *)malloc(nxgrid*sizeof(double));
-		     mpp_gather_field_int   (naxl[na][nl], atmxlnd_il[na][nl], g_il);
-		     mpp_gather_field_int   (naxl[na][nl], atmxlnd_jl[na][nl], g_jl);
-		     mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], g_area);
-		     for(i=0; i<nxgrid; i++) {
-			ii = g_jl[i]*nxl[nl]+g_il[i];
-			l_area[nl][ii] += g_area[i];
-		     }
-		     free(g_il);
-		     free(g_jl);
-		     free(g_area);
-		  }
-	       }
-
-	       for(no=0; no<ntile_ocn; no++) {
-		  int nxgrid;
-		  nxgrid = naxo[na][no];
-		  mpp_sum_int(1, &nxgrid);
-		  if(nxgrid > 0) {
-		     double *g_area;
-		     int    *g_io, *g_jo;
-		     int    ii;
-		     g_io = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
-		     g_area = (double *)malloc(nxgrid*sizeof(double));
-		     mpp_gather_field_int   (naxo[na][no], atmxocn_io[na][no], g_io);
-		     mpp_gather_field_int   (naxo[na][no], atmxocn_jo[na][no], g_jo);
-		     mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], g_area);
-		     for(i=0; i<nxgrid; i++) {	      
-			ii = g_jo[i]*nxo[no]+g_io[i];
-			o_area[no][ii] += g_area[i];
-		     }
-		     free(g_io);
-		     free(g_jo);
-		     free(g_area);
-		  }
-	       }
-	    }
-	 }
-	 else { /* interp_order == 2 */
-	    double **l_clon, **l_clat;
-	    double **o_clon, **o_clat;
-	    double  *a_area,  *a_clon,  *a_clat;
-	    int la;
-      
-	    l_clon = (double **)malloc(ntile_lnd*sizeof(double *));
-	    l_clat = (double **)malloc(ntile_lnd*sizeof(double *));
-	    for(nl =0; nl<ntile_lnd; nl++) {
-	       l_clon[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	       l_clat[nl] = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	       for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-		  l_clon[nl][ll] = 0;
-		  l_clat[nl][ll] = 0;
-	       }
-	    }
-	    o_clon = (double **)malloc(ntile_ocn*sizeof(double *));
-	    o_clat = (double **)malloc(ntile_ocn*sizeof(double *));
-	    for(no =0; no<ntile_ocn; no++) {
-	       o_clon[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	       o_clat[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	       for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-		  o_clon[no][lo] = 0;
-		  o_clat[no][lo] = 0;
-	       }
-	    }	
-	    for(na=0; na<ntile_atm; na++) {
-	       //	double *area, *clon, *clat;
-      
-	       a_area = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
-	       a_clon = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
-	       a_clat = (double *)malloc(nxa[na]*nya[na]*sizeof(double));
-	       for(la=0; la<nxa[na]*nya[na]; la++) {
-		  a_area[la] = 0;
-		  a_clon[la] = 0;
-		  a_clat[la] = 0;
-	       }
-
-	       for(nl=0; nl<ntile_lnd; nl++) {
-		  int nxgrid;
-	  
-		  nxgrid = naxl[na][nl];
-		  mpp_sum_int(1, &nxgrid);
-		  if(nxgrid > 0) {
-		     double *g_area, *g_clon, *g_clat;
-		     int    *g_ia,   *g_ja,   *g_il, *g_jl;
-		     int    ii;
-		     g_ia = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_ja = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_il = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_jl = (int    *)malloc(nxgrid*sizeof(int   ));	
-		     g_area = (double *)malloc(nxgrid*sizeof(double));
-		     g_clon = (double *)malloc(nxgrid*sizeof(double));
-		     g_clat = (double *)malloc(nxgrid*sizeof(double));
-		     mpp_gather_field_int   (naxl[na][nl], atmxlnd_ia[na][nl], g_ia);
-		     mpp_gather_field_int   (naxl[na][nl], atmxlnd_ja[na][nl], g_ja);
-		     mpp_gather_field_int   (naxl[na][nl], atmxlnd_il[na][nl], g_il);
-		     mpp_gather_field_int   (naxl[na][nl], atmxlnd_jl[na][nl], g_jl);
-		     mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], g_area);
-		     mpp_gather_field_double(naxl[na][nl], atmxlnd_clon[na][nl], g_clon);
-		     mpp_gather_field_double(naxl[na][nl], atmxlnd_clat[na][nl], g_clat);
-		     for(i=0; i<nxgrid; i++) {
-			ii = g_ja[i]*nxa[na]+g_ia[i];
-			a_area[ii] += g_area[i];
-			a_clon[ii] += g_clon[i];
-			a_clat[ii] += g_clat[i];
-			ii = g_jl[i]*nxl[nl]+g_il[i];
-			l_area[nl][ii] += g_area[i];
-			l_clon[nl][ii] += g_clon[i];
-			l_clat[nl][ii] += g_clat[i];
-		     }
-		     free(g_ia);
-		     free(g_ja);
-		     free(g_il);
-		     free(g_jl);
-		     free(g_area);
-		     free(g_clon);
-		     free(g_clat);
-		  }
-	       }
-
-	       for(no=0; no<ntile_ocn; no++) {
-		  int nxgrid;
-		  nxgrid = naxo[na][no];
-		  mpp_sum_int(1, &nxgrid);
-		  if(nxgrid > 0) {
-		     double *g_area, *g_clon, *g_clat;
-		     int    *g_ia,   *g_ja,   *g_io, *g_jo;
-		     int    ii;
-		     g_ia = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_ja = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_io = (int    *)malloc(nxgrid*sizeof(int   ));
-		     g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
-		     g_area = (double *)malloc(nxgrid*sizeof(double));
-		     g_clon = (double *)malloc(nxgrid*sizeof(double));
-		     g_clat = (double *)malloc(nxgrid*sizeof(double));
-		     mpp_gather_field_int   (naxo[na][no], atmxocn_ia[na][no], g_ia);
-		     mpp_gather_field_int   (naxo[na][no], atmxocn_ja[na][no], g_ja);
-		     mpp_gather_field_int   (naxo[na][no], atmxocn_io[na][no], g_io);
-		     mpp_gather_field_int   (naxo[na][no], atmxocn_jo[na][no], g_jo);
-		     mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], g_area);
-		     mpp_gather_field_double(naxo[na][no], atmxocn_clon[na][no], g_clon);
-		     mpp_gather_field_double(naxo[na][no], atmxocn_clat[na][no], g_clat);
-		     for(i=0; i<nxgrid; i++) {	      
-			ii = g_ja[i]*nxa[na]+g_ia[i];
-			a_area[ii] += g_area[i];
-			a_clon[ii] += g_clon[i];
-			a_clat[ii] += g_clat[i];
-			ii = g_jo[i]*nxo[no]+g_io[i];
-			o_area[no][ii] += g_area[i];
-			o_clon[no][ii] += g_clon[i];
-			o_clat[no][ii] += g_clat[i];
-		     }
-		     free(g_ia);
-		     free(g_ja);
-		     free(g_io);
-		     free(g_jo);
-		     free(g_area);
-		     free(g_clon);
-		     free(g_clat);
-		  }
-	       }
-
-	       for(la=0; la<nxa[na]*nya[na]; la++) {
-		  if(a_area[la] > 0) {
-		     a_clon[la] /= a_area[la];
-		     a_clat[la] /= a_area[la];
-		  }
-	       }
-	
-	       /* substract atmos centroid to get the centroid distance between atmos grid and exchange grid. */
-	       for(nl=0; nl<ntile_lnd; nl++) {
-		  for(i=0; i<naxl[na][nl]; i++) {
-		     la = atmxlnd_ja[na][nl][i]*nxa[na] + atmxlnd_ia[na][nl][i];
-		     atmxlnd_dia[na][nl][i] = atmxlnd_clon[na][nl][i]/atmxlnd_area[na][nl][i] - a_clon[la];
-		     atmxlnd_dja[na][nl][i] = atmxlnd_clat[na][nl][i]/atmxlnd_area[na][nl][i] - a_clat[la];
-		  }
-	       }
-	       for(no=0; no<ntile_ocn; no++) {
-		  for(i=0; i<naxo[na][no]; i++) {
-		     la = atmxocn_ja[na][no][i]*nxa[na] + atmxocn_ia[na][no][i];
-		     atmxocn_dia[na][no][i] = atmxocn_clon[na][no][i]/atmxocn_area[na][no][i] - a_clon[la];
-		     atmxocn_dja[na][no][i] = atmxocn_clat[na][no][i]/atmxocn_area[na][no][i] - a_clat[la];
-		  }
-	       }
-	
-	       free(a_area);
-	       free(a_clon);
-	       free(a_clat);
-	    }
-
-      
-	    /* centroid distance from exchange grid to land grid */
-	    for(nl=0; nl<ntile_lnd; nl++) {
-	       for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-		  if(l_area[nl][ll] > 0) {
-		     l_clon[nl][ll] /= l_area[nl][ll];
-		     l_clat[nl][ll] /= l_area[nl][ll];
-		  }
-	       }
-	       for(na=0; na<ntile_atm; na++) {
-		  for(i=0; i<naxl[na][nl]; i++) {
-		     ll = atmxlnd_jl[na][nl][i]*nxl[nl] + atmxlnd_il[na][nl][i];
-		     atmxlnd_dil[na][nl][i] = atmxlnd_clon[na][nl][i]/atmxlnd_area[na][nl][i] - l_clon[nl][ll];
-		     atmxlnd_djl[na][nl][i] = atmxlnd_clat[na][nl][i]/atmxlnd_area[na][nl][i] - l_clat[nl][ll];
-		  }
-	       }
-	       free(l_clon[nl]);
-	       free(l_clat[nl]);
-	    }
-
-	    /* centroid distance from exchange grid to ocean grid */
-	    for(no=0; no<ntile_ocn; no++) {
-	       for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-		  if(o_area[no][lo] > 0) {
-		     o_clon[no][lo] /= o_area[no][lo];
-		     o_clat[no][lo] /= o_area[no][lo];
-		  }
-	       }
-	       for(na=0; na<ntile_atm; na++) {
-		  for(i=0; i<naxo[na][no]; i++) {
-		     lo = atmxocn_jo[na][no][i]*nxo[no] + atmxocn_io[na][no][i];
-		     atmxocn_dio[na][no][i] = atmxocn_clon[na][no][i]/atmxocn_area[na][no][i] - o_clon[no][lo];
-		     atmxocn_djo[na][no][i] = atmxocn_clat[na][no][i]/atmxocn_area[na][no][i] - o_clat[no][lo];
-		  }
-	       }
-	       free(o_clon[no]);
-	       free(o_clat[no]);
-	    }
-	    free(o_clon);
-	    free(o_clat);
-	    free(l_clon);
-	    free(l_clat);  
-	 }
-
-	 /* calculate ocean_frac and compare ocean_frac with omask */
-	 /* also write out ocn_frac */
-	 {
-	    int    io, jo;
-	    double ocn_frac;
-	    int    id_mask, fid, dims[2];
-	    char ocn_mask_file[STRING];
-	    double *mask;
-	    int ny;
-
-
-	    for(no=0; no<ntile_ocn; no++) {
-	       ny = nyo[no]-ocn_south_ext;
-	       mask = (double *)malloc(nxo[no]*ny*sizeof(double));
-	       for(jo=0; jo<ny; jo++) for(io=0; io<nxo[no]; io++) {
-		     i = (jo+ocn_south_ext)*nxo[no]+io;
-		     ocn_frac = o_area[no][i]/area_ocn[no][i];
-		     if( fabs(omask[no][i] - ocn_frac) > TOLORENCE ) {
-			printf("at ocean point (%d,%d), omask = %f, ocn_frac = %f, diff = %f\n",
-			io, jo, omask[no][i], ocn_frac, omask[no][i] - ocn_frac);
-			mpp_error("make_coupler_mosaic: omask is not equal ocn_frac");
-		     }
-		     mask[jo*nxo[no]+io] = ocn_frac;
-		  }
-	       if(ntile_ocn > 1)
-		  sprintf(ocn_mask_file, "ocean_mask_tile%d.nc", no+1);
-	       else
-		  strcpy(ocn_mask_file, "ocean_mask.nc");
-	       fid = mpp_open(ocn_mask_file, MPP_WRITE);
-	       mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-	       mpp_def_global_att(fid, "code_version", TAGNAME);
-	       mpp_def_global_att(fid, "history", history);
-          	  
-
-	       dims[1] = mpp_def_dim(fid, "nx", nxo[no]); 
-	       dims[0] = mpp_def_dim(fid, "ny", ny);
-	       id_mask = mpp_def_var(fid, "mask", MPP_DOUBLE, 2, dims,  2, "standard_name",
-	       "ocean fraction at T-cell centers", "units", "none");
-	       mpp_end_def(fid);
-	       mpp_put_var_value(fid, id_mask, mask);
-	       mpp_close(fid);
-	       free(mask);
-	    }
-	 }
-
-	 /* calculate land_frac and  write out land_frac */
-	 {
-	    int    il, jl;
-	    int    id_mask, fid, dims[2];
-	    char lnd_mask_file[STRING];
-	    double *mask;
-	
-	    for(nl=0; nl<ntile_lnd; nl++) {
-	       mask = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	       for(jl=0; jl<nyl[nl]; jl++) for(il=0; il<nxl[nl]; il++) {
-		     i = jl*nxl[nl]+il;
-		     mask[i] = l_area[nl][i]/area_lnd[nl][i];
-		  }
-	       if(ntile_lnd > 1)
-		  sprintf(lnd_mask_file, "land_mask_tile%d.nc", nl+1);
-	       else
-		  strcpy(lnd_mask_file, "land_mask.nc");
-	       fid = mpp_open(lnd_mask_file, MPP_WRITE);
-	       mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-	       mpp_def_global_att(fid, "code_version", TAGNAME);
-	       mpp_def_global_att(fid, "history", history);
-	       dims[1] = mpp_def_dim(fid, "nx", nxl[nl]); 
-	       dims[0] = mpp_def_dim(fid, "ny", nyl[nl]);
-	       id_mask = mpp_def_var(fid, "mask", MPP_DOUBLE, 2, dims,  2, "standard_name",
-	       "land fraction at T-cell centers", "units", "none");
-	       mpp_end_def(fid);
-	       mpp_put_var_value(fid, id_mask, mask);
-	       free(mask);
-	       mpp_close(fid);
-	    }
-	 }        
-      
-	 for(nl=0; nl<ntile_lnd; nl++) free(l_area[nl]);
-	 for(no=0; no<ntile_ocn; no++) free(o_area[no]);      
-	 free(o_area);
-	 free(l_area);
-      }
-    
-  
-      for(na=0; na<ntile_atm; na++) {
-	 /* write out atmXlnd data*/
-	 for(nl = 0; nl < ntile_lnd; nl++) {
-	    int nxgrid;
-	    nxgrid = naxl[na][nl];
-	    mpp_sum_int(1, &nxgrid);
-	    if(nxgrid>0) {
-	       size_t start[4], nwrite[4];
-	       int *gdata_int;
-	       double *gdata_dbl;
-	  
-	       int fid, dim_string, dim_ncells, dim_two, dims[4];
-	       int id_xgrid_area, id_contact, n;
-	       int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-	       char contact[STRING];
-
-	       for(i=0; i<4; i++) {
-		  start[i] = 0; nwrite[i] = 1;
-	       }	  	  
-	       if(same_mosaic)
-		  sprintf(axl_file[nfile_axl], "atm_%s_%sXlnd_%s_%s.nc", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
-	       else
-		  sprintf(axl_file[nfile_axl], "%s_%sX%s_%s.nc", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
-	       sprintf(contact, "%s:%s::%s:%s", amosaic_name, atile_name[na], lmosaic_name, ltile_name[nl]);
-	       fid = mpp_open(axl_file[nfile_axl], MPP_WRITE);
-	       mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-	       mpp_def_global_att(fid, "code_version", TAGNAME);
-	       mpp_def_global_att(fid, "history", history);
-	       dim_string = mpp_def_dim(fid, "string", STRING);
-	       dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
-	       dim_two    = mpp_def_dim(fid, "two", 2);
-	       if(interp_order == 2) {
-		  id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
-		  "contact_type", "exchange", "parent1_cell",
-		  "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
-		  "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	       }
-	       else {
-		  id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
-		  "contact_type", "exchange", "parent1_cell",
-		  "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-	       }
-	    
-	       dims[0] = dim_ncells; dims[1] = dim_two;
-	       id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-	       id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-	       id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-	       "exchange_grid_area", "units", "m2");
-	       if(interp_order == 2) {
-		  id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-		  id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-	       }
-	       mpp_end_def(fid);
-
-	       /* the index will start from 1, instead of 0 ( fortran index) */
-	       for(i = 0;i < naxl[na][nl]; i++) {
-		  ++(atmxlnd_ia[na][nl][i]);
-		  ++(atmxlnd_ja[na][nl][i]);
-		  ++(atmxlnd_il[na][nl][i]);
-		  ++(atmxlnd_jl[na][nl][i]);
-	       }
-	       nwrite[0] = strlen(contact);
-	       mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	       nwrite[0] = nxgrid;
-
-	       gdata_int = (int *)malloc(nxgrid*sizeof(int));
-	       gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
-
-	       mpp_gather_field_double(naxl[na][nl], atmxlnd_area[na][nl], gdata_dbl);
-	       if(check) {
-		  for(n=0; n<nxgrid; n++) axl_area_sum += gdata_dbl[n];
-	       }
-	       mpp_put_var_value(fid, id_xgrid_area, gdata_dbl);
-	       mpp_gather_field_int(naxl[na][nl], atmxlnd_ia[na][nl], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	       mpp_gather_field_int(naxl[na][nl], atmxlnd_il[na][nl], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	       start[1] = 1;
-	       mpp_gather_field_int(naxl[na][nl], atmxlnd_ja[na][nl], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	       mpp_gather_field_int(naxl[na][nl], atmxlnd_jl[na][nl], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	       if(interp_order == 2) {
-		  start[1] = 0;
-		  mpp_gather_field_double(naxl[na][nl], atmxlnd_dia[na][nl], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-		  mpp_gather_field_double(naxl[na][nl], atmxlnd_dil[na][nl], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-		  start[1] = 1;
-		  mpp_gather_field_double(naxl[na][nl], atmxlnd_dja[na][nl], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-		  mpp_gather_field_double(naxl[na][nl], atmxlnd_djl[na][nl], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	       }
-	       mpp_close(fid);
-	       free(gdata_int);
-	       free(gdata_dbl);
-	       ++nfile_axl;
-	    }
-	 } /* end of nl loop */
-
-	 /* write out atmXocn data */
-	 for(no = 0; no < ntile_ocn; no++) {
-	    int nxgrid;
-	
-	    nxgrid = naxo[na][no];
-	    mpp_sum_int(1, &nxgrid);
-	    if(nxgrid>0) {
-	       size_t start[4], nwrite[4];
-	       int *gdata_int;
-	       double *gdata_dbl;
-	       int fid, dim_string, dim_ncells, dim_two, dims[4];
-	       int id_xgrid_area, id_contact, n;
-	       int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;	  
-	       char contact[STRING];
-
-	       for(i=0; i<4; i++) {
-		  start[i] = 0; nwrite[i] = 1;
-	       }
-	  
-	       if(same_mosaic)
-		  sprintf(axo_file[nfile_axo], "atm_%s_%sXocn_%s_%s.nc", amosaic_name, atile_name[na], omosaic_name, otile_name[no]);
-	       else
-		  sprintf(axo_file[nfile_axo], "%s_%sX%s_%s.nc", amosaic_name, atile_name[na], omosaic_name, otile_name[no]);
-	  
-	       sprintf(contact, "%s:%s::%s:%s", amosaic_name, atile_name[na], omosaic_name, otile_name[no]);
-	       fid = mpp_open(axo_file[nfile_axo], MPP_WRITE);
-	       mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-	       mpp_def_global_att(fid, "code_version", TAGNAME);
-	       mpp_def_global_att(fid, "history", history);
-	       dim_string = mpp_def_dim(fid, "string", STRING);
-	       dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
-	       dim_two    = mpp_def_dim(fid, "two", 2);
-	       if(interp_order == 2) {
-		  id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
-		  "contact_type", "exchange", "parent1_cell",
-		  "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
-		  "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	       }
-	       else {
-		  id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
-		  "contact_type", "exchange", "parent1_cell",
-		  "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area" );
-	       }
-	       dims[0] = dim_ncells; dims[1] = dim_two;
-	       id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-	       id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-	       id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-	       "exchange_grid_area", "units", "m2");
-	       if(interp_order == 2) {
-		  id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name",
-		  "distance_from_parent1_cell_centroid");
-		  id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name",
-		  "distance_from_parent2_cell_centroid");
-	       }
-	       mpp_end_def(fid);
-
-	       /* the index will start from 1, instead of 0 ( fortran index) */
-	       for(i = 0;i < naxo[na][no]; i++) {
-		  ++(atmxocn_ia[na][no][i]);
-		  ++(atmxocn_ja[na][no][i]);
-		  ++(atmxocn_io[na][no][i]);
-		  atmxocn_jo[na][no][i] += 1-ocn_south_ext; /* possible one artificial j-level is added at south end */
-	       }
-
-	       nwrite[0] = strlen(contact);
-	       mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	
-	       nwrite[0] = nxgrid;
-
-	       gdata_int = (int *)malloc(nxgrid*sizeof(int));
-	       gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
-
-	       mpp_gather_field_double(naxo[na][no], atmxocn_area[na][no], gdata_dbl);
-	       if(check) {
-		  for(n=0; n<nxgrid; n++) axo_area_sum += gdata_dbl[n];
-	       }
-	       mpp_put_var_value_block(fid, id_xgrid_area, start, nwrite, gdata_dbl);
-	       mpp_gather_field_int(naxo[na][no], atmxocn_ia[na][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	       mpp_gather_field_int(naxo[na][no], atmxocn_io[na][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	       start[1] = 1;
-	       mpp_gather_field_int(naxo[na][no], atmxocn_ja[na][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	       mpp_gather_field_int(naxo[na][no], atmxocn_jo[na][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	       if(interp_order == 2) {
-		  start[1] = 0;
-		  mpp_gather_field_double(naxo[na][no], atmxocn_dia[na][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-		  mpp_gather_field_double(naxo[na][no], atmxocn_dio[na][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-		  start[1] = 1;
-		  mpp_gather_field_double(naxo[na][no], atmxocn_dja[na][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-		  mpp_gather_field_double(naxo[na][no], atmxocn_djo[na][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	       }
-	       mpp_close(fid);
-	       free(gdata_int);
-	       free(gdata_dbl);
-	       ++nfile_axo;
-	    }
-	 } /* end of no loop */
-      
-      } /* end of na loop */
-
-      /*release the memory */
-      for(na=0; na<ntile_atm; na++) {
-	 for(nl=0; nl<ntile_lnd; nl++) {
-	    free(atmxlnd_area[na][nl]);
-	    free(atmxlnd_ia  [na][nl]);
-	    free(atmxlnd_ja  [na][nl]);
-	    free(atmxlnd_il  [na][nl]);
-	    free(atmxlnd_jl  [na][nl]);
-	    if(interp_order == 2) {
-	       free(atmxlnd_clon[na][nl]);
-	       free(atmxlnd_clat[na][nl]);
-	       free(atmxlnd_dia [na][nl]);
-	       free(atmxlnd_dja [na][nl]);
-	       free(atmxlnd_dil [na][nl]);
-	       free(atmxlnd_djl [na][nl]);
-	    }
-	 }
-	 free(atmxlnd_area[na]);
-	 free(atmxlnd_ia  [na]);
-	 free(atmxlnd_ja  [na]);
-	 free(atmxlnd_il  [na]);
-	 free(atmxlnd_jl  [na]);
-	 if(interp_order == 2) {
-	    free(atmxlnd_clon[na]);
-	    free(atmxlnd_clat[na]);
-	    free(atmxlnd_dia [na]);
-	    free(atmxlnd_dja [na]);
-	    free(atmxlnd_dil [na]);
-	    free(atmxlnd_djl [na]);
-	 }
-	 for(no=0; no<ntile_ocn; no++) {
-	    free(atmxocn_area[na][no]);
-	    free(atmxocn_ia  [na][no]);
-	    free(atmxocn_ja  [na][no]);
-	    free(atmxocn_io  [na][no]);
-	    free(atmxocn_jo  [na][no]);
-	    if(interp_order == 2) {
-	       free(atmxocn_clon[na][no]);
-	       free(atmxocn_clat[na][no]);
-	       free(atmxocn_dia [na][no]);
-	       free(atmxocn_dja [na][no]);
-	       free(atmxocn_dio [na][no]);
-	       free(atmxocn_djo [na][no]);
-	    }
-	 }
-	 free(atmxocn_area[na]);
-	 free(atmxocn_ia  [na]);
-	 free(atmxocn_ja  [na]);
-	 free(atmxocn_io  [na]);
-	 free(atmxocn_jo  [na]);
-	 if(interp_order == 2) {
-	    free(atmxocn_clon[na]);
-	    free(atmxocn_clat[na]);
-	    free(atmxocn_dia [na]);
-	    free(atmxocn_dja [na]);
-	    free(atmxocn_dio [na]);
-	    free(atmxocn_djo [na]);
-	 }
-	 free(naxl[na]);
-	 free(naxo[na]);
-      }    
-      free(atmxlnd_area);
-      free(atmxlnd_ia  );
-      free(atmxlnd_ja  );
-      free(atmxlnd_il  );
-      free(atmxlnd_jl  );
-      free(atmxocn_area);
-      free(atmxocn_ia  );
-      free(atmxocn_ja  );
-      free(atmxocn_io  );
-      free(atmxocn_jo  );   
-      if(interp_order == 2) {
-	 free(atmxlnd_clon);
-	 free(atmxlnd_clat);
-	 free(atmxlnd_dja );
-	 free(atmxlnd_dia );
-	 free(atmxlnd_dil );
-	 free(atmxlnd_djl );
-	 free(atmxocn_clon);
-	 free(atmxocn_clat);
-	 free(atmxocn_dia );
-	 free(atmxocn_dja );
-	 free(atmxocn_dio );
-	 free(atmxocn_djo );
-      }
-      free(naxl);
-      free(naxo);
-   }
-   if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Complete the process to create exchange grids "
-   "for fluxes between atmosphere and surface (sea ice and land)\n" );
-  
-   /***************************************************************************************
-     Then generate the exchange grid between land mosaic and ocean mosaic
-     if land mosaic is different from atmos mosaic
-   ***************************************************************************************/
-   nfile_lxo = 0;
-   if( !lnd_same_as_atm ) {
-      int     no, nl, ll, lo;
-      size_t  **nlxo;
-      int     ***lndxocn_il, ***lndxocn_jl, ***lndxocn_io, ***lndxocn_jo;
-      double  ***lndxocn_area, ***lndxocn_dil, ***lndxocn_djl, ***lndxocn_dio, ***lndxocn_djo;
-      double  ***lndxocn_clon, ***lndxocn_clat;
-      double  min_area;
-
-      nlxo         = (size_t ** )malloc(ntile_lnd*sizeof(size_t * ));
-      lndxocn_area = (double ***)malloc(ntile_lnd*sizeof(double **));
-      lndxocn_il   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-      lndxocn_jl   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-      lndxocn_io   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-      lndxocn_jo   = (int    ***)malloc(ntile_lnd*sizeof(int    **));
-      if(interp_order == 2) {
-	 lndxocn_dil  = (double ***)malloc(ntile_lnd*sizeof(double **));
-	 lndxocn_djl  = (double ***)malloc(ntile_lnd*sizeof(double **));
-	 lndxocn_dio  = (double ***)malloc(ntile_lnd*sizeof(double **));
-	 lndxocn_djo  = (double ***)malloc(ntile_lnd*sizeof(double **));
-	 lndxocn_clon = (double ***)malloc(ntile_lnd*sizeof(double **));
-	 lndxocn_clat = (double ***)malloc(ntile_lnd*sizeof(double **));
-      }
-      for(nl=0; nl<ntile_lnd; nl++) {
-	 nlxo        [nl] = (size_t * )malloc(ntile_ocn*sizeof(size_t  ));
-	 lndxocn_area[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	 lndxocn_il  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-	 lndxocn_jl  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-	 lndxocn_io  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-	 lndxocn_jo  [nl] = (int    **)malloc(ntile_ocn*sizeof(int    *));
-	 if(interp_order == 2) {
-	    lndxocn_dil [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    lndxocn_djl [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    lndxocn_dio [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    lndxocn_djo [nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    lndxocn_clon[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	    lndxocn_clat[nl] = (double **)malloc(ntile_ocn*sizeof(double *));
-	 }
-	 for(no=0; no<ntile_ocn; no++) {
-	    lndxocn_area[nl][no] = (double *)malloc(MAXXGRID*sizeof(double));
-	    lndxocn_il  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    lndxocn_jl  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    lndxocn_io  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));
-	    lndxocn_jo  [nl][no] = (int    *)malloc(MAXXGRID*sizeof(int   ));          
-	    if(interp_order == 2 ) {  
-	       lndxocn_dil[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	       lndxocn_djl[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	       lndxocn_dio[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	       lndxocn_djo[nl][no]  = (double *)malloc(MAXXGRID*sizeof(double));
-	       lndxocn_clon[nl][no] = (double *)malloc(MAXXGRID*sizeof(double *));
-	       lndxocn_clat[nl][no] = (double *)malloc(MAXXGRID*sizeof(double *));
-	    }
-	 }
-      }
- 
-      for(nl=0; nl<ntile_lnd; nl++) {
-	 int      il, jl, io, jo, is, ie, js, je, layout[2];
-	 int      n0, n1, n2, n3, nl_in, no_in, n_out, nxgrid;
-	 double   xarea, xctrlon, xctrlat;
-	 double   xl_min, yl_min, xo_min, yo_min, xl_avg;
-	 double   xl_max, yl_max, xo_max, yo_max;
-	 double   xl[MV], yl[MV], xo[MV], yo[MV], x_out[MV], y_out[MV];
-	 domain2D Dom;
-
-	 for(no=0; no<ntile_ocn; no++) nlxo[nl][no] = 0;
-      
-	 layout[0] = mpp_npes();
-	 layout[1] = 1;
-        
-	 mpp_define_domain2d(nxl[nl]*nyl[nl], 1, layout, 0, 0, &Dom);
-	 mpp_get_compute_domain2d(Dom, &is, &ie, &js, &je );
-	 for(ll=is;ll<=ie;ll++) {
-	    il = ll%nxl[nl];
-	    jl = ll/nxl[nl];
-	    n0 = jl    *(nxl[nl]+1) + il;
-	    n1 = jl    *(nxl[nl]+1) + il+1;
-	    n2 = (jl+1)*(nxl[nl]+1) + il+1;
-	    n3 = (jl+1)*(nxl[nl]+1) + il;
-	    xl[0] = xlnd[nl][n0]; yl[0] = ylnd[nl][n0];
-	    xl[1] = xlnd[nl][n1]; yl[1] = ylnd[nl][n1];
-	    xl[2] = xlnd[nl][n2]; yl[2] = ylnd[nl][n2];
-	    xl[3] = xlnd[nl][n3]; yl[3] = ylnd[nl][n3];
-	    yl_min  = minval_double(4, yl);
-	    yl_max  = maxval_double(4, yl);
-	    nl_in   = fix_lon(xl, yl, 4, M_PI);
-	    xl_min  = minval_double(nl_in, xl);
-	    xl_max  = maxval_double(nl_in, xl);
-	    xl_avg  = avgval_double(nl_in, xl);      
-	    for(no=0; no<ntile_ocn; no++) {
-	       for(jo = 0; jo < nyo[no]; jo++) for(io = 0; io < nxo[no]; io++) if(omask[no][jo*nxo[no]+io] > 0.5) {	
-			n0 = jo    *(nxo[no]+1) + io;
-			n1 = jo    *(nxo[no]+1) + io+1;
-			n2 = (jo+1)*(nxo[no]+1) + io+1;
-			n3 = (jo+1)*(nxo[no]+1) + io;
-			xo[0] = xocn[no][n0]; yo[0] = yocn[no][n0];
-			xo[1] = xocn[no][n1]; yo[1] = yocn[no][n1];
-			xo[2] = xocn[no][n2]; yo[2] = yocn[no][n2];
-			xo[3] = xocn[no][n3]; yo[3] = yocn[no][n3];
-			yo_min = minval_double(4, yo);
-			yo_max = maxval_double(4, yo);
-			if(yo_min >= yl_max || yo_max <= yl_min ) continue;	    
-			no_in  = fix_lon(xo, yo, 4, xl_avg);
-			xo_min = minval_double(no_in, xo);
-			xo_max = maxval_double(no_in, xo);
-			/* xo should in the same range as xa after lon_fix, so no need to
-			   consider cyclic condition
-			*/
-			if(xl_min >= xo_max || xl_max <= xo_min ) continue;
-			if (  (n_out = clip_2dx2d( xl, yl, nl_in, xo, yo, no_in, x_out, y_out )) > 0 ){
-			   xarea = poly_area(x_out, y_out, n_out );
-			   min_area = min(area_ocn[no][jo*nxo[no]+io], area_lnd[nl][ll] );
-			   if(xarea/min_area > AREA_RATIO_THRESH ) {
-			      lndxocn_area[nl][no][nlxo[nl][no]] = xarea;
-			      lndxocn_io[nl][no][nlxo[nl][no]]   = io;
-			      lndxocn_jo[nl][no][nlxo[nl][no]]   = jo;
-			      lndxocn_il[nl][no][nlxo[nl][no]]   = il;
-			      lndxocn_jl[nl][no][nlxo[nl][no]]   = jl;
-			      if(interp_order == 2) {
-				 lndxocn_clon[nl][no][nlxo[nl][no]] = poly_ctrlon ( x_out, y_out, n_out, xl_avg);
-				 lndxocn_clat[nl][no][nlxo[nl][no]] = poly_ctrlat ( x_out, y_out, n_out );
-			      }
-			      ++(nlxo[nl][no]);
-			      if(nlxo[nl][no] > MAXXGRID) mpp_error("nlxo is greater than MAXXGRID, increase MAXXGRID");
-			   }
-			}
-		     } /* end of io, jo loop */
-	    } 
-	 } /* end of ll( or il, jl) loop */
-	 mpp_delete_domain2d(&Dom);
-      }/* for(nl=0; nl<ntile_lnd; nl++) */
-
-      /* calculate the centroid of model grid. */
-      if(interp_order == 2) {
-	 double *l_area, *l_clon, *l_clat;
-	 double **o_area, **o_clon, **o_clat;
- 
-	 o_area = (double **)malloc(ntile_ocn*sizeof(double *));
-	 o_clon = (double **)malloc(ntile_ocn*sizeof(double *));
-	 o_clat = (double **)malloc(ntile_ocn*sizeof(double *));
-	 for(no =0; no<ntile_ocn; no++) {
-	    o_area[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	    o_clon[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	    o_clat[no] = (double *)malloc(nxo[no]*nyo[no]*sizeof(double));
-	    for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	       o_area[no][lo] = 0;
-	       o_clon[no][lo] = 0;
-	       o_clat[no][lo] = 0;
-	    }
-	 }
-
-	 for(nl=0; nl<ntile_lnd; nl++) {
-	    l_area = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	    l_clon = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	    l_clat = (double *)malloc(nxl[nl]*nyl[nl]*sizeof(double));
-	    for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	       l_area[ll] = 0;
-	       l_clon[ll] = 0;
-	       l_clat[ll] = 0;
-	    }
-
-	    for(no=0; no<ntile_ocn; no++) {
-	       int nxgrid;
-	       nxgrid = nlxo[nl][no];
-	       mpp_sum_int(1, &nxgrid);
-	       if(nxgrid > 0) {
-		  double *g_area, *g_clon, *g_clat;
-		  int    *g_il,   *g_jl,   *g_io, *g_jo;
-		  int    ii;
-		  g_il = (int    *)malloc(nxgrid*sizeof(int   ));
-		  g_jl = (int    *)malloc(nxgrid*sizeof(int   ));
-		  g_io = (int    *)malloc(nxgrid*sizeof(int   ));
-		  g_jo = (int    *)malloc(nxgrid*sizeof(int   ));	
-		  g_area = (double *)malloc(nxgrid*sizeof(double));
-		  g_clon = (double *)malloc(nxgrid*sizeof(double));
-		  g_clat = (double *)malloc(nxgrid*sizeof(double));
-		  mpp_gather_field_int   (nlxo[nl][no], lndxocn_il[nl][no], g_il);
-		  mpp_gather_field_int   (nlxo[nl][no], lndxocn_jl[nl][no], g_jl);
-		  mpp_gather_field_int   (nlxo[nl][no], lndxocn_io[nl][no], g_io);
-		  mpp_gather_field_int   (nlxo[nl][no], lndxocn_jo[nl][no], g_jo);
-		  mpp_gather_field_double(nlxo[nl][no], lndxocn_area[nl][no], g_area);
-		  mpp_gather_field_double(nlxo[nl][no], lndxocn_clon[nl][no], g_clon);
-		  mpp_gather_field_double(nlxo[nl][no], lndxocn_clat[nl][no], g_clat);
-		  for(i=0; i<nxgrid; i++) {	      
-		     ii = g_jl[i]*nxl[nl]+g_il[i];
-		     l_area[ii] += g_area[i];
-		     l_clon[ii] += g_clon[i];
-		     l_clat[ii] += g_clat[i];
-		     ii = g_jo[i]*nxo[no]+g_io[i];
-		     o_area[no][ii] += g_area[i];
-		     o_clon[no][ii] += g_clon[i];
-		     o_clat[no][ii] += g_clat[i];
-		  }
-		  free(g_il);
-		  free(g_jl);
-		  free(g_io);
-		  free(g_jo);
-		  free(g_area);
-		  free(g_clon);
-		  free(g_clat);
-	       }
-	    }
-	    for(ll=0; ll<nxl[nl]*nyl[nl]; ll++) {
-	       if(l_area[ll] > 0) {
-		  l_clon[ll] /= l_area[ll];
-		  l_clat[ll] /= l_area[ll];
-	       }
-	    }
-	    /* substract land centroid to get the centroid distance between land grid and exchange grid. */
-	    for(no=0; no<ntile_ocn; no++) {
-	       for(i=0; i<nlxo[nl][no]; i++) {
-		  ll = lndxocn_jl[nl][no][i]*nxl[nl] + lndxocn_il[nl][no][i];
-		  lndxocn_dil[nl][no][i] = lndxocn_clon[nl][no][i]/lndxocn_area[nl][no][i] - l_clon[ll];
-		  lndxocn_djl[nl][no][i] = lndxocn_clat[nl][no][i]/lndxocn_area[nl][no][i] - l_clat[ll];
-	       }
-	    }
-	
-	    free(l_area);
-	    free(l_clon);
-	    free(l_clat);	
-	 }
-
-	 /* centroid distance from exchange grid to ocean grid */
-	 for(no=0; no<ntile_ocn; no++) {
-	    for(lo=0; lo<nxo[no]*nyo[no]; lo++) {
-	       if(o_area[no][lo] > 0) {
-		  o_clon[no][lo] /= o_area[no][lo];
-		  o_clat[no][lo] /= o_area[no][lo];
-	       }
-	    }
-	    for(nl=0; nl<ntile_lnd; nl++) {
-	       for(i=0; i<nlxo[nl][no]; i++) {
-		  lo = lndxocn_jo[nl][no][i]*nxo[no] + lndxocn_io[nl][no][i];
-		  lndxocn_dio[nl][no][i] = lndxocn_clon[nl][no][i]/lndxocn_area[nl][no][i] - o_clon[no][lo];
-		  lndxocn_djo[nl][no][i] = lndxocn_clat[nl][no][i]/lndxocn_area[nl][no][i] - o_clat[no][lo];
-	       }
-	    }
-	    free(o_area[no]);
-	    free(o_clon[no]);
-	    free(o_clat[no]);
-	 }
-
-	 free(o_area);
-	 free(o_clon);
-	 free(o_clat);
-      }
-
-      /* write out lndXocn data */
-      for(nl = 0; nl < ntile_lnd; nl++) {
-	 for(no = 0; no < ntile_ocn; no++) {
-	    int nxgrid;
-	 
-	    /* get total number of exchange grid on all the pes */
-	    nxgrid = nlxo[nl][no];
-	    mpp_sum_int(1, &nxgrid);
-	
-	    if(nxgrid >0) {
-	       size_t start[4], nwrite[4];
-	       int *gdata_int;
-	       double *gdata_dbl;
-	  
-	       char contact[STRING];
-	       int fid, dim_string, dim_ncells, dim_two, dims[4];
-	       int id_contact, id_xgrid_area, n;
-	       int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-
-	       for(i=0; i<4; i++) {
-		  start[i] = 0; nwrite[i] = 1;
-	       }	  	  
-	  
-	       if(same_mosaic)
-		  sprintf(lxo_file[nfile_lxo], "lnd_%s_%sXocn_%s_%s.nc", lmosaic_name, ltile_name[nl], omosaic_name, otile_name[no]);
-	       else
-		  sprintf(lxo_file[nfile_lxo], "%s_%sX%s_%s.nc", lmosaic_name, ltile_name[nl], omosaic_name, otile_name[no]);
-	       sprintf(contact, "%s:%s::%s:%s", lmosaic_name, ltile_name[nl], omosaic_name, otile_name[no]);
-
-	       fid = mpp_open(lxo_file[nfile_lxo], MPP_WRITE);
-	       mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-	       mpp_def_global_att(fid, "code_version", TAGNAME);
-	       mpp_def_global_att(fid, "history", history);
-	       dim_string = mpp_def_dim(fid, "string", STRING);
-	       dim_ncells = mpp_def_dim(fid, "ncells", nxgrid);
-	       dim_two    = mpp_def_dim(fid, "two", 2);
-	       if(interp_order == 2) {
-		  id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 7, "standard_name", "grid_contact_spec",
-		  "contact_type", "exchange", "parent1_cell",
-		  "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area", 
-		  "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-	       }
-	       else {
-		  id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 5, "standard_name", "grid_contact_spec",
-		  "contact_type", "exchange", "parent1_cell",
-		  "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area" );
-	       }
-	       dims[0] = dim_ncells; dims[1] = dim_two;
-	       id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent1_cell_indices");
-	       id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent2_cell_indices");
-	       id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-	       "exchange_grid_area", "units", "m2");
-
-	       if(interp_order == 2) {
-		  id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-		  id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-	       }
-	       mpp_end_def(fid);
-
-	       /* the index will start from 1, instead of 0 ( fortran index) */
-	       for(i = 0;i < nlxo[nl][no]; i++) {
-		  ++(lndxocn_il[nl][no][i]);
-		  ++(lndxocn_jl[nl][no][i]);
-		  ++(lndxocn_io[nl][no][i]);
-		  lndxocn_jo[nl][no][i] += 1 - ocn_south_ext; /* one artificial j-level may be added in the south end */
-	       }
-
-	       nwrite[0] = strlen(contact);
-	       mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-	       nwrite[0] = nxgrid;
-
-	       gdata_int = (int *)malloc(nxgrid*sizeof(int));
-	       gdata_dbl = (double *)malloc(nxgrid*sizeof(double));
-
-	       mpp_gather_field_double(nlxo[nl][no], lndxocn_area[nl][no], gdata_dbl);
-	       mpp_put_var_value(fid, id_xgrid_area, gdata_dbl);
-	       mpp_gather_field_int(nlxo[nl][no], lndxocn_il[nl][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	       mpp_gather_field_int(nlxo[nl][no], lndxocn_io[nl][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	       start[1] = 1;
-	       mpp_gather_field_int(nlxo[nl][no], lndxocn_jl[nl][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, gdata_int);
-	       mpp_gather_field_int(nlxo[nl][no], lndxocn_jo[nl][no], gdata_int);
-	       mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, gdata_int);
-	       if(interp_order == 2) {
-		  start[1] = 0;
-		  mpp_gather_field_double(nlxo[nl][no], lndxocn_dil[nl][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-		  mpp_gather_field_double(nlxo[nl][no], lndxocn_dio[nl][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-		  start[1] = 1;
-		  mpp_gather_field_double(nlxo[nl][no], lndxocn_djl[nl][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, gdata_dbl);
-		  mpp_gather_field_double(nlxo[nl][no], lndxocn_djo[nl][no], gdata_dbl);
-		  mpp_put_var_value_block(fid, id_tile2_dist, start, nwrite, gdata_dbl);
-	       }
-	       mpp_close(fid);
-	       free(gdata_int);
-	       free(gdata_dbl);
-	       ++nfile_lxo;
-	    }
-	 } /* for(no=0; no<ntile_ocn; no++) */
-      } /* for(nl=0; nl<ntile_lnd; nl++) */
-
-      /* release the memory */
-      for(nl=0; nl<ntile_lnd; nl++) {
-	 for(no=0; no<ntile_ocn; no++) {
-	    free(lndxocn_area[nl][no]);
-	    free(lndxocn_il  [nl][no]);
-	    free(lndxocn_jl  [nl][no]);
-	    free(lndxocn_io  [nl][no]);
-	    free(lndxocn_jo  [nl][no]);
-	    if(interp_order == 2) {
-	       free(lndxocn_clon[nl][no]);
-	       free(lndxocn_clat[nl][no]);
-	       free(lndxocn_dil [nl][no]);
-	       free(lndxocn_djl [nl][no]);
-	       free(lndxocn_dio [nl][no]);
-	       free(lndxocn_djo [nl][no]);
-	    }
-	 }
-	 free(lndxocn_area[nl]);
-	 free(lndxocn_il  [nl]);
-	 free(lndxocn_jl  [nl]);
-	 free(lndxocn_io  [nl]);
-	 free(lndxocn_jo  [nl]);
-	 if(interp_order == 2) {
-	    free(lndxocn_clon[nl]);
-	    free(lndxocn_clat[nl]);
-	    free(lndxocn_dil [nl]);
-	    free(lndxocn_djl [nl]);
-	    free(lndxocn_dio [nl]);
-	    free(lndxocn_djo [nl]);
-	 }
-	 free(nlxo[nl]);
-      }
-      free(nlxo);
-      free(lndxocn_area);
-      free(lndxocn_il  );
-      free(lndxocn_jl  );
-      free(lndxocn_io  );
-      free(lndxocn_jo  );   
-      if(interp_order == 2) {
-	 free(lndxocn_clon);
-	 free(lndxocn_clat);
-	 free(lndxocn_dil );
-	 free(lndxocn_djl );
-	 free(lndxocn_dio );
-	 free(lndxocn_djo );
-      }
-
-      if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Complete the process to create exchange grids "
-      "for runoff between land and sea ice.\n" );
-   }
-   else {
-      nfile_lxo = nfile_axo;
-      for(i=0; i<nfile_axo; i++) strcpy(lxo_file[i], axo_file[i]);
-      if(mpp_pe() == mpp_root_pe()) printf("\nNOTE from make_coupler_mosaic: Since lmosaic is the same as amosaic, "
-      "no need to compute the exchange grid between lmosaic and omosaic, "
-      "simply use the exchange grid between amosaic and omosaic.\n");    
-   }
-
-   if(mpp_pe() == mpp_root_pe()) {
-      int n, i;
-      double axo_area_frac;
-      double axl_area_frac;
-      double tiling_area;
-      double *atm_area;
-      double atm_area_sum;
-
-      if(check) {
-	 /* for cubic grid, when number of model points is odd, some grid cell area will be negative,
-	    need to think about how to solve this issue in the future */
-	 /*      atm_area_sum = 4*M_PI*RADIUS*RADIUS; */
-	 atm_area_sum = 0;
-	 for(n=0; n<ntile_atm; n++) {
-	    atm_area = (double *)malloc(nxa[n]*nya[n]*sizeof(double));
-	    get_grid_area(&nxa[n], &nya[n], xatm[n], yatm[n], atm_area);
-	    for(i=0; i<nxa[n]*nya[n]; i++) atm_area_sum += atm_area[i];
-	    free(atm_area);
-	 }
-	 axo_area_frac = axo_area_sum/atm_area_sum*100;
-	 axl_area_frac = axl_area_sum/atm_area_sum*100;
-	 tiling_area   = (atm_area_sum-axo_area_sum-axl_area_sum)/atm_area_sum*100;    
-	 printf("\nNOTE: axo_area_sum is %f and ocean fraction is %f%%\n", axo_area_sum, axo_area_frac);
-	 printf("NOTE: axl_area_sum is %f and land  fraction is %f%%\n", axl_area_sum, axl_area_frac);
-	 printf("NOTE: tiling error is %f%%\n", tiling_area );
-      }
-   }
-  
-   /*Fianlly create the coupler mosaic file mosaic_name.nc */
-   {
-      int fid, dim_string, dim_axo, dim_lxo, dim_axl, dims[4], n;
-      size_t start[4], nwrite[4];
-      int id_lmosaic_dir, id_lmosaic_file, id_omosaic_dir, id_omosaic_file;
-      int id_amosaic_dir, id_amosaic_file, id_otopog_dir, id_otopog_file;
-      int id_xgrids_dir, id_axo_file, id_lxo_file, id_axl_file;
-      int id_amosaic, id_lmosaic, id_omosaic;
-    
-      fid = mpp_open(mosaic_file, MPP_WRITE);
-      mpp_def_global_att(fid, "grid_version", GRID_VERSION);
-      mpp_def_global_att(fid, "code_version", TAGNAME);
-      mpp_def_global_att(fid, "history", history);
-      dim_string = mpp_def_dim(fid, "string", STRING);
-      dim_axo = mpp_def_dim(fid, "nfile_aXo", nfile_axo);
-      dim_axl = mpp_def_dim(fid, "nfile_aXl", nfile_axl);
-      dim_lxo = mpp_def_dim(fid, "nfile_lXo", nfile_lxo);
-      id_amosaic_dir  = mpp_def_var(fid, "atm_mosaic_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_atmosphere_mosaic");
-      id_amosaic_file = mpp_def_var(fid, "atm_mosaic_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "atmosphere_mosaic_file_name");
-      id_amosaic      = mpp_def_var(fid, "atm_mosaic", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "atmosphere_mosaic_name");
-      id_lmosaic_dir  = mpp_def_var(fid, "lnd_mosaic_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_land_mosaic");
-      id_lmosaic_file = mpp_def_var(fid, "lnd_mosaic_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "land_mosaic_file_name");
-      id_lmosaic      = mpp_def_var(fid, "lnd_mosaic", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "land_mosaic_name");        
-      id_omosaic_dir  = mpp_def_var(fid, "ocn_mosaic_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_ocean_mosaic");
-      id_omosaic_file = mpp_def_var(fid, "ocn_mosaic_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "ocean_mosaic_file_name");
-      id_omosaic      = mpp_def_var(fid, "ocn_mosaic", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "ocean_mosaic_name");    
-      id_otopog_dir   = mpp_def_var(fid, "ocn_topog_dir", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "directory_storing_ocean_topog");
-      id_otopog_file  = mpp_def_var(fid, "ocn_topog_file", MPP_CHAR, 1, &dim_string,
-      1, "standard_name", "ocean_topog_file_name");
-      /* since exchange grid is created in this tool, we may add command line option to specify where to store the output */
-      /*    id_xgrids_dir = mpp_def_var(fid, "xgrids_dir", MPP_CHAR, 1, &dim_string,
-	    1, "standard_name", "directory_storing_xgrids"); */
-      dims[0] = dim_axo; dims[1] = dim_string;
-      id_axo_file = mpp_def_var(fid, "aXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXocn_exchange_grid_file");
-      dims[0] = dim_axl; dims[1] = dim_string;
-      id_axl_file = mpp_def_var(fid, "aXl_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXlnd_exchange_grid_file");
-      dims[0] = dim_lxo; dims[1] = dim_string;
-      id_lxo_file = mpp_def_var(fid, "lXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "lndXocn_exchange_grid_file");
-      mpp_end_def(fid);
-      for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; }
-    
-      nwrite[0] = strlen(amosaic_dir);
-      mpp_put_var_value_block(fid, id_amosaic_dir, start, nwrite, amosaic_dir);
-      nwrite[0] = strlen(amosaic_file);
-      mpp_put_var_value_block(fid, id_amosaic_file, start, nwrite, amosaic_file);
-      nwrite[0] = strlen(amosaic_name);
-      mpp_put_var_value_block(fid, id_amosaic, start, nwrite, amosaic_name);
-      nwrite[0] = strlen(lmosaic_dir);
-      mpp_put_var_value_block(fid, id_lmosaic_dir, start, nwrite, lmosaic_dir);
-      nwrite[0] = strlen(lmosaic_file);
-      mpp_put_var_value_block(fid, id_lmosaic_file, start, nwrite, lmosaic_file);
-      nwrite[0] = strlen(lmosaic_name);
-      mpp_put_var_value_block(fid, id_lmosaic, start, nwrite, lmosaic_name);
-      nwrite[0] = strlen(omosaic_dir);
-      mpp_put_var_value_block(fid, id_omosaic_dir, start, nwrite, omosaic_dir);
-      nwrite[0] = strlen(omosaic_file);
-      mpp_put_var_value_block(fid, id_omosaic_file, start, nwrite, omosaic_file);
-      nwrite[0] = strlen(omosaic_name);
-      mpp_put_var_value_block(fid, id_omosaic, start, nwrite, omosaic_name);
-      nwrite[0] = strlen(otopog_dir);
-      mpp_put_var_value_block(fid, id_otopog_dir, start, nwrite, otopog_dir);
-      nwrite[0] = strlen(otopog_file);
-      mpp_put_var_value_block(fid, id_otopog_file, start, nwrite, otopog_file);
-      nwrite[0] = 1;
-
-      for(n=0; n<nfile_axo; n++) {
-	 start[0] = n; nwrite[1] = strlen(axo_file[n]);
-	 mpp_put_var_value_block(fid, id_axo_file, start, nwrite, axo_file[n]);
-      }
-      for(n=0; n<nfile_axl; n++) {
-	 start[0] = n; nwrite[1] = strlen(axl_file[n]);
-	 mpp_put_var_value_block(fid, id_axl_file, start, nwrite, axl_file[n]);
-      }
-      for(n=0; n<nfile_lxo; n++) {
-	 start[0] = n; nwrite[1] = strlen(lxo_file[n]);
-	 mpp_put_var_value_block(fid, id_lxo_file, start, nwrite, lxo_file[n]);
-      }    
-      mpp_close(fid);
-   }
-   return 0;
-}
-  
diff --git a/gridspec_tools_20080702/tools/shared/tool_util.h b/gridspec_tools_20080702/tools/shared/tool_util.h
deleted file mode 100644
index bc5b8cf..0000000
--- a/gridspec_tools_20080702/tools/shared/tool_util.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/***********************************************************************
-                      tool_util.h
-    This header file provide some utilities routine that will be used in many tools.
-    
-    contact: Zhi.Liang at noaa.gov
-***********************************************************************/
-#ifndef TOOL_UTIL_H_
-#define TOOL_UTIL_H_
-void get_file_path(const char *file, char *dir);
-int get_int_entry(char *line, int *value); 
-int get_double_entry(char *line, double *value);
-double spherical_dist(double x1, double y1, double x2, double y2);
-double spherical_area(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ); 
-double bipolar_dist(double x1, double y1, double x2, double y2, double bpeq, double bpsp, double bpnp, double rp );
-double bipolar_area(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 );
-void tp_trans(double *lon, double *lat, double lon_ref, double lon_start, 
-              double lam0, double bpeq, double bpsp, double bpnp, double rp );
-double* compute_grid_bound(int nb, const double *bnds, const int *npts, int *grid_size, const char *center);
-
-typedef struct {
-  int nx;
-  int ny;
-  double *xt;
-  double *yt;
-  double *xb;
-  double *yb;
-  double *xb_r;
-  double *yb_r;
-  double *area;
-  double *landfrac;
-  double *subA;
-  double *cellarea;
-  double *celllength;
-  int    *tocell;
-  int    *travel;
-  int    *basin;
-  int    *dir;
-  int    *last_point;
-  double subA_missing;
-  double cellarea_missing;
-  double celllength_missing;
-  int    tocell_missing;
-  int    travel_missing;
-  int    basin_missing;
-  char   filename[128];
-} river_type;
-
-//inline void swap(void *x, void *y, size_t l);
-void qsort_index(double array[], int start, int end, int rank[]);
-void get_source_data(const char *src_file, river_type *river_data);
-void get_mosaic_grid(const char *coupler_mosaic, const char *land_mosaic,
-int ntiles, river_type *river_data, unsigned int *opcode);
-void init_river_data(int ntiles, river_type *river_out, const river_type * const river_in);
-void calc_max_subA(const river_type *river_in, river_type *river_out,
-int ntiles, unsigned int opcode);
-void update_halo_double(int ntiles, double **data, int nx, int ny, unsigned int opcode);
-void update_halo_int(int ntiles, int **data, int nx, int ny, unsigned int opcode);
-int adjust_lon(double x[], double tlon);
-void calc_tocell(int ntiles, river_type *river_out, unsigned int opcode );
-void calc_river_data(int ntiles, river_type* river_data, unsigned int opcode  );
-void sort_basin(int ntiles, river_type* river_data);
-
-void check_river_data( );
-void write_river_data(const char *river_src_file, const char *output_file,
-river_type* river_out, const char *history, int ntiles);
-double distance(double lon1, double lat1, double lon2, double lat2);
-
-
-#endif
diff --git a/gridspec_tools_20080702/tools/shared/transfer_to_mosaic.c b/gridspec_tools_20080702/tools/shared/transfer_to_mosaic.c
deleted file mode 100644
index fecdaf0..0000000
--- a/gridspec_tools_20080702/tools/shared/transfer_to_mosaic.c
+++ /dev/null
@@ -1,1278 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include <getopt.h>
-#include "constant.h"
-#include "mpp.h"
-#include "mpp_domain.h"
-#include "mpp_io.h"
-
-const int MAXBOUNDS = 100;
-const int STRINGLEN = 255;
-
-const int MAXTILE = 100;
-const int MAXCONTACT = 100;
-const int SHORTSTRING = 32;
-const char mosaic_version[] = "0.2";
-
-#define PI M_PI
-  
-double *x, *y, *dx, *dy, *area, *angle_dx, *angle_dy; 
-int nx, ny, nxp, nyp;
-char *old_file = NULL;
-
-int main(int argc, char* argv[])
-{
-/* ----------------------------- */
-  extern char *optarg;
-  char *pch=NULL, history[512], entry[1280];
-  char tilefile[MAXTILE][STRING], tiletype[MAXTILE][SHORTSTRING];
-  char tile_name[MAXTILE][STRING];
-  int ntiles=0, nfiles=0, ncontact=0;
-  double periodx=0, periody=0;
-  int contact_tile1[MAXCONTACT], contact_tile2[MAXCONTACT];
-  int contact_tile1_istart[MAXCONTACT], contact_tile1_iend[MAXCONTACT];
-  int contact_tile1_jstart[MAXCONTACT], contact_tile1_jend[MAXCONTACT];
-  int contact_tile2_istart[MAXCONTACT], contact_tile2_iend[MAXCONTACT];
-  int contact_tile2_jstart[MAXCONTACT], contact_tile2_jend[MAXCONTACT];
-  char mosaic_name[128] = "atmos_mosaic";
-  char mosaic_dir[256]  = "./" ;
-  char grid_descriptor[128] = "";
-  int c, i, n, m, l, errflg, check=0;
-
-  char atmos_name[128]="atmos", land_name[128]="land", ocean_name[128]="ocean";
-  char agrid_file[128], lgrid_file[128], ogrid_file[128];
-
-  int is_coupled_grid = 0, is_ocean_only =1; 
-  int interp_order=1;
-  
-  int option_index;
-  static struct option long_options[] = {
-    {"input_file",       required_argument, NULL, 'o'},
-    {"mosaic_dir",       required_argument, NULL, 'd'},    
-    {NULL, 0, NULL, 0}
-  };
-
-/* ----------------------------- */
-
-  mpp_init(&argc, &argv); /* Initilize */ 
-  //mpp_domain_init();  
-
-  while ((c = getopt_long(argc, argv, "h", long_options, &option_index) ) != -1)
-    switch (c) {
-      case 'o':
-	old_file = optarg;
-	break;
-      case 'd':
-        strcpy(mosaic_dir, optarg);
-	break;
-    }
-
-  if(!old_file) mpp_error("Usage:\n \t \t transfer_to_mosaic --input_file input_file.nc");
-  if(mpp_field_exist(old_file, "AREA_ATMxOCN") ) is_coupled_grid = 1;
-  if(mpp_field_exist(old_file, "AREA_ATM") ) is_ocean_only = 0;
-  if(mpp_field_exist(old_file, "DI_ATMxOCN") ) interp_order= 2;
-// -----------------ocean_hgrid.nc---------------------------------[
-// Ocean
-{
-  int nx_C, ny_C, nx_T, ny_T, nvertex;
-  int fid_old, vid;
-  
-  double *x_C, *y_C, *x_T, *y_T;
-  double *x_vert_T, *y_vert_T;
-
-
-  double *ds_00_02_C, *ds_00_20_C, *ds_01_11_C, *ds_01_21_C, *ds_02_22_C, 
-         *ds_10_11_C, *ds_10_12_C, *ds_11_21_C, *ds_11_12_C, *ds_20_22_C, 
-         *ds_01_11_T, *ds_01_21_T, *ds_02_22_T, *ds_10_11_T, *ds_10_12_T, 
-         *ds_11_12_T, *ds_11_21_T, *ds_20_22_T, 
-         *ds_01_21_E, *ds_10_12_N, *angle_C; 
-
- 
-  int i,j,k, i1, i2, j1, j2, k0, k1, k2, k3;
-  int ji, ji0, ji1, ji2, ji3;
-  int j1i1, j1i2, j2i1, j2i2; 
-  double unknown = 0.0; /* double unknown = -1.0E+10; */
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  nx_C = mpp_get_dimlen(fid_old, "grid_x_C");
-  ny_C = mpp_get_dimlen(fid_old, "grid_y_C");
-  nx_T = mpp_get_dimlen(fid_old, "grid_x_T");
-  ny_T = mpp_get_dimlen(fid_old, "grid_y_T");
-  nvertex = mpp_get_dimlen(fid_old, "vertex");
-
-  printf("\nReading file: %s \n", old_file); 
-
-
-/* Reading Ocean Grid Variables */
-  x_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  y_C = (double *) malloc(ny_C * nx_C * sizeof(double));
-  x_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  y_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  x_vert_T = (double *) malloc(nvertex*ny_T*nx_T*sizeof(double));
-  y_vert_T = (double *) malloc(nvertex*ny_T*nx_T*sizeof(double));
-  ds_01_11_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_10_11_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_11_21_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_11_12_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_01_11_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_10_11_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_11_12_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_11_21_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  ds_02_22_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_20_22_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  angle_C    = (double *) malloc(ny_C * nx_C * sizeof(double));
-  
-  vid = mpp_get_varid(fid_old, "x_C"); mpp_get_var_value(fid_old, vid, x_C);
-  vid = mpp_get_varid(fid_old, "y_C"); mpp_get_var_value(fid_old, vid, y_C);
-  vid = mpp_get_varid(fid_old, "x_T"); mpp_get_var_value(fid_old, vid, x_T);
-  vid = mpp_get_varid(fid_old, "y_T"); mpp_get_var_value(fid_old, vid, y_T);
-  vid = mpp_get_varid(fid_old, "x_vert_T"); mpp_get_var_value(fid_old, vid, x_vert_T);
-  vid = mpp_get_varid(fid_old, "y_vert_T"); mpp_get_var_value(fid_old, vid, y_vert_T);
-  vid = mpp_get_varid(fid_old, "ds_01_11_C"); mpp_get_var_value(fid_old, vid, ds_01_11_C);  
-  vid = mpp_get_varid(fid_old, "ds_10_11_C"); mpp_get_var_value(fid_old, vid, ds_10_11_C);
-  vid = mpp_get_varid(fid_old, "ds_11_21_C"); mpp_get_var_value(fid_old, vid, ds_11_21_C);    
-  vid = mpp_get_varid(fid_old, "ds_11_12_C"); mpp_get_var_value(fid_old, vid, ds_11_12_C);
-  vid = mpp_get_varid(fid_old, "ds_01_11_T"); mpp_get_var_value(fid_old, vid, ds_01_11_T);  
-  vid = mpp_get_varid(fid_old, "ds_10_11_T"); mpp_get_var_value(fid_old, vid, ds_10_11_T);
-  vid = mpp_get_varid(fid_old, "ds_11_21_T"); mpp_get_var_value(fid_old, vid, ds_11_21_T);    
-  vid = mpp_get_varid(fid_old, "ds_11_12_T"); mpp_get_var_value(fid_old, vid, ds_11_12_T);  
-  vid = mpp_get_varid(fid_old, "ds_02_22_T"); mpp_get_var_value(fid_old, vid, ds_02_22_T);    
-  vid = mpp_get_varid(fid_old, "ds_20_22_T"); mpp_get_var_value(fid_old, vid, ds_20_22_T);  
-  vid = mpp_get_varid(fid_old, "angle_C"); mpp_get_var_value(fid_old, vid, angle_C);  
-  mpp_close(fid_old);
-  
-  nx = 2*nx_T;  nxp = nx +1;
-  ny = 2*ny_T;  nyp = ny +1;
-  x = (double *) malloc(nxp*nyp * sizeof(double));
-  y = (double *) malloc(nxp*nyp* sizeof(double));
-  dx = (double *) malloc(nx*nyp * sizeof(double));
-  dy = (double *) malloc(nxp*ny * sizeof(double));
-  area = (double *) malloc(nx*ny * sizeof(double));
-  angle_dx = (double *) malloc(nxp*nyp * sizeof(double));
-
-  for(j = 0; j<ny_T; j++) {
-  for(i = 0; i<nx_T; i++) {
-
-	i2=2*(i+1); i1=i2-1;   j2=2*(j+1); j1=j2-1;
-
-  	j1i1=j1*nxp+i1; j1i2=j1*nxp+i2; j2i2=j2*nxp+i2; j2i1=j2*nxp+i1; 
-	ji=j*nx_T+i;
-	ji0=ji; ji1=ji0+nx_T*ny_T; ji2=ji1+nx_T*ny_T; ji3=ji2+nx_T*ny_T;
-
-        x[j1i1] = x_T[ji];
-        x[j1i2] = 0.5*(x_vert_T[ji1]+x_vert_T[ji2]);
-        x[j2i2] = x_vert_T[ji2];
-        x[j2i1] = 0.5*(x_vert_T[ji3]+x_vert_T[ji2]);
-
-        y[j1i1] = y_T[ji];
-        y[j1i2] = 0.5*(y_vert_T[ji1]+y_vert_T[ji2]);
-        y[j2i2] = y_vert_T[ji2];
-        y[j2i1] = 0.5*(y_vert_T[ji3]+y_vert_T[ji2]);
-
-/*      Mapping distance to new mosaic grid format from old grid
-
-	       dx(1,1)=                  dx(2,1)=           
-   Ci-1,j------ds_11_21_C(i-1,j)---+-----ds_01_11_C(i,j)--------Ci,j
-	|                          |                            |
-	|                          |                            |
-	|                          |                            |
-	|                     ds_11_12_T                   ds_10_11_C(i,j)
-	|                          |                            |
-	|         dx(1,1)=         |          dx(2,1)=          |
-	+---------ds_01_11_T------Tij---------ds_11_21_T--------+
-	|                          |                            |
-	|                          |                            |
-	|                          |                            |
-	|                     ds_11_12_T                   ds_11_12_C(i,j-1)
-	|                          |                            |
-	|                          |                            |
- Ci-1,j-1--------------------------+----------------------------Ci,j-1
-
-*/
-	dx[(2*j+1)*nx  + (2*i)]   = ds_01_11_T[j*nx_T + i];
-	dx[(2*j+1)*nx  + (2*i+1)] = ds_11_21_T[j*nx_T + i];
-	if(i>0) dx[(2*j+2)*nx  + (2*i)]   = ds_11_21_C[j*nx_T + (i-1)];
-	dx[(2*j+2)*nx  + (2*i+1)] = ds_01_11_C[j*nx_T + i];
-
-	dy[(2*j  )*nxp + (2*i+1)]   = ds_10_11_T[j*nx_T + i];
-	if(j>0) dy[(2*j  )*nxp + (2*i+2)]   = ds_11_12_C[(j-1)*nx_T + i];
-	dy[(2*j+1)*nxp + (2*i+1)]   = ds_11_12_T[j*nx_T + i];
-	dy[(2*j+1)*nxp + (2*i+2)]   = ds_10_11_C[j*nx_T + i];
-
-	angle_dx[(2*j+1)*nxp + 2*i+1] = unknown;
-	angle_dx[(2*j+1)*nxp + 2*i+2] = unknown;
-	angle_dx[(2*j+2)*nxp + 2*i+1] = unknown;
-	angle_dx[(2*j+2)*nxp + 2*i+2] = angle_C[j*nx_C + i ]; 
-
-	if (j==0) {
-           x[i1] = 0.5*(x_vert_T[ji0]+x_vert_T[ji1]);
-           x[i2] = x_vert_T[ji1];
-           y[i1] = 0.5*(y_vert_T[ji0]+y_vert_T[ji1]);
-           y[i2] = y_vert_T[ji1];
-
-	   dx[ (2*i+0)] = unknown;
-	   dx[ (2*i+1)] = unknown;
-	   /* dy[(2*j  )*nxp + (2*i+2)]   = unknown; */
-	   dy[(2*j  )*nxp + (2*i+2)]   = ds_20_22_T[j*nx_T + i] - ds_10_11_C[j*nx_T + i];
-
-	   angle_dx[2*i+1] = unknown;
-	   angle_dx[2*i+2] = unknown;
-	}
-
-	if (i==0) {
-           x[j1*nxp] = 0.5*(x_vert_T[ji0]+x_vert_T[ji3]);
-           x[j2*nxp] = x_vert_T[ji3];
-           y[j1*nxp] = 0.5*(y_vert_T[ji0]+y_vert_T[ji3]);
-           y[j2*nxp] = y_vert_T[ji3];
-
-	   /* dx[(2*j+2)*nx  + (2*i)]   = unknown;*/
-	   dx[(2*j+2)*nx  + (2*i)]   = ds_02_22_T[j*nx_T + i] - ds_01_11_C[j*nx_T + i];
-	   dy[(2*j  )*nxp ]    = unknown;
-	   dy[(2*j+1)*nxp ]    = unknown;
-
-  	   angle_dx[(2*j+1)*nxp] = unknown;
-  	   angle_dx[(2*j+2)*nxp] = unknown;
-	}
-	if (i==0 && j==0) {
-           x[0] = x_vert_T[ji0]; y[0] = y_vert_T[ji0];
-  	   angle_dx[0] = unknown;
-	}
-
-  }
-  }
-
-  //for(j = 0; j<nyp; j++) { for(i = 0; i<nxp; i++) { if(angle_dx[j*nxp+i]>0.0) printf("%d %d %f\n ",i,j,angle_dx[j*nxp+i]); } }
-  //for(j = 0; j<ny_T; j++) { printf("%f ",y_C[j*nx_T+(nx_T+0)/4]); }
-  //for(i = 0; i<nx_T; i++) { if(y_T[(ny_T-1)*nx_T+i]>85.) printf("%f ",y_T[(ny_T-1)*nx_T+i]); }
-  //printf("\n\n");
-  //for(j = 0; j<nyp; j++) { printf("%f ",y[j*nxp+(nxp-1)/4]); }
-  //for(i = 0; i<nxp; i++) { if(y[(nyp-1)*nxp+i]>85.) printf("%f ",y[(nyp-1)*nxp+i]); }
-
-
-  /* write ocean-grid data */
-  /*-------ocean_hgrid.nc-------*/
-  {
-    int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-    int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-    char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-    char outfile[128] = "", tilename[128]="";
-    size_t start[4], nwrite[4];
-    
-	  sprintf(outfile, "%s_hgrid.nc",ocean_name);
-	  printf("Writing %s\n", outfile);
-          printf("\t nx_C=%d, ny_C=%d, x_T=%d, ny_T=%d \n", nx_C, ny_C,nx_T, ny_T); 
-          sprintf(tilename, "tile%d", 1);
-          fid = mpp_open(outfile, MPP_WRITE);
-
-          dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-          dimlist[1] = mpp_def_dim(fid, "nxp", nxp);
-          dimlist[2] = mpp_def_dim(fid, "nyp", nyp);
-          dimlist[3] = mpp_def_dim(fid, "nx", nx);
-          dimlist[4] = mpp_def_dim(fid, "ny", ny);
-
-          id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec",
-                                "tile_spec_version", tile_spec_version, "geometry", geometry,
-                                "discretization", discretization, "conformal", conformal );
-
-
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude",
-                             "units", "degree_east");
-          id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude",
-                             "units", "degree_north");
-
-          dims[0] = dimlist[2]; dims[1] = dimlist[3];
-          id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance",
-                             "units", "meters");
-          dims[0] = dimlist[4]; dims[1] = dimlist[1];
-          id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance",
-                             "units", "meters");
-
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-                             "units", "degrees_east");
-
-          dims[0] = dimlist[4]; dims[1] = dimlist[3];
-          id_area= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area",
-                             "units", "m2");
-
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	  nwrite[0] = strlen(tilename);
-	  mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-          mpp_put_var_value(fid, id_x, x);
-          mpp_put_var_value(fid, id_y, y);
-          mpp_put_var_value(fid, id_dx, dx);
-          mpp_put_var_value(fid, id_dy, dy);
-          mpp_put_var_value(fid, id_angle_dx, angle_dx);
-          mpp_close(fid);
-  }
-}
-// ----------------------------------------------------------------]
-// -----------------atmos_hgrid.nc---------------------------------[
-// Atmosphere
-  int nxba, nyba, nxta, nyta, nxap, nyap;
-if(is_coupled_grid) {
-  double *x_atmos, *y_atmos;
-  double *xba, *yba, *xta, *yta;
-  int i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  nxba = mpp_get_dimlen(fid_old, "xba");
-  nyba = mpp_get_dimlen(fid_old, "yba");
-  nxta = mpp_get_dimlen(fid_old, "xta");
-  nyta = mpp_get_dimlen(fid_old, "yta");
-  xba = (double *) malloc(nxba * sizeof(double)); 
-  yba = (double *) malloc(nyba * sizeof(double)); 
-  xta = (double *) malloc(nxta * sizeof(double)); 
-  yta = (double *) malloc(nyta * sizeof(double)); 
-  vid = mpp_get_varid(fid_old, "xba"); mpp_get_var_value(fid_old, vid, xba);
-  vid = mpp_get_varid(fid_old, "yba"); mpp_get_var_value(fid_old, vid, yba);
-  vid = mpp_get_varid(fid_old, "xta"); mpp_get_var_value(fid_old, vid, xta);
-  vid = mpp_get_varid(fid_old, "yta"); mpp_get_var_value(fid_old, vid, yta);
-  mpp_close(fid_old);
-  
-  nxap = nxba + nxta; nyap = nyba + nyta; 
-  x_atmos = (double *) malloc(nxap*nyap * sizeof(double));
-  y_atmos = (double *) malloc(nxap*nyap * sizeof(double));
-
-  for(i = 0; i<nxba; i++) x_atmos[2*i]   = xba[i]; for(i = 0; i<nxta; i++) x_atmos[2*i+1]   = xta[i]; 
-
-  for(j = 0; j<nyba; j++) y_atmos[2*j*nxap]   = yba[j]; 
-  for(j = 0; j<nyta; j++) y_atmos[(2*j+1)*nxap]   = yta[j]; 
-
-  for(j = 1; j<nyap; j++) for(i = 0; i<nxap; i++) x_atmos[j*nxap + i]   = x_atmos[i];
-  for(i = 1; i<nxap; i++) for(j = 0; j<nyap; j++) y_atmos[j*nxap + i]   = y_atmos[j*nxap];
-
-  /* write Atmosphere-grid data */
-  {
-    int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-    int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-    char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-    char outfile[128] = "", tilename[128]="";
-    size_t start[4], nwrite[4];
-    
-          sprintf(outfile, "%s_hgrid.nc", atmos_name);
-	  printf("Writing %s\n", outfile);
-          printf("\t nxba=%d, nyba=%d, nxta=%d, nyta=%d \n", nxba, nyba,nxta, nyta); 
-
-          sprintf(tilename, "tile%d", 1);
-          fid = mpp_open(outfile, MPP_WRITE);
-          dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-          dimlist[1] = mpp_def_dim(fid, "nxp", nxap);
-          dimlist[2] = mpp_def_dim(fid, "nyp", nyap);
-          dimlist[3] = mpp_def_dim(fid, "nx", nxap-1);
-          dimlist[4] = mpp_def_dim(fid, "ny", nyap-1);
-          id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec", "tile_spec_version", 
-			tile_spec_version, "geometry", geometry, "discretization", discretization, "conformal", conformal );
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude", "units", "degree_east");
-          id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude", "units", "degree_north");
-
-          /* Following variables are not defined */
-          dims[0] = dimlist[2]; dims[1] = dimlist[3];
-          id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance", "units", "meters");
-          dims[0] = dimlist[4]; dims[1] = dimlist[1];
-          id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance", "units", "meters");
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-                             "units", "degrees_east");
-          dims[0] = dimlist[4]; dims[1] = dimlist[3];
-          id_angle_dx= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area", "units", "m2");
-	  /* ------------------------------------------- */
-          mpp_end_def(fid);
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	  nwrite[0] = strlen(tilename);
-          mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-          mpp_put_var_value(fid, id_x, x_atmos);
-          mpp_put_var_value(fid, id_y, y_atmos);
-          mpp_close(fid);
-  }
-  free(xba); free(yba); free(xta); free(yta);  free(x_atmos); free(y_atmos);
-}
-// ----------------------------------------------------------------]
-
-//.................. Land .......................
-//..................land_hgrid.nc................
- int nxbl, nybl, nxtl, nytl,  nxlp, nylp;
-if(is_coupled_grid){
-  double *x_land, *y_land;
-  double *xbl, *ybl, *xtl, *ytl;
-  int i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  
-  nxbl = mpp_get_dimlen(fid_old, "xbl");
-  nybl = mpp_get_dimlen(fid_old, "ybl");
-  nxtl = mpp_get_dimlen(fid_old, "xtl");
-  nytl = mpp_get_dimlen(fid_old, "ytl");
-  xbl = (double *) malloc(nxbl * sizeof(double)); 
-  ybl = (double *) malloc(nybl * sizeof(double)); 
-  xtl = (double *) malloc(nxtl * sizeof(double)); 
-  ytl = (double *) malloc(nytl * sizeof(double)); 
-  vid = mpp_get_varid(fid_old, "xbl"); mpp_get_var_value(fid_old, vid, xbl);
-  vid = mpp_get_varid(fid_old, "ybl"); mpp_get_var_value(fid_old, vid, ybl);
-  vid = mpp_get_varid(fid_old, "xtl"); mpp_get_var_value(fid_old, vid, xtl);
-  vid = mpp_get_varid(fid_old, "ytl"); mpp_get_var_value(fid_old, vid, ytl);
-  mpp_close(fid_old);
-  
-  nxlp = nxbl + nxtl; nylp = nybl + nytl; 
-  x_land  = (double *) malloc(nxlp*nylp * sizeof(double));
-  y_land  = (double *) malloc(nxlp*nylp * sizeof(double));
-  
-  for(i = 0; i<nxbl; i++) x_land[2*i]   = xbl[i]; 
-  for(i = 0; i<nxtl; i++) x_land[2*i+1]   = xtl[i]; 
-
-  for(j = 0; j<nybl; j++) y_land[2*j*nxlp]   = ybl[j]; 
-  for(j = 0; j<nytl; j++) y_land[(2*j+1)*nxlp]   = ytl[j]; 
-
-  for(j = 1; j<nylp; j++) for(i = 0; i<nxlp; i++) x_land[j*nxlp + i]   = x_land[i];
-
-  for(i = 1; i<nxlp; i++) 
-	for(j = 0; j<nylp; j++) 
-		y_land[j*nxlp + i]   = y_land[j*nxlp];
-
-  /* write Land-grid data */
-  {
-    int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-    int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-    char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-    char outfile[128] = "", tilename[128]="";
-    size_t start[4], nwrite[4];
-    
-          sprintf(outfile, "%s_hgrid.nc",land_name);
-	  printf("Writing %s\n", outfile);
-          printf("\t nxbl=%d, nybl=%d, nxtl=%d, nytl=%d \n", nxbl, nybl,nxtl, nytl); 
-
-          sprintf(tilename, "tile%d", 1);
-        fid = mpp_open(outfile, MPP_WRITE);
-          dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-          dimlist[1] = mpp_def_dim(fid, "nxp", nxlp);
-          dimlist[2] = mpp_def_dim(fid, "nyp", nylp);
-          dimlist[3] = mpp_def_dim(fid, "nx", nxlp-1);
-          dimlist[4] = mpp_def_dim(fid, "ny", nylp-1);
-          id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec", "tile_spec_version", 
-			tile_spec_version, "geometry", geometry, "discretization", discretization, "conformal", conformal );
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude", "units", "degree_east");
-          id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude", "units", "degree_north");
-
-          /* Following variables are not defined */
-          dims[0] = dimlist[2]; dims[1] = dimlist[3];
-          id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance", "units", "meters");
-          dims[0] = dimlist[4]; dims[1] = dimlist[1];
-          id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance", "units", "meters");
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-                             "units", "degrees_east");
-          dims[0] = dimlist[4]; dims[1] = dimlist[3];
-          id_angle_dx= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area", "units", "m2");
-          /* ------------------------------------------- */
-
-          mpp_end_def(fid);
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	  nwrite[0] = strlen(tilename);
-          mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-          mpp_put_var_value(fid, id_x, x_land);
-          mpp_put_var_value(fid, id_y, y_land);
-          mpp_close(fid);
-  }
-  free(xbl); free(ybl); free(xtl); free(ytl);  free(x_land); free(y_land);
-}
-//-------------------------------ocean_vgrid.nc----------------------------------
-{ 
-  double *z, *zb, *zt;
-  int nzb, nzt, nz, i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  nzb = mpp_get_dimlen(fid_old, "zb");
-  nzt = mpp_get_dimlen(fid_old, "zt");
-  zb = (double *) malloc(nzb * sizeof(double)); 
-  zt = (double *) malloc(nzt * sizeof(double)); 
-  vid = mpp_get_varid(fid_old, "zb"); mpp_get_var_value(fid_old, vid, zb);
-  vid = mpp_get_varid(fid_old, "zt"); mpp_get_var_value(fid_old, vid, zt);
-  mpp_close(fid_old);
-  
-  nz = nzb + nzt + 1; 
-  z = (double *) malloc(nz * sizeof(double));
-  z[0]=0.0; 
-  for(i = 0; i<nzt; i++) { z[2*i + 1]   = zt[i]; z[2*i+2]   = zb[i]; } 
-
-  {
-    int fid, dim, varid;
-    char outfile[128] = "";
-
-    	sprintf(outfile, "%s_vgrid.nc",ocean_name);
-	printf("Writing %s\n", outfile);
-        printf("\t nzb=%d, nzt=%d\n", nzb, nzt); 
-
-    	fid = mpp_open(outfile, MPP_WRITE);
-    	  dim  = mpp_def_dim(fid, "nzv", nz);
-    	  varid = mpp_def_var(fid, "zeta", MPP_DOUBLE, 1, &dim, 2, "standard_name", "vertical_grid_vertex", "units", "meters");
-    	  mpp_end_def(fid);
-    	  mpp_put_var_value(fid, varid, z);
-    	mpp_close(fid);
-  }
-  free(zb); free(zt); free(z);
-}
-
-
-//-------------------------------topog.nc----------------------------------
-{ 
-  double *depth_t;
-  int nx, ny, ntiles, i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);  
-  nx= mpp_get_dimlen(fid_old, "grid_x_T");
-  ny= mpp_get_dimlen(fid_old, "grid_y_T");
-  depth_t= (double *) malloc(nx*ny* sizeof(double));
-  vid = mpp_get_varid(fid_old, "depth_t");  mpp_get_var_value(fid_old, vid, depth_t);
-  mpp_close(fid_old);
-  
-  {
-    int fid, dim[2], varid, ntiles = 1, dim_ntile;
-    char outfile[128] = "";
-        sprintf(outfile, "topog.nc");
-	printf("Writing %s\n", outfile);
-        printf("\t nx=%d, ny=%d\n", nx, ny);
-        fid = mpp_open(outfile, MPP_WRITE);
-	dim_ntile = mpp_def_dim(fid, "ntiles", 1);
-          dim[1]  = mpp_def_dim(fid, "nx", nx);
-          dim[0]  = mpp_def_dim(fid, "ny", ny);
-          varid = mpp_def_var(fid, "depth", MPP_DOUBLE, 2, dim, 2, "standard_name", "topographic depth at T-cell centers", "units", "meters");
-          mpp_end_def(fid);
-          mpp_put_var_value(fid, varid, depth_t);
-        mpp_close(fid);
-  }
-  free(depth_t); 
-}
-
-//................atmos_mosaic.nc............................
- if(is_coupled_grid)  {
-    char str[STRING], outfile[STRING];
-    int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-    int id_contact_index, id_griddir, id_gridfiles, dim[2];
-
-    size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-    ntiles = 1, ncontact = 0; 
-
-    sprintf(mosaic_name, "%s_mosaic",atmos_name);
-    sprintf(outfile, "%s.nc", mosaic_name);
-    printf("Writing %s\n", outfile);
-
-    sprintf(tile_name[0], "tile%d", 1);
-    sprintf(tilefile[0], "%s_hgrid.nc",atmos_name);
-    fid = mpp_open(outfile, MPP_WRITE);
-
-    contact_tile1_istart[0]=nxba-1; contact_tile1_iend[0]=nxba-1; 
-    contact_tile1_jstart[0]=1; contact_tile1_jend[0]=nyba-1; 
-
-    contact_tile2_istart[0]=1; contact_tile2_iend[0]=1; 
-    contact_tile2_jstart[0]=1; contact_tile2_jend[0]=nyba-1;
-//--------Initilize values --------------
-
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-
-    id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-                            "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-                            "children", "gridtiles", "contact_regions", "contacts",
-                            "grid_descriptor", grid_descriptor);
-    dim[0] = dim_ntiles; dim[1] = dim_string;
-    id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-                               "standard_name", "grid_file_location");
-    id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-    id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-    if(ncontact>0) {
-      dim[0] = dim_ncontact; dim[1] = dim_string;
-      id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-                                "contact_type", "boundary", "alignment", "true",
-                                "contact_index", "contact_index", "orientation", "orient");
-      id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-                                     "starting_ending_point_index_of_contact");
-
-    }
-
-    //mpp_def_global(fid, "history", history);
-    mpp_end_def(fid);
-
-    /* write out data */
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-    nwrite[0] = strlen(mosaic_name);
-    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-    nwrite[0] = 1;
-    for(n=0; n<ntiles; n++) {
-      start[0] = n; nwrite[1] = strlen(tile_name[n]);
-      mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-      nwrite[1] = strlen(tilefile[n]);
-      mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-    }
-
-    for(n=0; n<ncontact; n++) {
-      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-              tile_name[contact_tile2[n]]);
-      start[0] = n; nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-              contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-              contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-      nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-    }
-    mpp_close(fid);
-  }
-
-//................land_mosaic.nc............................
- if(is_coupled_grid)  {
-    char str[STRING], outfile[STRING];
-    int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-    int id_contact_index, id_griddir, id_gridfiles, dim[2];
-
-    size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-    ntiles = 1, ncontact = 1; 
-    contact_tile1_istart[1]=1; contact_tile1_iend[1]=1;
-    contact_tile1_jstart[1]=1; contact_tile1_jend[1]=nytl;
-
-    contact_tile2_istart[1]=nxtl; contact_tile2_iend[1]=nxtl;
-    contact_tile2_jstart[1]=1;    contact_tile2_jend[1]=nytl;
-    
-    sprintf(mosaic_name, "%s_mosaic",land_name);
-    sprintf(outfile, "%s.nc", mosaic_name);
-    printf("Writing %s\n", outfile);
-
-    sprintf(tile_name[0], "tile%d", 1);
-    sprintf(tilefile[0], "%s_hgrid.nc",land_name);
-    fid = mpp_open(outfile, MPP_WRITE);
-
-    contact_tile1_istart[0]=nxbl-1; contact_tile1_iend[0]=nxbl-1; 
-    contact_tile1_jstart[0]=1; contact_tile1_jend[0]=nybl-1; 
-
-    contact_tile2_istart[0]=1; contact_tile2_iend[0]=1; 
-    contact_tile2_jstart[0]=1; contact_tile2_jend[0]=nybl-1;
-//--------Initilize values --------------
-
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-
-    id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-                            "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-                            "children", "gridtiles", "contact_regions", "contacts",
-                            "grid_descriptor", grid_descriptor);
-    dim[0] = dim_ntiles; dim[1] = dim_string;
-    id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-                               "standard_name", "grid_file_location");
-    id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-    id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-    if(ncontact>0) {
-      dim[0] = dim_ncontact; dim[1] = dim_string;
-      id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-                                "contact_type", "boundary", "alignment", "true",
-                                "contact_index", "contact_index", "orientation", "orient");
-      id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-                                     "starting_ending_point_index_of_contact");
-
-    }
-
-    //mpp_def_global(fid, "history", history);
-    mpp_end_def(fid);
-
-    /* write out data */
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-    nwrite[0] = strlen(mosaic_name);
-    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-    nwrite[0] = 1;
-    for(n=0; n<ntiles; n++) {
-      start[0] = n; nwrite[1] = strlen(tile_name[n]);
-      mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-      nwrite[1] = strlen(tilefile[n]);
-      mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-    }
-
-    for(n=0; n<ncontact; n++) {
-      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-              tile_name[contact_tile2[n]]);
-      start[0] = n; nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-              contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-              contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-      nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-    }
-    mpp_close(fid);
-  }
-
-/* ...................... ocean_mosaic.nc .................*/
-  {
-    char str[STRING], outfile[STRING], x_boundary_type1[255]="", y_boundary_type1[255]="";
-    int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-    int id_contact_index, id_griddir, id_gridfiles, dim[2], itmp, fid_old;
-
-    size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-    ntiles = 1, ncontact = 0; 
-
-    sprintf(mosaic_name, "%s_mosaic",ocean_name);
-    sprintf(outfile, "%s.nc", mosaic_name);
-    printf("Writing %s\n", outfile);
-
-    sprintf(tile_name[0], "tile%d", 1);
-    sprintf(tilefile[0], "%s_hgrid.nc", ocean_name);
-    
-    /* ........... Read Boundary Type ................ */
-    fid_old = mpp_open(old_file, MPP_READ);
-    mpp_get_global_att(fid_old, "x_boundary_type",x_boundary_type1);
-    mpp_get_global_att(fid_old, "y_boundary_type",y_boundary_type1);
-    mpp_close(fid_old);
-    if (strcmp(x_boundary_type1, "cyclic")==0) {
-	n = ncontact; ncontact = ncontact + 1; 
-    	contact_tile1_istart[n]=360; contact_tile1_iend[n]=360; 
-    	contact_tile1_jstart[n]=1; contact_tile1_jend[n]=180; 
-
-    	contact_tile2_istart[n]=1; contact_tile2_iend[n]=1; 
-    	contact_tile2_jstart[n]=1; contact_tile2_jend[n]=180;
-	printf("\t x_boundary_type = %s, ncontact=%d \n",x_boundary_type1,ncontact);
-    }
-    
-    if (strcmp(y_boundary_type1, "fold_north_edge")==0) {
-	n = ncontact; ncontact = ncontact + 1; 
-        contact_tile1_istart[n]=1; contact_tile1_iend[n]=180;
-        contact_tile1_jstart[n]=180; contact_tile1_jend[n]=180;
-
-        contact_tile2_istart[n]=360; contact_tile2_iend[n]=181;
-        contact_tile2_jstart[n]=180; contact_tile2_jend[n]=180;
-	printf("\t y_boundary_type = %s, ncontact=%d \n",y_boundary_type1,ncontact);
-    }
-
-    fid = mpp_open(outfile, MPP_WRITE);
-
-//--------Initilize values --------------
-
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-
-    id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-                            "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-                            "children", "gridtiles", "contact_regions", "contacts",
-                            "grid_descriptor", grid_descriptor);
-    dim[0] = dim_ntiles; dim[1] = dim_string;
-    id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-                               "standard_name", "grid_file_location");
-    id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-    id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-    if(ncontact>0) {
-      dim[0] = dim_ncontact; dim[1] = dim_string;
-      id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-                                "contact_type", "boundary", "alignment", "true",
-                                "contact_index", "contact_index", "orientation", "orient");
-      id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-                                     "starting_ending_point_index_of_contact");
-
-    }
-
-    //mpp_def_global(fid, "history", history);
-    mpp_end_def(fid);
-
-    /* write out data */
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-    nwrite[0] = strlen(mosaic_name);
-    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-    nwrite[0] = 1;
-    for(n=0; n<ntiles; n++) {
-      start[0] = n; nwrite[1] = strlen(tile_name[n]);
-      mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-      nwrite[1] = strlen(tilefile[n]);
-      mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-    }
-
-    for(n=0; n<ncontact; n++) {
-      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-              tile_name[contact_tile2[n]]);
-      start[0] = n; nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-              contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-              contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-      nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-    }
-    mpp_close(fid);
-  }
-/* ...................... atmosXland.nc .................*/
-  if(is_coupled_grid)  {
-  const char version[] = "0.2";
-  char lxo_file[STRING], axo_file[STRING], axl_file[STRING];
-  char amosaic_file[STRING], lmosaic_file[STRING], omosaic_file[STRING];
-  char otopog_file[STRING];
-
-  char atile_name[255], ltile_name[255], otile_name[255];
-  char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-  int  fid_old, vid;
-  
-  strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-  strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-    int no, nl, na, n;
-    size_t  naxl, naxo, naxl_step;
-    int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-    int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-    int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-    double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-    double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-    double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-
-    fid_old = mpp_open(old_file, MPP_READ);
-    naxl = mpp_get_dimlen(fid_old, "i_atmXlnd");
-//----------------
- 
-      /* write out atmXlnd data*/
-        if(naxl>0) {
-          size_t start[4], nwrite[4];
-                                                                                                                                                          
-          int fid, dim_string, dim_ncells, dim_two, dims[4];
-          int id_xgrid_area, id_contact, n;
-          int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-          char contact[STRING];
-                                                                                                                                                          
-          for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-          }
-          sprintf(axl_file, "%s_mosaicX%s_mosaic.nc", amosaic_name, lmosaic_name);
-          printf("Writing %s_mosaicX%s_mosaic.nc\n", amosaic_name, lmosaic_name);
-          sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", amosaic_name, atile_name, lmosaic_name, ltile_name);
-          fid = mpp_open(axl_file, MPP_WRITE);
-          //mpp_def_global(fid, "history", history);
-          dim_string = mpp_def_dim(fid, "string", STRING);
-          dim_ncells = mpp_def_dim(fid, "ncells", naxl);
-          dim_two    = mpp_def_dim(fid, "two", 2);
-          if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-                                     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-          }
-          else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-          }
-                                                                                                                                                          
-          dims[0] = dim_ncells; dims[1] = dim_two;
-          id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-          id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-          id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-                                       "exchange_grid_area", "units", "m2");
-          if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-          }
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) {start[i] = 0; nwrite[i] = 1;}
-	  nwrite[0] = strlen(contact);
-          mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-          nwrite[0] = naxl;
-
-          atmxlnd_area = (double *)malloc(naxl*sizeof(double)); 
-          atmxlnd_ia   = (int    *)malloc(naxl*sizeof(int   )); 
-          atmxlnd_ja   = (int    *)malloc(naxl*sizeof(int   )); 
-          atmxlnd_il   = (int    *)malloc(naxl*sizeof(int   )); 
-          atmxlnd_jl   = (int    *)malloc(naxl*sizeof(int   )); 
-	  vid = mpp_get_varid(fid_old, "AREA_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_area);
-	  vid = mpp_get_varid(fid_old, "I_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ia);
-	  vid = mpp_get_varid(fid_old, "J_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ja);
-	  vid = mpp_get_varid(fid_old, "I_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_il);
-	  vid = mpp_get_varid(fid_old, "J_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_jl);
-	  
-	  for(i=0;i<naxl;i++)atmxlnd_area[i] = atmxlnd_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-          mpp_put_var_value(fid, id_xgrid_area, atmxlnd_area);
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxlnd_ia);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxlnd_il);
-          start[1] = 1;
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxlnd_ja);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxlnd_jl);
-          if(interp_order == 2) {
-            atmxlnd_di = (double *)malloc(naxl*sizeof(double)); 
-            atmxlnd_dj = (double *)malloc(naxl*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_di);
-	    vid = mpp_get_varid(fid_old, "DJ_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxlnd_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxlnd_dj);
-          }
-	  
-          mpp_close(fid);
-          free(atmxlnd_area);
-        }
-	mpp_close(fid_old);
-  }
-/* ...................... atmosXocean.nc .................*/
-  if(is_coupled_grid)  {
-  const char version[] = "0.2";
-  char lxo_file[STRING];
-  char axo_file[STRING];
-  char axl_file[STRING];
-  char amosaic_file[STRING];
-  char lmosaic_file[STRING];
-  char omosaic_file[STRING];
-  char otopog_file[STRING];
-
-  char atile_name[255], ltile_name[255], otile_name[255];
-  char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-
-  strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-  strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-    int no, nl, na, n;
-    size_t  naxl, naxo, naxl_step;
-    int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-    int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-    int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-    double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-    double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-    double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-    int fid_old, vid;
-
-    fid_old = mpp_open(old_file, MPP_READ);
-    naxo = mpp_get_dimlen(fid_old, "i_atmXocn");
-//----------------
- 
-      /* write out atmXlnd data*/
-        if(naxo>0) {
-          size_t start[4], nwrite[4];
-                                                                                                                                                          
-          int fid, dim_string, dim_ncells, dim_two, dims[4];
-          int id_xgrid_area, id_contact, n;
-          int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-          char contact[STRING];
-                                                                                                                                                          
-          for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-          }
-          sprintf(axo_file, "%s_mosaicX%s_mosaic.nc", amosaic_name, omosaic_name);
-          printf("Writing %s_mosaicX%s_mosaic.nc\n", amosaic_name, omosaic_name);
-          sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", amosaic_name, atile_name, omosaic_name, otile_name);
-          fid = mpp_open(axo_file, MPP_WRITE);
-          //mpp_def_global(fid, "history", history);
-          dim_string = mpp_def_dim(fid, "string", STRING);
-          dim_ncells = mpp_def_dim(fid, "ncells", naxo);
-          dim_two    = mpp_def_dim(fid, "two", 2);
-          if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-                                     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-          }
-          else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-          }
-                                                                                                                                                          
-          dims[0] = dim_ncells; dims[1] = dim_two;
-          id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-          id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-          id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-                                       "exchange_grid_area", "units", "m2");
-          if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-          }
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1;}
-	  nwrite[0] = strlen(contact);
-          mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-          nwrite[0] = naxo;
-
-          atmxocn_area = (double *)malloc(naxo*sizeof(double)); 
-          atmxocn_ia   = (int    *)malloc(naxo*sizeof(int   )); 
-          atmxocn_ja   = (int    *)malloc(naxo*sizeof(int   )); 
-          atmxocn_io   = (int    *)malloc(naxo*sizeof(int   )); 
-          atmxocn_jo   = (int    *)malloc(naxo*sizeof(int   )); 
-	  vid = mpp_get_varid(fid_old, "AREA_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_area);
-	  vid = mpp_get_varid(fid_old, "I_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ia);
-	  vid = mpp_get_varid(fid_old, "J_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ja);
-	  vid = mpp_get_varid(fid_old, "I_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_io);
-	  vid = mpp_get_varid(fid_old, "J_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_jo);
-	  
-          for(i=0;i<naxo;i++)atmxocn_area[i] = atmxocn_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-          mpp_put_var_value(fid, id_xgrid_area, atmxocn_area);
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxocn_ia);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxocn_io);
-          start[1] = 1;
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxocn_ja);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxocn_jo);
-          if(interp_order == 2) {
-            atmxocn_di = (double *)malloc(naxo*sizeof(double)); 
-            atmxocn_dj = (double *)malloc(naxo*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_di);
-	    vid = mpp_get_varid(fid_old, "DJ_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxocn_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxocn_dj);
-          }
-          mpp_close(fid);
-          free(atmxocn_area);
-        }
-	mpp_close(fid_old);
-  }
-/* ...................... landXocean.nc .................*/
-  if(is_coupled_grid)  {
-  const char version[] = "0.2";
-  char lxo_file[STRING];
-  char axo_file[STRING];
-  char axl_file[STRING];
-  char amosaic_file[STRING];
-  char lmosaic_file[STRING];
-  char omosaic_file[STRING];
-  char otopog_file[STRING];
-
-  char atile_name[255], ltile_name[255], otile_name[255];
-  char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-
-  strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-  strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-    int no, nl, na, n;
-    size_t  naxl, naxo, nlxo, naxl_step;
-    int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-    int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-    int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-    double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-    double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-    double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-    int     fid_old, vid;
-
-    fid_old = mpp_open(old_file, MPP_READ);
-    nlxo = mpp_get_dimlen(fid_old , "i_lndXocn");
-//----------------
- 
-      /* write out lndXocn data*/
-        if(nlxo>0) {
-          size_t start[4], nwrite[4];
-                                                                                                                                                          
-          int fid, dim_string, dim_ncells, dim_two, dims[4];
-          int id_xgrid_area, id_contact, n;
-          int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-          char contact[STRING];
-                                                                                                                                                          
-          for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-          }
-          sprintf(lxo_file, "%s_mosaicX%s_mosaic.nc", lmosaic_name, omosaic_name);
-          printf("Writing %s_mosaicX%s_mosaic.nc\n", lmosaic_name, omosaic_name);
-          sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", lmosaic_name, ltile_name, omosaic_name, otile_name);
-          fid = mpp_open(lxo_file, MPP_WRITE);
-          //mpp_def_global(fid, "history", history);
-          dim_string = mpp_def_dim(fid, "string", STRING);
-          dim_ncells = mpp_def_dim(fid, "ncells", nlxo);
-          dim_two    = mpp_def_dim(fid, "two", 2);
-          if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-                                     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-          }
-          else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-          }
-                                                                                                                                                          
-          dims[0] = dim_ncells; dims[1] = dim_two;
-          id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-          id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-          id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-                                       "exchange_grid_area", "units", "m2");
-          if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-          }
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1;}
-	  nwrite[0] = strlen(contact);
-          mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-          nwrite[0] = nlxo;
-
-          lndxocn_area = (double *)malloc(nlxo*sizeof(double)); 
-          lndxocn_il   = (int    *)malloc(nlxo*sizeof(int   )); 
-          lndxocn_jl   = (int    *)malloc(nlxo*sizeof(int   )); 
-          lndxocn_io   = (int    *)malloc(nlxo*sizeof(int   )); 
-          lndxocn_jo   = (int    *)malloc(nlxo*sizeof(int   )); 
-	  vid = mpp_get_varid(fid_old, "AREA_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_area);
-	  vid = mpp_get_varid(fid_old, "I_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_il);
-	  vid = mpp_get_varid(fid_old, "J_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jl);
-	  vid = mpp_get_varid(fid_old, "I_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_io);
-	  vid = mpp_get_varid(fid_old, "J_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jo);
-	  
-          for(i=0;i<nlxo;i++)lndxocn_area[i] = lndxocn_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-          mpp_put_var_value(fid, id_xgrid_area, lndxocn_area);
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, lndxocn_il);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, lndxocn_io);
-          start[1] = 1;
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, lndxocn_jl);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, lndxocn_jo);
-          if(interp_order == 2) {
-            lndxocn_di = (double *)malloc(nlxo*sizeof(double)); 
-            lndxocn_dj = (double *)malloc(nlxo*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_di);
-	    vid = mpp_get_varid(fid_old, "DJ_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, lndxocn_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, lndxocn_dj);
-          }
-          mpp_close(fid);
-          free(lndxocn_area);
-        }
-	mpp_close(fid_old);
-  }
-
-/* ...................... mosaic.nc .................*/
-  {
-  const char version[] = "0.2";
-  char lxo_file[STRING], axo_file[STRING], axl_file[STRING], mosaic_file[STRING];
-  char amosaic_file[STRING], lmosaic_file[STRING], omosaic_file[STRING];
-  char amosaic_name[STRING], lmosaic_name[STRING], omosaic_name[STRING];
-  char otopog_file[STRING];
-
-    int fid, dim_string, dim_axo, dim_lxo, dim_axl, dims[4], n;
-    size_t start[4], nwrite[4];
-    int id_lmosaic_dir, id_lmosaic_file, id_omosaic_dir, id_omosaic_file;
-    int id_amosaic_dir, id_amosaic_file, id_otopog_dir, id_otopog_file;
-    int id_xgrids_dir, id_axo_file, id_lxo_file, id_axl_file;
-    int id_amosaic, id_lmosaic, id_omosaic;
-
-    int nfile_axo = 1, nfile_axl = 1, nfile_lxo = 1; 
-
-    strcpy(mosaic_file,"mosaic.nc");
-    printf("Writing %s\n", mosaic_file);
-
-    fid = mpp_open(mosaic_file, MPP_WRITE);
-  //  mpp_def_global(fid, "history", history);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-    dim_axo = mpp_def_dim(fid, "nfile_aXo", nfile_axo);
-    dim_axl = mpp_def_dim(fid, "nfile_aXl", nfile_axl);
-    dim_lxo = mpp_def_dim(fid, "nfile_lXo", nfile_lxo);
-    id_amosaic_dir  = mpp_def_var(fid, "atm_mosaic_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_atmosphere_mosaic");
-    id_amosaic_file = mpp_def_var(fid, "atm_mosaic_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "atmosphere_mosaic_file_name");
-    id_amosaic      = mpp_def_var(fid, "atm_mosaic", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "atmosphere_mosaic_name");
-    id_lmosaic_dir  = mpp_def_var(fid, "lnd_mosaic_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_land_mosaic");
-    id_lmosaic_file = mpp_def_var(fid, "lnd_mosaic_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "land_mosaic_file_name");
-    id_lmosaic      = mpp_def_var(fid, "lnd_mosaic", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "land_mosaic_name");
-    id_omosaic_dir  = mpp_def_var(fid, "ocn_mosaic_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_ocean_mosaic");
-    id_omosaic_file = mpp_def_var(fid, "ocn_mosaic_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "ocean_mosaic_file_name");
-    id_omosaic      = mpp_def_var(fid, "ocn_mosaic", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "ocean_mosaic_name");
-    id_otopog_dir   = mpp_def_var(fid, "ocn_topog_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_ocean_topog");
-    id_otopog_file  = mpp_def_var(fid, "ocn_topog_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "ocean_topog_file_name");
-    /* since exchange grid is created in this tool, we may add command line option to specify where to store the output */
-    /*    id_xgrids_dir = mpp_def_var(fid, "xgrids_dir", MPP_CHAR, 1, &dim_string,
-          1, "standard_name", "directory_storing_xgrids"); */
-    dims[0] = dim_axo; dims[1] = dim_string;
-    id_axo_file = mpp_def_var(fid, "aXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXocn_exchange_grid_file");
-    dims[0] = dim_axl; dims[1] = dim_string;
-    id_axl_file = mpp_def_var(fid, "aXl_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXlnd_exchange_grid_file");
-    dims[0] = dim_lxo; dims[1] = dim_string;
-    id_lxo_file = mpp_def_var(fid, "lXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "lndXocn_exchange_grid_file");
-    mpp_end_def(fid);
-
-strcpy(otopog_file,"topog.nc");
-
-sprintf(amosaic_name,"%s_mosaic",atmos_name); sprintf(lmosaic_name,"%s_mosaic",land_name); sprintf(omosaic_name,"%s_mosaic",ocean_name);
-sprintf(amosaic_file,"%s.nc",amosaic_name); sprintf(lmosaic_file,"%s.nc",lmosaic_name); sprintf(omosaic_file,"%s.nc",omosaic_name);
-
-sprintf(axl_file,"%sX%s.nc", amosaic_name, lmosaic_name); 
-sprintf(axo_file,"%sX%s.nc", amosaic_name, omosaic_name); 
-sprintf(lxo_file,"%sX%s.nc", lmosaic_name, omosaic_name); 
-
-    for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; }
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_amosaic_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(amosaic_file);
-    mpp_put_var_value_block(fid, id_amosaic_file, start, nwrite, amosaic_file);
-    nwrite[0] = strlen(amosaic_name);
-    mpp_put_var_value_block(fid, id_amosaic, start, nwrite, amosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_lmosaic_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(lmosaic_file);
-    mpp_put_var_value_block(fid, id_lmosaic_file, start, nwrite, lmosaic_file);
-    nwrite[0] = strlen(lmosaic_name);
-    mpp_put_var_value_block(fid, id_lmosaic, start, nwrite, lmosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_omosaic_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(omosaic_file);
-    mpp_put_var_value_block(fid, id_omosaic_file, start, nwrite, omosaic_file);
-    nwrite[0] = strlen(omosaic_name);
-    mpp_put_var_value_block(fid, id_omosaic, start, nwrite, omosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_otopog_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(otopog_file);
-    mpp_put_var_value_block(fid, id_otopog_file, start, nwrite, otopog_file);
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-      start[0] = 0; nwrite[1] = strlen(axo_file);
-      mpp_put_var_value_block(fid, id_axo_file, start, nwrite, axo_file);
-
-      start[0] = 0; nwrite[1] = strlen(axl_file);
-      mpp_put_var_value_block(fid, id_axl_file, start, nwrite, axl_file);
-
-      start[0] = 0; nwrite[1] = strlen(lxo_file);
-      mpp_put_var_value_block(fid, id_lxo_file, start, nwrite, lxo_file);
-    mpp_close(fid);
-  }
-
-
-
-  return;
-  mpp_end();
-  
-};  /* end of main */
-
diff --git a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.am b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.am
deleted file mode 100644
index ab633ca..0000000
--- a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-## This is an automake file, part of Unidata's NetCDF CF Library
-## package. Copyright 2009, see the COPYRIGHT file for more
-## information.
-
-# This automake file is in charge of building the gridspec
-# transfer_to_mosaic tool.
-
-# $Id: Makefile.am,v 1.3 2009/04/08 16:50:35 ed Exp $
-
-bin_PROGRAMS = transfer_to_mosaic gs_transfer_to_mosaic
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic
-AM_LDFLAGS = -L../shared -L../../shared/mosaic
-
-# If the user specified a root location for NETCDF, use it.
-if USE_NETCDF_DIR
-AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
-AM_LDFLAGS += -L at NETCDFDIR@/lib
-endif
-
-# If the user specified a root location for HDF5, use it.
-if USE_HDF5_DIR
-AM_CPPFLAGS += -I at HDF5DIR@/include
-AM_LDFLAGS += -L at HDF5DIR@/lib
-endif
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
-
diff --git a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.in b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.in
deleted file mode 100644
index e04fd7a..0000000
--- a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.in
+++ /dev/null
@@ -1,523 +0,0 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
- at SET_MAKE@
-
-# This automake file is in charge of building the gridspec
-# transfer_to_mosaic tool.
-
-# $Id: Makefile.am,v 1.3 2009/04/08 16:50:35 ed Exp $
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-bin_PROGRAMS = transfer_to_mosaic$(EXEEXT) \
-	gs_transfer_to_mosaic$(EXEEXT)
-
-# If the user specified a root location for NETCDF, use it.
- at USE_NETCDF_DIR_TRUE@am__append_1 = -I at NETCDFDIR@/include
- at USE_NETCDF_DIR_TRUE@am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_5 = -lhdf5_hl -lhdf5 -lz
-subdir = gridspec_tools_20080702/tools/transfer_to_mosaic_grid
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
-	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
-	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
-	$(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
-CONFIG_CLEAN_FILES =
-am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-PROGRAMS = $(bin_PROGRAMS)
-gs_transfer_to_mosaic_SOURCES = gs_transfer_to_mosaic.c
-gs_transfer_to_mosaic_OBJECTS = gs_transfer_to_mosaic.$(OBJEXT)
-gs_transfer_to_mosaic_LDADD = $(LDADD)
-am__DEPENDENCIES_1 =
-gs_transfer_to_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1)
-transfer_to_mosaic_SOURCES = transfer_to_mosaic.c
-transfer_to_mosaic_OBJECTS = transfer_to_mosaic.$(OBJEXT)
-transfer_to_mosaic_LDADD = $(LDADD)
-transfer_to_mosaic_DEPENDENCIES = $(am__DEPENDENCIES_1)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
-SOURCES = gs_transfer_to_mosaic.c transfer_to_mosaic.c
-DIST_SOURCES = gs_transfer_to_mosaic.c transfer_to_mosaic.c
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ALLOCA = @ALLOCA@
-AMTAR = @AMTAR@
-AR = @AR@
-AS = @AS@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DLLTOOL = @DLLTOOL@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FC = @FC@
-FCFLAGS = @FCFLAGS@
-FFLAGS = @FFLAGS@
-FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
-GREP = @GREP@
-HDF5DIR = @HDF5DIR@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LD = @LD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIPO = @LIPO@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
-MKDIR_P = @MKDIR_P@
-NETCDFDIR = @NETCDFDIR@
-NM = @NM@
-NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-RANLIB = @RANLIB@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WHATIS = @WHATIS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-ac_ct_F77 = @ac_ct_F77@
-ac_ct_FC = @ac_ct_FC@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-prog = @prog@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-
-# Initalize these.
-AM_CPPFLAGS = -I../shared -I../../shared/mosaic $(am__append_1) \
-	$(am__append_3)
-AM_LDFLAGS = -L../shared -L../../shared/mosaic $(am__append_2) \
-	$(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
-
-# We need the netCDF library, of course!
-LDADD = -ltoolsshared -lshared -lnetcdf $(am__append_5)
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
-	@for dep in $?; do \
-	  case '$(am__configure_deps)' in \
-	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
-	      exit 1;; \
-	  esac; \
-	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	@case '$?' in \
-	  *config.status*) \
-	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
-	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
-	esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure:  $(am__configure_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
-	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-install-binPROGRAMS: $(bin_PROGRAMS)
-	@$(NORMAL_INSTALL)
-	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  if test -f $$p \
-	     || test -f $$p1 \
-	  ; then \
-	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
-	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
-	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
-	  else :; fi; \
-	done
-
-uninstall-binPROGRAMS:
-	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
-	done
-
-clean-binPROGRAMS:
-	@list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-gs_transfer_to_mosaic$(EXEEXT): $(gs_transfer_to_mosaic_OBJECTS) $(gs_transfer_to_mosaic_DEPENDENCIES) 
-	@rm -f gs_transfer_to_mosaic$(EXEEXT)
-	$(LINK) $(gs_transfer_to_mosaic_OBJECTS) $(gs_transfer_to_mosaic_LDADD) $(LIBS)
-transfer_to_mosaic$(EXEEXT): $(transfer_to_mosaic_OBJECTS) $(transfer_to_mosaic_DEPENDENCIES) 
-	@rm -f transfer_to_mosaic$(EXEEXT)
-	$(LINK) $(transfer_to_mosaic_OBJECTS) $(transfer_to_mosaic_LDADD) $(LIBS)
-
-mostlyclean-compile:
-	-rm -f *.$(OBJEXT)
-
-distclean-compile:
-	-rm -f *.tab.c
-
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_transfer_to_mosaic.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/transfer_to_mosaic.Po at am__quote@
-
-.c.o:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
-
-.c.obj:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
- at am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.c.lo:
- at am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
- at am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
-	-rm -f *.lo
-
-clean-libtool:
-	-rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
-	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
-	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	tags=; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
-	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
-
-GTAGS:
-	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
-	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	list='$(DISTFILES)'; \
-	  dist_files=`for file in $$list; do echo $$file; done | \
-	  sed -e "s|^$$srcdirstrip/||;t" \
-	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
-	case $$dist_files in \
-	  */*) $(MKDIR_P) `echo "$$dist_files" | \
-			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
-			   sort -u` ;; \
-	esac; \
-	for file in $$dist_files; do \
-	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  if test -d $$d/$$file; then \
-	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
-	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
-	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
-	    || exit 1; \
-	  fi; \
-	done
-check-am: all-am
-check: check-am
-all-am: Makefile $(PROGRAMS)
-installdirs:
-	for dir in "$(DESTDIR)$(bindir)"; do \
-	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
-	done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-
-maintainer-clean-generic:
-	@echo "This command is intended for maintainers to use"
-	@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
-
-distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-exec-am: install-binPROGRAMS
-
-install-html: install-html-am
-
-install-info: install-info-am
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-ps: install-ps-am
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-binPROGRAMS
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-libtool ctags distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-binPROGRAMS install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am \
-	uninstall-binPROGRAMS
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/gs_transfer_to_mosaic.c b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/gs_transfer_to_mosaic.c
deleted file mode 100644
index 07239d5..0000000
--- a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/gs_transfer_to_mosaic.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include <getopt.h>
-#include "constant.h"
-#include "mpp.h"
-#include "mpp_domain.h"
-#include "mpp_io.h"
-
-const int MAXBOUNDS = 100;
-const int STRINGLEN = 255;
-
-const int MAXTILE = 100;
-const int MAXCONTACT = 100;
-const int SHORTSTRING = 32;
-
-int main(int argc, char* argv[])
-{
-/* ----------------------------- */
-   extern char *optarg;
-   char *pch=NULL, history[512], entry[1280];
-   char tilefile[MAXTILE][STRING], tiletype[MAXTILE][SHORTSTRING];
-   char tile_name[MAXTILE][STRING];
-   int ntiles=0, nfiles=0, ncontact=0;
-   double periodx=0, periody=0;
-   int contact_tile1[MAXCONTACT], contact_tile2[MAXCONTACT];
-   int contact_tile1_istart[MAXCONTACT], contact_tile1_iend[MAXCONTACT];
-   int contact_tile1_jstart[MAXCONTACT], contact_tile1_jend[MAXCONTACT];
-   int contact_tile2_istart[MAXCONTACT], contact_tile2_iend[MAXCONTACT];
-   int contact_tile2_jstart[MAXCONTACT], contact_tile2_jend[MAXCONTACT];
-   char mosaic_name[128] = "atmos_mosaic";
-   char mosaic_dir[256]  = "./" ;
-   char grid_descriptor[128] = "";
-   int c, i, n, m, l, errflg, check=0;
-
-   char atmos_name[128]="atmos", land_name[128]="land", ocean_name[128]="ocean";
-   char agrid_file[128], lgrid_file[128], ogrid_file[128];
-   char *old_file = NULL;
-
-   int is_coupled_grid = 0, is_ocean_only =1; 
-   int interp_order=1;
-   int ret;
-  
-   int option_index;
-   static struct option long_options[] = {
-      {"input_file",       required_argument, NULL, 'o'},
-      {"mosaic_dir",       required_argument, NULL, 'd'},    
-      {NULL, 0, NULL, 0}
-   };
-
-/* ----------------------------- */
-
-   mpp_init(&argc, &argv); /* Initilize */ 
-   //mpp_domain_init();  
-
-   while ((c = getopt_long(argc, argv, "h", long_options, &option_index) ) != -1)
-      switch (c) {
-	 case 'o':
-	    old_file = optarg;
-	    break;
-	 case 'd':
-	    strcpy(mosaic_dir, optarg);
-	    break;
-      }
-
-   if ((ret = gs_transfer_to_mosaic(old_file, mosaic_dir)))
-      return ret;
-
-   mpp_end();
-  
-};  /* end of main */
-
diff --git a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c
deleted file mode 100644
index fecdaf0..0000000
--- a/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c
+++ /dev/null
@@ -1,1278 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include <getopt.h>
-#include "constant.h"
-#include "mpp.h"
-#include "mpp_domain.h"
-#include "mpp_io.h"
-
-const int MAXBOUNDS = 100;
-const int STRINGLEN = 255;
-
-const int MAXTILE = 100;
-const int MAXCONTACT = 100;
-const int SHORTSTRING = 32;
-const char mosaic_version[] = "0.2";
-
-#define PI M_PI
-  
-double *x, *y, *dx, *dy, *area, *angle_dx, *angle_dy; 
-int nx, ny, nxp, nyp;
-char *old_file = NULL;
-
-int main(int argc, char* argv[])
-{
-/* ----------------------------- */
-  extern char *optarg;
-  char *pch=NULL, history[512], entry[1280];
-  char tilefile[MAXTILE][STRING], tiletype[MAXTILE][SHORTSTRING];
-  char tile_name[MAXTILE][STRING];
-  int ntiles=0, nfiles=0, ncontact=0;
-  double periodx=0, periody=0;
-  int contact_tile1[MAXCONTACT], contact_tile2[MAXCONTACT];
-  int contact_tile1_istart[MAXCONTACT], contact_tile1_iend[MAXCONTACT];
-  int contact_tile1_jstart[MAXCONTACT], contact_tile1_jend[MAXCONTACT];
-  int contact_tile2_istart[MAXCONTACT], contact_tile2_iend[MAXCONTACT];
-  int contact_tile2_jstart[MAXCONTACT], contact_tile2_jend[MAXCONTACT];
-  char mosaic_name[128] = "atmos_mosaic";
-  char mosaic_dir[256]  = "./" ;
-  char grid_descriptor[128] = "";
-  int c, i, n, m, l, errflg, check=0;
-
-  char atmos_name[128]="atmos", land_name[128]="land", ocean_name[128]="ocean";
-  char agrid_file[128], lgrid_file[128], ogrid_file[128];
-
-  int is_coupled_grid = 0, is_ocean_only =1; 
-  int interp_order=1;
-  
-  int option_index;
-  static struct option long_options[] = {
-    {"input_file",       required_argument, NULL, 'o'},
-    {"mosaic_dir",       required_argument, NULL, 'd'},    
-    {NULL, 0, NULL, 0}
-  };
-
-/* ----------------------------- */
-
-  mpp_init(&argc, &argv); /* Initilize */ 
-  //mpp_domain_init();  
-
-  while ((c = getopt_long(argc, argv, "h", long_options, &option_index) ) != -1)
-    switch (c) {
-      case 'o':
-	old_file = optarg;
-	break;
-      case 'd':
-        strcpy(mosaic_dir, optarg);
-	break;
-    }
-
-  if(!old_file) mpp_error("Usage:\n \t \t transfer_to_mosaic --input_file input_file.nc");
-  if(mpp_field_exist(old_file, "AREA_ATMxOCN") ) is_coupled_grid = 1;
-  if(mpp_field_exist(old_file, "AREA_ATM") ) is_ocean_only = 0;
-  if(mpp_field_exist(old_file, "DI_ATMxOCN") ) interp_order= 2;
-// -----------------ocean_hgrid.nc---------------------------------[
-// Ocean
-{
-  int nx_C, ny_C, nx_T, ny_T, nvertex;
-  int fid_old, vid;
-  
-  double *x_C, *y_C, *x_T, *y_T;
-  double *x_vert_T, *y_vert_T;
-
-
-  double *ds_00_02_C, *ds_00_20_C, *ds_01_11_C, *ds_01_21_C, *ds_02_22_C, 
-         *ds_10_11_C, *ds_10_12_C, *ds_11_21_C, *ds_11_12_C, *ds_20_22_C, 
-         *ds_01_11_T, *ds_01_21_T, *ds_02_22_T, *ds_10_11_T, *ds_10_12_T, 
-         *ds_11_12_T, *ds_11_21_T, *ds_20_22_T, 
-         *ds_01_21_E, *ds_10_12_N, *angle_C; 
-
- 
-  int i,j,k, i1, i2, j1, j2, k0, k1, k2, k3;
-  int ji, ji0, ji1, ji2, ji3;
-  int j1i1, j1i2, j2i1, j2i2; 
-  double unknown = 0.0; /* double unknown = -1.0E+10; */
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  nx_C = mpp_get_dimlen(fid_old, "grid_x_C");
-  ny_C = mpp_get_dimlen(fid_old, "grid_y_C");
-  nx_T = mpp_get_dimlen(fid_old, "grid_x_T");
-  ny_T = mpp_get_dimlen(fid_old, "grid_y_T");
-  nvertex = mpp_get_dimlen(fid_old, "vertex");
-
-  printf("\nReading file: %s \n", old_file); 
-
-
-/* Reading Ocean Grid Variables */
-  x_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  y_C = (double *) malloc(ny_C * nx_C * sizeof(double));
-  x_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  y_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  x_vert_T = (double *) malloc(nvertex*ny_T*nx_T*sizeof(double));
-  y_vert_T = (double *) malloc(nvertex*ny_T*nx_T*sizeof(double));
-  ds_01_11_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_10_11_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_11_21_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_11_12_C = (double *) malloc(ny_C * nx_C * sizeof(double)); 
-  ds_01_11_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_10_11_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_11_12_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_11_21_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  ds_02_22_T = (double *) malloc(ny_T * nx_T * sizeof(double));  
-  ds_20_22_T = (double *) malloc(ny_T * nx_T * sizeof(double));
-  angle_C    = (double *) malloc(ny_C * nx_C * sizeof(double));
-  
-  vid = mpp_get_varid(fid_old, "x_C"); mpp_get_var_value(fid_old, vid, x_C);
-  vid = mpp_get_varid(fid_old, "y_C"); mpp_get_var_value(fid_old, vid, y_C);
-  vid = mpp_get_varid(fid_old, "x_T"); mpp_get_var_value(fid_old, vid, x_T);
-  vid = mpp_get_varid(fid_old, "y_T"); mpp_get_var_value(fid_old, vid, y_T);
-  vid = mpp_get_varid(fid_old, "x_vert_T"); mpp_get_var_value(fid_old, vid, x_vert_T);
-  vid = mpp_get_varid(fid_old, "y_vert_T"); mpp_get_var_value(fid_old, vid, y_vert_T);
-  vid = mpp_get_varid(fid_old, "ds_01_11_C"); mpp_get_var_value(fid_old, vid, ds_01_11_C);  
-  vid = mpp_get_varid(fid_old, "ds_10_11_C"); mpp_get_var_value(fid_old, vid, ds_10_11_C);
-  vid = mpp_get_varid(fid_old, "ds_11_21_C"); mpp_get_var_value(fid_old, vid, ds_11_21_C);    
-  vid = mpp_get_varid(fid_old, "ds_11_12_C"); mpp_get_var_value(fid_old, vid, ds_11_12_C);
-  vid = mpp_get_varid(fid_old, "ds_01_11_T"); mpp_get_var_value(fid_old, vid, ds_01_11_T);  
-  vid = mpp_get_varid(fid_old, "ds_10_11_T"); mpp_get_var_value(fid_old, vid, ds_10_11_T);
-  vid = mpp_get_varid(fid_old, "ds_11_21_T"); mpp_get_var_value(fid_old, vid, ds_11_21_T);    
-  vid = mpp_get_varid(fid_old, "ds_11_12_T"); mpp_get_var_value(fid_old, vid, ds_11_12_T);  
-  vid = mpp_get_varid(fid_old, "ds_02_22_T"); mpp_get_var_value(fid_old, vid, ds_02_22_T);    
-  vid = mpp_get_varid(fid_old, "ds_20_22_T"); mpp_get_var_value(fid_old, vid, ds_20_22_T);  
-  vid = mpp_get_varid(fid_old, "angle_C"); mpp_get_var_value(fid_old, vid, angle_C);  
-  mpp_close(fid_old);
-  
-  nx = 2*nx_T;  nxp = nx +1;
-  ny = 2*ny_T;  nyp = ny +1;
-  x = (double *) malloc(nxp*nyp * sizeof(double));
-  y = (double *) malloc(nxp*nyp* sizeof(double));
-  dx = (double *) malloc(nx*nyp * sizeof(double));
-  dy = (double *) malloc(nxp*ny * sizeof(double));
-  area = (double *) malloc(nx*ny * sizeof(double));
-  angle_dx = (double *) malloc(nxp*nyp * sizeof(double));
-
-  for(j = 0; j<ny_T; j++) {
-  for(i = 0; i<nx_T; i++) {
-
-	i2=2*(i+1); i1=i2-1;   j2=2*(j+1); j1=j2-1;
-
-  	j1i1=j1*nxp+i1; j1i2=j1*nxp+i2; j2i2=j2*nxp+i2; j2i1=j2*nxp+i1; 
-	ji=j*nx_T+i;
-	ji0=ji; ji1=ji0+nx_T*ny_T; ji2=ji1+nx_T*ny_T; ji3=ji2+nx_T*ny_T;
-
-        x[j1i1] = x_T[ji];
-        x[j1i2] = 0.5*(x_vert_T[ji1]+x_vert_T[ji2]);
-        x[j2i2] = x_vert_T[ji2];
-        x[j2i1] = 0.5*(x_vert_T[ji3]+x_vert_T[ji2]);
-
-        y[j1i1] = y_T[ji];
-        y[j1i2] = 0.5*(y_vert_T[ji1]+y_vert_T[ji2]);
-        y[j2i2] = y_vert_T[ji2];
-        y[j2i1] = 0.5*(y_vert_T[ji3]+y_vert_T[ji2]);
-
-/*      Mapping distance to new mosaic grid format from old grid
-
-	       dx(1,1)=                  dx(2,1)=           
-   Ci-1,j------ds_11_21_C(i-1,j)---+-----ds_01_11_C(i,j)--------Ci,j
-	|                          |                            |
-	|                          |                            |
-	|                          |                            |
-	|                     ds_11_12_T                   ds_10_11_C(i,j)
-	|                          |                            |
-	|         dx(1,1)=         |          dx(2,1)=          |
-	+---------ds_01_11_T------Tij---------ds_11_21_T--------+
-	|                          |                            |
-	|                          |                            |
-	|                          |                            |
-	|                     ds_11_12_T                   ds_11_12_C(i,j-1)
-	|                          |                            |
-	|                          |                            |
- Ci-1,j-1--------------------------+----------------------------Ci,j-1
-
-*/
-	dx[(2*j+1)*nx  + (2*i)]   = ds_01_11_T[j*nx_T + i];
-	dx[(2*j+1)*nx  + (2*i+1)] = ds_11_21_T[j*nx_T + i];
-	if(i>0) dx[(2*j+2)*nx  + (2*i)]   = ds_11_21_C[j*nx_T + (i-1)];
-	dx[(2*j+2)*nx  + (2*i+1)] = ds_01_11_C[j*nx_T + i];
-
-	dy[(2*j  )*nxp + (2*i+1)]   = ds_10_11_T[j*nx_T + i];
-	if(j>0) dy[(2*j  )*nxp + (2*i+2)]   = ds_11_12_C[(j-1)*nx_T + i];
-	dy[(2*j+1)*nxp + (2*i+1)]   = ds_11_12_T[j*nx_T + i];
-	dy[(2*j+1)*nxp + (2*i+2)]   = ds_10_11_C[j*nx_T + i];
-
-	angle_dx[(2*j+1)*nxp + 2*i+1] = unknown;
-	angle_dx[(2*j+1)*nxp + 2*i+2] = unknown;
-	angle_dx[(2*j+2)*nxp + 2*i+1] = unknown;
-	angle_dx[(2*j+2)*nxp + 2*i+2] = angle_C[j*nx_C + i ]; 
-
-	if (j==0) {
-           x[i1] = 0.5*(x_vert_T[ji0]+x_vert_T[ji1]);
-           x[i2] = x_vert_T[ji1];
-           y[i1] = 0.5*(y_vert_T[ji0]+y_vert_T[ji1]);
-           y[i2] = y_vert_T[ji1];
-
-	   dx[ (2*i+0)] = unknown;
-	   dx[ (2*i+1)] = unknown;
-	   /* dy[(2*j  )*nxp + (2*i+2)]   = unknown; */
-	   dy[(2*j  )*nxp + (2*i+2)]   = ds_20_22_T[j*nx_T + i] - ds_10_11_C[j*nx_T + i];
-
-	   angle_dx[2*i+1] = unknown;
-	   angle_dx[2*i+2] = unknown;
-	}
-
-	if (i==0) {
-           x[j1*nxp] = 0.5*(x_vert_T[ji0]+x_vert_T[ji3]);
-           x[j2*nxp] = x_vert_T[ji3];
-           y[j1*nxp] = 0.5*(y_vert_T[ji0]+y_vert_T[ji3]);
-           y[j2*nxp] = y_vert_T[ji3];
-
-	   /* dx[(2*j+2)*nx  + (2*i)]   = unknown;*/
-	   dx[(2*j+2)*nx  + (2*i)]   = ds_02_22_T[j*nx_T + i] - ds_01_11_C[j*nx_T + i];
-	   dy[(2*j  )*nxp ]    = unknown;
-	   dy[(2*j+1)*nxp ]    = unknown;
-
-  	   angle_dx[(2*j+1)*nxp] = unknown;
-  	   angle_dx[(2*j+2)*nxp] = unknown;
-	}
-	if (i==0 && j==0) {
-           x[0] = x_vert_T[ji0]; y[0] = y_vert_T[ji0];
-  	   angle_dx[0] = unknown;
-	}
-
-  }
-  }
-
-  //for(j = 0; j<nyp; j++) { for(i = 0; i<nxp; i++) { if(angle_dx[j*nxp+i]>0.0) printf("%d %d %f\n ",i,j,angle_dx[j*nxp+i]); } }
-  //for(j = 0; j<ny_T; j++) { printf("%f ",y_C[j*nx_T+(nx_T+0)/4]); }
-  //for(i = 0; i<nx_T; i++) { if(y_T[(ny_T-1)*nx_T+i]>85.) printf("%f ",y_T[(ny_T-1)*nx_T+i]); }
-  //printf("\n\n");
-  //for(j = 0; j<nyp; j++) { printf("%f ",y[j*nxp+(nxp-1)/4]); }
-  //for(i = 0; i<nxp; i++) { if(y[(nyp-1)*nxp+i]>85.) printf("%f ",y[(nyp-1)*nxp+i]); }
-
-
-  /* write ocean-grid data */
-  /*-------ocean_hgrid.nc-------*/
-  {
-    int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-    int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-    char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-    char outfile[128] = "", tilename[128]="";
-    size_t start[4], nwrite[4];
-    
-	  sprintf(outfile, "%s_hgrid.nc",ocean_name);
-	  printf("Writing %s\n", outfile);
-          printf("\t nx_C=%d, ny_C=%d, x_T=%d, ny_T=%d \n", nx_C, ny_C,nx_T, ny_T); 
-          sprintf(tilename, "tile%d", 1);
-          fid = mpp_open(outfile, MPP_WRITE);
-
-          dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-          dimlist[1] = mpp_def_dim(fid, "nxp", nxp);
-          dimlist[2] = mpp_def_dim(fid, "nyp", nyp);
-          dimlist[3] = mpp_def_dim(fid, "nx", nx);
-          dimlist[4] = mpp_def_dim(fid, "ny", ny);
-
-          id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec",
-                                "tile_spec_version", tile_spec_version, "geometry", geometry,
-                                "discretization", discretization, "conformal", conformal );
-
-
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude",
-                             "units", "degree_east");
-          id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude",
-                             "units", "degree_north");
-
-          dims[0] = dimlist[2]; dims[1] = dimlist[3];
-          id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance",
-                             "units", "meters");
-          dims[0] = dimlist[4]; dims[1] = dimlist[1];
-          id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance",
-                             "units", "meters");
-
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-                             "units", "degrees_east");
-
-          dims[0] = dimlist[4]; dims[1] = dimlist[3];
-          id_area= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area",
-                             "units", "m2");
-
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	  nwrite[0] = strlen(tilename);
-	  mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-          mpp_put_var_value(fid, id_x, x);
-          mpp_put_var_value(fid, id_y, y);
-          mpp_put_var_value(fid, id_dx, dx);
-          mpp_put_var_value(fid, id_dy, dy);
-          mpp_put_var_value(fid, id_angle_dx, angle_dx);
-          mpp_close(fid);
-  }
-}
-// ----------------------------------------------------------------]
-// -----------------atmos_hgrid.nc---------------------------------[
-// Atmosphere
-  int nxba, nyba, nxta, nyta, nxap, nyap;
-if(is_coupled_grid) {
-  double *x_atmos, *y_atmos;
-  double *xba, *yba, *xta, *yta;
-  int i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  nxba = mpp_get_dimlen(fid_old, "xba");
-  nyba = mpp_get_dimlen(fid_old, "yba");
-  nxta = mpp_get_dimlen(fid_old, "xta");
-  nyta = mpp_get_dimlen(fid_old, "yta");
-  xba = (double *) malloc(nxba * sizeof(double)); 
-  yba = (double *) malloc(nyba * sizeof(double)); 
-  xta = (double *) malloc(nxta * sizeof(double)); 
-  yta = (double *) malloc(nyta * sizeof(double)); 
-  vid = mpp_get_varid(fid_old, "xba"); mpp_get_var_value(fid_old, vid, xba);
-  vid = mpp_get_varid(fid_old, "yba"); mpp_get_var_value(fid_old, vid, yba);
-  vid = mpp_get_varid(fid_old, "xta"); mpp_get_var_value(fid_old, vid, xta);
-  vid = mpp_get_varid(fid_old, "yta"); mpp_get_var_value(fid_old, vid, yta);
-  mpp_close(fid_old);
-  
-  nxap = nxba + nxta; nyap = nyba + nyta; 
-  x_atmos = (double *) malloc(nxap*nyap * sizeof(double));
-  y_atmos = (double *) malloc(nxap*nyap * sizeof(double));
-
-  for(i = 0; i<nxba; i++) x_atmos[2*i]   = xba[i]; for(i = 0; i<nxta; i++) x_atmos[2*i+1]   = xta[i]; 
-
-  for(j = 0; j<nyba; j++) y_atmos[2*j*nxap]   = yba[j]; 
-  for(j = 0; j<nyta; j++) y_atmos[(2*j+1)*nxap]   = yta[j]; 
-
-  for(j = 1; j<nyap; j++) for(i = 0; i<nxap; i++) x_atmos[j*nxap + i]   = x_atmos[i];
-  for(i = 1; i<nxap; i++) for(j = 0; j<nyap; j++) y_atmos[j*nxap + i]   = y_atmos[j*nxap];
-
-  /* write Atmosphere-grid data */
-  {
-    int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-    int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-    char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-    char outfile[128] = "", tilename[128]="";
-    size_t start[4], nwrite[4];
-    
-          sprintf(outfile, "%s_hgrid.nc", atmos_name);
-	  printf("Writing %s\n", outfile);
-          printf("\t nxba=%d, nyba=%d, nxta=%d, nyta=%d \n", nxba, nyba,nxta, nyta); 
-
-          sprintf(tilename, "tile%d", 1);
-          fid = mpp_open(outfile, MPP_WRITE);
-          dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-          dimlist[1] = mpp_def_dim(fid, "nxp", nxap);
-          dimlist[2] = mpp_def_dim(fid, "nyp", nyap);
-          dimlist[3] = mpp_def_dim(fid, "nx", nxap-1);
-          dimlist[4] = mpp_def_dim(fid, "ny", nyap-1);
-          id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec", "tile_spec_version", 
-			tile_spec_version, "geometry", geometry, "discretization", discretization, "conformal", conformal );
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude", "units", "degree_east");
-          id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude", "units", "degree_north");
-
-          /* Following variables are not defined */
-          dims[0] = dimlist[2]; dims[1] = dimlist[3];
-          id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance", "units", "meters");
-          dims[0] = dimlist[4]; dims[1] = dimlist[1];
-          id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance", "units", "meters");
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-                             "units", "degrees_east");
-          dims[0] = dimlist[4]; dims[1] = dimlist[3];
-          id_angle_dx= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area", "units", "m2");
-	  /* ------------------------------------------- */
-          mpp_end_def(fid);
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	  nwrite[0] = strlen(tilename);
-          mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-          mpp_put_var_value(fid, id_x, x_atmos);
-          mpp_put_var_value(fid, id_y, y_atmos);
-          mpp_close(fid);
-  }
-  free(xba); free(yba); free(xta); free(yta);  free(x_atmos); free(y_atmos);
-}
-// ----------------------------------------------------------------]
-
-//.................. Land .......................
-//..................land_hgrid.nc................
- int nxbl, nybl, nxtl, nytl,  nxlp, nylp;
-if(is_coupled_grid){
-  double *x_land, *y_land;
-  double *xbl, *ybl, *xtl, *ytl;
-  int i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  
-  nxbl = mpp_get_dimlen(fid_old, "xbl");
-  nybl = mpp_get_dimlen(fid_old, "ybl");
-  nxtl = mpp_get_dimlen(fid_old, "xtl");
-  nytl = mpp_get_dimlen(fid_old, "ytl");
-  xbl = (double *) malloc(nxbl * sizeof(double)); 
-  ybl = (double *) malloc(nybl * sizeof(double)); 
-  xtl = (double *) malloc(nxtl * sizeof(double)); 
-  ytl = (double *) malloc(nytl * sizeof(double)); 
-  vid = mpp_get_varid(fid_old, "xbl"); mpp_get_var_value(fid_old, vid, xbl);
-  vid = mpp_get_varid(fid_old, "ybl"); mpp_get_var_value(fid_old, vid, ybl);
-  vid = mpp_get_varid(fid_old, "xtl"); mpp_get_var_value(fid_old, vid, xtl);
-  vid = mpp_get_varid(fid_old, "ytl"); mpp_get_var_value(fid_old, vid, ytl);
-  mpp_close(fid_old);
-  
-  nxlp = nxbl + nxtl; nylp = nybl + nytl; 
-  x_land  = (double *) malloc(nxlp*nylp * sizeof(double));
-  y_land  = (double *) malloc(nxlp*nylp * sizeof(double));
-  
-  for(i = 0; i<nxbl; i++) x_land[2*i]   = xbl[i]; 
-  for(i = 0; i<nxtl; i++) x_land[2*i+1]   = xtl[i]; 
-
-  for(j = 0; j<nybl; j++) y_land[2*j*nxlp]   = ybl[j]; 
-  for(j = 0; j<nytl; j++) y_land[(2*j+1)*nxlp]   = ytl[j]; 
-
-  for(j = 1; j<nylp; j++) for(i = 0; i<nxlp; i++) x_land[j*nxlp + i]   = x_land[i];
-
-  for(i = 1; i<nxlp; i++) 
-	for(j = 0; j<nylp; j++) 
-		y_land[j*nxlp + i]   = y_land[j*nxlp];
-
-  /* write Land-grid data */
-  {
-    int fid, id_tile, id_x, id_y, id_dx, id_dy, id_area, id_angle_dx, id_angle_dy, id_arcx;
-    int dimlist[5], dims[2], i, j, l, ni, nj, nip, njp;
-    char tile_spec_version[] = "0.2", geometry[] = "spherical", discretization[] = "logically_rectangular", conformal[]="true";
-    char outfile[128] = "", tilename[128]="";
-    size_t start[4], nwrite[4];
-    
-          sprintf(outfile, "%s_hgrid.nc",land_name);
-	  printf("Writing %s\n", outfile);
-          printf("\t nxbl=%d, nybl=%d, nxtl=%d, nytl=%d \n", nxbl, nybl,nxtl, nytl); 
-
-          sprintf(tilename, "tile%d", 1);
-        fid = mpp_open(outfile, MPP_WRITE);
-          dimlist[0] = mpp_def_dim(fid, "string", STRINGLEN);
-          dimlist[1] = mpp_def_dim(fid, "nxp", nxlp);
-          dimlist[2] = mpp_def_dim(fid, "nyp", nylp);
-          dimlist[3] = mpp_def_dim(fid, "nx", nxlp-1);
-          dimlist[4] = mpp_def_dim(fid, "ny", nylp-1);
-          id_tile = mpp_def_var(fid, "tile", MPP_CHAR, 1, dimlist, 5, "standard_name", "grid_tile_spec", "tile_spec_version", 
-			tile_spec_version, "geometry", geometry, "discretization", discretization, "conformal", conformal );
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_x = mpp_def_var(fid, "x", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_longitude", "units", "degree_east");
-          id_y = mpp_def_var(fid, "y", MPP_DOUBLE, 2, dims, 2, "standard_name", "geographic_latitude", "units", "degree_north");
-
-          /* Following variables are not defined */
-          dims[0] = dimlist[2]; dims[1] = dimlist[3];
-          id_dx = mpp_def_var(fid, "dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_x_distance", "units", "meters");
-          dims[0] = dimlist[4]; dims[1] = dimlist[1];
-          id_dy = mpp_def_var(fid, "dy", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_edge_y_distance", "units", "meters");
-          dims[0] = dimlist[2]; dims[1] = dimlist[1];
-          id_angle_dx= mpp_def_var(fid, "angle_dx", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_vertex_x_angle_WRT_geographic_east",
-                             "units", "degrees_east");
-          dims[0] = dimlist[4]; dims[1] = dimlist[3];
-          id_angle_dx= mpp_def_var(fid, "area", MPP_DOUBLE, 2, dims, 2, "standard_name", "grid_cell_area", "units", "m2");
-          /* ------------------------------------------- */
-
-          mpp_end_def(fid);
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 0; }
-	  nwrite[0] = strlen(tilename);
-          mpp_put_var_value_block(fid, id_tile, start, nwrite, tilename );
-          mpp_put_var_value(fid, id_x, x_land);
-          mpp_put_var_value(fid, id_y, y_land);
-          mpp_close(fid);
-  }
-  free(xbl); free(ybl); free(xtl); free(ytl);  free(x_land); free(y_land);
-}
-//-------------------------------ocean_vgrid.nc----------------------------------
-{ 
-  double *z, *zb, *zt;
-  int nzb, nzt, nz, i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);
-  nzb = mpp_get_dimlen(fid_old, "zb");
-  nzt = mpp_get_dimlen(fid_old, "zt");
-  zb = (double *) malloc(nzb * sizeof(double)); 
-  zt = (double *) malloc(nzt * sizeof(double)); 
-  vid = mpp_get_varid(fid_old, "zb"); mpp_get_var_value(fid_old, vid, zb);
-  vid = mpp_get_varid(fid_old, "zt"); mpp_get_var_value(fid_old, vid, zt);
-  mpp_close(fid_old);
-  
-  nz = nzb + nzt + 1; 
-  z = (double *) malloc(nz * sizeof(double));
-  z[0]=0.0; 
-  for(i = 0; i<nzt; i++) { z[2*i + 1]   = zt[i]; z[2*i+2]   = zb[i]; } 
-
-  {
-    int fid, dim, varid;
-    char outfile[128] = "";
-
-    	sprintf(outfile, "%s_vgrid.nc",ocean_name);
-	printf("Writing %s\n", outfile);
-        printf("\t nzb=%d, nzt=%d\n", nzb, nzt); 
-
-    	fid = mpp_open(outfile, MPP_WRITE);
-    	  dim  = mpp_def_dim(fid, "nzv", nz);
-    	  varid = mpp_def_var(fid, "zeta", MPP_DOUBLE, 1, &dim, 2, "standard_name", "vertical_grid_vertex", "units", "meters");
-    	  mpp_end_def(fid);
-    	  mpp_put_var_value(fid, varid, z);
-    	mpp_close(fid);
-  }
-  free(zb); free(zt); free(z);
-}
-
-
-//-------------------------------topog.nc----------------------------------
-{ 
-  double *depth_t;
-  int nx, ny, ntiles, i,j, fid_old, vid;
-
-  fid_old = mpp_open(old_file, MPP_READ);  
-  nx= mpp_get_dimlen(fid_old, "grid_x_T");
-  ny= mpp_get_dimlen(fid_old, "grid_y_T");
-  depth_t= (double *) malloc(nx*ny* sizeof(double));
-  vid = mpp_get_varid(fid_old, "depth_t");  mpp_get_var_value(fid_old, vid, depth_t);
-  mpp_close(fid_old);
-  
-  {
-    int fid, dim[2], varid, ntiles = 1, dim_ntile;
-    char outfile[128] = "";
-        sprintf(outfile, "topog.nc");
-	printf("Writing %s\n", outfile);
-        printf("\t nx=%d, ny=%d\n", nx, ny);
-        fid = mpp_open(outfile, MPP_WRITE);
-	dim_ntile = mpp_def_dim(fid, "ntiles", 1);
-          dim[1]  = mpp_def_dim(fid, "nx", nx);
-          dim[0]  = mpp_def_dim(fid, "ny", ny);
-          varid = mpp_def_var(fid, "depth", MPP_DOUBLE, 2, dim, 2, "standard_name", "topographic depth at T-cell centers", "units", "meters");
-          mpp_end_def(fid);
-          mpp_put_var_value(fid, varid, depth_t);
-        mpp_close(fid);
-  }
-  free(depth_t); 
-}
-
-//................atmos_mosaic.nc............................
- if(is_coupled_grid)  {
-    char str[STRING], outfile[STRING];
-    int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-    int id_contact_index, id_griddir, id_gridfiles, dim[2];
-
-    size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-    ntiles = 1, ncontact = 0; 
-
-    sprintf(mosaic_name, "%s_mosaic",atmos_name);
-    sprintf(outfile, "%s.nc", mosaic_name);
-    printf("Writing %s\n", outfile);
-
-    sprintf(tile_name[0], "tile%d", 1);
-    sprintf(tilefile[0], "%s_hgrid.nc",atmos_name);
-    fid = mpp_open(outfile, MPP_WRITE);
-
-    contact_tile1_istart[0]=nxba-1; contact_tile1_iend[0]=nxba-1; 
-    contact_tile1_jstart[0]=1; contact_tile1_jend[0]=nyba-1; 
-
-    contact_tile2_istart[0]=1; contact_tile2_iend[0]=1; 
-    contact_tile2_jstart[0]=1; contact_tile2_jend[0]=nyba-1;
-//--------Initilize values --------------
-
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-
-    id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-                            "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-                            "children", "gridtiles", "contact_regions", "contacts",
-                            "grid_descriptor", grid_descriptor);
-    dim[0] = dim_ntiles; dim[1] = dim_string;
-    id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-                               "standard_name", "grid_file_location");
-    id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-    id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-    if(ncontact>0) {
-      dim[0] = dim_ncontact; dim[1] = dim_string;
-      id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-                                "contact_type", "boundary", "alignment", "true",
-                                "contact_index", "contact_index", "orientation", "orient");
-      id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-                                     "starting_ending_point_index_of_contact");
-
-    }
-
-    //mpp_def_global(fid, "history", history);
-    mpp_end_def(fid);
-
-    /* write out data */
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-    nwrite[0] = strlen(mosaic_name);
-    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-    nwrite[0] = 1;
-    for(n=0; n<ntiles; n++) {
-      start[0] = n; nwrite[1] = strlen(tile_name[n]);
-      mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-      nwrite[1] = strlen(tilefile[n]);
-      mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-    }
-
-    for(n=0; n<ncontact; n++) {
-      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-              tile_name[contact_tile2[n]]);
-      start[0] = n; nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-              contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-              contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-      nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-    }
-    mpp_close(fid);
-  }
-
-//................land_mosaic.nc............................
- if(is_coupled_grid)  {
-    char str[STRING], outfile[STRING];
-    int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-    int id_contact_index, id_griddir, id_gridfiles, dim[2];
-
-    size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-    ntiles = 1, ncontact = 1; 
-    contact_tile1_istart[1]=1; contact_tile1_iend[1]=1;
-    contact_tile1_jstart[1]=1; contact_tile1_jend[1]=nytl;
-
-    contact_tile2_istart[1]=nxtl; contact_tile2_iend[1]=nxtl;
-    contact_tile2_jstart[1]=1;    contact_tile2_jend[1]=nytl;
-    
-    sprintf(mosaic_name, "%s_mosaic",land_name);
-    sprintf(outfile, "%s.nc", mosaic_name);
-    printf("Writing %s\n", outfile);
-
-    sprintf(tile_name[0], "tile%d", 1);
-    sprintf(tilefile[0], "%s_hgrid.nc",land_name);
-    fid = mpp_open(outfile, MPP_WRITE);
-
-    contact_tile1_istart[0]=nxbl-1; contact_tile1_iend[0]=nxbl-1; 
-    contact_tile1_jstart[0]=1; contact_tile1_jend[0]=nybl-1; 
-
-    contact_tile2_istart[0]=1; contact_tile2_iend[0]=1; 
-    contact_tile2_jstart[0]=1; contact_tile2_jend[0]=nybl-1;
-//--------Initilize values --------------
-
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-
-    id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-                            "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-                            "children", "gridtiles", "contact_regions", "contacts",
-                            "grid_descriptor", grid_descriptor);
-    dim[0] = dim_ntiles; dim[1] = dim_string;
-    id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-                               "standard_name", "grid_file_location");
-    id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-    id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-    if(ncontact>0) {
-      dim[0] = dim_ncontact; dim[1] = dim_string;
-      id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-                                "contact_type", "boundary", "alignment", "true",
-                                "contact_index", "contact_index", "orientation", "orient");
-      id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-                                     "starting_ending_point_index_of_contact");
-
-    }
-
-    //mpp_def_global(fid, "history", history);
-    mpp_end_def(fid);
-
-    /* write out data */
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-    nwrite[0] = strlen(mosaic_name);
-    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-    nwrite[0] = 1;
-    for(n=0; n<ntiles; n++) {
-      start[0] = n; nwrite[1] = strlen(tile_name[n]);
-      mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-      nwrite[1] = strlen(tilefile[n]);
-      mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-    }
-
-    for(n=0; n<ncontact; n++) {
-      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-              tile_name[contact_tile2[n]]);
-      start[0] = n; nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-              contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-              contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-      nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-    }
-    mpp_close(fid);
-  }
-
-/* ...................... ocean_mosaic.nc .................*/
-  {
-    char str[STRING], outfile[STRING], x_boundary_type1[255]="", y_boundary_type1[255]="";
-    int fid, dim_ntiles, dim_ncontact, dim_string, id_mosaic, id_gridtiles, id_contacts;
-    int id_contact_index, id_griddir, id_gridfiles, dim[2], itmp, fid_old;
-
-    size_t start[4], nwrite[4];
-
-//--------Initilize values --------------
-    ntiles = 1, ncontact = 0; 
-
-    sprintf(mosaic_name, "%s_mosaic",ocean_name);
-    sprintf(outfile, "%s.nc", mosaic_name);
-    printf("Writing %s\n", outfile);
-
-    sprintf(tile_name[0], "tile%d", 1);
-    sprintf(tilefile[0], "%s_hgrid.nc", ocean_name);
-    
-    /* ........... Read Boundary Type ................ */
-    fid_old = mpp_open(old_file, MPP_READ);
-    mpp_get_global_att(fid_old, "x_boundary_type",x_boundary_type1);
-    mpp_get_global_att(fid_old, "y_boundary_type",y_boundary_type1);
-    mpp_close(fid_old);
-    if (strcmp(x_boundary_type1, "cyclic")==0) {
-	n = ncontact; ncontact = ncontact + 1; 
-    	contact_tile1_istart[n]=360; contact_tile1_iend[n]=360; 
-    	contact_tile1_jstart[n]=1; contact_tile1_jend[n]=180; 
-
-    	contact_tile2_istart[n]=1; contact_tile2_iend[n]=1; 
-    	contact_tile2_jstart[n]=1; contact_tile2_jend[n]=180;
-	printf("\t x_boundary_type = %s, ncontact=%d \n",x_boundary_type1,ncontact);
-    }
-    
-    if (strcmp(y_boundary_type1, "fold_north_edge")==0) {
-	n = ncontact; ncontact = ncontact + 1; 
-        contact_tile1_istart[n]=1; contact_tile1_iend[n]=180;
-        contact_tile1_jstart[n]=180; contact_tile1_jend[n]=180;
-
-        contact_tile2_istart[n]=360; contact_tile2_iend[n]=181;
-        contact_tile2_jstart[n]=180; contact_tile2_jend[n]=180;
-	printf("\t y_boundary_type = %s, ncontact=%d \n",y_boundary_type1,ncontact);
-    }
-
-    fid = mpp_open(outfile, MPP_WRITE);
-
-//--------Initilize values --------------
-
-    dim_ntiles = mpp_def_dim(fid, "ntiles", ntiles);
-    if(ncontact>0) dim_ncontact = mpp_def_dim(fid, "ncontact", ncontact);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-
-    id_mosaic = mpp_def_var(fid, "mosaic", MPP_CHAR, 1, &dim_string, 5, "standard_name",
-                            "grid_mosaic_spec", "mosaic_spec_version", mosaic_version,
-                            "children", "gridtiles", "contact_regions", "contacts",
-                            "grid_descriptor", grid_descriptor);
-    dim[0] = dim_ntiles; dim[1] = dim_string;
-    id_griddir   = mpp_def_var(fid, "gridlocation", MPP_CHAR, 1, &dim[1], 1,
-                               "standard_name", "grid_file_location");
-    id_gridfiles = mpp_def_var(fid, "gridfiles", MPP_CHAR, 2, dim, 0);
-    id_gridtiles = mpp_def_var(fid, "gridtiles", MPP_CHAR, 2, dim, 0);
-
-    if(ncontact>0) {
-      dim[0] = dim_ncontact; dim[1] = dim_string;
-      id_contacts = mpp_def_var(fid, "contacts", MPP_CHAR, 2, dim, 5, "standard_name", "grid_contact_spec",
-                                "contact_type", "boundary", "alignment", "true",
-                                "contact_index", "contact_index", "orientation", "orient");
-      id_contact_index = mpp_def_var(fid, "contact_index", MPP_CHAR, 2, dim, 1, "standard_name",
-                                     "starting_ending_point_index_of_contact");
-
-    }
-
-    //mpp_def_global(fid, "history", history);
-    mpp_end_def(fid);
-
-    /* write out data */
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-    nwrite[0] = strlen(mosaic_name);
-    mpp_put_var_value_block(fid, id_mosaic, start, nwrite, mosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_griddir, start, nwrite, mosaic_dir);
-    nwrite[0] = 1;
-    for(n=0; n<ntiles; n++) {
-      start[0] = n; nwrite[1] = strlen(tile_name[n]);
-      mpp_put_var_value_block(fid, id_gridtiles, start, nwrite, tile_name[n]);
-      nwrite[1] = strlen(tilefile[n]);
-      mpp_put_var_value_block(fid, id_gridfiles, start, nwrite, tilefile[n]);
-    }
-
-    for(n=0; n<ncontact; n++) {
-      sprintf(str,"%s:%s::%s:%s", mosaic_name, tile_name[contact_tile1[n]], mosaic_name,
-              tile_name[contact_tile2[n]]);
-      start[0] = n; nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contacts, start, nwrite, str);
-      sprintf(str,"%d:%d,%d:%d::%d:%d,%d:%d", contact_tile1_istart[n], contact_tile1_iend[n],
-              contact_tile1_jstart[n], contact_tile1_jend[n], contact_tile2_istart[n],
-              contact_tile2_iend[n], contact_tile2_jstart[n], contact_tile2_jend[n] );
-      nwrite[1] = strlen(str);
-      mpp_put_var_value_block(fid, id_contact_index, start, nwrite, str);
-    }
-    mpp_close(fid);
-  }
-/* ...................... atmosXland.nc .................*/
-  if(is_coupled_grid)  {
-  const char version[] = "0.2";
-  char lxo_file[STRING], axo_file[STRING], axl_file[STRING];
-  char amosaic_file[STRING], lmosaic_file[STRING], omosaic_file[STRING];
-  char otopog_file[STRING];
-
-  char atile_name[255], ltile_name[255], otile_name[255];
-  char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-  int  fid_old, vid;
-  
-  strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-  strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-    int no, nl, na, n;
-    size_t  naxl, naxo, naxl_step;
-    int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-    int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-    int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-    double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-    double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-    double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-
-    fid_old = mpp_open(old_file, MPP_READ);
-    naxl = mpp_get_dimlen(fid_old, "i_atmXlnd");
-//----------------
- 
-      /* write out atmXlnd data*/
-        if(naxl>0) {
-          size_t start[4], nwrite[4];
-                                                                                                                                                          
-          int fid, dim_string, dim_ncells, dim_two, dims[4];
-          int id_xgrid_area, id_contact, n;
-          int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-          char contact[STRING];
-                                                                                                                                                          
-          for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-          }
-          sprintf(axl_file, "%s_mosaicX%s_mosaic.nc", amosaic_name, lmosaic_name);
-          printf("Writing %s_mosaicX%s_mosaic.nc\n", amosaic_name, lmosaic_name);
-          sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", amosaic_name, atile_name, lmosaic_name, ltile_name);
-          fid = mpp_open(axl_file, MPP_WRITE);
-          //mpp_def_global(fid, "history", history);
-          dim_string = mpp_def_dim(fid, "string", STRING);
-          dim_ncells = mpp_def_dim(fid, "ncells", naxl);
-          dim_two    = mpp_def_dim(fid, "two", 2);
-          if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-                                     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-          }
-          else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-          }
-                                                                                                                                                          
-          dims[0] = dim_ncells; dims[1] = dim_two;
-          id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-          id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-          id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-                                       "exchange_grid_area", "units", "m2");
-          if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-          }
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) {start[i] = 0; nwrite[i] = 1;}
-	  nwrite[0] = strlen(contact);
-          mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-          nwrite[0] = naxl;
-
-          atmxlnd_area = (double *)malloc(naxl*sizeof(double)); 
-          atmxlnd_ia   = (int    *)malloc(naxl*sizeof(int   )); 
-          atmxlnd_ja   = (int    *)malloc(naxl*sizeof(int   )); 
-          atmxlnd_il   = (int    *)malloc(naxl*sizeof(int   )); 
-          atmxlnd_jl   = (int    *)malloc(naxl*sizeof(int   )); 
-	  vid = mpp_get_varid(fid_old, "AREA_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_area);
-	  vid = mpp_get_varid(fid_old, "I_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ia);
-	  vid = mpp_get_varid(fid_old, "J_ATM_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_ja);
-	  vid = mpp_get_varid(fid_old, "I_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_il);
-	  vid = mpp_get_varid(fid_old, "J_LND_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_jl);
-	  
-	  for(i=0;i<naxl;i++)atmxlnd_area[i] = atmxlnd_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-          mpp_put_var_value(fid, id_xgrid_area, atmxlnd_area);
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxlnd_ia);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxlnd_il);
-          start[1] = 1;
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxlnd_ja);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxlnd_jl);
-          if(interp_order == 2) {
-            atmxlnd_di = (double *)malloc(naxl*sizeof(double)); 
-            atmxlnd_dj = (double *)malloc(naxl*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_di);
-	    vid = mpp_get_varid(fid_old, "DJ_ATMxLND"); mpp_get_var_value(fid_old, vid, atmxlnd_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxlnd_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxlnd_dj);
-          }
-	  
-          mpp_close(fid);
-          free(atmxlnd_area);
-        }
-	mpp_close(fid_old);
-  }
-/* ...................... atmosXocean.nc .................*/
-  if(is_coupled_grid)  {
-  const char version[] = "0.2";
-  char lxo_file[STRING];
-  char axo_file[STRING];
-  char axl_file[STRING];
-  char amosaic_file[STRING];
-  char lmosaic_file[STRING];
-  char omosaic_file[STRING];
-  char otopog_file[STRING];
-
-  char atile_name[255], ltile_name[255], otile_name[255];
-  char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-
-  strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-  strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-    int no, nl, na, n;
-    size_t  naxl, naxo, naxl_step;
-    int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-    int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-    int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-    double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-    double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-    double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-    int fid_old, vid;
-
-    fid_old = mpp_open(old_file, MPP_READ);
-    naxo = mpp_get_dimlen(fid_old, "i_atmXocn");
-//----------------
- 
-      /* write out atmXlnd data*/
-        if(naxo>0) {
-          size_t start[4], nwrite[4];
-                                                                                                                                                          
-          int fid, dim_string, dim_ncells, dim_two, dims[4];
-          int id_xgrid_area, id_contact, n;
-          int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-          char contact[STRING];
-                                                                                                                                                          
-          for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-          }
-          sprintf(axo_file, "%s_mosaicX%s_mosaic.nc", amosaic_name, omosaic_name);
-          printf("Writing %s_mosaicX%s_mosaic.nc\n", amosaic_name, omosaic_name);
-          sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", amosaic_name, atile_name, omosaic_name, otile_name);
-          fid = mpp_open(axo_file, MPP_WRITE);
-          //mpp_def_global(fid, "history", history);
-          dim_string = mpp_def_dim(fid, "string", STRING);
-          dim_ncells = mpp_def_dim(fid, "ncells", naxo);
-          dim_two    = mpp_def_dim(fid, "two", 2);
-          if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-                                     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-          }
-          else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-          }
-                                                                                                                                                          
-          dims[0] = dim_ncells; dims[1] = dim_two;
-          id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-          id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-          id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-                                       "exchange_grid_area", "units", "m2");
-          if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-          }
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1;}
-	  nwrite[0] = strlen(contact);
-          mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-          nwrite[0] = naxo;
-
-          atmxocn_area = (double *)malloc(naxo*sizeof(double)); 
-          atmxocn_ia   = (int    *)malloc(naxo*sizeof(int   )); 
-          atmxocn_ja   = (int    *)malloc(naxo*sizeof(int   )); 
-          atmxocn_io   = (int    *)malloc(naxo*sizeof(int   )); 
-          atmxocn_jo   = (int    *)malloc(naxo*sizeof(int   )); 
-	  vid = mpp_get_varid(fid_old, "AREA_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_area);
-	  vid = mpp_get_varid(fid_old, "I_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ia);
-	  vid = mpp_get_varid(fid_old, "J_ATM_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_ja);
-	  vid = mpp_get_varid(fid_old, "I_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_io);
-	  vid = mpp_get_varid(fid_old, "J_OCN_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_jo);
-	  
-          for(i=0;i<naxo;i++)atmxocn_area[i] = atmxocn_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-          mpp_put_var_value(fid, id_xgrid_area, atmxocn_area);
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxocn_ia);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxocn_io);
-          start[1] = 1;
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, atmxocn_ja);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, atmxocn_jo);
-          if(interp_order == 2) {
-            atmxocn_di = (double *)malloc(naxo*sizeof(double)); 
-            atmxocn_dj = (double *)malloc(naxo*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_di);
-	    vid = mpp_get_varid(fid_old, "DJ_ATMxOCN"); mpp_get_var_value(fid_old, vid, atmxocn_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxocn_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, atmxocn_dj);
-          }
-          mpp_close(fid);
-          free(atmxocn_area);
-        }
-	mpp_close(fid_old);
-  }
-/* ...................... landXocean.nc .................*/
-  if(is_coupled_grid)  {
-  const char version[] = "0.2";
-  char lxo_file[STRING];
-  char axo_file[STRING];
-  char axl_file[STRING];
-  char amosaic_file[STRING];
-  char lmosaic_file[STRING];
-  char omosaic_file[STRING];
-  char otopog_file[STRING];
-
-  char atile_name[255], ltile_name[255], otile_name[255];
-  char amosaic_name[255], lmosaic_name[255], omosaic_name[255];
-
-  strcpy(atile_name,"tile1"); strcpy(ltile_name,"tile1"); strcpy(otile_name,"tile1");
-  strcpy(amosaic_name,"atmos"); strcpy(lmosaic_name,"land"); strcpy(omosaic_name,"ocean");
-
-//---------------
-    int no, nl, na, n;
-    size_t  naxl, naxo, nlxo, naxl_step;
-    int     *atmxlnd_ia, *atmxlnd_ja, *atmxlnd_il, *atmxlnd_jl;
-    int     *atmxocn_ia, *atmxocn_ja, *atmxocn_io, *atmxocn_jo;
-    int     *lndxocn_il, *lndxocn_jl, *lndxocn_io, *lndxocn_jo;
-    double  *atmxlnd_area, *atmxlnd_di, *atmxlnd_dj;
-    double  *atmxocn_area, *atmxocn_di, *atmxocn_dj;
-    double  *lndxocn_area, *lndxocn_di, *lndxocn_dj;
-    int     fid_old, vid;
-
-    fid_old = mpp_open(old_file, MPP_READ);
-    nlxo = mpp_get_dimlen(fid_old , "i_lndXocn");
-//----------------
- 
-      /* write out lndXocn data*/
-        if(nlxo>0) {
-          size_t start[4], nwrite[4];
-                                                                                                                                                          
-          int fid, dim_string, dim_ncells, dim_two, dims[4];
-          int id_xgrid_area, id_contact, n;
-          int id_tile1_cell, id_tile2_cell, id_tile1_dist, id_tile2_dist;
-          char contact[STRING];
-                                                                                                                                                          
-          for(i=0; i<4; i++) {
-            start[i] = 0; nwrite[i] = 1;
-          }
-          sprintf(lxo_file, "%s_mosaicX%s_mosaic.nc", lmosaic_name, omosaic_name);
-          printf("Writing %s_mosaicX%s_mosaic.nc\n", lmosaic_name, omosaic_name);
-          sprintf(contact, "%s_mosaic:%s::%s_mosaic:%s", lmosaic_name, ltile_name, omosaic_name, otile_name);
-          fid = mpp_open(lxo_file, MPP_WRITE);
-          //mpp_def_global(fid, "history", history);
-          dim_string = mpp_def_dim(fid, "string", STRING);
-          dim_ncells = mpp_def_dim(fid, "ncells", nlxo);
-          dim_two    = mpp_def_dim(fid, "two", 2);
-          if(interp_order == 2) {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 8, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area",
-                                     "distant_to_parent1_centroid", "tile1_distance", "distant_to_parent2_centroid", "tile2_distance");
-          }
-          else {
-            id_contact = mpp_def_var(fid, "contact", MPP_CHAR, 1, &dim_string, 6, "standard_name", "grid_contact_spec",
-                                     "contact_spec_version", version, "contact_type", "exchange", "parent1_cell",
-                                     "tile1_cell", "parent2_cell", "tile2_cell", "xgrid_area_field", "xgrid_area");
-          }
-                                                                                                                                                          
-          dims[0] = dim_ncells; dims[1] = dim_two;
-          id_tile1_cell = mpp_def_var(fid, "tile1_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic1");
-          id_tile2_cell = mpp_def_var(fid, "tile2_cell", MPP_INT, 2, dims, 1, "standard_name", "parent_cell_indices_in_mosaic2");
-          id_xgrid_area = mpp_def_var(fid, "xgrid_area", MPP_DOUBLE, 1, &dim_ncells, 2, "standard_name",
-                                       "exchange_grid_area", "units", "m2");
-          if(interp_order == 2) {
-            id_tile1_dist = mpp_def_var(fid, "tile1_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent1_cell_centroid");
-            id_tile2_dist = mpp_def_var(fid, "tile2_distance", MPP_DOUBLE, 2, dims, 1, "standard_name", "distance_from_parent2_cell_centroid");
-          }
-          mpp_end_def(fid);
-
-	  for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1;}
-	  nwrite[0] = strlen(contact);
-          mpp_put_var_value_block(fid, id_contact, start, nwrite, contact);
-          nwrite[0] = nlxo;
-
-          lndxocn_area = (double *)malloc(nlxo*sizeof(double)); 
-          lndxocn_il   = (int    *)malloc(nlxo*sizeof(int   )); 
-          lndxocn_jl   = (int    *)malloc(nlxo*sizeof(int   )); 
-          lndxocn_io   = (int    *)malloc(nlxo*sizeof(int   )); 
-          lndxocn_jo   = (int    *)malloc(nlxo*sizeof(int   )); 
-	  vid = mpp_get_varid(fid_old, "AREA_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_area);
-	  vid = mpp_get_varid(fid_old, "I_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_il);
-	  vid = mpp_get_varid(fid_old, "J_LND_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jl);
-	  vid = mpp_get_varid(fid_old, "I_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_io);
-	  vid = mpp_get_varid(fid_old, "J_OCN_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_jo);
-	  
-          for(i=0;i<nlxo;i++)lndxocn_area[i] = lndxocn_area[i] * 4.0 * PI * RADIUS * RADIUS; 
-
-          mpp_put_var_value(fid, id_xgrid_area, lndxocn_area);
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, lndxocn_il);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, lndxocn_io);
-          start[1] = 1;
-          mpp_put_var_value_block(fid, id_tile1_cell, start, nwrite, lndxocn_jl);
-          mpp_put_var_value_block(fid, id_tile2_cell, start, nwrite, lndxocn_jo);
-          if(interp_order == 2) {
-            lndxocn_di = (double *)malloc(nlxo*sizeof(double)); 
-            lndxocn_dj = (double *)malloc(nlxo*sizeof(double)); 
-	    vid = mpp_get_varid(fid_old, "DI_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_di);
-	    vid = mpp_get_varid(fid_old, "DJ_LNDxOCN"); mpp_get_var_value(fid_old, vid, lndxocn_dj);
-            start[1] = 0;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, lndxocn_di);
-            start[1] = 1;
-            mpp_put_var_value_block(fid, id_tile1_dist, start, nwrite, lndxocn_dj);
-          }
-          mpp_close(fid);
-          free(lndxocn_area);
-        }
-	mpp_close(fid_old);
-  }
-
-/* ...................... mosaic.nc .................*/
-  {
-  const char version[] = "0.2";
-  char lxo_file[STRING], axo_file[STRING], axl_file[STRING], mosaic_file[STRING];
-  char amosaic_file[STRING], lmosaic_file[STRING], omosaic_file[STRING];
-  char amosaic_name[STRING], lmosaic_name[STRING], omosaic_name[STRING];
-  char otopog_file[STRING];
-
-    int fid, dim_string, dim_axo, dim_lxo, dim_axl, dims[4], n;
-    size_t start[4], nwrite[4];
-    int id_lmosaic_dir, id_lmosaic_file, id_omosaic_dir, id_omosaic_file;
-    int id_amosaic_dir, id_amosaic_file, id_otopog_dir, id_otopog_file;
-    int id_xgrids_dir, id_axo_file, id_lxo_file, id_axl_file;
-    int id_amosaic, id_lmosaic, id_omosaic;
-
-    int nfile_axo = 1, nfile_axl = 1, nfile_lxo = 1; 
-
-    strcpy(mosaic_file,"mosaic.nc");
-    printf("Writing %s\n", mosaic_file);
-
-    fid = mpp_open(mosaic_file, MPP_WRITE);
-  //  mpp_def_global(fid, "history", history);
-    dim_string = mpp_def_dim(fid, "string", STRING);
-    dim_axo = mpp_def_dim(fid, "nfile_aXo", nfile_axo);
-    dim_axl = mpp_def_dim(fid, "nfile_aXl", nfile_axl);
-    dim_lxo = mpp_def_dim(fid, "nfile_lXo", nfile_lxo);
-    id_amosaic_dir  = mpp_def_var(fid, "atm_mosaic_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_atmosphere_mosaic");
-    id_amosaic_file = mpp_def_var(fid, "atm_mosaic_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "atmosphere_mosaic_file_name");
-    id_amosaic      = mpp_def_var(fid, "atm_mosaic", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "atmosphere_mosaic_name");
-    id_lmosaic_dir  = mpp_def_var(fid, "lnd_mosaic_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_land_mosaic");
-    id_lmosaic_file = mpp_def_var(fid, "lnd_mosaic_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "land_mosaic_file_name");
-    id_lmosaic      = mpp_def_var(fid, "lnd_mosaic", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "land_mosaic_name");
-    id_omosaic_dir  = mpp_def_var(fid, "ocn_mosaic_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_ocean_mosaic");
-    id_omosaic_file = mpp_def_var(fid, "ocn_mosaic_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "ocean_mosaic_file_name");
-    id_omosaic      = mpp_def_var(fid, "ocn_mosaic", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "ocean_mosaic_name");
-    id_otopog_dir   = mpp_def_var(fid, "ocn_topog_dir", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "directory_storing_ocean_topog");
-    id_otopog_file  = mpp_def_var(fid, "ocn_topog_file", MPP_CHAR, 1, &dim_string,
-                                  1, "standard_name", "ocean_topog_file_name");
-    /* since exchange grid is created in this tool, we may add command line option to specify where to store the output */
-    /*    id_xgrids_dir = mpp_def_var(fid, "xgrids_dir", MPP_CHAR, 1, &dim_string,
-          1, "standard_name", "directory_storing_xgrids"); */
-    dims[0] = dim_axo; dims[1] = dim_string;
-    id_axo_file = mpp_def_var(fid, "aXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXocn_exchange_grid_file");
-    dims[0] = dim_axl; dims[1] = dim_string;
-    id_axl_file = mpp_def_var(fid, "aXl_file", MPP_CHAR, 2, dims, 1, "standard_name", "atmXlnd_exchange_grid_file");
-    dims[0] = dim_lxo; dims[1] = dim_string;
-    id_lxo_file = mpp_def_var(fid, "lXo_file", MPP_CHAR, 2, dims, 1, "standard_name", "lndXocn_exchange_grid_file");
-    mpp_end_def(fid);
-
-strcpy(otopog_file,"topog.nc");
-
-sprintf(amosaic_name,"%s_mosaic",atmos_name); sprintf(lmosaic_name,"%s_mosaic",land_name); sprintf(omosaic_name,"%s_mosaic",ocean_name);
-sprintf(amosaic_file,"%s.nc",amosaic_name); sprintf(lmosaic_file,"%s.nc",lmosaic_name); sprintf(omosaic_file,"%s.nc",omosaic_name);
-
-sprintf(axl_file,"%sX%s.nc", amosaic_name, lmosaic_name); 
-sprintf(axo_file,"%sX%s.nc", amosaic_name, omosaic_name); 
-sprintf(lxo_file,"%sX%s.nc", lmosaic_name, omosaic_name); 
-
-    for(i=0; i<4; i++) { start[i] = 0; nwrite[i] = 1; }
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_amosaic_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(amosaic_file);
-    mpp_put_var_value_block(fid, id_amosaic_file, start, nwrite, amosaic_file);
-    nwrite[0] = strlen(amosaic_name);
-    mpp_put_var_value_block(fid, id_amosaic, start, nwrite, amosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_lmosaic_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(lmosaic_file);
-    mpp_put_var_value_block(fid, id_lmosaic_file, start, nwrite, lmosaic_file);
-    nwrite[0] = strlen(lmosaic_name);
-    mpp_put_var_value_block(fid, id_lmosaic, start, nwrite, lmosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_omosaic_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(omosaic_file);
-    mpp_put_var_value_block(fid, id_omosaic_file, start, nwrite, omosaic_file);
-    nwrite[0] = strlen(omosaic_name);
-    mpp_put_var_value_block(fid, id_omosaic, start, nwrite, omosaic_name);
-    nwrite[0] = strlen(mosaic_dir);
-    mpp_put_var_value_block(fid, id_otopog_dir, start, nwrite, mosaic_dir);
-    nwrite[0] = strlen(otopog_file);
-    mpp_put_var_value_block(fid, id_otopog_file, start, nwrite, otopog_file);
-    for(i=0; i<4; i++) {
-      start[i] = 0; nwrite[i] = 1;
-    }
-      start[0] = 0; nwrite[1] = strlen(axo_file);
-      mpp_put_var_value_block(fid, id_axo_file, start, nwrite, axo_file);
-
-      start[0] = 0; nwrite[1] = strlen(axl_file);
-      mpp_put_var_value_block(fid, id_axl_file, start, nwrite, axl_file);
-
-      start[0] = 0; nwrite[1] = strlen(lxo_file);
-      mpp_put_var_value_block(fid, id_lxo_file, start, nwrite, lxo_file);
-    mpp_close(fid);
-  }
-
-
-
-  return;
-  mpp_end();
-  
-};  /* end of main */
-
diff --git a/install-sh b/install-sh
index a5897de..6781b98 100755
--- a/install-sh
+++ b/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2006-12-25.00
+scriptversion=2009-04-28.21; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -515,5 +515,6 @@ done
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/missing b/missing
index 1c8ff70..28055d2 100755
--- a/missing
+++ b/missing
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Common stub for a few missing GNU programs while installing.
 
-scriptversion=2006-05-10.23
+scriptversion=2009-04-28.21; # UTC
 
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
-#   Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
 # Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -18,9 +18,7 @@ scriptversion=2006-05-10.23
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -89,6 +87,9 @@ Supported PROGRAM values:
   tar          try tar, gnutar, gtar, then tar without non-portable flags
   yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
 
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
 Send bug reports to <bug-automake at gnu.org>."
     exit $?
     ;;
@@ -106,15 +107,22 @@ Send bug reports to <bug-automake at gnu.org>."
 
 esac
 
+# normalize program name to check for.
+program=`echo "$1" | sed '
+  s/^gnu-//; t
+  s/^gnu//; t
+  s/^g//; t'`
+
 # Now exit if we have it, but it failed.  Also exit now if we
 # don't have it and --version was passed (most likely to detect
-# the program).
+# the program).  This is about non-GNU programs, so use $1 not
+# $program.
 case $1 in
-  lex|yacc)
+  lex*|yacc*)
     # Not GNU programs, they don't have --version.
     ;;
 
-  tar)
+  tar*)
     if test -n "$run"; then
        echo 1>&2 "ERROR: \`tar' requires --run"
        exit 1
@@ -138,7 +146,7 @@ esac
 
 # If it does not exist, or fails to run (possibly an outdated version),
 # try to emulate it.
-case $1 in
+case $program in
   aclocal*)
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
@@ -148,7 +156,7 @@ WARNING: \`$1' is $msg.  You should only need it if
     touch aclocal.m4
     ;;
 
-  autoconf)
+  autoconf*)
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified \`${configure_ac}'.  You might want to install the
@@ -157,7 +165,7 @@ WARNING: \`$1' is $msg.  You should only need it if
     touch configure
     ;;
 
-  autoheader)
+  autoheader*)
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified \`acconfig.h' or \`${configure_ac}'.  You might want
@@ -187,7 +195,7 @@ WARNING: \`$1' is $msg.  You should only need it if
 	   while read f; do touch "$f"; done
     ;;
 
-  autom4te)
+  autom4te*)
     echo 1>&2 "\
 WARNING: \`$1' is needed, but is $msg.
          You might have modified some files without having the
@@ -210,7 +218,7 @@ WARNING: \`$1' is needed, but is $msg.
     fi
     ;;
 
-  bison|yacc)
+  bison*|yacc*)
     echo 1>&2 "\
 WARNING: \`$1' $msg.  You should only need it if
          you modified a \`.y' file.  You may need the \`Bison' package
@@ -240,7 +248,7 @@ WARNING: \`$1' $msg.  You should only need it if
     fi
     ;;
 
-  lex|flex)
+  lex*|flex*)
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified a \`.l' file.  You may need the \`Flex' package
@@ -263,7 +271,7 @@ WARNING: \`$1' is $msg.  You should only need it if
     fi
     ;;
 
-  help2man)
+  help2man*)
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
 	 you modified a dependency of a manual page.  You may need the
@@ -277,11 +285,11 @@ WARNING: \`$1' is $msg.  You should only need it if
     else
 	test -z "$file" || exec >$file
 	echo ".ab help2man is required to generate this page"
-	exit 1
+	exit $?
     fi
     ;;
 
-  makeinfo)
+  makeinfo*)
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified a \`.texi' or \`.texinfo' file, or any other file
@@ -310,7 +318,7 @@ WARNING: \`$1' is $msg.  You should only need it if
     touch $file
     ;;
 
-  tar)
+  tar*)
     shift
 
     # We have already tried tar in the generic part.
@@ -363,5 +371,6 @@ exit 0
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:
diff --git a/nfconfig.in b/nfconfig.in
index 6adf488..344cce1 100644
--- a/nfconfig.in
+++ b/nfconfig.in
@@ -1,5 +1,5 @@
 #if 0
-    $Id: nfconfig.in,v 1.1 2006/11/10 21:47:18 ed Exp $ 
+    $Id: nfconfig.in,v 1.2 2009/09/08 17:14:51 ed Exp $ 
 #endif
 
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 74dc395..60ee4e5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@
 
 # THis automake file is in charge of building the src directory.
 
-# $Id: Makefile.am,v 1.25 2009/04/12 14:10:14 ed Exp $
+# $Id: Makefile.am,v 1.5 2009/11/11 12:59:24 ed Exp $
 
 # Tell automake that libcf.h is a header file we want to install.
 include_HEADERS = libcf.h
@@ -16,26 +16,82 @@ LDADD = ${lib_LTLIBRARIES}
 AM_CPPFLAGS=
 AM_LDFLAGS=
 
-# If the user specified a root location for NETCDF, use it.
+# This is our output, the NetCDF CF Library.
+lib_LTLIBRARIES = libcf.la
+
+check_PROGRAMS = tst_coords tst_files tst_vars tst_cvars tst_vert	\
+tst_subsets
+
+if BUILD_F90
+lib_LTLIBRARIES += libcff.la
+libcff_la_DEPENDENCIES = libcf_api.f90
+EXTRA_DIST = libcf_api.f90
+libcff_la_SOURCES = cffcvars.f90
+if USE_NETCDF4
+check_PROGRAMS += tst_f03_file
+tst_f03_file_SOURCES = tst_f03_file.f90
+endif # USE_NETCDF4
+LDADD += libcf.la
+if USE_NETCDF_DIR
+AM_FCFLAGS = @MOD_FLAG@@NETCDFDIR@/include
+else
+AM_FCFLAGS = @MOD_FLAG at ../../f90
+endif
+endif # BUILD_F90
+
+# Link to the netCDF-4, (optionally) HDF4, and the HDF5 libraries.
 if USE_NETCDF_DIR
+LDADD += -lnetcdf
 AM_CPPFLAGS += -I at NETCDFDIR@/include
-AM_FCFLAGS = -I at NETCDFDIR@/include
 AM_LDFLAGS += -L at NETCDFDIR@/lib
+else
+if USE_NETCDF4
+LDADD += ../../libsrc4/libnetcdf.la 
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc4
+AM_LDFLAGS += -L../../libsrc4
+else 
+LDADD += ../../libsrc/libnetcdf.la
+AM_CPPFLAGS += -I$(top_srcdir)/../libsrc
+AM_LDFLAGS += -L../../libsrc
+endif # USE_NETCDF4
+endif # USE_NETCDF_DIR
+
+if USE_HDF4
+LDADD += -lmfhdf -ldf -ljpeg
+endif # USE_HDF4
+
+if USE_NETCDF4
+LDADD += -lhdf5_hl -lhdf5 -lz 
 endif
 
-# If the user specified a root location for HDF5, use it.
+# If the user specified a root for HDF5, use it.
 if USE_HDF5_DIR
 AM_CPPFLAGS += -I at HDF5DIR@/include
 AM_LDFLAGS += -L at HDF5DIR@/lib
 endif
 
-# This is our output, the NetCDF CF Library.
-lib_LTLIBRARIES = libcf.la
+# If the user specified a prefix for the HDF4 library location, use it.
+if USE_HDF4_DIR
+AM_CPPFLAGS += -I at HDF4DIR@/include
+AM_LDFLAGS += -L at HDF4DIR@/lib
+endif
+
+# If the user specified a root location for ZLIB, use it.
+if USE_ZLIB_DIR
+AM_CPPFLAGS += -I at ZLIBDIR@/include
+AM_LDFLAGS += -L at ZLIBDIR@/lib
+endif
+
+# If the user specified a root location for SZLIB, use it.
+if USE_SZLIB_DIR
+AM_CPPFLAGS += -I at SZLIBDIR@/include
+AM_LDFLAGS += -L at SZLIBDIR@/lib
+endif
 
 # Add the gridspec functions.
 if BUILD_GRIDSPEC
-libcf_la_LIBADD = ../gridspec_tools_20080702/shared/mosaic/libshared.la 
-libcf_la_LIBADD += ../gridspec_tools_20080702/tools/shared/libtoolsshared.la 
+#libcf_la_LIBADD = ../gridspec/shared/mosaic/libshared.la 
+#libcf_la_LIBADD += ../gridspec/tools/shared/libtoolsshared.la 
 endif 
 
 # These linker flags specify libtool version info.
@@ -51,7 +107,7 @@ CLEANFILES = tst_coords_classic.nc tst_coords_64bit.nc			\
 tst_coords_netcdf4_classic.nc tst_coords_netcdf4.nc tst_vars.nc		\
 tst_files.nc tst_cvars.nc tst_vert_sigma.nc tst_vert_hybrid_sigma.nc	\
 tst_subsets_simple_sigma.nc tst_subsets_nw.nc tst_subsets_sw.nc		\
-tst_subsets_se.nc tst_subsets_ne.nc 
+tst_subsets_se.nc tst_subsets_ne.nc tst_f03_file.nc libcf.mod
 
 tst_coords_SOURCES = tst_coords.c nc_tests.h
 tst_files_SOURCES = tst_files.c nc_tests.h
@@ -60,38 +116,17 @@ tst_cvars_SOURCES = tst_cvars.c nc_tests.h
 tst_vert_SOURCES = tst_vert.c nc_tests.h
 tst_subsets_SOURCES = tst_subsets.c nc_tests.h
 
-check_PROGRAMS = tst_coords tst_files tst_vars tst_cvars tst_vert	\
-tst_subsets
-
 if EXTRA_DATA_TESTS
 check_PROGRAMS += tst_example_data
 tst_example_data_SOURCES = tst_example_data.c nc_tests.h
 endif # EXTRA_DATA_TESTS
 
-if BUILD_F90
-lib_LTLIBRARIES += libcff.la
-libcff_la_SOURCES = cffcvars.f90
-check_PROGRAMS += tst_f03_file
-tst_f03_file_SOURCES = tst_f03_file.f90
-CLEANFILES += tst_f03_file.nc	
-LDADD += libcf.la
-endif # BUILD_F90
-
-LDADD += -lnetcdf
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
-if USE_NETCDF4
-LDADD += -lhdf5_hl -lhdf5 -lz
-endif # USE_NETCDF4
-
 # Rule to build Fortran 2003 code.
-# cfcvars.o:cfcvsars.f03
-# 	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
+#cfcvars.o:cfcvsars.f90
+#	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
 
-# tst_f03_file.o:tst_f03_file.f03
-# 	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
+tst_f03_file.o:tst_f03_file.f90
+	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
 
 TESTS = $(check_PROGRAMS)
 
diff --git a/src/Makefile.in b/src/Makefile.in
index 0131dc2..afcdc0d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
+# Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -18,13 +19,14 @@
 
 # THis automake file is in charge of building the src directory.
 
-# $Id: Makefile.am,v 1.25 2009/04/12 14:10:14 ed Exp $
+# $Id: Makefile.am,v 1.5 2009/11/11 12:59:24 ed Exp $
 
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
@@ -39,27 +41,42 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-
-# If the user specified a root location for NETCDF, use it.
- at USE_NETCDF_DIR_TRUE@am__append_1 = -I at NETCDFDIR@/include
- at USE_NETCDF_DIR_TRUE@am__append_2 = -L at NETCDFDIR@/lib
-
-# If the user specified a root location for HDF5, use it.
- at USE_HDF5_DIR_TRUE@am__append_3 = -I at HDF5DIR@/include
- at USE_HDF5_DIR_TRUE@am__append_4 = -L at HDF5DIR@/lib
 check_PROGRAMS = tst_coords$(EXEEXT) tst_files$(EXEEXT) \
 	tst_vars$(EXEEXT) tst_cvars$(EXEEXT) tst_vert$(EXEEXT) \
 	tst_subsets$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2)
- at EXTRA_DATA_TESTS_TRUE@am__append_5 = tst_example_data
- at BUILD_F90_TRUE@am__append_6 = libcff.la
- at BUILD_F90_TRUE@am__append_7 = tst_f03_file
- at BUILD_F90_TRUE@am__append_8 = tst_f03_file.nc	
- at BUILD_F90_TRUE@am__append_9 = libcf.la
-
-# If the user is building with netCDF-4, we also have to link to the
-# HDF5 high-level library, and the HDF5 library, and the zlib
-# compression library.
- at USE_NETCDF4_TRUE@am__append_10 = -lhdf5_hl -lhdf5 -lz
+ at BUILD_F90_TRUE@am__append_1 = libcff.la
+ at BUILD_F90_TRUE@@USE_NETCDF4_TRUE at am__append_2 = tst_f03_file
+ at BUILD_F90_TRUE@am__append_3 = libcf.la
+
+# Link to the netCDF-4, (optionally) HDF4, and the HDF5 libraries.
+ at USE_NETCDF_DIR_TRUE@am__append_4 = -lnetcdf
+ at USE_NETCDF_DIR_TRUE@am__append_5 = -I at NETCDFDIR@/include
+ at USE_NETCDF_DIR_TRUE@am__append_6 = -L at NETCDFDIR@/lib
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_7 = ../../libsrc4/libnetcdf.la 
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_8 = -I$(top_srcdir)/../libsrc4
+ at USE_NETCDF4_TRUE@@USE_NETCDF_DIR_FALSE at am__append_9 = -L../../libsrc4
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_10 = ../../libsrc/libnetcdf.la
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_11 = -I$(top_srcdir)/../libsrc
+ at USE_NETCDF4_FALSE@@USE_NETCDF_DIR_FALSE at am__append_12 = -L../../libsrc
+ at USE_HDF4_TRUE@am__append_13 = -lmfhdf -ldf -ljpeg
+ at USE_NETCDF4_TRUE@am__append_14 = -lhdf5_hl -lhdf5 -lz 
+
+# If the user specified a root for HDF5, use it.
+ at USE_HDF5_DIR_TRUE@am__append_15 = -I at HDF5DIR@/include
+ at USE_HDF5_DIR_TRUE@am__append_16 = -L at HDF5DIR@/lib
+
+# If the user specified a prefix for the HDF4 library location, use it.
+ at USE_HDF4_DIR_TRUE@am__append_17 = -I at HDF4DIR@/include
+ at USE_HDF4_DIR_TRUE@am__append_18 = -L at HDF4DIR@/lib
+
+# If the user specified a root location for ZLIB, use it.
+ at USE_ZLIB_DIR_TRUE@am__append_19 = -I at ZLIBDIR@/include
+ at USE_ZLIB_DIR_TRUE@am__append_20 = -L at ZLIBDIR@/lib
+
+# If the user specified a root location for SZLIB, use it.
+ at USE_SZLIB_DIR_TRUE@am__append_21 = -I at SZLIBDIR@/include
+ at USE_SZLIB_DIR_TRUE@am__append_22 = -L at SZLIBDIR@/lib
+ at EXTRA_DATA_TESTS_TRUE@am__append_23 = tst_example_data
 subdir = src
 DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
@@ -73,17 +90,31 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h $(top_builddir)/nfconfig.inc
 CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
     *) f=$$p;; \
   esac;
-am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
-libLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(lib_LTLIBRARIES)
- at BUILD_GRIDSPEC_TRUE@libcf_la_DEPENDENCIES = ../gridspec_tools_20080702/shared/mosaic/libshared.la \
- at BUILD_GRIDSPEC_TRUE@	../gridspec_tools_20080702/tools/shared/libtoolsshared.la
+libcf_la_LIBADD =
 am_libcf_la_OBJECTS = nccoord.lo cffiles.lo cfvars.lo cfcvars.lo \
 	cfsubsets.lo cferror.lo cdTimeConv.lo
 libcf_la_OBJECTS = $(am_libcf_la_OBJECTS)
@@ -95,55 +126,66 @@ am__libcff_la_SOURCES_DIST = cffcvars.f90
 @BUILD_F90_TRUE at am_libcff_la_OBJECTS = cffcvars.lo
 libcff_la_OBJECTS = $(am_libcff_la_OBJECTS)
 @BUILD_F90_TRUE at am_libcff_la_rpath = -rpath $(libdir)
- at EXTRA_DATA_TESTS_TRUE@am__EXEEXT_1 = tst_example_data$(EXEEXT)
- at BUILD_F90_TRUE@am__EXEEXT_2 = tst_f03_file$(EXEEXT)
+ at BUILD_F90_TRUE@@USE_NETCDF4_TRUE at am__EXEEXT_1 =  \
+ at BUILD_F90_TRUE@@USE_NETCDF4_TRUE@	tst_f03_file$(EXEEXT)
+ at EXTRA_DATA_TESTS_TRUE@am__EXEEXT_2 = tst_example_data$(EXEEXT)
 am_tst_coords_OBJECTS = tst_coords.$(OBJEXT)
 tst_coords_OBJECTS = $(am_tst_coords_OBJECTS)
 tst_coords_LDADD = $(LDADD)
 am__DEPENDENCIES_1 =
-tst_coords_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_coords_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am_tst_cvars_OBJECTS = tst_cvars.$(OBJEXT)
 tst_cvars_OBJECTS = $(am_tst_cvars_OBJECTS)
 tst_cvars_LDADD = $(LDADD)
-tst_cvars_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_cvars_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am__tst_example_data_SOURCES_DIST = tst_example_data.c nc_tests.h
 @EXTRA_DATA_TESTS_TRUE at am_tst_example_data_OBJECTS =  \
 @EXTRA_DATA_TESTS_TRUE@	tst_example_data.$(OBJEXT)
 tst_example_data_OBJECTS = $(am_tst_example_data_OBJECTS)
 tst_example_data_LDADD = $(LDADD)
-tst_example_data_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_example_data_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am__tst_f03_file_SOURCES_DIST = tst_f03_file.f90
- at BUILD_F90_TRUE@am_tst_f03_file_OBJECTS = tst_f03_file.$(OBJEXT)
+ at BUILD_F90_TRUE@@USE_NETCDF4_TRUE at am_tst_f03_file_OBJECTS =  \
+ at BUILD_F90_TRUE@@USE_NETCDF4_TRUE@	tst_f03_file.$(OBJEXT)
 tst_f03_file_OBJECTS = $(am_tst_f03_file_OBJECTS)
 tst_f03_file_LDADD = $(LDADD)
-tst_f03_file_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_f03_file_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am_tst_files_OBJECTS = tst_files.$(OBJEXT)
 tst_files_OBJECTS = $(am_tst_files_OBJECTS)
 tst_files_LDADD = $(LDADD)
-tst_files_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_files_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am_tst_subsets_OBJECTS = tst_subsets.$(OBJEXT)
 tst_subsets_OBJECTS = $(am_tst_subsets_OBJECTS)
 tst_subsets_LDADD = $(LDADD)
-tst_subsets_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_subsets_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am_tst_vars_OBJECTS = tst_vars.$(OBJEXT)
 tst_vars_OBJECTS = $(am_tst_vars_OBJECTS)
 tst_vars_LDADD = $(LDADD)
-tst_vars_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_vars_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 am_tst_vert_OBJECTS = tst_vert.$(OBJEXT)
 tst_vert_OBJECTS = $(am_tst_vert_OBJECTS)
 tst_vert_LDADD = $(LDADD)
-tst_vert_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_9) \
-	$(am__DEPENDENCIES_1)
+tst_vert_DEPENDENCIES = $(lib_LTLIBRARIES) $(am__append_3) \
+	$(am__DEPENDENCIES_1) $(am__append_7) $(am__append_10) \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
+am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -154,12 +196,12 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
 FCCOMPILE = $(FC) $(AM_FCFLAGS) $(FCFLAGS)
-LTFCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+LTFCCOMPILE = $(LIBTOOL) --tag=FC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	--mode=compile $(FC) $(AM_FCFLAGS) $(FCFLAGS)
 FCLD = $(FC)
-FCLINK = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
-	$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \
-	$@
+FCLINK = $(LIBTOOL) --tag=FC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
 SOURCES = $(libcf_la_SOURCES) $(libcff_la_SOURCES) \
 	$(tst_coords_SOURCES) $(tst_cvars_SOURCES) \
 	$(tst_example_data_SOURCES) $(tst_f03_file_SOURCES) \
@@ -170,10 +212,11 @@ DIST_SOURCES = $(libcf_la_SOURCES) $(am__libcff_la_SOURCES_DIST) \
 	$(am__tst_example_data_SOURCES_DIST) \
 	$(am__tst_f03_file_SOURCES_DIST) $(tst_files_SOURCES) \
 	$(tst_subsets_SOURCES) $(tst_vars_SOURCES) $(tst_vert_SOURCES)
-includeHEADERS_INSTALL = $(INSTALL_HEADER)
 HEADERS = $(include_HEADERS)
 ETAGS = etags
 CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
@@ -187,7 +230,6 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMPILE_F = @COMPILE_F@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -204,12 +246,11 @@ EXEEXT = @EXEEXT@
 F77 = @F77@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FFLAGS = @FFLAGS@
 FGREP = @FGREP@
-FLIBS = @FLIBS@
-FPP = @FPP@
-FPPFLAGS = @FPPFLAGS@
 GREP = @GREP@
+HDF4DIR = @HDF4DIR@
 HDF5DIR = @HDF5DIR@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -225,13 +266,12 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
-MAKEWHATIS_CMD = @MAKEWHATIS_CMD@
-MATHLIB = @MATHLIB@
 MKDIR_P = @MKDIR_P@
+MOD_FLAG = @MOD_FLAG@
+NCDUMPDIR = @NCDUMPDIR@
 NETCDFDIR = @NETCDFDIR@
 NM = @NM@
 NMEDIT = @NMEDIT@
-NMFLAGS = @NMFLAGS@
 OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
 OTOOL = @OTOOL@
@@ -248,8 +288,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+SZLIBDIR = @SZLIBDIR@
 VERSION = @VERSION@
-WHATIS = @WHATIS@
+ZLIBDIR = @ZLIBDIR@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -294,7 +335,6 @@ mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
 pdfdir = @pdfdir@
 prefix = @prefix@
-prog = @prog@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 sbindir = @sbindir@
@@ -311,19 +351,30 @@ include_HEADERS = libcf.h
 
 # Test programs will need to link to this library (libcf) and also
 # netcdf.
-LDADD = ${lib_LTLIBRARIES} $(am__append_9) -lnetcdf $(am__append_10)
+LDADD = ${lib_LTLIBRARIES} $(am__append_3) $(am__append_4) \
+	$(am__append_7) $(am__append_10) $(am__append_13) \
+	$(am__append_14)
 
 # Initalize these.
-AM_CPPFLAGS = $(am__append_1) $(am__append_3)
-AM_LDFLAGS = $(am__append_2) $(am__append_4)
- at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
+AM_CPPFLAGS = $(am__append_5) $(am__append_8) $(am__append_11) \
+	$(am__append_15) $(am__append_17) $(am__append_19) \
+	$(am__append_21)
+AM_LDFLAGS = $(am__append_6) $(am__append_9) $(am__append_12) \
+	$(am__append_16) $(am__append_18) $(am__append_20) \
+	$(am__append_22)
 
 # This is our output, the NetCDF CF Library.
-lib_LTLIBRARIES = libcf.la $(am__append_6)
+lib_LTLIBRARIES = libcf.la $(am__append_1)
+ at BUILD_F90_TRUE@libcff_la_DEPENDENCIES = libcf_api.f90
+ at BUILD_F90_TRUE@EXTRA_DIST = libcf_api.f90
+ at BUILD_F90_TRUE@libcff_la_SOURCES = cffcvars.f90
+ at BUILD_F90_TRUE@@USE_NETCDF4_TRUE at tst_f03_file_SOURCES = tst_f03_file.f90
+ at BUILD_F90_TRUE@@USE_NETCDF_DIR_FALSE at AM_FCFLAGS = @MOD_FLAG at ../../f90
+ at BUILD_F90_TRUE@@USE_NETCDF_DIR_TRUE at AM_FCFLAGS = @MOD_FLAG@@NETCDFDIR@/include
 
 # Add the gridspec functions.
- at BUILD_GRIDSPEC_TRUE@libcf_la_LIBADD = ../gridspec_tools_20080702/shared/mosaic/libshared.la \
- at BUILD_GRIDSPEC_TRUE@	../gridspec_tools_20080702/tools/shared/libtoolsshared.la
+#libcf_la_LIBADD = ../gridspec/shared/mosaic/libshared.la 
+#libcf_la_LIBADD += ../gridspec/tools/shared/libtoolsshared.la 
 
 # These linker flags specify libtool version info.
 libcf_la_LDFLAGS = -version-info 0:0:0
@@ -335,12 +386,12 @@ cdms.h cddrs.h drscdf.h cdunif.h
 
 
 # These files are created by the tests.
-CLEANFILES = tst_coords_classic.nc tst_coords_64bit.nc \
-	tst_coords_netcdf4_classic.nc tst_coords_netcdf4.nc \
-	tst_vars.nc tst_files.nc tst_cvars.nc tst_vert_sigma.nc \
-	tst_vert_hybrid_sigma.nc tst_subsets_simple_sigma.nc \
-	tst_subsets_nw.nc tst_subsets_sw.nc tst_subsets_se.nc \
-	tst_subsets_ne.nc $(am__append_8)
+CLEANFILES = tst_coords_classic.nc tst_coords_64bit.nc			\
+tst_coords_netcdf4_classic.nc tst_coords_netcdf4.nc tst_vars.nc		\
+tst_files.nc tst_cvars.nc tst_vert_sigma.nc tst_vert_hybrid_sigma.nc	\
+tst_subsets_simple_sigma.nc tst_subsets_nw.nc tst_subsets_sw.nc		\
+tst_subsets_se.nc tst_subsets_ne.nc tst_f03_file.nc libcf.mod
+
 tst_coords_SOURCES = tst_coords.c nc_tests.h
 tst_files_SOURCES = tst_files.c nc_tests.h
 tst_vars_SOURCES = tst_vars.c nc_tests.h
@@ -348,15 +399,6 @@ tst_cvars_SOURCES = tst_cvars.c nc_tests.h
 tst_vert_SOURCES = tst_vert.c nc_tests.h
 tst_subsets_SOURCES = tst_subsets.c nc_tests.h
 @EXTRA_DATA_TESTS_TRUE at tst_example_data_SOURCES = tst_example_data.c nc_tests.h
- at BUILD_F90_TRUE@libcff_la_SOURCES = cffcvars.f90
- at BUILD_F90_TRUE@tst_f03_file_SOURCES = tst_f03_file.f90
-
-# Rule to build Fortran 2003 code.
-# cfcvars.o:cfcvsars.f03
-# 	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
-
-# tst_f03_file.o:tst_f03_file.f03
-# 	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
 TESTS = $(check_PROGRAMS)
 all: all-am
 
@@ -366,14 +408,14 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
-		&& exit 0; \
+	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+	        && { if test -f $@; then exit 0; else break; fi; }; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
-	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  src/Makefile
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign src/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -391,23 +433,28 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
 	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	list2=; for p in $$list; do \
 	  if test -f $$p; then \
-	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
-	    $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+	    list2="$$list2 $$p"; \
 	  else :; fi; \
-	done
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+	}
 
 uninstall-libLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
-	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
 	done
 
 clean-libLTLIBRARIES:
@@ -424,11 +471,13 @@ libcff.la: $(libcff_la_OBJECTS) $(libcff_la_DEPENDENCIES)
 	$(FCLINK) $(am_libcff_la_rpath) $(libcff_la_OBJECTS) $(libcff_la_LIBADD) $(LIBS)
 
 clean-checkPROGRAMS:
-	@list='$(check_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
+	@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
 tst_coords$(EXEEXT): $(tst_coords_OBJECTS) $(tst_coords_DEPENDENCIES) 
 	@rm -f tst_coords$(EXEEXT)
 	$(LINK) $(tst_coords_OBJECTS) $(tst_coords_LDADD) $(LIBS)
@@ -478,7 +527,7 @@ distclean-compile:
 .c.o:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
@@ -486,7 +535,7 @@ distclean-compile:
 .c.obj:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Po
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@@ -494,19 +543,19 @@ distclean-compile:
 .c.lo:
 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
- at am__fastdepCC_TRUE@	mv -f $$depbase.Tpo $$depbase.Plo
+ at am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
 .f90.o:
-	$(FCCOMPILE) -c -o $@ $<
+	$(FCCOMPILE) -c -o $@ $(FCFLAGS_f90) $<
 
 .f90.obj:
-	$(FCCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+	$(FCCOMPILE) -c -o $@ $(FCFLAGS_f90) `$(CYGPATH_W) '$<'`
 
 .f90.lo:
-	$(LTFCCOMPILE) -c -o $@ $<
+	$(LTFCCOMPILE) -c -o $@ $(FCFLAGS_f90) $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -516,34 +565,37 @@ clean-libtool:
 install-includeHEADERS: $(include_HEADERS)
 	@$(NORMAL_INSTALL)
 	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
-	@list='$(include_HEADERS)'; for p in $$list; do \
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  f=$(am__strip_dir) \
-	  echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
-	  $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
+	  echo "$$d$$p"; \
+	done | $(am__base_list) | \
+	while read files; do \
+	  echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
 	done
 
 uninstall-includeHEADERS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(include_HEADERS)'; for p in $$list; do \
-	  f=$(am__strip_dir) \
-	  echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(includedir)/$$f"; \
-	done
+	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+	test -n "$$files" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(includedir)" && rm -f $$files
 
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
 	mkid -fID $$unique
 tags: TAGS
 
 TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
+	set x; \
 	here=`pwd`; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
@@ -551,37 +603,43 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
-	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	    $$tags $$unique; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
 	fi
 ctags: CTAGS
 CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
-	tags=; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
 	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
 	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$tags $$unique
+	     $$unique
 
 GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && cd $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) $$here
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 check-TESTS: $(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[	 ]'; \
+	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
 	srcdir=$(srcdir); export srcdir; \
 	list=' $(TESTS) '; \
+	$(am__tty_colors); \
 	if test -n "$$list"; then \
 	  for tst in $$list; do \
 	    if test -f ./$$tst; then dir=./; \
@@ -590,49 +648,63 @@ check-TESTS: $(TESTS)
 	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
 	      all=`expr $$all + 1`; \
 	      case " $(XFAIL_TESTS) " in \
-	      *$$ws$$tst$$ws*) \
+	      *[\ \	]$$tst[\ \	]*) \
 		xpass=`expr $$xpass + 1`; \
 		failed=`expr $$failed + 1`; \
-		echo "XPASS: $$tst"; \
+		col=$$red; res=XPASS; \
 	      ;; \
 	      *) \
-		echo "PASS: $$tst"; \
+		col=$$grn; res=PASS; \
 	      ;; \
 	      esac; \
 	    elif test $$? -ne 77; then \
 	      all=`expr $$all + 1`; \
 	      case " $(XFAIL_TESTS) " in \
-	      *$$ws$$tst$$ws*) \
+	      *[\ \	]$$tst[\ \	]*) \
 		xfail=`expr $$xfail + 1`; \
-		echo "XFAIL: $$tst"; \
+		col=$$lgn; res=XFAIL; \
 	      ;; \
 	      *) \
 		failed=`expr $$failed + 1`; \
-		echo "FAIL: $$tst"; \
+		col=$$red; res=FAIL; \
 	      ;; \
 	      esac; \
 	    else \
 	      skip=`expr $$skip + 1`; \
-	      echo "SKIP: $$tst"; \
+	      col=$$blu; res=SKIP; \
 	    fi; \
+	    echo "$${col}$$res$${std}: $$tst"; \
 	  done; \
+	  if test "$$all" -eq 1; then \
+	    tests="test"; \
+	    All=""; \
+	  else \
+	    tests="tests"; \
+	    All="All "; \
+	  fi; \
 	  if test "$$failed" -eq 0; then \
 	    if test "$$xfail" -eq 0; then \
-	      banner="All $$all tests passed"; \
+	      banner="$$All$$all $$tests passed"; \
 	    else \
-	      banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
 	    fi; \
 	  else \
 	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all tests failed"; \
+	      banner="$$failed of $$all $$tests failed"; \
 	    else \
-	      banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
 	    fi; \
 	  fi; \
 	  dashes="$$banner"; \
 	  skipped=""; \
 	  if test "$$skip" -ne 0; then \
-	    skipped="($$skip tests were not run)"; \
+	    if test "$$skip" -eq 1; then \
+	      skipped="($$skip test was not run)"; \
+	    else \
+	      skipped="($$skip tests were not run)"; \
+	    fi; \
 	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
 	      dashes="$$skipped"; \
 	  fi; \
@@ -643,11 +715,15 @@ check-TESTS: $(TESTS)
 	      dashes="$$report"; \
 	  fi; \
 	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  echo "$$dashes"; \
+	  if test "$$failed" -eq 0; then \
+	    echo "$$grn$$dashes"; \
+	  else \
+	    echo "$$red$$dashes"; \
+	  fi; \
 	  echo "$$banner"; \
 	  test -z "$$skipped" || echo "$$skipped"; \
 	  test -z "$$report" || echo "$$report"; \
-	  echo "$$dashes"; \
+	  echo "$$dashes$$std"; \
 	  test "$$failed" -eq 0; \
 	else :; fi
 
@@ -667,13 +743,17 @@ distdir: $(DISTFILES)
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 	  if test -d $$d/$$file; then \
 	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
 	    fi; \
-	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
 	  else \
-	    test -f $(distdir)/$$file \
-	    || cp -p $$d/$$file $(distdir)/$$file \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
 	    || exit 1; \
 	  fi; \
 	done
@@ -707,6 +787,7 @@ clean-generic:
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -728,6 +809,8 @@ dvi-am:
 
 html: html-am
 
+html-am:
+
 info: info-am
 
 info-am:
@@ -736,18 +819,28 @@ install-data-am: install-includeHEADERS
 
 install-dvi: install-dvi-am
 
+install-dvi-am:
+
 install-exec-am: install-libLTLIBRARIES
 
 install-html: install-html-am
 
+install-html-am:
+
 install-info: install-info-am
 
+install-info-am:
+
 install-man:
 
 install-pdf: install-pdf-am
 
+install-pdf-am:
+
 install-ps: install-ps-am
 
+install-ps-am:
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -770,7 +863,7 @@ ps-am:
 
 uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
 
-.MAKE: install-am install-strip
+.MAKE: check-am install-am install-strip
 
 .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
 	clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \
@@ -788,6 +881,14 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
 	tags uninstall uninstall-am uninstall-includeHEADERS \
 	uninstall-libLTLIBRARIES
 
+
+# Rule to build Fortran 2003 code.
+#cfcvars.o:cfcvsars.f90
+#	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
+
+tst_f03_file.o:tst_f03_file.f90
+	$(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/src/cdTimeConv.c b/src/cdTimeConv.c
index 27120d5..375df85 100644
--- a/src/cdTimeConv.c
+++ b/src/cdTimeConv.c
@@ -8,11 +8,17 @@
  * Author:      Bob Drach, Lawrence Livermore National Laboratory
  *              drach at llnl.gov
  *
- * Version:     $Id: cdTimeConv.c,v 1.1 2008/06/30 16:07:44 ed Exp $
+ * Version:     $Id: cdTimeConv.c,v 1.2 2009/09/08 17:14:52 ed Exp $
  *
  * Revision History:
  *
  * $Log: cdTimeConv.c,v $
+ * Revision 1.2  2009/09/08 17:14:52  ed
+ * many changes
+ *
+ * Revision 1.1.1.1  2009/07/06 15:06:30  ed
+ * added libcf to netcdf dist
+ *
  * Revision 1.1  2008/06/30 16:07:44  ed
  * Beginning merge of calandar stuff.
  *
diff --git a/src/cddrs.h b/src/cddrs.h
index 9556bdc..07d07a5 100644
--- a/src/cddrs.h
+++ b/src/cddrs.h
@@ -8,11 +8,17 @@
  * Author:      Bob Drach, Lawrence Livermore National Laboratory
  *              drach at llnl.gov
  *
- * Version:     $Id: cddrs.h,v 1.1 2008/06/30 16:07:44 ed Exp $
+ * Version:     $Id: cddrs.h,v 1.2 2009/09/08 17:14:53 ed Exp $
  *
  * Revision History:
  *
  * $Log: cddrs.h,v $
+ * Revision 1.2  2009/09/08 17:14:53  ed
+ * many changes
+ *
+ * Revision 1.1.1.1  2009/07/06 15:06:30  ed
+ * added libcf to netcdf dist
+ *
  * Revision 1.1  2008/06/30 16:07:44  ed
  * Beginning merge of calandar stuff.
  *
diff --git a/src/cdms.h b/src/cdms.h
index c3c7c95..07c6d23 100644
--- a/src/cdms.h
+++ b/src/cdms.h
@@ -8,11 +8,17 @@
  * Author:      Bob Drach, Lawrence Livermore National Laboratory
  *              drach at llnl.gov
  *
- * Version:     $Id: cdms.h,v 1.1 2008/06/30 16:07:44 ed Exp $
+ * Version:     $Id: cdms.h,v 1.2 2009/09/08 17:14:53 ed Exp $
  *
  * Revision History:
  *
  * $Log: cdms.h,v $
+ * Revision 1.2  2009/09/08 17:14:53  ed
+ * many changes
+ *
+ * Revision 1.1.1.1  2009/07/06 15:06:30  ed
+ * added libcf to netcdf dist
+ *
  * Revision 1.1  2008/06/30 16:07:44  ed
  * Beginning merge of calandar stuff.
  *
diff --git a/src/cdmsint.h b/src/cdmsint.h
index 20e2750..a988846 100644
--- a/src/cdmsint.h
+++ b/src/cdmsint.h
@@ -8,11 +8,17 @@
  * Author:      Bob Drach, Lawrence Livermore National Laboratory
  *              drach at llnl.gov
  *
- * Version:     $Id: cdmsint.h,v 1.1 2008/06/30 16:07:44 ed Exp $
+ * Version:     $Id: cdmsint.h,v 1.2 2009/09/08 17:14:53 ed Exp $
  *
  * Revision History:
  *
  * $Log: cdmsint.h,v $
+ * Revision 1.2  2009/09/08 17:14:53  ed
+ * many changes
+ *
+ * Revision 1.1.1.1  2009/07/06 15:06:30  ed
+ * added libcf to netcdf dist
+ *
  * Revision 1.1  2008/06/30 16:07:44  ed
  * Beginning merge of calandar stuff.
  *
diff --git a/src/cdunif.h b/src/cdunif.h
index abcf06d..a35d366 100644
--- a/src/cdunif.h
+++ b/src/cdunif.h
@@ -8,11 +8,17 @@
  * Author:      Bob Drach, Lawrence Livermore National Laboratory
  *              drach at llnl.gov
  *
- * Version:     $Id: cdunif.h,v 1.1 2008/06/30 16:07:44 ed Exp $
+ * Version:     $Id: cdunif.h,v 1.2 2009/09/08 17:14:53 ed Exp $
  *
  * Revision History:
  *
  * $Log: cdunif.h,v $
+ * Revision 1.2  2009/09/08 17:14:53  ed
+ * many changes
+ *
+ * Revision 1.1.1.1  2009/07/06 15:06:30  ed
+ * added libcf to netcdf dist
+ *
  * Revision 1.1  2008/06/30 16:07:44  ed
  * Beginning merge of calandar stuff.
  *
diff --git a/src/cfcvars.c b/src/cfcvars.c
index 5179292..f3d6631 100644
--- a/src/cfcvars.c
+++ b/src/cfcvars.c
@@ -8,7 +8,7 @@
 
   Ed Hartnett, 9/1/06
 
-  $Id: cfcvars.c,v 1.15 2009/01/20 19:16:53 ed Exp $
+  $Id: cfcvars.c,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #include <config.h>
@@ -397,9 +397,9 @@ int
 nccf_inq_latitude(int ncid, size_t *lenp, nc_type *xtypep, 
 		  int *lat_dimidp, int *lat_varidp)
 {
-   char val[NLAT_UNITS][CF_MAX_LEN + 1] = {"degrees_north", "degree_north", 
-					   "degree_N", "degrees_N", "degreeN",
-					   "degreesN"};
+   const char val[NLAT_UNITS][CF_MAX_LEN + 1] = {"degrees_north", "degree_north", 
+						 "degree_N", "degrees_N", "degreeN",
+						 "degreesN"};
    return inq_coord_var(ncid, NLAT_UNITS, val, NULL, NULL, lenp, xtypep, 
 			NULL, NULL, NULL, lat_dimidp, lat_varidp);
 }
@@ -422,9 +422,10 @@ int
 nccf_inq_longitude(int ncid, size_t *lenp, nc_type *xtypep, 
 		   int *lon_dimidp, int *lon_varidp)
 {
-   char val[NLON_UNITS][CF_MAX_LEN] = {"degrees_east", "degree_east", 
-				       "degree_E", "degrees_E", 
-				       "degreeE", "degreesE"};
+   const char val[NLON_UNITS][CF_MAX_LEN + 1] = {
+      "degrees_east", "degree_east", "degree_E", 
+      "degrees_E", "degreeE", "degreesE"};
+
    return inq_coord_var(ncid, NLON_UNITS, val, NULL, NULL, lenp, xtypep, 
 			NULL, NULL, NULL, lon_dimidp, lon_varidp);
 }
@@ -447,7 +448,7 @@ nccf_inq_lvl(int ncid, char *name, size_t *lenp, nc_type *xtypep,
 	     size_t *ft_lenp, char *formula_terms, int *positive_upp, 
 	     int *lon_dimidp, int *lon_varidp)
 {
-   char val[NLEVEL_UNITS][CF_MAX_LEN] = 
+   const char val[NLEVEL_UNITS][CF_MAX_LEN + 1] = 
       {"bar", "standard_atmosphere", "technical_atmosphere", 
        "inch_H2O_39F", "inch_H2O_60F", "inch_Hg_32F", 
        "inch_Hg_60F", "millimeter_Hg_0C", "footH2O", "cmHg", 
@@ -479,14 +480,15 @@ int
 nccf_inq_time(int ncid, char *name, size_t *lenp, nc_type *xtypep, 
 	      int *time_dimidp, int *time_varidp)
 {
-   char val[NTIME_UNITS][CF_MAX_LEN] = {"second", "day", "hour", "minute", "s", 
-					"sec", "shake", "sidereal_day", "sidereal_hour", 
-					"sidereal_minute", "sidereal_second", 
-					"sidereal_year", "tropical_year", "lunar_month", 
-					"common_year", "leap_year", "Julian_year", 
-					"Gregorian_year", "sidereal_month", "tropical_month", 
-					"d", "min", "hr", "h", "fortnight", "week", "jiffy", 
-					"jiffies", "year", "yr", "a", "eon", "month"};
+   const char val[NTIME_UNITS][CF_MAX_LEN + 1] = {
+      "second", "day", "hour", "minute", "s", 
+      "sec", "shake", "sidereal_day", "sidereal_hour", 
+      "sidereal_minute", "sidereal_second", 
+      "sidereal_year", "tropical_year", "lunar_month", 
+      "common_year", "leap_year", "Julian_year", 
+      "Gregorian_year", "sidereal_month", "tropical_month", 
+      "d", "min", "hr", "h", "fortnight", "week", "jiffy", 
+      "jiffies", "year", "yr", "a", "eon", "month"};
 
    return inq_coord_var(ncid, NTIME_UNITS, val, NULL, NULL, lenp, xtypep, NULL, 
 			NULL, NULL, time_dimidp, time_varidp);
diff --git a/src/cferror.c b/src/cferror.c
index 808c23c..557dce2 100644
--- a/src/cferror.c
+++ b/src/cferror.c
@@ -8,7 +8,7 @@
 
   Ed Hartnett, 5/22/07
 
-  $Id: cferror.c,v 1.1 2007/05/22 14:40:33 ed Exp $
+  $Id: cferror.c,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/cffcvars.f90 b/src/cffcvars.f90
index bc19a87..e3e438b 100644
--- a/src/cffcvars.f90
+++ b/src/cffcvars.f90
@@ -2,84 +2,371 @@ module libcf
   use iso_c_binding
   implicit none
 
+  ! For some odd reason, netCDF f90 has NF90_GLOBAL=0, but NC_GLOBAL
+  ! is really -1. WTF?
+  integer, parameter:: NC_GLOBAL = -1
+
+  ! Max len of history, institution, comment, etc.
+  integer, parameter :: CF_MAX_LEN = 1024
+
+  ! Max number of allowed coordinate variables
+  integer, parameter :: CF_MAX_COORDS = 64
+
+  ! Need a null pointer to pass to C for non-present strings and a
+  ! null terminator for initializing strings.
+  character, pointer :: null_ptr => NULL()
+  character(len = 1), parameter:: NT = achar(0)
+
   ! These interfaces map to the C library calls.
-  interface
-     function nccf_def_convention(ncid) bind(c)
-       use, intrinsic :: iso_c_binding
-       integer(c_int), value :: ncid
-       integer(c_int) :: nccf_def_convention
-     end function nccf_def_convention
-
-     function nccf_def_file(ncid, title, history) bind(c)
-       use, intrinsic :: iso_c_binding
-       integer(c_int), value :: ncid
-       character(len = *), intent(in) :: title
-       character(len = *), intent(in) :: history
-       integer(c_int) :: nccf_def_file
-     end function nccf_def_file
-
-     function nccf_inq_file(ncid, title_len, title, history_len, history) bind(c)
-       use, intrinsic :: iso_c_binding
-       integer(c_int), value :: ncid
-       integer(c_size_t), intent(out) :: title_len
-       character(len = *), intent(out) :: title
-       integer(c_size_t), intent(out) :: history_len
-       character(len = *), intent(out) :: history
-       integer(c_int) :: nccf_inq_file
-     end function nccf_inq_file
-  end interface
+  include 'libcf_api.f90'
 
 contains
 
   ! These functions are the new libcf F90 API.
-  function cf_def_file(ncid, convention, title, history)
+  function cf_def_file(ncid, convention, title, history, institution, &
+       source, comment, references)
     use iso_c_binding
+    use netcdf
     implicit none
-    integer, intent(in)::ncid
-    character (len = *), optional, intent(in):: convention
-    character (len = *), optional, intent(in):: title
-    character (len = *), optional, intent(in):: history
+    integer, intent(in) :: ncid
+    character(len = *), optional, intent(in):: convention, title, history, &
+         institution, source, comment, references
+    character(len = CF_MAX_LEN), pointer :: p_history => NULL(), p_title => NULL()
+    character(len = CF_MAX_LEN), target :: c_history, c_title
+    character(len = CF_MAX_LEN), pointer :: p_institution => NULL(), p_source => NULL(), &
+         p_comment => NULL(), p_references => NULL()
+    character(len = CF_MAX_LEN), target :: c_institution, c_source, c_comment, &
+         c_references
     integer:: cf_def_file
-    integer(c_int):: c_ncid
-    character (len = 80) c_title, c_history
 
-    c_ncid = ncid
+    cf_def_file = NF90_NOERR
+
+    ! Handle convention.
     if (present(convention)) then
-       cf_def_file = nccf_def_convention(c_ncid)
-       if (cf_def_file .ne. 0) then
-          return
+       cf_def_file = nccf_def_convention(ncid)
+       if (cf_def_file .ne. 0) return
+    endif
+
+    ! Handle title and history.
+    if (present(title) .or. present(history)) then
+       if (present(title)) then
+          p_title => c_title
+          p_title = trim(title)//c_null_char
+       endif
+       if (present(history)) then
+          p_history => c_history
+          p_history = trim(history)//c_null_char
        endif
+       cf_def_file = nccf_def_file(ncid, p_title, p_history)
+       if (cf_def_file .ne. 0) return
+    endif
+
+    ! Handle institution, source, comment, and references.
+    if (present(institution) .or. present(source) .or. present(comment) .or. &
+         present(references)) then
+       if (present(institution)) then
+          p_institution => c_institution
+          p_institution = trim(institution)//c_null_char
+       endif
+       if (present(source)) then
+          p_source => c_source
+          p_source = trim(source)//c_null_char
+       endif
+       if (present(comment)) then
+          p_comment => c_comment
+          p_comment = trim(comment)//c_null_char
+       endif
+       if (present(references)) then
+          p_references => c_references
+          p_references = trim(references)//c_null_char
+       endif
+       cf_def_file = nccf_def_notes(ncid, NC_GLOBAL, p_institution, p_source, &
+            p_comment, p_references)
+    endif
+  end function cf_def_file
+
+  function cf_def_var(ncid, varid, units, long_name, standard_name, &
+       ncoord_vars, coord_varids, institution, source, comment, references)
+    use iso_c_binding
+    use netcdf
+    implicit none
+    integer(c_int), intent(in) :: ncid, varid
+    integer, optional, intent(in) :: ncoord_vars
+    integer, target :: c_ncoord_vars = 0
+    integer, optional, dimension(:), intent(in) :: coord_varids
+    integer, target, dimension(CF_MAX_COORDS) :: c_coord_varids
+    character(len = *), optional, intent(in) :: institution, source, &
+         comment, references, units, long_name, standard_name
+    character(len = CF_MAX_LEN), target :: c_units, c_long_name, c_standard_name
+    character(len = CF_MAX_LEN), target :: c_institution, c_source, &
+         c_comment, c_references
+    character(len = CF_MAX_LEN), pointer :: p_units => NULL(), &
+         p_long_name => NULL(), p_standard_name => NULL()
+    character(len = CF_MAX_LEN), pointer :: p_institution => NULL(), p_source => NULL(), &
+         p_comment => NULL(), p_references => NULL()
+    integer  :: cf_def_var, i
+
+    cf_def_var = NF90_NOERR
+
+    ! Check input consistency.
+    if (present(ncoord_vars) .and. .not. present(coord_varids)) then
+       cf_def_var = NF90_EINVAL
+       return
     endif
-    if (present(title)) then
-       c_title = title
-       c_title(len_trim(title) + 1:len_trim(title) + 1) = achar(0)
-    else
-       c_title = ''
+
+    ! Handle institution, source, comment, and references.
+    if (present(institution) .or. present(source) .or. present(comment) .or. &
+         present(references)) then
+       if (present(institution)) then
+          p_institution => c_institution
+          p_institution = trim(institution)//c_null_char
+       endif
+       if (present(source)) then
+          p_source => c_source
+          p_source = trim(source)//c_null_char
+       endif
+       if (present(comment)) then
+          p_comment => c_comment
+          p_comment = trim(comment)//c_null_char
+       endif
+       if (present(references)) then
+          p_references => c_references
+          p_references = trim(references)//c_null_char
+       endif
+       cf_def_var = nccf_def_notes(ncid, varid - 1, p_institution, p_source, &
+            p_comment, p_references)
+       if (cf_def_var .ne. 0) return
     endif
-    if (present(history)) then
-       c_history = history
-       c_history(len_trim(history) + 1:len_trim(history) + 1) = achar(0)
-    else
-       c_history = ''
+
+    ! Handle units, long_name, standard_name.
+    if (present(units) .or. present(long_name) .or. present(standard_name) .or. &
+         present(ncoord_vars) .or. present(coord_varids)) then
+       if (present(units)) then
+          p_units => c_units
+          p_units = trim(units)//c_null_char
+       endif
+       if (present(long_name)) then
+          p_long_name => c_long_name
+          p_long_name = trim(long_name)//c_null_char
+       endif
+       if (present(standard_name)) then
+          p_standard_name => c_standard_name
+          p_standard_name = trim(standard_name)//c_null_char
+       endif
+       if (present(ncoord_vars)) c_ncoord_vars = ncoord_vars
+       if (present(coord_varids)) then
+          do i = 1, ncoord_vars
+             c_coord_varids(i) = coord_varids(i) - 1
+          end do
+       endif
+
+       cf_def_var = nccf_def_var(ncid, varid - 1, p_units, p_long_name, &
+            p_standard_name, c_ncoord_vars, c_coord_varids)
     endif
-    cf_def_file = nccf_def_file(ncid, c_title, c_history)
+  end function cf_def_var
+  
+  function cf_inq_var(ncid, varid, units, long_name, standard_name, &
+       ncoord_vars, coord_varids, institution, source, comment, references)
+    use iso_c_binding
+    use netcdf
+    implicit none
+    integer, intent(in) :: ncid, varid
+    character(len = *), optional, intent(out) :: units, long_name, standard_name
+    character(len = CF_MAX_LEN), target :: c_units, c_long_name, c_standard_name
+    character(len = CF_MAX_LEN), pointer :: p_units => NULL(), p_long_name => NULL(), &
+         p_standard_name => NULL()
+    integer(c_size_t) :: c_units_len, c_long_name_len, c_standard_name_len
+    character(len = *), optional, intent(out) :: institution, source, comment, references
+    character(len = CF_MAX_LEN), target :: c_institution, c_source, c_comment, c_references
+    integer(c_size_t) :: c_institution_len, c_source_len, c_comment_len, c_references_len
+    character(len = CF_MAX_LEN), pointer :: p_institution => NULL(), p_source => NULL(), &
+         p_comment => NULL(), p_references => NULL()
+    integer, intent(out), optional :: ncoord_vars
+    integer, dimension(*), optional, intent(out) :: coord_varids
+    integer :: c_ncoord_vars
+    integer, dimension(CF_MAX_COORDS) :: c_coord_varids
+    integer :: cf_inq_var, i
 
-  end function cf_def_file
+    if (present(units)) p_units => c_units
+    if (present(long_name)) p_long_name => c_long_name
+    if (present(standard_name)) p_standard_name => c_standard_name
+
+    cf_inq_var = nccf_inq_var(ncid, varid - 1, c_units_len, p_units, c_long_name_len, &
+         p_long_name, c_standard_name_len, p_standard_name, c_ncoord_vars, c_coord_varids)
+
+    if (present(units)) then
+       units = trim(c_units)
+       if (index(units, C_NULL_CHAR) .gt. 0) then
+          units(index(units, C_NULL_CHAR):len(units)) = ' '
+       endif
+    endif
+    if (present(long_name)) then
+       long_name = trim(c_long_name)
+       if (index(long_name, C_NULL_CHAR) .gt. 0) then
+          long_name(index(long_name, C_NULL_CHAR):len(long_name)) = ' '
+       endif
+    endif
+    if (present(standard_name)) then
+       standard_name = trim(c_standard_name)
+       if (index(standard_name, C_NULL_CHAR) .gt. 0) then
+          standard_name(index(standard_name, C_NULL_CHAR):len(standard_name)) = ' '
+       endif
+    endif
+    if (present(ncoord_vars)) ncoord_vars = c_ncoord_vars
+    if (present(coord_varids)) then
+       do i = 1, c_ncoord_vars
+          coord_varids(i) = c_coord_varids(i) + 1
+       end do
+    endif
+
+    if (present(institution)) p_institution => c_institution
+    if (present(source)) p_source => c_source 
+    if (present(comment)) p_comment => c_comment
+    if (present(references)) p_references => c_references
+
+    ! Get the institution and source strings.
+    cf_inq_var = nccf_inq_notes(ncid, varid - 1, c_institution_len, p_institution, &
+         c_source_len, p_source, c_comment_len, p_comment, c_references_len, &
+         p_references)
+    if (cf_inq_var .ne. NF90_NOERR) return
+
+    ! Copy the strings.
+    if (present(institution)) then
+       institution = p_institution(:len(institution))
+       if (index(institution, NT) .gt. 0) then
+          institution(index(institution, NT):len(institution)) = ' '
+       endif
+    endif
+    if (present(source)) then
+       source = p_source(:len(source))
+       if (index(source, NT) .gt. 0) then
+          source(index(source, NT):len(source)) = ' '
+       endif
+    endif
+    if (present(comment)) then
+       comment = p_comment(:len(comment))
+       if (index(comment, NT) .gt. 0) then
+          comment(index(comment, NT):len(comment)) = ' '
+       endif
+    endif
+    if (present(references)) then
+       references = p_references(:len(references))
+       if (index(references, NT) .gt. 0) then
+          references(index(references, NT):len(references)) = ' '
+       endif
+    endif
+  end function cf_inq_var
+
+  ! Input string MUST have length less then CF_MAX_LEN or universe
+  ! might collapse into a singularity.
+  function cstr(in_str)
+    use iso_c_binding
+    implicit none
+    character(len = *), intent(in):: in_str
+    character(len = CF_MAX_LEN) :: cstr
+
+    !print *, 'in_str=', in_str
+    cstr = achar(0)
+    if (len(in_str) .gt. CF_MAX_LEN) return
+    
+    cstr = in_str
+    cstr(len_trim(in_str) + 1:len_trim(in_str) + 1) = achar(0)
+  end function cstr
+
+  function cf_add_history(ncid, history)
+    use iso_c_binding
+    implicit none
+    integer, intent(in)::ncid
+    character (len = *), intent(in):: history
+    integer:: cf_add_history
+    integer(c_int):: c_ncid
+    character(len = 256):: c_history
+
+    c_ncid = ncid
+    c_history = history
+    c_history(len_trim(history) + 1:len_trim(history) + 1) = achar(0)
+    cf_add_history = nccf_add_history(ncid, c_history)
 
-  function cf_inq_file(ncid, title, history)
+  end function cf_add_history
+
+  function cf_inq_file(ncid, title, history, institution, source, &
+       comment, references)
     use iso_c_binding
+    use netcdf
     implicit none
     integer, intent(in):: ncid
-    character (len = *), intent(inout):: title, history
+    character (len = *), optional, intent(out):: title, history, institution
+    character (len = *), optional, intent(out):: source, comment, references
     integer:: cf_inq_file
-    integer(c_size_t):: title_len, history_len
-    character (len = 1), parameter:: NULL = achar(0)
-
-    cf_inq_file = nccf_inq_file(ncid, title_len, title, history_len, history)
-    title(index(title, NULL):len(title)) = ' '
-    title_len = title_len - 1
-    history(index(history, NULL):len(history)) = ' '
-    history_len = history_len - 1
-    end function cf_inq_file
+    integer(c_size_t):: c_title_len, c_history_len, c_institution_len
+    integer(c_size_t):: c_source_len, c_comment_len, c_references_len
+    character(len = CF_MAX_LEN), target :: c_history, c_title, c_institution, c_source, &
+         c_comment, c_references
+    character(len = CF_MAX_LEN), pointer :: p_history => NULL(), p_title => NULL(), &
+         p_institution => NULL(), p_source => NULL(), p_comment => NULL(), p_references => NULL()
+
+    cf_inq_file = NF90_NOERR
+    if (present(title) .or. present(history)) then
+       
+       if (present(title)) p_title => c_title
+       if (present(history)) p_history => c_history
+
+       cf_inq_file = nccf_inq_file(ncid, c_title_len, p_title, c_history_len, &
+            p_history)
+       if (cf_inq_file .ne. NF90_NOERR) return
+
+       ! Copy the strings.
+       if (present(title)) then
+          title = c_title(:len(title))
+          if (index(title, NT) .gt. 0) then
+             title(index(title, NT):len(title)) = ' '
+          endif
+       endif
+       if (present(history)) then
+          history = c_history(:len(history))
+          if (index(history, NT) .gt. 0) then
+             history(index(history, NT):len(history)) = ' '
+          endif
+       endif
+
+    endif ! present(title) .or. present(history)
 
+    if (present(institution)) p_institution => c_institution
+    if (present(source)) p_source => c_source 
+    if (present(comment)) p_comment => c_comment
+    if (present(references)) p_references => c_references
+
+    ! Get the institution and source strings.
+    cf_inq_file = nccf_inq_notes(ncid, NC_GLOBAL, c_institution_len, p_institution, &
+         c_source_len, p_source, c_comment_len, p_comment, c_references_len, &
+         p_references)
+    if (cf_inq_file .ne. NF90_NOERR) return
+
+    ! Copy the strings.
+    if (present(institution)) then
+       institution = p_institution(:len(institution))
+       if (index(institution, NT) .gt. 0) then
+          institution(index(institution, NT):len(institution)) = ' '
+       endif
+    endif
+    if (present(source)) then
+       source = p_source(:len(source))
+       if (index(source, NT) .gt. 0) then
+          source(index(source, NT):len(source)) = ' '
+       endif
+    endif
+    if (present(comment)) then
+       comment = p_comment(:len(comment))
+       if (index(comment, NT) .gt. 0) then
+          comment(index(comment, NT):len(comment)) = ' '
+       endif
+    endif
+    if (present(references)) then
+       references = p_references(:len(references))
+       if (index(references, NT) .gt. 0) then
+          references(index(references, NT):len(references)) = ' '
+       endif
+    endif
+    
+    end function cf_inq_file
 end module libcf
diff --git a/src/cffiles.c b/src/cffiles.c
index 26f1811..43836a6 100644
--- a/src/cffiles.c
+++ b/src/cffiles.c
@@ -8,7 +8,7 @@ This file handles the libcf file stuff.
 
 Ed Hartnett, 9/1/06
 
-$Id: cffiles.c,v 1.7 2009/04/12 14:10:35 ed Exp $
+$Id: cffiles.c,v 1.3 2009/09/28 14:52:22 ed Exp $
 */
 
 #include <config.h>
@@ -75,7 +75,7 @@ nccf_append_att(int ncid, const char *name, const char *string)
       }
 
       /* Append our string to the existing att. */
-      att_str[new_len] = 0;
+      att_str[len] = 0;
       strcat(att_str, " ");
       strcat(att_str, string);
 
@@ -313,44 +313,76 @@ int nccf_inq_notes(int ncid, int varid, size_t *institution_lenp,
    int ret;
 
    if (institution_lenp)
-      if ((ret = nc_inq_attlen(ncid, varid, CF_INSTITUTION, 
-				  institution_lenp)))
+   {
+      ret = nc_inq_attlen(ncid, varid, CF_INSTITUTION, institution_lenp);
+      if (ret == NC_ENOTATT)
+	 *institution_lenp = 0;
+      else if (ret)
 	 return ret;
+   }
 
    if (institution)
-      if ((ret = nc_get_att_text(ncid, varid, CF_INSTITUTION,
-				    institution)))
+   {
+      ret = nc_get_att_text(ncid, varid, CF_INSTITUTION, institution);
+      if (ret == NC_ENOTATT)
+	 strcpy(institution, "");
+      else if (ret)
 	 return ret;
+   }
 
    if (source_lenp)
-      if ((ret = nc_inq_attlen(ncid, varid, CF_SOURCE, 
-				  source_lenp)))
+   {
+      ret = nc_inq_attlen(ncid, varid, CF_SOURCE, source_lenp);
+      if (ret == NC_ENOTATT)
+	 *source_lenp = 0;
+      else if (ret)
 	 return ret;
+   }
 
    if (source)
-      if ((ret = nc_get_att_text(ncid, varid, CF_SOURCE,
-				    source)))
+   {
+      ret = nc_get_att_text(ncid, varid, CF_SOURCE, source);
+      if (ret == NC_ENOTATT)
+	 strcpy(source, "");
+      else if (ret)
 	 return ret;
+   }
 
    if (comment_lenp)
-      if ((ret = nc_inq_attlen(ncid, varid, CF_COMMENT, 
-				  comment_lenp)))
+   {
+      ret = nc_inq_attlen(ncid, varid, CF_COMMENT, comment_lenp);
+      if (ret == NC_ENOTATT)
+	 *comment_lenp = 0;
+      else if (ret)
 	 return ret;
+   }
 
    if (comment)
-      if ((ret = nc_get_att_text(ncid, varid, CF_COMMENT,
-				    comment)))
+   {
+      ret = nc_get_att_text(ncid, varid, CF_COMMENT, comment);
+      if (ret == NC_ENOTATT)
+	 strcpy(comment, "");
+      else if (ret)
 	 return ret;
+   }
 
    if (references_lenp)
-      if ((ret = nc_inq_attlen(ncid, varid, CF_REFERENCES, 
-				  references_lenp)))
+   {
+      ret = nc_inq_attlen(ncid, varid, CF_REFERENCES, references_lenp);
+      if (ret == NC_ENOTATT)
+	 *references_lenp = 0;
+      else if (ret)
 	 return ret;
+   }
 
    if (references)
-      if ((ret = nc_get_att_text(ncid, varid, CF_REFERENCES,
-				    references)))
+   {
+      ret = nc_get_att_text(ncid, varid, CF_REFERENCES, references);
+      if (ret == NC_ENOTATT)
+	 strcpy(references, "");
+      else if (ret)
 	 return ret;
+   }
    
    return NC_NOERR;
 }
diff --git a/src/cfsubsets.c b/src/cfsubsets.c
index a2bdafd..a6f35d0 100644
--- a/src/cfsubsets.c
+++ b/src/cfsubsets.c
@@ -8,7 +8,7 @@
 
   Ed Hartnett, 5/1/7
 
-  $Id: cfsubsets.c,v 1.7 2007/05/22 14:40:50 ed Exp $
+  $Id: cfsubsets.c,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/cfvars.c b/src/cfvars.c
index e39ac5e..7de3d85 100644
--- a/src/cfvars.c
+++ b/src/cfvars.c
@@ -8,7 +8,7 @@ This file handles the libcf file stuff.
 
 Ed Hartnett, 10/1/06
 
-$Id: cfvars.c,v 1.7 2006/11/11 15:03:03 ed Exp $
+$Id: cfvars.c,v 1.3 2009/09/28 14:52:23 ed Exp $
 */
 
 #include <config.h>
@@ -46,6 +46,13 @@ This function makes all of these optional.
 */
 
 int
+nccf_def_var1(int ncid, int varid, const char *units, 
+	     const char *long_name, const char *standard_name, 
+	     int ncoord_vars, int *coord_varids)
+{
+   return nccf_def_var(ncid, varid, units, long_name, standard_name, 0, NULL);
+}
+int
 nccf_def_var(int ncid, int varid, const char *units, 
 	     const char *long_name, const char *standard_name, 
 	     int ncoord_vars, int *coord_varids)
@@ -116,41 +123,69 @@ nccf_inq_var(int ncid, int varid,
 
    /* Read units length if desired. */
    if (units_lenp)
-      if ((ret = nc_inq_attlen(ncid, varid, CF_UNITS, units_lenp)))
+   {
+      if ((ret = nc_inq_attlen(ncid, varid, CF_UNITS, units_lenp)) == NC_ENOTATT)
+	 *units_lenp = 0;
+      else if (ret)
 	 return ret;
+   }
 
    /* Read units value if desired. */
    if (units)
-      if ((ret = nc_get_att_text(ncid, varid, CF_UNITS, units)))
+   {
+      if ((ret = nc_get_att_text(ncid, varid, CF_UNITS, units)) == NC_ENOTATT)
+	 strcpy(units, "");
+      else if (ret)
 	 return ret;
+   }
 
    if (long_name_lenp)
+   {
       if ((ret = nc_inq_attlen(ncid, varid, CF_LONG_NAME, 
-			       long_name_lenp)))
+			       long_name_lenp)) == NC_ENOTATT)
+	 *long_name_lenp = 0;
+      else if (ret)
 	 return ret;
+   }
 
    if (long_name)
-      if ((ret = nc_get_att_text(ncid, varid, CF_LONG_NAME, long_name)))
+   {
+      if ((ret = nc_get_att_text(ncid, varid, CF_LONG_NAME, long_name)) == NC_ENOTATT)
+	 strcpy(long_name, "");
+      else if (ret)
 	 return ret;
+   }
 
    if (standard_name_lenp)
+   {
       if ((ret = nc_inq_attlen(ncid, varid, CF_STANDARD_NAME, 
-			       standard_name_lenp)))
+			       standard_name_lenp)) == NC_ENOTATT)
+	 *standard_name_lenp = 0;
+      else if (ret)
 	 return ret;
+   }
 
    if (standard_name)
+   {
       if ((ret = nc_get_att_text(ncid, varid, CF_STANDARD_NAME,
-				 standard_name)))
+				 standard_name)) == NC_ENOTATT)
+	 strcpy(standard_name, "");
+      else if (ret)
 	 return ret;
+   }
 
    /* Learn the number of coordinate variables, and their IDs, if
     * desired. */
    if ((ret = nccf_parse_coords(ncid, varid, CF_COORDINATES, 
-				ncoord_vars, coord_varids)))
+				ncoord_vars, coord_varids)) == NC_ENOTATT)
+   {
+      if (ncoord_vars) 
+	 *ncoord_vars = 0;
+   }
+   else if (ret)
       return ret;
-
+      
    return NC_NOERR;
-
 }
 
 /* Set attributes to define missing data information. */
diff --git a/src/drscdf.h b/src/drscdf.h
index d00bc8c..bb4cfcd 100644
--- a/src/drscdf.h
+++ b/src/drscdf.h
@@ -1,6 +1,12 @@
 /*
-     $Id: drscdf.h,v 1.1 2008/06/30 16:07:44 ed Exp $
+     $Id: drscdf.h,v 1.2 2009/09/08 17:14:53 ed Exp $
      $Log: drscdf.h,v $
+     Revision 1.2  2009/09/08 17:14:53  ed
+     many changes
+
+     Revision 1.1.1.1  2009/07/06 15:06:30  ed
+     added libcf to netcdf dist
+
      Revision 1.1  2008/06/30 16:07:44  ed
      Beginning merge of calandar stuff.
 
diff --git a/src/libcf.h b/src/libcf.h
index cd47fe4..a84713b 100644
--- a/src/libcf.h
+++ b/src/libcf.h
@@ -10,15 +10,15 @@ http://www.unidata.ucar.edu/software/nccflib/
 
 Ed Hartnett, 8/1/06
 
-$Id: libcf.h,v 1.31 2008/06/30 16:35:02 ed Exp $
+$Id: libcf.h,v 1.5 2009/10/29 11:51:21 ed Exp $
 */
 
-#include <stdlib.h>
-#include <netcdf.h>
-
 #ifndef _NCCFLIB_
 #define _NCCFLIB_
 
+#include <stdlib.h>
+#include <netcdf.h>
+
 #define COORDINATE_AXIS_TYPE "_CoordinateAxisType"
 #define COORDINATE_AXES "_CoordinateAxes"
 #define COORDINATE_Z_IS_POSITIVE "_CoordinateZisPositive"
@@ -223,113 +223,103 @@ extern "C" {
 		    int *ncoord_vars, int *coord_varids);
 
    /* Set attributes to define missing data information. */
-   int nccf_def_var_missing(int ncid, int varid, const void *fill_value, 
+   int nccf_def_var_missing(int ncid, int varid, const void *fill_value,
 			    const void *valid_min, const void *valid_max);
 
    /* Get attributes which define missing data information. */
-   int nccf_inq_var_missing(int ncid, int varid, void *fill_value, 
+   int nccf_inq_var_missing(int ncid, int varid, void *fill_value,
 			    void *valid_min, void *valid_max);
 
    /* Add any or all of these four attributes to a file or variable. */
-   int nccf_def_notes(int ncid, int varid, const char *institution, 
-		      const char *source, const char *comment, 
+   int nccf_def_notes(int ncid, int varid, const char *institution,
+		      const char *source, const char *comment,
 		      const char *references);
 
    /* Read any or all of these four attributes of a file or
     * variable. */
    int nccf_inq_notes(int ncid, int varid,
-		      size_t *institution_lenp, char *institution, 
-		      size_t *source_lenp, char *source, 
-		      size_t *comment_lenp, char *comment, 
+		      size_t *institution_lenp, char *institution,
+		      size_t *source_lenp, char *source,
+		      size_t *comment_lenp, char *comment,
 		      size_t *references_lenp, char *references);
 
-   /* Set attributes to define missing data information. */
-   int nccf_def_var_missing(int ncid, int varid, const void *fill_valuep, 
-			    const void *valid_minp, const void *valid_maxp);
-
-   /* Get attributes which define missing data information. If the
-    * attributes are not there, then provide the valid data anyway, based
-    * on netCDF defaults. */
-   int nccf_inq_var_missing(int ncid, int varid, void *fill_valuep, 
-			    void *valid_minp, void *valid_maxp);
-
    /* Define a latitude dimension and variable with all the CF
     * recomended attribute accessories.*/
-   int nccf_def_latitude(int ncid, size_t len, nc_type xtype, 
+   int nccf_def_latitude(int ncid, size_t len, nc_type xtype,
 			 int *lat_dimidp, int *lat_varidp);
 
    /* Inquire about a latitude dimension and coordinate variable. */
-   int nccf_inq_latitude(int ncid, size_t *lenp, nc_type *xtypep, 
+   int nccf_inq_latitude(int ncid, size_t *lenp, nc_type *xtypep,
 			 int *lat_dimidp, int *lat_varidp);
 
    /* Define a longitude dimension and variable with all the CF
     * recomended attribute accessories.*/
-   int nccf_def_longitude(int ncid, size_t len, nc_type xtype, 
+   int nccf_def_longitude(int ncid, size_t len, nc_type xtype,
 			  int *lon_dimidp, int *lon_varidp);
 
    /* Inquire about a longitude dimension and coordinate variable.*/
-   int nccf_inq_longitude(int ncid, size_t *lenp, nc_type *xtypep, 
+   int nccf_inq_longitude(int ncid, size_t *lenp, nc_type *xtypep,
 			  int *lon_dimidp, int *lon_varidp);
 
-   int nccf_def_lvl(int ncid, const char *name, size_t len, nc_type xtype, 
-		    const char *units, int positive_up, 
-		    const char *standard_name, const char *formula_terms, 
+   int nccf_def_lvl(int ncid, const char *name, size_t len, nc_type xtype,
+		    const char *units, int positive_up,
+		    const char *standard_name, const char *formula_terms,
 		    int cdm_axis_type, int *lvl_dimidp, int *lvl_varidp);
 
    /* Inquire about a vertical dimension and coordinate variable. */
-   int nccf_inq_lvl(int ncid, char *name, size_t *lenp, nc_type *xtypep, 
-		    size_t *ft_lenp, char *formula_terms, int *positive_upp, 
+   int nccf_inq_lvl(int ncid, char *name, size_t *lenp, nc_type *xtypep,
+		    size_t *ft_lenp, char *formula_terms, int *positive_upp,
 		    int *lvl_dimidp, int *lvl_varidp);
 
    /* Define a time coordinate variable and dimension. */
-   int nccf_def_time(int ncid, const char *name, size_t len, nc_type xtype, 
-		     const char *units, const char *standard_name, 
+   int nccf_def_time(int ncid, const char *name, size_t len, nc_type xtype,
+		     const char *units, const char *standard_name,
 		     int *time_dimidp, int *time_varidp);
 
    /* Inquire about a time dimension and coordinate variable. */
-   int nccf_inq_time(int ncid, char *name, size_t *lenp, nc_type *xtypep, 
+   int nccf_inq_time(int ncid, char *name, size_t *lenp, nc_type *xtypep,
 		     int *time_dimidp, int *time_varidp);
 
    /* Define a unitless vertical coordinate. */
-   int nccf_def_lvl_vert(int ncid, int lvl_type, const char *name, nc_type xtype, 
+   int nccf_def_lvl_vert(int ncid, int lvl_type, const char *name, nc_type xtype,
 			 size_t len, int *lvl_dimidp, int *lvl_varidp);
 
    /* Learn about a unitless vertical coordinate. */
-   int nccf_inq_lvl_vert(int ncid, char *name, nc_type *xtypep, size_t *lenp, 
+   int nccf_inq_lvl_vert(int ncid, char *name, nc_type *xtypep, size_t *lenp,
 			 int *lvl_typep, int *lvl_dimidp, int *lvl_varidp);
 
    /* Define atmosphere sigma coordinate. */
-   int nccf_def_lvl_sigma(int ncid, const char *name, nc_type xtype, 
+   int nccf_def_lvl_sigma(int ncid, const char *name, nc_type xtype,
 			  size_t len, int *lvl_dimidp, int *lvl_varidp);
 
    /* Set the formula_terms to contain information about this level. */
    int nccf_def_ft_sigma(int ncid, int lvl_vid, int ps_vid, int p0_vid);
    
    /* Inquire about atmosphere sigma coordinate. */
-   int nccf_inq_lvl_sigma(int ncid, char *name, nc_type *xtypep, size_t *lenp, 
-			  int *ps_varidp, int *ptop_varidp, int *lvl_dimidp, 
+   int nccf_inq_lvl_sigma(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+			  int *ps_varidp, int *ptop_varidp, int *lvl_dimidp,
 			  int *lvl_varidp);
 
    /* Define hybrid_sigma coordinate. */
-   int nccf_def_lvl_hybrid_sigma(int ncid, const char *name, nc_type xtype, 
+   int nccf_def_lvl_hybrid_sigma(int ncid, const char *name, nc_type xtype,
 				 size_t len, int *lvl_dimidp, int *lvl_varidp);
 
    /* Set the formula_terms to contain information about this level. */
-   int nccf_def_ft_hybrid_sigma(int ncid, int lvl_vid, int a_vid, int b_vid, int ps_vid, 
+   int nccf_def_ft_hybrid_sigma(int ncid, int lvl_vid, int a_vid, int b_vid, int ps_vid,
 				int p0_vid);
 
    /* Inquire about hybrid_sigma coordinate. */
-   int nccf_inq_lvl_hybrid_sigma(int ncid, char *name, nc_type *xtypep, 
-				 size_t *lenp, int *a_varidp, int *b_varidp, 
-				 int *ps_varidp, int *p0_varidp, int *lvl_dimidp, 
+   int nccf_inq_lvl_hybrid_sigma(int ncid, char *name, nc_type *xtypep,
+				 size_t *lenp, int *a_varidp, int *b_varidp,
+				 int *ps_varidp, int *p0_varidp, int *lvl_dimidp,
 				 int *lvl_varidp);
 
    /* Define hybrid_sigma coordinate. */
-   int nccf_def_lvl_hybrid_sigma_full(int ncid, const char *name, nc_type xtype, 
+   int nccf_def_lvl_hybrid_sigma_full(int ncid, const char *name, nc_type xtype,
 				      size_t len, int *lvl_dimidp, int *lvl_varidp);
 
    /* Define hybrid_sigma coordinate. */
-   int nccf_def_ft_hybrid_sigma_full(int ncid, int varid, int a_varid, int b_varid, 
+   int nccf_def_ft_hybrid_sigma_full(int ncid, int varid, int a_varid, int b_varid,
 				     int ps_varid, int p0_varid);
 
    /* Define hybrid_height coordinate. */
@@ -337,7 +327,7 @@ extern "C" {
 				  int *lvl_dimidp, int *lvl_varidp);
 
    /* Define hybrid_height coordinate. */
-   int nccf_def_ft_hybrid_height(int ncid, int varid, int a_varid, int b_varid, 
+   int nccf_def_ft_hybrid_height(int ncid, int varid, int a_varid, int b_varid,
 				 int orog_varid);
 
    /* Inquire about hybrid_height coordinate. */
@@ -346,11 +336,11 @@ extern "C" {
 				  int *lvl_dimidp, int *lvl_varidp);
 
    /* Define sleve coordinate. */
-   int nccf_def_lvl_sleve(int ncid, const char *name, nc_type xtype, size_t len, 
+   int nccf_def_lvl_sleve(int ncid, const char *name, nc_type xtype, size_t len,
 			  int *lvl_dimidp, int *lvl_varidp);
 
    /* Define sleve coordinate. */
-   int nccf_def_ft_sleve(int ncid, int varid, int a_varid, int b1_varid, int b2_varid, 
+   int nccf_def_ft_sleve(int ncid, int varid, int a_varid, int b1_varid, int b2_varid,
 			 int ztop_varid, int zsurf1_varid, int zsurf2_varid);
 
    /* Inquire about sleve coordinate. */
@@ -373,7 +363,7 @@ extern "C" {
    int nccf_def_lvl_ocean_s(int ncid, const char *name, nc_type xtype, size_t len,
 			    int *lvl_dimidp, int *lvl_varidp);
 
-   int nccf_def_ft_ocean_s(int ncid, int varid, int eta_varid, int depth_varid, 
+   int nccf_def_ft_ocean_s(int ncid, int varid, int eta_varid, int depth_varid,
 			   int a_varid, int b_varid, int depth_c_varid);
 
    int nccf_inq_lvl_ocean_s(int ncid, char *name, nc_type *xtypep, size_t *lenp,
@@ -396,7 +386,7 @@ extern "C" {
    int nccf_def_lvl_ocean_dbl_sigma(int ncid, const char *name, nc_type xtype, size_t len,
 				    int *lvl_dimidp, int *lvl_varidp);
 
-   int nccf_def_ft_ocean_dbl_sigma(int ncid, int varid, int depth_varid, int z1_varid, 
+   int nccf_def_ft_ocean_dbl_sigma(int ncid, int varid, int depth_varid, int z1_varid,
 				   int z2_varid, int a_varid, int href_varid, int k_c_varid);
 
 
@@ -418,12 +408,12 @@ extern "C" {
     * represented by a coordinate varid in the axis_varids array. This
     * create a new (scalar, NC_CHAR) var, whose varid is returned in
     * system_varid. */
-   int nccf_def_coord_system(int ncid, const char *name, int naxes, int *axis_varids, 
+   int nccf_def_coord_system(int ncid, const char *name, int naxes, int *axis_varids,
 			     int *system_varid);
 
    /* Find out about a coordinate system, it's name, number of axes, and
     * the varid of each axis coordinate var. */
-   int nccf_inq_coord_system(int ncid, int system_varid, char *name, 
+   int nccf_inq_coord_system(int ncid, int system_varid, char *name,
 			     int *naxes, int *axis_varids);
 
    /* Assign a coordinate system to a var. This adds an attriibute to the
@@ -433,14 +423,14 @@ extern "C" {
    /* Define a coordinate transform. This adds a (scalar, NC_CHAR) var,
     * which contains some attributes. The varid of this new variable is
     * returned in transform_varid. */
-   int nccf_def_transform(int ncid, const char *name, const char *transform_type, 
+   int nccf_def_transform(int ncid, const char *name, const char *transform_type,
 			  const char *transform_name, int *transform_varid);
 
    /* Find out about a coordinate transform, it's name, and the contents
     * of the transform_type and transform_name attributes. Pass NULL for
     * any that you're not interested in. Pass NULL for transform_type and
     * transform_name to get their lengths with type_len and name_len. */
-   int nccf_inq_transform(int ncid, int transform_varid, char *name, size_t *type_len, 
+   int nccf_inq_transform(int ncid, int transform_varid, char *name, size_t *type_len,
 			  char *transform_type, size_t *name_len, char *transform_name);
 
    /* Assign a coordinate transform to a coordinate system. This adds an
@@ -449,58 +439,58 @@ extern "C" {
    int nccf_assign_transform(int ncid, int system_varid, int transform_varid);
 
    /* 4D geographic subsetting. */
-   int nccf_get_vara(int ncid, int varid, float *lat_range, int *nlat, float *lon_range, 
+   int nccf_get_vara(int ncid, int varid, float *lat_range, int *nlat, float *lon_range,
 		     int *nlon, int lvl_index, int timestep, void *data);
 
    /* Calandar and time. */
-#define cdStandardCal   0x11
-#define cdClimCal        0x0
-#define cdHasLeap      0x100
-#define cdHasNoLeap    0x000
-#define cd365Days     0x1000
-#define cd360Days     0x0000
-#define cdJulianCal  0x10000
-#define cdMixedCal   0x20000
-
-   typedef enum cdCalenType {
-      cdStandard    = ( cdStandardCal | cdHasLeap   | cd365Days),
-      cdJulian      = ( cdStandardCal | cdHasLeap   | cd365Days | cdJulianCal),
-      cdNoLeap      = ( cdStandardCal | cdHasNoLeap | cd365Days),
-      cd360         = ( cdStandardCal | cdHasNoLeap | cd360Days),
-      cdClim        = ( cdClimCal     | cdHasNoLeap | cd365Days),
-      cdClimLeap    = ( cdClimCal     | cdHasLeap   | cd365Days),
-      cdClim360     = ( cdClimCal     | cdHasNoLeap | cd360Days),
-      cdMixed       = ( cdStandardCal | cdHasLeap   | cd365Days | cdMixedCal)
-   }  cdCalenType;
-
-   typedef enum cdType {cdInvalidType = -1,
-			cdByte = NC_BYTE,
-			cdChar = NC_CHAR,
-			cdShort = NC_SHORT,
-			cdInt = NC_INT,
-			cdLong = NC_INT,
-			cdFloat = NC_FLOAT,
-			cdDouble = NC_DOUBLE,
-			cdLongDouble = NC_DOUBLE,
-			cdCharTime
-   } cdType;
-
-   typedef struct {
-	 long 		year;		     /* Year */
-	 short 		month;		     /* Numerical month (1..12) */
-	 short 		day;		     /* Day of month (1..31) */
-	 double 		hour;		     /* Hour and fractional hours */
-   } cdCompTime;
-
-   int cdAbs2Comp(char* absunits, void* abstime, cdType abstimetype, cdCompTime* comptime, double* frac);
-   void cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime);
-   void cdChar2Rel(cdCalenType timetype, char* chartime, char* relunits, double* reltime);
-   int cdComp2Abs(cdCompTime comptime, char* absunits, cdType abstimetype, double frac, void* abstime);
-   void cdComp2Char(cdCalenType timetype, cdCompTime comptime, char* time);
-   void cdComp2Rel(cdCalenType timetype, cdCompTime comptime, char* relunits, double* reltime);
-   void cdRel2Char(cdCalenType timetype, char* relunits, double reltime, char* chartime);
-   void cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* comptime);
-   void cdRel2Rel(cdCalenType timetype, char* inunits, double intime, char* newunits, double* outtime);
+/* #define cdStandardCal   0x11 */
+/* #define cdClimCal        0x0 */
+/* #define cdHasLeap      0x100 */
+/* #define cdHasNoLeap    0x000 */
+/* #define cd365Days     0x1000 */
+/* #define cd360Days     0x0000 */
+/* #define cdJulianCal  0x10000 */
+/* #define cdMixedCal   0x20000 */
+
+/*    typedef enum cdCalenType { */
+/*       cdStandard    = ( cdStandardCal | cdHasLeap   | cd365Days), */
+/*       cdJulian      = ( cdStandardCal | cdHasLeap   | cd365Days | cdJulianCal), */
+/*       cdNoLeap      = ( cdStandardCal | cdHasNoLeap | cd365Days), */
+/*       cd360         = ( cdStandardCal | cdHasNoLeap | cd360Days), */
+/*       cdClim        = ( cdClimCal     | cdHasNoLeap | cd365Days), */
+/*       cdClimLeap    = ( cdClimCal     | cdHasLeap   | cd365Days), */
+/*       cdClim360     = ( cdClimCal     | cdHasNoLeap | cd360Days), */
+/*       cdMixed       = ( cdStandardCal | cdHasLeap   | cd365Days | cdMixedCal) */
+/*    }  cdCalenType; */
+
+/*    typedef enum cdType {cdInvalidType = -1, */
+/* 			cdByte = NC_BYTE, */
+/* 			cdChar = NC_CHAR, */
+/* 			cdShort = NC_SHORT, */
+/* 			cdInt = NC_INT, */
+/* 			cdLong = NC_INT, */
+/* 			cdFloat = NC_FLOAT, */
+/* 			cdDouble = NC_DOUBLE, */
+/* 			cdLongDouble = NC_DOUBLE, */
+/* 			cdCharTime */
+/*    } cdType; */
+
+/*    typedef struct { */
+/* 	 long 		year;		     /\* Year *\/ */
+/* 	 short 		month;		     /\* Numerical month (1..12) *\/ */
+/* 	 short 		day;		     /\* Day of month (1..31) *\/ */
+/* 	 double 		hour;		     /\* Hour and fractional hours *\/ */
+/*    } cdCompTime; */
+
+/*    int cdAbs2Comp(char* absunits, void* abstime, cdType abstimetype, cdCompTime* comptime, double* frac); */
+/*    void cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime); */
+/*    void cdChar2Rel(cdCalenType timetype, char* chartime, char* relunits, double* reltime); */
+/*    int cdComp2Abs(cdCompTime comptime, char* absunits, cdType abstimetype, double frac, void* abstime); */
+/*    void cdComp2Char(cdCalenType timetype, cdCompTime comptime, char* time); */
+/*    void cdComp2Rel(cdCalenType timetype, cdCompTime comptime, char* relunits, double* reltime); */
+/*    void cdRel2Char(cdCalenType timetype, char* relunits, double reltime, char* chartime); */
+/*    void cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* comptime); */
+/*    void cdRel2Rel(cdCalenType timetype, char* inunits, double intime, char* newunits, double* outtime); */
 
 #if defined(__cplusplus)
 }
diff --git a/src/libcf_api.f90 b/src/libcf_api.f90
new file mode 100644
index 0000000..a15772d
--- /dev/null
+++ b/src/libcf_api.f90
@@ -0,0 +1,788 @@
+     interface
+!     int nccf_inq_libvers(char *version_string)
+     function nccf_inq_libvers(version_string) bind(c)
+       use, intrinsic :: iso_c_binding
+       character(c_char), intent(out) :: version_string
+       integer(c_int) :: nccf_inq_libvers
+     end function nccf_inq_libvers
+
+!     int nccf_def_convention(int ncid)
+     function nccf_def_convention(ncid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int) :: nccf_def_convention
+     end function nccf_def_convention
+
+!     int nccf_inq_convention(int ncid, int *cf_convention)
+     function nccf_inq_convention(ncid, cf_convention) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), intent(out) :: cf_convention
+       integer(c_int) :: nccf_inq_convention
+     end function nccf_inq_convention
+
+!     int nccf_def_file(int ncid, const char *title, const char *history)
+     function nccf_def_file(ncid, title, history) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: title
+       character(c_char), intent(in) :: history
+       integer(c_int) :: nccf_def_file
+     end function nccf_def_file
+
+!      int nccf_inq_file(int ncid, size_t *title_lenp, char *title, size_t *history_le
+!     np, char *history)
+     function nccf_inq_file(ncid, title_lenp, title, history_lenp, history) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_size_t), intent(out) :: title_lenp
+       character(c_char), intent(out) :: title
+       integer(c_size_t), intent(out) :: history_lenp
+       character(c_char), intent(out) :: history
+       integer(c_int) :: nccf_inq_file
+     end function nccf_inq_file
+
+!     int nccf_add_history(int ncid, const char *history)
+     function nccf_add_history(ncid, history) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: history
+       integer(c_int) :: nccf_add_history
+     end function nccf_add_history
+
+!      int nccf_def_var(int ncid, int varid, const char *units, const char *long_name,
+!      const char *standard_name, int ncoord_vars, int *coord_varids)
+     function nccf_def_var(ncid, varid, units, long_name, standard_name, &
+       ncoord_vars, coord_varids) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       character(c_char), intent(in) :: units
+       character(c_char), intent(in) :: long_name
+       character(c_char), intent(in) :: standard_name
+       integer(c_int), value, intent(in) :: ncoord_vars
+       integer(c_int), dimension(*), intent(in) :: coord_varids
+       integer(c_int) :: nccf_def_var
+     end function nccf_def_var
+
+!      int nccf_inq_var(int ncid, int varid, size_t *units_lenp, char *units, size_t *
+!     long_name_lenp, char *long_name, size_t *standard_name_lenp, char *standard_name
+!     , int *ncoord_vars, int *coord_varids)
+     function nccf_inq_var(ncid, varid, units_lenp, units, long_name_lenp, &
+       long_name, standard_name_lenp, standard_name, ncoord_vars, &
+       coord_varids) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_size_t), intent(out) :: units_lenp
+       character(c_char), intent(out) :: units
+       integer(c_size_t), intent(out) :: long_name_lenp
+       character(c_char), intent(out) :: long_name
+       integer(c_size_t), intent(out) :: standard_name_lenp
+       character(c_char), intent(out) :: standard_name
+       integer(c_int), intent(out) :: ncoord_vars
+       integer(c_int), dimension(*), intent(in) :: coord_varids
+       integer(c_int) :: nccf_inq_var
+     end function nccf_inq_var
+
+!      int nccf_def_var_missing(int ncid, int varid, const void *fill_value, const voi
+!     d *valid_min, const void *valid_max)
+     function nccf_def_var_missing(ncid, varid, fill_value, valid_min, valid_max) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       type(c_ptr), intent(in) :: fill_value
+       type(c_ptr), intent(in) :: valid_min
+       type(c_ptr), intent(in) :: valid_max
+       integer(c_int) :: nccf_def_var_missing
+     end function nccf_def_var_missing
+
+!      int nccf_inq_var_missing(int ncid, int varid, void *fill_value, void *valid_min
+!     , void *valid_max)
+     function nccf_inq_var_missing(ncid, varid, fill_value, valid_min, valid_max) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       type(c_ptr), intent(out) :: fill_value
+       type(c_ptr), intent(out) :: valid_min
+       type(c_ptr), intent(out) :: valid_max
+       integer(c_int) :: nccf_inq_var_missing
+     end function nccf_inq_var_missing
+
+!      int nccf_def_notes(int ncid, int varid, const char *institution, const char *so
+!     urce, const char *comment, const char *references)
+     function nccf_def_notes(ncid, varid, institution, source, comment, references) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       character(c_char), intent(in) :: institution
+       character(c_char), intent(in) :: source
+       character(c_char), intent(in) :: comment
+       character(c_char), intent(in) :: references
+       integer(c_int) :: nccf_def_notes
+     end function nccf_def_notes
+
+!      int nccf_inq_notes(int ncid, int varid, size_t *institution_lenp, char *institu
+!     tion, size_t *source_lenp, char *source, size_t *comment_lenp, char *comment, si
+!     ze_t *references_lenp, char *references)
+     function nccf_inq_notes(ncid, varid, institution_lenp, institution, &
+       source_lenp, source, comment_lenp, comment, references_lenp, &
+       references) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_size_t), intent(out) :: institution_lenp
+       character(c_char), intent(out) :: institution
+       integer(c_size_t), intent(out) :: source_lenp
+       character(c_char), intent(out) :: source
+       integer(c_size_t), intent(out) :: comment_lenp
+       character(c_char), intent(out) :: comment
+       integer(c_size_t), intent(out) :: references_lenp
+       character(c_char), intent(out) :: references
+       integer(c_int) :: nccf_inq_notes
+     end function nccf_inq_notes
+
+!      int nccf_def_latitude(int ncid, size_t len, nc_type xtype, int *lat_dimidp, int
+!      *lat_varidp)
+     function nccf_def_latitude(ncid, len, xtype, lat_dimidp, lat_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(in) :: xtype
+       integer(c_int), intent(out) :: lat_dimidp
+       integer(c_int), intent(out) :: lat_varidp
+       integer(c_int) :: nccf_def_latitude
+     end function nccf_def_latitude
+
+!      int nccf_inq_latitude(int ncid, size_t *lenp, nc_type *xtypep, int *lat_dimidp,
+!      int *lat_varidp)
+     function nccf_inq_latitude(ncid, lenp, xtypep, lat_dimidp, lat_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: xtypep
+       integer(c_int), intent(out) :: lat_dimidp
+       integer(c_int), intent(out) :: lat_varidp
+       integer(c_int) :: nccf_inq_latitude
+     end function nccf_inq_latitude
+
+!      int nccf_def_longitude(int ncid, size_t len, nc_type xtype, int *lon_dimidp, in
+!     t *lon_varidp)
+     function nccf_def_longitude(ncid, len, xtype, lon_dimidp, lon_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(in) :: xtype
+       integer(c_int), intent(out) :: lon_dimidp
+       integer(c_int), intent(out) :: lon_varidp
+       integer(c_int) :: nccf_def_longitude
+     end function nccf_def_longitude
+
+!      int nccf_inq_longitude(int ncid, size_t *lenp, nc_type *xtypep, int *lon_dimidp
+!     , int *lon_varidp)
+     function nccf_inq_longitude(ncid, lenp, xtypep, lon_dimidp, lon_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: xtypep
+       integer(c_int), intent(out) :: lon_dimidp
+       integer(c_int), intent(out) :: lon_varidp
+       integer(c_int) :: nccf_inq_longitude
+     end function nccf_inq_longitude
+
+!      int nccf_def_lvl(int ncid, const char *name, size_t len, nc_type xtype, const c
+!     har *units, int positive_up, const char *standard_name, const char *formula_term
+!     s, int cdm_axis_type, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl(ncid, name, len, xtype, units, positive_up, &
+       standard_name, formula_terms, cdm_axis_type, lvl_dimidp, &
+       lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(in) :: xtype
+       character(c_char), intent(in) :: units
+       integer(c_int), value, intent(in) :: positive_up
+       character(c_char), intent(in) :: standard_name
+       character(c_char), intent(in) :: formula_terms
+       integer(c_int), value, intent(in) :: cdm_axis_type
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl
+     end function nccf_def_lvl
+
+!      int nccf_inq_lvl(int ncid, char *name, size_t *lenp, nc_type *xtypep, size_t *f
+!     t_lenp, char *formula_terms, int *positive_upp, int *lvl_dimidp, int *lvl_varidp
+!     )
+     function nccf_inq_lvl(ncid, name, lenp, xtypep, ft_lenp, formula_terms, &
+       positive_upp, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: ft_lenp
+       character(c_char), intent(out) :: formula_terms
+       integer(c_int), intent(out) :: positive_upp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl
+     end function nccf_inq_lvl
+
+!      int nccf_def_time(int ncid, const char *name, size_t len, nc_type xtype, const 
+!     char *units, const char *standard_name, int *time_dimidp, int *time_varidp)
+     function nccf_def_time(ncid, name, len, xtype, units, standard_name, &
+       time_dimidp, time_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(in) :: xtype
+       character(c_char), intent(in) :: units
+       character(c_char), intent(in) :: standard_name
+       integer(c_int), intent(out) :: time_dimidp
+       integer(c_int), intent(out) :: time_varidp
+       integer(c_int) :: nccf_def_time
+     end function nccf_def_time
+
+!      int nccf_inq_time(int ncid, char *name, size_t *lenp, nc_type *xtypep, int *tim
+!     e_dimidp, int *time_varidp)
+     function nccf_inq_time(ncid, name, lenp, xtypep, time_dimidp, time_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: xtypep
+       integer(c_int), intent(out) :: time_dimidp
+       integer(c_int), intent(out) :: time_varidp
+       integer(c_int) :: nccf_inq_time
+     end function nccf_inq_time
+
+!      int nccf_def_lvl_vert(int ncid, int lvl_type, const char *name, nc_type xtype, 
+!     size_t len, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_vert(ncid, lvl_type, name, xtype, len, lvl_dimidp, &
+       lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: lvl_type
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_vert
+     end function nccf_def_lvl_vert
+
+!      int nccf_inq_lvl_vert(int ncid, char *name, nc_type *xtypep, size_t *lenp, int 
+!     *lvl_typep, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_inq_lvl_vert(ncid, name, xtypep, lenp, lvl_typep, lvl_dimidp, &
+       lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: lvl_typep
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_vert
+     end function nccf_inq_lvl_vert
+
+!      int nccf_def_lvl_sigma(int ncid, const char *name, nc_type xtype, size_t len, i
+!     nt *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_sigma(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_sigma
+     end function nccf_def_lvl_sigma
+
+!     int nccf_def_ft_sigma(int ncid, int lvl_vid, int ps_vid, int p0_vid)
+     function nccf_def_ft_sigma(ncid, lvl_vid, ps_vid, p0_vid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: lvl_vid
+       integer(c_int), value, intent(in) :: ps_vid
+       integer(c_int), value, intent(in) :: p0_vid
+       integer(c_int) :: nccf_def_ft_sigma
+     end function nccf_def_ft_sigma
+
+!      int nccf_inq_lvl_sigma(int ncid, char *name, nc_type *xtypep, size_t *lenp, int
+!      *ps_varidp, int *ptop_varidp, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_inq_lvl_sigma(ncid, name, xtypep, lenp, ps_varidp, ptop_varidp, &
+       lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: ps_varidp
+       integer(c_int), intent(out) :: ptop_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_sigma
+     end function nccf_inq_lvl_sigma
+
+!      int nccf_def_lvl_hybrid_sigma(int ncid, const char *name, nc_type xtype, size_t
+!      len, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_hybrid_sigma(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_hybrid_sigma
+     end function nccf_def_lvl_hybrid_sigma
+
+!      int nccf_def_ft_hybrid_sigma(int ncid, int lvl_vid, int a_vid, int b_vid, int p
+!     s_vid, int p0_vid)
+     function nccf_def_ft_hybrid_sigma(ncid, lvl_vid, a_vid, b_vid, ps_vid, p0_vid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: lvl_vid
+       integer(c_int), value, intent(in) :: a_vid
+       integer(c_int), value, intent(in) :: b_vid
+       integer(c_int), value, intent(in) :: ps_vid
+       integer(c_int), value, intent(in) :: p0_vid
+       integer(c_int) :: nccf_def_ft_hybrid_sigma
+     end function nccf_def_ft_hybrid_sigma
+
+!      int nccf_inq_lvl_hybrid_sigma(int ncid, char *name, nc_type *xtypep, size_t *le
+!     np, int *a_varidp, int *b_varidp, int *ps_varidp, int *p0_varidp, int *lvl_dimid
+!     p, int *lvl_varidp)
+     function nccf_inq_lvl_hybrid_sigma(ncid, name, xtypep, lenp, a_varidp, b_varidp, &
+       ps_varidp, p0_varidp, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: a_varidp
+       integer(c_int), intent(out) :: b_varidp
+       integer(c_int), intent(out) :: ps_varidp
+       integer(c_int), intent(out) :: p0_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_hybrid_sigma
+     end function nccf_inq_lvl_hybrid_sigma
+
+!      int nccf_def_lvl_hybrid_sigma_full(int ncid, const char *name, nc_type xtype, s
+!     ize_t len, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_hybrid_sigma_full(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_hybrid_sigma_full
+     end function nccf_def_lvl_hybrid_sigma_full
+
+!      int nccf_def_ft_hybrid_sigma_full(int ncid, int varid, int a_varid, int b_varid
+!     , int ps_varid, int p0_varid)
+     function nccf_def_ft_hybrid_sigma_full(ncid, varid, a_varid, b_varid, ps_varid, p0_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: a_varid
+       integer(c_int), value, intent(in) :: b_varid
+       integer(c_int), value, intent(in) :: ps_varid
+       integer(c_int), value, intent(in) :: p0_varid
+       integer(c_int) :: nccf_def_ft_hybrid_sigma_full
+     end function nccf_def_ft_hybrid_sigma_full
+
+!      int nccf_def_lvl_hybrid_height(int ncid, const char *name, nc_type xtype, size_
+!     t len, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_hybrid_height(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_hybrid_height
+     end function nccf_def_lvl_hybrid_height
+
+!      int nccf_def_ft_hybrid_height(int ncid, int varid, int a_varid, int b_varid, in
+!     t orog_varid)
+     function nccf_def_ft_hybrid_height(ncid, varid, a_varid, b_varid, orog_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: a_varid
+       integer(c_int), value, intent(in) :: b_varid
+       integer(c_int), value, intent(in) :: orog_varid
+       integer(c_int) :: nccf_def_ft_hybrid_height
+     end function nccf_def_ft_hybrid_height
+
+!      int nccf_inq_lvl_hybrid_height(int ncid, char *name, nc_type *xtypep, size_t *l
+!     enp, int *a_varidp, int *b_varidp, int *orog_varidp, int *lvl_dimidp, int *lvl_v
+!     aridp)
+     function nccf_inq_lvl_hybrid_height(ncid, name, xtypep, lenp, a_varidp, b_varidp, &
+       orog_varidp, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: a_varidp
+       integer(c_int), intent(out) :: b_varidp
+       integer(c_int), intent(out) :: orog_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_hybrid_height
+     end function nccf_inq_lvl_hybrid_height
+
+!      int nccf_def_lvl_sleve(int ncid, const char *name, nc_type xtype, size_t len, i
+!     nt *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_sleve(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_sleve
+     end function nccf_def_lvl_sleve
+
+!      int nccf_def_ft_sleve(int ncid, int varid, int a_varid, int b1_varid, int b2_va
+!     rid, int ztop_varid, int zsurf1_varid, int zsurf2_varid)
+     function nccf_def_ft_sleve(ncid, varid, a_varid, b1_varid, b2_varid, ztop_varid, &
+       zsurf1_varid, zsurf2_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: a_varid
+       integer(c_int), value, intent(in) :: b1_varid
+       integer(c_int), value, intent(in) :: b2_varid
+       integer(c_int), value, intent(in) :: ztop_varid
+       integer(c_int), value, intent(in) :: zsurf1_varid
+       integer(c_int), value, intent(in) :: zsurf2_varid
+       integer(c_int) :: nccf_def_ft_sleve
+     end function nccf_def_ft_sleve
+
+!      int nccf_inq_lvl_sleve(int ncid, char *name, nc_type *xtypep, size_t *lenp, int
+!      *a_varidp, int *b1_varidp, int *b2_varidp, int *ztop_varidp, int *zsurf1_varidp
+!     , int *zsurf2_varidp, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_inq_lvl_sleve(ncid, name, xtypep, lenp, a_varidp, b1_varidp, &
+       b2_varidp, ztop_varidp, zsurf1_varidp, zsurf2_varidp, &
+       lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: a_varidp
+       integer(c_int), intent(out) :: b1_varidp
+       integer(c_int), intent(out) :: b2_varidp
+       integer(c_int), intent(out) :: ztop_varidp
+       integer(c_int), intent(out) :: zsurf1_varidp
+       integer(c_int), intent(out) :: zsurf2_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_sleve
+     end function nccf_inq_lvl_sleve
+
+!      int nccf_def_lvl_ocean_sigma(int ncid, const char *name, nc_type xtype, size_t 
+!     len, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_ocean_sigma(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_ocean_sigma
+     end function nccf_def_lvl_ocean_sigma
+
+!      int nccf_def_ft_ocean_sigma(int ncid, int varid, int eta_varid, int depth_varid
+!     )
+     function nccf_def_ft_ocean_sigma(ncid, varid, eta_varid, depth_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: eta_varid
+       integer(c_int), value, intent(in) :: depth_varid
+       integer(c_int) :: nccf_def_ft_ocean_sigma
+     end function nccf_def_ft_ocean_sigma
+
+!      int nccf_inq_lvl_ocean_sigma(int ncid, char *name, nc_type *xtypep, size_t *len
+!     p, int *eta_varidp, int *depth_varidp, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_inq_lvl_ocean_sigma(ncid, name, xtypep, lenp, eta_varidp, depth_varidp, &
+       lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: eta_varidp
+       integer(c_int), intent(out) :: depth_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_ocean_sigma
+     end function nccf_inq_lvl_ocean_sigma
+
+!      int nccf_def_lvl_ocean_s(int ncid, const char *name, nc_type xtype, size_t len,
+!      int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_ocean_s(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_ocean_s
+     end function nccf_def_lvl_ocean_s
+
+!      int nccf_def_ft_ocean_s(int ncid, int varid, int eta_varid, int depth_varid, in
+!     t a_varid, int b_varid, int depth_c_varid)
+     function nccf_def_ft_ocean_s(ncid, varid, eta_varid, depth_varid, a_varid, b_varid, &
+       depth_c_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: eta_varid
+       integer(c_int), value, intent(in) :: depth_varid
+       integer(c_int), value, intent(in) :: a_varid
+       integer(c_int), value, intent(in) :: b_varid
+       integer(c_int), value, intent(in) :: depth_c_varid
+       integer(c_int) :: nccf_def_ft_ocean_s
+     end function nccf_def_ft_ocean_s
+
+!      int nccf_inq_lvl_ocean_s(int ncid, char *name, nc_type *xtypep, size_t *lenp, i
+!     nt *eta_varidp, int *depth_varidp, int *a_varidp, int *b_varidp, int *depth_c_va
+!     ridp, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_inq_lvl_ocean_s(ncid, name, xtypep, lenp, eta_varidp, depth_varidp, &
+       a_varidp, b_varidp, depth_c_varidp, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: eta_varidp
+       integer(c_int), intent(out) :: depth_varidp
+       integer(c_int), intent(out) :: a_varidp
+       integer(c_int), intent(out) :: b_varidp
+       integer(c_int), intent(out) :: depth_c_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_ocean_s
+     end function nccf_inq_lvl_ocean_s
+
+!      int nccf_def_lvl_ocean_sigma_z(int ncid, const char *name, nc_type xtype, size_
+!     t len, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_ocean_sigma_z(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_ocean_sigma_z
+     end function nccf_def_lvl_ocean_sigma_z
+
+!      int nccf_def_ft_ocean_sigma_z(int ncid, int varid, int eta_varid, int depth_var
+!     id, int depth_c_varid, int nsigma_varid, int zlev_varid)
+     function nccf_def_ft_ocean_sigma_z(ncid, varid, eta_varid, depth_varid, depth_c_varid, &
+       nsigma_varid, zlev_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: eta_varid
+       integer(c_int), value, intent(in) :: depth_varid
+       integer(c_int), value, intent(in) :: depth_c_varid
+       integer(c_int), value, intent(in) :: nsigma_varid
+       integer(c_int), value, intent(in) :: zlev_varid
+       integer(c_int) :: nccf_def_ft_ocean_sigma_z
+     end function nccf_def_ft_ocean_sigma_z
+
+!      int nccf_inq_lvl_ocean_sigma_z(int ncid, char *name, nc_type *xtypep, size_t *l
+!     enp, int *eta_varidp, int *depth_varidp, int *depth_c_varidp, int *nsigma_varidp
+!     , int *zlev_varidp, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_inq_lvl_ocean_sigma_z(ncid, name, xtypep, lenp, eta_varidp, depth_varidp, &
+       depth_c_varidp, nsigma_varidp, zlev_varidp, lvl_dimidp, &
+       lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: eta_varidp
+       integer(c_int), intent(out) :: depth_varidp
+       integer(c_int), intent(out) :: depth_c_varidp
+       integer(c_int), intent(out) :: nsigma_varidp
+       integer(c_int), intent(out) :: zlev_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_ocean_sigma_z
+     end function nccf_inq_lvl_ocean_sigma_z
+
+!      int nccf_def_lvl_ocean_dbl_sigma(int ncid, const char *name, nc_type xtype, siz
+!     e_t len, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_def_lvl_ocean_dbl_sigma(ncid, name, xtype, len, lvl_dimidp, lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), intent(in) :: xtype
+       integer(c_size_t), intent(in) :: len
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_def_lvl_ocean_dbl_sigma
+     end function nccf_def_lvl_ocean_dbl_sigma
+
+!      int nccf_def_ft_ocean_dbl_sigma(int ncid, int varid, int depth_varid, int z1_va
+!     rid, int z2_varid, int a_varid, int href_varid, int k_c_varid)
+     function nccf_def_ft_ocean_dbl_sigma(ncid, varid, depth_varid, z1_varid, z2_varid, a_varid, &
+       href_varid, k_c_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: depth_varid
+       integer(c_int), value, intent(in) :: z1_varid
+       integer(c_int), value, intent(in) :: z2_varid
+       integer(c_int), value, intent(in) :: a_varid
+       integer(c_int), value, intent(in) :: href_varid
+       integer(c_int), value, intent(in) :: k_c_varid
+       integer(c_int) :: nccf_def_ft_ocean_dbl_sigma
+     end function nccf_def_ft_ocean_dbl_sigma
+
+!      int nccf_inq_lvl_ocean_dbl_sigma(int ncid, char *name, nc_type *xtypep, size_t 
+!     *lenp, int *depth_varidp, int *z1_varidp, int *z2_varidp, int *a_varidp, int *hr
+!     ef_varidp, int *k_c_varidp, int *lvl_dimidp, int *lvl_varidp)
+     function nccf_inq_lvl_ocean_dbl_sigma(ncid, name, xtypep, lenp, depth_varidp, z1_varidp, &
+       z2_varidp, a_varidp, href_varidp, k_c_varidp, lvl_dimidp, &
+       lvl_varidp) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: xtypep
+       integer(c_size_t), intent(out) :: lenp
+       integer(c_int), intent(out) :: depth_varidp
+       integer(c_int), intent(out) :: z1_varidp
+       integer(c_int), intent(out) :: z2_varidp
+       integer(c_int), intent(out) :: a_varidp
+       integer(c_int), intent(out) :: href_varidp
+       integer(c_int), intent(out) :: k_c_varidp
+       integer(c_int), intent(out) :: lvl_dimidp
+       integer(c_int), intent(out) :: lvl_varidp
+       integer(c_int) :: nccf_inq_lvl_ocean_dbl_sigma
+     end function nccf_inq_lvl_ocean_dbl_sigma
+
+!     int nccf_def_axis_type(int ncid, int varid, int axis_type)
+     function nccf_def_axis_type(ncid, varid, axis_type) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: axis_type
+       integer(c_int) :: nccf_def_axis_type
+     end function nccf_def_axis_type
+
+!     int nccf_inq_axis_type(int ncid, int varid, int *axis_type)
+     function nccf_inq_axis_type(ncid, varid, axis_type) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), intent(out) :: axis_type
+       integer(c_int) :: nccf_inq_axis_type
+     end function nccf_inq_axis_type
+
+!      int nccf_def_coord_system(int ncid, const char *name, int naxes, int *axis_vari
+!     ds, int *system_varid)
+     function nccf_def_coord_system(ncid, name, naxes, axis_varids, system_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       integer(c_int), value, intent(in) :: naxes
+       integer(c_int), dimension(*), intent(in) :: axis_varids
+       integer(c_int), intent(out) :: system_varid
+       integer(c_int) :: nccf_def_coord_system
+     end function nccf_def_coord_system
+
+!      int nccf_inq_coord_system(int ncid, int system_varid, char *name, int *naxes, i
+!     nt *axis_varids)
+     function nccf_inq_coord_system(ncid, system_varid, name, naxes, axis_varids) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: system_varid
+       character(c_char), intent(out) :: name
+       integer(c_int), intent(out) :: naxes
+       integer(c_int), dimension(*), intent(in) :: axis_varids
+       integer(c_int) :: nccf_inq_coord_system
+     end function nccf_inq_coord_system
+
+!     int nccf_assign_coord_system(int ncid, int varid, int system_varid)
+     function nccf_assign_coord_system(ncid, varid, system_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       integer(c_int), value, intent(in) :: system_varid
+       integer(c_int) :: nccf_assign_coord_system
+     end function nccf_assign_coord_system
+
+!      int nccf_def_transform(int ncid, const char *name, const char *transform_type, 
+!     const char *transform_name, int *transform_varid)
+     function nccf_def_transform(ncid, name, transform_type, transform_name, &
+       transform_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       character(c_char), intent(in) :: name
+       character(c_char), intent(in) :: transform_type
+       character(c_char), intent(in) :: transform_name
+       integer(c_int), intent(out) :: transform_varid
+       integer(c_int) :: nccf_def_transform
+     end function nccf_def_transform
+
+!      int nccf_inq_transform(int ncid, int transform_varid, char *name, size_t *type_
+!     len, char *transform_type, size_t *name_len, char *transform_name)
+     function nccf_inq_transform(ncid, transform_varid, name, type_len, transform_type, &
+       name_len, transform_name) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: transform_varid
+       character(c_char), intent(out) :: name
+       integer(c_size_t), intent(out) :: type_len
+       character(c_char), intent(out) :: transform_type
+       integer(c_size_t), intent(out) :: name_len
+       character(c_char), intent(out) :: transform_name
+       integer(c_int) :: nccf_inq_transform
+     end function nccf_inq_transform
+
+!     int nccf_assign_transform(int ncid, int system_varid, int transform_varid)
+     function nccf_assign_transform(ncid, system_varid, transform_varid) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: system_varid
+       integer(c_int), value, intent(in) :: transform_varid
+       integer(c_int) :: nccf_assign_transform
+     end function nccf_assign_transform
+
+!      int nccf_get_vara(int ncid, int varid, float *lat_range, int *nlat, float *lon_
+!     range, int *nlon, int lvl_index, int timestep, void *data)
+     function nccf_get_vara(ncid, varid, lat_range, nlat, lon_range, nlon, &
+       lvl_index, timestep, data) bind(c)
+       use, intrinsic :: iso_c_binding
+       integer(c_int), value, intent(in) :: ncid
+       integer(c_int), value, intent(in) :: varid
+       real(c_float), intent(out) :: lat_range
+       integer(c_int), intent(out) :: nlat
+       real(c_float), intent(out) :: lon_range
+       integer(c_int), intent(out) :: nlon
+       integer(c_int), value, intent(in) :: lvl_index
+       integer(c_int), value, intent(in) :: timestep
+       type(c_ptr), intent(out) :: data
+       integer(c_int) :: nccf_get_vara
+     end function nccf_get_vara
+
+     end interface
diff --git a/src/libcf_int.h b/src/libcf_int.h
index 826b9ab..6e77bee 100644
--- a/src/libcf_int.h
+++ b/src/libcf_int.h
@@ -7,7 +7,7 @@ want in the libcf.h file.
 
 Ed Hartnett, 10/1/06
 
-$Id: libcf_int.h,v 1.4 2006/11/11 15:03:03 ed Exp $
+$Id: libcf_int.h,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #ifndef _LIBCF_INT_
diff --git a/src/nc_tests.h b/src/nc_tests.h
index c57a642..1015c1b 100644
--- a/src/nc_tests.h
+++ b/src/nc_tests.h
@@ -8,7 +8,7 @@ Common includes, defines, etc., for test code.
 
 Ed Hartnett, 10/1/06
 
-$Id: nc_tests.h,v 1.3 2006/11/11 15:03:03 ed Exp $
+$Id: nc_tests.h,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 #ifndef _NC_TESTS_
 #define _NC_TESTS_
diff --git a/src/nccoord.c b/src/nccoord.c
index 90387ee..7f88302 100644
--- a/src/nccoord.c
+++ b/src/nccoord.c
@@ -8,7 +8,7 @@ This file handles the nc4 coordinate systems.
 
 Ed Hartnett, 10/1/05
 
-$Id: nccoord.c,v 1.8 2008/06/30 16:34:30 ed Exp $
+$Id: nccoord.c,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/tst_coords.c b/src/tst_coords.c
index a51b84a..fd1d4da 100644
--- a/src/tst_coords.c
+++ b/src/tst_coords.c
@@ -8,7 +8,7 @@ systems.
 
 Ed Hartnett 10/1/05
 
-$Id: tst_coords.c,v 1.5 2007/05/27 06:56:36 ed Exp $
+$Id: tst_coords.c,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #include <nc_tests.h>
diff --git a/src/tst_cvars.c b/src/tst_cvars.c
index 65b6b38..4b74b5c 100644
--- a/src/tst_cvars.c
+++ b/src/tst_cvars.c
@@ -6,7 +6,7 @@
 
    Ed Hartnett, 10/1/06
 
-   $Id: tst_cvars.c,v 1.7 2006/11/20 15:43:37 ed Exp $
+   $Id: tst_cvars.c,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/tst_example_data.c b/src/tst_example_data.c
index 705e2ea..5ae0844 100644
--- a/src/tst_example_data.c
+++ b/src/tst_example_data.c
@@ -6,7 +6,7 @@
 
    Ed Hartnett, 10/1/06
 
-   $Id: tst_example_data.c,v 1.2 2007/06/02 12:32:05 ed Exp $
+   $Id: tst_example_data.c,v 1.2 2009/09/08 17:14:53 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/tst_f03_file.f90 b/src/tst_f03_file.f90
index 9d55ef9..b92887f 100644
--- a/src/tst_f03_file.f90
+++ b/src/tst_f03_file.f90
@@ -1,30 +1,136 @@
 program tst_f03_file
   use libcf
+  use typeSizes
   use netcdf
   implicit none
-  integer:: ncid
+  integer:: ncid, varid
+  integer, parameter :: MAX_LEN = 256
   character (len = *), parameter :: FILE_NAME = "tst_f03_file.nc"
   character (len = *), parameter :: TITLE = 'Viscount of Lafayette'
   character (len = *), parameter :: HISTORY = 'It all started one dark and stormy night...'
-  character (len = 100) :: title_in, history_in
-!  integer:: title_len, history_len
-  
-  print *,''
+  character (len = *), parameter :: INSTITUTION = 'Happy Home for Histronic Hacks'
+  character (len = *), parameter :: COMMENT = 'I like beans'
+  character (len = *), parameter :: SOURCE = 'Fevered imagination'
+  character (len = *), parameter :: REFERENCES = 'works of Emily Dickenson, Edgar Allen Poe'
+  character (len = *), parameter :: VAR_NAME = 'height'
+  character (len = *), parameter :: STANDARD_NAME = 'Constance'
+  character (len = *), parameter :: TITLE2 = 'Duke of Denver'
+  character (len = *), parameter :: HISTORY2 = 'In the beginning, there was the void......'
+  character (len = *), parameter :: INSTITUTION2 = 'St. Brutus Home for Hopeless Cases'
+  character (len = *), parameter :: COMMENT2 = 'soup is good when Muggles make it'
+  character (len = *), parameter :: SOURCE2 = 'Too much coffee waiting for BritRail'
+  character (len = *), parameter :: REFERENCES2 = 'Tales of Beadle the Bard'
+  character (len = *), parameter :: VAR_NAME2 = 'age'
+  character (len = *), parameter :: STANDARD_NAME2 = 'Harry'
+  character (len = MAX_LEN) :: title_in, history_in, institution_in, comment_in, &
+       source_in, references_in, standard_name_in
+  integer :: ncoord_vars_in
+  integer, dimension(CF_MAX_COORDS) :: coord_varids_in
+  integer, parameter :: FILL_VALUE = 42
+
+  print *
   print *,'*** Testing f90 file API. All hail the ', TITLE, '!'
   call check(nf90_create(FILE_NAME, NF90_NETCDF4, ncid))
-  call check(cf_def_file(ncid, '1.0', TITLE, HISTORY))
+
+  ! Write some of the CF file attributes, and check them.
+  print *,'*** testing cf_def_file with partial args... '
+  call check(cf_def_file(ncid, convention = '1.0', title = TITLE, history = HISTORY, &
+       institution = INSTITUTION))
+  call check(cf_inq_file(ncid, title = title_in, history = history_in, institution = institution_in, &
+       comment = comment_in, source = source_in, references = references_in))
+  if (title_in .ne. TITLE) stop 3
+  if (institution_in .ne. INSTITUTION) stop 4
+  if (source_in .ne. ' ') stop 5
+  if (references_in .ne. ' ') stop 6
+
+  print *,'*** testing cf_def_file with different partial args... '
+  call check(cf_def_file(ncid, convention = '1.0', title = TITLE2, &
+       institution = INSTITUTION2))
+  call check(cf_inq_file(ncid, title = title_in, history = history_in, institution = institution_in, &
+       comment = comment_in, source = source_in, references = references_in))
+  if (title_in .ne. TITLE2) stop 23
+  if (institution_in .ne. INSTITUTION2) stop 24
+  if (source_in .ne. ' ') stop 25
+  if (references_in .ne. ' ') stop 26
+  
+  ! Write all of the CF file attributes.
+  print *,'*** testing cf_def_file with all args... '
+  call check(cf_def_file(ncid, convention = '1.0', title = TITLE, history = HISTORY, &
+       institution = INSTITUTION, comment = COMMENT, source = SOURCE, references = REFERENCES))
+  call check(cf_add_history(ncid, 'by the pale and sickly light of a bloated, over-described, harvest moon.'))
+  call check(cf_inq_file(ncid, title = title_in, history = history_in, institution = institution_in, &
+       comment = comment_in, source = source_in, references = references_in))
+  if (title_in .ne. TITLE) stop 33
+  if (institution_in .ne. INSTITUTION) stop 34
+  if (comment_in .ne. COMMENT) stop 35
+  if (source_in .ne. SOURCE) stop 36
+  if (references_in .ne. REFERENCES) stop 37
+
+  ! Write the variable CF attributes.
+  print *,'*** testing cf_def_var with some args... '
+  call check(nf90_def_var(ncid, VAR_NAME, NF90_INT, varid))
+  call check(cf_def_var(ncid, varid, institution = INSTITUTION, standard_name = STANDARD_NAME))
+  call check(cf_inq_var(ncid, varid, standard_name = standard_name_in, &
+       institution = institution_in, source = source_in))
+  if (standard_name_in .ne. STANDARD_NAME) stop 46
+  if (institution_in .ne. INSTITUTION) stop 47
+  if (source_in .ne. ' ') stop 48
+
+  print *,'*** testing cf_def_var with some other args... '
+  call check(cf_def_var(ncid, varid, institution = INSTITUTION2, comment = COMMENT2, &
+       source = SOURCE2, references = REFERENCES2))
+  call check(cf_inq_var(ncid, varid, comment = comment_in, &
+       institution = institution_in, source = source_in, references = references_in))
+  if (institution_in .ne. INSTITUTION2) stop 51
+  if (comment_in .ne. COMMENT2) stop 52
+  if (source_in .ne. SOURCE2) stop 53
+  if (references_in .ne. REFERENCES2) stop 54
+
+  print *,'*** testing cf_def_var with coord_varids... '
+  call check(cf_def_var(ncid, varid, ncoord_vars = 1, coord_varids = (/1/)))
+  call check(cf_inq_var(ncid, varid, ncoord_vars = ncoord_vars_in, coord_varids = coord_varids_in))
+  if (ncoord_vars_in .ne. 1) stop 60
+  if (coord_varids_in(1) .ne. 1) stop 61
+
+  print *,'*** testing cf_def_var with missing values... '
+!  call check(cf_def_var(ncid, varid, fill_value = FILL_VALUE))
+  call check(cf_inq_var(ncid, varid, ncoord_vars = ncoord_vars_in, coord_varids = coord_varids_in))
+  if (ncoord_vars_in .ne. 1) stop 60
+  if (coord_varids_in(1) .ne. 1) stop 61
+
+  ! Close the file.
   call check(nf90_close(ncid))
 
+  ! Reopen and check.
+  print *,'*** testing after file reopen... '
   call check(nf90_open(FILE_NAME, NF90_NOWRITE, ncid))
-  call check(cf_inq_file(ncid, title_in, history_in))
-  if (.not. title_in == TITLE) stop 2
+  call check(cf_inq_file(ncid, title = title_in, &
+       history = history_in, institution = institution_in, &
+       comment = comment_in, source = source_in, references = references_in))
+  if (title_in .ne. TITLE) stop 13
+  if (institution_in .ne. INSTITUTION) stop 14
+  if (comment_in .ne. COMMENT) stop 15
+  if (source_in .ne. SOURCE) stop 16
+  if (references_in .ne. REFERENCES) stop 17
+
+  call check(cf_inq_var(ncid, varid, comment = comment_in, &
+       institution = institution_in, source = source_in, references = references_in))
+  if (institution_in .ne. INSTITUTION2) stop 91
+  if (comment_in .ne. COMMENT2) stop 92
+  if (source_in .ne. SOURCE2) stop 93
+  if (references_in .ne. REFERENCES2) stop 94
+  print *, '***     institution = ', trim(institution_in)
+  print *, '***     comment = ', trim(comment_in)
+  print *, '***     source = ', trim(source_in)
+  print *, '***     references = ', trim(references_in)
+
   call check(nf90_close(ncid))
   print *,'*** SUCCESS!!!'
-  
+
 contains
   subroutine check(status)
     integer, intent ( in) :: status
-    
+
     if(status /= nf90_noerr) then
        print *, trim(nf90_strerror(status))
        stop 2
diff --git a/src/tst_files.c b/src/tst_files.c
index e19179f..cac25c1 100644
--- a/src/tst_files.c
+++ b/src/tst_files.c
@@ -4,7 +4,7 @@
 
    Test libcf file stuff.
 
-   $Id: tst_files.c,v 1.5 2006/09/10 03:02:26 ed Exp $
+   $Id: tst_files.c,v 1.2 2009/09/08 17:14:54 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/tst_subsets.c b/src/tst_subsets.c
index 77268c1..036cbc6 100644
--- a/src/tst_subsets.c
+++ b/src/tst_subsets.c
@@ -6,7 +6,7 @@
 
    Ed Hartnett, 10/1/06
 
-   $Id: tst_subsets.c,v 1.15 2007/06/07 17:07:14 ed Exp $
+   $Id: tst_subsets.c,v 1.2 2009/09/08 17:14:54 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/tst_vars.c b/src/tst_vars.c
index a59fe5d..c129315 100644
--- a/src/tst_vars.c
+++ b/src/tst_vars.c
@@ -4,7 +4,7 @@
 
    Test libcf variable stuff.
 
-   $Id: tst_vars.c,v 1.3 2006/09/10 17:19:33 ed Exp $
+   $Id: tst_vars.c,v 1.2 2009/09/08 17:14:54 ed Exp $
 */
 
 #include <config.h>
diff --git a/src/tst_vert.c b/src/tst_vert.c
index 1fcb16a..2855bd0 100644
--- a/src/tst_vert.c
+++ b/src/tst_vert.c
@@ -6,7 +6,7 @@
 
    Ed Hartnett, 11/18/06
 
-   $Id: tst_vert.c,v 1.2 2006/11/22 11:24:32 ed Exp $
+   $Id: tst_vert.c,v 1.2 2009/09/08 17:14:54 ed Exp $
 */
 
 #include <config.h>

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



More information about the Pkg-grass-devel mailing list