[netcdf-libcf] 01/06: Imported Upstream version 1.0~alpha4
Bas Couwenberg
sebastic at xs4all.nl
Sat Jan 24 18:08:21 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 3786d9a82b2d7934668b3d32cb9de80c113197a7
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Sat Jan 17 18:52:29 2015 +0100
Imported Upstream version 1.0~alpha4
---
COPYRIGHT | 35 +
Makefile.am | 45 +
Makefile.in | 704 +
acinclude.m4 | 1170 +
aclocal.m4 | 908 +
cfcheck/Makefile.am | 43 +
cfcheck/Makefile.in | 593 +
cfcheck/cfcheck.c | 87 +
cfcheck/tst_cfcheck.sh | 21 +
compile | 142 +
config.guess | 1526 ++
config.h.in | 183 +
config.sub | 1658 ++
configure | 27024 +++++++++++++++++++
configure.ac | 256 +
depcomp | 589 +
doc/Makefile.am | 43 +
doc/Makefile.in | 676 +
doc/defines.texi | 61 +
doc/libcf.info | 2592 ++
doc/libcf.pdf | Bin 0 -> 152955 bytes
doc/libcf.ps | 3556 +++
doc/libcf.texi | 2546 ++
doc/mdate-sh | 201 +
doc/stamp-vti | 4 +
doc/texinfo.tex | 7210 +++++
doc/version.texi | 4 +
gridspec_tools_20080702/Makefile.am | 1 +
gridspec_tools_20080702/Makefile.in | 506 +
gridspec_tools_20080702/shared/Makefile.am | 1 +
gridspec_tools_20080702/shared/Makefile.in | 506 +
gridspec_tools_20080702/shared/mosaic/Makefile.am | 32 +
gridspec_tools_20080702/shared/mosaic/Makefile.in | 484 +
gridspec_tools_20080702/shared/mosaic/constant.h | 2 +
.../shared/mosaic/create_xgrid.c | 1106 +
.../shared/mosaic/create_xgrid.h | 43 +
.../shared/mosaic/gradient_c2l.c | 435 +
.../shared/mosaic/gradient_c2l.h | 17 +
gridspec_tools_20080702/shared/mosaic/interp.c | 152 +
gridspec_tools_20080702/shared/mosaic/interp.h | 14 +
.../shared/mosaic/mosaic_util.c | 531 +
.../shared/mosaic/mosaic_util.h | 34 +
.../shared/mosaic/read_mosaic.c | 656 +
.../shared/mosaic/read_mosaic.h | 15 +
gridspec_tools_20080702/tools/Makefile.am | 2 +
gridspec_tools_20080702/tools/Makefile.in | 508 +
gridspec_tools_20080702/tools/fregrid/Makefile.am | 45 +
gridspec_tools_20080702/tools/fregrid/Makefile.in | 537 +
.../tools/fregrid/bilinear_interp.c | 1131 +
.../tools/fregrid/bilinear_interp.h | 10 +
.../tools/fregrid/conserve_interp.c | 689 +
.../tools/fregrid/conserve_interp.h | 13 +
gridspec_tools_20080702/tools/fregrid/fregrid.c | 668 +
.../tools/fregrid/fregrid_util.c | 1597 ++
.../tools/fregrid/fregrid_util.h | 28 +
gridspec_tools_20080702/tools/fregrid/globals.h | 166 +
gridspec_tools_20080702/tools/fregrid/gs_fregrid.c | 416 +
.../tools/make_coupler_mosaic/Makefile.am | 41 +
.../tools/make_coupler_mosaic/Makefile.in | 527 +
.../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/Makefile.in | 540 +
.../tools/make_hgrid/create_conformal_cubic_grid.c | 814 +
.../tools/make_hgrid/create_gnomonic_cubic_grid.c | 907 +
.../tools/make_hgrid/create_grid_from_file.c | 152 +
.../tools/make_hgrid/create_hgrid.h | 41 +
.../tools/make_hgrid/create_lonlat_grid.c | 406 +
.../tools/make_hgrid/gs_make_hgrid.c | 340 +
.../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 +
.../tools/make_topog/Makefile.in | 524 +
.../tools/make_topog/make_topog.c | 511 +
gridspec_tools_20080702/tools/make_topog/topog.c | 542 +
gridspec_tools_20080702/tools/make_topog/topog.h | 14 +
.../tools/make_vgrid/Makefile.am | 41 +
.../tools/make_vgrid/Makefile.in | 526 +
.../tools/make_vgrid/create_vgrid.c | 43 +
.../tools/make_vgrid/create_vgrid.h | 11 +
.../tools/make_vgrid/gs_make_vgrid.c | 133 +
.../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 +
gridspec_tools_20080702/tools/shared/Makefile.in | 504 +
.../tools/shared/bilinear_interp.c | 1131 +
.../tools/shared/conserve_interp.c | 689 +
.../tools/shared/create_conformal_cubic_grid.c | 814 +
.../tools/shared/create_gnomonic_cubic_grid.c | 907 +
.../tools/shared/create_grid_from_file.c | 152 +
.../tools/shared/create_lonlat_grid.c | 406 +
.../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/mpp.c | 230 +
gridspec_tools_20080702/tools/shared/mpp.h | 24 +
gridspec_tools_20080702/tools/shared/mpp_domain.c | 534 +
gridspec_tools_20080702/tools/shared/mpp_domain.h | 50 +
gridspec_tools_20080702/tools/shared/mpp_io.c | 875 +
gridspec_tools_20080702/tools/shared/mpp_io.h | 44 +
gridspec_tools_20080702/tools/shared/tool_util.c | 5969 ++++
gridspec_tools_20080702/tools/shared/tool_util.h | 69 +
gridspec_tools_20080702/tools/shared/topog.c | 542 +
.../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 | 519 +
ltmain.sh | 7874 ++++++
m4/libtool.m4 | 7309 +++++
m4/ltoptions.m4 | 368 +
m4/ltsugar.m4 | 123 +
m4/ltversion.m4 | 23 +
m4/lt~obsolete.m4 | 92 +
missing | 367 +
nfconfig.in | 83 +
src/Makefile.am | 99 +
src/Makefile.in | 793 +
src/cdTimeConv.c | 1082 +
src/cddrs.h | 154 +
src/cdms.h | 317 +
src/cdmsint.h | 591 +
src/cdunif.h | 178 +
src/cfcvars.c | 1550 ++
src/cferror.c | 80 +
src/cferror.h | 37 +
src/cffcvars.f90 | 85 +
src/cffiles.c | 357 +
src/cfsubsets.c | 265 +
src/cfvars.c | 321 +
src/drscdf.h | 275 +
src/libcf.h | 509 +
src/libcf_int.h | 23 +
src/nc_tests.h | 71 +
src/nccoord.c | 379 +
src/tst_coords.c | 447 +
src/tst_cvars.c | 66 +
src/tst_example_data.c | 50 +
src/tst_f03_file.f90 | 33 +
src/tst_files.c | 165 +
src/tst_subsets.c | 623 +
src/tst_vars.c | 120 +
src/tst_vert.c | 283 +
152 files changed, 118800 insertions(+)
diff --git a/COPYRIGHT b/COPYRIGHT
new file mode 100644
index 0000000..da081ff
--- /dev/null
+++ b/COPYRIGHT
@@ -0,0 +1,35 @@
+Copyright 1993-2004 University Corporation for Atmospheric Research/Unidata
+
+Portions of this software were developed by the Unidata Program at the
+University Corporation for Atmospheric Research.
+
+Access and use of this software shall impose the following obligations
+and understandings on the user. The user is granted the right, without
+any fee or cost, to use, copy, modify, alter, enhance and distribute
+this software, and any derivative works thereof, and its supporting
+documentation for any purpose whatsoever, provided that this entire
+notice appears in all copies of the software, derivative works and
+supporting documentation. Further, UCAR requests that the user credit
+UCAR/Unidata in any publications that result from the use of this
+software or in any product that includes this software, although this
+is not an obligation. The names UCAR and/or Unidata, however, may not
+be used in any advertising or publicity to endorse or promote any
+products or commercial entity unless specific written permission is
+obtained from UCAR/Unidata. The user also understands that
+UCAR/Unidata is not obligated to provide the user with any support,
+consulting, training or assistance of any kind with regard to the use,
+operation and performance of this software nor to provide the user
+with any updates, revisions, new versions or "bug fixes."
+
+THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
+
+
+
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..f60e0b4
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,45 @@
+## This is a 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 $
+
+# These files get added to the distribution.
+EXTRA_DIST = COPYRIGHT
+
+ACLOCAL_AMFLAGS = -I m4
+
+# Does the user want to build cfcheck?
+if BUILD_CFCHECK
+CFCHECK = cfcheck
+endif
+
+# Does the user want to build the docs?
+if BUILD_DOCS
+DOC = doc
+endif
+
+# Does the user want to build the gridspec?
+if BUILD_GRIDSPEC
+GRIDSPEC = gridspec_tools_20080702
+endif
+
+SUBDIRS = $(GRIDSPEC) src $(CFCHECK) $(DOC)
+
+check_install: check install
+
+# What needs to go in the binrary dist?
+BINFILES = README_BINARIES.txt include/libcf.h lib/libcf.a
+
+# At Unidata, package up binaries.
+ftpbin: install
+ echo "Getting binaries from ${prefix}"
+ ls ${prefix}
+ echo "These are the binaries for libCF @PACKAGE_VERSION at ." > ${prefix}/README_BINARIES.txt
+ echo "For this build: CC=$(CC) CXX=$(CXX) FC=$(FC) F77=$(F77) $F90=$(F90)" >> ${prefix}/README_BINARIES.txt
+ echo "CFLAGS=$(CFLAGS) CXXFLAGS=$(CXXFLAGS)" >> ${prefix}/README_BINARIES.txt
+ 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
+
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..9e2bb04
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,704 @@
+# 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@
+
+# 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 $
+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@
+subdir = .
+DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(srcdir)/config.h.in \
+ $(srcdir)/nfconfig.in $(top_srcdir)/configure compile \
+ config.guess config.sub depcomp install-sh ltmain.sh missing
+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)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h nfconfig.inc
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = gridspec_tools_20080702 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
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+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@
+
+# These files get added to the distribution.
+EXTRA_DIST = COPYRIGHT
+ACLOCAL_AMFLAGS = -I m4
+
+# Does the user want to build cfcheck?
+ at BUILD_CFCHECK_TRUE@CFCHECK = cfcheck
+
+# Does the user want to build the docs?
+ at BUILD_DOCS_TRUE@DOC = doc
+
+# Does the user want to build the gridspec?
+ at BUILD_GRIDSPEC_TRUE@GRIDSPEC = gridspec_tools_20080702
+SUBDIRS = $(GRIDSPEC) src $(CFCHECK) $(DOC)
+
+# What needs to go in the binrary dist?
+BINFILES = README_BINARIES.txt include/libcf.h lib/libcf.a
+all: config.h nfconfig.inc
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+am--refresh:
+ @:
+$(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 \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ echo ' $(SHELL) ./config.status'; \
+ $(SHELL) ./config.status;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+config.h: stamp-h1
+ @if test ! -f $@; then \
+ rm -f stamp-h1; \
+ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+ else :; fi
+
+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)
+ rm -f stamp-h1
+ touch $@
+
+nfconfig.inc: stamp-h2
+ @if test ! -f $@; then \
+ rm -f stamp-h2; \
+ $(MAKE) $(AM_MAKEFLAGS) stamp-h2; \
+ else :; fi
+
+stamp-h2: $(srcdir)/nfconfig.in $(top_builddir)/config.status
+ @rm -f stamp-h2
+ cd $(top_builddir) && $(SHELL) ./config.status nfconfig.inc
+
+distclean-hdr:
+ -rm -f config.h stamp-h1 nfconfig.inc stamp-h2
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (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); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+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: tags-recursive $(HEADERS) $(SOURCES) config.h.in nfconfig.in $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ 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; }; }'`; \
+ 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: 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" \
+ || $(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)
+ $(am__remove_distdir)
+ test -d $(distdir) || mkdir $(distdir)
+ @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
+ 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 && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+ -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)
+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)
+
+dist-lzma: distdir
+ tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+ $(am__remove_distdir)
+dist-tarZ: distdir
+ tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ $(am__remove_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)
+ $(am__remove_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
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ case '$(DIST_ARCHIVES)' in \
+ *.tar.gz*) \
+ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+ *.tar.bz2*) \
+ bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+ *.tar.lzma*) \
+ unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+ *.tar.Z*) \
+ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+ *.shar.gz*) \
+ GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+ *.zip*) \
+ unzip $(distdir).zip ;;\
+ esac
+ chmod -R a-w $(distdir); chmod a+w $(distdir)
+ mkdir $(distdir)/_build
+ mkdir $(distdir)/_inst
+ chmod a-w $(distdir)
+ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+ && cd $(distdir)/_build \
+ && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+ distuninstallcheck \
+ && chmod -R a-w "$$dc_install_base" \
+ && ({ \
+ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+ } || { rm -rf "$$dc_destdir"; exit 1; }) \
+ && rm -rf "$$dc_destdir" \
+ && $(MAKE) $(AM_MAKEFLAGS) dist \
+ && rm -rf $(DIST_ARCHIVES) \
+ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+ $(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) \
+ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+ || { echo "ERROR: files left after uninstall:" ; \
+ if test -n "$(DESTDIR)"; then \
+ echo " (check DESTDIR support)"; \
+ fi ; \
+ $(distuninstallcheck_listfiles) ; \
+ exit 1; } >&2
+distcleancheck: distclean
+ @if test '$(srcdir)' = . ; then \
+ echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+ exit 1 ; \
+ fi
+ @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left in build directory after distclean:" ; \
+ $(distcleancheck_listfiles) ; \
+ exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile config.h nfconfig.inc
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-hdr \
+ distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf $(top_srcdir)/autom4te.cache
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+ install-strip
+
+.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
+
+
+check_install: check install
+
+# At Unidata, package up binaries.
+ftpbin: install
+ echo "Getting binaries from ${prefix}"
+ ls ${prefix}
+ echo "These are the binaries for libCF @PACKAGE_VERSION at ." > ${prefix}/README_BINARIES.txt
+ echo "For this build: CC=$(CC) CXX=$(CXX) FC=$(FC) F77=$(F77) $F90=$(F90)" >> ${prefix}/README_BINARIES.txt
+ echo "CFLAGS=$(CFLAGS) CXXFLAGS=$(CXXFLAGS)" >> ${prefix}/README_BINARIES.txt
+ 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
new file mode 100644
index 0000000..2d8d3af
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,1170 @@
+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)
+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
+
+])
+
+
+
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644
index 0000000..eab4b58
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,908 @@
+# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 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,
+# 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.
+
+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.
+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.
+#
+# 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.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# 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'
+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], [],
+ [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too. Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+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.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.10.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
+
+# AM_AUX_DIR_EXPAND -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005 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.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory. The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run. This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+# fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+# fails if $ac_aux_dir is absolute,
+# fails when called from a subdirectory in a VPATH build with
+# a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir. In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
+# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+# MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH. The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
+# 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
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
+ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+ AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# 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
+
+# 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,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery. Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
+ [$1], CXX, [depcc="$CXX" am_compiler_list=],
+ [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+ [$1], UPC, [depcc="$UPC" am_compiler_list=],
+ [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
+ [depcc="$$1" am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+ [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_$1_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+ fi
+ 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
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+ # Solaris 8's {/usr,}/bin/sh.
+ touch sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ case $depmode in
+ nosideeffect)
+ # after this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ 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} \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 &&
+ ${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
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_$1_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[ --disable-dependency-tracking speeds up one-time build
+ --enable-dependency-tracking do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking. -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# 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
+
+# _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"
+ done
+done
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled. FIXME. This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+ [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# 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.
+#
+# 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
+
+# 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.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out. PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition. After
+# the next Automake release, Autoconf can make the AC_INIT
+# 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
+dnl Autoconf wants to disallow AM_ names. We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+ [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+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_MKDIR_P])dnl
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+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([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+ [_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
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+ [_AM_DEPENDENCIES(OBJC)],
+ [define([AC_PROG_OBJC],
+ defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated. The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005 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.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# 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"}
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005 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
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes. -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005 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
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+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
+# 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
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
+# 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
+
+# AM_PROG_CC_C_O
+# --------------
+# Like AC_PROG_CC_C_O, but changed for automake.
+AC_DEFUN([AM_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC_C_O])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+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
+ # 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.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+dnl Make sure AC_PROG_CC is never called again, or it will override our
+dnl setting of CC.
+m4_define([AC_PROG_CC],
+ [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
+])
+
+# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
+# 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
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+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"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+ am_missing_run="$MISSING --run "
+else
+ am_missing_run=
+ AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006 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.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+ [[\\/$]]* | ?:[[\\/]]*) ;;
+ */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling. -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005 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
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME. Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane. -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# 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
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# 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`
+ if test "$[*]" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftest.file`
+ fi
+ rm -f conftest.file
+ if test "$[*]" != "X $srcdir/configure conftest.file" \
+ && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "$[2]" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2001, 2003, 2005 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.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries. This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# 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.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+ AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006 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.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# Check how to create a tarball. -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005 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_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+# tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+# $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+ [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+ [m4_case([$1], [ustar],, [pax],,
+ [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+ case $_am_tool in
+ gnutar)
+ for _am_tar in tar gnutar gtar;
+ do
+ AM_RUN_LOG([$_am_tar --version]) && break
+ done
+ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+ am__untar="$_am_tar -xf -"
+ ;;
+ plaintar)
+ # Must skip GNU tar: if it does not support --format= it doesn't create
+ # ustar tarball either.
+ (tar --version) >/dev/null 2>&1 && continue
+ am__tar='tar chf - "$$tardir"'
+ am__tar_='tar chf - "$tardir"'
+ am__untar='tar xf -'
+ ;;
+ pax)
+ am__tar='pax -L -x $1 -w "$$tardir"'
+ am__tar_='pax -L -x $1 -w "$tardir"'
+ am__untar='pax -r'
+ ;;
+ cpio)
+ am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+ am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+ am__untar='cpio -i -H $1 -d'
+ ;;
+ none)
+ am__tar=false
+ am__tar_=false
+ am__untar=false
+ ;;
+ esac
+
+ # If the value was cached, stop now. We just wanted to have am__tar
+ # and am__untar set.
+ test -n "${am_cv_prog_tar_$1}" && break
+
+ # tar/untar a dummy directory, and stop if the command works
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ echo GrepMe > conftest.dir/file
+ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+ rm -rf conftest.dir
+ if test -s conftest.tar; then
+ AM_RUN_LOG([$am__untar <conftest.tar])
+ grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+ fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
+m4_include([acinclude.m4])
diff --git a/cfcheck/Makefile.am b/cfcheck/Makefile.am
new file mode 100644
index 0000000..9588892
--- /dev/null
+++ b/cfcheck/Makefile.am
@@ -0,0 +1,43 @@
+# This is part of the libcf library.
+
+# 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 $
+
+# Find libcf.h here.
+AM_CPPFLAGS = -I${top_srcdir}/src
+
+AM_LDFLAGS =
+
+# 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
+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
+
+EXTRA_DIST = tst_cfcheck.sh
+
+bin_PROGRAMS = cfcheck
+cfcheck_SOURCES = cfcheck.c
+
+TESTS = tst_cfcheck.sh
+
+CLEANFILES = useage.txt
\ No newline at end of file
diff --git a/cfcheck/Makefile.in b/cfcheck/Makefile.in
new file mode 100644
index 0000000..69ea17e
--- /dev/null
+++ b/cfcheck/Makefile.in
@@ -0,0 +1,593 @@
+# 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 is part of the libcf library.
+
+# 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 $
+
+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@
+
+# 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
+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_cfcheck_OBJECTS = cfcheck.$(OBJEXT)
+cfcheck_OBJECTS = $(am_cfcheck_OBJECTS)
+cfcheck_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+cfcheck_DEPENDENCIES = ../src/libcf.la $(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 = $(cfcheck_SOURCES)
+DIST_SOURCES = $(cfcheck_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@
+
+# 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
+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 cfcheck/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign cfcheck/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
+cfcheck$(EXEEXT): $(cfcheck_OBJECTS) $(cfcheck_DEPENDENCIES)
+ @rm -f cfcheck$(EXEEXT)
+ $(LINK) $(cfcheck_OBJECTS) $(cfcheck_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cfcheck.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
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ 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 \
+ *$$ws$$tst$$ws*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ echo "XPASS: $$tst"; \
+ ;; \
+ *) \
+ echo "PASS: $$tst"; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *$$ws$$tst$$ws*) \
+ xfail=`expr $$xfail + 1`; \
+ echo "XFAIL: $$tst"; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ echo "SKIP: $$tst"; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ 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 \
+ 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)"; \
+ 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`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+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
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+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:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+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-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.
+.NOEXPORT:
diff --git a/cfcheck/cfcheck.c b/cfcheck/cfcheck.c
new file mode 100644
index 0000000..c38f184
--- /dev/null
+++ b/cfcheck/cfcheck.c
@@ -0,0 +1,87 @@
+/* Copyright 2006, Unidata/UCAR. See COPYRIGHT file for more
+ details.
+
+ This program checks a netCDF file to see how well it complies with
+ the CF Metadata conventions.
+
+ Ed Hartnett, 11/23/06
+
+ $Id: cfcheck.c,v 1.2 2006/11/26 11:45:09 ed Exp $
+*/
+
+#include <config.h>
+#include <stdio.h>
+#include <unistd.h> /* for getopt */
+#include <netcdf.h>
+#include <libcf.h>
+
+/* This struct is used to keep track of user options from the command
+ * line. */
+typedef struct
+{
+ int verbose;
+} OPTIONS_T;
+
+/* This is a message to the user about how to use cfcheck. */
+#define USAGE "\
+ file Name of netCDF file\n"
+
+/* This prints out a helpful message to the user when they screw up or
+ * are confused and ask for help. */
+static void
+usage()
+{
+ fprintf(stderr, "cfcheck file\n%s", USAGE);
+ fprintf(stderr, "netcdf library version %s\n", nc_inq_libvers());
+}
+
+/* This function checks one file for cf conventions. */
+static int
+do_cfcheck(char *filename, OPTIONS_T *options)
+{
+ printf("Checking CF conventions for file %s.\n", filename);
+ return CF_NOERR;
+}
+
+int
+main(int argc, char** argv)
+{
+ extern int optind;
+ extern int opterr;
+ extern char *optarg;
+ char c;
+ OPTIONS_T options;
+ int i;
+
+ /* If the user called ncdump without arguments, print the usage
+ * message and return peacefully. */
+ if (argc <= 1)
+ {
+ usage();
+ return 0;
+ }
+
+ /* See what options the user wants, and set flags in the OPTIONS_T
+ * stuct. */
+ while ((c = getopt(argc, argv, "?:v")) != EOF)
+ {
+ switch(c)
+ {
+ case '?':
+ usage();
+ return 0;
+ case 'v':
+ options.verbose = 1;
+ return 0;
+ }
+ argc -= optind;
+ argv += optind;
+ }
+
+ /* Check each file in turn. */
+ for (i = 1; i < argc; i++)
+ if (argc > 0)
+ do_cfcheck(argv[i], &options);
+
+ return CF_NOERR;
+}
diff --git a/cfcheck/tst_cfcheck.sh b/cfcheck/tst_cfcheck.sh
new file mode 100755
index 0000000..17981d3
--- /dev/null
+++ b/cfcheck/tst_cfcheck.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Copyright 2006, Unidata/UCAR. See COPYRIGHT file.
+
+# This is part of the libcf library.
+
+# This shell script runs the cfcheck tests.
+
+# Ed Hartnett, 11/23/06
+
+# $Id: tst_cfcheck.sh,v 1.2 2006/11/26 11:45:09 ed Exp $
+
+set -e
+echo ""
+echo "*** Testing cfcheck."
+
+echo "*** testing that useage works..."
+./cfcheck &> useage.txt
+#diff -w usage.txt ref_usage.txt
+
+echo "*** All tests of cfcheck passed!"
+exit 0
diff --git a/compile b/compile
new file mode 100755
index 0000000..1b1d232
--- /dev/null
+++ b/compile
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey at cygnus.com>.
+#
+# 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, 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.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "compile $scriptversion"
+ exit $?
+ ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as `compile cc -o foo foo.c'.
+ # So we strip `-o arg' only if arg is an object.
+ eat=1
+ case $2 in
+ *.o | *.obj)
+ ofile=$2
+ ;;
+ *)
+ set x "$@" -o "$2"
+ shift
+ ;;
+ esac
+ ;;
+ *.c)
+ cfile=$1
+ set x "$@" "$1"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+ # If no `-o' option was seen then we might have been invoked from a
+ # pattern rule where we don't need one. That is ok -- this is a
+ # normal compilation that the losing compiler can handle. If no
+ # `.c' file was seen then we are probably linking. That is also
+ # ok.
+ exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# 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
+while true; do
+ if mkdir "$lockdir" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+ mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+ mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/config.guess b/config.guess
new file mode 100755
index 0000000..ca2a03c
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1526 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+
+timestamp='2008-01-08'
+
+# 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
+# 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.
+
+
+# Originally written by Per Bothner <per at bothner.com>.
+# Please send patches to <config-patches at gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi at noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ 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/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[456])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ *:Interix*:[3456]*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T | authenticamd)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ 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.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ 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
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ 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; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel at ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes at openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf at swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green at stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green at stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+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
+and
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..bf5de8a
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,183 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* 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.
+ */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+#undef HAVE_ALLOCA_H
+
+/* 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
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define this if you have strlcat() */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if `st_blksize' is member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+
+/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use
+ `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
+#undef HAVE_ST_BLKSIZE
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* if true, turn on logging */
+#undef LOGGING
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#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
+
+/* no stdlib.h */
+#undef NO_STDLIB_H
+
+/* no strerror.h */
+#undef NO_STRERROR
+
+/* no sys_types.h */
+#undef NO_SYS_TYPES_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of `double', as computed by sizeof. */
+#undef SIZEOF_DOUBLE
+
+/* The size of `float', as computed by sizeof. */
+#undef SIZEOF_FLOAT
+
+/* The size of `int', as computed by sizeof. */
+#undef SIZEOF_INT
+
+/* The size of `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* type size */
+#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.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* if true, use netCDF-4 */
+#undef USE_NETCDF4
+
+/* Version number of package */
+#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
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to 1 if type `char' is unsigned and you are not using gcc. */
+#ifndef __CHAR_UNSIGNED__
+# undef __CHAR_UNSIGNED__
+#endif
+
+/* Define to `long int' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef ptrdiff_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef ssize_t
+
+/* Define to `unsigned char' if <sys/types.h> does not define. */
+#undef uchar
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000..6759825
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1658 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+
+timestamp='2008-01-16'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# 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
+# 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.
+
+
+# Please send patches to <config-patches at gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+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* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | 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 \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | 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-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tile*)
+ basic_machine=tile-unknown
+ os=-linux-gnu
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mep-*)
+ os=-elf
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755
index 0000000..c5f9766
--- /dev/null
+++ b/configure
@@ -0,0 +1,27024 @@
+#! /bin/sh
+# From configure.ac Id: configure.ac,v 1.22 2009/04/12 14:18:13 ed Exp .
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.62 for libcf 1.0-alpha4.
+#
+# Report bugs to <support at unidata.ucar.edu>.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+ if (eval ":") 2>/dev/null; then
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+
+ if test $as_have_required = yes && (eval ":
+(as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=\$LINENO
+ as_lineno_2=\$LINENO
+ test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+ test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+ :
+else
+ as_candidate_shells=
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ case $as_dir in
+ /*)
+ for as_base in sh bash ksh sh5; do
+ as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+ done;;
+ esac
+done
+IFS=$as_save_IFS
+
+
+ for as_shell in $as_candidate_shells $SHELL; do
+ # Try only shells that exist, to save several forks.
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+ CONFIG_SHELL=$as_shell
+ as_have_required=yes
+ if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+ (exit $1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+ break
+fi
+
+fi
+
+ done
+
+ if test "x$CONFIG_SHELL" != x; then
+ for as_var in BASH_ENV ENV
+ do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ done
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+ if test $as_have_required = no; then
+ echo This script requires a shell more modern than all the
+ echo shells that I found on your system. Please install a
+ echo modern shell, or manually run the script under such a
+ echo shell if you do have one.
+ { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+ echo No shell found that supports shell functions.
+ echo Please tell bug-autoconf at gnu.org about your system,
+ echo including any error possibly output before this message.
+ echo This can help us improve future autoconf versions.
+ echo Configuration will now proceed without shell functions.
+}
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -p'
+ fi
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','`
+ ;;
+esac
+
+ECHO=${lt_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 <<_LT_EOF
+$*
+_LT_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 "$lt_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 &&
+ { 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.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+ lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+
+exec 7<&0 </dev/null 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+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_BUGREPORT='support at unidata.ucar.edu'
+
+ac_unique_file="src/nccoord.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# 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
+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
+CPPFLAGS
+F77
+FFLAGS
+FC
+FCFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
+ { (exit 1); exit 1; }; }
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { $as_echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { $as_echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+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
+ { (exit 1); exit 1; }; } ;;
+ *) $as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; }
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+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
+ { (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
+ { (exit 1); exit 1; }; }
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
+ { (exit 1); exit 1; }; }
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+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.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/libcf]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of libcf 1.0-alpha4:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-shared[=PKGS] build shared libraries [default=no]
+ --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-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-extra-data-tests
+ Perform extra tests using CF example files from
+ Unidata web site (example files must be donloaded
+ separately). This option should only be used by
+ those with excessive interest in testing libcf.
+ --disable-f90 don't try to build Fortran 90 API
+ --disable-dependency-tracking speeds up one-time build
+ --enable-dependency-tracking do not reject slow dependency extractors
+ --enable-static[=PKGS] build static libraries [default=yes]
+ --enable-fast-install[=PKGS]
+ optimize for fast installation [default=yes]
+ --disable-libtool-lock avoid locking (might break parallel builds)
+ --disable-largefile omit support for large files
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --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-netcdf=<directory>
+ Specify location of netCDF library. Configure will
+ expect to find subdirs include and lib.
+ --with-pic try to use only PIC/non-PIC objects [default=use
+ both]
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ F77 Fortran 77 compiler command
+ FFLAGS Fortran 77 compiler flags
+ FC Fortran compiler command
+ FCFLAGS Fortran compiler flags
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <support at unidata.ucar.edu>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+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
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+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
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ 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;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test -r "$ac_site_file"; then
+ { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $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
+$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&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
+
+
+
+
+{ $as_echo "$as_me:$LINENO: libcf 1.0-alpha4" >&5
+$as_echo "$as_me: libcf 1.0-alpha4" >&6;}
+
+# Find out about the host we're building on.
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
+$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+{ $as_echo "$as_me:$LINENO: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+$as_echo "$as_me: error: invalid value of canonical build" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:$LINENO: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+$as_echo "$as_me: error: invalid value of canonical host" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+
+# We will output a config.h for the C library, and a fortran inc file,
+# nfconfig.inc.
+ac_config_headers="$ac_config_headers config.h"
+
+ac_config_headers="$ac_config_headers nfconfig.inc:nfconfig.in"
+
+
+# This call is required by automake.
+am__api_version='1.10'
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ rm -rf conftest.one conftest.two conftest.dir
+ echo one > conftest.one
+ echo two > conftest.two
+ mkdir conftest.dir
+ if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+ test -s conftest.one && test -s conftest.two &&
+ test -s conftest.dir/conftest.one &&
+ test -s conftest.dir/conftest.two
+ then
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+
+done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ INSTALL=$ac_install_sh
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# 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`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftest.file`
+ fi
+ rm -f conftest.file
+ if test "$*" != "X $srcdir/configure conftest.file" \
+ && test "$*" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" >&5
+$as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
+alias in your environment" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ test "$2" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files!
+Check your system clock" >&5
+$as_echo "$as_me: error: newly created file is older than distributed files!
+Check your system clock" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+ program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+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"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+ am_missing_run="$MISSING --run "
+else
+ am_missing_run=
+ { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+{ $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
+ if test "${ac_cv_path_mkdir+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in mkdir gmkdir; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+ case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+ 'mkdir (GNU coreutils) '* | \
+ 'mkdir (coreutils) '* | \
+ 'mkdir (fileutils) '4.1*)
+ ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+ break 3;;
+ esac
+ done
+ done
+done
+IFS=$as_save_IFS
+
+fi
+
+ if test "${ac_cv_path_mkdir+set}" = set; then
+ MKDIR_P="$ac_cv_path_mkdir -p"
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for MKDIR_P within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ test -d ./--version && rmdir ./--version
+ MKDIR_P="$ac_install_sh -d"
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+ [\\/$]* | ?:[\\/]*) ;;
+ */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+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_AWK+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AWK"; then
+ ac_cv_prog_AWK="$AWK" # 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_AWK="$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
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+ { $as_echo "$as_me:$LINENO: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+ @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+ *@@@%%%=?*=@@@%%%*)
+ eval ac_cv_prog_make_${ac_make}_set=yes;;
+ *)
+ eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+ { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+ SET_MAKE=
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ am__isrc=' -I$(srcdir)'
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='libcf'
+ VERSION='1.0-alpha4'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+
+# 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: 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 -'
+
+
+
+
+
+
+# Check for the existance of this file before proceeding.
+
+
+{ $as_echo "$as_me:$LINENO: checking user options" >&5
+$as_echo "$as_me: checking user options" >&6;}
+
+# Turn off shared libraries by default
+# Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then
+ enableval=$enable_shared; 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
+else
+ enable_shared=no
+fi
+
+
+
+
+
+
+
+
+
+
+# The autoconf manual suggests the following to set a var if it's not
+# already set: test "${var+set}" = set || var={value}
+
+# For backward compatibility, check to see if the user has set FC to
+# null. If so, treat that as the --disable-fortran option to
+# configure.
+
+# Did the user set fc to null?
+{ $as_echo "$as_me:$LINENO: checking whether FC is set to ''" >&5
+$as_echo_n "checking whether FC is set to ''... " >&6; }
+nc_null_fc=no
+test "x${FC+set}" = xset && test "x$FC" = x && nc_null_fc=yes
+{ $as_echo "$as_me:$LINENO: result: $nc_null_fc" >&5
+$as_echo "$nc_null_fc" >&6; }
+
+# Does the user want to build documentation?
+{ $as_echo "$as_me:$LINENO: checking whether documentation is to be built" >&5
+$as_echo_n "checking whether documentation is to be built... " >&6; }
+# Check whether --enable-docs was given.
+if test "${enable_docs+set}" = set; then
+ enableval=$enable_docs;
+fi
+
+test "x$enable_docs" = xyes || enable_docs=no
+{ $as_echo "$as_me:$LINENO: result: $enable_docs" >&5
+$as_echo "$enable_docs" >&6; }
+ if test x$enable_docs = xyes; then
+ BUILD_DOCS_TRUE=
+ BUILD_DOCS_FALSE='#'
+else
+ BUILD_DOCS_TRUE='#'
+ BUILD_DOCS_FALSE=
+fi
+
+
+# Does the user want to build gridspec tools?
+{ $as_echo "$as_me:$LINENO: checking whether gridspec tools are to be built" >&5
+$as_echo_n "checking whether gridspec tools are to be built... " >&6; }
+# Check whether --enable-gridspec was given.
+if test "${enable_gridspec+set}" = set; then
+ enableval=$enable_gridspec;
+fi
+
+test "x$enable_gridspec" = xyes || enable_gridspec=no
+{ $as_echo "$as_me:$LINENO: result: $enable_gridspec" >&5
+$as_echo "$enable_gridspec" >&6; }
+ if test x$enable_gridspec = xyes; then
+ BUILD_GRIDSPEC_TRUE=
+ BUILD_GRIDSPEC_FALSE='#'
+else
+ BUILD_GRIDSPEC_TRUE='#'
+ BUILD_GRIDSPEC_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; }
+# Check whether --enable-cfcheck was given.
+if test "${enable_cfcheck+set}" = set; then
+ enableval=$enable_cfcheck;
+fi
+
+test "x$enable_cfcheck" = xno || enable_cfcheck=yes
+{ $as_echo "$as_me:$LINENO: result: $enable_cfcheck" >&5
+$as_echo "$enable_cfcheck" >&6; }
+ if test x$enable_cfcheck = xyes; then
+ BUILD_CFCHECK_TRUE=
+ BUILD_CFCHECK_FALSE='#'
+else
+ BUILD_CFCHECK_TRUE='#'
+ BUILD_CFCHECK_FALSE=
+fi
+
+
+# Does the user want to enable logging?
+{ $as_echo "$as_me:$LINENO: checking whether logging is enabled (useful to CF developers, mainly" >&5
+$as_echo_n "checking whether logging is enabled (useful to CF developers, mainly... " >&6; }
+# Check whether --enable-logging was given.
+if test "${enable_logging+set}" = set; then
+ enableval=$enable_logging;
+fi
+
+test "x$enable_logging" = "xyes" || enable_logging=no
+{ $as_echo "$as_me:$LINENO: result: $enable_logging" >&5
+$as_echo "$enable_logging" >&6; }
+if test "x$enable_logging" = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define LOGGING 1
+_ACEOF
+
+fi
+
+# Does the user want to use netcdf-4?
+{ $as_echo "$as_me:$LINENO: checking whether netCDF-4 is to be used" >&5
+$as_echo_n "checking whether netCDF-4 is to be used... " >&6; }
+# Check whether --enable-netcdf-4 was given.
+if test "${enable_netcdf_4+set}" = set; then
+ enableval=$enable_netcdf_4;
+fi
+
+test "x$enable_netcdf_4" = xyes || enable_netcdf_4=no
+{ $as_echo "$as_me:$LINENO: result: $enable_netcdf_4" >&5
+$as_echo "$enable_netcdf_4" >&6; }
+ if test x$enable_netcdf_4 = xyes; then
+ USE_NETCDF4_TRUE=
+ USE_NETCDF4_FALSE='#'
+else
+ USE_NETCDF4_TRUE='#'
+ USE_NETCDF4_FALSE=
+fi
+
+if test "x$enable_netcdf_4" = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_NETCDF4 1
+_ACEOF
+
+fi
+
+# Does the user want to use netcdf-4?
+{ $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.
+if test "${enable_extra_data_tests+set}" = set; then
+ enableval=$enable_extra_data_tests;
+fi
+
+test "x$enable_extra_data_tests" = xyes || enable_extra_data_tests=no
+{ $as_echo "$as_me:$LINENO: result: $enable_extra_data_tests" >&5
+$as_echo "$enable_extra_data_tests" >&6; }
+ if test x$enable_extra_data_tests = xyes; then
+ EXTRA_DATA_TESTS_TRUE=
+ EXTRA_DATA_TESTS_FALSE='#'
+else
+ EXTRA_DATA_TESTS_TRUE='#'
+ EXTRA_DATA_TESTS_FALSE=
+fi
+
+
+# Did the user specify a location for the HDF5 library?
+{ $as_echo "$as_me:$LINENO: checking whether a location for the HDF5 library was specified" >&5
+$as_echo_n "checking whether a location for the HDF5 library was specified... " >&6; }
+
+# Check whether --with-hdf5 was given.
+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
+ USE_HDF5_DIR_TRUE=
+ USE_HDF5_DIR_FALSE='#'
+else
+ USE_HDF5_DIR_TRUE='#'
+ USE_HDF5_DIR_FALSE=
+fi
+
+HDF5DIR=$HDF5DIR
+
+
+# Do we want to build the fortran API? Check for --disable-f90
+nc_build_f90=yes
+{ $as_echo "$as_me:$LINENO: checking whether Fortran 90 API is desired" >&5
+$as_echo_n "checking whether Fortran 90 API is desired... " >&6; }
+# Check whether --enable-f90 was given.
+if test "${enable_f90+set}" = set; then
+ enableval=$enable_f90;
+fi
+
+test "x$enable_f90" = "xno" && nc_build_f90=no
+test "x$nc_null_fc" = xyes && nc_build_f90=no
+{ $as_echo "$as_me:$LINENO: result: $nc_build_f90" >&5
+$as_echo "$nc_build_f90" >&6; }
+ if test "x$nc_build_f90" = xyes; then
+ BUILD_F90_TRUE=
+ BUILD_F90_FALSE='#'
+else
+ BUILD_F90_TRUE='#'
+ BUILD_F90_FALSE=
+fi
+
+
+# Did the user specify a location for the netcdf library?
+{ $as_echo "$as_me:$LINENO: checking whether a location for the netCDF library was specified" >&5
+$as_echo_n "checking whether a location for the netCDF library was specified... " >&6; }
+
+# Check whether --with-netcdf was given.
+if test "${with_netcdf+set}" = set; then
+ withval=$with_netcdf; NETCDFDIR=$with_netcdf
+fi
+
+NETCDFDIR=${NETCDFDIR}
+{ $as_echo "$as_me:$LINENO: result: $NETCDFDIR" >&5
+$as_echo "$NETCDFDIR" >&6; }
+ if test ! "x$NETCDFDIR" = x; then
+ USE_NETCDF_DIR_TRUE=
+ USE_NETCDF_DIR_FALSE='#'
+else
+ USE_NETCDF_DIR_TRUE='#'
+ USE_NETCDF_DIR_FALSE=
+fi
+
+NETCDFDIR=$NETCDFDIR
+
+
+# According to the autoconf mailing list gurus, we must test for
+# compilers unconditionally. That is, we can't skip looking for the
+# fortran compilers, just because the user doesn't want fortran. This
+# is due to a limitation in autoconf.
+
+# Find the C compiler.
+{ $as_echo "$as_me:$LINENO: finding C compiler" >&5
+$as_echo "$as_me: finding C compiler" >&6;}
+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
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in mpcc_r xlc cc c89 acc gcc
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$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_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # 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_CC="$ac_tool_prefix$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
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in mpcc_r xlc cc c89 acc gcc
+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_ac_ct_CC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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_CC="$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
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ 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
+ CC=$ac_ct_CC
+ fi
+fi
+
+
+test -z "$CC" && { { $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; }; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+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_compiler --version >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+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_compiler -v >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+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_compiler -V >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+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_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+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: 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; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (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
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $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; }; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+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); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $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; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+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. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+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>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $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; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+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. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ 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_compiler_gnu=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+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_prog_cc_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ CFLAGS=""
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+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
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+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_prog_cc_g=yes
+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
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ 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_prog_cc_c89=$ac_arg
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+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
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+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
+# 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
+fi
+
+
+{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then
+ enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+ AMDEP_TRUE=
+ AMDEP_FALSE='#'
+else
+ AMDEP_TRUE='#'
+ AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC" am_compiler_list=
+
+{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CC_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ 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
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+ # Solaris 8's {/usr,}/bin/sh.
+ touch sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ case $depmode in
+ nosideeffect)
+ # after this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ 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} \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 &&
+ ${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
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CC_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+ am__fastdepCC_TRUE=
+ am__fastdepCC_FALSE='#'
+else
+ am__fastdepCC_TRUE='#'
+ am__fastdepCC_FALSE=
+fi
+
+
+if test "x$CC" != xcc; then
+ { $as_echo "$as_me:$LINENO: checking whether $CC and cc understand -c and -o together" >&5
+$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
+else
+ { $as_echo "$as_me:$LINENO: checking whether cc understands -c and -o together" >&5
+$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
+fi
+set dummy $CC; ac_cc=`$as_echo "$2" |
+ sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+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. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+rm -f conftest2.*
+if { (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); } &&
+ test -f conftest2.$ac_objext && { (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
+ eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+ if test "x$CC" != xcc; then
+ # Test first that cc exists at all.
+ if { ac_try='cc -c conftest.$ac_ext >&5'
+ { (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_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+ rm -f conftest2.*
+ if { (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); } &&
+ test -f conftest2.$ac_objext && { (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
+ # cc works too.
+ :
+ else
+ # cc exists but doesn't like -o.
+ eval ac_cv_prog_cc_${ac_cc}_c_o=no
+ fi
+ fi
+ fi
+else
+ eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+
+fi
+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
+ { $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; }
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_MINUS_C_MINUS_O 1
+_ACEOF
+
+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
+ # 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.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+
+
+
+# Find fortran compiler. If FC isn't set after AC_PROG_FC, we couldn't
+# find a fortran compiler. If the user requested the fortran API, then
+# bail out right here.
+{ $as_echo "$as_me:$LINENO: finding Fortran compiler (required, even if Fortran API is not desired)" >&5
+$as_echo "$as_me: finding Fortran compiler (required, even if Fortran API is not desired)" >&6;}
+
+# We must call AC_PROG_F77 here, otherwise the LIBTOOL macro below
+# will call it, and reset F77 to g77.
+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
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in mpxlf_r xlf fort xlf95 ifort ifc efc pgf95 lf95 g95 gfortran f95 frt pgf77 f77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 g77
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$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_F77+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$F77"; then
+ ac_cv_prog_F77="$F77" # 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_F77="$ac_tool_prefix$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
+F77=$ac_cv_prog_F77
+if test -n "$F77"; then
+ { $as_echo "$as_me:$LINENO: result: $F77" >&5
+$as_echo "$F77" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$F77" && break
+ done
+fi
+if test -z "$F77"; then
+ ac_ct_F77=$F77
+ for ac_prog in mpxlf_r xlf fort xlf95 ifort ifc efc pgf95 lf95 g95 gfortran f95 frt pgf77 f77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 g77
+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_ac_ct_F77+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_F77"; then
+ ac_cv_prog_ac_ct_F77="$ac_ct_F77" # 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_F77="$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
+ac_ct_F77=$ac_cv_prog_ac_ct_F77
+if test -n "$ac_ct_F77"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
+$as_echo "$ac_ct_F77" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_F77" && break
+done
+
+ if test "x$ac_ct_F77" = x; then
+ F77=""
+ 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
+ F77=$ac_ct_F77
+ fi
+fi
+
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for Fortran 77 compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+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_compiler --version >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+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_compiler -v >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+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_compiler -V >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file. (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran 77 compiler... " >&6; }
+if test "${ac_cv_f77_compiler_gnu+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+#ifndef __GNUC__
+ choke me
+#endif
+
+ 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_f77_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_compiler_gnu=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_f77_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
+$as_echo "$ac_cv_f77_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FFLAGS+set}
+ac_save_FFLAGS=$FFLAGS
+FFLAGS=
+{ $as_echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
+$as_echo_n "checking whether $F77 accepts -g... " >&6; }
+if test "${ac_cv_prog_f77_g+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ FFLAGS=-g
+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_f77_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_f77_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_prog_f77_g=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
+$as_echo "$ac_cv_prog_f77_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+ FFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_f77_g = yes; then
+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+ FFLAGS="-g -O2"
+ else
+ FFLAGS="-g"
+ fi
+else
+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+ FFLAGS="-O2"
+ else
+ FFLAGS=
+ fi
+fi
+
+if test $ac_compiler_gnu = yes; then
+ G77=yes
+else
+ G77=
+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
+
+if test "${F77+set}" = set && test "x$F77" = x && test "x$nc_build_fortran" = xyes; then
+ { { $as_echo "$as_me:$LINENO: error: Can't find F77 compiler, and compiler recovery disabled." >&5
+$as_echo "$as_me: error: Can't find F77 compiler, and compiler recovery disabled." >&2;}
+ { (exit 1); exit 1; }; }
+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
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in mpxlf_r xlf90 fort xlf95 ifort ifc efc pgf95 lf95 g95 gfortran f95 frt pgf77 f77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 g77
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$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_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="$ac_tool_prefix$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
+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; }
+fi
+
+
+ test -n "$FC" && break
+ done
+fi
+if test -z "$FC"; then
+ ac_ct_FC=$FC
+ for ac_prog in mpxlf_r xlf90 fort xlf95 ifort ifc efc pgf95 lf95 g95 gfortran f95 frt pgf77 f77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 g77
+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_ac_ct_FC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_FC"; then
+ ac_cv_prog_ac_ct_FC="$ac_ct_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_ac_ct_FC="$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
+ac_ct_FC=$ac_cv_prog_ac_ct_FC
+if test -n "$ac_ct_FC"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_FC" >&5
+$as_echo "$ac_ct_FC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_FC" && break
+done
+
+ if test "x$ac_ct_FC" = x; then
+ FC=""
+ 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
+ FC=$ac_ct_FC
+ fi
+fi
+
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for Fortran compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+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_compiler --version >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+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_compiler -v >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+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_compiler -V >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file. (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU Fortran compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran compiler... " >&6; }
+if test "${ac_cv_fc_compiler_gnu+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+#ifndef __GNUC__
+ choke me
+#endif
+
+ 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_compiler_gnu=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_fc_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_compiler_gnu" >&5
+$as_echo "$ac_cv_fc_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FCFLAGS+set}
+ac_save_FFLAGS=$FCFLAGS
+FCFLAGS=
+{ $as_echo "$as_me:$LINENO: checking whether $FC accepts -g" >&5
+$as_echo_n "checking whether $FC accepts -g... " >&6; }
+if test "${ac_cv_prog_fc_g+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ FCFLAGS=-g
+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_prog_fc_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_prog_fc_g=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_fc_g" >&5
+$as_echo "$ac_cv_prog_fc_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+ FCFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_fc_g = yes; then
+ if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+ FCFLAGS="-g -O2"
+ else
+ FCFLAGS="-g"
+ fi
+else
+ if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+ FCFLAGS="-O2"
+ else
+ FCFLAGS=
+ fi
+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
+
+
+{ $as_echo "$as_me:$LINENO: finding other utilities" >&5
+$as_echo "$as_me: finding other utilities" >&6;}
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ rm -rf conftest.one conftest.two conftest.dir
+ echo one > conftest.one
+ echo two > conftest.two
+ mkdir conftest.dir
+ if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+ test -s conftest.one && test -s conftest.two &&
+ test -s conftest.dir/conftest.one &&
+ test -s conftest.dir/conftest.two
+ then
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+
+done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ INSTALL=$ac_install_sh
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+{ $as_echo "$as_me:$LINENO: setting up libtool" >&5
+$as_echo "$as_me: setting up libtool" >&6;}
+
+# Produce a windows DLL. This macro must be before AM_PROG_LIBTOOL.
+enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
+set dummy ${ac_tool_prefix}as; 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_AS+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AS"; then
+ ac_cv_prog_AS="$AS" # 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_AS="${ac_tool_prefix}as"
+ $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
+AS=$ac_cv_prog_AS
+if test -n "$AS"; then
+ { $as_echo "$as_me:$LINENO: result: $AS" >&5
+$as_echo "$AS" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AS"; then
+ ac_ct_AS=$AS
+ # Extract the first word of "as", so it can be a program name with args.
+set dummy as; 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_AS+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AS"; then
+ ac_cv_prog_ac_ct_AS="$ac_ct_AS" # 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_AS="as"
+ $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_AS=$ac_cv_prog_ac_ct_AS
+if test -n "$ac_ct_AS"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_AS" >&5
+$as_echo "$ac_ct_AS" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_AS" = x; then
+ AS="false"
+ 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
+ AS=$ac_ct_AS
+ fi
+else
+ AS="$ac_cv_prog_AS"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; 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_DLLTOOL+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DLLTOOL"; then
+ ac_cv_prog_DLLTOOL="$DLLTOOL" # 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_DLLTOOL="${ac_tool_prefix}dlltool"
+ $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
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+ { $as_echo "$as_me:$LINENO: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+ ac_ct_DLLTOOL=$DLLTOOL
+ # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; 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_DLLTOOL+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DLLTOOL"; then
+ ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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_DLLTOOL="dlltool"
+ $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_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_DLLTOOL" = x; then
+ DLLTOOL="false"
+ 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
+ DLLTOOL=$ac_ct_DLLTOOL
+ fi
+else
+ DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; 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_OBJDUMP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OBJDUMP"; then
+ ac_cv_prog_OBJDUMP="$OBJDUMP" # 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_OBJDUMP="${ac_tool_prefix}objdump"
+ $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
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+ { $as_echo "$as_me:$LINENO: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+ ac_ct_OBJDUMP=$OBJDUMP
+ # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; 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_OBJDUMP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OBJDUMP"; then
+ ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # 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_OBJDUMP="objdump"
+ $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_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OBJDUMP" = x; then
+ OBJDUMP="false"
+ 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
+ OBJDUMP=$ac_ct_OBJDUMP
+ fi
+else
+ OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+ ;;
+esac
+
+test -z "$AS" && AS=as
+
+
+
+
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+
+# Use libtool.
+case `pwd` in
+ *\ * | *\ *)
+ { $as_echo "$as_me:$LINENO: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.2.4'
+macro_revision='1.2976'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+{ $as_echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if test "${ac_cv_path_SED+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+ for ac_i in 1 2 3 4 5 6 7; do
+ ac_script="$ac_script$as_nl$ac_script"
+ done
+ echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+ $as_unset ac_script || ac_script=
+ if test -z "$SED"; then
+ ac_path_SED_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ 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_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+# Check for GNU ac_path_SED and select it if it is found.
+ # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+ ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo '' >> "conftest.nl"
+ "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_SED_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_SED="$ac_path_SED"
+ ac_path_SED_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_SED_found && break 3
+ done
+ done
+done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_SED"; then
+ { { $as_echo "$as_me:$LINENO: error: no acceptable sed could be found in \$PATH" >&5
+$as_echo "$as_me: error: no acceptable sed could be found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+else
+ ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+ rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:$LINENO: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if test "${ac_cv_path_FGREP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+ then ac_cv_path_FGREP="$GREP -F"
+ else
+ if test -z "$FGREP"; then
+ ac_path_FGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in fgrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+ # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'FGREP' >> "conftest.nl"
+ "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_FGREP="$ac_path_FGREP"
+ ac_path_FGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_FGREP_found && break 3
+ done
+ done
+done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_FGREP"; then
+ { { $as_echo "$as_me:$LINENO: error: no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+else
+ ac_cv_path_FGREP=$FGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ { $as_echo "$as_me:$LINENO: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+ 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
+ { $as_echo "$as_me:$LINENO: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+ { $as_echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ { $as_echo "$as_me:$LINENO: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && { { $as_echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+$as_echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+{ $as_echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ # 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
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if test "${lt_cv_path_NM+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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
+ : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$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_DUMPBIN+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DUMPBIN"; then
+ ac_cv_prog_DUMPBIN="$DUMPBIN" # 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_DUMPBIN="$ac_tool_prefix$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
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+ { $as_echo "$as_me:$LINENO: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$DUMPBIN" && break
+ done
+fi
+if test -z "$DUMPBIN"; then
+ ac_ct_DUMPBIN=$DUMPBIN
+ for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+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_ac_ct_DUMPBIN+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DUMPBIN"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # 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_DUMPBIN="$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
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_DUMPBIN" && break
+done
+
+ if test "x$ac_ct_DUMPBIN" = x; then
+ DUMPBIN=":"
+ 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
+ DUMPBIN=$ac_ct_DUMPBIN
+ fi
+fi
+
+
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if test "${lt_cv_nm_interface+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:5566: $ac_compile\"" >&5)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:5569: $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)
+ cat conftest.out >&5
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+{ $as_echo "$as_me:$LINENO: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+ { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ 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
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+ { $as_echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:$LINENO: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+{ $as_echo "$as_me:$LINENO: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:$LINENO: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+{ $as_echo "$as_me:$LINENO: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if test "${lt_cv_ld_reload_flag+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+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
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:$LINENO: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if test "${lt_cv_deplibs_check_method+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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=pass_all
+ ;;
+
+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
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ 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
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+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
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; 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_AR+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # 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_AR="${ac_tool_prefix}ar"
+ $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
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:$LINENO: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; 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_AR+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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_AR="ar"
+ $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_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_AR" = x; then
+ AR="false"
+ 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
+ AR=$ac_ct_AR
+ fi
+else
+ AR="$ac_cv_prog_AR"
+fi
+
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+
+
+
+
+
+
+
+
+
+
+
+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: 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
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; 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_RANLIB+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # 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_RANLIB="${ac_tool_prefix}ranlib"
+ $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
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; 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_RANLIB+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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_RANLIB="ranlib"
+ $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_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_RANLIB" = x; then
+ RANLIB=":"
+ 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
+ RANLIB=$ac_ct_RANLIB
+ fi
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# 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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# 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
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+
+# 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]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[BCDT]'
+ ;;
+cygwin* | mingw* | pw32*)
+ symcode='[ABCDGISTW]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[ABCDEGRST]'
+ 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
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \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\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# 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
+
+# Try without a prefix underscore, 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.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK '"\
+" {last_section=section; section=\$ 3};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_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
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
+ (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && 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 <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_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_prog_compiler_no_builtin_flag"
+ 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}; then
+ pipe_works=yes
+ fi
+ LIBS="$lt_save_LIBS"
+ CFLAGS="$lt_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&5
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ 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
+
+fi
+
+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
+ { $as_echo "$as_me:$LINENO: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+ enableval=$enable_libtool_lock;
+fi
+
+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 { (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
+ 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 6683 "configure"' > 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); }; 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*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > 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); }; 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*)
+ 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*|s390*-*tpf*)
+ 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"
+ { $as_echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if test "${lt_cv_cc_needs_belf+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ 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
+ lt_cv_cc_needs_belf=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ lt_cv_cc_needs_belf=no
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ 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: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+ 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 { (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
+ 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*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+ case $host_os in
+ rhapsody* | darwin*)
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; 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_DSYMUTIL+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DSYMUTIL"; then
+ ac_cv_prog_DSYMUTIL="$DSYMUTIL" # 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_DSYMUTIL="${ac_tool_prefix}dsymutil"
+ $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
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+ { $as_echo "$as_me:$LINENO: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+ ac_ct_DSYMUTIL=$DSYMUTIL
+ # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; 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_DSYMUTIL+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DSYMUTIL"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # 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_DSYMUTIL="dsymutil"
+ $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_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_DSYMUTIL" = x; then
+ DSYMUTIL=":"
+ 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
+ DSYMUTIL=$ac_ct_DSYMUTIL
+ fi
+else
+ DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; 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_NMEDIT+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$NMEDIT"; then
+ ac_cv_prog_NMEDIT="$NMEDIT" # 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_NMEDIT="${ac_tool_prefix}nmedit"
+ $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
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+ { $as_echo "$as_me:$LINENO: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+ ac_ct_NMEDIT=$NMEDIT
+ # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; 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_NMEDIT+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_NMEDIT"; then
+ ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # 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_NMEDIT="nmedit"
+ $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_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_NMEDIT" = x; then
+ NMEDIT=":"
+ 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
+ NMEDIT=$ac_ct_NMEDIT
+ fi
+else
+ NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; 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_LIPO+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$LIPO"; then
+ ac_cv_prog_LIPO="$LIPO" # 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_LIPO="${ac_tool_prefix}lipo"
+ $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
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+ { $as_echo "$as_me:$LINENO: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+ ac_ct_LIPO=$LIPO
+ # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; 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_LIPO+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_LIPO"; then
+ ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # 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_LIPO="lipo"
+ $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_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_LIPO" = x; then
+ LIPO=":"
+ 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
+ LIPO=$ac_ct_LIPO
+ fi
+else
+ LIPO="$ac_cv_prog_LIPO"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; 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_OTOOL+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL"; then
+ ac_cv_prog_OTOOL="$OTOOL" # 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_OTOOL="${ac_tool_prefix}otool"
+ $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
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+ { $as_echo "$as_me:$LINENO: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+ ac_ct_OTOOL=$OTOOL
+ # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; 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_OTOOL+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL"; then
+ ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # 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_OTOOL="otool"
+ $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_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL" = x; then
+ OTOOL=":"
+ 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
+ OTOOL=$ac_ct_OTOOL
+ fi
+else
+ OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; 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_OTOOL64+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL64"; then
+ ac_cv_prog_OTOOL64="$OTOOL64" # 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_OTOOL64="${ac_tool_prefix}otool64"
+ $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
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+ { $as_echo "$as_me:$LINENO: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+ ac_ct_OTOOL64=$OTOOL64
+ # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; 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_OTOOL64+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL64"; then
+ ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # 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_OTOOL64="otool64"
+ $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_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL64" = x; then
+ OTOOL64=":"
+ 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
+ OTOOL64=$ac_ct_OTOOL64
+ fi
+else
+ OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if test "${lt_cv_apple_cc_single_mod+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&5
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+ { $as_echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if test "${lt_cv_ld_exported_symbols_list+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ 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
+ lt_cv_ld_exported_symbols_list=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ lt_cv_ld_exported_symbols_list=no
+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"
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+ case $host_os in
+ rhapsody* | darwin1.[012])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # 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
+
+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 how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+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_cpp conftest.$ac_ext") 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); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+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_cpp conftest.$ac_ext") 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); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+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_cpp conftest.$ac_ext") 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); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+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_cpp conftest.$ac_ext") 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); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+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
+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; }; }
+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
+
+
+{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+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. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+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_header_stdc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 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
+ :
+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_header_stdc=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
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+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
+
+#include <$ac_header>
+_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
+ eval "$as_ac_Header=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+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
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in dlfcn.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+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
+
+#include <$ac_header>
+_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
+ eval "$as_ac_Header=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+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
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+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
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$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_F77+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$F77"; then
+ ac_cv_prog_F77="$F77" # 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_F77="$ac_tool_prefix$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
+F77=$ac_cv_prog_F77
+if test -n "$F77"; then
+ { $as_echo "$as_me:$LINENO: result: $F77" >&5
+$as_echo "$F77" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$F77" && break
+ done
+fi
+if test -z "$F77"; then
+ ac_ct_F77=$F77
+ for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn
+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_ac_ct_F77+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_F77"; then
+ ac_cv_prog_ac_ct_F77="$ac_ct_F77" # 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_F77="$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
+ac_ct_F77=$ac_cv_prog_ac_ct_F77
+if test -n "$ac_ct_F77"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
+$as_echo "$ac_ct_F77" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_F77" && break
+done
+
+ if test "x$ac_ct_F77" = x; then
+ F77=""
+ 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
+ F77=$ac_ct_F77
+ fi
+fi
+
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for Fortran 77 compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+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_compiler --version >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+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_compiler -v >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+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_compiler -V >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file. (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran 77 compiler... " >&6; }
+if test "${ac_cv_f77_compiler_gnu+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+#ifndef __GNUC__
+ choke me
+#endif
+
+ 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_f77_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_compiler_gnu=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_f77_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
+$as_echo "$ac_cv_f77_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FFLAGS+set}
+ac_save_FFLAGS=$FFLAGS
+FFLAGS=
+{ $as_echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
+$as_echo_n "checking whether $F77 accepts -g... " >&6; }
+if test "${ac_cv_prog_f77_g+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ FFLAGS=-g
+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_f77_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_f77_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_prog_f77_g=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
+$as_echo "$ac_cv_prog_f77_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+ FFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_f77_g = yes; then
+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+ FFLAGS="-g -O2"
+ else
+ FFLAGS="-g"
+ fi
+else
+ if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+ FFLAGS="-O2"
+ else
+ FFLAGS=
+ fi
+fi
+
+if test $ac_compiler_gnu = yes; then
+ G77=yes
+else
+ G77=
+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
+
+if test -z "$F77" || test "X$F77" = "Xno"; then
+ _lt_disable_F77=yes
+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
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$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_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="$ac_tool_prefix$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
+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; }
+fi
+
+
+ test -n "$FC" && break
+ done
+fi
+if test -z "$FC"; then
+ ac_ct_FC=$FC
+ for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
+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_ac_ct_FC+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_FC"; then
+ ac_cv_prog_ac_ct_FC="$ac_ct_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_ac_ct_FC="$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
+ac_ct_FC=$ac_cv_prog_ac_ct_FC
+if test -n "$ac_ct_FC"; then
+ { $as_echo "$as_me:$LINENO: result: $ac_ct_FC" >&5
+$as_echo "$ac_ct_FC" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_FC" && break
+done
+
+ if test "x$ac_ct_FC" = x; then
+ FC=""
+ 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
+ FC=$ac_ct_FC
+ fi
+fi
+
+
+# Provide some information about the compiler.
+$as_echo "$as_me:$LINENO: checking for Fortran compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+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_compiler --version >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+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_compiler -v >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+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_compiler -V >&5") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file. (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU Fortran compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran compiler... " >&6; }
+if test "${ac_cv_fc_compiler_gnu+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+#ifndef __GNUC__
+ choke me
+#endif
+
+ 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_compiler_gnu=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_fc_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_fc_compiler_gnu" >&5
+$as_echo "$ac_cv_fc_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FCFLAGS+set}
+ac_save_FFLAGS=$FCFLAGS
+FCFLAGS=
+{ $as_echo "$as_me:$LINENO: checking whether $FC accepts -g" >&5
+$as_echo_n "checking whether $FC accepts -g... " >&6; }
+if test "${ac_cv_prog_fc_g+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ FCFLAGS=-g
+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_prog_fc_g=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_prog_fc_g=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_fc_g" >&5
+$as_echo "$ac_cv_prog_fc_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+ FCFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_fc_g = yes; then
+ if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+ FCFLAGS="-g -O2"
+ else
+ FCFLAGS="-g"
+ fi
+else
+ if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+ FCFLAGS="-O2"
+ else
+ FCFLAGS=
+ fi
+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
+
+if test -z "$FC" || test "X$FC" = "Xno"; then
+ _lt_disable_FC=yes
+fi
+
+
+
+
+
+# Set options
+
+
+
+ enable_dlopen=no
+
+
+
+
+ # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then
+ enableval=$enable_static; 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
+else
+ enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then
+ withval=$with_pic; pic_mode="$withval"
+else
+ pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+ # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then
+ enableval=$enable_fast_install; 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
+else
+ enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if test "${lt_cv_objdir+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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.
+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 delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+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-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ { $as_echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/${ac_tool_prefix}file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+ 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 <<_LT_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
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ { $as_echo "$as_me:$LINENO: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ 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
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/file"
+ 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 <<_LT_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
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ else
+ MAGIC_CMD=:
+ fi
+fi
+
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+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
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$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);}'
+
+
+
+
+
+
+
+# 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 the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$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*
+
+
+## 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...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+ lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+ { $as_echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_rtti_exceptions=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="-fno-rtti -fno-exceptions"
+ # 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:9075: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:9079: \$? = $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_rtti_exceptions=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+ :
+fi
+
+fi
+
+
+
+
+
+
+ lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ $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='-Wl,'
+ lt_prog_compiler_static='-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='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ lt_prog_compiler_pic='-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='-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='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic='-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='-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=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='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ else
+ lt_prog_compiler_static='-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='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl='-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='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ icc* | ecc* | ifort*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fpic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+ xl*)
+ # IBM XL C 8.0/Fortran 10.1 on PPC
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-qpic'
+ lt_prog_compiler_static='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C 5.9
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl='-Wl,'
+ ;;
+ *Sun\ F*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl=''
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ rdos*)
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95*)
+ lt_prog_compiler_wl='-Qoption ld ';;
+ *)
+ lt_prog_compiler_wl='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl='-Qoption ld '
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic='-Kconform_pic'
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ unicos*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_can_build_shared=no
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic='-pic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic=
+ ;;
+ *)
+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
+$as_echo "$lt_prog_compiler_pic" >&6; }
+
+
+
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+ { $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if test "${lt_cv_prog_compiler_pic_works+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_works=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+ # 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:9399: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:9403: \$? = $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=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+ case $lt_prog_compiler_pic in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+ esac
+else
+ lt_prog_compiler_pic=
+ lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $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+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_static_works=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=yes
+ fi
+ else
+ lt_cv_prog_compiler_static_works=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+ :
+else
+ lt_prog_compiler_static=
+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+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=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:9504: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:9508: \$? = $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=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" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&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+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=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:9559: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:9563: \$? = $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=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" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = 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=
+ always_export_symbols=no
+ archive_cmds=
+ archive_expsym_cmds=
+ compiler_needs_object=no
+ enable_shared_with_static_runtimes=no
+ export_dynamic_flag_spec=
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ hardcode_automatic=no
+ hardcode_direct=no
+ hardcode_direct_absolute=no
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_flag_spec_ld=
+ hardcode_libdir_separator=
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=unsupported
+ inherit_rpath=no
+ link_all_deplibs=unknown
+ module_cmds=
+ module_expsym_cmds=
+ old_archive_from_new_cmds=
+ old_archive_from_expsyms_cmds=
+ thread_safe_flag_spec=
+ whole_archive_flag_spec=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms=
+ # 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='_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=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='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec='${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="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec=
+ 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=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='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$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='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag=unsupported
+ # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ allow_undefined_flag=unsupported
+ always_export_symbols=no
+ enable_shared_with_static_runtimes=yes
+ export_symbols_cmds='$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='$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='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=no
+ fi
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${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='$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='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='${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='${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='${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=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ archive_cmds='$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='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='--whole-archive$convenience --no-whole-archive'
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_flag_spec_ld='-rpath $libdir'
+ archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='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=no
+ fi
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$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=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='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=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='${wl}-rpath ${wl}$libdir'
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs" = no; then
+ runpath_var=
+ hardcode_libdir_flag_spec=
+ export_dynamic_flag_spec=
+ whole_archive_flag_spec=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ archive_expsym_cmds='$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=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=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='$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='$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=''
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ file_list_spec='${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=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=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ 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=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='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ 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
+
+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
+
+
+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='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds='$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='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag="-z nodefs"
+ archive_expsym_cmds="\$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
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ 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
+
+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
+
+
+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='${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=' ${wl}-bernotok'
+ allow_undefined_flag=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec='$convenience'
+ archive_cmds_need_lc=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ archive_expsym_cmds="\$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='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$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='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[45]*)
+ export_dynamic_flag_spec=-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=' '
+ allow_undefined_flag=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='$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='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path='`cygpath -w "$srcfile"`'
+ enable_shared_with_static_runtimes=yes
+ ;;
+
+ darwin* | rhapsody*)
+
+
+ archive_cmds_need_lc=no
+ hardcode_direct=no
+ hardcode_automatic=yes
+ hardcode_shlibpath_var=unsupported
+ whole_archive_flag_spec=''
+ link_all_deplibs=yes
+ allow_undefined_flag="$_lt_dar_allow_undefined"
+ if test "$GCC" = "yes"; then
+ output_verbose_link_cmd=echo
+ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ archive_expsym_cmds="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="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=no
+ fi
+
+ ;;
+
+ dgux*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ freebsd1*)
+ ld_shlibs=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='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds='$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='$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='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$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='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld='+b $libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$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='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$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='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ ;;
+ *)
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds='$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_c_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='$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='$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='$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='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ inherit_rpath=yes
+ link_all_deplibs=yes
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ newsos6)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_shlibpath_var=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ hardcode_direct_absolute=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ allow_undefined_flag=unsupported
+ archive_cmds='$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='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$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=' -expect_unresolved \*'
+ archive_cmds='$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='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$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='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$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='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='-rpath $libdir'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_separator=:
+ ;;
+
+ solaris*)
+ no_undefined_flag=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='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='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds='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='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='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='-R$libdir'
+ hardcode_shlibpath_var=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='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ link_all_deplibs=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='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds='$CC -r -o $output$reload_objs'
+ hardcode_direct=no
+ ;;
+ motorola)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag='${wl}-z,text'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$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='${wl}-z,text'
+ allow_undefined_flag='${wl}-z,nodefs'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-R,$libdir'
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ export_dynamic_flag_spec='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+
+{ $as_echo "$as_me:$LINENO: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds 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
+
+ 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
+ pic_flag=$lt_prog_compiler_pic
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag
+ allow_undefined_flag=
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ (eval $archive_cmds 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=no
+ else
+ archive_cmds_need_lc=yes
+ fi
+ allow_undefined_flag=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
+$as_echo "$archive_cmds_need_lc" >&6; }
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+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
+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_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
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ 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
+ 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
+
+
+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
+
+ # 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
+
+ # 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=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
+ ;;
+
+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
+ 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
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $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=
+if test -n "$hardcode_libdir_flag_spec" ||
+ test -n "$runpath_var" ||
+ test "X$hardcode_automatic" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct" != 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, )" != no &&
+ test "$hardcode_minus_L" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:$LINENO: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+ test "$inherit_rpath" = 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
+
+
+
+
+
+
+ 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
+ { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+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 dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ 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_dl_dlopen=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_dl_dlopen=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_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ { $as_echo "$as_me:$LINENO: checking for shl_load" >&5
+$as_echo_n "checking for shl_load... " >&6; }
+if test "${ac_cv_func_shl_load+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. */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define shl_load innocuous_shl_load
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char shl_load (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef shl_load
+
+/* 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 shl_load ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_shl_load || defined __stub___shl_load
+choke me
+#endif
+
+int
+main ()
+{
+return shl_load ();
+ ;
+ 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_func_shl_load=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_func_shl_load=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
+{ $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
+ lt_cv_dlopen="shl_load"
+else
+ { $as_echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+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 shl_load ();
+int
+main ()
+{
+return shl_load ();
+ ;
+ 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_shl_load=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_dld_shl_load=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_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test $ac_cv_lib_dld_shl_load = yes; then
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+ { $as_echo "$as_me:$LINENO: checking for dlopen" >&5
+$as_echo_n "checking for dlopen... " >&6; }
+if test "${ac_cv_func_dlopen+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. */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define dlopen innocuous_dlopen
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char dlopen (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef dlopen
+
+/* 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 dlopen ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_dlopen || defined __stub___dlopen
+choke me
+#endif
+
+int
+main ()
+{
+return dlopen ();
+ ;
+ 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_func_dlopen=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_func_dlopen=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
+{ $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
+ lt_cv_dlopen="dlopen"
+else
+ { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+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 dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ 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_dl_dlopen=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_dl_dlopen=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_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ { $as_echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+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 dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ 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_svld_dlopen=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_svld_dlopen=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_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test $ac_cv_lib_svld_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ { $as_echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+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 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
+_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
+
+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
+
+
+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_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
+ 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"`
+fi
+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
+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
+ ;;
+
+ 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'
+
+ # 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
+
+ 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
+
+ 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
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $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
+ ;;
+
+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
+ # 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
+
+ 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
+
+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
+ 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
+
+ # 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=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
+ ;;
+
+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
+ 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
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $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
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+ ;;
+
+ 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
+ ;;
+
+ 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_FC='-DDLL_EXPORT'
+ ;;
+
+ 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
+ ;;
+
+ 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_FC=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_FC='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_FC=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ 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
+ 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'
+ ;;
+
+ 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'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static_FC='-non_shared'
+ ;;
+
+ 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
+ ;;
+
+ 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'
+ ;;
+
+ 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'
+ ;;
+
+ unicos*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_can_build_shared_FC=no
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic_FC='-pic'
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared_FC=no
+ ;;
+ esac
+ fi
+
+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: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*
+
+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: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'
+
+ 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
+
+ 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
+
+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
+
+
+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"
+ 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
+
+ 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
+
+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
+
+
+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
+ 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
+ ;;
+
+ 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'
+ 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
+ ;;
+
+ 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
+ ;;
+
+ 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
+ ;;
+
+ *)
+ ld_shlibs_FC=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ export_dynamic_flag_spec_FC='${wl}-Blargedynsym'
+ ;;
+ 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
+
+with_gnu_ld_FC=$with_gnu_ld
+
+
+
+
+
+
+#
+# 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.
+ ;;
+ '$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
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $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
+ ;;
+
+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
+ # 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
+
+ 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 ($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
+
+
+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
+
+ # 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
+
+ # 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=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
+ ;;
+
+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
+ 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
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $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
+
+
+
+
+
+
+
+ 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
+
+
+
+
+
+
+
+
+
+ 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;}
+
+# 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 ()
+{
+
+ ;
+ 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
+
+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
+
+
+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 ()
+{
+
+ ;
+ 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
+
+
+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
+
+
+fi
+
+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
+ 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 ()
+{
+
+ ;
+ 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
+
+
+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 _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 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=1; 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
+ 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
+
+
+{ $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
+
+{ $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
+
+
+
+{ $as_echo "$as_me:$LINENO: checking types, headers, and functions" >&5
+$as_echo "$as_me: checking types, headers, and functions" >&6;}
+
+
+
+ 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
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+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; }
+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`
+
+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 "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`
+
+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 "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
+
+ 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
+
+ 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`
+
+cat >>confdefs.h <<_ACEOF
+#define NF_DOUBLEPRECISION_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*
+
+
+
+ { $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
+ ac_status=$?
+ $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 NCBYTE_T $type
+_ACEOF
+
+ { $as_echo "$as_me:$LINENO: result: $type" >&5
+$as_echo "$type" >&6; }
+ NCBYTE_T=$type
+
+
+
+ { $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
+ ac_status=$?
+ $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
+
+ { $as_echo "$as_me:$LINENO: result: $type" >&5
+$as_echo "$type" >&6; }
+ NCSHORT_T=$type
+
+
+
+
+ ;;
+ esac
+
+
+ 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
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lc $LIBS"
+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 ();
+int
+main ()
+{
+return tanh ();
+ ;
+ 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_c_tanh=yes
+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
+/* 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 ();
+int
+main ()
+{
+return tanh ();
+ ;
+ 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_m_tanh=yes
+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
+
+fi
+
+ ;;
+ *)
+ ;;
+ esac
+
+
+if test "${ac_cv_header_stdlib_h+set}" = set; then
+ { $as_echo "$as_me:$LINENO: checking for stdlib.h" >&5
+$as_echo_n "checking for stdlib.h... " >&6; }
+if test "${ac_cv_header_stdlib_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdlib_h" >&5
+$as_echo "$ac_cv_header_stdlib_h" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking stdlib.h usability" >&5
+$as_echo_n "checking stdlib.h usability... " >&6; }
+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 <stdlib.h>
+_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_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking stdlib.h presence" >&5
+$as_echo_n "checking stdlib.h presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+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_cpp conftest.$ac_ext") 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); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: stdlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: stdlib.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: stdlib.h: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: stdlib.h: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: stdlib.h: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: stdlib.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: stdlib.h: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: stdlib.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: stdlib.h: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## --------------------------------------- ##
+## Report this to support at unidata.ucar.edu ##
+## --------------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for stdlib.h" >&5
+$as_echo_n "checking for stdlib.h... " >&6; }
+if test "${ac_cv_header_stdlib_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_header_stdlib_h=$ac_header_preproc
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdlib_h" >&5
+$as_echo "$ac_cv_header_stdlib_h" >&6; }
+
+fi
+if test $ac_cv_header_stdlib_h = yes; then
+ :
+else
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_STDLIB_H /**/
+_ACEOF
+
+fi
+
+
+if test "${ac_cv_header_sys_types_h+set}" = set; then
+ { $as_echo "$as_me:$LINENO: checking for sys/types.h" >&5
+$as_echo_n "checking for sys/types.h... " >&6; }
+if test "${ac_cv_header_sys_types_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_types_h" >&5
+$as_echo "$ac_cv_header_sys_types_h" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking sys/types.h usability" >&5
+$as_echo_n "checking sys/types.h usability... " >&6; }
+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>
+_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_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking sys/types.h presence" >&5
+$as_echo_n "checking sys/types.h presence... " >&6; }
+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>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+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_cpp conftest.$ac_ext") 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); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: sys/types.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: sys/types.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: sys/types.h: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: sys/types.h: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: sys/types.h: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: sys/types.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: sys/types.h: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: sys/types.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: sys/types.h: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## --------------------------------------- ##
+## Report this to support at unidata.ucar.edu ##
+## --------------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for sys/types.h" >&5
+$as_echo_n "checking for sys/types.h... " >&6; }
+if test "${ac_cv_header_sys_types_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_header_sys_types_h=$ac_header_preproc
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_types_h" >&5
+$as_echo "$ac_cv_header_sys_types_h" >&6; }
+
+fi
+if test $ac_cv_header_sys_types_h = yes; then
+ :
+else
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_SYS_TYPES_H /**/
+_ACEOF
+
+fi
+
+
+if test "${ac_cv_header_unistd_h+set}" = set; then
+ { $as_echo "$as_me:$LINENO: checking for unistd.h" >&5
+$as_echo_n "checking for unistd.h... " >&6; }
+if test "${ac_cv_header_unistd_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_unistd_h" >&5
+$as_echo "$ac_cv_header_unistd_h" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking unistd.h usability" >&5
+$as_echo_n "checking unistd.h usability... " >&6; }
+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 <unistd.h>
+_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_header_compiler=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking unistd.h presence" >&5
+$as_echo_n "checking unistd.h presence... " >&6; }
+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>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+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_cpp conftest.$ac_ext") 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); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: unistd.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: unistd.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: unistd.h: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: unistd.h: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: unistd.h: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: unistd.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: unistd.h: proceeding with the preprocessor's result" >&2;}
+ { $as_echo "$as_me:$LINENO: WARNING: unistd.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: unistd.h: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## --------------------------------------- ##
+## Report this to support at unidata.ucar.edu ##
+## --------------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for unistd.h" >&5
+$as_echo_n "checking for unistd.h... " >&6; }
+if test "${ac_cv_header_unistd_h+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_header_unistd_h=$ac_header_preproc
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_unistd_h" >&5
+$as_echo "$ac_cv_header_unistd_h" >&6; }
+
+fi
+
+
+{ $as_echo "$as_me:$LINENO: checking for strerror" >&5
+$as_echo_n "checking for strerror... " >&6; }
+if test "${ac_cv_func_strerror+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. */
+/* Define strerror to an innocuous variant, in case <limits.h> declares strerror.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define strerror innocuous_strerror
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char strerror (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef strerror
+
+/* 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 strerror ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_strerror || defined __stub___strerror
+choke me
+#endif
+
+int
+main ()
+{
+return strerror ();
+ ;
+ 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_func_strerror=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_func_strerror=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
+{ $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
+ :
+else
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_STRERROR /**/
+_ACEOF
+
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for strlcat" >&5
+$as_echo_n "checking for strlcat... " >&6; }
+if test "${ac_cv_func_strlcat+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. */
+/* Define strlcat to an innocuous variant, in case <limits.h> declares strlcat.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define strlcat innocuous_strlcat
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char strlcat (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef strlcat
+
+/* 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 strlcat ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_strlcat || defined __stub___strlcat
+choke me
+#endif
+
+int
+main ()
+{
+return strlcat ();
+ ;
+ 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_func_strlcat=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_func_strlcat=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
+{ $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
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_STRLCAT 1
+_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
+$as_echo_n "checking for working alloca.h... " >&6; }
+if test "${ac_cv_working_alloca_h+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. */
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+ if (p) return 0;
+ ;
+ 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_working_alloca_h=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_working_alloca_h=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
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5
+$as_echo "$ac_cv_working_alloca_h" >&6; }
+if test $ac_cv_working_alloca_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ALLOCA_H 1
+_ACEOF
+
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for alloca" >&5
+$as_echo_n "checking for alloca... " >&6; }
+if test "${ac_cv_func_alloca_works+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. */
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# else
+# ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+# endif
+#endif
+
+int
+main ()
+{
+char *p = (char *) alloca (1);
+ if (p) return 0;
+ ;
+ 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_func_alloca_works=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_func_alloca_works=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
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5
+$as_echo "$ac_cv_func_alloca_works" >&6; }
+
+if test $ac_cv_func_alloca_works = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ALLOCA 1
+_ACEOF
+
+else
+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+# that cause trouble. Some versions do not even contain alloca or
+# contain a buggy version. If you still want to use their alloca,
+# use ar to extract alloca.o from them instead of compiling alloca.c.
+
+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
+
+cat >>confdefs.h <<\_ACEOF
+#define C_ALLOCA 1
+_ACEOF
+
+
+{ $as_echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5
+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
+if test "${ac_cv_os_cray+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. */
+#if defined CRAY && ! defined CRAY2
+webecray
+#else
+wenotbecray
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "webecray" >/dev/null 2>&1; then
+ ac_cv_os_cray=yes
+else
+ ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5
+$as_echo "$ac_cv_os_cray" >&6; }
+if test $ac_cv_os_cray = yes; then
+ for ac_func in _getb67 GETB67 getb67; do
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+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. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* 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 $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ 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
+ eval "$as_ac_var=yes"
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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; }
+if test `eval 'as_val=${'$as_ac_var'}
+ $as_echo "$as_val"'` = 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 -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+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
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ST_BLKSIZE 1
+_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
+ :
+else
+ 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
+
+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
+}
+_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_ieeefloat=yes
+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_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
+
+
+{ $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
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_IEEE_FLOAT /**/
+_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_n "(cached) " >&6
+else
+ ac_cv_type_size_t=no
+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_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
+ 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_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
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+
+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
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned 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_n "(cached) " >&6
+else
+ ac_cv_type_off_t=no
+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 (off_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_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
+ 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 ((off_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_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
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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_type_off_t" >&5
+$as_echo "$ac_cv_type_off_t" >&6; }
+if test $ac_cv_type_off_t = yes; then
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define off_t long int
+_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_n "(cached) " >&6
+else
+ 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. */
+$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_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
+ 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_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
+ :
+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: 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_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
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof (ptrdiff_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_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
+ 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 ((ptrdiff_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_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
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_ptrdiff_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_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
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof (uchar))
+ 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
+ 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 ((uchar)))
+ 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
+ :
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_uchar=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_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
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((char) -1) < 0)];
+test_array [0] = 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_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 __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined.
+ 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;
+
+_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_c_bigendian=universal
+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
+ 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. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
+ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
+ && LITTLE_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ 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
+ # 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. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ 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_c_bigendian=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_c_bigendian=no
+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
+ 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. */
+#include <limits.h>
+
+int
+main ()
+{
+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ 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
+ # 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. */
+#include <limits.h>
+
+int
+main ()
+{
+#ifndef _BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ 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_c_bigendian=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_c_bigendian=no
+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
+ 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. */
+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 ()
+{
+return use_ascii (foo) == use_ebcdic (foo);
+ ;
+ 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
+ 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
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+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 ()
+{
+
+ /* 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_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_bigendian=no
+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
+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)
+ ;; #(
+ *)
+ { { $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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 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_hi=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+
+ 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 int test_array [1 - 2 * !(((long int) (sizeof (short))) < 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) >= $ac_mid)];
+test_array [0] = 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_lo=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+# 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 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_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: 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. */
+_ACEOF
+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 ()
+{
+
+ 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;
+}
+_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_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 )
+if test "$ac_cv_type_short" = yes; then
+ { { $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; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+_ACEOF
+
+
+# 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 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
+ # 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 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_hi=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+
+ 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 int test_array [1 - 2 * !(((long int) (sizeof (int))) < 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) >= $ac_mid)];
+test_array [0] = 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_lo=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+# 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 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_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_int=$ac_lo;;
+'') if test "$ac_cv_type_int" = yes; then
+ { { $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 (int)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_int=0
+ fi ;;
+esac
+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
+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
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (((long int) (sizeof (int))) < 0)
+ {
+ long int i = longval ();
+ if (i != ((long int) (sizeof (int))))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ((long int) (sizeof (int))))
+ 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;
+}
+_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_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_int" = yes; then
+ { { $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 (int)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_int=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_int" >&5
+$as_echo "$ac_cv_sizeof_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+# 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 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
+ # 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 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_hi=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+
+ 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 int test_array [1 - 2 * !(((long int) (sizeof (long))) < 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) >= $ac_mid)];
+test_array [0] = 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_lo=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+# 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 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_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_long=$ac_lo;;
+'') if test "$ac_cv_type_long" = yes; then
+ { { $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 (long)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_long=0
+ fi ;;
+esac
+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
+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
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (((long int) (sizeof (long))) < 0)
+ {
+ long int i = longval ();
+ if (i != ((long int) (sizeof (long))))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ((long int) (sizeof (long))))
+ 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;
+}
+_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_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_long" = yes; then
+ { { $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 (long)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_long=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_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+# 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 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
+ # 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)];
+test_array [0] = 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_hi=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+
+ 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 int test_array [1 - 2 * !(((long int) (sizeof (float))) < 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) >= $ac_mid)];
+test_array [0] = 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_lo=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+# 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (float))) <= $ac_mid)];
+test_array [0] = 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_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_float=$ac_lo;;
+'') if test "$ac_cv_type_float" = yes; then
+ { { $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 (float)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_float=0
+ fi ;;
+esac
+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
+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
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (((long int) (sizeof (float))) < 0)
+ {
+ long int i = longval ();
+ if (i != ((long int) (sizeof (float))))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ((long int) (sizeof (float))))
+ 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;
+}
+_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_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_float" = yes; then
+ { { $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 (float)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_float=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_float" >&5
+$as_echo "$ac_cv_sizeof_float" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_FLOAT $ac_cv_sizeof_float
+_ACEOF
+
+
+# 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 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
+ # 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)];
+test_array [0] = 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_hi=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+
+ 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 int test_array [1 - 2 * !(((long int) (sizeof (double))) < 0)];
+test_array [0] = 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_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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) >= $ac_mid)];
+test_array [0] = 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_lo=$ac_mid; break
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ 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
+# 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. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (double))) <= $ac_mid)];
+test_array [0] = 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_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_double=$ac_lo;;
+'') if test "$ac_cv_type_double" = yes; then
+ { { $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 (double)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_double=0
+ fi ;;
+esac
+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
+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
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (((long int) (sizeof (double))) < 0)
+ {
+ long int i = longval ();
+ if (i != ((long int) (sizeof (double))))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ((long int) (sizeof (double))))
+ 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;
+}
+_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_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_double" = yes; then
+ { { $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 (double)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_double=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_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
+_ACEOF
+
+
+
+ #
+ # 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: 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; }
+
+
+# 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
+
+{ $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 [...]
+
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ 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;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ test "x$cache_file" != "x/dev/null" &&
+ { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ cat confcache >$cache_file
+ else
+ { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+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
+$as_echo "$as_me: error: conditional \"BUILD_DOCS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${BUILD_GRIDSPEC_TRUE}" && test -z "${BUILD_GRIDSPEC_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"BUILD_GRIDSPEC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$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_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
+$as_echo "$as_me: error: conditional \"BUILD_CFCHECK\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${USE_NETCDF4_TRUE}" && test -z "${USE_NETCDF4_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"USE_NETCDF4\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"USE_NETCDF4\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${EXTRA_DATA_TESTS_TRUE}" && test -z "${EXTRA_DATA_TESTS_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"EXTRA_DATA_TESTS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"EXTRA_DATA_TESTS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${USE_HDF5_DIR_TRUE}" && test -z "${USE_HDF5_DIR_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"USE_HDF5_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$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 "${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
+$as_echo "$as_me: error: conditional \"BUILD_F90\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${USE_NETCDF_DIR_TRUE}" && test -z "${USE_NETCDF_DIR_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"USE_NETCDF_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"USE_NETCDF_DIR\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+ { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+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
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -p'
+ fi
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# 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
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [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
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+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,
+ with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ { $as_echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { $as_echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# 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
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
+AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`'
+DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`'
+macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
+enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
+host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
+host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
+host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
+build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
+build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
+build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
+SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
+Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
+GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
+EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
+FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
+LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
+NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
+LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
+exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
+AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
+GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
+SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
+ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
+need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`'
+LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`'
+libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
+version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
+striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`'
+LD_F77='`$ECHO "X$LD_F77" | $Xsed -e "$delay_single_quote_subst"`'
+LD_FC='`$ECHO "X$LD_FC" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds_F77='`$ECHO "X$old_archive_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds_FC='`$ECHO "X$old_archive_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_F77='`$ECHO "X$compiler_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_FC='`$ECHO "X$compiler_FC" | $Xsed -e "$delay_single_quote_subst"`'
+GCC_F77='`$ECHO "X$GCC_F77" | $Xsed -e "$delay_single_quote_subst"`'
+GCC_FC='`$ECHO "X$GCC_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_F77='`$ECHO "X$lt_prog_compiler_no_builtin_flag_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_FC='`$ECHO "X$lt_prog_compiler_no_builtin_flag_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_F77='`$ECHO "X$lt_prog_compiler_wl_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_FC='`$ECHO "X$lt_prog_compiler_wl_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_F77='`$ECHO "X$lt_prog_compiler_pic_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_FC='`$ECHO "X$lt_prog_compiler_pic_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static_F77='`$ECHO "X$lt_prog_compiler_static_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static_FC='`$ECHO "X$lt_prog_compiler_static_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_F77='`$ECHO "X$lt_cv_prog_compiler_c_o_F77" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_FC='`$ECHO "X$lt_cv_prog_compiler_c_o_FC" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc_F77='`$ECHO "X$archive_cmds_need_lc_F77" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc_FC='`$ECHO "X$archive_cmds_need_lc_FC" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_F77='`$ECHO "X$enable_shared_with_static_runtimes_F77" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_FC='`$ECHO "X$enable_shared_with_static_runtimes_FC" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_F77='`$ECHO "X$export_dynamic_flag_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_FC='`$ECHO "X$export_dynamic_flag_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec_F77='`$ECHO "X$whole_archive_flag_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec_FC='`$ECHO "X$whole_archive_flag_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object_F77='`$ECHO "X$compiler_needs_object_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object_FC='`$ECHO "X$compiler_needs_object_FC" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_F77='`$ECHO "X$old_archive_from_new_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_FC='`$ECHO "X$old_archive_from_new_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_F77='`$ECHO "X$old_archive_from_expsyms_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_FC='`$ECHO "X$old_archive_from_expsyms_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_F77='`$ECHO "X$archive_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_FC='`$ECHO "X$archive_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds_F77='`$ECHO "X$archive_expsym_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds_FC='`$ECHO "X$archive_expsym_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds_F77='`$ECHO "X$module_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds_FC='`$ECHO "X$module_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds_F77='`$ECHO "X$module_expsym_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds_FC='`$ECHO "X$module_expsym_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld_F77='`$ECHO "X$with_gnu_ld_F77" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld_FC='`$ECHO "X$with_gnu_ld_FC" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag_F77='`$ECHO "X$allow_undefined_flag_F77" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag_FC='`$ECHO "X$allow_undefined_flag_FC" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag_F77='`$ECHO "X$no_undefined_flag_F77" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag_FC='`$ECHO "X$no_undefined_flag_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_F77='`$ECHO "X$hardcode_libdir_flag_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_FC='`$ECHO "X$hardcode_libdir_flag_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld_F77='`$ECHO "X$hardcode_libdir_flag_spec_ld_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld_FC='`$ECHO "X$hardcode_libdir_flag_spec_ld_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator_F77='`$ECHO "X$hardcode_libdir_separator_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator_FC='`$ECHO "X$hardcode_libdir_separator_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_F77='`$ECHO "X$hardcode_direct_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_FC='`$ECHO "X$hardcode_direct_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute_F77='`$ECHO "X$hardcode_direct_absolute_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute_FC='`$ECHO "X$hardcode_direct_absolute_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L_F77='`$ECHO "X$hardcode_minus_L_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L_FC='`$ECHO "X$hardcode_minus_L_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_F77='`$ECHO "X$hardcode_shlibpath_var_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_FC='`$ECHO "X$hardcode_shlibpath_var_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic_F77='`$ECHO "X$hardcode_automatic_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic_FC='`$ECHO "X$hardcode_automatic_FC" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath_F77='`$ECHO "X$inherit_rpath_F77" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath_FC='`$ECHO "X$inherit_rpath_FC" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs_F77='`$ECHO "X$link_all_deplibs_F77" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs_FC='`$ECHO "X$link_all_deplibs_FC" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path_F77='`$ECHO "X$fix_srcfile_path_F77" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path_FC='`$ECHO "X$fix_srcfile_path_FC" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols_F77='`$ECHO "X$always_export_symbols_F77" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols_FC='`$ECHO "X$always_export_symbols_FC" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds_F77='`$ECHO "X$export_symbols_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds_FC='`$ECHO "X$export_symbols_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms_F77='`$ECHO "X$exclude_expsyms_F77" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms_FC='`$ECHO "X$exclude_expsyms_FC" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms_F77='`$ECHO "X$include_expsyms_F77" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms_FC='`$ECHO "X$include_expsyms_FC" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds_F77='`$ECHO "X$prelink_cmds_F77" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds_FC='`$ECHO "X$prelink_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec_F77='`$ECHO "X$file_list_spec_F77" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec_FC='`$ECHO "X$file_list_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action_F77='`$ECHO "X$hardcode_action_F77" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action_FC='`$ECHO "X$hardcode_action_FC" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_F77='`$ECHO "X$compiler_lib_search_dirs_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_FC='`$ECHO "X$compiler_lib_search_dirs_FC" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects_F77='`$ECHO "X$predep_objects_F77" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects_FC='`$ECHO "X$predep_objects_FC" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects_F77='`$ECHO "X$postdep_objects_F77" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects_FC='`$ECHO "X$postdep_objects_FC" | $Xsed -e "$delay_single_quote_subst"`'
+predeps_F77='`$ECHO "X$predeps_F77" | $Xsed -e "$delay_single_quote_subst"`'
+predeps_FC='`$ECHO "X$predeps_FC" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps_F77='`$ECHO "X$postdeps_F77" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps_FC='`$ECHO "X$postdeps_FC" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path_F77='`$ECHO "X$compiler_lib_search_path_F77" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path_FC='`$ECHO "X$compiler_lib_search_path_FC" | $Xsed -e "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+deplibs_check_method \
+file_magic_cmd \
+AR \
+AR_FLAGS \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+SHELL \
+ECHO \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_wl \
+lt_prog_compiler_pic \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_flag_spec_ld \
+hardcode_libdir_separator \
+fix_srcfile_path \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_F77 \
+LD_FC \
+compiler_F77 \
+compiler_FC \
+lt_prog_compiler_no_builtin_flag_F77 \
+lt_prog_compiler_no_builtin_flag_FC \
+lt_prog_compiler_wl_F77 \
+lt_prog_compiler_wl_FC \
+lt_prog_compiler_pic_F77 \
+lt_prog_compiler_pic_FC \
+lt_prog_compiler_static_F77 \
+lt_prog_compiler_static_FC \
+lt_cv_prog_compiler_c_o_F77 \
+lt_cv_prog_compiler_c_o_FC \
+export_dynamic_flag_spec_F77 \
+export_dynamic_flag_spec_FC \
+whole_archive_flag_spec_F77 \
+whole_archive_flag_spec_FC \
+compiler_needs_object_F77 \
+compiler_needs_object_FC \
+with_gnu_ld_F77 \
+with_gnu_ld_FC \
+allow_undefined_flag_F77 \
+allow_undefined_flag_FC \
+no_undefined_flag_F77 \
+no_undefined_flag_FC \
+hardcode_libdir_flag_spec_F77 \
+hardcode_libdir_flag_spec_FC \
+hardcode_libdir_flag_spec_ld_F77 \
+hardcode_libdir_flag_spec_ld_FC \
+hardcode_libdir_separator_F77 \
+hardcode_libdir_separator_FC \
+fix_srcfile_path_F77 \
+fix_srcfile_path_FC \
+exclude_expsyms_F77 \
+exclude_expsyms_FC \
+include_expsyms_F77 \
+include_expsyms_FC \
+file_list_spec_F77 \
+file_list_spec_FC \
+compiler_lib_search_dirs_F77 \
+compiler_lib_search_dirs_FC \
+predep_objects_F77 \
+predep_objects_FC \
+postdep_objects_F77 \
+postdep_objects_FC \
+predeps_F77 \
+predeps_FC \
+postdeps_F77 \
+postdeps_FC \
+compiler_lib_search_path_F77 \
+compiler_lib_search_path_FC; do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+old_archive_cmds_F77 \
+old_archive_cmds_FC \
+old_archive_from_new_cmds_F77 \
+old_archive_from_new_cmds_FC \
+old_archive_from_expsyms_cmds_F77 \
+old_archive_from_expsyms_cmds_FC \
+archive_cmds_F77 \
+archive_cmds_FC \
+archive_expsym_cmds_F77 \
+archive_expsym_cmds_FC \
+module_cmds_F77 \
+module_cmds_FC \
+module_expsym_cmds_F77 \
+module_expsym_cmds_FC \
+export_symbols_cmds_F77 \
+export_symbols_cmds_FC \
+prelink_cmds_F77 \
+prelink_cmds_FC; do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
+ ;;
+esac
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'
+
+
+
+
+
+
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+ "nfconfig.inc") CONFIG_HEADERS="$CONFIG_HEADERS nfconfig.inc:nfconfig.in" ;;
+ "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+ "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" ;;
+
+ *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp=
+ trap 'exit_status=$?
+ { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} ||
+{
+ $as_echo "$as_me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr='
'
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$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
+ break
+ elif $ac_last_try; then
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\).*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\).*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+ || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
+$as_echo "$as_me: error: could not setup config files machinery" >&2;}
+ { (exit 1); exit 1; }; }
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[ ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+ ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_t"; then
+ break
+ elif $ac_last_try; then
+ { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
+ { (exit 1); exit 1; }; }
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any. Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[ ]*#[ ]*define[ ][ ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ for (key in D) D_is_set[key] = 1
+ FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+ line = \$ 0
+ split(line, arg, " ")
+ if (arg[1] == "#") {
+ defundef = arg[2]
+ mac1 = arg[3]
+ } else {
+ defundef = substr(arg[1], 2)
+ mac1 = arg[2]
+ }
+ split(mac1, mac2, "(") #)
+ macro = mac2[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 {
+ # Replace #undef with comments. This is necessary, for example,
+ # 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, "*/"
+ next
+ }
+ }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
+$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
+ { (exit 1); exit 1; }; }
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ 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;}
+ { (exit 1); exit 1; }; };;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ ac_file_inputs="$ac_file_inputs '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:$LINENO: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$tmp/stdin" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ { as_dir="$ac_dir"
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || 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; }; }; }
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+ esac
+ ac_MKDIR_P=$MKDIR_P
+ case $MKDIR_P in
+ [\\/$]* | ?:[\\/]* ) ;;
+ */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+ esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&2;}
+
+ rm -f "$tmp/stdin"
+ case $ac_file in
+ -) cat "$tmp/out" && rm -f "$tmp/out";;
+ *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+ esac \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+ ;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+ if test x"$ac_file" != x-; then
+ {
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+ } >"$tmp/config.h" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+ if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+ { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f "$ac_file"
+ mv "$tmp/config.h" "$ac_file" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ else
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+ || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
+$as_echo "$as_me: error: could not create -" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$_am_arg" : 'X\(//\)[^/]' \| \
+ X"$_am_arg" : 'X\(//\)$' \| \
+ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+ :C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+ esac
+
+
+ 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" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$mf" : 'X\(//\)[^/]' \| \
+ X"$mf" : 'X\(//\)$' \| \
+ X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ 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" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$file" : 'X\(//\)[^/]' \| \
+ X"$file" : 'X\(//\)$' \| \
+ X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ { as_dir=$dirpart/$fdir
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || 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"
+ done
+done
+ ;;
+ "libtool":C)
+
+ # 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
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool 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.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="F77 FC "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Assembler program.
+AS=$AS
+
+# DLL creation program.
+DLLTOOL=$DLLTOOL
+
+# Object dumper program.
+OBJDUMP=$OBJDUMP
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# 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
+
+# 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//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# 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
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# 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
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that does not interpret backslashes.
+ECHO=$lt_ECHO
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# 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
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# 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
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# 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
+
+# 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
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# 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_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# 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=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# 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=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_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
+_LT_EOF
+ ;;
+ esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+ # 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 '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ case $xsi_shell in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+ func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=${1%%=*}
+ func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=$(( $* ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=${#1}
+}
+
+_LT_EOF
+ ;;
+ *) # Bourne compatible functions.
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+ esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[^=]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=`expr "$@"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$1+=\$2"
+}
+_LT_EOF
+ ;;
+ *)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$1=\$$1\$2"
+}
+
+_LT_EOF
+ ;;
+ esac
+
+
+ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+
+
+ cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: F77
+
+# The linker used to build libraries.
+LD=$lt_LD_F77
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_F77
+
+# A language specific compiler.
+CC=$lt_compiler_F77
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_F77
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_F77
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_F77
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_F77
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_F77
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_F77
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_F77
+archive_expsym_cmds=$lt_archive_expsym_cmds_F77
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_F77
+module_expsym_cmds=$lt_module_expsym_cmds_F77
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_F77
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_F77
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_F77
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
+
+# 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_hardcode_libdir_flag_spec_ld_F77
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_F77
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_F77
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_F77
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
+
+# 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=$hardcode_automatic_F77
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_F77
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_F77
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path_F77
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_F77
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_F77
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_F77
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_F77
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_F77
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_F77
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_F77
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_F77
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_F77
+postdep_objects=$lt_postdep_objects_F77
+predeps=$lt_predeps_F77
+postdeps=$lt_postdeps_F77
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_F77
+
+# ### END LIBTOOL TAG CONFIG: F77
+_LT_EOF
+
+
+ cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: FC
+
+# The linker used to build libraries.
+LD=$lt_LD_FC
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_FC
+
+# A language specific compiler.
+CC=$lt_compiler_FC
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_FC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_FC
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_FC
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_FC
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_FC
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_FC
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_FC
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_FC
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_FC
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_FC
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_FC
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_FC
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_FC
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_FC
+archive_expsym_cmds=$lt_archive_expsym_cmds_FC
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_FC
+module_expsym_cmds=$lt_module_expsym_cmds_FC
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_FC
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_FC
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_FC
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_FC
+
+# 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_hardcode_libdir_flag_spec_ld_FC
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_FC
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_FC
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_FC
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_FC
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_FC
+
+# 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=$hardcode_automatic_FC
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_FC
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_FC
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path_FC
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_FC
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_FC
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_FC
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_FC
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_FC
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_FC
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_FC
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_FC
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_FC
+postdep_objects=$lt_postdep_objects_FC
+predeps=$lt_predeps_FC
+postdeps=$lt_postdeps_FC
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_FC
+
+# ### END LIBTOOL TAG CONFIG: FC
+_LT_EOF
+
+ ;;
+
+ esac
+done # for ac_tag
+
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $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;}
+fi
+
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..39c28ac
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,256 @@
+# -*- Autoconf -*-
+## Process this file with autoconf to produce a configure script.
+
+# This is part of Unidata's NetCDF CF Library. package. Copyright
+# 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 $])
+
+## 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_CONFIG_MACRO_DIR([m4])
+
+AC_MSG_NOTICE([libcf AC_PACKAGE_VERSION])
+
+# Find out about the host we're building on.
+AC_CANONICAL_HOST
+
+# We will output a config.h for the C library, and a fortran inc file,
+# nfconfig.inc.
+AC_CONFIG_HEADERS([config.h])
+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])
+
+# Check for the existance of this file before proceeding.
+AC_CONFIG_SRCDIR([src/nccoord.c])
+
+AC_MSG_NOTICE([checking user options])
+
+# Turn off shared libraries by default
+AM_DISABLE_SHARED
+
+# The autoconf manual suggests the following to set a var if it's not
+# already set: test "${var+set}" = set || var={value}
+
+# For backward compatibility, check to see if the user has set FC to
+# null. If so, treat that as the --disable-fortran option to
+# configure.
+
+# Did the user set fc to null?
+AC_MSG_CHECKING([whether FC is set to ''])
+nc_null_fc=no
+test "x${FC+set}" = xset && test "x$FC" = x && nc_null_fc=yes
+AC_MSG_RESULT([$nc_null_fc])
+
+# Does the user want to build documentation?
+AC_MSG_CHECKING([whether documentation is to be built])
+AC_ARG_ENABLE([docs],
+ [AS_HELP_STRING([--enable-docs],
+ [build the libcf documentation (a built version is already \
+ included with the distrubution)])])
+test "x$enable_docs" = xyes || enable_docs=no
+AC_MSG_RESULT($enable_docs)
+AM_CONDITIONAL(BUILD_DOCS, [test x$enable_docs = xyes])
+
+# Does the user want to build gridspec tools?
+AC_MSG_CHECKING([whether gridspec tools are to be built])
+AC_ARG_ENABLE([gridspec],
+ [AS_HELP_STRING([--enable-gridspec],
+ [build the gridspec tools])])
+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 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
+AC_MSG_RESULT($enable_cfcheck)
+AM_CONDITIONAL(BUILD_CFCHECK, [test x$enable_cfcheck = xyes])
+
+# Does the user want to enable logging?
+AC_MSG_CHECKING([whether logging is enabled (useful to CF developers, mainly])
+AC_ARG_ENABLE([logging],
+ [AS_HELP_STRING([--enable-logging],
+ [enable logging capability. This debugging features \
+ is only of interest to libcf developers.])])
+test "x$enable_logging" = "xyes" || enable_logging=no
+AC_MSG_RESULT([$enable_logging])
+if test "x$enable_logging" = xyes; then
+ AC_DEFINE([LOGGING], 1, [if true, turn on logging])
+fi
+
+# Does the user want to use netcdf-4?
+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
+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?
+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],
+ [Perform extra tests using CF example files from Unidata web site \
+ (example files must be donloaded separately). This option should \
+ only be used by those with excessive interest in testing libcf.])])
+test "x$enable_extra_data_tests" = xyes || enable_extra_data_tests=no
+AC_MSG_RESULT($enable_extra_data_tests)
+AM_CONDITIONAL(EXTRA_DATA_TESTS, [test x$enable_extra_data_tests = xyes])
+
+# Did the user specify a location for the HDF5 library?
+AC_MSG_CHECKING([whether a location for the HDF5 library was specified])
+AC_ARG_WITH([hdf5],
+ [AS_HELP_STRING([--with-hdf5=<directory>],
+ [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])
+
+# Do we want to build the fortran API? Check for --disable-f90
+nc_build_f90=yes
+AC_MSG_CHECKING([whether Fortran 90 API is desired])
+AC_ARG_ENABLE([f90],
+ [AS_HELP_STRING([--disable-f90],
+ [don't try to build Fortran 90 API])])
+test "x$enable_f90" = "xno" && nc_build_f90=no
+test "x$nc_null_fc" = xyes && nc_build_f90=no
+AC_MSG_RESULT([$nc_build_f90])
+AM_CONDITIONAL(BUILD_F90, [test "x$nc_build_f90" = xyes])
+
+# Did the user specify a location for the netcdf library?
+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])
+
+# According to the autoconf mailing list gurus, we must test for
+# compilers unconditionally. That is, we can't skip looking for the
+# fortran compilers, just because the user doesn't want fortran. This
+# is due to a limitation in autoconf.
+
+# Find the C compiler.
+AC_MSG_NOTICE([finding C compiler])
+AC_PROG_CC(mpcc_r xlc cc c89 acc gcc)
+AM_PROG_CC_C_O
+
+# Find fortran compiler. If FC isn't set after AC_PROG_FC, we couldn't
+# find a fortran compiler. If the user requested the fortran API, then
+# bail out right here.
+AC_MSG_NOTICE([finding Fortran compiler (required, even if Fortran API is not desired)])
+
+# We must call AC_PROG_F77 here, otherwise the LIBTOOL macro below
+# will call it, and reset F77 to g77.
+AC_PROG_F77([mpxlf_r xlf fort xlf95 ifort ifc efc pgf95 lf95 g95 gfortran f95 frt pgf77 f77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 g77])
+if test "${F77+set}" = set && test "x$F77" = x && test "x$nc_build_fortran" = xyes; then
+ AC_MSG_ERROR([Can't find F77 compiler, and compiler recovery disabled.])
+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])
+
+AC_MSG_NOTICE([finding other utilities])
+
+AC_PROG_INSTALL
+
+AC_MSG_NOTICE([setting up libtool])
+
+# Produce a windows DLL. This macro must be before AM_PROG_LIBTOOL.
+AC_LIBTOOL_WIN32_DLL
+
+# Use libtool.
+AC_PROG_LIBTOOL
+
+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)
+AC_CHECK_TYPE(ptrdiff_t, int)
+AC_CHECK_TYPE(uchar, unsigned char)
+AC_C_CHAR_UNSIGNED
+AC_C_BIGENDIAN
+AC_CHECK_SIZEOF(short)
+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_MSG_NOTICE([generating header files and makefiles])
+
+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])
+
+AC_OUTPUT()
+
diff --git a/depcomp b/depcomp
new file mode 100755
index 0000000..e5f9736
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,589 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2007-03-29.01
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 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
+# the Free Software Foundation; either version 2, 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.
+
+# Originally written by Alexandre Oliva <oliva at dcc.unicamp.br>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+ depmode Dependency tracking mode.
+ source Source file read by `PROGRAMS ARGS'.
+ object Object file output by `PROGRAMS ARGS'.
+ DEPDIR directory where to store dependencies.
+ depfile Dependency file to output.
+ tmpdepfile Temporary file to use when outputing dependencies.
+ libtool Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "depcomp $scriptversion"
+ exit $?
+ ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+ sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am. Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+ for arg
+ do
+ case $arg in
+ -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+ *) set fnord "$@" "$arg" ;;
+ esac
+ shift # fnord
+ shift # $arg
+ done
+ "$@"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+ tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'. On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # 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
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like `#:fec' to the end of the
+ # dependency line.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+ tr '
+' ' ' >> $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
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts `$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$base.u
+ tmpdepfile3=$dir.libs/$base.u
+ "$@" -Wc,-M
+ else
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$dir$base.u
+ tmpdepfile3=$dir$base.u
+ "$@" -M
+ fi
+ stat=$?
+
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+icc)
+ # Intel's C compiler understands `-MD -MF file'. However on
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # ICC 7.0 will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+ # ICC 7.1 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using \ :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+ sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp2)
+ # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+ # compilers, which have integrated preprocessors. The correct option
+ # to use with these is +Maked; it writes dependencies to a file named
+ # 'foo.d', which lands next to the object file, wherever that
+ # happens to be.
+ # Much of this is similar to the tru64 case; see comments there.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir.libs/$base.d
+ "$@" -Wc,+Maked
+ else
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir$base.d
+ "$@" +Maked
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ 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"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile" "$tmpdepfile2"
+ ;;
+
+tru64)
+ # The Tru64 compiler uses -MD to generate dependencies as a side
+ # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in `foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+ if test "$libtool" = yes; then
+ # With Tru64 cc, shared objects can also be used to make a
+ # static library. This mechanism is used in libtool 1.4 series to
+ # handle both shared and static libraries in a single compilation.
+ # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+ #
+ # With libtool 1.5 this exception was removed, and libtool now
+ # generates 2 separate objects for the 2 libraries. These two
+ # compilations output dependencies in $dir.libs/$base.o.d and
+ # in $dir$base.o.d. We have to check for both files, because
+ # one of the two compilations can be disabled. We should prefer
+ # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+ # automatically cleaned when .libs/ is deleted, while ignoring
+ # the former would cause a distcleancheck panic.
+ tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
+ tmpdepfile2=$dir$base.o.d # libtool 1.5
+ tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
+ tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
+ "$@" -Wc,-MD
+ else
+ tmpdepfile1=$dir$base.o.d
+ tmpdepfile2=$dir$base.d
+ tmpdepfile3=$dir$base.d
+ tmpdepfile4=$dir$base.d
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ test -z "$dashmflag" && dashmflag=-M
+ # Require at least two characters before searching for `:'
+ # in the target name. This is to cope with DOS-style filenames:
+ # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ "$@" $dashmflag |
+ sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+dashXmstdout)
+ # This case only exists to satisfy depend.m4. It is never actually
+ # run, as this mode is specially recognized in the preamble.
+ exit 1
+ ;;
+
+makedepend)
+ "$@" || exit $?
+ # Remove any Libtool call
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+ # X makedepend
+ shift
+ cleared=no
+ for arg in "$@"; do
+ case $cleared in
+ no)
+ set ""; shift
+ cleared=yes ;;
+ esac
+ 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.
+ -*|$object)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift ;;
+ esac
+ done
+ obj_suffix="`echo $object | sed 's/^.*\././'`"
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile" "$tmpdepfile".bak
+ ;;
+
+cpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ "$@" -E |
+ sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+ sed '$ s: \\$::' > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ cat < "$tmpdepfile" >> "$depfile"
+ sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+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.
+ "$@" || exit $?
+ IFS=" "
+ for arg
+ do
+ case "$arg" in
+ "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+ set fnord "$@"
+ shift
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift
+ shift
+ ;;
+ esac
+ done
+ "$@" -E |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
+ echo " " >> "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+none)
+ exec "$@"
+ ;;
+
+*)
+ echo "Unknown depmode $depmode" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..4efa58d
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,43 @@
+## This is a automake file, part of Unidata's NetCDF CF Library package.
+# Copyright 2006, see the COPYRIGHT file for more information.
+
+# 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 $
+
+info_TEXINFOS = libcf.texi
+
+# Get texi2dvi to shut the hell up!
+TEXI2DVI = texi2dvi -s
+
+# Get lists of the coresponding ps, info, and pdf files.
+html_docs = ${info_TEXINFOS:.texi=.html}
+ps_docs = ${info_TEXINFOS:.texi=.ps}
+pdf_docs = ${info_TEXINFOS:.texi=.pdf}
+info_docs= ${info_TEXINFOS:.texi=.info}
+
+EXTRA_DIST = defines.texi
+
+# Distributes the ps, info, and pdf files with the distribution.
+dist_pkgdata_DATA = $(ps_docs) $(info_docs) $(pdf_docs)
+
+# Automake seems to be broken with respect to generating html
+# output. Also it steals the *.html targets, no matter what I do. So
+# this cheesy phoney target does the html builds.
+libcf_html:
+ $(MAKEINFO) --html $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I$(srcdir) libcf.texi
+ $(MAKEINFO) --no-split --html $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I$(srcdir) libcf.texi
+
+# This isn't made by all, but tars up everything needed for the website
+web-tarball: all libcf_html
+ tar cf libcf_info.tar *.info*
+ gzip -f libcf_info.tar
+ zip libcf_info *.info &> /dev/null
+ tar cf libcf_pdf.tar *.pdf
+ gzip -f libcf_pdf.tar
+ zip libcf_pdf *.pdf &> /dev/null
+ tar cf libcf_html.tar libcf libcf.html
+ gzip -f libcf_html.tar
+ zip libcf_html *.pdf &> /dev/null
+ tar cf libcf_docs.tar $(nmans) *.pdf *.html *.tar.gz *.zip libcf
+ gzip -f libcf_docs.tar
diff --git a/doc/Makefile.in b/doc/Makefile.in
new file mode 100644
index 0000000..ab9dfb0
--- /dev/null
+++ b/doc/Makefile.in
@@ -0,0 +1,676 @@
+# 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@
+
+# Copyright 2006, see the COPYRIGHT file for more information.
+
+# 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 $
+
+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@
+subdir = doc
+DIST_COMMON = $(dist_pkgdata_DATA) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(srcdir)/stamp-vti \
+ $(srcdir)/version.texi mdate-sh texinfo.tex
+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 =
+SOURCES =
+DIST_SOURCES =
+INFO_DEPS = $(srcdir)/libcf.info
+am__TEXINFO_TEX_DIR = $(srcdir)
+DVIS = libcf.dvi
+PDFS = libcf.pdf
+PSS = libcf.ps
+HTMLS = libcf.html
+TEXINFOS = libcf.texi
+TEXI2PDF = $(TEXI2DVI) --pdf --batch
+MAKEINFOHTML = $(MAKEINFO) --html
+AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
+DVIPS = dvips
+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__installdirs = "$(DESTDIR)$(pkgdatadir)"
+dist_pkgdataDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(dist_pkgdata_DATA)
+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@
+info_TEXINFOS = libcf.texi
+
+# Get texi2dvi to shut the hell up!
+TEXI2DVI = texi2dvi -s
+
+# Get lists of the coresponding ps, info, and pdf files.
+html_docs = ${info_TEXINFOS:.texi=.html}
+ps_docs = ${info_TEXINFOS:.texi=.ps}
+pdf_docs = ${info_TEXINFOS:.texi=.pdf}
+info_docs = ${info_TEXINFOS:.texi=.info}
+EXTRA_DIST = defines.texi
+
+# Distributes the ps, info, and pdf files with the distribution.
+dist_pkgdata_DATA = $(ps_docs) $(info_docs) $(pdf_docs)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .dvi .html .info .pdf .ps .texi
+$(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 doc/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign doc/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
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+.texi.info:
+ restore=: && backupdir="$(am__leading_dot)am$$$$" && \
+ am__cwd=`pwd` && 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 \
+ if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
+ done; \
+ else :; fi && \
+ cd "$$am__cwd"; \
+ if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
+ -o $@ $<; \
+ then \
+ rc=0; \
+ cd $(srcdir); \
+ else \
+ rc=$$?; \
+ cd $(srcdir) && \
+ $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
+ fi; \
+ rm -rf $$backupdir; exit $$rc
+
+.texi.dvi:
+ TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
+ $(TEXI2DVI) $<
+
+.texi.pdf:
+ TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \
+ $(TEXI2PDF) $<
+
+.texi.html:
+ rm -rf $(@:.html=.htp)
+ if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
+ -o $(@:.html=.htp) $<; \
+ then \
+ rm -rf $@; \
+ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
+ mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \
+ else \
+ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
+ rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \
+ exit 1; \
+ fi
+$(srcdir)/libcf.info: libcf.texi $(srcdir)/version.texi
+libcf.dvi: libcf.texi $(srcdir)/version.texi
+libcf.pdf: libcf.texi $(srcdir)/version.texi
+libcf.html: libcf.texi $(srcdir)/version.texi
+$(srcdir)/version.texi: $(srcdir)/stamp-vti
+$(srcdir)/stamp-vti: libcf.texi $(top_srcdir)/configure
+ @(dir=.; test -f ./libcf.texi || dir=$(srcdir); \
+ set `$(SHELL) $(srcdir)/mdate-sh $$dir/libcf.texi`; \
+ echo "@set UPDATED $$1 $$2 $$3"; \
+ echo "@set UPDATED-MONTH $$2 $$3"; \
+ echo "@set EDITION $(VERSION)"; \
+ echo "@set VERSION $(VERSION)") > vti.tmp
+ @cmp -s vti.tmp $(srcdir)/version.texi \
+ || (echo "Updating $(srcdir)/version.texi"; \
+ cp vti.tmp $(srcdir)/version.texi)
+ - at rm -f vti.tmp
+ @cp $(srcdir)/version.texi $@
+
+mostlyclean-vti:
+ -rm -f vti.tmp
+
+maintainer-clean-vti:
+ -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi
+.dvi.ps:
+ TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+ $(DVIPS) -o $@ $<
+
+uninstall-dvi-am:
+ @$(NORMAL_UNINSTALL)
+ @list='$(DVIS)'; for p in $$list; do \
+ f=$(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) \
+ echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \
+ rm -rf "$(DESTDIR)$(htmldir)/$$f"; \
+ done
+
+uninstall-info-am:
+ @$(PRE_UNINSTALL)
+ @if test -d '$(DESTDIR)$(infodir)' && \
+ (install-info --version && \
+ install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
+ list='$(INFO_DEPS)'; \
+ 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"; \
+ done; \
+ else :; fi
+ @$(NORMAL_UNINSTALL)
+ @list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ relfile=`echo "$$file" | sed 's|^.*/||'`; \
+ relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
+ (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \
+ echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \
+ rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
+ else :; fi); \
+ done
+
+uninstall-pdf-am:
+ @$(NORMAL_UNINSTALL)
+ @list='$(PDFS)'; for p in $$list; do \
+ f=$(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) \
+ echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(psdir)/$$f"; \
+ done
+
+dist-info: $(INFO_DEPS)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ list='$(INFO_DEPS)'; \
+ for base in $$list; do \
+ case $$base in \
+ $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
+ esac; \
+ if test -f $$base; then d=.; else d=$(srcdir); fi; \
+ base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \
+ 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; \
+ else :; fi; \
+ done; \
+ done
+
+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
+
+maintainer-clean-aminfo:
+ @list='$(INFO_DEPS)'; for i in $$list; do \
+ i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \
+ echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
+ rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
+ done
+install-dist_pkgdataDATA: $(dist_pkgdata_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgdatadir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)"
+ @list='$(dist_pkgdata_DATA)'; 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"; \
+ 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
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+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
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$(top_distdir)" distdir="$(distdir)" \
+ dist-info
+check-am: all-am
+check: check-am
+all-am: Makefile $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(pkgdatadir)"; 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-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am: $(DVIS)
+
+html: html-am
+
+html-am: $(HTMLS)
+
+info: info-am
+
+info-am: $(INFO_DEPS)
+
+install-data-am: install-dist_pkgdataDATA
+
+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 \
+ 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"; \
+ done
+install-exec-am:
+
+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 \
+ if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(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"; \
+ else \
+ echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
+ $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
+ fi; \
+ 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)'; \
+ for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ esac; \
+ 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 \
+ if test -f $$ifile; then \
+ relfile=`echo "$$ifile" | sed 's|^.*/||'`; \
+ echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \
+ $(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \
+ else : ; fi; \
+ done; \
+ 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)'; \
+ for file in $$list; do \
+ relfile=`echo "$$file" | sed 's|^.*/||'`; \
+ echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
+ install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\
+ done; \
+ else : ; fi
+install-man:
+
+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 \
+ 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
+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 \
+ 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
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-aminfo \
+ maintainer-clean-generic maintainer-clean-vti
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-aminfo mostlyclean-generic \
+ mostlyclean-libtool mostlyclean-vti
+
+pdf: pdf-am
+
+pdf-am: $(PDFS)
+
+ps: ps-am
+
+ps-am: $(PSS)
+
+uninstall-am: uninstall-dist_pkgdataDATA uninstall-dvi-am \
+ uninstall-html-am uninstall-info-am uninstall-pdf-am \
+ uninstall-ps-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 \
+ 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 \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-aminfo maintainer-clean-generic \
+ maintainer-clean-vti mostlyclean mostlyclean-aminfo \
+ mostlyclean-generic mostlyclean-libtool mostlyclean-vti pdf \
+ pdf-am ps ps-am uninstall uninstall-am \
+ uninstall-dist_pkgdataDATA uninstall-dvi-am uninstall-html-am \
+ uninstall-info-am uninstall-pdf-am uninstall-ps-am
+
+
+# Automake seems to be broken with respect to generating html
+# output. Also it steals the *.html targets, no matter what I do. So
+# this cheesy phoney target does the html builds.
+libcf_html:
+ $(MAKEINFO) --html $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I$(srcdir) libcf.texi
+ $(MAKEINFO) --no-split --html $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I$(srcdir) libcf.texi
+
+# This isn't made by all, but tars up everything needed for the website
+web-tarball: all libcf_html
+ tar cf libcf_info.tar *.info*
+ gzip -f libcf_info.tar
+ zip libcf_info *.info &> /dev/null
+ tar cf libcf_pdf.tar *.pdf
+ gzip -f libcf_pdf.tar
+ zip libcf_pdf *.pdf &> /dev/null
+ tar cf libcf_html.tar libcf libcf.html
+ gzip -f libcf_html.tar
+ 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
new file mode 100644
index 0000000..c208bab
--- /dev/null
+++ b/doc/defines.texi
@@ -0,0 +1,61 @@
+ at c This is part of the libcf documentation. See COPYRIGHT file
+ at c for terms of use.
+
+ at c This file is included by the texi file, and contains
+ at c common definitions.
+
+ at c $Id: defines.texi,v 1.2 2006/09/13 20:46:04 ed Exp $
+
+ at set libcf-man The NetCDF CF Library Users Guide and Reference
+
+ at set libcf-support-email support-libcf@@unidata.ucar.edu
+
+ at c URLs for CF stuff.
+ at set cf-url http://www.cgd.ucar.edu/cms/eaton/cf-metadata/CF-1.0.html
+
+ at c home pages for netcdf, netcdf-4, netcdf java, hdf5, Unidata
+ at set hdf5-url http://hdf.ncsa.uiuc.edu/HDF5
+ at set unidata-url http://www.unidata.ucar.edu
+ at set netcdf-url @value{unidata-url}/software/netcdf
+ at set netcdf-4-url @value{netcdf-url}/netcdf-4
+ at set netcdf-java-url @value{unidata-url}/software/netcdf-java
+ at set ucar-url http://www.ucar.edu
+ at set udunits-url http://www.unidata.ucar.edu/software/udunits/
+
+ at c urls for netcdf documents
+ at set docs-url @value{netcdf-url}/docs
+
+ at c urls to search on-line stuff
+ at set libcf-support-search-url @value{unidata-url}/mailsearchform.php?archive=libcf&archivename=LibCF
+ at set libcf-list-search-url @value{unidata-url}/mailsearchform.php?archive=libcfgroup-list&archivename=LibCF_Group
+
+ at c places to get downloads
+ at set ftp-site ftp://ftp.unidata.ucar.edu/pub/libcf
+
+ at setchapternewpage odd
+ at finalout
+ at copying
+Copyright @copyright{} 2006 University Corporation for
+Atmospheric Research
+
+ at sp 2
+Permission is granted to make and distribute verbatim copies of this
+manual provided that the copyright notice and these paragraphs are
+preserved on all copies. The software and any accompanying written
+materials are provided ``as is'' without warranty of any kind. UCAR
+expressly disclaims all warranties of any kind, either expressed or
+implied, including but not limited to the implied warranties of
+merchantability and fitness for a particular purpose.
+
+The Unidata Program Center is managed by the University
+Corporation for Atmospheric Research and sponsored by the National
+Science Foundation. Any opinions, findings, conclusions, or
+recommendations expressed in this publication are those of the
+author(s) and do not necessarily reflect the views of the National
+Science Foundation.
+
+Mention of any commercial company or product in this document
+does not constitute an endorsement by the Unidata Program Center.
+Unidata does not authorize any use of information from this
+publication for advertising or publicity purposes.
+ at end copying
diff --git a/doc/libcf.info b/doc/libcf.info
new file mode 100644
index 0000000..f001b29
--- /dev/null
+++ b/doc/libcf.info
@@ -0,0 +1,2592 @@
+This is libcf.info, produced by makeinfo version 4.11 from
+/machine/shecky/lb_new9/doc//defines.texi.
+
+Copyright (C) 2006 University Corporation for Atmospheric Research
+
+
+
+ Permission is granted to make and distribute verbatim copies of this
+manual provided that the copyright notice and these paragraphs are
+preserved on all copies. The software and any accompanying written
+materials are provided "as is" without warranty of any kind. UCAR
+expressly disclaims all warranties of any kind, either expressed or
+implied, including but not limited to the implied warranties of
+merchantability and fitness for a particular purpose.
+
+ The Unidata Program Center is managed by the University Corporation
+for Atmospheric Research and sponsored by the National Science
+Foundation. Any opinions, findings, conclusions, or recommendations
+expressed in this publication are those of the author(s) and do not
+necessarily reflect the views of the National Science Foundation.
+
+ Mention of any commercial company or product in this document does
+not constitute an endorsement by the Unidata Program Center. Unidata
+does not authorize any use of information from this publication for
+advertising or publicity purposes.
+
+INFO-DIR-SECTION netCDF CF Library
+START-INFO-DIR-ENTRY
+* libcf: (libcf). The NetCDF CF Library Users Guide and Reference
+END-INFO-DIR-ENTRY
+
+
+File: libcf.info, Node: Top, Next: Summary, Prev: (dir), Up: (dir)
+
+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.
+
+* Menu:
+
+* Summary::
+* Installation::
+* cfcheck::
+* Files::
+* Variables::
+* Coordinates::
+* Combined Index::
+
+
+File: libcf.info, Node: Summary, Next: Installation, Prev: Top, Up: Top
+
+Summary
+*******
+
+The CF conventions for climate and forecast metadata are designed to
+promote the processing and sharing of files created with the netCDF API.
+
+ This library, libcf, makes it easier to create and work with data
+files which conform to the CF conventions.
+
+ The functions of the CF library are intended to be interspersed with
+netCDF library calls. That is, the programmer will open or create a
+netCDF file with the netCDF API, and then add or read metadata with
+libcf library functions, then continue to working with the netCDF API
+to read and write data.
+
+ By using libcf, a data producer can produce files that conform to the
+CF standards, without having to write netCDF code to create and decode
+all the attributes that the CF convention uses to store meta-data. A
+data consumer can use libcf to read any file which conforms to the CF
+conventions; the file does not need to be created with libcf to be read
+by libcf.
+
+ Fortran-77 wrapper functions provide a Fortran 77 API, just as is
+done 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 `http://www.cgd.ucar.edu/cms/eaton/cf-metadata/CF-1.0.html'.
+
+
+File: libcf.info, Node: Installation, Next: cfcheck, Prev: Summary, Up: Top
+
+Downloading and Installing libcf
+********************************
+
+Currently, and for some time to come, libcf is in alpha release. The
+code is tested, but not extensively. The API may be extended, and
+possibly changed, in each release.
+
+ You must have either netCDF-3 (or netCDF-4) installed. And reasonably
+recent version of netCDF should work. libcf is tested with netCDF
+3.6.2-beta4.
+
+ Get the latest version of the libcf tarball at the libcf ftp site:
+ftp://ftp.unidata.ucar.edu/pub/libcf
+
+ Unpack the tarball, and run:
+
+ ./configure --with-netcdf=/my/netcdf --prefix=/my/libcf && make check install > output.txt
+
+ Where /my/netcdf is the root install directory of the netCDF library
+you want to use, and /my/libcf is the root directory where you want
+libcf installed. (They may be the same directory.)
+
+ If you wish to use netCDF-4, you must also have HDF5 and libz, the
+compression library, installed. In this case, configure libcf like this:
+
+ ./configure --with-netcdf=/s/n4_new1/install --enable-netcdf-4 --with-hdf5=/home/ed/local/s && make check install > output.txt
+
+ If the build does not work for you, please email libcf support:
+support-libcf at unidata.ucar.edu. Please send the *complete* output of the
+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.
+
+
+File: libcf.info, Node: cfcheck, Next: Files, 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
+*******
+
+* Menu:
+
+* nccf_def_convention::
+* nccf_inq_convention::
+* nccf_def_file::
+* nccf_inq_file::
+* nccf_add_history::
+
+
+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
+===============================================
+
+Mark the file as following CF-1.0 conventions.
+
+ This functions is called automatically by nccf_def_file, so need not
+be called by the user if nccf_def_file is being called.
+
+Usage
+=====
+
+ int nccf_def_convention(int ncid);
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+===========================================================
+
+Determine if the file claims to follow CF-1.0 conventions. This
+function only checks the global "Conventions" attribute. It does not
+look at file metadata to ensure that this is a well-formed CF file. It
+only tells whether the file claims to be a CF file.
+
+Usage
+=====
+
+ int nccf_inq_convention(int ncid, int *cf_convention);
+
+`ncid'
+ The ncid of the file.
+
+`cf_conventions'
+ If this pointer to an int is provided, a 1 is written there if this
+ file claims to follow CF 1.0 conventions, a 0 otherwise.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+==================================================
+
+Add some or all of the CF recommended text attributes to a file. Any
+parameters which are set to NULL will be ignored.
+
+Usage
+=====
+
+ int nccf_def_file(int ncid, char *title, char *history, char *institution,
+ char *source, char *comment, char *references);
+
+`ncid'
+ The ncid of the file.
+
+`title'
+ If non-NULL, this text string will be written as the CF-recommended
+ "title" attribute.
+
+`history'
+ If non-NULL, this text string will be written as the CF-recommended
+ "history" attribute.
+
+`institution'
+ If non-NULL, this text string will be written as the CF-recommended
+ "institution" attribute.
+
+`source'
+ If non-NULL, this text string will be written as the CF-recommended
+ "source" attribute.
+
+`comment'
+ If non-NULL, this text string will be written as the CF-recommended
+ "comment" attribute.
+
+`references'
+ If non-NULL, this text string will be written as the CF-recommended
+ "references" attribute.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=======================================================
+
+Read any existing CF recommended text attributes from the file.
+
+ Recall that in C, strlens do not include the null terminator. To get
+the lengths before the strings (in order to allocated) pass NULL for
+any or all strings and the lengths will be returned. Then call the
+function again after allocating memory.
+
+ The CF version is guaranteed to be less than NC_MAX_NAME.
+
+ Any of these pointer arguments may be NULL, in which case it will be
+ignored.
+
+Usage
+=====
+
+ int nccf_inq_file(int ncid, size_t *title_lenp, char *title,
+ size_t *history_lenp, char *history,
+ size_t *institution_lenp, char *institution,
+ size_t *source_lenp, char *source,
+ size_t *comment_lenp, char *comment,
+ size_t *references_lenp, char *references);
+
+`ncid'
+ The ncid of the file.
+
+`title_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ title attribute.
+
+`title'
+ Pointer to char array which, if not NULL, will get the title
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`history_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ history attribute.
+
+`history'
+ Pointer to char array which, if not NULL, will get the history
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`institution_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ institution attribute.
+
+`institution'
+ Pointer to char array which, if not NULL, will get the institution
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`source_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ source attribute.
+
+`source'
+ Pointer to char array which, if not NULL, will get the source
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`comment_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ comment attribute.
+
+`comment'
+ Pointer to char array which, if not NULL, will get the comment
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`references_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ references attribute.
+
+`references'
+ Pointer to char array which, if not NULL, will get the references
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+Example
+=======
+
+
+
+File: libcf.info, Node: nccf_add_history, Prev: nccf_inq_file, Up: Files
+
+2.5 Append to a History Attribute
+=================================
+
+This function appends a time-stamped history string to the history
+attribute, creating the attribute if it doesn't already exist.
+
+Usage
+=====
+
+ int nccf_add_history(int ncid, const char *history);
+
+`ncid'
+ The ncid of the file.
+
+`history'
+ The string to append to the history attribute.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+Example
+=======
+
+
+
+File: libcf.info, Node: Variables, Next: Coordinates, Prev: Files, Up: Top
+
+3 Variables
+***********
+
+* Menu:
+
+* nccf_def_var::
+* nccf_inq_var::
+* nccf_def_var_missing::
+* nccf_inq_var_missing::
+* nccf_def_notes::
+* nccf_inq_notes::
+* nccf_def_latitude::
+* nccf_inq_latitude::
+* nccf_def_longitude::
+* nccf_inq_longitude::
+* nccf_def_lvl::
+* nccf_inq_lvl::
+* nccf_def_lvl_vert::
+* nccf_inq_lvl_vert::
+* nccf_def_time::
+* nccf_inq_time::
+* nccf_def_ft_sigma::
+* nccf_inq_lvl_sigma::
+* nccf_def_ft_hybrid_sigma::
+* nccf_inq_lvl_hybrid_sigma::
+* nccf_def_ft_hybrid_height::
+* nccf_inq_lvl_hybrid_height::
+* nccf_def_ft_sleve::
+* nccf_inq_lvl_sleve::
+* nccf_def_ft_ocean_sigma::
+* nccf_inq_lvl_ocean_sigma::
+* nccf_def_ft_ocean_s::
+* nccf_inq_lvl_ocean_s::
+* nccf_def_ft_ocean_sigma_z::
+* nccf_inq_lvl_ocean_sigma_z::
+* nccf_def_ft_ocean_dbl_sigma::
+* nccf_inq_lvl_ocean_dbl_sigma::
+* nccf_get_vara::
+
+
+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
+===================================================
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the netCDF variable being described.
+
+`units'
+ If non-NULL, this text string will be written as the CF-recommended
+ "units" attribute.
+
+`long_name'
+ If non-NULL, this text string will be written as the CF-recommended
+ "long_name" attribute.
+
+`standard_name'
+ If non-NULL, this text string will be written as the CF-recommended
+ "standard_name" attribute.
+
+`ncoord_vars'
+ Number of coordinate variables for this variable.
+
+`coord_varids'
+ The variable IDs of the coordinate variables for this variable.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+===============================================
+
+Read any existing CF recommended text attributes from a variable.
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the netCDF variable.
+
+`units_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ units attribute.
+
+`units'
+ Pointer to char array which, if not NULL, will get the long_name
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`long_name_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ long_name attribute.
+
+`long_name'
+ Pointer to char array which, if not NULL, will get the long_name
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`standard_name_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ standard_name attribute.
+
+`standard_name'
+ Pointer to char array which, if not NULL, will get the
+ standard_name string. Memory must be allocated before this
+ function is called. Call this function with a NULL for this
+ parameter to get the size first.
+
+`ncoord_vars'
+ Pointer to an integer, which, if non-NULL, will get the number of
+ coordinate variables identified in the "coordinates" attribute.
+
+`coord_varids'
+ Pointer to an array of integer, which, if non-NULL, will be filled
+ with the variable IDs of the variables listed int he "coordinates"
+ attribute.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=======================================================================
+
+nccf_def_notes
+
+ This function sets the "fill_value", "valid_min", and "valid_max"
+attributes.
+
+Usage
+=====
+
+ int nccf_def_var_missing(int ncid, int varid, const void *fill_valuep,
+ const void *valid_minp, const void *valid_maxp);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the netCDF variable being described.
+
+`fill_valuep'
+ If non-NULL, this will point to a value of the same type as this
+ varid, which will be used as the fill_value for the data.
+
+`valid_minp'
+ If non-NULL, this will point to a value of the same type as this
+ varid, which will be written as the "valid_min" attribute. If this
+ parameter is non-NULL, valid_max must also be provided.
+
+`valid_maxp'
+ If non-NULL, this will point to a value of the same type as this
+ varid, which will be written as the "valid_max" attribute. If this
+ parameter is non-NULL, valid_min must also be provided.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+===============================================================
+
+Get attributes which define missing data information. If the attributes
+are not there, then provide the valid data anyway, based on netCDF
+defaults.
+
+Usage
+=====
+
+ int nccf_inq_var_missing(int ncid, int varid, void *fill_valuep,
+ void *valid_minp, void *valid_maxp);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the netCDF variable.
+
+`fill_valuep'
+ If this is not NULL, the fill value of the variable will be
+ written at this address by nccf_inq_var_missing. If the fill value
+ was not defined for the variable, the netCDF default value will be
+ used.
+
+`valid_minp'
+ If this is not NULL, the valid_min value of the variable will be
+ written at this address by nccf_inq_var_missing. If the valid_min
+ was not defined for the variable, the netCDF default value will be
+ used.
+
+`valid_maxp'
+ If this is not NULL, the valid_max value of the variable will be
+ written at this address by nccf_inq_var_missing. If the valid_max
+ value was not defined for the variable, the netCDF default value
+ will be used.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+==========================================================
+
+nccf_def_notes
+
+ This functions writes up to four text attributes for either a
+variable, or an entire file. These text attributes, "institution,"
+"source," "comment," and "references" are recommended by the CF
+Metadata Convention.
+
+Usage
+=====
+
+ int nccf_def_notes(int ncid, int varid, char *units, char *long_name,
+ char *standard_name, char *institution,
+ char *source, char *comment, char *references);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the netCDF variable being described. Use NC_GLOBAL if
+ you wish these attributes to apply to the entire file.
+
+`institution'
+ If non-NULL, this text string will be written as the CF-recommended
+ "institution" attribute.
+
+`source'
+ If non-NULL, this text string will be written as the CF-recommended
+ "source" attribute.
+
+`comment'
+ If non-NULL, this text string will be written as the CF-recommended
+ "comment" attribute.
+
+`references'
+ If non-NULL, this text string will be written as the CF-recommended
+ "references" attribute.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=================================================
+
+Read any existing CF recommended text attributes from a variable.
+
+Usage
+=====
+
+ 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 *references_lenp, char *references);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the netCDF variable.
+
+`institution_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ institution attribute.
+
+`institution'
+ Pointer to char array which, if not NULL, will get the institution
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`source_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ source attribute.
+
+`source'
+ Pointer to char array which, if not NULL, will get the source
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`comment_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ comment attribute.
+
+`comment'
+ Pointer to char array which, if not NULL, will get the comment
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+`references_lenp'
+ Pointer to size_t which, if not NULL, will get the length of the
+ references attribute.
+
+`references'
+ Pointer to char array which, if not NULL, will get the references
+ string. Memory must be allocated before this function is called.
+ Call this function with a NULL for this parameter to get the size
+ first.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+==================================================================================
+
+Define a coordinate variable and dimension with all the CF recommended
+attribute accessories for latitude.
+
+Usage
+=====
+
+ int nccf_def_latitude(int ncid, size_t len, nc_type xtype,
+ const char *formula_terms, int *lat_dimidp,
+ int *lat_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`len'
+ The length of this coordinate dimension.
+
+`xtype'
+ The type of this coordinate variable.
+
+`formula_terms'
+ If non-NULL, a string which will be written as the "formula_terms"
+ attribute on the coordinate variable.
+
+`lat_dimidp'
+ If non-NULL, nccf_def_latitude will write the dimension ID of the
+ netCDF dimension for the latitude here.
+
+`lat_varidp'
+ If non-NULL, nccf_def_latitude will write the variable ID of the
+ netCDF coordinate variable for the latitude here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+=================================================================
+
+nccf_inq_latitude
+
+ Inquire about a latitude dimension and coordinate variable.
+
+Usage
+=====
+
+ int nccf_inq_latitude(int ncid, size_t *lenp, nc_type *xtypep,
+ size_t *ft_lenp, char *formula_terms,
+ int *lat_dimidp, int *lat_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`lenp'
+ If non-NULL, the length of the latitude dimension will be written
+ here by nccf_inq_latitude.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`ft_lenp'
+ If non-NULL, the length of the value of the "formula_terms"
+ attribute will be written here by ft_lenp. If there is no
+ "formula_terms" attribute, zero will be written.
+
+`lat_dimidp'
+ If non-NULL, the dimid of the latitude dimension will be written
+ here.
+
+`lat_varidp'
+ If non-NULL, the varid of the latitude coordinate variable will be
+ written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+====================================================================================
+
+Define a coordinate variable and dimension with all the CF recommended
+attribute accessories for longitude.
+
+Usage
+=====
+
+ int nccf_def_longitude(int ncid, size_t len, nc_type xtype,
+ const char *formula_terms, int *lon_dimidp,
+ int *lon_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`len'
+ The length of this coordinate dimension.
+
+`xtype'
+ The type of this coordinate variable.
+
+`formula_terms'
+ If non-NULL, a string which will be written as the "formula_terms"
+ attribute on the coordinate variable.
+
+`lon_dimidp'
+ If non-NULL, nccf_def_longitude will write the dimension ID of the
+ netCDF dimension for the longitude here.
+
+`lon_varidp'
+ If non-NULL, nccf_def_longitude will write the variable ID of the
+ netCDF coordinate variable for the longitude here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+===================================================================
+
+nccf_inq_longitude
+
+ Inquire about a longitude dimension and coordinate variable.
+
+Usage
+=====
+
+ int nccf_inq_longitude(int ncid, size_t *lenp, nc_type *xtypep,
+ size_t *ft_lenp, char *formula_terms,
+ int *lon_dimidp, int *lon_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`lenp'
+ If non-NULL, the length of the longitude dimension will be written
+ here by nccf_inq_longitude.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`ft_lenp'
+ If non-NULL, the length of the value of the "formula_terms"
+ attribute will be written here by ft_lenp. If there is no
+ "formula_terms" attribute, zero will be written.
+
+`lon_dimidp'
+ If non-NULL, the dimid of the longitude dimension will be written
+ here.
+
+`lon_varidp'
+ If non-NULL, the varid of the longitude coordinate variable will be
+ written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+===========================================================================
+
+Define a coordinate variable and dimension with all the CF recommended
+attribute accessories for a vertical level.
+
+Usage
+=====
+
+ 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 *long_name, const char *formula_terms,
+ int *lvl_dimidp, int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ The name of the coordinate dimension and variable.
+
+`len'
+ The length of this coordinate dimension and variable.
+
+`xtype'
+ The type of this coordinate variable.
+
+`units'
+ If non-NULL, a string which will be written as the "units"
+ attribute on the coordinate variable.
+
+`positive_up'
+ Set to 0 and the attribute "positive" to "down". Set to any other
+ value to get "up".
+
+`standard_name'
+ If non-NULL, a string which will be written as the "standard_name"
+ attribute on the coordinate variable.
+
+`long_name'
+ If non-NULL, a string which will be written as the "long_name"
+ attribute on the coordinate variable.
+
+`lon_dimidp'
+ If non-NULL, nccf_def_lvl will write the dimension ID of the
+ netCDF dimension for the level here.
+
+`lon_varidp'
+ If non-NULL, nccf_def_lvl will write the variable ID of the netCDF
+ coordinate variable for the level here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+===============================================================
+
+nccf_inq_lvl
+
+ Inquire about a level dimension and coordinate variable.
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, the name of this vertical level dimension (and
+ variable) will be written here.
+
+`lenp'
+ If non-NULL, the length of the level dimension will be written
+ here by nccf_inq_lvl.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`ft_lenp'
+ If non-NULL, the length of the value of the "formula_terms"
+ attribute will be written here by ft_lenp. If there is no
+ "formula_terms" attribute, zero will be written.
+
+`positive_upp'
+ If non-NULL, a one will be written here if the "positive" attribute
+ of this coordinate variable is "up", a zero will be written if it
+ is "down".
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the level dimension will be written here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the level coordinate variable will be
+ written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+===========================================================================
+
+Define a unitless vertical coordinate variable and dimension from
+Apendix D of the CF Convention, with all the CF recommended attribute
+accessories for a vertical level.
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`lvl_type'
+ One of: CF_VERT_ATM_LN, CF_VERT_SIGMA, CF_VERT_HYBRID_SIGMA,
+ CF_VERT_HYBRID_HEIGHT, CF_VERT_SLEVE, CF_VERT_OCEAN_SIGMA,
+ CF_VERT_OCEAN_S, CF_VERT_OCEAN_SIGMA_Z, CF_VERT_OCEAN_DBL_SIGMA.
+
+`name'
+ The name of the coordinate dimension and variable.
+
+`xtype'
+ The type of this coordinate variable.
+
+`len'
+ The length of this coordinate dimension and variable.
+
+`lvl_dimidp'
+ If non-NULL, the function will write the dimension ID of the
+ netCDF dimension for the level here.
+
+`llvl_varidp'
+ If non-NULL, the function will write the variable ID of the netCDF
+ coordinate variable for the level here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+===============================================================
+
+nccf_inq_lvl
+
+ Inquire about a level dimension and coordinate variable.
+
+Usage
+=====
+
+ int nccf_inq_lvl_vert(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *lvl_typep, int *lvl_dimidp, int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, the name of this vertical level dimension (and
+ variable) will be written here.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the level dimension will be written
+ here.
+
+`lvl_typep'
+ If non-NULL, the type of vertical dimension will be written here,
+ one of CF_VERT_ATM_LN, CF_VERT_SIGMA, CF_VERT_HYBRID_SIGMA,
+ CF_VERT_HYBRID_HEIGHT, CF_VERT_SLEVE, CF_VERT_OCEAN_SIGMA,
+ CF_VERT_OCEAN_S, CF_VERT_OCEAN_SIGMA_Z, CF_VERT_OCEAN_DBL_SIGMA.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the level dimension will be written here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the level coordinate variable will be
+ written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+===========================================================================
+
+Define a coordinate variable and dimension with all the CF recommended
+attribute accessories for time.
+
+Usage
+=====
+
+ int nccf_def_time(int ncid, const char *name, size_t len, nc_type xtype,
+ const char *units, const char *standard_name, const char *long_name,
+ const char *formula_terms, int *time_dimidp, int *time_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`len'
+ The length of this coordinate dimension.
+
+`xtype'
+ The type of this coordinate variable.
+
+`formula_terms'
+ If non-NULL, a string which will be written as the "formula_terms"
+ attribute on the coordinate variable.
+
+`lon_dimidp'
+ If non-NULL, nccf_def_time will write the dimension ID of the
+ netCDF dimension for the time here.
+
+`lon_varidp'
+ If non-NULL, nccf_def_time will write the variable ID of the
+ netCDF coordinate variable for the time here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+==============================================================
+
+nccf_inq_time
+
+ Inquire about a time dimension and coordinate variable.
+
+Usage
+=====
+
+ int nccf_inq_time(int ncid, size_t *lenp, nc_type *xtypep, size_t *ft_lenp,
+ char *formula_terms, int *time_dimidp, int *time_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`lenp'
+ If non-NULL, the length of the time dimension will be written here
+ by nccf_inq_time.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`ft_lenp'
+ If non-NULL, the length of the value of the "formula_terms"
+ attribute will be written here by ft_lenp. If there is no
+ "formula_terms" attribute, zero will be written.
+
+`formula_terms'
+ If non-NULL the value of the "formula_terms" attribute, if any,
+ will be copied here.
+
+`time_dimidp'
+ If non-NULL, the dimid of the time dimension will be written here.
+
+`time_varidp'
+ If non-NULL, the varid of the time coordinate variable will be
+ written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+========================================
+
+Define formula terms attribute for atmosphere sigma coordinate variable.
+
+Usage
+=====
+
+ int nccf_def_ft_sigma(int ncid, int varid, int ps_varid, int ptop_varid);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`ps_varid'
+ The variable ID of the ps variable.
+
+`ptop_varid'
+ The variable ID of the ptop variable.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+===============================================
+
+nccf_inq_time
+
+ Inquire about atmosphere sigma coordinate.
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`ps_varidp'
+ If non-NULL, the variable ID of the ps variable will be written
+ here.
+
+`ptop_varidp'
+ If non-NULL, the variable ID of the ptop variable will be written
+ here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+========================================
+
+Define formula terms attribute for atmosphere hybrid sigma coordinate
+variable.
+
+Usage
+=====
+
+ int nccf_def_ft_hybrid_sigma(int ncid, int varid, int a_varid, int b_varid,
+ int ps_varid, int p0_varid);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`a_varid'
+ The variable ID of the a variable.
+
+`b_varid'
+ The variable ID of the b variable.
+
+`ps_varid'
+ The variable ID of the ps variable.
+
+`ptop_varid'
+ The variable ID of the ptop variable.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+===============================================
+
+Inquire about atmosphere hybrid sigma coordinate.
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`a_varidp'
+ If non-NULL, the variable ID of the a variable will be written
+ here.
+
+`b_varidp'
+ If non-NULL, the variable ID of the b variable will be written
+ here.
+
+`ps_varidp'
+ If non-NULL, the variable ID of the ps variable will be written
+ here.
+
+`ptop_varidp'
+ If non-NULL, the variable ID of the ptop variable will be written
+ here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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
+=============================================================
+
+Define formula terms attribute for atmosphere hybrid height coordinate
+variable
+
+Usage
+=====
+
+ int nccf_def_ft_hybrid_height(int ncid, int varid, int a_varid, int b_varid,
+ int orog_varid);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`a_varid'
+ The variable ID of the a variable.
+
+`b_varid'
+ The variable ID of the b variable.
+
+`orog_varid'
+ The variable ID of the orog variable.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+============================================
+
+Inquire about the hybrid height coordinate.
+
+Usage
+=====
+
+ int nccf_inq_lvl_hybrid_height(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *a_varidp, int *b_varidp, int *orog_varidp,
+ int *lvl_dimidp, int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`a_varidp'
+ If non-NULL, the variable ID of the a variable will be written
+ here.
+
+`b_varidp'
+ If non-NULL, the variable ID of the b variable will be written
+ here.
+
+`orog_varidp'
+ If non-NULL, the variable ID of the orog variable will be written
+ here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+========================================
+
+Define formula terms attribute for the atmosphere sleve coordinate
+variable.
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`a_varid'
+ The variable ID of the a variable.
+
+`b1_varid'
+ The variable ID of the b1 variable.
+
+`b2_varid'
+ The variable ID of the b2 variable.
+
+`ztop_varid'
+ The variable ID of the ztop variable.
+
+`zsurf1_varid'
+ The variable ID of the zsurf1 variable.
+
+`zsurf2_varid'
+ The variable ID of the zsurf2 variable.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+====================================
+
+Inquire about the sleve coordinate.
+
+Usage
+=====
+
+ 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);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`a_varidp'
+ If non-NULL, the variable ID of the a variable will be written
+ here.
+
+`b1_varidp'
+ If non-NULL, the variable ID of the b1 variable will be written
+ here.
+
+`b2_varidp'
+ If non-NULL, the variable ID of the b2 variable will be written
+ here.
+
+`ztop_varidp'
+ If non-NULL, the variable ID of the ztop variable will be written
+ here.
+
+`zsurf1_varidp'
+ If non-NULL, the variable ID of the zsurf1 variable will be written
+ here.
+
+`zsurf2_varidp'
+ If non-NULL, the variable ID of the zsurf2 variable will be written
+ here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+===================================
+
+Define the formula terms attribute for the ocean sigma coordinate
+variable.
+
+Usage
+=====
+
+ int nccf_def_ft_ocean_sigma(int ncid, int varid, int eta_varid, int depth_varid);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`eta_varid'
+ The variable ID of the eta variable.
+
+`depth_varid'
+ The variable ID of the depth variable.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+==========================================
+
+Inquire about the ocean sigma coordinate.
+
+Usage
+=====
+
+ int nccf_inq_lvl_ocean_sigma(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *lvl_dimidp,
+ int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`eta_varidp'
+ If non-NULL, the variable ID of the eta variable will be written
+ here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+===============================
+
+Define ocean s coordinate.
+
+Usage
+=====
+
+ int nccf_def_ft_ocean_s(int ncid, const char *name, nc_type xtype, size_t len,
+ int eta_varid, int depth_varid, int a_varid, int b_varid,
+ int depth_c_varid, int *lvl_dimidp, int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`xtype'
+ The type of this coordinate variable.
+
+`len'
+ The length of this coordinate dimension.
+
+`eta_varid'
+ The variable ID of the eta variable.
+
+`depth_varid'
+ The variable ID of the depth variable.
+
+`a_varid'
+ The variable ID of the a variable.
+
+`b_varid'
+ The variable ID of the b variable.
+
+`depth_c_varid'
+ The variable ID of the depth_c variable.
+
+`lvl_dimidp'
+ If non-NULL, the dimension ID of the netCDF coordinate dimension
+ will be written here.
+
+`lvl_varidp'
+ If non-NULL, the variable ID of the netCDF coordinate variable
+ will be written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+======================================
+
+nccf_inq_time
+
+ Inquire about the ocean s coordinate.
+
+Usage
+=====
+
+ int nccf_inq_lvl_ocean_s(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *a_varidp, int *b_varidp,
+ int *depth_c_varidp, int *lvl_dimidp, int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`eta_varidp'
+ If non-NULL, the variable ID of the eta variable will be written
+ here.
+
+`depth_varidp'
+ If non-NULL, the variable ID of the depth variable will be written
+ here.
+
+`a_varidp'
+ If non-NULL, the variable ID of the a variable will be written
+ here.
+
+`b_varidp'
+ If non-NULL, the variable ID of the b variable will be written
+ here.
+
+`depth_c_varidp'
+ If non-NULL, the variable ID of the depth_c variable will be
+ written here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+=====================================
+
+Define ocean sigma z coordinate.
+
+Usage
+=====
+
+ int nccf_def_ft_ocean_sigma_z(int ncid, const char *name, nc_type xtype,
+ size_t len, int eta_varid, int depth_varid,
+ int depth_c_varid, int nsigma_varid,
+ int zlev_varid, int *lvl_dimidp, int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`xtype'
+ The type of this coordinate variable.
+
+`len'
+ The length of this coordinate dimension.
+
+`eta_varid'
+ The variable ID of the eta variable.
+
+`depth_varid'
+ The variable ID of the depth variable.
+
+`depth_c_varid'
+ The variable ID of the depth_c variable.
+
+`nsigma_varid'
+ The variable ID of the nsigma variable.
+
+`zlev_varid'
+ The variable ID of the zlev variable.
+
+`lvl_dimidp'
+ If non-NULL, the dimension ID of the netCDF coordinate dimension
+ will be written here.
+
+`lvl_varidp'
+ If non-NULL, the variable ID of the netCDF coordinate variable
+ will be written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+============================================
+
+Inquire about the ocean sigma z coordinate.
+
+Usage
+=====
+
+ int nccf_inq_lvl_ocean_sigma_z(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *depth_c_varidp,
+ int *nsigma_varidp, int *zlev_varidp, int *lvl_dimidp,
+ int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`eta_varidp'
+ If non-NULL, the variable ID of the eta variable will be written
+ here.
+
+`depth_varidp'
+ If non-NULL, the variable ID of the depth variable will be written
+ here.
+
+`depth_c_varidp'
+ If non-NULL, the variable ID of the depth_c variable will be
+ written here.
+
+`nsigma_varidp'
+ If non-NULL, the variable ID of the nsigma variable will be written
+ here.
+
+`zlev_varidp'
+ If non-NULL, the variable ID of the zlev variable will be written
+ here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+==========================================
+
+Define ocean double sigma coordinate.
+
+Usage
+=====
+
+ int nccf_def_ft_ocean_dbl_sigma(int ncid, const char *name, nc_type xtype, size_t len,
+ int depth_varid, int z1_varid, int z2_varid, int a_varid,
+ int href_varid, int k_c_varid, int *lvl_dimidp,
+ int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the vertical coordinate variable.
+
+`xtype'
+ The type of this coordinate variable.
+
+`len'
+ The length of this coordinate dimension.
+
+`depth_varid'
+ The variable ID of the depth variable.
+
+`z1_varid'
+ The variable ID of the z1 variable.
+
+`z2_varid'
+ The variable ID of the z2 variable.
+
+`a_varid'
+ The variable ID of the a variable.
+
+`href_varid'
+ The variable ID of the href variable.
+
+`k_c_varid'
+ The variable ID of the k_c variable.
+
+`lvl_dimidp'
+ If non-NULL, the dimension ID of the netCDF coordinate dimension
+ will be written here.
+
+`lvl_varidp'
+ If non-NULL, the variable ID of the netCDF coordinate variable
+ will be written here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+=================================================
+
+Inquire about the ocean double sigma coordinate.
+
+Usage
+=====
+
+ 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 *href_varidp, int *k_c_varidp,
+ int *lvl_dimidp, int *lvl_varidp);
+
+`ncid'
+ The ncid of the file.
+
+`name'
+ If non-NULL, this pointer gets the name of the coordinate variable
+ and dimension.
+
+`xtypep'
+ If non-NULL, the type of the coordinate variable will be written
+ here.
+
+`lenp'
+ If non-NULL, the length of the coordinate dimension will be written
+ here.
+
+`depth_varidp'
+ If non-NULL, the variable ID of the depth variable will be written
+ here.
+
+`z1_varidp'
+ If non-NULL, the variable ID of the z1 variable will be written
+ here.
+
+`z2_varidp'
+ If non-NULL, the variable ID of the z2 variable will be written
+ here.
+
+`a_varidp'
+ If non-NULL, the variable ID of the a variable will be written
+ here.
+
+`href_varidp'
+ If non-NULL, the variable ID of the href variable will be written
+ here.
+
+`k_c_varidp'
+ If non-NULL, the variable ID of the k_c variable will be written
+ here.
+
+`lvl_dimidp'
+ If non-NULL, the dimid of the coordinate dimension will be written
+ here.
+
+`lvl_varidp'
+ If non-NULL, the varid of the coordinate variable will be written
+ here.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+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.
+=========================================
+
+Get a geographic subset of the data.
+
+Usage
+=====
+
+ int nccf_get_vara(int ncid, int varid, float *lat_bounds, int *nlat, float *lon_bounds,
+ int *nlon, int *lvl_index, int *nlvl, int rec, void *data);
+
+`ncid'
+ The ncid of the file.
+
+`varid'
+ The varid of the data variable from which the subset will be taken.
+
+`lat_bounds'
+ A length two array, this holds the latitude start and stop values
+ for the range of interest.
+
+`nlat'
+ A pointer to an integer which will get the number of latitude
+ values which fall within the range.
+
+`lon_bounds'
+ A length two array, this holds the longitude start and stop values
+ for the range of interest. (Wrapping around the dateline is not
+ allowed!)
+
+`nlon'
+ A pointer to an integer which will get the number of longitude
+ values which fall within the range.
+
+`lvl_index'
+ A zero-based index number for the verticle level of interest to the
+ subsetter. (Ignored if data has no vertical axis).
+
+`timestep'
+ A zero-based index number for the timestep of interest to the
+ subsetter. (Ignored if data has no time axis).
+
+`data'
+ A pointer to which the data subset will be written. Memory must be
+ allocated (and deallocated) by the user.
+
+
+Return Codes
+============
+
+This function returns zero for success, or an error code for failure.
+
+Example
+=======
+
+
+
+File: libcf.info, Node: Coordinates, Next: Combined Index, Prev: Variables, Up: Top
+
+4 Coordinate Systems
+********************
+
+* Menu:
+
+* nccf-def-axis-type::
+* nccf-inq-axis-type::
+* nccf-def-coord-system::
+* nccf-inq-coord-system::
+* nccf-assign-coord-system::
+* nccf-def-transform::
+* nccf-inq-transform::
+* nccf-assign-transform::
+
+
+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
+===================================================================
+
+Usage
+=====
+
+ int
+ nccf_def_axis_type(int ncid, int varid, int axis_type);
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+======================================================================
+
+Usage
+=====
+
+ int
+ nccf_inq_axis_type(int ncid, int varid, int *axis_type);
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=========================================================
+
+Usage
+=====
+
+ int
+ nccf_def_coord_system(int ncid, const char *name, int naxes, int *axis_varids,
+ int *system_varid);
+
+ Define a coordinate system consisting of naxes axes, each axis
+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.
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=================================================================
+
+Usage
+=====
+
+ int
+ nccf_inq_coord_system(int ncid, int system_varid, char *name,
+ int *naxes, int *axis_varids);
+
+ Find out about a coordinate system, it's name, number of axes, and
+the varid of each axis coordinate var.
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=====================================================================
+
+Usage
+=====
+
+ int
+ nccf_assign_coord_system(int ncid, int varid, int system_varid);
+
+ Assign a coordinate system to a var. This adds an attribute to the
+var.
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=========================================================
+
+Usage
+=====
+
+ int
+ nccf_def_transform(int ncid, const char *name, const char *transform_type,
+ const char *transform_name, int *transform_varid);
+
+ 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.
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+=================================================================
+
+Usage
+=====
+
+ 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);
+
+ 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.
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+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
+===================================================================================
+
+Usage
+=====
+
+ int
+ nccf_assign_transform(int ncid, int system_varid, int transform_varid);
+
+ Assign a coordinate transform to a coordinate system. This adds an
+attribute to the variable that holds the coordinate system attributes.
+
+`ncid'
+ The ncid of the file.
+
+
+Return Codes
+============
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+Example
+=======
+
+
+
+File: libcf.info, Node: Combined Index, Prev: Coordinates, Up: Top
+
+Index
+*****
+
+ [index ]
+* Menu:
+
+* API, C: Summary. (line 6)
+* API, F90: Summary. (line 6)
+* API, Fortran: Summary. (line 6)
+* supported programming languages: Summary. (line 6)
+
+
+
+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
+
+End Tag Table
diff --git a/doc/libcf.pdf b/doc/libcf.pdf
new file mode 100644
index 0000000..2cc72ab
Binary files /dev/null and b/doc/libcf.pdf differ
diff --git a/doc/libcf.ps b/doc/libcf.ps
new file mode 100644
index 0000000..547a019
--- /dev/null
+++ b/doc/libcf.ps
@@ -0,0 +1,3556 @@
+%!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
+%%PageOrder: Ascend
+%%BoundingBox: 0 0 595 842
+%%DocumentFonts: CMBX12 CMR10 CMSY10 CMBXTI10 CMTI10 CMTT10 CMR9 CMTI9
+%%DocumentPaperSizes: a4
+%%EndComments
+%DVIPSWebPage: (www.radicaleye.com)
+%DVIPSCommandLine: dvips -o libcf.ps libcf.dvi
+%DVIPSParameters: dpi=600
+%DVIPSSource: TeX output 2009.04.12:0813
+%%BeginProcSet: tex.pro 0 0
+%!
+/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S
+N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72
+mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0
+0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{
+landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize
+mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[
+matrix currentmatrix{A A round sub abs 0.00001 lt{round}if}forall round
+exch round exch]setmatrix}N/@landscape{/isls true N}B/@manualfeed{
+statusdict/manualfeed true put}B/@copies{/#copies X}B/FMat[1 0 0 -1 0 0]
+N/FBB[0 0 0 0]N/nn 0 N/IEn 0 N/ctr 0 N/df-tail{/nn 8 dict N nn begin
+/FontType 3 N/FontMatrix fntrx N/FontBBox FBB N string/base X array
+/BitMaps X/BuildChar{CharBuilder}N/Encoding IEn N end A{/foo setfont}2
+array copy cvx N load 0 nn put/ctr 0 N[}B/sf 0 N/df{/sf 1 N/fntrx FMat N
+df-tail}B/dfs{div/sf X/fntrx[sf 0 0 sf neg 0 0]N df-tail}B/E{pop nn A
+definefont setfont}B/Cw{Cd A length 5 sub get}B/Ch{Cd A length 4 sub get
+}B/Cx{128 Cd A length 3 sub get sub}B/Cy{Cd A length 2 sub get 127 sub}
+B/Cdx{Cd A length 1 sub get}B/Ci{Cd A type/stringtype ne{ctr get/ctr ctr
+1 add N}if}B/CharBuilder{save 3 1 roll S A/base get 2 index get S
+/BitMaps get S get/Cd X pop/ctr 0 N Cdx 0 Cx Cy Ch sub Cx Cw add Cy
+setcachedevice Cw Ch true[1 0 0 -1 -.1 Cx sub Cy .1 sub]{Ci}imagemask
+restore}B/D{/cc X A type/stringtype ne{]}if nn/base get cc ctr put nn
+/BitMaps get S ctr S sf 1 ne{A A length 1 sub A 2 index S get sf div put
+}if put/ctr ctr 1 add N}B/I{cc 1 add D}B/bop{userdict/bop-hook known{
+bop-hook}if/SI save N @rigin 0 0 moveto/V matrix currentmatrix A 1 get A
+mul exch 0 get A mul add .99 lt{/QV}{/RV}ifelse load def pop pop}N/eop{
+SI restore userdict/eop-hook known{eop-hook}if showpage}N/@start{
+userdict/start-hook known{start-hook}if pop/VResolution X/Resolution X
+1000 div/DVImag X/IEn 256 array N 2 string 0 1 255{IEn S A 360 add 36 4
+index cvrs cvn put}for pop 65781.76 div/vsize X 65781.76 div/hsize X}N
+/p{show}N/RMat[1 0 0 -1 0 0]N/BDot 260 string N/Rx 0 N/Ry 0 N/V{}B/RV/v{
+/Ry X/Rx X V}B statusdict begin/product where{pop false[(Display)(NeXT)
+(LaserWriter 16/600)]{A length product length le{A length product exch 0
+exch getinterval eq{pop true exit}if}{pop}ifelse}forall}{false}ifelse
+end{{gsave TR -.1 .1 TR 1 1 scale Rx Ry false RMat{BDot}imagemask
+grestore}}{{gsave TR -.1 .1 TR Rx Ry scale 1 1 false RMat{BDot}
+imagemask grestore}}ifelse B/QV{gsave newpath transform round exch round
+exch itransform moveto Rx 0 rlineto 0 Ry neg rlineto Rx neg 0 rlineto
+fill grestore}B/a{moveto}B/delta 0 N/tail{A/delta X 0 rmoveto}B/M{S p
+delta add tail}B/b{S p tail}B/c{-4 M}B/d{-3 M}B/e{-2 M}B/f{-1 M}B/g{0 M}
+B/h{1 M}B/i{2 M}B/j{3 M}B/k{4 M}B/w{0 rmoveto}B/l{p -4 w}B/m{p -3 w}B/n{
+p -2 w}B/o{p -1 w}B/q{p 1 w}B/r{p 2 w}B/s{p 3 w}B/t{p 4 w}B/x{0 S
+rmoveto}B/y{3 2 roll p a}B/bos{/SS save N}B/eos{SS restore}B end
+
+%%EndProcSet
+%%BeginProcSet: texps.pro 0 0
+%!
+TeXDict begin/rf{findfont dup length 1 add dict begin{1 index/FID ne 2
+index/UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll
+exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]FontType 0
+ne{/Metrics exch def dict begin Encoding{exch dup type/integertype ne{
+pop pop 1 sub dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get
+div def}ifelse}forall Metrics/Metrics currentdict end def}{{1 index type
+/nametype eq{exit}if exch pop}loop}ifelse[2 index currentdict end
+definefont 3 -1 roll makefont/setfont cvx]cvx def}def/ObliqueSlant{dup
+sin S cos div neg}B/SlantFont{4 index mul add}def/ExtendFont{3 -1 roll
+mul exch}def/ReEncodeFont{CharStrings rcheck{/Encoding false def dup[
+exch{dup CharStrings exch known not{pop/.notdef/Encoding true def}if}
+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
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.0) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMTI9) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Medium) readonly def
+/ItalicAngle -14.04 def
+/isFixedPitch false def
+end readonly def
+/FontName /CMTI9 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
+readonly def
+/FontBBox{-35 -250 1148 750}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
+3B12D472B7CF54651EF21185116A69AB1096ED4BAD2F646635E019B6417CC77B
+532F85D811C70D1429A19A5307EF63EB5C5E02C89FC6C20F6D9D89E7D91FE470
+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
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+%%EndFont
+%%BeginFont: CMR9
+%!PS-AdobeFont-1.1: CMR9 1.0
+%%CreationDate: 1991 Aug 20 16:39:59
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.0) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMR9) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Medium) readonly def
+/ItalicAngle 0 def
+/isFixedPitch false def
+end readonly def
+/FontName /CMR9 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 44 /comma put
+dup 48 /zero put
+dup 49 /one put
+dup 57 /nine put
+dup 65 /A put
+dup 67 /C put
+dup 70 /F put
+dup 73 /I put
+dup 80 /P put
+dup 97 /a put
+dup 100 /d put
+dup 101 /e put
+dup 103 /g put
+dup 105 /i put
+dup 108 /l put
+dup 109 /m put
+dup 110 /n put
+dup 111 /o put
+dup 112 /p put
+dup 114 /r put
+dup 115 /s put
+dup 116 /t put
+dup 117 /u put
+readonly def
+/FontBBox{-39 -250 1036 750}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA052A014267B7904EB3C0D3BD0B83D891
+016CA6CA4B712ADEB258FAAB9A130EE605E61F77FC1B738ABC7C51CD46EF8171
+9098D5FEE67660E69A7AB91B58F29A4D79E57022F783EB0FBBB6D4F4EC35014F
+D2DECBA99459A4C59DF0C6EBA150284454E707DC2100C15B76B4C19B84363758
+469A6C558785B226332152109871A9883487DD7710949204DDCF837E6A8708B8
+2BDBF16FBC7512FAA308A093FE5CF7158F1163BC1F3352E22A1452E73FECA8A4
+87100FB1FFC4C8AF409B2067537220E605DA0852CA49839E1386AF9D7A1A455F
+D1F017CE45884D76EF2CB9BC5821FD25365DDEA6E45F332B5F68A44AD8A530F0
+92A36FADB679CF58BAFDD3E51DFDD314B91A605515D729EE20C42505FD4E0835
+3C9D365B14C003BC6DD352F0228A8C161F172D2551CD1C67CD0B1B21DED53203
+046FAFF9B1129167921DD82C5964F9DDDFE0D2686875BD075FC81831A941F20E
+C5CD90040A092E559F6D1D3B0E9BB71733595AE0EA6093F986377A96060BF12A
+A1B525CD9FA741FE051DD54A32BECD55A868DD63119A4370F8322CCBEC889BC2
+A723CB4015FC4AA90AE873EA14DE13382CA9CF0D8DFB65F0ABEDFD9A64BB3F4D
+731E2E1C9A1789228FF44116230A70C339C9819676022AB31B5C9C589AE9094B
+09882051AD4637C1710D93E8DD117B4E7B478493B91EA6306FDB3FA6D738AAB1
+49FBB21A00AC2A999C21445DE3177F21D8B6AAB33869C882613EA6B5EC56476B
+5634181ECBF03BFEDB57F079EACE3B334F6F384BDF9D70AEBD592C8ECF21378B
+54A8B5DBF7CB9282E16AA517E14843909339B5E7C55B038BF3BB493F3B884A1C
+C25F9E8FB912CBE23199AD9D2C3E573727701BA301526C66C3617B9514D6F11F
+11930B1D97C17816C85B1BFD9B973A191B33CC3B391815AD14F1CBE935942AEC
+D4004E6BEF379066FD72209DC88D2E634E79BCC2B98C766CBD92C561F2703F8A
+109E6C6CEC7B866F2FC7ADF646BF492E520319F3B949AB5D84AE990B33344A40
+3971F58DFDF8D8D67FA0B8F2A0D884F8C09A5A721319B911DBA0A35903877343
+C37BC36C5EB32353272D1E6ED5FCA611BE319A7E1E842CB7576E7CCE29C1136C
+9B6311F452C368D335645E3F96DA7860EBBE80E932664C89515439473598CAFA
+870C56732A9C9ED76CC421B79A04E784CD2C11FF0E2ACE282D27D994330A1698
+923F5E81E38D6D57DAC50F4447E0E0550741867562616B0BEA3D13509C37B5AF
+E346798C9997651A866DB11F272BC20EA24A03137261E7A588D42FEE9786CDCE
+EED97AD7820F66219E23A25CBA10980E836DB7BF6B4A14FE78F5D73D7E4218BB
+22AEB254D86857E59DE82612AB3A520E13ADF219E6C0E3D9A24A3FA233247C76
+943E6E6765C0DBC85563B95EA6C5660BA7965D55C8E65BF1954473C9BD02C919
+82CD4293B4C67E6DF0F5C373FC135010CA9C302F5D60639B6E94E67DABDD1FF2
+292F0CE59AC4EFCBC882E94D353D9243F00A0359CC32809F931F64D35A6834F5
+7719E74037B9A791B95EDDE64BD981D8E8545CDB0F8380280100CD511DF4D9A4
+CAE390977F1F975D394D2E30447959780B8FEA839C699399AB1A269A5119E1E7
+4D9D95DF633D0EFC92473A14F90EC599910DCB8F8AB6355A692279E3F761E5D7
+51752923A5A0FC4A44F975CC3575AECC5721D1CC55C4FAFAC509D91FD81F6871
+01236C9CF4CBD17861AE0321AAE9BDC84A7B0F7865228B4CAB1B07FD1B823539
+72C71758A352AFCDEBDDA4E037B7104071CD79F569B0ECB2845E305D1367FAC7
+803F1B19FB9940AB50112ACA7DC70A86136EE62887D0844F64A20CCF45D602A7
+FD62790E004F37D759CB6F185422C5E5966323810F2B410AF967AD1A9D08ED0C
+478344D670DA60539C040C5DA62770D5B4075A3B6EFF0743C1876F103425B516
+ECA422FCDD538E4FBF4809A4F01A8A9618773B320ACAC824258A432F55AB4F61
+428A7A8555A4BBF9B9D9FC5C3A5EDFD760AD773E9C7DD54327DEEF4AAE675C62
+F58BA1D87EDCD84D3354EDDE797950E128DEE5EDDA6B0B20D812E47C00CAA72A
+C06BCCCF1B92E0BCD54C9D96CB7593BC6AE730B01ADEBECFD7BB3243A8C4FD61
+A726FBFB21E000E56D7A693BF65516C04C927F92FAA5D346B2D08E83629CF93E
+1FDA9F18875A9906818345F7713BF82AD92B36A6DCF8BB60B10CD971DD577754
+B15FBC9B18B66A0B569C96C4531C93DBF76E17EE1742419FDBA72329401CC4CA
+B5F683BBD0BF5055B93753DE807723AA8CFB534556B756CD3CA959A4717F8B72
+C399B60F9AF13A88E43AFB9AE8A2C786EEFB02817AB79D89B39415EE3F1E5FE1
+F8CEC8C58DC0C4E75936F19E0779363C820E59E16BCCC47C98A385385D240963
+DFED6DD9DC7FC43607F1E0C26E4C732534B01584BDD9B6FAA798DC8D1916C05D
+DD706B469F7A67881873C6B2F8B71A2CA48106D5E0DFADF1531CD1B74A4F4764
+B822F8942983D992E0E0E0973746DAA67F621AF66E7A2DDC9086750B19863261
+64D451635ABEB78065858D07E3D68355E1C8593E99D5C77102FAE32B0A1E5B52
+B2BF48E95001BD2F8E0E48F98C9D2D642386F26387F13B90921038C8C3FAAB1A
+278C97BA5A030B8483336C21C9D99CDB5C0A5C0CF24DB170264CF165F2C3544D
+32091A54CA96FF5EDB028B894515AA1F364E3FA14F5C126E91AE19AA65657DA3
+919B13422344DF7398EED00C204ED6B7F7FBF1354DA6D5511FB43163ED2FC148
+688139DBD26222C44FA541F559DEEB22A15D03604598CE6C36EC613FB205B8C8
+A831564BC21D0C5936E7B05D4CF0A0CDA82EBE81342E84F27C4DFAD48459AB90
+48EF9E2F1DA165A3FC74435B66089500A8CADE7FD953F806C7AAF4A3B59364B6
+4516F955238F4D541EA2585956A28B0365397A38A221C18C5B09829EAE7C22A1
+89CBEE163C10207F85000B706C8C037053722903460B18DABCECA11334643784
+1B7D412124DB3D31E72F3C60CA40DF86DC3965CC6490318ED3554DA28613588E
+4C329BCF4CCD209A511CC08575343BE51F9B71863B0D0AF717D326173FE85A6C
+1307C6FC6211DF29C288C5D2947C850D556ADEC0FEC8024B6FE3834F82269543
+CE4ACA88885A6CB96F82992AECEE34EDD8353B5276148DD70F9A892FA601D40E
+F9391F025531EF2BBC85D791AB7E7EC263D2D7B7B3B295AEA18C9DDD7DEEDAD3
+CD35CAE2A7CECFDCDCB100AFDF3FB1A5603E11862C0A2AB5E89C8BE60897917C
+29E56B027A8116FC3AE0BB8961AC88CE125B4C775F17F665D50D83A801B5C191
+4349F80CE9C6B4D9A1DAC60B5CEE711DE70817769C5D57489382D0C80B136846
+07852385BB15837C271407A1D251E54972A339C4B07C47EE9438196017D9E1BE
+8814A64AB6FC3F8B734D2E8BEBAA25A81661EF251F346917894252BC661F1F36
+2F79FE774CFF9783AE48D8B5B16597946F424ECDD29F7B61CF7D2BDA867E247A
+0811148747319C7BF5D917CBED59EC3F7A7DE5065D703C5779C530D273842BE6
+B4BE55D3BBE9E496C6D9D688CE455635FA8DF065D39C9EFC6B53624EC692ECF3
+FD9CD936001DBC8904B5CA9E07C48F07ED2B90271827BBBF349093F7945A8411
+9F6F94A6DA10D973C8921ECF58ADEEE4871253CC3D3269B56AC7F45D0E78DA07
+D13CBAB3C70F315479A941BD3487DEA2AA6FE8C8DF8DFD98837084C63B25DF12
+46F0FEE99D9413736665188AACE680804FBE3300D921A2799F2708838E07FEA6
+1DCCF84251C7B7A17CD0B211E0EF3893A0490FEBE8B4D42FCB65F92BF725FF20
+F3D9BB8803A806DCD62FA82BAE32D20A09A6970EBA1E1FDB406B35A6F0F5ED0E
+6914A7C9CF346B8761E92E6E14699057A50354D1A09007403CC5ECE50B7A0B5B
+652203F630395CB6C2108127EEA55E45901DB6187227F605AEC38CF1C90BF20E
+C53CB606C58D6D8A614B76655A7CBC5062EEF1F176E88975C20CB26DD77C2CDF
+2A57C6A97BFF573B463891D3D3A1C2C9365A625AF603442DDA20749523348E97
+74D4DAABEC96F0FC6843F7AA2EB655536DFC037C9FD87D4425AC530C93695CBC
+2CAE7743A8B5D5785B0A8DB841C0CA07C533FA97A36EA139CCF9798127B21D4E
+0AF2D6AF926A087E0F777913C1D310B86CDCB99EE8F80026950F1B148E997224
+F07DB07652D9DC338989FB5D3FAE78BA23C95899B61D5CC938A007F8773A716C
+97152E14C5B13B0131DA15C3C5E757506536CACF7E6714868DCCCBC23DFE67EA
+24B44E991467FEE2ECDBFA11169F65D977BE98D628085BD0B0C15B0994203722
+4E6F16D70F056D62AE17AAE036CE9CAE6CC90A7B3BEE0428E4A0BCFAE59EEBC5
+F1C608A527272FF5ED18218704F66DD9150EF9BE38123BC9CDC941D49D845CFA
+3557B109D080306D1DF89702F6FC99F4F172E0AC719C36DDD4DA60075929E77E
+2D9EB7CE42D8CFB7B88D54E5AEBF05A41DB655BE58299906E05FC1D4BA73F5A5
+9A356701D66051B6C50A1C58617779F659879C224D71CCE1F06B6C816AE5972F
+AEFFA78D9807D876771424D9E713F6F152FA8B874E50719CAF9A82026D6D92B2
+C5693164DEC775B32077858953A233C4DCCDD3A7A8247FC8DE0BA3E33CCD0353
+1B9FDF1061EFC94E2AA62660667E259A60FD5EF666B8874474E6BFF492541790
+05ABE6BB6162CEECB97F03DA3D90341473454755D95EC5830731941136069B83
+408EF639F0F8C69B6DA8377D232578FEF00EA8085595569B81B4F16C6A5F6DE7
+310D5A25ED1A59B2418813D5FBD398FE7E1AF850542FD22AA0A67FEB1FFB0522
+7EC6830BBA6DF7624F2FE54FE1EA45A6AB7C71B7E75BA77E073560B4E6AC0840
+D81F45FE04AE3CAF185CF0588553BE234ED01649FB6858353833132337C1C54A
+1CF117D4ABF3E81A7B85C653412CFDFABD033668B6640F5734C2AAF4B0850C61
+02DA99652B5717D5AF86A967AE9E2C31FE5B57118D5A6157ED1FE00EC35C96D6
+EB944E5BB4E06B8F673F6B51A6525D24007E919A2087F076C0F32DD527F96C4C
+94AC1BDA9797CE5E3E10EEE5A9BBF590155CCDAC886636188E333AB930B2F85C
+457545E24D6270D6EBC8723056D9438738F33929BAD4E50A7EE5B367E2EE4BB3
+B3FBA4128FABAC9A5476AE50DE5C341C7941EC72F18F30A94B40601D698391EF
+FD9C9ED71D113502A8EEA819CB0E89300E009AC7CBD12EABE70AECC943D5B2A6
+56A5818FA87F3612BE86F837942A1D9BDC06923140E438B47730E4A1C2BDAA2A
+9E620D1678E2B47B5CAAE8B68286A5B53648F6D81A09A8A9AA360EFFAF6D0D8B
+4167504EDAA4BCFED47B478069D2071CA3F014C6DE285FB44367982917EFD0D0
+790464444E38DBC8140E06B2585962C0E42C7ABA14ADDA7137E8BEC048BFFDAA
+305DF2A36EDCAD99E65A59FA4A04A36788291A3F01FB6B570EAA6926FB1B803B
+DBCEB039E6DDA600CF06B915AD97E6159489BD7D435A75B69174E800D73837E8
+641DB831F29234DB4E062BEF698EB3A8DCA650CF098DDB7727A2BD25EEC74359
+BC412027E62DB072B06EA440A2A5B3DEA44A09A6F3A0A9C53B4684B6218713DF
+4AA614D92F62E79B8E3C7452B4D85F69417ECE59B858AF3351485393DC37E2F2
+2D473159483078C91FD7AA503C792FFB7EBC004433C8690D4C9F7AE28217FAF6
+B7EA8C4BE755973454E9EB461D3B47AD55BFE90BCBA18A88FD16D122DBE327EE
+ABF23A45EECCF120DD8893B5868AAF9CFFF7B2A240B8D093A8B9F809D0BC9306
+5575AAC042BB9CF989E28CD390AC386D1BFC1E6A6D33F66EECB9FD49C460D560
+E6C282588555D41D7C1CE4C16E36BFB036AE947A23021065FFC381C4389E1BC9
+FC9EF2D3A9CEF4A283F25C83BA0BEB564FAEB23DD8C473285FB6683CC99FE43A
+6888099F895C111D25FDADEDDAF4116CBC6A2445FC0AE10F4838B3C6FBF29770
+905D5C390265911E6E69A8188D08E690BF6E8E5677F9DD5FE222C932FE1B8D8D
+0E1D587E27C4EA35023A4D5D074EA51A02E0A808E05A515C00846259576C456A
+D652C4EA6C09F3107B4570EF22C9E9E7A316FE26C1ACEA03724B483BA18BA248
+9AEC05E99502482F1FFA2CA3F25FC193307C6D07022FA9F9C7738BCB468E304E
+8FC35C43B14746FDD8B2EAE77F473FB938D9EC2B2F2D9E395E9A920796376866
+BA8B4AA98C523F4BD6A278D326650B6387EB41E019C818E9DD96166F76BB25E4
+5F411BF2388705D2E07CE1D72F03669571261F06BAC919611473922472EAB206
+10410EB228A32599FAC918CBBCF9B1EB3CD863D3675C66BA81
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+%%EndFont
+%%BeginFont: CMTT10
+%!PS-AdobeFont-1.1: CMTT10 1.00B
+%%CreationDate: 1992 Apr 26 10:42:42
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.00B) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMTT10) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Medium) readonly def
+/ItalicAngle 0 def
+/isFixedPitch true def
+end readonly def
+/FontName /CMTT10 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 38 /ampersand put
+dup 40 /parenleft put
+dup 41 /parenright put
+dup 42 /asterisk put
+dup 44 /comma put
+dup 45 /hyphen put
+dup 46 /period put
+dup 47 /slash put
+dup 48 /zero put
+dup 49 /one put
+dup 50 /two put
+dup 52 /four put
+dup 53 /five put
+dup 58 /colon put
+dup 59 /semicolon put
+dup 61 /equal put
+dup 62 /greater put
+dup 64 /at put
+dup 67 /C put
+dup 70 /F put
+dup 95 /underscore put
+dup 97 /a put
+dup 98 /b put
+dup 99 /c put
+dup 100 /d put
+dup 101 /e put
+dup 102 /f put
+dup 103 /g put
+dup 104 /h put
+dup 105 /i put
+dup 107 /k put
+dup 108 /l put
+dup 109 /m put
+dup 110 /n put
+dup 111 /o put
+dup 112 /p put
+dup 113 /q put
+dup 114 /r put
+dup 115 /s put
+dup 116 /t put
+dup 117 /u put
+dup 118 /v put
+dup 119 /w put
+dup 120 /x put
+dup 121 /y put
+dup 122 /z put
+readonly def
+/FontBBox{-4 -235 731 800}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA052A014267B7904EB3C0D3BD0B83D891
+016CA6CA4B712ADEB258FAAB9A130EE605E61F77FC1B738ABC7C51CD46EF8171
+9098D5FEE67660E69A7AB91B58F29A4D79E57022F783EB0FBBB6D4F4EC35014F
+D2DECBA99459A4C59DF0C6EBA150284454E707DC2100C15B76B4C19B84363758
+469A6C558785B226332152109871A9883487DD7710949204DDCF837E6A8708B8
+2BDBF16FBC7512FAA308A093FE5F00F963068B8232429ED8B7CF6A3D879A2D19
+38DD5C4467F9DD8C5D1A2000B3A6BF2F25629BAEC199AE8BD4BA6ED9BBF7DABF
+D0E153BAB1C17900D4FCE209622ACD19E7C74C2807D0397357ED07AB460D5204
+EB3A45B7AC4D106B7303AD8348853032A745F417943F9B4FED652B835AA49727
+A8B4117AFF1D4BCE831EB510B6851796D0BE6982B76620CB3CE0C22CACDD4593
+F244C14EEC0E5A7C4AC42392F81C01BC4257FE12AF33F4BFEA9108FF11CF9714
+4DD6EC70A2C4C1E4F328A1EB25E43525FB1E16C07E28CC359DF61F426B7D41EA
+6A0C84DD63275395A503AAE908E1C82D389FD12A21E86999799E7F24A994472E
+A10EAE77096709BE0D11AAD24A30D96E15A51D720AFB3B10D2E0AC8DC1A1204B
+E8725E00D7E3A96F9978BC19377034D93D080C4391E579C34FF9FC2379CB119F
+1E5BBEA91AE20F343C6420BE1E2BD0636B04FCCC0BEE0DC2D56D66F06DB22438
+452822CBEAF03EE9EAA8398F276EC0D92A7FB978C17805DB2F4A7DFBA56FD6AF
+8670EB364F01DE8FCAFBAF657D68C3A03112915736CEABAA8BA5C0AC25288369
+5D49BD891FABEFE8699A0AE3ED85B48ACB22229E15623399C93DE7D935734ADA
+DA7A1462C111D44AD53EA35B57E5D0B5FC0B481820E43222DB8EFCD5D30E15F9
+BA304FA879392EE0BCC0E1A61E74B3A1FC3A3D170218D7244580C7AA0DC65D19
+741FA5FE6F8CBF60250ACC27454BBF0897CA4B909C83A56672958752ED4B5E79
+E18660764F155E86F09EFA9F7685F2F5027EC85A775287B30E2069DE4E4D5712
+E7D033481A53A2702BA7542C71062173039030CF28D8B9C63B5596A9B42B33E7
+D922944A38713383D3648A4AF160A3B0C8F3379BA4372BE2E7EA49AABA75AEEE
+C5DDE1D8BF68483C3D21271280ABB91D54CC819680322EAB72E1250A760BC8DC
+FF798F2ABFC4F3539392985C4CB324B0007229586D1E0321559F67C057FD7902
+194490A4C133DA7E04E7895F3C8786BEB6B449472C32E3AE702291DAF51407EA
+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
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+%%EndFont
+%%BeginFont: CMTI10
+%!PS-AdobeFont-1.1: CMTI10 1.00B
+%%CreationDate: 1992 Feb 19 19:56:16
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.00B) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMTI10) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Medium) readonly def
+/ItalicAngle -14.04 def
+/isFixedPitch false def
+end readonly def
+/FontName /CMTI10 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
+readonly def
+/FontBBox{-163 -250 1146 969}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
+3B12D472B7CF54651EF21185116A69AB1096ED4BAD2F646635E019B6417CC77B
+532F85D811C70D1429A19A5307EF63EB5C5E02C89FC6C20F6D9D89E7D91FE470
+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
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+%%EndFont
+%%BeginFont: CMBXTI10
+%!PS-AdobeFont-1.1: CMBXTI10 1.0
+%%CreationDate: 1991 Aug 18 17:46:30
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.0) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMBXTI10) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Bold) readonly def
+/ItalicAngle -14.04 def
+/isFixedPitch false def
+end readonly def
+/FontName /CMBXTI10 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
+readonly def
+/FontBBox{-29 -250 1274 754}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA0529731C99A784CCBE85B4993B2EEBDE
+3B12D472B7CF54651EF21185116A69AB1096ED4BAD2F646635E019B6417CC77B
+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
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+%%EndFont
+%%BeginFont: CMBX12
+%!PS-AdobeFont-1.1: CMBX12 1.0
+%%CreationDate: 1991 Aug 20 16:34:54
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.0) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMBX12) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Bold) readonly def
+/ItalicAngle 0 def
+/isFixedPitch false def
+end readonly def
+/FontName /CMBX12 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 12 /fi put
+dup 45 /hyphen put
+dup 46 /period put
+dup 48 /zero put
+dup 49 /one put
+dup 50 /two put
+dup 51 /three put
+dup 52 /four put
+dup 53 /five put
+dup 54 /six put
+dup 55 /seven put
+dup 56 /eight put
+dup 57 /nine put
+dup 65 /A put
+dup 67 /C put
+dup 68 /D put
+dup 69 /E put
+dup 70 /F put
+dup 71 /G put
+dup 72 /H put
+dup 73 /I put
+dup 76 /L put
+dup 77 /M put
+dup 78 /N put
+dup 79 /O put
+dup 80 /P put
+dup 82 /R put
+dup 83 /S put
+dup 84 /T put
+dup 85 /U put
+dup 86 /V put
+dup 90 /Z put
+dup 97 /a put
+dup 98 /b put
+dup 99 /c put
+dup 100 /d put
+dup 101 /e put
+dup 102 /f put
+dup 103 /g put
+dup 104 /h put
+dup 105 /i put
+dup 107 /k put
+dup 108 /l put
+dup 109 /m put
+dup 110 /n put
+dup 111 /o put
+dup 112 /p put
+dup 113 /q put
+dup 114 /r put
+dup 115 /s put
+dup 116 /t put
+dup 117 /u put
+dup 118 /v put
+dup 119 /w put
+dup 120 /x put
+dup 121 /y put
+readonly def
+/FontBBox{-53 -251 1139 750}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA052A014267B7904EB3C0D3BD0B83D891
+016CA6CA4B712ADEB258FAAB9A130EE605E61F77FC1B738ABC7C51CD46EF8171
+9098D5FEE67660E69A7AB91B58F29A4D79E57022F783EB0FBBB6D4F4EC35014F
+D2DECBA99459A4C59DF0C6EBA150284454E707DC2100C15B76B4C19B84363758
+469A6C558785B226332152109871A9883487DD7710949204DDCF837E6A8708B8
+2BDBF16FBC7512FAA308A093FE5F0364CD5660F74BEE96790DE35AFA90CCF712
+B1805DA88AE375A04D99598EADFC625BDC1F9C315B6CF28C9BD427F32C745C99
+AEBE70DAAED49EA45AF94F081934AA47894A370D698ABABDA4215500B190AF26
+7FCFB7DDA2BC68605A4EF61ECCA3D61C684B47FFB5887A3BEDE0B4D30E8EBABF
+20980C23312618EB0EAF289B2924FF4A334B85D98FD68545FDADB47F991E7390
+B10EE86A46A5AF8866C010225024D5E5862D49DEB5D8ECCB95D94283C50A363D
+68A49071445610F03CE3600945118A6BC0B3AA4593104E727261C68C4A47F809
+D77E4CF27B3681F6B6F3AC498E45361BF9E01FAF5527F5E3CC790D3084674B3E
+26296F3E03321B5C555D2458578A89E72D3166A3C5D740B3ABB127CF420C316D
+F957873DA04CF0DB25A73574A4DE2E4F2D5D4E8E0B430654CF7F341A1BDB3E26
+77C194764EAD58C585F49EF10843FE020F9FDFD9008D660DE50B9BD7A2A87299
+BC319E66D781101BB956E30643A19B93C8967E1AE4719F300BFE5866F0D6DA5E
+C55E171A24D3B707EFA325D47F473764E99BC8B1108D815CF2ACADFA6C4663E8
+30855D673CE98AB78F5F829F7FA226AB57F07B3E7D4E7CE30ED3B7EB0D3035C5
+148DA8D9FA34483414FDA8E3DC9E6C479E3EEE9A11A0547FC9085FA4631AD19C
+E936E0598E3197207FA7BB6E55CFD5EF72AEC12D9A9675241C7A71316B2E148D
+E2A1732B3627109EA446CB320EBBE2E78281CDF0890E2E72B6711335857F1E23
+337C75E729701E93D5BEC0630CDC7F4E957233EC09F917E5CA703C7E93841598
+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
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+%%EndFont
+%%BeginFont: CMSY10
+%!PS-AdobeFont-1.1: CMSY10 1.0
+%%CreationDate: 1991 Aug 15 07:20:57
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.0) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMSY10) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Medium) readonly def
+/ItalicAngle -14.035 def
+/isFixedPitch false def
+end readonly def
+/FontName /CMSY10 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 13 /circlecopyrt put
+readonly def
+/FontBBox{-29 -960 1116 775}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA052F09F9C8ADE9D907C058B87E9B6964
+7D53359E51216774A4EAA1E2B58EC3176BD1184A633B951372B4198D4E8C5EF4
+A213ACB58AA0A658908035BF2ED8531779838A960DFE2B27EA49C37156989C85
+E21B3ABF72E39A89232CD9F4237FC80C9E64E8425AA3BEF7DED60B122A52922A
+221A37D9A807DD01161779DDE7D31FF2B87F97C73D63EECDDA4C49501773468A
+27D1663E0B62F461F6E40A5D6676D1D12B51E641C1D4E8E2771864FC104F8CBF
+5B78EC1D88228725F1C453A678F58A7E1B7BD7CA700717D288EB8DA1F57C4F09
+0ABF1D42C5DDD0C384C7E22F8F8047BE1D4C1CC8E33368FB1AC82B4E96146730
+DE3302B2E6B819CB6AE455B1AF3187FFE8071AA57EF8A6616B9CB7941D44EC7A
+71A7BB3DF755178D7D2E4BB69859EFA4BBC30BD6BB1531133FD4D9438FF99F09
+4ECC068A324D75B5F696B8688EEB2F17E5ED34CCD6D047A4E3806D000C199D7C
+515DB70A8D4F6146FE068DC1E5DE8BC5703711DA090312BA3FC00A08C453C609
+C627A8BFEF75B4DEFAF34B44B356A516B765AFCDD3F5475B1F928731D09D2170
+B97E40F12CCEDF4F6BB3756C4734F6E98D74B7E942A954B1BAAB83D4AD727FF6
+DF6DC50B2223BCB5568A73A112E4860AD490554E64E780073FF3399CB4688D33
+9E8829667CD6EAEF25E0C7D2D44F2BBFA40E999325F9561514844221B50BC8FC
+4C7AD68CA7220D69125C2AF06849A3E068D18733276F0C0A6A2936D3C2C87CDE
+59CD1AF148C44F85784A5DAD569F5FF53C061056C067CE29AEF1E3BD1FD8B0B8
+71A0A638CDAC6AEEDBD5337D4683C084BB60B1859E600F59CB4E19C5FC5C6327
+EC544A68134496A9BD0B87D83AF6FDA3CB62FBF0B54FACE1F0E6A2D84B467AFF
+0F62DB
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+cleartomark
+%%EndFont
+%%BeginFont: CMR10
+%!PS-AdobeFont-1.1: CMR10 1.00B
+%%CreationDate: 1992 Feb 19 19:54:52
+% Copyright (C) 1997 American Mathematical Society. All Rights Reserved.
+11 dict begin
+/FontInfo 7 dict dup begin
+/version (1.00B) readonly def
+/Notice (Copyright (C) 1997 American Mathematical Society. All Rights Reserved) readonly def
+/FullName (CMR10) readonly def
+/FamilyName (Computer Modern) readonly def
+/Weight (Medium) readonly def
+/ItalicAngle 0 def
+/isFixedPitch false def
+end readonly def
+/FontName /CMR10 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 12 /fi put
+dup 13 /fl put
+dup 33 /exclam put
+dup 34 /quotedblright put
+dup 39 /quoteright put
+dup 40 /parenleft put
+dup 41 /parenright put
+dup 42 /asterisk put
+dup 44 /comma put
+dup 45 /hyphen put
+dup 46 /period put
+dup 47 /slash put
+dup 48 /zero put
+dup 49 /one put
+dup 50 /two put
+dup 51 /three put
+dup 52 /four put
+dup 53 /five put
+dup 54 /six put
+dup 55 /seven put
+dup 56 /eight put
+dup 57 /nine put
+dup 58 /colon put
+dup 59 /semicolon put
+dup 65 /A put
+dup 66 /B put
+dup 67 /C put
+dup 68 /D put
+dup 69 /E put
+dup 70 /F put
+dup 71 /G put
+dup 72 /H put
+dup 73 /I put
+dup 76 /L put
+dup 77 /M put
+dup 78 /N put
+dup 79 /O put
+dup 80 /P put
+dup 82 /R put
+dup 83 /S put
+dup 84 /T put
+dup 85 /U put
+dup 86 /V put
+dup 87 /W put
+dup 88 /X put
+dup 89 /Y put
+dup 90 /Z put
+dup 92 /quotedblleft put
+dup 97 /a put
+dup 98 /b put
+dup 99 /c put
+dup 100 /d put
+dup 101 /e put
+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
+dup 110 /n put
+dup 111 /o put
+dup 112 /p put
+dup 113 /q put
+dup 114 /r put
+dup 115 /s put
+dup 116 /t put
+dup 117 /u put
+dup 118 /v put
+dup 119 /w put
+dup 120 /x put
+dup 121 /y put
+dup 122 /z put
+readonly def
+/FontBBox{-251 -250 1009 969}readonly def
+currentdict end
+currentfile eexec
+D9D66F633B846A97B686A97E45A3D0AA052A014267B7904EB3C0D3BD0B83D891
+016CA6CA4B712ADEB258FAAB9A130EE605E61F77FC1B738ABC7C51CD46EF8171
+9098D5FEE67660E69A7AB91B58F29A4D79E57022F783EB0FBBB6D4F4EC35014F
+D2DECBA99459A4C59DF0C6EBA150284454E707DC2100C15B76B4C19B84363758
+469A6C558785B226332152109871A9883487DD7710949204DDCF837E6A8708B8
+2BDBF16FBC7512FAA308A093FE5CF7158F1163BC1F3352E22A1452E73FECA8A4
+87100FB1FFC4C8AF409B2067537220E605DA0852CA49839E1386AF9D7A1A455F
+D1F017CE45884D76EF2CB9BC5821FD25365DDEA6E45F332B5F68A44AD8A530F0
+92A36FAC8D27F9087AFEEA2096F839A2BC4B937F24E080EF7C0F9374A18D565C
+295A05210DB96A23175AC59A9BD0147A310EF49C551A417E0A22703F94FF7B75
+409A5D417DA6730A69E310FA6A4229FC7E4F620B0FC4C63C50E99E179EB51E4C
+4BC45217722F1E8E40F1E1428E792EAFE05C5A50D38C52114DFCD24D54027CBF
+2512DD116F0463DE4052A7AD53B641A27E81E481947884CE35661B49153FA19E
+0A2A860C7B61558671303DE6AE06A80E4E450E17067676E6BBB42A9A24ACBC3E
+B0CA7B7A3BFEA84FED39CCFB6D545BB2BCC49E5E16976407AB9D94556CD4F008
+24EF579B6800B6DC3AAF840B3FC6822872368E3B4274DD06CA36AF8F6346C11B
+43C772CC242F3B212C4BD7018D71A1A74C9A94ED0093A5FB6557F4E0751047AF
+D72098ECA301B8AE68110F983796E581F106144951DF5B750432A230FDA3B575
+5A38B5E7972AABC12306A01A99FCF8189D71B8DBF49550BAEA9CF1B97CBFC7CC
+96498ECC938B1A1710B670657DE923A659DB8757147B140A48067328E7E3F9C3
+7D1888B284904301450CE0BC15EEEA00E48CCD6388F3FC3BEFD8D9C400015B65
+0F2F536D035626B1FF0A69D732C7A1836D635C30C06BED4327737029E5BA5830
+B9E88A4024C3326AD2F34F47B54739B48825AD6699F7D117EA4C4AEC4440BF6D
+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
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+0000000000000000000000000000000000000000000000000000000000000000
+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
+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
+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
+%%EndProlog
+%%BeginSetup
+%%Feature: *Resolution 600dpi
+TeXDict begin
+%%PaperSize: A4
+ end
+%%EndSetup
+%%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
+%%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
+(oration)e(for)g(A)m(tmospheric)h(Researc)m(h)150 4067
+y(P)m(ermission)e(is)g(gran)m(ted)h(to)g(mak)m(e)g(and)f(distribute)f
+(v)m(erbatim)i(copies)g(of)f(this)g(man)m(ual)h(pro)m(vided)e(that)150
+4177 y(the)c(cop)m(yrigh)m(t)i(notice)g(and)d(these)i(paragraphs)f(are)
+h(preserv)m(ed)e(on)i(all)g(copies.)39 b(The)24 b(soft)m(w)m(are)i(and)
+e(an)m(y)150 4286 y(accompan)m(ying)29 b(written)f(materials)h(are)f
+(pro)m(vided)f(\\as)i(is")f(without)g(w)m(arran)m(t)m(y)g(of)g(an)m(y)g
+(kind.)39 b(UCAR)150 4396 y(expressly)25 b(disclaims)g(all)h(w)m(arran)
+m(ties)g(of)f(an)m(y)g(kind,)g(either)h(expressed)e(or)h(implied,)h
+(including)f(but)f(not)150 4505 y(limited)31 b(to)g(the)g(implied)f(w)m
+(arran)m(ties)h(of)g(merc)m(han)m(tabilit)m(y)i(and)c(\014tness)h(for)g
+(a)h(particular)g(purp)s(ose.)150 4640 y(The)j(Unidata)h(Program)f(Cen)
+m(ter)g(is)h(managed)f(b)m(y)g(the)h(Univ)m(ersit)m(y)g(Corp)s(oration)
+f(for)g(A)m(tmospheric)150 4749 y(Researc)m(h)f(and)e(sp)s(onsored)f(b)
+m(y)i(the)g(National)h(Science)g(F)-8 b(oundation.)46
+b(An)m(y)31 b(opinions,)h(\014ndings,)f(con-)150 4859
+y(clusions,)k(or)e(recommendations)h(expressed)f(in)h(this)f
+(publication)h(are)g(those)g(of)g(the)g(author\(s\))g(and)150
+4969 y(do)c(not)h(necessarily)g(re\015ect)g(the)g(views)f(of)h(the)f
+(National)i(Science)g(F)-8 b(oundation.)150 5103 y(Men)m(tion)36
+b(of)f(an)m(y)h(commercial)g(compan)m(y)g(or)f(pro)s(duct)e(in)i(this)g
+(do)s(cumen)m(t)g(do)s(es)f(not)i(constitute)g(an)150
+5213 y(endorsemen)m(t)46 b(b)m(y)f(the)h(Unidata)g(Program)g(Cen)m
+(ter.)86 b(Unidata)46 b(do)s(es)g(not)f(authorize)i(an)m(y)f(use)f(of)
+150 5322 y(information)31 b(from)f(this)g(publication)h(for)f(adv)m
+(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(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
+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
+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
+%%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
+%%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)
+d(climate)j(and)d(forecast)i(metadata)h(are)e(designed)f(to)i(promote)f
+(the)g(pro-)150 643 y(cessing)31 b(and)f(sharing)g(of)g(\014les)h
+(created)g(with)f(the)h(netCDF)g(API.)275 777 y(This)h(library)-8
+b(,)34 b(lib)s(cf,)g(mak)m(es)g(it)f(easier)h(to)g(create)h(and)d(w)m
+(ork)i(with)e(data)i(\014les)f(whic)m(h)g(conform)g(to)150
+887 y(the)e(CF)f(con)m(v)m(en)m(tions.)275 1021 y(The)37
+b(functions)g(of)h(the)g(CF)g(library)g(are)g(in)m(tended)f(to)i(b)s(e)
+e(in)m(tersp)s(ersed)g(with)h(netCDF)g(library)150 1131
+y(calls.)59 b(That)36 b(is,)i(the)e(programmer)g(will)g(op)s(en)g(or)g
+(create)i(a)e(netCDF)h(\014le)f(with)g(the)g(netCDF)h(API,)150
+1240 y(and)30 b(then)f(add)h(or)g(read)g(metadata)i(with)e(lib)s(cf)g
+(library)g(functions,)g(then)f(con)m(tin)m(ue)j(to)f(w)m(orking)f(with)
+150 1350 y(the)h(netCDF)g(API)f(to)h(read)f(and)g(write)g(data.)275
+1484 y(By)39 b(using)g(lib)s(cf,)i(a)f(data)g(pro)s(ducer)d(can)j(pro)s
+(duce)e(\014les)h(that)h(conform)f(to)h(the)f(CF)h(standards,)150
+1594 y(without)32 b(ha)m(ving)h(to)g(write)f(netCDF)h(co)s(de)f(to)h
+(create)h(and)d(deco)s(de)i(all)g(the)f(attributes)h(that)g(the)f(CF)
+150 1704 y(con)m(v)m(en)m(tion)k(uses)d(to)h(store)g(meta-data.)51
+b(A)34 b(data)g(consumer)f(can)g(use)h(lib)s(cf)f(to)h(read)f(an)m(y)h
+(\014le)f(whic)m(h)150 1813 y(conforms)e(to)i(the)f(CF)f(con)m(v)m(en)m
+(tions;)k(the)d(\014le)g(do)s(es)f(not)h(need)g(to)g(b)s(e)f(created)i
+(with)e(lib)s(cf)h(to)g(b)s(e)f(read)150 1923 y(b)m(y)f(lib)s(cf.)275
+2057 y(F)-8 b(ortran-77)38 b(wrapp)s(er)d(functions)h(pro)m(vide)g(a)h
+(F)-8 b(ortran)37 b(77)g(API,)g(just)f(as)g(is)h(done)f(with)g(netCDF)
+150 2167 y(itself.)42 b(A)30 b(F)-8 b(ortran)31 b(90)g(API)f(is)h
+(planned,)f(but)f(not)i(y)m(et)g(b)s(egun.)275 2301 y(F)-8
+b(or)44 b(more)g(information)g(ab)s(out)f(the)h(CF)g(Con)m(v)m(en)m
+(tions,)k(see)d(the)e(CF)h(Metadata)i(w)m(eb)e(site)g(at)150
+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
+%%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
+b(and)i(Installing)g(lib)t(cf)150 533 y Fi(Curren)m(tly)-8
+b(,)30 b(and)f(for)h(some)g(time)h(to)g(come,)g(lib)s(cf)e(is)h(in)g
+(alpha)g(release.)42 b(The)29 b(co)s(de)h(is)g(tested,)h(but)f(not)150
+643 y(extensiv)m(ely)-8 b(.)43 b(The)30 b(API)g(ma)m(y)h(b)s(e)f
+(extended,)g(and)g(p)s(ossibly)g(c)m(hanged,)h(in)f(eac)m(h)h(release.)
+275 777 y(Y)-8 b(ou)26 b(m)m(ust)h(ha)m(v)m(e)h(either)e(netCDF-3)i
+(\(or)f(netCDF-4\))h(installed.)40 b(And)26 b(reasonably)h(recen)m(t)g
+(v)m(ersion)150 887 y(of)k(netCDF)g(should)e(w)m(ork.)41
+b(lib)s(cf)30 b(is)g(tested)h(with)f(netCDF)h(3.6.2-b)s(eta4.)275
+1021 y(Get)21 b(the)f(latest)i(v)m(ersion)f(of)f(the)h(lib)s(cf)f
+(tarball)h(at)g(the)f(lib)s(cf)g(ftp)g(site:)37 b
+(ftp://ftp.unidata.ucar.edu/pub/lib)s(cf)275 1156 y(Unpac)m(k)30
+b(the)h(tarball,)g(and)f(run:)390 1290 y Fc(./configure)45
+b(--with-netcdf=/my/netcd)o(f)d(--prefix=/my/libcf)h(&&)k(make)g(check)
+f(install)g(>)h(output.txt)275 1425 y Fi(Where)32 b(/m)m(y/netcdf)i(is)
+f(the)f(ro)s(ot)h(install)h(directory)f(of)f(the)h(netCDF)g(library)f
+(y)m(ou)h(w)m(an)m(t)h(to)f(use,)150 1534 y(and)28 b(/m)m(y/lib)s(cf)i
+(is)e(the)h(ro)s(ot)g(directory)h(where)e(y)m(ou)h(w)m(an)m(t)g(lib)s
+(cf)g(installed.)41 b(\(They)28 b(ma)m(y)i(b)s(e)e(the)h(same)150
+1644 y(directory)-8 b(.\))275 1778 y(If)22 b(y)m(ou)i(wish)f(to)h(use)f
+(netCDF-4,)k(y)m(ou)c(m)m(ust)h(also)g(ha)m(v)m(e)h(HDF5)f(and)f(libz,)
+j(the)d(compression)h(library)-8 b(,)150 1888 y(installed.)41
+b(In)30 b(this)g(case,)i(con\014gure)e(lib)s(cf)g(lik)m(e)i(this:)390
+2022 y Fc(./configure)45 b(--with-netcdf=/s/n4_new)o(1/in)o(stal)o(l)d
+(--enable-netcdf-4)h(--with-hdf5=/home/ed/lo)o(cal/)o(s)f(&&)47
+b(make)g(check)f(install)g(>)h(output.txt)275 2157 y
+Fi(If)78 b(the)i(build)e(do)s(es)h(not)h(w)m(ork)f(for)h(y)m(ou,)92
+b(please)80 b(email)g(lib)s(cf)f(supp)s(ort:)137 b(supp)s(ort-)150
+2267 y(lib)s(cf)p Fc(@)p Fi(unidata.ucar.edu.)91 b(Please)48
+b(send)f(the)g(*complete*)j(output)d(of)h(the)f(con\014gure)g(and)g
+(build)150 2376 y(output,)29 b(in)f(ASCI)s(I)g(\(the)h(output.txt)g
+(\014le)g(pro)s(duced)e(b)m(y)i(the)g(ab)s(o)m(v)m(e)h(build)d
+(commands\),)j(and)e(the)h(\014le)150 2486 y(con\014g.log,)j(whic)m(h)e
+(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
+%%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
+(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
+4 v 41 w(def)p 2241 997 V 39 w(\014le,)h(so)g(need)f(not)h(b)s(e)e
+(called)j(b)m(y)e(the)h(user)150 1106 y(if)g(nccf)p 398
+1106 V 40 w(def)p 557 1106 V 40 w(\014le)h(is)f(b)s(eing)g(called.)150
+1363 y Fh(Usage)533 1522 y Fc(int)47 b(nccf_def_convention\(int)42
+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
+(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
+3030 y(global)c(\\Con)m(v)m(en)m(tions")h(attribute.)55
+b(It)35 b(do)s(es)g(not)g(lo)s(ok)g(at)h(\014le)f(metadata)i(to)e
+(ensure)f(that)i(this)f(is)g(a)150 3139 y(w)m(ell-formed)c(CF)f
+(\014le.)41 b(It)31 b(only)f(tells)i(whether)d(the)i(\014le)f(claims)i
+(to)f(b)s(e)f(a)g(CF)h(\014le.)150 3396 y Fh(Usage)533
+3555 y Fc(int)47 b(nccf_inq_convention\(int)42 b(ncid,)k(int)h
+(*cf_convention\);)150 3739 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h
+(\014le.)150 3914 y Fc(cf_conventions)630 4024 y Fi(If)36
+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
+(is)g(written)g(there)g(if)g(this)g(\014le)f(claims)i(to)630
+4133 y(follo)m(w)32 b(CF)e(1.0)h(con)m(v)m(en)m(tions,)i(a)e(0)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
+(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
+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
+y Fi(If)j(non-NULL,)g(this)g(text)h(string)f(will)g(b)s(e)f(written)i
+(as)f(the)g(CF-recommended)g(\\institu-)630 1648 y(tion")j(attribute.)
+150 1809 y Fc(source)192 b Fi(If)27 b(non-NULL,)h(this)f(text)i(string)
+e(will)h(b)s(e)f(written)h(as)g(the)f(CF-recommended)h(\\source")630
+1918 y(attribute.)150 2079 y Fc(comment)144 b Fi(If)36
+b(non-NULL,)h(this)g(text)h(string)f(will)g(b)s(e)f(written)h(as)g(the)
+g(CF-recommended)g(\\com-)630 2188 y(men)m(t")31 b(attribute.)150
+2349 y Fc(references)630 2458 y Fi(If)k(non-NULL,)g(this)g(text)h
+(string)f(will)h(b)s(e)e(written)i(as)f(the)g(CF-recommended)g
+(\\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)
+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
+3748 y(Recall)k(that)g(in)f(C,)f(strlens)h(do)g(not)h(include)e(the)i
+(n)m(ull)f(terminator.)52 b(T)-8 b(o)35 b(get)g(the)f(lengths)g(b)s
+(efore)150 3857 y(the)d(strings)f(\(in)h(order)f(to)h(allo)s(cated\))i
+(pass)e(NULL)f(for)g(an)m(y)h(or)g(all)g(strings)g(and)f(the)h(lengths)
+g(will)g(b)s(e)150 3967 y(returned.)40 b(Then)29 b(call)j(the)e
+(function)g(again)i(after)f(allo)s(cating)h(memory)-8
+b(.)275 4102 y(The)29 b(CF)i(v)m(ersion)g(is)f(guaran)m(teed)h(to)g(b)s
+(e)f(less)h(than)f(NC)p 2239 4102 28 4 v 40 w(MAX)p 2498
+4102 V 41 w(NAME.)275 4238 y(An)m(y)g(of)h(these)f(p)s(oin)m(ter)h
+(argumen)m(ts)f(ma)m(y)h(b)s(e)f(NULL,)h(in)f(whic)m(h)g(case)h(it)g
+(will)g(b)s(e)f(ignored.)150 4472 y Fh(Usage)390 4631
+y Fc(int)47 b(nccf_inq_file\(int)c(ncid,)j(size_t)g(*title_lenp,)f
+(char)i(*title,)1249 4741 y(size_t)f(*history_lenp,)e(char)j(*history,)
+1249 4850 y(size_t)f(*institution_lenp,)d(char)k(*institution,)1249
+4960 y(size_t)f(*source_lenp,)e(char)j(*source,)1249
+5070 y(size_t)f(*comment_lenp,)e(char)j(*comment,)1249
+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
+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
+(whic)m(h,)h(if)e(not)h(NULL,)g(will)g(get)g(the)g(title)h(string.)38
+b(Memory)23 b(m)m(ust)630 685 y(b)s(e)31 b(allo)s(cated)j(b)s(efore)d
+(this)h(function)g(is)g(called.)46 b(Call)32 b(this)g(function)g(with)f
+(a)h(NULL)g(for)630 794 y(this)e(parameter)h(to)g(get)h(the)e(size)i
+(\014rst.)150 961 y Fc(history_lenp)630 1071 y Fi(P)m(oin)m(ter)25
+b(to)f(size)p 1194 1071 V 41 w(t)f(whic)m(h,)i(if)e(not)h(NULL,)f(will)
+h(get)g(the)g(length)g(of)f(the)h(history)f(attribute.)150
+1237 y Fc(history)144 b Fi(P)m(oin)m(ter)32 b(to)g(c)m(har)f(arra)m(y)g
+(whic)m(h,)g(if)g(not)g(NULL,)g(will)g(get)h(the)g(history)e(string.)42
+b(Memory)630 1347 y(m)m(ust)25 b(b)s(e)g(allo)s(cated)i(b)s(efore)e
+(this)g(function)f(is)i(called.)40 b(Call)26 b(this)f(function)g(with)f
+(a)i(NULL)630 1456 y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i
+(\014rst.)150 1623 y Fc(institution_lenp)630 1733 y Fi(P)m(oin)m(ter)45
+b(to)f(size)p 1234 1733 V 41 w(t)g(whic)m(h,)i(if)e(not)f(NULL,)h(will)
+g(get)h(the)e(length)h(of)g(the)f(institution)630 1842
+y(attribute.)150 2009 y Fc(institution)630 2119 y Fi(P)m(oin)m(ter)29
+b(to)f(c)m(har)h(arra)m(y)f(whic)m(h,)g(if)g(not)g(NULL,)f(will)h(get)h
+(the)f(institution)g(string.)40 b(Mem-)630 2228 y(ory)34
+b(m)m(ust)g(b)s(e)g(allo)s(cated)i(b)s(efore)e(this)g(function)g(is)g
+(called.)53 b(Call)35 b(this)f(function)g(with)g(a)630
+2338 y(NULL)c(for)g(this)h(parameter)g(to)g(get)g(the)g(size)g
+(\014rst.)150 2504 y Fc(source_lenp)630 2614 y Fi(P)m(oin)m(ter)c(to)f
+(size)p 1198 2614 V 41 w(t)f(whic)m(h,)i(if)e(not)g(NULL,)h(will)g(get)
+g(the)g(length)f(of)h(the)f(source)h(attribute.)150 2781
+y Fc(source)192 b Fi(P)m(oin)m(ter)34 b(to)f(c)m(har)g(arra)m(y)h(whic)
+m(h,)f(if)g(not)f(NULL,)h(will)g(get)h(the)f(source)g(string.)47
+b(Memory)630 2890 y(m)m(ust)25 b(b)s(e)g(allo)s(cated)i(b)s(efore)e
+(this)g(function)f(is)i(called.)40 b(Call)26 b(this)f(function)g(with)f
+(a)i(NULL)630 3000 y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i
+(\014rst.)150 3167 y Fc(comment_lenp)630 3276 y Fi(P)m(oin)m(ter)38
+b(to)f(size)p 1220 3276 V 41 w(t)f(whic)m(h,)i(if)f(not)f(NULL,)h(will)
+f(get)i(the)f(length)f(of)h(the)f(commen)m(t)i(at-)630
+3386 y(tribute.)150 3552 y Fc(comment)144 b Fi(P)m(oin)m(ter)25
+b(to)g(c)m(har)f(arra)m(y)h(whic)m(h,)g(if)f(not)g(NULL,)g(will)h(get)g
+(the)f(commen)m(t)h(string.)38 b(Memory)630 3662 y(m)m(ust)25
+b(b)s(e)g(allo)s(cated)i(b)s(efore)e(this)g(function)f(is)i(called.)40
+b(Call)26 b(this)f(function)g(with)f(a)i(NULL)630 3772
+y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i(\014rst.)150
+3938 y Fc(references_lenp)630 4048 y Fi(P)m(oin)m(ter)47
+b(to)f(size)p 1238 4048 V 41 w(t)g(whic)m(h,)j(if)d(not)f(NULL,)h(will)
+g(get)h(the)e(length)h(of)g(the)g(references)630 4157
+y(attribute.)150 4324 y Fc(references)630 4434 y Fi(P)m(oin)m(ter)23
+b(to)g(c)m(har)f(arra)m(y)g(whic)m(h,)i(if)d(not)h(NULL,)g(will)h(get)g
+(the)f(references)g(string.)37 b(Memory)630 4543 y(m)m(ust)25
+b(b)s(e)g(allo)s(cated)i(b)s(efore)e(this)g(function)f(is)i(called.)40
+b(Call)26 b(this)f(function)g(with)f(a)i(NULL)630 4653
+y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i(\014rst.)150
+4896 y Fh(Return)45 b(Co)t(des)150 5056 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 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
+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
+y(attribute)e(if)f(it)h(do)s(esn't)f(already)h(exist.)150
+800 y Fh(Usage)390 960 y Fc(int)47 b(nccf_add_history\(int)42
+b(ncid,)47 b(const)f(char)h(*history\);)150 1119 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 1279 y Fc(history)144
+b Fi(The)30 b(string)g(to)h(app)s(end)e(to)i(the)g(history)f
+(attribute.)150 1511 y Fh(Return)45 b(Co)t(des)150 1670
+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
+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
+(*units,)1345 1157 y(const)f(char)h(*long_name,)d(const)j(char)f
+(*standard_name,)1345 1267 y(int)g(ncoord_vars,)f(int)i
+(*coord_varids\);)150 1426 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h
+(\014le.)150 1586 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.)150
+1745 y Fc(units)240 b Fi(If)32 b(non-NULL,)g(this)g(text)h(string)f
+(will)h(b)s(e)e(written)i(as)f(the)g(CF-recommended)h(\\units")630
+1855 y(attribute.)150 2014 y Fc(long_name)630 2124 y
+Fi(If)64 b(non-NULL,)g(this)g(text)h(string)g(will)f(b)s(e)g(written)g
+(as)h(the)f(CF-recommended)630 2233 y(\\long)p 847 2233
+28 4 v 41 w(name")31 b(attribute.)150 2393 y Fc(standard_name)630
+2502 y Fi(If)36 b(non-NULL,)g(this)g(text)i(string)e(will)h(b)s(e)e
+(written)i(as)f(the)h(CF-recommended)f(\\stan-)630 2612
+y(dard)p 819 2612 V 39 w(name")31 b(attribute.)150 2771
+y Fc(ncoord_vars)630 2881 y Fi(Num)m(b)s(er)e(of)i(co)s(ordinate)g(v)-5
+b(ariables)31 b(for)f(this)g(v)-5 b(ariable.)150 3040
+y Fc(coord_varids)630 3150 y Fi(The)30 b(v)-5 b(ariable)31
+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
+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
+(attributes)g(from)f(a)h(v)-5 b(ariable.)150 4423 y Fh(Usage)390
+4583 y Fc(int)47 b(nccf_inq_var\(int)c(ncid,)k(int)g(varid,)f(size_t)g
+(*units_lenp,)e(char)j(*units,)1201 4692 y(size_t)f(*long_name_lenp,)e
+(char)i(*long_name,)1201 4802 y(size_t)g(*standard_name_lenp,)d(char)j
+(*standard_name,)1201 4912 y(int)h(*ncoord_vars,)d(int)j
+(*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
+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)
+g(the)h(units)e(attribute.)150 564 y Fc(units)240 b Fi(P)m(oin)m(ter)29
+b(to)f(c)m(har)f(arra)m(y)h(whic)m(h,)g(if)g(not)f(NULL,)h(will)f(get)i
+(the)e(long)p 2953 564 V 41 w(name)h(string.)39 b(Mem-)630
+674 y(ory)34 b(m)m(ust)g(b)s(e)g(allo)s(cated)i(b)s(efore)e(this)g
+(function)g(is)g(called.)53 b(Call)35 b(this)f(function)g(with)g(a)630
+783 y(NULL)c(for)g(this)h(parameter)g(to)g(get)g(the)g(size)g(\014rst.)
+150 939 y Fc(long_name_lenp)630 1048 y Fi(P)m(oin)m(ter)44
+b(to)g(size)p 1233 1048 V 41 w(t)g(whic)m(h,)i(if)d(not)h(NULL,)f(will)
+g(get)i(the)e(length)h(of)f(the)g(long)p 3503 1048 V
+41 w(name)630 1158 y(attribute.)150 1313 y Fc(long_name)630
+1423 y Fi(P)m(oin)m(ter)29 b(to)f(c)m(har)f(arra)m(y)h(whic)m(h,)g(if)g
+(not)f(NULL,)h(will)f(get)i(the)e(long)p 2953 1423 V
+41 w(name)h(string.)39 b(Mem-)630 1532 y(ory)34 b(m)m(ust)g(b)s(e)g
+(allo)s(cated)i(b)s(efore)e(this)g(function)g(is)g(called.)53
+b(Call)35 b(this)f(function)g(with)g(a)630 1642 y(NULL)c(for)g(this)h
+(parameter)g(to)g(get)g(the)g(size)g(\014rst.)150 1798
+y Fc(standard_name_lenp)630 1907 y Fi(P)m(oin)m(ter)g(to)f(size)p
+1206 1907 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(standard)p 3505 1907 V 39 w(name)630
+2017 y(attribute.)150 2172 y Fc(standard_name)630 2282
+y Fi(P)m(oin)m(ter)36 b(to)f(c)m(har)g(arra)m(y)g(whic)m(h,)h(if)e(not)
+h(NULL,)g(will)f(get)i(the)f(standard)p 3217 2282 V 39
+w(name)g(string.)630 2391 y(Memory)25 b(m)m(ust)f(b)s(e)g(allo)s(cated)
+j(b)s(efore)d(this)g(function)g(is)h(called.)40 b(Call)25
+b(this)f(function)g(with)630 2501 y(a)31 b(NULL)f(for)g(this)g
+(parameter)h(to)g(get)h(the)f(size)g(\014rst.)150 2656
+y Fc(ncoord_vars)630 2766 y Fi(P)m(oin)m(ter)36 b(to)g(an)e(in)m
+(teger,)k(whic)m(h,)d(if)g(non-NULL,)g(will)g(get)h(the)f(n)m(um)m(b)s
+(er)e(of)i(co)s(ordinate)630 2876 y(v)-5 b(ariables)31
+b(iden)m(ti\014ed)f(in)h(the)f(\\co)s(ordinates")i(attribute.)150
+3031 y Fc(coord_varids)630 3141 y Fi(P)m(oin)m(ter)46
+b(to)f(an)g(arra)m(y)g(of)g(in)m(teger,)50 b(whic)m(h,)e(if)d
+(non-NULL,)g(will)g(b)s(e)f(\014lled)g(with)h(the)630
+3250 y(v)-5 b(ariable)31 b(IDs)g(of)f(the)h(v)-5 b(ariables)31
+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
+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
+28 4 v 40 w(def)p 474 4399 V 40 w(notes)275 4531 y(This)29
+b(function)h(sets)h(the)g(\\\014ll)p 1325 4531 V 40 w(v)-5
+b(alue",)32 b(\\v)-5 b(alid)p 1905 4531 V 40 w(min",)31
+b(and)f(\\v)-5 b(alid)p 2609 4531 V 41 w(max")30 b(attributes.)150
+4760 y Fh(Usage)390 4919 y Fc(int)47 b(nccf_def_var_missing\(int)41
+b(ncid,)46 b(int)h(varid,)f(const)h(void)f(*fill_valuep,)1726
+5029 y(const)h(void)f(*valid_minp,)f(const)h(void)h(*valid_maxp\);)150
+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
+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
+(\014ll)p 1508 518 28 4 v 40 w(v)-5 b(alue)31 b(for)f(the)h(data.)150
+669 y Fc(valid_minp)630 778 y Fi(If)k(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 888 y(will)g(b)s(e)f(written)h
+(as)g(the)g(\\v)-5 b(alid)p 1779 888 V 41 w(min")35 b(attribute.)58
+b(If)35 b(this)h(parameter)g(is)g(non-NULL,)630 998 y(v)-5
+b(alid)p 825 998 V 40 w(max)31 b(m)m(ust)f(also)h(b)s(e)f(pro)m(vided.)
+150 1148 y Fc(valid_maxp)630 1258 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 1368 y(will)f(b)s(e)e
+(written)i(as)g(the)f(\\v)-5 b(alid)p 1772 1368 V 41
+w(max")35 b(attribute.)53 b(If)34 b(this)h(parameter)g(is)f(non-NULL,)
+630 1477 y(v)-5 b(alid)p 825 1477 V 40 w(min)30 b(m)m(ust)g(also)i(b)s
+(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)
+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
+(information.)42 b(If)31 b(the)g(attributes)g(are)g(not)g(there,)g
+(then)150 2724 y(pro)m(vide)f(the)h(v)-5 b(alid)31 b(data)g(an)m(yw)m
+(a)m(y)-8 b(,)32 b(based)e(on)h(netCDF)g(defaults.)150
+2947 y Fh(Usage)390 3107 y Fc(int)47 b(nccf_inq_var_missing\(int)41
+b(ncid,)46 b(int)h(varid,)f(void)h(*fill_valuep,)1726
+3216 y(void)g(*valid_minp,)d(void)j(*valid_maxp\);)150
+3367 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+3518 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 3669 y Fc(fill_valuep)630 3778 y
+Fi(If)28 b(this)h(is)f(not)h(NULL,)g(the)g(\014ll)g(v)-5
+b(alue)29 b(of)g(the)g(v)-5 b(ariable)29 b(will)g(b)s(e)f(written)h(at)
+g(this)g(address)630 3888 y(b)m(y)34 b(nccf)p 925 3888
+28 4 v 40 w(inq)p 1089 3888 V 40 w(v)-5 b(ar)p 1253 3888
+V 40 w(missing.)52 b(If)34 b(the)h(\014ll)f(v)-5 b(alue)35
+b(w)m(as)f(not)h(de\014ned)e(for)h(the)g(v)-5 b(ariable,)37
+b(the)630 3998 y(netCDF)31 b(default)g(v)-5 b(alue)30
+b(will)h(b)s(e)f(used.)150 4148 y Fc(valid_minp)630 4258
+y Fi(If)44 b(this)g(is)g(not)h(NULL,)f(the)h(v)-5 b(alid)p
+1892 4258 V 40 w(min)44 b(v)-5 b(alue)45 b(of)f(the)h(v)-5
+b(ariable)45 b(will)f(b)s(e)g(written)g(at)630 4368 y(this)33
+b(address)f(b)m(y)g(nccf)p 1430 4368 V 41 w(inq)p 1595
+4368 V 39 w(v)-5 b(ar)p 1758 4368 V 40 w(missing.)48
+b(If)33 b(the)g(v)-5 b(alid)p 2607 4368 V 40 w(min)32
+b(w)m(as)h(not)h(de\014ned)d(for)i(the)630 4477 y(v)-5
+b(ariable,)31 b(the)g(netCDF)g(default)g(v)-5 b(alue)30
+b(will)h(b)s(e)f(used.)150 4628 y Fc(valid_maxp)630 4738
+y Fi(If)g(this)g(is)h(not)f(NULL,)h(the)f(v)-5 b(alid)p
+1808 4738 V 41 w(max)30 b(v)-5 b(alue)31 b(of)f(the)h(v)-5
+b(ariable)31 b(will)g(b)s(e)f(written)g(at)h(this)630
+4847 y(address)25 b(b)m(y)h(nccf)p 1237 4847 V 40 w(inq)p
+1401 4847 V 40 w(v)-5 b(ar)p 1565 4847 V 40 w(missing.)39
+b(If)26 b(the)g(v)-5 b(alid)p 2391 4847 V 41 w(max)26
+b(v)-5 b(alue)27 b(w)m(as)f(not)h(de\014ned)e(for)h(the)630
+4957 y(v)-5 b(ariable,)31 b(the)g(netCDF)g(default)g(v)-5
+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
+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)
+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
+(for)g(either)g(a)f(v)-5 b(ariable,)39 b(or)e(an)f(en)m(tire)i(\014le.)
+150 1072 y(These)44 b(text)g(attributes,)k(\\institution,")h
+(\\source,")f(\\commen)m(t,")i(and)43 b(\\references")i(are)f(recom-)
+150 1182 y(mended)29 b(b)m(y)i(the)f(CF)h(Metadata)h(Con)m(v)m(en)m
+(tion.)150 1410 y Fh(Usage)390 1569 y Fc(int)47 b(nccf_def_notes\(int)c
+(ncid,)j(int)h(varid,)f(char)h(*units,)f(char)g(*long_name,)1297
+1679 y(char)g(*standard_name,)e(char)j(*institution,)1297
+1789 y(char)f(*source,)g(char)h(*comment,)e(char)i(*references\);)150
+1943 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+2098 y Fc(varid)240 b Fi(The)36 b(v)-5 b(arid)36 b(of)g(the)h(netCDF)f
+(v)-5 b(ariable)37 b(b)s(eing)f(describ)s(ed.)57 b(Use)37
+b(NC)p 3061 2098 V 40 w(GLOBAL)f(if)h(y)m(ou)630 2208
+y(wish)30 b(these)g(attributes)h(to)g(apply)f(to)i(the)e(en)m(tire)h
+(\014le.)150 2363 y Fc(institution)630 2472 y Fi(If)d(non-NULL,)g(this)
+g(text)h(string)f(will)g(b)s(e)f(written)i(as)f(the)g(CF-recommended)g
+(\\institu-)630 2582 y(tion")j(attribute.)150 2737 y
+Fc(source)192 b Fi(If)27 b(non-NULL,)h(this)f(text)i(string)e(will)h(b)
+s(e)f(written)h(as)g(the)f(CF-recommended)h(\\source")630
+2846 y(attribute.)150 3001 y Fc(comment)144 b Fi(If)36
+b(non-NULL,)h(this)g(text)h(string)f(will)g(b)s(e)f(written)h(as)g(the)
+g(CF-recommended)g(\\com-)630 3111 y(men)m(t")31 b(attribute.)150
+3265 y Fc(references)630 3375 y Fi(If)k(non-NULL,)g(this)g(text)h
+(string)f(will)h(b)s(e)e(written)i(as)f(the)g(CF-recommended)g
+(\\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
+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
+(v)-5 b(ariable.)150 4742 y Fh(Usage)390 4902 y Fc(int)47
+b(nccf_inq_notes\(int)c(ncid,)j(int)h(varid,)1297 5011
+y(size_t)f(*institution_lenp,)d(char)j(*institution,)1297
+5121 y(size_t)g(*source_lenp,)e(char)j(*source,)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
+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
+b(to)f(size)p 1234 706 28 4 v 41 w(t)g(whic)m(h,)i(if)e(not)f(NULL,)h
+(will)g(get)h(the)e(length)h(of)g(the)f(institution)630
+815 y(attribute.)150 964 y Fc(institution)630 1073 y
+Fi(P)m(oin)m(ter)29 b(to)f(c)m(har)h(arra)m(y)f(whic)m(h,)g(if)g(not)g
+(NULL,)f(will)h(get)h(the)f(institution)g(string.)40
+b(Mem-)630 1183 y(ory)34 b(m)m(ust)g(b)s(e)g(allo)s(cated)i(b)s(efore)e
+(this)g(function)g(is)g(called.)53 b(Call)35 b(this)f(function)g(with)g
+(a)630 1292 y(NULL)c(for)g(this)h(parameter)g(to)g(get)g(the)g(size)g
+(\014rst.)150 1441 y Fc(source_lenp)630 1551 y Fi(P)m(oin)m(ter)c(to)f
+(size)p 1198 1551 V 41 w(t)f(whic)m(h,)i(if)e(not)g(NULL,)h(will)g(get)
+g(the)g(length)f(of)h(the)f(source)h(attribute.)150 1699
+y Fc(source)192 b Fi(P)m(oin)m(ter)34 b(to)f(c)m(har)g(arra)m(y)h(whic)
+m(h,)f(if)g(not)f(NULL,)h(will)g(get)h(the)f(source)g(string.)47
+b(Memory)630 1809 y(m)m(ust)25 b(b)s(e)g(allo)s(cated)i(b)s(efore)e
+(this)g(function)f(is)i(called.)40 b(Call)26 b(this)f(function)g(with)f
+(a)i(NULL)630 1918 y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i
+(\014rst.)150 2067 y Fc(comment_lenp)630 2177 y Fi(P)m(oin)m(ter)38
+b(to)f(size)p 1220 2177 V 41 w(t)f(whic)m(h,)i(if)f(not)f(NULL,)h(will)
+f(get)i(the)f(length)f(of)h(the)f(commen)m(t)i(at-)630
+2286 y(tribute.)150 2435 y Fc(comment)144 b Fi(P)m(oin)m(ter)25
+b(to)g(c)m(har)f(arra)m(y)h(whic)m(h,)g(if)f(not)g(NULL,)g(will)h(get)g
+(the)f(commen)m(t)h(string.)38 b(Memory)630 2544 y(m)m(ust)25
+b(b)s(e)g(allo)s(cated)i(b)s(efore)e(this)g(function)f(is)i(called.)40
+b(Call)26 b(this)f(function)g(with)f(a)i(NULL)630 2654
+y(for)k(this)g(parameter)h(to)g(get)h(the)e(size)i(\014rst.)150
+2802 y Fc(references_lenp)630 2912 y Fi(P)m(oin)m(ter)47
+b(to)f(size)p 1238 2912 V 41 w(t)g(whic)m(h,)j(if)d(not)f(NULL,)h(will)
+g(get)h(the)e(length)h(of)g(the)g(references)630 3022
+y(attribute.)150 3170 y Fc(references)630 3280 y Fi(P)m(oin)m(ter)23
+b(to)g(c)m(har)f(arra)m(y)g(whic)m(h,)i(if)d(not)h(NULL,)g(will)h(get)g
+(the)f(references)g(string.)37 b(Memory)630 3389 y(m)m(ust)25
+b(b)s(e)g(allo)s(cated)i(b)s(efore)e(this)g(function)f(is)i(called.)40
+b(Call)26 b(this)f(function)g(with)f(a)i(NULL)630 3499
+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
+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
+b(ariable)32 b(and)e(dimension)h(with)g(all)h(the)f(CF)g(recommended)g
+(attribute)h(acces-)150 4740 y(sories)f(for)f(latitude.)150
+4961 y Fh(Usage)390 5121 y Fc(int)47 b(nccf_def_latitude\(int)42
+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
+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
+636 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.)150 805 y Fc(formula_terms)630
+914 y Fi(If)33 b(non-NULL,)g(a)g(string)g(whic)m(h)g(will)g(b)s(e)f
+(written)i(as)f(the)g(\\form)m(ula)p 3060 914 28 4 v
+41 w(terms")g(attribute)630 1024 y(on)d(the)h(co)s(ordinate)g(v)-5
+b(ariable.)150 1192 y Fc(lat_dimidp)630 1302 y Fi(If)45
+b(non-NULL,)g(nccf)p 1398 1302 V 40 w(def)p 1557 1302
+V 39 w(latitude)h(will)g(write)f(the)g(dimension)g(ID)g(of)g(the)g
+(netCDF)630 1412 y(dimension)30 b(for)g(the)h(latitude)g(here.)150
+1580 y Fc(lat_varidp)630 1690 y Fi(If)f(non-NULL,)h(nccf)p
+1369 1690 V 40 w(def)p 1528 1690 V 40 w(latitude)h(will)f(write)g(the)g
+(v)-5 b(ariable)32 b(ID)f(of)g(the)g(netCDF)g(co)s(or-)630
+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
+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
+3134 y(Inquire)29 b(ab)s(out)h(a)h(latitude)g(dimension)f(and)g(co)s
+(ordinate)h(v)-5 b(ariable.)150 3380 y Fh(Usage)390 3539
+y Fc(int)47 b(nccf_inq_latitude\(int)42 b(ncid,)k(size_t)g(*lenp,)g
+(nc_type)g(*xtypep,)1583 3649 y(size_t)g(*ft_lenp,)g(char)g
+(*formula_terms,)1583 3758 y(int)h(*lat_dimidp,)e(int)h(*lat_varidp\);)
+150 3931 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+4100 y Fc(lenp)288 b Fi(If)45 b(non-NULL,)g(the)g(length)h(of)f(the)g
+(latitude)h(dimension)f(will)g(b)s(e)g(written)g(here)g(b)m(y)630
+4210 y(nccf)p 795 4210 V 40 w(inq)p 959 4210 V 40 w(latitude.)150
+4378 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h
+(the)f(co)s(ordinate)i(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i
+(here.)150 4547 y Fc(ft_lenp)144 b Fi(If)32 b(non-NULL,)g(the)g(length)
+g(of)h(the)f(v)-5 b(alue)33 b(of)f(the)g(\\form)m(ula)p
+2762 4547 V 41 w(terms")g(attribute)h(will)g(b)s(e)630
+4656 y(written)h(here)f(b)m(y)h(ft)p 1351 4656 V 40 w(lenp.)50
+b(If)34 b(there)f(is)h(no)g(\\form)m(ula)p 2536 4656
+V 40 w(terms")h(attribute,)g(zero)g(will)f(b)s(e)630
+4766 y(written.)150 4935 y Fc(lat_dimidp)630 5044 y Fi(If)c(non-NULL,)g
+(the)h(dimid)e(of)i(the)f(latitude)i(dimension)e(will)g(b)s(e)g
+(written)h(here.)150 5213 y Fc(lat_varidp)630 5322 y
+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
+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
+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
+(v)-5 b(ariable)32 b(and)e(dimension)h(with)g(all)h(the)f(CF)g
+(recommended)g(attribute)h(acces-)150 1402 y(sories)f(for)f(longitude.)
+150 1685 y Fh(Usage)390 1844 y Fc(int)47 b(nccf_def_longitude\(int)42
+b(ncid,)k(size_t)g(len,)h(nc_type)f(xtype,)1583 1954
+y(const)h(char)f(*formula_terms,)e(int)j(*lon_dimidp,)1583
+2063 y(int)g(*lon_varidp\);)150 2273 y(ncid)288 b Fi(The)30
+b(ncid)g(of)g(the)h(\014le.)150 2466 y Fc(len)336 b Fi(The)30
+b(length)h(of)f(this)g(co)s(ordinate)i(dimension.)150
+2659 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.)150 2852 y Fc(formula_terms)630
+2962 y Fi(If)33 b(non-NULL,)g(a)g(string)g(whic)m(h)g(will)g(b)s(e)f
+(written)i(as)f(the)g(\\form)m(ula)p 3060 2962 28 4 v
+41 w(terms")g(attribute)630 3071 y(on)d(the)h(co)s(ordinate)g(v)-5
+b(ariable.)150 3264 y Fc(lon_dimidp)630 3374 y Fi(If)39
+b(non-NULL,)f(nccf)p 1385 3374 V 41 w(def)p 1545 3374
+V 39 w(longitude)i(will)f(write)g(the)g(dimension)g(ID)g(of)g(the)g
+(netCDF)630 3484 y(dimension)30 b(for)g(the)h(longitude)f(here.)150
+3677 y Fc(lon_varidp)630 3786 y Fi(If)i(non-NULL,)h(nccf)p
+1373 3786 V 40 w(def)p 1532 3786 V 40 w(longitude)h(will)f(write)g(the)
+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
+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
+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
+(*formula_terms,)1583 677 y(int)h(*lon_dimidp,)e(int)h(*lon_varidp\);)
+150 829 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+981 y Fc(lenp)288 b Fi(If)40 b(non-NULL,)g(the)g(length)g(of)h(the)f
+(longitude)h(dimension)e(will)i(b)s(e)e(written)h(here)g(b)m(y)630
+1091 y(nccf)p 795 1091 28 4 v 40 w(inq)p 959 1091 V 40
+w(longitude.)150 1243 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)
+m(yp)s(e)f(of)h(the)f(co)s(ordinate)i(v)-5 b(ariable)31
+b(will)g(b)s(e)e(written)i(here.)150 1395 y Fc(ft_lenp)144
+b Fi(If)32 b(non-NULL,)g(the)g(length)g(of)h(the)f(v)-5
+b(alue)33 b(of)f(the)g(\\form)m(ula)p 2762 1395 V 41
+w(terms")g(attribute)h(will)g(b)s(e)630 1504 y(written)h(here)f(b)m(y)h
+(ft)p 1351 1504 V 40 w(lenp.)50 b(If)34 b(there)f(is)h(no)g(\\form)m
+(ula)p 2536 1504 V 40 w(terms")h(attribute,)g(zero)g(will)f(b)s(e)630
+1614 y(written.)150 1766 y Fc(lon_dimidp)630 1876 y Fi(If)c(non-NULL,)g
+(the)h(dimid)e(of)i(the)f(longitude)h(dimension)f(will)h(b)s(e)f
+(written)g(here.)150 2027 y Fc(lon_varidp)630 2137 y
+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
+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
+3277 y Fi(De\014ne)31 b(a)h(co)s(ordinate)g(v)-5 b(ariable)32
+b(and)e(dimension)h(with)g(all)h(the)f(CF)g(recommended)g(attribute)h
+(acces-)150 3386 y(sories)f(for)f(a)h(v)m(ertical)h(lev)m(el.)150
+3611 y Fh(Usage)390 3771 y Fc(int)47 b(nccf_def_lvl\(int)c(ncid,)k
+(const)f(char)h(*name,)f(size_t)g(len,)g(nc_type)g(xtype,)1201
+3880 y(const)h(char)f(*units,)g(int)h(positive_up,)e(const)h(char)h
+(*standard_name,)1201 3990 y(const)g(char)f(*long_name,)f(const)h(char)
+h(*formula_terms,)1201 4100 y(int)g(*lvl_dimidp,)e(int)i
+(*lvl_varidp\);)150 4252 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h
+(\014le.)150 4403 y Fc(name)288 b Fi(The)30 b(name)g(of)h(the)f(co)s
+(ordinate)i(dimension)d(and)h(v)-5 b(ariable.)150 4555
+y Fc(len)336 b Fi(The)30 b(length)h(of)f(this)g(co)s(ordinate)i
+(dimension)d(and)h(v)-5 b(ariable.)150 4707 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.)150 4859 y Fc(units)240 b Fi(If)39 b(non-NULL,)g(a)h(string)
+f(whic)m(h)g(will)g(b)s(e)g(written)g(as)h(the)f(\\units")h(attribute)g
+(on)f(the)630 4969 y(co)s(ordinate)31 b(v)-5 b(ariable.)150
+5121 y Fc(positive_up)630 5230 y Fi(Set)31 b(to)h(0)f(and)g(the)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
+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
+b(ariable.)150 670 y Fc(long_name)630 780 y Fi(If)34
+b(non-NULL,)h(a)g(string)f(whic)m(h)g(will)h(b)s(e)f(written)h(as)g
+(the)g(\\long)p 2939 780 V 41 w(name")g(attribute)g(on)630
+889 y(the)c(co)s(ordinate)g(v)-5 b(ariable.)150 1042
+y Fc(lon_dimidp)630 1151 y Fi(If)23 b(non-NULL,)h(nccf)p
+1355 1151 V 40 w(def)p 1514 1151 V 40 w(lvl)g(will)g(write)g(the)g
+(dimension)f(ID)g(of)h(the)g(netCDF)h(dimension)630 1261
+y(for)30 b(the)h(lev)m(el)h(here.)150 1413 y Fc(lon_varidp)630
+1523 y Fi(If)e(non-NULL,)g(nccf)p 1368 1523 V 40 w(def)p
+1527 1523 V 40 w(lvl)g(will)h(write)f(the)g(v)-5 b(ariable)31
+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
+(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
+(dimension)e(and)f(co)s(ordinate)j(v)-5 b(ariable.)150
+3129 y Fh(Usage)390 3288 y Fc(int)47 b(nccf_inq_lvl\(int)c(ncid,)k
+(char)f(*name,)g(size_t)g(*lenp,)h(nc_type)e(*xtypep,)1201
+3398 y(size_t)h(*ft_lenp,)g(char)g(*formula_terms,)e(int)j
+(*positive_upp,)1201 3507 y(int)g(*lvl_dimidp,)e(int)i(*lvl_varidp\);)
+150 3660 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+3812 y Fc(name)288 b Fi(If)34 b(non-NULL,)h(the)g(name)g(of)g(this)f(v)
+m(ertical)j(lev)m(el)g(dimension)d(\(and)h(v)-5 b(ariable\))35
+b(will)h(b)s(e)630 3921 y(written)30 b(here.)150 4074
+y Fc(lenp)288 b Fi(If)56 b(non-NULL,)g(the)g(length)g(of)h(the)f(lev)m
+(el)i(dimension)d(will)i(b)s(e)e(written)h(here)g(b)m(y)630
+4183 y(nccf)p 795 4183 V 40 w(inq)p 959 4183 V 40 w(lvl.)150
+4335 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h
+(the)f(co)s(ordinate)i(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i
+(here.)150 4488 y Fc(ft_lenp)144 b Fi(If)32 b(non-NULL,)g(the)g(length)
+g(of)h(the)f(v)-5 b(alue)33 b(of)f(the)g(\\form)m(ula)p
+2762 4488 V 41 w(terms")g(attribute)h(will)g(b)s(e)630
+4597 y(written)h(here)f(b)m(y)h(ft)p 1351 4597 V 40 w(lenp.)50
+b(If)34 b(there)f(is)h(no)g(\\form)m(ula)p 2536 4597
+V 40 w(terms")h(attribute,)g(zero)g(will)f(b)s(e)630
+4707 y(written.)150 4859 y Fc(positive_upp)630 4969 y
+Fi(If)45 b(non-NULL,)g(a)g(one)h(will)f(b)s(e)f(written)i(here)f(if)g
+(the)g(\\p)s(ositiv)m(e")i(attribute)f(of)f(this)630
+5078 y(co)s(ordinate)31 b(v)-5 b(ariable)31 b(is)g(\\up",)f(a)h(zero)g
+(will)g(b)s(e)f(written)g(if)g(it)h(is)g(\\do)m(wn".)150
+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
+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
+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
+(ertical)j(co)s(ordinate)e(v)-5 b(ariable)41 b(and)f(dimension)f(from)h
+(Ap)s(endix)f(D)i(of)g(the)f(CF)150 1696 y(Con)m(v)m(en)m(tion,)32
+b(with)e(all)h(the)g(CF)f(recommended)g(attribute)h(accessories)i(for)d
+(a)h(v)m(ertical)h(lev)m(el.)150 1937 y Fh(Usage)390
+2097 y Fc(int)47 b(nccf_def_lvl_vert\(int)42 b(ncid,)k(int)h(lvl_type,)
+e(const)i(char)f(*name,)h(nc_type)e(xtype,)1440 2206
+y(size_t)h(len,)h(int)g(*lvl_dimidp,)d(int)j(*lvl_varidp\);)150
+2374 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+2539 y Fc(lvl_type)96 b Fi(One)20 b(of:)36 b(CF)p 1077
+2539 28 4 v 40 w(VER)-8 b(T)p 1372 2539 V 40 w(A)g(TM)p
+1621 2539 V 40 w(LN,)21 b(CF)p 1957 2539 V 40 w(VER)-8
+b(T)p 2252 2539 V 40 w(SIGMA,)20 b(CF)p 2768 2539 V 40
+w(VER)-8 b(T)p 3063 2539 V 41 w(HYBRID)p 3473 2539 V
+40 w(SIGMA,)630 2649 y(CF)p 761 2649 V 40 w(VER)g(T)p
+1056 2649 V 40 w(HYBRID)p 1465 2649 V 41 w(HEIGHT,)21
+b(CF)p 2045 2649 V 40 w(VER)-8 b(T)p 2340 2649 V 40 w(SLEVE,)19
+b(CF)p 2849 2649 V 40 w(VER)-8 b(T)p 3144 2649 V 40 w(OCEAN)p
+3519 2649 V 40 w(SIGMA,)630 2758 y(CF)p 761 2758 V 40
+w(VER)g(T)p 1056 2758 V 40 w(OCEAN)p 1431 2758 V 40 w(S,)20
+b(CF)p 1692 2758 V 40 w(VER)-8 b(T)p 1987 2758 V 40 w(OCEAN)p
+2362 2758 V 39 w(SIGMA)p 2707 2758 V 40 w(Z,)20 b(CF)p
+2973 2758 V 40 w(VER)-8 b(T)p 3268 2758 V 41 w(OCEAN)p
+3644 2758 V 39 w(DBL)p 3873 2758 V 41 w(SIGMA.)150 2923
+y Fc(name)288 b Fi(The)30 b(name)g(of)h(the)f(co)s(ordinate)i
+(dimension)d(and)h(v)-5 b(ariable.)150 3088 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.)150 3253 y Fc(len)336 b Fi(The)30 b(length)h(of)f(this)g(co)
+s(ordinate)i(dimension)d(and)h(v)-5 b(ariable.)150 3418
+y Fc(lvl_dimidp)630 3528 y Fi(If)22 b(non-NULL,)g(the)g(function)g
+(will)g(write)g(the)h(dimension)e(ID)h(of)h(the)f(netCDF)h(dimension)
+630 3637 y(for)30 b(the)h(lev)m(el)h(here.)150 3803 y
+Fc(llvl_varidp)630 3912 y Fi(If)c(non-NULL,)f(the)i(function)e(will)i
+(write)f(the)g(v)-5 b(ariable)29 b(ID)f(of)g(the)g(netCDF)h(co)s
+(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
+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
+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
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 909 y Fc(name)288
+b Fi(If)34 b(non-NULL,)h(the)g(name)g(of)g(this)f(v)m(ertical)j(lev)m
+(el)g(dimension)d(\(and)h(v)-5 b(ariable\))35 b(will)h(b)s(e)630
+1019 y(written)30 b(here.)150 1187 y Fc(xtypep)192 b
+Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h(the)f(co)s(ordinate)i(v)
+-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+1356 y Fc(lenp)288 b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h
+(lev)m(el)h(dimension)e(will)g(b)s(e)g(written)g(here.)150
+1524 y Fc(lvl_typep)630 1634 y Fi(If)51 b(non-NULL,)f(the)i(t)m(yp)s(e)
+f(of)g(v)m(ertical)i(dimension)d(will)i(b)s(e)e(written)h(here,)56
+b(one)c(of)630 1743 y(CF)p 761 1743 28 4 v 40 w(VER)-8
+b(T)p 1056 1743 V 40 w(A)g(TM)p 1305 1743 V 41 w(LN,)133
+b(CF)p 1754 1743 V 40 w(VER)-8 b(T)p 2049 1743 V 41 w(SIGMA,)134
+b(CF)p 2680 1743 V 40 w(VER)-8 b(T)p 2975 1743 V 40 w(HYBRID)p
+3384 1743 V 41 w(SIGMA,)630 1853 y(CF)p 761 1853 V 40
+w(VER)g(T)p 1056 1853 V 40 w(HYBRID)p 1465 1853 V 41
+w(HEIGHT,)21 b(CF)p 2045 1853 V 40 w(VER)-8 b(T)p 2340
+1853 V 40 w(SLEVE,)19 b(CF)p 2849 1853 V 40 w(VER)-8
+b(T)p 3144 1853 V 40 w(OCEAN)p 3519 1853 V 40 w(SIGMA,)630
+1962 y(CF)p 761 1962 V 40 w(VER)g(T)p 1056 1962 V 40
+w(OCEAN)p 1431 1962 V 40 w(S,)20 b(CF)p 1692 1962 V 40
+w(VER)-8 b(T)p 1987 1962 V 40 w(OCEAN)p 2362 1962 V 39
+w(SIGMA)p 2707 1962 V 40 w(Z,)20 b(CF)p 2973 1962 V 40
+w(VER)-8 b(T)p 3268 1962 V 41 w(OCEAN)p 3644 1962 V 39
+w(DBL)p 3873 1962 V 41 w(SIGMA.)150 2131 y Fc(lvl_dimidp)630
+2240 y Fi(If)30 b(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.)150 2409
+y Fc(lvl_varidp)630 2518 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 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)
+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
+b(ariable)32 b(and)e(dimension)h(with)g(all)h(the)f(CF)g(recommended)g
+(attribute)h(acces-)150 3818 y(sories)f(for)f(time.)150
+4064 y Fh(Usage)390 4223 y Fc(int)47 b(nccf_def_time\(int)c(ncid,)j
+(const)h(char)f(*name,)g(size_t)h(len,)f(nc_type)g(xtype,)1392
+4333 y(const)h(char)f(*units,)g(const)g(char)h(*standard_name,)d(const)
+i(char)h(*long_name,)1392 4443 y(const)g(char)f(*formula_terms,)e(int)j
+(*time_dimidp,)d(int)j(*time_varidp\);)150 4616 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 4784 y Fc(len)336
+b Fi(The)30 b(length)h(of)f(this)g(co)s(ordinate)i(dimension.)150
+4952 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.)150 5121 y Fc(formula_terms)630
+5230 y Fi(If)33 b(non-NULL,)g(a)g(string)g(whic)m(h)g(will)g(b)s(e)f
+(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
+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
+(netCDF)f(dimen-)630 518 y(sion)i(for)h(the)f(time)h(here.)150
+683 y Fc(lon_varidp)630 793 y Fi(If)23 b(non-NULL,)g(nccf)p
+1354 793 V 40 w(def)p 1513 793 V 39 w(time)h(will)f(write)h(the)f(v)-5
+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
+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
+2221 y(Inquire)29 b(ab)s(out)h(a)h(time)g(dimension)f(and)f(co)s
+(ordinate)j(v)-5 b(ariable.)150 2462 y Fh(Usage)390 2621
+y Fc(int)47 b(nccf_inq_time\(int)c(ncid,)j(size_t)g(*lenp,)h(nc_type)e
+(*xtypep,)h(size_t)g(*ft_lenp,)1392 2731 y(char)h(*formula_terms,)d
+(int)i(*time_dimidp,)f(int)i(*time_varidp\);)150 2899
+y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+3064 y Fc(lenp)288 b Fi(If)56 b(non-NULL,)g(the)g(length)g(of)h(the)f
+(time)h(dimension)e(will)i(b)s(e)e(written)h(here)g(b)m(y)630
+3173 y(nccf)p 795 3173 V 40 w(inq)p 959 3173 V 40 w(time.)150
+3338 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h
+(the)f(co)s(ordinate)i(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i
+(here.)150 3503 y Fc(ft_lenp)144 b Fi(If)32 b(non-NULL,)g(the)g(length)
+g(of)h(the)f(v)-5 b(alue)33 b(of)f(the)g(\\form)m(ula)p
+2762 3503 V 41 w(terms")g(attribute)h(will)g(b)s(e)630
+3613 y(written)h(here)f(b)m(y)h(ft)p 1351 3613 V 40 w(lenp.)50
+b(If)34 b(there)f(is)h(no)g(\\form)m(ula)p 2536 3613
+V 40 w(terms")h(attribute,)g(zero)g(will)f(b)s(e)630
+3723 y(written.)150 3888 y Fc(formula_terms)630 3997
+y Fi(If)c(non-NULL)g(the)h(v)-5 b(alue)31 b(of)g(the)g(\\form)m(ula)p
+2185 3997 V 41 w(terms")g(attribute,)g(if)g(an)m(y)-8
+b(,)32 b(will)e(b)s(e)g(copied)630 4107 y(here.)150 4272
+y Fc(time_dimidp)630 4381 y Fi(If)g(non-NULL,)g(the)h(dimid)e(of)i(the)
+f(time)i(dimension)d(will)i(b)s(e)f(written)g(here.)150
+4547 y Fc(time_varidp)630 4656 y Fi(If)g(non-NULL,)g(the)h(v)-5
+b(arid)30 b(of)g(the)h(time)g(co)s(ordinate)g(v)-5 b(ariable)31
+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
+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
+y Fc(int)47 b(nccf_def_ft_sigma\(int)42 b(ncid,)k(int)h(varid,)f(int)h
+(ps_varid,)e(int)i(ptop_varid\);)150 1120 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 1280 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 1439 y Fc(ps_varid)96 b Fi(The)30
+b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(ps)e(v)-5 b(ariable.)150
+1599 y Fc(ptop_varid)630 1709 y Fi(The)30 b(v)-5 b(ariable)31
+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
+(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
+3118 y Fh(Usage)390 3278 y Fc(int)47 b(nccf_inq_lvl_sigma\(int)42
+b(ncid,)k(char)h(*name,)f(nc_type)g(*xtypep,)f(size_t)h(*lenp,)1488
+3387 y(int)h(*ps_varidp,)d(int)j(*ptop_varidp,)d(int)j(*lvl_dimidp,)
+1488 3497 y(int)g(*lvl_varidp\);)150 3657 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 3816 y Fc(name)288
+b Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h(gets)h(the)g(name)f(of)
+g(the)g(co)s(ordinate)h(v)-5 b(ariable)29 b(and)e(dimen-)630
+3926 y(sion.)150 4086 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)
+m(yp)s(e)f(of)h(the)f(co)s(ordinate)i(v)-5 b(ariable)31
+b(will)g(b)s(e)e(written)i(here.)150 4245 y Fc(lenp)288
+b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h(co)s(ordinate)g
+(dimension)f(will)g(b)s(e)g(written)h(here.)150 4405
+y Fc(ps_varidp)630 4515 y Fi(If)f(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(ps)e(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 4674 y Fc(ptop_varidp)630
+4784 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
+(ptop)f(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+4943 y Fc(lvl_dimidp)630 5053 y Fi(If)f(non-NULL,)g(the)h(dimid)e(of)i
+(the)f(co)s(ordinate)i(dimension)d(will)i(b)s(e)f(written)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: 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(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
+(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
+b(nccf_def_ft_hybrid_sigma)o(\(int)41 b(ncid,)46 b(int)h(varid,)f(int)h
+(a_varid,)f(int)h(b_varid,)1774 1608 y(int)g(ps_varid,)e(int)i
+(p0_varid\);)150 1768 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h
+(\014le.)150 1927 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
+2086 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 2245 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 2405 y Fc(ps_varid)96 b Fi(The)30 b(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(ps)e(v)-5 b(ariable.)150
+2564 y Fc(ptop_varid)630 2673 y Fi(The)30 b(v)-5 b(ariable)31
+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
+(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
+(a\(in)o(t)42 b(ncid,)k(char)h(*name,)f(nc_type)g(*xtypep,)1822
+4215 y(size_t)g(*lenp,)g(int)h(*a_varidp,)e(int)i(*b_varidp,)1822
+4325 y(int)g(*ps_varidp,)d(int)j(*p0_varidp,)e(int)i(*lvl_dimidp,)1822
+4434 y(int)g(*lvl_varidp\);)150 4594 y(ncid)288 b Fi(The)30
+b(ncid)g(of)g(the)h(\014le.)150 4753 y Fc(name)288 b
+Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h(gets)h(the)g(name)f(of)g
+(the)g(co)s(ordinate)h(v)-5 b(ariable)29 b(and)e(dimen-)630
+4862 y(sion.)150 5022 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)
+m(yp)s(e)f(of)h(the)f(co)s(ordinate)i(v)-5 b(ariable)31
+b(will)g(b)s(e)e(written)i(here.)150 5181 y Fc(lenp)288
+b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h(co)s(ordinate)g
+(dimension)f(will)g(b)s(e)g(written)h(here.)150 5340
+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
+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
+b(ariable)31 b(ID)g(of)f(the)h(ps)e(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 767 y Fc(ptop_varidp)630
+877 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
+(ptop)f(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+1056 y Fc(lvl_dimidp)630 1165 y Fi(If)f(non-NULL,)g(the)h(dimid)e(of)i
+(the)f(co)s(ordinate)i(dimension)d(will)i(b)s(e)f(written)g(here.)150
+1345 y Fc(lvl_varidp)630 1454 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.)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
+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
+(v)-5 b(ariable)150 2945 y Fh(Usage)390 3104 y Fc(int)47
+b(nccf_def_ft_hybrid_heigh)o(t\(in)o(t)42 b(ncid,)k(int)h(varid,)f(int)
+h(a_varid,)f(int)g(b_varid,)1822 3214 y(int)h(orog_varid\);)150
+3403 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)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
+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
+(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
+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
+568 y(int)g(*a_varidp,)f(int)i(*b_varidp,)e(int)i(*orog_varidp,)1870
+677 y(int)f(*lvl_dimidp,)f(int)i(*lvl_varidp\);)150 842
+y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+1005 y Fc(name)288 b Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h
+(gets)h(the)g(name)f(of)g(the)g(co)s(ordinate)h(v)-5
+b(ariable)29 b(and)e(dimen-)630 1114 y(sion.)150 1277
+y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h(the)f
+(co)s(ordinate)i(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+1440 y Fc(lenp)288 b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h
+(co)s(ordinate)g(dimension)f(will)g(b)s(e)g(written)h(here.)150
+1603 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.)150 1766 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
+1928 y Fc(orog_varidp)630 2038 y Fi(If)g(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(orog)g(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 2201 y Fc(lvl_dimidp)630
+2310 y Fi(If)g(non-NULL,)g(the)h(dimid)e(of)i(the)f(co)s(ordinate)i
+(dimension)d(will)i(b)s(e)f(written)g(here.)150 2473
+y Fc(lvl_varidp)630 2583 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.)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)
+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
+(nccf_def_ft_sleve\(int)42 b(ncid,)k(int)h(varid,)f(int)h(a_varid,)f
+(int)h(b1_varid,)1440 4142 y(int)g(b2_varid,)e(int)i(ztop_varid,)e(int)
+i(zsurf1_varid,)1440 4252 y(int)g(zsurf2_varid\);)150
+4416 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+4579 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 4742 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 4905 y Fc(b1_varid)96 b Fi(The)30 b(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(b1)f(v)-5 b(ariable.)150
+5068 y Fc(b2_varid)96 b Fi(The)30 b(v)-5 b(ariable)31
+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
+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
+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
+b(ncid,)k(char)h(*name,)f(nc_type)g(*xtypep,)f(size_t)h(*lenp,)1488
+2250 y(int)h(*a_varidp,)e(int)i(*b1_varidp,)d(int)j(*b2_varidp,)e(int)i
+(*ztop_varidp,)1488 2360 y(int)g(*zsurf1_varidp,)c(int)k
+(*zsurf2_varidp,)d(int)j(*lvl_dimidp,)1488 2470 y(int)g(*lvl_varidp\);)
+150 2637 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+2801 y Fc(name)288 b Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h
+(gets)h(the)g(name)f(of)g(the)g(co)s(ordinate)h(v)-5
+b(ariable)29 b(and)e(dimen-)630 2911 y(sion.)150 3075
+y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h(the)f
+(co)s(ordinate)i(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+3239 y Fc(lenp)288 b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h
+(co)s(ordinate)g(dimension)f(will)g(b)s(e)g(written)h(here.)150
+3404 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.)150 3568 y Fc(b1_varidp)630
+3678 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
+(b1)f(v)-5 b(ariable)31 b(will)g(b)s(e)f(written)g(here.)150
+3842 y Fc(b2_varidp)630 3952 y Fi(If)g(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(b2)f(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 4117 y Fc(ztop_varidp)630
+4226 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
+(ztop)g(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+4391 y Fc(zsurf1_varidp)630 4500 y Fi(If)f(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(zsurf1)f(v)-5 b(ariable)31
+b(will)f(b)s(e)g(written)h(here.)150 4665 y Fc(zsurf2_varidp)630
+4774 y Fi(If)f(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
+(zsurf2)f(v)-5 b(ariable)31 b(will)f(b)s(e)g(written)h(here.)150
+4939 y Fc(lvl_dimidp)630 5048 y Fi(If)f(non-NULL,)g(the)h(dimid)e(of)i
+(the)f(co)s(ordinate)i(dimension)d(will)i(b)s(e)f(written)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: 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(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
+(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
+(nccf_def_ft_ocean_sigma\()o(int)41 b(ncid,)47 b(int)g(varid,)f(int)h
+(eta_varid,)e(int)h(depth_varid\);)150 1609 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 1755 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 1900 y Fc(eta_varid)630 2009 y Fi(The)30
+b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(eta)g(v)-5 b(ariable.)150
+2155 y Fc(depth_varid)630 2264 y Fi(The)30 b(v)-5 b(ariable)31
+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
+(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
+b(ncid,)46 b(char)h(*name,)f(nc_type)g(*xtypep,)f(size_t)i(*lenp,)1774
+3757 y(int)g(*eta_varidp,)d(int)j(*depth_varidp,)d(int)j(*lvl_dimidp,)
+1774 3867 y(int)g(*lvl_varidp\);)150 4012 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 4158 y Fc(name)288
+b Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h(gets)h(the)g(name)f(of)
+g(the)g(co)s(ordinate)h(v)-5 b(ariable)29 b(and)e(dimen-)630
+4267 y(sion.)150 4412 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)
+m(yp)s(e)f(of)h(the)f(co)s(ordinate)i(v)-5 b(ariable)31
+b(will)g(b)s(e)e(written)i(here.)150 4558 y Fc(lenp)288
+b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h(co)s(ordinate)g
+(dimension)f(will)g(b)s(e)g(written)h(here.)150 4703
+y Fc(eta_varidp)630 4813 y Fi(If)f(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(eta)g(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 4958 y Fc(lvl_dimidp)630
+5067 y Fi(If)g(non-NULL,)g(the)h(dimid)e(of)i(the)f(co)s(ordinate)i
+(dimension)d(will)i(b)s(e)f(written)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: 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
+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
+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,)
+1583 1598 y(int)h(eta_varid,)e(int)i(depth_varid,)d(int)j(a_varid,)f
+(int)h(b_varid,)1583 1707 y(int)g(depth_c_varid,)d(int)j(*lvl_dimidp,)d
+(int)j(*lvl_varidp\);)150 1862 y(ncid)288 b Fi(The)30
+b(ncid)g(of)g(the)h(\014le.)150 2017 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 2172 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.)150
+2327 y Fc(len)336 b Fi(The)30 b(length)h(of)f(this)g(co)s(ordinate)i
+(dimension.)150 2482 y Fc(eta_varid)630 2591 y Fi(The)e(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(eta)g(v)-5 b(ariable.)150
+2746 y Fc(depth_varid)630 2856 y Fi(The)30 b(v)-5 b(ariable)31
+b(ID)g(of)f(the)h(depth)e(v)-5 b(ariable.)150 3011 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 3165 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
+3320 y Fc(depth_c_varid)630 3430 y Fi(The)30 b(v)-5 b(ariable)31
+b(ID)g(of)f(the)h(depth)p 1785 3430 28 4 v 39 w(c)g(v)-5
+b(ariable.)150 3585 y Fc(lvl_dimidp)630 3694 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 3804 y(written)30 b(here.)150
+3959 y Fc(lvl_varidp)630 4068 y Fi(If)24 b(non-NULL,)h(the)g(v)-5
+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
+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
+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
+568 y(int)h(*eta_varidp,)e(int)h(*depth_varidp,)e(int)j(*a_varidp,)e
+(int)i(*b_varidp,)1583 677 y(int)g(*depth_c_varidp,)c(int)k
+(*lvl_dimidp,)e(int)i(*lvl_varidp\);)150 838 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 998 y Fc(name)288
+b Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h(gets)h(the)g(name)f(of)
+g(the)g(co)s(ordinate)h(v)-5 b(ariable)29 b(and)e(dimen-)630
+1107 y(sion.)150 1267 y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)
+m(yp)s(e)f(of)h(the)f(co)s(ordinate)i(v)-5 b(ariable)31
+b(will)g(b)s(e)e(written)i(here.)150 1427 y Fc(lenp)288
+b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h(co)s(ordinate)g
+(dimension)f(will)g(b)s(e)g(written)h(here.)150 1587
+y Fc(eta_varidp)630 1697 y Fi(If)f(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(eta)g(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 1857 y Fc(depth_varidp)630
+1966 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.)150
+2126 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.)150 2286 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
+2446 y Fc(depth_c_varidp)630 2556 y Fi(If)g(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(depth)p 2328 2556 28 4
+v 39 w(c)g(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+2716 y Fc(lvl_dimidp)630 2826 y Fi(If)f(non-NULL,)g(the)h(dimid)e(of)i
+(the)f(co)s(ordinate)i(dimension)d(will)i(b)s(e)f(written)g(here.)150
+2986 y Fc(lvl_varidp)630 3095 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.)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)
+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
+(*name,)f(nc_type)g(xtype,)1870 4641 y(size_t)g(len,)g(int)h
+(eta_varid,)e(int)i(depth_varid,)1870 4750 y(int)f(depth_c_varid,)e
+(int)j(nsigma_varid,)1870 4860 y(int)f(zlev_varid,)f(int)i
+(*lvl_dimidp,)e(int)h(*lvl_varidp\);)150 5020 y(ncid)288
+b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150 5180 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 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
+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
+824 y Fi(The)30 b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(depth)e(v)-5
+b(ariable.)150 977 y Fc(depth_c_varid)630 1086 y Fi(The)30
+b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(depth)p 1785 1086
+28 4 v 39 w(c)g(v)-5 b(ariable.)150 1239 y Fc(nsigma_varid)630
+1349 y Fi(The)30 b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(nsigma)f(v)-5
+b(ariable.)150 1502 y Fc(zlev_varid)630 1611 y Fi(The)30
+b(v)-5 b(ariable)31 b(ID)g(of)f(the)h(zlev)g(v)-5 b(ariable.)150
+1764 y Fc(lvl_dimidp)630 1874 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
+1983 y(written)30 b(here.)150 2136 y Fc(lvl_varidp)630
+2246 y Fi(If)24 b(non-NULL,)h(the)g(v)-5 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 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
+(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
+(_z\(i)o(nt)41 b(ncid,)47 b(char)f(*name,)h(nc_type)e(*xtypep,)h
+(size_t)g(*lenp,)1870 3875 y(int)g(*eta_varidp,)f(int)i(*depth_varidp,)
+d(int)j(*depth_c_varidp,)1870 3984 y(int)f(*nsigma_varidp,)e(int)j
+(*zlev_varidp,)d(int)j(*lvl_dimidp,)1870 4094 y(int)f(*lvl_varidp\);)
+150 4247 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+4400 y Fc(name)288 b Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h
+(gets)h(the)g(name)f(of)g(the)g(co)s(ordinate)h(v)-5
+b(ariable)29 b(and)e(dimen-)630 4509 y(sion.)150 4662
+y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h(the)f
+(co)s(ordinate)i(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+4815 y Fc(lenp)288 b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h
+(co)s(ordinate)g(dimension)f(will)g(b)s(e)g(written)h(here.)150
+4968 y Fc(eta_varidp)630 5078 y Fi(If)f(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(eta)g(v)-5 b(ariable)31
+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
+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
+(written)i(here.)150 577 y Fc(nsigma_varidp)630 686 y
+Fi(If)f(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h(nsigma)f
+(v)-5 b(ariable)31 b(will)g(b)s(e)f(written)g(here.)150
+854 y Fc(zlev_varidp)630 964 y Fi(If)g(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(zlev)g(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 1132 y Fc(lvl_dimidp)630
+1242 y Fi(If)g(non-NULL,)g(the)h(dimid)e(of)i(the)f(co)s(ordinate)i
+(dimension)d(will)i(b)s(e)f(written)g(here.)150 1410
+y Fc(lvl_varidp)630 1520 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.)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
+(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
+b(ncid,)47 b(const)f(char)h(*name,)f(nc_type)f(xtype,)i(size_t)f(len,)
+1965 3106 y(int)h(depth_varid,)d(int)j(z1_varid,)f(int)g(z2_varid,)g
+(int)h(a_varid,)1965 3216 y(int)g(href_varid,)e(int)i(k_c_varid,)e(int)
+h(*lvl_dimidp,)1965 3325 y(int)h(*lvl_varidp\);)150 3498
+y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+3666 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 3834 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.)150 4002 y Fc(len)336 b Fi(The)30 b(length)h(of)f(this)g
+(co)s(ordinate)i(dimension.)150 4170 y Fc(depth_varid)630
+4280 y Fi(The)e(v)-5 b(ariable)31 b(ID)g(of)f(the)h(depth)e(v)-5
+b(ariable.)150 4448 y Fc(z1_varid)96 b Fi(The)30 b(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(z1)g(v)-5 b(ariable.)150
+4616 y Fc(z2_varid)96 b Fi(The)30 b(v)-5 b(ariable)31
+b(ID)g(of)f(the)h(z2)g(v)-5 b(ariable.)150 4784 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 4953 y Fc(href_varid)630 5062 y Fi(The)30
+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
+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
+(v)-5 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 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
+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
+b(nccf_inq_lvl_ocean_dbl_s)o(igma)o(\(in)o(t)42 b(ncid,)k(char)h
+(*name,)f(nc_type)g(*xtypep,)f(size_t)h(*lenp,)1965 2405
+y(int)h(*depth_varidp,)d(int)j(*z1_varidp,)d(int)j(*z2_varidp,)1965
+2515 y(int)g(*a_varidp,)e(int)i(*href_varidp,)d(int)j(*k_c_varidp,)1965
+2624 y(int)g(*lvl_dimidp,)d(int)j(*lvl_varidp\);)150
+2776 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+2928 y Fc(name)288 b Fi(If)28 b(non-NULL,)g(this)f(p)s(oin)m(ter)h
+(gets)h(the)g(name)f(of)g(the)g(co)s(ordinate)h(v)-5
+b(ariable)29 b(and)e(dimen-)630 3037 y(sion.)150 3189
+y Fc(xtypep)192 b Fi(If)30 b(non-NULL,)g(the)h(t)m(yp)s(e)f(of)h(the)f
+(co)s(ordinate)i(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+3341 y Fc(lenp)288 b Fi(If)30 b(non-NULL,)g(the)h(length)g(of)f(the)h
+(co)s(ordinate)g(dimension)f(will)g(b)s(e)g(written)h(here.)150
+3493 y Fc(depth_varidp)630 3602 y Fi(If)f(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.)150 3754 y Fc(z1_varidp)630
+3864 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h
+(z1)g(v)-5 b(ariable)31 b(will)g(b)s(e)e(written)i(here.)150
+4015 y Fc(z2_varidp)630 4125 y Fi(If)f(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(z2)g(v)-5 b(ariable)31
+b(will)g(b)s(e)e(written)i(here.)150 4277 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.)150
+4429 y Fc(href_varidp)630 4538 y Fi(If)g(non-NULL,)g(the)h(v)-5
+b(ariable)31 b(ID)g(of)f(the)h(href)e(v)-5 b(ariable)31
+b(will)g(b)s(e)f(written)g(here.)150 4690 y Fc(k_c_varidp)630
+4800 y Fi(If)g(non-NULL,)g(the)h(v)-5 b(ariable)31 b(ID)g(of)f(the)h(k)
+p 2148 4800 28 4 v 40 w(c)f(v)-5 b(ariable)31 b(will)g(b)s(e)f(written)
+g(here.)150 4951 y Fc(lvl_dimidp)630 5061 y Fi(If)g(non-NULL,)g(the)h
+(dimid)e(of)i(the)f(co)s(ordinate)i(dimension)d(will)i(b)s(e)f(written)
+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
+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
+(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
+(int)j(*nlat,)f(float)h(*lon_bounds,)629 1609 y(int)g(*nlon,)f(int)h
+(*lvl_index,)d(int)j(*nlvl,)f(int)h(rec,)g(void)f(*data\);)150
+1768 y(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)150
+1928 y Fc(varid)240 b Fi(The)30 b(v)-5 b(arid)30 b(of)g(the)h(data)g(v)
+-5 b(ariable)31 b(from)f(whic)m(h)g(the)h(subset)f(will)g(b)s(e)g(tak)m
+(en.)150 2087 y Fc(lat_bounds)630 2197 y Fi(A)j(length)g(t)m(w)m(o)g
+(arra)m(y)-8 b(,)35 b(this)d(holds)g(the)h(latitude)g(start)g(and)f
+(stop)h(v)-5 b(alues)33 b(for)f(the)h(range)630 2306
+y(of)e(in)m(terest.)150 2466 y Fc(nlat)288 b Fi(A)31
+b(p)s(oin)m(ter)f(to)i(an)e(in)m(teger)i(whic)m(h)e(will)h(get)h(the)f
+(n)m(um)m(b)s(er)e(of)i(latitude)g(v)-5 b(alues)31 b(whic)m(h)f(fall)
+630 2575 y(within)g(the)g(range.)150 2735 y Fc(lon_bounds)630
+2844 y Fi(A)e(length)h(t)m(w)m(o)g(arra)m(y)-8 b(,)30
+b(this)e(holds)g(the)g(longitude)h(start)g(and)e(stop)i(v)-5
+b(alues)28 b(for)g(the)h(range)630 2954 y(of)i(in)m(terest.)41
+b(\(W)-8 b(rapping)31 b(around)f(the)g(dateline)i(is)e(not)h(allo)m(w)m
+(ed!\))150 3113 y Fc(nlon)288 b Fi(A)26 b(p)s(oin)m(ter)h(to)g(an)f(in)
+m(teger)h(whic)m(h)f(will)h(get)g(the)g(n)m(um)m(b)s(er)e(of)h
+(longitude)h(v)-5 b(alues)26 b(whic)m(h)g(fall)630 3223
+y(within)k(the)g(range.)150 3382 y Fc(lvl_index)630 3492
+y Fi(A)39 b(zero-based)g(index)f(n)m(um)m(b)s(er)f(for)h(the)h(v)m
+(erticle)h(lev)m(el)g(of)f(in)m(terest)g(to)g(the)g(subsetter.)630
+3601 y(\(Ignored)30 b(if)h(data)g(has)f(no)g(v)m(ertical)j(axis\).)150
+3761 y Fc(timestep)96 b Fi(A)35 b(zero-based)h(index)f(n)m(um)m(b)s(er)
+f(for)h(the)h(timestep)g(of)f(in)m(terest)i(to)e(the)h(subsetter.)55
+b(\(Ig-)630 3870 y(nored)30 b(if)g(data)h(has)f(no)h(time)g(axis\).)150
+4030 y Fc(data)288 b Fi(A)29 b(p)s(oin)m(ter)g(to)g(whic)m(h)g(the)g
+(data)h(subset)e(will)h(b)s(e)f(written.)41 b(Memory)29
+b(m)m(ust)g(b)s(e)f(allo)s(cated)630 4139 y(\(and)i(deallo)s(cated\))j
+(b)m(y)d(the)h(user.)150 4372 y Fh(Return)45 b(Co)t(des)150
+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
+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
+1053 y(Usage)390 1212 y Fc(int)390 1322 y(nccf_def_axis_type\(int)d
+(ncid,)k(int)h(varid,)f(int)h(axis_type\);)150 1497 y(ncid)288
+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
+(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
+y Fc(int)390 3065 y(nccf_inq_axis_type\(int)d(ncid,)k(int)h(varid,)f
+(int)h(*axis_type\);)150 3240 y(ncid)288 b Fi(The)30
+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
+(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)
+h(char)f(*name,)g(int)h(naxes,)f(int)h(*axis_varids,)1345
+4800 y(int)f(*system_varid\);)275 4945 y Fi(De\014ne)21
+b(a)g(co)s(ordinate)h(system)f(consisting)g(of)g(naxes)g(axes,)j(eac)m
+(h)e(axis)f(represen)m(ted)g(b)m(y)g(a)g(co)s(ordinate)150
+5055 y(v)-5 b(arid)35 b(in)f(the)i(axis)p 817 5055 28
+4 v 40 w(v)-5 b(arids)35 b(arra)m(y)-8 b(.)55 b(This)35
+b(create)h(a)g(new)e(\(scalar,)k(NC)p 2623 5055 V 40
+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
+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
+(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
+1593 y(nccf_inq_coord_system\(in)o(t)c(ncid,)k(int)h(system_varid,)d
+(char)j(*name,)1345 1703 y(int)f(*naxes,)g(int)h(*axis_varids\);)275
+1838 y Fi(Find)34 b(out)h(ab)s(out)f(a)h(co)s(ordinate)h(system,)g
+(it's)f(name,)h(n)m(um)m(b)s(er)d(of)i(axes,)i(and)d(the)h(v)-5
+b(arid)34 b(of)h(eac)m(h)150 1947 y(axis)c(co)s(ordinate)g(v)-5
+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
+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
+(\(int)c(ncid,)46 b(int)h(varid,)f(int)h(system_varid\);)275
+3770 y Fi(Assign)30 b(a)h(co)s(ordinate)g(system)f(to)i(a)e(v)-5
+b(ar.)41 b(This)30 b(adds)f(an)h(attribute)i(to)f(the)f(v)-5
+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
+(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
+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
+v 40 w(CHAR\))c(v)-5 b(ar,)42 b(whic)m(h)e(con)m(tains)150
+546 y(some)31 b(attributes.)41 b(The)30 b(v)-5 b(arid)30
+b(of)h(this)f(new)g(v)-5 b(ariable)31 b(is)f(returned)f(in)i(transform)
+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
+(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
+(ncid,)k(int)h(transform_varid,)c(char)k(*name,)f(size_t)g(*type_len,)
+1201 2360 y(char)h(*transform_type,)c(size_t)j(*name_len,)f(char)i
+(*transform_name\);)275 2498 y Fi(Find)21 b(out)i(ab)s(out)f(a)h(co)s
+(ordinate)g(transform,)g(it's)g(name,)h(and)e(the)g(con)m(ten)m(ts)i
+(of)f(the)f(transform)p 3542 2498 28 4 v 40 w(t)m(yp)s(e)150
+2608 y(and)38 b(transform)p 729 2608 V 39 w(name)h(attributes.)67
+b(P)m(ass)39 b(NULL)f(for)h(an)m(y)g(that)g(y)m(ou're)g(not)g(in)m
+(terested)h(in.)65 b(P)m(ass)150 2717 y(NULL)48 b(for)g(transform)p
+999 2717 V 39 w(t)m(yp)s(e)g(and)g(transform)p 1843 2717
+V 39 w(name)g(to)h(get)g(their)f(lengths)g(with)g(t)m(yp)s(e)p
+3405 2717 V 40 w(len)h(and)150 2827 y(name)p 368 2827
+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
+(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
+4531 y(nccf_assign_transform\(in)o(t)d(ncid,)k(int)h(system_varid,)d
+(int)j(transform_varid\);)275 4669 y Fi(Assign)37 b(a)h(co)s(ordinate)g
+(transform)e(to)j(a)e(co)s(ordinate)h(system.)62 b(This)37
+b(adds)f(an)i(attribute)g(to)g(the)150 4778 y(v)-5 b(ariable)31
+b(that)g(holds)f(the)h(co)s(ordinate)g(system)f(attributes.)150
+4943 y Fc(ncid)288 b Fi(The)30 b(ncid)g(of)g(the)h(\014le.)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
+b(CF)g(Library)g(Users)g(Guide)150 299 y Fh(Example)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
+%%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
+%%Trailer
+
+userdict /end-hook known{end-hook}if
+%%EOF
diff --git a/doc/libcf.texi b/doc/libcf.texi
new file mode 100644
index 0000000..b2b971c
--- /dev/null
+++ b/doc/libcf.texi
@@ -0,0 +1,2546 @@
+\input texinfo @c -*-texinfo-*-
+ at comment $Id: libcf.texi,v 1.11 2007/05/02 20:29:47 ed Exp $
+ at c %**start of header
+ at setfilename libcf.info
+ at settitle The CF Library Users Guide
+ at setcontentsaftertitlepage
+ at c Combine the variable, concept, and function indices.
+ at synindex vr cp
+ at synindex fn cp
+ at c %**end of header
+
+ at c version.texi is automatically generated by automake and contains
+ at c defined variables VERSION, UPDATED, UPDATED-MONTH.
+ at include version.texi
+ at include defines.texi
+
+ at ifinfo
+ at dircategory netCDF CF Library
+ at direntry
+* libcf: (libcf). @value{libcf-man}
+ at end direntry
+ at end ifinfo
+
+ at titlepage
+ at title @value{libcf-man}
+ at subtitle Version @value{VERSION}
+ at subtitle @value{UPDATED-MONTH}
+ at author Ed Hartnett
+ at author Unidata Program Center
+ at page
+ at vskip 0pt plus 1filll
+ at insertcopying
+ at end titlepage
+
+ at ifnottex
+ at node Top, Summary, (dir), (dir)
+ at top @value{libcf-man}
+
+This guide describes libcf, the netCDF CF Library. This document
+applies to libcf version @value{VERSION}, and was last updated on
+ at value{UPDATED}.
+
+ at end ifnottex
+
+ at menu
+* Summary::
+* Installation::
+* cfcheck::
+* Files::
+* Variables::
+* Coordinates::
+* Combined Index::
+ at end menu
+
+ at node Summary, Installation, Top, Top
+ at unnumbered Summary
+ at cindex supported programming languages
+ at cindex API, C
+ at cindex API, Fortran
+ at cindex API, F90
+
+The CF conventions for climate and forecast metadata are designed to
+promote the processing and sharing of files created with the netCDF
+API.
+
+This library, libcf, makes it easier to create and work with data
+files which conform to the CF conventions.
+
+The functions of the CF library are intended to be interspersed with
+netCDF library calls. That is, the programmer will open or create a
+netCDF file with the netCDF API, and then add or read metadata with
+libcf library functions, then continue to working with the netCDF API
+to read and write data.
+
+By using libcf, a data producer can produce files that conform to the
+CF standards, without having to write netCDF code to create and decode
+all the attributes that the CF convention uses to store meta-data. A
+data consumer can use libcf to read any file which conforms to the CF
+conventions; the file does not need to be created with libcf to be
+read by libcf.
+
+Fortran-77 wrapper functions provide a Fortran 77 API, just as is done
+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 unnumbered Downloading and Installing libcf
+
+Currently, and for some time to come, libcf is in alpha release. The
+code is tested, but not extensively. The API may be extended, and
+possibly changed, in each release.
+
+You must have either netCDF-3 (or netCDF-4) installed. And reasonably
+recent version of netCDF should work. libcf is tested with netCDF
+3.6.2-beta4.
+
+Get the latest version of the libcf tarball at the libcf ftp site:
+ at value{ftp-site}
+
+Unpack the tarball, and run:
+
+ at example
+./configure --with-netcdf=/my/netcdf --prefix=/my/libcf && make check install > output.txt
+ at end example
+
+Where /my/netcdf is the root install directory of the netCDF library
+you want to use, and /my/libcf is the root directory where you want
+libcf installed. (They may be the same directory.)
+
+If you wish to use netCDF-4, you must also have HDF5 and libz, the
+compression library, installed. In this case, configure libcf like
+this:
+
+ at example
+./configure --with-netcdf=/s/n4_new1/install --enable-netcdf-4 --with-hdf5=/home/ed/local/s && make check install > output.txt
+ at end example
+
+If the build does not work for you, please email libcf support:
+ at value{libcf-support-email}. Please send the *complete* output of the
+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
+
+The cfchck utility will chck a file to see if it contains valid CF
+metadata. Messages about the file are printed to stdout.
+
+ at node Files, Variables, cfcheck, Top
+ at chapter Files
+
+ at menu
+* nccf_def_convention::
+* nccf_inq_convention::
+* nccf_def_file::
+* nccf_inq_file::
+* nccf_add_history::
+ at end menu
+
+ at node nccf_def_convention, nccf_inq_convention, Files, Files
+ at section Mark a File as Conforming to CF Conventions
+
+Mark the file as following CF-1.0 conventions.
+
+This functions is called automatically by nccf_def_file, so need not
+be called by the user if nccf_def_file is being called.
+
+ at heading Usage
+
+ at example
+ int nccf_def_convention(int ncid);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_convention, nccf_def_file, nccf_def_convention, Files
+ at section Determine if a File Claims to Conform to CF Conventions
+
+Determine if the file claims to follow CF-1.0 conventions. This
+function only checks the global ``Conventions'' attribute. It does not
+look at file metadata to ensure that this is a well-formed CF file. It
+only tells whether the file claims to be a CF file.
+
+ at heading Usage
+
+ at example
+ int nccf_inq_convention(int ncid, int *cf_convention);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item cf_conventions
+If this pointer to an int is provided, a 1 is written there if this
+file claims to follow CF 1.0 conventions, a 0 otherwise.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_file, nccf_inq_file, nccf_inq_convention, Files
+ at section Add description to the data with nccf_def_file
+
+Add some or all of the CF recommended text attributes to a file. Any
+parameters which are set to NULL will be ignored.
+
+ at heading Usage
+
+ at example
+int nccf_def_file(int ncid, char *title, char *history, char *institution,
+ char *source, char *comment, char *references);
+ at end example
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item title
+If non-NULL, this text string will be written as the CF-recommended
+``title'' attribute.
+
+ at item history
+If non-NULL, this text string will be written as the CF-recommended
+``history'' attribute.
+
+ at item institution
+If non-NULL, this text string will be written as the CF-recommended
+``institution'' attribute.
+
+ at item source
+If non-NULL, this text string will be written as the CF-recommended
+``source'' attribute.
+
+ at item comment
+If non-NULL, this text string will be written as the CF-recommended
+``comment'' attribute.
+
+ at item references
+If non-NULL, this text string will be written as the CF-recommended
+``references'' attribute.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_file, nccf_add_history, nccf_def_file, Files
+ at section Read the description of the data with nccf_inq_file
+
+Read any existing CF recommended text attributes from the file.
+
+Recall that in C, strlens do not include the null terminator. To get
+the lengths before the strings (in order to allocated) pass NULL for
+any or all strings and the lengths will be returned. Then call the
+function again after allocating memory.
+
+The CF version is guaranteed to be less than NC_MAX_NAME.
+
+Any of these pointer arguments may be NULL, in which case it will be
+ignored.
+
+ at heading Usage
+
+ at example
+int nccf_inq_file(int ncid, size_t *title_lenp, char *title,
+ size_t *history_lenp, char *history,
+ size_t *institution_lenp, char *institution,
+ size_t *source_lenp, char *source,
+ size_t *comment_lenp, char *comment,
+ size_t *references_lenp, char *references);
+ at end example
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item title_lenp
+Pointer to size_t which, if not NULL, will get the length of the title
+attribute.
+
+ at item title
+Pointer to char array which, if not NULL, will get the title
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item history_lenp
+Pointer to size_t which, if not NULL, will get the length of the history
+attribute.
+
+ at item history
+Pointer to char array which, if not NULL, will get the history
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item institution_lenp
+Pointer to size_t which, if not NULL, will get the length of the institution
+attribute.
+
+ at item institution
+Pointer to char array which, if not NULL, will get the institution
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item source_lenp
+Pointer to size_t which, if not NULL, will get the length of the source
+attribute.
+
+ at item source
+Pointer to char array which, if not NULL, will get the source
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item comment_lenp
+Pointer to size_t which, if not NULL, will get the length of the comment
+attribute.
+
+ at item comment
+Pointer to char array which, if not NULL, will get the comment
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item references_lenp
+Pointer to size_t which, if not NULL, will get the length of the references
+attribute.
+
+ at item references
+Pointer to char array which, if not NULL, will get the references
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_add_history, , nccf_inq_file, Files
+ at section Append to a History Attribute
+
+This function appends a time-stamped history string to the history
+attribute, creating the attribute if it doesn't already exist.
+
+ at heading Usage
+
+ at example
+int nccf_add_history(int ncid, const char *history);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item history
+The string to append to the history attribute.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node Variables, Coordinates, Files, Top
+ at chapter Variables
+
+ at menu
+* nccf_def_var::
+* nccf_inq_var::
+* nccf_def_var_missing::
+* nccf_inq_var_missing::
+* nccf_def_notes::
+* nccf_inq_notes::
+* nccf_def_latitude::
+* nccf_inq_latitude::
+* nccf_def_longitude::
+* nccf_inq_longitude::
+* nccf_def_lvl::
+* nccf_inq_lvl::
+* nccf_def_lvl_vert::
+* nccf_inq_lvl_vert::
+* nccf_def_time::
+* nccf_inq_time::
+* nccf_def_ft_sigma::
+* nccf_inq_lvl_sigma::
+* nccf_def_ft_hybrid_sigma::
+* nccf_inq_lvl_hybrid_sigma::
+* nccf_def_ft_hybrid_height::
+* nccf_inq_lvl_hybrid_height::
+* nccf_def_ft_sleve::
+* nccf_inq_lvl_sleve::
+* nccf_def_ft_ocean_sigma::
+* nccf_inq_lvl_ocean_sigma::
+* nccf_def_ft_ocean_s::
+* nccf_inq_lvl_ocean_s::
+* nccf_def_ft_ocean_sigma_z::
+* nccf_inq_lvl_ocean_sigma_z::
+* nccf_def_ft_ocean_dbl_sigma::
+* nccf_inq_lvl_ocean_dbl_sigma::
+* nccf_get_vara::
+ at end menu
+
+ at node nccf_def_var, nccf_inq_var, Variables, Variables
+ at section Add description to a variable with nccf_def_var
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the netCDF variable being described.
+
+ at item units
+If non-NULL, this text string will be written as the CF-recommended
+``units'' attribute.
+
+ at item long_name
+If non-NULL, this text string will be written as the CF-recommended
+``long_name'' attribute.
+
+ at item standard_name
+If non-NULL, this text string will be written as the CF-recommended
+``standard_name'' attribute.
+
+ at item ncoord_vars
+Number of coordinate variables for this variable.
+
+ at item coord_varids
+The variable IDs of the coordinate variables for this variable.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_var, nccf_def_var_missing, nccf_def_var, Variables
+ at section Read variable description with nccf_inq_var
+
+Read any existing CF recommended text attributes from a variable.
+
+ at heading Usage
+
+ at example
+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);
+
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the netCDF variable.
+
+ at item units_lenp
+Pointer to size_t which, if not NULL, will get the length of the units
+attribute.
+
+ at item units
+Pointer to char array which, if not NULL, will get the long_name
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item long_name_lenp
+Pointer to size_t which, if not NULL, will get the length of the long_name
+attribute.
+
+ at item long_name
+Pointer to char array which, if not NULL, will get the long_name
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item standard_name_lenp
+Pointer to size_t which, if not NULL, will get the length of the standard_name
+attribute.
+
+ at item standard_name
+Pointer to char array which, if not NULL, will get the standard_name
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item ncoord_vars
+Pointer to an integer, which, if non-NULL, will get the number of
+coordinate variables identified in the ``coordinates'' attribute.
+
+ at item coord_varids
+Pointer to an array of integer, which, if non-NULL, will be filled
+with the variable IDs of the variables listed int he ``coordinates''
+attribute.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_var_missing, nccf_inq_var_missing, nccf_inq_var, Variables
+ at section Define missing data values for a variable with nccf_def_var_missing
+nccf_def_notes
+
+This function sets the ``fill_value'', ``valid_min'', and
+``valid_max'' attributes.
+
+ at heading Usage
+
+ at example
+int nccf_def_var_missing(int ncid, int varid, const void *fill_valuep,
+ const void *valid_minp, const void *valid_maxp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the netCDF variable being described.
+
+ at item fill_valuep
+If non-NULL, this will point to a value of the same type as this
+varid, which will be used as the fill_value for the data.
+
+ at item valid_minp
+If non-NULL, this will point to a value of the same type as this
+varid, which will be written as the ``valid_min'' attribute. If this
+parameter is non-NULL, valid_max must also be provided.
+
+ at item valid_maxp
+If non-NULL, this will point to a value of the same type as this
+varid, which will be written as the ``valid_max'' attribute. If this
+parameter is non-NULL, valid_min must also be provided.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_var_missing, nccf_def_notes, nccf_def_var_missing, Variables
+ at section Learn about missing data settings with nccf_inq_var_missing
+
+Get attributes which define missing data information. If the
+attributes are not there, then provide the valid data anyway, based on
+netCDF defaults.
+
+ at heading Usage
+
+ at example
+int nccf_inq_var_missing(int ncid, int varid, void *fill_valuep,
+ void *valid_minp, void *valid_maxp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the netCDF variable.
+
+ at item fill_valuep
+If this is not NULL, the fill value of the variable will be written at
+this address by nccf_inq_var_missing. If the fill value was not
+defined for the variable, the netCDF default value will be used.
+
+ at item valid_minp
+If this is not NULL, the valid_min value of the variable will be
+written at this address by nccf_inq_var_missing. If the valid_min was
+not defined for the variable, the netCDF default value will be used.
+
+ at item valid_maxp
+If this is not NULL, the valid_max value of the variable will be
+written at this address by nccf_inq_var_missing. If the valid_max
+value was not defined for the variable, the netCDF default value will
+be used.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_notes, nccf_inq_notes, nccf_inq_var_missing, Variables
+ at section Add CF-Recommended Metadata to a File or Variable with
+nccf_def_notes
+
+This functions writes up to four text attributes for either a
+variable, or an entire file. These text attributes, ``institution,''
+``source,'' ``comment,'' and ``references'' are recommended by the CF
+Metadata Convention.
+
+ at heading Usage
+
+ at example
+int nccf_def_notes(int ncid, int varid, char *units, char *long_name,
+ char *standard_name, char *institution,
+ char *source, char *comment, char *references);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the netCDF variable being described. Use NC_GLOBAL if you
+wish these attributes to apply to the entire file.
+
+ at item institution
+If non-NULL, this text string will be written as the CF-recommended
+``institution'' attribute.
+
+ at item source
+If non-NULL, this text string will be written as the CF-recommended
+``source'' attribute.
+
+ at item comment
+If non-NULL, this text string will be written as the CF-recommended
+``comment'' attribute.
+
+ at item references
+If non-NULL, this text string will be written as the CF-recommended
+``references'' attribute.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_notes, nccf_def_latitude, nccf_def_notes, Variables
+ at section Read variable description with nccf_inq_notes
+
+Read any existing CF recommended text attributes from a variable.
+
+ at heading Usage
+
+ at example
+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 *references_lenp, char *references);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the netCDF variable.
+
+ at item institution_lenp
+Pointer to size_t which, if not NULL, will get the length of the institution
+attribute.
+
+ at item institution
+Pointer to char array which, if not NULL, will get the institution
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item source_lenp
+Pointer to size_t which, if not NULL, will get the length of the source
+attribute.
+
+ at item source
+Pointer to char array which, if not NULL, will get the source
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item comment_lenp
+Pointer to size_t which, if not NULL, will get the length of the comment
+attribute.
+
+ at item comment
+Pointer to char array which, if not NULL, will get the comment
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at item references_lenp
+Pointer to size_t which, if not NULL, will get the length of the references
+attribute.
+
+ at item references
+Pointer to char array which, if not NULL, will get the references
+string. Memory must be allocated before this function is called. Call
+this function with a NULL for this parameter to get the size first.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_latitude, nccf_inq_latitude, nccf_inq_notes, Variables
+ at section Define a coordinate variable and dimension for latitude with nccf_def_latitude
+
+Define a coordinate variable and dimension with all the CF
+recommended attribute accessories for latitude.
+
+ at heading Usage
+
+ at example
+int nccf_def_latitude(int ncid, size_t len, nc_type xtype,
+ const char *formula_terms, int *lat_dimidp,
+ int *lat_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item len
+The length of this coordinate dimension.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item formula_terms
+If non-NULL, a string which will be written as the ``formula_terms''
+attribute on the coordinate variable.
+
+ at item lat_dimidp
+If non-NULL, nccf_def_latitude will write the dimension ID of the
+netCDF dimension for the latitude here.
+
+ at item lat_varidp
+If non-NULL, nccf_def_latitude will write the variable ID of the
+netCDF coordinate variable for the latitude here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_latitude, nccf_def_longitude, nccf_def_latitude, Variables
+ at section Learn about a latitude coordinate variable and dimension with
+nccf_inq_latitude
+
+Inquire about a latitude dimension and coordinate variable.
+
+ at heading Usage
+
+ at example
+int nccf_inq_latitude(int ncid, size_t *lenp, nc_type *xtypep,
+ size_t *ft_lenp, char *formula_terms,
+ int *lat_dimidp, int *lat_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item lenp
+If non-NULL, the length of the latitude dimension will be written
+here by nccf_inq_latitude.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item ft_lenp
+If non-NULL, the length of the value of the ``formula_terms''
+attribute will be written here by ft_lenp. If there is no
+``formula_terms'' attribute, zero will be written.
+
+ at item lat_dimidp
+If non-NULL, the dimid of the latitude dimension will be written here.
+
+ at item lat_varidp
+If non-NULL, the varid of the latitude coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_longitude, nccf_inq_longitude, nccf_inq_latitude, Variables
+ at section Define a coordinate variable and dimension for longitude with nccf_def_longitude
+
+Define a coordinate variable and dimension with all the CF
+recommended attribute accessories for longitude.
+
+ at heading Usage
+
+ at example
+int nccf_def_longitude(int ncid, size_t len, nc_type xtype,
+ const char *formula_terms, int *lon_dimidp,
+ int *lon_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item len
+The length of this coordinate dimension.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item formula_terms
+If non-NULL, a string which will be written as the ``formula_terms''
+attribute on the coordinate variable.
+
+ at item lon_dimidp
+If non-NULL, nccf_def_longitude will write the dimension ID of the
+netCDF dimension for the longitude here.
+
+ at item lon_varidp
+If non-NULL, nccf_def_longitude will write the variable ID of the
+netCDF coordinate variable for the longitude here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_longitude, nccf_def_lvl, nccf_def_longitude, Variables
+ at section Learn about a longitude coordinate variable and dimension with
+nccf_inq_longitude
+
+Inquire about a longitude dimension and coordinate variable.
+
+ at heading Usage
+
+ at example
+int nccf_inq_longitude(int ncid, size_t *lenp, nc_type *xtypep,
+ size_t *ft_lenp, char *formula_terms,
+ int *lon_dimidp, int *lon_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item lenp
+If non-NULL, the length of the longitude dimension will be written
+here by nccf_inq_longitude.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item ft_lenp
+If non-NULL, the length of the value of the ``formula_terms''
+attribute will be written here by ft_lenp. If there is no
+``formula_terms'' attribute, zero will be written.
+
+ at item lon_dimidp
+If non-NULL, the dimid of the longitude dimension will be written here.
+
+ at item lon_varidp
+If non-NULL, the varid of the longitude coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_lvl, nccf_inq_lvl, nccf_inq_longitude, Variables
+ at section Define a coordinate variable and dimension for level with nccf_def_lvl
+
+Define a coordinate variable and dimension with all the CF
+recommended attribute accessories for a vertical level.
+
+ at heading Usage
+
+ at example
+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 *long_name, const char *formula_terms,
+ int *lvl_dimidp, int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+The name of the coordinate dimension and variable.
+
+ at item len
+The length of this coordinate dimension and variable.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item units
+If non-NULL, a string which will be written as the ``units''
+attribute on the coordinate variable.
+
+ at item positive_up
+Set to 0 and the attribute ``positive'' to ``down''. Set to any other
+value to get ``up''.
+
+ at item standard_name
+If non-NULL, a string which will be written as the ``standard_name''
+attribute on the coordinate variable.
+
+ at item long_name
+If non-NULL, a string which will be written as the ``long_name''
+attribute on the coordinate variable.
+
+ at item lon_dimidp
+If non-NULL, nccf_def_lvl will write the dimension ID of the
+netCDF dimension for the level here.
+
+ at item lon_varidp
+If non-NULL, nccf_def_lvl will write the variable ID of the
+netCDF coordinate variable for the level here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl, nccf_def_lvl_vert, nccf_def_lvl, Variables
+ at section Learn about a level coordinate variable and dimension with
+nccf_inq_lvl
+
+Inquire about a level dimension and coordinate variable.
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, the name of this vertical level dimension (and variable)
+will be written here.
+
+ at item lenp
+If non-NULL, the length of the level dimension will be written
+here by nccf_inq_lvl.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item ft_lenp
+If non-NULL, the length of the value of the ``formula_terms''
+attribute will be written here by ft_lenp. If there is no
+``formula_terms'' attribute, zero will be written.
+
+ at item positive_upp
+If non-NULL, a one will be written here if the ``positive'' attribute
+of this coordinate variable is ``up'', a zero will be written if it is
+``down''.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the level dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the level coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_lvl_vert, nccf_inq_lvl_vert, nccf_inq_lvl, Variables
+ at section Define a coordinate variable and dimension for level with nccf_def_lvl
+
+Define a unitless vertical coordinate variable and dimension from
+Apendix D of the CF Convention, with all the CF recommended attribute
+accessories for a vertical level.
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item lvl_type
+One of: CF_VERT_ATM_LN, CF_VERT_SIGMA, CF_VERT_HYBRID_SIGMA,
+CF_VERT_HYBRID_HEIGHT, CF_VERT_SLEVE, CF_VERT_OCEAN_SIGMA,
+CF_VERT_OCEAN_S, CF_VERT_OCEAN_SIGMA_Z, CF_VERT_OCEAN_DBL_SIGMA.
+
+ at item name
+The name of the coordinate dimension and variable.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item len
+The length of this coordinate dimension and variable.
+
+ at item lvl_dimidp
+If non-NULL, the function will write the dimension ID of the
+netCDF dimension for the level here.
+
+ at item llvl_varidp
+If non-NULL, the function will write the variable ID of the
+netCDF coordinate variable for the level here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_vert, nccf_def_time, nccf_def_lvl_vert, Variables
+ at section Learn about a level coordinate variable and dimension with
+nccf_inq_lvl
+
+Inquire about a level dimension and coordinate variable.
+
+ at heading Usage
+
+ at example
+int nccf_inq_lvl_vert(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *lvl_typep, int *lvl_dimidp, int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, the name of this vertical level dimension (and variable)
+will be written here.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the level dimension will be written
+here.
+
+ at item lvl_typep
+If non-NULL, the type of vertical dimension will be written here, one
+of CF_VERT_ATM_LN, CF_VERT_SIGMA, CF_VERT_HYBRID_SIGMA,
+CF_VERT_HYBRID_HEIGHT, CF_VERT_SLEVE, CF_VERT_OCEAN_SIGMA,
+CF_VERT_OCEAN_S, CF_VERT_OCEAN_SIGMA_Z, CF_VERT_OCEAN_DBL_SIGMA.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the level dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the level coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_time, nccf_inq_time, nccf_inq_lvl_vert, Variables
+ at section Define a coordinate variable and dimension for time with nccf_def_time
+
+Define a coordinate variable and dimension with all the CF
+recommended attribute accessories for time.
+
+ at heading Usage
+
+ at example
+int nccf_def_time(int ncid, const char *name, size_t len, nc_type xtype,
+ const char *units, const char *standard_name, const char *long_name,
+ const char *formula_terms, int *time_dimidp, int *time_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item len
+The length of this coordinate dimension.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item formula_terms
+If non-NULL, a string which will be written as the ``formula_terms''
+attribute on the coordinate variable.
+
+ at item lon_dimidp
+If non-NULL, nccf_def_time will write the dimension ID of the
+netCDF dimension for the time here.
+
+ at item lon_varidp
+If non-NULL, nccf_def_time will write the variable ID of the
+netCDF coordinate variable for the time here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_time, nccf_def_ft_sigma, nccf_def_time, Variables
+ at section Learn about a time coordinate variable and dimension with
+nccf_inq_time
+
+Inquire about a time dimension and coordinate variable.
+
+ at heading Usage
+
+ at example
+int nccf_inq_time(int ncid, size_t *lenp, nc_type *xtypep, size_t *ft_lenp,
+ char *formula_terms, int *time_dimidp, int *time_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item lenp
+If non-NULL, the length of the time dimension will be written
+here by nccf_inq_time.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item ft_lenp
+If non-NULL, the length of the value of the ``formula_terms''
+attribute will be written here by ft_lenp. If there is no
+``formula_terms'' attribute, zero will be written.
+
+ at item formula_terms
+If non-NULL the value of the ``formula_terms'' attribute, if any, will
+be copied here.
+
+ at item time_dimidp
+If non-NULL, the dimid of the time dimension will be written here.
+
+ at item time_varidp
+If non-NULL, the varid of the time coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_sigma, nccf_inq_lvl_sigma, nccf_inq_time, Variables
+ at section Define atmosphere sigma coordinate.
+
+Define formula terms attribute for atmosphere sigma coordinate variable.
+
+ at heading Usage
+
+ at example
+int nccf_def_ft_sigma(int ncid, int varid, int ps_varid, int ptop_varid);
+
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item ps_varid
+The variable ID of the ps variable.
+
+ at item ptop_varid
+The variable ID of the ptop variable.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_sigma, nccf_def_ft_hybrid_sigma, nccf_def_ft_sigma, Variables
+ at section Inquire about atmosphere sigma coordinate.
+nccf_inq_time
+
+Inquire about atmosphere sigma coordinate.
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item ps_varidp
+If non-NULL, the variable ID of the ps variable will be written
+here.
+
+ at item ptop_varidp
+If non-NULL, the variable ID of the ptop variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_hybrid_sigma, nccf_inq_lvl_hybrid_sigma, nccf_inq_lvl_sigma, Variables
+ at section Define atmosphere sigma coordinate.
+
+Define formula terms attribute for atmosphere hybrid sigma coordinate
+variable.
+
+ at heading Usage
+
+ at example
+int nccf_def_ft_hybrid_sigma(int ncid, int varid, int a_varid, int b_varid,
+ int ps_varid, int p0_varid);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item a_varid
+The variable ID of the a variable.
+
+ at item b_varid
+The variable ID of the b variable.
+
+ at item ps_varid
+The variable ID of the ps variable.
+
+ at item ptop_varid
+The variable ID of the ptop variable.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_hybrid_sigma, nccf_def_ft_hybrid_height, nccf_def_ft_hybrid_sigma, Variables
+ at section Inquire about atmosphere sigma coordinate.
+
+Inquire about atmosphere hybrid sigma coordinate.
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item a_varidp
+If non-NULL, the variable ID of the a variable will be written
+here.
+
+ at item b_varidp
+If non-NULL, the variable ID of the b variable will be written
+here.
+
+ at item ps_varidp
+If non-NULL, the variable ID of the ps variable will be written
+here.
+
+ at item ptop_varidp
+If non-NULL, the variable ID of the ptop variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_hybrid_height, nccf_inq_lvl_hybrid_height, nccf_inq_lvl_hybrid_sigma, Variables
+ at section The formula_terms attribute for atmosphere hybrid height
+
+Define formula terms attribute for atmosphere hybrid height
+coordinate variable
+
+ at heading Usage
+
+ at example
+int nccf_def_ft_hybrid_height(int ncid, int varid, int a_varid, int b_varid,
+ int orog_varid);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item a_varid
+The variable ID of the a variable.
+
+ at item b_varid
+The variable ID of the b variable.
+
+ at item orog_varid
+The variable ID of the orog variable.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_hybrid_height, nccf_def_ft_sleve, nccf_def_ft_hybrid_height, Variables
+ at section Inquire about hybrid height coordinate.
+
+Inquire about the hybrid height coordinate.
+
+ at heading Usage
+
+ at example
+int nccf_inq_lvl_hybrid_height(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *a_varidp, int *b_varidp, int *orog_varidp,
+ int *lvl_dimidp, int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item a_varidp
+If non-NULL, the variable ID of the a variable will be written
+here.
+
+ at item b_varidp
+If non-NULL, the variable ID of the b variable will be written
+here.
+
+ at item orog_varidp
+If non-NULL, the variable ID of the orog variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_sleve, nccf_inq_lvl_sleve, nccf_inq_lvl_hybrid_height, Variables
+ at section Define atmosphere sleve coordinate.
+
+Define formula terms attribute for the atmosphere sleve coordinate
+variable.
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item a_varid
+The variable ID of the a variable.
+
+ at item b1_varid
+The variable ID of the b1 variable.
+
+ at item b2_varid
+The variable ID of the b2 variable.
+
+ at item ztop_varid
+The variable ID of the ztop variable.
+
+ at item zsurf1_varid
+The variable ID of the zsurf1 variable.
+
+ at item zsurf2_varid
+The variable ID of the zsurf2 variable.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_sleve, nccf_def_ft_ocean_sigma, nccf_def_ft_sleve, Variables
+ at section Inquire About Sleve Coordinate.
+
+Inquire about the sleve coordinate.
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item a_varidp
+If non-NULL, the variable ID of the a variable will be written
+here.
+
+ at item b1_varidp
+If non-NULL, the variable ID of the b1 variable will be written
+here.
+
+ at item b2_varidp
+If non-NULL, the variable ID of the b2 variable will be written
+here.
+
+ at item ztop_varidp
+If non-NULL, the variable ID of the ztop variable will be written
+here.
+
+ at item zsurf1_varidp
+If non-NULL, the variable ID of the zsurf1 variable will be written
+here.
+
+ at item zsurf2_varidp
+If non-NULL, the variable ID of the zsurf2 variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_ocean_sigma, nccf_inq_lvl_ocean_sigma, nccf_inq_lvl_sleve, Variables
+ at section Define Ocean Sigma Coordinate.
+
+Define the formula terms attribute for the ocean sigma coordinate variable.
+
+ at heading Usage
+
+ at example
+int nccf_def_ft_ocean_sigma(int ncid, int varid, int eta_varid, int depth_varid);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item eta_varid
+The variable ID of the eta variable.
+
+ at item depth_varid
+The variable ID of the depth variable.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_ocean_sigma, nccf_def_ft_ocean_s, nccf_def_ft_ocean_sigma, Variables
+ at section Inquire About Ocean Sigma Coordinate.
+
+Inquire about the ocean sigma coordinate.
+
+ at heading Usage
+
+ at example
+int nccf_inq_lvl_ocean_sigma(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *lvl_dimidp,
+ int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item eta_varidp
+If non-NULL, the variable ID of the eta variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_ocean_s, nccf_inq_lvl_ocean_s, nccf_inq_lvl_ocean_sigma, Variables
+ at section Define Ocean S Coordinate.
+
+Define ocean s coordinate.
+
+ at heading Usage
+
+ at example
+int nccf_def_ft_ocean_s(int ncid, const char *name, nc_type xtype, size_t len,
+ int eta_varid, int depth_varid, int a_varid, int b_varid,
+ int depth_c_varid, int *lvl_dimidp, int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item len
+The length of this coordinate dimension.
+
+ at item eta_varid
+The variable ID of the eta variable.
+
+ at item depth_varid
+The variable ID of the depth variable.
+
+ at item a_varid
+The variable ID of the a variable.
+
+ at item b_varid
+The variable ID of the b variable.
+
+ at item depth_c_varid
+The variable ID of the depth_c variable.
+
+ at item lvl_dimidp
+If non-NULL, the dimension ID of the netCDF coordinate dimension will
+be written here.
+
+ at item lvl_varidp
+If non-NULL, the variable ID of the netCDF coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_ocean_s, nccf_def_ft_ocean_sigma_z, nccf_def_ft_ocean_s, Variables
+ at section Inquire About Ocean S Coordinate.
+nccf_inq_time
+
+Inquire about the ocean s coordinate.
+
+ at heading Usage
+
+ at example
+int nccf_inq_lvl_ocean_s(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *a_varidp, int *b_varidp,
+ int *depth_c_varidp, int *lvl_dimidp, int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item eta_varidp
+If non-NULL, the variable ID of the eta variable will be written
+here.
+
+ at item depth_varidp
+If non-NULL, the variable ID of the depth variable will be written
+here.
+
+ at item a_varidp
+If non-NULL, the variable ID of the a variable will be written
+here.
+
+ at item b_varidp
+If non-NULL, the variable ID of the b variable will be written
+here.
+
+ at item depth_c_varidp
+If non-NULL, the variable ID of the depth_c variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_ocean_sigma_z, nccf_inq_lvl_ocean_sigma_z, nccf_inq_lvl_ocean_s, Variables
+ at section Define Ocean Sigma Z Coordinate.
+
+Define ocean sigma z coordinate.
+
+ at heading Usage
+
+ at example
+int nccf_def_ft_ocean_sigma_z(int ncid, const char *name, nc_type xtype,
+ size_t len, int eta_varid, int depth_varid,
+ int depth_c_varid, int nsigma_varid,
+ int zlev_varid, int *lvl_dimidp, int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item len
+The length of this coordinate dimension.
+
+ at item eta_varid
+The variable ID of the eta variable.
+
+ at item depth_varid
+The variable ID of the depth variable.
+
+ at item depth_c_varid
+The variable ID of the depth_c variable.
+
+ at item nsigma_varid
+The variable ID of the nsigma variable.
+
+ at item zlev_varid
+The variable ID of the zlev variable.
+
+ at item lvl_dimidp
+If non-NULL, the dimension ID of the netCDF coordinate dimension will
+be written here.
+
+ at item lvl_varidp
+If non-NULL, the variable ID of the netCDF coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_ocean_sigma_z, nccf_def_ft_ocean_dbl_sigma, nccf_def_ft_ocean_sigma_z, Variables
+ at section Inquire About Ocean Sigma Z Coordinate.
+
+Inquire about the ocean sigma z coordinate.
+
+ at heading Usage
+
+ at example
+int nccf_inq_lvl_ocean_sigma_z(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *depth_c_varidp,
+ int *nsigma_varidp, int *zlev_varidp, int *lvl_dimidp,
+ int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item eta_varidp
+If non-NULL, the variable ID of the eta variable will be written
+here.
+
+ at item depth_varidp
+If non-NULL, the variable ID of the depth variable will be written
+here.
+
+ at item depth_c_varidp
+If non-NULL, the variable ID of the depth_c variable will be written
+here.
+
+ at item nsigma_varidp
+If non-NULL, the variable ID of the nsigma variable will be written
+here.
+
+ at item zlev_varidp
+If non-NULL, the variable ID of the zlev variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_def_ft_ocean_dbl_sigma, nccf_inq_lvl_ocean_dbl_sigma, nccf_inq_lvl_ocean_sigma_z, Variables
+ at section Define Ocean Double Sigma Coordinate.
+
+Define ocean double sigma coordinate.
+
+ at heading Usage
+
+ at example
+int nccf_def_ft_ocean_dbl_sigma(int ncid, const char *name, nc_type xtype, size_t len,
+ int depth_varid, int z1_varid, int z2_varid, int a_varid,
+ int href_varid, int k_c_varid, int *lvl_dimidp,
+ int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the vertical coordinate variable.
+
+ at item xtype
+The type of this coordinate variable.
+
+ at item len
+The length of this coordinate dimension.
+
+ at item depth_varid
+The variable ID of the depth variable.
+
+ at item z1_varid
+The variable ID of the z1 variable.
+
+ at item z2_varid
+The variable ID of the z2 variable.
+
+ at item a_varid
+The variable ID of the a variable.
+
+ at item href_varid
+The variable ID of the href variable.
+
+ at item k_c_varid
+The variable ID of the k_c variable.
+
+ at item lvl_dimidp
+If non-NULL, the dimension ID of the netCDF coordinate dimension will
+be written here.
+
+ at item lvl_varidp
+If non-NULL, the variable ID of the netCDF coordinate variable will be
+written here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_inq_lvl_ocean_dbl_sigma, nccf_get_vara, nccf_def_ft_ocean_dbl_sigma, Variables
+ at section Inquire About Ocean Double Sigma Coordinate.
+
+Inquire about the ocean double sigma coordinate.
+
+ at heading Usage
+
+ at example
+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 *href_varidp, int *k_c_varidp,
+ int *lvl_dimidp, int *lvl_varidp);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item name
+If non-NULL, this pointer gets the name of the coordinate variable and
+dimension.
+
+ at item xtypep
+If non-NULL, the type of the coordinate variable will be written here.
+
+ at item lenp
+If non-NULL, the length of the coordinate dimension will be written
+here.
+
+ at item depth_varidp
+If non-NULL, the variable ID of the depth variable will be written
+here.
+
+ at item z1_varidp
+If non-NULL, the variable ID of the z1 variable will be written
+here.
+
+ at item z2_varidp
+If non-NULL, the variable ID of the z2 variable will be written
+here.
+
+ at item a_varidp
+If non-NULL, the variable ID of the a variable will be written
+here.
+
+ at item href_varidp
+If non-NULL, the variable ID of the href variable will be written
+here.
+
+ at item k_c_varidp
+If non-NULL, the variable ID of the k_c variable will be written
+here.
+
+ at item lvl_dimidp
+If non-NULL, the dimid of the coordinate dimension will be written here.
+
+ at item lvl_varidp
+If non-NULL, the varid of the coordinate variable will be written
+here.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf_get_vara, , nccf_inq_lvl_ocean_dbl_sigma, Variables
+ at section Get a geographic subset of the data.
+
+Get a geographic subset of the data.
+
+ at heading Usage
+
+ at example
+ int nccf_get_vara(int ncid, int varid, float *lat_bounds, int *nlat, float *lon_bounds,
+ int *nlon, int *lvl_index, int *nlvl, int rec, void *data);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at item varid
+The varid of the data variable from which the subset will be taken.
+
+ at item lat_bounds
+A length two array, this holds the latitude start and stop values for
+the range of interest.
+
+ at item nlat
+A pointer to an integer which will get the number of latitude values
+which fall within the range.
+
+ at item lon_bounds
+A length two array, this holds the longitude start and stop values for
+the range of interest. (Wrapping around the dateline is not allowed!)
+
+ at item nlon
+A pointer to an integer which will get the number of longitude values
+which fall within the range.
+
+ at item lvl_index
+A zero-based index number for the verticle level of interest to the
+subsetter. (Ignored if data has no vertical axis).
+
+ at item timestep
+A zero-based index number for the timestep of interest to the
+subsetter. (Ignored if data has no time axis).
+
+ at item data
+A pointer to which the data subset will be written. Memory must be
+allocated (and deallocated) by the user.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or an error code for failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node Coordinates, Combined Index, Variables, Top
+ at chapter Coordinate Systems
+
+ at menu
+* nccf-def-axis-type::
+* nccf-inq-axis-type::
+* nccf-def-coord-system::
+* nccf-inq-coord-system::
+* nccf-assign-coord-system::
+* nccf-def-transform::
+* nccf-inq-transform::
+* nccf-assign-transform::
+ at end menu
+
+ at node nccf-def-axis-type, nccf-inq-axis-type, Coordinates, Coordinates
+ at section Label the axis type of a coordinate var with nccf_def_axis_type
+
+ at heading Usage
+
+ at example
+int
+nccf_def_axis_type(int ncid, int varid, int axis_type);
+ at end example
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf-inq-axis-type, nccf-def-coord-system, nccf-def-axis-type, Coordinates
+ at section Find out the axis type of a coordinate var with nccf_inq_axis_type
+
+ at heading Usage
+
+ at example
+int
+nccf_inq_axis_type(int ncid, int varid, int *axis_type);
+ at end example
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf-def-coord-system, nccf-inq-coord-system, nccf-inq-axis-type, Coordinates
+ at section Define a coordinate system with nccf_def_coord_system
+
+ at heading Usage
+
+ at example
+int
+nccf_def_coord_system(int ncid, const char *name, int naxes, int *axis_varids,
+ int *system_varid);
+ at end example
+
+Define a coordinate system consisting of naxes axes, each axis
+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.
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf-inq-coord-system, nccf-assign-coord-system, nccf-def-coord-system, Coordinates
+ at section Find out about a coordinate system with nccf_inq_coord_system
+
+ at heading Usage
+
+ at example
+int
+nccf_inq_coord_system(int ncid, int system_varid, char *name,
+ int *naxes, int *axis_varids);
+ at end example
+
+Find out about a coordinate system, it's name, number of axes, and the
+varid of each axis coordinate var.
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf-assign-coord-system, nccf-def-transform, nccf-inq-coord-system, Coordinates
+ at section Assign a coordinate system to a var with nccf_assign_coord_system
+
+ at heading Usage
+
+ at example
+int
+nccf_assign_coord_system(int ncid, int varid, int system_varid);
+ at end example
+
+Assign a coordinate system to a var. This adds an attribute to the
+var.
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf-def-transform, nccf-inq-transform, nccf-assign-coord-system, Coordinates
+ at section Define a coordinate transform with nccf_def_transform
+
+ at heading Usage
+
+ at example
+int
+nccf_def_transform(int ncid, const char *name, const char *transform_type,
+ const char *transform_name, int *transform_varid);
+ at end example
+
+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.
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf-inq-transform, nccf-assign-transform, nccf-def-transform, Coordinates
+ at section Find out about a coordinate transform with nccf_inq_transform
+
+ at heading Usage
+
+ at example
+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);
+ at end example
+
+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.
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node nccf-assign-transform, , nccf-inq-transform, Coordinates
+ at section Assign a coordinate transform to a coordinate system with nccf_assign_transform
+
+ at heading Usage
+
+ at example
+int
+nccf_assign_transform(int ncid, int system_varid, int transform_varid);
+ at end example
+
+Assign a coordinate transform to a coordinate system. This adds an
+attribute to the variable that holds the coordinate system
+attributes.
+
+
+ at table @code
+
+ at item ncid
+The ncid of the file.
+
+ at end table
+
+ at heading Return Codes
+
+This function returns zero for success, or a netCDF error code for
+failure.
+
+ at heading Example
+
+ at example
+ at end example
+
+ at node Combined Index, , Coordinates, Top
+ at unnumbered Index
+
+ at printindex cp
+
+ at bye
+End:
diff --git a/doc/mdate-sh b/doc/mdate-sh
new file mode 100755
index 0000000..cd916c0
--- /dev/null
+++ b/doc/mdate-sh
@@ -0,0 +1,201 @@
+#!/bin/sh
+# Get modification time of a file or directory and pretty-print it.
+
+scriptversion=2005-06-29.22
+
+# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 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
+# 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.
+#
+# 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.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
+
+case $1 in
+ '')
+ echo "$0: No file. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: mdate-sh [--help] [--version] FILE
+
+Pretty-print the modification time of FILE.
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "mdate-sh $scriptversion"
+ exit $?
+ ;;
+esac
+
+# Prevent date giving response in another language.
+LANG=C
+export LANG
+LC_ALL=C
+export LC_ALL
+LC_TIME=C
+export LC_TIME
+
+# GNU ls changes its time format in response to the TIME_STYLE
+# variable. Since we cannot assume `unset' works, revert this
+# variable to its documented default.
+if test "${TIME_STYLE+set}" = set; then
+ TIME_STYLE=posix-long-iso
+ export TIME_STYLE
+fi
+
+save_arg1=$1
+
+# Find out how to get the extended ls output of a file or directory.
+if ls -L /dev/null 1>/dev/null 2>&1; then
+ ls_command='ls -L -l -d'
+else
+ ls_command='ls -l -d'
+fi
+
+# A `ls -l' line looks as follows on OS/2.
+# drwxrwx--- 0 Aug 11 2001 foo
+# This differs from Unix, which adds ownership information.
+# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
+#
+# To find the date, we split the line on spaces and iterate on words
+# until we find a month. This cannot work with files whose owner is a
+# user named `Jan', or `Feb', etc. However, it's unlikely that `/'
+# will be owned by a user whose name is a month. So we first look at
+# the extended ls output of the root directory to decide how many
+# 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 /`
+
+# Find which argument is the month.
+month=
+command=
+until test $month
+do
+ shift
+ # Add another shift to the command.
+ command="$command shift;"
+ case $1 in
+ Jan) month=January; nummonth=1;;
+ Feb) month=February; nummonth=2;;
+ Mar) month=March; nummonth=3;;
+ Apr) month=April; nummonth=4;;
+ May) month=May; nummonth=5;;
+ Jun) month=June; nummonth=6;;
+ Jul) month=July; nummonth=7;;
+ Aug) month=August; nummonth=8;;
+ Sep) month=September; nummonth=9;;
+ Oct) month=October; nummonth=10;;
+ Nov) month=November; nummonth=11;;
+ Dec) month=December; nummonth=12;;
+ esac
+done
+
+# Get the extended ls output of the file or directory.
+set dummy x`eval "$ls_command \"\$save_arg1\""`
+
+# Remove all preceding arguments
+eval $command
+
+# Because of the dummy argument above, month is in $2.
+#
+# On a POSIX system, we should have
+#
+# $# = 5
+# $1 = file size
+# $2 = month
+# $3 = day
+# $4 = year or time
+# $5 = filename
+#
+# On Darwin 7.7.0 and 7.6.0, we have
+#
+# $# = 4
+# $1 = day
+# $2 = month
+# $3 = year or time
+# $4 = filename
+
+# Get the month.
+case $2 in
+ Jan) month=January; nummonth=1;;
+ Feb) month=February; nummonth=2;;
+ Mar) month=March; nummonth=3;;
+ Apr) month=April; nummonth=4;;
+ May) month=May; nummonth=5;;
+ Jun) month=June; nummonth=6;;
+ Jul) month=July; nummonth=7;;
+ Aug) month=August; nummonth=8;;
+ Sep) month=September; nummonth=9;;
+ Oct) month=October; nummonth=10;;
+ Nov) month=November; nummonth=11;;
+ Dec) month=December; nummonth=12;;
+esac
+
+case $3 in
+ ???*) day=$1;;
+ *) day=$3; shift;;
+esac
+
+# Here we have to deal with the problem that the ls output gives either
+# the time of day or the year.
+case $3 in
+ *:*) set `date`; eval year=\$$#
+ case $2 in
+ Jan) nummonthtod=1;;
+ Feb) nummonthtod=2;;
+ Mar) nummonthtod=3;;
+ Apr) nummonthtod=4;;
+ May) nummonthtod=5;;
+ Jun) nummonthtod=6;;
+ Jul) nummonthtod=7;;
+ Aug) nummonthtod=8;;
+ Sep) nummonthtod=9;;
+ Oct) nummonthtod=10;;
+ Nov) nummonthtod=11;;
+ Dec) nummonthtod=12;;
+ esac
+ # For the first six month of the year the time notation can also
+ # be used for files modified in the last year.
+ if (expr $nummonth \> $nummonthtod) > /dev/null;
+ then
+ year=`expr $year - 1`
+ fi;;
+ *) year=$3;;
+esac
+
+# The result.
+echo $day $month $year
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/doc/stamp-vti b/doc/stamp-vti
new file mode 100644
index 0000000..5da139a
--- /dev/null
+++ b/doc/stamp-vti
@@ -0,0 +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
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
new file mode 100644
index 0000000..ff2c406
--- /dev/null
+++ b/doc/texinfo.tex
@@ -0,0 +1,7210 @@
+% texinfo.tex -- TeX macros to handle Texinfo files.
+%
+% 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}
+%
+% 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.
+%
+% 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.
+%
+% This texinfo.tex file 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 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.
+%
+% As a special exception, when this file is read by TeX when processing
+% a Texinfo source document, you may use the result without
+% restriction. (This has been our intent since Texinfo was invented.)
+%
+% Please try the latest version of texinfo.tex before submitting bug
+% reports; you can get the latest version from:
+% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
+% ftp://tug.org/tex/texinfo.tex
+% (and all CTAN mirrors, see http://www.ctan.org).
+% The texinfo.tex in any given distribution could well be out
+% of date, so if that's what you're using, please check.
+%
+% Send bug reports to bug-texinfo at gnu.org. Please include including a
+% complete document in each bug report with which we can reproduce the
+% problem. Patches are, of course, greatly appreciated.
+%
+% To process a Texinfo manual with TeX, it's most reliable to use the
+% texi2dvi shell script that comes with the distribution. For a simple
+% manual foo.texi, however, you can get away with this:
+% tex foo.texi
+% texindex foo.??
+% tex foo.texi
+% tex foo.texi
+% dvips foo.dvi -o # or whatever; this makes foo.ps.
+% The extra TeX runs get the cross-reference information correct.
+% Sometimes one run after texindex suffices, and sometimes you need more
+% than two; texi2dvi does it as many times as necessary.
+%
+% It is possible to adapt texinfo.tex for other languages, to some
+% extent. You can get the existing language-specific files from the
+% full Texinfo distribution.
+%
+% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
+
+
+\message{Loading texinfo [version \texinfoversion]:}
+
+% If in a .fmt file, print the version number
+% and turn on active characters that we couldn't do earlier because
+% they might have appeared in the input file name.
+\everyjob{\message{[Texinfo version \texinfoversion]}%
+ \catcode`+=\active \catcode`\_=\active}
+
+\message{Basics,}
+\chardef\other=12
+
+% We never want plain's \outer definition of \+ in Texinfo.
+% For @tex, we can use \tabalign.
+\let\+ = \relax
+
+% Save some plain tex macros whose names we will redefine.
+\let\ptexb=\b
+\let\ptexbullet=\bullet
+\let\ptexc=\c
+\let\ptexcomma=\,
+\let\ptexdot=\.
+\let\ptexdots=\dots
+\let\ptexend=\end
+\let\ptexequiv=\equiv
+\let\ptexexclam=\!
+\let\ptexfootnote=\footnote
+\let\ptexgtr=>
+\let\ptexhat=^
+\let\ptexi=\i
+\let\ptexindent=\indent
+\let\ptexinsert=\insert
+\let\ptexlbrace=\{
+\let\ptexless=<
+\let\ptexnewwrite\newwrite
+\let\ptexnoindent=\noindent
+\let\ptexplus=+
+\let\ptexrbrace=\}
+\let\ptexslash=\/
+\let\ptexstar=\*
+\let\ptext=\t
+
+% If this character appears in an error message or help string, it
+% starts a new line in the output.
+\newlinechar = `^^J
+
+% Use TeX 3.0's \inputlineno to get the line number, for better error
+% messages, but if we're using an old version of TeX, don't do anything.
+%
+\ifx\inputlineno\thisisundefined
+ \let\linenumber = \empty % Pre-3.0.
+\else
+ \def\linenumber{l.\the\inputlineno:\space}
+\fi
+
+% Set up fixed words for English if not already set.
+\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
+\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
+\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
+\ifx\putwordin\undefined \gdef\putwordin{in}\fi
+\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
+\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
+\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
+\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
+\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
+\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
+\ifx\putwordof\undefined \gdef\putwordof{of}\fi
+\ifx\putwordon\undefined \gdef\putwordon{on}\fi
+\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
+\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
+\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
+\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
+\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
+\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
+\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
+%
+\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
+\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
+\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
+\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
+\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
+\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
+\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
+\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
+\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
+\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
+\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
+\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
+%
+\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
+\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
+\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
+\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 = `\\
+\chardef\colonChar = `\:
+\chardef\commaChar = `\,
+\chardef\dotChar = `\.
+\chardef\exclamChar= `\!
+\chardef\plusChar = `\+
+\chardef\questChar = `\?
+\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{}
+
+% The following is used inside several \edef's.
+\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
+
+% Hyphenation fixes.
+\hyphenation{
+ Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
+ ap-pen-dix bit-map bit-maps
+ data-base data-bases eshell fall-ing half-way long-est man-u-script
+ man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
+ par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
+ spell-ing spell-ings
+ stand-alone strong-est time-stamp time-stamps which-ever white-space
+ wide-spread wrap-around
+}
+
+% Margin to add to right of even pages, to left of odd pages.
+\newdimen\bindingoffset
+\newdimen\normaloffset
+\newdimen\pagewidth \newdimen\pageheight
+
+% For a final copy, take out the rectangles
+% that mark overfull boxes (in case you have decided
+% that the text looks ok even though it passes the margin).
+%
+\def\finalout{\overfullrule=0pt}
+
+% @| inserts a changebar to the left of the current line. It should
+% surround any changed text. This approach does *not* work if the
+% change spans more than two lines of output. To handle that, we would
+% have adopt a much more difficult approach (putting marks into the main
+% vertical list for the beginning and end of each change).
+%
+\def\|{%
+ % \vadjust can only be used in horizontal mode.
+ \leavevmode
+ %
+ % Append this vertical mode material after the current line in the output.
+ \vadjust{%
+ % We want to insert a rule with the height and depth of the current
+ % leading; that is exactly what \strutbox is supposed to record.
+ \vskip-\baselineskip
+ %
+ % \vadjust-items are inserted at the left edge of the type. So
+ % the \llap here moves out into the left-hand margin.
+ \llap{%
+ %
+ % For a thicker or thinner bar, change the `1pt'.
+ \vrule height\baselineskip width1pt
+ %
+ % This is the space between the bar and the text.
+ \hskip 12pt
+ }%
+ }%
+}
+
+% Sometimes it is convenient to have everything in the transcript file
+% and nothing on the terminal. We don't just call \tracingall here,
+% since that produces some useless output on the terminal. We also make
+% some effort to order the tracing commands to reduce output in the log
+% file; cf. trace.sty in LaTeX.
+%
+\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
+\def\loggingall{%
+ \tracingstats2
+ \tracingpages1
+ \tracinglostchars2 % 2 gives us more in etex
+ \tracingparagraphs1
+ \tracingoutput1
+ \tracingmacros2
+ \tracingrestores1
+ \showboxbreadth\maxdimen \showboxdepth\maxdimen
+ \ifx\eTeXversion\undefined\else % etex gives us more logging
+ \tracingscantokens1
+ \tracingifs1
+ \tracinggroups1
+ \tracingnesting2
+ \tracingassigns1
+ \fi
+ \tracingcommands3 % 3 gives us more in etex
+ \errorcontextlines16
+}%
+
+% add check for \lastpenalty to plain's definitions. If the last thing
+% we did was a \nobreak, we don't want to insert more space.
+%
+\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
+ \removelastskip\penalty-50\smallskip\fi\fi}
+\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
+ \removelastskip\penalty-100\medskip\fi\fi}
+\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
+ \removelastskip\penalty-200\bigskip\fi\fi}
+
+% For @cropmarks command.
+% Do @cropmarks to get crop marks.
+%
+\newif\ifcropmarks
+\let\cropmarks = \cropmarkstrue
+%
+% Dimensions to add cropmarks at corners.
+% Added by P. A. MacKay, 12 Nov. 1986
+%
+\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
+\newdimen\cornerlong \cornerlong=1pc
+\newdimen\cornerthick \cornerthick=.3pt
+\newdimen\topandbottommargin \topandbottommargin=.75in
+
+% Main output routine.
+\chardef\PAGE = 255
+\output = {\onepageout{\pagecontents\PAGE}}
+
+\newbox\headlinebox
+\newbox\footlinebox
+
+% \onepageout takes a vbox as an argument. Note that \pagecontents
+% does insertions, but you have to call it yourself.
+\def\onepageout#1{%
+ \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
+ %
+ \ifodd\pageno \advance\hoffset by \bindingoffset
+ \else \advance\hoffset by -\bindingoffset\fi
+ %
+ % Do this outside of the \shipout so @code etc. will be expanded in
+ % the headline as they should be, not taken literally (outputting ''code).
+ \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
+ \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
+ %
+ {%
+ % Have to do this stuff outside the \shipout because we want it to
+ % take effect in \write's, yet the group defined by the \vbox ends
+ % before the \shipout runs.
+ %
+ \indexdummies % don't expand commands in the output.
+ \shipout\vbox{%
+ % Do this early so pdf references go to the beginning of the page.
+ \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
+ %
+ \ifcropmarks \vbox to \outervsize\bgroup
+ \hsize = \outerhsize
+ \vskip-\topandbottommargin
+ \vtop to0pt{%
+ \line{\ewtop\hfil\ewtop}%
+ \nointerlineskip
+ \line{%
+ \vbox{\moveleft\cornerthick\nstop}%
+ \hfill
+ \vbox{\moveright\cornerthick\nstop}%
+ }%
+ \vss}%
+ \vskip\topandbottommargin
+ \line\bgroup
+ \hfil % center the page within the outer (page) hsize.
+ \ifodd\pageno\hskip\bindingoffset\fi
+ \vbox\bgroup
+ \fi
+ %
+ \unvbox\headlinebox
+ \pagebody{#1}%
+ \ifdim\ht\footlinebox > 0pt
+ % Only leave this space if the footline is nonempty.
+ % (We lessened \vsize for it in \oddfootingxxx.)
+ % The \baselineskip=24pt in plain's \makefootline has no effect.
+ \vskip 2\baselineskip
+ \unvbox\footlinebox
+ \fi
+ %
+ \ifcropmarks
+ \egroup % end of \vbox\bgroup
+ \hfil\egroup % end of (centering) \line\bgroup
+ \vskip\topandbottommargin plus1fill minus1fill
+ \boxmaxdepth = \cornerthick
+ \vbox to0pt{\vss
+ \line{%
+ \vbox{\moveleft\cornerthick\nsbot}%
+ \hfill
+ \vbox{\moveright\cornerthick\nsbot}%
+ }%
+ \nointerlineskip
+ \line{\ewbot\hfil\ewbot}%
+ }%
+ \egroup % \vbox from first cropmarks clause
+ \fi
+ }% end of \shipout\vbox
+ }% end of group with \indexdummies
+ \advancepageno
+ \ifnum\outputpenalty>-20000 \else\dosupereject\fi
+}
+
+\newinsert\margin \dimen\margin=\maxdimen
+
+\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
+{\catcode`\@ =11
+\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
+% 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
+\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
+\ifr at ggedbottom \kern-\dimen@ \vfil \fi}
+}
+
+% Here are the rules for the cropmarks. Note that they are
+% offset so that the space between them is truly \outerhsize or \outervsize
+% (P. A. MacKay, 12 November, 1986)
+%
+\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
+\def\nstop{\vbox
+ {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
+\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
+\def\nsbot{\vbox
+ {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
+
+% Parse an argument, then pass it to #1. The argument is the rest of
+% the input line (except we remove a trailing comment). #1 should be a
+% macro which expects an ordinary undelimited TeX argument.
+%
+\def\parsearg{\parseargusing{}}
+\def\parseargusing#1#2{%
+ \def\next{#2}%
+ \begingroup
+ \obeylines
+ \spaceisspace
+ #1%
+ \parseargline\empty% Insert the \empty token, see \finishparsearg below.
+}
+
+{\obeylines %
+ \gdef\parseargline#1^^M{%
+ \endgroup % End of the group started in \parsearg.
+ \argremovecomment #1\comment\ArgTerm%
+ }%
+}
+
+% First remove any @comment, then any @c comment.
+\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.
+%
+% \argremovec might leave us with trailing space, e.g.,
+% @end itemize @c foo
+% This space token undergoes the same procedure and is eventually removed
+% by \finishparsearg.
+%
+\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
+\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
+\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.
+ \let\temp\finishparsearg
+ \else
+ \let\temp\argcheckspaces
+ \fi
+ % Put the space token in:
+ \temp#1 #3\ArgTerm
+}
+
+% 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
+% 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}}
+
+% \parseargdef\foo{...}
+% is roughly equivalent to
+% \def\foo{\parsearg\Xfoo}
+% \def\Xfoo#1{...}
+%
+% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
+% favourite TeX trick. --kasal, 16nov03
+
+\def\parseargdef#1{%
+ \expandafter \doparseargdef \csname\string#1\endcsname #1%
+}
+\def\doparseargdef#1#2{%
+ \def#2{\parsearg#1}%
+ \def#1##1%
+}
+
+% Several utility definitions with active space:
+{
+ \obeyspaces
+ \gdef\obeyedspace{ }
+
+ % Make each space character in the input produce a normal interword
+ % space in the output. Don't allow a line break at this space, as this
+ % is used only in environments like @example, where each line of input
+ % should produce a line of output anyway.
+ %
+ \gdef\sepspaces{\obeyspaces\let =\tie}
+
+ % If an index command is used in an @example environment, any spaces
+ % therein should become regular spaces in the raw index file, not the
+ % expansion of \tie (\leavevmode \penalty \@M \ ).
+ \gdef\unsepspaces{\let =\space}
+}
+
+
+\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
+
+% Define the framework for environments in texinfo.tex. It's used like this:
+%
+% \envdef\foo{...}
+% \def\Efoo{...}
+%
+% It's the responsibility of \envdef to insert \begingroup before the
+% actual body; @end closes the group after calling \Efoo. \envdef also
+% defines \thisenv, so the current environment is known; @end checks
+% whether the environment name matches. The \checkenv macro can also be
+% 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
+% implementation of @end takes care not to call \endgroup in this
+% special case.)
+
+
+% At runtime, environments start with this:
+\def\startenvironment#1{\begingroup\def\thisenv{#1}}
+% initialize
+\let\thisenv\empty
+
+% ... but they get defined via ``\envdef\foo{...}'':
+\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
+\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
+
+% Check whether we're in the right environment:
+\def\checkenv#1{%
+ \def\temp{#1}%
+ \ifx\thisenv\temp
+ \else
+ \badenverr
+ \fi
+}
+
+% Evironment mismatch, #1 expected:
+\def\badenverr{%
+ \errhelp = \EMsimple
+ \errmessage{This command can appear only \inenvironment\temp,
+ not \inenvironment\thisenv}%
+}
+\def\inenvironment#1{%
+ \ifx#1\empty
+ out of any environment%
+ \else
+ in environment \expandafter\string#1%
+ \fi
+}
+
+% @end foo executes the definition of \Efoo.
+% But first, it executes a specialized version of \checkenv
+%
+\parseargdef\end{%
+ \if 1\csname iscond.#1\endcsname
+ \else
+ % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
+ \expandafter\checkenv\csname#1\endcsname
+ \csname E#1\endcsname
+ \endgroup
+ \fi
+}
+
+\newhelp\EMsimple{Press RETURN to continue.}
+
+
+%% Simple single-character @ commands
+
+% @@ prints an @
+% Kludge this until the fonts are right (grr).
+\def\@{{\tt\char64}}
+
+% This is turned off because it was never documented
+% and you can use @w{...} around a quote to suppress ligatures.
+%% Define @` and @' to be the same as ` and '
+%% but suppressing ligatures.
+%\def\`{{`}}
+%\def\'{{'}}
+
+% Used to generate quoted braces.
+\def\mylbrace {{\tt\char123}}
+\def\myrbrace {{\tt\char125}}
+\let\{=\mylbrace
+\let\}=\myrbrace
+\begingroup
+ % Definitions to produce \{ and \} commands for indices,
+ % and @{ and @} for the aux/toc files.
+ \catcode`\{ = \other \catcode`\} = \other
+ \catcode`\[ = 1 \catcode`\] = 2
+ \catcode`\! = 0 \catcode`\\ = \other
+ !gdef!lbracecmd[\{]%
+ !gdef!rbracecmd[\}]%
+ !gdef!lbraceatcmd[@{]%
+ !gdef!rbraceatcmd[@}]%
+!endgroup
+
+% @comma{} to avoid , parsing problems.
+\let\comma = ,
+
+% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
+% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
+\let\, = \c
+\let\dotaccent = \.
+\def\ringaccent#1{{\accent23 #1}}
+\let\tieaccent = \t
+\let\ubaraccent = \b
+\let\udotaccent = \d
+
+% Other special characters: @questiondown @exclamdown @ordf @ordm
+% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
+\def\questiondown{?`}
+\def\exclamdown{!`}
+\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
+\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
+
+% Dotless i and dotless j, used for accents.
+\def\imacro{i}
+\def\jmacro{j}
+\def\dotless#1{%
+ \def\temp{#1}%
+ \ifx\temp\imacro \ptexi
+ \else\ifx\temp\jmacro \j
+ \else \errmessage{@dotless can be used only with i or j}%
+ \fi\fi
+}
+
+% The \TeX{} logo, as in plain, but resetting the spacing so that a
+% period following counts as ending a sentence. (Idea found in latex.)
+%
+\edef\TeX{\TeX \spacefactor=1000 }
+
+% @LaTeX{} logo. Not quite the same results as the definition in
+% latex.ltx, since we use a different font for the raised A; it's most
+% convenient for us to use an explicitly smaller font, rather than using
+% the \scriptstyle font (since we don't reset \scriptstyle and
+% \scriptscriptstyle).
+%
+\def\LaTeX{%
+ L\kern-.36em
+ {\setbox0=\hbox{T}%
+ \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}%
+ \kern-.15em
+ \TeX
+}
+
+% Be sure we're in horizontal mode when doing a tie, since we make space
+% equivalent to this in @example-like environments. Otherwise, a space
+% at the beginning of a line will start with \penalty -- and
+% since \penalty is valid in vertical mode, we'd end up putting the
+% penalty on the vertical list instead of in the new paragraph.
+{\catcode`@ = 11
+ % Avoid using \@M directly, because that causes trouble
+ % if the definition is written into an index file.
+ \global\let\tiepenalty = \@M
+ \gdef\tie{\leavevmode\penalty\tiepenalty\ }
+}
+
+% @: forces normal size whitespace following.
+\def\:{\spacefactor=1000 }
+
+% @* forces a line break.
+\def\*{\hfil\break\hbox{}\ignorespaces}
+
+% @/ allows a line break.
+\let\/=\allowbreak
+
+% @. is an end-of-sentence period.
+\def\.{.\spacefactor=\endofsentencespacefactor\space}
+
+% @! is an end-of-sentence bang.
+\def\!{!\spacefactor=\endofsentencespacefactor\space}
+
+% @? is an end-of-sentence query.
+\def\?{?\spacefactor=\endofsentencespacefactor\space}
+
+% @frenchspacing on|off says whether to put extra space after punctuation.
+%
+\def\onword{on}
+\def\offword{off}
+%
+\parseargdef\frenchspacing{%
+ \def\temp{#1}%
+ \ifx\temp\onword \plainfrenchspacing
+ \else\ifx\temp\offword \plainnonfrenchspacing
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @frenchspacing option `\temp', must be on/off}%
+ \fi\fi
+}
+
+% @w prevents a word break. Without the \leavevmode, @w at the
+% beginning of a paragraph, when TeX is still in vertical mode, would
+% produce a whole line of output instead of starting the paragraph.
+\def\w#1{\leavevmode\hbox{#1}}
+
+% @group ... @end group forces ... to be all on one page, by enclosing
+% it in a TeX vbox. We use \vtop instead of \vbox to construct the box
+% to keep its height that of a normal line. According to the rules for
+% \topskip (p.114 of the TeXbook), the glue inserted is
+% max (\topskip - \ht (first item), 0). If that height is large,
+% therefore, no glue is inserted, and the space between the headline and
+% the text is small, which looks bad.
+%
+% Another complication is that the group might be very large. This can
+% cause the glue on the previous page to be unduly stretched, because it
+% does not have much material. In this case, it's better to add an
+% explicit \vfill so that the extra space is at the bottom. The
+% threshold for doing this is if the group is more than \vfilllimit
+% percent of a page (\vfilllimit can be changed inside of @tex).
+%
+\newbox\groupbox
+\def\vfilllimit{0.7}
+%
+\envdef\group{%
+ \ifnum\catcode`\^^M=\active \else
+ \errhelp = \groupinvalidhelp
+ \errmessage{@group invalid in context where filling is enabled}%
+ \fi
+ \startsavinginserts
+ %
+ \setbox\groupbox = \vtop\bgroup
+ % Do @comment since we are called inside an environment such as
+ % @example, where each end-of-line in the input causes an
+ % end-of-line in the output. We don't want the end-of-line after
+ % the `@group' to put extra space in the output. Since @group
+ % should appear on a line by itself (according to the Texinfo
+ % manual), we don't worry about eating any user text.
+ \comment
+}
+%
+% The \vtop produces a box with normal height and large depth; thus, TeX puts
+% \baselineskip glue before it, and (when the next line of text is done)
+% \lineskip glue after it. Thus, space below is not quite equal to space
+% above. But it's pretty close.
+\def\Egroup{%
+ % To get correct interline space between the last line of the group
+ % and the first line afterwards, we have to propagate \prevdepth.
+ \endgraf % Not \par, as it may have been set to \lisppar.
+ \global\dimen1 = \prevdepth
+ \egroup % End the \vtop.
+ % \dimen0 is the vertical size of the group's box.
+ \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
+ % \dimen2 is how much space is left on the page (more or less).
+ \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
+ % if the group doesn't fit on the current page, and it's a big big
+ % group, force a page break.
+ \ifdim \dimen0 > \dimen2
+ \ifdim \pagetotal < \vfilllimit\pageheight
+ \page
+ \fi
+ \fi
+ \box\groupbox
+ \prevdepth = \dimen1
+ \checkinserts
+}
+%
+% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
+% message, so this ends up printing `@group can only ...'.
+%
+\newhelp\groupinvalidhelp{%
+group can only be used in environments such as @example,^^J%
+where each line of input produces a line of output.}
+
+% @need space-in-mils
+% forces a page break if there is not space-in-mils remaining.
+
+\newdimen\mil \mil=0.001in
+
+% Old definition--didn't work.
+%\parseargdef\need{\par %
+%% This method tries to make TeX break the page naturally
+%% if the depth of the box does not fit.
+%{\baselineskip=0pt%
+%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
+%\prevdepth=-1000pt
+%}}
+
+\parseargdef\need{%
+ % Ensure vertical mode, so we don't make a big box in the middle of a
+ % paragraph.
+ \par
+ %
+ % If the @need value is less than one line space, it's useless.
+ \dimen0 = #1\mil
+ \dimen2 = \ht\strutbox
+ \advance\dimen2 by \dp\strutbox
+ \ifdim\dimen0 > \dimen2
+ %
+ % Do a \strut just to make the height of this box be normal, so the
+ % normal leading is inserted relative to the preceding line.
+ % And a page break here is fine.
+ \vtop to #1\mil{\strut\vfil}%
+ %
+ % TeX does not even consider page breaks if a penalty added to the
+ % main vertical list is 10000 or more. But in order to see if the
+ % empty box we just added fits on the page, we must make it consider
+ % page breaks. On the other hand, we don't want to actually break the
+ % page after the empty box. So we use a penalty of 9999.
+ %
+ % There is an extremely small chance that TeX will actually break the
+ % page at this \penalty, if there are no other feasible breakpoints in
+ % sight. (If the user is using lots of big @group commands, which
+ % almost-but-not-quite fill up a page, TeX will have a hard time doing
+ % good page breaking, for example.) However, I could not construct an
+ % example where a page broke at this \penalty; if it happens in a real
+ % document, then we can reconsider our strategy.
+ \penalty9999
+ %
+ % Back up by the size of the box, whether we did a page break or not.
+ \kern -#1\mil
+ %
+ % Do not allow a page break right after this kern.
+ \nobreak
+ \fi
+}
+
+% @br forces paragraph break (and is undocumented).
+
+\let\br = \par
+
+% @page forces the start of a new page.
+%
+\def\page{\par\vfill\supereject}
+
+% @exdent text....
+% outputs text on separate line in roman font, starting at standard page margin
+
+% This records the amount of indent in the innermost environment.
+% That's how much \exdent should take out.
+\newskip\exdentamount
+
+% This defn is used inside fill environments such as @defun.
+\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
+
+% This defn is used inside nofill environments such as @example.
+\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
+ \leftline{\hskip\leftskip{\rm#1}}}}
+
+% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
+% paragraph. For more general purposes, use the \margin insertion
+% class. WHICH is `l' or `r'.
+%
+\newskip\inmarginspacing \inmarginspacing=1cm
+\def\strutdepth{\dp\strutbox}
+%
+\def\doinmargin#1#2{\strut\vadjust{%
+ \nobreak
+ \kern-\strutdepth
+ \vtop to \strutdepth{%
+ \baselineskip=\strutdepth
+ \vss
+ % if you have multiple lines of stuff to put here, you'll need to
+ % make the vbox yourself of the appropriate size.
+ \ifx#1l%
+ \llap{\ignorespaces #2\hskip\inmarginspacing}%
+ \else
+ \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
+ \fi
+ \null
+ }%
+}}
+\def\inleftmargin{\doinmargin l}
+\def\inrightmargin{\doinmargin r}
+%
+% @inmargin{TEXT [, RIGHT-TEXT]}
+% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
+% else use TEXT for both).
+%
+\def\inmargin#1{\parseinmargin #1,,\finish}
+\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0 > 0pt
+ \def\lefttext{#1}% have both texts
+ \def\righttext{#2}%
+ \else
+ \def\lefttext{#1}% have only one text
+ \def\righttext{#1}%
+ \fi
+ %
+ \ifodd\pageno
+ \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
+ \else
+ \def\temp{\inleftmargin\lefttext}%
+ \fi
+ \temp
+}
+
+% @include file insert text of that file as input.
+%
+\def\include{\parseargusing\filenamecatcodes\includezzz}
+\def\includezzz#1{%
+ \pushthisfilestack
+ \def\thisfile{#1}%
+ {%
+ \makevalueexpandable
+ \def\temp{\input #1 }%
+ \expandafter
+ }\temp
+ \popthisfilestack
+}
+\def\filenamecatcodes{%
+ \catcode`\\=\other
+ \catcode`~=\other
+ \catcode`^=\other
+ \catcode`_=\other
+ \catcode`|=\other
+ \catcode`<=\other
+ \catcode`>=\other
+ \catcode`+=\other
+ \catcode`-=\other
+}
+
+\def\pushthisfilestack{%
+ \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
+}
+\def\pushthisfilestackX{%
+ \expandafter\pushthisfilestackY\thisfile\StackTerm
+}
+\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
+ \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
+}
+
+\def\popthisfilestack{\errthisfilestackempty}
+\def\errthisfilestackempty{\errmessage{Internal error:
+ the stack of filenames is empty.}}
+
+\def\thisfile{}
+
+% @center line
+% outputs that line, centered.
+%
+\parseargdef\center{%
+ \ifhmode
+ \let\next\centerH
+ \else
+ \let\next\centerV
+ \fi
+ \next{\hfil \ignorespaces#1\unskip \hfil}%
+}
+\def\centerH#1{%
+ {%
+ \hfil\break
+ \advance\hsize by -\leftskip
+ \advance\hsize by -\rightskip
+ \line{#1}%
+ \break
+ }%
+}
+\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
+
+% @sp n outputs n lines of vertical space
+
+\parseargdef\sp{\vskip #1\baselineskip}
+
+% @comment ...line which is ignored...
+% @c is the same as @comment
+% @ignore ... @end ignore is another way to write a comment
+
+\def\comment{\begingroup \catcode`\^^M=\other%
+\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
+\commentxxx}
+{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
+
+\let\c=\comment
+
+% @paragraphindent NCHARS
+% We'll use ems for NCHARS, close enough.
+% NCHARS can also be the word `asis' or `none'.
+% We cannot feasibly implement @paragraphindent asis, though.
+%
+\def\asisword{asis} % no translation, these are keywords
+\def\noneword{none}
+%
+\parseargdef\paragraphindent{%
+ \def\temp{#1}%
+ \ifx\temp\asisword
+ \else
+ \ifx\temp\noneword
+ \defaultparindent = 0pt
+ \else
+ \defaultparindent = #1em
+ \fi
+ \fi
+ \parindent = \defaultparindent
+}
+
+% @exampleindent NCHARS
+% We'll use ems for NCHARS like @paragraphindent.
+% It seems @exampleindent asis isn't necessary, but
+% I preserve it to make it similar to @paragraphindent.
+\parseargdef\exampleindent{%
+ \def\temp{#1}%
+ \ifx\temp\asisword
+ \else
+ \ifx\temp\noneword
+ \lispnarrowing = 0pt
+ \else
+ \lispnarrowing = #1em
+ \fi
+ \fi
+}
+
+% @firstparagraphindent WORD
+% If WORD is `none', then suppress indentation of the first paragraph
+% after a section heading. If WORD is `insert', then do indent at such
+% paragraphs.
+%
+% The paragraph indentation is suppressed or not by calling
+% \suppressfirstparagraphindent, which the sectioning commands do.
+% We switch the definition of this back and forth according to WORD.
+% By default, we suppress indentation.
+%
+\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
+\def\insertword{insert}
+%
+\parseargdef\firstparagraphindent{%
+ \def\temp{#1}%
+ \ifx\temp\noneword
+ \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
+ \else\ifx\temp\insertword
+ \let\suppressfirstparagraphindent = \relax
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @firstparagraphindent option `\temp'}%
+ \fi\fi
+}
+
+% Here is how we actually suppress indentation. Redefine \everypar to
+% \kern backwards by \parindent, and then reset itself to empty.
+%
+% We also make \indent itself not actually do anything until the next
+% paragraph.
+%
+\gdef\dosuppressfirstparagraphindent{%
+ \gdef\indent{%
+ \restorefirstparagraphindent
+ \indent
+ }%
+ \gdef\noindent{%
+ \restorefirstparagraphindent
+ \noindent
+ }%
+ \global\everypar = {%
+ \kern -\parindent
+ \restorefirstparagraphindent
+ }%
+}
+
+\gdef\restorefirstparagraphindent{%
+ \global \let \indent = \ptexindent
+ \global \let \noindent = \ptexnoindent
+ \global \everypar = {}%
+}
+
+
+% @asis just yields its argument. Used with @table, for example.
+%
+\def\asis#1{#1}
+
+% @math outputs its argument in math mode.
+%
+% One complication: _ usually means subscripts, but it could also mean
+% an actual _ character, as in @math{@var{some_variable} + 1}. So make
+% _ active, and distinguish by seeing if the current family is \slfam,
+% which is what @var uses.
+{
+ \catcode\underChar = \active
+ \gdef\mathunderscore{%
+ \catcode\underChar=\active
+ \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
+ }
+}
+% Another complication: we want \\ (and @\) to output a \ character.
+% FYI, plain.tex uses \\ as a temporary control sequence (why?), but
+% this is not advertised and we don't care. Texinfo does not
+% otherwise define @\.
+%
+% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
+\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
+%
+\def\math{%
+ \tex
+ \mathunderscore
+ \let\\ = \mathbackslash
+ \mathactive
+ $\finishmath
+}
+\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
+
+% Some active characters (such as <) are spaced differently in math.
+% We have to reset their definitions in case the @math was an argument
+% to a command which sets the catcodes (such as @item or @section).
+%
+{
+ \catcode`^ = \active
+ \catcode`< = \active
+ \catcode`> = \active
+ \catcode`+ = \active
+ \gdef\mathactive{%
+ \let^ = \ptexhat
+ \let< = \ptexless
+ \let> = \ptexgtr
+ \let+ = \ptexplus
+ }
+}
+
+% @bullet and @minus need the same treatment as @math, just above.
+\def\bullet{$\ptexbullet$}
+\def\minus{$-$}
+
+% @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.
+%
+\def\dots{%
+ \leavevmode
+ \hbox to 1.5em{%
+ \hskip 0pt plus 0.25fil
+ .\hfil.\hfil.%
+ \hskip 0pt plus 0.5fil
+ }%
+}
+
+% @enddots{} is an end-of-sentence ellipsis.
+%
+\def\enddots{%
+ \dots
+ \spacefactor=\endofsentencespacefactor
+}
+
+% @comma{} is so commas can be inserted into text without messing up
+% Texinfo's parsing.
+%
+\let\comma = ,
+
+% @refill is a no-op.
+\let\refill=\relax
+
+% If working on a large document in chapters, it is convenient to
+% be able to disable indexing, cross-referencing, and contents, for test runs.
+% This is done with @novalidate (before @setfilename).
+%
+\newif\iflinks \linkstrue % by default we want the aux files.
+\let\novalidate = \linksfalse
+
+% @setfilename is done at the beginning of every texinfo file.
+% So open here the files we need to have open while reading the input.
+% This makes it possible to make a .fmt file for texinfo.
+\def\setfilename{%
+ \fixbackslash % Turn off hack to swallow `\input texinfo'.
+ \iflinks
+ \tryauxfile
+ % Open the new aux file. TeX will close it automatically at exit.
+ \immediate\openout\auxfile=\jobname.aux
+ \fi % \openindices needs to do some work in any case.
+ \openindices
+ \let\setfilename=\comment % Ignore extra @setfilename cmds.
+ %
+ % If texinfo.cnf is present on the system, read it.
+ % Useful for site-wide @afourpaper, etc.
+ \openin 1 texinfo.cnf
+ \ifeof 1 \else \input texinfo.cnf \fi
+ \closein 1
+ %
+ \comment % Ignore the actual filename.
+}
+
+% Called from \setfilename.
+%
+\def\openindices{%
+ \newindex{cp}%
+ \newcodeindex{fn}%
+ \newcodeindex{vr}%
+ \newcodeindex{tp}%
+ \newcodeindex{ky}%
+ \newcodeindex{pg}%
+}
+
+% @bye.
+\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
+
+
+\message{pdf,}
+% adobe `portable' document format
+\newcount\tempnum
+\newcount\lnkcount
+\newtoks\filename
+\newcount\filenamelength
+\newcount\pgn
+\newtoks\toksA
+\newtoks\toksB
+\newtoks\toksC
+\newtoks\toksD
+\newbox\boxA
+\newcount\countA
+\newif\ifpdf
+\newif\ifpdfmakepagedest
+
+% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
+% can be set). So we test for \relax and 0 as well as \undefined,
+% borrowed from ifpdf.sty.
+\ifx\pdfoutput\undefined
+\else
+ \ifx\pdfoutput\relax
+ \else
+ \ifcase\pdfoutput
+ \else
+ \pdftrue
+ \fi
+ \fi
+\fi
+
+% PDF uses PostScript string constants for the names of xref targets, to
+% 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).
+
+% double active backslashes.
+%
+{\catcode`\@=0 \catcode`\\=\active
+ @gdef at activebackslash{@catcode`@\=@active @otherbackslash}
+ @gdef at activebackslashdouble{%
+ @catcode at backChar=@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.
+%
+% #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%
+ \ifx\\##2\\%
+ \else
+ #2%
+ \HyReturnAfterFi{%
+ \HyPsdReplace##2\END
+ }%
+ \fi
+ }%
+ \xdef#3{\expandafter\HyPsdReplace#3#1\END}%
+}
+\long\def\HyReturnAfterFi#1\fi{\fi#1}
+
+% #1 is a control sequence in which to do the replacements.
+\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}%
+}
+
+{\catcode\exclamChar = 0 \catcode\backChar = \other
+ !gdef!backslashlparen{\(}%
+ !gdef!backslashrparen{\)}%
+}
+
+\ifpdf
+ \input pdfcolor
+ \pdfcatalog{/PageMode /UseOutlines}%
+ \def\dopdfimage#1#2#3{%
+ \def\imagewidth{#2}%
+ \def\imageheight{#3}%
+ % without \immediate, 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
+ \ifnum\pdftexversion<13
+ #1.pdf%
+ \else
+ {#1.pdf}%
+ \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
+ \activebackslashdouble
+ \def\pdfdestname{#1}%
+ \backslashparens\pdfdestname
+ \pdfdest name{\pdfdestname} xyz%
+ }}%
+ %
+ % used to mark target names; must be expandable.
+ \def\pdfmkpgn#1{#1}%
+ %
+ \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%
+ \else \csname#1\endcsname \fi}
+ \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
+ \advance\tempnum by 1
+ \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
+ %
+ % #1 is the section text, which is what will be displayed in the
+ % outline by the pdf viewer. #2 is the pdf expression for the number
+ % of subentries (or empty, for subsubsections). #3 is the node text,
+ % which might be empty if this toc entry had no corresponding node.
+ % #4 is the page number
+ %
+ \def\dopdfoutline#1#2#3#4{%
+ % Generate a link to the node text if that exists; else, use the
+ % page number. We could generate a destination for the section
+ % text in the case where a section has no node, but it doesn't
+ % seem worth the trouble, since most documents are normally structured.
+ \def\pdfoutlinedest{#3}%
+ \ifx\pdfoutlinedest\empty
+ \def\pdfoutlinedest{#4}%
+ \else
+ % Doubled backslashes in the name.
+ {\activebackslashdouble \xdef\pdfoutlinedest{#3}%
+ \backslashparens\pdfoutlinedest}%
+ \fi
+ %
+ % Also double the backslashes in the display string.
+ {\activebackslashdouble \xdef\pdfoutlinetext{#1}%
+ \backslashparens\pdfoutlinetext}%
+ %
+ \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
+ }
+ %
+ \def\pdfmakeoutlines{%
+ \begingroup
+ % Thanh's hack / proper braces in bookmarks
+ \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
+ \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
+ %
+ % Read toc silently, to get counts of subentries for \pdfoutline.
+ \def\numchapentry##1##2##3##4{%
+ \def\thischapnum{##2}%
+ \def\thissecnum{0}%
+ \def\thissubsecnum{0}%
+ }%
+ \def\numsecentry##1##2##3##4{%
+ \advancenumber{chap\thischapnum}%
+ \def\thissecnum{##2}%
+ \def\thissubsecnum{0}%
+ }%
+ \def\numsubsecentry##1##2##3##4{%
+ \advancenumber{sec\thissecnum}%
+ \def\thissubsecnum{##2}%
+ }%
+ \def\numsubsubsecentry##1##2##3##4{%
+ \advancenumber{subsec\thissubsecnum}%
+ }%
+ \def\thischapnum{0}%
+ \def\thissecnum{0}%
+ \def\thissubsecnum{0}%
+ %
+ % use \def rather than \let here because we redefine \chapentry et
+ % al. a second time, below.
+ \def\appentry{\numchapentry}%
+ \def\appsecentry{\numsecentry}%
+ \def\appsubsecentry{\numsubsecentry}%
+ \def\appsubsubsecentry{\numsubsubsecentry}%
+ \def\unnchapentry{\numchapentry}%
+ \def\unnsecentry{\numsecentry}%
+ \def\unnsubsecentry{\numsubsecentry}%
+ \def\unnsubsubsecentry{\numsubsubsecentry}%
+ \readdatafile{toc}%
+ %
+ % Read toc second time, this time actually producing the outlines.
+ % The `-' means take the \expnumber as the absolute number of
+ % subentries, which we calculated on our first read of the .toc above.
+ %
+ % We use the node names as the destinations.
+ \def\numchapentry##1##2##3##4{%
+ \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
+ \def\numsecentry##1##2##3##4{%
+ \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
+ \def\numsubsecentry##1##2##3##4{%
+ \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
+ \def\numsubsubsecentry##1##2##3##4{% count is always zero
+ \dopdfoutline{##1}{}{##3}{##4}}%
+ %
+ % PDF outlines are displayed using system fonts, instead of
+ % document fonts. Therefore we cannot use special characters,
+ % since the encoding is unknown. For example, the eogonek from
+ % Latin 2 (0xea) gets translated to a | character. Info from
+ % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
+ %
+ % xx to do this right, we have to translate 8-bit characters to
+ % their "best" equivalent, based on the @documentencoding. Right
+ % now, I guess we'll just let the pdf reader have its way.
+ \indexnofonts
+ \setupdatafile
+ \activebackslash
+ \input \jobname.toc
+ \endgroup
+ }
+ %
+ \def\skipspaces#1{\def\PP{#1}\def\D{|}%
+ \ifx\PP\D\let\nextsp\relax
+ \else\let\nextsp\skipspaces
+ \ifx\p\space\else\addtokens{\filename}{\PP}%
+ \advance\filenamelength by 1
+ \fi
+ \fi
+ \nextsp}
+ \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
+ \ifnum\pdftexversion < 14
+ \let \startlink \pdfannotlink
+ \else
+ \let \startlink \pdfstartlink
+ \fi
+ \def\pdfurl#1{%
+ \begingroup
+ \normalturnoffactive\def\@{@}%
+ \makevalueexpandable
+ \leavevmode\Red
+ \startlink attr{/Border [0 0 0]}%
+ user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
+ \endgroup}
+ \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
+ \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
+ \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
+ \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
+ \def\maketoks{%
+ \expandafter\poptoks\the\toksA|ENDTOKS|\relax
+ \ifx\first0\adn0
+ \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
+ \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
+ \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
+ \else
+ \ifnum0=\countA\else\makelink\fi
+ \ifx\first.\let\next=\done\else
+ \let\next=\maketoks
+ \addtokens{\toksB}{\the\toksD}
+ \ifx\first,\addtokens{\toksB}{\space}\fi
+ \fi
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \next}
+ \def\makelink{\addtokens{\toksB}%
+ {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
+ \def\pdflink#1{%
+ \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
+ \linkcolor #1\endlink}
+ \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
+\else
+ \let\pdfmkdest = \gobble
+ \let\pdfurl = \gobble
+ \let\endlink = \relax
+ \let\linkcolor = \relax
+ \let\pdfmakeoutlines = \relax
+\fi % \ifx\pdfoutput
+
+
+\message{fonts,}
+
+% Change the current font style to #1, remembering it in \curfontstyle.
+% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
+% italics, not bold italics.
+%
+\def\setfontstyle#1{%
+ \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
+ \csname ten#1\endcsname % change the current font
+}
+
+% Select #1 fonts with the current style.
+%
+\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
+
+\def\rm{\fam=0 \setfontstyle{rm}}
+\def\it{\fam=\itfam \setfontstyle{it}}
+\def\sl{\fam=\slfam \setfontstyle{sl}}
+\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
+\def\tt{\fam=\ttfam \setfontstyle{tt}}
+
+% Texinfo sort of supports the sans serif font style, which plain TeX does not.
+% So we set up a \sf.
+\newfam\sffam
+\def\sf{\fam=\sffam \setfontstyle{sf}}
+\let\li = \sf % Sometimes we call it \li, not \sf.
+
+% We don't need math for this font style.
+\def\ttsl{\setfontstyle{ttsl}}
+
+% Default leading.
+\newdimen\textleading \textleading = 13.2pt
+
+% Set the baselineskip to #1, and the lineskip and strut size
+% correspondingly. There is no deep meaning behind these magic numbers
+% used as factors; they just match (closely enough) what Knuth defined.
+%
+\def\lineskipfactor{.08333}
+\def\strutheightpercent{.70833}
+\def\strutdepthpercent {.29167}
+%
+\def\setleading#1{%
+ \normalbaselineskip = #1\relax
+ \normallineskip = \lineskipfactor\normalbaselineskip
+ \normalbaselines
+ \setbox\strutbox =\hbox{%
+ \vrule width0pt height\strutheightpercent\baselineskip
+ depth \strutdepthpercent \baselineskip
+ }%
+}
+
+% 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}
+
+% Use cm as the default font prefix.
+% To specify the font prefix, you must define \fontprefix
+% before you read in texinfo.tex.
+\ifx\fontprefix\undefined
+\def\fontprefix{cm}
+\fi
+% Support font families that don't use the same naming scheme as CM.
+\def\rmshape{r}
+\def\rmbshape{bx} %where the normal face is bold
+\def\bfshape{b}
+\def\bxshape{bx}
+\def\ttshape{tt}
+\def\ttbshape{tt}
+\def\ttslshape{sltt}
+\def\itshape{ti}
+\def\itbshape{bxti}
+\def\slshape{sl}
+\def\slbshape{bxsl}
+\def\sfshape{ss}
+\def\sfbshape{ss}
+\def\scshape{csc}
+\def\scbshape{csc}
+
+% 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}
+\font\texti=cmmi10 scaled \mainmagstep
+\font\textsy=cmsy10 scaled \mainmagstep
+
+% A few fonts for @defun names and args.
+\setfont\defbf\bfshape{10}{\magstep1}
+\setfont\deftt\ttshape{10}{\magstep1}
+\setfont\defttsl\ttslshape{10}{\magstep1}
+\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}
+\font\smalli=cmmi9
+\font\smallsy=cmsy9
+
+% 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}
+\font\smalleri=cmmi8
+\font\smallersy=cmsy8
+
+% 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}
+\let\titlebf=\titlerm
+\setfont\titlesc\scbshape{10}{\magstep4}
+\font\titlei=cmmi12 scaled \magstep3
+\font\titlesy=cmsy10 scaled \magstep4
+\def\authorrm{\secrm}
+\def\authortt{\sectt}
+
+% 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}
+\let\chapbf=\chaprm
+\setfont\chapsc\scbshape{10}{\magstep3}
+\font\chapi=cmmi12 scaled \magstep2
+\font\chapsy=cmsy10 scaled \magstep3
+
+% 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}
+\let\secbf\secrm
+\setfont\secsc\scbshape{10}{\magstep2}
+\font\seci=cmmi12 scaled \magstep1
+\font\secsy=cmsy10 scaled \magstep2
+
+% 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}
+\let\ssecbf\ssecrm
+\setfont\ssecsc\scbshape{10}{1315}
+\font\sseci=cmmi12 scaled \magstephalf
+\font\ssecsy=cmsy10 scaled 1315
+
+% 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}
+\font\reducedi=cmmi10
+\font\reducedsy=cmsy10
+
+% In order for the font changes to affect most math symbols and letters,
+% we have to define the \textfont of the standard families. Since
+% texinfo doesn't allow for producing subscripts and superscripts except
+% in the main text, we don't bother to reset \scriptfont and
+% \scriptscriptfont (which would also require loading a lot more fonts).
+%
+\def\resetmathfonts{%
+ \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
+ \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
+ \textfont\ttfam=\tentt \textfont\sffam=\tensf
+}
+
+% The font-changing commands redefine the meanings of \tenSTYLE, instead
+% of just \STYLE. We do this because \STYLE needs to also set the
+% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
+% \tenSTYLE to set the current font.
+%
+% Each font-changing command also sets the names \lsize (one size lower)
+% and \lllsize (three sizes lower). These relative commands are used in
+% the LaTeX logo and acronyms.
+%
+% This all needs generalizing, badly.
+%
+\def\textfonts{%
+ \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
+ \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
+ \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
+ \let\tenttsl=\textttsl
+ \def\curfontsize{text}%
+ \def\lsize{reduced}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{\textleading}}
+\def\titlefonts{%
+ \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
+ \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
+ \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
+ \let\tenttsl=\titlettsl
+ \def\curfontsize{title}%
+ \def\lsize{chap}\def\lllsize{subsec}%
+ \resetmathfonts \setleading{25pt}}
+\def\titlefont#1{{\titlefonts\rm #1}}
+\def\chapfonts{%
+ \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
+ \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
+ \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
+ \let\tenttsl=\chapttsl
+ \def\curfontsize{chap}%
+ \def\lsize{sec}\def\lllsize{text}%
+ \resetmathfonts \setleading{19pt}}
+\def\secfonts{%
+ \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
+ \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
+ \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
+ \let\tenttsl=\secttsl
+ \def\curfontsize{sec}%
+ \def\lsize{subsec}\def\lllsize{reduced}%
+ \resetmathfonts \setleading{16pt}}
+\def\subsecfonts{%
+ \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
+ \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
+ \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
+ \let\tenttsl=\ssecttsl
+ \def\curfontsize{ssec}%
+ \def\lsize{text}\def\lllsize{small}%
+ \resetmathfonts \setleading{15pt}}
+\let\subsubsecfonts = \subsecfonts
+\def\reducedfonts{%
+ \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
+ \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
+ \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
+ \let\tenttsl=\reducedttsl
+ \def\curfontsize{reduced}%
+ \def\lsize{small}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{10.5pt}}
+\def\smallfonts{%
+ \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
+ \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
+ \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
+ \let\tenttsl=\smallttsl
+ \def\curfontsize{small}%
+ \def\lsize{smaller}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{10.5pt}}
+\def\smallerfonts{%
+ \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
+ \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
+ \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
+ \let\tenttsl=\smallerttsl
+ \def\curfontsize{smaller}%
+ \def\lsize{smaller}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{9.5pt}}
+
+% Set the fonts to use with the @small... environments.
+\let\smallexamplefonts = \smallfonts
+
+% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
+% can fit this many characters:
+% 8.5x11=86 smallbook=72 a4=90 a5=69
+% If we use \scriptfonts (8pt), then we can fit this many characters:
+% 8.5x11=90+ smallbook=80 a4=90+ a5=77
+% For me, subjectively, the few extra characters that fit aren't worth
+% the additional smallness of 8pt. So I'm making the default 9pt.
+%
+% 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
+
+% Define these so they can be easily changed for other fonts.
+\def\angleleft{$\langle$}
+\def\angleright{$\rangle$}
+
+% 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
+
+% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
+% unless the following character is such as not to need one.
+\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else
+ \ptexslash\fi\fi\fi}
+\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx}
+\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx}
+
+% like \smartslanted except unconditionally uses \ttsl.
+% @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
+% ttsl for book titles, do we?
+\def\cite#1{{\sl #1}\futurelet\next\smartitalicx}
+
+\let\i=\smartitalic
+\let\slanted=\smartslanted
+\let\var=\smartslanted
+\let\dfn=\smartslanted
+\let\emph=\smartitalic
+
+% @b, explicit bold.
+\def\b#1{{\bf #1}}
+\let\strong=\b
+
+% @sansserif, explicit sans.
+\def\sansserif#1{{\sf #1}}
+
+% We can't just use \exhyphenpenalty, because that only has effect at
+% the end of a paragraph. Restore normal hyphenation at the end of the
+% group within which \nohyphenation is presumably called.
+%
+\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
+\def\restorehyphenation{\hyphenchar\font = `- }
+
+% Set sfcode to normal for the chars that usually have another value.
+% Can't use plain's \frenchspacing because it uses the `\x notation, and
+% sometimes \x has an active definition that messes things up.
+%
+\catcode`@=11
+ \def\plainfrenchspacing{%
+ \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
+ \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
+ \def\endofsentencespacefactor{1000}% for @. and friends
+ }
+ \def\plainnonfrenchspacing{%
+ \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
+ \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
+ \def\endofsentencespacefactor{3000}% for @. and friends
+ }
+\catcode`@=\other
+\def\endofsentencespacefactor{3000}% default
+
+\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}
+\def\ctrl #1{{\tt \rawbackslash \hat}#1}
+
+% @file, @option are the same as @samp.
+\let\file=\samp
+\let\option=\samp
+
+% @code is a modification of @t,
+% which makes spaces the same size as normal in the surrounding text.
+\def\tclose#1{%
+ {%
+ % Change normal interword space to be same as for the current font.
+ \spaceskip = \fontdimen2\font
+ %
+ % Switch to typewriter.
+ \tt
+ %
+ % But `\ ' produces the large typewriter interword space.
+ \def\ {{\spaceskip = 0pt{} }}%
+ %
+ % Turn off hyphenation.
+ \nohyphenation
+ %
+ \rawbackslash
+ \plainfrenchspacing
+ #1%
+ }%
+ \null
+}
+
+% We *must* turn on hyphenation at `-' and `_' in @code.
+% Otherwise, it is too hard to avoid overfull hboxes
+% in the Emacs manual, the Library manual, etc.
+
+% Unfortunately, TeX uses one parameter (\hyphenchar) to control
+% both hyphenation at - and hyphenation within words.
+% We must therefore turn them both off (\tclose does that)
+% and arrange explicitly to hyphenate at a dash.
+% -- rms.
+{
+ \catcode`\-=\active
+ \catcode`\_=\active
+ %
+ \global\def\code{\begingroup
+ \catcode`\-=\active \catcode`\_=\active
+ \ifallowcodebreaks
+ \let-\codedash
+ \let_\codeunder
+ \else
+ \let-\realdash
+ \let_\realunder
+ \fi
+ \codex
+ }
+}
+
+\def\realdash{-}
+\def\codedash{-\discretionary{}{}{}}
+\def\codeunder{%
+ % this is all so @math{@code{var_name}+1} can work. In math mode, _
+ % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
+ % will therefore expand the active definition of _, which is us
+ % (inside @code that is), therefore an endless loop.
+ \ifusingtt{\ifmmode
+ \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
+ \else\normalunderscore \fi
+ \discretionary{}{}{}}%
+ {\_}%
+}
+\def\codex #1{\tclose{#1}\endgroup}
+
+% An additional complication: the above will allow breaks after, e.g.,
+% 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}
+\def\keywordfalse{false}
+
+\parseargdef\allowcodebreaks{%
+ \def\txiarg{#1}%
+ \ifx\txiarg\keywordtrue
+ \allowcodebreakstrue
+ \else\ifx\txiarg\keywordfalse
+ \allowcodebreaksfalse
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @allowcodebreaks option `\txiarg'}%
+ \fi\fi
+}
+
+% @kbd is like @code, except that if the argument is just one @key command,
+% then @kbd has no effect.
+
+% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
+% `example' (@kbd uses ttsl only inside of @example and friends),
+% or `code' (@kbd uses normal tty font always).
+\parseargdef\kbdinputstyle{%
+ \def\txiarg{#1}%
+ \ifx\txiarg\worddistinct
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
+ \else\ifx\txiarg\wordexample
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
+ \else\ifx\txiarg\wordcode
+ \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @kbdinputstyle option `\txiarg'}%
+ \fi\fi\fi
+}
+\def\worddistinct{distinct}
+\def\wordexample{example}
+\def\wordcode{code}
+
+% 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}
+
+% For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
+\let\indicateurl=\code
+\let\env=\code
+\let\command=\code
+
+% @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
+% itself. First (mandatory) arg is the url. Perhaps eventually put in
+% a hypertex \special here.
+%
+\def\uref#1{\douref #1,,,\finish}
+\def\douref#1,#2,#3,#4\finish{\begingroup
+ \unsepspaces
+ \pdfurl{#1}%
+ \setbox0 = \hbox{\ignorespaces #3}%
+ \ifdim\wd0 > 0pt
+ \unhbox0 % third arg given, show only that
+ \else
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0 > 0pt
+ \ifpdf
+ \unhbox0 % PDF: 2nd arg given, show only it
+ \else
+ \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
+ \fi
+ \else
+ \code{#1}% only url given, so show it
+ \fi
+ \fi
+ \endlink
+\endgroup}
+
+% @url synonym for @uref, since that's how everyone uses it.
+%
+\let\url=\uref
+
+% rms does not like angle brackets --karl, 17may97.
+% So now @email is just like @uref, unless we are pdf.
+%
+%\def\email#1{\angleleft{\tt #1}\angleright}
+\ifpdf
+ \def\email#1{\doemail#1,,\finish}
+ \def\doemail#1,#2,#3\finish{\begingroup
+ \unsepspaces
+ \pdfurl{mailto:#1}%
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
+ \endlink
+ \endgroup}
+\else
+ \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}%
+ \def\temp{#2}%
+ \ifx\temp\empty \else
+ \space ({\unsepspaces \ignorespaces \temp \unskip})%
+ \fi
+}
+
+% @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}%
+ \def\temp{#2}%
+ \ifx\temp\empty \else
+ \space ({\unsepspaces \ignorespaces \temp \unskip})%
+ \fi
+}
+
+% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
+%
+\def\pounds{{\it\$}}
+
+% @euro{} comes from a separate font, depending on the current style.
+% We use the free feym* fonts from the eurosym package by Henrik
+% 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
+ % bold:
+ \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
+ \else
+ % regular:
+ \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
+ \fi
+ \thiseurofont
+}
+
+% @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.
+%
+\def\registeredsymbol{%
+ $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
+ \hfil\crcr\Orb}}%
+ }$%
+}
+
+% 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
+
+
+\message{page headings,}
+
+\newskip\titlepagetopglue \titlepagetopglue = 1.5in
+\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
+
+% First the title page. Must do @settitle before @titlepage.
+\newif\ifseenauthor
+\newif\iffinishedtitlepage
+
+% Do an implicit @contents or @shortcontents after @end titlepage if the
+% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
+%
+\newif\ifsetcontentsaftertitlepage
+ \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
+\newif\ifsetshortcontentsaftertitlepage
+ \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
+
+\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
+ \endgroup\page\hbox{}\page}
+
+\envdef\titlepage{%
+ % Open one extra group, as we want to close it in the middle of \Etitlepage.
+ \begingroup
+ \parindent=0pt \textfonts
+ % Leave some space at the very top of the page.
+ \vglue\titlepagetopglue
+ % No rule at page bottom unless we print one at the top with @title.
+ \finishedtitlepagetrue
+ %
+ % Most title ``pages'' are actually two pages long, with space
+ % at the top of the second. We don't want the ragged left on the second.
+ \let\oldpage = \page
+ \def\page{%
+ \iffinishedtitlepage\else
+ \finishtitlepage
+ \fi
+ \let\page = \oldpage
+ \page
+ \null
+ }%
+}
+
+\def\Etitlepage{%
+ \iffinishedtitlepage\else
+ \finishtitlepage
+ \fi
+ % It is important to do the page break before ending the group,
+ % because the headline and footline are only empty inside the group.
+ % If we use the new definition of \page, we always get a blank page
+ % after the title page, which we certainly don't want.
+ \oldpage
+ \endgroup
+ %
+ % Need this before the \...aftertitlepage checks so that if they are
+ % in effect the toc pages will come out with page numbers.
+ \HEADINGSon
+ %
+ % If they want short, they certainly want long too.
+ \ifsetshortcontentsaftertitlepage
+ \shortcontents
+ \contents
+ \global\let\shortcontents = \relax
+ \global\let\contents = \relax
+ \fi
+ %
+ \ifsetcontentsaftertitlepage
+ \contents
+ \global\let\contents = \relax
+ \global\let\shortcontents = \relax
+ \fi
+}
+
+\def\finishtitlepage{%
+ \vskip4pt \hrule height 2pt width \hsize
+ \vskip\titlepagebottomglue
+ \finishedtitlepagetrue
+}
+
+%%% Macros to be used within @titlepage:
+
+\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}
+ % print a rule at the page bottom also.
+ \finishedtitlepagefalse
+ \vskip4pt \hrule height 4pt width \hsize \vskip4pt
+}
+
+\parseargdef\subtitle{%
+ \checkenv\titlepage
+ {\subtitlefont \rightline{#1}}%
+}
+
+% @author should come last, but may come many times.
+% It can also be used inside @quotation.
+%
+\parseargdef\author{%
+ \def\temp{\quotation}%
+ \ifx\thisenv\temp
+ \def\quotationauthor{#1}% printed in \Equotation.
+ \else
+ \checkenv\titlepage
+ \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
+ {\authorfont \leftline{#1}}%
+ \fi
+}
+
+
+%%% Set up page headings and footings.
+
+\let\thispage=\folio
+
+\newtoks\evenheadline % headline on even pages
+\newtoks\oddheadline % headline on odd pages
+\newtoks\evenfootline % footline on even pages
+\newtoks\oddfootline % footline on odd pages
+
+% Now make TeX use those variables
+\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
+ \else \the\evenheadline \fi}}
+\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
+ \else \the\evenfootline \fi}\HEADINGShook}
+\let\HEADINGShook=\relax
+
+% Commands to set those variables.
+% For example, this is what @headings on does
+% @evenheading @thistitle|@thispage|@thischapter
+% @oddheading @thischapter|@thispage|@thistitle
+% @evenfooting @thisfile||
+% @oddfooting ||@thisfile
+
+
+\def\evenheading{\parsearg\evenheadingxxx}
+\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
+\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
+\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\def\oddheading{\parsearg\oddheadingxxx}
+\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
+\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
+\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
+
+\def\evenfooting{\parsearg\evenfootingxxx}
+\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
+\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
+\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\def\oddfooting{\parsearg\oddfootingxxx}
+\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
+\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
+ \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
+ %
+ % 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
+}
+
+\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
+
+
+% @headings double turns headings on for double-sided printing.
+% @headings single turns headings on for single-sided printing.
+% @headings off turns them off.
+% @headings on same as @headings double, retained for compatibility.
+% @headings after turns on double-sided headings after this page.
+% @headings doubleafter turns on double-sided headings after this page.
+% @headings singleafter turns on single-sided headings after this page.
+% By default, they are off at the start of a document,
+% and turned `on' after @end titlepage.
+
+\def\headings #1 {\csname HEADINGS#1\endcsname}
+
+\def\HEADINGSoff{%
+\global\evenheadline={\hfil} \global\evenfootline={\hfil}
+\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
+\HEADINGSoff
+% When we turn headings on, set the page number to 1.
+% For double-sided printing, put current file name in lower left corner,
+% chapter name on inside top of right hand pages, document
+% title on inside top of left hand pages, and page numbers on outside top
+% edge of all pages.
+\def\HEADINGSdouble{%
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\folio\hfil\thistitle}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chapoddpage
+}
+\let\contentsalignmacro = \chappager
+
+% For single-sided printing, chapter title goes across top left of page,
+% page number on top right.
+\def\HEADINGSsingle{%
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chappager
+}
+\def\HEADINGSon{\HEADINGSdouble}
+
+\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
+\let\HEADINGSdoubleafter=\HEADINGSafter
+\def\HEADINGSdoublex{%
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\folio\hfil\thistitle}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chapoddpage
+}
+
+\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
+\def\HEADINGSsinglex{%
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chappager
+}
+
+% Subroutines used in generating headings
+% This produces Day Month Year style of output.
+% Only define if not already defined, in case a txi-??.tex file has set
+% up a different format (e.g., txi-cs.tex does this).
+\ifx\today\undefined
+\def\today{%
+ \number\day\space
+ \ifcase\month
+ \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
+ \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
+ \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
+ \fi
+ \space\number\year}
+\fi
+
+% @settitle line... specifies the title of the document, for headings.
+% It generates no output of its own.
+\def\thistitle{\putwordNoTitle}
+\def\settitle{\parsearg{\gdef\thistitle}}
+
+
+\message{tables,}
+% Tables -- @table, @ftable, @vtable, @item(x).
+
+% default indentation of table text
+\newdimen\tableindent \tableindent=.8in
+% default indentation of @itemize and @enumerate text
+\newdimen\itemindent \itemindent=.3in
+% margin between end of table item and start of table text.
+\newdimen\itemmargin \itemmargin=.1in
+
+% used internally for \itemindent minus \itemmargin
+\newdimen\itemmax
+
+% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
+% these defs.
+% They also define \itemindex
+% to index the item name in whatever manner is desired (perhaps none).
+
+\newif\ifitemxneedsnegativevskip
+
+\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
+
+\def\internalBitem{\smallbreak \parsearg\itemzzz}
+\def\internalBitemx{\itemxpar \parsearg\itemzzz}
+
+\def\itemzzz #1{\begingroup %
+ \advance\hsize by -\rightskip
+ \advance\hsize by -\tableindent
+ \setbox0=\hbox{\itemindicate{#1}}%
+ \itemindex{#1}%
+ \nobreak % This prevents a break before @itemx.
+ %
+ % If the item text does not fit in the space we have, put it on a line
+ % by itself, and do not allow a page break either before or after that
+ % line. We do not start a paragraph here because then if the next
+ % command is, e.g., @kindex, the whatsit would get put into the
+ % horizontal list on a line by itself, resulting in extra blank space.
+ \ifdim \wd0>\itemmax
+ %
+ % Make this a paragraph so we get the \parskip glue and wrapping,
+ % but leave it ragged-right.
+ \begingroup
+ \advance\leftskip by-\tableindent
+ \advance\hsize by\tableindent
+ \advance\rightskip by0pt plus1fil
+ \leavevmode\unhbox0\par
+ \endgroup
+ %
+ % We're going to be starting a paragraph, but we don't want the
+ % \parskip glue -- logically it's part of the @item we just started.
+ \nobreak \vskip-\parskip
+ %
+ % Stop a page break at the \parskip glue coming up. However, if
+ % what follows is an environment such as @example, there will be no
+ % \parskip glue; then the negative vskip we just inserted would
+ % 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
+ \else
+ % The item text fits into the space. Start a paragraph, so that the
+ % following text (if any) will end up on the same line.
+ \noindent
+ % Do this with kerns and \unhbox so that if there is a footnote in
+ % the item text, it can migrate to the main vertical list and
+ % eventually be printed.
+ \nobreak\kern-\tableindent
+ \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
+ \unhbox0
+ \nobreak\kern\dimen0
+ \endgroup
+ \itemxneedsnegativevskiptrue
+ \fi
+}
+
+\def\item{\errmessage{@item while not in a list environment}}
+\def\itemx{\errmessage{@itemx while not in a list environment}}
+
+% @table, @ftable, @vtable.
+\envdef\table{%
+ \let\itemindex\gobble
+ \tablecheck{table}%
+}
+\envdef\ftable{%
+ \def\itemindex ##1{\doind {fn}{\code{##1}}}%
+ \tablecheck{ftable}%
+}
+\envdef\vtable{%
+ \def\itemindex ##1{\doind {vr}{\code{##1}}}%
+ \tablecheck{vtable}%
+}
+\def\tablecheck#1{%
+ \ifnum \the\catcode`\^^M=\active
+ \endgroup
+ \errmessage{This command won't work in this context; perhaps the problem is
+ that we are \inenvironment\thisenv}%
+ \def\next{\doignore{#1}}%
+ \else
+ \let\next\tablex
+ \fi
+ \next
+}
+\def\tablex#1{%
+ \def\itemindicate{#1}%
+ \parsearg\tabley
+}
+\def\tabley#1{%
+ {%
+ \makevalueexpandable
+ \edef\temp{\noexpand\tablez #1\space\space\space}%
+ \expandafter
+ }\temp \endtablez
+}
+\def\tablez #1 #2 #3 #4\endtablez{%
+ \aboveenvbreak
+ \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
+ \ifnum 0#2>0 \tableindent=#2\mil \fi
+ \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
+ \itemmax=\tableindent
+ \advance \itemmax by -\itemmargin
+ \advance \leftskip by \tableindent
+ \exdentamount=\tableindent
+ \parindent = 0pt
+ \parskip = \smallskipamount
+ \ifdim \parskip=0pt \parskip=2pt \fi
+ \let\item = \internalBitem
+ \let\itemx = \internalBitemx
+}
+\def\Etable{\endgraf\afterenvbreak}
+\let\Eftable\Etable
+\let\Evtable\Etable
+\let\Eitemize\Etable
+\let\Eenumerate\Etable
+
+% This is the counter used by @enumerate, which is really @itemize
+
+\newcount \itemno
+
+\envdef\itemize{\parsearg\doitemize}
+
+\def\doitemize#1{%
+ \aboveenvbreak
+ \itemmax=\itemindent
+ \advance\itemmax by -\itemmargin
+ \advance\leftskip by \itemindent
+ \exdentamount=\itemindent
+ \parindent=0pt
+ \parskip=\smallskipamount
+ \ifdim\parskip=0pt \parskip=2pt \fi
+ \def\itemcontents{#1}%
+ % @itemize with no arg is equivalent to @itemize @bullet.
+ \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
+ \let\item=\itemizeitem
+}
+
+% Definition of @item while inside @itemize and @enumerate.
+%
+\def\itemizeitem{%
+ \advance\itemno by 1 % for enumerations
+ {\let\par=\endgraf \smallbreak}% reasonable place to break
+ {%
+ % If the document has an @itemize directly after a section title, a
+ % \nobreak will be last on the list, and \sectionheading will have
+ % done a \vskip-\parskip. In that case, we don't want to zero
+ % parskip, or the item text will crash with the heading. On the
+ % other hand, when there is normal text preceding the item (as there
+ % usually is), we do want to zero parskip, or there would be too much
+ % space. In that case, we won't have a \nobreak before. At least
+ % that's the theory.
+ \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
+}
+
+% \splitoff TOKENS\endmark defines \first to be the first token in
+% TOKENS, and \rest to be the remainder.
+%
+\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
+
+% Allow an optional argument of an uppercase letter, lowercase letter,
+% or number, to specify the first label in the enumerated list. No
+% argument is the same as `1'.
+%
+\envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
+\def\enumeratey #1 #2\endenumeratey{%
+ % If we were given no argument, pretend we were given `1'.
+ \def\thearg{#1}%
+ \ifx\thearg\empty \def\thearg{1}\fi
+ %
+ % Detect if the argument is a single token. If so, it might be a
+ % letter. Otherwise, the only valid thing it can be is a number.
+ % (We will always have one token, because of the test we just made.
+ % This is a good thing, since \splitoff doesn't work given nothing at
+ % all -- the first parameter is undelimited.)
+ \expandafter\splitoff\thearg\endmark
+ \ifx\rest\empty
+ % Only one token in the argument. It could still be anything.
+ % A ``lowercase letter'' is one whose \lccode is nonzero.
+ % An ``uppercase letter'' is one whose \lccode is both nonzero, and
+ % not equal to itself.
+ % Otherwise, we assume it's a number.
+ %
+ % We need the \relax at the end of the \ifnum lines to stop TeX from
+ % continuing to look for a <number>.
+ %
+ \ifnum\lccode\expandafter`\thearg=0\relax
+ \numericenumerate % a number (we hope)
+ \else
+ % It's a letter.
+ \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
+ \lowercaseenumerate % lowercase letter
+ \else
+ \uppercaseenumerate % uppercase letter
+ \fi
+ \fi
+ \else
+ % Multiple tokens in the argument. We hope it's a number.
+ \numericenumerate
+ \fi
+}
+
+% An @enumerate whose labels are integers. The starting integer is
+% given in \thearg.
+%
+\def\numericenumerate{%
+ \itemno = \thearg
+ \startenumeration{\the\itemno}%
+}
+
+% The starting (lowercase) letter is in \thearg.
+\def\lowercaseenumerate{%
+ \itemno = \expandafter`\thearg
+ \startenumeration{%
+ % Be sure we're not beyond the end of the alphabet.
+ \ifnum\itemno=0
+ \errmessage{No more lowercase letters in @enumerate; get a bigger
+ alphabet}%
+ \fi
+ \char\lccode\itemno
+ }%
+}
+
+% The starting (uppercase) letter is in \thearg.
+\def\uppercaseenumerate{%
+ \itemno = \expandafter`\thearg
+ \startenumeration{%
+ % Be sure we're not beyond the end of the alphabet.
+ \ifnum\itemno=0
+ \errmessage{No more uppercase letters in @enumerate; get a bigger
+ alphabet}
+ \fi
+ \char\uccode\itemno
+ }%
+}
+
+% Call \doitemize, adding a period to the first argument and supplying the
+% common last two arguments. Also subtract one from the initial value in
+% \itemno, since @item increments \itemno.
+%
+\def\startenumeration#1{%
+ \advance\itemno by -1
+ \doitemize{#1.}\flushcr
+}
+
+% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
+% to @enumerate.
+%
+\def\alphaenumerate{\enumerate{a}}
+\def\capsenumerate{\enumerate{A}}
+\def\Ealphaenumerate{\Eenumerate}
+\def\Ecapsenumerate{\Eenumerate}
+
+
+% @multitable macros
+% Amy Hendrickson, 8/18/94, 3/6/96
+%
+% @multitable ... @end multitable will make as many columns as desired.
+% Contents of each column will wrap at width given in preamble. Width
+% can be specified either with sample text given in a template line,
+% or in percent of \hsize, the current width of text on page.
+
+% Table can continue over pages but will only break between lines.
+
+% To make preamble:
+%
+% Either define widths of columns in terms of percent of \hsize:
+% @multitable @columnfractions .25 .3 .45
+% @item ...
+%
+% Numbers following @columnfractions are the percent of the total
+% current hsize to be used for each column. You may use as many
+% columns as desired.
+
+
+% Or use a template:
+% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
+% @item ...
+% using the widest term desired in each column.
+
+% Each new table line starts with @item, each subsequent new column
+% starts with @tab. Empty columns may be produced by supplying @tab's
+% with nothing between them for as many times as empty columns are needed,
+% ie, @tab at tab@tab will produce two empty columns.
+
+% @item, @tab do not need to be on their own lines, but it will not hurt
+% if they are.
+
+% Sample multitable:
+
+% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
+% @item first col stuff @tab second col stuff @tab third col
+% @item
+% first col stuff
+% @tab
+% second col stuff
+% @tab
+% third col
+% @item first col stuff @tab second col stuff
+% @tab Many paragraphs of text may be used in any column.
+%
+% They will wrap at the width determined by the template.
+% @item at tab@tab This will be in third column.
+% @end multitable
+
+% Default dimensions may be reset by user.
+% @multitableparskip is vertical space between paragraphs in table.
+% @multitableparindent is paragraph indent in table.
+% @multitablecolmargin is horizontal space to be left between columns.
+% @multitablelinespace is space to leave between table items, baseline
+% to baseline.
+% 0pt means it depends on current normal line spacing.
+%
+\newskip\multitableparskip
+\newskip\multitableparindent
+\newdimen\multitablecolspace
+\newskip\multitablelinespace
+\multitableparskip=0pt
+\multitableparindent=6pt
+\multitablecolspace=12pt
+\multitablelinespace=0pt
+
+% Macros used to set up halign preamble:
+%
+\let\endsetuptable\relax
+\def\xendsetuptable{\endsetuptable}
+\let\columnfractions\relax
+\def\xcolumnfractions{\columnfractions}
+\newif\ifsetpercent
+
+% #1 is the @columnfraction, usually a decimal number like .5, but might
+% be just 1. We just use it, whatever it is.
+%
+\def\pickupwholefraction#1 {%
+ \global\advance\colcount by 1
+ \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
+ \setuptable
+}
+
+\newcount\colcount
+\def\setuptable#1{%
+ \def\firstarg{#1}%
+ \ifx\firstarg\xendsetuptable
+ \let\go = \relax
+ \else
+ \ifx\firstarg\xcolumnfractions
+ \global\setpercenttrue
+ \else
+ \ifsetpercent
+ \let\go\pickupwholefraction
+ \else
+ \global\advance\colcount by 1
+ \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
+ % separator; typically that is always in the input, anyway.
+ \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
+ \fi
+ \fi
+ \ifx\go\pickupwholefraction
+ % Put the argument back for the \pickupwholefraction call, so
+ % we'll always have a period there to be parsed.
+ \def\go{\pickupwholefraction#1}%
+ \else
+ \let\go = \setuptable
+ \fi%
+ \fi
+ \go
+}
+
+% multitable-only commands.
+%
+% @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}%
+%
+% 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.
+% --karl, nathan at acm.org, 20apr99.
+\def\tab{\checkenv\multitable &\the\everytab}%
+
+% @multitable ... @end multitable definitions:
+%
+\newtoks\everytab % insert after every tab.
+%
+\envdef\multitable{%
+ \vskip\parskip
+ \startsavinginserts
+ %
+ % @item within a multitable starts a normal row.
+ % We use \def instead of \let so that if one of the multitable entries
+ % contains an @itemize, we don't choke on the \item (seen as \crcr aka
+ % \endtemplate) expanding \doitemize.
+ \def\item{\crcr}%
+ %
+ \tolerance=9500
+ \hbadness=9500
+ \setmultitablespacing
+ \parskip=\multitableparskip
+ \parindent=\multitableparindent
+ \overfullrule=0pt
+ \global\colcount=0
+ %
+ \everycr = {%
+ \noalign{%
+ \global\everytab={}%
+ \global\colcount=0 % Reset the column counter.
+ % Check for saved footnotes, etc.
+ \checkinserts
+ % Keeps underfull box messages off when table breaks over pages.
+ %\filbreak
+ % Maybe so, but it also creates really weird page breaks when the
+ % table breaks over pages. Wouldn't \vfil be better? Wait until the
+ % problem manifests itself, so it can be fixed for real --karl.
+ }%
+ }%
+ %
+ \parsearg\domultitable
+}
+\def\domultitable#1{%
+ % To parse everything between @multitable and @item:
+ \setuptable#1 \endsetuptable
+ %
+ % This preamble sets up a generic column definition, which will
+ % be used as many times as user calls for columns.
+ % \vtop will set a single line and will also let text wrap and
+ % continue for many paragraphs if desired.
+ \halign\bgroup &%
+ \global\advance\colcount by 1
+ \multistrut
+ \vtop{%
+ % Use the current \colcount to find the correct column width:
+ \hsize=\expandafter\csname col\the\colcount\endcsname
+ %
+ % In order to keep entries from bumping into each other
+ % we will add a \leftskip of \multitablecolspace to all columns after
+ % the first one.
+ %
+ % If a template has been used, we will add \multitablecolspace
+ % to the width of each template entry.
+ %
+ % If the user has set preamble in terms of percent of \hsize we will
+ % use that dimension as the width of the column, and the \leftskip
+ % will keep entries from bumping into each other. Table will start at
+ % left margin and final column will justify at right margin.
+ %
+ % Make sure we don't inherit \rightskip from the outer environment.
+ \rightskip=0pt
+ \ifnum\colcount=1
+ % The first column will be indented with the surrounding text.
+ \advance\hsize by\leftskip
+ \else
+ \ifsetpercent \else
+ % If user has not set preamble in terms of percent of \hsize
+ % we will advance \hsize by \multitablecolspace.
+ \advance\hsize by \multitablecolspace
+ \fi
+ % In either case we will make \leftskip=\multitablecolspace:
+ \leftskip=\multitablecolspace
+ \fi
+ % Ignoring space at the beginning and end avoids an occasional spurious
+ % blank line, when TeX decides to break the line at the space before the
+ % box from the multistrut, so the strut ends up on a line by itself.
+ % For example:
+ % @multitable @columnfractions .11 .89
+ % @item @code{#}
+ % @tab Legal holiday which is valid in major parts of the whole country.
+ % Is automatically provided with highlighting sequences respectively
+ % marking characters.
+ \noindent\ignorespaces##\unskip\multistrut
+ }\cr
+}
+\def\Emultitable{%
+ \crcr
+ \egroup % end the \halign
+ \global\setpercentfalse
+}
+
+\def\setmultitablespacing{%
+ \def\multistrut{\strut}% just use the standard line spacing
+ %
+ % Compute \multitablelinespace (if not defined by user) for use in
+ % \multitableparskip calculation. We used define \multistrut based on
+ % this, but (ironically) that caused the spacing to be off.
+ % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
+\ifdim\multitablelinespace=0pt
+\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
+\global\advance\multitablelinespace by-\ht0
+\fi
+%% Test to see if parskip is larger than space between lines of
+%% table. If not, do nothing.
+%% If so, set to same dimension as multitablelinespace.
+\ifdim\multitableparskip>\multitablelinespace
+\global\multitableparskip=\multitablelinespace
+\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
+ %% than skip between lines in the table.
+\fi%
+\ifdim\multitableparskip=0pt
+\global\multitableparskip=\multitablelinespace
+\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
+ %% than skip between lines in the table.
+\fi}
+
+
+\message{conditionals,}
+
+% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
+% @ifnotxml always succeed. They currently do nothing; we don't
+% attempt to check whether the conditionals are properly nested. But we
+% have to remember that they are conditionals, so that @end doesn't
+% attempt to close an environment group.
+%
+\def\makecond#1{%
+ \expandafter\let\csname #1\endcsname = \relax
+ \expandafter\let\csname iscond.#1\endcsname = 1
+}
+\makecond{iftex}
+\makecond{ifnotdocbook}
+\makecond{ifnothtml}
+\makecond{ifnotinfo}
+\makecond{ifnotplaintext}
+\makecond{ifnotxml}
+
+% Ignore @ignore, @ifhtml, @ifinfo, and the like.
+%
+\def\direntry{\doignore{direntry}}
+\def\documentdescription{\doignore{documentdescription}}
+\def\docbook{\doignore{docbook}}
+\def\html{\doignore{html}}
+\def\ifdocbook{\doignore{ifdocbook}}
+\def\ifhtml{\doignore{ifhtml}}
+\def\ifinfo{\doignore{ifinfo}}
+\def\ifnottex{\doignore{ifnottex}}
+\def\ifplaintext{\doignore{ifplaintext}}
+\def\ifxml{\doignore{ifxml}}
+\def\ignore{\doignore{ignore}}
+\def\menu{\doignore{menu}}
+\def\xml{\doignore{xml}}
+
+% Ignore text until a line `@end #1', keeping track of nested conditionals.
+%
+% A count to remember the depth of nesting.
+\newcount\doignorecount
+
+\def\doignore#1{\begingroup
+ % Scan in ``verbatim'' mode:
+ \catcode`\@ = \other
+ \catcode`\{ = \other
+ \catcode`\} = \other
+ %
+ % Make sure that spaces turn into tokens that match what \doignoretext wants.
+ \spaceisspace
+ %
+ % Count number of #1's that we've seen.
+ \doignorecount = 0
+ %
+ % Swallow text until we reach the matching `@end #1'.
+ \dodoignore{#1}%
+}
+
+{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
+ \obeylines %
+ %
+ \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_}%
+ % 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%
+ }%
+}
+
+\def\doignoreyyy#1{%
+ \def\temp{#1}%
+ \ifx\temp\empty % Nothing found.
+ \let\next\doignoretextzzz
+ \else % Found a nested condition, ...
+ \advance\doignorecount by 1
+ \let\next\doignoretextyyy % ..., look for another.
+ % If we're here, #1 ends with ^^M\ifinfo (for example).
+ \fi
+ \next #1% the token \_STOP_ is present just after this macro.
+}
+
+% We have to swallow the remaining "\_STOP_".
+%
+\def\doignoretextzzz#1{%
+ \ifnum\doignorecount = 0 % We have just found the outermost @end.
+ \let\next\enddoignore
+ \else % Still inside a nested condition.
+ \advance\doignorecount by -1
+ \let\next\doignoretext % Look for the next @end.
+ \fi
+ \next
+}
+
+% Finish off ignored text.
+\def\enddoignore{\endgroup\ignorespaces}
+
+
+% @set VAR sets the variable VAR to an empty value.
+% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
+%
+% Since we want to separate VAR from REST-OF-LINE (which might be
+% empty), we can't just use \parsearg; we have to insert a space of our
+% own to delimit the rest of the line, and then take it out again if we
+% didn't need it.
+% We rely on the fact that \parsearg sets \catcode`\ =10.
+%
+\parseargdef\set{\setyyy#1 \endsetyyy}
+\def\setyyy#1 #2\endsetyyy{%
+ {%
+ \makevalueexpandable
+ \def\temp{#2}%
+ \edef\next{\gdef\makecsname{SET#1}}%
+ \ifx\temp\empty
+ \next{}%
+ \else
+ \setzzz#2\endsetzzz
+ \fi
+ }%
+}
+% Remove the trailing space \setxxx inserted.
+\def\setzzz#1 \endsetzzz{\next{#1}}
+
+% @clear VAR clears (i.e., unsets) the variable VAR.
+%
+\parseargdef\clear{%
+ {%
+ \makevalueexpandable
+ \global\expandafter\let\csname SET#1\endcsname=\relax
+ }%
+}
+
+% @value{foo} gets the text saved in variable foo.
+\def\value{\begingroup\makevalueexpandable\valuexxx}
+\def\valuexxx#1{\expandablevalue{#1}\endgroup}
+{
+ \catcode`\- = \active \catcode`\_ = \active
+ %
+ \gdef\makevalueexpandable{%
+ \let\value = \expandablevalue
+ % We don't want these characters active, ...
+ \catcode`\-=\other \catcode`\_=\other
+ % ..., but we might end up with active ones in the argument if
+ % we're called from @code, as @code{@value{foo-bar_}}, though.
+ % So \let them to their normal equivalents.
+ \let-\realdash \let_\normalunderscore
+ }
+}
+
+% We have this subroutine so that we can handle at least some @value's
+% properly in indexes (we call \makevalueexpandable in \indexdummies).
+% The command has to be fully expandable (if the variable is set), since
+% the result winds up in the index file. This means that if the
+% variable's value contains other Texinfo commands, it's almost certain
+% it will fail (although perhaps we could fix that with sufficient work
+% to do a one-level expansion on the result, instead of complete).
+%
+\def\expandablevalue#1{%
+ \expandafter\ifx\csname SET#1\endcsname\relax
+ {[No value for ``#1'']}%
+ \message{Variable `#1', used in @value, is not set.}%
+ \else
+ \csname SET#1\endcsname
+ \fi
+}
+
+% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
+% with @set.
+%
+% To get special treatment of `@end ifset,' call \makeond and the redefine.
+%
+\makecond{ifset}
+\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
+\def\doifset#1#2{%
+ {%
+ \makevalueexpandable
+ \let\next=\empty
+ \expandafter\ifx\csname SET#2\endcsname\relax
+ #1% If not set, redefine \next.
+ \fi
+ \expandafter
+ }\next
+}
+\def\ifsetfail{\doignore{ifset}}
+
+% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
+% defined with @set, or has been undefined with @clear.
+%
+% The `\else' inside the `\doifset' parameter is a trick to reuse the
+% above code: if the variable is not set, do nothing, if it is set,
+% then redefine \next to \ifclearfail.
+%
+\makecond{ifclear}
+\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
+\def\ifclearfail{\doignore{ifclear}}
+
+% @dircategory CATEGORY -- specify a category of the dir file
+% which this file should belong to. Ignore this in TeX.
+\let\dircategory=\comment
+
+% @defininfoenclose.
+\let\definfoenclose=\comment
+
+
+\message{indexing,}
+% Index generation facilities
+
+% Define \newwrite to be identical to plain tex's \newwrite
+% except not \outer, so it can be used within macros and \if's.
+\edef\newwrite{\makecsname{ptexnewwrite}}
+
+% \newindex {foo} defines an index named foo.
+% It automatically defines \fooindex such that
+% \fooindex ...rest of line... puts an entry in the index foo.
+% It also defines \fooindfile to be the number of the output channel for
+% the file that accumulates this index. The file's extension is foo.
+% The name of an index should be no more than 2 characters long
+% for the sake of vms.
+%
+\def\newindex#1{%
+ \iflinks
+ \expandafter\newwrite \csname#1indfile\endcsname
+ \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
+ \fi
+ \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
+ \noexpand\doindex{#1}}
+}
+
+% @defindex foo == \newindex{foo}
+%
+\def\defindex{\parsearg\newindex}
+
+% Define @defcodeindex, like @defindex except put all entries in @code.
+%
+\def\defcodeindex{\parsearg\newcodeindex}
+%
+\def\newcodeindex#1{%
+ \iflinks
+ \expandafter\newwrite \csname#1indfile\endcsname
+ \openout \csname#1indfile\endcsname \jobname.#1
+ \fi
+ \expandafter\xdef\csname#1index\endcsname{%
+ \noexpand\docodeindex{#1}}%
+}
+
+
+% @synindex foo bar makes index foo feed into index bar.
+% Do this instead of @defindex foo if you don't want it as a separate index.
+%
+% @syncodeindex foo bar similar, but put all entries made for index foo
+% inside @code.
+%
+\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
+\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
+
+% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
+% #3 the target index (bar).
+\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
+ % 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
+ \fi
+ % redefine \fooindfile:
+ \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
+ \expandafter\let\csname#2indfile\endcsname=\temp
+ % redefine \fooindex:
+ \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
+}
+
+% Define \doindex, the driver for all \fooindex macros.
+% Argument #1 is generated by the calling \fooindex macro,
+% and it is "foo", the name of the index.
+
+% \doindex just uses \parsearg; it calls \doind for the actual work.
+% This is because \doind is more useful to call from other macros.
+
+% There is also \dosubind {index}{topic}{subtopic}
+% which makes an entry in a two-level index such as the operation index.
+
+\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
+\def\singleindexer #1{\doind{\indexname}{#1}}
+
+% like the previous two, but they put @code around the argument.
+\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
+\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
+
+% Take care of Texinfo commands that can appear in an index entry.
+% Since there are some commands we want to expand, and others we don't,
+% we have to laboriously prevent expansion for those that we don't.
+%
+\def\indexdummies{%
+ \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
+ %
+ % Do the redefinitions.
+ \commondummies
+}
+
+% For the aux and toc files, @ is the escape character. So we want to
+% redefine everything using @ as the escape character (instead of
+% \realbackslash, still used for index files). When everything uses @,
+% this will be simpler.
+%
+\def\atdummies{%
+ \def\@{@@}%
+ \def\ {@ }%
+ \let\{ = \lbraceatcmd
+ \let\} = \rbraceatcmd
+ %
+ % Do the redefinitions.
+ \commondummies
+}
+
+% Called from \indexdummies and \atdummies.
+%
+\def\commondummies{%
+ %
+ % \definedummyword defines \#1 as \string\#1\space, thus effectively
+ % preventing its expansion. This is used only for control% words,
+ % not control letters, because the \space would be incorrect for
+ % control characters, but is needed to separate the control word
+ % from whatever follows.
+ %
+ % For control letters, we have \definedummyletter, which omits the
+ % space.
+ %
+ % These can be used both for control words that take an argument and
+ % those that do not. If it is followed by {arg} in the input, then
+ % that will dutifully get written to the index (or wherever).
+ %
+ \def\definedummyword ##1{\def##1{\string##1\space}}%
+ \def\definedummyletter##1{\def##1{\string##1}}%
+ \let\definedummyaccent\definedummyletter
+ %
+ \commondummiesnofonts
+ %
+ \definedummyletter\_%
+ %
+ % Non-English letters.
+ \definedummyword\AA
+ \definedummyword\AE
+ \definedummyword\L
+ \definedummyword\OE
+ \definedummyword\O
+ \definedummyword\aa
+ \definedummyword\ae
+ \definedummyword\l
+ \definedummyword\oe
+ \definedummyword\o
+ \definedummyword\ss
+ \definedummyword\exclamdown
+ \definedummyword\questiondown
+ \definedummyword\ordf
+ \definedummyword\ordm
+ %
+ % Although these internal commands shouldn't show up, sometimes they do.
+ \definedummyword\bf
+ \definedummyword\gtr
+ \definedummyword\hat
+ \definedummyword\less
+ \definedummyword\sf
+ \definedummyword\sl
+ \definedummyword\tclose
+ \definedummyword\tt
+ %
+ \definedummyword\LaTeX
+ \definedummyword\TeX
+ %
+ % Assorted special characters.
+ \definedummyword\bullet
+ \definedummyword\comma
+ \definedummyword\copyright
+ \definedummyword\registeredsymbol
+ \definedummyword\dots
+ \definedummyword\enddots
+ \definedummyword\equiv
+ \definedummyword\error
+ \definedummyword\euro
+ \definedummyword\expansion
+ \definedummyword\minus
+ \definedummyword\pounds
+ \definedummyword\point
+ \definedummyword\print
+ \definedummyword\result
+ %
+ % We want to disable all macros so that they are not expanded by \write.
+ \macrolist
+ %
+ \normalturnoffactive
+ %
+ % Handle some cases of @value -- where it does not contain any
+ % (non-fully-expandable) commands.
+ \makevalueexpandable
+}
+
+% \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
+ }
+}
+
+% \indexnofonts is used when outputting the strings to sort the index
+% by, and when constructing control sequence names. It eliminates all
+% control sequences and just writes whatever the best ASCII sort string
+% would be for a given command (usually its argument).
+%
+\def\indexnofonts{%
+ % Accent commands should become @asis.
+ \def\definedummyaccent##1{\let##1\asis}%
+ % We can just ignore other control letters.
+ \def\definedummyletter##1{\let##1\empty}%
+ % Hopefully, all control words can become @asis.
+ \let\definedummyword\definedummyaccent
+ %
+ \commondummiesnofonts
+ %
+ % Don't no-op \tt, since it isn't a user-level command
+ % and is used in the definitions of the active chars like <, >, |, etc.
+ % Likewise with the other plain tex font commands.
+ %\let\tt=\asis
+ %
+ \def\ { }%
+ \def\@{@}%
+ % how to handle braces?
+ \def\_{\normalunderscore}%
+ %
+ % Non-English letters.
+ \def\AA{AA}%
+ \def\AE{AE}%
+ \def\L{L}%
+ \def\OE{OE}%
+ \def\O{O}%
+ \def\aa{aa}%
+ \def\ae{ae}%
+ \def\l{l}%
+ \def\oe{oe}%
+ \def\o{o}%
+ \def\ss{ss}%
+ \def\exclamdown{!}%
+ \def\questiondown{?}%
+ \def\ordf{a}%
+ \def\ordm{o}%
+ %
+ \def\LaTeX{LaTeX}%
+ \def\TeX{TeX}%
+ %
+ % Assorted special characters.
+ % (The following {} will end up in the sort string, but that's ok.)
+ \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\minus{-}%
+ \def\pounds{pounds}%
+ \def\point{.}%
+ \def\print{-|}%
+ \def\result{=>}%
+ %
+ % 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
+}
+
+\let\indexbackslash=0 %overridden during \printindex.
+\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
+
+% Most index entries go through here, but \dosubind is the general case.
+% #1 is the index name, #2 is the entry text.
+\def\doind#1#2{\dosubind{#1}{#2}{}}
+
+% Workhorse for all \fooindexes.
+% #1 is name of index, #2 is stuff to put there, #3 is subentry --
+% empty if called from \doind, as we usually are (the main exception
+% is with most defuns, which call us directly).
+%
+\def\dosubind#1#2#3{%
+ \iflinks
+ {%
+ % Store the main index entry text (including the third arg).
+ \toks0 = {#2}%
+ % If third arg is present, precede it with a space.
+ \def\thirdarg{#3}%
+ \ifx\thirdarg\empty \else
+ \toks0 = \expandafter{\the\toks0 \space #3}%
+ \fi
+ %
+ \edef\writeto{\csname#1indfile\endcsname}%
+ %
+ \ifvmode
+ \dosubindsanitize
+ \else
+ \dosubindwrite
+ \fi
+ }%
+ \fi
+}
+
+% Write the entry in \toks0 to the index file:
+%
+\def\dosubindwrite{%
+ % Put the index entry in the margin if desired.
+ \ifx\SETmarginindex\relax\else
+ \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
+ \fi
+ %
+ % Remember, we are within a group.
+ \indexdummies % Must do this here, since \bf, etc expand at this stage
+ \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
+ % so it will be output as is; and it will print as backslash.
+ %
+ % Process the index entry with all font commands turned off, to
+ % get the string to sort by.
+ {\indexnofonts
+ \edef\temp{\the\toks0}% need full expansion
+ \xdef\indexsorttmp{\temp}%
+ }%
+ %
+ % Set up the complete index entry, with both the sort key and
+ % the original text, including any font commands. We write
+ % three arguments to \entry to the .?? file (four in the
+ % subentry case), texindex reduces to two when writing the .??s
+ % sorted result.
+ \edef\temp{%
+ \write\writeto{%
+ \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
+ }%
+ \temp
+}
+
+% Take care of unwanted page breaks:
+%
+% 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:
+% @end defun
+% @tindex whatever
+% @defun ...
+% will have extra space inserted, because the \medbreak in the
+% start of the @defun won't see the skip inserted by the @end of
+% the previous defun.
+%
+% But don't do any of this if we're not in vertical mode. We
+% don't want to do a \vskip and prematurely end a paragraph.
+%
+% Avoid page breaks due to these extra skips, too.
+%
+% But wait, there is a catch there:
+% We'll have to check whether \lastskip is zero skip. \ifdim is not
+% sufficient for this purpose, as it ignores stretch and shrink parts
+% of the skip. The only way seems to be to check the textual
+% representation of the skip.
+%
+% The following is almost like \def\zeroskipmacro{0.0pt} except that
+% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
+%
+\edef\zeroskipmacro{\expandafter\the\csname z at skip\endcsname}
+%
+% ..., ready, GO:
+%
+\def\dosubindsanitize{%
+ % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
+ \skip0 = \lastskip
+ \edef\lastskipmacro{\the\lastskip}%
+ \count255 = \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
+ % non-discardable item, therefore it is not a potential
+ % breakpoint, therefore no \nobreak needed.
+ \ifx\lastskipmacro\zeroskipmacro
+ \else
+ \vskip-\skip0
+ \fi
+ %
+ \dosubindwrite
+ %
+ \ifx\lastskipmacro\zeroskipmacro
+ % If \lastskip was zero, perhaps the last item was a penalty, and
+ % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
+ % 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
+ \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
+ \fi
+}
+
+% The index entry written in the file actually looks like
+% \entry {sortstring}{page}{topic}
+% or
+% \entry {sortstring}{page}{topic}{subtopic}
+% The texindex program reads in these files and writes files
+% containing these kinds of lines:
+% \initial {c}
+% before the first topic whose initial is c
+% \entry {topic}{pagelist}
+% for a topic that is used without subtopics
+% \primary {topic}
+% for the beginning of a topic that is used with subtopics
+% \secondary {subtopic}{pagelist}
+% for each subtopic.
+
+% Define the user-accessible indexing commands
+% @findex, @vindex, @kindex, @cindex.
+
+\def\findex {\fnindex}
+\def\kindex {\kyindex}
+\def\cindex {\cpindex}
+\def\vindex {\vrindex}
+\def\tindex {\tpindex}
+\def\pindex {\pgindex}
+
+\def\cindexsub {\begingroup\obeylines\cindexsub}
+{\obeylines %
+\gdef\cindexsub "#1" #2^^M{\endgroup %
+\dosubind{cp}{#2}{#1}}}
+
+% Define the macros used in formatting output of the sorted index material.
+
+% @printindex causes a particular index (the ??s file) to get printed.
+% It does not print any chapter heading (usually an @unnumbered).
+%
+\parseargdef\printindex{\begingroup
+ \dobreak \chapheadingskip{10000}%
+ %
+ \smallfonts \rm
+ \tolerance = 9500
+ \everypar = {}% don't want the \kern\-parindent from indentation suppression.
+ %
+ % See if the index file exists and is nonempty.
+ % Change catcode of @ here so that if the index file contains
+ % \initial {@}
+ % as its first line, TeX doesn't complain about mismatched braces
+ % (because it thinks @} is a control sequence).
+ \catcode`\@ = 11
+ \openin 1 \jobname.#1s
+ \ifeof 1
+ % \enddoublecolumns gets confused if there is no text in the index,
+ % and it loses the chapter title and the aux file entries for the
+ % index. The easiest way to prevent this problem is to make sure
+ % there is some text.
+ \putwordIndexNonexistent
+ \else
+ %
+ % If the index file exists but is empty, then \openin leaves \ifeof
+ % false. We have to make TeX try to read something from the file, so
+ % it can discover if there is anything in it.
+ \read 1 to \temp
+ \ifeof 1
+ \putwordIndexIsEmpty
+ \else
+ % Index files are almost Texinfo source, but we use \ as the escape
+ % character. It would be better to use @, but that's too big a change
+ % to make right now.
+ \def\indexbackslash{\backslashcurfont}%
+ \catcode`\\ = 0
+ \escapechar = `\\
+ \begindoublecolumns
+ \input \jobname.#1s
+ \enddoublecolumns
+ \fi
+ \fi
+ \closein 1
+\endgroup}
+
+% These macros are used by the sorted index file itself.
+% Change them to control the appearance of the index.
+
+\def\initial#1{{%
+ % Some minor font changes for the special characters.
+ \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
+ %
+ % Remove any glue we may have, we'll be inserting our own.
+ \removelastskip
+ %
+ % We like breaks before the index initials, so insert a bonus.
+ \nobreak
+ \vskip 0pt plus 3\baselineskip
+ \penalty 0
+ \vskip 0pt plus -3\baselineskip
+ %
+ % Typeset the initial. Making this add up to a whole number of
+ % baselineskips increases the chance of the dots lining up from column
+ % to column. It still won't often be perfect, because of the stretch
+ % we need before each entry, but it's better.
+ %
+ % No shrink because it confuses \balancecolumns.
+ \vskip 1.67\baselineskip plus .5\baselineskip
+ \leftline{\secbf #1}%
+ % Do our best not to break after the initial.
+ \nobreak
+ \vskip .33\baselineskip plus .1\baselineskip
+}}
+
+% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
+% then page number (#2) flushed to the right margin. It is used for index
+% and table of contents entries. The paragraph is indented by \leftskip.
+%
+% A straightforward implementation would start like this:
+% \def\entry#1#2{...
+% But this frozes 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.
+%
+% The right solution is to prevent \entry from swallowing the whole text.
+% --kasal, 21nov03
+\def\entry{%
+ \begingroup
+ %
+ % Start a new paragraph if necessary, so our assignments below can't
+ % affect previous text.
+ \par
+ %
+ % Do not fill out the last line with white space.
+ \parfillskip = 0in
+ %
+ % No extra space above this paragraph.
+ \parskip = 0in
+ %
+ % Do not prefer a separate line ending with a hyphen to fewer lines.
+ \finalhyphendemerits = 0
+ %
+ % \hangindent is only relevant when the entry text and page number
+ % don't both fit on one line. In that case, bob suggests starting the
+ % dots pretty far over on the line. Unfortunately, a large
+ % indentation looks wrong when the entry text itself is broken across
+ % lines. So we use a small indentation and put up with long leaders.
+ %
+ % \hangafter is reset to 1 (which is the value we want) at the start
+ % of each paragraph, so we need not do anything with that.
+ \hangindent = 2em
+ %
+ % When the entry text needs to be broken, just fill out the first line
+ % with blank space.
+ \rightskip = 0pt plus1fil
+ %
+ % A bit of stretch before each entry for the benefit of balancing
+ % columns.
+ \vskip 0pt plus1pt
+ %
+ % Swallow the left brace of the text (first parameter):
+ \afterassignment\doentry
+ \let\temp =
+}
+\def\doentry{%
+ \bgroup % Instead of the swallowed brace.
+ \noindent
+ \aftergroup\finishentry
+ % And now comes the text of the entry.
+}
+\def\finishentry#1{%
+ % #1 is the page number.
+ %
+ % 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
+ \ %
+ \else
+ %
+ % If we must, put the page number on a line of its own, and fill out
+ % this line with blank space. (The \hfil is overwhelmed with the
+ % fill leaders glue in \indexdotfill if the page number does fit.)
+ \hfil\penalty50
+ \null\nobreak\indexdotfill % Have leaders before the page number.
+ %
+ % The `\ ' here is removed by the implicit \unskip that TeX does as
+ % part of (the primitive) \par. Without it, a spurious underfull
+ % \hbox ensues.
+ \ifpdf
+ \pdfgettoks#1.%
+ \ \the\toksA
+ \else
+ \ #1%
+ \fi
+ \fi
+ \par
+ \endgroup
+}
+
+% Like \dotfill except takes at least 1 em.
+\def\indexdotfill{\cleaders
+ \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
+
+\def\primary #1{\line{#1\hfil}}
+
+\newskip\secondaryindent \secondaryindent=0.5cm
+\def\secondary#1#2{{%
+ \parfillskip=0in
+ \parskip=0in
+ \hangindent=1in
+ \hangafter=1
+ \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
+ \ifpdf
+ \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
+ \else
+ #2
+ \fi
+ \par
+}}
+
+% Define two-column mode, which we use to typeset indexes.
+% Adapted from the TeXbook, page 416, which is to say,
+% the manmac.tex format used to print the TeXbook itself.
+\catcode`\@=11
+
+\newbox\partialpage
+\newdimen\doublecolumnhsize
+
+\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
+ % Grab any single-column material above us.
+ \output = {%
+ %
+ % Here is a possibility not foreseen in manmac: if we accumulate a
+ % whole lot of material, we might end up calling this \output
+ % routine twice in a row (see the doublecol-lose test, which is
+ % essentially a couple of indexes with @setchapternewpage off). In
+ % that case we just ship out what is in \partialpage with the normal
+ % output routine. Generally, \partialpage will be empty when this
+ % runs and this will be a no-op. See the indexspread.tex test case.
+ \ifvoid\partialpage \else
+ \onepageout{\pagecontents\partialpage}%
+ \fi
+ %
+ \global\setbox\partialpage = \vbox{%
+ % Unvbox the main output page.
+ \unvbox\PAGE
+ \kern-\topskip \kern\baselineskip
+ }%
+ }%
+ \eject % run that output routine to set \partialpage
+ %
+ % Use the double-column output routine for subsequent pages.
+ \output = {\doublecolumnout}%
+ %
+ % Change the page size parameters. We could do this once outside this
+ % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
+ % format, but then we repeat the same computation. Repeating a couple
+ % of assignments once per index is clearly meaningless for the
+ % execution time, so we may as well do it in one place.
+ %
+ % First we halve the line length, less a little for the gutter between
+ % the columns. We compute the gutter based on the line length, so it
+ % changes automatically with the paper format. The magic constant
+ % below is chosen so that the gutter has the same value (well, +-<1pt)
+ % as it did when we hard-coded it.
+ %
+ % We put the result in a separate register, \doublecolumhsize, so we
+ % can restore it in \pagesofar, after \hsize itself has (potentially)
+ % been clobbered.
+ %
+ \doublecolumnhsize = \hsize
+ \advance\doublecolumnhsize by -.04154\hsize
+ \divide\doublecolumnhsize by 2
+ \hsize = \doublecolumnhsize
+ %
+ % Double the \vsize as well. (We don't need a separate register here,
+ % since nobody clobbers \vsize.)
+ \vsize = 2\vsize
+}
+
+% The double-column output routine for all double-column pages except
+% the last.
+%
+\def\doublecolumnout{%
+ \splittopskip=\topskip \splitmaxdepth=\maxdepth
+ % Get the available space for the double columns -- the normal
+ % (undoubled) page height minus any material left over from the
+ % previous page.
+ \dimen@ = \vsize
+ \divide\dimen@ by 2
+ \advance\dimen@ by -\ht\partialpage
+ %
+ % box0 will be the left-hand column, box2 the right.
+ \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
+ \onepageout\pagesofar
+ \unvbox255
+ \penalty\outputpenalty
+}
+%
+% Re-output the contents of the output page -- any previous material,
+% followed by the two boxes we just split, in box0 and box2.
+\def\pagesofar{%
+ \unvbox\partialpage
+ %
+ \hsize = \doublecolumnhsize
+ \wd0=\hsize \wd2=\hsize
+ \hbox to\pagewidth{\box0\hfil\box2}%
+}
+%
+% All done with double columns.
+\def\enddoublecolumns{%
+ \output = {%
+ % Split the last of the double-column material. Leave it on the
+ % current page, no automatic page break.
+ \balancecolumns
+ %
+ % If we end up splitting too much material for the current page,
+ % though, there will be another page break right after this \output
+ % invocation ends. Having called \balancecolumns once, we do not
+ % want to call it again. Therefore, reset \output to its normal
+ % definition right away. (We hope \balancecolumns will never be
+ % called on to balance too much material, but if it is, this makes
+ % the output somewhat more palatable.)
+ \global\output = {\onepageout{\pagecontents\PAGE}}%
+ }%
+ \eject
+ \endgroup % started in \begindoublecolumns
+ %
+ % \pagegoal was set to the doubled \vsize above, since we restarted
+ % the current page. We're now back to normal single-column
+ % typesetting, so reset \pagegoal to the normal \vsize (after the
+ % \endgroup where \vsize got restored).
+ \pagegoal = \vsize
+}
+%
+% Called at the end of the double column material.
+\def\balancecolumns{%
+ \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
+ \dimen@ = \ht0
+ \advance\dimen@ by \topskip
+ \advance\dimen@ by-\baselineskip
+ \divide\dimen@ by 2 % target to split to
+ %debug\message{final 2-column material height=\the\ht0, target=\the\dimen at .}%
+ \splittopskip = \topskip
+ % Loop until we get a decent breakpoint.
+ {%
+ \vbadness = 10000
+ \loop
+ \global\setbox3 = \copy0
+ \global\setbox1 = \vsplit3 to \dimen@
+ \ifdim\ht3>\dimen@
+ \global\advance\dimen@ by 1pt
+ \repeat
+ }%
+ %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
+ \setbox0=\vbox to\dimen@{\unvbox1}%
+ \setbox2=\vbox to\dimen@{\unvbox3}%
+ %
+ \pagesofar
+}
+\catcode`\@ = \other
+
+
+\message{sectioning,}
+% Chapters, sections, etc.
+
+% \unnumberedno is an oxymoron, of course. But we count the unnumbered
+% sections so that we can refer to them unambiguously in the pdf
+% outlines by their "section number". We avoid collisions with chapter
+% numbers by starting them at 10000. (If a document ever has 10000
+% chapters, we're in trouble anyway, I'm sure.)
+\newcount\unnumberedno \unnumberedno = 10000
+\newcount\chapno
+\newcount\secno \secno=0
+\newcount\subsecno \subsecno=0
+\newcount\subsubsecno \subsubsecno=0
+
+% This counter is funny since it counts through charcodes of letters A, B, ...
+\newcount\appendixno \appendixno = `\@
+%
+% \def\appendixletter{\char\the\appendixno}
+% We do the following ugly conditional instead of the above simple
+% construct for the sake of pdftex, which needs the actual
+% letter in the expansion, not just typeset.
+%
+\def\appendixletter{%
+ \ifnum\appendixno=`A A%
+ \else\ifnum\appendixno=`B B%
+ \else\ifnum\appendixno=`C C%
+ \else\ifnum\appendixno=`D D%
+ \else\ifnum\appendixno=`E E%
+ \else\ifnum\appendixno=`F F%
+ \else\ifnum\appendixno=`G G%
+ \else\ifnum\appendixno=`H H%
+ \else\ifnum\appendixno=`I I%
+ \else\ifnum\appendixno=`J J%
+ \else\ifnum\appendixno=`K K%
+ \else\ifnum\appendixno=`L L%
+ \else\ifnum\appendixno=`M M%
+ \else\ifnum\appendixno=`N N%
+ \else\ifnum\appendixno=`O O%
+ \else\ifnum\appendixno=`P P%
+ \else\ifnum\appendixno=`Q Q%
+ \else\ifnum\appendixno=`R R%
+ \else\ifnum\appendixno=`S S%
+ \else\ifnum\appendixno=`T T%
+ \else\ifnum\appendixno=`U U%
+ \else\ifnum\appendixno=`V V%
+ \else\ifnum\appendixno=`W W%
+ \else\ifnum\appendixno=`X X%
+ \else\ifnum\appendixno=`Y Y%
+ \else\ifnum\appendixno=`Z Z%
+ % The \the is necessary, despite appearances, because \appendixletter is
+ % expanded while writing the .toc file. \char\appendixno is not
+ % expandable, thus it is written literally, thus all appendixes come out
+ % with the same letter (or @) in the toc without it.
+ \else\char\the\appendixno
+ \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.
+\def\thischapter{}
+\def\thissection{}
+
+\newcount\absseclevel % used to calculate proper heading level
+\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
+
+% @raisesections: treat @section as chapter, @subsection as section, etc.
+\def\raisesections{\global\advance\secbase by -1}
+\let\up=\raisesections % original BFox name
+
+% @lowersections: treat @chapter as section, @section as subsection, etc.
+\def\lowersections{\global\advance\secbase by 1}
+\let\down=\lowersections % original BFox name
+
+% we only have subsub.
+\chardef\maxseclevel = 3
+%
+% A numbered section within an unnumbered changes to unnumbered too.
+% To achive this, remember the "biggest" unnum. sec. we are currently in:
+\chardef\unmlevel = \maxseclevel
+%
+% Trace whether the current chapter is an appendix or not:
+% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
+\def\chapheadtype{N}
+
+% Choose a heading macro
+% #1 is heading type
+% #2 is heading level
+% #3 is text for heading
+\def\genhead#1#2#3{%
+ % Compute the abs. sec. level:
+ \absseclevel=#2
+ \advance\absseclevel by \secbase
+ % Make sure \absseclevel doesn't fall outside the range:
+ \ifnum \absseclevel < 0
+ \absseclevel = 0
+ \else
+ \ifnum \absseclevel > 3
+ \absseclevel = 3
+ \fi
+ \fi
+ % The heading type:
+ \def\headtype{#1}%
+ \if \headtype U%
+ \ifnum \absseclevel < \unmlevel
+ \chardef\unmlevel = \absseclevel
+ \fi
+ \else
+ % Check for appendix sections:
+ \ifnum \absseclevel = 0
+ \edef\chapheadtype{\headtype}%
+ \else
+ \if \headtype A\if \chapheadtype N%
+ \errmessage{@appendix... within a non-appendix chapter}%
+ \fi\fi
+ \fi
+ % Check for numbered within unnumbered:
+ \ifnum \absseclevel > \unmlevel
+ \def\headtype{U}%
+ \else
+ \chardef\unmlevel = 3
+ \fi
+ \fi
+ % Now print the heading:
+ \if \headtype U%
+ \ifcase\absseclevel
+ \unnumberedzzz{#3}%
+ \or \unnumberedseczzz{#3}%
+ \or \unnumberedsubseczzz{#3}%
+ \or \unnumberedsubsubseczzz{#3}%
+ \fi
+ \else
+ \if \headtype A%
+ \ifcase\absseclevel
+ \appendixzzz{#3}%
+ \or \appendixsectionzzz{#3}%
+ \or \appendixsubseczzz{#3}%
+ \or \appendixsubsubseczzz{#3}%
+ \fi
+ \else
+ \ifcase\absseclevel
+ \chapterzzz{#3}%
+ \or \seczzz{#3}%
+ \or \numberedsubseczzz{#3}%
+ \or \numberedsubsubseczzz{#3}%
+ \fi
+ \fi
+ \fi
+ \suppressfirstparagraphindent
+}
+
+% an interface:
+\def\numhead{\genhead N}
+\def\apphead{\genhead A}
+\def\unnmhead{\genhead U}
+
+% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
+% all lower-level sectioning counters to zero.
+%
+% Also set \chaplevelprefix, which we prepend to @float sequence numbers
+% (e.g., figures), q.v. By default (before any chapter), that is empty.
+\let\chaplevelprefix = \empty
+%
+\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
+\def\chapterzzz#1{%
+ % section resetting is \global in case the chapter is in a group, such
+ % as an @include file.
+ \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
+ \global\advance\chapno by 1
+ %
+ % Used for \float.
+ \gdef\chaplevelprefix{\the\chapno.}%
+ \resetallfloatnos
+ %
+ \message{\putwordChapter\space \the\chapno}%
+ %
+ % Write the actual heading.
+ \chapmacro{#1}{Ynumbered}{\the\chapno}%
+ %
+ % So @section and the like are numbered underneath this chapter.
+ \global\let\section = \numberedsec
+ \global\let\subsection = \numberedsubsec
+ \global\let\subsubsection = \numberedsubsubsec
+}
+
+\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 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}%
+ %
+ \chapmacro{#1}{Yappendix}{\appendixletter}%
+ %
+ \global\let\section = \appendixsec
+ \global\let\subsection = \appendixsubsec
+ \global\let\subsubsection = \appendixsubsubsec
+}
+
+\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
+\def\unnumberedzzz#1{%
+ \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
+ \global\advance\unnumberedno by 1
+ %
+ % Since an unnumbered has no number, no prefix for figures.
+ \global\let\chaplevelprefix = \empty
+ \resetallfloatnos
+ %
+ % This used to be simply \message{#1}, but TeX fully expands the
+ % argument to \message. Therefore, if #1 contained @-commands, TeX
+ % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
+ % expanded @cite (which turns out to cause errors because \cite is meant
+ % to be executed, not expanded).
+ %
+ % Anyway, we don't want the fully-expanded definition of @cite to appear
+ % as a result of the \message, we just want `@cite' itself. We use
+ % \the<toks register> to achieve this: TeX expands \the<toks> only once,
+ % simply yielding the contents of <toks register>. (We also do this for
+ % the toc entries.)
+ \toks0 = {#1}%
+ \message{(\the\toks0)}%
+ %
+ \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
+ %
+ \global\let\section = \unnumberedsec
+ \global\let\subsection = \unnumberedsubsec
+ \global\let\subsubsection = \unnumberedsubsubsec
+}
+
+% @centerchap is like @unnumbered, but the heading is centered.
+\outer\parseargdef\centerchap{%
+ % Well, we could do the following in a group, but that would break
+ % an assumption that \chapmacro is called at the outermost level.
+ % Thus we are safer this way: --kasal, 24feb04
+ \let\centerparametersmaybe = \centerparameters
+ \unnmhead0{#1}%
+ \let\centerparametersmaybe = \relax
+}
+
+% @top is like @unnumbered.
+\let\top\unnumbered
+
+% Sections.
+\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
+\def\seczzz#1{%
+ \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
+ \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
+}
+
+\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
+\def\appendixsectionzzz#1{%
+ \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
+ \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
+}
+\let\appendixsec\appendixsection
+
+\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
+\def\unnumberedseczzz#1{%
+ \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
+ \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
+}
+
+% Subsections.
+\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
+\def\numberedsubseczzz#1{%
+ \global\subsubsecno=0 \global\advance\subsecno by 1
+ \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
+}
+
+\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
+\def\appendixsubseczzz#1{%
+ \global\subsubsecno=0 \global\advance\subsecno by 1
+ \sectionheading{#1}{subsec}{Yappendix}%
+ {\appendixletter.\the\secno.\the\subsecno}%
+}
+
+\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
+\def\unnumberedsubseczzz#1{%
+ \global\subsubsecno=0 \global\advance\subsecno by 1
+ \sectionheading{#1}{subsec}{Ynothing}%
+ {\the\unnumberedno.\the\secno.\the\subsecno}%
+}
+
+% Subsubsections.
+\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
+\def\numberedsubsubseczzz#1{%
+ \global\advance\subsubsecno by 1
+ \sectionheading{#1}{subsubsec}{Ynumbered}%
+ {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
+}
+
+\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
+\def\appendixsubsubseczzz#1{%
+ \global\advance\subsubsecno by 1
+ \sectionheading{#1}{subsubsec}{Yappendix}%
+ {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
+}
+
+\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
+\def\unnumberedsubsubseczzz#1{%
+ \global\advance\subsubsecno by 1
+ \sectionheading{#1}{subsubsec}{Ynothing}%
+ {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
+}
+
+% These macros control what the section commands do, according
+% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
+% Define them by default for a numbered chapter.
+\let\section = \numberedsec
+\let\subsection = \numberedsubsec
+\let\subsubsection = \numberedsubsubsec
+
+% Define @majorheading, @heading and @subheading
+
+% NOTE on use of \vbox for chapter headings, section headings, and such:
+% 1) We use \vbox rather than the earlier \line to permit
+% overlong headings to fold.
+% 2) \hyphenpenalty is set to 10000 because hyphenation in a
+% heading is obnoxious; this forbids it.
+% 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
+}
+
+\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
+\def\chapheadingzzz#1{%
+ {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt\raggedright
+ \rm #1\hfill}}%
+ \bigskip \par\penalty 200\relax
+ \suppressfirstparagraphindent
+}
+
+% @heading, @subheading, @subsubheading.
+\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
+ \suppressfirstparagraphindent}
+\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
+ \suppressfirstparagraphindent}
+\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
+ \suppressfirstparagraphindent}
+
+% These macros generate a chapter, section, etc. heading only
+% (including whitespace, linebreaking, etc. around it),
+% given all the information in convenient, parsed form.
+
+%%% Args are the skip and penalty (usually negative)
+\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
+
+%%% Define plain chapter starts, and page on/off switching for it
+% Parameter controlling skip before chapter headings (if needed)
+
+\newskip\chapheadingskip
+
+\def\chapbreak{\dobreak \chapheadingskip {-4000}}
+\def\chappager{\par\vfill\supereject}
+\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
+
+\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
+
+\def\CHAPPAGoff{%
+\global\let\contentsalignmacro = \chappager
+\global\let\pchapsepmacro=\chapbreak
+\global\let\pagealignmacro=\chappager}
+
+\def\CHAPPAGon{%
+\global\let\contentsalignmacro = \chappager
+\global\let\pchapsepmacro=\chappager
+\global\let\pagealignmacro=\chappager
+\global\def\HEADINGSon{\HEADINGSsingle}}
+
+\def\CHAPPAGodd{%
+\global\let\contentsalignmacro = \chapoddpage
+\global\let\pchapsepmacro=\chapoddpage
+\global\let\pagealignmacro=\chapoddpage
+\global\def\HEADINGSon{\HEADINGSdouble}}
+
+\CHAPPAGon
+
+% Chapter opening.
+%
+% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
+% Yappendix, Yomitfromtoc), #3 the chapter number.
+%
+% To test against our argument.
+\def\Ynothingkeyword{Ynothing}
+\def\Yomitfromtockeyword{Yomitfromtoc}
+\def\Yappendixkeyword{Yappendix}
+%
+\def\chapmacro#1#2#3{%
+ \pchapsepmacro
+ {%
+ \chapfonts \rm
+ %
+ % Have to define \thissection 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}%
+ %
+ % 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
+ % \donoderef, because we include the current node name in the toc
+ % entry, and \donoderef resets it to empty.
+ \writetocentry{\toctype}{#1}{#3}%
+ %
+ % For pdftex, we have to write out the node definition (aka, make
+ % the pdfdest) after any page break, but before the actual text has
+ % been typeset. If the destination for the pdf outline is after the
+ % text, then jumping from the outline may wind up with the text not
+ % being visible, for instance under high magnification.
+ \donoderef{#2}%
+ %
+ % Typeset the actual heading.
+ \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
+ \hangindent=\wd0 \centerparametersmaybe
+ \unhbox0 #1\par}%
+ }%
+ \nobreak\bigskip % no page break after a chapter title
+ \nobreak
+}
+
+% @centerchap -- centered and unnumbered.
+\let\centerparametersmaybe = \relax
+\def\centerparameters{%
+ \advance\rightskip by 3\rightskip
+ \leftskip = \rightskip
+ \parfillskip = 0pt
+}
+
+
+% I don't think this chapter style is supported any more, so I'm not
+% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
+%
+\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
+%
+\def\unnchfopen #1{%
+\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt\raggedright
+ \rm #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}}%
+\par\penalty 5000 %
+}
+\def\centerchfopen #1{%
+\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt
+ \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
+}
+\def\CHAPFopen{%
+ \global\let\chapmacro=\chfopen
+ \global\let\centerchapmacro=\centerchfopen}
+
+
+% Section titles. These macros combine the section number parts and
+% call the generic \sectionheading to do the printing.
+%
+\newskip\secheadingskip
+\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
+
+% Subsection titles.
+\newskip\subsecheadingskip
+\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
+
+% Subsubsection titles.
+\def\subsubsecheadingskip{\subsecheadingskip}
+\def\subsubsecheadingbreak{\subsecheadingbreak}
+
+
+% Print any size, any type, section title.
+%
+% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
+% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
+% section number.
+%
+\def\sectionheading#1#2#3#4{%
+ {%
+ % Switch to the right set of fonts.
+ \csname #2fonts\endcsname \rm
+ %
+ % 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}%
+ %
+ \ifx\temptype\Ynothingkeyword
+ \setbox0 = \hbox{}%
+ \def\toctype{unn}%
+ \gdef\thissection{#1}%
+ \else\ifx\temptype\Yomitfromtockeyword
+ % for @headings -- no section number, don't include in toc,
+ % and don't redefine \thissection.
+ \setbox0 = \hbox{}%
+ \def\toctype{omit}%
+ \let\sectionlevel=\empty
+ \else\ifx\temptype\Yappendixkeyword
+ \setbox0 = \hbox{#4\enspace}%
+ \def\toctype{app}%
+ \gdef\thissection{#1}%
+ \else
+ \setbox0 = \hbox{#4\enspace}%
+ \def\toctype{num}%
+ \gdef\thissection{#1}%
+ \fi\fi\fi
+ %
+ % Write the toc entry (before \donoderef). See comments in \chfplain.
+ \writetocentry{\toctype\sectionlevel}{#1}{#4}%
+ %
+ % Write the node reference (= pdf destination for pdftex).
+ % Again, see comments in \chfplain.
+ \donoderef{#3}%
+ %
+ % Output the actual section heading.
+ \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
+ \hangindent=\wd0 % zero if no section number
+ \unhbox0 #1}%
+ }%
+ % Add extra space after the heading -- half of whatever came above it.
+ % Don't allow stretch, though.
+ \kern .5 \csname #2headingskip\endcsname
+ %
+ % Do not let the kern be a potential breakpoint, as it would be if it
+ % was followed by glue.
+ \nobreak
+ %
+ % We'll almost certainly start a paragraph next, so don't let that
+ % 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
+}
+
+
+\message{toc,}
+% Table of contents.
+\newwrite\tocfile
+
+% Write an entry to the toc file, opening it if necessary.
+% Called from @chapter, etc.
+%
+% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
+% We append the current node name (if any) and page number as additional
+% arguments for the \{chap,sec,...}entry macros which will eventually
+% read this. The node name is used in the pdf outlines as the
+% destination to jump to.
+%
+% We open the .toc file for writing here instead of at @setfilename (or
+% any other fixed time) so that @contents can be anywhere in the document.
+% But if #1 is `omit', then we don't do anything. This is used for the
+% table of contents chapter openings themselves.
+%
+\newif\iftocfileopened
+\def\omitkeyword{omit}%
+%
+\def\writetocentry#1#2#3{%
+ \edef\writetoctype{#1}%
+ \ifx\writetoctype\omitkeyword \else
+ \iftocfileopened\else
+ \immediate\openout\tocfile = \jobname.toc
+ \global\tocfileopenedtrue
+ \fi
+ %
+ \iflinks
+ {\atdummies
+ \edef\temp{%
+ \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
+ \temp
+ }
+ \fi
+ \fi
+ %
+ % Tell \shipout to create a pdf destination on each page, if we're
+ % writing pdf. These are used in the table of contents. We can't
+ % just write one on every page because the title pages are numbered
+ % 1 and 2 (the page numbers aren't printed), and so are the first
+ % two pages of the document. Thus, we'd have two destinations named
+ % `1', and two named `2'.
+ \ifpdf \global\pdfmakepagedesttrue \fi
+}
+
+
+% 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
+ \catcode`\<=\active
+ \catcode`\>=\active
+ \catcode`\\=\active
+ \catcode`\^=\active
+ \catcode`\_=\active
+ \catcode`\|=\active
+ \catcode`\~=\active
+}
+
+
+% Read the toc file, which is essentially Texinfo input.
+\def\readtocfile{%
+ \setupdatafile
+ \activecatcodes
+ \input \jobname.toc
+}
+
+\newskip\contentsrightmargin \contentsrightmargin=1in
+\newcount\savepageno
+\newcount\lastnegativepageno \lastnegativepageno = -1
+
+% Prepare to read what we've written to \tocfile.
+%
+\def\startcontents#1{%
+ % If @setchapternewpage on, and @headings double, the contents should
+ % start on an odd page, unlike chapters. Thus, we maintain
+ % \contentsalignmacro in parallel with \pagealignmacro.
+ % From: Torbjorn Granlund <tege at matematik.su.se>
+ \contentsalignmacro
+ \immediate\closeout\tocfile
+ %
+ % 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
+ \begingroup % Set up to handle contents files properly.
+ \raggedbottom % Worry more about breakpoints than the bottom.
+ \advance\hsize by -\contentsrightmargin % Don't use the full line length.
+ %
+ % Roman numerals for page numbers.
+ \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
+}
+
+
+% Normal (long) toc.
+\def\contents{%
+ \startcontents{\putwordTOC}%
+ \openin 1 \jobname.toc
+ \ifeof 1 \else
+ \readtocfile
+ \fi
+ \vfill \eject
+ \contentsalignmacro % in case @setchapternewpage odd is in effect
+ \ifeof 1 \else
+ \pdfmakeoutlines
+ \fi
+ \closein 1
+ \endgroup
+ \lastnegativepageno = \pageno
+ \global\pageno = \savepageno
+}
+
+% And just the chapters.
+\def\summarycontents{%
+ \startcontents{\putwordShortTOC}%
+ %
+ \let\numchapentry = \shortchapentry
+ \let\appentry = \shortchapentry
+ \let\unnchapentry = \shortunnchapentry
+ % We want a true roman here for the page numbers.
+ \secfonts
+ \let\rm=\shortcontrm \let\bf=\shortcontbf
+ \let\sl=\shortcontsl \let\tt=\shortconttt
+ \rm
+ \hyphenpenalty = 10000
+ \advance\baselineskip by 1pt % Open it up a little.
+ \def\numsecentry##1##2##3##4{}
+ \let\appsecentry = \numsecentry
+ \let\unnsecentry = \numsecentry
+ \let\numsubsecentry = \numsecentry
+ \let\appsubsecentry = \numsecentry
+ \let\unnsubsecentry = \numsecentry
+ \let\numsubsubsecentry = \numsecentry
+ \let\appsubsubsecentry = \numsecentry
+ \let\unnsubsubsecentry = \numsecentry
+ \openin 1 \jobname.toc
+ \ifeof 1 \else
+ \readtocfile
+ \fi
+ \closein 1
+ \vfill \eject
+ \contentsalignmacro % in case @setchapternewpage odd is in effect
+ \endgroup
+ \lastnegativepageno = \pageno
+ \global\pageno = \savepageno
+}
+\let\shortcontents = \summarycontents
+
+% Typeset the label for a chapter or appendix for the short contents.
+% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
+%
+\def\shortchaplabel#1{%
+ % This space should be enough, since a single number is .5em, and the
+ % widest letter (M) is 1em, at least in the Computer Modern fonts.
+ % But use \hss just in case.
+ % (This space doesn't include the extra space that gets added after
+ % the label; that gets put in by \shortchapentry above.)
+ %
+ % We'd like to right-justify chapter numbers, but that looks strange
+ % with appendix letters. And right-justifying numbers and
+ % left-justifying letters looks strange when there is less than 10
+ % chapters. Have to read the whole toc once to know how many chapters
+ % there are before deciding ...
+ \hbox to 1em{#1\hss}%
+}
+
+% These macros generate individual entries in the table of contents.
+% The first argument is the chapter or section name.
+% The last argument is the page number.
+% The arguments in between are the chapter number, section number, ...
+
+% Chapters, in the main contents.
+\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
+%
+% Chapters, in the short toc.
+% See comments in \dochapentry re vbox and related settings.
+\def\shortchapentry#1#2#3#4{%
+ \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
+}
+
+% Appendices, in the main contents.
+% Need the word Appendix, and a fixed-size box.
+%
+\def\appendixbox#1{%
+ % We use M since it's probably the widest letter.
+ \setbox0 = \hbox{\putwordAppendix{} M}%
+ \hbox to \wd0{\putwordAppendix{} #1\hss}}
+%
+\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
+
+% Unnumbered chapters.
+\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
+\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
+
+% Sections.
+\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
+\let\appsecentry=\numsecentry
+\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
+
+% Subsections.
+\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
+\let\appsubsecentry=\numsubsecentry
+\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
+
+% And subsubsections.
+\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
+\let\appsubsubsecentry=\numsubsubsecentry
+\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
+
+% This parameter controls the indentation of the various levels.
+% Same as \defaultparindent.
+\newdimen\tocindent \tocindent = 15pt
+
+% Now for the actual typesetting. In all these, #1 is the text and #2 is the
+% page number.
+%
+% If the toc has to be broken over pages, we want it to be at chapters
+% if at all possible; hence the \penalty.
+\def\dochapentry#1#2{%
+ \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
+ \begingroup
+ \chapentryfonts
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+ \endgroup
+ \nobreak\vskip .25\baselineskip plus.1\baselineskip
+}
+
+\def\dosecentry#1#2{\begingroup
+ \secentryfonts \leftskip=\tocindent
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+\endgroup}
+
+\def\dosubsecentry#1#2{\begingroup
+ \subsecentryfonts \leftskip=2\tocindent
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+\endgroup}
+
+\def\dosubsubsecentry#1#2{\begingroup
+ \subsubsecentryfonts \leftskip=3\tocindent
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+\endgroup}
+
+% We use the same \entry macro as for the index entries.
+\let\tocentry = \entry
+
+% Space between chapter (or whatever) number and the title.
+\def\labelspace{\hskip1em \relax}
+
+\def\dopageno#1{{\rm #1}}
+\def\doshortpageno#1{{\rm #1}}
+
+\def\chapentryfonts{\secfonts \rm}
+\def\secentryfonts{\textfonts}
+\def\subsecentryfonts{\textfonts}
+\def\subsubsecentryfonts{\textfonts}
+
+
+\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{%
+ \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
+ \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
+ \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
+ \catcode `\%=14
+ \catcode `\+=\other
+ \catcode `\"=\other
+ \catcode `\|=\other
+ \catcode `\<=\other
+ \catcode `\>=\other
+ \escapechar=`\\
+ %
+ \let\b=\ptexb
+ \let\bullet=\ptexbullet
+ \let\c=\ptexc
+ \let\,=\ptexcomma
+ \let\.=\ptexdot
+ \let\dots=\ptexdots
+ \let\equiv=\ptexequiv
+ \let\!=\ptexexclam
+ \let\i=\ptexi
+ \let\indent=\ptexindent
+ \let\noindent=\ptexnoindent
+ \let\{=\ptexlbrace
+ \let\+=\tabalign
+ \let\}=\ptexrbrace
+ \let\/=\ptexslash
+ \let\*=\ptexstar
+ \let\t=\ptext
+ \let\frenchspacing=\plainfrenchspacing
+ %
+ \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
+ \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
+ \def\@{@}%
+}
+% There is no need to define \Etex.
+
+% Define @lisp ... @end lisp.
+% @lisp environment forms a group so it can rebind things,
+% including the definition of @end lisp (which normally is erroneous).
+
+% Amount to narrow the margins by for @lisp.
+\newskip\lispnarrowing \lispnarrowing=0.4in
+
+% This is the definition that ^^M gets inside @lisp, @example, and other
+% such environments. \null is better than a space, since it doesn't
+% have any width.
+\def\lisppar{\null\endgraf}
+
+% This space is always present above and below environments.
+\newskip\envskipamount \envskipamount = 0pt
+
+% Make spacing and below environment symmetrical. We use \parskip here
+% to help in doing that, since in @example-like environments \parskip
+% is reset to zero; thus the \afterenvbreak inserts no space -- but the
+% start of the next paragraph will insert \parskip.
+%
+\def\aboveenvbreak{{%
+ % =10000 instead of <10000 because of a special case in \itemzzz and
+ % \sectionheading, q.v.
+ \ifnum \lastpenalty=10000 \else
+ \advance\envskipamount by \parskip
+ \endgraf
+ \ifdim\lastskip<\envskipamount
+ \removelastskip
+ % it's not a good place to break if the last penalty was \nobreak
+ % or better ...
+ \ifnum\lastpenalty<10000 \penalty-50 \fi
+ \vskip\envskipamount
+ \fi
+ \fi
+}}
+
+\let\afterenvbreak = \aboveenvbreak
+
+% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
+% also clear it, so that its embedded environments do the narrowing again.
+\let\nonarrowing=\relax
+
+% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
+% environment contents.
+\font\circle=lcircle10
+\newdimen\circthick
+\newdimen\cartouter\newdimen\cartinner
+\newskip\normbskip\newskip\normpskip\newskip\normlskip
+\circthick=\fontdimen8\circle
+%
+\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
+\def\ctr{{\hskip 6pt\circle\char'010}}
+\def\cbl{{\circle\char'012\hskip -6pt}}
+\def\cbr{{\hskip 6pt\circle\char'011}}
+\def\carttop{\hbox to \cartouter{\hskip\lskip
+ \ctl\leaders\hrule height\circthick\hfil\ctr
+ \hskip\rskip}}
+\def\cartbot{\hbox to \cartouter{\hskip\lskip
+ \cbl\leaders\hrule height\circthick\hfil\cbr
+ \hskip\rskip}}
+%
+\newskip\lskip\newskip\rskip
+
+\envdef\cartouche{%
+ \ifhmode\par\fi % can't be in the midst of a paragraph.
+ \startsavinginserts
+ \lskip=\leftskip \rskip=\rightskip
+ \leftskip=0pt\rightskip=0pt % we want these *outside*.
+ \cartinner=\hsize \advance\cartinner by-\lskip
+ \advance\cartinner by-\rskip
+ \cartouter=\hsize
+ \advance\cartouter by 18.4pt % allow for 3pt kerns on either
+ % side, and for 6pt waste from
+ % each corner char, and rule thickness
+ \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
+ % Flag to tell @lisp, etc., not to narrow margin.
+ \let\nonarrowing = t%
+ \vbox\bgroup
+ \baselineskip=0pt\parskip=0pt\lineskip=0pt
+ \carttop
+ \hbox\bgroup
+ \hskip\lskip
+ \vrule\kern3pt
+ \vbox\bgroup
+ \kern3pt
+ \hsize=\cartinner
+ \baselineskip=\normbskip
+ \lineskip=\normlskip
+ \parskip=\normpskip
+ \vskip -\parskip
+ \comment % For explanation, see the end of \def\group.
+}
+\def\Ecartouche{%
+ \ifhmode\par\fi
+ \kern3pt
+ \egroup
+ \kern3pt\vrule
+ \hskip\rskip
+ \egroup
+ \cartbot
+ \egroup
+ \checkinserts
+}
+
+
+% This macro is called at the beginning of all the @example variants,
+% inside a group.
+\def\nonfillstart{%
+ \aboveenvbreak
+ \hfuzz = 12pt % Don't be fussy
+ \sepspaces % Make spaces be word-separators rather than space tokens.
+ \let\par = \lisppar % don't ignore blank lines
+ \obeylines % each line of input is a line of output
+ \parskip = 0pt
+ \parindent = 0pt
+ \emergencystretch = 0pt % don't try to avoid overfull boxes
+ \ifx\nonarrowing\relax
+ \advance \leftskip by \lispnarrowing
+ \exdentamount=\lispnarrowing
+ \else
+ \let\nonarrowing = \relax
+ \fi
+ \let\exdent=\nofillexdent
+}
+
+% 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:
+% @example, @display, @format, @lisp
+%
+\def\smallword{small}
+\def\nosmallword{nosmall}
+\let\SETdispenvsize\relax
+\def\setnormaldispenv{%
+ \ifx\SETdispenvsize\smallword
+ \smallexamplefonts \rm
+ \fi
+}
+\def\setsmalldispenv{%
+ \ifx\SETdispenvsize\nosmallword
+ \else
+ \smallexamplefonts \rm
+ \fi
+}
+
+% We often define two environments, @foo and @smallfoo.
+% Let's do it by one command:
+\def\makedispenv #1#2{
+ \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}
+ \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}
+ \expandafter\let\csname E#1\endcsname \afterenvbreak
+ \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
+}
+
+% Define two synonyms:
+\def\maketwodispenvs #1#2#3{
+ \makedispenv{#1}{#3}
+ \makedispenv{#2}{#3}
+}
+
+% @lisp: indented, narrowed, typewriter font; @example: same as @lisp.
+%
+% @smallexample and @smalllisp: use smaller fonts.
+% Originally contributed by Pavel at xerox.
+%
+\maketwodispenvs {lisp}{example}{%
+ \nonfillstart
+ \tt
+ \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
+ \gobble % eat return
+}
+
+% @display/@smalldisplay: same as @lisp except keep current font.
+%
+\makedispenv {display}{%
+ \nonfillstart
+ \gobble
+}
+
+% @format/@smallformat: same as @display except don't narrow margins.
+%
+\makedispenv{format}{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ \gobble
+}
+
+% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
+\envdef\flushleft{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ \gobble
+}
+\let\Eflushleft = \afterenvbreak
+
+% @flushright.
+%
+\envdef\flushright{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ \advance\leftskip by 0pt plus 1fill
+ \gobble
+}
+\let\Eflushright = \afterenvbreak
+
+
+% @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{%
+ {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
+ \parindent=0pt
+ %
+ % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
+ \ifx\nonarrowing\relax
+ \advance\leftskip by \lispnarrowing
+ \advance\rightskip by \lispnarrowing
+ \exdentamount = \lispnarrowing
+ \else
+ \let\nonarrowing = \relax
+ \fi
+ \parsearg\quotationlabel
+}
+
+% We have retained a nonzero parskip for the environment, since we're
+% doing normal filling.
+%
+\def\Equotation{%
+ \par
+ \ifx\quotationauthor\undefined\else
+ % indent a bit.
+ \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
+ \fi
+ {\parskip=0pt \afterenvbreak}%
+}
+
+% If we're given an argument, typeset it in bold with a colon after.
+\def\quotationlabel#1{%
+ \def\temp{#1}%
+ \ifx\temp\empty \else
+ {\bf #1: }%
+ \fi
+}
+
+
+% LaTeX-like @verbatim... at end verbatim and @verb{<char>...<char>}
+% If we want to allow any <char> as delimiter,
+% we need the curly braces so that makeinfo sees the @verb command, eg:
+% `@verbx...x' would look like the '@verbx' command. --janneke at gnu.org
+%
+% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
+%
+% [Knuth] p.344; only we need to do the other characters Texinfo sets
+% active too. Otherwise, they get lost as the first character on a
+% verbatim line.
+\def\dospecials{%
+ \do\ \do\\\do\{\do\}\do\$\do\&%
+ \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
+ \do\<\do\>\do\|\do\@\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
+\begingroup
+ \catcode`\^^I=\active
+ \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
+\endgroup
+%
+\def\setupverb{%
+ \tt % easiest (and conventionally used) font for verbatim
+ \def\par{\leavevmode\endgraf}%
+ \catcode`\`=\active
+ \tabeightspaces
+ % Respect line breaks,
+ % print special symbols as themselves, and
+ % make each space count
+ % must do in this order:
+ \obeylines \uncatcodespecials \sepspaces
+}
+
+% Setup for the @verbatim environment
+%
+% Real tab expansion
+\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
+%
+\def\starttabbox{\setbox0=\hbox\bgroup}
+\begingroup
+ \catcode`\^^I=\active
+ \gdef\tabexpand{%
+ \catcode`\^^I=\active
+ \def^^I{\leavevmode\egroup
+ \dimen0=\wd0 % the width so far, or since the previous tab
+ \divide\dimen0 by\tabw
+ \multiply\dimen0 by\tabw % compute previous multiple of \tabw
+ \advance\dimen0 by\tabw % advance to next multiple of \tabw
+ \wd0=\dimen0 \box0 \starttabbox
+ }%
+ }
+\endgroup
+\def\setupverbatim{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ % Easiest (and conventionally used) font for verbatim
+ \tt
+ \def\par{\leavevmode\egroup\box0\endgraf}%
+ \catcode`\`=\active
+ \tabexpand
+ % Respect line breaks,
+ % print special symbols as themselves, and
+ % make each space count
+ % must do in this order:
+ \obeylines \uncatcodespecials \sepspaces
+ \everypar{\starttabbox}%
+}
+
+% Do the @verb magic: verbatim text is quoted by unique
+% delimiter characters. Before first delimiter expect a
+% right brace, after last delimiter expect closing brace:
+%
+% \def\doverb'{'<char>#1<char>'}'{#1}
+%
+% [Knuth] p. 382; only eat outer {}
+\begingroup
+ \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
+ \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
+\endgroup
+%
+\def\verb{\begingroup\setupverb\doverb}
+%
+%
+% Do the @verbatim magic: define the macro \doverbatim so that
+% the (first) argument ends when '@end verbatim' is reached, ie:
+%
+% \def\doverbatim#1 at end verbatim{#1}
+%
+% For Texinfo it's a lot easier than for LaTeX,
+% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
+% we need not redefine '\', '{' and '}'.
+%
+% Inspired by LaTeX's verbatim command set [latex.ltx]
+%
+\begingroup
+ \catcode`\ =\active
+ \obeylines %
+ % ignore everything up to the first ^^M, that's the newline at the end
+ % of the @verbatim input line itself. Otherwise we get an extra blank
+ % line in the output.
+ \xdef\doverbatim#1^^M#2 at end verbatim{#2\noexpand\end\gobble verbatim}%
+ % We really want {...\end verbatim} in the body of the macro, but
+ % without the active space; thus we have to use \xdef and \gobble.
+\endgroup
+%
+\envdef\verbatim{%
+ \setupverbatim\doverbatim
+}
+\let\Everbatim = \afterenvbreak
+
+
+% @verbatiminclude FILE - insert text of file in verbatim environment.
+%
+\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
+%
+\def\doverbatiminclude#1{%
+ {%
+ \makevalueexpandable
+ \setupverbatim
+ \input #1
+ \afterenvbreak
+ }%
+}
+
+% @copying ... @end copying.
+% Save the text away for @insertcopying later.
+%
+% We save the uninterpreted tokens, rather than creating a box.
+% Saving the text in a box would be much easier, but then all the
+% typesetting commands (@smallbook, font changes, etc.) have to be done
+% beforehand -- and a) we want @copying to be done first in the source
+% file; b) letting users define the frontmatter in as flexible order as
+% possible is very desirable.
+%
+\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
+\def\docopying#1 at end copying{\endgroup\def\copyingtext{#1}}
+%
+\def\insertcopying{%
+ \begingroup
+ \parindent = 0pt % paragraph indentation looks wrong on title page
+ \scanexp\copyingtext
+ \endgroup
+}
+
+\message{defuns,}
+% @defun etc.
+
+\newskip\defbodyindent \defbodyindent=.4in
+\newskip\defargsindent \defargsindent=50pt
+\newskip\deflastargmargin \deflastargmargin=18pt
+
+% Start the processing of @deffn:
+\def\startdefun{%
+ \ifnum\lastpenalty<10000
+ \medbreak
+ \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
+ % 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
+ %
+ % Similarly, after a section heading, do not allow a break.
+ % But do insert the glue.
+ \medskip % preceded by discardable penalty, so not a breakpoint
+ \fi
+ %
+ \parindent=0in
+ \advance\leftskip by \defbodyindent
+ \exdentamount=\defbodyindent
+}
+
+\def\dodefunx#1{%
+ % First, check whether we are in the right environment:
+ \checkenv#1%
+ %
+ % 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
+ %
+ % And now, it's time to reuse the body of the original defun:
+ \expandafter\gobbledefun#1%
+}
+\def\gobbledefun#1\startdefun{}
+
+% \printdefunline \deffnheader{text}
+%
+\def\printdefunline#1#2{%
+ \begingroup
+ % call \deffnheader:
+ #1#2 \endheader
+ % common ending:
+ \interlinepenalty = 10000
+ \advance\rightskip by 0pt plus 1fil
+ \endgraf
+ \nobreak\vskip -\parskip
+ \penalty 10002 % 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
+ \endgroup
+}
+
+\def\Edefun{\endgraf\medbreak}
+
+% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
+% the only thing remainnig is to define \deffnheader.
+%
+\def\makedefun#1{%
+ \expandafter\let\csname E#1\endcsname = \Edefun
+ \edef\temp{\noexpand\domakedefun
+ \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
+ \temp
+}
+
+% \domakedefun \deffn \deffnx \deffnheader
+%
+% Define \deffn and \deffnx, without parameters.
+% \deffnheader has to be defined explicitly.
+%
+\def\domakedefun#1#2#3{%
+ \envdef#1{%
+ \startdefun
+ \parseargusing\activeparens{\printdefunline#3}%
+ }%
+ \def#2{\dodefunx#1}%
+ \def#3%
+}
+
+%%% Untyped functions:
+
+% @deffn category name args
+\makedefun{deffn}{\deffngeneral{}}
+
+% @deffn category class name args
+\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
+
+% \defopon {category on}class name args
+\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
+
+% \deffngeneral {subind}category name args
+%
+\def\deffngeneral#1#2 #3 #4\endheader{%
+ % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
+ \dosubind{fn}{\code{#3}}{#1}%
+ \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
+}
+
+%%% Typed functions:
+
+% @deftypefn category type name args
+\makedefun{deftypefn}{\deftypefngeneral{}}
+
+% @deftypeop category class type name args
+\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
+
+% \deftypeopon {category on}class type name args
+\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
+
+% \deftypefngeneral {subind}category type name args
+%
+\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
+ \dosubind{fn}{\code{#4}}{#1}%
+ \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
+}
+
+%%% Typed variables:
+
+% @deftypevr category type var args
+\makedefun{deftypevr}{\deftypecvgeneral{}}
+
+% @deftypecv category class type var args
+\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
+
+% \deftypecvof {category of}class type var args
+\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
+
+% \deftypecvgeneral {subind}category type var args
+%
+\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
+ \dosubind{vr}{\code{#4}}{#1}%
+ \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
+}
+
+%%% Untyped variables:
+
+% @defvr category var args
+\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
+
+% @defcv category class var args
+\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
+
+% \defcvof {category of}class var args
+\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
+
+%%% Type:
+% @deftp category name args
+\makedefun{deftp}#1 #2 #3\endheader{%
+ \doind{tp}{\code{#2}}%
+ \defname{#1}{}{#2}\defunargs{#3\unskip}%
+}
+
+% Remaining @defun-like shortcuts:
+\makedefun{defun}{\deffnheader{\putwordDeffunc} }
+\makedefun{defmac}{\deffnheader{\putwordDefmac} }
+\makedefun{defspec}{\deffnheader{\putwordDefspec} }
+\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
+\makedefun{defvar}{\defvrheader{\putwordDefvar} }
+\makedefun{defopt}{\defvrheader{\putwordDefopt} }
+\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
+\makedefun{defmethod}{\defopon\putwordMethodon}
+\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
+\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
+\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
+
+% \defname, which formats the name of the @def (not the args).
+% #1 is the category, such as "Function".
+% #2 is the return type, if any.
+% #3 is the function name.
+%
+% We are followed by (but not passed) the arguments, if any.
+%
+\def\defname#1#2#3{%
+ % Get the values of \leftskip and \rightskip as they were outside the @def...
+ \advance\leftskip by -\defbodyindent
+ %
+ % How we'll format the type name. Putting it in brackets helps
+ % distinguish it from the body text that may end up on the next line
+ % just below it.
+ \def\temp{#1}%
+ \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
+ %
+ % Figure out line sizes for the paragraph shape.
+ % The first line needs space for \box0; but if \rightskip is nonzero,
+ % we need only space for the part of \box0 which exceeds it:
+ \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
+ % The continuations:
+ \dimen2=\hsize \advance\dimen2 by -\defargsindent
+ % (plain.tex says that \dimen1 should be used only as global.)
+ \parshape 2 0in \dimen0 \defargsindent \dimen2
+ %
+ % Put the type name to the right margin.
+ \noindent
+ \hbox to 0pt{%
+ \hfil\box0 \kern-\hsize
+ % \hsize has to be shortened this way:
+ \kern\leftskip
+ % Intentionally do not respect \rightskip, since we need the space.
+ }%
+ %
+ % Allow all lines to be underfull without complaint:
+ \tolerance=10000 \hbadness=10000
+ \exdentamount=\defbodyindent
+ {%
+ % defun fonts. We use typewriter by default (used to be bold) because:
+ % . we're printing identifiers, they should be in tt in principle.
+ % . in languages with many accents, such as Czech or French, it's
+ % common to leave accents off identifiers. The result looks ok in
+ % tt, but exceedingly strange in rm.
+ % . we don't want -- and --- to be treated as ligatures.
+ % . this still does not fix the ?` and !` ligatures, but so far no
+ % one has made identifiers using them :).
+ \df \tt
+ \def\temp{#2}% return value type
+ \ifx\temp\empty\else \tclose{\temp} \fi
+ #3% output function name
+ }%
+ {\rm\enskip}% hskip 0.5 em of \tenrm
+ %
+ \boldbrax
+ % arguments will be output next, if any.
+}
+
+% Print arguments in slanted roman (not ttsl), inconsistently with using
+% tt for the name. This is because literal text is sometimes needed in
+% the argument list (groff manual), and ttsl and tt are not very
+% distinguishable. Prevent hyphenation at `-' chars.
+%
+\def\defunargs#1{%
+ % use sl by default (not ttsl),
+ % tt for the names.
+ \df \sl \hyphenchar\font=0
+ %
+ % 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
+ #1%
+ \sl\hyphenchar\font=45
+}
+
+% We want ()&[] to print specially on the defun line.
+%
+\def\activeparens{%
+ \catcode`\(=\active \catcode`\)=\active
+ \catcode`\[=\active \catcode`\]=\active
+ \catcode`\&=\active
+}
+
+% Make control sequences which act like normal parenthesis chars.
+\let\lparen = ( \let\rparen = )
+
+% Be sure that we always have a definition for `(', etc. For example,
+% if the fn name has parens in it, \boldbrax will not be in effect yet,
+% so TeX would otherwise complain about undefined control sequence.
+{
+ \activeparens
+ \global\let(=\lparen \global\let)=\rparen
+ \global\let[=\lbrack \global\let]=\rbrack
+ \global\let& = \&
+
+ \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
+ \gdef\magicamp{\let&=\amprm}
+}
+
+\newcount\parencount
+
+% If we encounter &foo, then turn on ()-hacking afterwards
+\newif\ifampseen
+\def\amprm#1 {\ampseentrue{\bf\ }}
+
+\def\parenfont{%
+ \ifampseen
+ % At the first level, print parens in roman,
+ % otherwise use the default font.
+ \ifnum \parencount=1 \rm \fi
+ \else
+ % The \sf parens (in \boldbrax) actually are a little bolder than
+ % the contained text. This is especially needed for [ and ] .
+ \sf
+ \fi
+}
+\def\infirstlevel#1{%
+ \ifampseen
+ \ifnum\parencount=1
+ #1%
+ \fi
+ \fi
+}
+\def\bfafterword#1 {#1 \bf}
+
+\def\opnr{%
+ \global\advance\parencount by 1
+ {\parenfont(}%
+ \infirstlevel \bfafterword
+}
+\def\clnr{%
+ {\parenfont)}%
+ \infirstlevel \sl
+ \global\advance\parencount by -1
+}
+
+\newcount\brackcount
+\def\lbrb{%
+ \global\advance\brackcount by 1
+ {\bf[}%
+}
+\def\rbrb{%
+ {\bf]}%
+ \global\advance\brackcount by -1
+}
+
+\def\checkparencounts{%
+ \ifnum\parencount=0 \else \badparencount \fi
+ \ifnum\brackcount=0 \else \badbrackcount \fi
+}
+\def\badparencount{%
+ \errmessage{Unbalanced parentheses in @def}%
+ \global\parencount=0
+}
+\def\badbrackcount{%
+ \errmessage{Unbalanced square braces in @def}%
+ \global\brackcount=0
+}
+
+
+\message{macros,}
+% @macro.
+
+% To do this right we need a feature of e-TeX, \scantokens,
+% which we arrange to emulate with a temporary file in ordinary TeX.
+\ifx\eTeXversion\undefined
+ \newwrite\macscribble
+ \def\scantokens#1{%
+ \toks0={#1}%
+ \immediate\openout\macscribble=\jobname.tmp
+ \immediate\write\macscribble{\the\toks0}%
+ \immediate\closeout\macscribble
+ \input \jobname.tmp
+ }
+\fi
+
+\def\scanmacro#1{%
+ \begingroup
+ \newlinechar`\^^M
+ \let\xeatspaces\eatspaces
+ % Undo catcode changes of \startcontents and \doprintindex
+ % When called from @insertcopying or (short)caption, we need active
+ % backslash to get it printed correctly. Previously, we had
+ % \catcode`\\=\other instead. We'll see whether a problem appears
+ % with macro expansion. --kasal, 19aug04
+ \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
+ % ... and \example
+ \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}%
+ \endgroup
+}
+
+\def\scanexp#1{%
+ \edef\temp{\noexpand\scanmacro{#1}}%
+ \temp
+}
+
+\newcount\paramno % Count of parameters
+\newtoks\macname % Macro name
+\newif\ifrecursive % Is it recursive?
+
+% List of all defined macros in the form
+% \definedummyword\macro1\definedummyword\macro2...
+% Currently is also contains all @aliases; the list can be split
+% if there is a need.
+\def\macrolist{}
+
+% Add the macro to \macrolist
+\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
+\def\addtomacrolistxxx#1{%
+ \toks0 = \expandafter{\macrolist\definedummyword#1}%
+ \xdef\macrolist{\the\toks0}%
+}
+
+% Utility routines.
+% 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
+ \csname#2\endcsname
+}
+
+% Trim leading and trailing spaces off a string.
+% Concepts from aro-bend problem 15 (see CTAN).
+{\catcode`\@=11
+\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
+\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
+\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
+\def\unbrace#1{#1}
+\unbrace{\gdef\trim@@@ #1 } #2@{#1}
+}
+
+% Trim a single trailing ^^M off a string.
+{\catcode`\^^M=\other \catcode`\Q=3%
+\gdef\eatcr #1{\eatcra #1Q^^MQ}%
+\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
+\gdef\eatcrb#1Q#2Q{#1}%
+}
+
+% Macro bodies are absorbed as an argument in a context where
+% all characters are catcode 10, 11 or 12, except \ which is active
+% (as in normal texinfo). It is necessary to change the definition of \.
+
+% 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.
+
+\def\scanctxt{%
+ \catcode`\"=\other
+ \catcode`\+=\other
+ \catcode`\<=\other
+ \catcode`\>=\other
+ \catcode`\@=\other
+ \catcode`\^=\other
+ \catcode`\_=\other
+ \catcode`\|=\other
+ \catcode`\~=\other
+}
+
+\def\scanargctxt{%
+ \scanctxt
+ \catcode`\\=\other
+ \catcode`\^^M=\other
+}
+
+\def\macrobodyctxt{%
+ \scanctxt
+ \catcode`\{=\other
+ \catcode`\}=\other
+ \catcode`\^^M=\other
+ \usembodybackslash
+}
+
+\def\macroargctxt{%
+ \scanctxt
+ \catcode`\\=\other
+}
+
+% \mbodybackslash is the definition of \ in @macro bodies.
+% It maps \foo\ => \csname macarg.foo\endcsname => #N
+% where N is the macro parameter number.
+% We define \csname macarg.\endcsname to be \realbackslash, so
+% \\ in macro replacement text gets you a backslash.
+
+{\catcode`@=0 @catcode`@\=@active
+ @gdef at usembodybackslash{@let\=@mbodybackslash}
+ @gdef at mbodybackslash#1\{@csname macarg.#1 at endcsname}
+}
+\expandafter\def\csname macarg.\endcsname{\realbackslash}
+
+\def\macro{\recursivefalse\parsearg\macroxxx}
+\def\rmacro{\recursivetrue\parsearg\macroxxx}
+
+\def\macroxxx#1{%
+ \getargs{#1}% now \macname is the macname and \argl the arglist
+ \ifx\argl\empty % no arguments
+ \paramno=0%
+ \else
+ \expandafter\parsemargdef \argl;%
+ \fi
+ \if1\csname ismacro.\the\macname\endcsname
+ \message{Warning: redefining \the\macname}%
+ \else
+ \expandafter\ifx\csname \the\macname\endcsname \relax
+ \else \errmessage{Macro name \the\macname\space already defined}\fi
+ \global\cslet{macsave.\the\macname}{\the\macname}%
+ \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
+ \addtomacrolist{\the\macname}%
+ \fi
+ \begingroup \macrobodyctxt
+ \ifrecursive \expandafter\parsermacbody
+ \else \expandafter\parsemacbody
+ \fi}
+
+\parseargdef\unmacro{%
+ \if1\csname ismacro.#1\endcsname
+ \global\cslet{#1}{macsave.#1}%
+ \global\expandafter\let \csname ismacro.#1\endcsname=0%
+ % Remove the macro name from \macrolist:
+ \begingroup
+ \expandafter\let\csname#1\endcsname \relax
+ \let\definedummyword\unmacrodo
+ \xdef\macrolist{\macrolist}%
+ \endgroup
+ \else
+ \errmessage{Macro #1 not defined}%
+ \fi
+}
+
+% Called by \do from \dounmacro on each macro. The idea is to omit any
+% macro definitions that have been changed to \relax.
+%
+\def\unmacrodo#1{%
+ \ifx #1\relax
+ % remove this
+ \else
+ \noexpand\definedummyword \noexpand#1%
+ \fi
+}
+
+% This makes use of the obscure feature that if the last token of a
+% <parameter list> is #, then the preceding argument is delimited by
+% an opening brace, and that opening brace is not consumed.
+\def\getargs#1{\getargsxxx#1{}}
+\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
+\def\getmacname #1 #2\relax{\macname={#1}}
+\def\getmacargs#1{\def\argl{#1}}
+
+% Parse the optional {params} list. Set up \paramno and \paramlist
+% so \defmacro knows what to do. Define \macarg.blah for each blah
+% in the params list, to be ##N where N is the position in that list.
+% That gets used by \mbodybackslash (above).
+
+% We need to get `macro parameter char #' into several definitions.
+% The technique used is stolen from LaTeX: let \hash be something
+% unexpandable, insert that wherever you need a #, and then redefine
+% it to # just before using the token list produced.
+%
+% The same technique is used to protect \eatspaces till just before
+% the macro is used.
+
+\def\parsemargdef#1;{\paramno=0\def\paramlist{}%
+ \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
+\def\parsemargdefxxx#1,{%
+ \if#1;\let\next=\relax
+ \else \let\next=\parsemargdefxxx
+ \advance\paramno by 1%
+ \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
+ {\xeatspaces{\hash\the\paramno}}%
+ \edef\paramlist{\paramlist\hash\the\paramno,}%
+ \fi\next}
+
+% These two commands read recursive and nonrecursive macro bodies.
+% (They're different since rec and nonrec macros end differently.)
+
+\long\def\parsemacbody#1 at end macro%
+{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
+\long\def\parsermacbody#1 at end rmacro%
+{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
+
+% This defines the macro itself. There are six cases: recursive and
+% nonrecursive macros of zero, one, and many arguments.
+% Much magic with \expandafter here.
+% \xdef is used so that macro definitions will survive the file
+% they're defined in; @include reads the file inside a group.
+\def\defmacro{%
+ \let\hash=##% convert placeholders to macro parameter chars
+ \ifrecursive
+ \ifcase\paramno
+ % 0
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\scanmacro{\temp}}%
+ \or % 1
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\braceorline
+ \expandafter\noexpand\csname\the\macname xxx\endcsname}%
+ \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
+ \egroup\noexpand\scanmacro{\temp}}%
+ \else % many
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\csname\the\macname xx\endcsname}%
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{\egroup\noexpand\scanmacro{\temp}}%
+ \fi
+ \else
+ \ifcase\paramno
+ % 0
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \or % 1
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\braceorline
+ \expandafter\noexpand\csname\the\macname xxx\endcsname}%
+ \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
+ \egroup
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \else % many
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \expandafter\noexpand\csname\the\macname xx\endcsname}%
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{%
+ \egroup
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \fi
+ \fi}
+
+\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
+
+% \braceorline decides whether the next nonwhitespace character is a
+% {. 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\braceorlinexxx{%
+ \ifx\nchar\bgroup\else
+ \expandafter\parsearg
+ \fi \next}
+
+
+% @alias.
+% We need some trickery to remove the optional spaces around the equal
+% sign. Just make them active and then expand them all to nothing.
+\def\alias{\parseargusing\obeyspaces\aliasxxx}
+\def\aliasxxx #1{\aliasyyy#1\relax}
+\def\aliasyyy #1=#2\relax{%
+ {%
+ \expandafter\let\obeyedspace=\empty
+ \addtomacrolist{#1}%
+ \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
+ }%
+ \next
+}
+
+
+\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.
+
+% @inforef is relatively simple.
+\def\inforef #1{\inforefzzz #1,,,,**}
+\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
+ node \samp{\ignorespaces#1{}}}
+
+% @node's only job in TeX is to define \lastnode, which is used in
+% cross-references. The @node line might or might not have commas, and
+% might or might not have spaces before the first comma, like:
+% @node foo , bar , ...
+% We don't want such trailing spaces in the node name.
+%
+\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
+%
+% also remove a trailing comma, in case of something like this:
+% @node Help-Cross, , , Cross-refs
+\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
+\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
+
+\let\nwnode=\node
+\let\lastnode=\empty
+
+% Write a cross-reference definition for the current node. #1 is the
+% type (Ynumbered, Yappendix, Ynothing).
+%
+\def\donoderef#1{%
+ \ifx\lastnode\empty\else
+ \setref{\lastnode}{#1}%
+ \global\let\lastnode=\empty
+ \fi
+}
+
+% @anchor{NAME} -- define xref target at arbitrary point.
+%
+\newcount\savesfregister
+%
+\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
+\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
+\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
+
+% \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,
+% or the anchor name.
+% 2) NAME-snt - section number and type, passed as the SNT arg, or
+% empty for anchors.
+% 3) NAME-pg - the page number.
+%
+% This is called from \donoderef, \anchor, and \dofloat. In the case of
+% floats, there is an additional part, which is not written here:
+% 4) NAME-lof - the text as it should appear in a @listoffloats.
+%
+\def\setref#1#2{%
+ \pdfmkdest{#1}%
+ \iflinks
+ {%
+ \atdummies % preserve commands, but don't expand them
+ \edef\writexrdef##1##2{%
+ \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
+ ##1}{##2}}% these are parameters of \writexrdef
+ }%
+ \toks0 = \expandafter{\thissection}%
+ \immediate \writexrdef{title}{\the\toks0 }%
+ \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
+ \writexrdef{pg}{\folio}% will be written later, during \shipout
+ }%
+ \fi
+}
+
+% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
+% the node name, #2 the name of the Info cross-reference, #3 the printed
+% node name, #4 the name of the Info file, #5 the name of the printed
+% manual. All but the node name can be omitted.
+%
+\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
+\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
+\def\ref#1{\xrefX[#1,,,,,,,]}
+\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
+ \unsepspaces
+ \def\printedmanual{\ignorespaces #5}%
+ \def\printedrefname{\ignorespaces #3}%
+ \setbox1=\hbox{\printedmanual\unskip}%
+ \setbox0=\hbox{\printedrefname\unskip}%
+ \ifdim \wd0 = 0pt
+ % No printed node name was explicitly given.
+ \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
+ % Use the node name inside the square brackets.
+ \def\printedrefname{\ignorespaces #1}%
+ \else
+ % Use the actual chapter/section title appear inside
+ % the square brackets. Use the real section title if we have it.
+ \ifdim \wd1 > 0pt
+ % It is in another manual, so we don't have it.
+ \def\printedrefname{\ignorespaces #1}%
+ \else
+ \ifhavexrefs
+ % We know the real title if we have the xref values.
+ \def\printedrefname{\refx{#1-title}{}}%
+ \else
+ % Otherwise just copy the Info node name.
+ \def\printedrefname{\ignorespaces #1}%
+ \fi%
+ \fi
+ \fi
+ \fi
+ %
+ % Make link in pdf output.
+ \ifpdf
+ \leavevmode
+ \getfilename{#4}%
+ {\turnoffactive
+ % See comments at \activebackslashdouble.
+ {\activebackslashdouble \xdef\pdfxrefdest{#1}%
+ \backslashparens\pdfxrefdest}%
+ %
+ \ifnum\filenamelength>0
+ \startlink attr{/Border [0 0 0]}%
+ goto file{\the\filename.pdf} name{\pdfxrefdest}%
+ \else
+ \startlink attr{/Border [0 0 0]}%
+ goto name{\pdfmkpgn{\pdfxrefdest}}%
+ \fi
+ }%
+ \linkcolor
+ \fi
+ %
+ % Float references are printed completely differently: "Figure 1.2"
+ % instead of "[somenode], p.3". We distinguish them by the
+ % LABEL-title being set to a magic string.
+ {%
+ % Have to otherify everything special to allow the \csname to
+ % include an _ in the xref name, etc.
+ \indexnofonts
+ \turnoffactive
+ \expandafter\global\expandafter\let\expandafter\Xthisreftitle
+ \csname XR#1-title\endcsname
+ }%
+ \iffloat\Xthisreftitle
+ % 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}%
+ \else
+ \printedrefname
+ \fi
+ %
+ % if the user also gave the printed manual name (fifth arg), append
+ % "in MANUALNAME".
+ \ifdim \wd1 > 0pt
+ \space \putwordin{} \cite{\printedmanual}%
+ \fi
+ \else
+ % node/anchor (non-float) references.
+ %
+ % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
+ % insert empty discretionaries after hyphens, which means that it will
+ % not find a line break at a hyphen in a node names. Since some manuals
+ % are best written with fairly long node names, containing hyphens, this
+ % 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}%
+ \else
+ % _ (for example) has to be the character _ for the purposes of the
+ % control sequence corresponding to the node, but it has to expand
+ % into the usual \leavevmode...\vrule stuff for purposes of
+ % printing. So we \turnoffactive for the \refx-snt, back on for the
+ % printing, back off for the \refx-pg.
+ {\turnoffactive
+ % Only output a following space if the -snt ref is nonempty; for
+ % @unnumbered and @anchor, it won't be.
+ \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
+ \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
+ }%
+ % output the `[mynode]' via a macro so it can be overridden.
+ \xrefprintnodename\printedrefname
+ %
+ % But we always want a comma and a space:
+ ,\space
+ %
+ % output the `page 3'.
+ \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
+ \fi
+ \fi
+ \endlink
+\endgroup}
+
+% This macro is called from \xrefX for the `[nodename]' part of xref
+% output. It's a separate macro only so it can be changed more easily,
+% since square brackets don't work well in some documents. Particularly
+% one that Bob is working on :).
+%
+\def\xrefprintnodename#1{[#1]}
+
+% Things referred to by \setref.
+%
+\def\Ynothing{}
+\def\Yomitfromtoc{}
+\def\Ynumbered{%
+ \ifnum\secno=0
+ \putwordChapter at tie \the\chapno
+ \else \ifnum\subsecno=0
+ \putwordSection at tie \the\chapno.\the\secno
+ \else \ifnum\subsubsecno=0
+ \putwordSection at tie \the\chapno.\the\secno.\the\subsecno
+ \else
+ \putwordSection at tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
+ \fi\fi\fi
+}
+\def\Yappendix{%
+ \ifnum\secno=0
+ \putwordAppendix at tie @char\the\appendixno{}%
+ \else \ifnum\subsecno=0
+ \putwordSection at tie @char\the\appendixno.\the\secno
+ \else \ifnum\subsubsecno=0
+ \putwordSection at tie @char\the\appendixno.\the\secno.\the\subsecno
+ \else
+ \putwordSection at tie
+ @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
+ \fi\fi\fi
+}
+
+% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
+% If its value is nonempty, SUFFIX is output afterward.
+%
+\def\refx#1#2{%
+ {%
+ \indexnofonts
+ \otherbackslash
+ \expandafter\global\expandafter\let\expandafter\thisrefX
+ \csname XR#1\endcsname
+ }%
+ \ifx\thisrefX\relax
+ % If not defined, say something at least.
+ \angleleft un\-de\-fined\angleright
+ \iflinks
+ \ifhavexrefs
+ \message{\linenumber Undefined cross reference `#1'.}%
+ \else
+ \ifwarnedxrefs\else
+ \global\warnedxrefstrue
+ \message{Cross reference values unknown; you must run TeX again.}%
+ \fi
+ \fi
+ \fi
+ \else
+ % It's defined, so just use it.
+ \thisrefX
+ \fi
+ #2% Output the suffix in any case.
+}
+
+% This is the macro invoked by entries in the aux file. Usually it's
+% just a \def (we prepend XR to the control sequence name to avoid
+% 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.
+ %
+ % Was that xref control sequence that we just defined for a float?
+ \expandafter\iffloat\csname XR#1\endcsname
+ % it was a float, and we have the (safe) float type in \iffloattype.
+ \expandafter\let\expandafter\floatlist
+ \csname floatlist\iffloattype\endcsname
+ %
+ % Is this the first time we've seen this float type?
+ \expandafter\ifx\floatlist\relax
+ \toks0 = {\do}% yes, so just \do
+ \else
+ % had it before, so preserve previous elements in list.
+ \toks0 = \expandafter{\floatlist\do}%
+ \fi
+ %
+ % Remember this xref in the control sequence \floatlistFLOATTYPE,
+ % for later use in \listoffloats.
+ \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}%
+ \fi
+}
+
+% Read the last existing aux file, if any. No error if none exists.
+%
+\def\tryauxfile{%
+ \openin 1 \jobname.aux
+ \ifeof 1 \else
+ \readdatafile{aux}%
+ \global\havexrefstrue
+ \fi
+ \closein 1
+}
+
+\def\setupdatafile{%
+ \catcode`\^^@=\other
+ \catcode`\^^A=\other
+ \catcode`\^^B=\other
+ \catcode`\^^C=\other
+ \catcode`\^^D=\other
+ \catcode`\^^E=\other
+ \catcode`\^^F=\other
+ \catcode`\^^G=\other
+ \catcode`\^^H=\other
+ \catcode`\^^K=\other
+ \catcode`\^^L=\other
+ \catcode`\^^N=\other
+ \catcode`\^^P=\other
+ \catcode`\^^Q=\other
+ \catcode`\^^R=\other
+ \catcode`\^^S=\other
+ \catcode`\^^T=\other
+ \catcode`\^^U=\other
+ \catcode`\^^V=\other
+ \catcode`\^^W=\other
+ \catcode`\^^X=\other
+ \catcode`\^^Z=\other
+ \catcode`\^^[=\other
+ \catcode`\^^\=\other
+ \catcode`\^^]=\other
+ \catcode`\^^^=\other
+ \catcode`\^^_=\other
+ % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
+ % in xref tags, i.e., node names. But since ^^e4 notation isn't
+ % supported in the main text, it doesn't seem desirable. Furthermore,
+ % that is not enough: for node names that actually contain a ^
+ % character, we would end up writing a line like this: 'xrdef {'hat
+ % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
+ % argument, and \hat is not an expandable control sequence. It could
+ % all be worked out, but why? Either we support ^^ or we don't.
+ %
+ % The other change necessary for this was to define \auxhat:
+ % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
+ % and then to call \auxhat in \setq.
+ %
+ \catcode`\^=\other
+ %
+ % Special characters. Should be turned off anyway, but...
+ \catcode`\~=\other
+ \catcode`\[=\other
+ \catcode`\]=\other
+ \catcode`\"=\other
+ \catcode`\_=\other
+ \catcode`\|=\other
+ \catcode`\<=\other
+ \catcode`\>=\other
+ \catcode`\$=\other
+ \catcode`\#=\other
+ \catcode`\&=\other
+ \catcode`\%=\other
+ \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
+ %
+ % This is to support \ in node names and titles, since the \
+ % characters end up in a \csname. It's easier than
+ % leaving it active and making its active definition an actual \
+ % character. What I don't understand is why it works in the *value*
+ % of the xrdef. Seems like it should be a catcode12 \, and that
+ % should not typeset properly. But it works, so I'm moving on for
+ % now. --karl, 15jan04.
+ \catcode`\\=\other
+ %
+ % Make the characters 128-255 be printing characters.
+ {%
+ \count1=128
+ \def\loop{%
+ \catcode\count1=\other
+ \advance\count1 by 1
+ \ifnum \count1<256 \loop \fi
+ }%
+ }%
+ %
+ % @ is our escape character in .aux files, and we need braces.
+ \catcode`\{=1
+ \catcode`\}=2
+ \catcode`\@=0
+}
+
+\def\readdatafile#1{%
+\begingroup
+ \setupdatafile
+ \input\jobname.#1
+\endgroup}
+
+\message{insertions,}
+% including footnotes.
+
+\newcount \footnoteno
+
+% The trailing space in the following definition for supereject is
+% vital for proper filling; pages come out unaligned when you do a
+% pagealignmacro call if that space before the closing brace is
+% removed. (Generally, numeric constants should always be followed by a
+% space to prevent strange expansion errors.)
+\def\supereject{\par\penalty -20000\footnoteno =0 }
+
+% @footnotestyle is meaningful for info output only.
+\let\footnotestyle=\comment
+
+{\catcode `\@=11
+%
+% Auto-number footnotes. Otherwise like plain.
+\gdef\footnote{%
+ \let\indent=\ptexindent
+ \let\noindent=\ptexnoindent
+ \global\advance\footnoteno by \@ne
+ \edef\thisfootno{$^{\the\footnoteno}$}%
+ %
+ % In case the footnote comes at the end of a sentence, preserve the
+ % extra spacing after we do the footnote number.
+ \let\@sf\empty
+ \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
+ %
+ % Remove inadvertent blank space before typesetting the footnote number.
+ \unskip
+ \thisfootno\@sf
+ \dofootnote
+}%
+
+% Don't bother with the trickery in plain.tex to not require the
+% footnote text as a parameter. Our footnotes don't need to be so general.
+%
+% Oh yes, they do; otherwise, @ifset (and anything else that uses
+% \parseargline) fails inside footnotes because the tokens are fixed when
+% the footnote is read. --karl, 16nov96.
+%
+\gdef\dofootnote{%
+ \insert\footins\bgroup
+ % We want to typeset this text as a normal paragraph, even if the
+ % footnote reference occurs in (for example) a display environment.
+ % So reset some parameters.
+ \hsize=\pagewidth
+ \interlinepenalty\interfootnotelinepenalty
+ \splittopskip\ht\strutbox % top baseline for broken footnotes
+ \splitmaxdepth\dp\strutbox
+ \floatingpenalty\@MM
+ \leftskip\z at skip
+ \rightskip\z at skip
+ \spaceskip\z at skip
+ \xspaceskip\z at skip
+ \parindent\defaultparindent
+ %
+ \smallfonts \rm
+ %
+ % Because we use hanging indentation in footnotes, a @noindent appears
+ % to exdent this text, so make it be a no-op. makeinfo does not use
+ % hanging indentation so @noindent can still be needed within footnote
+ % text after an @example or the like (not that this is good style).
+ \let\noindent = \relax
+ %
+ % Hang the footnote text off the number. Use \everypar in case the
+ % footnote extends for more than one paragraph.
+ \everypar = {\hang}%
+ \textindent{\thisfootno}%
+ %
+ % Don't crash into the line above the footnote text. Since this
+ % expands into a box, it must come within the paragraph, lest it
+ % provide a place where TeX can split the footnote.
+ \footstrut
+ \futurelet\next\fo at t
+}
+}%end \catcode `\@=11
+
+% 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
+% 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.
+
+% Replace the \insert primitive by a cheating macro.
+% Deeper inside, just make sure that the saved insertions are not spilled
+% out prematurely.
+%
+\def\startsavinginserts{%
+ \ifx \insert\ptexinsert
+ \let\insert\saveinsert
+ \else
+ \let\checkinserts\relax
+ \fi
+}
+
+% This \insert replacement works for both \insert\footins{foo} and
+% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
+%
+\def\saveinsert#1{%
+ \edef\next{\noexpand\savetobox \makeSAVEname#1}%
+ \afterassignment\next
+ % swallow the left brace
+ \let\temp =
+}
+\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
+\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
+
+\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
+
+\def\placesaveins#1{%
+ \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
+ {\box#1}%
+}
+
+% eat @SAVE -- beware, all of them have catcode \other:
+{
+ \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
+ \gdef\gobblesave @SAVE{}
+}
+
+% initialization:
+\def\newsaveins #1{%
+ \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
+ \next
+}
+\def\newsaveinsX #1{%
+ \csname newbox\endcsname #1%
+ \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
+ \checksaveins #1}%
+}
+
+% initialize:
+\let\checkinserts\empty
+\newsaveins\footins
+\newsaveins\margin
+
+
+% @image. We use the macros from epsf.tex to support this.
+% If epsf.tex is not installed and @image is used, we complain.
+%
+% Check for and read epsf.tex up front. If we read it only at @image
+% time, we might be inside a group, and then its definitions would get
+% undone and the next image would fail.
+\openin 1 = epsf.tex
+\ifeof 1 \else
+ % Do not bother showing banner with epsf.tex v2.7k (available in
+ % doc/epsf.tex and on ctan).
+ \def\epsfannounce{\toks0 = }%
+ \input epsf.tex
+\fi
+\closein 1
+%
+% We will only complain once about lack of epsf.tex.
+\newif\ifwarnednoepsf
+\newhelp\noepsfhelp{epsf.tex must be installed for images to
+ work. It is also included in the Texinfo distribution, or you can get
+ it from ftp://tug.org/tex/epsf.tex.}
+%
+\def\image#1{%
+ \ifx\epsfbox\undefined
+ \ifwarnednoepsf \else
+ \errhelp = \noepsfhelp
+ \errmessage{epsf.tex not found, images will be ignored}%
+ \global\warnednoepsftrue
+ \fi
+ \else
+ \imagexxx #1,,,,,\finish
+ \fi
+}
+%
+% Arguments to @image:
+% #1 is (mandatory) image filename; we tack on .eps extension.
+% #2 is (optional) width, #3 is (optional) height.
+% #4 is (ignored optional) html alt text.
+% #5 is (ignored optional) extension.
+% #6 is just the usual extra ignored arg for parsing this stuff.
+\newif\ifimagevmode
+\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
+ \catcode`\^^M = 5 % in case we're inside an example
+ \normalturnoffactive % allow _ et al. in names
+ % If the image is by itself, center it.
+ \ifvmode
+ \imagevmodetrue
+ \nobreak\bigskip
+ % 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
+ %
+ % Output the image.
+ \ifpdf
+ \dopdfimage{#1}{#2}{#3}%
+ \else
+ % \epsfbox itself resets \epsf?size at each figure.
+ \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
+ \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
+ \epsfbox{#1.eps}%
+ \fi
+ %
+ \ifimagevmode \hss \egroup \bigbreak \fi % space after the image
+\endgroup}
+
+
+% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
+% etc. We don't actually implement floating yet, we always include the
+% float "here". But it seemed the best name for the future.
+%
+\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
+
+% There may be a space before second and/or third parameter; delete it.
+\def\eatcommaspace#1, {#1,}
+
+% #1 is the optional FLOATTYPE, the text label for this float, typically
+% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
+% this float will not be numbered and cannot be referred to.
+%
+% #2 is the optional xref label. Also must be present for the float to
+% be referable.
+%
+% #3 is the optional positioning argument; for now, it is ignored. It
+% will somehow specify the positions allowed to float to (here, top, bottom).
+%
+% We keep a separate counter for each FLOATTYPE, which we reset at each
+% chapter-level command.
+\let\resetallfloatnos=\empty
+%
+\def\dofloat#1,#2,#3,#4\finish{%
+ \let\thiscaption=\empty
+ \let\thisshortcaption=\empty
+ %
+ % don't lose footnotes inside @float.
+ %
+ % BEWARE: when the floats start float, we have to issue warning whenever an
+ % insert appears inside a float which could possibly float. --kasal, 26may04
+ %
+ \startsavinginserts
+ %
+ % We can't be used inside a paragraph.
+ \par
+ %
+ \vtop\bgroup
+ \def\floattype{#1}%
+ \def\floatlabel{#2}%
+ \def\floatloc{#3}% we do nothing with this yet.
+ %
+ \ifx\floattype\empty
+ \let\safefloattype=\empty
+ \else
+ {%
+ % the floattype might have accents or other special characters,
+ % but we need to use it in a control sequence name.
+ \indexnofonts
+ \turnoffactive
+ \xdef\safefloattype{\floattype}%
+ }%
+ \fi
+ %
+ % If label is given but no type, we handle that as the empty type.
+ \ifx\floatlabel\empty \else
+ % We want each FLOATTYPE to be numbered separately (Figure 1,
+ % Table 1, Figure 2, ...). (And if no label, no number.)
+ %
+ \expandafter\getfloatno\csname\safefloattype floatno\endcsname
+ \global\advance\floatno by 1
+ %
+ {%
+ % This magic value for \thissection 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}%
+ \setref{\floatlabel}{Yfloat}%
+ }%
+ \fi
+ %
+ % start with \parskip glue, I guess.
+ \vskip\parskip
+ %
+ % Don't suppress indentation if a float happens to start a section.
+ \restorefirstparagraphindent
+}
+
+% we have these possibilities:
+% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
+% @float Foo,lbl & no caption: Foo 1.1
+% @float Foo & @caption{Cap}: Foo: Cap
+% @float Foo & no caption: Foo
+% @float ,lbl & Caption{Cap}: 1.1: Cap
+% @float ,lbl & no caption: 1.1
+% @float & @caption{Cap}: Cap
+% @float & no caption:
+%
+\def\Efloat{%
+ \let\floatident = \empty
+ %
+ % In all cases, if we have a float type, it comes first.
+ \ifx\floattype\empty \else \def\floatident{\floattype}\fi
+ %
+ % If we have an xref label, the number comes next.
+ \ifx\floatlabel\empty \else
+ \ifx\floattype\empty \else % if also had float type, need tie first.
+ \appendtomacro\floatident{\tie}%
+ \fi
+ % the number.
+ \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
+ \fi
+ %
+ % Start the printed caption with what we've constructed in
+ % \floatident, but keep it separate; we need \floatident again.
+ \let\captionline = \floatident
+ %
+ \ifx\thiscaption\empty \else
+ \ifx\floatident\empty \else
+ \appendtomacro\captionline{: }% had ident, so need a colon between
+ \fi
+ %
+ % caption text.
+ \appendtomacro\captionline{\scanexp\thiscaption}%
+ \fi
+ %
+ % If we have anything to print, print it, with space before.
+ % Eventually this needs to become an \insert.
+ \ifx\captionline\empty \else
+ \vskip.5\parskip
+ \captionline
+ %
+ % Space below caption.
+ \vskip\parskip
+ \fi
+ %
+ % If have an xref label, write the list of floats info. Do this
+ % after the caption, to avoid chance of it being a breakpoint.
+ \ifx\floatlabel\empty \else
+ % Write the text that goes in the lof to the aux file as
+ % \floatlabel-lof. Besides \floatident, we include the short
+ % 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.
+ \scanexp{%
+ \xdef\noexpand\gtemp{%
+ \ifx\thisshortcaption\empty
+ \thiscaption
+ \else
+ \thisshortcaption
+ \fi
+ }%
+ }%
+ \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
+ \ifx\gtemp\empty \else : \gtemp \fi}}%
+ }%
+ \fi
+ \egroup % end of \vtop
+ %
+ % 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
+ %
+ \checkinserts
+}
+
+% Append the tokens #2 to the definition of macro #1, not expanding either.
+%
+\def\appendtomacro#1#2{%
+ \expandafter\def\expandafter#1\expandafter{#1#2}%
+}
+
+% @caption, @shortcaption
+%
+\def\caption{\docaption\thiscaption}
+\def\shortcaption{\docaption\thisshortcaption}
+\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
+\def\defcaption#1#2{\egroup \def#1{#2}}
+
+% The parameter is the control sequence identifying the counter we are
+% going to use. Create it if it doesn't exist and assign it to \floatno.
+\def\getfloatno#1{%
+ \ifx#1\relax
+ % Haven't seen this figure type before.
+ \csname newcount\endcsname #1%
+ %
+ % Remember to reset this floatno at the next chap.
+ \expandafter\gdef\expandafter\resetallfloatnos
+ \expandafter{\resetallfloatnos #1=0 }%
+ \fi
+ \let\floatno#1%
+}
+
+% \setref calls this to get the XREFLABEL-snt value. We want an @xref
+% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
+% first read the @float command.
+%
+\def\Yfloat{\floattype at tie \chaplevelprefix\the\floatno}%
+
+% Magic string used for the XREFLABEL-title value, so \xrefX can
+% distinguish floats from other xref types.
+\def\floatmagic{!!float!!}
+
+% #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.
+%
+\def\iffloat#1{\expandafter\doiffloat#1==\finish}
+%
+% #1 is (maybe) the \floatmagic string. If so, #2 will be the
+% (safe) float type for this float. We set \iffloattype to #2.
+%
+\def\doiffloat#1=#2=#3\finish{%
+ \def\temp{#1}%
+ \def\iffloattype{#2}%
+ \ifx\temp\floatmagic
+}
+
+% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
+%
+\parseargdef\listoffloats{%
+ \def\floattype{#1}% floattype
+ {%
+ % the floattype might have accents or other special characters,
+ % but we need to use it in a control sequence name.
+ \indexnofonts
+ \turnoffactive
+ \xdef\safefloattype{\floattype}%
+ }%
+ %
+ % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
+ \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
+ \ifhavexrefs
+ % if the user said @listoffloats foo but never @float foo.
+ \message{\linenumber No `\safefloattype' floats to list.}%
+ \fi
+ \else
+ \begingroup
+ \leftskip=\tocindent % indent these entries like a toc
+ \let\do=\listoffloatsdo
+ \csname floatlist\safefloattype\endcsname
+ \endgroup
+ \fi
+}
+
+% This is called on each entry in a list of floats. We're passed the
+% xref label, in the form LABEL-title, which is how we save it in the
+% aux file. We strip off the -title and look up \XRLABEL-lof, which
+% has the text we're supposed to typeset here.
+%
+% Figures without xref labels will not be included in the list (since
+% they won't appear in the aux file).
+%
+\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
+\def\listoffloatsdoentry#1-title\finish{{%
+ % Can't fully expand XR#1-lof because it can contain anything. Just
+ % pass the control sequence. On the other hand, XR#1-pg is just the
+ % page number, and we want to fully expand that so we can get a link
+ % in pdf output.
+ \toksA = \expandafter{\csname XR#1-lof\endcsname}%
+ %
+ % use the same \entry macro we use to generate the TOC and index.
+ \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
+ \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.
+%
+\parseargdef\documentlanguage{%
+ \tex % read txi-??.tex file in plain TeX.
+ % Read the file if it exists.
+ \openin 1 txi-#1.tex
+ \ifeof 1
+ \errhelp = \nolanghelp
+ \errmessage{Cannot read language file txi-#1.tex}%
+ \else
+ \input txi-#1.tex
+ \fi
+ \closein 1
+ \endgroup
+}
+\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.}
+
+
+% @documentencoding should change something in TeX eventually, most
+% likely, but for now just recognize it.
+\let\documentencoding = \comment
+
+
+% Page size parameters.
+%
+\newdimen\defaultparindent \defaultparindent = 15pt
+
+\chapheadingskip = 15pt plus 4pt minus 2pt
+\secheadingskip = 12pt plus 3pt minus 2pt
+\subsecheadingskip = 9pt plus 2pt minus 2pt
+
+% Prevent underfull vbox error messages.
+\vbadness = 10000
+
+% Don't be so finicky about underfull hboxes, either.
+\hbadness = 2000
+
+% Following George Bush, just get rid of widows and orphans.
+\widowpenalty=10000
+\clubpenalty=10000
+
+% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
+% using an old version of TeX, don't do anything. We want the amount of
+% stretch added to depend on the line length, hence the dependence on
+% \hsize. We call this whenever the paper size is set.
+%
+\def\setemergencystretch{%
+ \ifx\emergencystretch\thisisundefined
+ % Allow us to assign to \emergencystretch anyway.
+ \def\emergencystretch{\dimen0}%
+ \else
+ \emergencystretch = .15\hsize
+ \fi
+}
+
+% Parameters in order: 1) textheight; 2) textwidth;
+% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
+% 7) physical page height; 8) physical page width.
+%
+% We also call \setleading{\textleading}, so the caller should define
+% \textleading. The caller should also set \parskip.
+%
+\def\internalpagesizes#1#2#3#4#5#6#7#8{%
+ \voffset = #3\relax
+ \topskip = #6\relax
+ \splittopskip = \topskip
+ %
+ \vsize = #1\relax
+ \advance\vsize by \topskip
+ \outervsize = \vsize
+ \advance\outervsize by 2\topandbottommargin
+ \pageheight = \vsize
+ %
+ \hsize = #2\relax
+ \outerhsize = \hsize
+ \advance\outerhsize by 0.5in
+ \pagewidth = \hsize
+ %
+ \normaloffset = #4\relax
+ \bindingoffset = #5\relax
+ %
+ \ifpdf
+ \pdfpageheight #7\relax
+ \pdfpagewidth #8\relax
+ \fi
+ %
+ \setleading{\textleading}
+ %
+ \parindent = \defaultparindent
+ \setemergencystretch
+}
+
+% @letterpaper (the default).
+\def\letterpaper{{\globaldefs = 1
+ \parskip = 3pt plus 2pt minus 1pt
+ \textleading = 13.2pt
+ %
+ % If page is nothing but text, make it come out even.
+ \internalpagesizes{46\baselineskip}{6in}%
+ {\voffset}{.25in}%
+ {\bindingoffset}{36pt}%
+ {11in}{8.5in}%
+}}
+
+% Use @smallbook to reset parameters for 7x9.25 trim size.
+\def\smallbook{{\globaldefs = 1
+ \parskip = 2pt plus 1pt
+ \textleading = 12pt
+ %
+ \internalpagesizes{7.5in}{5in}%
+ {\voffset}{.25in}%
+ {\bindingoffset}{16pt}%
+ {9.25in}{7in}%
+ %
+ \lispnarrowing = 0.3in
+ \tolerance = 700
+ \hfuzz = 1pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = .5cm
+}}
+
+% Use @smallerbook to reset parameters for 6x9 trim size.
+% (Just testing, parameters still in flux.)
+\def\smallerbook{{\globaldefs = 1
+ \parskip = 1.5pt plus 1pt
+ \textleading = 12pt
+ %
+ \internalpagesizes{7.4in}{4.8in}%
+ {-.2in}{-.4in}%
+ {0pt}{14pt}%
+ {9in}{6in}%
+ %
+ \lispnarrowing = 0.25in
+ \tolerance = 700
+ \hfuzz = 1pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = .4cm
+}}
+
+% Use @afourpaper to print on European A4 paper.
+\def\afourpaper{{\globaldefs = 1
+ \parskip = 3pt plus 2pt minus 1pt
+ \textleading = 13.2pt
+ %
+ % Double-side printing via postscript on Laserjet 4050
+ % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
+ % To change the settings for a different printer or situation, adjust
+ % \normaloffset until the front-side and back-side texts align. Then
+ % do the same for \bindingoffset. You can set these for testing in
+ % your texinfo source file like this:
+ % @tex
+ % \global\normaloffset = -6mm
+ % \global\bindingoffset = 10mm
+ % @end tex
+ \internalpagesizes{51\baselineskip}{160mm}
+ {\voffset}{\hoffset}%
+ {\bindingoffset}{44pt}%
+ {297mm}{210mm}%
+ %
+ \tolerance = 700
+ \hfuzz = 1pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = 5mm
+}}
+
+% Use @afivepaper to print on European A5 paper.
+% From romildo at urano.iceb.ufop.br, 2 July 2000.
+% He also recommends making @example and @lisp be small.
+\def\afivepaper{{\globaldefs = 1
+ \parskip = 2pt plus 1pt minus 0.1pt
+ \textleading = 12.5pt
+ %
+ \internalpagesizes{160mm}{120mm}%
+ {\voffset}{\hoffset}%
+ {\bindingoffset}{8pt}%
+ {210mm}{148mm}%
+ %
+ \lispnarrowing = 0.2in
+ \tolerance = 800
+ \hfuzz = 1.2pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = 2mm
+ \tableindent = 12mm
+}}
+
+% A specific text layout, 24x15cm overall, intended for A4 paper.
+\def\afourlatex{{\globaldefs = 1
+ \afourpaper
+ \internalpagesizes{237mm}{150mm}%
+ {\voffset}{4.6mm}%
+ {\bindingoffset}{7mm}%
+ {297mm}{210mm}%
+ %
+ % Must explicitly reset to 0 because we call \afourpaper.
+ \globaldefs = 0
+}}
+
+% Use @afourwide to print on A4 paper in landscape format.
+\def\afourwide{{\globaldefs = 1
+ \afourpaper
+ \internalpagesizes{241mm}{165mm}%
+ {\voffset}{-2.95mm}%
+ {\bindingoffset}{7mm}%
+ {297mm}{210mm}%
+ \globaldefs = 0
+}}
+
+% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
+% Perhaps we should allow setting the margins, \topskip, \parskip,
+% and/or leading, also. Or perhaps we should compute them somehow.
+%
+\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
+\def\pagesizesyyy#1,#2,#3\finish{{%
+ \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
+ \globaldefs = 1
+ %
+ \parskip = 3pt plus 2pt minus 1pt
+ \setleading{\textleading}%
+ %
+ \dimen0 = #1
+ \advance\dimen0 by \voffset
+ %
+ \dimen2 = \hsize
+ \advance\dimen2 by \normaloffset
+ %
+ \internalpagesizes{#1}{\hsize}%
+ {\voffset}{\normaloffset}%
+ {\bindingoffset}{44pt}%
+ {\dimen0}{\dimen2}%
+}}
+
+% Set default to letter.
+%
+\letterpaper
+
+
+\message{and turning on texinfo input format.}
+
+% Define macros to output various characters with catcode for normal text.
+\catcode`\"=\other
+\catcode`\~=\other
+\catcode`\^=\other
+\catcode`\_=\other
+\catcode`\|=\other
+\catcode`\<=\other
+\catcode`\>=\other
+\catcode`\+=\other
+\catcode`\$=\other
+\def\normaldoublequote{"}
+\def\normaltilde{~}
+\def\normalcaret{^}
+\def\normalunderscore{_}
+\def\normalverticalbar{|}
+\def\normalless{<}
+\def\normalgreater{>}
+\def\normalplus{+}
+\def\normaldollar{$}%$ font-lock fix
+
+% This macro is used to make a character print one way in \tt
+% (where it can probably be output as-is), and another way in other fonts,
+% where something hairier probably needs to be done.
+%
+% #1 is what to print if we are indeed using \tt; #2 is what to print
+% otherwise. 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, we can check that font parameter.
+%
+\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
+
+% Same as above, but check for italic font. Actually this also catches
+% non-italic slanted fonts since it is impossible to distinguish them from
+% italic fonts. But since this is only used by $ and it uses \sl anyway
+% this is not a problem.
+\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
+
+% Turn off all special characters except @
+% (and those which the user can use as if they were ordinary).
+% Most of these we simply print from the \tt font, but for some, we can
+% use math or other variants that look better in normal text.
+
+\catcode`\"=\active
+\def\activedoublequote{{\tt\char34}}
+\let"=\activedoublequote
+\catcode`\~=\active
+\def~{{\tt\char126}}
+\chardef\hat=`\^
+\catcode`\^=\active
+\def^{{\tt \hat}}
+
+\catcode`\_=\active
+\def_{\ifusingtt\normalunderscore\_}
+\let\realunder=_
+% Subroutine for the previous macro.
+\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
+
+\catcode`\|=\active
+\def|{{\tt\char124}}
+\chardef \less=`\<
+\catcode`\<=\active
+\def<{{\tt \less}}
+\chardef \gtr=`\>
+\catcode`\>=\active
+\def>{{\tt \gtr}}
+\catcode`\+=\active
+\def+{{\tt \char 43}}
+\catcode`\$=\active
+\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
+
+% If a .fmt file is being used, characters that might appear in a file
+% name cannot be active until we have parsed the command line.
+% So turn them off again, and have \everyjob (or @setfilename) turn them on.
+% \otherifyactive is called near the end of this file.
+\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
+
+\catcode`\@=0
+
+% \backslashcurfont outputs one backslash character in current font,
+% as in \char`\\.
+\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}}
+
+\catcode`\\=\active
+
+% Used sometimes to turn off (effectively) the active characters
+% even after parsing them.
+ at def@turnoffactive{%
+ @let"=@normaldoublequote
+ @let\=@realbackslash
+ @let~=@normaltilde
+ @let^=@normalcaret
+ @let_=@normalunderscore
+ @let|=@normalverticalbar
+ @let<=@normalless
+ @let>=@normalgreater
+ @let+=@normalplus
+ @let$=@normaldollar %$ font-lock fix
+ @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.
+ at otherifyactive
+
+% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
+% That is what \eatinput is for; after that, the `\' should revert to printing
+% a backslash.
+%
+ at gdef@eatinput input texinfo{@fixbackslash}
+ at global@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
+% 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.
+%
+ at gdef@fixbackslash{%
+ @ifx\@eatinput @let\ = @normalbackslash @fi
+ @catcode`+=@active
+ @catcode`@_=@active
+}
+
+% Say @foo, not \foo, in error messages.
+ at escapechar = `@@
+
+% These look ok in all fonts, so just make them not special.
+ at catcode`@& = @other
+ at catcode`@# = @other
+ at catcode`@% = @other
+
+
+ at c Local variables:
+ at c eval: (add-hook 'write-file-hooks 'time-stamp)
+ at c page-delimiter: "^\\\\message"
+ at c time-stamp-start: "def\\\\texinfoversion{"
+ at c time-stamp-format: "%:y-%02m-%02d.%02H"
+ at c time-stamp-end: "}"
+ at c End:
+
+ at c vim:sw=2:
+
+ at ignore
+ arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
+ at end ignore
diff --git a/doc/version.texi b/doc/version.texi
new file mode 100644
index 0000000..5da139a
--- /dev/null
+++ b/doc/version.texi
@@ -0,0 +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
diff --git a/gridspec_tools_20080702/Makefile.am b/gridspec_tools_20080702/Makefile.am
new file mode 100644
index 0000000..d0e16d5
--- /dev/null
+++ b/gridspec_tools_20080702/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = shared tools
\ No newline at end of file
diff --git a/gridspec_tools_20080702/Makefile.in b/gridspec_tools_20080702/Makefile.in
new file mode 100644
index 0000000..916e8da
--- /dev/null
+++ b/gridspec_tools_20080702/Makefile.in
@@ -0,0 +1,506 @@
+# 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@
+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@
+subdir = gridspec_tools_20080702
+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 =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+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@
+SUBDIRS = shared tools
+all: all-recursive
+
+.SUFFIXES:
+$(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/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/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
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (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); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ 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: 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" \
+ || $(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
+ 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 && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+ install-strip
+
+.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
+
+# 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/shared/Makefile.am b/gridspec_tools_20080702/shared/Makefile.am
new file mode 100644
index 0000000..dd68216
--- /dev/null
+++ b/gridspec_tools_20080702/shared/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = mosaic
\ No newline at end of file
diff --git a/gridspec_tools_20080702/shared/Makefile.in b/gridspec_tools_20080702/shared/Makefile.in
new file mode 100644
index 0000000..5c2115c
--- /dev/null
+++ b/gridspec_tools_20080702/shared/Makefile.in
@@ -0,0 +1,506 @@
+# 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@
+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@
+subdir = gridspec_tools_20080702/shared
+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 =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+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@
+SUBDIRS = mosaic
+all: all-recursive
+
+.SUFFIXES:
+$(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/shared/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/shared/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
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (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); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ 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: 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" \
+ || $(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
+ 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 && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+ install-strip
+
+.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
+
+# 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/shared/mosaic/Makefile.am b/gridspec_tools_20080702/shared/mosaic/Makefile.am
new file mode 100644
index 0000000..81552df
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/Makefile.am
@@ -0,0 +1,32 @@
+## 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/Makefile.in b/gridspec_tools_20080702/shared/mosaic/Makefile.in
new file mode 100644
index 0000000..76f6abb
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/Makefile.in
@@ -0,0 +1,484 @@
+# 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
+# tools/shared convenience library.
+
+# $Id: Makefile.am,v 1.1 2009/04/03 15:02:15 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@
+
+# 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
+subdir = gridspec_tools_20080702/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 \
+ $(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 =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libshared_la_LIBADD =
+am_libshared_la_OBJECTS = create_xgrid.lo gradient_c2l.lo interp.lo \
+ mosaic_util.lo read_mosaic.lo
+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
+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 = $(libshared_la_SOURCES)
+DIST_SOURCES = $(libshared_la_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@
+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__append_1) $(am__append_3)
+AM_LDFLAGS = $(am__append_2) $(am__append_4)
+ at USE_NETCDF_DIR_TRUE@AM_FCFLAGS = -I at NETCDFDIR@/include
+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/shared/mosaic/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/shared/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
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libshared.la: $(libshared_la_OBJECTS) $(libshared_la_DEPENDENCIES)
+ $(LINK) $(libshared_la_OBJECTS) $(libshared_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_xgrid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gradient_c2l.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/interp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mosaic_util.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/read_mosaic.Plo 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 $(LTLIBRARIES)
+installdirs:
+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-generic clean-libtool clean-noinstLTLIBRARIES \
+ 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-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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile 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 \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ 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/shared/mosaic/constant.h b/gridspec_tools_20080702/shared/mosaic/constant.h
new file mode 100644
index 0000000..619ae07
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/constant.h
@@ -0,0 +1,2 @@
+#define RADIUS (6371000.)
+#define STRING 255
diff --git a/gridspec_tools_20080702/shared/mosaic/create_xgrid.c b/gridspec_tools_20080702/shared/mosaic/create_xgrid.c
new file mode 100644
index 0000000..9f0c409
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/create_xgrid.c
@@ -0,0 +1,1106 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include "mosaic_util.h"
+#include "create_xgrid.h"
+#include "constant.h"
+
+#define AREA_RATIO_THRESH (1.e-6)
+#define MASK_THRESH (0.5)
+#define EPSLN (1.0e-30)
+double grid_box_radius(const double *x, const double *y, const double *z, int n);
+double dist_between_boxes(const double *x1, const double *y1, const double *z1, int n1,
+ const double *x2, const double *y2, const double *z2, int n2);
+int inside_edge(double x0, double y0, double x1, double y1, double x, double y);
+/*******************************************************************************
+ int get_maxxgrid
+ return constants MAXXGRID.
+*******************************************************************************/
+int get_maxxgrid(void)
+{
+ return MAXXGRID;
+}
+
+int get_maxxgrid_(void)
+{
+ return get_maxxgrid();
+}
+
+/*******************************************************************************
+void get_grid_area(const int *nlon, const int *nlat, const double *lon, const double *lat, const double *area)
+ return the grid area.
+*******************************************************************************/
+void get_grid_area_(const int *nlon, const int *nlat, const double *lon, const double *lat, double *area)
+{
+ get_grid_area(nlon, nlat, lon, lat, area);
+}
+
+void get_grid_area(const int *nlon, const int *nlat, const double *lon, const double *lat, double *area)
+{
+ int nx, ny, nxp, i, j, n_in;
+ double x_in[20], y_in[20];
+
+ nx = *nlon;
+ ny = *nlat;
+ nxp = nx + 1;
+
+ for(j=0; j<ny; j++) for(i=0; i < nx; i++) {
+ x_in[0] = lon[j*nxp+i];
+ x_in[1] = lon[j*nxp+i+1];
+ x_in[2] = lon[(j+1)*nxp+i+1];
+ x_in[3] = lon[(j+1)*nxp+i];
+ y_in[0] = lat[j*nxp+i];
+ y_in[1] = lat[j*nxp+i+1];
+ y_in[2] = lat[(j+1)*nxp+i+1];
+ y_in[3] = lat[(j+1)*nxp+i];
+ n_in = fix_lon(x_in, y_in, 4, M_PI);
+ area[j*nx+i] = poly_area(x_in, y_in, n_in);
+ }
+
+}; /* get_grid_area */
+
+
+void get_grid_area_no_adjust(const int *nlon, const int *nlat, const double *lon, const double *lat, double *area)
+{
+ int nx, ny, nxp, i, j, n_in;
+ double x_in[20], y_in[20];
+
+ nx = *nlon;
+ ny = *nlat;
+ nxp = nx + 1;
+
+ for(j=0; j<ny; j++) for(i=0; i < nx; i++) {
+ x_in[0] = lon[j*nxp+i];
+ x_in[1] = lon[j*nxp+i+1];
+ x_in[2] = lon[(j+1)*nxp+i+1];
+ x_in[3] = lon[(j+1)*nxp+i];
+ y_in[0] = lat[j*nxp+i];
+ y_in[1] = lat[j*nxp+i+1];
+ y_in[2] = lat[(j+1)*nxp+i+1];
+ y_in[3] = lat[(j+1)*nxp+i];
+ n_in = 4;
+ area[j*nx+i] = poly_area_no_adjust(x_in, y_in, n_in);
+ }
+
+}; /* get_grid_area_no_adjust */
+
+/*******************************************************************************
+ void create_xgrid_1dx2d_order1
+ This routine generate exchange grids between two grids for the first order
+ conservative interpolation. nlon_in,nlat_in,nlon_out,nlat_out are the size of the grid cell
+ and lon_in,lat_in are 1-D grid bounds, lon_out,lat_out are geographic grid location of grid cell bounds.
+*******************************************************************************/
+int create_xgrid_1dx2d_order1_(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out, double *xgrid_area)
+{
+ int nxgrid;
+
+ nxgrid = create_xgrid_1dx2d_order1(nlon_in, nlat_in, nlon_out, nlat_out, lon_in, lat_in, lon_out, lat_out, mask_in,
+ i_in, j_in, i_out, j_out, xgrid_area);
+ return nxgrid;
+
+};
+
+int create_xgrid_1dx2d_order1(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, const double *lon_in,
+ const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area)
+{
+
+ int nx1, ny1, nx2, ny2, nx1p, nx2p;
+ int i1, j1, i2, j2, nxgrid;
+ double ll_lon, ll_lat, ur_lon, ur_lat, x_in[MV], y_in[MV], x_out[MV], y_out[MV];
+ double *area_in, *area_out, min_area;
+ double *tmpx, *tmpy;
+
+ nx1 = *nlon_in;
+ ny1 = *nlat_in;
+ nx2 = *nlon_out;
+ ny2 = *nlat_out;
+
+ nxgrid = 0;
+ nx1p = nx1 + 1;
+ nx2p = nx2 + 1;
+
+ area_in = (double *)malloc(nx1*ny1*sizeof(double));
+ area_out = (double *)malloc(nx2*ny2*sizeof(double));
+ tmpx = (double *)malloc((nx1+1)*(ny1+1)*sizeof(double));
+ tmpy = (double *)malloc((nx1+1)*(ny1+1)*sizeof(double));
+ for(j1=0; j1<=ny1; j1++) for(i1=0; i1<=nx1; i1++) {
+ tmpx[j1*nx1p+i1] = lon_in[i1];
+ tmpy[j1*nx1p+i1] = lat_in[j1];
+ }
+ /* This is just a temporary fix to solve the issue that there is one point in zonal direction */
+ if(nx1 > 1)
+ get_grid_area(nlon_in, nlat_in, tmpx, tmpy, area_in);
+ else
+ get_grid_area_no_adjust(nlon_in, nlat_in, tmpx, tmpy, area_in);
+
+ get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out);
+ free(tmpx);
+ free(tmpy);
+
+ for(j1=0; j1<ny1; j1++) for(i1=0; i1<nx1; i1++) if( mask_in[j1*nx1+i1] > MASK_THRESH ) {
+
+ ll_lon = lon_in[i1]; ll_lat = lat_in[j1];
+ ur_lon = lon_in[i1+1]; ur_lat = lat_in[j1+1];
+ for(j2=0; j2<ny2; j2++) for(i2=0; i2<nx2; i2++) {
+ int n_in, n_out;
+ double Xarea;
+
+ y_in[0] = lat_out[j2*nx2p+i2];
+ y_in[1] = lat_out[j2*nx2p+i2+1];
+ y_in[2] = lat_out[(j2+1)*nx2p+i2+1];
+ y_in[3] = lat_out[(j2+1)*nx2p+i2];
+ if ( (y_in[0]<=ll_lat) && (y_in[1]<=ll_lat)
+ && (y_in[2]<=ll_lat) && (y_in[3]<=ll_lat) ) continue;
+ if ( (y_in[0]>=ur_lat) && (y_in[1]>=ur_lat)
+ && (y_in[2]>=ur_lat) && (y_in[3]>=ur_lat) ) continue;
+
+ x_in[0] = lon_out[j2*nx2p+i2];
+ x_in[1] = lon_out[j2*nx2p+i2+1];
+ x_in[2] = lon_out[(j2+1)*nx2p+i2+1];
+ x_in[3] = lon_out[(j2+1)*nx2p+i2];
+ n_in = fix_lon(x_in, y_in, 4, (ll_lon+ur_lon)/2);
+
+ if ( (n_out = clip ( x_in, y_in, n_in, ll_lon, ll_lat, ur_lon, ur_lat, x_out, y_out )) > 0 ) {
+ Xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1];
+ min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]);
+ if( Xarea/min_area > AREA_RATIO_THRESH ) {
+ xgrid_area[nxgrid] = Xarea;
+ i_in[nxgrid] = i1;
+ j_in[nxgrid] = j1;
+ i_out[nxgrid] = i2;
+ j_out[nxgrid] = j2;
+ ++nxgrid;
+ if(nxgrid > MAXXGRID) error_handler("nxgrid is greater than MAXXGRID, increase MAXXGRID");
+ }
+ }
+ }
+ }
+
+ free(area_in);
+ free(area_out);
+
+ return nxgrid;
+
+}; /* create_xgrid_1dx2d_order1 */
+
+
+/********************************************************************************
+ void create_xgrid_1dx2d_order2
+ This routine generate exchange grids between two grids for the second order
+ conservative interpolation. nlon_in,nlat_in,nlon_out,nlat_out are the size of the grid cell
+ and lon_in,lat_in are 1-D grid bounds, lon_out,lat_out are geographic grid location of grid cell bounds.
+********************************************************************************/
+int create_xgrid_1dx2d_order2_(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat)
+{
+ int nxgrid;
+ nxgrid = create_xgrid_1dx2d_order2(nlon_in, nlat_in, nlon_out, nlat_out, lon_in, lat_in, lon_out, lat_out, mask_in, i_in,
+ j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat);
+ return nxgrid;
+
+};
+int create_xgrid_1dx2d_order2(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat)
+{
+
+ int nx1, ny1, nx2, ny2, nx1p, nx2p;
+ int i1, j1, i2, j2, nxgrid, n;
+ double ll_lon, ll_lat, ur_lon, ur_lat, x_in[MV], y_in[MV], x_out[MV], y_out[MV];
+ double *area_in, *area_out, min_area;
+ double *tmpx, *tmpy;
+
+ nx1 = *nlon_in;
+ ny1 = *nlat_in;
+ nx2 = *nlon_out;
+ ny2 = *nlat_out;
+
+ nxgrid = 0;
+ nx1p = nx1 + 1;
+ nx2p = nx2 + 1;
+
+ area_in = (double *)malloc(nx1*ny1*sizeof(double));
+ area_out = (double *)malloc(nx2*ny2*sizeof(double));
+ tmpx = (double *)malloc((nx1+1)*(ny1+1)*sizeof(double));
+ tmpy = (double *)malloc((nx1+1)*(ny1+1)*sizeof(double));
+ for(j1=0; j1<=ny1; j1++) for(i1=0; i1<=nx1; i1++) {
+ tmpx[j1*nx1p+i1] = lon_in[i1];
+ tmpy[j1*nx1p+i1] = lat_in[j1];
+ }
+ get_grid_area(nlon_in, nlat_in, tmpx, tmpy, area_in);
+ get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out);
+ free(tmpx);
+ free(tmpy);
+
+ for(j1=0; j1<ny1; j1++) for(i1=0; i1<nx1; i1++) if( mask_in[j1*nx1+i1] > MASK_THRESH ) {
+
+ ll_lon = lon_in[i1]; ll_lat = lat_in[j1];
+ ur_lon = lon_in[i1+1]; ur_lat = lat_in[j1+1];
+ for(j2=0; j2<ny2; j2++) for(i2=0; i2<nx2; i2++) {
+ int n_in, n_out;
+ double xarea, lon_in_avg;
+
+ y_in[0] = lat_out[j2*nx2p+i2];
+ y_in[1] = lat_out[j2*nx2p+i2+1];
+ y_in[2] = lat_out[(j2+1)*nx2p+i2+1];
+ y_in[3] = lat_out[(j2+1)*nx2p+i2];
+ if ( (y_in[0]<=ll_lat) && (y_in[1]<=ll_lat)
+ && (y_in[2]<=ll_lat) && (y_in[3]<=ll_lat) ) continue;
+ if ( (y_in[0]>=ur_lat) && (y_in[1]>=ur_lat)
+ && (y_in[2]>=ur_lat) && (y_in[3]>=ur_lat) ) continue;
+
+ x_in[0] = lon_out[j2*nx2p+i2];
+ x_in[1] = lon_out[j2*nx2p+i2+1];
+ x_in[2] = lon_out[(j2+1)*nx2p+i2+1];
+ x_in[3] = lon_out[(j2+1)*nx2p+i2];
+ n_in = fix_lon(x_in, y_in, 4, (ll_lon+ur_lon)/2);
+ lon_in_avg = avgval_double(n_in, x_in);
+
+ if ( (n_out = clip ( x_in, y_in, n_in, ll_lon, ll_lat, ur_lon, ur_lat, x_out, y_out )) > 0 ) {
+ xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1];
+ min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]);
+ if(xarea/min_area > AREA_RATIO_THRESH ) {
+ xgrid_area[nxgrid] = xarea;
+ xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg);
+ xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out );
+ i_in[nxgrid] = i1;
+ j_in[nxgrid] = j1;
+ i_out[nxgrid] = i2;
+ j_out[nxgrid] = j2;
+ ++nxgrid;
+ if(nxgrid > MAXXGRID) error_handler("nxgrid is greater than MAXXGRID, increase MAXXGRID");
+ }
+ }
+ }
+ }
+ free(area_in);
+ free(area_out);
+
+ return nxgrid;
+
+}; /* create_xgrid_1dx2d_order2 */
+
+/*******************************************************************************
+ void create_xgrid_2dx1d_order1
+ This routine generate exchange grids between two grids for the first order
+ conservative interpolation. nlon_in,nlat_in,nlon_out,nlat_out are the size of the grid cell
+ and lon_out,lat_out are 1-D grid bounds, lon_in,lat_in are geographic grid location of grid cell bounds.
+ mask is on grid lon_in/lat_in.
+*******************************************************************************/
+int create_xgrid_2dx1d_order1_(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area)
+{
+ int nxgrid;
+
+ nxgrid = create_xgrid_2dx1d_order1(nlon_in, nlat_in, nlon_out, nlat_out, lon_in, lat_in, lon_out, lat_out, mask_in,
+ i_in, j_in, i_out, j_out, xgrid_area);
+ return nxgrid;
+
+};
+int create_xgrid_2dx1d_order1(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, const double *lon_in,
+ const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area)
+{
+
+ int nx1, ny1, nx2, ny2, nx1p, nx2p;
+ int i1, j1, i2, j2, nxgrid;
+ double ll_lon, ll_lat, ur_lon, ur_lat, x_in[MV], y_in[MV], x_out[MV], y_out[MV];
+ double *area_in, *area_out, min_area;
+ double *tmpx, *tmpy;
+
+ nx1 = *nlon_in;
+ ny1 = *nlat_in;
+ nx2 = *nlon_out;
+ ny2 = *nlat_out;
+
+ nxgrid = 0;
+ nx1p = nx1 + 1;
+ nx2p = nx2 + 1;
+ area_in = (double *)malloc(nx1*ny1*sizeof(double));
+ area_out = (double *)malloc(nx2*ny2*sizeof(double));
+ tmpx = (double *)malloc((nx2+1)*(ny2+1)*sizeof(double));
+ tmpy = (double *)malloc((nx2+1)*(ny2+1)*sizeof(double));
+ for(j2=0; j2<=ny2; j2++) for(i2=0; i2<=nx2; i2++) {
+ tmpx[j2*nx2p+i2] = lon_out[i2];
+ tmpy[j2*nx2p+i2] = lat_out[j2];
+ }
+ get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in);
+ get_grid_area(nlon_out, nlat_out, tmpx, tmpy, area_out);
+
+ free(tmpx);
+ free(tmpy);
+
+ for(j2=0; j2<ny2; j2++) for(i2=0; i2<nx2; i2++) {
+
+ ll_lon = lon_out[i2]; ll_lat = lat_out[j2];
+ ur_lon = lon_out[i2+1]; ur_lat = lat_out[j2+1];
+ for(j1=0; j1<ny1; j1++) for(i1=0; i1<nx1; i1++) if( mask_in[j1*nx1+i1] > MASK_THRESH ) {
+ int n_in, n_out;
+ double Xarea;
+
+ y_in[0] = lat_in[j1*nx1p+i1];
+ y_in[1] = lat_in[j1*nx1p+i1+1];
+ y_in[2] = lat_in[(j1+1)*nx1p+i1+1];
+ y_in[3] = lat_in[(j1+1)*nx1p+i1];
+ if ( (y_in[0]<=ll_lat) && (y_in[1]<=ll_lat)
+ && (y_in[2]<=ll_lat) && (y_in[3]<=ll_lat) ) continue;
+ if ( (y_in[0]>=ur_lat) && (y_in[1]>=ur_lat)
+ && (y_in[2]>=ur_lat) && (y_in[3]>=ur_lat) ) continue;
+
+ x_in[0] = lon_in[j1*nx1p+i1];
+ x_in[1] = lon_in[j1*nx1p+i1+1];
+ x_in[2] = lon_in[(j1+1)*nx1p+i1+1];
+ x_in[3] = lon_in[(j1+1)*nx1p+i1];
+
+ n_in = fix_lon(x_in, y_in, 4, (ll_lon+ur_lon)/2);
+
+ if ( (n_out = clip ( x_in, y_in, n_in, ll_lon, ll_lat, ur_lon, ur_lat, x_out, y_out )) > 0 ) {
+ Xarea = poly_area ( x_out, y_out, n_out ) * mask_in[j1*nx1+i1];
+ min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]);
+ if( Xarea/min_area > AREA_RATIO_THRESH ) {
+ xgrid_area[nxgrid] = Xarea;
+ i_in[nxgrid] = i1;
+ j_in[nxgrid] = j1;
+ i_out[nxgrid] = i2;
+ j_out[nxgrid] = j2;
+ ++nxgrid;
+ if(nxgrid > MAXXGRID) error_handler("nxgrid is greater than MAXXGRID, increase MAXXGRID");
+ }
+ }
+ }
+ }
+
+ free(area_in);
+ free(area_out);
+
+ return nxgrid;
+
+}; /* create_xgrid_2dx1d_order1 */
+
+
+/********************************************************************************
+ void create_xgrid_2dx1d_order2
+ This routine generate exchange grids between two grids for the second order
+ conservative interpolation. nlon_in,nlat_in,nlon_out,nlat_out are the size of the grid cell
+ and lon_out,lat_out are 1-D grid bounds, lon_in,lat_in are geographic grid location of grid cell bounds.
+ mask is on grid lon_in/lat_in.
+********************************************************************************/
+int create_xgrid_2dx1d_order2_(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat)
+{
+ int nxgrid;
+ nxgrid = create_xgrid_2dx1d_order2(nlon_in, nlat_in, nlon_out, nlat_out, lon_in, lat_in, lon_out, lat_out, mask_in, i_in,
+ j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat);
+ return nxgrid;
+
+};
+
+int create_xgrid_2dx1d_order2(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat)
+{
+
+ int nx1, ny1, nx2, ny2, nx1p, nx2p;
+ int i1, j1, i2, j2, nxgrid, n;
+ double ll_lon, ll_lat, ur_lon, ur_lat, x_in[MV], y_in[MV], x_out[MV], y_out[MV];
+ double *tmpx, *tmpy;
+ double *area_in, *area_out, min_area;
+ double lon_in_avg;
+
+ nx1 = *nlon_in;
+ ny1 = *nlat_in;
+ nx2 = *nlon_out;
+ ny2 = *nlat_out;
+
+ nxgrid = 0;
+ nx1p = nx1 + 1;
+ nx2p = nx2 + 1;
+
+ area_in = (double *)malloc(nx1*ny1*sizeof(double));
+ area_out = (double *)malloc(nx2*ny2*sizeof(double));
+ tmpx = (double *)malloc((nx2+1)*(ny2+1)*sizeof(double));
+ tmpy = (double *)malloc((nx2+1)*(ny2+1)*sizeof(double));
+ for(j2=0; j2<=ny2; j2++) for(i2=0; i2<=nx2; i2++) {
+ tmpx[j2*nx2p+i2] = lon_out[i2];
+ tmpy[j2*nx2p+i2] = lat_out[j2];
+ }
+ get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in);
+ get_grid_area(nlon_out, nlat_out, tmpx, tmpy, area_out);
+
+ free(tmpx);
+ free(tmpy);
+
+ for(j2=0; j2<ny2; j2++) for(i2=0; i2<nx2; i2++) {
+
+ ll_lon = lon_out[i2]; ll_lat = lat_out[j2];
+ ur_lon = lon_out[i2+1]; ur_lat = lat_out[j2+1];
+ for(j1=0; j1<ny1; j1++) for(i1=0; i1<nx1; i1++) if( mask_in[j1*nx1+i1] > MASK_THRESH ) {
+ int n_in, n_out;
+ double xarea;
+
+ y_in[0] = lat_in[j1*nx1p+i1];
+ y_in[1] = lat_in[j1*nx1p+i1+1];
+ y_in[2] = lat_in[(j1+1)*nx1p+i1+1];
+ y_in[3] = lat_in[(j1+1)*nx1p+i1];
+ if ( (y_in[0]<=ll_lat) && (y_in[1]<=ll_lat)
+ && (y_in[2]<=ll_lat) && (y_in[3]<=ll_lat) ) continue;
+ if ( (y_in[0]>=ur_lat) && (y_in[1]>=ur_lat)
+ && (y_in[2]>=ur_lat) && (y_in[3]>=ur_lat) ) continue;
+
+ x_in[0] = lon_in[j1*nx1p+i1];
+ x_in[1] = lon_in[j1*nx1p+i1+1];
+ x_in[2] = lon_in[(j1+1)*nx1p+i1+1];
+ x_in[3] = lon_in[(j1+1)*nx1p+i1];
+
+ n_in = fix_lon(x_in, y_in, 4, (ll_lon+ur_lon)/2);
+ lon_in_avg = avgval_double(n_in, x_in);
+
+ if ( (n_out = clip ( x_in, y_in, n_in, ll_lon, ll_lat, ur_lon, ur_lat, x_out, y_out )) > 0 ) {
+ xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1];
+ min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]);
+ if(xarea/min_area > AREA_RATIO_THRESH ) {
+ xgrid_area[nxgrid] = xarea;
+ xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg);
+ xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out );
+ i_in[nxgrid] = i1;
+ j_in[nxgrid] = j1;
+ i_out[nxgrid] = i2;
+ j_out[nxgrid] = j2;
+ ++nxgrid;
+ if(nxgrid > MAXXGRID) error_handler("nxgrid is greater than MAXXGRID, increase MAXXGRID");
+ }
+ }
+ }
+ }
+
+ free(area_in);
+ free(area_out);
+
+ return nxgrid;
+
+}; /* create_xgrid_2dx1d_order2 */
+
+/*******************************************************************************
+ void create_xgrid_2DX2D_order1
+ This routine generate exchange grids between two grids for the first order
+ conservative interpolation. nlon_in,nlat_in,nlon_out,nlat_out are the size of the grid cell
+ and lon_in,lat_in, lon_out,lat_out are geographic grid location of grid cell bounds.
+ mask is on grid lon_in/lat_in.
+*******************************************************************************/
+#ifndef __AIX
+int create_xgrid_2dx2d_order1_(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area)
+{
+ int nxgrid;
+
+ nxgrid = create_xgrid_2dx2d_order1(nlon_in, nlat_in, nlon_out, nlat_out, lon_in, lat_in, lon_out, lat_out, mask_in,
+ i_in, j_in, i_out, j_out, xgrid_area);
+ return nxgrid;
+
+};
+#endif
+int create_xgrid_2dx2d_order1(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area)
+{
+
+ int nx1, ny1, nx2, ny2, nx1p, nx2p, ny1p, ny2p, nxgrid, n1_in, n2_in;
+ int n0, n1, n2, n3, i1, j1, i2, j2, l;
+ double x1_in[MV], y1_in[MV], x2_in[MV], y2_in[MV], x_out[MV], y_out[MV];
+ double lon_in_min, lon_out_min, lon_in_max, lon_out_max, lat_in_min, lat_in_max, lat_out_min, lat_out_max;
+ double lon_in_avg;
+ double *area_in, *area_out, min_area;
+
+ nx1 = *nlon_in;
+ ny1 = *nlat_in;
+ nx2 = *nlon_out;
+ ny2 = *nlat_out;
+
+ nxgrid = 0;
+ nx1p = nx1 + 1;
+ nx2p = nx2 + 1;
+
+ area_in = (double *)malloc(nx1*ny1*sizeof(double));
+ area_out = (double *)malloc(nx2*ny2*sizeof(double));
+ get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in);
+ get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out);
+
+ for(j1=0; j1<ny1; j1++) for(i1=0; i1<nx1; i1++) if( mask_in[j1*nx1+i1] > MASK_THRESH ) {
+ n0 = j1*nx1p+i1; n1 = j1*nx1p+i1+1;
+ n2 = (j1+1)*nx1p+i1+1; n3 = (j1+1)*nx1p+i1;
+ x1_in[0] = lon_in[n0]; y1_in[0] = lat_in[n0];
+ x1_in[1] = lon_in[n1]; y1_in[1] = lat_in[n1];
+ x1_in[2] = lon_in[n2]; y1_in[2] = lat_in[n2];
+ x1_in[3] = lon_in[n3]; y1_in[3] = lat_in[n3];
+ lat_in_min = minval_double(4, y1_in);
+ lat_in_max = maxval_double(4, y1_in);
+ n1_in = fix_lon(x1_in, y1_in, 4, M_PI);
+ lon_in_min = minval_double(n1_in, x1_in);
+ lon_in_max = maxval_double(n1_in, x1_in);
+ lon_in_avg = avgval_double(n1_in, x1_in);
+
+ for(j2=0; j2<ny2; j2++) for(i2=0; i2<nx2; i2++) {
+ int n_in, n_out;
+ double Xarea;
+ n0 = j2*nx2p+i2; n1 = j2*nx2p+i2+1;
+ n2 = (j2+1)*nx2p+i2+1; n3 = (j2+1)*nx2p+i2;
+ x2_in[0] = lon_out[n0]; y2_in[0] = lat_out[n0];
+ x2_in[1] = lon_out[n1]; y2_in[1] = lat_out[n1];
+ x2_in[2] = lon_out[n2]; y2_in[2] = lat_out[n2];
+ x2_in[3] = lon_out[n3]; y2_in[3] = lat_out[n3];
+
+ lat_out_min = minval_double(4, y2_in);
+ lat_out_max = maxval_double(4, y2_in);
+ if(lat_out_min >= lat_in_max || lat_out_max <= lat_in_min ) continue;
+ n2_in = fix_lon(x2_in, y2_in, 4, lon_in_avg);
+ lon_out_min = minval_double(n2_in, x2_in);
+ lon_out_max = maxval_double(n2_in, x2_in);
+
+ /* x2_in should in the same range as lon_in_in after lon_fix, so no need to
+ consider cyclic condition
+ */
+ if(lon_out_min >= lon_in_max || lon_out_max <= lon_in_min ) continue;
+
+ if ( (n_out = clip_2dx2d ( x1_in, y1_in, n1_in, x2_in, y2_in, n2_in, x_out, y_out )) > 0) {
+ Xarea = poly_area (x_out, y_out, n_out) * mask_in[j1*nx1+i1];
+ min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]);
+ if( Xarea/min_area > AREA_RATIO_THRESH ) {
+ xgrid_area[nxgrid] = Xarea;
+ i_in[nxgrid] = i1;
+ j_in[nxgrid] = j1;
+ i_out[nxgrid] = i2;
+ j_out[nxgrid] = j2;
+ ++nxgrid;
+ if(nxgrid > MAXXGRID) error_handler("nxgrid is greater than MAXXGRID, increase MAXXGRID");
+ }
+ }
+ }
+ }
+
+ free(area_in);
+ free(area_out);
+ return nxgrid;
+
+};/* get_xgrid_2Dx2D_order1 */
+
+/********************************************************************************
+ void create_xgrid_2dx1d_order2
+ This routine generate exchange grids between two grids for the second order
+ conservative interpolation. nlon_in,nlat_in,nlon_out,nlat_out are the size of the grid cell
+ and lon_in,lat_in, lon_out,lat_out are geographic grid location of grid cell bounds.
+ mask is on grid lon_in/lat_in.
+********************************************************************************/
+#ifndef __AIX
+int create_xgrid_2dx2d_order2_(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat)
+{
+ int nxgrid;
+ nxgrid = create_xgrid_2dx2d_order2(nlon_in, nlat_in, nlon_out, nlat_out, lon_in, lat_in, lon_out, lat_out, mask_in, i_in,
+ j_in, i_out, j_out, xgrid_area, xgrid_clon, xgrid_clat);
+ return nxgrid;
+
+};
+#endif
+int create_xgrid_2dx2d_order2(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat)
+{
+
+ int nx1, nx2, ny1, ny2, nx1p, nx2p, ny1p, ny2p, nxgrid, n1_in, n2_in;
+ int n0, n1, n2, n3, i1, j1, i2, j2, l, n;
+ double x1_in[MV], y1_in[MV], x2_in[MV], y2_in[MV], x_out[MV], y_out[MV];
+ double lon_in_min, lon_out_min, lon_in_max, lon_out_max, lat_in_min, lat_in_max, lat_out_min, lat_out_max;
+ double lon_in_avg, xctrlon, xctrlat;
+ double *area_in, *area_out, min_area;
+
+ nx1 = *nlon_in;
+ ny1 = *nlat_in;
+ nx2 = *nlon_out;
+ ny2 = *nlat_out;
+ nxgrid = 0;
+ nx1p = nx1 + 1;
+ nx2p = nx2 + 1;
+ ny1p = ny1 + 1;
+ ny2p = ny2 + 1;
+
+ area_in = (double *)malloc(nx1*ny1*sizeof(double));
+ area_out = (double *)malloc(nx2*ny2*sizeof(double));
+ get_grid_area(nlon_in, nlat_in, lon_in, lat_in, area_in);
+ get_grid_area(nlon_out, nlat_out, lon_out, lat_out, area_out);
+
+ for(j1=0; j1<ny1; j1++) for(i1=0; i1<nx1; i1++) if( mask_in[j1*nx1+i1] > MASK_THRESH ) {
+ n0 = j1*nx1p+i1; n1 = j1*nx1p+i1+1;
+ n2 = (j1+1)*nx1p+i1+1; n3 = (j1+1)*nx1p+i1;
+ x1_in[0] = lon_in[n0]; y1_in[0] = lat_in[n0];
+ x1_in[1] = lon_in[n1]; y1_in[1] = lat_in[n1];
+ x1_in[2] = lon_in[n2]; y1_in[2] = lat_in[n2];
+ x1_in[3] = lon_in[n3]; y1_in[3] = lat_in[n3];
+ lat_in_min = minval_double(4, y1_in);
+ lat_in_max = maxval_double(4, y1_in);
+ n1_in = fix_lon(x1_in, y1_in, 4, M_PI);
+ lon_in_min = minval_double(n1_in, x1_in);
+ lon_in_max = maxval_double(n1_in, x1_in);
+ lon_in_avg = avgval_double(n1_in, x1_in);
+
+ for(j2=0; j2<ny2; j2++) for(i2=0; i2<nx2; i2++) {
+ int n_in, n_out;
+ double xarea;
+ n0 = j2*nx2p+i2; n1 = j2*nx2p+i2+1;
+ n2 = (j2+1)*nx2p+i2+1; n3 = (j2+1)*nx2p+i2;
+ x2_in[0] = lon_out[n0]; y2_in[0] = lat_out[n0];
+ x2_in[1] = lon_out[n1]; y2_in[1] = lat_out[n1];
+ x2_in[2] = lon_out[n2]; y2_in[2] = lat_out[n2];
+ x2_in[3] = lon_out[n3]; y2_in[3] = lat_out[n3];
+
+ lat_out_min = minval_double(4, y2_in);
+ lat_out_max = maxval_double(4, y2_in);
+ if(lat_out_min >= lat_in_max || lat_out_max <= lat_in_min ) continue;
+ n2_in = fix_lon(x2_in, y2_in, 4, lon_in_avg);
+ lon_out_min = minval_double(n2_in, x2_in);
+ lon_out_max = maxval_double(n2_in, x2_in);
+
+ /* x2_in should in the same range as x1_in after lon_fix, so no need to
+ consider cyclic condition
+ */
+ if(lon_out_min >= lon_in_max || lon_out_max <= lon_in_min ) continue;
+
+ if ( (n_out = clip_2dx2d( x1_in, y1_in, n1_in, x2_in, y2_in, n2_in, x_out, y_out )) > 0) {
+ xarea = poly_area (x_out, y_out, n_out ) * mask_in[j1*nx1+i1];
+ min_area = min(area_in[j1*nx1+i1], area_out[j2*nx2+i2]);
+ if( xarea/min_area > AREA_RATIO_THRESH ) {
+ xgrid_area[nxgrid] = xarea;
+ xgrid_clon[nxgrid] = poly_ctrlon(x_out, y_out, n_out, lon_in_avg);
+ xgrid_clat[nxgrid] = poly_ctrlat (x_out, y_out, n_out );
+ i_in[nxgrid] = i1;
+ j_in[nxgrid] = j1;
+ i_out[nxgrid] = i2;
+ j_out[nxgrid] = j2;
+ ++nxgrid;
+ if(nxgrid > MAXXGRID) error_handler("nxgrid is greater than MAXXGRID, increase MAXXGRID");
+ }
+ }
+ }
+ }
+
+ free(area_in);
+ free(area_out);
+
+ return nxgrid;
+
+};/* get_xgrid_2Dx2D_order2 */
+
+/*******************************************************************************
+ Sutherland-Hodgeman algorithm sequentially clips parts outside 4 boundaries
+*******************************************************************************/
+
+int clip(const double lon_in[], const double lat_in[], int n_in, double ll_lon, double ll_lat,
+ double ur_lon, double ur_lat, double lon_out[], double lat_out[])
+{
+ double x_tmp[MV], y_tmp[MV], x_last, y_last;
+ int i_in, i_out, n_out, inside_last, inside;
+
+ /* clip polygon with LEFT boundary - clip V_IN to V_TMP */
+ x_last = lon_in[n_in-1];
+ y_last = lat_in[n_in-1];
+ inside_last = (x_last >= ll_lon);
+ for (i_in=0,i_out=0;i_in<n_in;i_in++) {
+
+ /* if crossing LEFT boundary - output intersection */
+ if ((inside=(lon_in[i_in] >= ll_lon))!=inside_last) {
+ x_tmp[i_out] = ll_lon;
+ y_tmp[i_out++] = y_last + (ll_lon - x_last) * (lat_in[i_in] - y_last) / (lon_in[i_in] - x_last);
+ }
+
+ /* if "to" point is right of LEFT boundary, output it */
+ if (inside) {
+ x_tmp[i_out] = lon_in[i_in];
+ y_tmp[i_out++] = lat_in[i_in];
+ }
+ x_last = lon_in[i_in];
+ y_last = lat_in[i_in];
+ inside_last = inside;
+ }
+ if (!(n_out=i_out)) return(0);
+
+ /* clip polygon with RIGHT boundary - clip V_TMP to V_OUT */
+ x_last = x_tmp[n_out-1];
+ y_last = y_tmp[n_out-1];
+ inside_last = (x_last <= ur_lon);
+ for (i_in=0,i_out=0;i_in<n_out;i_in++) {
+
+ /* if crossing RIGHT boundary - output intersection */
+ if ((inside=(x_tmp[i_in] <= ur_lon))!=inside_last) {
+ lon_out[i_out] = ur_lon;
+ lat_out[i_out++] = y_last + (ur_lon - x_last) * (y_tmp[i_in] - y_last)
+ / (x_tmp[i_in] - x_last);
+ }
+
+ /* if "to" point is left of RIGHT boundary, output it */
+ if (inside) {
+ lon_out[i_out] = x_tmp[i_in];
+ lat_out[i_out++] = y_tmp[i_in];
+ }
+
+ x_last = x_tmp[i_in];
+ y_last = y_tmp[i_in];
+ inside_last = inside;
+ }
+ if (!(n_out=i_out)) return(0);
+
+ /* clip polygon with BOTTOM boundary - clip V_OUT to V_TMP */
+ x_last = lon_out[n_out-1];
+ y_last = lat_out[n_out-1];
+ inside_last = (y_last >= ll_lat);
+ for (i_in=0,i_out=0;i_in<n_out;i_in++) {
+
+ /* if crossing BOTTOM boundary - output intersection */
+ if ((inside=(lat_out[i_in] >= ll_lat))!=inside_last) {
+ y_tmp[i_out] = ll_lat;
+ x_tmp[i_out++] = x_last + (ll_lat - y_last) * (lon_out[i_in] - x_last) / (lat_out[i_in] - y_last);
+ }
+
+ /* if "to" point is above BOTTOM boundary, output it */
+ if (inside) {
+ x_tmp[i_out] = lon_out[i_in];
+ y_tmp[i_out++] = lat_out[i_in];
+ }
+ x_last = lon_out[i_in];
+ y_last = lat_out[i_in];
+ inside_last = inside;
+ }
+ if (!(n_out=i_out)) return(0);
+
+ /* clip polygon with TOP boundary - clip V_TMP to V_OUT */
+ x_last = x_tmp[n_out-1];
+ y_last = y_tmp[n_out-1];
+ inside_last = (y_last <= ur_lat);
+ for (i_in=0,i_out=0;i_in<n_out;i_in++) {
+
+ /* if crossing TOP boundary - output intersection */
+ if ((inside=(y_tmp[i_in] <= ur_lat))!=inside_last) {
+ lat_out[i_out] = ur_lat;
+ lon_out[i_out++] = x_last + (ur_lat - y_last) * (x_tmp[i_in] - x_last) / (y_tmp[i_in] - y_last);
+ }
+
+ /* if "to" point is below TOP boundary, output it */
+ if (inside) {
+ lon_out[i_out] = x_tmp[i_in];
+ lat_out[i_out++] = y_tmp[i_in];
+ }
+ x_last = x_tmp[i_in];
+ y_last = y_tmp[i_in];
+ inside_last = inside;
+ }
+ return(i_out);
+}; /* clip */
+
+
+/*******************************************************************************
+ Revise Sutherland-Hodgeman algorithm to find the vertices of the overlapping
+ between any two grid boxes. It return the number of vertices for the exchange grid.
+*******************************************************************************/
+
+int clip_2dx2d(const double lon1_in[], const double lat1_in[], int n1_in,
+ const double lon2_in[], const double lat2_in[], int n2_in,
+ double lon_out[], double lat_out[])
+{
+ double lon_tmp[MV], lat_tmp[MV];
+ double x1_0, y1_0, x1_1, y1_1, x2_0, y2_0, x2_1, y2_1;
+ double dx1, dy1, dx2, dy2, determ, ds1, ds2;
+ int i_out, n_out, inside_last, inside, i1, i2;
+
+ /* clip polygon with each boundary of the polygon */
+ /* We treat lon1_in/lat1_in as clip polygon and lon2_in/lat2_in as subject polygon */
+ n_out = n1_in;
+ for(i1=0; i1<n1_in; i1++) {
+ lon_tmp[i1] = lon1_in[i1];
+ lat_tmp[i1] = lat1_in[i1];
+ }
+ x2_0 = lon2_in[n2_in-1];
+ y2_0 = lat2_in[n2_in-1];
+ for(i2=0; i2<n2_in; i2++) {
+ x2_1 = lon2_in[i2];
+ y2_1 = lat2_in[i2];
+ x1_0 = lon_tmp[n_out-1];
+ y1_0 = lat_tmp[n_out-1];
+ inside_last = inside_edge( x2_0, y2_0, x2_1, y2_1, x1_0, y1_0);
+ for(i1=0, i_out=0; i1<n_out; i1++) {
+ x1_1 = lon_tmp[i1];
+ y1_1 = lat_tmp[i1];
+ if((inside = inside_edge(x2_0, y2_0, x2_1, y2_1, x1_1, y1_1)) != inside_last ) {
+ /* there is intersection, the line between <x1_0,y1_0> and <x1_1,y1_1>
+ should not parallel to the line between <x2_0,y2_0> and <x2_1,y2_1>
+ may need to consider truncation error */
+ dy1 = y1_1-y1_0;
+ dy2 = y2_1-y2_0;
+ dx1 = x1_1-x1_0;
+ dx2 = x2_1-x2_0;
+ ds1 = y1_0*x1_1 - y1_1*x1_0;
+ ds2 = y2_0*x2_1 - y2_1*x2_0;
+ determ = dy2*dx1 - dy1*dx2;
+ if(fabs(determ) < EPSLN) {
+ error_handler("the line between <x1_0,y1_0> and <x1_1,y1_1> should not parallel to "
+ "the line between <x2_0,y2_0> and <x2_1,y2_1>");
+ }
+ lon_out[i_out] = (dx2*ds1 - dx1*ds2)/determ;
+ lat_out[i_out++] = (dy2*ds1 - dy1*ds2)/determ;
+
+
+ }
+ if(inside) {
+ lon_out[i_out] = x1_1;
+ lat_out[i_out++] = y1_1;
+ }
+ x1_0 = x1_1;
+ y1_0 = y1_1;
+ inside_last = inside;
+ }
+ if(!(n_out=i_out)) return 0;
+ for(i1=0; i1<n_out; i1++) {
+ lon_tmp[i1] = lon_out[i1];
+ lat_tmp[i1] = lat_out[i1];
+ }
+ /* shift the starting point */
+ x2_0 = x2_1;
+ y2_0 = y2_1;
+ }
+ return(n_out);
+}; /* clip */
+
+
+/*------------------------------------------------------------------------------
+ double poly_ctrlat(const double x[], const double y[], int n)
+ This routine is used to calculate the latitude of the centroid
+ ---------------------------------------------------------------------------*/
+
+double poly_ctrlat(const double x[], const double y[], int n)
+{
+ double ctrlat = 0.0;
+ int i;
+
+ for (i=0;i<n;i++) {
+ int ip = (i+1) % n;
+ double dx = (x[ip]-x[i]);
+ double dy, avg_y, hdy;
+ double lat1, lat2;
+ lat1 = y[ip];
+ lat2 = y[i];
+ dy = lat2 - lat1;
+ hdy = dy*0.5;
+ avg_y = (lat1+lat2)*0.5;
+ 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 ( fabs(hdy)< SMALL_VALUE ) /* cheap area calculation along latitude */
+ ctrlat -= dx*(2*cos(avg_y) + lat2*sin(avg_y) - cos(lat1) );
+ else
+ ctrlat -= dx*( (sin(hdy)/hdy)*(2*cos(avg_y) + lat2*sin(avg_y)) - cos(lat1) );
+ }
+ return (ctrlat*RADIUS*RADIUS);
+}; /* poly_ctrlat */
+
+/*------------------------------------------------------------------------------
+ double poly_ctrlon(const double x[], const double y[], int n, double clon)
+ This routine is used to calculate the lontitude of the centroid.
+ ---------------------------------------------------------------------------*/
+double poly_ctrlon(const double x[], const double y[], int n, double clon)
+{
+ double ctrlon = 0.0;
+ int i;
+
+ clon = clon;
+ for (i=0;i<n;i++) {
+ int ip = (i+1) % n;
+ double phi1, phi2, dphi, lat1, lat2, dphi1, dphi2;
+ double f1, f2, fac, fint;
+ phi1 = x[ip];
+ phi2 = x[i];
+ lat1 = y[ip];
+ lat2 = y[i];
+ dphi = phi1 - phi2;
+
+ if (dphi==0.0) continue;
+
+ f1 = 0.5*(cos(lat1)*sin(lat1)+lat1);
+ f2 = 0.5*(cos(lat2)*sin(lat2)+lat2);
+
+ /* this will make sure longitude of centroid is at
+ the same interval as the center of any grid */
+ if(dphi > M_PI) dphi = dphi - 2.0*M_PI;
+ if(dphi < -M_PI) dphi = dphi + 2.0*M_PI;
+ dphi1 = phi1 - clon;
+ if( dphi1 > M_PI) dphi1 -= 2.0*M_PI;
+ if( dphi1 <-M_PI) dphi1 += 2.0*M_PI;
+ dphi2 = phi2 -clon;
+ if( dphi2 > M_PI) dphi2 -= 2.0*M_PI;
+ if( dphi2 <-M_PI) dphi2 += 2.0*M_PI;
+
+ if(abs(dphi2 -dphi1) < M_PI) {
+ ctrlon -= dphi * (dphi1*f1+dphi2*f2)/2.0;
+ }
+ else {
+ if(dphi1 > 0.0)
+ fac = M_PI;
+ else
+ fac = -M_PI;
+ fint = f1 + (f2-f1)*(fac-dphi1)/abs(dphi);
+ ctrlon -= 0.5*dphi1*(dphi1-fac)*f1 - 0.5*dphi2*(dphi2+fac)*f2
+ + 0.5*fac*(dphi1+dphi2)*fint;
+ }
+
+ }
+ return (ctrlon*RADIUS*RADIUS);
+}; /* poly_ctrlon */
+
+/* -----------------------------------------------------------------------------
+ double box_ctrlat(double ll_lon, double ll_lat, double ur_lon, double ur_lat)
+ This routine is used to calculate the latitude of the centroid.
+ ---------------------------------------------------------------------------*/
+double box_ctrlat(double ll_lon, double ll_lat, double ur_lon, double ur_lat)
+{
+ double dphi = ur_lon-ll_lon;
+ double ctrlat;
+
+ if(dphi > M_PI) dphi = dphi - 2.0*M_PI;
+ if(dphi < -M_PI) dphi = dphi + 2.0*M_PI;
+ ctrlat = dphi*(cos(ur_lat) + ur_lat*sin(ur_lat)-(cos(ll_lat) + ll_lat*sin(ll_lat)));
+ return (ctrlat*RADIUS*RADIUS);
+}; /* box_ctrlat */
+
+/*------------------------------------------------------------------------------
+ double box_ctrlon(double ll_lon, double ll_lat, double ur_lon, double ur_lat, double clon)
+ This routine is used to calculate the lontitude of the centroid
+ ----------------------------------------------------------------------------*/
+double box_ctrlon(double ll_lon, double ll_lat, double ur_lon, double ur_lat, double clon)
+{
+ double phi1, phi2, dphi, lat1, lat2, dphi1, dphi2;
+ double f1, f2, fac, fint;
+ double ctrlon = 0.0;
+ int i;
+ clon = clon;
+ for( i =0; i<2; i++) {
+ if(i == 0) {
+ phi1 = ur_lon;
+ phi2 = ll_lon;
+ lat1 = lat2 = ll_lat;
+ }
+ else {
+ phi1 = ll_lon;
+ phi2 = ur_lon;
+ lat1 = lat2 = ur_lat;
+ }
+ dphi = phi1 - phi2;
+ f1 = 0.5*(cos(lat1)*sin(lat1)+lat1);
+ f2 = 0.5*(cos(lat2)*sin(lat2)+lat2);
+
+ if(dphi > M_PI) dphi = dphi - 2.0*M_PI;
+ if(dphi < -M_PI) dphi = dphi + 2.0*M_PI;
+ /* make sure the center is in the same grid box. */
+ dphi1 = phi1 - clon;
+ if( dphi1 > M_PI) dphi1 -= 2.0*M_PI;
+ if( dphi1 <-M_PI) dphi1 += 2.0*M_PI;
+ dphi2 = phi2 -clon;
+ if( dphi2 > M_PI) dphi2 -= 2.0*M_PI;
+ if( dphi2 <-M_PI) dphi2 += 2.0*M_PI;
+
+ if(abs(dphi2 -dphi1) < M_PI) {
+ ctrlon -= dphi * (dphi1*f1+dphi2*f2)/2.0;
+ }
+ else {
+ if(dphi1 > 0.0)
+ fac = M_PI;
+ else
+ fac = -M_PI;
+ fint = f1 + (f2-f1)*(fac-dphi1)/abs(dphi);
+ ctrlon -= 0.5*dphi1*(dphi1-fac)*f1 - 0.5*dphi2*(dphi2+fac)*f2
+ + 0.5*fac*(dphi1+dphi2)*fint;
+ }
+ }
+ return (ctrlon*RADIUS*RADIUS);
+} /* box_ctrlon */
+
+/*******************************************************************************
+ double grid_box_radius(double *x, double *y, double *z, int n);
+ Find the radius of the grid box, the radius is defined the
+ maximum distance between any two vertices
+*******************************************************************************/
+double grid_box_radius(const double *x, const double *y, const double *z, int n)
+{
+ double radius;
+ int i, j;
+
+ radius = 0;
+ for(i=0; i<n-1; i++) {
+ for(j=i+1; j<n; j++) {
+ radius = max(radius, pow(x[i]-x[j],2.)+pow(y[i]-y[j],2.)+pow(z[i]-z[j],2.));
+ }
+ }
+
+ radius = sqrt(radius);
+
+ return (radius);
+
+}; /* grid_box_radius */
+
+/*******************************************************************************
+ double dist_between_boxes(const double *x1, const double *y1, const double *z1, int n1,
+ const double *x2, const double *y2, const double *z2, int n2);
+ Find the distance between any two grid boxes. The distance is defined by the maximum
+ distance between any vertices of these two box
+*******************************************************************************/
+double dist_between_boxes(const double *x1, const double *y1, const double *z1, int n1,
+ const double *x2, const double *y2, const double *z2, int n2)
+{
+ double dist;
+ int i, j;
+
+ for(i=0; i<n1; i++) {
+ for(j=0; j<n2; j++) {
+ dist = max(dist, pow(x1[i]-x2[j],2.)+pow(y1[i]-y2[j],2.)+pow(z1[i]-z2[j],2.));
+ }
+ }
+
+ dist = sqrt(dist);
+ return (dist);
+
+}; /* dist_between_boxes */
+
+/*******************************************************************************
+ int inside_edge(double x0, double y0, double x1, double y1, double x, double y)
+ determine a point(x,y) is inside or outside a given edge with vertex,
+ (x0,y0) and (x1,y1). return 1 if inside and 0 if outside. <y1-y0, -(x1-x0)> is
+ the outward edge normal from vertex <x0,y0> to <x1,y1>. <x-x0,y-y0> is the vector
+ from <x0,y0> to <x,y>.
+ if Inner produce <x-x0,y-y0>*<y1-y0, -(x1-x0)> > 0, outside, otherwise inside.
+ inner product value = 0 also treate as inside.
+*******************************************************************************/
+ int inside_edge(double x0, double y0, double x1, double y1, double x, double y)
+ {
+ const double SMALL = 1.e-12;
+ double product;
+
+ product = ( x-x0 )*(y1-y0) + (x0-x1)*(y-y0);
+ return (product<=SMALL) ? 1:0;
+
+ }; /* inside_edge */
+
diff --git a/gridspec_tools_20080702/shared/mosaic/create_xgrid.h b/gridspec_tools_20080702/shared/mosaic/create_xgrid.h
new file mode 100644
index 0000000..629ea59
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/create_xgrid.h
@@ -0,0 +1,43 @@
+#ifndef CREATE_XGRID_H_
+#define CREATE_XGRID_H_
+#define MAXXGRID 1e7
+#define MV 50
+/* this value is small compare to earth area */
+
+double poly_ctrlon(const double lon[], const double lat[], int n, double clon);
+double poly_ctrlat(const double lon[], const double lat[], int n);
+double box_ctrlon(double ll_lon, double ll_lat, double ur_lon, double ur_lat, double clon);
+double box_ctrlat(double ll_lon, double ll_lat, double ur_lon, double ur_lat);
+int get_maxxgrid(void);
+void get_grid_area(const int *nlon, const int *nlat, const double *lon, const double *lat, double *area);
+void get_grid_area_no_adjust(const int *nlon, const int *nlat, const double *lon, const double *lat, double *area);
+int clip(const double lon_in[], const double lat_in[], int n_in, double ll_lon, double ll_lat,
+ double ur_lon, double ur_lat, double lon_out[], double lat_out[]);
+int clip_2dx2d(const double lon1_in[], const double lat1_in[], int n1_in,
+ const double lon2_in[], const double lat2_in[], int n2_in,
+ double lon_out[], double lat_out[]);
+int create_xgrid_1dx2d_order1(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, const double *lon_in,
+ const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area);
+int create_xgrid_1dx2d_order2(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat);
+int create_xgrid_2dx1d_order1(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out, const double *lon_in,
+ const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area);
+int create_xgrid_2dx1d_order2(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat);
+int create_xgrid_2dx2d_order1(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out,
+ int *j_out, double *xgrid_area);
+int create_xgrid_2dx2d_order2(const int *nlon_in, const int *nlat_in, const int *nlon_out, const int *nlat_out,
+ const double *lon_in, const double *lat_in, const double *lon_out, const double *lat_out,
+ const double *mask_in, int *i_in, int *j_in, int *i_out, int *j_out,
+ double *xgrid_area, double *xgrid_clon, double *xgrid_clat);
+#endif
diff --git a/gridspec_tools_20080702/shared/mosaic/gradient_c2l.c b/gridspec_tools_20080702/shared/mosaic/gradient_c2l.c
new file mode 100644
index 0000000..b246fad
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/gradient_c2l.c
@@ -0,0 +1,435 @@
+#include <math.h>
+#include <stdlib.h>
+#include "constant.h"
+#include "mosaic_util.h"
+#include "gradient_c2l.h"
+#include <stdio.h>
+void a2b_ord2(int nx, int ny, const double *qin, const double *edge_w, const double *edge_e,
+ const double *edge_s, const double *edge_n, double *qout,
+ int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge);
+
+
+/*------------------------------------------------------------------------------
+ Routine to compute gradient terms for SCRIP:
+ SJL: Oct 5, 2007
+ NOTe: pin has halo size = 1.
+ the size of pin will be (nx+2,ny+2), T-cell center, with halo = 1
+ the size of dx will be (nx, ny+1), N-cell center
+ the size of dy will be (nx+1, ny), E-cell center
+ the size of area will be (nx, ny), T-cell center.
+ The size of edge_w will be (ny+1), C-cell center
+ The size of edge_e will be (ny+1), C-cell center
+ The size of edge_s will be (nx+1), C-cell center
+ The size of edge_n will be (nx+1), C-cell center
+ The size of en_n will be (nx, ny+1,3),N-cell center
+ The size of en_e will be (nx+1,ny,3), E-cell center
+ The size of vlon will be (nx, ny, 3) T-cell center
+ The size of vlat will be (nx, ny, 3), T-cell center
+ ----------------------------------------------------------------------------*/
+void grad_c2l_(const int *nlon, const int *nlat, const double *pin, const double *dx, const double *dy, const double *area,
+ const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n,
+ const double *en_n, const double *en_e, const double *vlon, const double *vlat,
+ double *grad_x, double *grad_y, const int *on_west_edge, const int *on_east_edge,
+ const int *on_south_edge, const int *on_north_edge)
+{
+ grad_c2l(nlon, nlat, pin, dx, dy, area, edge_w, edge_e, edge_s, edge_n, en_n, en_e, vlon, vlat, grad_x, grad_y,
+ on_west_edge, on_east_edge, on_south_edge, on_north_edge);
+}
+
+void grad_c2l(const int *nlon, const int *nlat, const double *pin, const double *dx, const double *dy, const double *area,
+ const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n,
+ const double *en_n, const double *en_e, const double *vlon, const double *vlat,
+ double *grad_x, double *grad_y, const int *on_west_edge, const int *on_east_edge,
+ const int *on_south_edge, const int *on_north_edge)
+{
+
+ double *pb, *pdx, *pdy, *grad3;
+ int nx, ny, nxp, nyp, i, j, m0, m1, m2, n;
+
+ nx = *nlon;
+ ny = *nlat;
+ nxp = nx+1;
+ nyp = ny+1;
+ pb = (double *)malloc(nxp*nyp*sizeof(double));
+ pdx = (double *)malloc(3*nx*(ny+1)*sizeof(double));
+ pdy = (double *)malloc(3*(nx+1)*ny*sizeof(double));
+ grad3 = (double *)malloc(3*nx*ny*sizeof(double));
+ a2b_ord2(nx, ny, pin, edge_w, edge_e, edge_s, edge_n, pb, *on_west_edge, *on_east_edge,*on_south_edge, *on_north_edge);
+
+ for(j=0; j<nyp; j++) for(i=0; i<nx; i++) {
+ m0 = j*nx+i;
+ m1 = j*nxp+i;
+ for(n=0; n<3; n++) {
+ pdx[3*m0+n] = 0.5*(pb[m1]+pb[m1+1])*dx[m0]*en_n[3*m0+n];
+ }
+ }
+
+ for(j=0; j<ny; j++) for(i=0; i<nxp; i++) {
+ m0 = j*nxp+i;
+ for(n=0; n<3; n++) {
+ pdy[3*m0+n] = 0.5*(pb[m0]+pb[m0+nxp])*dy[m0]*en_e[3*m0+n];
+ }
+ }
+
+ /* Compute 3D grad of the input scalar field by Green's theorem */
+ for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
+ m0 = 3*(j*nx+i);
+ for(n=0; n<3; n++) {
+ grad3[m0+n] = pdx[3*((j+1)*nx+i)+n]-pdx[m0+n]-pdy[3*(j*nxp+i)+n]+pdy[3*(j*nxp+i+1)+n];
+ }
+ }
+
+ /* Compute inner product: V3 * grad (pe) */
+ for(j=0; j<ny; j++) for(i=0; i<nx; i++) {
+ m0 = j*nx+i;
+ m1 = 3*m0;
+ /* dq / d(Lamda)*/
+ grad_x[m0] = (vlon[m1]*grad3[m1] + vlon[m1+1]*grad3[m1+1] + vlon[m1+2]*grad3[m1+2])/area[m0];
+ grad_x[m0] *= RADIUS;
+ /* dq / d(theta) */
+ grad_y[m0] = (vlat[m1]*grad3[m1] + vlat[m1+1]*grad3[m1+1] + vlat[m1+2]*grad3[m1+2] )/area[m0];
+ grad_y[m0] *= RADIUS;
+ }
+
+ free(pb);
+ free(pdx);
+ free(pdy);
+ free(grad3);
+
+}; /* grad_c2l */
+
+/*------------------------------------------------------------------------------
+ qin: A-grid field, size (nx+2, ny+2)
+ qout: B-grid field, size (nx+1, ny+1)
+ ----------------------------------------------------------------------------*/
+void a2b_ord2(int nx, int ny, const double *qin, const double *edge_w, const double *edge_e,
+ const double *edge_s, const double *edge_n, double *qout,
+ int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge)
+{
+ int nxp, nyp, i, j;
+ int istart, iend, jstart, jend;
+ double *q1, *q2;
+ const double r3 = 1./3.;
+
+ nxp = nx+1;
+ nyp = ny+1;
+ q1 = (double *)malloc((nx+2)*sizeof(double));
+ q2 = (double *)malloc((ny+2)*sizeof(double));
+
+
+ if(on_west_edge)
+ istart = 1;
+ else
+ istart = 0;
+ if(on_east_edge)
+ iend = nx;
+ else
+ iend = nxp;
+ if(on_south_edge)
+ jstart = 1;
+ else
+ jstart = 0;
+ if(on_north_edge)
+ jend = ny;
+ else
+ jend = nyp;
+
+ /* internal region ( 1: nx-1, 1:ny-1) */
+ for(j=jstart; j<jend; j++) for(i=istart; i<iend; i++) {
+ qout[j*nxp+i] = 0.25*(qin[j*(nx+2)+i] + qin[j*(nx+2)+i+1] +
+ qin[(j+1)*(nx+2)+i] + qin[(j+1)*(nx+2)+i+1] );
+ }
+
+ /* Fix the 4 Corners */
+ if(on_west_edge && on_south_edge)qout[ 0] = r3*(qin[1* (nx+2)+1 ]+qin[1* (nx+2) ]+qin[ 1]); /* sw_corner */
+ if(on_east_edge && on_south_edge)qout[ nx] = r3*(qin[1* (nx+2)+nx]+qin[ nx ]+qin[1* (nx+2)+nxp]); /* se_corner */
+ if(on_east_edge && on_north_edge)qout[ny*nxp+nx] = r3*(qin[ny*(nx+2)+nx]+qin[ny*(nx+2)+nxp]+qin[nyp*(nx+2)+nx ]); /* ne_corner */
+ if(on_west_edge && on_north_edge)qout[ny*nxp ] = r3*(qin[ny*(nx+2)+1 ]+qin[ny*(nx+2) ]+qin[nyp*(nx+2)+1 ]); /* nw_corner */
+
+ /* West Edges */
+ if(on_west_edge) {
+ for(j=jstart; j<=jend; j++) q2[j] = 0.5*(qin[j*(nx+2)] + qin[j*(nx+2)+1]);
+ for(j=jstart; j<jend; j++) qout[j*nxp] = edge_w[j]*q2[j] + (1-edge_w[j])*q2[j+1];
+ }
+
+ /* East Edges */
+ if(on_east_edge) {
+ for(j=jstart; j<=jend; j++)q2[j] = 0.5*(qin[j*(nx+2)+nx] + qin[j*(nx+2)+nxp]);
+ for(j=jstart; j<jend; j++) qout[j*nxp+nx] = edge_e[j]*q2[j] + (1-edge_e[j])*q2[j+1];
+ }
+
+ /* south edge */
+ if(on_south_edge) {
+ for(i=istart; i<=iend; i++) q1[i] = 0.5*(qin[i] + qin[(nx+2)+i]);
+ for(i=istart; i<iend; i++) qout[i] = edge_s[i]*q1[i] + (1 - edge_s[i])*q1[i+1];
+ }
+
+ /* north edge */
+ if(on_north_edge) {
+ for(i=istart; i<=iend; i++) q1[i] = 0.5*(qin[ny*(nx+2)+i] + qin[nyp*(nx+2)+i]);
+ for(i=istart; i<iend; i++) qout[ny*nxp+i] = edge_n[i]*q1[i] + (1 - edge_n[i])*q1[i+1];
+ }
+
+}; /* a2b_ord2 */
+
+
+void get_edge(int nx, int ny, const double *lont, const double *latt,
+ const double *lonc, const double *latc, double *edge_w, double *edge_e, double *edge_s, double *edge_n,
+ int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge)
+{
+ int i, j, nxp, nyp;
+ int istart, iend, jstart, jend;
+ double p1[2], p2[2];
+ double *py, *px;
+ double d1, d2;
+
+ nxp = nx + 1;
+ nyp = ny + 1;
+
+ for(i=0; i<nxp; i++) {
+ edge_s[i] = 0.5; /* dummy value */
+ edge_n[i] = 0.5; /* dummy value */
+ }
+ for(j=0; j<nyp; j++) {
+ edge_w[j] = 0.5; /* dummy value */
+ edge_e[j] = 0.5; /* dummy value */
+ }
+
+ px = (double *)malloc(2*(nx+2)*sizeof(double));
+ py = (double *)malloc(2*(ny+2)*sizeof(double));
+
+ if(on_west_edge)
+ istart = 1;
+ else
+ istart = 0;
+ if(on_east_edge)
+ iend = nx;
+ else
+ iend = nxp;
+ if(on_south_edge)
+ jstart = 1;
+ else
+ jstart = 0;
+ if(on_north_edge)
+ jend = ny;
+ else
+ jend = nyp;
+ /* west edge */
+
+ if(on_west_edge) {
+ i=0;
+ for(j=jstart; j<=jend; j++) {
+ /* get mid point sphere */
+ p1[0] = lont[j*(nx+2)+i ]; p1[1] = latt[j*(nx+2)+i ];
+ p2[0] = lont[j*(nx+2)+i+1]; p2[1] = latt[j*(nx+2)+i+1];
+ mid_pt_sphere(p1, p2, &(py[2*j]));
+ }
+
+ for(j=jstart; j<jend; j++) {
+ p1[0] = lonc[j*nxp+i];
+ p1[1] = latc[j*nxp+i];
+ d1 = great_circle_distance(py+2*j, p1);
+ d2 = great_circle_distance(py+2*(j+1), p1);
+ edge_w[j] = d2/(d1+d2);
+ }
+ }
+ /* east edge */
+ if(on_east_edge) {
+ i=nx;
+ for(j=jstart; j<=jend; j++) {
+ /* get mid point sphere */
+ p1[0] = lont[j*(nx+2)+i ]; p1[1] = latt[j*(nx+2)+i ];
+ p2[0] = lont[j*(nx+2)+i+1]; p2[1] = latt[j*(nx+2)+i+1];
+ mid_pt_sphere(p1, p2, &(py[2*j]));
+ }
+
+ for(j=jstart; j<jend; j++) {
+ p1[0] = lonc[j*nxp+i];
+ p1[1] = latc[j*nxp+i];
+ d1 = great_circle_distance(&(py[2*j]), p1);
+ d2 = great_circle_distance(&(py[2*(j+1)]), p1);
+ edge_e[j] = d2/(d1+d2);
+ }
+ }
+
+ /* south edge */
+ if(on_south_edge) {
+ j=0;
+ for(i=istart; i<=iend; i++) {
+ p1[0] = lont[j *(nx+2)+i]; p1[1] = latt[j *(nx+2)+i];
+ p2[0] = lont[(j+1)*(nx+2)+i]; p2[1] = latt[(j+1)*(nx+2)+i];
+ mid_pt_sphere(p1, p2, &(px[2*i]));
+ }
+ for(i=istart; i<iend; i++) {
+ p1[0] = lonc[j*nxp+i];
+ p1[1] = latc[j*nxp+i];
+ d1 = great_circle_distance(&(px[2*i]), p1);
+ d2 = great_circle_distance(&(px[2*(i+1)]), p1);
+ edge_s[i] = d2/(d1+d2);
+ }
+ }
+ /* north edge */
+ if(on_north_edge) {
+ j=ny;
+ for(i=istart; i<=iend; i++) {
+ p1[0] = lont[j *(nx+2)+i]; p1[1] = latt[j *(nx+2)+i];
+ p2[0] = lont[(j+1)*(nx+2)+i]; p2[1] = latt[(j+1)*(nx+2)+i];
+ mid_pt_sphere(p1, p2, &(px[2*i]));
+ }
+ for(i=istart; i<iend; i++) {
+ p1[0] = lonc[j*nxp+i];
+ p1[1] = latc[j*nxp+i];
+ d1 = great_circle_distance(&(px[2*i]), p1);
+ d2 = great_circle_distance(&(px[2*(i+1)]), p1);
+ edge_n[i] = d2/(d1+d2);
+ }
+ }
+
+ free(px);
+ free(py);
+
+}; /* get_edge */
+
+void mid_pt_sphere(const double *p1, const double *p2, double *pm)
+{
+ double e1[3], e2[3], e3[3];
+
+ latlon2xyz(1, p1, p1+1, e1, e1+1, e1+2);
+ latlon2xyz(1, p2, p2+1, e2, e2+1, e2+2);
+ mid_pt3_cart(e1, e2, e3);
+ xyz2latlon(1, e3, e3+1, e3+2, pm, pm+1);
+
+}
+
+void mid_pt3_cart(const double *p1, const double *p2, double *e)
+{
+ double dd;
+
+ e[0] = p1[0] + p2[0];
+ e[1] = p1[1] + p2[1];
+ e[2] = p1[2] + p2[2];
+ dd = sqrt( e[0]*e[0] + e[1]*e[1] + e[2]*e[2] );
+ e[0] /= dd;
+ e[1] /= dd;
+ e[2] /= dd;
+}
+
+/**********************************************************************************************
+ This routine is used to calculate grid information for second order conservative interpolation
+ from cubic grid to other grid
+ the size of xt will be (nx+2,ny+2), T-cell center, with halo = 1
+ the size of yt will be (nx+2,ny+2), T-cell center, with halo = 1
+ the size of xc will be (nx+1,ny+1), C-cell center
+ the size of yc will be (nx+1,ny+1), C-cell center
+ the size of dx will be (nx, ny+1), N-cell center
+ the size of dy will be (nx+1, ny), E-cell center
+ the size of area will be (nx, ny), T-cell center.
+ The size of edge_w will be (ny-1), C-cell center, without two end point
+ The size of edge_e will be (ny-1), C-cell center, without two end point
+ The size of edge_s will be (nx-1), C-cell center, without two end point
+ The size of edge_n will be (nx-1), C-cell center, without two end point
+ The size of en_n will be (nx, ny+1,3),N-cell center
+ The size of en_e will be (nx+1,ny,3), E-cell center
+ The size of vlon will be (nx, ny) T-cell center
+ The size of vlat will be (nx, ny), T-cell center
+**********************************************************************************************/
+void calc_c2l_grid_info_(int *nx_pt, int *ny_pt, const double *xt, const double *yt, const double *xc, const double *yc,
+ double *dx, double *dy, double *area, double *edge_w, double *edge_e, double *edge_s,
+ double *edge_n, double *en_n, double *en_e, double *vlon, double *vlat,
+ int *on_west_edge, int *on_east_edge, int *on_south_edge, int *on_north_edge)
+{
+ calc_c2l_grid_info(nx_pt, ny_pt, xt, yt, xc, yc, dx, dy, area, edge_w, edge_e, edge_s, edge_n,
+ en_n, en_e, vlon, vlat, on_west_edge, on_east_edge, on_south_edge, on_north_edge);
+
+}
+
+void calc_c2l_grid_info(int *nx_pt, int *ny_pt, const double *xt, const double *yt, const double *xc, const double *yc,
+ double *dx, double *dy, double *area, double *edge_w, double *edge_e, double *edge_s,
+ double *edge_n, double *en_n, double *en_e, double *vlon, double *vlat,
+ int *on_west_edge, int *on_east_edge, int *on_south_edge, int *on_north_edge)
+{
+ double *x, *y, *z, *xt_tmp, *yt_tmp;
+ int nx, ny, nxp, nyp, i, j;
+ double p1[3], p2[3], p3[3], p4[3];
+
+
+ nx = *nx_pt;
+ ny = *ny_pt;
+ nxp = nx+1;
+ nyp = ny+1;
+
+ for(j=0; j<nyp; j++) for(i=0; i<nx; i++) {
+ p1[0] = xc[j*nxp+i];
+ p1[1] = yc[j*nxp+i];
+ p2[0] = xc[j*nxp+i+1];
+ p2[1] = yc[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] = xc[j*nxp+i];
+ p1[1] = yc[j*nxp+i];
+ p2[0] = xc[(j+1)*nxp+i];
+ p2[1] = yc[(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] = xc[j*nxp+i]; /* ll lon */
+ p1[1] = yc[j*nxp+i]; /* ll lat */
+ p2[0] = xc[(j+1)*nxp+i]; /* ul lon */
+ p2[1] = yc[(j+1)*nxp+i]; /* ul lat */
+ p3[0] = xc[j*nxp+i+1]; /* lr lon */
+ p3[1] = yc[j*nxp+i+1]; /* lr lat */
+ p4[0] = xc[(j+1)*nxp+i+1]; /* ur lon */
+ p4[1] = yc[(j+1)*nxp+i+1]; /* ur lat */
+ area[j*nx+i] = spherical_excess_area(p1, p2, p3, p4, RADIUS);
+ }
+
+ x = (double *)malloc(nxp*nyp*sizeof(double));
+ y = (double *)malloc(nxp*nyp*sizeof(double));
+ z = (double *)malloc(nxp*nyp*sizeof(double));
+
+ latlon2xyz(nxp*nyp, xc, yc, x, y, z);
+ for(j=0; j<nyp; j++) for(i=0; i<nx; i++) {
+ p1[0] = x[j*nxp+i];
+ p1[1] = y[j*nxp+i];
+ p1[2] = z[j*nxp+i];
+ p2[0] = x[j*nxp+i+1];
+ p2[1] = y[j*nxp+i+1];
+ p2[2] = z[j*nxp+i+1];
+ vect_cross(p1, p2, en_n+3*(j*nx+i) );
+ normalize_vect(en_n+3*(j*nx+i));
+ }
+
+ for(j=0; j<ny; j++) for(i=0; i<nxp; i++) {
+ p2[0] = x[j*nxp+i];
+ p2[1] = y[j*nxp+i];
+ p2[2] = z[j*nxp+i];
+ p1[0] = x[(j+1)*nxp+i];
+ p1[1] = y[(j+1)*nxp+i];
+ p1[2] = z[(j+1)*nxp+i];
+ vect_cross(p1, p2, en_e+3*(j*nxp+i) );
+ normalize_vect(en_e+3*(j*nxp+i));
+ }
+
+ xt_tmp = (double *)malloc(nx*ny*sizeof(double));
+ yt_tmp = (double *)malloc(nx*ny*sizeof(double));
+ for(j=0; j<ny; j++)for(i=0; i<nx; i++) {
+ xt_tmp[j*nx+i] = xt[(j+1)*(nx+2)+i+1];
+ yt_tmp[j*nx+i] = yt[(j+1)*(nx+2)+i+1];
+ }
+ unit_vect_latlon(nx*ny, xt_tmp, yt_tmp, vlon, vlat);
+ get_edge(nx, ny, xt, yt, xc, yc, edge_w, edge_e, edge_s, edge_n, *on_west_edge, *on_east_edge,
+ *on_south_edge, *on_north_edge);
+
+ free(x);
+ free(y);
+ free(z);
+ free(xt_tmp);
+ free(yt_tmp);
+
+}
+
+
+
diff --git a/gridspec_tools_20080702/shared/mosaic/gradient_c2l.h b/gridspec_tools_20080702/shared/mosaic/gradient_c2l.h
new file mode 100644
index 0000000..e68440a
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/gradient_c2l.h
@@ -0,0 +1,17 @@
+#ifndef GRADIENT_H_
+#define GRADIENT_H_
+void grad_c2l(const int *nlon, const int *nlat, const double *pin, const double *dx, const double *dy, const double *area,
+ const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n,
+ const double *en_n, const double *en_e, const double *vlon, const double *vlat,
+ double *grad_x, double *grad_y, const int *on_west_edge, const int *on_east_edge,
+ const int *on_south_edge, const int *on_north_edge);
+void calc_c2l_grid_info(int *nx_pt, int *ny_pt, const double *xt, const double *yt, const double *xc, const double *yc,
+ double *dx, double *dy, double *area, double *edge_w, double *edge_e, double *edge_s,
+ double *edge_n, double *en_n, double *en_e, double *vlon, double *vlat,
+ int *on_west_edge, int *on_east_edge, int *on_south_edge, int *on_north_edge);
+void get_edge(int nx, int ny, const double *lont, const double *latt,
+ const double *lonc, const double *latc, double *edge_w, double *edge_e, double *edge_s, double *edge_n,
+ int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge );
+void mid_pt_sphere(const double *p1, const double *p2, double *pm);
+void mid_pt3_cart(const double *p1, const double *p2, double *e);
+#endif
diff --git a/gridspec_tools_20080702/shared/mosaic/interp.c b/gridspec_tools_20080702/shared/mosaic/interp.c
new file mode 100644
index 0000000..97deb59
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/interp.c
@@ -0,0 +1,152 @@
+#include <stdlib.h>
+#include <math.h>
+#include "mosaic_util.h"
+#include "interp.h"
+#include "create_xgrid.h"
+
+/*********************************************************************
+ void cublic_spline(size1, size2, grid1, grid2, data1, data2, yp1, ypn )
+
+ This alborithm is to get an interpolation formula that is smooth in the first
+ derivative, and continuous in the second derivative, both within an interval
+ and its boundaries. It will be used to interpolation data in 1-D space.
+
+ INPUT Arguments:
+ grid1: grid for input data grid.
+ grid2: grid for output data grid.
+ size1: size of input grid.
+ size2: size of output grid.
+ data1: input data associated with grid1.
+ yp1: first derivative of starting point.
+ Set to 0 to be "natural" (INPUT)
+ ypn: first derivative of ending point.
+ Set to 0 to be "natural" (INPUT)
+
+ OUTPUT ARGUMENTS:
+ data2: output data associated with grid2. (OUTPUT)
+
+*********************************************************************/
+
+void cubic_spline(int size1, int size2, const double *grid1, const double *grid2, const double *data1,
+ double *data2, double yp1, double ypn )
+{
+ double *y2=NULL, *u=NULL;
+ double p, sig, qn, un, h, a, b;
+ int i, k, n, klo, khi;
+
+ for(i=1; i<size1; i++) {
+ if( grid1[i] <= grid1[i-1] ) error_handler("cubic_spline: grid1 is not monotonic increasing");
+ }
+
+ for(i=0; i<size2; i++) {
+ if( grid2[i] < grid1[0] || grid2[i] > grid1[size1-1]) error_handler("cubic_spline: grid2 lies outside grid1");
+ }
+
+ if(size1 < 2) error_handler("cubic_spline: the size of input grid should be at least 2");
+ if(size1 == 2) { /* when size1 is 2, it just reduced to a linear interpolation */
+ p = (data1[1]-data1[0])/(grid1[1]-grid1[0]);
+ for(i=0; i< size2; i++) data2[i] = p*(grid2[i] - grid1[0]) + data1[0];
+ return;
+ }
+ y2 = (double *)malloc(size1*sizeof(double));
+ u = (double *)malloc(size1*sizeof(double));
+ if (yp1 >.99e30) {
+ y2[0]=0.;
+ u[0]=0.;
+ }
+ else {
+ y2[0]=-0.5;
+ u[0]=(3./(grid1[1]-grid1[0]))*((data1[1]-data1[0])/(grid1[1]-grid1[0])-yp1);
+ }
+
+ for(i=1; i<size1-1; i++) {
+ sig=(grid1[i]-grid1[i-1])/(grid1[i+1]-grid1[i-1]);
+ p=sig*y2[i-1]+2.;
+ y2[i]=(sig-1.)/p;
+ u[i]=(6.*((data1[i+1]-data1[i])/(grid1[i+1]-grid1[i])-(data1[i]-data1[i-1])
+ /(grid1[i]-grid1[i-1]))/(grid1[i+1]-grid1[i-1])-sig*u[i-1])/p;
+
+ }
+
+ if (ypn > .99e30) {
+ qn=0.;
+ un=0.;
+ }
+ else {
+ qn=0.5;
+ un=(3./(grid1[size1-1]-grid1[size1-2]))*(ypn-(data1[size1-1]-data1[size1-2])/(grid1[size1-1]-grid1[size1-2]));
+ }
+
+ y2[size1-1]=(un-qn*u[size1-2])/(qn*y2[size1-2]+1.);
+
+ for(k=size1-2; k>=0; k--) y2[k] = y2[k]*y2[k+1]+u[k];
+
+ /* interpolate data onto grid2 */
+ for(k=0; k<size2; k++) {
+ n = nearest_index(grid2[k],grid1, size1);
+ if (grid1[n] < grid2[k]) {
+ klo = n;
+ }
+ else {
+ if(n==0) {
+ klo = n;
+ }
+ else {
+ klo = n -1;
+ }
+ }
+ khi = klo+1;
+ h = grid1[khi]-grid1[klo];
+ a = (grid1[khi] - grid2[k])/h;
+ b = (grid2[k] - grid1[klo])/h;
+ data2[k] = a*data1[klo] + b*data1[khi]+ ((pow(a,3.0)-a)*y2[klo] + (pow(b,3.0)-b)*y2[khi])*(pow(h,2.0))/6;
+ }
+
+ free(y2);
+ free(u);
+
+};/* cubic spline */
+
+
+/*------------------------------------------------------------------------------
+ void conserve_interp()
+ conservative interpolation through exchange grid.
+ Currently only first order interpolation are implemented here.
+ ----------------------------------------------------------------------------*/
+void conserve_interp(int nx_src, int ny_src, int nx_dst, int ny_dst, const double *x_src,
+ const double *y_src, const double *x_dst, const double *y_dst,
+ const double *mask_src, const double *data_src, double *data_dst )
+{
+ int n, nxgrid;
+ int *xgrid_i1, *xgrid_j1, *xgrid_i2, *xgrid_j2;
+ double *xgrid_area, *dst_area, *area_frac;
+
+ /* get the exchange grid between source and destination grid. */
+ xgrid_i1 = (int *)malloc(MAXXGRID*sizeof(int));
+ xgrid_j1 = (int *)malloc(MAXXGRID*sizeof(int));
+ xgrid_i2 = (int *)malloc(MAXXGRID*sizeof(int));
+ xgrid_j2 = (int *)malloc(MAXXGRID*sizeof(int));
+ xgrid_area = (double *)malloc(MAXXGRID*sizeof(double));
+ dst_area = (double *)malloc(nx_dst*ny_dst*sizeof(double));
+ nxgrid = create_xgrid_2dx2d_order1(&nx_src, &ny_src, &nx_dst, &ny_dst, x_src, y_src, x_dst, y_dst, mask_src,
+ xgrid_i1, xgrid_j1, xgrid_i2, xgrid_j2, xgrid_area );
+ get_grid_area(&nx_dst, &ny_dst, x_dst, y_dst, dst_area);
+ area_frac = (double *)malloc(nxgrid*sizeof(double));
+ for(n=0; n<nxgrid; n++) area_frac[n] = xgrid_area[n]/dst_area[xgrid_j2[n]*nx_dst+xgrid_i2[n]];
+
+ for(n=0; n<nx_dst*ny_dst; n++) {
+ data_dst[n] = 0;
+ }
+ for(n=0; n<nxgrid; n++) {
+ data_dst[xgrid_j2[n]*nx_dst+xgrid_i2[n]] += data_src[xgrid_j1[n]*nx_src+xgrid_i1[n]]*area_frac[n];
+ }
+
+ free(xgrid_i1);
+ free(xgrid_j1);
+ free(xgrid_i2);
+ free(xgrid_j2);
+ free(xgrid_area);
+ free(dst_area);
+ free(area_frac);
+
+}; /* conserve_interp */
diff --git a/gridspec_tools_20080702/shared/mosaic/interp.h b/gridspec_tools_20080702/shared/mosaic/interp.h
new file mode 100644
index 0000000..245dec8
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/interp.h
@@ -0,0 +1,14 @@
+#ifndef INTERP_H_
+#define INTERP_H_
+/*********************************************************************
+ interp.h
+ This header files contains defition of some interpolation routine (1-D or 2-D).
+ contact: Zhi.Liang at noaa.gov
+*********************************************************************/
+
+void cubic_spline(int size1, int size2, const double *grid1, const double *grid2, const double *data1,
+ double *data2, double yp1, double ypn );
+void conserve_interp(int nx_src, int ny_src, int nx_dst, int ny_dst, const double *x_src,
+ const double *y_src, const double *x_dst, const double *y_dst,
+ const double *mask_src, const double *data_src, double *data_dst );
+#endif
diff --git a/gridspec_tools_20080702/shared/mosaic/mosaic_util.c b/gridspec_tools_20080702/shared/mosaic/mosaic_util.c
new file mode 100644
index 0000000..4634428
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/mosaic_util.c
@@ -0,0 +1,531 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#ifdef use_libMPI
+#include <mpi.h>
+#endif
+#include "mosaic_util.h"
+#include "constant.h"
+
+#define HPI (0.5*M_PI)
+#define TPI (2.0*M_PI)
+#define TOLORENCE (1.e-6)
+#define EPSLN (1.e-10)
+/***********************************************************
+ void error_handler(char *str)
+ error handler: will print out error message and then abort
+***********************************************************/
+
+void error_handler(const char *msg)
+{
+ fprintf(stderr, "FATAL Error: %s\n", msg );
+#ifdef use_libMPI
+ MPI_Abort(MPI_COMM_WORLD, -1);
+#else
+ exit(1);
+#endif
+}; /* error_handler */
+
+/*********************************************************************
+
+ int nearest_index(double value, const double *array, int ia)
+
+ return index of nearest data point within "array" corresponding to "value".
+ if "value" is outside the domain of "array" then nearest_index = 0
+ or = size(array)-1 depending on whether array(0) or array(ia-1) is
+ closest to "value"
+
+ Arguments:
+ value: arbitrary data...same units as elements in "array"
+ array: array of data points (must be monotonically increasing)
+ ia : size of array.
+
+ ********************************************************************/
+int nearest_index(double value, const double *array, int ia)
+{
+ int index, i;
+ int keep_going;
+
+ for(i=1; i<ia; i++){
+ if (array[i] < array[i-1])
+ error_handler("nearest_index: array must be monotonically increasing");
+ }
+ if (value < array[0] )
+ index = 0;
+ else if ( value > array[ia-1])
+ index = ia-1;
+ else
+ {
+ i=0;
+ keep_going = 1;
+ while (i < ia && keep_going) {
+ i = i+1;
+ if (value <= array[i]) {
+ index = i;
+ if (array[i]-value > value-array[i-1]) index = i-1;
+ keep_going = 0;
+ }
+ }
+ }
+ return index;
+
+};
+
+/******************************************************************/
+
+void tokenize(const char * const string, const char *tokens, unsigned int varlen,
+ unsigned int maxvar, char * pstring, unsigned int * const nstr)
+{
+ size_t i, j, nvar, len, ntoken;
+ int found, n;
+
+ nvar = 0; j = 0;
+ len = strlen(string);
+ ntoken = strlen(tokens);
+ /* here we use the fact that C array [][] is contiguous in memory */
+ if(string[0] == 0)error_handler("Error from tokenize: to-be-parsed string is empty");
+
+ for(i = 0; i < len; i ++){
+ if(string[i] != ' ' && string[i] != '\t'){
+ found = 0;
+ for(n=0; n<ntoken; n++) {
+ if(string[i] == tokens[n] ) {
+ found = 1;
+ break;
+ }
+ }
+ if(found) {
+ if( j != 0) { /* remove :: */
+ *(pstring + (nvar++)*varlen + j) = 0;
+ j = 0;
+ if(nvar >= maxvar) error_handler("Error from tokenize: number of variables exceeds limit");
+ }
+ }
+ else {
+ *(pstring + nvar*varlen + j++) = string[i];
+ if(j >= varlen ) error_handler("error from tokenize: variable name length exceeds limit during tokenization");
+ }
+ }
+ }
+ *(pstring + nvar*varlen + j) = 0;
+
+ *nstr = ++nvar;
+
+}
+
+/*******************************************************************************
+ double maxval_double(int size, double *data)
+ get the maximum value of double array
+*******************************************************************************/
+double maxval_double(int size, const double *data)
+{
+ int n;
+ double maxval;
+
+ maxval = data[0];
+ for(n=1; n<size; n++){
+ if( data[n] > maxval ) maxval = data[n];
+ }
+
+ return maxval;
+
+}; /* maxval_double */
+
+
+/*******************************************************************************
+ double minval_double(int size, double *data)
+ get the minimum value of double array
+*******************************************************************************/
+double minval_double(int size, const double *data)
+{
+ int n;
+ double minval;
+
+ minval = data[0];
+ for(n=1; n<size; n++){
+ if( data[n] < minval ) minval = data[n];
+ }
+
+ return minval;
+
+}; /* minval_double */
+
+/*******************************************************************************
+ double avgval_double(int size, double *data)
+ get the average value of double array
+*******************************************************************************/
+double avgval_double(int size, const double *data)
+{
+ int n;
+ double avgval;
+
+ avgval = 0;
+ for(n=0; n<size; n++) avgval += data[n];
+ avgval /= size;
+
+ return avgval;
+
+}; /* avgval_double */
+
+
+/*******************************************************************************
+ void latlon2xyz
+ Routine to map (lon, lat) to (x,y,z)
+******************************************************************************/
+void latlon2xyz(int size, const double *lon, const double *lat, double *x, double *y, double *z)
+{
+ int n;
+
+ for(n=0; n<size; n++) {
+ x[n] = cos(lat[n])*cos(lon[n]);
+ y[n] = cos(lat[n])*sin(lon[n]);
+ z[n] = sin(lat[n]);
+ }
+
+} /* latlon2xyz */
+
+/*------------------------------------------------------------
+ void xyz2laton(np, p, xs, ys)
+ Transfer cartesian coordinates to spherical coordinates
+ ----------------------------------------------------------*/
+void xyz2latlon( int np, const double *x, const double *y, const double *z, double *lon, double *lat)
+{
+
+ double xx, yy, zz;
+ double dist, sinp;
+ int i;
+
+ for(i=0; i<np; i++) {
+ xx = x[i];
+ yy = y[i];
+ zz = z[i];
+ dist = sqrt(xx*xx+yy*yy+zz*zz);
+ xx /= dist;
+ yy /= dist;
+ zz /= dist;
+
+ if ( fabs(xx)+fabs(yy) < EPSLN )
+ lon[i] = 0;
+ else
+ lon[i] = atan2(yy, xx);
+ lat[i] = asin(zz);
+
+ if ( lon[i] < 0.) lon[i] = 2.*M_PI + lon[i];
+ }
+
+} /* xyz2latlon */
+
+/*------------------------------------------------------------------------------
+ double box_area(double ll_lon, double ll_lat, double ur_lon, double ur_lat)
+ return the area of a lat-lon grid box. grid is in radians.
+ ----------------------------------------------------------------------------*/
+double box_area(double ll_lon, double ll_lat, double ur_lon, double ur_lat)
+{
+ double dx = ur_lon-ll_lon;
+ double area;
+
+ if(dx > M_PI) dx = dx - 2.0*M_PI;
+ if(dx < -M_PI) dx = dx + 2.0*M_PI;
+
+ return (dx*(sin(ur_lat)-sin(ll_lat))*RADIUS*RADIUS ) ;
+
+}; /* box_area */
+
+
+/*------------------------------------------------------------------------------
+ double poly_area(const x[], const y[], int n)
+ obtains area of input polygon by line integrating -sin(lat)d(lon)
+ Vertex coordinates must be in degrees.
+ Vertices must be listed counter-clockwise around polygon.
+ grid is in radians.
+ ----------------------------------------------------------------------------*/
+double poly_area(const double x[], const double y[], int n)
+{
+ double area = 0.0;
+ int i;
+
+ for (i=0;i<n;i++) {
+ int ip = (i+1) % n;
+ double dx = (x[ip]-x[i]);
+ double lat1, lat2;
+
+ lat1 = y[ip];
+ lat2 = y[i];
+ if(dx > M_PI) dx = dx - 2.0*M_PI;
+ if(dx < -M_PI) dx = dx + 2.0*M_PI;
+ if (dx==0.0) continue;
+
+ if ( fabs(lat1-lat2) < SMALL_VALUE) /* cheap area calculation along latitude */
+ area -= dx*sin(0.5*(lat1+lat2));
+ else
+ area += dx*(cos(lat1)-cos(lat2))/(lat1-lat2);
+ }
+ return area*RADIUS*RADIUS;
+
+}; /* poly_area */
+
+double poly_area_no_adjust(const double x[], const double y[], int n)
+{
+ double area = 0.0;
+ int i;
+
+ for (i=0;i<n;i++) {
+ int ip = (i+1) % n;
+ double dx = (x[ip]-x[i]);
+ double lat1, lat2;
+
+ lat1 = y[ip];
+ lat2 = y[i];
+ if (dx==0.0) continue;
+
+ if ( fabs(lat1-lat2) < SMALL_VALUE) /* cheap area calculation along latitude */
+ area -= dx*sin(0.5*(lat1+lat2));
+ else
+ area += dx*(cos(lat1)-cos(lat2))/(lat1-lat2);
+ }
+ return area*RADIUS*RADIUS;
+
+}; /* poly_area_no_adjust */
+
+int delete_vtx(double x[], double y[], int n, int n_del)
+{
+ for (;n_del<n-1;n_del++) {
+ x[n_del] = x[n_del+1];
+ y[n_del] = y[n_del+1];
+ }
+
+ return (n-1);
+} /* delete_vtx */
+
+int insert_vtx(double x[], double y[], int n, int n_ins, double lon_in, double lat_in)
+{
+ int i;
+
+ for (i=n-1;i>=n_ins;i--) {
+ x[i+1] = x[i];
+ y[i+1] = y[i];
+ }
+
+ x[n_ins] = lon_in;
+ y[n_ins] = lat_in;
+ return (n+1);
+} /* insert_vtx */
+
+void v_print(double x[], double y[], int n)
+{
+ int i;
+
+ for (i=0;i<n;i++) printf(" %20g %20g\n", x[i], y[i]);
+} /* v_print */
+
+int fix_lon(double x[], double y[], int n, double tlon)
+{
+ double x_sum, dx;
+ int i, nn = n, pole = 0;
+
+ for (i=0;i<nn;i++) if (fabs(y[i])>=HPI-TOLORENCE) pole = 1;
+ if (0&&pole) {
+ printf("fixing pole cell\n");
+ v_print(x, y, nn);
+ printf("---------");
+ }
+
+ /* all pole points must be paired */
+ for (i=0;i<nn;i++) if (fabs(y[i])>=HPI-TOLORENCE) {
+ int im=(i+nn-1)%nn, ip=(i+1)%nn;
+
+ if (y[im]==y[i] && y[ip]==y[i]) {
+ nn = delete_vtx(x, y, nn, i);
+ i--;
+ } else if (y[im]!=y[i] && y[ip]!=y[i]) {
+ nn = insert_vtx(x, y, nn, i, x[i], y[i]);
+ i++;
+ }
+ }
+ /* first of pole pair has longitude of previous vertex */
+ /* second of pole pair has longitude of subsequent vertex */
+ for (i=0;i<nn;i++) if (fabs(y[i])>=HPI-TOLORENCE) {
+ int im=(i+nn-1)%nn, ip=(i+1)%nn;
+
+ if (y[im]!=y[i]) x[i] = x[im];
+ if (y[ip]!=y[i]) x[i] = x[ip];
+ }
+
+ if (nn) x_sum = x[0]; else return(0);
+ for (i=1;i<nn;i++) {
+ double dx = x[i]-x[i-1];
+
+ if (dx < -M_PI) dx = dx + TPI;
+ else if (dx > M_PI) dx = dx - TPI;
+ x_sum += (x[i] = x[i-1] + dx);
+ }
+
+ dx = (x_sum/nn)-tlon;
+ if (dx < -M_PI) for (i=0;i<nn;i++) x[i] += TPI;
+ else if (dx > M_PI) for (i=0;i<nn;i++) x[i] -= TPI;
+
+ if (0&&pole) {
+ printf("area=%g\n", poly_area(x, y,nn));
+ v_print(x, y, nn);
+ printf("---------");
+ }
+
+ return (nn);
+} /* fix_lon */
+
+
+/*------------------------------------------------------------------------------
+ double great_circle_distance()
+ computes distance between two points along a great circle
+ (the shortest distance between 2 points on a sphere)
+ returned in units of meter
+ ----------------------------------------------------------------------------*/
+double great_circle_distance(double *p1, double *p2)
+{
+ double dist, beta;
+
+ /* This algorithm is not accurate for small distance
+ dist = RADIUS*ACOS(SIN(p1[1])*SIN(p2[1]) + COS(p1[1])*COS(p2[1])*COS(p1[0]-p2[0]));
+ */
+ beta = 2.*asin( sqrt( sin((p1[1]-p2[1])/2.)*sin((p1[1]-p2[1])/2.) +
+ cos(p1[1])*cos(p2[1])*(sin((p1[0]-p2[0])/2.)*sin((p1[0]-p2[0])/2.)) ) );
+ dist = RADIUS*beta;
+ return dist;
+
+}; /* great_circle_distance */
+
+
+/*------------------------------------------------------------------------------
+ double spherical_angle(const double *p1, const double *p2, const double *p3)
+ p3
+ /
+ /
+ p1 ---> angle
+ \
+ \
+ p2
+ -----------------------------------------------------------------------------*/
+double spherical_angle(const double *v1, const double *v2, const double *v3)
+{
+ double angle;
+ double px, py, pz, qx, qy, qz, ddd;
+
+ /* 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 */
+ ddd = sqrt( (px*px+py*py+pz*pz)*(qx*qx+qy*qy+qz*qz) );
+ if (ddd > 0) {
+ angle = acos((px*qx+py*qy+pz*qz)/ddd);
+ }
+ else
+ angle = 0.;
+
+ return angle;
+}; /* spherical_angle */
+
+/*------------------------------------------------------------------------------
+ double spherical_excess_area(p_lL, p_uL, p_lR, p_uR)
+ get the surface area of a cell defined as a quadrilateral
+ on the sphere. Area is computed as the spherical excess
+ [area units are m^2]
+ ----------------------------------------------------------------------------*/
+double spherical_excess_area(const double* p_ll, const double* p_ul,
+ const double* p_lr, const double* p_ur, double radius)
+{
+ double area, ang1, ang2, ang3, ang4;
+ double v1[3], v2[3], v3[3];
+
+ /* S-W: 1 */
+ latlon2xyz(1, p_ll, p_ll+1, v1, v1+1, v1+2);
+ latlon2xyz(1, p_lr, p_lr+1, v2, v2+1, v2+2);
+ latlon2xyz(1, p_ul, p_ul+1, v3, v3+1, v3+2);
+ ang1 = spherical_angle(v1, v2, v3);
+
+ /* S-E: 2 */
+ latlon2xyz(1, p_lr, p_lr+1, v1, v1+1, v1+2);
+ latlon2xyz(1, p_ur, p_ur+1, v2, v2+1, v2+2);
+ latlon2xyz(1, p_ll, p_ll+1, v3, v3+1, v3+2);
+ ang2 = spherical_angle(v1, v2, v3);
+
+ /* N-E: 3 */
+ latlon2xyz(1, p_ur, p_ur+1, v1, v1+1, v1+2);
+ latlon2xyz(1, p_ul, p_ul+1, v2, v2+1, v2+2);
+ latlon2xyz(1, p_lr, p_lr+1, v3, v3+1, v3+2);
+ ang3 = spherical_angle(v1, v2, v3);
+
+ /* N-W: 4 */
+ latlon2xyz(1, p_ul, p_ul+1, v1, v1+1, v1+2);
+ latlon2xyz(1, p_ur, p_ur+1, v2, v2+1, v2+2);
+ latlon2xyz(1, p_ll, p_ll+1, v3, v3+1, v3+2);
+ ang4 = spherical_angle(v1, v2, v3);
+
+ area = (ang1 + ang2 + ang3 + ang4 - 2.*M_PI) * radius* radius;
+
+ return area;
+
+}; /* spherical_excess_area */
+
+
+/*----------------------------------------------------------------------
+ void vect_cross(e, p1, p2)
+ Perform cross products of 3D vectors: e = P1 X P2
+ -------------------------------------------------------------------*/
+
+void vect_cross(const double *p1, const double *p2, double *e )
+{
+
+ e[0] = p1[1]*p2[2] - p1[2]*p2[1];
+ e[1] = p1[2]*p2[0] - p1[0]*p2[2];
+ e[2] = p1[0]*p2[1] - p1[1]*p2[0];
+
+}; /* vect_cross */
+
+/* ----------------------------------------------------------------
+ make a unit vector
+ --------------------------------------------------------------*/
+void normalize_vect(double *e)
+{
+ double pdot;
+ int k;
+
+ pdot = e[0]*e[0] + e[1] * e[1] + e[2] * e[2];
+ pdot = sqrt( pdot );
+
+ for(k=0; k<3; k++) e[k] /= pdot;
+};
+
+
+/*------------------------------------------------------------------
+ void unit_vect_latlon(int size, lon, lat, vlon, vlat)
+
+ calculate unit vector for latlon in cartesian coordinates
+
+ ---------------------------------------------------------------------*/
+void unit_vect_latlon(int size, const double *lon, const double *lat, double *vlon, double *vlat)
+{
+ double sin_lon, cos_lon, sin_lat, cos_lat;
+ int n;
+
+ for(n=0; n<size; n++) {
+ sin_lon = sin(lon[n]);
+ cos_lon = cos(lon[n]);
+ sin_lat = sin(lat[n]);
+ cos_lat = cos(lat[n]);
+
+ vlon[3*n] = -sin_lon;
+ vlon[3*n+1] = cos_lon;
+ vlon[3*n+2] = 0.;
+
+ vlat[3*n] = -sin_lat*cos_lon;
+ vlat[3*n+1] = -sin_lat*sin_lon;
+ vlat[3*n+2] = cos_lat;
+ }
+}; /* unit_vect_latlon */
diff --git a/gridspec_tools_20080702/shared/mosaic/mosaic_util.h b/gridspec_tools_20080702/shared/mosaic/mosaic_util.h
new file mode 100644
index 0000000..7de4854
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/mosaic_util.h
@@ -0,0 +1,34 @@
+/***********************************************************************
+ mosaic_util.h
+ This header file provide some utilities routine that will be used in many tools.
+
+ contact: Zhi.Liang at noaa.gov
+***********************************************************************/
+#ifndef MOSAIC_UTIL_H_
+#define MOSAIC_UTIL_H_
+
+#define min(a,b) (a<b ? a:b)
+#define max(a,b) (a>b ? a:b)
+#define SMALL_VALUE ( 1.e-10 )
+void error_handler(const char *msg);
+int nearest_index(double value, const double *array, int ia);
+int lon_fix(double *x, double *y, int n_in, double tlon);
+double minval_double(int size, const double *data);
+double maxval_double(int size, const double *data);
+double avgval_double(int size, const double *data);
+void latlon2xyz(int size, const double *lon, const double *lat, double *x, double *y, double *z);
+void xyz2latlon(int size, const double *x, const double *y, const double *z, double *lon, double *lat);
+double box_area(double ll_lon, double ll_lat, double ur_lon, double ur_lat);
+double poly_area(const double lon[], const double lat[], int n);
+double poly_area_no_adjust(const double x[], const double y[], int n);
+int fix_lon(double lon[], double lat[], int n, double tlon);
+void tokenize(const char * const string, const char *tokens, unsigned int varlen,
+ unsigned int maxvar, char * pstring, unsigned int * const nstr);
+double great_circle_distance(double *p1, double *p2);
+double spherical_excess_area(const double* p_ll, const double* p_ul,
+ const double* p_lr, const double* p_ur, double radius);
+void vect_cross(const double *p1, const double *p2, double *e );
+double spherical_angle(const double *v1, const double *v2, const double *v3);
+void normalize_vect(double *e);
+void unit_vect_latlon(int size, const double *lon, const double *lat, double *vlon, double *vlat);
+#endif
diff --git a/gridspec_tools_20080702/shared/mosaic/read_mosaic.c b/gridspec_tools_20080702/shared/mosaic/read_mosaic.c
new file mode 100644
index 0000000..cc82b25
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/read_mosaic.c
@@ -0,0 +1,656 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include "read_mosaic.h"
+#include "constant.h"
+#ifdef use_netCDF
+#include <netcdf.h>
+#endif
+/*********************************************************************
+ void netcdf_error( int status )
+ status is the returning value of netcdf call. this routine will
+ handle the error when status is not NC_NOERR.
+********************************************************************/
+void handle_netcdf_error(const char *msg, int status )
+{
+ char errmsg[512];
+
+ sprintf( errmsg, "%s: %s", msg, nc_strerror(status) );
+ error_handler(errmsg);
+
+}; /* handle_netcdf_error */
+
+/***************************************************************************
+ void get_file_dir(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_dir(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_dir */
+
+
+int get_dimlen(const char* file, const char *name)
+{
+ int ncid, dimid, status, len;
+ size_t size;
+ char msg[512];
+#ifdef use_netCDF
+ status = nc_open(file, NC_NOWRITE, &ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in opening file %s", file);
+ handle_netcdf_error(msg, status);
+ }
+
+ status = nc_inq_dimid(ncid, name, &dimid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting dimid of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+
+ status = nc_inq_dimlen(ncid, dimid, &size);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting dimension size of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_close(ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in closing file %s.", file);
+ handle_netcdf_error(msg, status);
+ }
+
+ len = size;
+ if(status != NC_NOERR) {
+ sprintf(msg, "in closing file ", file);
+ handle_netcdf_error(msg, status);
+ }
+#else
+ error_handler("read_mosaic: Add flag -Duse_netCDF when compiling");
+#endif
+
+ return len;
+
+}; /* get_dimlen */
+
+/*******************************************************************************
+ void get_string_data(const char *file, const char *name, char *data)
+ get string data of field with "name" from "file".
+******************************************************************************/
+void get_string_data(const char *file, const char *name, char *data)
+{
+ int ncid, varid, status;
+ char msg[512];
+
+#ifdef use_netCDF
+ status = nc_open(file, NC_NOWRITE, &ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in opening file %s", file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_inq_varid(ncid, name, &varid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting varid of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_get_var_text(ncid, varid, data);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting data of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_close(ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in closing file %s.", file);
+ handle_netcdf_error(msg, status);
+ }
+#else
+ error_handler("read_mosaic: Add flag -Duse_netCDF when compiling");
+#endif
+
+}; /* get_string_data */
+
+/*******************************************************************************
+ void get_string_data_level(const char *file, const char *name, const size_t *start, const size_t *nread, char *data)
+ get string data of field with "name" from "file".
+******************************************************************************/
+void get_string_data_level(const char *file, const char *name, char *data, const int *level)
+{
+ int ncid, varid, status, i;
+ size_t start[4], nread[4];
+ char msg[512];
+
+#ifdef use_netCDF
+ status = nc_open(file, NC_NOWRITE, &ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in opening file %s", file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_inq_varid(ncid, name, &varid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting varid of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ for(i=0; i<4; i++) {
+ start[i] = 0; nread[i] = 1;
+ }
+ start[0] = *level; nread[1] = STRING;
+ status = nc_get_vara_text(ncid, varid, start, nread, data);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting data of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_close(ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in closing file %s.", file);
+ handle_netcdf_error(msg, status);
+ }
+#else
+ error_handler("read_mosaic: Add flag -Duse_netCDF when compiling");
+#endif
+
+}; /* get_string_data_level */
+
+
+/*******************************************************************************
+ void get_int_data(const char *file, const char *name, int *data)
+ get int data of field with "name" from "file".
+******************************************************************************/
+void get_int_data(const char *file, const char *name, int *data)
+{
+ int ncid, varid, status;
+ char msg[512];
+
+#ifdef use_netCDF
+ status = nc_open(file, NC_NOWRITE, &ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in opening file %s", file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_inq_varid(ncid, name, &varid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting varid of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_get_var_int(ncid, varid, data);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting data of %s from file %s", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_close(ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in closing file %s.", file);
+ handle_netcdf_error(msg, status);
+ }
+#else
+ error_handler("read_mosaic: Add flag -Duse_netCDF when compiling");
+#endif
+
+}; /* get_int_data */
+
+/*******************************************************************************
+ void get_double_data(const char *file, const char *name, double *data)
+ get double data of field with "name" from "file".
+******************************************************************************/
+void get_double_data(const char *file, const char *name, double *data)
+{
+
+ int ncid, varid, status;
+ char msg[512];
+
+#ifdef use_netCDF
+ status = nc_open(file, NC_NOWRITE, &ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in opening file ", file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_inq_varid(ncid, name, &varid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting varid of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_get_var_double(ncid, varid, data);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting data of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_close(ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in closing file %s.", file);
+ handle_netcdf_error(msg, status);
+ }
+#else
+ error_handler("read_mosaic: Add flag -Duse_netCDF when compiling");
+#endif
+
+}; /* get_double_data */
+
+/******************************************************************************
+ void get_var_text_att(const char *file, const char *name, const char *attname, char *att)
+ get text attribute of field 'name' from 'file
+******************************************************************************/
+void get_var_text_att(const char *file, const char *name, const char *attname, char *att)
+{
+ int ncid, varid, status;
+ char msg[512];
+
+#ifdef use_netCDF
+ status = nc_open(file, NC_NOWRITE, &ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in opening file ", file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_inq_varid(ncid, name, &varid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting varid of %s from file %s.", name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_get_att_text(ncid, varid, attname, att);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in getting attribute %s of %s from file %s.", attname, name, file);
+ handle_netcdf_error(msg, status);
+ }
+ status = nc_close(ncid);
+ if(status != NC_NOERR) {
+ sprintf(msg, "in closing file %s.", file);
+ handle_netcdf_error(msg, status);
+ }
+#else
+ error_handler("read_mosaic: Add flag -Duse_netCDF when compiling");
+#endif
+
+}; /* get_var_text_att */
+
+/***********************************************************************
+ return number of overlapping cells.
+***********************************************************************/
+#ifndef __AIX
+int read_mosaic_xgrid_size_( const char *xgrid_file )
+{
+ return read_mosaic_xgrid_size(xgrid_file);
+}
+#endif
+
+int read_mosaic_xgrid_size( const char *xgrid_file )
+{
+ int ncells;
+
+ ncells = get_dimlen(xgrid_file, "ncells");
+ return ncells;
+}
+
+
+
+/****************************************************************************/
+#ifndef __AIX
+void read_mosaic_xgrid_order1_(const char *xgrid_file, int *i1, int *j1, int *i2, int *j2, double *area )
+{
+ read_mosaic_xgrid_order1(xgrid_file, i1, j1, i2, j2, area);
+
+};
+#endif
+
+void read_mosaic_xgrid_order1(const char *xgrid_file, int *i1, int *j1, int *i2, int *j2, double *area )
+{
+ int ncells, n;
+ int *tile1_cell, *tile2_cell;
+ double garea;
+
+ ncells = get_dimlen(xgrid_file, "ncells");
+
+ tile1_cell = (int *)malloc(ncells*2*sizeof(int));
+ tile2_cell = (int *)malloc(ncells*2*sizeof(int));
+ get_int_data(xgrid_file, "tile1_cell", tile1_cell);
+ get_int_data(xgrid_file, "tile2_cell", tile2_cell);
+ get_double_data(xgrid_file, "xgrid_area", area);
+ garea = 4*M_PI*RADIUS*RADIUS;
+
+ for(n=0; n<ncells; n++) {
+ i1[n] = tile1_cell[n*2] - 1;
+ j1[n] = tile1_cell[n*2+1] - 1;
+ i2[n] = tile2_cell[n*2] - 1;
+ j2[n] = tile2_cell[n*2+1] - 1;
+ area[n] /= garea; /* rescale the exchange grid area to unit earth area */
+ }
+
+ free(tile1_cell);
+ free(tile2_cell);
+
+}; /* read_mosaic_xgrid_order1 */
+
+/* NOTE: di, dj is for tile1, */
+/****************************************************************************/
+#ifndef __AIX
+void read_mosaic_xgrid_order2_(const char *xgrid_file, int *i1, int *j1, int *i2, int *j2, double *area, double *di, double *dj )
+{
+ read_mosaic_xgrid_order2(xgrid_file, i1, j1, i2, j2, area, di, dj);
+
+};
+#endif
+
+void read_mosaic_xgrid_order2(const char *xgrid_file, int *i1, int *j1, int *i2, int *j2, double *area, double *di, double *dj )
+{
+ int ncells, n;
+ int *tile1_cell, *tile2_cell;
+ double *tile1_distance;
+ double garea;
+
+ ncells = get_dimlen(xgrid_file, "ncells");
+
+ tile1_cell = (int *)malloc(ncells*2*sizeof(int ));
+ tile2_cell = (int *)malloc(ncells*2*sizeof(int ));
+ tile1_distance = (double *)malloc(ncells*2*sizeof(double));
+ get_int_data(xgrid_file, "tile1_cell", tile1_cell);
+ get_int_data(xgrid_file, "tile2_cell", tile2_cell);
+ get_double_data(xgrid_file, "xgrid_area", area);
+ get_double_data(xgrid_file, "tile1_distance", tile1_distance);
+ garea = 4*M_PI*RADIUS*RADIUS;
+
+ for(n=0; n<ncells; n++) {
+ i1[n] = tile1_cell[n*2] - 1;
+ j1[n] = tile1_cell[n*2+1] - 1;
+ i2[n] = tile2_cell[n*2] - 1;
+ j2[n] = tile2_cell[n*2+1] - 1;
+ di[n] = tile1_distance[n*2];
+ dj[n] = tile1_distance[n*2+1];
+ area[n] /= garea; /* rescale the exchange grid area to unit earth area */
+ }
+
+ free(tile1_cell);
+ free(tile2_cell);
+ free(tile1_distance);
+
+}; /* read_mosaic_xgrid_order2 */
+
+/******************************************************************************
+ int read_mosaic_ntiles(const char *mosaic_file)
+ return number tiles in mosaic_file
+******************************************************************************/
+#ifndef __AIX
+int read_mosaic_ntiles_(const char *mosaic_file)
+{
+ return read_mosaic_ntiles(mosaic_file);
+}
+#endif
+int read_mosaic_ntiles(const char *mosaic_file)
+{
+
+ int ntiles;
+
+ ntiles = get_dimlen(mosaic_file, "ntiles");
+
+ return ntiles;
+
+}; /* read_mosaic_ntiles */
+
+/******************************************************************************
+ int read_mosaic_ncontacts(const char *mosaic_file)
+ return number of contacts in mosaic_file
+******************************************************************************/
+#ifndef __AIX
+int read_mosaic_ncontacts_(const char *mosaic_file)
+{
+ return read_mosaic_ncontacts(mosaic_file);
+}
+#endif
+int read_mosaic_ncontacts(const char *mosaic_file)
+{
+
+ int ncontacts;
+
+ ncontacts = get_dimlen(mosaic_file, "ncontact");
+
+ return ncontacts;
+
+}; /* read_mosaic_ncontacts */
+
+
+/*****************************************************************************
+ void read_mosaic_grid_sizes(const char *mosaic_file, int *nx, int *ny)
+ read mosaic grid size of each tile, currently we are assuming the refinement is 2.
+ We assume the grid files are located at the same directory as mosaic_file.
+*****************************************************************************/
+#ifndef __AIX
+void read_mosaic_grid_sizes_(const char *mosaic_file, int *nx, int *ny)
+{
+ read_mosaic_grid_sizes(mosaic_file, nx, ny);
+}
+#endif
+void read_mosaic_grid_sizes(const char *mosaic_file, int *nx, int *ny)
+{
+ int ntiles, n;
+ char gridfile[STRING], tilefile[2*STRING];
+ char dir[STRING];
+ const int x_refine = 2, y_refine = 2;
+
+ get_file_dir(mosaic_file, dir);
+ ntiles = get_dimlen(mosaic_file, "ntiles");
+ for(n = 0; n < ntiles; n++) {
+ get_string_data_level(mosaic_file, "gridfiles", gridfile, &n);
+ sprintf(tilefile, "%s/%s", dir, gridfile);
+ nx[n] = get_dimlen(tilefile, "nx");
+ ny[n] = get_dimlen(tilefile, "ny");
+ if(nx[n]%x_refine != 0) error_handler("Error from read_mosaic_grid_sizes: nx is not divided by x_refine");
+ if(ny[n]%y_refine != 0) error_handler("Error from read_mosaic_grid_sizes: ny is not divided by y_refine");
+ nx[n] /= x_refine;
+ ny[n] /= y_refine;
+ }
+
+}; /* read_mosaic_grid_sizes */
+
+
+/******************************************************************************
+ void read_mosaic_contact(const char *mosaic_file)
+ read mosaic contact information
+******************************************************************************/
+#ifndef __AIX
+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)
+{
+ read_mosaic_contact(mosaic_file, tile1, tile2, istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2);
+}
+#endif
+
+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 **gridtiles;
+#define MAXVAR 40
+ char pstring[MAXVAR][STRING];
+ int ntiles, ncontacts, n, m, l, nstr, found;
+ const int x_refine = 2, y_refine = 2;
+
+ 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);
+ }
+
+ ncontacts = get_dimlen(mosaic_file, "ncontact");
+ for(n = 0; n < ncontacts; n++) {
+ get_string_data_level(mosaic_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 "
+ "in contact seperated by :/:: should be 4");
+ found = 0;
+ for(m=0; m<ntiles; m++) {
+ if(strcmp(gridtiles[m], pstring[1]) == 0) { /*found the tile name */
+ found = 1;
+ tile1[n] = m+1;
+ break;
+ }
+ }
+ if(!found) error_handler("error from read_mosaic: the first tile name specified "
+ "in contact is not found in tile list");
+ found = 0;
+ for(m=0; m<ntiles; m++) {
+ if(strcmp(gridtiles[m], pstring[3]) == 0) { /*found the tile name */
+ found = 1;
+ tile2[n] = m+1;
+ break;
+ }
+ }
+ 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);
+ /* 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 "
+ "in contact_index seperated by :/, should be 8");
+ /* make sure the string is only composed of numbers */
+ for(m=0; m<nstr; m++) for(l=0; l<strlen(pstring[m]); l++) {
+ if(pstring[m][l] > '9' || pstring[m][l] < '0' ) {
+ error_handler("Error from read_mosaic: some of the character in "
+ "contact_indices except token is not digit number");
+ }
+ }
+ istart1[n] = atoi(pstring[0]);
+ iend1[n] = atoi(pstring[1]);
+ jstart1[n] = atoi(pstring[2]);
+ jend1[n] = atoi(pstring[3]);
+ istart2[n] = atoi(pstring[4]);
+ iend2[n] = atoi(pstring[5]);
+ jstart2[n] = atoi(pstring[6]);
+ jend2[n] = atoi(pstring[7]);
+ if(istart1[n] == iend1[n] ) {
+ istart1[n] = (istart1[n]+1)/x_refine-1;
+ iend1[n] = istart1[n];
+ if( jend1[n] > jstart1[n] ) {
+ jstart1[n] -= 1;
+ jend1[n] -= y_refine;
+ }
+ else if( jend1[n] < jstart1[n] ) {
+ jstart1[n] -= y_refine;
+ jend1[n] -= 1;
+ }
+ else
+ error_handler("Error from read_mosaic_contact: jstart1 and jend1 should not be equal when istart1=iend1");
+
+ if(jstart1[n]%y_refine || jend1[n]%y_refine)
+ error_handler("Error from read_mosaic_contact: mismatch between y_refine and jstart1/jend1 when istart1=iend1");
+ jstart1[n] /= y_refine;
+ jend1[n] /= y_refine;
+ }
+ else if( jstart1[n] == jend1[n] ) {
+ jstart1[n] = (jstart1[n]+1)/y_refine-1;
+ jend1[n] = jstart1[n];
+ if(iend1[n] > istart1[n] ) {
+ istart1[n] -= 1;
+ iend1[n] -= x_refine;
+ }
+ else if(istart1[n] > iend1[n] ) {
+ istart1[n] -= x_refine;
+ iend1[n] -= 1;
+ }
+ else
+ error_handler("Error from read_mosaic_contact: istart1 and iend1 should not be equal when jstart1=jend1");
+
+ if(istart1[n]%x_refine || iend1[n]%x_refine)
+ error_handler("Error from read_mosaic_contact: mismatch between x_refine and istart1/iend1 when jstart1=jend1");
+ istart1[n] /= x_refine;
+ iend1[n] /= x_refine;
+ }
+ else {
+ error_handler("Error from read_mosaic_contact: only line contact is supported now, contact developer");
+ }
+ if(istart2[n] == iend2[n] ) {
+ istart2[n] = (istart2[n]+1)/x_refine-1;
+ iend2[n] = istart2[n];
+ if( jend2[n] > jstart2[n] ) {
+ jstart2[n] -= 1;
+ jend2[n] -= y_refine;
+ }
+ else if( jstart2[n] > jend2[n] ) {
+ jstart2[n] -= y_refine;
+ jend2[n] -= 1;
+ }
+ else
+ error_handler("Error from read_mosaic_contact: jstart2 and jend2 should not be equal when istart2=iend2");
+
+ if(jstart2[n]%y_refine || jend2[n]%y_refine )
+ error_handler("Error from read_mosaic_contact: mismatch between y_refine and jstart2/jend2 when istart2=iend2");
+
+ jstart2[n] /= y_refine;
+ jend2[n] /= y_refine;
+ }
+ else if( jstart2[n] == jend2[n] ) {
+ jstart2[n] = (jstart2[n]+1)/y_refine-1;
+ jend2[n] = jstart2[n];
+ if(iend2[n] > istart2[n] ) {
+ istart2[n] -= 1;
+ iend2[n] -= x_refine;
+ }
+ else if(istart2[n] > iend2[n] ) {
+ istart2[n] -= x_refine;
+ iend2[n] -= 1;
+ }
+ else
+ error_handler("Error from read_mosaic_contact: istart2 and iend2 should not be equal when jstart2=jend2");
+
+ if(istart2[n]%x_refine || iend2[n]%x_refine)
+ error_handler("Error from read_mosaic_contact: mismatch between x_refine and istart2/iend2 when jstart2=jend2");
+ istart2[n] /= x_refine;
+ iend2[n] /= x_refine;
+ }
+ else {
+ error_handler("Error from read_mosaic_contact: only line contact is supported now, contact developer");
+ }
+
+ }
+
+}; /* read_mosaic_contact */
+
+
+/******************************************************************************
+ void read_mosaic_grid_data(const char *mosaic_file, const char *name, int nx, int ny,
+ double *data, int level, int ioff, int joff)
+ read mosaic grid information onto model grid. We assume the refinement is 2 right now.
+ We may remove this restriction in the future. nx and ny are model grid size. level
+ is the tile number. ioff and joff to indicate grid location. ioff =0 and joff = 0
+ for C-cell. ioff=0 and joff=1 for E-cell, ioff=1 and joff=0 for N-cell,
+ ioff=1 and joff=1 for T-cell
+******************************************************************************/
+void read_mosaic_grid_data(const char *mosaic_file, const char *name, int nx, int ny,
+ double *data, int level, int ioff, int joff)
+{
+ char tilefile[STRING], gridfile[STRING], dir[STRING];
+ double *tmp;
+ int ni, nj, nxp, nyp, i, j;
+
+ get_file_dir(mosaic_file, dir);
+
+ get_string_data_level(mosaic_file, "gridfiles", gridfile, &level);
+ sprintf(tilefile, "%s/%s", dir, gridfile);
+
+ ni = get_dimlen(tilefile, "nx");
+ nj = get_dimlen(tilefile, "ny");
+
+ if( ni != nx*2 || nj != ny*2) error_handler("supergrid size should be double of the model grid size");
+ tmp = (double *)malloc((ni+1)*(nj+1)*sizeof(double));
+ get_double_data( tilefile, name, tmp);
+ nxp = nx + 1 - ioff;
+ nyp = ny + 1 - joff;
+ for(j=0; j<nyp; j++) for(i=0; i<nxp; i++) data[j*nxp+i] = tmp[(2*j+joff)*(ni+1)+2*i+ioff];
+ free(tmp);
+
+}; /* read_mosaic_grid_data */
+
+
diff --git a/gridspec_tools_20080702/shared/mosaic/read_mosaic.h b/gridspec_tools_20080702/shared/mosaic/read_mosaic.h
new file mode 100644
index 0000000..b698cc6
--- /dev/null
+++ b/gridspec_tools_20080702/shared/mosaic/read_mosaic.h
@@ -0,0 +1,15 @@
+#ifndef READ_MOSAIC_H_
+#define READ_MOSAIC_H_
+
+int read_mosaic_xgrid_size( const char *xgrid_file );
+void read_mosaic_xgrid_order1(const char *xgrid_file, int *i1, int *j1, int *i2, int *j2, double *area );
+void read_mosaic_xgrid_order2(const char *xgrid_file, int *i1, int *j1, int *i2, int *j2,
+ double *area, double *di, double *dj );
+int read_mosaic_ntiles(const char *mosaic_file);
+int read_mosaic_ncontacts(const char *mosaic_file);
+void read_mosaic_grid_sizes(const char *mosaic_file, int *nx, int *ny);
+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);
+void read_mosaic_grid_data(const char *mosaic_file, const char *name, int nx, int ny,
+ double *data, int level, int ioff, int joff);
+#endif
diff --git a/gridspec_tools_20080702/tools/Makefile.am b/gridspec_tools_20080702/tools/Makefile.am
new file mode 100644
index 0000000..61da840
--- /dev/null
+++ b/gridspec_tools_20080702/tools/Makefile.am
@@ -0,0 +1,2 @@
+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/Makefile.in b/gridspec_tools_20080702/tools/Makefile.in
new file mode 100644
index 0000000..1391d7f
--- /dev/null
+++ b/gridspec_tools_20080702/tools/Makefile.in
@@ -0,0 +1,508 @@
+# 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@
+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@
+subdir = gridspec_tools_20080702/tools
+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 =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+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@
+SUBDIRS = shared make_hgrid make_solo_mosaic make_coupler_mosaic \
+make_topog make_vgrid river_regrid transfer_to_mosaic_grid fregrid
+
+all: all-recursive
+
+.SUFFIXES:
+$(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/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/tools/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
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (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); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ 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: 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" \
+ || $(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
+ 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 && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+ install-strip
+
+.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
+
+# 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/Makefile.am b/gridspec_tools_20080702/tools/fregrid/Makefile.am
new file mode 100644
index 0000000..fedd3ec
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/Makefile.am
@@ -0,0 +1,45 @@
+## 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/Makefile.in b/gridspec_tools_20080702/tools/fregrid/Makefile.in
new file mode 100644
index 0000000..c6fb3bc
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/Makefile.in
@@ -0,0 +1,537 @@
+# 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
+# fregrid tool.
+
+# $Id: Makefile.am,v 1.2 2009/04/06 22:21:10 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 = fregrid$(EXEEXT) gs_fregrid$(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/fregrid
+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_fregrid_OBJECTS = bilinear_interp.$(OBJEXT) \
+ conserve_interp.$(OBJEXT) fregrid.$(OBJEXT) \
+ fregrid_util.$(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)
+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 = $(fregrid_SOURCES) $(gs_fregrid_SOURCES)
+DIST_SOURCES = $(fregrid_SOURCES) $(gs_fregrid_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@
+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__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/fregrid/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/tools/fregrid/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
+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)
+
+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@
+ at 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:
+ 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/fregrid/bilinear_interp.c b/gridspec_tools_20080702/tools/fregrid/bilinear_interp.c
new file mode 100644
index 0000000..337b2da
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/bilinear_interp.c
@@ -0,0 +1,1131 @@
+#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/fregrid/bilinear_interp.h b/gridspec_tools_20080702/tools/fregrid/bilinear_interp.h
new file mode 100644
index 0000000..faead20
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/bilinear_interp.h
@@ -0,0 +1,10 @@
+#ifndef BILINEAR_INTERP_H_
+#define BILINEAR_INTERP_H_
+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);
+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);
+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);
+#endif
diff --git a/gridspec_tools_20080702/tools/fregrid/conserve_interp.c b/gridspec_tools_20080702/tools/fregrid/conserve_interp.c
new file mode 100644
index 0000000..05d714d
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/conserve_interp.c
@@ -0,0 +1,689 @@
+#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/conserve_interp.h b/gridspec_tools_20080702/tools/fregrid/conserve_interp.h
new file mode 100644
index 0000000..3e61df5
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/conserve_interp.h
@@ -0,0 +1,13 @@
+#ifndef CONSERVE_INTERP_H_
+#define CONSERVE_INTERP_H_
+#include "globals.h"
+
+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);
+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);
+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);
+#endif
diff --git a/gridspec_tools_20080702/tools/fregrid/fregrid.c b/gridspec_tools_20080702/tools/fregrid/fregrid.c
new file mode 100644
index 0000000..bbc88e8
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/fregrid.c
@@ -0,0 +1,668 @@
+#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;
+
+ 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);
+ }
+ /* 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
+ 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]);
+ }
+
+ /* 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);
+ }
+ }
+ }
+
+ mpp_end();
+ return 0;
+
+} /* end of main */
+
+
+
+
diff --git a/gridspec_tools_20080702/tools/fregrid/fregrid_util.c b/gridspec_tools_20080702/tools/fregrid/fregrid_util.c
new file mode 100644
index 0000000..2e12176
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/fregrid_util.c
@@ -0,0 +1,1597 @@
+#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/fregrid/fregrid_util.h b/gridspec_tools_20080702/tools/fregrid/fregrid_util.h
new file mode 100644
index 0000000..12b390e
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/fregrid_util.h
@@ -0,0 +1,28 @@
+#ifndef FREGRID_UTIL_H_
+#define FREGRID_UTIL_H_
+#include "globals.h"
+void set_mosaic_data_file(int ntiles, const char *mosaic_file, const char *dir, File_config *file,
+ const char *filename);
+void set_field_struct(int ntiles, Field_config *field, int nvar, char * varname, File_config *file);
+void get_input_grid(int ntiles, Grid_config *grid, Bound_config *bound, const char *mosaic_file, unsigned int opcode);
+void get_output_grid_from_mosaic(int ntiles, Grid_config *grid, const char *mosaic_file, unsigned int opcode);
+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);
+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);
+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);
+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_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);
+
+#endif
diff --git a/gridspec_tools_20080702/tools/fregrid/globals.h b/gridspec_tools_20080702/tools/fregrid/globals.h
new file mode 100644
index 0000000..f58f54f
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/globals.h
@@ -0,0 +1,166 @@
+#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
new file mode 100644
index 0000000..ba34f74
--- /dev/null
+++ b/gridspec_tools_20080702/tools/fregrid/gs_fregrid.c
@@ -0,0 +1,416 @@
+#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
new file mode 100644
index 0000000..6b4d280
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.am
@@ -0,0 +1,41 @@
+## 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/Makefile.in b/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.in
new file mode 100644
index 0000000..507aaa0
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_coupler_mosaic/Makefile.in
@@ -0,0 +1,527 @@
+# 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_coupler_mosaic tool.
+
+# $Id: Makefile.am,v 1.2 2009/04/07 15:14:47 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_coupler_mosaic$(EXEEXT) \
+ gs_make_coupler_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_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 \
+ $(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_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)
+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_coupler_mosaic_SOURCES) \
+ $(make_coupler_mosaic_SOURCES)
+DIST_SOURCES = $(gs_make_coupler_mosaic_SOURCES) \
+ $(make_coupler_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_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_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_coupler_mosaic/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/tools/make_coupler_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_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)
+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)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gs_make_coupler_mosaic.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_coupler_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_coupler_mosaic/gs_make_coupler_mosaic.c b/gridspec_tools_20080702/tools/make_coupler_mosaic/gs_make_coupler_mosaic.c
new file mode 100644
index 0000000..60f1a88
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_coupler_mosaic/gs_make_coupler_mosaic.c
@@ -0,0 +1,218 @@
+/*
+ * 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
new file mode 100644
index 0000000..493d85a
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_coupler_mosaic/make_coupler_mosaic.c
@@ -0,0 +1,2005 @@
+/*
+ * 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
new file mode 100644
index 0000000..5583a38
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/Makefile.am
@@ -0,0 +1,45 @@
+## 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/Makefile.in b/gridspec_tools_20080702/tools/make_hgrid/Makefile.in
new file mode 100644
index 0000000..f374e5d
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/Makefile.in
@@ -0,0 +1,540 @@
+# 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_hgrid
+# tools.
+
+# $Id: Makefile.am,v 1.3 2009/04/04 11:22:53 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_hgrid$(EXEEXT) gs_make_hgrid$(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_hgrid
+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_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__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)
+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_hgrid_SOURCES) $(make_hgrid_SOURCES)
+DIST_SOURCES = $(gs_make_hgrid_SOURCES) $(make_hgrid_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_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__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_hgrid/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/tools/make_hgrid/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_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)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+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@
+
+.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_hgrid/create_conformal_cubic_grid.c b/gridspec_tools_20080702/tools/make_hgrid/create_conformal_cubic_grid.c
new file mode 100644
index 0000000..b044ea7
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/create_conformal_cubic_grid.c
@@ -0,0 +1,814 @@
+#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_gnomonic_cubic_grid.c b/gridspec_tools_20080702/tools/make_hgrid/create_gnomonic_cubic_grid.c
new file mode 100644
index 0000000..8d37c16
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/create_gnomonic_cubic_grid.c
@@ -0,0 +1,907 @@
+#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/make_hgrid/create_grid_from_file.c b/gridspec_tools_20080702/tools/make_hgrid/create_grid_from_file.c
new file mode 100644
index 0000000..3dc60cc
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/create_grid_from_file.c
@@ -0,0 +1,152 @@
+#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/make_hgrid/create_hgrid.h b/gridspec_tools_20080702/tools/make_hgrid/create_hgrid.h
new file mode 100644
index 0000000..88ac844
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/create_hgrid.h
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ create_hgrid.h
+ This header file provide interface to create different types of horizontal
+ grid. geographical grid location, cell length, cell area and rotation
+ angle are returned. All the returned data are on supergrid.
+
+ contact: Zhi.Liang at noaa.gov
+
+*******************************************************************************/
+#ifdef 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 );
+
+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 );
+
+void create_grid_from_file( char *file, int *nlon, int *nlat, double *x, double *y, double *dx, double *dy,
+ double *area, double *angle_dx );
+
+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 );
+
+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 );
+
+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 );
+
+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 );
+#endif
diff --git a/gridspec_tools_20080702/tools/make_hgrid/create_lonlat_grid.c b/gridspec_tools_20080702/tools/make_hgrid/create_lonlat_grid.c
new file mode 100644
index 0000000..f562c69
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/create_lonlat_grid.c
@@ -0,0 +1,406 @@
+#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/gs_make_hgrid.c b/gridspec_tools_20080702/tools/make_hgrid/gs_make_hgrid.c
new file mode 100644
index 0000000..db3c309
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/gs_make_hgrid.c
@@ -0,0 +1,340 @@
+#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"
+
+#define MAXBOUNDS 100
+#define STRINGLEN 255
+
+/* char grid_version[] = "0.2"; */
+/* char tagname[] = "$Name: $"; */
+
+char *usage[] = {
+ "",
+ " ",
+ " ",
+ " Usage of gs_make_hgrid ",
+ " ",
+ " gs_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 };
+
+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;
+ int ret;
+
+ 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);
+
+ /* Do everything. */
+ if ((ret = gs_make_hgrid(grid_type, entry, nxbnds0, nybnds0, nxbnds1,
+ nybnds1, nxbnds2, nybnds2, lat_join, nratio, simple_dx,
+ simple_dy, ntilex, ntiley, gridname, center)))
+ return ret;
+
+ 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_hgrid/make_hgrid.c b/gridspec_tools_20080702/tools/make_hgrid/make_hgrid.c
new file mode 100644
index 0000000..f321564
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_hgrid/make_hgrid.c
@@ -0,0 +1,626 @@
+#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
new file mode 100644
index 0000000..1ce167f
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.am
@@ -0,0 +1,43 @@
+## 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
new file mode 100644
index 0000000..d9c8ca6
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_solo_mosaic/Makefile.in
@@ -0,0 +1,532 @@
+# 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
new file mode 100644
index 0000000..43a977a
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.c
@@ -0,0 +1,326 @@
+#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
new file mode 100644
index 0000000..c881609
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_solo_mosaic/get_contact.h
@@ -0,0 +1,13 @@
+#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
new file mode 100644
index 0000000..748ddfb
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_solo_mosaic/gs_make_solo_mosaic.c
@@ -0,0 +1,152 @@
+#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
new file mode 100644
index 0000000..3f7bf27
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_solo_mosaic/make_solo_mosaic.c
@@ -0,0 +1,287 @@
+#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
new file mode 100644
index 0000000..4a39d34
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_topog/Makefile.am
@@ -0,0 +1,41 @@
+## 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/Makefile.in b/gridspec_tools_20080702/tools/make_topog/Makefile.in
new file mode 100644
index 0000000..85fc7a2
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_topog/Makefile.in
@@ -0,0 +1,524 @@
+# 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_topog tool.
+
+# $Id: Makefile.am,v 1.2 2009/04/07 22:02:40 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_topog$(EXEEXT) gs_make_topog$(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_topog
+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_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)
+make_topog_OBJECTS = $(am_make_topog_OBJECTS)
+make_topog_LDADD = $(LDADD)
+make_topog_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_topog_SOURCES) $(make_topog_SOURCES)
+DIST_SOURCES = $(gs_make_topog_SOURCES) $(make_topog_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_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__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_topog/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/tools/make_topog/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_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)
+make_topog$(EXEEXT): $(make_topog_OBJECTS) $(make_topog_DEPENDENCIES)
+ @rm -f make_topog$(EXEEXT)
+ $(LINK) $(make_topog_OBJECTS) $(make_topog_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at 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:
+ 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_topog/make_topog.c b/gridspec_tools_20080702/tools/make_topog/make_topog.c
new file mode 100644
index 0000000..c030a85
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_topog/make_topog.c
@@ -0,0 +1,511 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <string.h>
+#include "topog.h"
+#include "mpp.h"
+#include "mpp_domain.h"
+#include "mpp_io.h"
+#include "tool_util.h"
+
+char *usage[] = {
+ "",
+ " ",
+ " ",
+ " Usage of make_topog ",
+ " ",
+ " make_topog --mosaic mosaic_file [--topog_type topog_type] [x_refine #] [y_refine #] ",
+ " [--basin_depth #] [--bottom_depth #] [--min_depth #] ",
+ " [--topog_file topog_file] [--topog_field topog_field] ",
+ " [--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] ",
+ " [--output output_file [--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 ",
+ " 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. ",
+ " Below specify the option (required or non-required) needed for every kind ",
+ " of topog_type. when topog_type (--topog_type) is ",
+ " ",
+ " 1. 'realistic': --topog_file and --topog_field must be specified, ",
+ " --bottom_depth, --min_depth, --scale_factor, ",
+ " --num_filter_pass, --flat_bottom ",
+ " --fill_first_row --adjust_topo --filter_topog ",
+ " --round_shallow] --fill_shallow --deepen_shallow] ",
+ " --smooth_topo_allow_deepening are optional arguments. ",
+ " 2. 'rectangular_basin': --basin_depth are optional arguments. Set basin_depth ",
+ " to 0 to get all land topography. ",
+ " 3. 'gaussian': --bottom_depth, --min_depth --gauss_amp, --gauss_scale, ",
+ " --slope_x, --slope_y are optional arguments. ",
+ " 4.. 'bowl': --bottom_depth, --min_depth, --bowl_south, --bowl_north, ",
+ " --bowl_west, --bowl_east are optional arguments. ",
+ " 5. 'idealized': --bottom_depth, --min_depth are optional arguments. ",
+ " ",
+ " generate_mosaic_topo take the following flags ",
+ " ",
+ " --mosaic mosaic_file Specify the mosaic file where topography data located. ",
+ " ",
+ " --topog_type topog_type Specify type of topography. Its value can be ",
+ " 'realistic', 'rectangular_basin', 'gaussian', 'bowl' ",
+ " or 'idealized'. The default value is 'realistic'. ",
+ " ",
+ " --x_refine # specify the refinement ratio of model grid vs supergrid ",
+ " ins x-directin. default value 2. ",
+ " ",
+ " --y_refine # specify the refinement ratio of model grid vs supergrid ",
+ " ins y-directin. default value 2. ",
+ " ",
+ " --basin_depth # Specify the basin depth when topog_type is ",
+ " 'rectangular_basin'. Default value is 5000 meter. ",
+ " ",
+ " --topog_file topog_file Specify name of topograhy file (e.g. scripps, ",
+ " navy_topo, ...) ",
+ " ",
+ " --topog_field topog_field Specify name of topography field name in topog_file. ",
+ " ",
+ " --bottom_depth # Specify maximum depth (or bottom depth) of ocean. ",
+ " default value is 5000 meter. ",
+ " ",
+ " --min_depth # Specify minimum depth of ocean. ",
+ " default value is 10 meter. ",
+ " ",
+ " --scale_factor # Specify 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 # Specify number of passes of spatial filter ",
+ " default value is 1. ",
+ " ",
+ " --gauss_amp # specify height of gaussian bump as percentage of ocean ",
+ " depth. default value is 0.5. ",
+ " ",
+ " --gauss_scale # Specify width of gaussian bump as percentag e of ",
+ " basin width. Default value is 0.25. ",
+ " ",
+ " --slope_x # Specify rise of the ocean floor to the east for ",
+ " the gaussian bump. Default value is 0. ",
+ " ",
+ " --slope_y # Specify rise of the ocean floor to the north for ",
+ " the gaussian bump. Default value is 0. ",
+ " ",
+ " --bowl_south # Specify southern boundary of Winton bowl. ",
+ " Default value is 60. ",
+ " ",
+ " --bowl_north # Specify northern boundary of Winton bowl. ",
+ " Default value is 70. ",
+ " ",
+ " --bowl_west # Specify western boundary of Winton bowl. ",
+ " Default value is 0. ",
+ " ",
+ " --bowl_east # Specify eastern boundary of Winton bowl. ",
+ " Default value is 20. ",
+ " ",
+ " --fill_first_row when specified, make first row of ocean model all ",
+ " land points for ice model. ",
+ " ",
+ " --filter_topog When specified, apply filter to topography. ",
+ " ",
+ " --round_shallow When specified, 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 output_file The created netcdf file that contains mosaic ",
+ " topography. Default value is 'topog.nc' ",
+ " --help Print out this message and then exit. ",
+ " ",
+ " Example ",
+ " ",
+ " 1. Generate '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 ",
+ " ",
+ " 2. Generate 'rectangular_basin' topography (with uniform topography 200 meters). ",
+ " > make_topog --mosaic mosaic.nc --topog_type rectangular_basin ",
+ " --basin_depth 200 ",
+ " ",
+ " "
+ "",
+ 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";
+ 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;
+ double gauss_amp = 0.5, gauss_scale = 0.25, slope_x = 0, slope_y = 0;
+ double bowl_south = 60, bowl_north = 70, bowl_west = 0, bowl_east = 20;
+ int flat_bottom = 0, fill_first_row = 0;
+ int filter_topog = 0, round_shallow = 0, fill_shallow = 0;
+ int deepen_shallow = 0, smooth_topo_allow_deepening = 0;
+ int errflg = (argc == 1);
+ int option_index, i, c;
+
+
+ /*
+ * process command line
+ */
+
+ static struct option long_options[] = {
+ {"mosaic", required_argument, NULL, 'a'},
+ {"topog_type", required_argument, NULL, 'b'},
+ {"x_refine", required_argument, NULL, 'X'},
+ {"y_refine", required_argument, NULL, 'Y'},
+ {"basin_depth", required_argument, NULL, 'c'},
+ {"topog_file", required_argument, NULL, 'd'},
+ {"topog_field", required_argument, NULL, 'e'},
+ {"bottom_depth", required_argument, NULL, 'f'},
+ {"min_depth", required_argument, NULL, 'g'},
+ {"scale_factor", required_argument, NULL, 'i'},
+ {"num_filter_pass", required_argument, NULL, 'j'},
+ {"gauss_amp", required_argument, NULL, 'k'},
+ {"gauss_scale", required_argument, NULL, 'l'},
+ {"slope_x", required_argument, NULL, 'm'},
+ {"slope_y", required_argument, NULL, 'n'},
+ {"bowl_south", required_argument, NULL, 'p'},
+ {"bowl_north", required_argument, NULL, 'q'},
+ {"bowl_west", required_argument, NULL, 'r'},
+ {"bowl_east", required_argument, NULL, 's'},
+ {"fill_first_row", no_argument, NULL, 't'},
+ {"filter_topog", no_argument, NULL, 'u'},
+ {"round_shallow", no_argument, NULL, 'v'},
+ {"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'},
+ {"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_file = optarg;
+ break;
+ case 'b':
+ strcpy(topog_type, optarg);
+ break;
+ case 'X':
+ x_refine = atoi(optarg);
+ break;
+ case 'Y':
+ y_refine = atoi(optarg);
+ break;
+ case 'c':
+ basin_depth = atof(optarg);
+ break;
+ case 'd':
+ topog_file = optarg;
+ break;
+ case 'e':
+ topog_field = optarg;
+ break;
+ case 'f':
+ bottom_depth = atof(optarg);
+ break;
+ case 'g':
+ min_depth = atof(optarg);
+ break;
+ case 'i':
+ scale_factor = atof(optarg);
+ break;
+ case 'j':
+ num_filter_pass = atoi(optarg);
+ break;
+ case 'k':
+ gauss_amp = atof(optarg);
+ break;
+ case 'l':
+ gauss_scale = atof(optarg);
+ break;
+ case 'm':
+ slope_x = atof(optarg);
+ break;
+ case 'n':
+ slope_y = atof(optarg);
+ break;
+ case 'p':
+ bowl_south = atof(optarg);
+ break;
+ case 'q':
+ bowl_north = atof(optarg);
+ break;
+ case 'r':
+ bowl_west = atof(optarg);
+ break;
+ case 's':
+ bowl_east = atof(optarg);
+ break;
+ case 't':
+ fill_first_row = 1;
+ break;
+ case 'u':
+ filter_topog = 1;
+ break;
+ case 'v':
+ round_shallow = 1;
+ break;
+ case 'w':
+ fill_shallow = 1;
+ break;
+ case 'x':
+ deepen_shallow = 1;
+ break;
+ case 'y':
+ smooth_topo_allow_deepening = 1;
+ break;
+ case 'o':
+ strcpy(output_file,optarg);
+ break;
+ case '?':
+ errflg++;
+ break;
+ }
+
+ if (errflg || !mosaic_file ) {
+ char **u = usage;
+ while (*u) { fprintf(stderr, "%s\n", *u); u++; }
+ exit(2);
+ }
+
+
+ /* 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);
+
+ 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");
+ }
+
+ {
+ 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);
+
+ /* 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);
+
+ mpp_end();
+
+ return 0;
+}; //main
diff --git a/gridspec_tools_20080702/tools/make_topog/topog.c b/gridspec_tools_20080702/tools/make_topog/topog.c
new file mode 100644
index 0000000..0f9e5a0
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_topog/topog.c
@@ -0,0 +1,542 @@
+#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_topog/topog.h b/gridspec_tools_20080702/tools/make_topog/topog.h
new file mode 100644
index 0000000..291710c
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_topog/topog.h
@@ -0,0 +1,14 @@
+void create_rectangular_topog(int nx, int ny, double basin_depth, double *depth);
+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);
+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);
+void create_idealized_topog( int nx, int ny, const double *x, const double *y,
+ double bottom_depth, double min_depth, double *depth);
+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 );
diff --git a/gridspec_tools_20080702/tools/make_vgrid/Makefile.am b/gridspec_tools_20080702/tools/make_vgrid/Makefile.am
new file mode 100644
index 0000000..665483d
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_vgrid/Makefile.am
@@ -0,0 +1,41 @@
+## 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/Makefile.in b/gridspec_tools_20080702/tools/make_vgrid/Makefile.in
new file mode 100644
index 0000000..31c9141
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_vgrid/Makefile.in
@@ -0,0 +1,526 @@
+# 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_vgrid 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 = make_vgrid$(EXEEXT) gs_make_vgrid$(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_vgrid
+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_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)
+make_vgrid_OBJECTS = $(am_make_vgrid_OBJECTS)
+make_vgrid_LDADD = $(LDADD)
+make_vgrid_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_vgrid_SOURCES) $(make_vgrid_SOURCES)
+DIST_SOURCES = $(gs_make_vgrid_SOURCES) $(make_vgrid_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_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__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_vgrid/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/tools/make_vgrid/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_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)
+make_vgrid$(EXEEXT): $(make_vgrid_OBJECTS) $(make_vgrid_DEPENDENCIES)
+ @rm -f make_vgrid$(EXEEXT)
+ $(LINK) $(make_vgrid_OBJECTS) $(make_vgrid_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+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@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/make_vgrid.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_vgrid/create_vgrid.c b/gridspec_tools_20080702/tools/make_vgrid/create_vgrid.c
new file mode 100644
index 0000000..6e84402
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_vgrid/create_vgrid.c
@@ -0,0 +1,43 @@
+#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/make_vgrid/create_vgrid.h b/gridspec_tools_20080702/tools/make_vgrid/create_vgrid.h
new file mode 100644
index 0000000..679f7d4
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_vgrid/create_vgrid.h
@@ -0,0 +1,11 @@
+/***********************************************************************
+ creater_vgrid.h
+ This header file contains interface to create vertical grid on supergrid.
+ refinement =2 is assumed in this routine.
+ contact: Zhi.Liang at noaa.gov
+************************************************************************/
+
+#ifndef CREATE_VGRID_H_
+#define CREATE_VGRID_H_
+void create_vgrid(int nbnds, double *bnds, int *nz, double *zeta, const char *center);
+#endif
diff --git a/gridspec_tools_20080702/tools/make_vgrid/gs_make_vgrid.c b/gridspec_tools_20080702/tools/make_vgrid/gs_make_vgrid.c
new file mode 100644
index 0000000..0ff8321
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_vgrid/gs_make_vgrid.c
@@ -0,0 +1,133 @@
+#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;
+ int ret;
+
+ 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") ;
+ }
+
+ /* 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 ((ret = gs_make_vgrid(history, nbnds, n1, n2, gridname, center)))
+ return ret;
+
+ mpp_end();
+
+ return 0;
+}
diff --git a/gridspec_tools_20080702/tools/make_vgrid/make_vgrid.c b/gridspec_tools_20080702/tools/make_vgrid/make_vgrid.c
new file mode 100644
index 0000000..987a682
--- /dev/null
+++ b/gridspec_tools_20080702/tools/make_vgrid/make_vgrid.c
@@ -0,0 +1,162 @@
+#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
new file mode 100644
index 0000000..f2d1a67
--- /dev/null
+++ b/gridspec_tools_20080702/tools/river_regrid/Makefile.am
@@ -0,0 +1,41 @@
+## 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
new file mode 100644
index 0000000..b6583b5
--- /dev/null
+++ b/gridspec_tools_20080702/tools/river_regrid/Makefile.in
@@ -0,0 +1,524 @@
+# 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
new file mode 100644
index 0000000..a7d738c
--- /dev/null
+++ b/gridspec_tools_20080702/tools/river_regrid/gs_river_regrid.c
@@ -0,0 +1,119 @@
+#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
new file mode 100644
index 0000000..f821e9e
--- /dev/null
+++ b/gridspec_tools_20080702/tools/river_regrid/river_regrid.c
@@ -0,0 +1,1484 @@
+#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
new file mode 100644
index 0000000..3c501d3
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/Makefile.am
@@ -0,0 +1,39 @@
+## 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/Makefile.in b/gridspec_tools_20080702/tools/shared/Makefile.in
new file mode 100644
index 0000000..ccc6a6d
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/Makefile.in
@@ -0,0 +1,504 @@
+# 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
+# tools/shared convenience library.
+
+# $Id: Makefile.am,v 1.8 2009/04/08 15:57:16 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@
+
+# 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
+subdir = gridspec_tools_20080702/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 \
+ $(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 =
+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
+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
+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 = $(libtoolsshared_la_SOURCES)
+DIST_SOURCES = $(libtoolsshared_la_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@
+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
+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/shared/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign gridspec_tools_20080702/tools/shared/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
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libtoolsshared.la: $(libtoolsshared_la_OBJECTS) $(libtoolsshared_la_DEPENDENCIES)
+ $(LINK) $(libtoolsshared_la_OBJECTS) $(libtoolsshared_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/bilinear_interp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/conserve_interp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_conformal_cubic_grid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_gnomonic_cubic_grid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_grid_from_file.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_lonlat_grid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/create_vgrid.Plo at am__quote@
+ at 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)/mpp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mpp_domain.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mpp_io.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tool_util.Plo at am__quote@
+ at 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:
+ 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 $(LTLIBRARIES)
+installdirs:
+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-generic clean-libtool clean-noinstLTLIBRARIES \
+ 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-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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile 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 \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ 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/shared/bilinear_interp.c b/gridspec_tools_20080702/tools/shared/bilinear_interp.c
new file mode 100644
index 0000000..337b2da
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/bilinear_interp.c
@@ -0,0 +1,1131 @@
+#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/conserve_interp.c b/gridspec_tools_20080702/tools/shared/conserve_interp.c
new file mode 100644
index 0000000..05d714d
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/conserve_interp.c
@@ -0,0 +1,689 @@
+#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/shared/create_conformal_cubic_grid.c b/gridspec_tools_20080702/tools/shared/create_conformal_cubic_grid.c
new file mode 100644
index 0000000..b044ea7
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/create_conformal_cubic_grid.c
@@ -0,0 +1,814 @@
+#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/shared/create_gnomonic_cubic_grid.c b/gridspec_tools_20080702/tools/shared/create_gnomonic_cubic_grid.c
new file mode 100644
index 0000000..8d37c16
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/create_gnomonic_cubic_grid.c
@@ -0,0 +1,907 @@
+#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
new file mode 100644
index 0000000..3dc60cc
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/create_grid_from_file.c
@@ -0,0 +1,152 @@
+#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_lonlat_grid.c b/gridspec_tools_20080702/tools/shared/create_lonlat_grid.c
new file mode 100644
index 0000000..f562c69
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/create_lonlat_grid.c
@@ -0,0 +1,406 @@
+#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/shared/create_vgrid.c b/gridspec_tools_20080702/tools/shared/create_vgrid.c
new file mode 100644
index 0000000..6e84402
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/create_vgrid.c
@@ -0,0 +1,43 @@
+#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
new file mode 100644
index 0000000..2e12176
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/fregrid_util.c
@@ -0,0 +1,1597 @@
+#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
new file mode 100644
index 0000000..43a977a
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/get_contact.c
@@ -0,0 +1,326 @@
+#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/mpp.c b/gridspec_tools_20080702/tools/shared/mpp.c
new file mode 100644
index 0000000..86c6d84
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/mpp.c
@@ -0,0 +1,230 @@
+#include <stdlib.h>
+#include <stdio.h>
+#ifdef use_libMPI
+#include <mpi.h>
+#endif
+#include "mpp.h"
+
+
+/****************************************************
+ global variables
+*****************************************************/
+int npes, root_pe, pe;
+int *pelist=NULL;
+const int tag = 1;
+#ifdef use_libMPI
+MPI_Request *request;
+#endif
+
+/**************************************************************
+ void mpp_init()
+ this routine will create communicator.
+***************************************************************/
+
+void mpp_init(int *argc, char ***argv)
+{
+ int n;
+
+#ifdef use_libMPI
+ MPI_Init(argc, argv);
+ MPI_Comm_rank(MPI_COMM_WORLD,&pe);
+ MPI_Comm_size(MPI_COMM_WORLD,&npes);
+ request = (MPI_Request *)malloc(npes*sizeof(MPI_Request));
+ for(n=0; n<npes; n++) request[n] = MPI_REQUEST_NULL;
+#else
+ pe = 0;
+ npes = 1;
+#endif
+ pelist = (int *)malloc(npes*sizeof(int));
+ for(n=0; n<npes; n++) pelist[n] = n;
+ root_pe = 0;
+}; /* mpp_init */
+
+/***********************************************************
+ void mpp_end()
+ This routine will terminate the parallel.
+************************************************************/
+
+void mpp_end()
+{
+#ifdef use_libMPI
+ MPI_Finalize();
+#endif
+} /* mpp_end */
+
+/*****************************************************************
+ int mpp_pe()
+ Returns processor ID.
+******************************************************************/
+
+int mpp_pe()
+{
+ return pe;
+}; /* mpp_pe */
+
+
+/**************************************************************
+ int mpp_npes()
+ Returns processor count for current pelist.
+**************************************************************/
+
+int mpp_npes()
+{
+ return npes;
+}; /* mpp_npes */
+
+/*************************************************************
+ int mpp_root_pe()
+ return root processor of current pelist
+*************************************************************/
+
+int mpp_root_pe()
+{
+ return root_pe;
+}; /* mpp_root_pe */
+
+/*************************************************************
+ int* mpp_get_pelist()
+ return current pelist
+*************************************************************/
+
+int* mpp_get_pelist()
+{
+ return pelist;
+}; /* mpp_get_pelist */
+
+/************************************************************
+ void mpp_sync_self()
+ this is to check if current PE's outstanding puts are complete
+*************************************************************/
+void mpp_sync_self() {
+ int n;
+#ifdef use_libMPI
+ MPI_Status status;
+
+ for(n=0; n<npes; n++) {
+ if(request[n] != MPI_REQUEST_NULL) MPI_Wait( request+n, &status );
+ }
+#endif
+
+}
+
+/*************************************************************
+ void mpp_send_double(const double* data, int size, int to_pe)
+ send data to "to_pe"
+*************************************************************/
+
+void mpp_send_double(const double* data, int size, int to_pe)
+{
+#ifdef use_libMPI
+ MPI_Status status;
+ /* make sure only one message from pe->to_pe in queue */
+ if(request[to_pe] != MPI_REQUEST_NULL) {
+ MPI_Wait( request+to_pe, &status );
+ }
+
+ MPI_Isend(data, size, MPI_DOUBLE, to_pe, tag, MPI_COMM_WORLD, request+to_pe);
+#endif
+
+}; /* mpp_send_double */
+
+
+/*************************************************************
+ void mpp_send_int(const int* data, int size, int to_pe)
+ send data to "to_pe"
+*************************************************************/
+
+void mpp_send_int(const int* data, int size, int to_pe)
+{
+#ifdef use_libMPI
+ MPI_Status status;
+ if(request[to_pe] != MPI_REQUEST_NULL) {
+ MPI_Wait( request+to_pe, &status );
+ }
+
+ MPI_Isend(data, size, MPI_INT, to_pe, tag, MPI_COMM_WORLD, request+to_pe);
+#endif
+
+}; /* mpp_send_int */
+
+/***********************************************************
+ void mpp_recv_double(double* data, int size, int from_pe)
+ receive data from "from_pe"
+***********************************************************/
+
+void mpp_recv_double(double* data, int size, int from_pe)
+{
+#ifdef use_libMPI
+ MPI_Status status;
+ MPI_Recv(data, size, MPI_DOUBLE, from_pe, MPI_ANY_TAG, MPI_COMM_WORLD,&status);
+#endif
+}; /* mpp_recv_double */
+
+/***********************************************************
+ void mpp_recv_int(int* data, int size, int from_pe)
+ receive data from "from_pe"
+***********************************************************/
+
+void mpp_recv_int(int* data, int size, int from_pe)
+{
+#ifdef use_libMPI
+ MPI_Status status;
+ MPI_Recv(data, size, MPI_INT, from_pe, MPI_ANY_TAG, MPI_COMM_WORLD,&status);
+#endif
+}; /* mpp_recv_int */
+
+
+/*******************************************************************************
+ int mpp_sum_int(int count, int *data)
+ sum integer over all the pes.
+*******************************************************************************/
+void mpp_sum_int(int count, int *data)
+{
+
+#ifdef use_libMPI
+ int i;
+ int *sum;
+ sum = (int *)malloc(count*sizeof(int));
+ MPI_Allreduce(data, sum, count, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ for(i=0; i<count; i++)data[i] = sum[i];
+ free(sum);
+#endif
+
+
+}; /* mpp_sum_int */
+
+/*******************************************************************************
+ int mpp_sum_double(int count, double *data)
+ sum double over all the pes.
+*******************************************************************************/
+void mpp_sum_double(int count, double *data)
+{
+
+#ifdef use_libMPI
+ int i;
+ double *sum;
+ sum = (double *)malloc(count*sizeof(double));
+ MPI_Allreduce(data, sum, count, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
+ for(i=0; i<count; i++)data[i] = sum[i];
+ free(sum);
+#endif
+
+
+}; /* mpp_sum_double */
+
+
+/***********************************************************
+ void mpp_error(char *str)
+ error handler: will print out error message and then abort
+***********************************************************/
+
+void mpp_error(char *str)
+{
+ fprintf(stderr, "Error from pe %d: %s\n", pe, str );
+#ifdef use_libMPI
+ MPI_Abort(MPI_COMM_WORLD, -1);
+#else
+ exit(1);
+#endif
+}; /* mpp_error */
+
diff --git a/gridspec_tools_20080702/tools/shared/mpp.h b/gridspec_tools_20080702/tools/shared/mpp.h
new file mode 100644
index 0000000..a212b74
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/mpp.h
@@ -0,0 +1,24 @@
+
+/*********************************************************************
+ mpp.h
+ This header contains subroutine for parallel programming.
+ only MPI parallel is implemented.
+ Contact: Zhi.Liang at noaa.gov
+ ********************************************************************/
+#ifndef MPP_H_
+#define MPP_H_
+
+void mpp_init(int *argc, char ***argv); /* start parallel programming, create communicator */
+void mpp_end(); /* end of parallel programming, abort the program */
+int mpp_pe(); /* return processor ID */
+int mpp_root_pe(); /* return root pe of current pelist */
+int mpp_npes(); /* return number of processor used */
+int* mpp_get_pelist();
+void mpp_send_double(const double* data, int size, int to_pe); /* send data */
+void mpp_send_int(const int* data, int size, int to_pe); /* send data */
+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_sync_self();
+#endif
diff --git a/gridspec_tools_20080702/tools/shared/mpp_domain.c b/gridspec_tools_20080702/tools/shared/mpp_domain.c
new file mode 100644
index 0000000..49715af
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/mpp_domain.c
@@ -0,0 +1,534 @@
+/*
+ **** MppDomain.cpp ****
+ MppDomain package
+ NOTE: only mpi is implemented here. if needed, shmem version
+ will be added on in the future.
+ Contact: Zhi.Liang at noaa.gov
+*/
+#include <stdlib.h>
+#include <math.h>
+#include "mpp.h"
+#include "mpp_domain.h"
+
+/***********************************************************
+ global variables
+***********************************************************/
+int pe, npes, root_pe;
+
+/************************************************************
+ void mpp_domain_init()
+ initialization routine. get the processor information.
+ memory allocation.
+************************************************************/
+void mpp_domain_init( )
+{
+ pe = mpp_pe();
+ npes = mpp_npes();
+ root_pe = mpp_root_pe();
+}; /* mpp_domain_init */
+
+/***********************************************************
+ void mpp_domain_end()
+ release memory.
+***********************************************************/
+void mpp_domain_end ()
+{
+ /* will add something here if needed */
+};
+
+/************************************************************
+ void mpp_define_layout()
+ define domain layout based on given grid resolution and
+ number of processors
+***********************************************************/
+
+void mpp_define_layout(int ni, int nj, int ndivs, int layout[])
+{
+ int idiv, jdiv;
+ float fdiv;
+
+ /*first try to divide ndivs in the domain aspect ratio:
+ if imperfect aspect, reduce idiv till it divides ndivs */
+ fdiv = sqrt((1.0*ndivs*ni)/nj);
+ idiv = floor(fdiv);
+ if(fdiv-idiv > 0.5) idiv = idiv + 1;
+ idiv = (idiv>1) ? idiv : 1; /*for isz=1 line above can give 0*/
+ while( ndivs%idiv != 0 ) {
+ idiv = idiv - 1;
+ } /*will terminate at idiv=1 if not before*/
+ jdiv = ndivs/idiv;
+ layout[0] = idiv;
+ layout[1] = jdiv;
+};
+
+/***********************************************************
+ void mpp_define_domain_1d(int size, domain1D *domain )
+ define 1-D domain decomposition.
+**********************************************************/
+void mpp_define_domain_1d(int npts, int ndivs, domain1D *domain )
+{
+ int n, npts_left, pos, size;
+
+ domain->beglist = (int *)malloc(ndivs*sizeof(int));
+ domain->endlist = (int *)malloc(ndivs*sizeof(int));
+
+ if(ndivs > npts ) {
+ mpp_error("mpp_define_domain1d: more divisions requested than rows available. " );
+ }
+ npts_left = npts;
+ pos = 0;
+ for(n=0; n<ndivs; n++){
+ domain->beglist[n] = pos;
+ size = ceil((1.0*npts_left)/(ndivs-n));
+ domain->endlist[n] = pos + size - 1;
+ npts_left=npts_left - size;
+ pos += size;
+ }
+
+ if(npes == ndivs) {
+ domain->start = domain->beglist[pe];
+ domain->end = domain->endlist[pe];
+ domain->size = domain->end - domain->start + 1;
+ domain->sizeg = npts;
+ }
+
+}; /* mpp_define_domain_1d */
+
+
+/************************************************************
+ void define_domain(int ni, int nj, int layout[], int xhalo, int yhalo, domain2D *domain )
+ define 2D domain decomposition
+************************************************************/
+
+void mpp_define_domain2d(int ni, int nj, int layout[], int xhalo, int yhalo, domain2D *domain )
+{
+ domain1D domx, domy;
+ int i, j, posx, posy, n;
+
+ domain->isclist = (int *)malloc(layout[0]*layout[1]*sizeof(int));
+ domain->ieclist = (int *)malloc(layout[0]*layout[1]*sizeof(int));
+ domain->jsclist = (int *)malloc(layout[0]*layout[1]*sizeof(int));
+ domain->jeclist = (int *)malloc(layout[0]*layout[1]*sizeof(int));
+
+ mpp_define_domain_1d(ni, layout[0], &domx);
+ mpp_define_domain_1d(nj, layout[1], &domy);
+
+ n = 0;
+ for(j=0; j<layout[1]; j++) {
+ for(i=0; i<layout[0]; i++) {
+ domain->isclist[n] = domx.beglist[i]+xhalo;
+ domain->ieclist[n] = domx.endlist[i]+xhalo;
+ domain->jsclist[n] = domy.beglist[j]+yhalo;
+ domain->jeclist[n] = domy.endlist[j]+yhalo;
+ n++;
+ }
+ }
+
+ domain->xhalo = xhalo;
+ domain->yhalo = yhalo;
+ domain->isc = domain->isclist[pe];
+ domain->iec = domain->ieclist[pe];
+ domain->jsc = domain->jsclist[pe];
+ domain->jec = domain->jeclist[pe];
+ domain->isd = domain->isc - xhalo;
+ domain->ied = domain->iec + xhalo;
+ domain->jsd = domain->jsc - yhalo;
+ domain->jed = domain->jec + yhalo;
+ domain->nxc = domain->iec - domain->isc + 1;
+ domain->nyc = domain->jec - domain->jsc + 1;
+ domain->nxd = domain->ied - domain->isd + 1;
+ domain->nyd = domain->jed - domain->jsd + 1;
+ domain->nxg = ni;
+ domain->nyg = nj;
+
+ mpp_delete_domain1d(&domx);
+ mpp_delete_domain1d(&domy);
+
+}; /* mpp_define_domain2d */
+
+/****************************************************************************
+ void mpp_delete_domain1d(domain1D *domain);
+ release the memory assigned to 1-D domain
+*****************************************************************************/
+void mpp_delete_domain1d(domain1D *domain)
+{
+
+ free(domain->beglist);
+ free(domain->endlist);
+
+}; /* mpp_delete_domain1d */
+
+/****************************************************************************
+ void mpp_delete_domain2d(domain2D *domain);
+ release the memory assigned to 2-D domain
+*****************************************************************************/
+void mpp_delete_domain2d(domain2D *domain)
+{
+
+ free(domain->isclist);
+ free(domain->ieclist);
+ free(domain->jsclist);
+ free(domain->jeclist);
+
+}; /* mpp_delete_domain2d */
+
+
+
+/***********************************************************
+ void get_get_compute_domain(omain2D domain, int *is, int *ie, int *js, int *je)
+ get the compute domain decomposition
+***********************************************************/
+
+void mpp_get_compute_domain2d(domain2D domain, int *is, int *ie, int *js, int *je)
+{
+ *is = domain.isc;
+ *ie = domain.iec;
+ *js = domain.jsc;
+ *je = domain.jec;
+}; /* mpp_get_compute_domain */
+
+/***********************************************************
+ void get_get_compute_domain( int *is, int *ie, int *js, int *je)
+ get the compute domain decomposition of current pe list.
+***********************************************************/
+
+void mpp_get_compute_domains2d(domain2D domain, int *is, int *ie, int *js, int *je)
+{
+ int n;
+
+ for(n=0; n<npes;n++) {
+ is[n] = domain.isclist[n];
+ ie[n] = domain.ieclist[n];
+ js[n] = domain.jsclist[n];
+ je[n] = domain.jeclist[n];
+ }
+
+}/* mpp_get_compute_domains */
+
+/**********************************************************
+ void mpp_get_data_domain(int *is, int *ie, int *js, int *je)
+ get the data domain decomposition
+***********************************************************/
+
+void mpp_get_data_domain2d(domain2D domain, int *is, int *ie, int *js, int *je)
+{
+ *is = domain.isd;
+ *ie = domain.ied;
+ *js = domain.jsd;
+ *je = domain.jed;
+}; /* mpp_get_data_domain */
+
+/**********************************************************
+ void mpp_get_global_domain(int *nx, int *ny )
+ get the global domain size
+***********************************************************/
+
+void mpp_get_global_domain2d(domain2D domain, int *nx, int *ny )
+{
+ *nx = domain.nxg;
+ *ny = domain.nyg;
+}; /* mpp_get_global_domain */
+
+/****************************************************************
+ void mpp_get_shift(int sizex, int sizey, int *ishift, int *jshift)
+ Return the shift value. For non-symmetry domain, ishift will be always 0.
+ For symmetric domain, shift value can be 0 or 1 depending on position.
+
+****************************************************************/
+void mpp_get_shift(domain2D domain, int sizex, int sizey, int *ishift, int *jshift)
+{
+ int nxc, nyc, nxd, nyd;
+
+ nxc = domain.nxc; nyc = domain.nyc;
+ nxd = domain.nxd; nyd = domain.nyd;
+
+ if( (sizex == nxc && sizey == nyc) || (sizex == nxd && sizey == nyd) ) {
+ *ishift = 0;
+ *jshift = 0;
+ }
+ else if ( (sizex == nxc+1 && sizey == nyc) || (sizex == nxd+1 && sizey == nyd)) {
+ *ishift = 1;
+ *jshift = 0;
+ }
+ else if ( (sizex == nxc && sizey == nyc+1) || (sizex == nxd && sizey == nyd+1) ) {
+ *ishift = 0;
+ *jshift = 1;
+ }
+ else if ( (sizex == nxc+1 && sizey == nyc+1) || (sizex == nxd+1 && sizey == nyd+1) ) {
+ *ishift = 1;
+ *jshift = 1;
+ }
+ else
+ mpp_error("mpp_domain: data should be on either compute or data domain.");
+
+}; /* mpp_get_shift */
+
+
+/*************************************************************
+ mpp_global_field_double(domain2D domain, int sizex, int sizey, const double *ldata, double *gdata)
+ get the global data on root pe.
+ ldata is on compute domain and gdata is on global domain
+************************************************************/
+void mpp_global_field_double(domain2D domain, int sizex, int sizey, const double* ldata, double* gdata)
+{
+ double *send_buffer=NULL, *recv_buffer=NULL;
+ int i, j, n, ni, nj, ii, jj, l, p, recv_size;
+ int ishift, jshift, nxc, nyc, nxd, nyd, nxg;
+ int is, ie, js, je, isd, jsd;
+
+ mpp_get_shift( domain, sizex, sizey, &ishift, &jshift);
+ is = domain.isc;
+ ie = domain.iec + ishift;
+ js = domain.jsc;
+ je = domain.jec + jshift;
+
+ nxc = ie-is+1;
+ nyc = je-js+1;
+ isd = domain.isd;
+ jsd = domain.jsd;
+ nxd = domain.nxd + ishift;
+ nyd = domain.nyd + jshift;
+ nxg = domain.nxg + ishift;
+
+ /* all other pe except root pe will send data to root pe */
+ if( pe != root_pe) {
+ if( sizex == nxc && sizey == nyc ){ /* data is on compute domain */
+ mpp_send_double(ldata, sizex*sizey, root_pe);
+ }
+ else if( sizex == nxd && sizey == nyd ){ /* data is on data domain */
+ send_buffer = (double *)malloc(nxc*nyc*sizeof(double));
+ n = 0;
+ for(j=js;j<=je;j++) {
+ for(i=is;i<=ie;i++) send_buffer[n++] = ldata[(j-jsd)*nxd+(i-isd)];
+ }
+ mpp_send_double(send_buffer, nxc*nyc, root_pe);
+ }
+ else
+ mpp_error("mpp_domain: data should be on compute/data domain");
+ }
+
+ /* receive from other pe on root pe */
+ if( pe == root_pe ) {
+ for(p=0;p<npes;p++) {
+ if( p == root_pe) {
+ if( sizex == nxc && sizey == nyc ){ /* data is on compute domain */
+ n = 0;
+ for(j=js;j<=je;j++) {
+ for(i=is;i<=ie;i++) gdata[j*nxg+i] = ldata[n++];
+ }
+ }
+ else {
+ for(j=js;j<=je;j++) {
+ for(i=is;i<=ie;i++) gdata[j*nxg+i] = ldata[(j-jsd)*nxd+(i-isd)];
+ }
+ }
+ }
+ else {
+ recv_size = (domain.ieclist[p]-domain.isclist[p]+1+ishift)*(domain.jeclist[p]-domain.jsclist[p]+1+jshift);
+ recv_buffer = ( double *) malloc(recv_size*sizeof(double));
+ mpp_recv_double(recv_buffer, recv_size, p );
+ n = 0;
+ for(j=domain.jsclist[p]; j<=domain.jeclist[p]+jshift; j++){
+ for(i=domain.isclist[p]; i<=domain.ieclist[p]+ishift; i++){
+ gdata[j*nxg+i] = recv_buffer[n++];
+ }
+ }
+ free(recv_buffer);
+ }
+ }
+ }
+
+ mpp_sync_self();
+
+ if(send_buffer != NULL) free(send_buffer);
+}; /* mpp_global_field_double */
+
+/*************************************************************
+ mpp_global_field_double_3D(domain2D domain, int sizex, int sizey, int sizez,
+ const double *ldata, double *gdata)
+ get the global data on root pe.
+ ldata is on compute domain and gdata is on global domain
+************************************************************/
+void mpp_global_field_double_3D(domain2D domain, int sizex, int sizey, int sizez,
+ const double* ldata, double* gdata)
+{
+ double *send_buffer=NULL, *recv_buffer=NULL;
+ int i, j, k, n, ni, nj, ii, jj, l, p, recv_size;
+ int ishift, jshift, nxc, nyc, nxd, nyd, nxg, nyg;
+ int is, ie, js, je, isd, jsd;
+
+ mpp_get_shift( domain, sizex, sizey, &ishift, &jshift);
+ is = domain.isc;
+ ie = domain.iec + ishift;
+ js = domain.jsc;
+ je = domain.jec + jshift;
+
+ nxc = ie-is+1;
+ nyc = je-js+1;
+ isd = domain.isd;
+ jsd = domain.jsd;
+ nxd = domain.nxd + ishift;
+ nyd = domain.nyd + jshift;
+ nxg = domain.nxg + ishift;
+ nyg = domain.nyg + ishift;
+
+ /* all other pe except root pe will send data to root pe */
+ if( pe != root_pe) {
+ if( sizex == nxc && sizey == nyc ){ /* data is on compute domain */
+ mpp_send_double(ldata, sizex*sizey*sizez, root_pe);
+ }
+ else if( sizex == nxd && sizey == nyd ){ /* data is on data domain */
+ send_buffer = (double *)malloc(nxc*nyc*sizez*sizeof(double));
+ n = 0;
+ for(k=0; k<sizez; k++) for(j=js;j<=je;j++) {
+ for(i=is;i<=ie;i++) send_buffer[n++] = ldata[k*nxd*nyd+(j-jsd)*nxd+(i-isd)];
+ }
+ mpp_send_double(send_buffer, nxc*nyc*sizez, root_pe);
+ }
+ else
+ mpp_error("mpp_domain: data should be on compute/data domain");
+ }
+
+ /* receive from other pe on root pe */
+ if( pe == root_pe ) {
+ for(p=0;p<npes;p++) {
+ if( p == root_pe) {
+ if( sizex == nxc && sizey == nyc ){ /* data is on compute domain */
+ n = 0;
+ for(k=0;k<sizez;k++) for(j=js;j<=je;j++) {
+ for(i=is;i<=ie;i++) gdata[k*nxg*nyg+j*nxg+i] = ldata[n++];
+ }
+ }
+ else {
+ for(k=0;k<sizez;k++) for(j=js;j<=je;j++) {
+ for(i=is;i<=ie;i++) gdata[k*nxg*nyg+j*nxg+i] = ldata[k*nxd*nyd+(j-jsd)*nxd+(i-isd)];
+ }
+ }
+ }
+ else {
+ recv_size = (domain.ieclist[p]-domain.isclist[p]+1+ishift)
+ *(domain.jeclist[p]-domain.jsclist[p]+1+jshift)*sizez;
+ recv_buffer = ( double *) malloc(recv_size*sizeof(double));
+ mpp_recv_double(recv_buffer, recv_size, p );
+ n = 0;
+ for(k=0;k<sizez;k++) {
+ for(j=domain.jsclist[p]; j<=domain.jeclist[p]+jshift; j++){
+ for(i=domain.isclist[p]; i<=domain.ieclist[p]+ishift; i++){
+ gdata[k*nxg*nyg+j*nxg+i] = recv_buffer[n++];
+ }
+ }
+ }
+ free(recv_buffer);
+ }
+ }
+ }
+
+ mpp_sync_self();
+
+ if(send_buffer != NULL) free(send_buffer);
+}; /* mpp_global_field_double */
+
+/*******************************************************************************
+ void mpp_gather_field_int(int lsize, int *ldata, int *gdata)
+ gather integer data onto every processor
+*******************************************************************************/
+void mpp_gather_field_int(int lsize, int *ldata, int *gdata)
+{
+ int n, p, i;
+ int *rbuffer;
+ int *rsize;
+
+ rsize = (int *)malloc(npes*sizeof(int));
+
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* send to other pe. */
+ mpp_send_int(&lsize, 1, p);
+ }
+ }
+
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* recv from other pe. */
+ mpp_recv_int(rsize+p, 1, p);
+ }
+ }
+
+ mpp_sync_self();
+
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* send to other pe. */
+ if(lsize>0) mpp_send_int(ldata, lsize, p);
+ }
+ }
+ n = 0;
+ /* receive from other pe and fill the gdata */
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* recv from other pe. */
+ if(rsize[p]>0) {
+ rbuffer = ( int *) malloc(rsize[p]*sizeof(int));
+ mpp_recv_int(rbuffer, rsize[p], p );
+ for(i=0; i<rsize[p]; i++) gdata[n++] = rbuffer[i];
+ free(rbuffer);
+ }
+ }
+ else {
+ for(i=0; i<lsize; i++) gdata[n++] = ldata[i];
+ }
+ }
+
+ mpp_sync_self();
+ free(rsize);
+
+}; /* mpp_gather_field_int */
+
+/*******************************************************************************
+ void mpp_gather_field_double(int lsize, double *ldata, double *gdata)
+ gather doubleeger data onto every processor
+*******************************************************************************/
+void mpp_gather_field_double(int lsize, double *ldata, double *gdata)
+{
+ int n, p, i;
+ double*rbuffer;
+ int *rsize;
+
+ rsize = (int *)malloc(npes*sizeof(int));
+
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* send to other pe. */
+ mpp_send_int(&lsize, 1, p);
+ }
+ }
+
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* recv from other pe. */
+ mpp_recv_int(rsize+p, 1, p);
+ }
+ }
+
+ mpp_sync_self();
+
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* send to other pe. */
+ if(lsize>0) mpp_send_double(ldata, lsize, p);
+ }
+ }
+ n = 0;
+ /* receive from other pe and fill the gdata */
+ for(p = 0; p<npes; p++) {
+ if(pe != p) { /* recv from other pe. */
+ if(rsize[p]>0) {
+ rbuffer = (double *) malloc(rsize[p]*sizeof(double));
+ mpp_recv_double(rbuffer, rsize[p], p );
+ for(i=0; i<rsize[p]; i++) gdata[n++] = rbuffer[i];
+ free(rbuffer);
+ }
+ }
+ else {
+ for(i=0; i<lsize; i++) gdata[n++] = ldata[i];
+ }
+ }
+
+ mpp_sync_self();
+ free(rsize);
+
+}; /* mpp_gather_field_double*/
+
diff --git a/gridspec_tools_20080702/tools/shared/mpp_domain.h b/gridspec_tools_20080702/tools/shared/mpp_domain.h
new file mode 100644
index 0000000..c742c30
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/mpp_domain.h
@@ -0,0 +1,50 @@
+/****************************************************************
+ mpp_domain.h
+ This headers define interface to define domain layout,
+ define domain decomposition and global field to root pe,
+ some utilities routine to return domain decomposition.
+ Currently it only used in tools and assume only one domain is created.
+ If more domains are needed, we may define a struct to hold domain informaiton.
+ contact: Zhi.Liang at noaa.gov
+
+****************************************************************/
+#ifndef MPP_DOMAIN_H_
+#define MPP_DOMAIN_H_
+
+typedef struct{
+ int start, end; /* starting and ending index of compute domain */
+ int size; /* compute domain size */
+ int sizeg; /* global domain size */
+ int *beglist, *endlist; /* list of starting and ending index of compute domain */
+} domain1D;
+
+typedef struct {
+ int isc, iec, jsc, jec; /* compute domain decomposition */
+ int isd, ied, jsd, jed; /* data domain decomposition */
+ int nxc, nyc; /* compute domain size */
+ int nxd, nyd; /* data domain size */
+ int nxg, nyg; /* global domain size */
+ int *isclist, *ieclist; /* list of i-index of compute domain */
+ int *jsclist, *jeclist; /* list of j-index of compute domain */
+ int xhalo, yhalo; /* halo size */
+} domain2D;
+
+void mpp_domain_init();
+void mpp_domain_end();
+void mpp_define_layout(int ni, int nj, int ndivs, int layout[]);
+void mpp_define_domain1d(int npts, int ndvis, domain1D *domain );
+void mpp_define_domain2d(int ni, int nj, int layout[], int xhalo, int yhalo, domain2D *domain );
+void mpp_delete_domain1d(domain1D *domain);
+void mpp_delete_domain2d(domain2D *domain);
+void mpp_get_compute_domain2d(domain2D domain, int *is, int *ie, int *js, int *je);
+void mpp_get_data_domain2d(domain2D domain, int *is, int *ie, int *js, int *je);
+void mpp_get_global_domain2d(domain2D domain, int *nx, int *ny);
+void mpp_get_compute_domains2d(domain2D domain, int *is, int *ie, int *js, int *je);
+void mpp_get_shift(domain2D domain, int sizex, int sizey, int *ishift, int *jshift);
+void mpp_global_field_double(domain2D domain, int sizex, int sizey, const double* ldata, double* gdata);
+void mpp_global_field_double_3D(domain2D domain, int sizex, int sizey, int sizez,
+ const double* ldata, double* gdata);
+void mpp_gather_field_int(int lsize, int *ldata, int *gdata);
+void mpp_gather_field_double(int lsize, double *ldata, double *gdata);
+
+#endif
diff --git a/gridspec_tools_20080702/tools/shared/mpp_io.c b/gridspec_tools_20080702/tools/shared/mpp_io.c
new file mode 100644
index 0000000..51d4c98
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/mpp_io.c
@@ -0,0 +1,875 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <netcdf.h>
+#include "mpp.h"
+#include "mpp_domain.h"
+#include "mpp_io.h"
+
+#define MAXFILE 50
+#define MAXVAR 1024
+
+typedef struct {
+ int fldid;
+ char name[128];
+ nc_type type;
+} VarType;
+
+typedef struct {
+ int ncid;
+ char name[512];
+ int action; /* indicate the action, MPP_WRITE or MPP_READ */
+ int status; /* indicate if the file is opened or closed */
+ int nvar;
+ VarType *var;
+} FileType;
+
+FileType files[MAXFILE];
+int nfiles = 0;
+
+/*********************************************************************
+ void netcdf_error( int status )
+ status is the returning value of netcdf call. this routine will
+ handle the error when status is not NC_NOERR.
+********************************************************************/
+void netcdf_error(const char *msg, int status )
+{
+ char errmsg[512];
+
+ sprintf( errmsg, "%s: %s", msg, nc_strerror(status) );
+ mpp_error(errmsg);
+
+}; /* netcdf_error */
+
+
+/*************************************************************
+ int mpp_open(char *filename, int action)
+ open netcdf file to read or write. return the id for the file opened.
+ Here the id is not the netcdf ncid of the file opened, it is the index
+ in the mpp_io data files. If the file is already opened, will exit with
+ an error message. For the write action, mpp_open can only be called once.
+ For the read action, the file could be open and then close and then open
+ again. The action should be MPP_READ, MPP_WRITE, a constant defined in
+ mpp_io.h. When action is MPP_WRITE, file will be created on root pe.
+************************************************************/
+
+int mpp_open(const char *file, int action) {
+ char curfile[128];
+ char errmsg[512];
+ int ncid, status, n, fid;
+
+ /* write only from root pe. */
+ if(action == MPP_WRITE && mpp_pe() != mpp_root_pe() ) return -1;
+ /*if file is not ended with .nc add .nc at the end. */
+ strcpy(curfile, file);
+ if(strstr(curfile, ".nc") == NULL) strcat(curfile,".nc");
+
+ /* look through currently files to make sure the file is not in the list*/
+ fid = -1;
+ for(n=0; n<nfiles; n++) {
+ if(!strcmp(files[n].name, file)) {
+ fid = n;
+ break;
+ }
+ }
+ if(fid > -1) {
+ if(files[n].action == MPP_WRITE) {
+ sprintf( errmsg, "mpp_io(mpp_open): %s is already created for write", file);
+ mpp_error(errmsg);
+ }
+ if(files[n].status) {
+ sprintf( errmsg, "mpp_io(mpp_open): %s is already opened", file);
+ mpp_error(errmsg);
+ }
+ }
+ else {
+ fid = nfiles;
+ nfiles++;
+ if(nfiles > MAXFILE) mpp_error("mpp_io(mpp_open): nfiles is larger than MAXFILE, increase MAXFILE");
+ strcpy(files[fid].name, file);
+ files[fid].nvar = 0;
+ files[fid].var = (VarType *)malloc(MAXVAR*sizeof(VarType));
+ }
+
+ switch (action) {
+ case MPP_WRITE:
+#ifdef NC_64BIT_OFFSET
+ status = nc_create(curfile, NC_64BIT_OFFSET, &ncid);
+#else
+ status = nc_create(curfile, NC_WRITE, &ncid);
+#endif
+ break;
+ case MPP_READ:
+ status = nc_open(curfile,NC_NOWRITE, &ncid);
+ break;
+ default:
+ sprintf(errmsg, "mpp_io(mpp_open): the action should be MPP_WRITE or MPP_READ when opening file %s", file);
+ mpp_error(errmsg);
+ }
+
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_open): error in opening file %s", file);
+ netcdf_error(errmsg, status);
+ }
+
+ files[fid].ncid = ncid;
+ files[fid].status = 1;
+ files[fid].action = action;
+
+ return fid;
+}
+
+/* close the file */
+void mpp_close(int fid)
+{
+ int status;
+ char errmsg[512];
+
+ if(fid == -1 && mpp_pe() != mpp_root_pe() ) return;
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_close): invalid id number, id should be "
+ "a nonnegative integer that less than nfiles");
+
+ status = nc_close(files[fid].ncid);
+ if(status != NC_NOERR) {
+ sprintf( errmsg, "mpp_io(mpp_close): error in closing files %s ", files[fid].name);
+ netcdf_error(errmsg, status);
+ }
+ files[fid].ncid = 0;
+ files[fid].status = 0;
+
+}
+
+/*******************************************************************************/
+/* */
+/* The following are routines that retrieve information */
+/* */
+/*******************************************************************************/
+
+/*********************************************************************
+ 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.
+*********************************************************************/
+int mpp_get_varid(int fid, const char *varname)
+{
+ int status, fldid, vid, n;
+ 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_varid): invalid id number, id should be "
+ "a nonnegative integer that less than nfiles");
+
+ for(n=0; n<files[fid].nvar; n++) {
+ if( !strcmp(files[fid].var[n].name, varname) ) return n;
+ }
+
+ vid = files[fid].nvar;
+ files[fid].nvar++;
+ if(files[fid].nvar > MAXVAR ) mpp_error("mpp_io(mpp_get_varid): nvar is larger than MAXVAR, increase MAXVAR");
+
+ status = nc_inq_varid(files[fid].ncid, varname, &fldid);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_varid): error in get field_id of variable %s from file %s", varname, files[fid].name);
+ netcdf_error(errmsg, status);
+ }
+
+ status = nc_inq_vartype(files[fid].ncid, fldid, &(files[fid].var[vid].type));
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_varid): Error in getting type of of field %s in file %s ",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+ files[fid].var[vid].fldid = fldid;
+ strcpy(files[fid].var[vid].name, varname);
+ return vid;
+
+};/* mpp_get_varid */
+
+/********************************************************************
+ int mpp_get_dimlen(char* file, char *name)
+ Get the dimension.
+ *******************************************************************/
+int mpp_get_dimlen(int fid, const char *name)
+{
+ int ncid, dimid, status, len;
+ size_t size;
+ char errmsg[512];
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_dimlen): invalid fid number, fid should be "
+ "a nonnegative integer that less than nfiles");
+ ncid = files[fid].ncid;
+ status = nc_inq_dimid(ncid, name, &dimid);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_dimlen): error in inquiring dimid of %s from file %s", name, files[fid].name);
+ netcdf_error(errmsg, status);
+ }
+ status = nc_inq_dimlen(ncid, dimid, &size);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_dimlen): error in inquiring dimlen of %s from file %s", name, files[fid].name);
+ netcdf_error(errmsg, status);
+ }
+ len = size;
+ return len;
+
+}; /* mpp_get_dimlen */
+
+/*********************************************************************
+ void mpp_get_var_value(int fid, int vid, void *data)
+ read part of var data, the part is defined by start and nread.
+*********************************************************************/
+void mpp_get_var_value(int fid, int vid, void *data)
+{
+ int status;
+ char errmsg[512];
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_value_block): 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_value_block): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+
+ switch(files[fid].var[vid].type) {
+ 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;
+ 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 );
+ 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",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+}; /* mpp_get_var_value */
+
+/*********************************************************************
+ void mpp_get_var_value_block(int fid, int vid, const size_t *start, const size_t *nread, void *data)
+ read part of var data, the part is defined by start and nread.
+*********************************************************************/
+void mpp_get_var_value_block(int fid, int vid, const size_t *start, const size_t *nread, void *data)
+{
+ int status;
+ char errmsg[512];
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_value_block): 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_value_block): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+
+ switch(files[fid].var[vid].type) {
+ 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;
+ 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 );
+ 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",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+}; /* mpp_get_var_value_block */
+
+/*******************************************************************
+ void mpp_get_var_att(int fid, int vid, const char *name, void *val)
+ get the attribute value of vid from file fid.
+ ******************************************************************/
+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;
+ 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 );
+ 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_global_att(int fid, const char *name, void *val)
+ get the global attribute from file fid.
+ ******************************************************************/
+void mpp_get_global_att(int fid, const char *name, void *val)
+{
+ int status;
+ char errmsg[512];
+ nc_type type;
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_global_att): invalid fid number, fid should be "
+ "a nonnegative integer that less than nfiles");
+ status = nc_inq_atttype(files[fid].ncid, NC_GLOBAL, name, &type);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_global_att): Error in getting type of global attribute %s in file %s ",
+ name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+ switch(type) {
+ case NC_DOUBLE: case NC_FLOAT:
+ status = nc_get_att_double(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 );
+ mpp_error(errmsg);
+ }
+
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_global_att): Error in getting value of global attribute %s from file %s",
+ name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+}
+
+/********************************************************************
+ int mpp_get_var_ndim(int fid, int vid)
+********************************************************************/
+int mpp_get_var_ndim(int fid, int vid)
+{
+ int status, ndim;
+ char errmsg[512];
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_ndim): 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_ndim): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+
+ status = nc_inq_varndims(files[fid].ncid, files[fid].var[vid].fldid, &ndim);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_var_ndim): Error in getting ndims of var %s from file %s",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+ return ndim;
+}
+
+/********************************************************************
+ nc_type mpp_get_var_type(int fid, int vid)
+ get var type
+********************************************************************/
+nc_type mpp_get_var_type(int fid, int vid)
+{
+ char errmsg[512];
+
+ nc_type vartype;
+ int status;
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_ndim): 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_ndim): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+
+ status = nc_inq_vartype(files[fid].ncid, files[fid].var[vid].fldid, &vartype);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_var_type): Error in getting type of var %s from file %s",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+ return vartype;
+}
+
+
+/*********************************************************************
+void mpp_get_var_dimname(int fid, int vid, int i, char *name)
+For each dimension we are assuming there is a 1-d field have the same name as the dimension.
+*********************************************************************/
+void mpp_get_var_dimname(int fid, int vid, int ind, char *name)
+{
+ int status, ncid, fldid, ndims, dims[4];
+ char errmsg[512];
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_dimname): 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_dimname): 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_inq_varndims(ncid, fldid, &ndims);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_var2D_dimname): Error in getting ndims of var %s from file %s",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+ if(ind < 0 || ind >= ndims) mpp_error("mpp_io(mpp_get_var_dimname): invalid ind value, ind should be between 0 and ndim-1");
+
+ status = nc_inq_vardimid(ncid,fldid,dims);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_var2D_dimname): Error in getting dimid of var %s from file %s",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+ status = nc_inq_dimname(ncid, dims[ind], name);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_var2D_dimname): Error in getting %d dimension name of var %s from file %s",
+ ind, files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+}; /* mpp_get_var_dimname */
+
+
+/***************************************************************************
+ char mpp_get_var_cart(int fid, int vid)
+ get the cart of the dimension variable
+ *************************************************************************/
+char mpp_get_var_cart(int fid, int vid)
+{
+ char cart;
+ int ncid, fldid, status;
+ char errmsg[512];
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_cart): 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_cart): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+ cart = 'N';
+
+ ncid = files[fid].ncid;
+ fldid = files[fid].var[vid].fldid;
+ status = nc_get_att_text(ncid, fldid, "cartesian_axis", &cart);
+ if(status != NC_NOERR)status = nc_get_att_text(ncid, fldid, "axis", &cart);
+ if(status != NC_NOERR){
+ sprintf(errmsg, "mpp_io(mpp_get_var_cart): Error in getting attribute cartesian_axis/axis of "
+ "dimension variable %s from file %s", files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+ return cart;
+}
+
+/***************************************************************************
+ void mpp_get_var_bndname(int fid, int vid, char *bndname)
+ Get the bound name of dimension variable if it exist, otherwise the value will be 'none'
+ for time axis, the bounds may be 'climatology'
+ **************************************************************************/
+void mpp_get_var_bndname(int fid, int vid, char *bndname)
+{
+ int ncid, fldid, status;
+ char errmsg[512], name[32];
+ size_t siz;
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_get_var_cart): 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_cart): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+ ncid = files[fid].ncid;
+ fldid = files[fid].var[vid].fldid;
+ strcpy(name, "climatology");
+ status = nc_inq_attlen(ncid, fldid, name, &siz);
+ if(status != NC_NOERR){
+ strcpy(name, "bounds");
+ status = nc_inq_attlen(ncid, fldid, name, &siz);
+ }
+ if(status != NC_NOERR){
+ strcpy(name, "edges");
+ status = nc_inq_attlen(ncid, fldid, name, &siz);
+ }
+ if(status != NC_NOERR) {
+ strcpy(bndname, "none");
+ }
+ else {
+ status = nc_get_att_text(ncid, fldid, name, bndname);
+ bndname[siz] = '\0';
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_get_var_bndname): Error in getting attribute %s of "
+ "dimension variable %s from file %s", name, files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+ }
+}
+
+/***************************************************************************
+ int mpp_var_att_exist(int fid, int vid, const char *att)
+ check the field var has the attribute "att" or not.
+***************************************************************************/
+int mpp_var_att_exist(int fid, int vid, 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");
+ if(vid<0 || vid >=files[fid].nvar) mpp_error("mpp_io(mpp_var_att_exist): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+
+ status = nc_inq_att(files[fid].ncid, files[fid].var[vid].fldid, att, &atttype, &attlen);
+ if(status == NC_NOERR)
+ return 1;
+ else
+ return 0;
+
+}; /* mpp_att_exist */
+
+
+/*******************************************************************************/
+/* */
+/* The following are routines to write out data */
+/* */
+/*******************************************************************************/
+
+/********************************************************************
+ int mpp_def_dim(int fid, char* name, int size)
+ define dimension.
+********************************************************************/
+int mpp_def_dim(int fid, const char* name, int size) {
+ int dimid, status;
+ char errmsg[512];
+
+ if( mpp_pe() != mpp_root_pe() ) return 0;
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_def_dim): invalid fid number, fid should be "
+ "a nonnegative integer that less than nfiles");
+
+ status = nc_def_dim(files[fid].ncid, name, size, &dimid);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_def_dim): Error in defining dimension %s of file %s",
+ name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+ return dimid;
+} /* mpp_def_dim */
+
+/********************************************************************
+ int mpp_def_var(nt fid, const char* name, int type, int ndim, int *dims, int natts ... )
+ define metadata of field.
+********************************************************************/
+int mpp_def_var(int fid, const char* name, nc_type type, int ndim, const int *dims, int natts, ...) {
+ int fldid, status, i, vid, ncid;
+ va_list ap;
+ char errmsg[512];
+
+ if( mpp_pe() != mpp_root_pe() ) return 0;
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_def_var): invalid fid number, fid should be "
+ "a nonnegative integer that less than nfiles");
+
+ ncid = files[fid].ncid;
+ status = nc_def_var(ncid, name, type, ndim, dims, &fldid);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_def_var): Error in defining var %s of file %s",
+ name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+ vid = files[fid].nvar;
+ files[fid].nvar++;
+ if(files[fid].nvar > MAXVAR ) mpp_error("mpp_io(mpp_def_var): nvar is larger than MAXVAR, increase MAXVAR");
+ files[fid].var[vid].fldid = fldid;
+ files[fid].var[vid].type = type;
+ strcpy(files[fid].var[vid].name, name);
+
+ va_start(ap, natts);
+ for( i=0; i<natts; i++) {
+ char* attname = va_arg(ap, char*);
+ char* attval = va_arg(ap, char*);
+ if( attname == NULL || attval == NULL) {
+ mpp_error("mpp_io: attribute name and attribute value not defined suitably, check the arguments list.");
+ }
+ status = nc_put_att_text(ncid,fldid,attname,strlen(attval),attval);
+ if(status != NC_NOERR ) {
+ sprintf(errmsg, "mpp_io(mpp_def_var): Error in put attribute %s of var %s of file %s",
+ attname, name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+ }
+ va_end(ap);
+ return vid;
+} /* mpp_define_var */
+
+/*********************************************************************
+ void mpp_def_global_att(int fid, const char *name, const char *val)
+ write out global attribute
+ ********************************************************************/
+void mpp_def_global_att(int fid, const char *name, const char *val)
+{
+ size_t status;
+ char errmsg[512];
+
+ if( mpp_pe() != mpp_root_pe() ) return;
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_def_global_att): invalid fid number, fid should be "
+ "a nonnegative integer that less than nfiles");
+ status = nc_put_att_text(files[fid].ncid, NC_GLOBAL, name, strlen(val), val);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_def_global_att): Error in put glboal attribute %s of file %s",
+ name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+}; /* mpp_def_global_att */
+
+/**********************************************************************
+ void mpp_copy_var_att(fid_in, fid_out)
+ copy all the field attribute from infile to outfile
+**********************************************************************/
+void mpp_copy_var_att(int fid_in, int vid_in, int fid_out, int vid_out)
+{
+ int natt, status, i, ncid_in, ncid_out, fldid_in, fldid_out;
+ char name[256];
+ char errmsg[512];
+
+ if( mpp_pe() != mpp_root_pe() ) return;
+
+ if(fid_in<0 || fid_in >=nfiles) mpp_error("mpp_io(mpp_copy_var_att): invalid fid_in number, fid should be "
+ "a nonnegative integer that less than nfiles");
+ if(fid_out<0 || fid_out >=nfiles) mpp_error("mpp_io(mpp_copy_var_att): invalid fid_out number, fid should be "
+ "a nonnegative integer that less than nfiles");
+
+ ncid_in = files[fid_in].ncid;
+ ncid_out = files[fid_out].ncid;
+ fldid_in = files[fid_in].var[vid_in].fldid;
+ fldid_out = files[fid_out].var[vid_out].fldid;
+
+ status = nc_inq_varnatts(ncid_in, fldid_in, &natt);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_copy_var_att): Error in inquiring natts of var %s of file %s",
+ files[fid_in].var[vid_in].name, files[fid_in].name );
+ netcdf_error(errmsg, status);
+ }
+
+ for(i=0; i<natt; i++) {
+ status = nc_inq_attname(ncid_in, fldid_in, i, name);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_copy_var_att): Error in inquiring %d attname of var %s of file %s", i,
+ files[fid_in].var[vid_in].name, files[fid_in].name );
+ netcdf_error(errmsg, status);
+ }
+ status = nc_copy_att(ncid_in, fldid_in, name, ncid_out, fldid_out);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_copy_var_att): Error in copying att %s of var %s of file %s", name,
+ files[fid_in].var[vid_in].name, files[fid_in].name );
+ netcdf_error(errmsg, status);
+ }
+ }
+
+}; /* mpp_copy_field_att */
+
+
+/**********************************************************************
+ void mpp_copy_global_att(fid_in, fid_out)
+ copy all the global attribute from infile to outfile
+**********************************************************************/
+void mpp_copy_global_att(int fid_in, int fid_out)
+{
+ int natt, status, i, ncid_in, ncid_out;
+ char name[256], errmsg[512];
+
+ if( mpp_pe() != mpp_root_pe() ) return;
+
+ if(fid_in<0 || fid_in >=nfiles) mpp_error("mpp_io(mpp_copy_global_att): invalid fid_in number, fid should be "
+ "a nonnegative integer that less than nfiles");
+ if(fid_out<0 || fid_out >=nfiles) mpp_error("mpp_io(mpp_copy_global_att): invalid fid_out number, fid should be "
+ "a nonnegative integer that less than nfiles");
+ ncid_in = files[fid_in].ncid;
+ ncid_out = files[fid_out].ncid;
+
+ status = nc_inq_varnatts(ncid_in, NC_GLOBAL, &natt);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_copy_global_att): Error in inquiring natts(global) of file %s",
+ files[fid_in].name );
+ netcdf_error(errmsg, status);
+ }
+
+ for(i=0; i<natt; i++) {
+ status = nc_inq_attname(ncid_in, NC_GLOBAL, i, name);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_copy_global_att): Error in inquiring %d global attname of file %s", i,
+ files[fid_in].name );
+ netcdf_error(errmsg, status);
+ }
+
+ status = nc_copy_att(ncid_in, NC_GLOBAL, name, ncid_out, NC_GLOBAL);
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_copy_global_att): Error in copying %d global att %s of file %s", i, name,
+ files[fid_in].name );
+ netcdf_error(errmsg, status);
+ }
+ }
+
+}; /* mpp_copy_global_att */
+
+/*********************************************************************
+ void mpp_put_var_value(int fid, int vid, const void* data)
+ write out string-type data
+
+ ********************************************************************/
+void mpp_put_var_value(int fid, int vid, const void* data)
+{
+ size_t status;
+ char errmsg[600];
+
+ if( mpp_pe() != mpp_root_pe() ) return;
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_put_var_value): 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_put_var_value): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+
+ switch(files[fid].var[vid].type) {
+ 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;
+ 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 );
+ mpp_error(errmsg);
+ }
+
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_put_var_value): Error in putting value of variable %s from file %s",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+}; /* mpp_put_var_value*/
+
+/*********************************************************************
+ void mpp_put_var_value_block(int fid, int vid, const size_t *start, const size_t *nread, void *data)
+ read part of var data, the part is defined by start and nread.
+*********************************************************************/
+void mpp_put_var_value_block(int fid, int vid, const size_t *start, const size_t *nwrite, const void *data)
+{
+ int status;
+ char errmsg[512];
+
+ if( mpp_pe() != mpp_root_pe() ) return;
+
+ if(fid<0 || fid >=nfiles) mpp_error("mpp_io(mpp_put_var_value_block): 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_put_var_value_block): invalid vid number, vid should be "
+ "a nonnegative integer that less than nvar");
+
+ switch(files[fid].var[vid].type) {
+ 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;
+ case NC_CHAR:
+ status = nc_put_vara_text(files[fid].ncid, files[fid].var[vid].fldid, start, nwrite, data);
+ 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 );
+ mpp_error(errmsg);
+ }
+
+ if(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_put_var_value_block): Error in putting value of variable %s from file %s",
+ files[fid].var[vid].name, files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+
+}; /* mpp_put_var_value_block */
+
+/*********************************************************************
+ void mpp_end_def(int ncid)
+ end the definition of netcdf file with ncid.
+ *******************************************************************/
+void mpp_end_def(int fid) {
+ int status;
+ char errmsg[512];
+
+ 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(status != NC_NOERR) {
+ sprintf(errmsg, "mpp_io(mpp_end_def): Error in end definition of file %s", files[fid].name );
+ netcdf_error(errmsg, status);
+ }
+} /* mpp_end_def */
+
+/*******************************************************************************
+ int mpp_file_exist(const char *file)
+ check to see if file exist or not.
+*******************************************************************************/
+int mpp_file_exist(const char *file)
+{
+ int status, ncid;
+
+ status = nc_open(file,NC_NOWRITE, &ncid);
+ if(status == NC_NOERR) {
+ status = nc_close(ncid);
+ if(status != NC_NOERR) netcdf_error("mpp_file_exist(mpp_io):in closing file", status);
+ return 1;
+ }
+ else
+ return 0;
+};
+
+int mpp_field_exist(const char *file, const char *field)
+{
+ int fid, status, varid;
+
+ fid = mpp_open(file, MPP_READ);
+ status = nc_inq_varid(files[fid].ncid, field, &varid);
+ mpp_close(fid);
+
+ if(status == NC_NOERR)
+ return 1;
+ else
+ return 0;
+
+}
+
+
+
+
diff --git a/gridspec_tools_20080702/tools/shared/mpp_io.h b/gridspec_tools_20080702/tools/shared/mpp_io.h
new file mode 100644
index 0000000..cd3ee03
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/mpp_io.h
@@ -0,0 +1,44 @@
+/****************************************************************
+ mpp_io.h
+ This headers defines interface to read and write netcdf file. All the data
+will be written out from root pe.
+
+ contact: Zhi.Liang at noaa.gov
+
+****************************************************************/
+#ifndef MPP_IO_H_
+#define MPP_IO_H_
+#include <netcdf.h>
+
+#define MPP_WRITE 100
+#define MPP_READ 200
+#define MPP_INT NC_INT
+#define MPP_DOUBLE NC_DOUBLE
+#define MPP_CHAR NC_CHAR
+
+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_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_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);
+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_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_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);
+int mpp_file_exist(const char *file);
+int mpp_field_exist(const char *file, const char *field);
+#endif
diff --git a/gridspec_tools_20080702/tools/shared/tool_util.c b/gridspec_tools_20080702/tools/shared/tool_util.c
new file mode 100644
index 0000000..e4aba73
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/tool_util.c
@@ -0,0 +1,5969 @@
+
+
+#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
new file mode 100644
index 0000000..bc5b8cf
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/tool_util.h
@@ -0,0 +1,69 @@
+/***********************************************************************
+ 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/topog.c b/gridspec_tools_20080702/tools/shared/topog.c
new file mode 100644
index 0000000..0f9e5a0
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/topog.c
@@ -0,0 +1,542 @@
+#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/shared/transfer_to_mosaic.c b/gridspec_tools_20080702/tools/shared/transfer_to_mosaic.c
new file mode 100644
index 0000000..fecdaf0
--- /dev/null
+++ b/gridspec_tools_20080702/tools/shared/transfer_to_mosaic.c
@@ -0,0 +1,1278 @@
+#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
new file mode 100644
index 0000000..ab633ca
--- /dev/null
+++ b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.am
@@ -0,0 +1,39 @@
+## 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
new file mode 100644
index 0000000..e04fd7a
--- /dev/null
+++ b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/Makefile.in
@@ -0,0 +1,523 @@
+# 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
new file mode 100644
index 0000000..07239d5
--- /dev/null
+++ b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/gs_transfer_to_mosaic.c
@@ -0,0 +1,73 @@
+#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
new file mode 100644
index 0000000..fecdaf0
--- /dev/null
+++ b/gridspec_tools_20080702/tools/transfer_to_mosaic_grid/transfer_to_mosaic.c
@@ -0,0 +1,1278 @@
+#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
new file mode 100755
index 0000000..a5897de
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,519 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2006-12-25.00
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ trap '(exit $?); exit' 1 2 13 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names starting with `-'.
+ case $src in
+ -*) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+
+ dst=$dst_arg
+ # Protect names starting with `-'.
+ case $dst in
+ -*) dst=./$dst;;
+ esac
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writeable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ -*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test -z "$d" && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/ltmain.sh b/ltmain.sh
new file mode 100755
index 0000000..174e492
--- /dev/null
+++ b/ltmain.sh
@@ -0,0 +1,7874 @@
+# Generated from ltmain.m4sh.
+
+# ltmain.sh (GNU libtool) 2.2.4
+# Written by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions. There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool 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.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+# --config show all configuration variables
+# --debug enable verbose shell tracing
+# -n, --dry-run display commands without modifying any files
+# --features display basic configuration information and exit
+# --mode=MODE use operation mode MODE
+# --preserve-dup-deps don't remove duplicate dependency libraries
+# --quiet, --silent don't print informational messages
+# --tag=TAG use configuration variables from tag TAG
+# -v, --verbose print informational messages (default)
+# --version print version information
+# -h, --help print short or long help message
+#
+# MODE must be one of the following:
+#
+# clean remove files from the build directory
+# compile compile a source file into a libtool object
+# execute automatically set library path, then run a program
+# finish complete the installation of libtool libraries
+# install install libraries or executables
+# link create a library or an executable
+# uninstall remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+# host-triplet: $host
+# shell: $SHELL
+# compiler: $LTCC
+# compiler flags: $LTCFLAGS
+# linker: $LD (gnu? $with_gnu_ld)
+# $progname: (GNU libtool) 2.2.4
+# automake: $automake_version
+# autoconf: $autoconf_version
+#
+# Report bugs to <bug-libtool at gnu.org>.
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=2.2.4
+TIMESTAMP=""
+package_revision=1.2976
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# NLS nuisances: We save the old values to restore during execute mode.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+ eval "if test \"\${$lt_var+set}\" = set; then
+ save_$lt_var=\$$lt_var
+ $lt_var=C
+ export $lt_var
+ lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+ lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+ fi"
+done
+
+$lt_unset CDPATH
+
+
+
+
+
+: ${CP="cp -f"}
+: ${ECHO="echo"}
+: ${EGREP="/usr/bin/grep -E"}
+: ${FGREP="/usr/bin/grep -F"}
+: ${GREP="/usr/bin/grep"}
+: ${LN_S="ln -s"}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SED="/opt/local/bin/gsed"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" $lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+# In the unlikely event $progname began with a '-', it would play havoc with
+# func_echo (imagine progname=-n), so we prepend ./ in that case:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+case $progname in
+ -*) progname=./$progname ;;
+esac
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+ [\\/]*|[A-Za-z]:\\*) ;;
+ *[\\/]*)
+ progdir=$func_dirname_result
+ progdir=`cd "$progdir" && pwd`
+ progpath="$progdir/$progname"
+ ;;
+ *)
+ save_IFS="$IFS"
+ IFS=:
+ for progdir in $PATH; do
+ IFS="$save_IFS"
+ test -x "$progdir/$progname" && break
+ done
+ IFS="$save_IFS"
+ test -n "$progdir" || progdir=`pwd`
+ progpath="$progdir/$progname"
+ ;;
+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'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+ s/$bs4/&\\
+/g
+ s/^$bs2$dollar/$bs&/
+ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+ s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+ $ECHO "$progname${mode+: }$mode: $*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+ $opt_verbose && func_echo ${1+"$@"}
+
+ # A bug in bash halts the script if the last line of a function
+ # fails when set -e is in force, so we need another command to
+ # work around that:
+ :
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+ $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+ $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
+
+ # bash bug again:
+ :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+ func_error ${1+"$@"}
+ exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+ func_error ${1+"$@"}
+ func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information." ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+ $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+ my_directory_path="$1"
+ my_dir_list=
+
+ if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+ # Protect directory names starting with `-'
+ case $my_directory_path in
+ -*) my_directory_path="./$my_directory_path" ;;
+ esac
+
+ # While some portion of DIR does not yet exist...
+ while test ! -d "$my_directory_path"; do
+ # ...make a list in topmost first order. Use a colon delimited
+ # list incase some portion of path contains whitespace.
+ my_dir_list="$my_directory_path:$my_dir_list"
+
+ # If the last portion added has no slash in it, the list is done
+ case $my_directory_path in */*) ;; *) break ;; esac
+
+ # ...otherwise throw away the child directory and loop
+ my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
+ done
+ my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
+
+ save_mkdir_p_IFS="$IFS"; IFS=':'
+ for my_dir in $my_dir_list; do
+ IFS="$save_mkdir_p_IFS"
+ # mkdir can fail with a `File exist' error if two processes
+ # try to create one of the directories concurrently. Don't
+ # stop in that case!
+ $MKDIR "$my_dir" 2>/dev/null || :
+ done
+ IFS="$save_mkdir_p_IFS"
+
+ # Bail out if we (or some other process) failed to create a directory.
+ test -d "$my_directory_path" || \
+ func_fatal_error "Failed to create \`$1'"
+ fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible. If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+ my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+ if test "$opt_dry_run" = ":"; then
+ # Return a directory name, but don't create it in dry-run mode
+ my_tmpdir="${my_template}-$$"
+ else
+
+ # If mktemp works, use that first and foremost
+ my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+ if test ! -d "$my_tmpdir"; then
+ # Failing that, at least try and use $RANDOM to avoid a race
+ my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+ save_mktempdir_umask=`umask`
+ umask 0077
+ $MKDIR "$my_tmpdir"
+ umask $save_mktempdir_umask
+ fi
+
+ # If we're not in dry-run mode, bomb out on failure
+ test -d "$my_tmpdir" || \
+ func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+ fi
+
+ $ECHO "X$my_tmpdir" | $Xsed
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+ case $1 in
+ *[\\\`\"\$]*)
+ func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
+ *)
+ func_quote_for_eval_unquoted_result="$1" ;;
+ esac
+
+ case $func_quote_for_eval_unquoted_result in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting, command substitution and and variable
+ # expansion for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+ ;;
+ *)
+ func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+ esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+ case $1 in
+ *[\\\`\"]*)
+ my_arg=`$ECHO "X$1" | $Xsed \
+ -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+ *)
+ my_arg="$1" ;;
+ esac
+
+ case $my_arg in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting and command substitution for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ my_arg="\"$my_arg\""
+ ;;
+ esac
+
+ func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$my_cmd"
+ my_status=$?
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it. Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$lt_user_locale
+ $my_cmd"
+ my_status=$?
+ eval "$lt_safe_locale"
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+
+
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+ $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
+ s/^# //
+ s/^# *$//
+ s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+ p
+ }' < "$progpath"
+ exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+ $SED -n '/^# Usage:/,/# -h/ {
+ s/^# //
+ s/^# *$//
+ s/\$progname/'$progname'/
+ p
+ }' < "$progpath"
+ $ECHO
+ $ECHO "run \`$progname --help | more' for full usage"
+ exit $?
+}
+
+# func_help
+# Echo long help message to standard output and exit.
+func_help ()
+{
+ $SED -n '/^# Usage:/,/# Report bugs to/ {
+ s/^# //
+ s/^# *$//
+ s*\$progname*'$progname'*
+ s*\$host*'"$host"'*
+ s*\$SHELL*'"$SHELL"'*
+ s*\$LTCC*'"$LTCC"'*
+ s*\$LTCFLAGS*'"$LTCFLAGS"'*
+ s*\$LD*'"$LD"'*
+ s/\$with_gnu_ld/'"$with_gnu_ld"'/
+ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
+ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+ p
+ }' < "$progpath"
+ exit $?
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+ func_error "missing argument for $1"
+ exit_cmd=exit
+}
+
+exit_cmd=:
+
+
+
+
+
+# Check that we have a working $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, and then maybe $ECHO will work.
+ exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+$*
+EOF
+ exit $EXIT_SUCCESS
+fi
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+# $mode is unset
+nonopt=
+execute_dlfiles=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+opt_dry_run=false
+opt_duplicate_deps=false
+opt_silent=false
+opt_debug=:
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+ func_error ${1+"$@"}
+ func_error "See the $PACKAGE documentation for more information."
+ func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+ re_begincf='^# ### BEGIN LIBTOOL'
+ re_endcf='^# ### END LIBTOOL'
+
+ # Default configuration.
+ $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+ # Now print the configurations for the tags.
+ for tagname in $taglist; do
+ $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+ done
+
+ exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+ $ECHO "host: $host"
+ if test "$build_libtool_libs" = yes; then
+ $ECHO "enable shared libraries"
+ else
+ $ECHO "disable shared libraries"
+ fi
+ if test "$build_old_libs" = yes; then
+ $ECHO "enable static libraries"
+ else
+ $ECHO "disable static libraries"
+ fi
+
+ exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+ # Global variable:
+ tagname="$1"
+
+ re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+ re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+ sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+ # Validate tagname.
+ case $tagname in
+ *[!-_A-Za-z0-9,/]*)
+ func_fatal_error "invalid tag name: $tagname"
+ ;;
+ esac
+
+ # Don't test for the "default" C tag, as we know it's
+ # there but not specially marked.
+ case $tagname in
+ CC) ;;
+ *)
+ if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+ taglist="$taglist $tagname"
+
+ # Evaluate the configuration. Be careful to quote the path
+ # and the sed script, to avoid splitting on whitespace, but
+ # also don't use non-portable quotes within backquotes within
+ # quotes we have to do it in 2 steps:
+ extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+ eval "$extractedcf"
+ else
+ func_error "ignoring unknown tag $tagname"
+ fi
+ ;;
+ esac
+}
+
+# Parse options once, thoroughly. This comes as soon as possible in
+# the script to make things like `libtool --version' happen quickly.
+{
+
+ # Shorthand for --mode=foo, only valid as the first argument
+ case $1 in
+ clean|clea|cle|cl)
+ shift; set dummy --mode clean ${1+"$@"}; shift
+ ;;
+ compile|compil|compi|comp|com|co|c)
+ shift; set dummy --mode compile ${1+"$@"}; shift
+ ;;
+ execute|execut|execu|exec|exe|ex|e)
+ shift; set dummy --mode execute ${1+"$@"}; shift
+ ;;
+ finish|finis|fini|fin|fi|f)
+ shift; set dummy --mode finish ${1+"$@"}; shift
+ ;;
+ install|instal|insta|inst|ins|in|i)
+ shift; set dummy --mode install ${1+"$@"}; shift
+ ;;
+ link|lin|li|l)
+ shift; set dummy --mode link ${1+"$@"}; shift
+ ;;
+ uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+ shift; set dummy --mode uninstall ${1+"$@"}; shift
+ ;;
+ esac
+
+ # Parse non-mode specific arguments:
+ while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --config) func_config ;;
+
+ --debug) preserve_args="$preserve_args $opt"
+ func_echo "enabling shell trace mode"
+ opt_debug='set -x'
+ $opt_debug
+ ;;
+
+ -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
+ execute_dlfiles="$execute_dlfiles $1"
+ shift
+ ;;
+
+ --dry-run | -n) opt_dry_run=: ;;
+ --features) func_features ;;
+ --finish) mode="finish" ;;
+
+ --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
+ case $1 in
+ # Valid mode arguments:
+ clean) ;;
+ compile) ;;
+ execute) ;;
+ finish) ;;
+ install) ;;
+ link) ;;
+ relink) ;;
+ uninstall) ;;
+
+ # Catch anything else as an error
+ *) func_error "invalid argument for $opt"
+ exit_cmd=exit
+ break
+ ;;
+ esac
+
+ mode="$1"
+ shift
+ ;;
+
+ --preserve-dup-deps)
+ opt_duplicate_deps=: ;;
+
+ --quiet|--silent) preserve_args="$preserve_args $opt"
+ opt_silent=:
+ ;;
+
+ --verbose| -v) preserve_args="$preserve_args $opt"
+ opt_silent=false
+ ;;
+
+ --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
+ preserve_args="$preserve_args $opt $1"
+ func_enable_tag "$1" # tagname is set here
+ shift
+ ;;
+
+ # Separate optargs to long options:
+ -dlopen=*|--mode=*|--tag=*)
+ func_opt_split "$opt"
+ set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
+ shift
+ ;;
+
+ -\?|-h) func_usage ;;
+ --help) opt_help=: ;;
+ --version) func_version ;;
+
+ -*) func_fatal_help "unrecognized option \`$opt'" ;;
+
+ *) nonopt="$opt"
+ break
+ ;;
+ esac
+ done
+
+
+ case $host in
+ *cygwin* | *mingw* | *pw32*)
+ # don't eliminate duplications in $postdeps and $predeps
+ opt_duplicate_compiler_generated_deps=:
+ ;;
+ *)
+ opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
+ ;;
+ esac
+
+ # Having warned about all mis-specified options, bail out if
+ # anything was wrong.
+ $exit_cmd $EXIT_FAILURE
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+ if test "$package_revision" != "$macro_revision"; then
+ if test "$VERSION" != "$macro_version"; then
+ if test -z "$macro_version"; then
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ fi
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+ fi
+
+ exit $EXIT_MISMATCH
+ fi
+}
+
+
+## ----------- ##
+## Main. ##
+## ----------- ##
+
+$opt_help || {
+ # Sanity checks first:
+ func_check_version_match
+
+ if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ func_fatal_configuration "not configured to build any kind of library"
+ fi
+
+ test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+ # Darwin sucks
+ eval std_shrext=\"$shrext_cmds\"
+
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$execute_dlfiles" && test "$mode" != execute; then
+ func_error "unrecognized option \`-dlopen'"
+ $ECHO "$help" 1>&2
+ exit $EXIT_FAILURE
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+ $SED -e 4q "$1" 2>/dev/null \
+ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs. To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway. Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+ lalib_p=no
+ if test -r "$1" && exec 5<&0 <"$1"; then
+ for lalib_p_l in 1 2 3 4
+ do
+ read lalib_p_line
+ case "$lalib_p_line" in
+ \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+ esac
+ done
+ exec 0<&5 5<&-
+ fi
+ test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+ func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+ func_ltwrapper_exec_suffix=
+ case $1 in
+ *.exe) ;;
+ *) func_ltwrapper_exec_suffix=.exe ;;
+ esac
+ $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+ func_ltwrapper_scriptname_result=""
+ if func_ltwrapper_executable_p "$1"; then
+ func_dirname_and_basename "$1" "" "."
+ func_stripname '' '.exe' "$func_basename_result"
+ func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+ fi
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+ func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+ $opt_debug
+ save_ifs=$IFS; IFS='~'
+ for cmd in $1; do
+ IFS=$save_ifs
+ eval cmd=\"$cmd\"
+ func_show_eval "$cmd" "${2-:}"
+ done
+ IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)! Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+ $opt_debug
+ case $1 in
+ */* | *\\*) . "$1" ;;
+ *) . "./$1" ;;
+ esac
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+ $opt_debug
+ if test -n "$available_tags" && test -z "$tagname"; then
+ CC_quoted=
+ for arg in $CC; do
+ func_quote_for_eval "$arg"
+ CC_quoted="$CC_quoted $func_quote_for_eval_result"
+ done
+ case $@ in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+ CC_quoted=
+ for arg in $CC; do
+ # Double-quote args containing other shell metacharacters.
+ func_quote_for_eval "$arg"
+ CC_quoted="$CC_quoted $func_quote_for_eval_result"
+ done
+ case "$@ " in
+ " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
+ # The compiler in the base compile command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ func_echo "unable to infer tagged configuration"
+ func_fatal_error "specify a tag with \`--tag'"
+# else
+# func_verbose "using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+ write_libobj=${1}
+ if test "$build_libtool_libs" = yes; then
+ write_lobj=\'${2}\'
+ else
+ write_lobj=none
+ fi
+
+ if test "$build_old_libs" = yes; then
+ write_oldobj=\'${3}\'
+ else
+ write_oldobj=none
+ fi
+
+ $opt_dry_run || {
+ cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+ $MV "${write_libobj}T" "${write_libobj}"
+ }
+}
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+ $opt_debug
+ # Get the compilation command and the source file.
+ base_compile=
+ srcfile="$nonopt" # always keep a non-empty value in "srcfile"
+ suppress_opt=yes
+ suppress_output=
+ arg_mode=normal
+ libobj=
+ later=
+ pie_flag=
+
+ for arg
+ do
+ case $arg_mode in
+ arg )
+ # do not "continue". Instead, add this to base_compile
+ lastarg="$arg"
+ arg_mode=normal
+ ;;
+
+ target )
+ libobj="$arg"
+ arg_mode=normal
+ continue
+ ;;
+
+ normal )
+ # Accept any command-line options.
+ case $arg in
+ -o)
+ test -n "$libobj" && \
+ func_fatal_error "you cannot specify \`-o' more than once"
+ arg_mode=target
+ continue
+ ;;
+
+ -pie | -fpie | -fPIE)
+ pie_flag="$pie_flag $arg"
+ continue
+ ;;
+
+ -shared | -static | -prefer-pic | -prefer-non-pic)
+ later="$later $arg"
+ continue
+ ;;
+
+ -no-suppress)
+ suppress_opt=no
+ continue
+ ;;
+
+ -Xcompiler)
+ arg_mode=arg # the next one goes into the "base_compile" arg list
+ continue # The current "srcfile" will either be retained or
+ ;; # replaced later. I would guess that would be a bug.
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ lastarg=
+ save_ifs="$IFS"; IFS=','
+ for arg in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$arg"
+ lastarg="$lastarg $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$lastarg"
+ lastarg=$func_stripname_result
+
+ # Add the arguments to base_compile.
+ base_compile="$base_compile $lastarg"
+ continue
+ ;;
+
+ *)
+ # Accept the current argument as the source file.
+ # The previous "srcfile" becomes the current argument.
+ #
+ lastarg="$srcfile"
+ srcfile="$arg"
+ ;;
+ esac # case $arg
+ ;;
+ esac # case $arg_mode
+
+ # Aesthetically quote the previous argument.
+ func_quote_for_eval "$lastarg"
+ base_compile="$base_compile $func_quote_for_eval_result"
+ done # for arg
+
+ case $arg_mode in
+ arg)
+ func_fatal_error "you must specify an argument for -Xcompile"
+ ;;
+ target)
+ func_fatal_error "you must specify a target with \`-o'"
+ ;;
+ *)
+ # Get the name of the library object.
+ test -z "$libobj" && {
+ func_basename "$srcfile"
+ libobj="$func_basename_result"
+ }
+ ;;
+ esac
+
+ # Recognize several different file suffixes.
+ # If the user specifies -o file.o, it is replaced with file.lo
+ case $libobj in
+ *.[cCFSifmso] | \
+ *.ada | *.adb | *.ads | *.asm | \
+ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+ *.[fF][09]? | *.for | *.java | *.obj | *.sx)
+ func_xform "$libobj"
+ libobj=$func_xform_result
+ ;;
+ esac
+
+ case $libobj in
+ *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+ *)
+ func_fatal_error "cannot determine name of library object from \`$libobj'"
+ ;;
+ esac
+
+ func_infer_tag $base_compile
+
+ for arg in $later; do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ continue
+ ;;
+
+ -static)
+ build_libtool_libs=no
+ build_old_libs=yes
+ continue
+ ;;
+
+ -prefer-pic)
+ pic_mode=yes
+ continue
+ ;;
+
+ -prefer-non-pic)
+ pic_mode=no
+ continue
+ ;;
+ esac
+ done
+
+ func_quote_for_eval "$libobj"
+ test "X$libobj" != "X$func_quote_for_eval_result" \
+ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
+ && func_warning "libobj name \`$libobj' may not contain shell special characters."
+ func_dirname_and_basename "$obj" "/" ""
+ objname="$func_basename_result"
+ xdir="$func_dirname_result"
+ lobj=${xdir}$objdir/$objname
+
+ test -z "$base_compile" && \
+ func_fatal_help "you must specify a compilation command"
+
+ # Delete any leftover library objects.
+ if test "$build_old_libs" = yes; then
+ removelist="$obj $lobj $libobj ${libobj}T"
+ else
+ removelist="$lobj $libobj ${libobj}T"
+ fi
+
+ # On Cygwin there's no "real" PIC flag so we must build both object types
+ case $host_os in
+ cygwin* | mingw* | pw32* | os2*)
+ pic_mode=default
+ ;;
+ esac
+ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+ # non-PIC code in shared libraries is not supported
+ pic_mode=default
+ fi
+
+ # Calculate the filename of the output object if compiler does
+ # not support -o with -c
+ if test "$compiler_c_o" = no; then
+ output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+ lockfile="$output_obj.lock"
+ else
+ output_obj=
+ need_locks=no
+ lockfile=
+ fi
+
+ # Lock this critical section if it is needed
+ # We use this script file to make the link, it avoids creating a new file
+ if test "$need_locks" = yes; then
+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+ func_echo "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ elif test "$need_locks" = warn; then
+ if test -f "$lockfile"; then
+ $ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+ removelist="$removelist $output_obj"
+ $ECHO "$srcfile" > "$lockfile"
+ fi
+
+ $opt_dry_run || $RM $removelist
+ removelist="$removelist $lockfile"
+ trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+ if test -n "$fix_srcfile_path"; then
+ eval srcfile=\"$fix_srcfile_path\"
+ fi
+ func_quote_for_eval "$srcfile"
+ qsrcfile=$func_quote_for_eval_result
+
+ # Only build a PIC object if we are building libtool libraries.
+ if test "$build_libtool_libs" = yes; then
+ # Without this assignment, base_compile gets emptied.
+ fbsd_hideous_sh_bug=$base_compile
+
+ if test "$pic_mode" != no; then
+ command="$base_compile $qsrcfile $pic_flag"
+ else
+ # Don't build PIC code
+ command="$base_compile $qsrcfile"
+ fi
+
+ func_mkdir_p "$xdir$objdir"
+
+ if test -z "$output_obj"; then
+ # Place PIC objects in $objdir
+ command="$command -o $lobj"
+ fi
+
+ func_show_eval_locale "$command" \
+ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed, then go on to compile the next one
+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+ func_show_eval '$MV "$output_obj" "$lobj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+
+ # Allow error messages only from the first compilation.
+ if test "$suppress_opt" = yes; then
+ suppress_output=' >/dev/null 2>&1'
+ fi
+ fi
+
+ # Only build a position-dependent object if we build old libraries.
+ if test "$build_old_libs" = yes; then
+ if test "$pic_mode" != yes; then
+ # Don't build PIC code
+ command="$base_compile $qsrcfile$pie_flag"
+ else
+ command="$base_compile $qsrcfile $pic_flag"
+ fi
+ if test "$compiler_c_o" = yes; then
+ command="$command -o $obj"
+ fi
+
+ # Suppress compiler output if we already did a PIC compilation.
+ command="$command$suppress_output"
+ func_show_eval_locale "$command" \
+ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed
+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+ func_show_eval '$MV "$output_obj" "$obj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+ fi
+
+ $opt_dry_run || {
+ func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ removelist=$lockfile
+ $RM "$lockfile"
+ fi
+ }
+
+ exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+test "$mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+ # We need to display help for each of the modes.
+ case $mode in
+ "")
+ # Generic help is extracted from the usage comments
+ # at the start of this file.
+ func_help
+ ;;
+
+ clean)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ compile)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+ -o OUTPUT-FILE set the output file name to OUTPUT-FILE
+ -no-suppress do not suppress compiler output for multiple passes
+ -prefer-pic try to building PIC objects only
+ -prefer-non-pic try to building non-PIC objects only
+ -shared do not build a \`.o' file suitable for static linking
+ -static only build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+ ;;
+
+ execute)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+ -dlopen FILE add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+ ;;
+
+ finish)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges. Use
+the \`--dry-run' option if you just want to see what would be executed."
+ ;;
+
+ install)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command. The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+ -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+ ;;
+
+ link)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+ -all-static do not do any dynamic linking at all
+ -avoid-version do not add a version suffix if possible
+ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+ -export-symbols SYMFILE
+ try to export only the symbols listed in SYMFILE
+ -export-symbols-regex REGEX
+ try to export only the symbols matching REGEX
+ -LLIBDIR search LIBDIR for required installed libraries
+ -lNAME OUTPUT-FILE requires the installed library libNAME
+ -module build a library that can dlopened
+ -no-fast-install disable the fast-install mode
+ -no-install link a not-installable executable
+ -no-undefined declare that a library does not refer to external symbols
+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
+ -objectlist FILE Use a list of object files found in FILE to specify objects
+ -precious-files-regex REGEX
+ don't remove output files matching REGEX
+ -release RELEASE specify package release information
+ -rpath LIBDIR the created library will eventually be installed in LIBDIR
+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
+ -shared only do dynamic linking of libtool libraries
+ -shrext SUFFIX override the standard shared library file extension
+ -static do not do any dynamic linking of uninstalled libtool libraries
+ -static-libtool-libs
+ do not do any dynamic linking of libtool libraries
+ -version-info CURRENT[:REVISION[:AGE]]
+ specify library version info [each variable defaults to 0]
+ -weak LIBNAME declare that the target provides the LIBNAME interface
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename. Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+ ;;
+
+ uninstall)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ *)
+ func_fatal_help "invalid operation mode \`$mode'"
+ ;;
+ esac
+
+ $ECHO
+ $ECHO "Try \`$progname --help' for more information about other modes."
+
+ exit $?
+}
+
+ # Now that we've collected a possible --mode arg, show help if necessary
+ $opt_help && func_mode_help
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+ $opt_debug
+ # The first argument is the command name.
+ cmd="$nonopt"
+ test -z "$cmd" && \
+ func_fatal_help "you must specify a COMMAND"
+
+ # Handle -dlopen flags immediately.
+ for file in $execute_dlfiles; do
+ test -f "$file" \
+ || func_fatal_help "\`$file' is not a file"
+
+ dir=
+ case $file in
+ *.la)
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+ # Read the libtool library.
+ dlname=
+ library_names=
+ func_source "$file"
+
+ # Skip this library if it cannot be dlopened.
+ if test -z "$dlname"; then
+ # Warn if it was a shared library.
+ test -n "$library_names" && \
+ func_warning "\`$file' was not linked with \`-export-dynamic'"
+ continue
+ fi
+
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+
+ if test -f "$dir/$objdir/$dlname"; then
+ dir="$dir/$objdir"
+ else
+ if test ! -f "$dir/$dlname"; then
+ func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+ fi
+ fi
+ ;;
+
+ *.lo)
+ # Just add the directory containing the .lo file.
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ ;;
+
+ *)
+ func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+ continue
+ ;;
+ esac
+
+ # Get the absolute pathname.
+ absdir=`cd "$dir" && pwd`
+ test -n "$absdir" && dir="$absdir"
+
+ # Now add the directory to shlibpath_var.
+ if eval "test -z \"\$$shlibpath_var\""; then
+ eval "$shlibpath_var=\"\$dir\""
+ else
+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+ fi
+ done
+
+ # This variable tells wrapper scripts just to set shlibpath_var
+ # rather than running their programs.
+ libtool_execute_magic="$magic"
+
+ # Check if any of the arguments is a wrapper script.
+ args=
+ for file
+ do
+ case $file in
+ -*) ;;
+ *)
+ # Do a test to see if this is really a libtool program.
+ if func_ltwrapper_script_p "$file"; then
+ func_source "$file"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ elif func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ func_source "$func_ltwrapper_scriptname_result"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ fi
+ ;;
+ esac
+ # Quote arguments (to preserve shell metacharacters).
+ func_quote_for_eval "$file"
+ args="$args $func_quote_for_eval_result"
+ done
+
+ if test "X$opt_dry_run" = Xfalse; then
+ if test -n "$shlibpath_var"; then
+ # Export the shlibpath_var.
+ eval "export $shlibpath_var"
+ fi
+
+ # Restore saved environment variables
+ for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+ do
+ eval "if test \"\${save_$lt_var+set}\" = set; then
+ $lt_var=\$save_$lt_var; export $lt_var
+ else
+ $lt_unset $lt_var
+ fi"
+ done
+
+ # Now prepare to actually exec the command.
+ exec_cmd="\$cmd$args"
+ else
+ # Display what would be done.
+ if test -n "$shlibpath_var"; then
+ eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+ $ECHO "export $shlibpath_var"
+ fi
+ $ECHO "$cmd$args"
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+ $opt_debug
+ libdirs="$nonopt"
+ admincmds=
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ for dir
+ do
+ libdirs="$libdirs $dir"
+ done
+
+ for libdir in $libdirs; do
+ if test -n "$finish_cmds"; then
+ # Do each command in the finish commands.
+ func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+ fi
+ if test -n "$finish_eval"; then
+ # Do the single finish_eval.
+ eval cmds=\"$finish_eval\"
+ $opt_dry_run || eval "$cmds" || admincmds="$admincmds
+ $cmds"
+ fi
+ done
+ fi
+
+ # Exit here if they wanted silent mode.
+ $opt_silent && exit $EXIT_SUCCESS
+
+ $ECHO "X----------------------------------------------------------------------" | $Xsed
+ $ECHO "Libraries have been installed in:"
+ for libdir in $libdirs; do
+ $ECHO " $libdir"
+ done
+ $ECHO
+ $ECHO "If you ever happen to want to link against installed libraries"
+ $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
+ $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
+ $ECHO "flag during linking and do at least one of the following:"
+ if test -n "$shlibpath_var"; then
+ $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
+ $ECHO " during execution"
+ fi
+ if test -n "$runpath_var"; then
+ $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
+ $ECHO " during linking"
+ fi
+ if test -n "$hardcode_libdir_flag_spec"; then
+ libdir=LIBDIR
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ $ECHO " - use the \`$flag' linker flag"
+ fi
+ if test -n "$admincmds"; then
+ $ECHO " - have your system administrator run these commands:$admincmds"
+ fi
+ if test -f /etc/ld.so.conf; then
+ $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+ fi
+ $ECHO
+
+ $ECHO "See any operating system documentation about shared libraries for"
+ case $host in
+ solaris2.[6789]|solaris2.1[0-9])
+ $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+ $ECHO "pages."
+ ;;
+ *)
+ $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
+ ;;
+ esac
+ $ECHO "X----------------------------------------------------------------------" | $Xsed
+ exit $EXIT_SUCCESS
+}
+
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+ $opt_debug
+ # There may be an optional sh(1) argument at the beginning of
+ # install_prog (especially on Windows NT).
+ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+ # Allow the use of GNU shtool's install command.
+ $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
+ # Aesthetically quote it.
+ func_quote_for_eval "$nonopt"
+ install_prog="$func_quote_for_eval_result "
+ arg=$1
+ shift
+ else
+ install_prog=
+ arg=$nonopt
+ fi
+
+ # The real first argument should be the name of the installation program.
+ # Aesthetically quote it.
+ func_quote_for_eval "$arg"
+ install_prog="$install_prog$func_quote_for_eval_result"
+
+ # We need to accept at least all the BSD install flags.
+ dest=
+ files=
+ opts=
+ prev=
+ install_type=
+ isdir=no
+ stripme=
+ for arg
+ do
+ if test -n "$dest"; then
+ files="$files $dest"
+ dest=$arg
+ continue
+ fi
+
+ case $arg in
+ -d) isdir=yes ;;
+ -f)
+ case " $install_prog " in
+ *[\\\ /]cp\ *) ;;
+ *) prev=$arg ;;
+ esac
+ ;;
+ -g | -m | -o)
+ prev=$arg
+ ;;
+ -s)
+ stripme=" -s"
+ continue
+ ;;
+ -*)
+ ;;
+ *)
+ # If the previous option needed an argument, then skip it.
+ if test -n "$prev"; then
+ prev=
+ else
+ dest=$arg
+ continue
+ fi
+ ;;
+ esac
+
+ # Aesthetically quote the argument.
+ func_quote_for_eval "$arg"
+ install_prog="$install_prog $func_quote_for_eval_result"
+ done
+
+ test -z "$install_prog" && \
+ func_fatal_help "you must specify an install program"
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prev' option requires an argument"
+
+ if test -z "$files"; then
+ if test -z "$dest"; then
+ func_fatal_help "no file or destination specified"
+ else
+ func_fatal_help "you must specify a destination"
+ fi
+ fi
+
+ # Strip any trailing slash from the destination.
+ func_stripname '' '/' "$dest"
+ dest=$func_stripname_result
+
+ # Check to see that the destination is a directory.
+ test -d "$dest" && isdir=yes
+ if test "$isdir" = yes; then
+ destdir="$dest"
+ destname=
+ else
+ func_dirname_and_basename "$dest" "" "."
+ destdir="$func_dirname_result"
+ destname="$func_basename_result"
+
+ # Not a directory, so check to see that there is only one file specified.
+ set dummy $files; shift
+ test "$#" -gt 1 && \
+ func_fatal_help "\`$dest' is not a directory"
+ fi
+ case $destdir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ for file in $files; do
+ case $file in
+ *.lo) ;;
+ *)
+ func_fatal_help "\`$destdir' must be an absolute directory name"
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ staticlibs=
+ future_libdirs=
+ current_libdirs=
+ for file in $files; do
+
+ # Do each installation.
+ case $file in
+ *.$libext)
+ # Do the static libraries later.
+ staticlibs="$staticlibs $file"
+ ;;
+
+ *.la)
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$file' is not a valid libtool archive"
+
+ library_names=
+ old_library=
+ relink_command=
+ func_source "$file"
+
+ # Add the libdir to current_libdirs if it is the destination.
+ if test "X$destdir" = "X$libdir"; then
+ case "$current_libdirs " in
+ *" $libdir "*) ;;
+ *) current_libdirs="$current_libdirs $libdir" ;;
+ esac
+ else
+ # Note the libdir as a future libdir.
+ case "$future_libdirs " in
+ *" $libdir "*) ;;
+ *) future_libdirs="$future_libdirs $libdir" ;;
+ esac
+ fi
+
+ func_dirname "$file" "/" ""
+ dir="$func_dirname_result"
+ dir="$dir$objdir"
+
+ if test -n "$relink_command"; then
+ # Determine the prefix the user has applied to our future dir.
+ inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
+
+ # Don't allow the user to place us outside of our expected
+ # location b/c this prevents finding dependent libraries that
+ # are installed to the same prefix.
+ # At present, this check doesn't affect windows .dll's that
+ # are installed into $libdir/../bin (currently, that works fine)
+ # but it's something to keep an eye on.
+ test "$inst_prefix_dir" = "$destdir" && \
+ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+ if test -n "$inst_prefix_dir"; then
+ # Stick the inst_prefix_dir data into the link command.
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+ else
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
+ fi
+
+ func_warning "relinking \`$file'"
+ func_show_eval "$relink_command" \
+ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+ fi
+
+ # See the names of the shared library.
+ set dummy $library_names; shift
+ if test -n "$1"; then
+ realname="$1"
+ shift
+
+ srcname="$realname"
+ test -n "$relink_command" && srcname="$realname"T
+
+ # Install the shared library and build the symlinks.
+ func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
+ 'exit $?'
+ tstripme="$stripme"
+ case $host_os in
+ cygwin* | mingw* | pw32*)
+ case $realname in
+ *.dll.a)
+ tstripme=""
+ ;;
+ esac
+ ;;
+ esac
+ if test -n "$tstripme" && test -n "$striplib"; then
+ func_show_eval "$striplib $destdir/$realname" 'exit $?'
+ fi
+
+ if test "$#" -gt 0; then
+ # Delete the old symlinks, and create new ones.
+ # Try `ln -sf' first, because the `ln' binary might depend on
+ # the symlink we replace! Solaris /bin/ln does not understand -f,
+ # so we also need to try rm && ln -s.
+ for linkname
+ do
+ test "$linkname" != "$realname" \
+ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+ done
+ fi
+
+ # Do each command in the postinstall commands.
+ lib="$destdir/$realname"
+ func_execute_cmds "$postinstall_cmds" 'exit $?'
+ fi
+
+ # Install the pseudo-library for information purposes.
+ func_basename "$file"
+ name="$func_basename_result"
+ instname="$dir/$name"i
+ func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+ # Maybe install the static library, too.
+ test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+ ;;
+
+ *.lo)
+ # Install (i.e. copy) a libtool object.
+
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # Deduce the name of the destination old-style object file.
+ case $destfile in
+ *.lo)
+ func_lo2o "$destfile"
+ staticdest=$func_lo2o_result
+ ;;
+ *.$objext)
+ staticdest="$destfile"
+ destfile=
+ ;;
+ *)
+ func_fatal_help "cannot copy a libtool object to \`$destfile'"
+ ;;
+ esac
+
+ # Install the libtool object if requested.
+ test -n "$destfile" && \
+ func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+ # Install the old object if enabled.
+ if test "$build_old_libs" = yes; then
+ # Deduce the name of the old-style object file.
+ func_lo2o "$file"
+ staticobj=$func_lo2o_result
+ func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+ fi
+ exit $EXIT_SUCCESS
+ ;;
+
+ *)
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # If the file is missing, and there is a .exe on the end, strip it
+ # because it is most likely a libtool script we actually want to
+ # install
+ stripped_ext=""
+ case $file in
+ *.exe)
+ if test ! -f "$file"; then
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ stripped_ext=".exe"
+ fi
+ ;;
+ esac
+
+ # Do a test to see if this is really a libtool program.
+ case $host in
+ *cygwin*|*mingw*)
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ wrapper=$func_ltwrapper_scriptname_result
+ else
+ func_stripname '' '.exe' "$file"
+ wrapper=$func_stripname_result
+ fi
+ ;;
+ *)
+ wrapper=$file
+ ;;
+ esac
+ if func_ltwrapper_script_p "$wrapper"; then
+ notinst_deplibs=
+ relink_command=
+
+ func_source "$wrapper"
+
+ # Check the variables that should have been set.
+ test -z "$generated_by_libtool_version" && \
+ func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+ finalize=yes
+ for lib in $notinst_deplibs; do
+ # Check to see that each library is installed.
+ libdir=
+ if test -f "$lib"; then
+ func_source "$lib"
+ fi
+ libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+ if test -n "$libdir" && test ! -f "$libfile"; then
+ func_warning "\`$lib' has not been installed in \`$libdir'"
+ finalize=no
+ fi
+ done
+
+ relink_command=
+ func_source "$wrapper"
+
+ outputname=
+ if test "$fast_install" = no && test -n "$relink_command"; then
+ $opt_dry_run || {
+ if test "$finalize" = yes; then
+ tmpdir=`func_mktempdir`
+ func_basename "$file$stripped_ext"
+ file="$func_basename_result"
+ outputname="$tmpdir/$file"
+ # Replace the output file specification.
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+ $opt_silent || {
+ func_quote_for_expand "$relink_command"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ if eval "$relink_command"; then :
+ else
+ func_error "error: relink \`$file' with the above command before installing it"
+ $opt_dry_run || ${RM}r "$tmpdir"
+ continue
+ fi
+ file="$outputname"
+ else
+ func_warning "cannot relink \`$file'"
+ fi
+ }
+ else
+ # Install the binary that we compiled earlier.
+ file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+ fi
+ fi
+
+ # remove .exe since cygwin /usr/bin/install will append another
+ # one anyway
+ case $install_prog,$host in
+ */usr/bin/install*,*cygwin*)
+ case $file:$destfile in
+ *.exe:*.exe)
+ # this is ok
+ ;;
+ *.exe:*)
+ destfile=$destfile.exe
+ ;;
+ *:*.exe)
+ func_stripname '' '.exe' "$destfile"
+ destfile=$func_stripname_result
+ ;;
+ esac
+ ;;
+ esac
+ func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+ $opt_dry_run || if test -n "$outputname"; then
+ ${RM}r "$tmpdir"
+ fi
+ ;;
+ esac
+ done
+
+ for file in $staticlibs; do
+ func_basename "$file"
+ name="$func_basename_result"
+
+ # Set up the ranlib parameters.
+ oldlib="$destdir/$name"
+
+ func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+ if test -n "$stripme" && test -n "$old_striplib"; then
+ func_show_eval "$old_striplib $oldlib" 'exit $?'
+ fi
+
+ # Do each command in the postinstall commands.
+ func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+ done
+
+ test -n "$future_libdirs" && \
+ func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+ if test -n "$current_libdirs"; then
+ # Maybe just do a dry run.
+ $opt_dry_run && current_libdirs=" -n$current_libdirs"
+ exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+ else
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+ $opt_debug
+ my_outputname="$1"
+ my_originator="$2"
+ my_pic_p="${3-no}"
+ my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+ my_dlsyms=
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ if test -n "$NM" && test -n "$global_symbol_pipe"; then
+ my_dlsyms="${my_outputname}S.c"
+ else
+ func_error "not configured to extract global symbols from dlpreopened files"
+ fi
+ fi
+
+ if test -n "$my_dlsyms"; then
+ case $my_dlsyms in
+ "") ;;
+ *.c)
+ # Discover the nlist of each of the dlfiles.
+ nlist="$output_objdir/${my_outputname}.nm"
+
+ func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+ # Parse the name list into a source file.
+ func_verbose "creating $output_objdir/$my_dlsyms"
+
+ $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+ if test "$dlself" = yes; then
+ func_verbose "generating symbol list for \`$output'"
+
+ $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+ # Add our own program objects to the symbol list.
+ progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ for progfile in $progfiles; do
+ func_verbose "extracting global C symbols from \`$progfile'"
+ $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -n "$exclude_expsyms"; then
+ $opt_dry_run || {
+ eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ if test -n "$export_symbols_regex"; then
+ $opt_dry_run || {
+ eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ export_symbols="$output_objdir/$outputname.exp"
+ $opt_dry_run || {
+ $RM $export_symbols
+ eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ case $host in
+ *cygwin* | *mingw* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ else
+ $opt_dry_run || {
+ eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+ eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ case $host in
+ *cygwin | *mingw* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ fi
+ fi
+
+ for dlprefile in $dlprefiles; do
+ func_verbose "extracting global C symbols from \`$dlprefile'"
+ func_basename "$dlprefile"
+ name="$func_basename_result"
+ $opt_dry_run || {
+ eval '$ECHO ": $name " >> "$nlist"'
+ eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+ }
+ done
+
+ $opt_dry_run || {
+ # Make sure we have at least an empty file.
+ test -f "$nlist" || : > "$nlist"
+
+ if test -n "$exclude_expsyms"; then
+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+ $MV "$nlist"T "$nlist"
+ fi
+
+ # Try sorting and uniquifying the output.
+ if $GREP -v "^: " < "$nlist" |
+ if sort -k 3 </dev/null >/dev/null 2>&1; then
+ sort -k 3
+ else
+ sort +2
+ fi |
+ uniq > "$nlist"S; then
+ :
+ else
+ $GREP -v "^: " < "$nlist" > "$nlist"S
+ fi
+
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+ else
+ $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
+ fi
+
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols. */
+typedef struct {
+ const char *name;
+ void *address;
+} lt_dlsymlist;
+"
+ case $host in
+ *cygwin* | *mingw* )
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+/* DATA imports from DLLs on WIN32 con't be const, because
+ runtime relocations are performed -- see ld's documentation
+ on pseudo-relocs. */"
+ lt_dlsym_const= ;;
+ *osf5*)
+ echo >> "$output_objdir/$my_dlsyms" "\
+/* This system does not cope well with relocations in const data */"
+ lt_dlsym_const= ;;
+ *)
+ lt_dlsym_const=const ;;
+ esac
+
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+extern $lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+$lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+ { \"$my_originator\", (void *) 0 },"
+
+ case $need_lib_prefix in
+ no)
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ *)
+ eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ esac
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+ } # !$opt_dry_run
+
+ pic_flag_for_symtable=
+ case "$compile_command " in
+ *" -static "*) ;;
+ *)
+ case $host in
+ # compiling the symbol table file with pic_flag works around
+ # a FreeBSD bug that causes programs to crash when -lm is
+ # linked before any other PIC object. But we must not use
+ # pic_flag when linking with -static. The problem exists in
+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+ *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+ pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+ *-*-hpux*)
+ pic_flag_for_symtable=" $pic_flag" ;;
+ *)
+ if test "X$my_pic_p" != Xno; then
+ pic_flag_for_symtable=" $pic_flag"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ symtab_cflags=
+ for arg in $LTCFLAGS; do
+ case $arg in
+ -pie | -fpie | -fPIE) ;;
+ *) symtab_cflags="$symtab_cflags $arg" ;;
+ esac
+ done
+
+ # Now compile the dynamic symbol file.
+ func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+ # Clean up the generated files.
+ func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+ # Transform the symbol file into the correct name.
+ symfileobj="$output_objdir/${my_outputname}S.$objext"
+ case $host in
+ *cygwin* | *mingw* )
+ if test -f "$output_objdir/$my_outputname.def"; then
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ else
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ fi
+ ;;
+ *)
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ ;;
+ esac
+ ;;
+ *)
+ func_fatal_error "unknown suffix for \`$my_dlsyms'"
+ ;;
+ esac
+ else
+ # We keep going just in case the user didn't refer to
+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
+ # really was required.
+
+ # Nullify the symbol file.
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+ fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+ $opt_debug
+ win32_libid_type="unknown"
+ win32_fileres=`file -L $1 2>/dev/null`
+ case $win32_fileres in
+ *ar\ archive\ import\ library*) # definitely import
+ win32_libid_type="x86 archive import"
+ ;;
+ *ar\ archive*) # could be an import, or static
+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+ $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+ win32_nmres=`eval $NM -f posix -A $1 |
+ $SED -n -e '
+ 1,100{
+ / I /{
+ s,.*,import,
+ p
+ q
+ }
+ }'`
+ case $win32_nmres in
+ import*) win32_libid_type="x86 archive import";;
+ *) win32_libid_type="x86 archive static";;
+ esac
+ fi
+ ;;
+ *DLL*)
+ win32_libid_type="x86 DLL"
+ ;;
+ *executable*) # but shell scripts are "executable" too...
+ case $win32_fileres in
+ *MS\ Windows\ PE\ Intel*)
+ win32_libid_type="x86 DLL"
+ ;;
+ esac
+ ;;
+ esac
+ $ECHO "$win32_libid_type"
+}
+
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+ $opt_debug
+ f_ex_an_ar_dir="$1"; shift
+ f_ex_an_ar_oldlib="$1"
+ func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
+ if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+ fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+ $opt_debug
+ my_gentop="$1"; shift
+ my_oldlibs=${1+"$@"}
+ my_oldobjs=""
+ my_xlib=""
+ my_xabs=""
+ my_xdir=""
+
+ for my_xlib in $my_oldlibs; do
+ # Extract the objects.
+ case $my_xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+ *) my_xabs=`pwd`"/$my_xlib" ;;
+ esac
+ func_basename "$my_xlib"
+ my_xlib="$func_basename_result"
+ my_xlib_u=$my_xlib
+ while :; do
+ case " $extracted_archives " in
+ *" $my_xlib_u "*)
+ func_arith $extracted_serial + 1
+ extracted_serial=$func_arith_result
+ my_xlib_u=lt$extracted_serial-$my_xlib ;;
+ *) break ;;
+ esac
+ done
+ extracted_archives="$extracted_archives $my_xlib_u"
+ my_xdir="$my_gentop/$my_xlib_u"
+
+ func_mkdir_p "$my_xdir"
+
+ case $host in
+ *-darwin*)
+ func_verbose "Extracting $my_xabs"
+ # Do not bother doing anything if just a dry run
+ $opt_dry_run || {
+ darwin_orig_dir=`pwd`
+ cd $my_xdir || exit $?
+ darwin_archive=$my_xabs
+ darwin_curdir=`pwd`
+ darwin_base_archive=`basename "$darwin_archive"`
+ darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+ if test -n "$darwin_arches"; then
+ darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+ darwin_arch=
+ func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+ for darwin_arch in $darwin_arches ; do
+ func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+ cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+ cd "$darwin_curdir"
+ $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+ done # $darwin_arches
+ ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+ darwin_file=
+ darwin_files=
+ for darwin_file in $darwin_filelist; do
+ darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+ $LIPO -create -output "$darwin_file" $darwin_files
+ done # $darwin_filelist
+ $RM -rf unfat-$$
+ cd "$darwin_orig_dir"
+ else
+ cd $darwin_orig_dir
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ fi # $darwin_arches
+ } # !$opt_dry_run
+ ;;
+ *)
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ ;;
+ esac
+ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+ done
+
+ func_extract_archives_result="$my_oldobjs"
+}
+
+
+
+# func_emit_wrapper arg
+#
+# emit a libtool wrapper script on stdout
+# don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable. Must ONLY be called from within
+# func_mode_link because it depends on a number of variable
+# set therein.
+#
+# arg is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take. If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the '.lib' directory. This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+ func_emit_wrapper_arg1=no
+ if test -n "$1" ; then
+ func_emit_wrapper_arg1=$1
+ fi
+
+ $ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# 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='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# 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
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='$macro_version'
+ notinst_deplibs='$notinst_deplibs'
+else
+ # When we are sourced in execute mode, \$file and \$ECHO are already set.
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ ECHO=\"$qecho\"
+ file=\"\$0\"
+ # Make sure echo works.
+ if test \"X\$1\" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
+ # Yippee, \$ECHO works!
+ :
+ else
+ # Restart under the correct shell, and then maybe \$ECHO will work.
+ exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+ fi
+ fi\
+"
+ $ECHO "\
+
+ # Find the directory that this script lives in.
+ thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+ while test -n \"\$file\"; do
+ destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+ # If there was a directory component, then change thisdir.
+ if test \"x\$destdir\" != \"x\$file\"; then
+ case \"\$destdir\" in
+ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+ *) thisdir=\"\$thisdir/\$destdir\" ;;
+ esac
+ fi
+
+ file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+ done
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
+ if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+ # special case for '.'
+ if test \"\$thisdir\" = \".\"; then
+ thisdir=\`pwd\`
+ fi
+ # remove .libs from thisdir
+ case \"\$thisdir\" in
+ *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
+ $objdir ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=\`cd \"\$thisdir\" && pwd\`
+ test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+ if test "$fast_install" = yes; then
+ $ECHO "\
+ program=lt-'$outputname'$exeext
+ progdir=\"\$thisdir/$objdir\"
+
+ if test ! -f \"\$progdir/\$program\" ||
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+ file=\"\$\$-\$program\"
+
+ if test ! -d \"\$progdir\"; then
+ $MKDIR \"\$progdir\"
+ else
+ $RM \"\$progdir/\$file\"
+ fi"
+
+ $ECHO "\
+
+ # relink executable if necessary
+ if test -n \"\$relink_command\"; then
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+ else
+ $ECHO \"\$relink_command_output\" >&2
+ $RM \"\$progdir/\$file\"
+ exit 1
+ fi
+ fi
+
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+ { $RM \"\$progdir/\$program\";
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+ $RM \"\$progdir/\$file\"
+ fi"
+ else
+ $ECHO "\
+ program='$outputname'
+ progdir=\"\$thisdir/$objdir\"
+"
+ fi
+
+ $ECHO "\
+
+ if test -f \"\$progdir/\$program\"; then"
+
+ # Export our shlibpath_var if we have one.
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ $ECHO "\
+ # Add our own library path to $shlibpath_var
+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+ # Some systems cannot cope with colon-terminated $shlibpath_var
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+ export $shlibpath_var
+"
+ fi
+
+ # fixup the dll searchpath if we need to.
+ if test -n "$dllsearchpath"; then
+ $ECHO "\
+ # Add the dll search path components to the executable PATH
+ PATH=$dllsearchpath:\$PATH
+"
+ fi
+
+ $ECHO "\
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ # Run the actual program with our arguments.
+"
+ case $host in
+ # Backslashes separate directories on plain windows
+ *-*-mingw | *-*-os2*)
+ $ECHO "\
+ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+ ;;
+
+ *)
+ $ECHO "\
+ exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+ ;;
+ esac
+ $ECHO "\
+ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+ \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+ $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+ exit 1
+ fi
+fi\
+"
+}
+# end: func_emit_wrapper
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+ cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+ Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+ The $output program cannot be directly executed until all the libtool
+ libraries that it depends on are installed.
+
+ This wrapper executable should never be moved out of the build directory.
+ If it is, it will not operate correctly.
+
+ Currently, it simply execs the wrapper *script* "$SHELL $output",
+ but could eventually absorb all of the scripts functionality and
+ exec $objdir/$outputname directly.
+*/
+EOF
+ cat <<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+# define setmode _setmode
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+# include <io.h>
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+#ifdef _MSC_VER
+# define S_IXUSR _S_IEXEC
+# define stat _stat
+# ifndef _INTPTR_T_DEFINED
+# define intptr_t int
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+ defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+# define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+# define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifdef __CYGWIN__
+# define FOPEN_WB "wb"
+#endif
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+ if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#undef LTWRAPPER_DEBUGPRINTF
+#if defined DEBUGWRAPPER
+# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
+static void
+ltwrapper_debugprintf (const char *fmt, ...)
+{
+ va_list args;
+ va_start (args, fmt);
+ (void) vfprintf (stderr, fmt, args);
+ va_end (args);
+}
+#else
+# define LTWRAPPER_DEBUGPRINTF(args)
+#endif
+
+const char *program_name = NULL;
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+
+static const char *script_text =
+EOF
+
+ func_emit_wrapper yes |
+ $SED -e 's/\([\\"]\)/\\\1/g' \
+ -e 's/^/ "/' -e 's/$/\\n"/'
+ echo ";"
+
+ cat <<EOF
+const char * MAGIC_EXE = "$magic_exe";
+
+int
+main (int argc, char *argv[])
+{
+ char **newargz;
+ char *tmp_pathspec;
+ char *actual_cwrapper_path;
+ char *shwrapper_name;
+ intptr_t rval = 127;
+ FILE *shwrapper;
+
+ const char *dumpscript_opt = "--lt-dump-script";
+ int i;
+
+ program_name = (char *) xstrdup (base_name (argv[0]));
+ LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
+ LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
+
+ /* very simple arg parsing; don't want to rely on getopt */
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp (argv[i], dumpscript_opt) == 0)
+ {
+EOF
+ case "$host" in
+ *mingw* | *cygwin* )
+ # make stdout use "unix" line endings
+ echo " setmode(1,_O_BINARY);"
+ ;;
+ esac
+
+ cat <<EOF
+ printf ("%s", script_text);
+ return 0;
+ }
+ }
+
+ newargz = XMALLOC (char *, argc + 2);
+EOF
+
+ if test -n "$TARGETSHELL" ; then
+ # no path translation at all
+ lt_newargv0=$TARGETSHELL
+ else
+ case "$host" in
+ *mingw* )
+ # awkward: cmd appends spaces to result
+ lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+ lt_newargv0=`( cmd //c echo $SHELL | $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo $SHELL`
+ case $lt_newargv0 in
+ *.exe | *.EXE) ;;
+ *) lt_newargv0=$lt_newargv0.exe ;;
+ esac
+ ;;
+ * ) lt_newargv0=$SHELL ;;
+ esac
+ fi
+
+ cat <<EOF
+ newargz[0] = (char *) xstrdup ("$lt_newargv0");
+EOF
+
+ cat <<"EOF"
+ tmp_pathspec = find_executable (argv[0]);
+ if (tmp_pathspec == NULL)
+ lt_fatal ("Couldn't find %s", argv[0]);
+ LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
+ tmp_pathspec));
+
+ actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+ LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
+ actual_cwrapper_path));
+ XFREE (tmp_pathspec);
+
+ shwrapper_name = (char *) xstrdup (base_name (actual_cwrapper_path));
+ strendzap (actual_cwrapper_path, shwrapper_name);
+
+ /* shwrapper_name transforms */
+ strendzap (shwrapper_name, ".exe");
+ tmp_pathspec = XMALLOC (char, (strlen (shwrapper_name) +
+ strlen ("_ltshwrapperTMP") + 1));
+ strcpy (tmp_pathspec, shwrapper_name);
+ strcat (tmp_pathspec, "_ltshwrapperTMP");
+ XFREE (shwrapper_name);
+ shwrapper_name = tmp_pathspec;
+ tmp_pathspec = 0;
+ LTWRAPPER_DEBUGPRINTF (("(main) libtool shell wrapper name: %s\n",
+ shwrapper_name));
+EOF
+
+ cat <<EOF
+ newargz[1] =
+ XMALLOC (char, (strlen (actual_cwrapper_path) +
+ strlen ("$objdir") + 1 + strlen (shwrapper_name) + 1));
+ strcpy (newargz[1], actual_cwrapper_path);
+ strcat (newargz[1], "$objdir");
+ strcat (newargz[1], "/");
+ strcat (newargz[1], shwrapper_name);
+EOF
+
+
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+ {
+ char* p;
+ while ((p = strchr (newargz[1], '\\')) != NULL)
+ {
+ *p = '/';
+ }
+ }
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+ XFREE (shwrapper_name);
+ XFREE (actual_cwrapper_path);
+
+ /* always write in binary mode */
+ if ((shwrapper = fopen (newargz[1], FOPEN_WB)) == 0)
+ {
+ lt_fatal ("Could not open %s for writing", newargz[1]);
+ }
+ fprintf (shwrapper, "%s", script_text);
+ fclose (shwrapper);
+
+ make_executable (newargz[1]);
+
+ for (i = 1; i < argc; i++)
+ newargz[i + 1] = xstrdup (argv[i]);
+ newargz[argc + 1] = NULL;
+
+ for (i = 0; i < argc + 1; i++)
+ {
+ LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, newargz[i]));
+ }
+
+EOF
+
+ case $host_os in
+ mingw*)
+ cat <<EOF
+ /* execv doesn't actually work on mingw as expected on unix */
+ rval = _spawnv (_P_WAIT, "$lt_newargv0", (const char * const *) newargz);
+ if (rval == -1)
+ {
+ /* failed to start process */
+ LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"$lt_newargv0\": errno = %d\n", errno));
+ return 127;
+ }
+ return rval;
+}
+EOF
+ ;;
+ *)
+ cat <<EOF
+ execv ("$lt_newargv0", newargz);
+ return rval; /* =127, but avoids unused variable warning */
+}
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+
+void *
+xmalloc (size_t num)
+{
+ void *p = (void *) malloc (num);
+ if (!p)
+ lt_fatal ("Memory exhausted");
+
+ return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+ string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+ const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+ name += 2;
+#endif
+
+ for (base = name; *name; name++)
+ if (IS_DIR_SEPARATOR (*name))
+ base = name + 1;
+ return base;
+}
+
+int
+check_executable (const char *path)
+{
+ struct stat st;
+
+ LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
+ path ? (*path ? path : "EMPTY!") : "NULL!"));
+ if ((!path) || (!*path))
+ return 0;
+
+ if ((stat (path, &st) >= 0)
+ && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ return 1;
+ else
+ return 0;
+}
+
+int
+make_executable (const char *path)
+{
+ int rval = 0;
+ struct stat st;
+
+ LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
+ path ? (*path ? path : "EMPTY!") : "NULL!"));
+ if ((!path) || (!*path))
+ return 0;
+
+ if (stat (path, &st) >= 0)
+ {
+ rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+ }
+ return rval;
+}
+
+/* Searches for the full path of the wrapper. Returns
+ newly allocated full path name if found, NULL otherwise
+ Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+ int has_slash = 0;
+ const char *p;
+ const char *p_next;
+ /* static buffer for getcwd */
+ char tmp[LT_PATHMAX + 1];
+ int tmp_len;
+ char *concat_name;
+
+ LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
+ wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
+
+ if ((wrapper == NULL) || (*wrapper == '\0'))
+ return NULL;
+
+ /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ else
+ {
+#endif
+ if (IS_DIR_SEPARATOR (wrapper[0]))
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ }
+#endif
+
+ for (p = wrapper; *p; p++)
+ if (*p == '/')
+ {
+ has_slash = 1;
+ break;
+ }
+ if (!has_slash)
+ {
+ /* no slashes; search PATH */
+ const char *path = getenv ("PATH");
+ if (path != NULL)
+ {
+ for (p = path; *p; p = p_next)
+ {
+ const char *q;
+ size_t p_len;
+ for (q = p; *q; q++)
+ if (IS_PATH_SEPARATOR (*q))
+ break;
+ p_len = q - p;
+ p_next = (*q == '\0' ? q : q + 1);
+ if (p_len == 0)
+ {
+ /* empty path: current directory */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal ("getcwd failed");
+ tmp_len = strlen (tmp);
+ concat_name =
+ XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+ }
+ else
+ {
+ concat_name =
+ XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, p, p_len);
+ concat_name[p_len] = '/';
+ strcpy (concat_name + p_len + 1, wrapper);
+ }
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ }
+ /* not found in PATH; assume curdir */
+ }
+ /* Relative path | not found in path: prepend cwd */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal ("getcwd failed");
+ tmp_len = strlen (tmp);
+ concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+ return xstrdup (pathspec);
+#else
+ char buf[LT_PATHMAX];
+ struct stat s;
+ char *tmp_pathspec = xstrdup (pathspec);
+ char *p;
+ int has_symlinks = 0;
+ while (strlen (tmp_pathspec) && !has_symlinks)
+ {
+ LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
+ tmp_pathspec));
+ if (lstat (tmp_pathspec, &s) == 0)
+ {
+ if (S_ISLNK (s.st_mode) != 0)
+ {
+ has_symlinks = 1;
+ break;
+ }
+
+ /* search backwards for last DIR_SEPARATOR */
+ p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+ while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ p--;
+ if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ {
+ /* no more DIR_SEPARATORS left */
+ break;
+ }
+ *p = '\0';
+ }
+ else
+ {
+ char *errstr = strerror (errno);
+ lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
+ }
+ }
+ XFREE (tmp_pathspec);
+
+ if (!has_symlinks)
+ {
+ return xstrdup (pathspec);
+ }
+
+ tmp_pathspec = realpath (pathspec, buf);
+ if (tmp_pathspec == 0)
+ {
+ lt_fatal ("Could not follow symlinks for %s", pathspec);
+ }
+ return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+ size_t len, patlen;
+
+ assert (str != NULL);
+ assert (pat != NULL);
+
+ len = strlen (str);
+ patlen = strlen (pat);
+
+ if (patlen <= len)
+ {
+ str += len - patlen;
+ if (strcmp (str, pat) == 0)
+ *str = '\0';
+ }
+ return str;
+}
+
+static void
+lt_error_core (int exit_status, const char *mode,
+ const char *message, va_list ap)
+{
+ fprintf (stderr, "%s: %s: ", program_name, mode);
+ vfprintf (stderr, message, ap);
+ fprintf (stderr, ".\n");
+
+ if (exit_status >= 0)
+ exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+ va_list ap;
+ va_start (ap, message);
+ lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+ va_end (ap);
+}
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_mode_link arg...
+func_mode_link ()
+{
+ $opt_debug
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ # It is impossible to link a dll without this setting, and
+ # we shouldn't force the makefile maintainer to figure out
+ # which system we are compiling for in order to pass an extra
+ # flag for every libtool invocation.
+ # allow_undefined=no
+
+ # FIXME: Unfortunately, there are problems with the above when trying
+ # to make a dll which has undefined symbols, in which case not
+ # even a static library is built. For now, we need to specify
+ # -no-undefined on the libtool link line when we can be certain
+ # that all symbols are satisfied, otherwise we get a static library.
+ allow_undefined=yes
+ ;;
+ *)
+ allow_undefined=yes
+ ;;
+ esac
+ libtool_args=$nonopt
+ base_compile="$nonopt $@"
+ compile_command=$nonopt
+ finalize_command=$nonopt
+
+ compile_rpath=
+ finalize_rpath=
+ compile_shlibpath=
+ finalize_shlibpath=
+ convenience=
+ old_convenience=
+ deplibs=
+ old_deplibs=
+ compiler_flags=
+ linker_flags=
+ dllsearchpath=
+ lib_search_path=`pwd`
+ inst_prefix_dir=
+ new_inherited_linker_flags=
+
+ avoid_version=no
+ dlfiles=
+ dlprefiles=
+ dlself=no
+ export_dynamic=no
+ export_symbols=
+ export_symbols_regex=
+ generated=
+ libobjs=
+ ltlibs=
+ module=no
+ no_install=no
+ objs=
+ non_pic_objects=
+ precious_files_regex=
+ prefer_static_libs=no
+ preload=no
+ prev=
+ prevarg=
+ release=
+ rpath=
+ xrpath=
+ perm_rpath=
+ temp_rpath=
+ thread_safe=no
+ vinfo=
+ vinfo_number=no
+ weak_libs=
+ single_module="${wl}-single_module"
+ func_infer_tag $base_compile
+
+ # We need to know -static, to get the right output filenames.
+ for arg
+ do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ break
+ ;;
+ -all-static | -static | -static-libtool-libs)
+ case $arg in
+ -all-static)
+ if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+ func_warning "complete static linking is impossible in this configuration"
+ fi
+ if test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ -static)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=built
+ ;;
+ -static-libtool-libs)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ esac
+ build_libtool_libs=no
+ build_old_libs=yes
+ break
+ ;;
+ esac
+ done
+
+ # See if our shared archives depend on static archives.
+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+ # Go through the arguments, transforming them on the way.
+ while test "$#" -gt 0; do
+ arg="$1"
+ shift
+ func_quote_for_eval "$arg"
+ qarg=$func_quote_for_eval_unquoted_result
+ func_append libtool_args " $func_quote_for_eval_result"
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ output)
+ func_append compile_command " @OUTPUT@"
+ func_append finalize_command " @OUTPUT@"
+ ;;
+ esac
+
+ case $prev in
+ dlfiles|dlprefiles)
+ if test "$preload" = no; then
+ # Add the symbol object into the linking commands.
+ func_append compile_command " @SYMFILE@"
+ func_append finalize_command " @SYMFILE@"
+ preload=yes
+ fi
+ case $arg in
+ *.la | *.lo) ;; # We handle these cases below.
+ force)
+ if test "$dlself" = no; then
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ self)
+ if test "$prev" = dlprefiles; then
+ dlself=yes
+ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+ dlself=yes
+ else
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ *)
+ if test "$prev" = dlfiles; then
+ dlfiles="$dlfiles $arg"
+ else
+ dlprefiles="$dlprefiles $arg"
+ fi
+ prev=
+ continue
+ ;;
+ esac
+ ;;
+ expsyms)
+ export_symbols="$arg"
+ test -f "$arg" \
+ || func_fatal_error "symbol file \`$arg' does not exist"
+ prev=
+ continue
+ ;;
+ expsyms_regex)
+ export_symbols_regex="$arg"
+ prev=
+ continue
+ ;;
+ framework)
+ case $host in
+ *-*-darwin*)
+ case "$deplibs " in
+ *" $qarg.ltframework "*) ;;
+ *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+ ;;
+ esac
+ ;;
+ esac
+ prev=
+ continue
+ ;;
+ inst_prefix)
+ inst_prefix_dir="$arg"
+ prev=
+ continue
+ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+ moreargs=
+ for fil in `cat "$save_arg"`
+ do
+# moreargs="$moreargs $fil"
+ arg=$fil
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ done
+ else
+ func_fatal_error "link input file \`$arg' does not exist"
+ fi
+ arg=$save_arg
+ prev=
+ continue
+ ;;
+ precious_regex)
+ precious_files_regex="$arg"
+ prev=
+ continue
+ ;;
+ release)
+ release="-$arg"
+ prev=
+ continue
+ ;;
+ rpath | xrpath)
+ # We need an absolute path.
+ case $arg in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ if test "$prev" = rpath; then
+ case "$rpath " in
+ *" $arg "*) ;;
+ *) rpath="$rpath $arg" ;;
+ esac
+ else
+ case "$xrpath " in
+ *" $arg "*) ;;
+ *) xrpath="$xrpath $arg" ;;
+ esac
+ fi
+ prev=
+ continue
+ ;;
+ shrext)
+ shrext_cmds="$arg"
+ prev=
+ continue
+ ;;
+ weak)
+ weak_libs="$weak_libs $arg"
+ prev=
+ continue
+ ;;
+ xcclinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xcompiler)
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xlinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $wl$qarg"
+ prev=
+ func_append compile_command " $wl$qarg"
+ func_append finalize_command " $wl$qarg"
+ continue
+ ;;
+ *)
+ eval "$prev=\"\$arg\""
+ prev=
+ continue
+ ;;
+ esac
+ fi # test -n "$prev"
+
+ prevarg="$arg"
+
+ case $arg in
+ -all-static)
+ if test -n "$link_static_flag"; then
+ # See comment for -static flag below, for more details.
+ func_append compile_command " $link_static_flag"
+ func_append finalize_command " $link_static_flag"
+ fi
+ continue
+ ;;
+
+ -allow-undefined)
+ # FIXME: remove this flag sometime in the future.
+ func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+ ;;
+
+ -avoid-version)
+ avoid_version=yes
+ continue
+ ;;
+
+ -dlopen)
+ prev=dlfiles
+ continue
+ ;;
+
+ -dlpreopen)
+ prev=dlprefiles
+ continue
+ ;;
+
+ -export-dynamic)
+ export_dynamic=yes
+ continue
+ ;;
+
+ -export-symbols | -export-symbols-regex)
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ func_fatal_error "more than one -exported-symbols argument is not allowed"
+ fi
+ if test "X$arg" = "X-export-symbols"; then
+ prev=expsyms
+ else
+ prev=expsyms_regex
+ fi
+ continue
+ ;;
+
+ -framework)
+ prev=framework
+ continue
+ ;;
+
+ -inst-prefix-dir)
+ prev=inst_prefix
+ continue
+ ;;
+
+ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+ # so, if we see these flags be careful not to treat them like -L
+ -L[A-Z][A-Z]*:*)
+ case $with_gcc/$host in
+ no/*-*-irix* | /*-*-irix*)
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ ;;
+ esac
+ continue
+ ;;
+
+ -L*)
+ func_stripname '-L' '' "$arg"
+ dir=$func_stripname_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ test -z "$absdir" && \
+ func_fatal_error "cannot determine absolute directory name of \`$dir'"
+ dir="$absdir"
+ ;;
+ esac
+ case "$deplibs " in
+ *" -L$dir "*) ;;
+ *)
+ deplibs="$deplibs -L$dir"
+ lib_search_path="$lib_search_path $dir"
+ ;;
+ esac
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$dir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$dir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$testbindir";;
+ esac
+ ;;
+ esac
+ continue
+ ;;
+
+ -l*)
+ if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
+ # These systems don't actually have a C or math library (as such)
+ continue
+ ;;
+ *-*-os2*)
+ # These systems don't actually have a C library (as such)
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C and math libraries are in the System framework
+ deplibs="$deplibs System.ltframework"
+ continue
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ test "X$arg" = "X-lc" && continue
+ ;;
+ esac
+ elif test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
+ esac
+ fi
+ deplibs="$deplibs $arg"
+ continue
+ ;;
+
+ -module)
+ module=yes
+ continue
+ ;;
+
+ # Tru64 UNIX uses -model [arg] to determine the layout of C++
+ # classes, name mangling, and exception handling.
+ # Darwin uses the -arch flag to determine output architecture.
+ -model|-arch|-isysroot)
+ compiler_flags="$compiler_flags $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ prev=xcompiler
+ continue
+ ;;
+
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+ compiler_flags="$compiler_flags $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ case "$new_inherited_linker_flags " in
+ *" $arg "*) ;;
+ * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
+ esac
+ continue
+ ;;
+
+ -multi_module)
+ single_module="${wl}-multi_module"
+ continue
+ ;;
+
+ -no-fast-install)
+ fast_install=no
+ continue
+ ;;
+
+ -no-install)
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
+ # The PATH hackery in wrapper scripts is required on Windows
+ # and Darwin in order for the loader to find any dlls it needs.
+ func_warning "\`-no-install' is ignored for $host"
+ func_warning "assuming \`-no-fast-install' instead"
+ fast_install=no
+ ;;
+ *) no_install=yes ;;
+ esac
+ continue
+ ;;
+
+ -no-undefined)
+ allow_undefined=no
+ continue
+ ;;
+
+ -objectlist)
+ prev=objectlist
+ continue
+ ;;
+
+ -o) prev=output ;;
+
+ -precious-files-regex)
+ prev=precious_regex
+ continue
+ ;;
+
+ -release)
+ prev=release
+ continue
+ ;;
+
+ -rpath)
+ prev=rpath
+ continue
+ ;;
+
+ -R)
+ prev=xrpath
+ continue
+ ;;
+
+ -R*)
+ func_stripname '-R' '' "$arg"
+ dir=$func_stripname_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ continue
+ ;;
+
+ -shared)
+ # The effects of -shared are defined in a previous loop.
+ continue
+ ;;
+
+ -shrext)
+ prev=shrext
+ continue
+ ;;
+
+ -static | -static-libtool-libs)
+ # The effects of -static are defined in a previous loop.
+ # We used to do the same as -all-static on platforms that
+ # didn't have a PIC flag, but the assumption that the effects
+ # would be equivalent was wrong. It would break on at least
+ # Digital Unix and AIX.
+ continue
+ ;;
+
+ -thread-safe)
+ thread_safe=yes
+ continue
+ ;;
+
+ -version-info)
+ prev=vinfo
+ continue
+ ;;
+
+ -version-number)
+ prev=vinfo
+ vinfo_number=yes
+ continue
+ ;;
+
+ -weak)
+ prev=weak
+ continue
+ ;;
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ arg="$arg $wl$func_quote_for_eval_result"
+ compiler_flags="$compiler_flags $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Wl,*)
+ func_stripname '-Wl,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ arg="$arg $wl$func_quote_for_eval_result"
+ compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+ linker_flags="$linker_flags $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Xcompiler)
+ prev=xcompiler
+ continue
+ ;;
+
+ -Xlinker)
+ prev=xlinker
+ continue
+ ;;
+
+ -XCClinker)
+ prev=xcclinker
+ continue
+ ;;
+
+ # -msg_* for osf cc
+ -msg_*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+ # -r[0-9][0-9]* specifies the processor on the SGI compiler
+ # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+ # +DA*, +DD* enable 64-bit mode on the HP compiler
+ # -q* pass through compiler args for the IBM compiler
+ # -m*, -t[45]*, -txscale* pass through architecture-specific
+ # compiler args for GCC
+ # -F/path gives path to uninstalled frameworks, gcc on darwin
+ # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+ # @file GCC response files
+ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ compiler_flags="$compiler_flags $arg"
+ continue
+ ;;
+
+ # Some other compiler flag.
+ -* | +*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ *.$objext)
+ # A standard object.
+ objs="$objs $arg"
+ ;;
+
+ *.lo)
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ ;;
+
+ *.$libext)
+ # An archive.
+ deplibs="$deplibs $arg"
+ old_deplibs="$old_deplibs $arg"
+ continue
+ ;;
+
+ *.la)
+ # A libtool-controlled library.
+
+ if test "$prev" = dlfiles; then
+ # This library was specified with -dlopen.
+ dlfiles="$dlfiles $arg"
+ prev=
+ elif test "$prev" = dlprefiles; then
+ # The library was specified with -dlpreopen.
+ dlprefiles="$dlprefiles $arg"
+ prev=
+ else
+ deplibs="$deplibs $arg"
+ fi
+ continue
+ ;;
+
+ # Some other compiler argument.
+ *)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+ esac # arg
+
+ # Now actually substitute the argument into the commands.
+ if test -n "$arg"; then
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+ done # argument parsing loop
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prevarg' option requires an argument"
+
+ if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+
+ oldlibs=
+ # calculate the name of the file, without its directory
+ func_basename "$output"
+ outputname="$func_basename_result"
+ libobjs_save="$libobjs"
+
+ if test -n "$shlibpath_var"; then
+ # get the directories listed in $shlibpath_var
+ eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+ else
+ shlib_search_path=
+ fi
+ eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+ func_dirname "$output" "/" ""
+ output_objdir="$func_dirname_result$objdir"
+ # Create the object directory.
+ func_mkdir_p "$output_objdir"
+
+ # Determine the type of output
+ case $output in
+ "")
+ func_fatal_help "you must specify an output file"
+ ;;
+ *.$libext) linkmode=oldlib ;;
+ *.lo | *.$objext) linkmode=obj ;;
+ *.la) linkmode=lib ;;
+ *) linkmode=prog ;; # Anything else should be a program.
+ esac
+
+ specialdeplibs=
+
+ libs=
+ # Find all interdependent deplibs by searching for libraries
+ # that are linked more than once (e.g. -la -lb -la)
+ for deplib in $deplibs; do
+ if $opt_duplicate_deps ; then
+ case "$libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ libs="$libs $deplib"
+ done
+
+ if test "$linkmode" = lib; then
+ libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+ # Compute libraries that are listed more than once in $predeps
+ # $postdeps and mark them as special (i.e., whose duplicates are
+ # not to be eliminated).
+ pre_post_deps=
+ if $opt_duplicate_compiler_generated_deps; then
+ for pre_post_dep in $predeps $postdeps; do
+ case "$pre_post_deps " in
+ *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+ esac
+ pre_post_deps="$pre_post_deps $pre_post_dep"
+ done
+ fi
+ pre_post_deps=
+ fi
+
+ deplibs=
+ newdependency_libs=
+ newlib_search_path=
+ need_relink=no # whether we're linking any uninstalled libtool libraries
+ notinst_deplibs= # not-installed libtool libraries
+ notinst_path= # paths that contain not-installed libtool libraries
+
+ case $linkmode in
+ lib)
+ passes="conv dlpreopen link"
+ for file in $dlfiles $dlprefiles; do
+ case $file in
+ *.la) ;;
+ *)
+ func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+ ;;
+ esac
+ done
+ ;;
+ prog)
+ compile_deplibs=
+ finalize_deplibs=
+ alldeplibs=no
+ newdlfiles=
+ newdlprefiles=
+ passes="conv scan dlopen dlpreopen link"
+ ;;
+ *) passes="conv"
+ ;;
+ esac
+
+ for pass in $passes; do
+ # The preopen pass in lib mode reverses $deplibs; put it back here
+ # so that -L comes before libs that need it for instance...
+ if test "$linkmode,$pass" = "lib,link"; then
+ ## FIXME: Find the place where the list is rebuilt in the wrong
+ ## order, and fix it there properly
+ tmp_deplibs=
+ for deplib in $deplibs; do
+ tmp_deplibs="$deplib $tmp_deplibs"
+ done
+ deplibs="$tmp_deplibs"
+ fi
+
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan"; then
+ libs="$deplibs"
+ deplibs=
+ fi
+ if test "$linkmode" = prog; then
+ case $pass in
+ dlopen) libs="$dlfiles" ;;
+ dlpreopen) libs="$dlprefiles" ;;
+ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+ esac
+ fi
+ if test "$linkmode,$pass" = "lib,dlpreopen"; then
+ # Collect and forward deplibs of preopened libtool libs
+ for lib in $dlprefiles; do
+ # Ignore non-libtool-libs
+ dependency_libs=
+ case $lib in
+ *.la) func_source "$lib" ;;
+ esac
+
+ # Collect preopened libtool deplibs, except any this library
+ # has declared as weak libs
+ for deplib in $dependency_libs; do
+ deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
+ case " $weak_libs " in
+ *" $deplib_base "*) ;;
+ *) deplibs="$deplibs $deplib" ;;
+ esac
+ done
+ done
+ libs="$dlprefiles"
+ fi
+ if test "$pass" = dlopen; then
+ # Collect dlpreopened libraries
+ save_deplibs="$deplibs"
+ deplibs=
+ fi
+
+ for deplib in $libs; do
+ lib=
+ found=no
+ case $deplib in
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ compiler_flags="$compiler_flags $deplib"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -l*)
+ if test "$linkmode" != lib && test "$linkmode" != prog; then
+ func_warning "\`-l' is ignored for archives/objects"
+ continue
+ fi
+ func_stripname '-l' '' "$deplib"
+ name=$func_stripname_result
+ if test "$linkmode" = lib; then
+ searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+ else
+ searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+ fi
+ for searchdir in $searchdirs; do
+ for search_ext in .la $std_shrext .so .a; do
+ # Search the libtool library
+ lib="$searchdir/lib${name}${search_ext}"
+ if test -f "$lib"; then
+ if test "$search_ext" = ".la"; then
+ found=yes
+ else
+ found=no
+ fi
+ break 2
+ fi
+ done
+ done
+ if test "$found" != yes; then
+ # deplib doesn't seem to be a libtool library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ else # deplib is a libtool library
+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+ # We need to do some special things here, and not later.
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $deplib "*)
+ if func_lalib_p "$lib"; then
+ library_names=
+ old_library=
+ func_source "$lib"
+ for l in $old_library $library_names; do
+ ll="$l"
+ done
+ if test "X$ll" = "X$old_library" ; then # only static version available
+ found=no
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+ lib=$ladir/$old_library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ fi
+ fi
+ ;;
+ *) ;;
+ esac
+ fi
+ fi
+ ;; # -l
+ *.ltframework)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -L*)
+ case $linkmode in
+ lib)
+ deplibs="$deplib $deplibs"
+ test "$pass" = conv && continue
+ newdependency_libs="$deplib $newdependency_libs"
+ func_stripname '-L' '' "$deplib"
+ newlib_search_path="$newlib_search_path $func_stripname_result"
+ ;;
+ prog)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ if test "$pass" = scan; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ func_stripname '-L' '' "$deplib"
+ newlib_search_path="$newlib_search_path $func_stripname_result"
+ ;;
+ *)
+ func_warning "\`-L' is ignored for archives/objects"
+ ;;
+ esac # linkmode
+ continue
+ ;; # -L
+ -R*)
+ if test "$pass" = link; then
+ func_stripname '-R' '' "$deplib"
+ dir=$func_stripname_result
+ # Make sure the xrpath contains only unique directories.
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ fi
+ deplibs="$deplib $deplibs"
+ continue
+ ;;
+ *.la) lib="$deplib" ;;
+ *.$libext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ case $linkmode in
+ lib)
+ # Linking convenience modules into shared libraries is allowed,
+ # but linking other static libraries is non-portable.
+ case " $dlpreconveniencelibs " in
+ *" $deplib "*) ;;
+ *)
+ valid_a_lib=no
+ case $deplibs_check_method in
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
+ | $EGREP "$match_pattern_regex" > /dev/null; then
+ valid_a_lib=yes
+ fi
+ ;;
+ pass_all)
+ valid_a_lib=yes
+ ;;
+ esac
+ if test "$valid_a_lib" != yes; then
+ $ECHO
+ $ECHO "*** Warning: Trying to link with static lib archive $deplib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because the file extensions .$libext of this argument makes me believe"
+ $ECHO "*** that it is just a static archive that I should not use here."
+ else
+ $ECHO
+ $ECHO "*** Warning: Linking the shared library $output against the"
+ $ECHO "*** static library $deplib is not portable!"
+ deplibs="$deplib $deplibs"
+ fi
+ ;;
+ esac
+ continue
+ ;;
+ prog)
+ if test "$pass" != link; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ continue
+ ;;
+ esac # linkmode
+ ;; # *.$libext
+ *.lo | *.$objext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ elif test "$linkmode" = prog; then
+ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlopen support or we're linking statically,
+ # we need to preload.
+ newdlprefiles="$newdlprefiles $deplib"
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ newdlfiles="$newdlfiles $deplib"
+ fi
+ fi
+ continue
+ ;;
+ %DEPLIBS%)
+ alldeplibs=yes
+ continue
+ ;;
+ esac # case $deplib
+
+ if test "$found" = yes || test -f "$lib"; then :
+ else
+ func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+ fi
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$lib" \
+ || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+
+ dlname=
+ dlopen=
+ dlpreopen=
+ libdir=
+ library_names=
+ old_library=
+ inherited_linker_flags=
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variables installed, or shouldnotlink
+ installed=yes
+ shouldnotlink=no
+ avoidtemprpath=
+
+
+ # Read the .la file
+ func_source "$lib"
+
+ # Convert "-framework foo" to "foo.ltframework"
+ if test -n "$inherited_linker_flags"; then
+ tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
+ for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+ case " $new_inherited_linker_flags " in
+ *" $tmp_inherited_linker_flag "*) ;;
+ *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
+ esac
+ done
+ fi
+ dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan" ||
+ { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+ test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+ test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+ fi
+
+ if test "$pass" = conv; then
+ # Only check for convenience libraries
+ deplibs="$lib $deplibs"
+ if test -z "$libdir"; then
+ if test -z "$old_library"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+ # It is a libtool convenience library, so add in its objects.
+ convenience="$convenience $ladir/$objdir/$old_library"
+ old_convenience="$old_convenience $ladir/$objdir/$old_library"
+ elif test "$linkmode" != prog && test "$linkmode" != lib; then
+ func_fatal_error "\`$lib' is not a convenience library"
+ fi
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+ if $opt_duplicate_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+ continue
+ fi # $pass = conv
+
+
+ # Get the name of the library we link against.
+ linklib=
+ for l in $old_library $library_names; do
+ linklib="$l"
+ done
+ if test -z "$linklib"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+
+ # This library was specified with -dlopen.
+ if test "$pass" = dlopen; then
+ if test -z "$libdir"; then
+ func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+ fi
+ if test -z "$dlname" ||
+ test "$dlopen_support" != yes ||
+ test "$build_libtool_libs" = no; then
+ # If there is no dlname, no dlopen support or we're linking
+ # statically, we need to preload. We also need to preload any
+ # dependent libraries so libltdl's deplib preloader doesn't
+ # bomb out in the load deplibs phase.
+ dlprefiles="$dlprefiles $lib $dependency_libs"
+ else
+ newdlfiles="$newdlfiles $lib"
+ fi
+ continue
+ fi # $pass = dlopen
+
+ # We need an absolute path.
+ case $ladir in
+ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+ *)
+ abs_ladir=`cd "$ladir" && pwd`
+ if test -z "$abs_ladir"; then
+ func_warning "cannot determine absolute directory name of \`$ladir'"
+ func_warning "passing it literally to the linker, although it might fail"
+ abs_ladir="$ladir"
+ fi
+ ;;
+ esac
+ func_basename "$lib"
+ laname="$func_basename_result"
+
+ # Find the relevant object directory and library name.
+ if test "X$installed" = Xyes; then
+ if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ func_warning "library \`$lib' was moved."
+ dir="$ladir"
+ absdir="$abs_ladir"
+ libdir="$abs_ladir"
+ else
+ dir="$libdir"
+ absdir="$libdir"
+ fi
+ test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+ else
+ if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ dir="$ladir"
+ absdir="$abs_ladir"
+ # Remove this search path later
+ notinst_path="$notinst_path $abs_ladir"
+ else
+ dir="$ladir/$objdir"
+ absdir="$abs_ladir/$objdir"
+ # Remove this search path later
+ notinst_path="$notinst_path $abs_ladir"
+ fi
+ fi # $installed = yes
+ func_stripname 'lib' '.la' "$laname"
+ name=$func_stripname_result
+
+ # This library was specified with -dlpreopen.
+ if test "$pass" = dlpreopen; then
+ if test -z "$libdir" && test "$linkmode" = prog; then
+ func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+ fi
+ # Prefer using a static library (so that no silly _DYNAMIC symbols
+ # are required to link).
+ if test -n "$old_library"; then
+ newdlprefiles="$newdlprefiles $dir/$old_library"
+ # Keep a list of preopened convenience libraries to check
+ # that they are being used correctly in the link pass.
+ test -z "$libdir" && \
+ dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
+ # Otherwise, use the dlname, so that lt_dlopen finds it.
+ elif test -n "$dlname"; then
+ newdlprefiles="$newdlprefiles $dir/$dlname"
+ else
+ newdlprefiles="$newdlprefiles $dir/$linklib"
+ fi
+ fi # $pass = dlpreopen
+
+ if test -z "$libdir"; then
+ # Link the convenience library
+ if test "$linkmode" = lib; then
+ deplibs="$dir/$old_library $deplibs"
+ elif test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$dir/$old_library $compile_deplibs"
+ finalize_deplibs="$dir/$old_library $finalize_deplibs"
+ else
+ deplibs="$lib $deplibs" # used for prog,scan pass
+ fi
+ continue
+ fi
+
+
+ if test "$linkmode" = prog && test "$pass" != link; then
+ newlib_search_path="$newlib_search_path $ladir"
+ deplibs="$lib $deplibs"
+
+ linkalldeplibs=no
+ if test "$link_all_deplibs" != no || test -z "$library_names" ||
+ test "$build_libtool_libs" = no; then
+ linkalldeplibs=yes
+ fi
+
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) func_stripname '-L' '' "$deplib"
+ newlib_search_path="$newlib_search_path $func_stripname_result"
+ ;;
+ esac
+ # Need to link against all dependency_libs?
+ if test "$linkalldeplibs" = yes; then
+ deplibs="$deplib $deplibs"
+ else
+ # Need to hardcode shared library paths
+ # or/and link against static libraries
+ newdependency_libs="$deplib $newdependency_libs"
+ fi
+ if $opt_duplicate_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done # for deplib
+ continue
+ fi # $linkmode = prog...
+
+ if test "$linkmode,$pass" = "prog,link"; then
+ if test -n "$library_names" &&
+ { { test "$prefer_static_libs" = no ||
+ test "$prefer_static_libs,$installed" = "built,yes"; } ||
+ test -z "$old_library"; }; then
+ # We need to hardcode the library path
+ if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+ # Make sure the rpath contains only unique directories.
+ case "$temp_rpath:" in
+ *"$absdir:"*) ;;
+ *) temp_rpath="$temp_rpath$absdir:" ;;
+ esac
+ fi
+
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi # $linkmode,$pass = prog,link...
+
+ if test "$alldeplibs" = yes &&
+ { test "$deplibs_check_method" = pass_all ||
+ { test "$build_libtool_libs" = yes &&
+ test -n "$library_names"; }; }; then
+ # We only need to search for static libraries
+ continue
+ fi
+ fi
+
+ link_static=no # Whether the deplib will be linked statically
+ use_static_libs=$prefer_static_libs
+ if test "$use_static_libs" = built && test "$installed" = yes; then
+ use_static_libs=no
+ fi
+ if test -n "$library_names" &&
+ { test "$use_static_libs" = no || test -z "$old_library"; }; then
+ case $host in
+ *cygwin* | *mingw*)
+ # No point in relinking DLLs because paths are not encoded
+ notinst_deplibs="$notinst_deplibs $lib"
+ need_relink=no
+ ;;
+ *)
+ if test "$installed" = no; then
+ notinst_deplibs="$notinst_deplibs $lib"
+ need_relink=yes
+ fi
+ ;;
+ esac
+ # This is a shared library
+
+ # Warn about portability, can't link against -module's on some
+ # systems (darwin). Don't bleat about dlopened modules though!
+ dlopenmodule=""
+ for dlpremoduletest in $dlprefiles; do
+ if test "X$dlpremoduletest" = "X$lib"; then
+ dlopenmodule="$dlpremoduletest"
+ break
+ fi
+ done
+ if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+ $ECHO
+ if test "$linkmode" = prog; then
+ $ECHO "*** Warning: Linking the executable $output against the loadable module"
+ else
+ $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+ fi
+ $ECHO "*** $linklib is not portable!"
+ fi
+ if test "$linkmode" = lib &&
+ test "$hardcode_into_libs" = yes; then
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi
+
+ if test -n "$old_archive_from_expsyms_cmds"; then
+ # figure out the soname
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ # use dlname if we got it. it's perfectly good, no?
+ if test -n "$dlname"; then
+ soname="$dlname"
+ elif test -n "$soname_spec"; then
+ # bleh windows
+ case $host in
+ *cygwin* | mingw*)
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+ esac
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+
+ # Make a new name for the extract_expsyms_cmds to use
+ soroot="$soname"
+ func_basename "$soroot"
+ soname="$func_basename_result"
+ func_stripname 'lib' '.dll' "$soname"
+ newlib=libimp-$func_stripname_result.a
+
+ # If the library has no export list, then create one now
+ if test -f "$output_objdir/$soname-def"; then :
+ else
+ func_verbose "extracting exported symbol list from \`$soname'"
+ func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+ fi
+
+ # Create $newlib
+ if test -f "$output_objdir/$newlib"; then :; else
+ func_verbose "generating import library for \`$soname'"
+ func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+ fi
+ # make sure the library variables are pointing to the new library
+ dir=$output_objdir
+ linklib=$newlib
+ fi # test -n "$old_archive_from_expsyms_cmds"
+
+ if test "$linkmode" = prog || test "$mode" != relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ lib_linked=yes
+ case $hardcode_action in
+ immediate | unsupported)
+ if test "$hardcode_direct" = no; then
+ add="$dir/$linklib"
+ case $host in
+ *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+ *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+ *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+ *-*-unixware7*) add_dir="-L$dir" ;;
+ *-*-darwin* )
+ # if the lib is a (non-dlopened) module then we can not
+ # link against it, someone is ignoring the earlier warnings
+ if /usr/bin/file -L $add 2> /dev/null |
+ $GREP ": [^:]* bundle" >/dev/null ; then
+ if test "X$dlopenmodule" != "X$lib"; then
+ $ECHO "*** Warning: lib $linklib is a module, not a shared library"
+ if test -z "$old_library" ; then
+ $ECHO
+ $ECHO "*** And there doesn't seem to be a static archive available"
+ $ECHO "*** The link will probably fail, sorry"
+ else
+ add="$dir/$old_library"
+ fi
+ elif test -n "$old_library"; then
+ add="$dir/$old_library"
+ fi
+ fi
+ esac
+ elif test "$hardcode_minus_L" = no; then
+ case $host in
+ *-*-sunos*) add_shlibpath="$dir" ;;
+ esac
+ add_dir="-L$dir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = no; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ relink)
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$dir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$dir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ add_dir="$add_dir -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ *) lib_linked=no ;;
+ esac
+
+ if test "$lib_linked" != yes; then
+ func_fatal_configuration "unsupported hardcode properties"
+ fi
+
+ if test -n "$add_shlibpath"; then
+ case :$compile_shlibpath: in
+ *":$add_shlibpath:"*) ;;
+ *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+ esac
+ fi
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+ test -n "$add" && compile_deplibs="$add $compile_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ if test "$hardcode_direct" != yes &&
+ test "$hardcode_minus_L" != yes &&
+ test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ fi
+ fi
+ fi
+
+ if test "$linkmode" = prog || test "$mode" = relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ # Finalize command for both is simple: just hardcode it.
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$libdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$libdir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ add="-l$name"
+ elif test "$hardcode_automatic" = yes; then
+ if test -n "$inst_prefix_dir" &&
+ test -f "$inst_prefix_dir$libdir/$linklib" ; then
+ add="$inst_prefix_dir$libdir/$linklib"
+ else
+ add="$libdir/$linklib"
+ fi
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+ add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ add_dir="$add_dir -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ fi
+
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+ test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ fi
+ fi
+ elif test "$linkmode" = prog; then
+ # Here we assume that one of hardcode_direct or hardcode_minus_L
+ # is not unsupported. This is valid on all known static and
+ # shared platforms.
+ if test "$hardcode_direct" != unsupported; then
+ test -n "$old_library" && linklib="$old_library"
+ compile_deplibs="$dir/$linklib $compile_deplibs"
+ finalize_deplibs="$dir/$linklib $finalize_deplibs"
+ else
+ compile_deplibs="-l$name -L$dir $compile_deplibs"
+ finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+ fi
+ elif test "$build_libtool_libs" = yes; then
+ # Not a shared library
+ if test "$deplibs_check_method" != pass_all; then
+ # We're trying link a shared library against a static one
+ # but the system doesn't support it.
+
+ # Just print a warning and add the library to dependency_libs so
+ # that the program can be linked against the static library.
+ $ECHO
+ $ECHO "*** Warning: This system can not link to static lib archive $lib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have."
+ if test "$module" = yes; then
+ $ECHO "*** But as you try to build a module library, libtool will still create "
+ $ECHO "*** a static module, that should work as long as the dlopening application"
+ $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
+ if test -z "$global_symbol_pipe"; then
+ $ECHO
+ $ECHO "*** However, this would only work if libtool was able to extract symbol"
+ $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $ECHO "*** not find such a program. So, this module is probably useless."
+ $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ else
+ deplibs="$dir/$old_library $deplibs"
+ link_static=yes
+ fi
+ fi # link shared/static library?
+
+ if test "$linkmode" = lib; then
+ if test -n "$dependency_libs" &&
+ { test "$hardcode_into_libs" != yes ||
+ test "$build_old_libs" = yes ||
+ test "$link_static" = yes; }; then
+ # Extract -R from dependency_libs
+ temp_deplibs=
+ for libdir in $dependency_libs; do
+ case $libdir in
+ -R*) func_stripname '-R' '' "$libdir"
+ temp_xrpath=$func_stripname_result
+ case " $xrpath " in
+ *" $temp_xrpath "*) ;;
+ *) xrpath="$xrpath $temp_xrpath";;
+ esac;;
+ *) temp_deplibs="$temp_deplibs $libdir";;
+ esac
+ done
+ dependency_libs="$temp_deplibs"
+ fi
+
+ newlib_search_path="$newlib_search_path $absdir"
+ # Link against this library
+ test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+ # ... and its dependency_libs
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ newdependency_libs="$deplib $newdependency_libs"
+ if $opt_duplicate_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+
+ if test "$link_all_deplibs" != no; then
+ # Add the search paths of all dependency libraries
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) path="$deplib" ;;
+ *.la)
+ func_dirname "$deplib" "" "."
+ dir="$func_dirname_result"
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ func_warning "cannot determine absolute directory name of \`$dir'"
+ absdir="$dir"
+ fi
+ ;;
+ esac
+ if $GREP "^installed=no" $deplib > /dev/null; then
+ case $host in
+ *-*-darwin*)
+ depdepl=
+ eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+ if test -n "$deplibrary_names" ; then
+ for tmp in $deplibrary_names ; do
+ depdepl=$tmp
+ done
+ if test -f "$absdir/$objdir/$depdepl" ; then
+ depdepl="$absdir/$objdir/$depdepl"
+ darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ if test -z "$darwin_install_name"; then
+ darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ fi
+ compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+ linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
+ path=
+ fi
+ fi
+ ;;
+ *)
+ path="-L$absdir/$objdir"
+ ;;
+ esac
+ else
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ test "$absdir" != "$libdir" && \
+ func_warning "\`$deplib' seems to be moved"
+
+ path="-L$absdir"
+ fi
+ ;;
+ esac
+ case " $deplibs " in
+ *" $path "*) ;;
+ *) deplibs="$path $deplibs" ;;
+ esac
+ done
+ fi # link_all_deplibs != no
+ fi # linkmode = lib
+ done # for deplib in $libs
+ if test "$pass" = link; then
+ if test "$linkmode" = "prog"; then
+ compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+ finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+ else
+ compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ fi
+ fi
+ dependency_libs="$newdependency_libs"
+ if test "$pass" = dlpreopen; then
+ # Link the dlpreopened libraries before other libraries
+ for deplib in $save_deplibs; do
+ deplibs="$deplib $deplibs"
+ done
+ fi
+ if test "$pass" != dlopen; then
+ if test "$pass" != conv; then
+ # Make sure lib_search_path contains only unique directories.
+ lib_search_path=
+ for dir in $newlib_search_path; do
+ case "$lib_search_path " in
+ *" $dir "*) ;;
+ *) lib_search_path="$lib_search_path $dir" ;;
+ esac
+ done
+ newlib_search_path=
+ fi
+
+ if test "$linkmode,$pass" != "prog,link"; then
+ vars="deplibs"
+ else
+ vars="compile_deplibs finalize_deplibs"
+ fi
+ for var in $vars dependency_libs; do
+ # Add libraries to $var in reverse order
+ eval tmp_libs=\"\$$var\"
+ new_libs=
+ for deplib in $tmp_libs; do
+ # FIXME: Pedantically, this is the right thing to do, so
+ # that some nasty dependency loop isn't accidentally
+ # broken:
+ #new_libs="$deplib $new_libs"
+ # Pragmatically, this seems to cause very few problems in
+ # practice:
+ case $deplib in
+ -L*) new_libs="$deplib $new_libs" ;;
+ -R*) ;;
+ *)
+ # And here is the reason: when a library appears more
+ # than once as an explicit dependence of a library, or
+ # is implicitly linked in more than once by the
+ # compiler, it is considered special, and multiple
+ # occurrences thereof are not removed. Compare this
+ # with having the same library being listed as a
+ # dependency of multiple other libraries: in this case,
+ # we know (pedantically, we assume) the library does not
+ # need to be listed more than once, so we keep only the
+ # last copy. This is not always right, but it is rare
+ # enough that we require users that really mean to play
+ # such unportable linking tricks to link the library
+ # using -Wl,-lname, so that libtool does not consider it
+ # for duplicate removal.
+ case " $specialdeplibs " in
+ *" $deplib "*) new_libs="$deplib $new_libs" ;;
+ *)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$deplib $new_libs" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ tmp_libs=
+ for deplib in $new_libs; do
+ case $deplib in
+ -L*)
+ case " $tmp_libs " in
+ *" $deplib "*) ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ done
+ eval $var=\"$tmp_libs\"
+ done # for var
+ fi
+ # Last step: remove runtime libs from dependency_libs
+ # (they stay in deplibs)
+ tmp_libs=
+ for i in $dependency_libs ; do
+ case " $predeps $postdeps $compiler_lib_search_path " in
+ *" $i "*)
+ i=""
+ ;;
+ esac
+ if test -n "$i" ; then
+ tmp_libs="$tmp_libs $i"
+ fi
+ done
+ dependency_libs=$tmp_libs
+ done # for pass
+ if test "$linkmode" = prog; then
+ dlfiles="$newdlfiles"
+ fi
+ if test "$linkmode" = prog || test "$linkmode" = lib; then
+ dlprefiles="$newdlprefiles"
+ fi
+
+ case $linkmode in
+ oldlib)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for archives"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for archives" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for archives"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for archives"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for archives"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for archives"
+
+ test -n "$export_symbols$export_symbols_regex" && \
+ func_warning "\`-export-symbols' is ignored for archives"
+
+ # Now set the variables for building old libraries.
+ build_libtool_libs=no
+ oldlibs="$output"
+ objs="$objs$old_deplibs"
+ ;;
+
+ lib)
+ # Make sure we only generate libraries of the form `libNAME.la'.
+ case $outputname in
+ lib*)
+ func_stripname 'lib' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ ;;
+ *)
+ test "$module" = no && \
+ func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+ if test "$need_lib_prefix" != no; then
+ # Add the "lib" prefix for modules if required
+ func_stripname '' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ else
+ func_stripname '' '.la' "$outputname"
+ libname=$func_stripname_result
+ fi
+ ;;
+ esac
+
+ if test -n "$objs"; then
+ if test "$deplibs_check_method" != pass_all; then
+ func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+ else
+ $ECHO
+ $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+ $ECHO "*** objects $objs is not portable!"
+ libobjs="$libobjs $objs"
+ fi
+ fi
+
+ test "$dlself" != no && \
+ func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+ set dummy $rpath
+ shift
+ test "$#" -gt 1 && \
+ func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+ install_libdir="$1"
+
+ oldlibs=
+ if test -z "$rpath"; then
+ if test "$build_libtool_libs" = yes; then
+ # Building a libtool convenience library.
+ # Some compilers have problems with a `.al' extension so
+ # convenience libraries should have the same extension an
+ # archive normally would.
+ oldlibs="$output_objdir/$libname.$libext $oldlibs"
+ build_libtool_libs=convenience
+ build_old_libs=yes
+ fi
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for convenience libraries"
+ else
+
+ # Parse the version information argument.
+ save_ifs="$IFS"; IFS=':'
+ set dummy $vinfo 0 0 0
+ shift
+ IFS="$save_ifs"
+
+ test -n "$7" && \
+ func_fatal_help "too many parameters to \`-version-info'"
+
+ # convert absolute version numbers to libtool ages
+ # this retains compatibility with .la files and attempts
+ # to make the code below a bit more comprehensible
+
+ case $vinfo_number in
+ yes)
+ number_major="$1"
+ number_minor="$2"
+ number_revision="$3"
+ #
+ # There are really only two kinds -- those that
+ # use the current revision as the major version
+ # and those that subtract age and use age as
+ # a minor version. But, then there is irix
+ # which has an extra 1 added just for fun
+ #
+ case $version_type in
+ darwin|linux|osf|windows|none)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|sunos)
+ current="$number_major"
+ revision="$number_minor"
+ age="0"
+ ;;
+ irix|nonstopux)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_minor"
+ lt_irix_increment=no
+ ;;
+ esac
+ ;;
+ no)
+ current="$1"
+ revision="$2"
+ age="$3"
+ ;;
+ esac
+
+ # Check that each of the things are valid numbers.
+ case $current in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "CURRENT \`$current' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $revision in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "REVISION \`$revision' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $age in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "AGE \`$age' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ if test "$age" -gt "$current"; then
+ func_error "AGE \`$age' is greater than the current interface number \`$current'"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ fi
+
+ # Calculate the version variables.
+ major=
+ versuffix=
+ verstring=
+ case $version_type in
+ none) ;;
+
+ darwin)
+ # Like Linux, but with the current version available in
+ # verstring for coding it into the library header
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ # Darwin ld doesn't like 0 for these options...
+ func_arith $current + 1
+ minor_current=$func_arith_result
+ xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+ ;;
+
+ freebsd-aout)
+ major=".$current"
+ versuffix=".$current.$revision";
+ ;;
+
+ freebsd-elf)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ irix | nonstopux)
+ if test "X$lt_irix_increment" = "Xno"; then
+ func_arith $current - $age
+ else
+ func_arith $current - $age + 1
+ fi
+ major=$func_arith_result
+
+ case $version_type in
+ nonstopux) verstring_prefix=nonstopux ;;
+ *) verstring_prefix=sgi ;;
+ esac
+ verstring="$verstring_prefix$major.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$revision
+ while test "$loop" -ne 0; do
+ func_arith $revision - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring_prefix$major.$iface:$verstring"
+ done
+
+ # Before this point, $major must not contain `.'.
+ major=.$major
+ versuffix="$major.$revision"
+ ;;
+
+ linux)
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ ;;
+
+ osf)
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix=".$current.$age.$revision"
+ verstring="$current.$age.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$age
+ while test "$loop" -ne 0; do
+ func_arith $current - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring:${iface}.0"
+ done
+
+ # Make executables depend on our current version.
+ verstring="$verstring:${current}.0"
+ ;;
+
+ qnx)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ sunos)
+ major=".$current"
+ versuffix=".$current.$revision"
+ ;;
+
+ windows)
+ # Use '-' rather than '.', since we only want one
+ # extension on DOS 8.3 filesystems.
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+
+ *)
+ func_fatal_configuration "unknown library version type \`$version_type'"
+ ;;
+ esac
+
+ # Clear the version info if we defaulted, and they specified a release.
+ if test -z "$vinfo" && test -n "$release"; then
+ major=
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
+ if test "$need_version" = no; then
+ versuffix=
+ else
+ versuffix=".0.0"
+ fi
+ fi
+
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_version" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
+ # Check to see if the archive will have undefined symbols.
+ if test "$allow_undefined" = yes; then
+ if test "$allow_undefined_flag" = unsupported; then
+ func_warning "undefined symbols not allowed in $host shared libraries"
+ build_libtool_libs=no
+ build_old_libs=yes
+ fi
+ else
+ # Don't allow undefined symbols.
+ allow_undefined_flag="$no_undefined_flag"
+ fi
+
+ fi
+
+ func_generate_dlsyms "$libname" "$libname" "yes"
+ libobjs="$libobjs $symfileobj"
+ test "X$libobjs" = "X " && libobjs=
+
+ if test "$mode" != relink; then
+ # Remove our outputs, but don't remove object files since they
+ # may have been created when compiling PIC objects.
+ removelist=
+ tempremovelist=`$ECHO "$output_objdir/*"`
+ for p in $tempremovelist; do
+ case $p in
+ *.$objext)
+ ;;
+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+ if test "X$precious_files_regex" != "X"; then
+ if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+ then
+ continue
+ fi
+ fi
+ removelist="$removelist $p"
+ ;;
+ *) ;;
+ esac
+ done
+ test -n "$removelist" && \
+ func_show_eval "${RM}r \$removelist"
+ fi
+
+ # Now set the variables for building old libraries.
+ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+ oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+ # Transform .lo files to .o files.
+ oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+ fi
+
+ # Eliminate all temporary directories.
+ #for path in $notinst_path; do
+ # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
+ # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
+ # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
+ #done
+
+ if test -n "$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ temp_xrpath=
+ for libdir in $xrpath; do
+ temp_xrpath="$temp_xrpath -R$libdir"
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+ dependency_libs="$temp_xrpath $dependency_libs"
+ fi
+ fi
+
+ # Make sure dlfiles contains only unique files that won't be dlpreopened
+ old_dlfiles="$dlfiles"
+ dlfiles=
+ for lib in $old_dlfiles; do
+ case " $dlprefiles $dlfiles " in
+ *" $lib "*) ;;
+ *) dlfiles="$dlfiles $lib" ;;
+ esac
+ done
+
+ # Make sure dlprefiles contains only unique files
+ old_dlprefiles="$dlprefiles"
+ dlprefiles=
+ for lib in $old_dlprefiles; do
+ case "$dlprefiles " in
+ *" $lib "*) ;;
+ *) dlprefiles="$dlprefiles $lib" ;;
+ esac
+ done
+
+ if test "$build_libtool_libs" = yes; then
+ if test -n "$rpath"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
+ # these systems don't actually have a c library (as such)!
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C library is in the System framework
+ deplibs="$deplibs System.ltframework"
+ ;;
+ *-*-netbsd*)
+ # Don't link with libc until the a.out ld.so is fixed.
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ ;;
+ *)
+ # Add libc to deplibs on all other systems if necessary.
+ if test "$build_libtool_need_lc" = "yes"; then
+ deplibs="$deplibs -lc"
+ fi
+ ;;
+ esac
+ fi
+
+ # Transform deplibs into only deplibs that can be linked in shared.
+ name_save=$name
+ libname_save=$libname
+ release_save=$release
+ versuffix_save=$versuffix
+ major_save=$major
+ # I'm not sure if I'm treating the release correctly. I think
+ # release should show up in the -l (ie -lgmp5) so we don't want to
+ # add it in twice. Is that correct?
+ release=""
+ versuffix=""
+ major=""
+ newdeplibs=
+ droppeddeps=no
+ case $deplibs_check_method in
+ pass_all)
+ # Don't check for shared/static. Everything works.
+ # This might be a little naive. We might want to check
+ # whether the library exists or not. But this is on
+ # osf3 & osf4 and I'm not really sure... Just
+ # implementing what was already the behavior.
+ newdeplibs=$deplibs
+ ;;
+ test_compile)
+ # This code stresses the "libraries are programs" paradigm to its
+ # limits. Maybe even breaks it. We compile a program, linking it
+ # against the deplibs as a proxy for the library. Then we can check
+ # whether they linked in statically or dynamically with ldd.
+ $opt_dry_run || $RM conftest.c
+ cat > conftest.c <<EOF
+ int main() { return 0; }
+EOF
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+ ldd_output=`ldd conftest`
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which I believe you do not have"
+ $ECHO "*** because a test_compile did reveal that the linker did not use it for"
+ $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
+ fi
+ fi
+ ;;
+ *)
+ newdeplibs="$newdeplibs $i"
+ ;;
+ esac
+ done
+ else
+ # Error occurred in the first compile. Let's try to salvage
+ # the situation: Compile a separate program for each library.
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+ ldd_output=`ldd conftest`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because a test_compile did reveal that the linker did not use this one"
+ $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
+ fi
+ fi
+ else
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
+ $ECHO "*** make it link in! You will probably need to install it or some"
+ $ECHO "*** library that it depends on before this library will be fully"
+ $ECHO "*** functional. Installing it before continuing would be even better."
+ fi
+ ;;
+ *)
+ newdeplibs="$newdeplibs $i"
+ ;;
+ esac
+ done
+ fi
+ ;;
+ file_magic*)
+ set dummy $deplibs_check_method; shift
+ file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ # Follow soft links.
+ if ls -lLd "$potent_lib" 2>/dev/null |
+ $GREP " -> " >/dev/null; then
+ continue
+ fi
+ # The statement above tries to avoid entering an
+ # endless loop below, in case of cyclic links.
+ # We might still enter an endless loop, since a link
+ # loop can be closed while we follow links,
+ # but so what?
+ potlib="$potent_lib"
+ while test -h "$potlib" 2>/dev/null; do
+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+ case $potliblink in
+ [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+ *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+ esac
+ done
+ if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+ $SED -e 10q |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a file magic. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ potlib="$potent_lib" # see symlink-check above in file_magic test
+ if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
+ $EGREP "$match_pattern_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a regex pattern. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ none | unknown | *)
+ newdeplibs=""
+ tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
+ -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ for i in $predeps $postdeps ; do
+ # can't use Xsed below, because $i might contain '/'
+ tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
+ done
+ fi
+ if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' |
+ $GREP . >/dev/null; then
+ $ECHO
+ if test "X$deplibs_check_method" = "Xnone"; then
+ $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
+ else
+ $ECHO "*** Warning: inter-library dependencies are not known to be supported."
+ fi
+ $ECHO "*** All declared inter-library dependencies are being dropped."
+ droppeddeps=yes
+ fi
+ ;;
+ esac
+ versuffix=$versuffix_save
+ major=$major_save
+ release=$release_save
+ libname=$libname_save
+ name=$name_save
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library with the System framework
+ newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ if test "$droppeddeps" = yes; then
+ if test "$module" = yes; then
+ $ECHO
+ $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
+ $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
+ $ECHO "*** a static module, that should work as long as the dlopening"
+ $ECHO "*** application is linked with the -dlopen flag."
+ if test -z "$global_symbol_pipe"; then
+ $ECHO
+ $ECHO "*** However, this would only work if libtool was able to extract symbol"
+ $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $ECHO "*** not find such a program. So, this module is probably useless."
+ $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ else
+ $ECHO "*** The inter-library dependencies that have been dropped here will be"
+ $ECHO "*** automatically added whenever a program is linked with this library"
+ $ECHO "*** or is declared to -dlopen it."
+
+ if test "$allow_undefined" = no; then
+ $ECHO
+ $ECHO "*** Since this library must not contain undefined symbols,"
+ $ECHO "*** because either the platform does not support them or"
+ $ECHO "*** it was explicitly requested with -no-undefined,"
+ $ECHO "*** libtool will only create a static version of it."
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ fi
+ fi
+ # Done checking deplibs!
+ deplibs=$newdeplibs
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ case $host in
+ *-*-darwin*)
+ newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $deplibs " in
+ *" -L$path/$objdir "*)
+ new_libs="$new_libs -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ done
+ deplibs="$new_libs"
+
+ # All the library-specific variables (install_libdir is set above).
+ library_names=
+ old_library=
+ dlname=
+
+ # Test again, we may have decided not to build it any more
+ if test "$build_libtool_libs" = yes; then
+ if test "$hardcode_into_libs" = yes; then
+ # Hardcode the library paths
+ hardcode_libdirs=
+ dep_rpath=
+ rpath="$finalize_rpath"
+ test "$mode" != relink && rpath="$compile_rpath$rpath"
+ for libdir in $rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ dep_rpath="$dep_rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ if test -n "$hardcode_libdir_flag_spec_ld"; then
+ eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+ else
+ eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+ fi
+ fi
+ if test -n "$runpath_var" && test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+ fi
+ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+ fi
+
+ shlibpath="$finalize_shlibpath"
+ test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+ if test -n "$shlibpath"; then
+ eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+ fi
+
+ # Get the real and link names of the library.
+ eval shared_ext=\"$shrext_cmds\"
+ eval library_names=\"$library_names_spec\"
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+
+ if test -n "$soname_spec"; then
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+ if test -z "$dlname"; then
+ dlname=$soname
+ fi
+
+ lib="$output_objdir/$realname"
+ linknames=
+ for link
+ do
+ linknames="$linknames $link"
+ done
+
+ # Use standard objects if they are pic
+ test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ test "X$libobjs" = "X " && libobjs=
+
+ delfiles=
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+ export_symbols="$output_objdir/$libname.uexp"
+ delfiles="$delfiles $export_symbols"
+ fi
+
+ orig_export_symbols=
+ case $host_os in
+ cygwin* | mingw*)
+ if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+ # exporting using user supplied symfile
+ if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+ # and it's NOT already a .def file. Must figure out
+ # which of the given symbols are data symbols and tag
+ # them as such. So, trigger use of export_symbols_cmds.
+ # export_symbols gets reassigned inside the "prepare
+ # the list of exported symbols" if statement, so the
+ # include_expsyms logic still works.
+ orig_export_symbols="$export_symbols"
+ export_symbols=
+ always_export_symbols=yes
+ fi
+ fi
+ ;;
+ esac
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ cmds=$export_symbols_cmds
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ eval cmd=\"$cmd\"
+ func_len " $cmd"
+ len=$func_len_result
+ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ func_show_eval "$cmd" 'exit $?'
+ skipped_export=false
+ else
+ # The command line is too long to execute in one step.
+ func_verbose "using reloadable object file for export list..."
+ skipped_export=:
+ # Break out early, otherwise skipped_export may be
+ # set to false by a later but shorter cmd.
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+ fi
+
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+
+ tmp_deplibs=
+ for test_deplib in $deplibs; do
+ case " $convenience " in
+ *" $test_deplib "*) ;;
+ *)
+ tmp_deplibs="$tmp_deplibs $test_deplib"
+ ;;
+ esac
+ done
+ deplibs="$tmp_deplibs"
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec" &&
+ test "$compiler_needs_object" = yes &&
+ test -z "$libobjs"; then
+ # extract the archives, so we have objects to list.
+ # TODO: could optimize this to just extract one archive.
+ whole_archive_flag_spec=
+ fi
+ if test -n "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ else
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $convenience
+ libobjs="$libobjs $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ fi
+
+ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+ eval flag=\"$thread_safe_flag_spec\"
+ linker_flags="$linker_flags $flag"
+ fi
+
+ # Make a backup of the uninstalled library when relinking
+ if test "$mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+ fi
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ eval test_cmds=\"$module_expsym_cmds\"
+ cmds=$module_expsym_cmds
+ else
+ eval test_cmds=\"$module_cmds\"
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval test_cmds=\"$archive_expsym_cmds\"
+ cmds=$archive_expsym_cmds
+ else
+ eval test_cmds=\"$archive_cmds\"
+ cmds=$archive_cmds
+ fi
+ fi
+
+ if test "X$skipped_export" != "X:" &&
+ func_len " $test_cmds" &&
+ len=$func_len_result &&
+ test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # The command line is too long to link in one step, link piecewise
+ # or, if using GNU ld and skipped_export is not :, use a linker
+ # script.
+
+ # Save the value of $output and $libobjs because we want to
+ # use them later. If we have whole_archive_flag_spec, we
+ # want to use save_libobjs as it was before
+ # whole_archive_flag_spec was expanded, because we can't
+ # assume the linker understands whole_archive_flag_spec.
+ # This may have to be revisited, in case too many
+ # convenience libraries get linked in and end up exceeding
+ # the spec.
+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ fi
+ save_output=$output
+ output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
+
+ # Clear the reloadable object creation command queue and
+ # initialize k to one.
+ test_cmds=
+ concat_cmds=
+ objlist=
+ last_robj=
+ k=1
+
+ if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+ output=${output_objdir}/${output_la}.lnkscript
+ func_verbose "creating GNU ld script: $output"
+ $ECHO 'INPUT (' > $output
+ for obj in $save_libobjs
+ do
+ $ECHO "$obj" >> $output
+ done
+ $ECHO ')' >> $output
+ delfiles="$delfiles $output"
+ elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+ output=${output_objdir}/${output_la}.lnk
+ func_verbose "creating linker input file list: $output"
+ : > $output
+ set x $save_libobjs
+ shift
+ firstobj=
+ if test "$compiler_needs_object" = yes; then
+ firstobj="$1 "
+ shift
+ fi
+ for obj
+ do
+ $ECHO "$obj" >> $output
+ done
+ delfiles="$delfiles $output"
+ output=$firstobj\"$file_list_spec$output\"
+ else
+ if test -n "$save_libobjs"; then
+ func_verbose "creating reloadable object files..."
+ output=$output_objdir/$output_la-${k}.$objext
+ eval test_cmds=\"$reload_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+
+ # Loop over the list of objects to be linked.
+ for obj in $save_libobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ if test "X$objlist" = X ||
+ test "$len" -lt "$max_cmd_len"; then
+ func_append objlist " $obj"
+ else
+ # The command $test_cmds is almost too long, add a
+ # command to the queue.
+ if test "$k" -eq 1 ; then
+ # The first file doesn't have a previous command to add.
+ eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+ else
+ # All subsequent reloadable object files will link in
+ # the last one created.
+ eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
+ fi
+ last_robj=$output_objdir/$output_la-${k}.$objext
+ func_arith $k + 1
+ k=$func_arith_result
+ output=$output_objdir/$output_la-${k}.$objext
+ objlist=$obj
+ func_len " $last_robj"
+ func_arith $len0 + $func_len_result
+ len=$func_arith_result
+ fi
+ done
+ # Handle the remaining objects by creating one last
+ # reloadable object file. All subsequent reloadable object
+ # files will link in the last one created.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+ fi
+ delfiles="$delfiles $output"
+
+ else
+ output=
+ fi
+
+ if ${skipped_export-false}; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+ fi
+ fi
+
+ test -n "$save_libobjs" &&
+ func_verbose "creating a temporary reloadable object file: $output"
+
+ # Loop through the commands generated above and execute them.
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+
+ if ${skipped_export-false}; then
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+ fi
+
+ libobjs=$output
+ # Restore the value of output.
+ output=$save_output
+
+ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ # Expand the library linking commands again to reset the
+ # value of $libobjs for piecewise linking.
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ cmds=$module_expsym_cmds
+ else
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ cmds=$archive_expsym_cmds
+ else
+ cmds=$archive_cmds
+ fi
+ fi
+ fi
+
+ if test -n "$delfiles"; then
+ # Append the command to remove temporary files to $cmds.
+ eval cmds=\"\$cmds~\$RM $delfiles\"
+ fi
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ libobjs="$libobjs $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ eval cmd=\"$cmd\"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+ if test -n "$convenience"; then
+ if test -z "$whole_archive_flag_spec"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ # Create links to the real library.
+ for linkname in $linknames; do
+ if test "$realname" != "$linkname"; then
+ func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+ fi
+ done
+
+ # If -module or -export-dynamic was specified, set the dlname.
+ if test "$module" = yes || test "$export_dynamic" = yes; then
+ # On all known operating systems, these are identical.
+ dlname="$soname"
+ fi
+ fi
+ ;;
+
+ obj)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for objects"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for objects" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for objects"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for objects"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for objects"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for objects"
+
+ case $output in
+ *.lo)
+ test -n "$objs$old_deplibs" && \
+ func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+ libobj=$output
+ func_lo2o "$libobj"
+ obj=$func_lo2o_result
+ ;;
+ *)
+ libobj=
+ obj="$output"
+ ;;
+ esac
+
+ # Delete the old objects.
+ $opt_dry_run || $RM $obj $libobj
+
+ # Objects from convenience libraries. This assumes
+ # single-version convenience libraries. Whenever we create
+ # different ones for PIC/non-PIC, this we'll have to duplicate
+ # the extraction.
+ reload_conv_objs=
+ gentop=
+ # reload_cmds runs $LD directly, so let us get rid of
+ # -Wl from whole_archive_flag_spec and hope we can get by with
+ # turning comma into space..
+ wl=
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+ reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
+ else
+ gentop="$output_objdir/${obj}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $convenience
+ reload_conv_objs="$reload_objs $func_extract_archives_result"
+ fi
+ fi
+
+ # Create the old-style object.
+ reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+ output="$obj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+
+ # Exit if we aren't doing a library object file.
+ if test -z "$libobj"; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$build_libtool_libs" != yes; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ # Create an invalid libtool object if no PIC, so that we don't
+ # accidentally link it into a program.
+ # $show "echo timestamp > $libobj"
+ # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+ exit $EXIT_SUCCESS
+ fi
+
+ if test -n "$pic_flag" || test "$pic_mode" != default; then
+ # Only do commands if we really have different PIC objects.
+ reload_objs="$libobjs $reload_conv_objs"
+ output="$libobj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+ fi
+
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ ;;
+
+ prog)
+ case $host in
+ *cygwin*) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result.exe;;
+ esac
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for programs"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for programs"
+
+ test "$preload" = yes \
+ && test "$dlopen_support" = unknown \
+ && test "$dlopen_self" = unknown \
+ && test "$dlopen_self_static" = unknown && \
+ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+ finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ case $host in
+ *-*-darwin*)
+ # Don't allow lazy linking, it breaks C++ global constructors
+ # But is supposedly fixed on 10.4 or later (yay!).
+ if test "$tagname" = CXX ; then
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+ 10.[0123])
+ compile_command="$compile_command ${wl}-bind_at_load"
+ finalize_command="$finalize_command ${wl}-bind_at_load"
+ ;;
+ esac
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $compile_deplibs " in
+ *" -L$path/$objdir "*)
+ new_libs="$new_libs -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $compile_deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ done
+ compile_deplibs="$new_libs"
+
+
+ compile_command="$compile_command $compile_deplibs"
+ finalize_command="$finalize_command $finalize_deplibs"
+
+ if test -n "$rpath$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ for libdir in $rpath $xrpath; do
+ # This is the magic to use -rpath.
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ fi
+
+ # Now hardcode the library paths
+ rpath=
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$libdir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$libdir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$testbindir";;
+ esac
+ ;;
+ esac
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ compile_rpath="$rpath"
+
+ rpath=
+ hardcode_libdirs=
+ for libdir in $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$finalize_perm_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ finalize_rpath="$rpath"
+
+ if test -n "$libobjs" && test "$build_old_libs" = yes; then
+ # Transform all the library objects into standard objects.
+ compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ fi
+
+ func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+ # template prelinking step
+ if test -n "$prelink_cmds"; then
+ func_execute_cmds "$prelink_cmds" 'exit $?'
+ fi
+
+ wrappers_required=yes
+ case $host in
+ *cygwin* | *mingw* )
+ if test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ *)
+ if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ esac
+ if test "$wrappers_required" = no; then
+ # Replace the output file specification.
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ link_command="$compile_command$compile_rpath"
+
+ # We have no uninstalled library dependencies, so finalize right now.
+ exit_status=0
+ func_show_eval "$link_command" 'exit_status=$?'
+
+ # Delete the generated files.
+ if test -f "$output_objdir/${outputname}S.${objext}"; then
+ func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+ fi
+
+ exit $exit_status
+ fi
+
+ if test -n "$compile_shlibpath$finalize_shlibpath"; then
+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+ fi
+ if test -n "$finalize_shlibpath"; then
+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+ fi
+
+ compile_var=
+ finalize_var=
+ if test -n "$runpath_var"; then
+ if test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ if test -n "$finalize_perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $finalize_perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ fi
+
+ if test "$no_install" = yes; then
+ # We don't need to create a wrapper script.
+ link_command="$compile_var$compile_command$compile_rpath"
+ # Replace the output file specification.
+ link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ # Delete the old output file.
+ $opt_dry_run || $RM $output
+ # Link the executable and exit
+ func_show_eval "$link_command" 'exit $?'
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+ func_warning "this platform does not like uninstalled shared libraries"
+ func_warning "\`$output' will be relinked during installation"
+ else
+ if test "$fast_install" != no; then
+ link_command="$finalize_var$compile_command$finalize_rpath"
+ if test "$fast_install" = yes; then
+ relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+ else
+ # fast_install is set to needless
+ relink_command=
+ fi
+ else
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+ fi
+ fi
+
+ # Replace the output file specification.
+ link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+ # Delete the old output files.
+ $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+ func_show_eval "$link_command" 'exit $?'
+
+ # Now create the wrapper script.
+ func_verbose "creating $output"
+
+ # Quote the relink command for shipping.
+ if test -n "$relink_command"; then
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ relink_command="(cd `pwd`; $relink_command)"
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Quote $ECHO for shipping.
+ if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
+ case $progpath in
+ [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+ *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+ esac
+ qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
+ else
+ qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Only actually do things if not in dry run mode.
+ $opt_dry_run || {
+ # win32 will think the script is a binary if it has
+ # a .exe suffix, so we strip it off here.
+ case $output in
+ *.exe) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result ;;
+ esac
+ # test for cygwin because mv fails w/o .exe extensions
+ case $host in
+ *cygwin*)
+ exeext=.exe
+ func_stripname '' '.exe' "$outputname"
+ outputname=$func_stripname_result ;;
+ *) exeext= ;;
+ esac
+ case $host in
+ *cygwin* | *mingw* )
+ func_dirname_and_basename "$output" "" "."
+ output_name=$func_basename_result
+ output_path=$func_dirname_result
+ cwrappersource="$output_path/$objdir/lt-$output_name.c"
+ cwrapper="$output_path/$output_name.exe"
+ $RM $cwrappersource $cwrapper
+ trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_cwrapperexe_src > $cwrappersource
+
+ # we should really use a build-platform specific compiler
+ # here, but OTOH, the wrappers (shell script and this C one)
+ # are only useful if you want to execute the "real" binary.
+ # Since the "real" binary is built for $host, then this
+ # wrapper might as well be built for $host, too.
+ $opt_dry_run || {
+ $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+ $STRIP $cwrapper
+ }
+
+ # Now, create the wrapper script for func_source use:
+ func_ltwrapper_scriptname $cwrapper
+ $RM $func_ltwrapper_scriptname_result
+ trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+ $opt_dry_run || {
+ # note: this script will not be executed, so do not chmod.
+ if test "x$build" = "x$host" ; then
+ $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+ else
+ func_emit_wrapper no > $func_ltwrapper_scriptname_result
+ fi
+ }
+ ;;
+ * )
+ $RM $output
+ trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_wrapper no > $output
+ chmod +x $output
+ ;;
+ esac
+ }
+ exit $EXIT_SUCCESS
+ ;;
+ esac
+
+ # See if we need to build an old-fashioned archive.
+ for oldlib in $oldlibs; do
+
+ if test "$build_libtool_libs" = convenience; then
+ oldobjs="$libobjs_save $symfileobj"
+ addlibs="$convenience"
+ build_libtool_libs=no
+ else
+ if test "$build_libtool_libs" = module; then
+ oldobjs="$libobjs_save"
+ build_libtool_libs=no
+ else
+ oldobjs="$old_deplibs $non_pic_objects"
+ if test "$preload" = yes && test -f "$symfileobj"; then
+ oldobjs="$oldobjs $symfileobj"
+ fi
+ fi
+ addlibs="$old_convenience"
+ fi
+
+ if test -n "$addlibs"; then
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $addlibs
+ oldobjs="$oldobjs $func_extract_archives_result"
+ fi
+
+ # Do each command in the archive commands.
+ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+ cmds=$old_archive_from_new_cmds
+ else
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ oldobjs="$oldobjs $func_extract_archives_result"
+ fi
+
+ # POSIX demands no paths to be encoded in archives. We have
+ # to avoid creating archives with duplicate basenames if we
+ # might have to extract them afterwards, e.g., when creating a
+ # static archive out of a convenience library, or when linking
+ # the entirety of a libtool archive into another (currently
+ # not supported by libtool).
+ if (for obj in $oldobjs
+ do
+ func_basename "$obj"
+ $ECHO "$func_basename_result"
+ done | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $ECHO "copying selected object files to avoid basename conflicts..."
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+ func_mkdir_p "$gentop"
+ save_oldobjs=$oldobjs
+ oldobjs=
+ counter=1
+ for obj in $save_oldobjs
+ do
+ func_basename "$obj"
+ objbase="$func_basename_result"
+ case " $oldobjs " in
+ " ") oldobjs=$obj ;;
+ *[\ /]"$objbase "*)
+ while :; do
+ # Make sure we don't pick an alternate name that also
+ # overlaps.
+ newobj=lt$counter-$objbase
+ func_arith $counter + 1
+ counter=$func_arith_result
+ case " $oldobjs " in
+ *[\ /]"$newobj "*) ;;
+ *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+ esac
+ done
+ func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+ oldobjs="$oldobjs $gentop/$newobj"
+ ;;
+ *) oldobjs="$oldobjs $obj" ;;
+ esac
+ done
+ fi
+ eval cmds=\"$old_archive_cmds\"
+
+ func_len " $cmds"
+ len=$func_len_result
+ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ cmds=$old_archive_cmds
+ else
+ # the command line is too long to link in one step, link in parts
+ func_verbose "using piecewise archive linking..."
+ save_RANLIB=$RANLIB
+ RANLIB=:
+ objlist=
+ concat_cmds=
+ save_oldobjs=$oldobjs
+ oldobjs=
+ # Is there a better way of finding the last object in the list?
+ for obj in $save_oldobjs
+ do
+ last_oldobj=$obj
+ done
+ eval test_cmds=\"$old_archive_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+ for obj in $save_oldobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ func_append objlist " $obj"
+ if test "$len" -lt "$max_cmd_len"; then
+ :
+ else
+ # the above command should be used before it gets too long
+ oldobjs=$objlist
+ if test "$obj" = "$last_oldobj" ; then
+ RANLIB=$save_RANLIB
+ fi
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+ objlist=
+ len=$len0
+ fi
+ done
+ RANLIB=$save_RANLIB
+ oldobjs=$objlist
+ if test "X$oldobjs" = "X" ; then
+ eval cmds=\"\$concat_cmds\"
+ else
+ eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+ fi
+ fi
+ fi
+ func_execute_cmds "$cmds" 'exit $?'
+ done
+
+ test -n "$generated" && \
+ func_show_eval "${RM}r$generated"
+
+ # Now create the libtool archive.
+ case $output in
+ *.la)
+ old_library=
+ test "$build_old_libs" = yes && old_library="$libname.$libext"
+ func_verbose "creating $output"
+
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ # Quote the link command for shipping.
+ relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ if test "$hardcode_automatic" = yes ; then
+ relink_command=
+ fi
+
+ # Only create the output if not a dry run.
+ $opt_dry_run || {
+ for installed in no yes; do
+ if test "$installed" = yes; then
+ if test -z "$install_libdir"; then
+ break
+ fi
+ output="$output_objdir/$outputname"i
+ # Replace all uninstalled libtool libraries with the installed ones
+ newdependency_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ *.la)
+ func_basename "$deplib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ newdependency_libs="$newdependency_libs $libdir/$name"
+ ;;
+ *) newdependency_libs="$newdependency_libs $deplib" ;;
+ esac
+ done
+ dependency_libs="$newdependency_libs"
+ newdlfiles=
+
+ for lib in $dlfiles; do
+ case $lib in
+ *.la)
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ newdlfiles="$newdlfiles $libdir/$name"
+ ;;
+ *) newdlfiles="$newdlfiles $lib" ;;
+ esac
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ *.la)
+ # Only pass preopened files to the pseudo-archive (for
+ # eventual linking with the app. that links it) if we
+ # didn't already link the preopened objects directly into
+ # the library:
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ newdlprefiles="$newdlprefiles $libdir/$name"
+ ;;
+ esac
+ done
+ dlprefiles="$newdlprefiles"
+ else
+ newdlfiles=
+ for lib in $dlfiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ newdlfiles="$newdlfiles $abs"
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ newdlprefiles="$newdlprefiles $abs"
+ done
+ dlprefiles="$newdlprefiles"
+ fi
+ $RM $output
+ # place dlname in correct position for cygwin
+ tdlname=$dlname
+ case $host,$output,$installed,$module,$dlname in
+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+ esac
+ $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+ if test "$installed" = no && test "$need_relink" = yes; then
+ $ECHO >> $output "\
+relink_command=\"$relink_command\""
+ fi
+ done
+ }
+
+ # Do a symbolic link so that the libtool archive can be found in
+ # LD_LIBRARY_PATH before the program is installed.
+ func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+ ;;
+ esac
+ exit $EXIT_SUCCESS
+}
+
+{ test "$mode" = link || test "$mode" = relink; } &&
+ func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+ $opt_debug
+ RM="$nonopt"
+ files=
+ rmforce=
+ exit_status=0
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ for arg
+ do
+ case $arg in
+ -f) RM="$RM $arg"; rmforce=yes ;;
+ -*) RM="$RM $arg" ;;
+ *) files="$files $arg" ;;
+ esac
+ done
+
+ test -z "$RM" && \
+ func_fatal_help "you must specify an RM program"
+
+ rmdirs=
+
+ origobjdir="$objdir"
+ for file in $files; do
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ if test "X$dir" = X.; then
+ objdir="$origobjdir"
+ else
+ objdir="$dir/$origobjdir"
+ fi
+ func_basename "$file"
+ name="$func_basename_result"
+ test "$mode" = uninstall && objdir="$dir"
+
+ # Remember objdir for removal later, being careful to avoid duplicates
+ if test "$mode" = clean; then
+ case " $rmdirs " in
+ *" $objdir "*) ;;
+ *) rmdirs="$rmdirs $objdir" ;;
+ esac
+ fi
+
+ # Don't error if the file doesn't exist and rm -f was used.
+ if { test -L "$file"; } >/dev/null 2>&1 ||
+ { test -h "$file"; } >/dev/null 2>&1 ||
+ test -f "$file"; then
+ :
+ elif test -d "$file"; then
+ exit_status=1
+ continue
+ elif test "$rmforce" = yes; then
+ continue
+ fi
+
+ rmfiles="$file"
+
+ case $name in
+ *.la)
+ # Possibly a libtool archive, so verify it.
+ if func_lalib_p "$file"; then
+ func_source $dir/$name
+
+ # Delete the libtool libraries and symlinks.
+ for n in $library_names; do
+ rmfiles="$rmfiles $objdir/$n"
+ done
+ test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+ case "$mode" in
+ clean)
+ case " $library_names " in
+ # " " in the beginning catches empty $dlname
+ *" $dlname "*) ;;
+ *) rmfiles="$rmfiles $objdir/$dlname" ;;
+ esac
+ test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+ ;;
+ uninstall)
+ if test -n "$library_names"; then
+ # Do each command in the postuninstall commands.
+ func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+
+ if test -n "$old_library"; then
+ # Do each command in the old_postuninstall commands.
+ func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+ # FIXME: should reinstall the best remaining shared library.
+ ;;
+ esac
+ fi
+ ;;
+
+ *.lo)
+ # Possibly a libtool object, so verify it.
+ if func_lalib_p "$file"; then
+
+ # Read the .lo file
+ func_source $dir/$name
+
+ # Add PIC object to the list of files to remove.
+ if test -n "$pic_object" &&
+ test "$pic_object" != none; then
+ rmfiles="$rmfiles $dir/$pic_object"
+ fi
+
+ # Add non-PIC object to the list of files to remove.
+ if test -n "$non_pic_object" &&
+ test "$non_pic_object" != none; then
+ rmfiles="$rmfiles $dir/$non_pic_object"
+ fi
+ fi
+ ;;
+
+ *)
+ if test "$mode" = clean ; then
+ noexename=$name
+ case $file in
+ *.exe)
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ func_stripname '' '.exe' "$name"
+ noexename=$func_stripname_result
+ # $file with .exe has already been added to rmfiles,
+ # add $file without .exe
+ rmfiles="$rmfiles $file"
+ ;;
+ esac
+ # Do a test to see if this is a libtool program.
+ if func_ltwrapper_p "$file"; then
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ relink_command=
+ func_source $func_ltwrapper_scriptname_result
+ rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
+ else
+ relink_command=
+ func_source $dir/$noexename
+ fi
+
+ # note $name still contains .exe if it was in $file originally
+ # as does the version of $file that was added into $rmfiles
+ rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+ if test "$fast_install" = yes && test -n "$relink_command"; then
+ rmfiles="$rmfiles $objdir/lt-$name"
+ fi
+ if test "X$noexename" != "X$name" ; then
+ rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ func_show_eval "$RM $rmfiles" 'exit_status=1'
+ done
+ objdir="$origobjdir"
+
+ # Try to remove the ${objdir}s in the directories where we deleted files
+ for dir in $rmdirs; do
+ if test -d "$dir"; then
+ func_show_eval "rmdir $dir >/dev/null 2>&1"
+ fi
+ done
+
+ exit $exit_status
+}
+
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+ func_mode_uninstall ${1+"$@"}
+
+test -z "$mode" && {
+ help="$generic_help"
+ func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+ func_fatal_help "invalid operation mode \`$mode'"
+
+if test -n "$exec_cmd"; then
+ eval exec "$exec_cmd"
+ exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries. Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them. This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration. But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/m4/libtool.m4 b/m4/libtool.m4
new file mode 100644
index 0000000..4ceb7f1
--- /dev/null
+++ b/m4/libtool.m4
@@ -0,0 +1,7309 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# 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.
+
+m4_define([_LT_COPYING], [dnl
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool 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.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 56 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+ [m4_default([$3],
+ [m4_fatal([Libtool version $1 or higher is required],
+ 63)])],
+ [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+ *\ * | *\ *)
+ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+m4_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_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+_LT_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.
+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 delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ _LT_PATH_MAGIC
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME. Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+ [m4_ifval([$1], [$1], [$2])])
+ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+ m4_ifval([$4],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+ lt_dict_add_subkey([lt_decl_dict], [$2],
+ [tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+ [0], [m4_fatal([$0: too few arguments: $#])],
+ [1], [m4_fatal([$0: too few arguments: $#: $1])],
+ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_quote(m4_if([$2], [],
+ m4_quote(lt_decl_tag_varnames),
+ m4_quote(m4_shift($@)))),
+ m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
+m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_if([$2], [],
+ m4_quote(lt_decl_varnames),
+ m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'. VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly. In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+# <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+# # Some comment about what VAR is for.
+# visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+ [description])))[]dnl
+m4_pushdef([_libtool_name],
+ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+ [0], [_libtool_name=[$]$1],
+ [1], [_libtool_name=$lt_[]$1],
+ [2], [_libtool_name=$lt_[]$1],
+ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'. Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+ dnl If the libtool generation code has been placed in $CONFIG_LT,
+ dnl instead of duplicating it all over again into config.status,
+ dnl then we will have config.status run $CONFIG_LT later, so it
+ dnl needs to know what name is stored there:
+ [AC_CONFIG_COMMANDS([libtool],
+ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+ dnl If the libtool generation code is destined for config.status,
+ dnl expand the accumulated commands and init code now:
+ [AC_CONFIG_COMMANDS([libtool],
+ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# 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
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\[$]0 --fallback-echo"')dnl "
+ lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+ ;;
+esac
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+cat >"$CONFIG_LT" <<_LTEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate a libtool stub with the current configuration.
+
+lt_cl_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AS_SHELL_SANITIZE
+_AS_PREPARE
+
+exec AS_MESSAGE_FD>&1
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+ echo
+ AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+
+Report bugs to <bug-libtool at gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+ case $[1] in
+ --version | --v* | -V )
+ echo "$lt_cl_version"; exit 0 ;;
+ --help | --h* | -h )
+ echo "$lt_cl_help"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --quiet | --q* | --silent | --s* | -q )
+ lt_cl_silent=: ;;
+
+ -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+ *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+ esac
+ shift
+done
+
+if $lt_cl_silent; then
+ exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure. Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+if test "$no_create" != yes; then
+ lt_cl_success=:
+ test "$silent" = yes &&
+ lt_config_lt_args="$lt_config_lt_args --quiet"
+ exec AS_MESSAGE_LOG_FD>/dev/null
+ $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+ exec AS_MESSAGE_LOG_FD>>config.log
+ $lt_cl_success || AS_EXIT(1)
+fi
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, 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 TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+ m4_if(_LT_TAG, [C], [
+ # 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
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_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
+_LT_EOF
+ ;;
+ esac
+
+ _LT_PROG_LTMAIN
+
+ # 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 '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ _LT_PROG_XSI_SHELLFNS
+
+ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+# autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+ [C], [_LT_LANG(C)],
+ [C++], [_LT_LANG(CXX)],
+ [Java], [_LT_LANG(GCJ)],
+ [Fortran 77], [_LT_LANG(F77)],
+ [Fortran], [_LT_LANG(FC)],
+ [Windows Resource], [_LT_LANG(RC)],
+ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+ [_LT_LANG($1)],
+ [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+ [LT_SUPPORTED_TAG([$1])dnl
+ m4_append([_LT_TAGS], [$1 ])dnl
+ m4_define([_LT_LANG_]$1[_enabled], [])dnl
+ _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [LT_LANG(CXX)],
+ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+ [LT_LANG(F77)],
+ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+ [LT_LANG(FC)],
+ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [m4_ifdef([AC_PROG_GCJ],
+ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([A][M_PROG_GCJ],
+ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([LT_PROG_GCJ],
+ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+ [LT_LANG(RC)],
+ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])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_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_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.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_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
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+ case $host_os in
+ rhapsody* | darwin*)
+ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+ AC_CHECK_TOOL([LIPO], [lipo], [:])
+ AC_CHECK_TOOL([OTOOL], [otool], [:])
+ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+ _LT_DECL([], [DSYMUTIL], [1],
+ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+ _LT_DECL([], [NMEDIT], [1],
+ [Tool to change global to local symbols on Mac OS X])
+ _LT_DECL([], [LIPO], [1],
+ [Tool to manipulate fat objects and archives on Mac OS X])
+ _LT_DECL([], [OTOOL], [1],
+ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+ _LT_DECL([], [OTOOL64], [1],
+ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+ 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.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ 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.[[012]])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # 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_DARWIN_LINKER_FEATURES
+# --------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+ if test "$GCC" = "yes"; then
+ output_verbose_link_cmd=echo
+ _LT_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_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ _LT_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_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}"
+ m4_if([$1], [CXX],
+[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ _LT_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_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
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+])
+
+# _LT_SYS_MODULE_PATH_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.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_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_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+ [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_SHELL_INIT
+
+
+# _LT_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.
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[_LT_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+ ;;
+esac
+
+ECHO=${lt_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 <<_LT_EOF
+[$]*
+_LT_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 "$lt_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 &&
+ { 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.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+ lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(lt_ECHO)
+])
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1],
+ [An echo program that does not interpret backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+ [AS_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*|s390*-*tpf*|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*)
+ 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*|s390*-*tpf*)
+ 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_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[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*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[AC_CHECK_TOOL(AR, ar, false)
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1])
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+ [Commands used to install an old-style archive])
+
+# 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_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+ [Commands used to build an old-style archive])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ m4_if([$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
+ m4_if([$5], , :, [$5])
+else
+ m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_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
+ m4_if([$4], , :, [$4])
+else
+ m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# 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
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ 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
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+ [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_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 <<_LT_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);
+}]
+_LT_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_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_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_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_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
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+ [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+ [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+ [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+ [_LT_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_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 ..
+ $RM -r conftest
+ $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+ [Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_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
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_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
+_LT_DECL([], [objdir], [0],
+ [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+ [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$_LT_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_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+ # Linking always hardcodes the temporary library directory.
+ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+ test "$_LT_TAGVAR(inherit_rpath, $1)" = 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
+_LT_TAGDECL([], [hardcode_action], [0],
+ [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+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
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+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])
+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`'
+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
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+ [shlibpath_overrides_runpath=yes])])
+ 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
+
+ # 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=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
+ ;;
+
+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
+ 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
+AC_MSG_RESULT([$dynamic_linker])
+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
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+ [Variables whose values should be saved in libtool wrapper scripts and
+ restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+ [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+ [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+ [[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]])
+_LT_DECL([], [soname_spec], [1],
+ [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [postinstall_cmds], [2],
+ [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+ [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+ [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+ [[As "finish_cmds", except a single script fragment to be evaled but
+ not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+ [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+ [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+ [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_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="m4_if([$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 <<_LT_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
+
+_LT_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
+_LT_DECL([], [MAGIC_CMD], [0],
+ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_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
+ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+ else
+ MAGIC_CMD=:
+ fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_ARG_WITH([gnu-ld],
+ [AS_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])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])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[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
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+# -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[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
+_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_DECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+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=pass_all
+ ;;
+
+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
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ 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
+ ;;
+
+tpf*)
+ 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
+
+_LT_DECL([], [deplibs_check_method], [1],
+ [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+ [Command to use when deplibs_check_method == "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (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
+ : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
+ AC_SUBST([DUMPBIN])
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+ [lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
+ cat conftest.out >&AS_MESSAGE_LOG_FD
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[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_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+ lt_cv_prog_compiler_rtti_exceptions,
+ [-fno-rtti -fno-exceptions], [],
+ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+ [Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# 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]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[[BCDT]]'
+ ;;
+cygwin* | mingw* | pw32*)
+ symcode='[[ABCDGISTW]]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[[ABCDEGRST]]'
+ 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
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \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\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# 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
+
+# Try without a prefix underscore, 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.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK ['"\
+" {last_section=section; section=\$ 3};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx]"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_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 <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_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_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
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+ [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+ [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+ [lt_cv_sys_global_symbol_to_c_name_address], [1],
+ [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+ [Transform the output of nm in a C name address pair when lib prefix is needed])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+m4_if([$1], [CXX], [
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_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_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ 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_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_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ _LT_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_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_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ *)
+ _LT_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_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_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
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ fi
+ ;;
+ aCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_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_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_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_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_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_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xlc* | xlC*)
+ # IBM XL 8.0 on PPC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd*)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ _LT_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_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_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_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+],
+[
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_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_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)='-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
+ m4_if([$1], [GCJ], [],
+ [_LT_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_TAGVAR(lt_prog_compiler_pic, $1)='-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_TAGVAR(lt_prog_compiler_pic, $1)='-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_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ _LT_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_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-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).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ _LT_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_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC (with -KPIC) is the default.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ icc* | ecc* | ifort*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_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_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ ccc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All Alpha code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xl*)
+ # IBM XL C 8.0/Fortran 10.1 on PPC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ ;;
+ *Sun\ F*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All OSF/1 code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ rdos*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ unicos*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+])
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t at m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+ ;;
+esac
+AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+ [How to pass a linker flag through the compiler])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t at m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+ "" | " "*) ;;
+ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+ esac],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+ [Additional compiler flags for building library objects])
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+ $lt_tmp_static_flag,
+ [],
+ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+ [Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+ _LT_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_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_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_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+ ;;
+ cygwin* | mingw*)
+ _LT_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_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+], [
+ runpath_var=
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(archive_cmds, $1)=
+ _LT_TAGVAR(archive_expsym_cmds, $1)=
+ _LT_TAGVAR(compiler_needs_object, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(hardcode_automatic, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ _LT_TAGVAR(hardcode_minus_L, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(inherit_rpath, $1)=no
+ _LT_TAGVAR(link_all_deplibs, $1)=unknown
+ _LT_TAGVAR(module_cmds, $1)=
+ _LT_TAGVAR(module_expsym_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+ _LT_TAGVAR(thread_safe_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ _LT_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_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=
+
+ 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_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_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_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_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ 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
+ _LT_TAGVAR(ld_shlibs, $1)=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
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_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_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(export_symbols_cmds, $1)='$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
+ _LT_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_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_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_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_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_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* | 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
+ _LT_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_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' ;;
+ 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
+ _LT_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'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_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
+
+ case $cc_basename in
+ xlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_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~
+ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_TAGVAR(ld_shlibs, $1)=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
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_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_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
+ ;;
+ *)
+ # 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
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+
+ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+ runpath_var=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_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_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_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_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_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_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_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_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${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
+ _LT_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_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_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_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_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_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 "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_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_SYS_MODULE_PATH_AIX
+ _LT_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_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ _LT_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*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[[45]]*)
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_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_TAGVAR(archive_cmds, $1)='$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.
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ # FIXME: Should let the user specify the lib program.
+ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ freebsd1*)
+ _LT_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_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ _LT_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_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_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_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_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_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_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_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_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_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$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"
+ AC_LINK_IFELSE(int foo(void) {},
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$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'
+ )
+ LDFLAGS="$save_LDFLAGS"
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$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'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$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
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ else
+ case $host_os in
+ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_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_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$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
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$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
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$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'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$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'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='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
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_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}-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=''
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_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'
+ ;;
+ *)
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_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} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_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_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ _LT_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_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ ;;
+ motorola)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4.3*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_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_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+ [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+ # Assume -lc should be added
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $_LT_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_TAGVAR(lt_prog_compiler_wl, $1)
+ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+ then
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ else
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ fi
+ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+ [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+ [enable_shared_with_static_runtimes], [0],
+ [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+ [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+ [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+ [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+ [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+ [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+ [Commands used to build a loadable module if different from building
+ a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+ [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+ [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+ [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+ [Flag to hardcode $libdir into a binary during linking.
+ This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [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]])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+ [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary and the resulting library dependency is
+ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+ library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+ [Set to "yes" if building a shared library automatically hardcodes DIR
+ into the library and all subsequent libraries and executables linked
+ against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+ [Set to yes if linker adds runtime paths of dependent libraries
+ to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+ [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [fix_srcfile_path], [1],
+ [Fix the shell variable $srcfile for the compiler])
+_LT_TAGDECL([], [always_export_symbols], [0],
+ [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+ [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+ [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+ [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+ [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [file_list_spec], [1],
+ [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+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_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_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## 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...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+ LT_SYS_DLOPEN_SELF
+ _LT_CMD_STRIPLIB
+
+ # 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])
+
+ _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_PROG_CXX
+# ------------
+# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
+# compiler, we have our own version here.
+m4_defun([_LT_PROG_CXX],
+[
+pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
+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
+else
+ _lt_caught_CXX_error=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_CXX
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[AC_REQUIRE([_LT_PROG_CXX])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX 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_caught_CXX_error" != yes; then
+ # 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_TAG_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_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+ LT_PATH_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_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_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_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_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_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_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ _LT_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_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ 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_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_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_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_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_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ _LT_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 "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_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_SYS_MODULE_PATH_AIX
+ _LT_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_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ _LT_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_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_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_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_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_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ freebsd[[12]]*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ freebsd-elf*)
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ hpux9*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_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_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ _LT_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) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ _LT_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_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_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_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_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 "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_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_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_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_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_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_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_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -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_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_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $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
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+ fi
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+ esac
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ ;;
+
+ 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_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_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 "X$list" | $Xsed'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_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_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # 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_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
+ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+ $RANLIB $oldlib'
+ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 will use weak symbols
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_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'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_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_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ _LT_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 "X$templist" | $Xsed -e "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 "X$list" | $Xsed'
+ ;;
+ xl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_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 -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_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'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+ # 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_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_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::"'
+ ;;
+
+ *nto* | *qnx*)
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ _LT_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_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_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=echo
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ osf3* | 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_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_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_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 "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ ;;
+ esac
+
+ _LT_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 "X$templist" | $Xsed -e "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 "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ _LT_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 "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ _LT_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" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_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_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_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_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ _LT_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_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_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_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_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_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_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_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_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ _LT_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_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_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.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$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_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+ _LT_TAGVAR(GCC, $1)="$GXX"
+ _LT_TAGVAR(LD, $1)="$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_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ 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
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_SYS_HIDDEN_LIBDEPS([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.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+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...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer*4 a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+ private int a;
+ public void bar (void) {
+ a = 0;
+ }
+};
+_LT_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
+
+ 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_TAGVAR(compiler_lib_search_path, $1)"; then
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_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_TAGVAR(postdeps, $1)"; then
+ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(postdeps, $1)="${_LT_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_TAGVAR(predep_objects, $1)"; then
+ _LT_TAGVAR(predep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+ fi
+ else
+ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+ _LT_TAGVAR(postdep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(postdep_objects, $1)="$_LT_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
+
+# PORTME: override above test on systems where it is broken
+m4_if([$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_TAGVAR(predep_objects,$1)=
+ _LT_TAGVAR(postdep_objects,$1)=
+ _LT_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_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_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+ [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+ [Dependencies to place before and after the objects being linked to
+ create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+ [The library search path used internally by the compiler when linking
+ a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_PROG_F77
+# ------------
+# Since AC_PROG_F77 is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_F77],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
+AC_PROG_F77
+if test -z "$F77" || test "X$F77" = "Xno"; then
+ _lt_disable_F77=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_F77
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_F77], [])
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_REQUIRE([_LT_PROG_F77])dnl
+AC_LANG_PUSH(Fortran 77)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_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_TAGVAR(objext, $1)=$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.
+ _LT_TAG_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_GCC=$GCC
+ CC=${F77-"f77"}
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+ GCC=$G77
+ if test -n "$compiler"; then
+ 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_TAGVAR(GCC, $1)="$G77"
+ _LT_TAGVAR(LD, $1)="$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_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_PROG_FC
+# -----------
+# Since AC_PROG_FC is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_FC],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
+AC_PROG_FC
+if test -z "$FC" || test "X$FC" = "Xno"; then
+ _lt_disable_FC=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_FC
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_FC], [])
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_REQUIRE([_LT_PROG_FC])dnl
+AC_LANG_PUSH(Fortran)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$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.
+ _LT_TAG_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_GCC=$GCC
+ CC=${FC-"f95"}
+ compiler=$CC
+ GCC=$ac_cv_fc_compiler_gnu
+
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ 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_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+ _LT_TAGVAR(LD, $1)="$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_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_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_TAG_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_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+## 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...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC="$lt_save_CC"
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_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_TAG_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_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+ :
+ _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+ [AC_CHECK_TOOL(GCJ, gcj,)
+ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible. Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# 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. #
+############################################################
+
+m4_defun([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])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_XSI_SHELLFNS
+# ---------------------
+# Bourne and XSI compatible variants of some useful shell functions.
+m4_defun([_LT_PROG_XSI_SHELLFNS],
+[case $xsi_shell in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+ func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=${1%%=*}
+ func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=$(( $[*] ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=${#1}
+}
+
+_LT_EOF
+ ;;
+ *) # Bourne compatible functions.
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+dnl func_dirname_and_basename
+dnl A portable version of this function is already defined in general.m4sh
+dnl so there is no need for it here.
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+ esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[[^=]]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=`expr "$[@]"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$[1]+=\$[2]"
+}
+_LT_EOF
+ ;;
+ *)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$[1]=\$$[1]\$[2]"
+}
+
+_LT_EOF
+ ;;
+ esac
+])
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
new file mode 100644
index 0000000..e970119
--- /dev/null
+++ b/m4/ltoptions.m4
@@ -0,0 +1,368 @@
+# Helper functions for option handling. -*- Autoconf -*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# 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 6 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it. Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+ _LT_MANGLE_DEFUN([$1], [$2]),
+ [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+ [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME. If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+ dnl
+ dnl Simply set some default values (i.e off) if boolean options were not
+ dnl specified:
+ _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+ ])
+ _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+ ])
+ dnl
+ dnl If no reference was made to various pairs of opposing options, then
+ dnl we run the default mode handler for the pair. For example, if neither
+ dnl `shared' nor `disable-shared' was passed, we enable building of shared
+ dnl archives by default:
+ _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+ _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+ [_LT_ENABLE_FAST_INSTALL])
+ ])
+])# _LT_SET_OPTIONS
+
+
+## --------------------------------- ##
+## Macros to handle LT_INIT options. ##
+## --------------------------------- ##
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+ AC_CHECK_TOOL(AS, as, false)
+ AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+ AC_CHECK_TOOL(OBJDUMP, objdump, false)
+ ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS], [0], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+ [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+ [build shared libraries @<:@default=]_LT_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=]_LT_ENABLE_SHARED_DEFAULT)
+
+ _LT_DECL([build_libtool_libs], [enable_shared], [0],
+ [Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+ [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+ [build static libraries @<:@default=]_LT_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=]_LT_ENABLE_STATIC_DEFAULT)
+
+ _LT_DECL([build_old_libs], [enable_static], [0],
+ [Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+ [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+ [optimize for fast installation @<:@default=]_LT_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=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+ [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+ [AS_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=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+## ----------------- ##
+## LTDL_INIT Options ##
+## ----------------- ##
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+ [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+ [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+ [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+ [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+ [m4_define([_LTDL_TYPE], [convenience])])
diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4
new file mode 100644
index 0000000..0d258e0
--- /dev/null
+++ b/m4/ltsugar.m4
@@ -0,0 +1,123 @@
+# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# 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 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+ [$#], [2], [[$2]],
+ [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+ [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+ [$#], 1, [],
+ [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+ m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+m4_define([lt_combine],
+[m4_if([$2], [], [],
+ [m4_if([$4], [], [],
+ [lt_join(m4_quote(m4_default([$1], [[, ]])),
+ lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2],
+ [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]),
+ [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl
+])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+ [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+ [lt_append([$1], [$2], [$3])$4],
+ [$5])],
+ [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+ m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+ m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+ [$5],
+ [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+ [lt_join(m4_quote(m4_default([$4], [[, ]])),
+ lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+ [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
new file mode 100644
index 0000000..45cb155
--- /dev/null
+++ b/m4/ltversion.m4
@@ -0,0 +1,23 @@
+# ltversion.m4 -- version numbers -*- Autoconf -*-
+#
+# Copyright (C) 2004 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004
+#
+# 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.
+
+# Generated from ltversion.in.
+
+# serial 2976 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.2.4])
+m4_define([LT_PACKAGE_REVISION], [1.2976])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.2.4'
+macro_revision='1.2976'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4
new file mode 100644
index 0000000..637bb20
--- /dev/null
+++ b/m4/lt~obsolete.m4
@@ -0,0 +1,92 @@
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004.
+#
+# 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 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else. This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
diff --git a/missing b/missing
new file mode 100755
index 0000000..1c8ff70
--- /dev/null
+++ b/missing
@@ -0,0 +1,367 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2006-05-10.23
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+# 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
+# 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.
+
+# 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.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ # Exit code 63 means version mismatch. This often happens
+ # when the user try to use an ancient version of a tool on
+ # a file that requires a minimum version. In this case we
+ # we should proceed has if the program had been absent, or
+ # if --run hadn't been passed.
+ if test $? = 63; then
+ run=:
+ msg="probably too old"
+ fi
+ ;;
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ autom4te touch the output file, or create a stub one
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake at gnu.org>."
+ exit $?
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing $scriptversion (GNU Automake)"
+ exit $?
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+esac
+
+# 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).
+case $1 in
+ lex|yacc)
+ # Not GNU programs, they don't have --version.
+ ;;
+
+ tar)
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ exit 1
+ fi
+ ;;
+
+ *)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ # Could not run --version or --help. This is probably someone
+ # running `$TOOL --version' or `$TOOL --help' to check whether
+ # $TOOL exists and not knowing $TOOL uses missing.
+ exit 1
+ fi
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $1 in
+ aclocal*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case $f in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ 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
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f y.tab.h; then
+ echo >y.tab.h
+ fi
+ if test ! -f y.tab.c; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ 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
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f lex.yy.c; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ 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
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit 1
+ fi
+ ;;
+
+ 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
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ # The file to touch is that specified with -o ...
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -z "$file"; then
+ # ... or it is the one specified with @setfilename ...
+ infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '
+ /^@setfilename/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
+ # ... or it is derived from the source name (dir/f.texi becomes f.info)
+ test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+ fi
+ # If the file does not exist, the user really needs makeinfo;
+ # let's fail without touching anything.
+ test -f $file || exit 1
+ touch $file
+ ;;
+
+ tar)
+ shift
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case $firstarg in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case $firstarg in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequisites for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/nfconfig.in b/nfconfig.in
new file mode 100644
index 0000000..6adf488
--- /dev/null
+++ b/nfconfig.in
@@ -0,0 +1,83 @@
+#if 0
+ $Id: nfconfig.in,v 1.1 2006/11/10 21:47:18 ed Exp $
+#endif
+
+
+#ifndef UD_NETCDF_CPP_INC
+#define UD_NETCDF_CPP_INC
+
+
+#if 0
+ Do not have C-style comments in here because this file is processed
+ by both the FORTRAN compiler (for the nf_test/ stuff) and the C
+ compiler (for the FORTRAN-callable interface routines) and some
+ FORTRAN preprocessors do not understand the /*...*/ syntax.
+#endif
+
+
+#if 0
+ The following macros define the supplementary FORTRAN arithmetic
+ datatypes beyond the standard INTEGER, REAL, and DOUBLEPRECISION --
+ ostensibly corresponding to 8-bit and 16-bit integers, respectively.
+ For example:
+
+ #define NF_INT1_T byte
+ #define NF_INT2_T integer*2
+
+ These are the types of the relevant arguments in the NF_*_INT1() and
+ NF_*_INT2() netCDF FORTRAN function calls. The word "ostensibly"
+ is used advisedly: on some systems an "integer*2" datatype,
+ nevertheless, occupies 64 bits (we are not making this up).
+
+ If your FORTRAN system does not have the respective supplementary
+ datatype, then do not define the corresponding macro.
+#endif
+#undef NF_INT1_T
+#undef NF_INT2_T
+
+
+#if 0
+ Define the following NF_*_IS_C_* macros appropriatly for your system.
+ The "INT1", "INT2" and "INT" after the "NF_" refer to the NF_INT1_T
+ FORTRAN datatype, the NF_INT2_T FORTRAN datatype, and the INTEGER
+ FORTRAN datatype, respectively. If the respective FORTRAN datatype
+ does not exist, then do not define the corresponding macro.
+#endif
+#undef NF_INT1_IS_C_SIGNED_CHAR
+#undef NF_INT1_IS_C_SHORT
+#undef NF_INT1_IS_C_INT
+#undef NF_INT1_IS_C_LONG
+#undef NF_INT2_IS_C_SHORT
+#undef NF_INT2_IS_C_INT
+#undef NF_INT2_IS_C_LONG
+#undef NF_INT_IS_C_INT
+#undef NF_INT_IS_C_LONG
+#undef NF_REAL_IS_C_FLOAT
+#undef NF_REAL_IS_C_DOUBLE
+#undef NF_DOUBLEPRECISION_IS_C_DOUBLE
+#undef NF_DOUBLEPRECISION_IS_C_FLOAT
+
+
+#if 0
+ Whether the system uses something besides the IEEE floating-point
+ format to represent floating-point values.
+#endif
+#undef NO_IEEE_FLOAT
+
+
+#if 0
+ END OF CUSTOMIZATION
+#endif
+
+
+#if 0
+ FORTRAN data types corresponding to netCDF version 2 "byte" and "short"
+ data types (e.g. INTEGER*1, INTEGER*2). See file "ftest.F" for usage.
+#endif
+#if !defined(NO_NETCDF_2)
+# undef NCBYTE_T
+# undef NCSHORT_T
+#endif
+
+
+#endif
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..74dc395
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,99 @@
+## This is an automake file, part of Unidata's NetCDF CF Library package.
+# Copyright 2006, see the COPYRIGHT file for more information.
+
+# 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 $
+
+# Tell automake that libcf.h is a header file we want to install.
+include_HEADERS = libcf.h
+
+# Test programs will need to link to this library (libcf) and also
+# netcdf.
+LDADD = ${lib_LTLIBRARIES}
+
+# Initalize these.
+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
+
+# This is our output, the NetCDF CF Library.
+lib_LTLIBRARIES = libcf.la
+
+# 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
+endif
+
+# These linker flags specify libtool version info.
+libcf_la_LDFLAGS = -version-info 0:0:0
+
+# This is the coordinate systems stuff.
+libcf_la_SOURCES = nccoord.c libcf.h libcf_int.h cffiles.c cfvars.c \
+cfcvars.c cfsubsets.c cferror.c cferror.h cdTimeConv.c cdmsint.h \
+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
+
+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
+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 $@
+
+# tst_f03_file.o:tst_f03_file.f03
+# $(FC) -c $(AM_FCFLAGS) $(FCFLAGS) -c $? -o $@
+
+TESTS = $(check_PROGRAMS)
+
+
+
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..0131dc2
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,793 @@
+# 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@
+
+# Copyright 2006, see the COPYRIGHT file for more information.
+
+# 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 $
+
+
+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@
+
+# 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
+subdir = src
+DIST_COMMON = $(include_HEADERS) $(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__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__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
+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)
+libcf_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(libcf_la_LDFLAGS) \
+ $(LDFLAGS) -o $@
+libcff_la_LIBADD =
+am__libcff_la_SOURCES_DIST = cffcvars.f90
+ at BUILD_F90_TRUE@am_libcff_la_OBJECTS = cffcvars.lo
+libcff_la_OBJECTS = $(am_libcff_la_OBJECTS)
+ at BUILD_F90_TRUE@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)
+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)
+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)
+am__tst_example_data_SOURCES_DIST = tst_example_data.c nc_tests.h
+ at EXTRA_DATA_TESTS_TRUE@am_tst_example_data_OBJECTS = \
+ at 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)
+am__tst_f03_file_SOURCES_DIST = tst_f03_file.f90
+ at BUILD_F90_TRUE@am_tst_f03_file_OBJECTS = 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)
+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)
+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)
+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)
+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)
+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 $@
+FCCOMPILE = $(FC) $(AM_FCFLAGS) $(FCFLAGS)
+LTFCCOMPILE = $(LIBTOOL) $(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 \
+ $@
+SOURCES = $(libcf_la_SOURCES) $(libcff_la_SOURCES) \
+ $(tst_coords_SOURCES) $(tst_cvars_SOURCES) \
+ $(tst_example_data_SOURCES) $(tst_f03_file_SOURCES) \
+ $(tst_files_SOURCES) $(tst_subsets_SOURCES) \
+ $(tst_vars_SOURCES) $(tst_vert_SOURCES)
+DIST_SOURCES = $(libcf_la_SOURCES) $(am__libcff_la_SOURCES_DIST) \
+ $(tst_coords_SOURCES) $(tst_cvars_SOURCES) \
+ $(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
+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@
+
+# Tell automake that libcf.h is a header file we want to install.
+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)
+
+# 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
+
+# This is our output, the NetCDF CF Library.
+lib_LTLIBRARIES = libcf.la $(am__append_6)
+
+# 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
+
+# These linker flags specify libtool version info.
+libcf_la_LDFLAGS = -version-info 0:0:0
+
+# This is the coordinate systems stuff.
+libcf_la_SOURCES = nccoord.c libcf.h libcf_int.h cffiles.c cfvars.c \
+cfcvars.c cfsubsets.c cferror.c cferror.h cdTimeConv.c cdmsint.h \
+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)
+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
+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
+ at EXTRA_DATA_TESTS_TRUE@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
+
+.SUFFIXES:
+.SUFFIXES: .c .f90 .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 src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/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-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; 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"; \
+ else :; fi; \
+ done
+
+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"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libcf.la: $(libcf_la_OBJECTS) $(libcf_la_DEPENDENCIES)
+ $(libcf_la_LINK) -rpath $(libdir) $(libcf_la_OBJECTS) $(libcf_la_LIBADD) $(LIBS)
+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
+tst_coords$(EXEEXT): $(tst_coords_OBJECTS) $(tst_coords_DEPENDENCIES)
+ @rm -f tst_coords$(EXEEXT)
+ $(LINK) $(tst_coords_OBJECTS) $(tst_coords_LDADD) $(LIBS)
+tst_cvars$(EXEEXT): $(tst_cvars_OBJECTS) $(tst_cvars_DEPENDENCIES)
+ @rm -f tst_cvars$(EXEEXT)
+ $(LINK) $(tst_cvars_OBJECTS) $(tst_cvars_LDADD) $(LIBS)
+tst_example_data$(EXEEXT): $(tst_example_data_OBJECTS) $(tst_example_data_DEPENDENCIES)
+ @rm -f tst_example_data$(EXEEXT)
+ $(LINK) $(tst_example_data_OBJECTS) $(tst_example_data_LDADD) $(LIBS)
+tst_f03_file$(EXEEXT): $(tst_f03_file_OBJECTS) $(tst_f03_file_DEPENDENCIES)
+ @rm -f tst_f03_file$(EXEEXT)
+ $(FCLINK) $(tst_f03_file_OBJECTS) $(tst_f03_file_LDADD) $(LIBS)
+tst_files$(EXEEXT): $(tst_files_OBJECTS) $(tst_files_DEPENDENCIES)
+ @rm -f tst_files$(EXEEXT)
+ $(LINK) $(tst_files_OBJECTS) $(tst_files_LDADD) $(LIBS)
+tst_subsets$(EXEEXT): $(tst_subsets_OBJECTS) $(tst_subsets_DEPENDENCIES)
+ @rm -f tst_subsets$(EXEEXT)
+ $(LINK) $(tst_subsets_OBJECTS) $(tst_subsets_LDADD) $(LIBS)
+tst_vars$(EXEEXT): $(tst_vars_OBJECTS) $(tst_vars_DEPENDENCIES)
+ @rm -f tst_vars$(EXEEXT)
+ $(LINK) $(tst_vars_OBJECTS) $(tst_vars_LDADD) $(LIBS)
+tst_vert$(EXEEXT): $(tst_vert_OBJECTS) $(tst_vert_DEPENDENCIES)
+ @rm -f tst_vert$(EXEEXT)
+ $(LINK) $(tst_vert_OBJECTS) $(tst_vert_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdTimeConv.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cfcvars.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cferror.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cffiles.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cfsubsets.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cfvars.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/nccoord.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_coords.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_cvars.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_example_data.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_files.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_subsets.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_vars.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tst_vert.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 $@ $<
+
+.f90.o:
+ $(FCCOMPILE) -c -o $@ $<
+
+.f90.obj:
+ $(FCCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.f90.lo:
+ $(LTFCCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+ @list='$(include_HEADERS)'; 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"; \
+ 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
+
+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
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ 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 \
+ *$$ws$$tst$$ws*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ echo "XPASS: $$tst"; \
+ ;; \
+ *) \
+ echo "PASS: $$tst"; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *$$ws$$tst$$ws*) \
+ xfail=`expr $$xfail + 1`; \
+ echo "XFAIL: $$tst"; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ echo "SKIP: $$tst"; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ 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 \
+ 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)"; \
+ 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`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+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
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; 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:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+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-checkPROGRAMS clean-generic clean-libLTLIBRARIES \
+ 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-includeHEADERS
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-libLTLIBRARIES
+
+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-includeHEADERS uninstall-libLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \
+ 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-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-includeHEADERS install-info install-info-am \
+ install-libLTLIBRARIES 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-includeHEADERS \
+ uninstall-libLTLIBRARIES
+
+# 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
new file mode 100644
index 0000000..27120d5
--- /dev/null
+++ b/src/cdTimeConv.c
@@ -0,0 +1,1082 @@
+/* -*-Mode: C;-*-
+ * Module: CDMS time conversion and arithmetic routines
+ *
+ * Copyright: 1995, Regents of the University of California
+ * This software may not be distributed to others without
+ * permission of the author.
+ *
+ * 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 $
+ *
+ * Revision History:
+ *
+ * $Log: cdTimeConv.c,v $
+ * Revision 1.1 2008/06/30 16:07:44 ed
+ * Beginning merge of calandar stuff.
+ *
+ * Revision 1.1.1.1 1997/12/09 18:57:40 drach
+ * Copied from cirrus
+ *
+ * Revision 1.3 1996/09/09 18:28:33 drach
+ * - Cleaned up minor compilation warnings
+ *
+ * Revision 1.2 1996/04/04 18:29:04 drach
+ * - Added FORTRAN interface to time routines
+ * - Added function cdParseDeltaTime
+ *
+ * Revision 1.1 1996/02/21 23:56:47 drach
+ * - Overlayed cdtime routines in cdTimeConv.c:
+ * - Added seconds, julian calendar, changed include to cdmsint.h for old
+ * time routines in timeArith.c and timeConv.c
+ *
+ *
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+#include <string.h>
+#include "cdmsint.h"
+
+void cdComp2RelMixed(cdCompTime ct, cdUnitTime unit, cdCompTime basetime, double *reltime);
+void cdRel2CompMixed(double reltime, cdUnitTime unit, cdCompTime basetime, cdCompTime *comptime);
+
+#define CD_DEFAULT_BASEYEAR "1979" /* Default base year for relative time (no 'since' clause) */
+#define VALCMP(a,b) ((a)<(b)?-1:(b)<(a)?1:0)
+
+/* Validate the component time, return 0 if valid, 1 if not */
+int
+cdValidateTime(cdCalenType timetype, cdCompTime comptime)
+{
+ if(comptime.month<1 || comptime.month>12){
+ cdError("Error on time conversion: invalid month = %hd\n",comptime.month);
+ return 1;
+ }
+ if(comptime.day<1 || comptime.day>31){
+ cdError("Error on time conversion: invalid day = %hd\n",comptime.day);
+ return 1;
+ }
+ if(comptime.hour<0.0 || comptime.hour>24.0){
+ cdError("Error on time conversion: invalid hour = %lf\n",comptime.hour);
+ return 1;
+ }
+ return 0;
+}
+
+/* Trim trailing whitespace, up to n characters. */
+/* If no whitespace up to the last character, set */
+/* the last character to null, else set the first */
+/* whitespace character to null. */
+void
+cdTrim(char* s, int n)
+{
+ char* c;
+
+ if(s==NULL)
+ return;
+ for(c=s; *c && c<s+n-1 && !isspace(*c); c++);
+ *c='\0';
+ return;
+}
+ /* Map to old timetypes */
+int
+cdToOldTimetype(cdCalenType newtype, CdTimeType* oldtype)
+{
+ switch(newtype){
+ case cdStandard:
+ *oldtype = CdChron;
+ break;
+ case cdJulian:
+ *oldtype = CdJulianCal;
+ break;
+ case cdNoLeap:
+ *oldtype = CdChronNoLeap;
+ break;
+ case cd360:
+ *oldtype = CdChron360;
+ break;
+ case cdClim:
+ *oldtype = CdClim;
+ break;
+ case cdClimLeap:
+ *oldtype = CdClimLeap;
+ break;
+ case cdClim360:
+ *oldtype = CdClim360;
+ break;
+ default:
+ cdError("Error on relative units conversion, invalid timetype = %d",newtype);
+ return 1;
+ }
+ return 0;
+}
+
+/* Parse relative units, returning the unit and base component time. */
+/* Function returns 1 if error, 0 on success */
+int
+cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTime* base_comptime)
+{
+ char charunits[CD_MAX_RELUNITS];
+ char basetime_1[CD_MAX_CHARTIME];
+ char basetime_2[CD_MAX_CHARTIME];
+ char basetime[CD_MAX_CHARTIME];
+ int nconv;
+ /* Parse the relunits */
+ nconv = sscanf(relunits,"%s since %s %s",charunits,basetime_1,basetime_2);
+ if(nconv==EOF || nconv==0){
+ cdError("Error on relative units conversion, string = %s\n",relunits);
+ return 1;
+ }
+
+ /* Get the units */
+ cdTrim(charunits,CD_MAX_RELUNITS);
+ if(!strncmp(charunits,"sec",3) || !strcmp(charunits,"s")){
+ *unit = cdSecond;
+ }
+ else if(!strncmp(charunits,"min",3) || !strcmp(charunits,"mn")){
+ *unit = cdMinute;
+ }
+ else if(!strncmp(charunits,"hour",4) || !strcmp(charunits,"hr")){
+ *unit = cdHour;
+ }
+ else if(!strncmp(charunits,"day",3) || !strcmp(charunits,"dy")){
+ *unit = cdDay;
+ }
+ else if(!strncmp(charunits,"week",4) || !strcmp(charunits,"wk")){
+ *unit = cdWeek;
+ }
+ else if(!strncmp(charunits,"month",5) || !strcmp(charunits,"mo")){
+ *unit = cdMonth;
+ }
+ else if(!strncmp(charunits,"season",6)){
+ *unit = cdSeason;
+ }
+ else if(!strncmp(charunits,"year",4) || !strcmp(charunits,"yr")){
+ if(!(timetype & cdStandardCal)){
+ cdError("Error on relative units conversion: climatological units cannot be 'years'.\n");
+ return 1;
+ }
+ *unit = cdYear;
+ }
+ else {
+ cdError("Error on relative units conversion: invalid units = %s\n",charunits);
+ return 1;
+ }
+
+ /* Build the basetime, if any (default is 1979), */
+ /* or month 1 for climatological time. */
+ if(nconv == 1){
+ if(timetype & cdStandardCal)
+ strcpy(basetime,CD_DEFAULT_BASEYEAR);
+ else
+ strcpy(basetime,"1");
+ }
+ /* Convert the basetime to component, then epochal (hours since 1970) */
+ else{
+ if(nconv == 2){
+ cdTrim(basetime_1,CD_MAX_CHARTIME);
+ strcpy(basetime,basetime_1);
+ }
+ else{
+ cdTrim(basetime_1,CD_MAX_CHARTIME);
+ cdTrim(basetime_2,CD_MAX_CHARTIME);
+ sprintf(basetime,"%s %s",basetime_1,basetime_2);
+ }
+ }
+
+ cdChar2Comp(timetype, basetime, base_comptime);
+
+ return 0;
+}
+
+/* Parse delta time. Return 0 if success, 1 on error. */
+int
+cdParseDeltaTime(cdCalenType timetype, char* deltaTime, double* value, cdUnitTime* unit){
+ char charunits[CD_MAX_TIME_DELTA];
+ int nconv;
+
+ nconv = sscanf(deltaTime,"%lf %s",value,charunits);
+ if(nconv==EOF || nconv==0){
+ cdError("Error on delta time conversion, string = %s",deltaTime);
+ return 1;
+ }
+ cdTrim(charunits,CD_MAX_TIME_DELTA);
+ if(!strncmp(charunits,"sec",3) || !strcmp(charunits,"s")){
+ *unit = cdSecond;
+ }
+ else if(!strncmp(charunits,"min",3) || !strcmp(charunits,"mn")){
+ *unit = cdMinute;
+ }
+ else if(!strncmp(charunits,"hour",4) || !strcmp(charunits,"hr")){
+ *unit = cdHour;
+ }
+ else if(!strncmp(charunits,"day",3) || !strcmp(charunits,"dy")){
+ *unit = cdDay;
+ }
+ else if(!strncmp(charunits,"week",4) || !strcmp(charunits,"wk")){
+ *unit = cdWeek;
+ }
+ else if(!strncmp(charunits,"month",5) || !strcmp(charunits,"mo")){
+ *unit = cdMonth;
+ }
+ else if(!strncmp(charunits,"season",6)){
+ *unit = cdSeason;
+ }
+ else if(!strncmp(charunits,"year",4) || !strcmp(charunits,"yr")){
+ if(!(timetype & cdStandardCal)){
+ cdError("Error on delta time conversion: climatological units cannot be 'years'.");
+ return 1;
+ }
+ *unit = cdYear;
+ }
+ else {
+ cdError("Error on delta time conversion: invalid units = %s",charunits);
+ return 1;
+ }
+ return 0;
+}
+
+void
+cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime)
+{
+ double sec;
+ int ihr, imin, nconv;
+ long year;
+ short day;
+ short month;
+
+ comptime->year = CD_NULL_YEAR;
+ comptime->month = CD_NULL_MONTH;
+ comptime->day = CD_NULL_DAY;
+ comptime->hour = CD_NULL_HOUR;
+
+ if(timetype & cdStandardCal){
+ nconv = sscanf(chartime,"%ld-%hd-%hd %d:%d:%lf",&year,&month,&day,&ihr,&imin,&sec);
+ if(nconv==EOF || nconv==0){
+ cdError("Error on character time conversion, string = %s\n",chartime);
+ return;
+ }
+ if(nconv >= 1){
+ comptime->year = year;
+ }
+ if(nconv >= 2){
+ comptime->month = month;
+ }
+ if(nconv >= 3){
+ comptime->day = day;
+ }
+ if(nconv >= 4){
+ if(ihr<0 || ihr>23){
+ cdError("Error on character time conversion: invalid hour = %d\n",ihr);
+ return;
+ }
+ comptime->hour = (double)ihr;
+ }
+ if(nconv >= 5){
+ if(imin<0 || imin>59){
+ cdError("Error on character time conversion: invalid minute = %d\n",imin);
+ return;
+ }
+ comptime->hour += (double)imin/60.;
+ }
+ if(nconv >= 6){
+ if(sec<0.0 || sec>60.0){
+ cdError("Error on character time conversion: invalid second = %lf\n",sec);
+ return;
+ }
+ comptime->hour += sec/3600.;
+ }
+ }
+ else{ /* Climatological */
+ nconv = sscanf(chartime,"%hd-%hd %d:%d:%lf",&month,&day,&ihr,&imin,&sec);
+ if(nconv==EOF || nconv==0){
+ cdError("Error on character time conversion, string = %s",chartime);
+ return;
+ }
+ if(nconv >= 1){
+ comptime->month = month;
+ }
+ if(nconv >= 2){
+ comptime->day = day;
+ }
+ if(nconv >= 3){
+ if(ihr<0 || ihr>23){
+ cdError("Error on character time conversion: invalid hour = %d\n",ihr);
+ return;
+ }
+ comptime->hour = (double)ihr;
+ }
+ if(nconv >= 4){
+ if(imin<0 || imin>59){
+ cdError("Error on character time conversion: invalid minute = %d\n",imin);
+ return;
+ }
+ comptime->hour += (double)imin/60.;
+ }
+ if(nconv >= 5){
+ if(sec<0.0 || sec>60.0){
+ cdError("Error on character time conversion: invalid second = %lf\n",sec);
+ return;
+ }
+ comptime->hour += sec/3600.;
+ }
+ }
+ (void)cdValidateTime(timetype,*comptime);
+ return;
+}
+void
+cdChar2Rel(cdCalenType timetype, char* chartime, char* relunits, double* reltime)
+{
+ cdCompTime comptime;
+
+ cdChar2Comp(timetype, chartime, &comptime);
+ cdComp2Rel(timetype, comptime, relunits, reltime);
+ return;
+}
+void
+cdComp2Char(cdCalenType timetype, cdCompTime comptime, char* time)
+{
+ double dtmp, sec;
+ int ihr, imin;
+ int nskip;
+
+ if(cdValidateTime(timetype,comptime))
+ return;
+
+ ihr = (int)comptime.hour;
+ dtmp = 60.0 * (comptime.hour - (double)ihr);
+ imin = (int)dtmp;
+ sec = 60.0 * (dtmp - (double)imin);
+
+ nskip = 0;
+ if(sec == 0.0){
+ if(imin == 0)
+ nskip = 2;
+ else
+ nskip = 1;
+ }
+
+ if(timetype & cdStandardCal){
+ if(nskip == 0)
+ sprintf(time,"%ld-%hd-%hd %d:%d:%lf",comptime.year,comptime.month,comptime.day,ihr,imin,sec);
+ else if(nskip == 1)
+ sprintf(time,"%ld-%hd-%hd %d:%d",comptime.year,comptime.month,comptime.day,ihr,imin);
+ else
+ sprintf(time,"%ld-%hd-%hd %d:0",comptime.year,comptime.month,comptime.day,ihr);
+ }
+ else { /* Climatological */
+ if(nskip == 0)
+ sprintf(time,"%hd-%hd %d:%d:%lf",comptime.month,comptime.day,ihr,imin,sec);
+ else if(nskip == 1)
+ sprintf(time,"%hd-%hd %d:%d",comptime.month,comptime.day,ihr,imin);
+ else
+ sprintf(time,"%hd-%hd %d:0",comptime.month,comptime.day,ihr);
+ }
+ return;
+}
+void
+cdComp2Rel(cdCalenType timetype, cdCompTime comptime, char* relunits, double* reltime)
+{
+ cdCompTime base_comptime;
+ CdDeltaTime deltime;
+ CdTime humantime;
+ CdTimeType old_timetype;
+ cdUnitTime unit;
+ double base_etm, etm, delta;
+ long ndel, hoursInYear;
+
+ /* Parse the relunits */
+ if(cdParseRelunits(timetype, relunits, &unit, &base_comptime))
+ return;
+
+ /* Handle mixed Julian/Gregorian calendar */
+ if (timetype == cdMixed){
+ switch(unit){
+ case cdWeek: case cdDay: case cdHour: case cdMinute: case cdSecond:
+ cdComp2RelMixed(comptime, unit, base_comptime, reltime);
+ return;
+ case cdYear: case cdSeason: case cdMonth:
+ timetype = cdStandard;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Convert basetime to epochal */
+ humantime.year = base_comptime.year;
+ humantime.month = base_comptime.month;
+ humantime.day = base_comptime.day;
+ humantime.hour = base_comptime.hour;
+ humantime.baseYear = 1970;
+ /* Map to old-style timetype */
+ if(cdToOldTimetype(timetype,&old_timetype))
+ return;
+ humantime.timeType = old_timetype;
+ Cdh2e(&humantime,&base_etm);
+
+ /* Map end time to epochal */
+ humantime.year = comptime.year;
+ humantime.month = comptime.month;
+ humantime.day = comptime.day;
+ humantime.hour = comptime.hour;
+ Cdh2e(&humantime,&etm);
+ /* Calculate relative time value for months or hours */
+ deltime.count = 1;
+ deltime.units = (CdTimeUnit)unit;
+ switch(unit){
+ case cdWeek: case cdDay: case cdHour: case cdMinute: case cdSecond:
+ delta = etm - base_etm;
+ if(!(timetype & cdStandardCal)){ /* Climatological time */
+ hoursInYear = (timetype & cd365Days) ? 8760. : (timetype & cdHasLeap) ? 8784. : 8640.;
+ /* Normalize delta to interval [0,hoursInYear) */
+ if(delta < 0.0 || delta >= hoursInYear)
+ delta -= hoursInYear * floor(delta/hoursInYear);
+ }
+ break;
+ case cdYear: case cdSeason: case cdMonth:
+ CdDivDelTime(base_etm, etm, deltime, old_timetype, 1970, &ndel);
+ break;
+ }
+
+ /* Convert to output units */
+ switch(unit){
+ case cdSecond:
+ *reltime = 3600.0 * delta;
+ break;
+ case cdMinute:
+ *reltime = 60.0 * delta;
+ break;
+ case cdHour:
+ *reltime = delta;
+ break;
+ case cdDay:
+ *reltime = delta/24.0;
+ break;
+ case cdWeek:
+ *reltime = delta/168.0;
+ break;
+ case cdMonth: case cdSeason: case cdYear: /* Already in correct units */
+ if(timetype & cdStandardCal)
+ *reltime = (base_etm <= etm) ? (double)ndel : (double)(-ndel);
+ else /* Climatological time is already normalized*/
+ *reltime = (double)ndel;
+ break;
+ }
+
+ return;
+}
+void
+cdRel2Char(cdCalenType timetype, char* relunits, double reltime, char* chartime)
+{
+ cdCompTime comptime;
+
+ cdRel2Comp(timetype, relunits, reltime, &comptime);
+ cdComp2Char(timetype, comptime, chartime);
+
+ return;
+}
+void
+cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* comptime)
+{
+ CdDeltaTime deltime;
+ CdTime humantime;
+ CdTimeType old_timetype;
+ cdCompTime base_comptime;
+ cdUnitTime unit, baseunits;
+ double base_etm, result_etm;
+ double delta;
+ long idelta;
+
+ /* Parse the relunits */
+ if(cdParseRelunits(timetype, relunits, &unit, &base_comptime))
+ return;
+
+ if (timetype == cdMixed){
+ switch(unit){
+ case cdWeek: case cdDay: case cdHour: case cdMinute: case cdSecond:
+ cdRel2CompMixed(reltime, unit, base_comptime, comptime);
+ return;
+ case cdYear: case cdSeason: case cdMonth:
+ timetype = cdStandard;
+ break;
+ }
+ }
+
+ switch(unit){
+ case cdSecond:
+ delta = reltime/3600.0;
+ baseunits = cdHour;
+ break;
+ case cdMinute:
+ delta = reltime/60.0;
+ baseunits = cdHour;
+ break;
+ case cdHour:
+ delta = reltime;
+ baseunits = cdHour;
+ break;
+ case cdDay:
+ delta = 24.0 * reltime;
+ baseunits = cdHour;
+ break;
+ case cdWeek:
+ delta = 168.0 * reltime;
+ baseunits = cdHour;
+ break;
+ case cdMonth:
+ idelta = (long)(reltime + (reltime<0 ? -1.e-10 : 1.e-10));
+ baseunits = cdMonth;
+ break;
+ case cdSeason:
+ idelta = (long)(3.0 * reltime + (reltime<0 ? -1.e-10 : 1.e-10));
+ baseunits = cdMonth;
+ break;
+ case cdYear:
+ idelta = (long)(12 * reltime + (reltime<0 ? -1.e-10 : 1.e-10));
+ baseunits = cdMonth;
+ break;
+ }
+
+ deltime.count = 1;
+ deltime.units = (CdTimeUnit)baseunits;
+
+ humantime.year = base_comptime.year;
+ humantime.month = base_comptime.month;
+ humantime.day = base_comptime.day;
+ humantime.hour = base_comptime.hour;
+ humantime.baseYear = 1970;
+ /* Map to old-style timetype */
+ if(cdToOldTimetype(timetype,&old_timetype))
+ return;
+ humantime.timeType = old_timetype;
+
+ Cdh2e(&humantime,&base_etm);
+ /* If months, seasons, or years, */
+ if(baseunits == cdMonth){
+
+ /* Calculate new epochal time from integer months. */
+ /* Convert back to human, then comptime. */
+ /* For zero reltime, just return the basetime*/
+ if(reltime != 0.0){
+ CdAddDelTime(base_etm,idelta,deltime,old_timetype,1970,&result_etm);
+ Cde2h(result_etm, old_timetype, 1970, &humantime);
+ }
+ }
+ /* Calculate new epochal time. */
+ /* Convert back to human, then comptime. */
+ else{
+ Cde2h(base_etm+delta, old_timetype, 1970, &humantime);
+
+ }
+ comptime->year = humantime.year;
+ comptime->month = humantime.month;
+ comptime->day = humantime.day;
+ comptime->hour = humantime.hour;
+
+ return;
+}
+void
+cdRel2Rel(cdCalenType timetype, char* relunits, double reltime, char* outunits, double* outtime)
+{
+ cdCompTime comptime;
+
+ cdRel2Comp(timetype, relunits, reltime, &comptime);
+ cdComp2Rel(timetype, comptime, outunits, outtime);
+ return;
+}
+
+/* ----------------------------------------------------------------------------------------------*/
+/* Absolute time routines */
+
+ /* Parse absolute time units, returning */
+ /* the unit and format components. */
+ /* For example, "day as %Y%m%d.f" returns */
+ /* a unit of cdDay, and components [cdYear,cdMonth, */
+ /* cdDay,cdFraction]. ncompon is the number of components. */
+ /* Returns 1 on success, 0 on error. */
+int
+cdParseAbsunits(char *absunits, cdUnitTime *unit, int *ncompon, cdUnitTime compon[]){
+ int nconv;
+ char charunits[CD_MAX_ABSUNITS];
+ char format[CD_MAX_ABSUNITS];
+ char *c;
+ int iform;
+
+ nconv = sscanf(absunits,"%s as %s",charunits,format);
+ if(nconv==EOF || nconv<2){
+ cdError("Error on absolute units conversion, string = %s\n",absunits);
+ return 1;
+ }
+ cdTrim(charunits,CD_MAX_ABSUNITS);
+ if(!strncmp(charunits,"hour",4)){
+ *unit = cdHour;
+ }
+ else if(!strncmp(charunits,"day",3)){
+ *unit = cdDay;
+ }
+ else if(!strncmp(charunits,"calendar_month",14)){
+ *unit = cdMonth;
+ }
+ else if(!strncmp(charunits,"calendar_year",13)){
+ *unit = cdYear;
+ }
+ else if(!strncmp(charunits,"min",3)){
+ *unit = cdMinute;
+ }
+ else if(!strncmp(charunits,"sec",3)){
+ *unit = cdSecond;
+ }
+ else {
+ cdError("Error on absolute units conversion: invalid units = %s\n",charunits);
+ return 1;
+ }
+
+ /* Parse the format */
+ for(c=format, iform=0; *c && iform<CD_MAX_ABS_COMPON; c++){
+ if(*c=='.')
+ continue;
+ else if(*c=='%'){
+ c++;
+ switch(*c){
+ case 'Y':
+ compon[iform++]=cdYear;
+ break;
+ case 'm':
+ compon[iform++]=cdMonth;
+ break;
+ case 'd':
+ compon[iform++]=cdDay;
+ break;
+ case 'H':
+ compon[iform++]=cdHour;
+ break;
+ case 'M':
+ compon[iform++]=cdMinute;
+ break;
+ case 'S':
+ compon[iform++]=cdSecond;
+ break;
+ case 'f':
+ compon[iform++]=cdFraction;
+ break;
+ default:
+ cdError("Error on absolute units conversion: invalid format = %s\n",format);
+ return 1;
+
+ }
+ }
+ else {
+ cdError("Error on absolute units conversion: invalid format = %s\n",format);
+ return 1;
+ }
+ }
+ *ncompon=iform;
+ return 0;
+}
+
+ /* Convert absolute time to component time. */
+ /* frac is the fractional part, or 0.0 if */
+ /* abstimetype is cdInt. */
+ /* */
+ /* Note: for formats which incorporate the */
+ /* diurnal phase, the fractional part is */
+ /* incorporated into comptime->hour. */
+ /* Return 0 on success, 1 on failure. */
+int
+cdAbs2Comp(char *absunits, void *abstime, cdType abstimetype, cdCompTime *comptime, double *frac){
+ cdUnitTime unit;
+ int ncompon;
+ cdUnitTime compon[CD_MAX_ABS_COMPON];
+ double dabstime, fraction;
+ long iabstime;
+ int iform;
+
+ /* Parse the absunits */
+ if (cdParseAbsunits(absunits, &unit, &ncompon, compon)==1)
+ return 1;
+
+ /* Break the time into integer and fractional parts */
+ switch(abstimetype){
+ case cdFloat:
+ dabstime = (double)(*(float *)abstime);
+ iabstime = (long)dabstime;
+ fraction = dabstime-(double)iabstime;
+ break;
+ case cdDouble:
+ dabstime = *(double *)abstime;
+ iabstime = (long)dabstime;
+ fraction = dabstime-(double)iabstime;
+ break;
+ case cdInt:
+ iabstime = (long)(*(int *)abstime);
+ dabstime = (double)iabstime;
+ fraction = 0.0;
+ break;
+ case cdLong:
+ iabstime = *(long *)abstime;
+ dabstime = (double)iabstime;
+ fraction = 0.0;
+ break;
+ default:
+ cdError("Error converting absolute to component time: invalid datatype = %d\n",abstimetype);
+ return 1;
+ }
+
+ /* Extract the components */
+ comptime->year = 0;
+ comptime->month = comptime->day = 1;
+ comptime->hour = 0.0;
+ for(iform=ncompon-1; iform>=0; iform--){
+ switch(compon[iform]){
+ case cdYear:
+ comptime->year = iabstime%10000;
+ iabstime /= 10000;
+ break;
+ case cdMonth:
+ comptime->month = iabstime%100;
+ iabstime /= 100;
+ break;
+ case cdDay:
+ comptime->day = iabstime%100;
+ iabstime /= 100;
+ break;
+ case cdHour:
+ comptime->hour = dabstime;
+ break;
+ case cdMinute:
+ comptime->hour = dabstime/60.0;
+ break;
+ case cdSecond:
+ comptime->hour = dabstime/3600.0;
+ break;
+ case cdFraction:
+ if (unit==cdDay)
+ comptime->hour = 24.0*fraction;
+ break;
+ }
+ }
+ *frac = fraction;
+ return 0;
+}
+
+ /* Convert component to absolute time. */
+ /* absunits is of the form "<unit> as <format>". */
+ /* abstimetype is either cdFloat, cdDouble, or cdInt. */
+ /* frac, the fractional part, is only used */
+ /* if unit is cdMonth or cdYear, and */
+ /* abstimetype is cdFloat or cdDouble. */
+ /* Otherwise, it is derived from comptime.hour. */
+ /* abstime is the absolute time returned. */
+ /* The function returns 0 on success, 1 on failure. */
+
+int
+cdComp2Abs(cdCompTime comptime, char *absunits, cdType abstimetype, double frac, void *abstime){
+ cdUnitTime unit;
+ int ncompon;
+ cdUnitTime compon[CD_MAX_ABS_COMPON];
+ double dabstime;
+ long iabstime;
+ int iform;
+
+ /* Parse the absunits */
+ if (cdParseAbsunits(absunits, &unit, &ncompon, compon)==1)
+ return 1;
+
+ /* Set the absolute time */
+ iabstime = 0;
+ dabstime = 0.0;
+ for(iform=0; iform<ncompon; iform++){
+ switch(compon[iform]){
+ case cdYear:
+ iabstime = iabstime*10000+comptime.year;
+ dabstime = (double)iabstime;
+ break;
+ case cdMonth:
+ iabstime = iabstime*100+comptime.month;
+ dabstime = (double)iabstime;
+ break;
+ case cdDay:
+ iabstime = iabstime*100+comptime.day;
+ dabstime = (double)iabstime;
+ break;
+ case cdHour:
+ dabstime = comptime.hour;
+ iabstime = (long)dabstime;
+ break;
+ case cdMinute:
+ dabstime = 60.0*comptime.hour;
+ iabstime = (long)dabstime;
+ break;
+ case cdSecond:
+ dabstime = 3600.0*comptime.hour;
+ iabstime = (long)dabstime;
+ break;
+ case cdFraction:
+ if (unit==cdDay)
+ dabstime += comptime.hour/24.0;
+ else if(unit==cdYear)
+ dabstime += frac;
+ else if(unit==cdMonth)
+ dabstime += frac;
+ break;
+ }
+ }
+
+ /* Cast to the specified datatype */
+ switch(abstimetype){
+ case cdFloat:
+ *(float *)abstime = (float)dabstime;
+ break;
+ case cdDouble:
+ *(double *)abstime = dabstime;
+ break;
+ case cdInt:
+ *(int *)abstime = (int)iabstime;
+ break;
+ case cdLong:
+ *(long *)abstime = iabstime;
+ break;
+ default:
+ cdError("Error converting component to absolute time: invalid datatype = %d\n",abstimetype);
+ return 1;
+ }
+ return 0;
+}
+
+ /* Return 1 if the time and units are a valid relative */
+ /* time, 0 if not. If comptime is non-null, return the */
+ /* components */
+int
+cdDecodeRelativeTime(cdCalenType timetype, char* units, double time, cdCompTime* comptime){
+ int saveOpts, saveOccurred, err;
+ cdCompTime ctime, *pctime;
+
+ pctime = (comptime ? comptime : &ctime);
+
+ saveOpts = cuErrOpts;
+ saveOccurred = cuErrorOccurred;
+ cuErrOpts = 0; /* Turn off error reporting */
+
+ /* If it's absolute, it's not relative */
+ if (cdDecodeAbsoluteTime(units, &time, cdDouble, 0, 0)){
+ cuErrOpts = saveOpts;
+ return 0;
+ }
+ cuErrorOccurred = 0;
+ cdRel2Comp(timetype, units, time, pctime);
+
+ err = (cuErrorOccurred==0);
+ cuErrOpts = saveOpts;
+ cuErrorOccurred = saveOccurred;
+ return err;
+}
+
+ /* Return 1 if the time and units are a valid absolute */
+ /* time, 0 if not.*/
+int
+cdDecodeAbsoluteTime(char* units, void* time, cdType abstimetype, cdCompTime* comptime, double* fraction){
+ int saveOpts, err;
+ cdCompTime ctime, *pctime;
+ double frac, *pfrac;
+
+ pctime = (comptime ? comptime : &ctime);
+ pfrac = (fraction ? fraction : &frac);
+
+ saveOpts = cuErrOpts;
+ cuErrOpts = 0; /* Turn off error reporting */
+ err = cdAbs2Comp(units, time, abstimetype, pctime, pfrac);
+
+ cuErrOpts = saveOpts;
+ return (err==0);
+}
+/* ----------------------------------------------------------------------------------------------*/
+/* Mixed Julian/Gregorian calendar routines */
+
+ /* Return value expressed in hours. */
+double
+cdToHours(double value, cdUnitTime unit){
+
+ double result;
+
+ switch(unit){
+ case cdSecond:
+ result = value/3600.0;
+ break;
+ case cdMinute:
+ result = value/60.0;
+ break;
+ case cdHour:
+ result = value;
+ break;
+ case cdDay:
+ result = 24.0 * value;
+ break;
+ case cdWeek:
+ result = 168.0 * value;
+ break;
+ }
+ return result;
+}
+ /* Value is in hours. Translate to units. */
+double cdFromHours(double value, cdUnitTime unit){
+ double result;
+
+ switch(unit){
+ case cdSecond:
+ result = value * 3600.0;
+ break;
+ case cdMinute:
+ result = value * 60.0;
+ break;
+ case cdHour:
+ result = value;
+ break;
+ case cdDay:
+ result = value/24.0;
+ break;
+ case cdWeek:
+ result = value/168.0;
+ break;
+ }
+ return result;
+}
+
+ /* Add (value,unit) to comptime. */
+ /* value is in hours. */
+ /* calendar is anything but cdMixed. */
+void
+cdCompAdd(cdCompTime comptime, double value, cdCalenType calendar, cdCompTime *result){
+
+ double reltime;
+
+ cdComp2Rel(calendar, comptime, "hours", &reltime);
+ reltime += value;
+ cdRel2Comp(calendar, "hours", reltime, result);
+ return;
+}
+
+ /* ca - cb in Julian calendar */
+ /* Result is in hours. */
+double
+cdDiffJulian(cdCompTime ca, cdCompTime cb){
+
+ double rela, relb;
+
+ cdComp2Rel(cdJulian, ca, "hours", &rela);
+ cdComp2Rel(cdJulian, cb, "hours", &relb);
+ return (rela - relb);
+}
+
+ /* ca - cb in Gregorian calendar */
+ /* Result is in hours. */
+double
+cdDiffGregorian(cdCompTime ca, cdCompTime cb){
+
+ double rela, relb;
+
+ cdComp2Rel(cdStandard, ca, "hours", &rela);
+ cdComp2Rel(cdStandard, cb, "hours", &relb);
+ return (rela - relb);
+}
+
+ /* Return -1, 0, 1 as ca is less than, equal to, */
+ /* or greater than cb, respectively. */
+int cdCompCompare(cdCompTime ca, cdCompTime cb){
+
+ int test;
+
+ if ((test = VALCMP(ca.year, cb.year)))
+ return test;
+ else if ((test = VALCMP(ca.month, cb.month)))
+ return test;
+ else if ((test = VALCMP(ca.day, cb.day)))
+ return test;
+ else
+ return (test = VALCMP(ca.hour, cb.hour));
+}
+
+ /* ca - cb in mixed Julian/Gregorian calendar. */
+ /* Result is in hours. */
+double
+cdDiffMixed(cdCompTime ca, cdCompTime cb){
+
+ static cdCompTime ZA = {1582, 10, 5, 0.0};
+ static cdCompTime ZB = {1582, 10, 15, 0.0};
+ double result;
+
+ if (cdCompCompare(cb, ZB) == -1){
+ if (cdCompCompare(ca, ZB) == -1) {
+ result = cdDiffJulian(ca, cb);
+ }
+ else {
+ result = cdDiffGregorian(ca, ZB) + cdDiffJulian(ZA, cb);
+ }
+ }
+ else {
+ if (cdCompCompare(ca, ZB) == -1){
+ result = cdDiffJulian(ca, ZA) + cdDiffGregorian(ZB, cb);
+ }
+ else {
+ result = cdDiffGregorian(ca, cb);
+ }
+ }
+ return result;
+}
+
+ /* Add value in hours to ct, */
+ /* in the mixed Julian/Gregorian calendar. */
+void
+cdCompAddMixed(cdCompTime ct, double value, cdCompTime *result){
+
+ static cdCompTime ZA = {1582, 10, 5, 0.0};
+ static cdCompTime ZB = {1582, 10, 15, 0.0};
+ double xj, xg;
+
+ if (cdCompCompare(ct, ZB) == -1){
+ xj = cdDiffJulian(ZA, ct);
+ if (value <= xj){
+ cdCompAdd(ct, value, cdJulian, result);
+ }
+ else {
+ cdCompAdd(ZB, value-xj, cdStandard, result);
+ }
+ }
+ else {
+ xg = cdDiffGregorian(ZB, ct);
+ if (value > xg){
+ cdCompAdd(ct, value, cdStandard, result);
+ }
+ else {
+ cdCompAdd(ZA, value-xg, cdJulian, result);
+ }
+ }
+ return;
+}
+
+ /* Convert ct to relunits (unit, basetime) */
+ /* in the mixed Julian/Gregorian calendar. */
+ /* unit is anything but year, season, month. unit and basetime are */
+ /* from the parsed relunits. Return result in reltime. */
+void
+cdComp2RelMixed(cdCompTime ct, cdUnitTime unit, cdCompTime basetime, double *reltime){
+
+ double hourdiff;
+
+ hourdiff = cdDiffMixed(ct, basetime);
+ *reltime = cdFromHours(hourdiff, unit);
+ return;
+}
+
+ /* Convert relative time (reltime, unit, basetime) to comptime in the */
+ /* mixed Julian/Gregorian calendar. unit is anything but */
+ /* year, season, month. unit and basetime are */
+ /* from the parsed relunits. Return result in comptime. */
+void
+cdRel2CompMixed(double reltime, cdUnitTime unit, cdCompTime basetime, cdCompTime *comptime){
+
+ reltime = cdToHours(reltime, unit);
+ cdCompAddMixed(basetime, reltime, comptime);
+ return;
+}
diff --git a/src/cddrs.h b/src/cddrs.h
new file mode 100644
index 0000000..9556bdc
--- /dev/null
+++ b/src/cddrs.h
@@ -0,0 +1,154 @@
+/* -*-Mode: C;-*-
+ * Module: cddrs.h - include file for C DRS wrapper routines
+ *
+ * Copyright: 1994, Regents of the University of California
+ * This software may not be distributed to others without
+ * permission of the author.
+ *
+ * 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 $
+ *
+ * Revision History:
+ *
+ * $Log: cddrs.h,v $
+ * Revision 1.1 2008/06/30 16:07:44 ed
+ * Beginning merge of calandar stuff.
+ *
+ * Revision 1.13 1997/09/26 21:45:26 drach
+ * - Added HDF
+ * - Repaired fouled up cddrs includes
+ *
+ * Revision 1.10 1995/07/12 22:07:49 drach
+ * - Add cw_get_fileid function
+ *
+ * Revision 1.9 1995/06/09 22:44:15 drach
+ * Added extensions for string length and dimension types
+ *
+ * Revision 1.8 1995/02/15 20:54:58 drach
+ * - Added IDRS_VECTOR as synonym for IDRS_UNEQUALLY_SPACED
+ *
+ * Revision 1.7 1995/01/21 00:52:24 drach
+ * - Added compatibility defines
+ *
+ * Revision 1.6 1995/01/18 02:53:05 drach
+ * - Added majority flags
+ *
+ * Revision 1.5 1995/01/13 01:02:30 drach
+ * Added getnd prototype
+ *
+ * Revision 1.4 1994/12/17 00:42:37 drach
+ * - removed CW_MAX_LU (use CU_MAX_LU in cdunif instead)
+ *
+ * Revision 1.3 1994/12/16 00:44:43 drach
+ * - Included drscdf.h
+ *
+ * Revision 1.2 1994/12/14 02:32:43 drach
+ * - Modified extern function declarations
+ * - Added CwRoundPolicy typedef
+ * - Added null defs
+ *
+ * Revision 1.1 1994/11/23 22:56:22 drach
+ * Initial version.
+ *
+ *
+ */
+
+#ifndef __cddrs_h
+#define __cddrs_h
+
+#include "drscdf.h"
+
+#define CW_STRING_NULL " " /* Null character string */
+#define CW_FLOAT_NULL 1.0e20 /* Null float arg */
+#define CW_FLOAT_DELTA 1.0e14 /* Treat floats as null if = CW_FLOAT_NULL +/- CW_FLOAT_DELTA */
+#define CW_INT_NULL 0 /* Null int arg */
+#define CW_MAX_NAME 128 /* Max characters in a name (= CU_MAX_NAME) */
+#define IDRS_VECTOR IDRS_UNEQUALLY_SPACED /* Synonym for unequally-spaced dimension flag */
+
+ /* For compatibility with older versions of drscdf.h */
+#ifndef __EXTENDED_DRS_DATATYPES
+#define __EXTENDED_DRS_DATATYPES
+#define IDRS_I1 7
+#define IDRS_I2 8
+#define IDRS_IEEE_R8 9
+#define IDRS_CRAY_R16 10
+#define IDRS_IEEE_R16 11
+#endif
+
+typedef enum {CW_ROUND_NEAREST = 1, CW_ROUND_UP, CW_ROUND_DOWN, CW_RANGE} CwRoundPolicy;
+typedef enum {CW_C_MAJORITY = 1, CW_FORTRAN_MAJORITY} CwMajority;
+typedef enum {CW_STANDARD = 1, CW_EXTENDED} CwExtensionOption;
+typedef enum {CW_LOCAL = 1, CW_SHARED, CW_IMPLICIT_SHARED} CwDimensionType;
+
+#undef PROTO
+#if defined(__STDC__) || (OS_NAME == AIX)
+#define PROTO(x) x
+#else
+#define PROTO(x) ()
+#endif
+
+extern int cw_aslun PROTO((int lud,char* dicfil,int lu,char* datfil,int istat));
+extern int cw_cllun PROTO((int lu));
+extern int cw_cluvdb PROTO((void));
+extern int cw_drstest PROTO((int ierr));
+extern int cw_getdat PROTO((int lu,void* a,int isize));
+extern int cw_getcdim PROTO((int idim,char* source,char* name,char* title,char* units,int* dtype,int reqlen,float* var,int* retlen));
+extern int cw_getcdimD PROTO((int idim,char* source,char* name,char* title,char* units,int* dtype,int reqlen,double* var,int* retlen));
+extern int cw_getedim PROTO((int n,char* dsrc,char* dna,char* dti,char* dun,int* dtype,int* idim,float* df,float* dl));
+extern int cw_getedimD PROTO((int n,char* dsrc,char* dna,char* dti,char* dun,int* dtype,int* idim,double* df,double* dl));
+extern int cw_getelemd PROTO((int* type,int* bpe));
+extern int cw_get_fileid PROTO((int lu));
+extern int cw_getname PROTO((char* source,char* name,char* title,char* units,char* date,char* time,char* typed,int* nd));
+extern int cw_getnd PROTO((int* nd));
+extern int cw_getrge2 PROTO((int lu,int idim,double elem1,double elem2,int* ind1,int* ind2,float* dlow,float* dhigh));
+extern int cw_getrge2D PROTO((int lu,int idim,double elem1,double elem2,int* ind1,int* ind2,double* dlow,double* dhigh));
+extern int cw_getslab PROTO((int lu,int rank,int* order,float* fe,float* le,float* cycle,void* data,int* datadim));
+extern int cw_inqdict PROTO((int lu,int oper));
+extern int cw_inqlun PROTO((int lu,char* datafile,int* nvar,float* version));
+extern int cw_majority PROTO((CwMajority majority));
+extern int cw_set_dimension_option PROTO((CwExtensionOption option));
+extern int cw_set_string_option PROTO((CwExtensionOption option));
+extern int cw_setdim PROTO((int n,char* dna,char* dun,int idim,double df,double dl));
+extern int cw_seterr PROTO((int ierrlun,int reportlevel));
+extern int cw_setname PROTO((char* source,char* name,char* title,char* units,char* typed));
+extern int cw_setvdim PROTO((int n,char* dso,char* dna,char* dti,char* dun,double df,double dl));
+
+ /* Compatibility functions */
+extern int cw_putdat PROTO((int lu,void* a));
+extern int cw_putdic PROTO((int lu, int iopt));
+extern int cw_putvdim PROTO((int lu,int len,float* dimvar,int* i1,int* i2));
+extern int cw_setdate PROTO((char* date,char* time));
+extern int cw_setrep PROTO((int irep));
+
+#ifdef CDCOMPAT
+#define Aslun cw_aslun
+#define Cllun cw_cllun
+#define Cluvdb cw_cluvdb
+#define Drstest cw_drstest
+#define Getdat cw_getdat
+#define Getcdim cw_getcdim
+#define GetcdimD cw_getcdimD
+#define Getedim cw_getedim
+#define GetedimD cw_getedimD
+#define Getelemd cw_getelemd
+#define Getname cw_getname
+#define Getnd cw_getnd
+#define Getrge2 cw_getrge2
+#define Getslab cw_getslab
+#define Inqdict cw_inqdict
+#define Inqlun cw_inqlun
+#define Majority cw_majority
+#define Setdim cw_setdim
+#define Seterr cw_seterr
+#define Setname cw_setname
+#define Setvdim cw_setvdim
+#define Putdat cw_putdat
+#define Putdic cw_putdic
+#define Putvdim cw_putvdim
+#define Setdate cw_setdate
+#define Setrep cw_setrep
+#endif
+
+#endif
diff --git a/src/cdms.h b/src/cdms.h
new file mode 100644
index 0000000..c3c7c95
--- /dev/null
+++ b/src/cdms.h
@@ -0,0 +1,317 @@
+/*
+ * Module: cdms.h - CDMS user-level definitions
+ *
+ * Copyright: 1994, Regents of the University of California
+ * This software may not be distributed to others without
+ * permission of the author.
+ *
+ * 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 $
+ *
+ * Revision History:
+ *
+ * $Log: cdms.h,v $
+ * Revision 1.1 2008/06/30 16:07:44 ed
+ * Beginning merge of calandar stuff.
+ *
+ * Revision 1.1.1.1 1997/12/09 18:57:39 drach
+ * Copied from cirrus
+ *
+ * Revision 1.11 1997/11/24 17:28:03 drach
+ * - Added QL package to cdunif
+ * - Added NdimIntersect function to CDMS
+ *
+ * Revision 1.10 1997/11/10 19:22:28 drach
+ * - Added cuvargets to cdunif, cdSlabRead to cdms
+ *
+ * Revision 1.9 1997/10/24 18:23:34 drach
+ * - Cache netCDF unlimited dimensions
+ * - Consistent with GrADS src170
+ *
+ * Revision 1.8 1996/04/04 21:48:02 drach
+ * - Minor fix for SGI version
+ *
+ * Revision 1.7 1996/04/04 18:27:02 drach
+ * - Added CDMS inquiry, lookup, open, and internal routines
+ *
+ * Revision 1.6 1996/02/23 01:21:21 drach
+ * - Moved most of cdms.h to cdmsint.h (original in cdms_v1.h)
+ * - Added new time model declarations to cdms.h
+ * - Added -DNO_DECLARE flag to fcddrs.h
+ *
+ * Revision 1.5 1994/11/17 20:02:29 drach
+ * Moved #endif
+ *
+ * Revision 1.4 1994/10/25 00:58:51 drach
+ * - Added dset and var tags for get functions
+ * - Added CdDeleteDset and CdDeleteVar prototypes
+ *
+ * Revision 1.3 1994/08/12 21:45:33 drach
+ * - modified access fields to longs
+ * - added dimension directions to order struct
+ * - changed geom floats to doubles
+ * - added level, sset struct
+ * - changed varHandle args to var
+ * - added templates for new routines
+ *
+ * Revision 1.2 1994/07/19 23:57:53 drach
+ * - Added CdMinute
+ * - changed unsigned struct components to signed
+ *
+ * Revision 1.1 1994/07/13 18:29:29 drach
+ * Initial version
+ *
+ *
+ */
+
+
+/*
+ * =================================================================
+ * Macros and Enums
+ * =================================================================
+ */
+#ifndef _CDMS_H
+#define _CDMS_H
+
+#include "cddrs.h"
+#include "cdunif.h"
+
+#define CD_ATT_MAX 10240 /* Max bytes in attribute */
+#define CD_DEFAULT_DB 0
+#define CD_DIM_OFFSET 0x80000 /* Dimension ID offset */
+#define CD_GLOBAL 0 /* Null variable ID */
+#define CD_GLOB_DIM_OFFSET 0x200000 /* Global dimension offset */
+#define CD_GLOB_GRID_OFFSET 0x400000 /* Global grid offset */
+#define CD_GRID_OFFSET 0x100000 /* Grid ID offset */
+#define CD_LAST_DAY -1 /* Last day of month */
+#define CD_MAX_ABSUNITS 64 /* Max characters in absolute units */
+#define CD_MAX_ABS_COMPON 7 /* Max components in absolute time format */
+#define CD_MAX_CHARTIME 48 /* Max characters in character time */
+#define CD_MAX_NAME CU_MAX_NAME /* Max characters in a name */
+#define CD_MAX_PATH CU_MAX_PATH /* Max characters in a file pathname */
+#define CD_MAX_RELUNITS 64 /* Max characters in relative units */
+#define CD_MAX_TIME_DELTA 64 /* Max characters in time delta */
+#define CD_MAX_VAR_COMPS 32 /* Max number of variable components */
+#define CD_MAX_VAR_DIMS CU_MAX_VAR_DIMS /* Max dimensions in a variable */
+#define CD_NULL_DAY 1 /* Null day value */
+#define CD_NULL_HOUR 0.0 /* Null hour value */
+#define CD_NULL_ID 0 /* Reserved ID */
+#define CD_NULL_MONTH 1 /* Null month value */
+#define CD_NULL_YEAR 0 /* Null year value, component time */
+#define CD_ROOT_ENV "CDMSROOT" /* CDMS root environment variable */
+#define CD_SUCCESS 0
+
+typedef enum cdType {cdInvalidType = -1,
+ cdByte = CuByte,
+ cdChar = CuChar,
+ cdShort = CuShort,
+ cdInt = CuInt,
+ cdLong = CuLong,
+ cdFloat = CuFloat,
+ cdDouble = CuDouble,
+ cdLongDouble = CuLongDouble,
+ cdCharTime
+} cdType;
+
+typedef enum cdIntersectPolicy {cdRoundNearest = CW_ROUND_NEAREST,
+ cdRange = CW_RANGE
+} cdIntersectPolicy;
+
+typedef enum cdRepresent {cdExternalArray = 1, cdInternalArray, cdLinearRep} cdRepresent;
+typedef enum cdOpenMode {cdReadOnly = 1, cdReadWrite} cdOpenMode;
+typedef enum cdGridType {cdRectangular = 1, cdZonal, cdMeridional, cdProjected, cdQuasiRegular} cdGridType;
+typedef enum cdDimType {cdLongitude = 1, cdLatitude, cdLevel, cdCalendar, cdClimatology,
+ cdMonotonic} cdDimType;
+typedef enum cdDimShape {cdLinearShape = 1, cdWrapped} cdDimShape;
+typedef enum cdPolygonType {cdBox = 1, cdAnnulus, cdLoc, cdPoly, cdGlobal} cdPolygonType;
+typedef enum cdMonths {cdJan = 1, cdFeb, cdMar, cdApr, cdMay, cdJun, cdJul, cdAug,
+ cdSep, cdOct, cdNov, cdDec } cdMonths;
+typedef enum cdSeasons {cdDJF = cdDec, /* DJF */
+ cdMAM = cdMar, /* MAM */
+ cdJJA = cdJun, /* JJA */
+ cdSON = cdSep} cdSeasons; /* SON */
+
+typedef enum cdIntersectOpt {cdSubset = 1, cdPoint, cdIntersect} cdIntersectOpt;
+
+enum cdLevelType {cdUnknown=0, cdTwoMeter, cdAtmosphere, cdHybrid, cdPressure, cdSeaLevel, cdSigma, cdSkin,
+ cdSoil, cdSurface, cdTopAtmos};
+
+ /* Dean's DRS-like functions */
+
+typedef enum {CE_C_MAJORITY = 1, CE_FORTRAN_MAJORITY} CeMajority;
+#define CU_C_MAJORITY CE_C_MAJORITY
+#define CU_FORTRAN_MAJORITY CE_FORTRAN_MAJORITY
+
+ /* Note: if time stuff changes, so should fcdms.h!! */
+#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;
+
+/*
+ * =================================================================
+ * Structures
+ * =================================================================
+ */
+
+/* Component time */
+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;
+
+/*
+ * =================================================================
+ * Function Prototypes
+ * =================================================================
+ */
+extern int cdDimInq(long dsetid, long dimid, char* name, char* alias, cdType* datatype, int* natts, cdDimType* type, int* subtype, long* length, cdDimShape* topology);
+extern int cdDsetClose(long dsetid);
+extern int cdDsetInq(long dsetid, int* ndims, int* nvars, int* ngrids, int* ngatts);
+extern int cdGridInq(long dsetid, long gridid, char* name, cdGridType* type, int* ndims, long dim[], int* natts);
+extern int cdVarGetCoord(long dsetid, long varid, long dimid, double indices[]);
+extern int cdVarGetIndex(long dsetid, long varid, long dimid, long indices[]);
+extern int cdVarGetIndexRange(long dsetid, long varid, long dimid, long* index1, long* index2);
+extern int cdVarInq(long dsetid, long varid, char* name, char* alias, cdType* datatype, int* ndims, long dim[], int* natts);
+extern int cdVarSetCoordRange(long dsetid, long varid, long dimid, double coord1, double coord2, cdIntersectOpt opt, long* len);
+extern int cdVarSetIndex(long dsetid, long varid, long dimid, long nindices, long index[], long* len);
+extern int cdVarSetIndexRange(long dsetid, long varid, long dimid, long index1, long index2, long* len);
+extern long cdDimLookup(long dsetid, char* name);
+extern long cdDimLookupAlias(long dsetid, char* alias);
+extern long cdDsetOpen(const char* path, cdOpenMode mode, long dbid);
+extern long cdGridLookup(long dsetid, char* name);
+extern long cdVarLookup(long dsetid, char* name);
+extern long cdVarLookupAlias(long dsetid, char* alias);
+
+extern void cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime);
+extern void cdChar2Rel(cdCalenType timetype, char* chartime, char* relunits, double* reltime);
+extern void cdComp2Char(cdCalenType timetype, cdCompTime comptime, char* time);
+extern void cdComp2Rel(cdCalenType timetype, cdCompTime comptime, char* relunits, double* reltime);
+extern void cdRel2Char(cdCalenType timetype, char* relunits, double reltime, char* chartime);
+extern void cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* comptime);
+extern void cdRel2Rel(cdCalenType timetype, char* relunits, double reltime, char* outunits, double* outtime);
+extern int cdAbs2Comp(char *absunits, void *abstime, cdType abstimetype, cdCompTime *comptime, double *frac);
+extern int cdComp2Abs(cdCompTime comptime, char *absunits, cdType abstimetype, double frac, void *abstime);
+extern int cdDecodeRelativeTime(cdCalenType timetype, char* units, double time, cdCompTime* comptime);
+extern int cdDecodeAbsoluteTime(char* units, void* time, cdType abstimetype, cdCompTime* comptime, double* fraction);
+
+extern long cdSlabRead(long dsetid, long varid, const long order[], const double first[], const double last[], const double modulus[], cdIntersectPolicy policy, cdType usertype, void *values);
+extern long cdNdimIntersect(long dsetid, long varid, const long order[], const double first[], const double last[], const double modulus[], cdIntersectPolicy policy, long start[], long count[], long stride[]);
+
+extern int cdTypeLen(cdType datatype);
+
+ /* Dean's DRS-like extensions */
+extern int cedimgeta(int fileid, int dimid, void* values, void **charvalues[]);
+extern int cevargeta(int fileid, int varid, const long start[], const long count[], void* value);
+extern int cemajority(CeMajority majority);
+extern int cehyperslabinq(int fileid, int varid, int rank,long* order,double* fe,double* le,double* cycle, long *data_arraysize, int *dim_arraylengths);
+extern int cehyperslab(int fileid, int varid, int rank,long* order,double* fe,double* le,double* cycle,double *dimarray, void *data);
+extern int cehyperslaba(int fileid, int varid, int rank,long* order,double* fe,double* le,double* cycle,long dimsize, double *dimarray, void *data);
+extern int cehyperslabi(int fileid, int varid, int rank,long* order,long* fe,long* le,double* cycle,void **data, int *dimsize, double *dimarray[]);
+
+
+#define cudimgeta cedimgeta
+#define cuvargeta cevargeta
+#define cumajority cemajority
+#define cuhyperslabinq cehyperslabinq
+#define cuhyperslab cehyperslab
+#define cuhyperslaba cehyperslaba
+#define cuhyperslabi cehyperslabi
+
+/*
+ * =================================================================
+ * Globals
+ * =================================================================
+ */
+
+extern CeMajority ceMajority; /* Default majority for Dean's extensions */
+
+
+/*
+ * =================================================================
+ * This stuff is used in the original time stuff,
+ * should eventually be moved to cdmsint.h
+ * =================================================================
+ */
+
+typedef enum CdMonths {CdJan = 1, CdFeb, CdMar, CdApr, CdMay, CdJun, CdJul, CdAug,
+ CdSep, CdOct, CdNov, CdDec } CdMonths;
+
+typedef enum CdSeasons {CdWinter = CdDec, /* DJF */
+ CdSpring = CdMar, /* MAM */
+ CdSummer = CdJun, /* JJA */
+ CdFall = CdSep} CdSeasons; /* SON */
+
+typedef enum CdTimeUnit {
+ CdMinute = 1,
+ CdHour = 2,
+ CdDay = 3,
+ CdWeek = 4, /* Always = 7 days */
+ CdMonth = 5,
+ CdSeason = 6, /* Always = 3 months */
+ CdYear = 7,
+ CdSecond = 8
+} CdTimeUnit;
+
+#define CdChronCal 0x1
+#define CdClimCal 0x0
+#define CdBaseRel 0x00
+#define CdBase1970 0x10
+#define CdHasLeap 0x100
+#define CdNoLeap 0x000
+#define Cd365 0x1000
+#define Cd360 0x0000
+#define CdJulianType 0x10000
+
+typedef enum CdTimeType {
+ CdChron = ( CdChronCal | CdBase1970 | CdHasLeap | Cd365), /* 4369 */
+ CdJulianCal = ( CdChronCal | CdBase1970 | CdHasLeap | Cd365 | CdJulianType),
+ CdChronNoLeap = ( CdChronCal | CdBase1970 | CdNoLeap | Cd365), /* 4113 */
+ CdChron360 = ( CdChronCal | CdBase1970 | CdNoLeap | Cd360), /* 17 */
+ CdRel = ( CdChronCal | CdBaseRel | CdHasLeap | Cd365), /* 4353 */
+ CdRelNoLeap = ( CdChronCal | CdBaseRel | CdNoLeap | Cd365), /* 4097 */
+ CdClim = ( CdClimCal | CdBaseRel | CdNoLeap | Cd365), /* 4096 */
+ CdClimLeap = ( CdClimCal | CdBaseRel | CdHasLeap | Cd365),
+ CdClim360 = ( CdClimCal | CdBaseRel | CdNoLeap | Cd365)
+} CdTimeType;
+
+#define CdNullYear 0
+#define CdNullMonth CdJan
+#define CdNullDay 1
+#define CdLastDay -1
+#define CdNullHour 0.0
+
+typedef struct {
+ long year; /* e.g., 1979 */
+ short month; /* e.g., CdDec */
+ short day; /* e.g., 30 */
+ double hour; /* hour and fractional hour */
+ long baseYear; /* base year for relative, 1970 for CdChron */
+ CdTimeType timeType; /* e.g., CdChron */
+} CdTime;
+
+typedef struct {
+ long count; /* units count */
+ CdTimeUnit units; /* time interval units */
+} CdDeltaTime;
+
+#endif
diff --git a/src/cdmsint.h b/src/cdmsint.h
new file mode 100644
index 0000000..20e2750
--- /dev/null
+++ b/src/cdmsint.h
@@ -0,0 +1,591 @@
+/* -*-Mode: C;-*-
+ * Module: cdmsint.h - CDMS internal database definitions
+ *
+ * Copyright: 1995, Regents of the University of California
+ * This software may not be distributed to others without
+ * permission of the author.
+ *
+ * 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 $
+ *
+ * Revision History:
+ *
+ * $Log: cdmsint.h,v $
+ * Revision 1.1 2008/06/30 16:07:44 ed
+ * Beginning merge of calandar stuff.
+ *
+ * Revision 1.1.1.1 1997/12/09 18:57:39 drach
+ * Copied from cirrus
+ *
+ * Revision 1.3 1997/10/24 18:23:35 drach
+ * - Cache netCDF unlimited dimensions
+ * - Consistent with GrADS src170
+ *
+ * Revision 1.2 1996/04/04 18:27:04 drach
+ * - Added CDMS inquiry, lookup, open, and internal routines
+ *
+ * Revision 1.1 1996/02/23 01:21:23 drach
+ * - Moved most of cdms.h to cdmsint.h (original in cdms_v1.h)
+ * - Added new time model declarations to cdms.h
+ * - Added -DNO_DECLARE flag to fcddrs.h
+ *
+ *
+ */
+
+#ifndef _CDMSINT_H
+#define _CDMSINT_H
+
+#include <stdio.h>
+#include <stddef.h>
+#include "cdms.h"
+
+/*
+ * =================================================================
+ * Macros and Typedefs
+ * =================================================================
+ */
+
+#define CD_NAME_DUP -2
+#define CD_ALIAS_DUP -3
+#define cdSymtabNentries(table) (table)->nentries /* number of entries in symbol table */
+#define cdDsetVar(dset,varid) (cdVar*)((dset)->vars->entries)+((varid)-1) /* dset variable with id varid */
+#define cdDsetDim(dset,dimid) (cdDim*)((dset)->dims->entries)+((dimid)-CD_DIM_OFFSET-1) /* dset dimension with id dimid */
+#define cdDsetGrid(dset,gridid) (cdGrid*)((dset)->grids->entries)+((gridid)-CD_GRID_OFFSET-1) /* dset dimension with id dimid */
+
+#define cdSetByte(vp,val) {unsigned char *ucp; ucp=(unsigned char*)(vp); *ucp=(val);}
+#define cdSetShort(vp,val) {short *sp; sp=(short*)(vp); *sp=(val);}
+#define cdSetInt(vp,val) {int *ip; ip=(int*)(vp); *ip=(val);}
+#define cdSetLong(vp,val) {long *lp; lp=(long*)(vp); *lp=(val);}
+#define cdSetFloat(vp,val) {float *fp; fp = (float *)(vp); *fp=(val);}
+#define cdSetDouble(vp,val) {double *dp; dp=(double*)(vp); *dp=(val);}
+#if !defined(sgi) && !defined(__alpha)
+#define cdSetLongDouble(vp,val) {long double *ldp; ldp=(long double*)(vp); *ldp=(val);}
+#endif
+#define cdSetCharTime(vp,val) {char *cp; cp=(char*)(vp); strncpy(cp,(val),CD_MAX_CHARTIME); cp[CD_MAX_CHARTIME-1]='\0';}
+
+ /* For Dean's DRS-like extensions */
+
+#define CE_FLOAT_NULL 1.0e20 /* Null float arg */
+#define CE_FLOAT_DELTA 1.0e14 /* Treat floats as null if = CE_FLOAT_NULL +/- CE_FLOAT_DELTA */
+#define CE_INT_NULL 0
+#define CE_IS_FLOAT_NULL(x) (fabs((x)-CE_FLOAT_NULL)<=CE_FLOAT_DELTA)
+
+typedef enum {CE_ROUND_NEAREST = 1, CE_ROUND_UP, CE_ROUND_DOWN, CE_RANGE} CeRoundPolicy;
+
+typedef enum cdUnit {
+ cdMinute = CdMinute,
+ cdHour = CdHour,
+ cdDay = CdDay,
+ cdWeek = CdWeek, /* Always = 7 days */
+ cdMonth = CdMonth,
+ cdSeason = CdSeason, /* Always = 3 months */
+ cdYear = CdYear,
+ cdSecond = CdSecond,
+ cdFraction /* Fractional part of absolute time */
+} cdUnitTime;
+
+/*
+ * =================================================================
+ * Structures
+ * =================================================================
+ */
+
+/* Symbol table index entry */
+typedef struct {
+ char name[CD_MAX_NAME]; /* Name (key) */
+ int index; /* Index into symbol table (0-origin) */
+ short deleted; /* 1 iff entry is marked for deletion */
+} cdTag;
+
+/* Symbol table */
+typedef struct {
+ cdTag *nameIndex; /* Sorted name index */
+ cdTag *aliasIndex; /* Sorted alias index */
+ int nentries; /* Number of table entries */
+ int length; /* Allocated slots for entries, may be > nentries */
+ size_t entrySize; /* Size of each entry*/
+ void *entries; /* Symbol table */
+} cdSymtab;
+
+/* Attribute */
+typedef struct cdAtt {
+ char name[CD_MAX_NAME]; /* Attribute name */
+ cdType datatype; /* Datatype of the attribute */
+ long length; /* Number of elements (NOT bytes) */
+ void* values; /* Pointer to internal structure for GrADS */
+ struct cdAtt* next; /* Next attribute */
+} cdAtt;
+
+/* Dataset */
+typedef struct cdDset {
+ long id; /* Dataset ID */
+ long dbid; /* Database ID */
+ char path[CD_MAX_PATH]; /* Dataset pathname */
+ char fileTemp[CD_MAX_PATH]; /* File template */
+ cdSymtab* vars; /* Variables */
+ cdSymtab* dims; /* Dimensions */
+ cdSymtab* grids; /* Grids */
+ int ngatts; /* Number of global attributes */
+ cdAtt* atts; /* Global attributes */
+ struct cdDset* next; /* Next dataset */
+} cdDset;
+
+/* Database */
+typedef struct cdDb {
+ long id; /* Database ID */
+ char path[CD_MAX_PATH]; /* Database pathname */
+ cdDset* dsets; /* Datasets */
+ struct cdDb* next; /* Next database */
+} cdDb;
+
+/* Parameter */
+typedef struct {
+ char name[CD_MAX_NAME]; /* Parameter name */
+ char longName[CD_MAX_NAME]; /* Descriptive name */
+ char units[CD_MAX_NAME]; /* Standard units */
+} cdParm;
+
+/* Polygon */
+typedef struct {
+ long id; /* Polygon ID */
+ cdPolygonType type; /* cdBox, cdAnnulus, etc. */
+ long length; /* Number of points */
+ struct {
+ double lon; /* Longitude point */
+ double lat; /* Latitude point */
+ } *points; /* Points */
+} cdPolygon;
+
+/* Variable */
+typedef struct {
+ long id; /* Variable ID */
+ long dsetid; /* Dataset ID */
+ char name[CD_MAX_NAME]; /* Parameter name (official) */
+ char alias[CD_MAX_NAME]; /* Name in file */
+ char aliasTitle[CD_MAX_NAME]; /* Title in file */
+ int natts; /* Number of attributes */
+ cdAtt* atts; /* Attribute list */
+ int ncomps; /* Number of components */
+ long comps[CD_MAX_VAR_COMPS]; /* Component variable IDs, if ncomps>1 */
+ void* data; /* Data for implicit array definition */
+ cdType datatype; /* cdChar, cdInt, etc. */
+ char delta[CD_MAX_TIME_DELTA]; /* Delta, for linear rep (datatype is double, long, or chartime) */
+ long length; /* Number of elements */
+ int ndims; /* Number of dimensions */
+ long dim[CD_MAX_VAR_DIMS]; /* Dimension IDs */
+ char fileTemp[CD_MAX_PATH]; /* File template */
+ long gridid; /* Grid ID, if spatio-temporal */
+ char initVal[CD_MAX_CHARTIME]; /* Initial value, for linear rep (datatype is double, long, or chartime)*/
+ long levelid; /* Level ID, if spatio-temporal */
+ char longName[CD_MAX_NAME]; /* Parameter title */
+ cdRepresent rep; /* cdExternalArray, cdInternalArray, cdLinear, ... */
+ char stat[CD_MAX_NAME]; /* Statistic */
+ long timeid; /* Time ID, if spatio-temporal */
+ char units[CD_MAX_NAME]; /* Units in file */
+} cdVar;
+
+/* Dimension */
+typedef struct cdDim{
+ long id; /* Dimension ID */
+ char name[CD_MAX_NAME]; /* Dimension name */
+ char alias[CD_MAX_NAME]; /* Dimension alias */
+ int natts; /* Number of attribtues */
+ cdAtt* atts; /* Attributes */
+ cdDimType type; /* cdLongitude, cdLatitude, etc. */
+ cdType datatype; /* Dimension datatype */
+ int subtype; /* cdSigma, cdJulian, etc., interpret using type */
+ long length; /* Number of elements */
+ int topology; /* E.g., cdWrapped */
+ int unlimited; /* 0 if fixed, 1 if unlimited length (extensible) */
+ cdVar* boundary; /* Boundary variable if any */
+ struct cdDim* partition; /* variable with partition indices */
+ cdRepresent rep; /* cdExternalArray, cdInternalArray, cdLinear, ... */
+ char units[CD_MAX_NAME]; /* Dimension units */
+ char delta[CD_MAX_TIME_DELTA]; /* Delta, for linear rep (datatype is double, long, or chartime) */
+ char initVal[CD_MAX_CHARTIME]; /* Initial value, for linear rep (datatype is double, long, or chartime) */
+ void* data; /* Data for implicit array definition */
+} cdDim;
+
+/* Grid */
+typedef struct {
+ long id; /* Grid ID */
+ char name[CD_MAX_NAME]; /* Grid name */
+ int natts; /* Number of attributes */
+ cdAtt* atts; /* Attribute list */
+ cdGridType type; /* Grid type (rectangular, projected, ...) */
+ long familyid; /* Grid family ID */
+ long lon; /* Longitude dimension ID */
+ long lat; /* Latitude dimension ID */
+ long length; /* Number of zones */
+ int ndims; /* Number of dimensions */
+ long dim[CD_MAX_VAR_DIMS]; /* Dimensions (IDs), in order of definition */
+ cdVar* mask; /* Mask variable if any */
+ double projArgs[3]; /* Projection arguments */
+} cdGrid;
+
+/*
+ * =================================================================
+ * Function Prototypes
+ * =================================================================
+ */
+
+extern cdDb* cdDbLookupId(long dbid);
+extern cdDset* cdDsetLookup(cdDb* db, const char* path);
+extern cdDset* cdDsetLookupId(long dsetid);
+extern cdDset* cdDsetInsert(cdDb* db, const char* path);
+extern int cdDsetDelete(long dsetid);
+extern void cdAttlistDestroy(cdAtt* attlist);
+extern cdAtt* cdAttInsert(char* name, cdAtt** attlist);
+extern cdAtt* cdAttlistGet(cdDset* dset, long objid);
+
+extern void cdError(char *fmt, ...);
+extern int cdInit(void);
+extern cdSymtab *cdSymtabCreate(int nentries, size_t entrySize);
+extern void cdSymtabDestroy(cdSymtab *table);
+extern int cdSymDelete(cdSymtab *table, int id);
+extern int cdSymInsert(cdSymtab *table, char *name, char *alias, void *entry);
+extern int cdSymLookup(int nindex, cdTag *indexTable, char *key, int *loc);
+extern int cdSymLookupName(cdSymtab *table, char *name, int *loc, void **entry);
+extern int cdSymLookupAlias(cdSymtab *table, char *alias, int *loc, void **entry);
+
+ /* Basic time routines */
+int cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTime* base_comptime);
+int cdParseDeltaTime(cdCalenType timetype, char* deltaTime, double* value, cdUnitTime* unit);
+extern void CdDayOfYear(CdTime *date, int *doy);
+extern void CdDaysInMonth(CdTime *date, int *days);
+extern void CdError(char *fmt, ...);
+extern void CdMonthDay(int *doy, CdTime *date);
+extern void Cdc2e(char *ctime, CdTimeType timeType, double *etime, long *baseYear);
+extern void Cdc2h(char *ctime, CdTimeType timeType, CdTime *htime);
+extern void Cde2c(double etime, CdTimeType timeType, long baseYear, char *ctime);
+extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
+extern void Cdh2c(CdTime *htime, char *ctime);
+extern void Cdh2e(CdTime *htime, double *etime);
+
+ /* Dean's DRS-like extensions */
+extern int cealterdata(int fileid, int varid, const long count[], void* value);
+extern int ce_dimget(int fileid, int dimid, double** values, long *dimlen);
+extern void ce_lookup(double tab[], long n, double x, long *k);
+extern int ce_lookup_with_policy(double tab[], long n, double x, CeRoundPolicy policy, double delta, long *k);
+extern int ce_lookup_cycle(double tab[], long n, double x, double cycle, CeRoundPolicy policy, double delta,
+ long *k, long *icycle);
+extern int ce_dimmap(int fileid, int dimid, double df, double dl, CeRoundPolicy policy, double delta, int isCycle,
+ double cycle, double** dp, long *idf, long *idl, double *xdf, double *xdl);
+extern int ce_dimmapi(int fileid, int dimid, double df, double dl, CeRoundPolicy policy, double delta, int isCycle,
+ double cycle, double** dp, long *idf, long *idl, double *xdf, double *xdl);
+extern int cevarinq(int fileid, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+
+/*
+ * =================================================================
+ * Globals
+ * =================================================================
+ */
+
+extern cdDb* cdCurrentDb; /* Database for dataset currently being parsed */
+extern cdDset* cdCurrentDset; /* Dataset currently being parsed */
+extern int cdLineno; /* Line number of dataset file currently being parsed */
+extern long cdNextDimid; /* Next dimension ID */
+extern long cdNextGridid; /* Next grid ID */
+extern long cdNextVarid; /* Next variable ID */
+extern int cdYyerrors; /* Number of parsing errors */
+
+
+
+
+/* NB!!! Everything below this line is OBSOLETE!! */
+
+typedef enum CdDsetType {CdExperiment = 1, CdObservation} CdDsetType;
+typedef enum CdGridType {CdRegistered = 1, CdSpectral = 2} CdGridType;
+typedef enum CdOpenMode {CdReadOnly = 1, CdReadWrite} CdOpenMode;
+typedef enum CdQaLevel {CdUnvalidated = 1, CdValidated = 2} CdQaLevel;
+
+ /* See cdunif.h */
+typedef enum CdType {CdInvalidType = -1,
+ CdByte = CuByte,
+ CdChar = CuChar,
+ CdShort = CuShort,
+ CdInt = CuInt,
+ CdLong = CuLong,
+ CdFloat = CuFloat,
+ CdDouble = CuDouble,
+ CdLongDouble = CuLongDouble} CdType;
+
+typedef enum CdDimensionType {
+ CdXDimension = 1,
+ CdYDimension,
+ CdZDimension,
+ CdTDimension,
+ CdPDimension
+} CdDimensionType;
+
+ /* Sequential access cursor operations */
+typedef enum {
+ CdFirst = 1,
+ CdLast,
+ CdNext,
+ CdPrev
+} CdCursorOp;
+
+/* predefined statistics */
+#define CdMonthlyMeans "monthly mean"
+
+/*
+ * =================================================================
+ * Structures
+ * =================================================================
+ */
+
+typedef struct {
+ long id; /* Database ID */
+ char name[CU_MAX_PATH]; /* Full dataset pathname */
+ CdDsetType dsetType; /* Experimental or observed */
+} CdDsetDes;
+typedef CdDsetDes *CdDset;
+
+/* Order descriptor */
+/* Each value is a dimension index, 0 .. 4, indicating */
+/* the order of the dimensions on output. C-majority is observed, */
+/* that is, dimension 0 is LEAST rapidly varying. A negative value */
+/* indicates that the dimension is not applicable. For direction, a positive value */
+/* indicates increasing values, negative indicates decreasing */
+/* values. Direction for parameters refers to the canonical */
+/* ordering as defined in the database. */
+
+typedef struct {
+ short parm; /* Parameter dimension, for compound elements */
+ short lon; /* Longitude dimension */
+ short lat; /* Latitude dimension */
+ short lev; /* Level dimension */
+ short time; /* Time dimension */
+ short parmDir; /* Parameter dimension direction, for compound elements */
+ short lonDir; /* Longitude dimension direction */
+ short latDir; /* Latitude dimension direction */
+ short levDir; /* Level dimension direction */
+ short timeDir; /* Time dimension direction */
+} CdOrder;
+
+typedef struct { /* specification of range of data to return */
+ int bgnColNum; /* begining column number to read */
+ int colCnt; /* count of colums to read */
+ int bgnRowNum; /* beginning row number to read */
+ int rowCnt; /* count of rows to read */
+ int bgnLevNum;
+ int levCnt;
+ double bgnTime; /* beginning time to read; depends on timeType */
+ int stepCnt; /* count of time steps to read */
+} CdRegion;
+
+typedef struct {
+ char prjnName[21]; /* projection name */
+ long nx; /* count of columns */
+ long ny; /* count of rows */
+ double lat; /* lat of origin in degrees */
+ double lon; /* lon of origin in degrees */
+ long orig_ix; /* column # for origin, left column is 1 */
+ long orig_iy; /* row # for origin; top row is 1 */
+ double x_int_dis; /* distance interval between columns in km */
+ double y_int_dis; /* distance interval between rows in km */
+ double parm_1; /* geom parm 1, depends on projection */
+ double parm_2; /* geom parm 2, depends on projection */
+ double parm_3; /* geom parm 3, depends on projection */
+} CdRegGeom;
+
+typedef struct { /* info from table grid_spct_geom */
+ char trnc_type[21]; /* spectral truncation type (triangular/etc) */
+ long coef_cnt; /* count of complex coefficients used */
+ long max_lat_wav_num; /* max latitudinal wavenumber (M in GRIB) */
+ long max_lon_wav_num_1; /* max longitudinal wavenumber 1 (J in GRIB) */
+ long max_lon_wav_num_2; /* max longitudinal wavenumber 2 (K in GRIB) */
+} CdSpctGeom;
+
+typedef struct {
+ double begEtm; /* Beginning epochal time */
+ double begLvl; /* Beginning level */
+ double endEtm; /* End epochal time */
+ double endLvl; /* End level */
+ long fileId; /* Database file ID */
+ CdOrder storageOrder; /* Storage order in external file */
+ long varId; /* Database variable ID */
+} CdSlab;
+
+typedef struct {
+ long id;
+ char name[41];
+ long count;
+ char lvlType[41];
+ char remark[121];
+ char units[41];
+ double *values;
+} CdLevel;
+
+typedef struct {
+ char alias[CD_MAX_NAME]; /* name in the file */
+ CdType dataType; /* data type of var */
+ long dsetId; /* Dataset ID */
+ CdGridType gridType; /* grid type (registered | spectral) */
+ long id; /* Variable ID */
+ CdLevel level; /* Level */
+ long lvlId; /* level database ID */
+ double maxEtm; /* Ending epochal time */
+ double minEtm; /* Beginning epochal time */
+ double missing; /* missing data value */
+ char name[CD_MAX_NAME]; /* parameter (official variable) name */
+ long nx; /* Number of longitudes */
+ long ny; /* Number of latitudes */
+ long nz; /* Number of levels */
+ long nt; /* Number of times */
+ long parmId; /* parameter database ID */
+ char parmUnits[CD_MAX_NAME]; /* official units */
+ CdRegGeom regGeom; /* registered geometry */
+ char remark[CD_MAX_NAME]; /* comments */
+ double scaleB; /* mapping from actual units to official units */
+ /* is parmUnits = (scaleM * units) + scaleB*/
+ double scaleM;
+ CdSpctGeom spctGeom; /* spectral geometry */
+ char statistic[CD_MAX_NAME]; /* Statistic identifier */
+ CdOrder storageOrder; /* storage order, in external file or internally */
+ CdTimeType timeType; /* time type */
+ char title[CD_MAX_NAME]; /* parameter title */
+ char units[CD_MAX_NAME]; /* actual units (cf. parmUnits) */
+} CdVar;
+
+/*
+ * =================================================================
+ * Function Prototypes
+ * =================================================================
+ */
+
+/* Connect to the database */
+/*
+extern int
+CdConnectDb(void);
+*/
+/* Disconnect from the database */
+/*
+extern void
+CdDisconnectDb(void);
+*/
+/* Open a dataset. Returns a handle for the dataset*/
+
+extern CdDset
+CdOpenDset(char *path, /* Dataset path name */
+ CdOpenMode openMode /* Open mode */
+ );
+
+
+/* Close a dataset */
+
+extern void
+CdCloseDset(CdDset dset); /* Dataset handle */
+
+/* Get a variable handle */
+
+extern int
+CdLookupVar(CdDset dset, /* Dataset handle */
+ char *varName, /* Variable (parameter) name*/
+ char *statistic, /* Statistic (if NULL, return the first variable) */
+ CdVar *var, /* Variable descriptor (returned) */
+ CdRegion *region); /* Region (returned) */
+
+/* Read a region of data. A region is a description of a four-dimensional */
+/* lon-lat-lev-time portion of data. */
+
+extern int
+CdReadRegion(CdVar *var, /* variable */
+ CdRegion *region, /* Region to read */
+ CdOrder *order, /* Ordering of data dimensions on return */
+ CdType datatype, /* Datatype of data to be returned (input) */
+ void *data); /* Data returned (output) */
+
+
+/* Set a region */
+
+extern int
+CdSetLon(CdVar *var, /* variable */
+ double firstLon, /* first longitude in range */
+ double lastLon, /* last longitude in range */
+ CdRegion *region); /* region to set */
+
+extern int
+CdSetLat(CdVar *var, /* variable */
+ double firstLat,
+ double lastLat,
+ CdRegion *region);
+
+extern int
+CdSetLevel(CdVar *var, /* variable */
+ double firstLevel,
+ double lastLevel,
+ CdRegion *region);
+
+extern int
+CdSetTime(CdVar *var, /* variable */
+ CdTime *start,
+ CdTime *end,
+ CdRegion *region);
+
+/* Get dimension ranges from a region */
+
+extern int
+CdGetLon(CdVar *var, /* variable */
+ CdRegion *region,
+ double *firstLon,
+ double *lastLon);
+
+extern int
+CdGetLat(CdVar *var, /* variable */
+ CdRegion *region,
+ double *firstLat,
+ double *lastLat);
+
+extern int
+CdGetLevel(CdVar *var, /* variable */
+ CdRegion *region,
+ double *firstLevel,
+ double *lastLevel);
+
+extern int
+CdGetTime(CdVar *var, /* variable */
+ CdRegion *region,
+ CdTime *start,
+ CdTime *end);
+
+/* Get region size, returns number of elements */
+
+extern long
+CdRegionSize(CdRegion *region, CdType dataType);
+
+/* Set the order structure from human-readable form */
+extern int
+CdSetOrder(CdVar *var, /* Variable handle */
+ CdOrder *order, /* Returned order structure */
+ char orderSpec[11]); /* Order specification, any permutation such as */
+ /* "SpSxSySzSt", "SxSySpStSz" , "StSpSzSySx" */
+ /* where S is either '+' for increasing dimension values */
+ /* in the resulting array, or '-' for decreasing values. */
+
+/* Get the registered geometry for a variable */
+extern int
+CdGetRegGeom(CdVar *var, /* Variableiable */
+ CdRegGeom *varRegGeom); /* registered geometry (output) */
+
+/* Get the spectral geometry for a variable */
+extern int
+CdGetSpctGeom(CdVar *var, /* Variable */
+ CdSpctGeom *varSpctGeom); /* spectral geometry */
+
+
+extern CdVar
+CdSetVarCursor(CdDset dset, /* Dataset handle */
+ char *varName, /* Variable name */
+ char *statistic); /* Variable statistic, or NULL for first */
+
+ /* Fetch a variable */
+extern CdVar
+CdFetchVar(CdCursorOp op); /* Cursor operation */
+
+ /* Error routines */
+
+#endif
diff --git a/src/cdunif.h b/src/cdunif.h
new file mode 100644
index 0000000..abcf06d
--- /dev/null
+++ b/src/cdunif.h
@@ -0,0 +1,178 @@
+/* -*-Mode: C;-*-
+ * Module: cdunif - cdunif uniform I/O include file
+ *
+ * Copyright: 1994, Regents of the University of California
+ * This software may not be distributed to others without
+ * permission of the author.
+ *
+ * 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 $
+ *
+ * Revision History:
+ *
+ * $Log: cdunif.h,v $
+ * Revision 1.1 2008/06/30 16:07:44 ed
+ * Beginning merge of calandar stuff.
+ *
+ * Revision 1.1.1.1 1997/12/09 18:57:39 drach
+ * Copied from cirrus
+ *
+ * Revision 1.14 1997/11/24 17:28:04 drach
+ * - Added QL package to cdunif
+ * - Added NdimIntersect function to CDMS
+ *
+ * Revision 1.13 1997/11/10 19:22:29 drach
+ * - Added cuvargets to cdunif, cdSlabRead to cdms
+ *
+ * Revision 1.12 1997/01/06 17:47:13 drach
+ * - Added HDF to cdunif
+ *
+ * Revision 1.11 1996/02/23 01:21:24 drach
+ * - Moved most of cdms.h to cdmsint.h (original in cdms_v1.h)
+ * - Added new time model declarations to cdms.h
+ * - Added -DNO_DECLARE flag to fcddrs.h
+ *
+ * Revision 1.10 1995/10/16 18:56:33 drach
+ * - Added CuInt datatype, DEC Alpha version
+ *
+ * Revision 1.9 1995/03/09 00:35:18 drach
+ * Added netCDF, upgraded cureadarray with casting, user-specified indices
+ *
+ * Revision 1.8 1995/01/18 02:53:38 drach
+ * - Explicitly set CuFileType enums
+ *
+ * Revision 1.7 1994/12/20 01:19:45 drach
+ * - Added cdrra and cureadarray functions
+ *
+ * Revision 1.6 1994/12/17 00:43:02 drach
+ * - add cugetlu, cufreelu
+ *
+ * Revision 1.5 1994/12/16 00:45:42 drach
+ * - Added invalid CuType
+ *
+ * Revision 1.4 1994/12/14 02:33:01 drach
+ * - Added comment
+ *
+ * Revision 1.3 1994/11/23 23:00:06 drach
+ * *** empty log message ***
+ *
+ * Revision 1.2 1994/11/23 22:56:23 drach
+ * Changed hyperlong to long double.
+ *
+ * Revision 1.1 1994/11/18 23:42:27 drach
+ * Initial version
+ *
+ *
+ */
+#ifndef _CDUNIF_H
+#define _CDUNIF_H
+
+/*
+ * =================================================================
+ * Macros and Enums
+ * =================================================================
+ */
+
+#define CU_FATAL 1 /* Exit immediately on fatal error */
+#define CU_VERBOSE 2 /* Report errors */
+
+#define CU_GLOBAL -1 /* Global varid */
+#define CU_MAX_LU 99 /* Max logical unit for Fortran I/O */
+#define CU_MAX_NAME 128 /* Max characters in a name */
+#define CU_MAX_PATH 256 /* Max characters in a file pathname */
+#define CU_MAX_VAR_DIMS 32 /* Max dimensions in a variable */
+#define CU_SETRRA(a,id,i,value) a->indices[id][i]=value /* Set a right-ragged array element */
+
+ /* Note: integer types must be grouped, also floats (cf cuCast) */
+ /* IF MODIFIED, SHOULD ALSO MODIFY CDMS.H !!*/
+typedef enum CuType {CuInvalidType = -1, CuByte = 1, CuChar, CuShort, CuInt, CuLong, CuFloat, CuDouble, CuLongDouble} CuType;
+
+ /* Note: For cuseterropts to work correctly,
+ * valid formats must begin at 0 and increase
+ * sequentially, with CuNumberOfFormats the last entry.
+ */
+typedef enum CuFileType {CuUnknown = -1, CuDrs=0, CuGrads=1, CuNetcdf=2, CuHdf=3, CuQL=4, CuPop=5, CuNumberOfFormats} CuFileType;
+typedef enum CuDimType {CuGlobalDim = 1, CuLocalDim} CuDimType;
+
+typedef struct {
+ long rank; /* number of dimensions */
+ long *arraySize; /* vector of lengths of dimensions of base array */
+ long *dimensionSize; /* vector of lengths of index vectors */
+ long **indices; /* index vectors; indices[k] is vector of length dimensionSize[k] */
+} CuRRA;
+
+/*
+ * =================================================================
+ * Function prototypes
+ * =================================================================
+ */
+
+extern int cuopenread(const char* controlpath, const char* datapath);
+extern int cuclose(int fileid);
+extern int cuinquire(int fileid, int* ngdims, int* nvars, int* natts, int* recdim);
+extern int cudimid(int fileid, int varid, const char* name);
+extern int cudiminq(int fileid, int dimid, char* dimname, char* dimunits, CuType* dataType, CuDimType* dimtype, int* varid, long* length);
+extern int cudimget(int fileid, int dimid, void* values);
+extern int cuvarid(int fileid, const char* name);
+extern int cuvarinq(int fileid, int varid, char* name, CuType* datatype, int* ndims, int dimids[], int* natts);
+extern int cuvarget(int fileid, int varid, const long start[], const long count[], void* value);
+extern int cuvargets(int fileid, int varid, const long order[], const long start[], const long count[], const long stride[], CuType usertype, void *values);
+extern int cuattinq(int fileid, int varid, const char* name, CuType* datatype, int* len);
+extern int cuattget(int fileid, int varid, const char* name, void* value);
+extern int cuattname(int fileid, int varid, int attnum, char* name);
+extern int cutypelen(CuType datatype);
+extern int cusetlu(int lu1, int lu2);
+extern int cugetlu(int* lu1, int* lu2);
+extern int cufreelu(int lu);
+extern void cuseterropts(int erropts);
+extern int cugeterropts(void);
+extern int cugeterr(void);
+
+extern int cureadarray(int fileid, int varid, CuRRA *vIndices, CuRRA *uIndices,
+ const long transpose[], CuType usertype, void *userArray);
+extern CuRRA *cucreateRRA(long rank, const long arraySize[], const long dimensionSize[]);
+extern void cudestroyRRA(CuRRA *);
+extern int cusortRRA(CuRRA *, CuRRA *, const long []);
+extern void cuprintRRA(CuRRA *);
+
+/*
+ * =================================================================
+ * Globals
+ * =================================================================
+ */
+
+extern int cuErrOpts; /* Error options */
+extern int cuErrorOccurred; /* True iff cdError was called */
+
+/*
+ * =================================================================
+ * Error returns
+ * =================================================================
+ */
+
+#define CU_SERROR -1 /* System error */
+#define CU_SUCCESS 0 /* Success */
+#define CU_EBADID 1 /* Bad ID passed to driver layer */
+#define CU_OPENFILES 2 /* Too many files open */
+#define CU_EINVAL 4 /* Invalid Argument */
+#define CU_ENOTINDEFINE 6 /* Operation not allowed in data mode (netCDF only) */
+#define CU_EINDEFINE 7 /* Operation not allowed in define mode (netCDF only) */
+#define CU_EINVALCOORDS 8 /* Coordinates out of Domain */
+#define CU_ENOTATT 11 /* Attribute not found */
+#define CU_EBADTYPE 13 /* Not a cdunif data type */
+#define CU_EBADDIM 14 /* Invalid dimension id */
+#define CU_ENOTVAR 17 /* Variable not found */
+#define CU_EGLOBAL 18 /* Action prohibited on CU_GLOBAL varid */
+#define CU_ENOTCU 19 /* Not a file supported by cdunif*/
+#define CU_EMAXNAME 21 /* CU_MAX_NAME exceeded */
+#define CU_ENOVARS 51 /* File has no variables */
+#define CU_EINTERN 52 /* cdunif internal error */
+#define CU_EBADFORM 53 /* Format recognized but not supported */
+#define CU_DRIVER 54 /* Driver layer error */
+#define CU_EINVLU 55 /* Invalid logical unit (DRS only) */
+#define CU_EOPEN 56 /* File open error */
+#define CU_ENOCAST 57 /* Cannot cast between user and file datatypes */
+
+#endif
diff --git a/src/cfcvars.c b/src/cfcvars.c
new file mode 100644
index 0000000..5179292
--- /dev/null
+++ b/src/cfcvars.c
@@ -0,0 +1,1550 @@
+/*
+ Copyright 2006, University Corporation for Atmospheric Research. See
+ COPYRIGHT file for copying and redistribution conditions.
+
+ This file is part of the NetCDF CF Library.
+
+ This file handles the libcf file stuff.
+
+ Ed Hartnett, 9/1/06
+
+ $Id: cfcvars.c,v 1.15 2009/01/20 19:16:53 ed Exp $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <libcf_int.h>
+#include <netcdf.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#define NLAT_UNITS 6
+#define NLON_UNITS 6
+#define NPRES_UNITS 31
+#define NLEVEL_UNITS 35
+#define NTIME_UNITS 33
+#define CF_POS_LEN 4
+
+#define CF_PTOP "PTOP"
+
+static char *vert_std_name[] = {
+ STD_ATM_LN, STD_SIGMA, STD_HYBRID_SIGMA, STD_HYBRID_HEIGHT, STD_SLEVE,
+ STD_OCEAN_SIGMA, STD_OCEAN_S, STD_OCEAN_SIGMA_Z, STD_OCEAN_DBL_SIGMA
+};
+
+/* The Common Data Model defines these axis types. */
+static char* axis_type_name[] = {"", "Lat", "Lon", "GeoX", "GeoY", "GeoZ",
+ "Height", "Height", "Pressure", "Time",
+ "RadialAzimuth", "RadialElevation",
+ "RadialDistance"};
+
+int
+cf_test1(int i)
+{
+ printf("i = %d", i);
+ return 0;
+}
+
+/* Define a coordinate dimension and variable with all the CF
+ * recomended attribute accessories. */
+static int
+def_coord_var(int ncid, const char *name, size_t len, nc_type xtype,
+ const char *units, const char *axis, int positive_up,
+ const char *standard_name, const char *formula_terms,
+ int cdm_axis_type, int *dimidp, int *varidp)
+{
+ int did, vid;
+ int ret;
+
+ /* Name is required. */
+ if (!name)
+ return CF_EINVAL;
+
+ /* There must be neither a dimension nor a variable of the chosen
+ * name. */
+ if (nc_inq_dimid(ncid, name, &did) != NC_EBADDIM ||
+ nc_inq_varid(ncid, name, &vid) != NC_ENOTVAR)
+ return CF_EEXISTS;
+
+ /* Create a dimension. */
+ if ((ret = nc_def_dim(ncid, name, len, &did)))
+ return ret;
+
+ /* Give the user back the dimid if he wants it. */
+ if (dimidp)
+ *dimidp = did;
+
+ /* Create a variable. */
+ if ((ret = nc_def_var(ncid, name, xtype, 1, &did, &vid)))
+ return ret;
+
+ /* Give the user back the varid if he wants it. */
+ if (varidp)
+ *varidp = vid;
+
+ /* Create required attributes for this coordinate variable. */
+ if (units)
+ if ((ret = nc_put_att_text(ncid, vid, CF_UNITS, strlen(units) + 1,
+ units)))
+ return ret;
+
+ /* If an axis was provided, then use it. This is the "axis"
+ * described in the CF document, section 4. It is a text string, X,
+ * Y, Z or T.*/
+ if (axis)
+ {
+ if ((ret = nc_put_att_text(ncid, vid, CF_AXIS, strlen(axis) + 1,
+ axis)))
+ return ret;
+
+ /* If this is a vertical axis, use the "positive" attribute to
+ * indicate whether it is increasing upwards, or downwards. */
+ if (!strncmp(axis, CF_LEVEL_AXIS, strlen(CF_LEVEL_AXIS)))
+ {
+ if (positive_up)
+ {
+ if ((ret = nc_put_att_text(ncid, vid, CF_POSITIVE,
+ strlen(CF_UP) + 1, CF_UP)))
+ return ret;
+ }
+ else
+ {
+ if ((ret = nc_put_att_text(ncid, vid, CF_POSITIVE,
+ strlen(CF_DOWN) + 1, CF_DOWN)))
+ return ret;
+ }
+ }
+ }
+
+ /* This is the CDM axis, which is somewhat different. */
+ if (cdm_axis_type)
+ {
+ /* Is the axis type valid? */
+ if (cdm_axis_type < 0 || cdm_axis_type > NCCF_RADDIST)
+ return NC_EINVAL;
+
+ /* Now write the attribute which stores the axis type. */
+ if ((ret = nc_put_att_text(ncid, vid, COORDINATE_AXIS_TYPE,
+ strlen(axis_type_name[cdm_axis_type]) + 1,
+ axis_type_name[cdm_axis_type])))
+ return ret;
+ }
+
+ /* If formula_terms was provided, then use it. */
+ if (formula_terms)
+ if ((ret = nc_put_att_text(ncid, vid, CF_FORMULA_TERMS,
+ strlen(formula_terms) + 1,
+ formula_terms)))
+ return ret;
+
+ /* If standard_name was provided, then use it. */
+ if (standard_name)
+ if ((ret = nc_put_att_text(ncid, vid, CF_STANDARD_NAME,
+ strlen(standard_name) + 1,
+ standard_name)))
+ return ret;
+
+ return CF_NOERR;
+}
+
+/* Inquire about a coordinate variable. */
+static int
+inq_coord_var(int ncid, int nvalid, const char valid_units[][CF_MAX_LEN + 1],
+ const char *valid_standard_name, char *name, size_t *lenp,
+ nc_type *xtypep, size_t *ft_lenp, char *formula_terms,
+ int *positive_upp, int *dimidp, int *varidp)
+{
+ int varid, nvars, dimid;
+ nc_type att_type_in, xtype_in;
+ size_t att_len_in, target_len_in;
+ char *target_end;
+ char target_in[NC_MAX_NAME + 1], var_name[NC_MAX_NAME + 1];
+ char target[NC_MAX_NAME + 1];
+ char pos_in[CF_POS_LEN + 1];
+ int positive_found = 0, positive_up, vnum;
+ int ret;
+
+ /* How many vars are there? */
+ if ((ret = nc_inq_nvars(ncid, &nvars)))
+ return ret;
+
+ /* If there are no valid units, and no standard name, I can't find
+ * a coodinate variable! */
+ if (!valid_units && !valid_standard_name)
+ return CF_EINVAL;
+
+ /* Decide what we are looking for. */
+ if (valid_units)
+ strcpy(target, CF_UNITS);
+ else
+ strcpy(target, CF_STANDARD_NAME);
+
+ /* Search for a variable with an appropriate "units" or
+ * "standard_name" attribute. */
+ for (varid = 0; varid < nvars; varid++)
+ {
+ /* Is there's no units or standard_name attribute for this
+ * var, move on. */
+ if ((ret = nc_inq_att(ncid, varid, target, &att_type_in,
+ &att_len_in)) == NC_ENOTATT)
+ continue;
+
+ /* If we got some other error, we're totally hosed. */
+ if (ret != NC_NOERR)
+ return ret;
+
+ /* If the attribute is not a character string, or if it's longer
+ * than NC_MAX_NAME, then what the heck is going on? Skip it. */
+ if (att_type_in != NC_CHAR || att_len_in > NC_MAX_NAME)
+ continue;
+
+ /* Get the value of the attribute. */
+ if ((ret = nc_get_att_text(ncid, varid, target, target_in)))
+ return ret;
+
+ /* We only care about this string before the first space. */
+ target_end = index(target_in, ' ');
+ if (target_end)
+ target_len_in = target_end - target_in - 1;
+ else
+ target_len_in = att_len_in;
+
+ if (valid_units)
+ {
+ /* If the length and value matches on of our valid strings,
+ * then we have found our coordinate variable. */
+ for (vnum = 0; vnum < nvalid; vnum++)
+ if (target_len_in <= strlen(valid_units[vnum]) + 1 &&
+ !strncmp(target_in, valid_units[vnum], strlen(valid_units[vnum])))
+ break;
+
+ /* If we found the coordinate var, stop looking. */
+ if (vnum < nvalid)
+ break;
+ }
+ else
+ {
+ if (target_len_in <= strlen(valid_standard_name) + 1 &&
+ !strncmp(target_in, valid_standard_name, strlen(valid_standard_name)))
+ break;
+ }
+
+ } /* next varid*/
+
+ /* Did we still not find our coordinate variable? */
+ if (varid == nvars)
+ {
+ /* Let's look for an attribute named "positve". */
+ for (varid = 0; varid < nvars; varid++)
+ {
+ /* Is there's no "positive" attribute for this var, move on. */
+ if ((ret = nc_inq_att(ncid, varid, CF_POSITIVE, &att_type_in,
+ &att_len_in)) == NC_ENOTATT)
+ continue;
+
+ /* If we got some other error, we're totally hosed. */
+ if (ret != NC_NOERR)
+ return ret;
+
+ /* If the "positive" attribute is not a character string,
+ * or it's too long, then what the heck is going on? Skip
+ * it. */
+ if (att_type_in != NC_CHAR || att_len_in > strlen(CF_DOWN) + 1)
+ continue;
+
+ /* Get the value of the "positive" attribute. */
+ if ((ret = nc_get_att_text(ncid, varid, CF_POSITIVE, pos_in)))
+ return ret;
+ if (strncasecmp(pos_in, CF_DOWN, strlen(CF_DOWN)) == 0)
+ positive_up = 0;
+ else if (strncasecmp(pos_in, CF_UP, strlen(CF_UP)) == 0)
+ positive_up = 1;
+ else
+ return CF_EBADVALUE;
+
+ /* Remember that we have already found and dealt with the
+ * "positive" attribute. */
+ positive_found++;
+
+ /* We found the coordinate var, stop looking. */
+ break;
+
+ } /* next varid*/
+
+ if (varid == nvars)
+ return CF_ENOTFOUND;
+ }
+
+ /* Does the user want the varid of this coordinate variable? */
+ if (varidp)
+ *varidp = varid;
+
+ /* We need to know some stuff. */
+ if ((ret = nc_inq_vartype(ncid, varid, &xtype_in)))
+ return ret;
+
+ /* Does the user want the type of this coordinate variable? */
+ if (xtypep)
+ *xtypep = xtype_in;
+
+ /* Is there an interest in the formula_terms attribute? */
+ if (ft_lenp || formula_terms)
+ {
+ ret = nc_inq_att(ncid, varid, CF_FORMULA_TERMS, &att_type_in,
+ &att_len_in);
+ if (ret == NC_ENOTATT)
+ {
+ if (ft_lenp)
+ *ft_lenp = 0;
+ }
+ else if (ret == CF_NOERR)
+ {
+ /* If this is not a character attribute, what the heck is
+ * it? */
+ if (att_type_in != NC_CHAR)
+ {
+ if (ft_lenp)
+ *ft_lenp = 0;
+ }
+ else
+ {
+ if (ft_lenp)
+ *ft_lenp = att_len_in;
+ if (formula_terms)
+ if ((ret = nc_get_att_text(ncid, varid, CF_FORMULA_TERMS,
+ formula_terms)))
+ return ret;
+ }
+ }
+ }
+
+ if (positive_upp)
+ *positive_upp = positive_up;
+
+ if (positive_upp)
+ {
+ if (!positive_found)
+ {
+ /* Is there a "positive" attribute? */
+ ret = nc_inq_att(ncid, varid, CF_POSITIVE, &att_type_in, &att_len_in);
+ if (ret == NC_NOERR && att_len_in <= CF_POS_LEN + 1)
+ {
+ /* Get the contents of the attribute and see if it is "up" or
+ * "down". */
+ if ((ret = nc_get_att_text(ncid, varid, CF_POSITIVE, pos_in)))
+ return ret;
+ if (strncasecmp(pos_in, CF_DOWN, strlen(CF_DOWN)))
+ *positive_upp = 0;
+ else if (strncasecmp(pos_in, CF_UP, strlen(CF_UP)))
+ *positive_upp = 1;
+ else
+ return CF_EBADVALUE;
+ }
+ if (ret == NC_ENOTATT)
+ {
+ /* No "positive" attribute there. What should be done?
+ * According to the CF standards, assume down for pressure
+ * units, up otherwise. */
+ if (vnum < NPRES_UNITS)
+ *positive_upp = 0;
+ else
+ *positive_upp = 1;
+ }
+ }
+ }
+
+ /* Get the name. */
+ if ((ret = nc_inq_varname(ncid, varid, var_name)))
+ return ret;
+
+ /* Does the user want the name? */
+ if (name)
+ strcpy(name, var_name);
+
+ /* Now that we have our coordianate variable, let's find the
+ * associated dimension. It will have the same name. */
+ if ((ret = nc_inq_dimid(ncid, var_name, &dimid)))
+ return CF_ENODIM;
+
+ /* Does the user want the dimid? */
+ if (dimidp)
+ *dimidp = dimid;
+
+ /* Does the user want to know the length of this coordinate
+ * axis? */
+ if (lenp)
+ if ((ret = nc_inq_dimlen(ncid, dimid, lenp)))
+ return ret;
+ return CF_NOERR;
+}
+
+/* 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 *lat_dimidp, int *lat_varidp)
+{
+ return def_coord_var(ncid, CF_LATITUDE_NAME, len,
+ xtype, CF_LATITUDE_UNITS, CF_LATITUDE_AXIS,
+ 0, CF_LATITUDE_NAME, NULL,
+ NCCF_LATITUDE, lat_dimidp, lat_varidp);
+}
+
+/* Inquire about a latitude dimension and variable with all the CF
+ * recomended attribute accessories.*/
+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"};
+ return inq_coord_var(ncid, NLAT_UNITS, val, NULL, NULL, lenp, xtypep,
+ NULL, NULL, NULL, lat_dimidp, 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 *lon_dimidp, int *lon_varidp)
+{
+ return def_coord_var(ncid, CF_LONGITUDE_NAME, len,
+ xtype, CF_LONGITUDE_UNITS, CF_LONGITUDE_AXIS,
+ 0, CF_LONGITUDE_NAME, NULL,
+ NCCF_LONGITUDE, lon_dimidp, lon_varidp);
+}
+
+/* Inquire about a longitude dimension and variable with all the CF
+ * recomended attribute accessories.*/
+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"};
+ return inq_coord_var(ncid, NLON_UNITS, val, NULL, NULL, lenp, xtypep,
+ NULL, NULL, NULL, lon_dimidp, lon_varidp);
+}
+
+/* Define a verticle level coordinate variable and dimension. */
+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)
+{
+ return def_coord_var(ncid, name, len, xtype, units, CF_LEVEL_AXIS,
+ positive_up, standard_name, formula_terms,
+ cdm_axis_type, lvl_dimidp, 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 *lon_dimidp, int *lon_varidp)
+{
+ char val[NLEVEL_UNITS][CF_MAX_LEN] =
+ {"bar", "standard_atmosphere", "technical_atmosphere",
+ "inch_H2O_39F", "inch_H2O_60F", "inch_Hg_32F",
+ "inch_Hg_60F", "millimeter_Hg_0C", "footH2O", "cmHg",
+ "cmH2O", "Pa", "inch_Hg", "inch_hg", "inHg", "in_Hg",
+ "in_hg", "millimeter_Hg", "mmHg", "mm_Hg", "mm_hg",
+ "torr", "foot_H2O", "ftH2O", "psi", "ksi", "barie",
+ "at", "atmosphere", "atm", "barye", "level", "layer",
+ "sigma_level", "sigma"};
+
+ /* Find a coordinate var and dim with one of the units above. */
+ return inq_coord_var(ncid, NLEVEL_UNITS, val, NULL, name, lenp, xtypep,
+ ft_lenp, formula_terms, positive_upp, lon_dimidp,
+ lon_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 *time_dimidp, int *time_varidp)
+{
+ return def_coord_var(ncid, name, len, xtype, units, CF_TIME_AXIS, 0,
+ standard_name, NULL, NCCF_TIME, time_dimidp,
+ time_varidp);
+}
+
+/* Inquire about a vertical dimension and coordinate variable. */
+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"};
+
+ return inq_coord_var(ncid, NTIME_UNITS, val, NULL, NULL, lenp, xtypep, NULL,
+ NULL, NULL, time_dimidp, time_varidp);
+}
+
+/* Define one of the unitless vertical coordinate variables from
+ * appendix D of the CF document. */
+static int
+def_vert_var(int ncid, const char *name, nc_type xtype, size_t len,
+ int nterms, int *term_id, const char *ft_format,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ char formula_terms[CF_MAX_FT_LEN + 1];
+ char term_name[CF_MAX_FT_VARS][NC_MAX_NAME + 1];
+ int v;
+ int ret;
+
+ if (strlen(name) > NC_MAX_NAME)
+ return CF_EMAX_NAME;
+
+ /* Find names of the vars to put in formula terms.*/
+ for (v = 0; v < nterms; v++)
+ {
+ if (term_id[v] == -99)
+ strcpy(term_name[v], name);
+ else
+ if ((ret = nc_inq_varname(ncid, term_id[v], term_name[v])))
+ return ret;
+ }
+
+ /* Assemble the formula terms attribute, depending on how many
+ * terms are in use. */
+ switch (nterms)
+ {
+ case 1:
+ sprintf(formula_terms, ft_format, term_name[0]);
+ break;
+ case 2:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1]);
+ break;
+ case 3:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2]);
+ break;
+ case 4:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3]);
+ break;
+ case 5:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4]);
+ break;
+ case 6:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4], term_name[5]);
+ break;
+ case 7:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4], term_name[5],
+ term_name[6]);
+ break;
+ default:
+ return CF_EINVAL;
+ }
+
+ /* Create the coordinate variable and dimension with this
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_SIGMA, formula_terms, NCCF_GEOZ,
+ lvl_dimidp, lvl_varidp);
+}
+
+static int
+nccf_set_ft(int ncid, int varid, int nterms, int *ft_varids,
+ const char *ft_format)
+{
+ char formula_terms[CF_MAX_FT_LEN + 1];
+ char term_name[CF_MAX_FT_VARS][NC_MAX_NAME + 1];
+ int v;
+ int ret;
+
+ /* Find names of the vars to put in formula terms.*/
+ for (v = 0; v < nterms; v++)
+ if ((ret = nc_inq_varname(ncid, ft_varids[v], term_name[v])))
+ return ret;
+
+ /* Assemble the formula terms attribute, depending on how many
+ * terms are in use. */
+ switch (nterms)
+ {
+ case 1:
+ sprintf(formula_terms, ft_format, term_name[0]);
+ break;
+ case 2:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1]);
+ break;
+ case 3:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2]);
+ break;
+ case 4:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3]);
+ break;
+ case 5:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4]);
+ break;
+ case 6:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4], term_name[5]);
+ break;
+ case 7:
+ sprintf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4], term_name[5],
+ term_name[6]);
+ break;
+ default:
+ return CF_EINVAL;
+ }
+
+ /* Attatch the formula_terms attribute to the coordinate variable. */
+ if ((ret = nc_put_att_text(ncid, varid, CF_FORMULA_TERMS,
+ strlen(formula_terms) + 1, formula_terms)))
+ return ret;
+
+ return CF_NOERR;
+}
+
+/* Find out about one of the unitless vertical coordinates in appendix
+ * D of the CF document. */
+static int
+inq_vert_var(int ncid, const char *standard_name, int nterms,
+ const char *ft_format, int *termids, char *name,
+ nc_type *xtypep, size_t *lenp, int *lvl_dimidp,
+ int *lvl_varidp)
+{
+ char formula_terms[CF_MAX_FT_LEN + 1];
+ char term_name[FT_MAX_TERMS][CF_MAX_FT_LEN + 1];
+ size_t ft_len;
+ int t;
+ int ret;
+
+ /* Get some of the info, including the formula_terms attribute. */
+ if ((ret = inq_coord_var(ncid, 0, NULL, standard_name, name, lenp,
+ xtypep, &ft_len, formula_terms, NULL,
+ lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Was the formula_terms attribute too big? */
+ if (ft_len > CF_MAX_FT_LEN)
+ return CF_EMAXFT;
+
+ /* Parse the formula_terms attribute, depending on the number of
+ * terms in use. */
+ switch (nterms)
+ {
+ case 1:
+ if (sscanf(formula_terms, ft_format, term_name[0]) != nterms)
+ return CF_EBADFT;
+ break;
+ case 2:
+ if (sscanf(formula_terms, ft_format, term_name[0],
+ term_name[1]) != nterms)
+ return CF_EBADFT;
+ break;
+ case 3:
+ if (sscanf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2]) != nterms)
+ return CF_EBADFT;
+ break;
+ case 4:
+ if (sscanf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3]) != nterms)
+ return CF_EBADFT;
+ break;
+ case 5:
+ if (sscanf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4]) != nterms)
+ return CF_EBADFT;
+ break;
+ case 6:
+ if (sscanf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4],
+ term_name[5]) != nterms)
+ return CF_EBADFT;
+ break;
+ case 7:
+ if (sscanf(formula_terms, ft_format, term_name[0], term_name[1],
+ term_name[2], term_name[3], term_name[4], term_name[5],
+ term_name[6]) != nterms)
+ return CF_EBADFT;
+ break;
+ default:
+ return CF_EINVAL;
+ }
+
+ /* Convert the names of the terms into variable ids, and return
+ * them in the termids array. */
+ if (termids)
+ for (t = 0; t < nterms; t++)
+ if ((ret = nc_inq_varid(ncid, term_name[t], &termids[t])))
+ return ret;
+
+ return CF_NOERR;
+}
+
+/*
+ Atmosphere natural log pressure coordinate
+
+ standard_name = "atmosphere_ln_pressure_coordinate"
+
+ Definition:
+
+ p(k) = p0 * exp(-lev(k))
+
+ where p(k) is the pressure at gridpoint (k), p0 is a reference
+ pressure, lev(k) is the dimensionless coordinate at vertical gridpoint
+ (k).
+
+ The format for the formula_terms attribute is
+
+ formula_terms = "p0: var1 lev: var2"
+*/
+int
+nccf_def_lvl_atm_ln(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_ATM_LN, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+int
+nccf_def_ft_atm_ln(int ncid, int varid, int pref_varid)
+{
+ int ft_varids[FT_MAX_TERMS];
+
+ ft_varids[0] = pref_varid;
+
+ return nccf_set_ft(ncid, varid, FT_ATM_LN_TERMS, ft_varids, FT_ATM_LN_FORMAT);
+}
+
+/* Atmosphere natural log pressure coordinate. */
+int
+nccf_inq_lvl_atm_ln(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *pref_varidp, int *lvl_dimidp, int *lvl_varidp)
+{
+ int termids[FT_ATM_LN_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_ATM_LN, FT_ATM_LN_TERMS, FT_ATM_LN_FORMAT,
+ termids, name, xtypep, lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for atm_ln level coordinate formula terms. */
+ if (pref_varidp)
+ *pref_varidp = termids[0];
+
+ return CF_NOERR;
+}
+
+/* Create a unitless vertical dimension/variable from appendix D of
+ * the CF standard. */
+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)
+{
+ /* Must be a known level type... */
+ if (lvl_type < 0 || lvl_type >= CF_NUM_VERT)
+ return CF_EINVAL;
+
+ /* Do the deed! */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS, 0,
+ vert_std_name[lvl_type], NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+/* Define a vertical sigma coordinate dimension.
+ From the CF doc:
+
+ Atmosphere sigma coordinate:
+ float lev(lev) ;
+ lev:long_name = "sigma at layer midpoints" ;
+ lev:positive = "down" ;
+ lev:standard_name = "atmosphere_sigma_coordinate" ;
+ lev:formula_terms = "sigma: lev ps: PS ptop: PTOP" ;
+*/
+int
+nccf_def_lvl_sigma(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_SIGMA, NULL, NCCF_GEOZ, lvl_dimidp,
+ 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)
+{
+ int ft_varids[FT_MAX_TERMS];
+
+ ft_varids[0] = lvl_vid;
+ ft_varids[1] = ps_vid;
+ ft_varids[2] = p0_vid;
+ return nccf_set_ft(ncid, lvl_vid, FT_SIGMA_TERMS, ft_varids, FT_SIGMA_FORMAT);
+}
+
+int
+nccf_inq_lvl_vert(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *lvl_typep, int *lvl_dimidp, int *lvl_varidp)
+{
+ char dim_name[NC_MAX_NAME + 1];
+ int varid, d, ndims, v;
+ size_t name_len;
+ char standard_name[NC_MAX_NAME + 1], var_name[NC_MAX_NAME + 1];
+ size_t dim_len;
+ nc_type var_type;
+ int ret;
+
+ /* Loop thru vars in file to see if any has a standard name that
+ * matches one of the standard names of the appendix D vertical
+ * dimensions.*/
+ if ((ret = nc_inq_ndims(ncid, &ndims)))
+ return ret;
+ for (d = 0; d < ndims; d++)
+ {
+ /* Any var with same name as this dim? */
+ if ((ret = nc_inq_dimname(ncid, d, dim_name)))
+ return ret;
+ ret = nc_inq_varid(ncid, dim_name, &varid);
+ if (ret == NC_ENOTVAR)
+ continue;
+ else if (ret)
+ return ret;
+ else
+ {
+ /* Find length of standard_name attribute, if it exists. */
+ ret = nc_inq_attlen(ncid, varid, CF_STANDARD_NAME, &name_len);
+ if (ret == NC_ENOTATT)
+ continue;
+ else if (ret)
+ return ret;
+
+ /* If the name is not too long, read it in. */
+ if (name_len > NC_MAX_NAME)
+ return CF_EMAX_NAME;
+ if ((ret = nc_get_att_text(ncid, varid, CF_STANDARD_NAME, standard_name)))
+ return ret;
+
+ /* Compare the standard name to our list of unitless vert
+ * dimension standard names. */
+ for (v = 0; v < CF_NUM_VERT; v++)
+ {
+ if (!strncmp(vert_std_name[v], standard_name, strlen(vert_std_name[v])))
+ break;
+ }
+ if (v < CF_NUM_VERT)
+ break;
+ }
+ }
+
+ /* If we went thru all dimensions, I guess we didn't find a
+ * unitless vertical coordinate variable. Boo hoo! */
+ if (d == ndims)
+ return CF_ENOTFOUND;
+
+ /* Learn the type and name from the coordinate variable. */
+ if ((ret = nc_inq_var(ncid, v, var_name, &var_type, NULL, NULL, NULL)))
+ return ret;
+
+ /* Learn the length from the coordinate dimension. */
+ if ((ret = nc_inq_dim(ncid, d, NULL, &dim_len)))
+ return ret;
+
+ /* Give the user the results they are interested in. */
+ if (name)
+ strcpy(name, var_name);
+
+ if (xtypep)
+ *xtypep = var_type;
+
+ if (lenp)
+ *lenp = dim_len;
+
+ if (lvl_dimidp)
+ *lvl_dimidp = d;
+
+ if (lvl_typep)
+ *lvl_typep = v;
+
+ if (lvl_varidp)
+ *lvl_varidp = varid;
+
+ return CF_NOERR;
+}
+
+/* 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 *lvl_varidp)
+{
+ int termids[FT_SIGMA_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_SIGMA, FT_SIGMA_TERMS, FT_SIGMA_FORMAT,
+ termids, name, xtypep, lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for sigma level coordinate formula terms. */
+ if (ps_varidp)
+ *ps_varidp = termids[1];
+ if (ptop_varidp)
+ *ptop_varidp = termids[2];
+
+ return CF_NOERR;
+}
+
+/*
+ Atmosphere hybrid sigma pressure coordinate
+
+ standard_name = "atmosphere_hybrid_sigma_pressure_coordinate"
+
+ Definition:
+
+ p(n,k,j,i) = a(k)*p0 + b(k)*ps(n,j,i)
+
+ or
+
+ p(n,k,j,i) = ap(k) + b(k)*ps(n,j,i)
+
+ where p(n,k,j,i) is the pressure at gridpoint (n,k,j,i), a(k) or ap(k)
+ and b(k) are components of the hybrid coordinate at level k, p0 is a
+ reference pressure, and ps(n,j,i) is the surface pressure at
+ horizontal gridpoint (j,i) and time (n). The choice of whether a(k) or
+ ap(k) is used depends on model formulation; the former is a
+ dimensionless fraction, the latter a pressure value. In both
+ formulations, b(k) is a dimensionless fraction.
+
+ The format for the formula_terms attribute is
+
+ formula_terms = "a: var1 b: var2 ps: var3 p0: var4"
+
+ where a is replaced by ap if appropriate.
+
+ The hybrid sigma-pressure coordinate for level k is defined as
+ a(k)+b(k) or ap(k)/p0+b(k), as appropriate.
+
+*/
+int
+nccf_def_lvl_hybrid_sigma(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ /* Create the coordinate variable and dimension with no
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_HYBRID_SIGMA, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+/* Set the formula_terms atribute to contain all this information. */
+int
+nccf_def_ft_hybrid_sigma(int ncid, int lvl_vid, int a_vid, int b_vid, int ps_vid,
+ int p0_vid)
+{
+ int ft_varids[FT_MAX_TERMS];
+
+ ft_varids[0] = a_vid;
+ ft_varids[1] = b_vid;
+ ft_varids[2] = ps_vid;
+ ft_varids[3] = p0_vid;
+ return nccf_set_ft(ncid, lvl_vid, FT_HYBRID_SIGMA_TERMS, ft_varids,
+ FT_HYBRID_SIGMA_FORMAT);
+}
+
+/* #define CF_4D 4 */
+/* int */
+/* nccf_def_hybrid_sigma(int ncid, char names[CF_4D][NC_MAX_NAME+1], int *lens, */
+/* nc_type *types, int *dids, int *vids, int *term_vids) */
+/* { */
+/* return nccf_def_coord_system(ncid, CF_VERT_HYBRID_SIGMA, names, lens, types, time_units, */
+/* FT_HYBRID_SIGMA_TERMS, term_names, term_types, term_ndims, */
+/* term_dimids, did, vids, term_vids); */
+/* } */
+
+/* int */
+/* nccf_def_coord_system(int ncid, int vert_axis_type, char name[CF_4D][NC_MAX_NAME+1], */
+/* int *lens, nc_type *types, char *time_units, int nterms, */
+/* char *term_names, nc_type *term_types, int *term_ndims, */
+/* int *term_dimds, int *dids, int *vids, int *term_vids) */
+/* { */
+/* int t; */
+/* int ret; */
+
+/* /\* Create the latitude and longitude dimensions and variables, with */
+/* * appropriate attributes. *\/ */
+/* if ((ret = nccf_def_latitude(ncid, lens[0], types[0], &did[0], &vid[0]))) */
+/* return ret; */
+/* if ((ret = nccf_def_longitude(ncid, lens[1], types[1], &did[1], &vid[1]))) */
+/* return ret; */
+
+/* /\* Create the vertical axis dimension and variable. *\/ */
+/* if (def_coord_var(ncid, names[2], lens[2], types[2], NULL, CF_LEVEL_AXIS, */
+/* 0, vert_axis_type, NULL, NCCF_GEOZ, &did[2], &vid[2])) */
+/* return ret; */
+
+/* /\* Now define the time coordinate variable and dimension. *\/ */
+/* if ((ret = nccf_def_time(ncid, names[3], lens[3], types[3], time_units, */
+/* "time", &did[3], &vid[3]))) */
+/* return ret; */
+
+/* /\* Before we can set up the formula_terms attribute, we need to */
+/* * define some additional variables specific to this type of */
+/* * vertical dimension. *\/ */
+/* for (t = 0; t < nterms; t++) */
+/* { */
+/* if ((ret = nc_def_var(ncid, term_names[t], term_types[t], 1, did, &a_vid))) */
+/* return ret; */
+/* } */
+
+/* if ((ret = nc_def_var(ncid, "b", NC_FLOAT, 1, did, &b_vid))) */
+/* return ret; */
+/* if ((ret = nc_def_var(ncid, "ps", NC_FLOAT, 2, did, &ps_vid))) */
+/* return ret; */
+/* if ((ret = nc_def_var(ncid, "P0", NC_FLOAT, 0, NULL, &p0_vid))) */
+/* return ret; */
+
+/* if ((ret = nccf_def_ft_hybrid_sigma(ncid, lvl_vid, a_vid, b_vid, ps_vid, */
+/* p0_vid))) */
+/* return ret; */
+
+/* return CF_NOERR; */
+/* } */
+
+/* #define A_NDIMS 1 */
+/* #define B_NDIMS 1 */
+/* #define P0_NDIMS 0 */
+/* #define PS_NDIMS 3 */
+/* int */
+/* nccf_def_lvl_hybrid_sigma_full(int ncid, const char *name, nc_type xtype, size_t len, */
+/* const char *a_name, nc_type a_type, int *a_varid, const char *a_units, */
+/* const char *b_name, nc_type b_type, int *b_varid, const char *b_units, */
+/* const char *ps_name, nc_type ps_type, int *ps_varid, const char *ps_units, */
+/* const char *p0_name, nc_type p0_type, int *p0_varid, const char *p0_units, */
+/* int *lvl_dimidp, int *lvl_varidp) */
+/* { */
+/* int termids[FT_HYBRID_SIGMA_TERMS] = {a_varid, b_varid, ps_varid, p0_varid}; */
+/* int ret; */
+
+/* /\* Create the coordinate variable and dimension without */
+/* * formula_terms. *\/ */
+/* if ((ret = def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS, */
+/* 0, STD_SIGMA, NULL, NCCF_GEOZ, */
+/* lvl_dimidp, lvl_varidp))) */
+/* return ret; */
+
+/* if ((ret = nc_def_var(ncid, a_name, a_type, A_NDIMS, */
+
+/* } */
+
+/* Inquire about atmosphere 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 *lvl_varidp)
+{
+ int termids[FT_HYBRID_SIGMA_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_HYBRID_SIGMA, FT_HYBRID_SIGMA_TERMS,
+ FT_HYBRID_SIGMA_FORMAT, termids, name, xtypep,
+ lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for hybrid_sigma level coordinate formula terms. */
+ if (a_varidp)
+ *a_varidp = termids[0];
+ if (b_varidp)
+ *b_varidp = termids[1];
+ if (ps_varidp)
+ *ps_varidp = termids[2];
+ if (p0_varidp)
+ *p0_varidp = termids[3];
+
+ return CF_NOERR;
+}
+
+/* Atmosphere hybrid height coordinate
+
+ standard_name = "atmosphere_hybrid_height_coordinate"
+
+ Definition:
+ z(n,k,j,i) = a(k) + b(k)*orog(n,j,i)
+
+ where z(n,k,j,i) is the height above the geoid (approximately mean
+ sea level) at gridpoint (k,j,i) and time (n), orog(n,j,i) is the
+ height of the surface above the geoid at (j,i) and time (n), and
+ a(k) and b(k) are the coordinates which define hybrid height level
+ k. a(k) has the dimensions of height and b(k) is dimensionless.
+
+ The format for the formula_terms attribute is
+ formula_terms = "a: var1 b: var2 orog: var3"
+
+ There is no dimensionless hybrid height coordinate. The hybrid
+ height is best approximated as a(k) if a level-dependent constant
+ is needed.
+*/
+int
+nccf_def_lvl_hybrid_height(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ /* Create the coordinate variable and dimension with no
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_HYBRID_HEIGHT, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+int
+nccf_def_ft_hybrid_height(int ncid, int varid, int a_varid, int b_varid,
+ int orog_varid)
+{
+ int ft_varids[FT_HYBRID_HEIGHT_TERMS];
+
+ ft_varids[0] = a_varid;
+ ft_varids[1] = b_varid;
+ ft_varids[2] = orog_varid;
+ return nccf_set_ft(ncid, varid, FT_HYBRID_HEIGHT_TERMS, ft_varids,
+ FT_HYBRID_HEIGHT_FORMAT);
+}
+
+/* Inquire about atmosphere hybrid_height coordinate. */
+int
+nccf_inq_lvl_hybrid_height(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *a_varidp, int *b_varidp, int *orog_varidp,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ int termids[FT_HYBRID_HEIGHT_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_HYBRID_HEIGHT, FT_HYBRID_HEIGHT_TERMS,
+ FT_HYBRID_HEIGHT_FORMAT, termids, name, xtypep,
+ lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for hybrid_height level coordinate formula terms. */
+ if (a_varidp)
+ *a_varidp = termids[1];
+ if (b_varidp)
+ *b_varidp = termids[2];
+ if (orog_varidp)
+ *orog_varidp = termids[3];
+
+ return CF_NOERR;
+}
+
+/* Atmosphere smooth level vertical (SLEVE) coordinate
+
+ standard_name = "atmosphere_sleve_coordinate"
+
+ Definition:
+ z(n,k,j,i) = a(k)*ztop + b1(k)*zsurf1(n,j,i) + b2(k)*zsurf2(n,j,i)
+
+ where z(n,k,j,i) is the height above the geoid (approximately mean
+ sea level) at gridpoint (k,j,i) and time (n), ztop is the height of
+ the top of the model, and a(k), b1(k) and b2(k) are the
+ dimensionless coordinates which define hybrid height level
+ k. zsurf1(n,j,i) and zsurf2(n,j,i) are respectively the large and
+ small scale parts of the topography. See Schaer et al [SCH02] for
+ details.
+
+ The format for the formula_terms attribute is
+
+ formula_terms = "a: var1 b1: var2 b2: var3 ztop: var4 zsurf1: var5
+ zsurf2: var6"
+
+ The hybrid height coordinate for level k is defined as a(k)*ztop.
+*/
+int
+nccf_def_lvl_sleve(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ /* Create the coordinate variable and dimension with no
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_SLEVE, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+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)
+{
+ int ft_varids[FT_SLEVE_TERMS];
+
+ ft_varids[0] = a_varid;
+ ft_varids[1] = b1_varid;
+ ft_varids[2] = b2_varid;
+ ft_varids[3] = ztop_varid;
+ ft_varids[4] = zsurf1_varid;
+ ft_varids[5] = zsurf2_varid;
+ return nccf_set_ft(ncid, varid, FT_SLEVE_TERMS, ft_varids, FT_SLEVE_FORMAT);
+}
+
+/* Inquire about atmosphere sleve coordinate. */
+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)
+{
+ int termids[FT_SLEVE_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_SLEVE, FT_SLEVE_TERMS, FT_SLEVE_FORMAT,
+ termids, name, xtypep, lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for sleve level coordinate formula terms. */
+ if (a_varidp)
+ *a_varidp = termids[0];
+ if (b1_varidp)
+ *b1_varidp = termids[1];
+ if (b2_varidp)
+ *b2_varidp = termids[2];
+ if (ztop_varidp)
+ *ztop_varidp = termids[3];
+ if (zsurf1_varidp)
+ *zsurf1_varidp = termids[4];
+ if (zsurf2_varidp)
+ *zsurf2_varidp = termids[5];
+
+ return CF_NOERR;
+}
+
+/* Ocean sigma coordinate
+
+ standard_name = "ocean_sigma_coordinate"
+
+ Definition:
+ z(n,k,j,i) = eta(n,j,i) + sigma(k) * (depth(j,i)+eta(n,j,i))
+
+ where z(n,k,j,i) is height, positive upwards, relative to ocean
+ datum (e.g. mean sea level) at gridpoint (n,k,j,i), eta(n,j,i) is
+ the height of the ocean surface, positive upwards, relative to
+ ocean datum at gridpoint (n,j,i), sigma(k) is the dimensionless
+ coordinate at vertical gridpoint (k), and depth(j,i) is the
+ distance from ocean datum to sea floor (positive value) at
+ horizontal gridpoint (j,i).
+
+ The format for the formula_terms attribute is
+ formula_terms = "sigma: var1 eta: var2 depth: var3"
+*/
+int
+nccf_def_lvl_ocean_sigma(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ /* Create the coordinate variable and dimension with no
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_OCEAN_SIGMA, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+int
+nccf_def_ft_ocean_sigma(int ncid, int varid, int eta_varid, int depth_varid)
+{
+ int ft_varids[FT_OCEAN_SIGMA_TERMS];
+
+ ft_varids[0] = varid;
+ ft_varids[1] = eta_varid;
+ ft_varids[2] = depth_varid;
+ return nccf_set_ft(ncid, varid, FT_OCEAN_SIGMA_TERMS, ft_varids,
+ FT_OCEAN_SIGMA_FORMAT);
+}
+
+/* Inquire about atmosphere ocean_sigma coordinate. */
+int
+nccf_inq_lvl_ocean_sigma(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *lvl_dimidp,
+ int *lvl_varidp)
+{
+ int termids[FT_OCEAN_SIGMA_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_OCEAN_SIGMA, FT_OCEAN_SIGMA_TERMS, FT_OCEAN_SIGMA_FORMAT,
+ termids, name, xtypep, lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for ocean_sigma level coordinate formula terms. */
+ if (eta_varidp)
+ *eta_varidp = termids[1];
+ if (depth_varidp)
+ *depth_varidp = termids[2];
+
+ return CF_NOERR;
+}
+
+/* Ocean s-coordinate
+
+ standard_name = "ocean_s_coordinate"
+
+ z(n,k,j,i) = eta(n,j,i)*(1+s(k)) + depth_c*s(k) +
+ (depth(j,i)-depth_c)*C(k)
+
+ C(k) = (1-b)*sinh(a*s(k))/sinh(a) +
+ b*[tanh(a*(s(k)+0.5))/(2*tanh(0.5*a)) - 0.5]
+
+ where z(n,k,j,i) is height, positive upwards, relative to ocean
+ datum (e.g. mean sea level) at gridpoint (n,k,j,i), eta(n,j,i) is
+ the height of the ocean surface, positive upwards, relative to
+ ocean datum at gridpoint (n,j,i), s(k) is the dimensionless
+ coordinate at vertical gridpoint (k), and depth(j,i) is the
+ distance from ocean datum to sea floor (positive value) at
+ horizontal gridpoint (j,i). The constants a, b, and depth_c control
+ the stretching.
+
+ The format for the formula_terms attribute is
+
+ formula_terms = "s: var1 eta: var2 depth: var3 a: var4 b: var5
+ depth_c: var6"
+*/
+int
+nccf_def_lvl_ocean_s(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ /* Create the coordinate variable and dimension with no
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_OCEAN_S, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+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 ft_varids[FT_OCEAN_S_TERMS];
+
+ ft_varids[0] = varid;
+ ft_varids[1] = eta_varid;
+ ft_varids[2] = depth_varid;
+ ft_varids[3] = a_varid;
+ ft_varids[4] = b_varid;
+ ft_varids[5] = depth_c_varid;
+ return nccf_set_ft(ncid, varid, FT_OCEAN_S_TERMS, ft_varids,
+ FT_OCEAN_S_FORMAT);
+}
+
+/* Inquire about atmosphere ocean_s coordinate. */
+int
+nccf_inq_lvl_ocean_s(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *a_varidp, int *b_varidp,
+ int *depth_c_varidp, int *lvl_dimidp, int *lvl_varidp)
+{
+ int termids[FT_OCEAN_S_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_OCEAN_S, FT_OCEAN_S_TERMS, FT_OCEAN_S_FORMAT,
+ termids, name, xtypep, lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for ocean_s level coordinate formula terms. */
+ if (eta_varidp)
+ *eta_varidp = termids[1];
+ if (depth_varidp)
+ *depth_varidp = termids[2];
+ if (a_varidp)
+ *a_varidp = termids[3];
+ if (b_varidp)
+ *b_varidp = termids[4];
+ if (depth_c_varidp)
+ *depth_c_varidp = termids[5];
+
+ return CF_NOERR;
+}
+
+/* Ocean sigma over z coordinate
+
+ standard_name = "ocean_sigma_z_coordinate"
+
+ for k <= nsigma:
+ z(n,k,j,i) = eta(n,j,i) + sigma(k)*(min(depth_c,depth(j,i))+eta(n,j,i))
+
+ for k > nsigma:
+ z(n,k,j,i) = zlev(k)
+
+ where z(n,k,j,i) is height, positive upwards, relative to ocean
+ datum (e.g. mean sea level) at gridpoint (n,k,j,i), eta(n,j,i) is
+ the height of the ocean surface, positive upwards, relative to
+ ocean datum at gridpoint (n,j,i), sigma(k) is the dimensionless
+ coordinate at vertical gridpoint (k) for k <= nsigma, and
+ depth(j,i) is the distance from ocean datum to sea floor (positive
+ value) at horizontal gridpoint (j,i). Above depth depth_c there are
+ nsigma layers.
+
+ The format for the formula_terms attribute is
+
+ formula_terms = "sigma: var1 eta: var2 depth: var3 depth_c: var4
+ nsigma: var5 zlev: var6"
+*/
+int
+nccf_def_lvl_ocean_sigma_z(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ /* Create the coordinate variable and dimension with no
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_OCEAN_SIGMA_Z, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+
+}
+
+int
+nccf_def_ft_ocean_sigma_z(int ncid, int varid, int eta_varid, int depth_varid,
+ int depth_c_varid, int nsigma_varid, int zlev_varid)
+{
+ int ft_varids[FT_OCEAN_SIGMA_Z_TERMS];
+
+ ft_varids[0] = varid;
+ ft_varids[1] = eta_varid;
+ ft_varids[2] = depth_varid;
+ ft_varids[3] = depth_c_varid;
+ ft_varids[4] = nsigma_varid;
+ ft_varids[5] = zlev_varid;
+ return nccf_set_ft(ncid, varid, FT_OCEAN_SIGMA_Z_TERMS, ft_varids,
+ FT_OCEAN_SIGMA_Z_FORMAT);
+}
+
+/* Inquire about atmosphere ocean_sigma_z coordinate. */
+int
+nccf_inq_lvl_ocean_sigma_z(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *depth_c_varidp,
+ int *nsigma_varidp, int *zlev_varidp, int *lvl_dimidp,
+ int *lvl_varidp)
+{
+ int termids[FT_OCEAN_SIGMA_Z_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_OCEAN_SIGMA_Z, FT_OCEAN_SIGMA_Z_TERMS,
+ FT_OCEAN_SIGMA_Z_FORMAT, termids, name, xtypep,
+ lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for ocean_sigma_z level coordinate formula terms. */
+ if (eta_varidp)
+ *eta_varidp = termids[1];
+ if (depth_varidp)
+ *depth_varidp = termids[2];
+ if (depth_c_varidp)
+ *depth_c_varidp = termids[3];
+ if (nsigma_varidp)
+ *nsigma_varidp = termids[4];
+ if (zlev_varidp)
+ *zlev_varidp = termids[5];
+
+ return CF_NOERR;
+}
+
+/*
+ Ocean double sigma coordinate
+
+ standard_name = "ocean_double_sigma_coordinate"
+
+ Definition:
+
+ for k <= k_c
+
+ z(k,j,i)= sigma(k)*f(j,i)
+
+ for k > k_c
+
+ z(k,j,i)= f(j,i) + (sigma(k)-1)*(depth(j,i)-f(j,i))
+
+ f(j,i)= 0.5*(z1+ z2) + 0.5*(z1-z2)* tanh(2*a/(z1-z2)*(depth(j,i)-href))
+
+ where z(k,j,i) is height, positive upwards, relative to ocean datum
+ (e.g. mean sea level) at gridpoint (k,j,i), sigma(k) is the
+ dimensionless coordinate at vertical gridpoint (k) for k <= k_c, and
+ depth(j,i) is the distance from ocean datum to sea floor (positive
+ value) at horizontal gridpoint (j,i). z1, z2, a, and href are
+ constants.
+
+ The format for the formula_terms attribute is:
+
+ formula_terms = "sigma: var1 depth: var2 z1: var3 z2: var4 a: var5
+ href: var6 k_c: var7"
+*/
+
+int
+nccf_def_lvl_ocean_dbl_sigma(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ /* Create the coordinate variable and dimension with no
+ * formula_terms. */
+ return def_coord_var(ncid, name, len, xtype, NULL, CF_LEVEL_AXIS,
+ 0, STD_OCEAN_DBL_SIGMA, NULL, NCCF_GEOZ, lvl_dimidp,
+ lvl_varidp);
+}
+
+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)
+{
+ int ft_varids[FT_OCEAN_DBL_SIGMA_TERMS];
+
+ ft_varids[0] = varid;
+ ft_varids[1] = depth_varid;
+ ft_varids[2] = z1_varid;
+ ft_varids[3] = z2_varid;
+ ft_varids[4] = a_varid;
+ ft_varids[5] = href_varid;
+ ft_varids[6] = k_c_varid;
+ return nccf_set_ft(ncid, varid, FT_OCEAN_DBL_SIGMA_TERMS, ft_varids,
+ FT_OCEAN_DBL_SIGMA_FORMAT);
+}
+
+/* Inquire about atmosphere ocean_dbl_sigma coordinate. */
+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 *href_varidp, int *k_c_varidp,
+ int *lvl_dimidp, int *lvl_varidp)
+{
+ int termids[FT_OCEAN_DBL_SIGMA_TERMS];
+ int ret;
+
+ /* Get most of the info from inq_vert_var. */
+ if ((ret = inq_vert_var(ncid, STD_OCEAN_DBL_SIGMA, FT_OCEAN_DBL_SIGMA_TERMS,
+ FT_OCEAN_DBL_SIGMA_FORMAT, termids, name, xtypep,
+ lenp, lvl_dimidp, lvl_varidp)))
+ return ret;
+
+ /* Pull out the varids for ocean_dbl_sigma level coordinate formula
+ * terms. */
+ if (depth_varidp)
+ *depth_varidp = termids[1];
+ if (z1_varidp)
+ *z1_varidp = termids[2];
+ if (z2_varidp)
+ *z2_varidp = termids[3];
+ if (a_varidp)
+ *a_varidp = termids[4];
+ if (href_varidp)
+ *href_varidp = termids[5];
+ if (k_c_varidp)
+ *k_c_varidp = termids[6];
+
+ return CF_NOERR;
+}
+
diff --git a/src/cferror.c b/src/cferror.c
new file mode 100644
index 0000000..808c23c
--- /dev/null
+++ b/src/cferror.c
@@ -0,0 +1,80 @@
+/*
+ Copyright 2007, University Corporation for Atmospheric Research. See
+ COPYRIGHT file for copying and redistribution conditions.
+
+ This file is part of the NetCDF CF Library.
+
+ This file handles errors and logging.
+
+ Ed Hartnett, 5/22/07
+
+ $Id: cferror.c,v 1.1 2007/05/22 14:40:33 ed Exp $
+*/
+
+#include <config.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <cferror.h>
+#include <assert.h>
+
+/* This contents of this file get skipped if LOGGING is not defined
+ * during compile. */
+#ifdef LOGGING
+
+/* This is the severity level of messages which will be logged. Use
+ severity 0 for errors, 1 for important log messages, 2 for less
+ important, etc. */
+int cf_log_level = -1;
+
+/* This function prints out a message, if the severity of the message
+ is lower than the global cf_log_level. To use it, do something like
+ this:
+
+ cf_log(0, "this computer will explode in %d seconds", i);
+
+ After the first arg (the severity), use the rest like a normal
+ printf statement. Output will appear on stdout.
+
+ This function is heavily based on the function in section 15.5 of
+ the C FAQ. */
+void cf_log(int severity, const char *fmt, ...)
+{
+ va_list argp;
+ int t;
+
+ /* If the severity is greater than the log level, we don' care to
+ print this message. */
+ if (severity > cf_log_level)
+ return;
+
+ /* If the severity is zero, this is an error. Otherwise insert that
+ many tabs before the message. */
+ if (!severity)
+ fprintf(stdout, "ERROR: ");
+ for (t=0; t<severity; t++)
+ fprintf(stdout, "\t");
+
+ /* Print out the variable list of args with vprintf. */
+ va_start(argp, fmt);
+ vfprintf(stdout, fmt, argp);
+ va_end(argp);
+
+ /* Put on a final linefeed. */
+ fprintf(stdout, "\n");
+ fflush(stdout);
+}
+
+/* Use this to set the global log level. Set it to CF_TURN_OFF_LOGGING
+ (-1) to turn off all logging. Set it to 0 to show only errors, and
+ to higher numbers to show more and more logging details. */
+int
+cf_set_log_level(int new_level)
+{
+ /* Now remember the new level. */
+ cf_log_level = new_level;
+ LOG((4, "log_level changed to %d", cf_log_level));
+ return 0;
+}
+
+#endif /* LOGGING */
diff --git a/src/cferror.h b/src/cferror.h
new file mode 100644
index 0000000..8cb6af8
--- /dev/null
+++ b/src/cferror.h
@@ -0,0 +1,37 @@
+/*
+ Copyright 2007, University Corporation for Atmospheric Research. See
+ COPYRIGHT file for copying and redistribution conditions.
+
+ This file is part of the NetCDF CF Library.
+
+ This file handles errors and logging.
+
+ Ed Hartnett, 5/22/07
+*/
+
+#ifndef _CFERROR_
+#define _CFERROR_
+
+#include <config.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#ifdef LOGGING
+
+/* To log something... */
+void cf_log(int severity, const char *fmt, ...);
+#define LOG(e) cf_log e
+
+#else
+
+/* These definitions will be used unless LOGGING is defined. */
+#define LOG(e)
+#define cf_set_log_level(e)
+#endif
+
+#endif /* _CFERROR_ */
+
+
+
+
+
diff --git a/src/cffcvars.f90 b/src/cffcvars.f90
new file mode 100644
index 0000000..bc19a87
--- /dev/null
+++ b/src/cffcvars.f90
@@ -0,0 +1,85 @@
+module libcf
+ use iso_c_binding
+ implicit none
+
+ ! 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
+
+contains
+
+ ! These functions are the new libcf F90 API.
+ function cf_def_file(ncid, convention, title, history)
+ use iso_c_binding
+ 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:: cf_def_file
+ integer(c_int):: c_ncid
+ character (len = 80) c_title, c_history
+
+ c_ncid = ncid
+ if (present(convention)) then
+ cf_def_file = nccf_def_convention(c_ncid)
+ if (cf_def_file .ne. 0) then
+ return
+ endif
+ endif
+ if (present(title)) then
+ c_title = title
+ c_title(len_trim(title) + 1:len_trim(title) + 1) = achar(0)
+ else
+ c_title = ''
+ endif
+ if (present(history)) then
+ c_history = history
+ c_history(len_trim(history) + 1:len_trim(history) + 1) = achar(0)
+ else
+ c_history = ''
+ endif
+ cf_def_file = nccf_def_file(ncid, c_title, c_history)
+
+ end function cf_def_file
+
+ function cf_inq_file(ncid, title, history)
+ use iso_c_binding
+ implicit none
+ integer, intent(in):: ncid
+ character (len = *), intent(inout):: title, history
+ 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
+
+end module libcf
diff --git a/src/cffiles.c b/src/cffiles.c
new file mode 100644
index 0000000..26f1811
--- /dev/null
+++ b/src/cffiles.c
@@ -0,0 +1,357 @@
+/*
+Copyright 2006, University Corporation for Atmospheric Research. See
+COPYRIGHT file for copying and redistribution conditions.
+
+This file is part of the NetCDF CF Library.
+
+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 $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <libcf_int.h>
+#include <netcdf.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+
+/* Get the version string for the CF Library (max length:
+ NC_MAX_NAME + 1). */
+int
+nccf_inq_libvers(char *version_string)
+{
+ char ver[NC_MAX_NAME + 1];
+
+ sprintf(ver, "libcf library version %s", VERSION);
+ if (version_string)
+ strcpy(version_string, ver);
+
+ return CF_NOERR;
+}
+
+/* Append string to a named global attribute. Create the attribute if
+ * it doesn't exist. */
+static int
+nccf_append_att(int ncid, const char *name, const char *string)
+{
+ char *att_str = NULL;
+ size_t len, new_len;
+ int ret;
+
+ /* Find out if there is an attribute of this name. */
+ ret = nc_inq_attlen(ncid, NC_GLOBAL, name, &len);
+
+ if (ret == NC_ENOTATT)
+ {
+ /* Create the attribute. I will null-terminate this
+ * attribute. */
+ if ((ret = nc_put_att_text(ncid, NC_GLOBAL, name,
+ strlen(string) + 1, string)))
+ return ret;
+ }
+ else if (ret == NC_NOERR)
+ {
+ /* The attribute already exists. Get memory to hold the existing
+ * att plus our version string. Add one for the space, and one
+ * for a terminating null. */
+ new_len = len + strlen(string) + 1;
+ if (!(att_str = malloc(new_len + 1)))
+ return CF_ENOMEM;
+
+ /* Get the existing attribute value. */
+ if ((ret = nc_get_att_text(ncid, NC_GLOBAL, name, att_str)))
+ BAIL(CF_ENETCDF);
+
+ /* If it's already in the string, our work is done.*/
+ if (strstr(att_str, string))
+ {
+ free(att_str);
+ return CF_NOERR;
+ }
+
+ /* Append our string to the existing att. */
+ att_str[new_len] = 0;
+ strcat(att_str, " ");
+ strcat(att_str, string);
+
+ /* Delete the existing attribute, so we can rewrite it. */
+ if ((ret = nc_del_att(ncid, NC_GLOBAL, name)))
+ BAIL(ret);
+
+ /* Rewrite the attribute with our string appended. */
+ if ((ret = nc_put_att_text(ncid, NC_GLOBAL, name,
+ strlen(att_str) + 1, att_str)))
+ BAIL(ret);
+ }
+
+ exit:
+ if (att_str)
+ free(att_str);
+ return ret;
+}
+
+/* From the CF 1.0 conventions:
+
+"We recommend that the NUG defined attribute Conventions be given the
+string value "CF-1.0" to identify datasets that conform to these
+conventions. */
+
+/* Mark a file with the CF-1.0 string in a Conventions attribute. */
+int
+nccf_def_convention(int ncid)
+{
+ return nccf_append_att(ncid, CF_CONVENTIONS, CF_CONVENTION_STRING);
+}
+
+int
+nccf_inq_convention(int ncid, int *cf_convention)
+{
+ size_t len, new_len;
+ char *existing_att = NULL;
+ int ret = CF_NOERR;
+
+ /* Find out if there is a conventions attribute. */
+ ret = nc_inq_attlen(ncid, NC_GLOBAL, CF_CONVENTIONS, &len);
+
+ if (ret == NC_NOERR)
+ {
+ /* Get memory to hold the existing att plus our version
+ * string. */
+ new_len = len + strlen(CF_CONVENTION_STRING) + 1;
+ if (!(existing_att = malloc(new_len)))
+ return CF_ENOMEM;
+
+ /* Get the existing att. */
+ if ((ret = nc_get_att_text(ncid, NC_GLOBAL, CF_CONVENTIONS,
+ existing_att)))
+ BAIL(CF_ENETCDF);
+
+ /* If it's already in the string, our work is done.*/
+ if (strstr(existing_att, CF_CONVENTION_STRING))
+ {
+ if (cf_convention)
+ *cf_convention = 1;
+ ret = CF_NOERR;
+ }
+ }
+ else if (ret == NC_ENOTATT)
+ {
+ /* No conventions att means no cf conventions. ;-( But this is
+ * not an error. */
+ if (cf_convention)
+ *cf_convention = 0;
+ ret = NC_NOERR;
+ }
+ else
+ BAIL(CF_ENETCDF);
+
+ exit:
+ if (existing_att)
+ free(existing_att);
+ return ret;
+}
+
+
+/* From the CF 1.0 conventions:
+
+"The general description of a file's contents should be contained in
+the following attributes: title, history, institution, source, comment
+and references (2.6.2). For backwards compatibility with COARDS none
+of these attributes is required, but their use is recommended to
+provide human readable documentation of the file contents."
+*/
+
+/* Add CF_recomended attributes to a file. Any NULLs will cause the
+ * cooresponding attribute to not be written. */
+int
+nccf_def_file(int ncid, const char *title, const char *history)
+{
+ int ret;
+
+ /* Make sure the file is labled with "CF-1.0" in a Conventions
+ * attribute. */
+ if ((ret = nccf_def_convention(ncid)))
+ return ret;
+
+ /* If title already exists this will return an error. */
+ if (title)
+ if ((ret = nc_put_att_text(ncid, NC_GLOBAL, CF_TITLE,
+ strlen(title) + 1, title)))
+ return ret;
+
+ /* This will append to the history attribute, creating it if
+ * needed. */
+ if (history)
+ ret = nccf_add_history(ncid, history);
+
+ return ret;
+}
+
+
+/* Append to the global "history" attribute, with a timestamp. Create
+ * the attribute if it does not exist. */
+#define NCCF_MAX_TIMESTAMP_LEN 35
+int
+nccf_add_history(int ncid, const char *history)
+{
+ time_t now;
+ char *hist_str;
+ char timestamp[NCCF_MAX_TIMESTAMP_LEN + 1];
+ struct tm *timptr;
+ int ret;
+
+ if (!history)
+ return NC_NOERR;
+
+ /* Get the date and time. */
+ time(&now);
+ if (!(timptr = localtime(&now)))
+ return CF_ETIME;
+ if (!strftime(timestamp, NCCF_MAX_TIMESTAMP_LEN, "%x %X", timptr))
+ return CF_ETIME;
+
+ /* Allocate space for this string, with the time prepended. */
+ if (!(hist_str = malloc(strlen(history) + strlen(timestamp) + 2)))
+ return CF_ENOMEM;
+
+ /* Create a string with the time and then the user's history
+ * comment. */
+ sprintf(hist_str, "%s %s\n", timestamp, history);
+
+ /* Now append that to the existing history att, or create one. */
+ ret = nccf_append_att(ncid, CF_HISTORY, hist_str);
+
+ /* Free our memory. */
+ free(hist_str);
+
+ return ret;
+}
+
+/* Read the CF annotations. Recall that in C, strlens do not include
+ * the null terminator. To get the lengths before the strings (in
+ * order to allocatate) pass NULL for any or all strngs and the
+ * lengths will be returned. Then call the funtion again after
+ * allocating memory.
+
+ * The CF version is guarenteed to be less than NC_MAX_NAME.
+
+ * Any of these pointer args may be NULL, in which case it will be
+ * ignored.
+*/
+int
+nccf_inq_file(int ncid, size_t *title_lenp, char *title,
+ size_t *history_lenp, char *history)
+{
+ int ret;
+
+ /* Find length of title. */
+ if (title_lenp)
+ if ((ret = nc_inq_attlen(ncid, NC_GLOBAL, CF_TITLE, title_lenp)))
+ return ret;
+
+ /* Get title. */
+ if (title)
+ if ((ret = nc_get_att_text(ncid, NC_GLOBAL, CF_TITLE, title)))
+ return ret;
+
+ /* Find length of history. */
+ if (history_lenp)
+ if ((ret = nc_inq_attlen(ncid, NC_GLOBAL, CF_HISTORY, history_lenp)))
+ return ret;
+
+ /* Get history. */
+ if (history)
+ if ((ret = nc_get_att_text(ncid, NC_GLOBAL, CF_HISTORY, history)))
+ return ret;
+
+ return NC_NOERR;
+
+}
+/* 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,
+ const char *references)
+{
+ int ret;
+
+ if (institution)
+ if ((ret = nc_put_att_text(ncid, varid, CF_INSTITUTION,
+ strlen(institution) + 1, institution)))
+ return ret;
+
+ if (source)
+ if ((ret = nc_put_att_text(ncid, varid, CF_SOURCE,
+ strlen(source) + 1, source)))
+ return ret;
+
+ if (comment)
+ if ((ret = nc_put_att_text(ncid, varid, CF_COMMENT,
+ strlen(comment) + 1, comment)))
+ return ret;
+
+ if (references)
+ if ((ret = nc_put_att_text(ncid, varid, CF_REFERENCES,
+ strlen(references) + 1, references)))
+ return ret;
+
+ return CF_NOERR;
+}
+
+/* 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 *references_lenp, char *references)
+{
+ int ret;
+
+ if (institution_lenp)
+ if ((ret = nc_inq_attlen(ncid, varid, CF_INSTITUTION,
+ institution_lenp)))
+ return ret;
+
+ if (institution)
+ if ((ret = nc_get_att_text(ncid, varid, CF_INSTITUTION,
+ institution)))
+ return ret;
+
+ if (source_lenp)
+ if ((ret = nc_inq_attlen(ncid, varid, CF_SOURCE,
+ source_lenp)))
+ return ret;
+
+ if (source)
+ if ((ret = nc_get_att_text(ncid, varid, CF_SOURCE,
+ source)))
+ return ret;
+
+ if (comment_lenp)
+ if ((ret = nc_inq_attlen(ncid, varid, CF_COMMENT,
+ comment_lenp)))
+ return ret;
+
+ if (comment)
+ if ((ret = nc_get_att_text(ncid, varid, CF_COMMENT,
+ comment)))
+ return ret;
+
+ if (references_lenp)
+ if ((ret = nc_inq_attlen(ncid, varid, CF_REFERENCES,
+ references_lenp)))
+ return ret;
+
+ if (references)
+ if ((ret = nc_get_att_text(ncid, varid, CF_REFERENCES,
+ references)))
+ return ret;
+
+ return NC_NOERR;
+}
+
diff --git a/src/cfsubsets.c b/src/cfsubsets.c
new file mode 100644
index 0000000..a2bdafd
--- /dev/null
+++ b/src/cfsubsets.c
@@ -0,0 +1,265 @@
+/*
+ Copyright 2006, University Corporation for Atmospheric Research. See
+ COPYRIGHT file for copying and redistribution conditions.
+
+ This file is part of the NetCDF CF Library.
+
+ This file handles the libcf subsetting.
+
+ Ed Hartnett, 5/1/7
+
+ $Id: cfsubsets.c,v 1.7 2007/05/22 14:40:50 ed Exp $
+*/
+
+#include <config.h>
+#include <cferror.h>
+#include <libcf.h>
+#include <libcf_int.h>
+#include <netcdf.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#define NDIMS 4
+#define TIME 0
+#define LVL 1
+#define LON 2
+#define LAT 3
+#define START 0
+#define END 1
+#define UNSET -1
+#define MAX_DIMS 7
+
+static int
+find_coord_idx(int ncid, int vid, size_t len, float *range, int *nidxp,
+ size_t *startp, size_t *endp)
+{
+ int i;
+ float *coord;
+ int start = UNSET, end = UNSET, nidx;
+ int ret;
+
+ if (!range)
+ {
+ /* If lat range are not provided, take all lats. */
+ nidx = len;
+ start = 0;
+ end = len - 1;
+ }
+ else
+ {
+ /* The end must be greater than or equal to the start. */
+ if (range[END] < range[START])
+ return CF_EBADRANGE;
+
+ /* Get memory for the coordinate data. */
+ if (!(coord = malloc(sizeof(float) * len)))
+ return CF_ENOMEM;
+
+ /* Open the coordinate varid and learn the values. */
+ if ((ret = nc_get_var_float(ncid, vid, coord)))
+ {
+ free(coord);
+ return ret;
+ }
+
+ /* Is this increasing or decreasing? */
+ if (len > 1 && coord[0] < coord[1])
+ {
+ /* Increasing coord. */
+ /* Find the start and end indexes. */
+ LOG((1, "range: %f %f", range[0], range[1]));
+ for (i = 0; i < len; i++)
+ {
+ LOG((3, "coord[%d]=%f", i, coord[i]));
+ if (start == UNSET && coord[i] >= range[START] &&
+ coord[i] <= range[END])
+ start = i;
+
+ if (start != UNSET)
+ {
+ if (coord[i] == range[END])
+ {
+ end = i;
+ break;
+ }
+ else if (coord[i] > range[END])
+ {
+ end = i - 1;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ /* Decreasing coord. */
+ /* Find the start and end indexes. */
+ LOG((1, "range: %f %f", range[0], range[1]));
+ for (i = 0; i < len; i++)
+ {
+ LOG((3, "coord[%d]=%f", i, coord[i]));
+ if (start == UNSET && coord[i] >= range[START] &&
+ coord[i] <= range[END])
+ start = i;
+
+ if (start != UNSET && coord[i] == range[START])
+ {
+ end = i;
+ break;
+ }
+ }
+ }
+ LOG((1, "start %d end %d", start, end));
+
+ /* If start is unset, no data are in the range. If we found a
+ * start but not an end, take all the data we can get. */
+ if (start == UNSET)
+ nidx = 0;
+ else if (end == UNSET)
+ {
+ end = len - 1;
+ nidx = abs(abs(end) - abs(start)) + 1;
+ }
+ else
+ nidx = abs(abs(end) - abs(start)) + 1;
+ free(coord);
+ }
+
+ if (startp)
+ *startp = start;
+ if (endp)
+ *endp = end;
+ if (nidxp)
+ *nidxp = nidx;
+
+ return CF_NOERR;
+}
+
+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)
+{
+ nc_type xtype[NDIMS];
+ char name[NDIMS][NC_MAX_NAME];
+ int did[NDIMS], vid[NDIMS];
+ size_t len[NDIMS];
+ size_t start[NDIMS], end[NDIMS];
+ int ndims, dimids[MAX_DIMS];
+ size_t dstart[NDIMS], dcount[NDIMS];
+ int num[NDIMS];
+ int found_lvl = 0, found_time = 0;
+ int d;
+ int ret;
+
+ /* Get information about each coordinate axis. */
+ if ((ret = nccf_inq_latitude(ncid, &len[LAT], &xtype[LAT], &did[LAT], &vid[LAT])))
+ return ret;
+ if ((ret = nccf_inq_longitude(ncid, &len[LON], &xtype[LON], &did[LON], &vid[LON])))
+ return ret;
+
+ /* Get the vertical level info, if there is one. */
+ ret = nccf_inq_lvl(ncid, name[LVL], &len[LVL], &xtype[LVL], NULL, NULL, NULL,
+ &did[LVL], &vid[LVL]);
+ if (ret && ret != CF_ENOTFOUND)
+ return ret;
+ else if (ret == CF_NOERR)
+ found_lvl++;
+
+ /* Get the time info, if there is a time axis. */
+ ret = nccf_inq_time(ncid, name[TIME], &len[TIME], &xtype[TIME], &did[TIME],
+ &vid[TIME]);
+ if (ret && ret != CF_ENOTFOUND)
+ return ret;
+ else if (ret == CF_NOERR)
+ found_time++;
+
+ /* Find the indixies along the latitude coordinate values to subset
+ * along this dimension. */
+ if ((ret = find_coord_idx(ncid, vid[LAT], len[LAT], lat_range, &num[LAT],
+ &start[LAT], &end[LAT])))
+ return ret;
+ if (nlat)
+ *nlat = num[LAT];
+
+ /* Find the indixies along the longitude coordinate values to subset
+ * along this dimension. */
+ if ((ret = find_coord_idx(ncid, vid[LON], len[LON], lon_range, &num[LON],
+ &start[LON], &end[LON])))
+ return ret;
+ if (nlon)
+ *nlon = num[LON];
+
+ /* If level indicies are not provided, take all levels. */
+/* if (!lvl_index) */
+/* num[LVL] = len[LVL]; */
+/* else */
+/* num[LVL] = 1; */
+/* if (nlvl) */
+/* *nlvl = num[LVL]; */
+
+ if (found_time && timestep >= len[TIME])
+ return CF_ERECTOOLARGE;
+
+ /* If the user wants the data, get it for him. */
+ if (lat_range && lon_range && data && num[LAT] && num[LON])
+ {
+ /* Find out about the dimensions of this data variable. */
+ if ((ret = nc_inq_varndims(ncid, varid, &ndims)))
+ return ret;
+ if (ndims > MAX_DIMS)
+ return CF_ENDIMS;
+ if ((ret = nc_inq_vardimid(ncid, varid, dimids)))
+ return ret;
+
+ /* Set the lat info. */
+ for (d = 0; d < ndims; d++)
+ if (dimids[d] == did[LAT])
+ break;
+ if (d == ndims)
+ return CF_ENODIM;
+ dstart[d] = start[LAT];
+ dcount[d] = num[LAT];
+
+ /* Set the lon info. */
+ for (d = 0; d < ndims; d++)
+ if (dimids[d] == did[LON])
+ break;
+ if (d == ndims)
+ return CF_ENODIM;
+ dstart[d] = start[LON];
+ dcount[d] = num[LON];
+
+ /* Set the level info. */
+ if (found_lvl)
+ {
+ for (d = 0; d < ndims; d++)
+ if (dimids[d] == did[LVL])
+ break;
+ if (d != ndims)
+ {
+ dstart[d] = lvl_index;
+ dcount[d] = 1;
+ }
+ }
+
+ /* Set the time info. */
+ if (found_time)
+ {
+ for (d = 0; d < ndims; d++)
+ if (dimids[d] == did[TIME])
+ break;
+ if (d != ndims)
+ {
+ dstart[d] = timestep;
+ dcount[d] = 1;
+ }
+ }
+
+ /* Now I've got everything needed to read a record of this data! */
+ if ((ret = nc_get_vara(ncid, varid, dstart, dcount, data)))
+ return ret;
+ }
+
+ return CF_NOERR;
+}
diff --git a/src/cfvars.c b/src/cfvars.c
new file mode 100644
index 0000000..e39ac5e
--- /dev/null
+++ b/src/cfvars.c
@@ -0,0 +1,321 @@
+/*
+Copyright 2006, University Corporation for Atmospheric Research. See
+COPYRIGHT file for copying and redistribution conditions.
+
+This file is part of the NetCDF CF Library.
+
+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 $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <libcf_int.h>
+#include <netcdf.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int nccf_parse_coords(int ncid, int varid, char *att_name, int *naxes,
+ int *axis_varids);
+
+/* From the CF conventions, 1.0:
+
+"Each variable in a netCDF file has an associated description which is
+provided by the attributes units, long_name, and standard_name. The
+units, and long_name attributes are defined in the NUG and the
+standard_name attribute is defined in this document."
+
+also
+
+"We wish to allow ... institution, source, references, and comment, to
+be either global or assigned to individual variables. When an
+attribute appears both globally and as a variable attribute, the
+variable's version has precedence."
+
+also
+
+"The value of the coordinates attribute is a blank separated list of
+the names of auxiliary coordinate variables."
+
+This function makes all of these optional.
+
+*/
+
+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)
+{
+ char coord_name[NC_MAX_NAME + 1];
+ char coords_str[CF_MAX_COORD_LEN + 1];
+ int c, ret;
+
+ /* Write units. */
+ if (units)
+ if ((ret = nc_put_att_text(ncid, varid, CF_UNITS,
+ strlen(units) + 1, units)))
+ return ret;
+
+ /* Write long_name. */
+ if (long_name)
+ if ((ret = nc_put_att_text(ncid, varid, CF_LONG_NAME,
+ strlen(long_name) + 1, long_name)))
+ return ret;
+
+ /* Write standard_name. */
+ if (standard_name)
+ if ((ret = nc_put_att_text(ncid, varid, CF_STANDARD_NAME,
+ strlen(standard_name) + 1, standard_name)))
+ return ret;
+
+ /* Now add the "coordinates" atttribute, which holds a space
+ * separated list of auxilary coordinate variables. */
+ if (ncoord_vars)
+ {
+ if (ncoord_vars > CF_MAX_COORDS)
+ return CF_EMAXCOORDS;
+ if (!coord_varids)
+ return CF_EINVAL;
+ strcpy(coords_str, "");
+ for (c = 0; c < ncoord_vars; c++)
+ {
+ /* Find the names of this coordinate var. */
+ if ((ret = nc_inq_varname(ncid, coord_varids[c], coord_name)))
+ return ret;
+ strcat(coords_str, coord_name);
+ strcat(coords_str, " ");
+ }
+ if ((ret = nc_put_att_text(ncid, varid, CF_COORDINATES,
+ strlen(coords_str) + 1, coords_str)))
+ return ret;
+ }
+
+ return NC_NOERR;
+}
+
+/* Read the CF annotations. Recall that in C, strlens do not include
+ * the null terminator. To get the lengths before the strings (in
+ * order to allocatate) pass NULL for any or all strngs and the
+ * lengths will be returned. Then call the funtion again after
+ * allocating memory.
+ * Any of these pointer args may be NULL, in which case it will be
+ * ignored.
+*/
+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)
+{
+ int ret;
+
+ /* Read units length if desired. */
+ if (units_lenp)
+ if ((ret = nc_inq_attlen(ncid, varid, CF_UNITS, units_lenp)))
+ return ret;
+
+ /* Read units value if desired. */
+ if (units)
+ if ((ret = nc_get_att_text(ncid, varid, CF_UNITS, units)))
+ return ret;
+
+ if (long_name_lenp)
+ if ((ret = nc_inq_attlen(ncid, varid, CF_LONG_NAME,
+ long_name_lenp)))
+ return ret;
+
+ if (long_name)
+ if ((ret = nc_get_att_text(ncid, varid, CF_LONG_NAME, long_name)))
+ return ret;
+
+ if (standard_name_lenp)
+ if ((ret = nc_inq_attlen(ncid, varid, CF_STANDARD_NAME,
+ standard_name_lenp)))
+ return ret;
+
+ if (standard_name)
+ if ((ret = nc_get_att_text(ncid, varid, CF_STANDARD_NAME,
+ standard_name)))
+ 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)))
+ return ret;
+
+ return NC_NOERR;
+
+}
+
+/* Set attributes to define missing data information. */
+int
+nccf_def_var_missing(int ncid, int varid, const void *fill_value,
+ const void *valid_min, const void *valid_max)
+{
+ nc_type xtype;
+ int ret;
+
+ /* User must provide either both or neither of valid_min and
+ * valid_max. */
+ if ((valid_min && !valid_max) ||
+ (!valid_min && valid_max))
+ return CF_EMINMAX;
+
+ /* Get the variable type. */
+ if ((ret = nc_inq_vartype(ncid, varid, &xtype)))
+ return ret;
+
+ /* Write a fill value if the user provided one. */
+ if (fill_value)
+ if ((ret = nc_put_att(ncid, varid, CF_FILL_VALUE,
+ xtype, 1, fill_value)))
+ return ret;
+
+ /* Write a valid_min if the user provided one. */
+ if (valid_min)
+ if ((ret = nc_put_att(ncid, varid, CF_VALID_MIN,
+ xtype, 1, valid_min)))
+ return ret;
+
+ /* Write a valid_max value if the user provided one. */
+ if (valid_max)
+ if ((ret = nc_put_att(ncid, varid, CF_VALID_MAX,
+ xtype, 1, valid_max)))
+ return ret;
+
+ return NC_NOERR;
+}
+
+/* Return the default fill value of a netCDF-3 type. */
+static int
+nccf_get_default_missing(nc_type xtype, void *fill_value,
+ void *valid_min, void *valid_max)
+{
+ /* At the moment, only handle netCDF-3 types. */
+ switch(xtype)
+ {
+ case NC_BYTE:
+ if (fill_value)
+ *((signed char *)fill_value) = NC_FILL_BYTE;
+ if (valid_min)
+ *((signed char *)valid_min) = CF_BYTE_MIN;
+ if (valid_max)
+ *((signed char *)valid_max) = CF_BYTE_MAX;
+ break;
+ case NC_CHAR:
+ if (fill_value)
+ *((char *)fill_value) = NC_FILL_CHAR;
+ if (valid_min)
+ *((char *)valid_min) = CF_CHAR_MIN;
+ if (valid_max)
+ *((char *)valid_max) = CF_CHAR_MAX;
+ break;
+ case NC_SHORT:
+ if (fill_value)
+ *((short *)fill_value) = NC_FILL_SHORT;
+ if (valid_min)
+ *((short *)valid_min) = CF_SHORT_MIN;
+ if (valid_max)
+ *((short *)valid_max) = CF_SHORT_MAX;
+ break;
+ case NC_INT:
+ if (fill_value)
+ *((int *)fill_value) = NC_FILL_INT;
+ if (valid_min)
+ *((int *)valid_min) = CF_INT_MIN;
+ if (valid_max)
+ *((int *)valid_max) = CF_INT_MAX;
+ break;
+ case NC_FLOAT:
+ if (fill_value)
+ *((float *)fill_value) = NC_FILL_FLOAT;
+ if (valid_min)
+ *((float *)valid_min) = CF_FLOAT_MIN;
+ if (valid_max)
+ *((float *)valid_max) = CF_FLOAT_MAX;
+ break;
+ case NC_DOUBLE:
+ if (fill_value)
+ *((double *)fill_value) = NC_FILL_DOUBLE;
+ if (valid_min)
+ *((double *)valid_min) = CF_DOUBLE_MIN;
+ if (valid_max)
+ *((double *)valid_max) = CF_DOUBLE_MAX;
+ break;
+ default:
+ return CF_EBADTYPE;
+ }
+
+ return NC_NOERR;
+}
+
+/* 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_value,
+ void *valid_min, void *valid_max)
+{
+ nc_type xtype;
+ int ret;
+
+ if ((ret = nc_inq_vartype(ncid, varid, &xtype)))
+ return ret;
+
+ /* Does the user want the fill value?*/
+ if (fill_value)
+ {
+ /* Get the value of the _FillValue att, if it is there. */
+ ret = nc_get_att(ncid, varid, CF_FILL_VALUE, fill_value);
+ if (ret == NC_ENOTATT)
+ {
+ /* No _FillValue att, so find the default fill value for this
+ * type. */
+ if ((ret = nccf_get_default_missing(xtype, fill_value, NULL, NULL)))
+ return ret;
+ }
+ else if (ret != NC_NOERR)
+ return ret;
+ }
+
+ /* Does the user want the fill value?*/
+ if (valid_min)
+ {
+ /* Get the value of the valid_min, if it is there. */
+ ret = nc_get_att(ncid, varid, CF_VALID_MIN, valid_min);
+ if (ret == NC_ENOTATT)
+ {
+ /* No _FillValue att, so find the default fill value for this
+ * type. */
+ if ((ret = nccf_get_default_missing(xtype, NULL, valid_min, NULL)))
+ return ret;
+ }
+ else if (ret != NC_NOERR)
+ return ret;
+ }
+
+ /* Does the user want the fill value?*/
+ if (valid_max)
+ {
+ /* Get the value of the _FillValue att, if it is there. */
+ ret = nc_get_att(ncid, varid, CF_VALID_MAX, valid_max);
+ if (ret == NC_ENOTATT)
+ {
+ /* No _FillValue att, so find the default fill value for this
+ * type. */
+ if ((ret = nccf_get_default_missing(xtype, NULL, NULL, valid_max)))
+ return ret;
+ }
+ else if (ret != NC_NOERR)
+ return ret;
+ }
+
+ return NC_NOERR;
+}
+
diff --git a/src/drscdf.h b/src/drscdf.h
new file mode 100644
index 0000000..d00bc8c
--- /dev/null
+++ b/src/drscdf.h
@@ -0,0 +1,275 @@
+/*
+ $Id: drscdf.h,v 1.1 2008/06/30 16:07:44 ed Exp $
+ $Log: drscdf.h,v $
+ Revision 1.1 2008/06/30 16:07:44 ed
+ Beginning merge of calandar stuff.
+
+ * Revision 2.8 1995/10/26 23:22:46 drach
+ * - Added automatic copy of dictionary to/from NSL, NSL version
+ *
+ * Revision 2.7 1995/03/30 00:50:34 drach
+ * Added disclaimer
+ *
+ * Revision 2.6 1995/01/30 19:14:22 drach
+ * Minor revisions
+ *
+ * Revision 2.5 1994/11/23 19:16:58 drach
+ * Added function declarations for K&R and ANSI C.
+ *
+ * Revision 2.4 1993/10/21 01:23:01 drach
+ * Changed name of sync options for consistency, added sync error.
+ *
+ * Revision 2.3 1993/10/20 17:16:29 drach
+ * Define autosync options.
+ *
+ * Revision 2.2 1993/07/14 22:30:30 drach
+ * Removed text after #endif, etc.
+ *
+ * Revision 2.1 1993/07/13 01:12:47 drach
+ * Merged Sun, Unicos, SGI, and HP versions.
+ *
+# Revision 2.3 1992/10/14 23:14:54 drach
+# Added putdic options
+#
+# Revision 2.2 1992/10/06 00:53:59 drach
+# Added putdic errors.
+#
+# Revision 2.1 1992/05/22 01:07:07 drach
+# removed drsmg (error messages structure)
+#
+# Revision 2.0 1992/03/07 00:12:24 drach
+# Entered into RCS
+#
+ Data Retrieval and Storage System
+
+**********************************************************************
+
+ DISCLAIMER
+
+ This software was prepared as an account of work sponsored by an
+ agency of the United States Government. Neither the United
+ States Government nor the University of California nor any of
+ their employees, makes any warranty, express or implied, or
+ assumes any liability or responsibility for the accuracy,
+ completeness, or usefulness of any information, apparatus,
+ product, or process disclosed, or represents that its use would
+ not infringe privately owned rights. Reference herein to any
+ specific commercial products, process, or service by trade name,
+ trademark, manufacturer, or otherwise, does not necessarily
+ constitute or imply its endorsement, recommendation, or favoring
+ by the United States Government or the University of California.
+ The views and opinions of authors expressed herein do not
+ necessarily state or reflect those of the United States
+ Government or the University of California, and shall not be
+ used for advertising or product endorsement purposes.
+
+**********************************************************************
+
+
+
+*/
+/*#######################################################################
+ * drscdf.h
+ *
+
+ *#######################################################################*/
+/* General definitions */
+#ifndef __drscdf_h
+#define __drscdf_h
+
+#define IDRS_NOVALUE 0
+#define IDRS_DEFAULT 0
+
+
+/* DimensionType */
+#define IDRS_EQUALLY_SPACED 1
+#define IDRS_UNEQUALLY_SPACED 2
+
+/* FileStatus */
+#define IDRS_READ 1
+#define IDRS_CREATE 2
+#define IDRS_EXTEND 3
+
+/* MachineName */
+#define IDRS_SUN 1
+#define IDRS_CRAY 2
+
+#ifdef cray
+
+#define IDRS_MACHINE IDRS_CRAY
+#define IDRS_BYTES_PER_WORD 8
+#define IDRS_NSL 8 /* Aslun flag: file is on NSL UniTree */
+#define IDRS_NOCOPY 16 /* Aslun flag: do not copy dictionary from NSL on open */
+#else
+#define IDRS_MACHINE IDRS_SUN
+#define IDRS_BYTES_PER_WORD 4
+
+#endif
+
+/* DRSVersion */
+/* DRS_VERSION is current version */
+/* DRS_MAXVERSION is max allowed version before version */
+/* is considered 'novalue' */
+#define DRS_VERSION 2.1
+#define DRS_MAXVERSION 10.0
+
+/* Inquiry operators (INQDICT) */
+#define IDRS_GETFIRSTVAR 1
+#define IDRS_GETNEXTVAR 2
+
+/* Standard argument lengths */
+#define IDRS_SOURCELEN 121
+#define IDRS_NAMELEN 17
+#define IDRS_TITLELEN 81
+#define IDRS_UNITSLEN 41
+#define IDRS_DATELEN 9
+#define IDRS_TIMELEN 9
+#define IDRS_TYPELEN 9
+
+#ifdef cray
+
+#define IDRS_FILENAMELEN 248
+#else
+#define IDRS_FILENAMELEN 1024
+
+#endif
+
+
+typedef char DRS_SOURCE[IDRS_SOURCELEN];
+typedef char DRS_NAME[IDRS_NAMELEN];
+typedef char DRS_TITLE[IDRS_TITLELEN];
+typedef char DRS_UNITS[IDRS_UNITSLEN];
+typedef char DRS_DATE[IDRS_DATELEN];
+typedef char DRS_TIME[IDRS_TIMELEN];
+typedef char DRS_TYPE[IDRS_TYPELEN];
+typedef char DRS_FILENAME[IDRS_FILENAMELEN];
+
+/* Cray-to-IEEE translation parameters */
+#define IDRS_LEFTHALFWORD 0
+#define IDRS_RIGHTHALFWORD 4
+
+/* ElementType */
+#define IDRS_I4 1
+#define IDRS_I8 2
+#define IDRS_IEEE_R4 3
+#define IDRS_CRAY_R8 4
+#define IDRS_ASCII 5
+#define IDRS_USER 6
+#ifndef __EXTENDED_DRS_DATATYPES
+#define __EXTENDED_DRS_DATATYPES
+#define IDRS_I1 7
+#define IDRS_I2 8
+#define IDRS_IEEE_R8 9
+#define IDRS_CRAY_R16 10
+#define IDRS_IEEE_R16 11
+#endif
+
+ /* Synchronization options */
+#define IDRS_SYNC_OFF 1
+#define IDRS_SYNC_ON 2
+
+/* Error reporting */
+#define IDRS_NOREPORT 1
+#define IDRS_FATAL 2
+#define IDRS_WARNING 3
+#define IDRS_INTERNAL 4
+
+/* Putdic options */
+#define IDRS_BLANKS_ARE_NULL 1
+#define IDRS_BLANKS_ARE_LITERAL 2
+
+/* Error definitions */
+#define IDRS_SUCCESS 0
+#define IDRS_NOMEMORY 1
+#define IDRS_BINFAILED 2002
+#define IDRS_BADLEN 3
+#define IDRS_NOMONO 4
+#define IDRS_NOCOMPARISON 2005
+#define IDRS_VDBNOTFOUND 6
+#define IDRS_BADDIM 7
+#define IDRS_NOTMONOTONE 8
+#define IDRS_DICTREADERROR 9
+#define IDRS_NODICTFILE 10
+#define IDRS_BADLU 11
+#define IDRS_BADTYPE 12
+#define IDRS_AMBIGUITYEXISTS 13
+#define IDRS_CANNOTADDDATA 14
+#define IDRS_DICTFULL 15
+#define IDRS_VERSION1FILE 1016
+#define IDRS_NEWFILEFORMAT 1017
+#define IDRS_CANNOTREADHEADER 18
+#define IDRS_CANNOTREADDATA 19
+#define IDRS_BADDIMNAME 20
+#define IDRS_TOOMANYFILES 21
+#define IDRS_CANNOTOPENDICT 22
+#define IDRS_CANNOTOPENDATA 23
+#define IDRS_BADSTATUS 24
+#define IDRS_BADDIMTYPE 25
+#define IDRS_INDEXHIGH 2026
+#define IDRS_INDEXLOW 2027
+#define IDRS_INDEXBETWEEN 2028
+#define IDRS_NORANGE 29
+#define IDRS_SAVEBUFOVERFLOW 30
+#define IDRS_BADERRLEVEL 31
+#define IDRS_ERROROUTOFRANGE 32
+#define IDRS_CANNOTWRITEHEADER 33
+#define IDRS_CANNOTWRITEDATA 34
+#define IDRS_BADCHARLEN 35
+#define IDRS_BADOPER 36
+#define IDRS_NOMOREVARS 1037
+#define IDRS_DICTALREADYOPEN 38
+#define IDRS_LOOKUPFAILED 2039
+#define IDRS_DICTWRITEERROR 40
+#define IDRS_DICTEXTENDERROR 41
+#define IDRS_DATEXTENDERROR 42
+#define IDRS_DICTRUNCATEERR 43
+#define IDRS_DATTRUNCATEERR 44
+#define IDRS_BADIEEEFP 45
+#define IDRS_BADCRAYFP 46
+#define IDRS_BADCRAYINT 47
+#define IDRS_CANNOTCONVERT 48
+#define IDRS_INEXACTMATCH 1049
+#define IDRS_DUPLICATEVAR 50
+#define IDRS_CANNOTWRITEDIC 51
+#define IDRS_BADSYNCOPT 52
+
+#undef PROTO
+#ifdef __STDC__
+#define PROTO(x) x
+#else
+#define PROTO(x) ()
+#endif
+
+extern int Aslun PROTO((int lud,char* dicfil,int lu,char* datfil,int istat));
+extern int Cllun PROTO((int lu));
+extern int Cluvdb PROTO((void));
+extern int Drstest PROTO((int ierr));
+extern int Getdat PROTO((int lu,void* a,int isize));
+extern int Getcdim PROTO((int idim,char* source,char* name,char* title,char* units,int* dtype,int reqlen,float* var,int* retlen));
+extern int GetcdimD PROTO((int idim,char* source,char* name,char* title,char* units,int* dtype,int reqlen,double* var,int* retlen));
+extern int Getedim PROTO((int n,char* dsrc,char* dna,char* dti,char* dun,int* dtype,int* idim,float* df,float* dl));
+extern int GetedimD PROTO((int n,char* dsrc,char* dna,char* dti,char* dun,int* dtype,int* idim,double* df,double* dl));
+extern int Getelemd PROTO((int* type,int* bpe));
+extern int Getname PROTO((char* source,char* name,char* title,char* units,char* date,char* time,char* typed,int* nd));
+extern int Getrge2 PROTO((int lu,int idim,double elem1,double elem2,int* ind1,int* ind2,float* dlow,float* dhigh));
+extern int Getslab PROTO((int lu,int rank,int* order,float* fe,float* le,float* cycle,void* data,int* datadim));
+extern int Getvdim PROTO((int idim,char* source,char* title,int reqlen,float* var,int* retlen));
+extern int Inqdict PROTO((int lu,int oper));
+extern int Inqlun PROTO((int lu,char* datafile,int* nvar,float* version));
+extern int Prdict PROTO((int lup,int lu));
+extern int Putdat PROTO((int lu,void* a));
+extern int Putdic PROTO((int lu, int iopt));
+extern int Putvdim PROTO((int lu,int len,float* dimvar,int* i1,int* i2));
+extern int Setdate PROTO((char* date,char* time));
+extern int Setdim PROTO((int n,char* dna,char* dun,int idim,double df,double dl));
+extern int Seterr PROTO((int ierrlun,int reportlevel));
+extern int Setname PROTO((char* source,char* name,char* title,char* units,char* typed));
+extern int Setrep PROTO((int irep));
+extern int Setvdim PROTO((int n,char* dso,char* dna,char* dti,char* dun,double df,double dl));
+#ifdef NSL_DRS
+extern int drsn2lcp PROTO((char* infile, char* outfile));
+extern int drsl2ncp PROTO((char* infile, char* outfile));
+#endif
+
+#endif
+
diff --git a/src/libcf.h b/src/libcf.h
new file mode 100644
index 0000000..cd47fe4
--- /dev/null
+++ b/src/libcf.h
@@ -0,0 +1,509 @@
+/*
+
+Copyright 2006, University Corporation for Atmospheric Research. See
+COPYRIGHT file for copying and redistribution conditions.
+
+This is the header file for the NetCDF CF Library.
+
+For more info on the NetCDF CF Library, see:
+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 $
+*/
+
+#include <stdlib.h>
+#include <netcdf.h>
+
+#ifndef _NCCFLIB_
+#define _NCCFLIB_
+
+#define COORDINATE_AXIS_TYPE "_CoordinateAxisType"
+#define COORDINATE_AXES "_CoordinateAxes"
+#define COORDINATE_Z_IS_POSITIVE "_CoordinateZisPositive"
+#define Z_UP "up"
+#define Z_DOWN "down"
+#define COORDINATE_SYSTEMS "_CoordinateSystems"
+#define TRANSFORM_NAME "transform_name"
+#define TRANSFORM_TYPE "_CoordinateTransformType"
+#define COORDINATE_TRANSFORMS "_CoordinateTransforms"
+
+#define CF_LONGITUDE_NAME "longitude"
+#define CF_LATITUDE_NAME "latitude"
+#define CF_LONGITUDE_UNITS "degrees_east"
+#define CF_LATITUDE_UNITS "degrees_north"
+#define CF_LONGITUDE_AXIS "X"
+#define CF_LATITUDE_AXIS "Y"
+#define CF_LEVEL_AXIS "Z"
+#define CF_TIME_AXIS "T"
+#define CF_UNITS "units"
+#define CF_FORMULA_TERMS "formula_terms"
+#define CF_AXIS "axis"
+#define CF_UP "up"
+#define CF_DOWN "down"
+#define CF_POSITIVE "positive"
+#define CF_MAX_LEN 40
+
+/* Some maximums for the "formula_terms" attribute used with
+ * dimensionless vertical coordinates. There are (currently) at most 7
+ * var names in a formula_terms attribute, and each may be NC_MAX_NAME
+ * chars long. */
+#define CF_MAX_FT_VARS 7
+#define CF_MAX_FT_LEN (NC_MAX_NAME * CF_MAX_FT_VARS + 31)
+
+/* The maximum length of the "coordinates" attribue. */
+#define CF_MAX_COORDS 10
+#define CF_MAX_COORD_LEN (NC_MAX_NAME * CF_MAX_COORDS)
+
+/* These are in support of the coordinate axis stuff. */
+#define NCCF_NOAXISTYPE 0
+#define NCCF_LATITUDE 1
+#define NCCF_LONGITUDE 2
+#define NCCF_GEOX 3
+#define NCCF_GEOY 4
+#define NCCF_GEOZ 5
+#define NCCF_HEIGHT_UP 6
+#define NCCF_HEIGHT_DOWN 7
+#define NCCF_PRESSURE 8
+#define NCCF_TIME 9
+#define NCCF_RADAZ 10
+#define NCCF_RADEL 11
+#define NCCF_RADDIST 12
+
+/* Error codes for libcf. */
+#define CF_NOERR NC_NOERR
+#define CF_ENOMEM NC_ENOMEM /* Out of memory. */
+#define CF_EBADTYPE NC_EBADTYPE /* Bad type. */
+#define CF_EINVAL NC_EINVAL /* Invalid input. */
+#define CF_ENETCDF -400 /* Error at netCDF layer. */
+#define CF_ETIME -401 /* Error getting current time and date. */
+#define CF_EMINMAX -402 /* Min and max must both be provided. */
+#define CF_EUNKCOORD -403 /* Unknown coordinate type. */
+#define CF_EEXISTS -404 /* Attempting to define var, dim, or att that already exists. */
+#define CF_ENOTFOUND -405 /* Can't find what you're looking for! */
+#define CF_ENODIM -406 /* Can't find dim to go with coordinate variable. */
+#define CF_EBADVALUE -407 /* Attribute has incorrect value for CF. */
+#define CF_EMAXFT -408 /* formula_terms attribute exceeds max size. */
+#define CF_EBADFT -409 /* Couldn't parse formula_terms attribute. */
+#define CF_EMAX_NAME -410 /* Name of netCDF object too long. */
+#define CF_EMAXCOORDS -411 /* Too many coordinates! */
+#define CF_ERECTOOLARGE -412 /* Record number too large. */
+#define CF_ENDIMS -413 /* Wrong number of dimensions. */
+#define CF_EBADRANGE -414 /* range[0] must be <= range[1]. */
+
+/* These are from libsrc/ncx.h. They will never change. */
+#define X_SCHAR_MAX 127
+#define X_UCHAR_MAX 255U
+#define X_SHORT_MAX 32767
+#define X_INT_MAX 2147483647
+#define X_FLOAT_MAX 3.402823466e+38f
+#define X_FLOAT_MIN (-X_FLOAT_MAX)
+#define X_DOUBLE_MAX 1.7976931348623157e+308
+#define X_DOUBLE_MIN (-X_DOUBLE_MAX)
+
+/* Default valid min and valid max for netCDF-3 types. These values
+ * take into account the default fill values, which always will fall
+ * out of the range expressed here for each type. */
+#define CF_BYTE_MIN (-126)
+#define CF_BYTE_MAX X_SCHAR_MAX
+#define CF_CHAR_MIN 1
+#define CF_CHAR_MAX X_UCHAR_MAX
+#define CF_SHORT_MIN (-32766)
+#define CF_SHORT_MAX X_SHORT_MAX
+#define CF_INT_MIN (-2147483646L)
+#define CF_INT_MAX X_INT_MAX
+#define CF_FLOAT_MIN X_FLOAT_MIN
+#define CF_FLOAT_MAX NC_FILL_FLOAT
+#define CF_DOUBLE_MIN NC_FILL_DOUBLE
+#define CF_DOUBLE_MAX X_DOUBLE_MIN
+
+#define CF_CONVENTIONS "Conventions"
+#define CF_CONVENTION_STRING "CF-1.0"
+#define CF_TITLE "title"
+#define CF_HISTORY "history"
+#define CF_INSTITUTION "institution"
+#define CF_SOURCE "source"
+#define CF_COMMENT "comment"
+#define CF_REFERENCES "references"
+#define CF_UNITS "units"
+#define CF_LONG_NAME "long_name"
+#define CF_STANDARD_NAME "standard_name"
+#define CF_FILL_VALUE "_FillValue"
+#define CF_VALID_MIN "valid_min"
+#define CF_VALID_MAX "valid_max"
+#define CF_COORDINATES "coordinates"
+
+/* These are defined in appendix D of the CF standard. They are for
+ * dimensionless vertical coordinates. */
+#define CF_VERT_ATM_LN 0
+#define STD_ATM_LN "atmosphere_ln_pressure_coordinate"
+#define FT_ATM_LN_FORMAT "p0: %s lev: %s"
+#define FT_ATM_LN_TERMS 2
+
+#define CF_VERT_SIGMA 1
+#define STD_SIGMA "atmosphere_sigma_coordinate"
+#define FT_SIGMA_FORMAT "sigma: %s ps: %s ptop: %s"
+#define FT_SIGMA_TERMS 3
+
+#define CF_VERT_HYBRID_SIGMA 2
+#define STD_HYBRID_SIGMA "atmosphere_hybrid_sigma_pressure_coordinate"
+#define FT_HYBRID_SIGMA_FORMAT "a: %s b: %s ps: %s p0: %s"
+#define FT_HYBRID_SIGMA_TERMS 4
+
+#define CF_VERT_HYBRID_HEIGHT 3
+#define STD_HYBRID_HEIGHT "atmosphere_hybrid_height_coordinate"
+#define FT_HYBRID_HEIGHT_FORMAT "a: %s b: %s orog: %s"
+#define FT_HYBRID_HEIGHT_TERMS 3
+
+#define CF_VERT_SLEVE 4
+#define STD_SLEVE "atmosphere_sleve_coordinate"
+#define FT_SLEVE_FORMAT "a: %s b1: %s b2: %s ztop: %s zsurf1: %s zsurf2: %s"
+#define FT_SLEVE_TERMS 6
+
+#define CF_VERT_OCEAN_SIGMA 5
+#define STD_OCEAN_SIGMA "ocean_sigma_coordinate"
+#define FT_OCEAN_SIGMA_FORMAT "sigma: %s eta: %s depth: %s"
+#define FT_OCEAN_SIGMA_TERMS 3
+
+#define CF_VERT_OCEAN_S 6
+#define STD_OCEAN_S "ocean_s_coordinate"
+#define FT_OCEAN_S_FORMAT "s: %s eta: %s depth: %s a: %s b: %s depth_c: %s"
+#define FT_OCEAN_S_TERMS 6
+
+#define CF_VERT_OCEAN_SIGMA_Z 7
+#define STD_OCEAN_SIGMA_Z "ocean_sigma_z_coordinate"
+#define FT_OCEAN_SIGMA_Z_FORMAT "sigma: %s eta: %s depth: %s depth_c: %s nsigma: %s zlev: %s"
+#define FT_OCEAN_SIGMA_Z_TERMS 6
+
+#define CF_VERT_OCEAN_DBL_SIGMA 8
+#define STD_OCEAN_DBL_SIGMA "ocean_double_sigma_coordinate"
+#define FT_OCEAN_DBL_SIGMA_FORMAT "sigma: %s depth: %s z1: %s z2: %s a: %s href: %s k_c: %s"
+#define FT_OCEAN_DBL_SIGMA_TERMS 7
+
+#define CF_NUM_VERT 9
+#define FT_MAX_TERMS 7
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+ /* Get the version string for the CF Library (max length:
+ * NC_MAX_NAME + 1). */
+ int nccf_inq_libvers(char *version_string);
+
+ /* Mark the file as following CF-1.0 conventions. */
+ int nccf_def_convention(int ncid);
+
+ /* Determine if the file follows CF-1.0 conventions. */
+ int nccf_inq_convention(int ncid, int *cf_convention);
+
+ /* Add some or all of the CF recomended text attributes to a
+ * file. Timestamp will be added to history. If history attribute
+ * already exists, this history value will be appended. */
+ int nccf_def_file(int ncid, const char *title, const char *history);
+
+ /* Read any existing CF recomended text attributes from the
+ * file. The history will get a timestamp. */
+ int nccf_inq_file(int ncid, size_t *title_lenp, char *title,
+ size_t *history_lenp, char *history);
+
+ /* Append to the global "history" attribute, with a timestamp. */
+ int nccf_add_history(int ncid, const char *history);
+
+ /* Add some or all of the CF recomended text attributes to a variable. */
+ 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);
+
+ /* Read any existing CF recomended text attributes from a variable. */
+ 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);
+
+ /* Set attributes to define missing data information. */
+ 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,
+ 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,
+ 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 *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 *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 *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 *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 *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 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 *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 *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 *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,
+ 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 *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,
+ 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 *lvl_varidp);
+
+ /* Define hybrid_sigma coordinate. */
+ 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 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 *lvl_varidp);
+
+ /* Define hybrid_sigma coordinate. */
+ 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 ps_varid, int p0_varid);
+
+ /* Define hybrid_height coordinate. */
+ int nccf_def_lvl_hybrid_height(int ncid, const char *name, nc_type xtype, size_t len,
+ 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 orog_varid);
+
+ /* Inquire about hybrid_height coordinate. */
+ int nccf_inq_lvl_hybrid_height(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *a_varidp, int *b_varidp, int *orog_varidp,
+ 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 *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 ztop_varid, int zsurf1_varid, int zsurf2_varid);
+
+ /* Inquire about sleve coordinate. */
+ 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);
+
+
+
+ int nccf_def_lvl_ocean_sigma(int ncid, const char *name, nc_type xtype, size_t len,
+ int *lvl_dimidp, int *lvl_varidp);
+
+ int nccf_def_ft_ocean_sigma(int ncid, int varid, int eta_varid, int depth_varid);
+
+ int nccf_inq_lvl_ocean_sigma(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *lvl_dimidp,
+ int *lvl_varidp);
+
+ 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 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,
+ int *eta_varidp, int *depth_varidp, int *a_varidp, int *b_varidp,
+ int *depth_c_varidp, int *lvl_dimidp, int *lvl_varidp);
+
+ /* Define ocean_sigma_z coordinate. */
+ int nccf_def_lvl_ocean_sigma_z(int ncid, const char *name, nc_type xtype,
+ size_t len, int *lvl_dimidp, int *lvl_varidp);
+
+ int nccf_def_ft_ocean_sigma_z(int ncid, int varid, int eta_varid, int depth_varid,
+ int depth_c_varid, int nsigma_varid, int zlev_varid);
+
+ /* Inquire about ocean_sigma_z coordinate. */
+ int nccf_inq_lvl_ocean_sigma_z(int ncid, char *name, nc_type *xtypep, size_t *lenp,
+ int *eta_varidp, int *depth_varidp, int *depth_c_varidp,
+ int *nsigma_varidp, int *zlev_varidp, int *lvl_dimidp,
+ int *lvl_varidp);
+
+ 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 z2_varid, int a_varid, int href_varid, int k_c_varid);
+
+
+ /* Inquire about atmosphere ocean_dbl_sigma coordinate. */
+ 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 *href_varidp, int *k_c_varidp,
+ int *lvl_dimidp, int *lvl_varidp);
+
+ /* Here are functions for coordinate axis stuff. */
+
+ /* Label the axis type of a coordinate var. */
+ int nccf_def_axis_type(int ncid, int varid, int axis_type);
+
+ /* Find out the axis type o a coordinate var. */
+ int nccf_inq_axis_type(int ncid, int varid, int *axis_type);
+
+ /* Define a coordinate system consisting of naxes axes, each axis
+ * 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 *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 *naxes, int *axis_varids);
+
+ /* Assign a coordinate system to a var. This adds an attriibute to the
+ * var. */
+ int nccf_assign_coord_system(int ncid, int varid, int system_varid);
+
+ /* 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,
+ 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,
+ char *transform_type, size_t *name_len, char *transform_name);
+
+ /* Assign a coordinate transform to a coordinate system. This adds an
+ * attribute to the variable that holds the coordinate system
+ * attributes. */
+ 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 *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);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* NCCFLIB */
diff --git a/src/libcf_int.h b/src/libcf_int.h
new file mode 100644
index 0000000..826b9ab
--- /dev/null
+++ b/src/libcf_int.h
@@ -0,0 +1,23 @@
+/*
+This is part of the libcf package from Unidata. Copyright UCAR
+2006.
+
+This is an internal header file for library-wide stuff that I don't
+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 $
+*/
+
+#ifndef _LIBCF_INT_
+#define _LIBCF_INT_
+
+/* To log based on error code, and set retval. */
+#define BAIL(e) do { \
+ret = e; \
+printf("file %s, line %d.\n%s", __FILE__, __LINE__, nc_strerror(e)); \
+goto exit; \
+} while (0)
+
+#endif /* _LIBCF_INT_ */
diff --git a/src/nc_tests.h b/src/nc_tests.h
new file mode 100644
index 0000000..c57a642
--- /dev/null
+++ b/src/nc_tests.h
@@ -0,0 +1,71 @@
+/*
+Copyright 2005 University Corporation for Atmospheric Research/Unidata
+See COPYRIGHT file for conditions of use.
+
+This is part of the libcf package.
+
+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 $
+*/
+#ifndef _NC_TESTS_
+#define _NC_TESTS_
+
+#include <config.h>
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Err is used to keep track of errors within each set of tests,
+ * total_err is the number of errors in the entire test program, which
+ * generally cosists of several sets of tests. */
+int total_err = 0, err = 0;
+
+/* This is handy for print statements. */
+char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4",
+ "netCDF-4 classic model"};
+
+/* This macro prints an error message with line number and name of
+ * test program. */
+#define ERR do { \
+fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
+err++; \
+fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
+ __FILE__, __LINE__); \
+} while (0)
+
+/* After a set of tests, report the number of errors, and increment
+ * total_err. */
+#define SUMMARIZE_ERR do { \
+ if (err) \
+ { \
+ printf("%d failures\n", err); \
+ total_err += err; \
+ err = 0; \
+ } \
+ else \
+ printf("ok.\n"); \
+} while (0)
+
+/* If extra memory debugging is not in use (as it usually isn't),
+ * define away the nc_exit function, which may be in some tests. */
+#ifndef EXTRA_MEM_DEBUG
+#define nc_exit()
+#endif
+
+/* This macro prints out our total number of errors, if any, and exits
+ * with a 0 if there are not, or a 2 if there were errors. Make will
+ * stop if a non-zero value is returned from a test program. */
+#define FINAL_RESULTS do { \
+ if (total_err) \
+ { \
+ printf("%d errors detected! Sorry!\n", total_err); \
+ return 2; \
+ } \
+ printf("*** Tests successful!\n"); \
+ return 0; \
+} while (0)
+
+#endif /* _NC_TESTS_ */
diff --git a/src/nccoord.c b/src/nccoord.c
new file mode 100644
index 0000000..90387ee
--- /dev/null
+++ b/src/nccoord.c
@@ -0,0 +1,379 @@
+/*
+Copyright 2006, University Corporation for Atmospheric Research. See
+COPYRIGHT file for copying and redistribution conditions.
+
+This file is part of the CF Library.
+
+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 $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <libcf_int.h>
+#include <stdlib.h>
+#include <string.h>
+
+static char* axis_type_name[] = {"", "Lat", "Lon", "GeoX", "GeoY", "GeoZ",
+ "Height", "Height", "Pressure", "Time",
+ "RadialAzimuth", "RadialElevation",
+ "RadialDistance"};
+
+/* Here are functions for coordinate axis stuff. */
+int
+nccf_def_axis_type(int ncid, int varid, int axis_type)
+{
+ int dimid;
+ char var_name[NC_MAX_NAME + 1];
+ int ret;
+
+ /* Is the axis type valid? */
+ if (axis_type < 0 || axis_type > NCCF_RADDIST)
+ return NC_EINVAL;
+
+ /* Make sure there's a dimension with the same name in this
+ * ncid. */
+ if ((ret = nc_inq_varname(ncid, varid, var_name)))
+ return ret;
+ if ((ret = nc_inq_dimid(ncid, var_name, &dimid)))
+ return ret;
+
+ /* Now write the attribute which stores the axis type. */
+ if ((ret = nc_put_att_text(ncid, varid, COORDINATE_AXIS_TYPE,
+ strlen(axis_type_name[axis_type]) + 1,
+ axis_type_name[axis_type])))
+ return ret;
+
+ /* For height we write another attribute, indicating up
+ * vs. down. */
+ if (axis_type == NCCF_HEIGHT_UP)
+ {
+ if ((ret = nc_put_att_text(ncid, varid, COORDINATE_Z_IS_POSITIVE,
+ strlen(Z_UP) + 1, Z_UP)))
+ return ret;
+ }
+ else if (axis_type == NCCF_HEIGHT_DOWN)
+ {
+ if ((ret = nc_put_att_text(ncid, varid, COORDINATE_Z_IS_POSITIVE,
+ strlen(Z_UP) + 1, Z_UP)))
+ return ret;
+ }
+
+ return NC_NOERR;
+}
+
+int
+nccf_inq_axis_type(int ncid, int varid, int *axis_type)
+{
+ char value[NC_MAX_NAME + 1];
+ int i;
+ int ret;
+
+ /* Get the attribute which stores the axis type. */
+ if ((ret = nc_get_att_text(ncid, varid, COORDINATE_AXIS_TYPE,
+ value)))
+ return ret;
+
+ /* Which axis type is this? */
+ for (i = 1; i <= NCCF_RADDIST; i++)
+ if (!strcmp(value, axis_type_name[i]))
+ break;
+
+ /* For height we also have to look at another attribute to find out
+ * whether it is up or down. At this point, i will equal
+ * NCCF_HEIGHT_UP, find out whether it should be HEIGHT_DOWN. */
+ if (i == NCCF_HEIGHT_UP)
+ {
+ if ((ret = nc_get_att_text(ncid, varid, COORDINATE_Z_IS_POSITIVE,
+ value)))
+ return ret;
+ if (!strcmp(value, Z_DOWN))
+ i = NCCF_HEIGHT_DOWN;
+ }
+
+ /* Return a valid type if we found one, otherwise zero. */
+ if (i > NCCF_RADDIST)
+ return NCCF_NOAXISTYPE;
+
+ if (axis_type)
+ *axis_type = i;
+
+ return NC_NOERR;
+}
+
+
+/* Define a coordinate system. This creates a var with contains a text
+ * attribute, which is the names of the (coordinate) vars which make
+ * up the axes of a coordinate system. */
+int
+nccf_def_coord_system(int ncid, const char *name, int naxes, int *axis_varids,
+ int *system_varid)
+{
+ int dimid, a;
+ int varid;
+ char var_name[NC_MAX_NAME + 1];
+ char *coord_axes_str;
+ int ret;
+
+ /* naxes must be positive and less than max_dims. */
+ if (naxes < 0)
+ return NC_EINVAL;
+ if (naxes > NC_MAX_DIMS)
+ return NC_EMAXDIMS;
+
+ /* Create a scalar var, type NC_CHAR, to hold the attribute that
+ * defines this system. */
+ if ((ret = nc_def_var(ncid, name, NC_CHAR, 0, NULL, &varid)))
+ return ret;
+
+ /* If the user wants it, return the varid of this system. */
+ if (system_varid)
+ *system_varid = varid;
+
+ /* malloc space for the string which will hold the names of all the
+ * axes. */
+ if (!(coord_axes_str = malloc(naxes * NC_MAX_NAME + naxes)))
+ return NC_NOERR;
+ coord_axes_str[0] = 0;
+
+ /* Store the names of the axes in an attribute. At the same time,
+ * make sure that all the axis_varids are actually coordinate
+ * variables - that is, there is a dimension withn the same
+ * name. */
+ for (a = 0; a < naxes; a++)
+ {
+ if ((ret = nc_inq_varname(ncid, axis_varids[a], var_name)))
+ break;
+ if ((ret = nc_inq_dimid(ncid, var_name, &dimid)))
+ break;
+ strcat(coord_axes_str, var_name);
+ if (a < naxes - 1)
+ strcat(coord_axes_str, " ");
+ }
+
+ /* If we arrived here without error, then write the coord_axes_str
+ * to the appropriate attribute, to save the system in the file. */
+ if (!ret)
+ ret = nc_put_att_text(ncid, varid, COORDINATE_AXES,
+ strlen(coord_axes_str) + 1, coord_axes_str);
+
+ /* Free the memory we allocated. */
+ free(coord_axes_str);
+
+ return ret;
+}
+
+/* Both CF and CDM use an attribute to hold a space-separated list of
+ * names of coordinate variables. This function reads that attribute
+ * and looks up the ID of each coordinate var. */
+int
+nccf_parse_coords(int ncid, int varid, char *att_name, int *naxes,
+ int *axis_varids)
+{
+ size_t len;
+ char *coords_str;
+ char axis_name[NC_MAX_NAME + 1], *p, *a;
+ int num_axes = 0, axes[NC_MAX_DIMS];
+ int a1, ret;
+
+ /* Check reasonableness of name. */
+ if (!att_name || strlen(att_name) > NC_MAX_NAME)
+ return CF_EINVAL;
+
+ /* Find length of the attribute. */
+ if ((ret = nc_inq_att(ncid, varid, att_name, NULL, &len)))
+ return ret;
+
+ /* Allocate space to read in the string. */
+ if (!(coords_str = malloc(len)))
+ return CF_ENOMEM;
+
+ /* Read in the system string. */
+ ret = nc_get_att_text(ncid, varid, att_name, coords_str);
+
+ /* If we got the coord axes string, parse it to find the names of
+ * the coordinate vars which make up this system. */
+ for (p = coords_str; !ret && (p - coords_str) < strlen(coords_str);)
+ {
+ for (a = axis_name; *p && *p != ' '; )
+ *a++ = *p++;
+ p++;
+ *a = '\0';
+
+ ret = nc_inq_varid(ncid, axis_name, &axes[num_axes++]);
+ }
+
+ /* Thanks for the memories! */
+ free(coords_str);
+
+ /* Give the user what they asked for. */
+ if (naxes)
+ *naxes = num_axes;
+ if (axis_varids)
+ for (a1 = 0; a1 < num_axes; a1++)
+ axis_varids[a1] = axes[a1];
+
+ return CF_NOERR;
+}
+
+/* Inquire about a coordinate system. */
+EXTERNL int
+nccf_inq_coord_system(int ncid, int system_varid, char *name,
+ int *naxes, int *axis_varids)
+{
+ int ret;
+
+ /* Get the name of this coordinate system, which is the same as the
+ * name of this variable. */
+ if ((ret = nc_inq_varname(ncid, system_varid, name)))
+ return ret;
+
+ /* Look up the ids of the vars in the COORDINATE_AXES attribute. */
+ if ((ret = nccf_parse_coords(ncid, system_varid, COORDINATE_AXES,
+ naxes, axis_varids)))
+ return ret;
+
+ return ret;
+}
+
+/* Given the varid of a system, write an attribute to a varid, whcih
+ * indicates that it (the var) partakes of the system. Recall that the
+ * system is just a collection of var names which are axes of the
+ * coordinate system. */
+int
+nccf_assign_coord_system(int ncid, int varid, int system_varid)
+{
+ char system_name[NC_MAX_NAME + 1];
+ char *systems_str;
+ size_t len, new_len = 0;
+ int ret;
+
+ /* Find the name of this system. */
+ if ((ret = nc_inq_varname(ncid, system_varid, system_name)))
+ return ret;
+
+ /* Is the att already here? If so, get it's length, then it's
+ * contents, then append a space and the new system name. */
+ ret = nc_inq_att(ncid, varid, COORDINATE_SYSTEMS, NULL, &len);
+ if (ret != NC_ENOTATT && ret != NC_NOERR)
+ return ret;
+ if (!ret)
+ new_len += len;
+ new_len += strlen(system_name) + 1;
+ if (!(systems_str = malloc(new_len)))
+ return NC_NOERR;
+ systems_str[0] = 0;
+ if (!ret)
+ {
+ if ((ret = nc_get_att_text(ncid, varid, COORDINATE_SYSTEMS,
+ systems_str)))
+ return ret;
+ strcat(systems_str, " ");
+ }
+ strcat(systems_str, system_name);
+
+ /* Write an att, called _CoordinateSystems, which
+ * contains a list of the system names related to this variable. */
+ ret = nc_put_att_text(ncid, varid, COORDINATE_SYSTEMS,
+ strlen(systems_str) + 1, systems_str);
+
+
+ /* Free the memory we allocated. */
+ free(systems_str);
+
+ return ret;
+}
+
+/* Define a transform. This will create a scalar var of type NC_CHAR
+ * to hold some attributes. */
+int
+nccf_def_transform(int ncid, const char *name, const char *transform_type,
+ const char *transform_name, int *transform_varid)
+{
+ int varid;
+ int ret;
+
+ /* Create a scalar var, type NC_CHAR, to hold the attribute that
+ * defines this transform. */
+ if ((ret = nc_def_var(ncid, name, NC_CHAR, 0, NULL, &varid)))
+ return ret;
+
+ /* If the user wants it, return the varid of this system. */
+ if (transform_varid)
+ *transform_varid = varid;
+
+ /* Store the transform_type, if provided by the user. */
+ if (transform_type)
+ if ((ret = nc_put_att_text(ncid, varid, TRANSFORM_TYPE,
+ strlen(transform_type) + 1, transform_type)))
+ return ret;
+
+ /* Store the transform name, if provided by the user. */
+ if (transform_type)
+ if ((ret = nc_put_att_text(ncid, varid, TRANSFORM_NAME,
+ strlen(transform_name) + 1, transform_name)))
+ return ret;
+
+ return NC_NOERR;
+}
+
+EXTERNL 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)
+{
+ int ret;
+
+ /* Find the name of the transform var, if desired. */
+ if (name)
+ if ((ret = nc_inq_varname(ncid, transform_varid, name)))
+ return ret;
+
+ /* If the user wants the length of the transform_type, find it. */
+ if (type_len)
+ if ((ret = nc_inq_attlen(ncid, transform_varid, TRANSFORM_TYPE,
+ type_len)))
+ return ret;
+
+ /* If the user wants the transform type string, get it. */
+ if (transform_type)
+ if ((ret = nc_get_att_text(ncid, transform_varid,
+ TRANSFORM_TYPE, transform_type)))
+ return ret;
+
+ /* If the user wants the length of the transform_name, find it. */
+ if (type_len)
+ if ((ret = nc_inq_attlen(ncid, transform_varid, TRANSFORM_NAME,
+ name_len)))
+ return ret;
+
+ /* If the user wants the transform name string, get it. */
+ if (transform_name)
+ if ((ret = nc_get_att_text(ncid, transform_varid,
+ TRANSFORM_NAME, transform_name)))
+ return ret;
+
+ return NC_NOERR;
+}
+
+int
+nccf_assign_transform(int ncid, int system_varid, int transform_varid)
+{
+ char transform_name[NC_MAX_NAME + 1];
+ int ret;
+
+ /* Find the name of the transform. */
+ if ((ret = nc_inq_varname(ncid, transform_varid, transform_name)))
+ return ret;
+
+ /* Write the transform name as an att of the system to which it
+ * applies. */
+ if ((ret = nc_put_att_text(ncid, system_varid, COORDINATE_TRANSFORMS,
+ strlen(transform_name) + 1, transform_name)))
+ return ret;
+
+ return NC_NOERR;
+}
+
diff --git a/src/tst_coords.c b/src/tst_coords.c
new file mode 100644
index 0000000..a51b84a
--- /dev/null
+++ b/src/tst_coords.c
@@ -0,0 +1,447 @@
+/*
+Copyright 2005 University Corporation for Atmospheric Research/Unidata
+See COPYRIGHT file for conditions of use. See www.unidata.ucar.edu for
+more info.
+
+This file is part of the libcf package; it tests libcf coordinate
+systems.
+
+Ed Hartnett 10/1/05
+
+$Id: tst_coords.c,v 1.5 2007/05/27 06:56:36 ed Exp $
+*/
+
+#include <nc_tests.h>
+#include <netcdf.h>
+#include <libcf.h>
+
+#define DIM_LEN 4
+#define DIM1_NAME "lat"
+#define VAR_NAME "earth"
+#define COORD_SYSTEM "coord_system"
+#define COORD_NAME "coord_name"
+#define TRANSFORM_NAME "transform_name"
+#define TRANSFORM_TYPE1 "transform_type"
+#define TRANSFORM_NAME "transform_name"
+
+#define COORDINATE_AXES "_CoordinateAxes"
+#define COORDINATE_Z_IS_POSITIVE "_CoordinateZisPositive"
+#define Z_UP "up"
+#define Z_DOWN "down"
+
+/* These are used to implement tests that end up like John Caron's
+ * examples of coordinate systems. */
+#define EARTH "earth"
+#define AIR "air"
+#define TIME "time"
+#define LEVEL "level"
+#define LEVEL_LEN 17
+#define LAT "lat"
+#define LAT_LEN 73
+#define LON "lon"
+#define LON_LEN 144
+#define NDIMS 4
+#define LAT_LON_COORDINATE_SYSTEM "LatLonCoordinateSytem"
+#define COORDINATE_SYSTEMS "_CoordinateSystems"
+#define TRANSFORM_NAME "transform_name"
+#define COORDINATE_TRANSFORMS "_CoordinateTransforms"
+#define LAMBERT_CONFORMAL_PROJECTION "LambertConformalProjection"
+#define PROJECTION "Projection"
+#define LAMBERT_CONFORMAL_CONIC "lambert_conformal_conic"
+
+/* Test everything for classic and 64-bit offsetfiles. If netcdf-4 is
+ * included, that means another whole round of testing. */
+#ifdef USE_NETCDF4
+#define NUM_FORMATS (4)
+#else
+#define NUM_FORMATS (2)
+#endif
+
+static void
+test_axis(const char *testfile)
+{
+ int ncid, dimid, varid, dimids[1] = {0};
+ int axis_type;
+ int nvars, ndims, natts, unlimdimid;
+ char value[NC_MAX_NAME + 1];
+
+ /* Create a file. */
+ if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+
+ /* Create an dimension and a coordinate var to go with it. */
+ if (nc_def_dim(ncid, DIM1_NAME, DIM_LEN, &dimid)) ERR;
+ if (dimid != 0) ERR;
+ if (nc_def_var(ncid, DIM1_NAME, NC_FLOAT, 1, dimids, &varid)) ERR;
+ if (varid != 0) ERR;
+ if (nccf_def_axis_type(ncid, varid, NCCF_LONGITUDE)) ERR;
+ if (nccf_inq_axis_type(ncid, varid, &axis_type)) ERR;
+ if (axis_type != NCCF_LONGITUDE) ERR;
+
+ /* Write the file. */
+ if (nc_close(ncid)) ERR;
+
+ /* Reopen the file, check the axis type. */
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
+ if (ndims != 1 && nvars != 2 && natts != 0 && unlimdimid != -1) ERR;
+ if (nccf_inq_axis_type(ncid, 0, &axis_type)) ERR;
+ if (axis_type != NCCF_LONGITUDE) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ /* Now create a file with the HEIGHT_UP axis. */
+ if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+
+ /* Create an dimension and a coordinate var to go with it. */
+ if (nc_def_dim(ncid, DIM1_NAME, DIM_LEN, &dimid)) ERR;
+ if (dimid != 0) ERR;
+ if (nc_def_var(ncid, DIM1_NAME, NC_FLOAT, 1, dimids, &varid)) ERR;
+ if (varid != 0) ERR;
+ if (nccf_def_axis_type(ncid, varid, NCCF_HEIGHT_UP)) ERR;
+ if (nccf_inq_axis_type(ncid, varid, &axis_type)) ERR;
+ if (axis_type != NCCF_HEIGHT_UP) ERR;
+
+ /* Write the file. */
+ if (nc_close(ncid)) ERR;
+
+ /* Reopen the file, check the axis type. */
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nccf_inq_axis_type(ncid, 0, &axis_type)) ERR;
+ if (axis_type != NCCF_HEIGHT_UP) ERR;
+ if (nc_get_att_text(ncid, varid, COORDINATE_Z_IS_POSITIVE,
+ value)) ERR;
+ if (strcmp(value, Z_UP)) ERR;
+
+ if (nc_close(ncid)) ERR;
+}
+
+static void
+test_system(const char *testfile)
+{
+ int ncid, dimid, axis_varid, system_varid, dimids[1] = {0};
+ int axes_varids[1] = {0};
+ int nvars, ndims, natts, unlimdimid;
+ char name_in[NC_MAX_NAME + 1];
+ int naxes_in, axes_varids_in[1];
+
+ /* Create a file. */
+ if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+
+ /* Create an dimension and a coordinate var to go with it. */
+ if (nc_def_dim(ncid, DIM1_NAME, DIM_LEN, &dimid)) ERR;
+ if (nc_def_var(ncid, DIM1_NAME, NC_FLOAT, 1, dimids, &axis_varid)) ERR;
+ if (axis_varid != 0) ERR;
+ if (nccf_def_coord_system(ncid, COORD_SYSTEM, 1, axes_varids, &system_varid)) ERR;
+ if (system_varid != 1) ERR;
+ if (nccf_inq_coord_system(ncid, 1, name_in, &naxes_in, axes_varids_in)) ERR;
+ if (strcmp(name_in, COORD_SYSTEM) || naxes_in != 1 ||
+ axes_varids_in[0] != axes_varids[0]) ERR;
+
+
+ /* Write the file. */
+ if (nc_close(ncid)) ERR;
+
+ /* Reopen the file and check it. */
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
+ if (ndims != 1 && nvars != 2 && natts != 0 && unlimdimid != -1) ERR;
+ if (nccf_inq_coord_system(ncid, 1, name_in, &naxes_in,
+ axes_varids_in)) ERR;
+ if (strcmp(name_in, COORD_SYSTEM) || naxes_in != 1 ||
+ axes_varids_in[0] != axes_varids[0]) ERR;
+
+ if (nc_close(ncid)) ERR;
+}
+
+/* Test the creation of a system, and it's assignment to a data
+ * variable. THis matches example 2 from John's document (with some of
+ * the other attributes left out.) */
+static void
+test_system_assign(const char *testfile)
+{
+ int ncid, axis_varids[NDIMS], system_varid, dimids[NDIMS];
+ int nvars, ndims, natts, unlimdimid;
+ int dimids_in[NDIMS], ndims_in;
+ size_t len_in;
+ char name_in[NC_MAX_NAME + 1];
+ char systems_in[NC_MAX_NAME + 1];
+ int naxes_in, axis_varids_in[NDIMS], natts_in;
+ char *dim_name[] = {TIME, LEVEL, LAT, LON};
+ size_t dim_len[NDIMS] = {NC_UNLIMITED, LEVEL_LEN, LAT_LEN, LON_LEN};
+ int earth_varid, air_varid;
+ int varid_in;
+ nc_type type_in;
+ int d;
+
+ /* Create a file. */
+ if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+
+ /* Create 4 dimensions, and a coordinate var to go with each. */
+ for (d = 0; d < NDIMS; d++)
+ {
+ if (nc_def_dim(ncid, dim_name[d], dim_len[d], &dimids[d])) ERR;
+ if (nc_def_var(ncid, dim_name[d], NC_FLOAT, 1, &dimids[d],
+ &axis_varids[d])) ERR;
+ }
+
+ /* Create two data vars, earth and air. (Don't know what happened
+ * to fire and water Aristotle!) */
+ if (nc_def_var(ncid, EARTH, NC_FLOAT, NDIMS, dimids,
+ &earth_varid)) ERR;
+ if (nc_def_var(ncid, AIR, NC_FLOAT, NDIMS, dimids,
+ &air_varid)) ERR;
+
+ /* Unite our 4 dims in a coordinate system. */
+ if (nccf_def_coord_system(ncid, LAT_LON_COORDINATE_SYSTEM, NDIMS,
+ axis_varids, &system_varid)) ERR;
+
+ /* Check things out. */
+ if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
+ if (ndims != 4 && nvars != 7 && natts != 0 && unlimdimid != dimids[3]) ERR;
+ if (nc_inq_varid(ncid, LAT_LON_COORDINATE_SYSTEM, &varid_in)) ERR;
+ if (varid_in != system_varid) ERR;
+ if (nc_inq_var(ncid, system_varid, name_in, &type_in, &ndims_in,
+ dimids_in, &natts_in)) ERR;
+ if (strcmp(name_in, LAT_LON_COORDINATE_SYSTEM) || type_in != NC_CHAR ||
+ ndims_in != 0 || natts_in != 1);
+ if (nc_inq_att(ncid, system_varid, COORDINATE_AXES, &type_in, &len_in)) ERR;
+ if (type_in != NC_CHAR) ERR;
+ if (nccf_inq_coord_system(ncid, system_varid, name_in, &naxes_in, axis_varids_in)) ERR;
+ if (strcmp(name_in, LAT_LON_COORDINATE_SYSTEM) || naxes_in != NDIMS) ERR;
+ for (d = 0; d < NDIMS; d++)
+ if (axis_varids_in[d] != axis_varids[d]) ERR;
+
+ /* Assign the system to the earth and air data variables. */
+ if (nccf_assign_coord_system(ncid, earth_varid, system_varid)) ERR;
+ if (nccf_assign_coord_system(ncid, air_varid, system_varid)) ERR;
+
+ /* Check to ensure that the assignments happened. */
+ if (nc_inq_varnatts(ncid, earth_varid, &natts_in)) ERR;
+ if (natts_in != 1) ERR;
+ if (nc_inq_att(ncid, earth_varid, COORDINATE_SYSTEMS, &type_in, &len_in)) ERR;
+ if (type_in != NC_CHAR) ERR;
+ if (nc_inq_varnatts(ncid, air_varid, &natts_in)) ERR;
+ if (natts_in != 1) ERR;
+ if (nc_get_att_text(ncid, earth_varid, COORDINATE_SYSTEMS, systems_in)) ERR;
+ if (strcmp(systems_in, LAT_LON_COORDINATE_SYSTEM)) ERR;
+ if (nc_inq_att(ncid, air_varid, COORDINATE_SYSTEMS, &type_in, &len_in)) ERR;
+ if (type_in != NC_CHAR) ERR;
+ if (nc_get_att_text(ncid, air_varid, COORDINATE_SYSTEMS, systems_in)) ERR;
+ if (strcmp(systems_in, LAT_LON_COORDINATE_SYSTEM)) ERR;
+
+ /* Write the file. */
+ if (nc_close(ncid)) ERR;
+
+ /* Reopen the file and check it. */
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
+ if (ndims != 4 && nvars != 7 && natts != 0 && unlimdimid != dimids[3]) ERR;
+ if (nc_inq_var(ncid, system_varid, name_in, &type_in, &ndims_in,
+ dimids_in, &natts_in)) ERR;
+ if (strcmp(name_in, LAT_LON_COORDINATE_SYSTEM) || type_in != NC_CHAR ||
+ ndims_in != 0 || natts_in != 1);
+ if (nc_inq_att(ncid, system_varid, COORDINATE_AXES, &type_in, &len_in)) ERR;
+ if (type_in != NC_CHAR) ERR;
+ if (nccf_inq_coord_system(ncid, system_varid, name_in, &naxes_in, axis_varids_in)) ERR;
+ if (strcmp(name_in, LAT_LON_COORDINATE_SYSTEM) || naxes_in != NDIMS) ERR;
+ for (d = 0; d < NDIMS; d++)
+ if (axis_varids_in[d] != axis_varids[d]) ERR;
+
+ /* Check to ensure that the assignments happened. */
+ if (nc_inq_varnatts(ncid, earth_varid, &natts_in)) ERR;
+ if (natts_in != 1) ERR;
+ if (nc_inq_att(ncid, earth_varid, COORDINATE_SYSTEMS, &type_in, &len_in)) ERR;
+ if (type_in != NC_CHAR) ERR;
+ if (nc_inq_varnatts(ncid, air_varid, &natts_in)) ERR;
+ if (natts_in != 1) ERR;
+ if (nc_get_att_text(ncid, earth_varid, COORDINATE_SYSTEMS, systems_in)) ERR;
+ if (strcmp(systems_in, LAT_LON_COORDINATE_SYSTEM)) ERR;
+ if (nc_inq_att(ncid, air_varid, COORDINATE_SYSTEMS, &type_in, &len_in)) ERR;
+ if (type_in != NC_CHAR) ERR;
+ if (nc_get_att_text(ncid, air_varid, COORDINATE_SYSTEMS, systems_in)) ERR;
+ if (strcmp(systems_in, LAT_LON_COORDINATE_SYSTEM)) ERR;
+
+ if (nc_close(ncid)) ERR;
+}
+
+static void
+test_transform(const char *testfile)
+{
+ int ncid, transform_varid;
+ int nvars, ndims, natts, unlimdimid;
+ char name_in[NC_MAX_NAME + 1];
+ char transform_name_in[NC_MAX_NAME + 1], transform_type_in[NC_MAX_NAME + 1];
+ size_t type_len, name_len;
+
+ /* Create a file. */
+ if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+
+ /* Create a transform. */
+ if (nccf_def_transform(ncid, TRANSFORM_NAME, TRANSFORM_TYPE1,
+ TRANSFORM_NAME, &transform_varid)) ERR;
+ if (transform_varid != 0) ERR;
+ if (nccf_inq_transform(ncid, transform_varid, name_in, &type_len,
+ transform_type_in, &name_len,
+ transform_name_in)) ERR;
+ if (strcmp(name_in, TRANSFORM_NAME) || type_len != strlen(TRANSFORM_TYPE1) + 1 ||
+ strcmp(transform_type_in, TRANSFORM_TYPE1) || name_len != strlen(TRANSFORM_NAME) + 1 ||
+ strcmp(transform_name_in, TRANSFORM_NAME)) ERR;
+
+ /* Write the file. */
+ if (nc_close(ncid)) ERR;
+
+ /* Reopen the file and check it. */
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
+ if (ndims != 0 && nvars != 1 && natts != 0 && unlimdimid != -1) ERR;
+ if (nccf_inq_transform(ncid, 0, name_in, &type_len, transform_type_in,
+ &name_len, transform_name_in)) ERR;
+ if (strcmp(name_in, TRANSFORM_NAME) || type_len != strlen(TRANSFORM_TYPE1) + 1 ||
+ strcmp(transform_type_in, TRANSFORM_TYPE1) || name_len != strlen(TRANSFORM_NAME) + 1 ||
+ strcmp(transform_name_in, TRANSFORM_NAME)) ERR;
+
+ if (nc_close(ncid)) ERR;
+}
+
+/* Create a coordinate system and transform, and create a file like
+ * John's example 4. */
+static void
+test_transform_assign(const char *testfile)
+{
+ int ncid, axis_varids[NDIMS], system_varid, dimids[NDIMS];
+ int transform_varid;
+ size_t len_in, name_len, type_len;
+ char name_in[NC_MAX_NAME + 1];
+ char transform_in[NC_MAX_NAME + 1];
+ char transform_type_in[NC_MAX_NAME + 1], transform_name_in[NC_MAX_NAME + 1];
+ char *dim_name[NDIMS] = {TIME, LEVEL, LAT, LON};
+ size_t dim_len[NDIMS] = {NC_UNLIMITED, LEVEL_LEN, LAT_LEN, LON_LEN};
+ int axis_type[NDIMS] = {NCCF_TIME, NCCF_HEIGHT_DOWN, NCCF_LATITUDE, NCCF_LONGITUDE};
+ int earth_varid, air_varid;
+ int d;
+
+ /* Create a file. */
+ if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
+
+ /* Create 4 dimensions, and a coordinate var to go with each. Also
+ * set the axis type for each axis. */
+ for (d = 0; d < NDIMS; d++)
+ {
+ if (nc_def_dim(ncid, dim_name[d], dim_len[d], &dimids[d])) ERR;
+ if (nc_def_var(ncid, dim_name[d], NC_FLOAT, 1, &dimids[d],
+ &axis_varids[d])) ERR;
+ if (nccf_def_axis_type(ncid, axis_varids[d], axis_type[d])) ERR;
+ }
+
+ /* Create two data vars, earth and air. */
+ if (nc_def_var(ncid, EARTH, NC_FLOAT, NDIMS, dimids,
+ &earth_varid)) ERR;
+ if (nc_def_var(ncid, AIR, NC_FLOAT, NDIMS, dimids,
+ &air_varid)) ERR;
+
+ /* Unite our 4 dims in a coordinate system. */
+ if (nccf_def_coord_system(ncid, LAT_LON_COORDINATE_SYSTEM, NDIMS,
+ axis_varids, &system_varid)) ERR;
+
+ /* Assign the system to the earth and air data variables. */
+ if (nccf_assign_coord_system(ncid, earth_varid, system_varid)) ERR;
+ if (nccf_assign_coord_system(ncid, air_varid, system_varid)) ERR;
+
+ /* Create a coordinate transform called LambertConformalProjection. */
+ if (nccf_def_transform(ncid, LAMBERT_CONFORMAL_PROJECTION, PROJECTION,
+ LAMBERT_CONFORMAL_CONIC, &transform_varid)) ERR;
+ if (nccf_inq_transform(ncid, transform_varid, name_in, &len_in,
+ transform_type_in, &name_len, transform_name_in)) ERR;
+ if (strcmp(name_in, LAMBERT_CONFORMAL_PROJECTION) || len_in != strlen(PROJECTION) + 1 ||
+ strcmp(transform_type_in, PROJECTION) || name_len != strlen(LAMBERT_CONFORMAL_CONIC) + 1 ||
+ strcmp(transform_name_in, LAMBERT_CONFORMAL_CONIC)) ERR;
+
+ /* Assign the transform to the coordinate system. */
+ if (nccf_assign_transform(ncid, system_varid, transform_varid)) ERR;
+
+ /* Check it out. */
+ if (nc_get_att_text(ncid, system_varid, COORDINATE_TRANSFORMS, transform_in)) ERR;
+ if (strcmp(transform_in, LAMBERT_CONFORMAL_PROJECTION)) ERR;
+
+ /* Write the file. */
+ if (nc_close(ncid)) ERR;
+
+ /* Reopen the file and check it. */
+ if (nc_open(testfile, NC_NOWRITE, &ncid)) ERR;
+ if (nccf_inq_transform(ncid, transform_varid, name_in, &type_len,
+ transform_type_in, &name_len, transform_name_in)) ERR;
+ if (strcmp(name_in, LAMBERT_CONFORMAL_PROJECTION) || type_len != strlen(PROJECTION) + 1 ||
+ strcmp(transform_type_in, PROJECTION) || name_len != strlen(LAMBERT_CONFORMAL_CONIC) + 1 ||
+ strcmp(transform_name_in, LAMBERT_CONFORMAL_CONIC)) ERR;
+ if (nc_get_att_text(ncid, system_varid, COORDINATE_TRANSFORMS, transform_in)) ERR;
+ if (strcmp(transform_in, LAMBERT_CONFORMAL_PROJECTION)) ERR;
+
+ if (nc_close(ncid)) ERR;
+}
+
+int
+main(int argc, char **argv)
+{
+ int i;
+ char testfile[NC_MAX_NAME + 1];
+
+ printf("\n*** Testing coordinate systems.\n");
+ /*nc_set_log_level(3);*/
+
+ /* Go thru formats and run all tests for each of two (for netCDF-3
+ * only builds), or 3 (for netCDF-4 builds) different formats. */
+ for (i = NUM_FORMATS; i >= 1; i--)
+ {
+ switch (i)
+ {
+ case NC_FORMAT_CLASSIC:
+ nc_set_default_format(NC_FORMAT_CLASSIC, NULL);
+ fprintf(stderr, "\nSwitching to netCDF classic format.\n");
+ strcpy(testfile, "tst_coords_classic.nc");
+ break;
+ case NC_FORMAT_64BIT:
+ nc_set_default_format(NC_FORMAT_64BIT, NULL);
+ fprintf(stderr, "\nSwitching to 64-bit offset format.\n");
+ strcpy(testfile, "tst_coords_64bit.nc");
+ break;
+#ifdef USE_NETCDF4
+ case NC_FORMAT_NETCDF4_CLASSIC:
+ nc_set_default_format(NC_FORMAT_NETCDF4_CLASSIC, NULL);
+ strcpy(testfile, "tst_coords_netcdf4_classic.nc");
+ fprintf(stderr, "\nSwitching to netCDF-4 format (with NC_CLASSIC_MODEL).\n");
+ break;
+ case NC_FORMAT_NETCDF4: /* actually it's _CLASSIC. */
+ nc_set_default_format(NC_FORMAT_NETCDF4, NULL);
+ strcpy(testfile, "tst_coords_netcdf4.nc");
+ fprintf(stderr, "\nSwitching to netCDF-4 format.\n");
+ break;
+#endif
+ default:
+ fprintf(stderr, "Unexpected format!\n");
+ return 2;
+ }
+
+ printf("*** creating coordinate axis...");
+ test_axis(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** creating coordinate system...");
+ test_system(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** assigning a coordinate system...");
+ test_system_assign(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** creating coordinate transform...");
+ test_transform(testfile);
+ SUMMARIZE_ERR;
+
+ printf("*** assigning a coordinate transform...");
+ test_transform_assign(testfile);
+ SUMMARIZE_ERR;
+ }
+
+ FINAL_RESULTS;
+}
+
diff --git a/src/tst_cvars.c b/src/tst_cvars.c
new file mode 100644
index 0000000..65b6b38
--- /dev/null
+++ b/src/tst_cvars.c
@@ -0,0 +1,66 @@
+/* This is part of the libcf package. Copyright 2006 University
+ Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
+ conditions of use. See www.unidata.ucar.edu for more info.
+
+ Test libcf coordinate variable stuff.
+
+ Ed Hartnett, 10/1/06
+
+ $Id: tst_cvars.c,v 1.7 2006/11/20 15:43:37 ed Exp $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <netcdf.h>
+#include <nc_tests.h>
+
+#define FILE_NAME "tst_cvars.nc"
+
+int
+main(int argc, char **argv)
+{
+ printf("\n*** Testing libcf coordinate variable stuff.\n");
+
+#define NDIMS 1
+#define NLATS 20
+
+ printf("*** testing coordinate variable creation...");
+ {
+ int ncid, varid, dimid, varid_in, dimid_in;
+ int l, lat[NLATS];
+ size_t len_in;
+ nc_type xtype_in;
+
+ /* Create some latitudes. */
+ for (lat[0] = 40, l = 1; l < NLATS; l++)
+ lat[l] = lat[l-1] + 2;
+
+ /* CReate a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME, 0, &ncid)) ERR;
+ if (nccf_def_latitude(ncid, NLATS, NC_INT, &dimid,
+ &varid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in,
+ &varid_in)) ERR;
+ if (len_in != NLATS || xtype_in != NC_INT ||
+ dimid_in != 0 || varid_in != 0) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in,
+ &varid_in)) ERR;
+ if (len_in != NLATS || xtype_in != NC_INT ||
+ dimid_in != 0 || varid_in != 0) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ }
+ SUMMARIZE_ERR;
+ FINAL_RESULTS;
+}
+
+
diff --git a/src/tst_example_data.c b/src/tst_example_data.c
new file mode 100644
index 0000000..705e2ea
--- /dev/null
+++ b/src/tst_example_data.c
@@ -0,0 +1,50 @@
+/* This is part of the libcf package. Copyright 2007 University
+ Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
+ conditions of use. See www.unidata.ucar.edu for more info.
+
+ Test libcf variable subsetting stuff.
+
+ Ed Hartnett, 10/1/06
+
+ $Id: tst_example_data.c,v 1.2 2007/06/02 12:32:05 ed Exp $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <netcdf.h>
+#include <nc_tests.h>
+
+int
+main(int argc, char **argv)
+{
+ printf("\n*** Testing libcf data examples.\n");
+
+#define EXAMPLE_FILE "/upc/share/ed/libcf_data/cami_0000-09-01_2x2.5_L26_c030918_USGS.nc"
+ printf("*** looking at %s...", EXAMPLE_FILE);
+ {
+ int ncid, did, vid;
+ char formula_terms[CF_MAX_FT_LEN + 1];
+ int positive_up;
+ char name[NC_MAX_NAME + 1];
+ size_t len, ft_len;
+ nc_type xtype;
+
+ /* Check the file. */
+ if (nc_open(EXAMPLE_FILE, 0, &ncid)) ERR;
+ if (nccf_inq_latitude(ncid, &len, &xtype, &did, &vid)) ERR;
+ if (len != 91 || xtype != NC_DOUBLE || did != 0 || vid != 1) ERR;
+ if (nccf_inq_longitude(ncid, &len, &xtype, &did, &vid)) ERR;
+ if (len != 144 || xtype != NC_DOUBLE || did != 1 || vid != 2) ERR;
+ if (nccf_inq_lvl(ncid, name, &len, &xtype, &ft_len, formula_terms,
+ &positive_up, &did, &vid)) ERR;
+ if (len != 26 || xtype != NC_DOUBLE || did != 4 || vid != 6 || positive_up != 0) ERR;
+
+
+ if (nc_close(ncid)) ERR;
+ }
+ SUMMARIZE_ERR;
+
+ FINAL_RESULTS;
+}
+
+
diff --git a/src/tst_f03_file.f90 b/src/tst_f03_file.f90
new file mode 100644
index 0000000..9d55ef9
--- /dev/null
+++ b/src/tst_f03_file.f90
@@ -0,0 +1,33 @@
+program tst_f03_file
+ use libcf
+ use netcdf
+ implicit none
+ integer:: ncid
+ 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 *,''
+ 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))
+ call check(nf90_close(ncid))
+
+ 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(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
+ end if
+ end subroutine check
+end program tst_f03_file
diff --git a/src/tst_files.c b/src/tst_files.c
new file mode 100644
index 0000000..e19179f
--- /dev/null
+++ b/src/tst_files.c
@@ -0,0 +1,165 @@
+/* This is part of the netCDF package. Copyright 2005 University
+ Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
+ conditions of use. See www.unidata.ucar.edu for more info.
+
+ Test libcf file stuff.
+
+ $Id: tst_files.c,v 1.5 2006/09/10 03:02:26 ed Exp $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <netcdf.h>
+#include <nc_tests.h>
+
+#define FILE_NAME "tst_files.nc"
+
+int
+main(int argc, char **argv)
+{
+ printf("\n*** Testing libcf file stuff.\n");
+ printf("*** testing file convention...");
+ {
+ int ncid;
+ int cf_convention;
+
+ /* Create a file and indicate it follows CF conventions. */
+ if (nc_create(FILE_NAME, 0, &ncid)) ERR;
+
+ if (nccf_inq_convention(ncid, &cf_convention)) ERR;
+ if (cf_convention) ERR;
+
+ if (nccf_def_convention(ncid)) ERR;
+
+ /* Check it. */
+ if (nccf_inq_convention(ncid, &cf_convention)) ERR;
+ if (!cf_convention) ERR;
+
+ if (nc_close(ncid)) ERR;
+ if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+
+ /* Check it. */
+ if (nccf_inq_convention(ncid, &cf_convention)) ERR;
+ if (!cf_convention) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ }
+ SUMMARIZE_ERR;
+
+#define C_STRING "Gaal_Dornick"
+ printf("*** testing file convention append...");
+ {
+ int ncid;
+ int cf_convention;
+
+ /* Create a file with an attribute called "Convention". */
+ if (nc_create(FILE_NAME, 0, &ncid)) ERR;
+ if (nc_put_att_text(ncid, NC_GLOBAL, CF_CONVENTIONS, strlen(C_STRING),
+ C_STRING)) ERR;
+ if (nccf_def_convention(ncid)) ERR;
+ if (nc_close(ncid)) ERR;
+
+ if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+ if (nccf_inq_convention(ncid, &cf_convention)) ERR;
+ if (!cf_convention) ERR;
+ if (nc_close(ncid)) ERR;
+
+ }
+ SUMMARIZE_ERR;
+
+#define TITLE "The_Complete_Works_of_Edward_James_Hartnett"
+#define HISTORY "This file was generated by a grant from the Obscurity Foundation"
+
+ printf("*** testing file annotation...");
+ {
+ int ncid;
+ int cf_convention;
+ size_t tlen, hlen;
+ char *history_in, *title_in;
+
+ /* CReate a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME, 0, &ncid)) ERR;
+ if (nccf_def_file(ncid, TITLE, HISTORY)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_convention(ncid, &cf_convention)) ERR;
+ if (!cf_convention) ERR;
+ if (nccf_inq_file(ncid, &tlen, NULL, &hlen, NULL)) ERR;
+ if (tlen != strlen(TITLE) + 1 || hlen != strlen(HISTORY) + 20) ERR;
+ if (!(history_in = malloc(hlen))) ERR;
+ if (!(title_in = malloc(tlen))) ERR;
+ if (nccf_inq_file(ncid, NULL, title_in, NULL, history_in)) ERR;
+ if (strncmp(title_in, TITLE, tlen) ||
+ strncmp(history_in + 18, HISTORY, strlen(HISTORY))) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_convention(ncid, &cf_convention)) ERR;
+ if (!cf_convention) ERR;
+ if (nccf_inq_file(ncid, &tlen, NULL, &hlen, NULL)) ERR;
+ if (tlen != strlen(TITLE) + 1 || hlen != strlen(HISTORY) + 20) ERR;
+ if (!(history_in = malloc(hlen))) ERR;
+ if (!(title_in = malloc(tlen))) ERR;
+ if (nccf_inq_file(ncid, NULL, title_in, NULL, history_in)) ERR;
+ if (strncmp(title_in, TITLE, tlen) ||
+ strncmp(history_in + 18, HISTORY, strlen(HISTORY))) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ }
+ SUMMARIZE_ERR;
+
+#define INSTITUTION "Unidata Asylum for Hopelessly Insane Programmers"
+#define SOURCE "These data were generated from the feverish imagination of a diseased mind."
+#define COMMENT "I think that lawn mowers smell like grass."
+#define REFERENCES "References will be fabricated upon request."
+#define MAX_LEN 200
+
+ printf("*** testing file notes...");
+ {
+ int ncid;
+ size_t ilen, slen, clen, rlen;
+ char inst_in[MAX_LEN], source_in[MAX_LEN];
+ char comment_in[MAX_LEN], ref_in[MAX_LEN];
+
+ /* CReate a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME, 0, &ncid)) ERR;
+ if (nccf_def_notes(ncid, NC_GLOBAL, INSTITUTION, SOURCE,
+ COMMENT, REFERENCES)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_notes(ncid, NC_GLOBAL, &ilen, inst_in, &slen, source_in,
+ &clen, comment_in, &rlen, ref_in)) ERR;
+ if (ilen != strlen(INSTITUTION) + 1 || slen != strlen(SOURCE) + 1 ||
+ clen != strlen(COMMENT) + 1 || rlen != strlen(REFERENCES) + 1) ERR;
+ if (strncmp(inst_in, INSTITUTION, ilen) ||
+ strncmp(source_in, SOURCE, slen) ||
+ strncmp(comment_in, COMMENT, clen) ||
+ strncmp(ref_in, REFERENCES, rlen)) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_notes(ncid, NC_GLOBAL, &ilen, inst_in, &slen, source_in,
+ &clen, comment_in, &rlen, ref_in)) ERR;
+ if (ilen != strlen(INSTITUTION) + 1 || slen != strlen(SOURCE) + 1 ||
+ clen != strlen(COMMENT) + 1 || rlen != strlen(REFERENCES) + 1) ERR;
+ if (strncmp(inst_in, INSTITUTION, ilen) ||
+ strncmp(source_in, SOURCE, slen) ||
+ strncmp(comment_in, COMMENT, clen) ||
+ strncmp(ref_in, REFERENCES, rlen)) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ }
+ SUMMARIZE_ERR;
+
+ FINAL_RESULTS;
+}
+
diff --git a/src/tst_subsets.c b/src/tst_subsets.c
new file mode 100644
index 0000000..77268c1
--- /dev/null
+++ b/src/tst_subsets.c
@@ -0,0 +1,623 @@
+/* This is part of the libcf package. Copyright 2007 University
+ Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
+ conditions of use. See www.unidata.ucar.edu for more info.
+
+ Test libcf variable subsetting stuff.
+
+ Ed Hartnett, 10/1/06
+
+ $Id: tst_subsets.c,v 1.15 2007/06/07 17:07:14 ed Exp $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <netcdf.h>
+#include <nc_tests.h>
+
+#define NLONS_HEMI 180
+#define NLATS_HEMI 90
+#define NLONS_SIMPLE 1
+#define NLATS_SIMPLE 1
+#define NDIMS_2 2
+
+int
+main(int argc, char **argv)
+{
+ printf("\n*** Testing libcf geographic subsetting.\n");
+
+#define NLONS 2
+#define NLATS 3
+#define NLVLS 7
+#define NDIMS 4
+#define MAX_REC 3
+#define TIME_UNITS "seconds since 1992-10-8"
+#define TITLE "Libcf Automatic Testing Test File: tst_subset.nc."
+#define HISTORY "Created by tst_subsets.c, a libcf test program."
+#define FILE_NAME_SIMPLE_SIGMA "tst_subsets_simple_sigma.nc"
+
+ printf("*** testing index size stuff...");
+ {
+ int ncid;
+ int time_vid, lvl_vid, lat_vid, lon_vid;
+ int time_did, lvl_did, lat_did, lon_did;
+ int l, lat[NLATS], lon[NLONS], dimids[NDIMS];
+ int ps_vid, ptop_vid, data_vid, data_vid_in;
+ float lat_bounds[] = {40.0, 40.005}, lon_bounds[] = {80.0, 80.005};
+ float bad_lat_bounds[] = {10.0, 20.0}, bad_lon_bounds[] = {50.0, 60.005};
+ int nlat_in, nlon_in;
+ float data[NLVLS][NLATS][NLONS];
+ float data_in[NLVLS][NLATS][NLONS];
+ size_t start[NDIMS], count[NDIMS];
+ int i, j, k;
+
+ /* Create some latitudes. */
+ for (lat[0] = 40, l = 1; l < NLATS; l++)
+ lat[l] = lat[l-1] + 2;
+ for (lon[0] = 80, l = 1; l < NLONS; l++)
+ lon[l] = lon[l-1] + 2;
+
+ /* Create some phoney data. */
+ for (i = 0; i < NLVLS; i++)
+ for (j = 0; j < NLATS; j++)
+ for (k = 0; k < NLONS; k++)
+ data[i][j][k] = i + j + k;
+
+ /* CReate a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME_SIMPLE_SIGMA, 0, &ncid)) ERR;
+ if (nccf_def_file(ncid, TITLE, HISTORY)) ERR;
+ if (nccf_def_latitude(ncid, NLATS, NC_INT, &lat_did,
+ &lat_vid)) ERR;
+ if (nccf_def_longitude(ncid, NLONS, NC_INT, &lon_did,
+ &lon_vid)) ERR;
+
+ /* Now define sigma level coordinage var and dim. */
+ if (nccf_def_lvl_sigma(ncid, "sigma", NC_FLOAT, NLVLS,
+ &lvl_did, &lvl_vid)) ERR;
+
+ /* Now define the time coordinate. */
+ if (nccf_def_time(ncid, "time", NC_UNLIMITED, NC_FLOAT, TIME_UNITS,
+ "time", &time_did, &time_vid)) ERR;
+
+ /* Before we can set the sigma level formula terms, we
+ * need to define two variables, the surface pressure and PTOP
+ * (a scalar).*/
+ dimids[0] = lat_did;
+ dimids[1] = lon_did;
+ if (nc_def_var(ncid, "ps", NC_FLOAT, 2, dimids, &ps_vid)) ERR;
+ if (nc_def_var(ncid, "PTOP", NC_FLOAT, 0, NULL, &ptop_vid)) ERR;
+
+ /* Save the ps and ptop info in the formula terms attribute. */
+ if (nccf_def_ft_sigma(ncid, lvl_vid, ps_vid, ptop_vid)) ERR;
+
+ /* Now create a data variable. */
+ dimids[0] = time_did;
+ dimids[1] = lvl_did;
+ dimids[2] = lat_did;
+ dimids[3] = lon_did;
+ if (nc_def_var(ncid, "data", NC_FLOAT, NDIMS, dimids, &data_vid)) ERR;
+
+ /* End define mode. */
+ if (nc_enddef(ncid)) ERR;
+
+ /* Write lats and lons. */
+ if (nc_put_var_int(ncid, lat_vid, lat)) ERR;
+ if (nc_put_var_int(ncid, lon_vid, lon)) ERR;
+
+ /* Now write some data, one record at a time. */
+ start[1] = start[2] = start[3] = 0;
+ count[0] = 1;
+ count[1] = NLVLS;
+ count[2] = NLATS;
+ count[3] = NLONS;
+ for (start[0] = 0; start[0] < MAX_REC; start[0]++)
+ if (nc_put_vara(ncid, data_vid, start, count, &data)) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ /* Check the file. */
+ if (nc_open(FILE_NAME_SIMPLE_SIGMA, 0, &ncid)) ERR;
+ if (nc_inq_varid(ncid, "data", &data_vid_in)) ERR;
+ if (data_vid_in != data_vid) ERR;
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS || nlon_in != NLONS) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_bounds, &nlat_in, bad_lon_bounds, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, lat_bounds, &nlat_in, lon_bounds, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != 1) ERR;
+
+ if (nc_close(ncid)) ERR;
+ }
+ SUMMARIZE_ERR;
+
+ printf("*** testing simple subsetting case, with 2D data around CONUS...");
+#define NLONS_W 180
+#define NLATS_N 90
+#define NLONS_SIMPLE 1
+#define NLATS_SIMPLE 1
+#define NDIMS_2 2
+#define DATA_VAR_NAME_SIMPLE "Simon"
+#define NLONS_CONUS 56
+#define NLATS_CONUS 15
+#define FILE_NAME_NW "tst_subsets_nw.nc"
+ {
+ int ncid, lat_vid, lon_vid, lat_did, lon_did, data_vid;
+ int lat[NLATS_N], lon[NLONS_W], dimids[NDIMS_2];
+ float simple_lat_range[] = {30.0, 30.5}, simple_lon_range[] = {-1.0, -0.5};
+ float simple_lat_range2[] = {50.0, 50.5}, simple_lon_range2[] = {-179.0, -178.5};
+ float bad_lat_range[] = {-40.0, -30.5}, bad_lon_range[] = {1.0, 2.5};
+ float conus_lat_range[] = {30.0, 44.5}, conus_lon_range[] = {-130.0, -74.5};
+ int conus_lat_index[] = {30, 44}, conus_lon_index[] = {75, 130};
+ int nlat_in, nlon_in;
+ float data[NLATS_N][NLONS_W];
+ float data_in[NLATS_SIMPLE][NLONS_SIMPLE];
+ float data_conus[NLATS_CONUS][NLONS_CONUS];
+ int l, j, k;
+
+ /* Create some latitudes for the Western Hem. */
+ for (lat[0] = 0, l = 1; l < NLATS_N; l++)
+ lat[l] = lat[l-1] + 1;
+ for (lon[0] = 0, l = 1; l < NLONS_W; l++)
+ lon[l] = lon[l-1] - 1;
+
+ /* Create some phoney data. */
+ for (j = 0; j < NLATS_N; j++)
+ for (k = 0; k < NLONS_W; k++)
+ data[j][k] = (j + k) * 2.5;
+
+ /* Create a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME_NW, 0, &ncid)) ERR;
+ if (nccf_def_file(ncid, TITLE, HISTORY)) ERR;
+ if (nccf_def_latitude(ncid, NLATS_N, NC_INT, &lat_did,
+ &lat_vid)) ERR;
+ if (nccf_def_longitude(ncid, NLONS_W, NC_INT, &lon_did,
+ &lon_vid)) ERR;
+
+ /* Now create a data variable. */
+ dimids[0] = lat_did;
+ dimids[1] = lon_did;
+ if (nc_def_var(ncid, DATA_VAR_NAME_SIMPLE, NC_FLOAT, NDIMS_2, dimids,
+ &data_vid)) ERR;
+
+ /* End define mode. */
+ if (nc_enddef(ncid)) ERR;
+
+ /* Write lats and lons. */
+ if (nc_put_var_int(ncid, lat_vid, lat)) ERR;
+ if (nc_put_var_int(ncid, lon_vid, lon)) ERR;
+
+ /* Now write some 2D data. */
+ if (nc_put_var_float(ncid, data_vid, &data[0][0])) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ /* Check the file. */
+ if (nc_open(FILE_NAME_NW, 0, &ncid)) ERR;
+ if (nc_inq_varid(ncid, DATA_VAR_NAME_SIMPLE, &data_vid)) ERR;
+
+ /* All lons, one lat. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != NLONS_W) ERR;
+
+ /* All lats, one lon. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_N || nlon_in != 1) ERR;
+
+ /* These should all yeild no subset. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 180) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 1) ERR;
+
+ /* No ranges, so get the entire thing. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_N || nlon_in != NLONS_W) ERR;
+
+ /* Read a small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, simple_lon_range,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[(int)simple_lat_range[0]][abs((int)simple_lon_range[0])])
+ ERR;
+
+ /* Read a different small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range2, &nlat_in, simple_lon_range2,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[(int)simple_lat_range2[0]][abs((int)simple_lon_range2[0])])
+ ERR;
+
+ /* Read a big subset (approximate CONUS). */
+ if (nccf_get_vara(ncid, data_vid, conus_lat_range, &nlat_in, conus_lon_range,
+ &nlon_in, 0, 0, data_conus)) ERR;
+ if (nlat_in != NLATS_CONUS || nlon_in != NLONS_CONUS) ERR;
+ for (j = 0; j < conus_lat_index[1] - conus_lat_index[0]; j++)
+ for (k = 0; k < conus_lat_index[1] - conus_lat_index[0]; k++)
+ if (data_conus[j][k] !=
+ data[j + conus_lat_index[0]][k + conus_lon_index[0]]) ERR;
+
+ if (nc_close(ncid)) ERR;
+ }
+ SUMMARIZE_ERR;
+
+ printf("*** testing simple subsetting case, with 2D data around South America...");
+#define NLONS_W 180
+#define NLATS_S 90
+#define NLONS_SIMPLE 1
+#define NLATS_SIMPLE 1
+#define NDIMS_2 2
+#define NLONS_SA 50
+#define NLATS_SA 81
+#define FILE_NAME_SW "tst_subsets_sw.nc"
+ {
+ int ncid, lat_vid, lon_vid, lat_did, lon_did, data_vid;
+ int lat[NLATS_S], lon[NLONS_W], dimids[NDIMS_2];
+ float simple_lat_range[] = {-30.0, -29.5}, simple_lon_range[] = {-1.0, -0.5};
+ float simple_lat_range2[] = {-50.0, -49.5}, simple_lon_range2[] = {-179.0, -178.5};
+ float bad_lat_range[] = {20.0, 30.5}, bad_lon_range[] = {1.0, 2.5};
+ float sa_lat_range[] = {-80.0, 0}, sa_lon_range[] = {-80.0, -30.5};
+ int sa_lat_index[] = {0, 81}, sa_lon_index[] = {31, 81};
+ int nlat_in, nlon_in;
+ float data[NLATS_S][NLONS_W];
+ float data_in[NLATS_SIMPLE][NLONS_SIMPLE];
+ float data_sa[NLATS_SA][NLONS_SA];
+ int l, j, k;
+
+ /* Create some latitudes for the South Western quarter of the
+ * Earth. */
+ for (lat[0] = 0, l = 1; l < NLATS_S; l++)
+ lat[l] = lat[l-1] - 1;
+ for (lon[0] = 0, l = 1; l < NLONS_W; l++)
+ lon[l] = lon[l-1] - 1;
+
+ /* Create some phoney data. */
+ for (j = 0; j < NLATS_S; j++)
+ for (k = 0; k < NLONS_W; k++)
+ data[j][k] = (j + k) * -10.5;
+
+ /* Create a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME_SW, 0, &ncid)) ERR;
+ if (nccf_def_file(ncid, TITLE, HISTORY)) ERR;
+ if (nccf_def_latitude(ncid, NLATS_S, NC_INT, &lat_did,
+ &lat_vid)) ERR;
+ if (nccf_def_longitude(ncid, NLONS_W, NC_INT, &lon_did,
+ &lon_vid)) ERR;
+
+ /* Now create a data variable. */
+ dimids[0] = lat_did;
+ dimids[1] = lon_did;
+ if (nc_def_var(ncid, DATA_VAR_NAME_SIMPLE, NC_FLOAT, NDIMS_2, dimids,
+ &data_vid)) ERR;
+
+ /* End define mode. */
+ if (nc_enddef(ncid)) ERR;
+
+ /* Write lats and lons. */
+ if (nc_put_var_int(ncid, lat_vid, lat)) ERR;
+ if (nc_put_var_int(ncid, lon_vid, lon)) ERR;
+
+ /* Now write some 2D data. */
+ if (nc_put_var_float(ncid, data_vid, &data[0][0])) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ /* Check the file. */
+ if (nc_open(FILE_NAME_SW, 0, &ncid)) ERR;
+ if (nc_inq_varid(ncid, DATA_VAR_NAME_SIMPLE, &data_vid)) ERR;
+
+ /* All lons, one lat. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != NLONS_W) ERR;
+
+ /* All lats, one lon. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_S || nlon_in != 1) ERR;
+
+ /* These should all yeild no subset. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 180) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 1) ERR;
+
+ /* No ranges, so get the entire thing. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_S || nlon_in != NLONS_W) ERR;
+
+ /* Read a small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, simple_lon_range,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[abs((int)simple_lat_range[0])][abs((int)simple_lon_range[0])])
+ ERR;
+
+ /* Read a different small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range2, &nlat_in, simple_lon_range2,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[abs((int)simple_lat_range2[0])][abs((int)simple_lon_range2[0])])
+ ERR;
+
+ /* Read a big subset (approximate SA). */
+ if (nccf_get_vara(ncid, data_vid, sa_lat_range, &nlat_in, sa_lon_range,
+ &nlon_in, 0, 0, data_sa)) ERR;
+ if (nlat_in != NLATS_SA || nlon_in != NLONS_SA) ERR;
+ for (j = 0; j < NLATS_SA; j++)
+ for (k = 0; k < NLONS_SA; k++)
+ if (data_sa[j][k] !=
+ data[j + sa_lat_index[0]][k + sa_lon_index[0]]) ERR;
+
+ if (nc_close(ncid)) ERR;
+ }
+ SUMMARIZE_ERR;
+
+ printf("*** testing simple subsetting case, with 2D data around Australia...");
+#define NLONS_HEMI 180
+#define NLATS_HEMI 90
+#define NLONS_SIMPLE 1
+#define NLATS_SIMPLE 1
+#define NDIMS_2 2
+#define NLATS_AUS 36
+#define NLONS_AUS 46
+#define FILE_NAME_SE "tst_subsets_se.nc"
+ {
+ int ncid, lat_vid, lon_vid, lat_did, lon_did, data_vid;
+ int lat[NLATS_HEMI], lon[NLONS_HEMI], dimids[NDIMS_2];
+ float simple_lat_range[] = {-30.0, -29.5}, simple_lon_range[] = {1.0, 1.5};
+ float simple_lat_range2[] = {-50.0, -49.5}, simple_lon_range2[] = {178.0, 178.5};
+ float bad_lat_range[] = {20.0, 30.5}, bad_lon_range[] = {-10.0, -2.5};
+ float aus_lat_range[] = {-45.0, -10.0}, aus_lon_range[] = {110.0, 155.0};
+ int aus_lat_index[] = {10, 35}, aus_lon_index[] = {110, 45};
+ int nlat_in, nlon_in;
+ float data[NLATS_HEMI][NLONS_HEMI];
+ float data_in[NLATS_SIMPLE][NLONS_SIMPLE];
+ float data_aus[NLATS_AUS][NLONS_AUS];
+ int l, j, k;
+
+ /* Create some latitudes for the South Eastern quarter of the
+ * Earth. */
+ for (lat[0] = 0, l = 1; l < NLATS_HEMI; l++)
+ lat[l] = lat[l-1] - 1;
+ for (lon[0] = 0, l = 1; l < NLONS_HEMI; l++)
+ lon[l] = lon[l-1] + 1;
+
+ /* Create some phoney data. */
+ for (j = 0; j < NLATS_HEMI; j++)
+ for (k = 0; k < NLONS_HEMI; k++)
+ data[j][k] = (j + k) * -10.5;
+
+ /* Create a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME_SE, 0, &ncid)) ERR;
+ if (nccf_def_file(ncid, TITLE, HISTORY)) ERR;
+ if (nccf_def_latitude(ncid, NLATS_HEMI, NC_INT, &lat_did,
+ &lat_vid)) ERR;
+ if (nccf_def_longitude(ncid, NLONS_HEMI, NC_INT, &lon_did,
+ &lon_vid)) ERR;
+
+ /* Now create a data variable. */
+ dimids[0] = lat_did;
+ dimids[1] = lon_did;
+ if (nc_def_var(ncid, DATA_VAR_NAME_SIMPLE, NC_FLOAT, NDIMS_2, dimids,
+ &data_vid)) ERR;
+
+ /* End define mode. */
+ if (nc_enddef(ncid)) ERR;
+
+ /* Write lats and lons. */
+ if (nc_put_var_int(ncid, lat_vid, lat)) ERR;
+ if (nc_put_var_int(ncid, lon_vid, lon)) ERR;
+
+ /* Now write some 2D data. */
+ if (nc_put_var_float(ncid, data_vid, &data[0][0])) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ /* Check the file. */
+ if (nc_open(FILE_NAME_SE, 0, &ncid)) ERR;
+ if (nc_inq_varid(ncid, DATA_VAR_NAME_SIMPLE, &data_vid)) ERR;
+
+ /* All lons, one lat. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != NLONS_HEMI) ERR;
+
+ /* All lats, one lon. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_HEMI || nlon_in != 1) ERR;
+
+ /* These should all yeild no subset. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 180) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 1) ERR;
+
+ /* No ranges, so get the entire thing. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_HEMI || nlon_in != NLONS_HEMI) ERR;
+
+ /* Read a small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, simple_lon_range,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[abs((int)simple_lat_range[0])][abs((int)simple_lon_range[0])])
+ ERR;
+
+ /* Read a different small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range2, &nlat_in, simple_lon_range2,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[abs((int)simple_lat_range2[0])][abs((int)simple_lon_range2[0])])
+ ERR;
+
+ /* Read a big subset (approximatly Australia). */
+ if (nccf_get_vara(ncid, data_vid, aus_lat_range, &nlat_in, aus_lon_range,
+ &nlon_in, 0, 0, data_aus)) ERR;
+ if (nlat_in != NLATS_AUS || nlon_in != NLONS_AUS) ERR;
+ for (j = 0; j < NLATS_AUS; j++)
+ for (k = 0; k < NLONS_AUS; k++)
+ if (data_aus[j][k] !=
+ data[j + aus_lat_index[0]][k + aus_lon_index[0]])
+ {
+ ERR;
+ break;
+ }
+
+ if (nc_close(ncid)) ERR;
+ }
+ SUMMARIZE_ERR;
+ printf("*** testing simple subsetting case, with 2D data around Japan...");
+#define NLATS_JAPAN 16
+#define NLONS_JAPAN 21
+#define FILE_NAME_NE "tst_subsets_ne.nc"
+ {
+ int ncid, lat_vid, lon_vid, lat_did, lon_did, data_vid;
+ int lat[NLATS_HEMI], lon[NLONS_HEMI], dimids[NDIMS_2];
+ float simple_lat_range[] = {30.0, 30.5}, simple_lon_range[] = {1.0, 1.5};
+ float simple_lat_range2[] = {50.0, 50.5}, simple_lon_range2[] = {178.0, 178.5};
+ float bad_lat_range[] = {-20.0, -10.5}, bad_lon_range[] = {-10.0, -2.5};
+ float japan_lat_range[] = {30.0, 45.0}, japan_lon_range[] = {130.0, 150.0};
+ int japan_lat_index[] = {30, 45}, japan_lon_index[] = {130, 150};
+ int nlat_in, nlon_in;
+ float data[NLATS_HEMI][NLONS_HEMI];
+ float data_in[NLATS_SIMPLE][NLONS_SIMPLE];
+ float data_aus[NLATS_JAPAN][NLONS_JAPAN];
+ int l, j, k;
+
+ /* Create some latitudes for the South Eastern quarter of the
+ * Earth. */
+ for (lat[0] = 0, l = 1; l < NLATS_HEMI; l++)
+ lat[l] = lat[l-1] + 1;
+ for (lon[0] = 0, l = 1; l < NLONS_HEMI; l++)
+ lon[l] = lon[l-1] + 1;
+
+ /* Create some phoney data. */
+ for (j = 0; j < NLATS_HEMI; j++)
+ for (k = 0; k < NLONS_HEMI; k++)
+ data[j][k] = (j + k) * -10.5;
+
+ /* Create a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME_NE, 0, &ncid)) ERR;
+ if (nccf_def_file(ncid, TITLE, HISTORY)) ERR;
+ if (nccf_def_latitude(ncid, NLATS_HEMI, NC_INT, &lat_did,
+ &lat_vid)) ERR;
+ if (nccf_def_longitude(ncid, NLONS_HEMI, NC_INT, &lon_did,
+ &lon_vid)) ERR;
+
+ /* Now create a data variable. */
+ dimids[0] = lat_did;
+ dimids[1] = lon_did;
+ if (nc_def_var(ncid, DATA_VAR_NAME_SIMPLE, NC_FLOAT, NDIMS_2, dimids,
+ &data_vid)) ERR;
+
+ /* End define mode. */
+ if (nc_enddef(ncid)) ERR;
+
+ /* Write lats and lons. */
+ if (nc_put_var_int(ncid, lat_vid, lat)) ERR;
+ if (nc_put_var_int(ncid, lon_vid, lon)) ERR;
+
+ /* Now write some 2D data. */
+ if (nc_put_var_float(ncid, data_vid, &data[0][0])) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ /* Check the file. */
+ if (nc_open(FILE_NAME_NE, 0, &ncid)) ERR;
+ if (nc_inq_varid(ncid, DATA_VAR_NAME_SIMPLE, &data_vid)) ERR;
+
+ /* All lons, one lat. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != NLONS_HEMI) ERR;
+
+ /* All lats, one lon. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_HEMI || nlon_in != 1) ERR;
+
+ /* These should all yeild no subset. */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 1 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 180) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, bad_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 0) ERR;
+ if (nccf_get_vara(ncid, data_vid, bad_lat_range, &nlat_in, simple_lon_range, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != 0 || nlon_in != 1) ERR;
+
+ /* No ranges, so get the entire thing. */
+ if (nccf_get_vara(ncid, data_vid, NULL, &nlat_in, NULL, &nlon_in,
+ 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_HEMI || nlon_in != NLONS_HEMI) ERR;
+
+ /* Read a small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range, &nlat_in, simple_lon_range,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[abs((int)simple_lat_range[0])][abs((int)simple_lon_range[0])])
+ ERR;
+
+ /* Read a different small subset (1 value). */
+ if (nccf_get_vara(ncid, data_vid, simple_lat_range2, &nlat_in, simple_lon_range2,
+ &nlon_in, 0, 0, data_in)) ERR;
+ if (nlat_in != NLATS_SIMPLE || nlon_in != NLONS_SIMPLE) ERR;
+ if (data_in[0][0] != data[abs((int)simple_lat_range2[0])][abs((int)simple_lon_range2[0])])
+ ERR;
+
+ /* Read a big subset (approximatly Australia). */
+ if (nccf_get_vara(ncid, data_vid, japan_lat_range, &nlat_in, japan_lon_range,
+ &nlon_in, 0, 0, data_aus)) ERR;
+ if (nlat_in != NLATS_JAPAN || nlon_in != NLONS_JAPAN) ERR;
+ for (j = 0; j < NLATS_JAPAN; j++)
+ for (k = 0; k < NLONS_JAPAN; k++)
+ if (data_aus[j][k] !=
+ data[j + japan_lat_index[0]][k + japan_lon_index[0]])
+ {
+ ERR;
+ break;
+ }
+
+ if (nc_close(ncid)) ERR;
+ }
+ SUMMARIZE_ERR;
+ FINAL_RESULTS;
+}
+
+
diff --git a/src/tst_vars.c b/src/tst_vars.c
new file mode 100644
index 0000000..a59fe5d
--- /dev/null
+++ b/src/tst_vars.c
@@ -0,0 +1,120 @@
+/* This is part of the netCDF package. Copyright 2005 University
+ Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
+ conditions of use. See www.unidata.ucar.edu for more info.
+
+ Test libcf variable stuff.
+
+ $Id: tst_vars.c,v 1.3 2006/09/10 17:19:33 ed Exp $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <netcdf.h>
+#include <nc_tests.h>
+
+#define FILE_NAME "tst_vars.nc"
+
+int
+main(int argc, char **argv)
+{
+ printf("\n*** Testing libcf variable stuff.\n");
+
+#define INSTITUTION "Unidata Programmaing Drone Sector 7G"
+#define SOURCE "We buy our data at DataMart."
+#define COMMENT "Happy trails to you!"
+#define REFERENCES "Why bother?"
+#define MAX_LEN 100
+#define NDIMS 1
+#define VAR_NAME "Programmer_Productivity"
+#define DIM_NAME "Lines_of_code_per_cube_per_second"
+
+ printf("*** testing variable notes...");
+ {
+ int ncid, varid, dimids[NDIMS];
+ size_t ilen, slen, clen, rlen;
+ char inst_in[MAX_LEN], source_in[MAX_LEN];
+ char comment_in[MAX_LEN], ref_in[MAX_LEN];
+
+ /* CReate a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME, 0, &ncid)) ERR;
+ if (nc_def_dim(ncid, DIM_NAME, NC_UNLIMITED, dimids)) ERR;
+ if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS, dimids, &varid)) ERR;
+ if (nccf_def_notes(ncid, varid, INSTITUTION, SOURCE,
+ COMMENT, REFERENCES)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_notes(ncid, varid, &ilen, inst_in, &slen, source_in,
+ &clen, comment_in, &rlen, ref_in)) ERR;
+ if (ilen != strlen(INSTITUTION) + 1 || slen != strlen(SOURCE) + 1 ||
+ clen != strlen(COMMENT) + 1 || rlen != strlen(REFERENCES) + 1) ERR;
+ if (strncmp(inst_in, INSTITUTION, ilen) ||
+ strncmp(source_in, SOURCE, slen) ||
+ strncmp(comment_in, COMMENT, clen) ||
+ strncmp(ref_in, REFERENCES, rlen)) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_notes(ncid, varid, &ilen, inst_in, &slen, source_in,
+ &clen, comment_in, &rlen, ref_in)) ERR;
+ if (ilen != strlen(INSTITUTION) + 1 || slen != strlen(SOURCE) + 1 ||
+ clen != strlen(COMMENT) + 1 || rlen != strlen(REFERENCES) + 1) ERR;
+ if (strncmp(inst_in, INSTITUTION, ilen) ||
+ strncmp(source_in, SOURCE, slen) ||
+ strncmp(comment_in, COMMENT, clen) ||
+ strncmp(ref_in, REFERENCES, rlen)) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ }
+ SUMMARIZE_ERR;
+
+#define VALID_MIN -10.0
+#define VALID_MAX 10.0
+#define FILL_VALUE 99.9
+#define VAR2_NAME "manager_salary"
+
+ printf("*** testing missing values...");
+ {
+ int ncid, varid, varid2, dimids[NDIMS];
+ int valid_min = VALID_MIN, valid_max = VALID_MAX;
+ int fill_value = FILL_VALUE;
+ int fill_value_in, valid_min_in, valid_max_in;
+
+ /* CReate a file and use nccd_def_file to annotate it. */
+ if (nc_create(FILE_NAME, 0, &ncid)) ERR;
+ if (nc_def_dim(ncid, DIM_NAME, NC_UNLIMITED, dimids)) ERR;
+ if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIMS, dimids, &varid)) ERR;
+ if (nc_def_var(ncid, VAR2_NAME, NC_INT, NDIMS, dimids, &varid2)) ERR;
+ if (nccf_def_var_missing(ncid, varid, &fill_value, &valid_min,
+ &valid_max)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_var_missing(ncid, varid, &fill_value_in,
+ &valid_min_in, &valid_max_in)) ERR;
+ if (fill_value_in != fill_value || valid_min_in != valid_min ||
+ valid_max_in != valid_max) ERR;
+ if (nccf_inq_var_missing(ncid, varid2, &fill_value_in,
+ &valid_min_in, &valid_max_in)) ERR;
+ if (fill_value_in != NC_FILL_INT || valid_min_in != CF_INT_MIN ||
+ valid_max_in != CF_INT_MAX) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ if (nc_open(FILE_NAME, 0, &ncid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_var_missing(ncid, varid, &fill_value_in,
+ &valid_min_in, &valid_max_in)) ERR;
+ if (fill_value_in != fill_value || valid_min_in != valid_min ||
+ valid_max_in != valid_max) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ }
+ SUMMARIZE_ERR;
+ FINAL_RESULTS;
+}
+
diff --git a/src/tst_vert.c b/src/tst_vert.c
new file mode 100644
index 0000000..1fcb16a
--- /dev/null
+++ b/src/tst_vert.c
@@ -0,0 +1,283 @@
+/* This is part of the libcf package. Copyright 2006 University
+ Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
+ conditions of use. See www.unidata.ucar.edu for more info.
+
+ Test libcf vertical coordinate variable stuff.
+
+ Ed Hartnett, 11/18/06
+
+ $Id: tst_vert.c,v 1.2 2006/11/22 11:24:32 ed Exp $
+*/
+
+#include <config.h>
+#include <libcf.h>
+#include <netcdf.h>
+#include <nc_tests.h>
+
+#define NLAT 3
+#define NLON 2
+#define NLVL 5
+#define NTIME 2
+#define NDIM 4
+#define TIME_UNITS "seconds since 1992-10-8"
+#define TITLE "This test file is part of libcf automatic testing."
+#define HISTORY "Created by tst_vert.c, a libcf test program."
+
+int
+main(int argc, char **argv)
+{
+ char file_name[NC_MAX_NAME + 1];
+
+ printf("\n*** Testing libcf vertical coordinate variables.\n");
+ strcpy(file_name, "tst_vert_sigma.nc");
+ printf("*** creating file %s...", file_name);
+ {
+ int ncid, ps_vid, ptop_vid;
+ int dimids[NDIM];
+ int lat_vid, lon_vid, lvl_vid, time_vid;
+ int lat_did, lon_did, lvl_did, time_did;
+ int lvl_type_in;
+ size_t len_in;
+ nc_type xtype_in;
+ int dimid_in, varid_in, ps_varid_in, ptop_varid_in;
+ char name_in[NC_MAX_NAME + 1];
+ char title_in[NC_MAX_NAME + 1], history_in[NC_MAX_NAME + 1];
+ size_t title_len, history_len;
+
+ /* Create a file and define four coordinate varibles, lat, lon,
+ * sigma level, and time. */
+ if (nc_create(file_name, 0, &ncid)) ERR;
+ if (nccf_def_file(ncid, TITLE, HISTORY)) ERR;
+ if (nccf_def_latitude(ncid, NLAT, NC_FLOAT, &lat_did, &lat_vid)) ERR;
+ if (nccf_def_longitude(ncid, NLON, NC_FLOAT, &lon_did, &lon_vid)) ERR;
+
+ /* Now define sigma level coordinage var and dim. */
+ if (nccf_def_lvl_vert(ncid, CF_VERT_SIGMA, "sigma", NC_FLOAT, NLVL,
+ &lvl_did, &lvl_vid)) ERR;
+
+ /* Now define the time coordinate. */
+ if (nccf_def_time(ncid, "time", NC_UNLIMITED, NC_FLOAT, TIME_UNITS,
+ "time", &time_did, &time_vid)) ERR;
+
+ /* Before we can set the sigma level formula terms, we
+ * need to define two variables, the surface pressure and PTOP
+ * (a scalar).*/
+ dimids[0] = lat_did;
+ dimids[1] = lon_did;
+ if (nc_def_var(ncid, "ps", NC_FLOAT, 2, dimids, &ps_vid)) ERR;
+ if (nc_def_var(ncid, "PTOP", NC_FLOAT, 0, NULL, &ptop_vid)) ERR;
+
+ /* Save the ps and ptop info in the formula terms attribute. */
+ if (nccf_def_ft_sigma(ncid, lvl_vid, ps_vid, ptop_vid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_file(ncid, &title_len, title_in, &history_len,
+ history_in)) ERR;
+ if (title_len != strlen(TITLE) + 1 ||
+ strncmp(title_in, TITLE, strlen(TITLE))) ERR;
+ if (nccf_inq_lvl_vert(ncid, name_in, &xtype_in, &len_in,
+ &lvl_type_in, &dimid_in, &varid_in)) ERR;
+ if (!strcmp(name_in, "sigma") || xtype_in != NC_FLOAT ||
+ len_in != NLVL || lvl_type_in != CF_VERT_SIGMA ||
+ dimid_in != lvl_did || varid_in != lvl_vid) ERR;
+ if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in,
+ &varid_in)) ERR;
+ if (len_in != NLAT || xtype_in != NC_FLOAT ||
+ dimid_in != lat_did || varid_in != lat_vid) ERR;
+ if (nccf_inq_longitude(ncid, &len_in, &xtype_in, &dimid_in,
+ &varid_in)) ERR;
+ if (len_in != NLON || xtype_in != NC_FLOAT ||
+ dimid_in != lon_did || varid_in != lon_vid) ERR;
+ if (nccf_inq_lvl_sigma(ncid, name_in, &xtype_in, &len_in, &ps_varid_in,
+ &ptop_varid_in, &dimid_in, &varid_in)) ERR;
+ if (len_in != NLVL || xtype_in != NC_FLOAT || dimid_in != lvl_did ||
+ varid_in != lvl_vid || ps_varid_in != ps_vid ||
+ ptop_varid_in != ptop_vid) ERR;
+ if (nccf_inq_time(ncid, name_in, &len_in, &xtype_in,
+ &dimid_in, &varid_in)) ERR;
+ if (len_in != NC_UNLIMITED || xtype_in != NC_FLOAT || dimid_in != time_did ||
+ varid_in != time_vid) ERR;
+
+ if (nc_close(ncid)) ERR;
+
+ if (nc_open(file_name, 0, &ncid)) ERR;
+
+ /* Check the file. */
+ if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in,
+ &varid_in)) ERR;
+ if (len_in != NLAT || xtype_in != NC_FLOAT ||
+ dimid_in != lat_did || varid_in != lat_vid) ERR;
+ if (nccf_inq_longitude(ncid, &len_in, &xtype_in, &dimid_in,
+ &varid_in)) ERR;
+ if (len_in != NLON || xtype_in != NC_FLOAT ||
+ dimid_in != lon_did || varid_in != lon_vid) ERR;
+ if (nccf_inq_lvl_sigma(ncid, name_in, &xtype_in, &len_in, &ps_varid_in,
+ &ptop_varid_in, &dimid_in, &varid_in)) ERR;
+ if (len_in != NLVL || xtype_in != NC_FLOAT || dimid_in != lvl_did ||
+ varid_in != lvl_vid || ps_varid_in != ps_vid ||
+ ptop_varid_in != ptop_vid) ERR;
+ if (nccf_inq_time(ncid, name_in, &len_in, &xtype_in,
+ &dimid_in, &varid_in)) ERR;
+ if (len_in != NC_UNLIMITED || xtype_in != NC_FLOAT || dimid_in != time_did ||
+ varid_in != time_vid) ERR;
+
+ if (nc_close(ncid)) ERR;
+ }
+ SUMMARIZE_ERR;
+/* strcpy(file_name, "tst_vert_hybrid_sigma.nc"); */
+/* printf("*** creating file %s...", file_name); */
+/* { */
+/* int ncid, ps_vid, p0_vid, a_vid, b_vid; */
+/* int dimids[NDIM]; */
+/* int lat_vid, lon_vid, lvl_vid, time_vid; */
+/* int lat_did, lon_did, lvl_did, time_did; */
+/* size_t len_in; */
+/* nc_type xtype_in; */
+/* int dimid_in, varid_in, ps_varid_in, p0_varid_in; */
+/* int a_varid_in, b_varid_in; */
+/* char name_in[NC_MAX_NAME + 1]; */
+
+/* /\* Create a file and define four coordinate varibles, lat, lon, */
+/* * hybrid_sigma level, and time. *\/ */
+/* if (nc_create(file_name, 0, &ncid)) ERR; */
+
+/* if (nccf_def_latitude(ncid, NLAT, NC_FLOAT, &lat_did, &lat_vid)) ERR; */
+/* if (nccf_def_longitude(ncid, NLON, NC_FLOAT, &lon_did, &lon_vid)) ERR; */
+
+/* /\* Now define hybrid_sigma level coordinage var and dim. *\/ */
+/* if (nccf_def_lvl_hybrid_sigma(ncid, "hybrid_sigma", NC_FLOAT, NLVL, */
+/* &lvl_did, &lvl_vid)) ERR; */
+
+/* /\* Now define the time coordinate. *\/ */
+/* if (nccf_def_time(ncid, "time", NC_UNLIMITED, NC_FLOAT, TIME_UNITS, */
+/* "time", &time_did, &time_vid)) ERR; */
+
+/* /\* Before we can set up the formula_terms attribute, we need to */
+/* * define some additional variables specific to this type of */
+/* * vertical dimension. *\/ */
+/* dimids[0] = lat_did; */
+/* if (nc_def_var(ncid, "a", NC_FLOAT, 1, dimids, &a_vid)) ERR; */
+/* if (nc_def_var(ncid, "b", NC_FLOAT, 1, dimids, &b_vid)) ERR; */
+/* dimids[0] = lat_did; */
+/* dimids[1] = lon_did; */
+/* if (nc_def_var(ncid, "ps", NC_FLOAT, 2, dimids, &ps_vid)) ERR; */
+/* if (nc_def_var(ncid, "P0", NC_FLOAT, 0, NULL, &p0_vid)) ERR; */
+
+/* if (nccf_def_ft_hybrid_sigma(ncid, lvl_vid, a_vid, b_vid, ps_vid, */
+/* p0_vid)) ERR; */
+
+/* /\* Check the file. *\/ */
+/* if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLAT || xtype_in != NC_FLOAT || */
+/* dimid_in != lat_did || varid_in != lat_vid) ERR; */
+/* if (nccf_inq_longitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLON || xtype_in != NC_FLOAT || */
+/* dimid_in != lon_did || varid_in != lon_vid) ERR; */
+/* if (nccf_inq_lvl_hybrid_sigma(ncid, name_in, &xtype_in, &len_in, &a_varid_in, &b_varid_in, &ps_varid_in, */
+/* &p0_varid_in, &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NLVL || xtype_in != NC_FLOAT || dimid_in != lvl_did || */
+/* varid_in != lvl_vid || ps_varid_in != ps_vid || p0_varid_in != p0_vid || */
+/* a_varid_in != a_vid || b_varid_in != b_vid) ERR; */
+/* if (nccf_inq_time(ncid, name_in, &len_in, &xtype_in, */
+/* &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NC_UNLIMITED || xtype_in != NC_FLOAT || dimid_in != time_did || */
+/* varid_in != time_vid) ERR; */
+
+/* /\* Close and re-open. *\/ */
+/* if (nc_close(ncid)) ERR; */
+/* if (nc_open(file_name, 0, &ncid)) ERR; */
+
+/* /\* Check the file. *\/ */
+/* if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLAT || xtype_in != NC_FLOAT || */
+/* dimid_in != lat_did || varid_in != lat_vid) ERR; */
+/* if (nccf_inq_longitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLON || xtype_in != NC_FLOAT || */
+/* dimid_in != lon_did || varid_in != lon_vid) ERR; */
+/* if (nccf_inq_lvl_hybrid_sigma(ncid, name_in, &xtype_in, &len_in, &a_varid_in, &b_varid_in, &ps_varid_in, */
+/* &p0_varid_in, &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NLVL || xtype_in != NC_FLOAT || dimid_in != lvl_did || */
+/* varid_in != lvl_vid || ps_varid_in != ps_vid || p0_varid_in != p0_vid || */
+/* a_varid_in != a_vid || b_varid_in != b_vid) ERR; */
+/* if (nccf_inq_time(ncid, name_in, &len_in, &xtype_in, */
+/* &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NC_UNLIMITED || xtype_in != NC_FLOAT || dimid_in != time_did || */
+/* varid_in != time_vid) ERR; */
+
+/* if (nc_close(ncid)) ERR; */
+
+/* } */
+/* SUMMARIZE_ERR; */
+/* printf("testing quick creation of hybrid_sigma coordinate system..."); */
+/* { */
+/* int ncid, ps_vid, p0_vid, a_vid, b_vid; */
+/* int dimids[NDIM]; */
+/* int lat_vid, lon_vid, lvl_vid, time_vid; */
+/* int lat_did, lon_did, lvl_did, time_did; */
+/* size_t len_in; */
+/* nc_type xtype_in; */
+/* int dimid_in, varid_in, ps_varid_in, p0_varid_in; */
+/* int a_varid_in, b_varid_in; */
+/* char name_in[NC_MAX_NAME + 1]; */
+/* char file_name[] = {"tst_cvars_hybrid_sigma.nc"}; */
+
+/* /\* Create a file and define four coordinate varibles, lat, lon, */
+/* * hybrid_sigma level, and time. *\/ */
+/* if (nc_create(file_name, 0, &ncid)) ERR; */
+
+/* /\* It'd be nice to do this instead... *\/ */
+/* if (nccf_def_hybrid_sigma(names, lens, types, term_names, term_types, */
+/* term_varids, dimids, varids)) ERR; */
+
+/* /\* Check the file. *\/ */
+/* if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLAT || xtype_in != NC_FLOAT || */
+/* dimid_in != 0 || varid_in != 0) ERR; */
+/* if (nccf_inq_longitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLON || xtype_in != NC_FLOAT || */
+/* dimid_in != 1 || varid_in != 1) ERR; */
+/* if (nccf_inq_lvl_hybrid_sigma(ncid, name_in, &xtype_in, &len_in, &ps_varid_in, */
+/* &p0_varid_in, &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NLVL || xtype_in != NC_FLOAT || dimid_in != 2 || */
+/* varid_in != 4 || ps_varid_in != 2 || p0_varid_in != 3) ERR; */
+/* if (nccf_inq_time(ncid, name_in, &len_in, &xtype_in, */
+/* &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NC_UNLIMITED || xtype_in != NC_FLOAT || dimid_in != 3 || */
+/* varid_in != 5) ERR; */
+
+/* /\* Close and re-open. *\/ */
+/* if (nc_close(ncid)) ERR; */
+/* if (nc_open(file_name, 0, &ncid)) ERR; */
+
+/* /\* Check the file. *\/ */
+/* if (nccf_inq_latitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLAT || xtype_in != NC_FLOAT || */
+/* dimid_in != 0 || varid_in != 0) ERR; */
+/* if (nccf_inq_longitude(ncid, &len_in, &xtype_in, &dimid_in, */
+/* &varid_in)) ERR; */
+/* if (len_in != NLON || xtype_in != NC_FLOAT || */
+/* dimid_in != 1 || varid_in != 1) ERR; */
+/* if (nccf_inq_lvl_hybrid_sigma(ncid, name_in, &xtype_in, &len_in, &ps_varid_in, */
+/* &p0_varid_in, &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NLVL || xtype_in != NC_FLOAT || dimid_in != 2 || */
+/* varid_in != 4 || ps_varid_in != 2 || p0_varid_in != 3) ERR; */
+/* if (nccf_inq_time(ncid, name_in, &len_in, &xtype_in, */
+/* &dimid_in, &varid_in)) ERR; */
+/* if (len_in != NC_UNLIMITED || xtype_in != NC_FLOAT || dimid_in != 3 || */
+/* varid_in != 5) ERR; */
+
+/* if (nc_close(ncid)) ERR; */
+
+/* } */
+/* SUMMARIZE_ERR; */
+ FINAL_RESULTS;
+}
+
+
--
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